diff --git a/plugins/discovery-gce/src/main/java/org/elasticsearch/cloud/gce/GceMetadataService.java b/plugins/discovery-gce/src/main/java/org/elasticsearch/cloud/gce/GceMetadataService.java deleted file mode 100644 index 65021516f9f..00000000000 --- a/plugins/discovery-gce/src/main/java/org/elasticsearch/cloud/gce/GceMetadataService.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 org.elasticsearch.common.component.LifecycleComponent; -import org.elasticsearch.common.settings.Setting; - -import java.io.IOException; -import java.net.URISyntaxException; -import java.util.function.Function; - -/** - * Access Google Compute Engine metadata - */ -public interface GceMetadataService extends LifecycleComponent { - /** - *

Gets metadata on the current running machine (call to - * http://metadata.google.internal/computeMetadata/v1/instance/xxx).

- *

For example, you can retrieve network information by replacing xxx with:

- * - * @see org.elasticsearch.cloud.gce.network.GceNameResolver for bindings - * @param metadataPath path to metadata information - * @return extracted information (for example a hostname or an IP address) - * @throws IOException in case metadata URL is not accessible - */ - String metadata(String metadataPath) throws IOException, URISyntaxException; -} diff --git a/plugins/discovery-gce/src/main/java/org/elasticsearch/cloud/gce/GceMetadataServiceImpl.java b/plugins/discovery-gce/src/main/java/org/elasticsearch/cloud/gce/GceMetadataServiceImpl.java index 7ccf0d6a7a7..568c2c14b48 100644 --- a/plugins/discovery-gce/src/main/java/org/elasticsearch/cloud/gce/GceMetadataServiceImpl.java +++ b/plugins/discovery-gce/src/main/java/org/elasticsearch/cloud/gce/GceMetadataServiceImpl.java @@ -35,14 +35,13 @@ import org.elasticsearch.common.settings.Settings; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; -import java.net.URL; import java.security.AccessController; import java.security.GeneralSecurityException; import java.security.PrivilegedAction; import java.security.PrivilegedExceptionAction; import java.util.function.Function; -public class GceMetadataServiceImpl extends AbstractLifecycleComponent implements GceMetadataService { +public class GceMetadataServiceImpl extends AbstractLifecycleComponent { // Forcing Google Token API URL as set in GCE SDK to // http://metadata/computeMetadata/v1/instance/service-accounts/default/token @@ -67,7 +66,6 @@ public class GceMetadataServiceImpl extends AbstractLifecycleComponent computeServiceImpl = GceInstancesServiceImpl.class; - static Class metadataServiceImpl = GceMetadataServiceImpl.class; + static Class metadataServiceImpl = GceMetadataServiceImpl.class; protected final Settings settings; protected final ESLogger logger = Loggers.getLogger(GceModule.class); @@ -40,7 +40,7 @@ public class GceModule extends AbstractModule { return computeServiceImpl; } - public static Class getMetadataServiceImpl() { + public static Class getMetadataServiceImpl() { return metadataServiceImpl; } @@ -48,6 +48,6 @@ public class GceModule extends AbstractModule { protected void configure() { logger.debug("configure GceModule (bind compute and metadata services)"); bind(GceInstancesService.class).to(computeServiceImpl).asEagerSingleton(); - bind(GceMetadataService.class).to(metadataServiceImpl).asEagerSingleton(); + bind(GceMetadataServiceImpl.class).asEagerSingleton(); } } diff --git a/plugins/discovery-gce/src/main/java/org/elasticsearch/cloud/gce/network/GceNameResolver.java b/plugins/discovery-gce/src/main/java/org/elasticsearch/cloud/gce/network/GceNameResolver.java index 54f96a971ca..a244b7f57de 100644 --- a/plugins/discovery-gce/src/main/java/org/elasticsearch/cloud/gce/network/GceNameResolver.java +++ b/plugins/discovery-gce/src/main/java/org/elasticsearch/cloud/gce/network/GceNameResolver.java @@ -19,7 +19,7 @@ package org.elasticsearch.cloud.gce.network; -import org.elasticsearch.cloud.gce.GceMetadataService; +import org.elasticsearch.cloud.gce.GceMetadataServiceImpl; import org.elasticsearch.common.Strings; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.network.NetworkService.CustomNameResolver; @@ -41,7 +41,7 @@ import java.net.URISyntaxException; */ public class GceNameResolver extends AbstractComponent implements CustomNameResolver { - private final GceMetadataService gceMetadataService; + private final GceMetadataServiceImpl gceMetadataService; /** * enum that can be added to over time with more meta-data types @@ -73,7 +73,7 @@ public class GceNameResolver extends AbstractComponent implements CustomNameReso /** * Construct a {@link CustomNameResolver}. */ - public GceNameResolver(Settings settings, GceMetadataService gceMetadataService) { + public GceNameResolver(Settings settings, GceMetadataServiceImpl gceMetadataService) { super(settings); this.gceMetadataService = gceMetadataService; } diff --git a/plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/GceDiscoverTests.java b/plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/GceDiscoverTests.java index c09f63011ed..1bc72f689a1 100644 --- a/plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/GceDiscoverTests.java +++ b/plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/GceDiscoverTests.java @@ -23,9 +23,7 @@ import com.sun.net.httpserver.Headers; import com.sun.net.httpserver.HttpServer; import com.sun.net.httpserver.HttpsConfigurator; import com.sun.net.httpserver.HttpsServer; -import org.elasticsearch.cloud.gce.GceInstancesService; import org.elasticsearch.cloud.gce.GceInstancesServiceImpl; -import org.elasticsearch.cloud.gce.GceMetadataService; import org.elasticsearch.cloud.gce.GceMetadataServiceImpl; import org.elasticsearch.common.SuppressForbidden; import org.elasticsearch.common.io.FileSystemUtils;