diff --git a/pom.xml b/pom.xml
index 4b8c8de3c3a..bd83e6a476b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -99,6 +99,14 @@ governing permissions and limitations under the License. -->
+
+
+ org.kuali.maven.wagons
+ maven-s3-wagon
+ 1.1.19
+
+
+
src/main/resources
@@ -153,6 +161,25 @@ governing permissions and limitations under the License. -->
+
+ org.codehaus.mojo
+ wagon-maven-plugin
+ 1.0-beta-4
+
+ elasticsearch.download
+ ${project.build.directory}/releases/${project.build.finalName}.zip
+ s3://test.elasticsearch.org/elasticsearch/${project.artifactId}/
+
+
+
+ upload-zip-to-server
+ deploy
+
+ upload-single
+
+
+
+
diff --git a/src/main/java/org/elasticsearch/cloud/gce/GceComputeService.java b/src/main/java/org/elasticsearch/cloud/gce/GceComputeService.java
index 6f76fd82b02..262aa8834c2 100644
--- a/src/main/java/org/elasticsearch/cloud/gce/GceComputeService.java
+++ b/src/main/java/org/elasticsearch/cloud/gce/GceComputeService.java
@@ -19,88 +19,20 @@
package org.elasticsearch.cloud.gce;
-import com.google.api.client.googleapis.compute.ComputeCredential;
-import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
-import com.google.api.client.http.HttpTransport;
-import com.google.api.client.json.JsonFactory;
-import com.google.api.client.json.jackson2.JacksonFactory;
-import com.google.api.services.compute.Compute;
-import org.elasticsearch.ElasticSearchException;
-import org.elasticsearch.common.component.AbstractLifecycleComponent;
-import org.elasticsearch.common.inject.Inject;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.common.settings.SettingsFilter;
-import org.elasticsearch.common.unit.TimeValue;
-import org.elasticsearch.discovery.DiscoveryException;
+import com.google.api.services.compute.model.Instance;
+
+import java.util.Collection;
/**
*
*/
-public class GceComputeService extends AbstractLifecycleComponent {
-
- static final class Fields {
- private static final String VERSION = "Elasticsearch/GceCloud/1.0";
+public interface GceComputeService {
+ static final public class Fields {
+ public static final String PROJECT = "project_id";
+ public static final String ZONE = "zone";
+ public static final String REFRESH = "refresh_interval";
+ public static final String VERSION = "Elasticsearch/GceCloud/1.0";
}
- private Compute client;
- private TimeValue refreshInterval = null;
- private long lastRefresh;
-
- /** Global instance of the HTTP transport. */
- private static HttpTransport HTTP_TRANSPORT;
-
- /** Global instance of the JSON factory. */
- private static JsonFactory JSON_FACTORY;
-
- @Inject
- public GceComputeService(Settings settings, SettingsFilter settingsFilter) {
- super(settings);
- settingsFilter.addFilter(new GceSettingsFilter());
- }
-
- public synchronized Compute client() {
- if (refreshInterval != null && refreshInterval.millis() != 0) {
- if (client != null &&
- (refreshInterval.millis() < 0 || (System.currentTimeMillis() - lastRefresh) < refreshInterval.millis())) {
- if (logger.isTraceEnabled()) logger.trace("using cache to retrieve client");
- return client;
- }
- lastRefresh = System.currentTimeMillis();
- }
-
- try {
- HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
- JSON_FACTORY = new JacksonFactory();
-
- logger.debug("starting GCE discovery service");
- ComputeCredential credential = new ComputeCredential.Builder(HTTP_TRANSPORT, JSON_FACTORY).build();
- credential.refreshToken();
-
- logger.debug("token [{}] will expire in [{}] s", credential.getAccessToken(), credential.getExpiresInSeconds());
- refreshInterval = TimeValue.timeValueSeconds(credential.getExpiresInSeconds()-1);
-
- // Once done, let's use this token
- this.client = new Compute.Builder(HTTP_TRANSPORT, JSON_FACTORY, null)
- .setApplicationName(Fields.VERSION)
- .setHttpRequestInitializer(credential)
- .build();
- } catch (Exception e) {
- logger.warn("unable to start GCE discovery service: {} : {}", e.getClass().getName(), e.getMessage());
- throw new DiscoveryException("unable to start GCE discovery service", e);
- }
-
- return this.client;
- }
-
- @Override
- protected void doStart() throws ElasticSearchException {
- }
-
- @Override
- protected void doStop() throws ElasticSearchException {
- }
-
- @Override
- protected void doClose() throws ElasticSearchException {
- }
+ public Collection instances();
}
diff --git a/src/main/java/org/elasticsearch/cloud/gce/GceComputeServiceImpl.java b/src/main/java/org/elasticsearch/cloud/gce/GceComputeServiceImpl.java
new file mode 100644
index 00000000000..0dd3f2da3db
--- /dev/null
+++ b/src/main/java/org/elasticsearch/cloud/gce/GceComputeServiceImpl.java
@@ -0,0 +1,127 @@
+/*
+ * Licensed to ElasticSearch under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. ElasticSearch 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.gce;
+
+import com.google.api.client.googleapis.compute.ComputeCredential;
+import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
+import com.google.api.client.http.HttpTransport;
+import com.google.api.client.json.JsonFactory;
+import com.google.api.client.json.jackson2.JacksonFactory;
+import com.google.api.services.compute.Compute;
+import com.google.api.services.compute.model.Instance;
+import com.google.api.services.compute.model.InstanceList;
+import org.elasticsearch.ElasticSearchException;
+import org.elasticsearch.common.component.AbstractLifecycleComponent;
+import org.elasticsearch.common.inject.Inject;
+import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.common.settings.SettingsFilter;
+import org.elasticsearch.common.unit.TimeValue;
+import org.elasticsearch.discovery.DiscoveryException;
+
+import java.io.IOException;
+import java.util.Collection;
+
+/**
+ *
+ */
+public class GceComputeServiceImpl extends AbstractLifecycleComponent
+ implements GceComputeService {
+
+ private final String project;
+ private final String zone;
+
+ @Override
+ public Collection instances() {
+ try {
+ Compute.Instances.List list = client().instances().list(project, zone);
+ InstanceList instanceList = list.execute();
+
+ return instanceList.getItems();
+ } catch (IOException e) {
+ throw new ElasticSearchException("Pas glop");
+ }
+
+ }
+
+ private Compute client;
+ private TimeValue refreshInterval = null;
+ private long lastRefresh;
+
+ /** Global instance of the HTTP transport. */
+ private static HttpTransport HTTP_TRANSPORT;
+
+ /** Global instance of the JSON factory. */
+ private static JsonFactory JSON_FACTORY;
+
+ @Inject
+ public GceComputeServiceImpl(Settings settings, SettingsFilter settingsFilter) {
+ super(settings);
+ settingsFilter.addFilter(new GceSettingsFilter());
+
+ this.project = componentSettings.get(Fields.PROJECT, settings.get("cloud.gce." + Fields.PROJECT));
+ this.zone = componentSettings.get(Fields.ZONE, settings.get("cloud.gce." + Fields.ZONE));
+ }
+
+ public synchronized Compute client() {
+ if (refreshInterval != null && refreshInterval.millis() != 0) {
+ if (client != null &&
+ (refreshInterval.millis() < 0 || (System.currentTimeMillis() - lastRefresh) < refreshInterval.millis())) {
+ if (logger.isTraceEnabled()) logger.trace("using cache to retrieve client");
+ return client;
+ }
+ lastRefresh = System.currentTimeMillis();
+ }
+
+ try {
+ HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
+ JSON_FACTORY = new JacksonFactory();
+
+ logger.debug("starting GCE discovery service");
+ ComputeCredential credential = new ComputeCredential.Builder(HTTP_TRANSPORT, JSON_FACTORY).build();
+ credential.refreshToken();
+
+ logger.debug("token [{}] will expire in [{}] s", credential.getAccessToken(), credential.getExpiresInSeconds());
+ refreshInterval = TimeValue.timeValueSeconds(credential.getExpiresInSeconds()-1);
+
+ // Once done, let's use this token
+ this.client = new Compute.Builder(HTTP_TRANSPORT, JSON_FACTORY, null)
+ .setApplicationName(Fields.VERSION)
+ .setHttpRequestInitializer(credential)
+ .build();
+ } catch (Exception e) {
+ logger.warn("unable to start GCE discovery service: {} : {}", e.getClass().getName(), e.getMessage());
+ throw new DiscoveryException("unable to start GCE discovery service", e);
+ }
+
+ return this.client;
+ }
+
+ @Override
+ protected void doStart() throws ElasticSearchException {
+ }
+
+ @Override
+ protected void doStop() throws ElasticSearchException {
+ }
+
+ @Override
+ protected void doClose() throws ElasticSearchException {
+ }
+}
diff --git a/src/main/java/org/elasticsearch/cloud/gce/GceModule.java b/src/main/java/org/elasticsearch/cloud/gce/GceModule.java
index 938c603bbf7..b6628dc5653 100644
--- a/src/main/java/org/elasticsearch/cloud/gce/GceModule.java
+++ b/src/main/java/org/elasticsearch/cloud/gce/GceModule.java
@@ -28,6 +28,6 @@ public class GceModule extends AbstractModule {
@Override
protected void configure() {
- bind(GceComputeService.class).asEagerSingleton();
+ bind(GceComputeService.class).to(GceComputeServiceImpl.class).asEagerSingleton();
}
}
diff --git a/src/main/java/org/elasticsearch/discovery/gce/GceUnicastHostsProvider.java b/src/main/java/org/elasticsearch/discovery/gce/GceUnicastHostsProvider.java
index 76ec9831acb..98fbb80960f 100644
--- a/src/main/java/org/elasticsearch/discovery/gce/GceUnicastHostsProvider.java
+++ b/src/main/java/org/elasticsearch/discovery/gce/GceUnicastHostsProvider.java
@@ -19,10 +19,8 @@
package org.elasticsearch.discovery.gce;
-import com.google.api.services.compute.Compute;
import com.google.api.services.compute.model.AccessConfig;
import com.google.api.services.compute.model.Instance;
-import com.google.api.services.compute.model.InstanceList;
import com.google.api.services.compute.model.NetworkInterface;
import org.elasticsearch.cloud.gce.GceComputeService;
import org.elasticsearch.cluster.node.DiscoveryNode;
@@ -40,6 +38,7 @@ import org.elasticsearch.transport.TransportService;
import java.io.IOException;
import java.net.InetAddress;
+import java.util.Collection;
import java.util.List;
/**
@@ -125,11 +124,9 @@ public class GceUnicastHostsProvider extends AbstractComponent implements Unicas
}
try {
- Compute.Instances.List list = gceComputeService.client().instances().list(project, zone);
+ Collection instances = gceComputeService.instances();
- InstanceList instanceList = list.execute();
-
- for (Instance instance : instanceList.getItems()) {
+ for (Instance instance : instances) {
String name = instance.getName();
String type = instance.getMachineType();
String image = instance.getImage();
@@ -215,7 +212,7 @@ public class GceUnicastHostsProvider extends AbstractComponent implements Unicas
}
}
- } catch (IOException e) {
+ } catch (Throwable e) {
logger.warn("Exception caught during discovery {} : {}", e.getClass().getName(), e.getMessage());
logger.trace("Exception caught during discovery", e);
}
diff --git a/src/main/java/org/elasticsearch/plugin/cloud/gce/CloudGcePlugin.java b/src/main/java/org/elasticsearch/plugin/cloud/gce/CloudGcePlugin.java
index 0100a32c6eb..40be7338a09 100644
--- a/src/main/java/org/elasticsearch/plugin/cloud/gce/CloudGcePlugin.java
+++ b/src/main/java/org/elasticsearch/plugin/cloud/gce/CloudGcePlugin.java
@@ -19,7 +19,7 @@
package org.elasticsearch.plugin.cloud.gce;
-import org.elasticsearch.cloud.gce.GceComputeService;
+import org.elasticsearch.cloud.gce.GceComputeServiceImpl;
import org.elasticsearch.cloud.gce.GceModule;
import org.elasticsearch.common.collect.Lists;
import org.elasticsearch.common.component.LifecycleComponent;
@@ -63,7 +63,7 @@ public class CloudGcePlugin extends AbstractPlugin {
public Collection> services() {
Collection> services = Lists.newArrayList();
if (settings.getAsBoolean("cloud.enabled", true)) {
- services.add(GceComputeService.class);
+ services.add(GceComputeServiceImpl.class);
}
return services;
}
diff --git a/src/test/java/org/elasticsearch/cloud/gce/tests/GceComputeServiceMock.java b/src/test/java/org/elasticsearch/cloud/gce/tests/GceComputeServiceMock.java
new file mode 100644
index 00000000000..9d44d25e63b
--- /dev/null
+++ b/src/test/java/org/elasticsearch/cloud/gce/tests/GceComputeServiceMock.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to ElasticSearch under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. ElasticSearch 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.gce.tests;
+
+import com.google.api.services.compute.model.Instance;
+import org.elasticsearch.ElasticSearchException;
+import org.elasticsearch.cloud.gce.GceComputeService;
+import org.elasticsearch.common.component.AbstractLifecycleComponent;
+import org.elasticsearch.common.settings.Settings;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ *
+ */
+public class GceComputeServiceMock extends AbstractLifecycleComponent
+ implements GceComputeService {
+
+ protected GceComputeServiceMock(Settings settings) {
+ super(settings);
+ logger.debug("Starting MOCK");
+ }
+
+ @Override
+ public Collection instances() {
+ Collection instances = new ArrayList();
+
+ return instances;
+ }
+
+ @Override
+ protected void doStart() throws ElasticSearchException {
+ }
+
+ @Override
+ protected void doStop() throws ElasticSearchException {
+ }
+
+ @Override
+ protected void doClose() throws ElasticSearchException {
+ }
+}