minor restructering of plugins, create the cloud plugin
This commit is contained in:
parent
e81d559f5f
commit
1323fe8b5e
|
@ -8,12 +8,15 @@
|
|||
<w>banon</w>
|
||||
<w>bindhost</w>
|
||||
<w>birthdate</w>
|
||||
<w>blobstore</w>
|
||||
<w>bool</w>
|
||||
<w>booleans</w>
|
||||
<w>camelcase</w>
|
||||
<w>canonicalhost</w>
|
||||
<w>checksum</w>
|
||||
<w>closeable</w>
|
||||
<w>cloudfiles</w>
|
||||
<w>cloudservers</w>
|
||||
<w>commitable</w>
|
||||
<w>committable</w>
|
||||
<w>configurator</w>
|
||||
|
@ -59,6 +62,7 @@
|
|||
<w>porterstem</w>
|
||||
<w>publishhost</w>
|
||||
<w>queryparser</w>
|
||||
<w>rackspace</w>
|
||||
<w>rebalance</w>
|
||||
<w>sbuf</w>
|
||||
<w>searchable</w>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<module fileurl="file://$PROJECT_DIR$/.idea/modules//plugin-discovery-jgroups.iml" filepath="$PROJECT_DIR$/.idea/modules//plugin-discovery-jgroups.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules//plugin-mapper-attachments.iml" filepath="$PROJECT_DIR$/.idea/modules//plugin-mapper-attachments.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules//plugin-transport-memcached.iml" filepath="$PROJECT_DIR$/.idea/modules//plugin-transport-memcached.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules//plugins-cloud.iml" filepath="$PROJECT_DIR$/.idea/modules//plugins-cloud.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules//test-integration.iml" filepath="$PROJECT_DIR$/.idea/modules//test-integration.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules//test-testng.iml" filepath="$PROJECT_DIR$/.idea/modules//test-testng.iml" />
|
||||
</modules>
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
<orderEntry type="module" module-name="plugin-mapper-attachments" />
|
||||
<orderEntry type="module" module-name="plugin-transport-memcached" />
|
||||
<orderEntry type="module" module-name="plugin-analysis-icu" />
|
||||
<orderEntry type="module" module-name="plugins-cloud" />
|
||||
<orderEntry type="module" module-name="test-integration" />
|
||||
</component>
|
||||
</module>
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="false">
|
||||
<output url="file://$MODULE_DIR$/../../plugins/cloud/build/classes/main" />
|
||||
<output-test url="file://$MODULE_DIR$/../../plugins/cloud/build/classes/test" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$/../../plugins/cloud">
|
||||
<sourceFolder url="file://$MODULE_DIR$/../../plugins/cloud/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/../../plugins/cloud/src/test/java" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/../../plugins/cloud/build" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="elasticsearch" />
|
||||
<orderEntry type="module-library">
|
||||
<library name="jclouds">
|
||||
<CLASSES>
|
||||
<root url="jar://$GRADLE_REPOSITORY$/com.google.code.gson/gson/jars/gson-1.4.jar!/" />
|
||||
<root url="jar://$GRADLE_REPOSITORY$/com.google.code.guice/guice/jars/guice-2.1-r1128.jar!/" />
|
||||
<root url="jar://$GRADLE_REPOSITORY$/com.jamesmurty.utils/java-xmlbuilder/jars/java-xmlbuilder-0.3.jar!/" />
|
||||
<root url="jar://$GRADLE_REPOSITORY$/org.jclouds/jclouds-compute/jars/jclouds-compute-1.0-beta-4.jar!/" />
|
||||
<root url="jar://$GRADLE_REPOSITORY$/org.jclouds/jclouds-aws/jars/jclouds-aws-1.0-beta-4.jar!/" />
|
||||
<root url="jar://$GRADLE_REPOSITORY$/org.jclouds/jclouds-scriptbuilder/jars/jclouds-scriptbuilder-1.0-beta-4.jar!/" />
|
||||
<root url="jar://$GRADLE_REPOSITORY$/org.jclouds/jclouds-blobstore/jars/jclouds-blobstore-1.0-beta-4.jar!/" />
|
||||
<root url="jar://$GRADLE_REPOSITORY$/org.jclouds/jclouds-core/jars/jclouds-core-1.0-beta-4.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="http://jclouds.rimuhosting.com/apidocs/" />
|
||||
</JAVADOC>
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
</component>
|
||||
</module>
|
||||
|
|
@ -19,10 +19,10 @@
|
|||
|
||||
package org.elasticsearch.discovery;
|
||||
|
||||
import org.elasticsearch.util.guice.inject.AbstractModule;
|
||||
import org.elasticsearch.util.guice.inject.Module;
|
||||
import org.elasticsearch.discovery.local.LocalDiscoveryModule;
|
||||
import org.elasticsearch.discovery.zen.ZenDiscoveryModule;
|
||||
import org.elasticsearch.util.guice.inject.AbstractModule;
|
||||
import org.elasticsearch.util.guice.inject.Module;
|
||||
import org.elasticsearch.util.settings.Settings;
|
||||
|
||||
import static org.elasticsearch.util.guice.ModulesFactory.*;
|
||||
|
@ -34,8 +34,15 @@ public class DiscoveryModule extends AbstractModule {
|
|||
|
||||
private final Settings settings;
|
||||
|
||||
private Class<? extends Module> defaultDiscoModule;
|
||||
|
||||
public DiscoveryModule(Settings settings) {
|
||||
this.settings = settings;
|
||||
this.defaultDiscoModule = ZenDiscoveryModule.class;
|
||||
}
|
||||
|
||||
public void replaceDefaultDiscoModule(Class<? extends Module> defaultDiscoModule) {
|
||||
this.defaultDiscoModule = defaultDiscoModule;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -44,7 +51,7 @@ public class DiscoveryModule extends AbstractModule {
|
|||
if (settings.getAsBoolean("node.local", false)) {
|
||||
defaultDiscoveryModule = LocalDiscoveryModule.class;
|
||||
} else {
|
||||
defaultDiscoveryModule = ZenDiscoveryModule.class;
|
||||
defaultDiscoveryModule = defaultDiscoModule;
|
||||
}
|
||||
|
||||
Class<? extends Module> moduleClass = settings.getAsClass("discovery.type", defaultDiscoveryModule, "org.elasticsearch.discovery.", "DiscoveryModule");
|
||||
|
|
|
@ -0,0 +1,141 @@
|
|||
dependsOn(':elasticsearch')
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'maven'
|
||||
|
||||
archivesBaseName = "elasticsearch-cloud"
|
||||
|
||||
explodedDistDir = new File(distsDir, 'exploded')
|
||||
|
||||
manifest.mainAttributes("Implementation-Title": "ElasticSearch::Plugins::Cloud", "Implementation-Version": rootProject.version, "Implementation-Date": buildTimeStr)
|
||||
|
||||
configurations.compile.transitive = true
|
||||
configurations.testCompile.transitive = true
|
||||
|
||||
// no need to use the resource dir
|
||||
sourceSets.main.resources.srcDirs 'src/main/java'
|
||||
sourceSets.test.resources.srcDirs 'src/test/java'
|
||||
|
||||
// add the source files to the dist jar
|
||||
//jar {
|
||||
// from sourceSets.main.allJava
|
||||
//}
|
||||
|
||||
configurations {
|
||||
dists
|
||||
distLib {
|
||||
visible = false
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenRepo urls: "http://jclouds.googlecode.com/svn/repo"
|
||||
mavenRepo urls: "http://java-xmlbuilder.googlecode.com/svn/repo"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile project(':elasticsearch')
|
||||
compile('org.jclouds:jclouds-aws:1.0-beta-4')
|
||||
distLib('org.jclouds:jclouds-aws:1.0-beta-4')
|
||||
|
||||
testCompile project(':test-testng')
|
||||
testCompile('org.testng:testng:5.10:jdk15') { transitive = false }
|
||||
}
|
||||
|
||||
test {
|
||||
useTestNG()
|
||||
jmvArgs = ["-ea", "-Xmx1024m"]
|
||||
suiteName = project.name
|
||||
listeners = ["org.elasticsearch.util.testng.Listeners"]
|
||||
systemProperties["es.test.log.conf"] = System.getProperty("es.test.log.conf", "log4j-gradle.properties")
|
||||
}
|
||||
|
||||
task explodedDist(dependsOn: [jar], description: 'Builds the plugin zip file') << {
|
||||
[explodedDistDir]*.mkdirs()
|
||||
|
||||
copy {
|
||||
from configurations.distLib
|
||||
into explodedDistDir
|
||||
}
|
||||
|
||||
// remove elasticsearch files (compile above adds the elasticsearch one)
|
||||
ant.delete { fileset(dir: explodedDistDir, includes: "elasticsearch-*.jar") }
|
||||
|
||||
copy {
|
||||
from libsDir
|
||||
into explodedDistDir
|
||||
}
|
||||
|
||||
ant.delete { fileset(dir: explodedDistDir, includes: "elasticsearch-*-javadoc.jar") }
|
||||
ant.delete { fileset(dir: explodedDistDir, includes: "elasticsearch-*-sources.jar") }
|
||||
}
|
||||
|
||||
task zip(type: Zip, dependsOn: ['explodedDist']) {
|
||||
from(explodedDistDir) {
|
||||
}
|
||||
}
|
||||
|
||||
task release(dependsOn: [zip]) << {
|
||||
ant.delete(dir: explodedDistDir)
|
||||
copy {
|
||||
from distsDir
|
||||
into(new File(rootProject.distsDir, "plugins"))
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
deployerJars
|
||||
}
|
||||
|
||||
dependencies {
|
||||
deployerJars "org.apache.maven.wagon:wagon-http:1.0-beta-2"
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar, dependsOn: classes) {
|
||||
classifier = 'sources'
|
||||
from sourceSets.main.allSource
|
||||
}
|
||||
|
||||
task javadocJar(type: Jar, dependsOn: javadoc) {
|
||||
classifier = 'javadoc'
|
||||
from javadoc.destinationDir
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives sourcesJar
|
||||
archives javadocJar
|
||||
}
|
||||
|
||||
uploadArchives {
|
||||
repositories.mavenDeployer {
|
||||
configuration = configurations.deployerJars
|
||||
repository(url: rootProject.mavenRepoUrl) {
|
||||
authentication(userName: rootProject.mavenRepoUser, password: rootProject.mavenRepoPass)
|
||||
}
|
||||
snapshotRepository(url: rootProject.mavenSnapshotRepoUrl) {
|
||||
authentication(userName: rootProject.mavenRepoUser, password: rootProject.mavenRepoPass)
|
||||
}
|
||||
|
||||
pom.project {
|
||||
inceptionYear '2009'
|
||||
name 'elasticsearch-plugins-cloud'
|
||||
description 'Clouud Plugin for ElasticSearch'
|
||||
licenses {
|
||||
license {
|
||||
name 'The Apache Software License, Version 2.0'
|
||||
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
|
||||
distribution 'repo'
|
||||
}
|
||||
}
|
||||
scm {
|
||||
connection 'git://github.com/elasticsearch/elasticsearch.git'
|
||||
developerConnection 'git@github.com:elasticsearch/elasticsearch.git'
|
||||
url 'http://github.com/elasticsearch/elasticsearch'
|
||||
}
|
||||
}
|
||||
|
||||
pom.whenConfigured {pom ->
|
||||
pom.dependencies = pom.dependencies.findAll {dep -> dep.scope != 'test' } // removes the test scoped ones
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
plugin=org.elasticsearch.plugin.cloud.CloudPlugin
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.cloud;
|
||||
|
||||
import org.elasticsearch.cloud.blobstore.CloudBlobstoreService;
|
||||
import org.elasticsearch.cloud.compute.CloudComputeService;
|
||||
import org.elasticsearch.util.guice.inject.AbstractModule;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class CloudModule extends AbstractModule {
|
||||
|
||||
@Override protected void configure() {
|
||||
bind(CloudComputeService.class).asEagerSingleton();
|
||||
bind(CloudBlobstoreService.class).asEagerSingleton();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.cloud.blobstore;
|
||||
|
||||
import org.elasticsearch.ElasticSearchException;
|
||||
import org.elasticsearch.util.component.AbstractLifecycleComponent;
|
||||
import org.elasticsearch.util.guice.inject.Inject;
|
||||
import org.elasticsearch.util.settings.Settings;
|
||||
import org.jclouds.blobstore.BlobStoreContext;
|
||||
import org.jclouds.blobstore.BlobStoreContextFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class CloudBlobstoreService extends AbstractLifecycleComponent<CloudBlobstoreService> {
|
||||
|
||||
private final String type;
|
||||
|
||||
private final BlobStoreContext blobStoreContext;
|
||||
|
||||
@Inject public CloudBlobstoreService(Settings settings) throws IOException {
|
||||
super(settings);
|
||||
|
||||
String type = componentSettings.get("type");
|
||||
if (type == null) {
|
||||
// see if we can get a global type
|
||||
type = settings.get("cloud.type");
|
||||
}
|
||||
// consolidate names
|
||||
if ("aws".equalsIgnoreCase(type) || "amazon".equalsIgnoreCase(type)) {
|
||||
type = "s3";
|
||||
} else if ("rackspace".equalsIgnoreCase(type)) {
|
||||
type = "cloudfiles";
|
||||
}
|
||||
this.type = type;
|
||||
|
||||
String account = componentSettings.get("account", settings.get("cloud.account"));
|
||||
String key = componentSettings.get("key", settings.get("cloud.key"));
|
||||
|
||||
if (type != null) {
|
||||
blobStoreContext = new BlobStoreContextFactory().createContext(type, account, key);
|
||||
logger.info("Connected to [{}] blob store service");
|
||||
} else {
|
||||
blobStoreContext = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override protected void doStart() throws ElasticSearchException {
|
||||
}
|
||||
|
||||
@Override protected void doStop() throws ElasticSearchException {
|
||||
}
|
||||
|
||||
@Override protected void doClose() throws ElasticSearchException {
|
||||
if (blobStoreContext != null) {
|
||||
blobStoreContext.close();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.cloud.compute;
|
||||
|
||||
import org.elasticsearch.ElasticSearchException;
|
||||
import org.elasticsearch.util.component.AbstractLifecycleComponent;
|
||||
import org.elasticsearch.util.guice.inject.Inject;
|
||||
import org.elasticsearch.util.settings.Settings;
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class CloudComputeService extends AbstractLifecycleComponent<CloudComputeService> {
|
||||
|
||||
private final String type;
|
||||
|
||||
private final ComputeServiceContext computeServiceContext;
|
||||
|
||||
@Inject public CloudComputeService(Settings settings) throws IOException {
|
||||
super(settings);
|
||||
|
||||
String type = componentSettings.get("type");
|
||||
if (type == null) {
|
||||
// see if we can get a global type
|
||||
type = settings.get("cloud.type");
|
||||
}
|
||||
// consolidate names
|
||||
if ("aws".equalsIgnoreCase(type) || "amazon".equalsIgnoreCase(type)) {
|
||||
type = "ec2";
|
||||
} else if ("rackspace".equalsIgnoreCase(type)) {
|
||||
type = "cloudservers";
|
||||
}
|
||||
this.type = type;
|
||||
|
||||
String account = componentSettings.get("account", settings.get("cloud.account"));
|
||||
String key = componentSettings.get("key", settings.get("cloud.key"));
|
||||
|
||||
if (type != null) {
|
||||
computeServiceContext = new ComputeServiceContextFactory().createContext(type, account, key);
|
||||
logger.info("Connected to [{}] compute service");
|
||||
} else {
|
||||
computeServiceContext = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override protected void doStart() throws ElasticSearchException {
|
||||
}
|
||||
|
||||
@Override protected void doStop() throws ElasticSearchException {
|
||||
}
|
||||
|
||||
@Override protected void doClose() throws ElasticSearchException {
|
||||
if (computeServiceContext != null) {
|
||||
computeServiceContext.close();
|
||||
}
|
||||
}
|
||||
|
||||
public ComputeServiceContext context() {
|
||||
return this.computeServiceContext;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.discovery.cloud;
|
||||
|
||||
import org.elasticsearch.cloud.compute.CloudComputeService;
|
||||
import org.elasticsearch.cluster.ClusterName;
|
||||
import org.elasticsearch.cluster.ClusterService;
|
||||
import org.elasticsearch.discovery.zen.ZenDiscovery;
|
||||
import org.elasticsearch.discovery.zen.ping.ZenPingService;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
import org.elasticsearch.util.gcommon.collect.ImmutableList;
|
||||
import org.elasticsearch.util.settings.Settings;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class CloudDiscovery extends ZenDiscovery {
|
||||
|
||||
public CloudDiscovery(Settings settings, ClusterName clusterName, ThreadPool threadPool, TransportService transportService,
|
||||
ClusterService clusterService, ZenPingService pingService, CloudComputeService computeService) {
|
||||
super(settings, clusterName, threadPool, transportService, clusterService, pingService);
|
||||
pingService.zenPings(ImmutableList.of(new CloudZenPing(settings, threadPool, transportService, clusterName, computeService)));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.discovery.cloud;
|
||||
|
||||
import org.elasticsearch.cloud.compute.CloudComputeService;
|
||||
import org.elasticsearch.cluster.ClusterName;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.discovery.zen.ping.unicast.UnicastZenPing;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
import org.elasticsearch.util.settings.Settings;
|
||||
import org.elasticsearch.util.transport.InetSocketTransportAddress;
|
||||
import org.elasticsearch.util.transport.PortsRange;
|
||||
import org.jclouds.compute.domain.ComputeMetadata;
|
||||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.compute.domain.NodeState;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.elasticsearch.util.gcommon.collect.Lists.*;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class CloudZenPing extends UnicastZenPing {
|
||||
|
||||
private final CloudComputeService computeService;
|
||||
|
||||
private final String ports;
|
||||
|
||||
public CloudZenPing(Settings settings, ThreadPool threadPool, TransportService transportService, ClusterName clusterName,
|
||||
CloudComputeService computeService) {
|
||||
super(settings, threadPool, transportService, clusterName);
|
||||
this.computeService = computeService;
|
||||
this.ports = componentSettings.get("ports", "9300-9302");
|
||||
// parse the ports just to see that they are valid
|
||||
new PortsRange(ports).ports();
|
||||
}
|
||||
|
||||
@Override protected List<DiscoveryNode> buildDynamicNodes() {
|
||||
List<DiscoveryNode> discoNodes = newArrayList();
|
||||
Map<String, ? extends ComputeMetadata> nodes = computeService.context().getComputeService().getNodes();
|
||||
for (Map.Entry<String, ? extends ComputeMetadata> node : nodes.entrySet()) {
|
||||
NodeMetadata nodeMetadata = computeService.context().getComputeService().getNodeMetadata(node.getValue());
|
||||
if (nodeMetadata.getState() == NodeState.PENDING || nodeMetadata.getState() == NodeState.RUNNING) {
|
||||
logger.debug("Adding {}/{}", nodeMetadata.getName(), nodeMetadata.getPrivateAddresses());
|
||||
for (InetAddress inetAddress : nodeMetadata.getPrivateAddresses()) {
|
||||
for (int port : new PortsRange(ports).ports()) {
|
||||
discoNodes.add(new DiscoveryNode("#cloud-" + inetAddress.getHostAddress() + "-" + port, new InetSocketTransportAddress(new InetSocketAddress(inetAddress, port))));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return discoNodes;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.plugin.cloud;
|
||||
|
||||
import org.elasticsearch.cloud.CloudModule;
|
||||
import org.elasticsearch.cloud.blobstore.CloudBlobstoreService;
|
||||
import org.elasticsearch.cloud.compute.CloudComputeService;
|
||||
import org.elasticsearch.plugins.AbstractPlugin;
|
||||
import org.elasticsearch.util.component.LifecycleComponent;
|
||||
import org.elasticsearch.util.guice.inject.Module;
|
||||
import org.elasticsearch.util.settings.Settings;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import static org.elasticsearch.util.gcommon.collect.Lists.*;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class CloudPlugin extends AbstractPlugin {
|
||||
|
||||
private final Settings settings;
|
||||
|
||||
public CloudPlugin(Settings settings) {
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
@Override public String name() {
|
||||
return "cloud";
|
||||
}
|
||||
|
||||
@Override public String description() {
|
||||
return "Cloud plugin";
|
||||
}
|
||||
|
||||
@Override public Collection<Class<? extends Module>> modules() {
|
||||
Collection<Class<? extends Module>> modules = newArrayList();
|
||||
if (settings.getAsBoolean("cloud.enabled", true)) {
|
||||
modules.add(CloudModule.class);
|
||||
}
|
||||
return modules;
|
||||
}
|
||||
|
||||
@Override public Collection<Class<? extends LifecycleComponent>> services() {
|
||||
Collection<Class<? extends LifecycleComponent>> services = newArrayList();
|
||||
if (settings.getAsBoolean("cloud.enabled", true)) {
|
||||
services.add(CloudComputeService.class);
|
||||
services.add(CloudBlobstoreService.class);
|
||||
}
|
||||
return services;
|
||||
}
|
||||
}
|
|
@ -32,6 +32,7 @@ configurations {
|
|||
dependencies {
|
||||
compile project(':elasticsearch')
|
||||
compile('jgroups:jgroups:2.9.0.GA') { transitive = false }
|
||||
distLib('jgroups:jgroups:2.9.0.GA') { transitive = false }
|
||||
|
||||
testCompile project(':test-testng')
|
||||
testCompile('org.testng:testng:5.10:jdk15') { transitive = false }
|
||||
|
|
|
@ -1 +1 @@
|
|||
plugin=org.elasticsearch.plugin.jgroups.JgroupsPlugin
|
||||
plugin=org.elasticsearch.plugin.discovery.jgroups.JgroupsDiscoveryPlugin
|
||||
|
|
|
@ -17,17 +17,17 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.plugin.jgroups;
|
||||
package org.elasticsearch.plugin.discovery.jgroups;
|
||||
|
||||
import org.elasticsearch.plugins.AbstractPlugin;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class JgroupsPlugin extends AbstractPlugin {
|
||||
public class JgroupsDiscoveryPlugin extends AbstractPlugin {
|
||||
|
||||
@Override public String name() {
|
||||
return "discovery-plugin";
|
||||
return "discovery-jgroups";
|
||||
}
|
||||
|
||||
@Override public String description() {
|
|
@ -1 +1 @@
|
|||
plugin=org.elasticsearch.plugin.attachments.MapperAttachmentsPlugin
|
||||
plugin=org.elasticsearch.plugin.mapper.attachments.MapperAttachmentsPlugin
|
||||
|
|
|
@ -33,7 +33,7 @@ import java.util.Map;
|
|||
|
||||
import static org.elasticsearch.index.mapper.xcontent.XContentMapperBuilders.*;
|
||||
import static org.elasticsearch.index.mapper.xcontent.XContentTypeParsers.*;
|
||||
import static org.elasticsearch.plugin.attachments.tika.TikaInstance.*;
|
||||
import static org.elasticsearch.plugin.mapper.attachments.tika.TikaInstance.*;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
|
@ -200,8 +200,8 @@ public class XContentAttachmentMapper implements XContentMapper {
|
|||
private final XContentStringFieldMapper keywordsMapper;
|
||||
|
||||
public XContentAttachmentMapper(String name, ContentPath.Type pathType, XContentStringFieldMapper contentMapper,
|
||||
XContentDateFieldMapper dateMapper, XContentStringFieldMapper titleMapper, XContentStringFieldMapper authorMapper,
|
||||
XContentStringFieldMapper keywordsMapper) {
|
||||
XContentDateFieldMapper dateMapper, XContentStringFieldMapper titleMapper, XContentStringFieldMapper authorMapper,
|
||||
XContentStringFieldMapper keywordsMapper) {
|
||||
this.name = name;
|
||||
this.pathType = pathType;
|
||||
this.contentMapper = contentMapper;
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.plugin.attachments;
|
||||
package org.elasticsearch.plugin.mapper.attachments;
|
||||
|
||||
import org.elasticsearch.util.guice.inject.AbstractModule;
|
||||
import org.elasticsearch.index.mapper.xcontent.XContentAttachmentMapperService;
|
||||
import org.elasticsearch.util.guice.inject.AbstractModule;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
|
@ -17,10 +17,10 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.plugin.attachments;
|
||||
package org.elasticsearch.plugin.mapper.attachments;
|
||||
|
||||
import org.elasticsearch.util.guice.inject.Module;
|
||||
import org.elasticsearch.plugins.AbstractPlugin;
|
||||
import org.elasticsearch.util.guice.inject.Module;
|
||||
|
||||
import java.util.Collection;
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.plugin.attachments.tika;
|
||||
package org.elasticsearch.plugin.mapper.attachments.tika;
|
||||
|
||||
import org.apache.tika.Tika;
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.plugin.attachments.test;
|
||||
package org.elasticsearch.plugin.mapper.attachments.test;
|
||||
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
|
@ -1 +1 @@
|
|||
plugin=org.elasticsearch.memcached.MemcachedPlugin
|
||||
plugin=org.elasticsearch.plugin.transport.memcached.MemcachedTransportPlugin
|
||||
|
|
|
@ -17,11 +17,13 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.memcached;
|
||||
package org.elasticsearch.plugin.transport.memcached;
|
||||
|
||||
import org.elasticsearch.util.guice.inject.Module;
|
||||
import org.elasticsearch.memcached.MemcachedServer;
|
||||
import org.elasticsearch.memcached.MemcachedServerModule;
|
||||
import org.elasticsearch.plugins.AbstractPlugin;
|
||||
import org.elasticsearch.util.component.LifecycleComponent;
|
||||
import org.elasticsearch.util.guice.inject.Module;
|
||||
import org.elasticsearch.util.settings.Settings;
|
||||
|
||||
import java.util.Collection;
|
||||
|
@ -31,11 +33,11 @@ import static org.elasticsearch.util.gcommon.collect.Lists.*;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class MemcachedPlugin extends AbstractPlugin {
|
||||
public class MemcachedTransportPlugin extends AbstractPlugin {
|
||||
|
||||
private final Settings settings;
|
||||
|
||||
public MemcachedPlugin(Settings settings) {
|
||||
public MemcachedTransportPlugin(Settings settings) {
|
||||
this.settings = settings;
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ include 'test-integration'
|
|||
|
||||
include 'benchmark-micro'
|
||||
|
||||
include 'plugins-cloud'
|
||||
include 'plugins-analysis-icu'
|
||||
include 'plugins-mapper-attachments'
|
||||
include 'plugins-client-groovy'
|
||||
|
|
Loading…
Reference in New Issue