more work on cloud

This commit is contained in:
kimchy 2010-05-02 16:36:05 +03:00
parent b7bcc6ccb6
commit 4c53422428
4 changed files with 13 additions and 5 deletions

View File

@ -19,7 +19,7 @@
package org.elasticsearch.cloud;
import org.elasticsearch.cloud.blobstore.CloudBlobstoreService;
import org.elasticsearch.cloud.blobstore.CloudBlobStoreService;
import org.elasticsearch.cloud.compute.CloudComputeService;
import org.elasticsearch.util.guice.inject.AbstractModule;
@ -30,6 +30,6 @@ public class CloudModule extends AbstractModule {
@Override protected void configure() {
bind(CloudComputeService.class).asEagerSingleton();
bind(CloudBlobstoreService.class).asEagerSingleton();
bind(CloudBlobStoreService.class).asEagerSingleton();
}
}

View File

@ -37,6 +37,8 @@ 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)));
if (settings.getAsBoolean("cloud.enabled", true)) {
pingService.zenPings(ImmutableList.of(new CloudZenPing(settings, threadPool, transportService, clusterName, computeService)));
}
}
}

View File

@ -48,10 +48,13 @@ public class CloudZenPing extends UnicastZenPing {
private final String ports;
private final String tag;
public CloudZenPing(Settings settings, ThreadPool threadPool, TransportService transportService, ClusterName clusterName,
CloudComputeService computeService) {
super(settings, threadPool, transportService, clusterName);
this.computeService = computeService;
this.tag = componentSettings.get("tag");
this.ports = componentSettings.get("ports", "9300-9302");
// parse the ports just to see that they are valid
new PortsRange(ports).ports();
@ -62,6 +65,9 @@ public class CloudZenPing extends UnicastZenPing {
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 (tag != null && !nodeMetadata.getTag().equals(tag)) {
continue;
}
if (nodeMetadata.getState() == NodeState.PENDING || nodeMetadata.getState() == NodeState.RUNNING) {
logger.debug("Adding {}/{}", nodeMetadata.getName(), nodeMetadata.getPrivateAddresses());
for (InetAddress inetAddress : nodeMetadata.getPrivateAddresses()) {

View File

@ -20,7 +20,7 @@
package org.elasticsearch.plugin.cloud;
import org.elasticsearch.cloud.CloudModule;
import org.elasticsearch.cloud.blobstore.CloudBlobstoreService;
import org.elasticsearch.cloud.blobstore.CloudBlobStoreService;
import org.elasticsearch.cloud.compute.CloudComputeService;
import org.elasticsearch.plugins.AbstractPlugin;
import org.elasticsearch.util.component.LifecycleComponent;
@ -62,7 +62,7 @@ public class CloudPlugin extends AbstractPlugin {
Collection<Class<? extends LifecycleComponent>> services = newArrayList();
if (settings.getAsBoolean("cloud.enabled", true)) {
services.add(CloudComputeService.class);
services.add(CloudBlobstoreService.class);
services.add(CloudBlobStoreService.class);
}
return services;
}