Remove GceMetadataService interface as not needed
This commit is contained in:
parent
b0bdd443bd
commit
e7ab0a9233
|
@ -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<GceMetadataService> {
|
|
||||||
/**
|
|
||||||
* <p>Gets metadata on the current running machine (call to
|
|
||||||
* http://metadata.google.internal/computeMetadata/v1/instance/xxx).</p>
|
|
||||||
* <p>For example, you can retrieve network information by replacing xxx with:</p>
|
|
||||||
* <ul>
|
|
||||||
* <li>`hostname` when we need to resolve the host name</li>
|
|
||||||
* <li>`network-interfaces/0/ip` when we need to resolve private IP</li>
|
|
||||||
* </ul>
|
|
||||||
* @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;
|
|
||||||
}
|
|
|
@ -35,14 +35,13 @@ import org.elasticsearch.common.settings.Settings;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
|
||||||
import java.security.AccessController;
|
import java.security.AccessController;
|
||||||
import java.security.GeneralSecurityException;
|
import java.security.GeneralSecurityException;
|
||||||
import java.security.PrivilegedAction;
|
import java.security.PrivilegedAction;
|
||||||
import java.security.PrivilegedExceptionAction;
|
import java.security.PrivilegedExceptionAction;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
public class GceMetadataServiceImpl extends AbstractLifecycleComponent<GceMetadataService> implements GceMetadataService {
|
public class GceMetadataServiceImpl extends AbstractLifecycleComponent<GceMetadataServiceImpl> {
|
||||||
|
|
||||||
// Forcing Google Token API URL as set in GCE SDK to
|
// Forcing Google Token API URL as set in GCE SDK to
|
||||||
// http://metadata/computeMetadata/v1/instance/service-accounts/default/token
|
// http://metadata/computeMetadata/v1/instance/service-accounts/default/token
|
||||||
|
@ -67,7 +66,6 @@ public class GceMetadataServiceImpl extends AbstractLifecycleComponent<GceMetada
|
||||||
return gceHttpTransport;
|
return gceHttpTransport;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String metadata(String metadataPath) throws IOException, URISyntaxException {
|
public String metadata(String metadataPath) throws IOException, URISyntaxException {
|
||||||
// Forcing Google Token API URL as set in GCE SDK to
|
// Forcing Google Token API URL as set in GCE SDK to
|
||||||
// http://metadata/computeMetadata/v1/instance/service-accounts/default/token
|
// http://metadata/computeMetadata/v1/instance/service-accounts/default/token
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.elasticsearch.common.settings.Settings;
|
||||||
public class GceModule extends AbstractModule {
|
public class GceModule extends AbstractModule {
|
||||||
// pkg private so tests can override with mock
|
// pkg private so tests can override with mock
|
||||||
static Class<? extends GceInstancesService> computeServiceImpl = GceInstancesServiceImpl.class;
|
static Class<? extends GceInstancesService> computeServiceImpl = GceInstancesServiceImpl.class;
|
||||||
static Class<? extends GceMetadataService> metadataServiceImpl = GceMetadataServiceImpl.class;
|
static Class<? extends GceMetadataServiceImpl> metadataServiceImpl = GceMetadataServiceImpl.class;
|
||||||
|
|
||||||
protected final Settings settings;
|
protected final Settings settings;
|
||||||
protected final ESLogger logger = Loggers.getLogger(GceModule.class);
|
protected final ESLogger logger = Loggers.getLogger(GceModule.class);
|
||||||
|
@ -40,7 +40,7 @@ public class GceModule extends AbstractModule {
|
||||||
return computeServiceImpl;
|
return computeServiceImpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<? extends GceMetadataService> getMetadataServiceImpl() {
|
public static Class<? extends GceMetadataServiceImpl> getMetadataServiceImpl() {
|
||||||
return metadataServiceImpl;
|
return metadataServiceImpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,6 +48,6 @@ public class GceModule extends AbstractModule {
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
logger.debug("configure GceModule (bind compute and metadata services)");
|
logger.debug("configure GceModule (bind compute and metadata services)");
|
||||||
bind(GceInstancesService.class).to(computeServiceImpl).asEagerSingleton();
|
bind(GceInstancesService.class).to(computeServiceImpl).asEagerSingleton();
|
||||||
bind(GceMetadataService.class).to(metadataServiceImpl).asEagerSingleton();
|
bind(GceMetadataServiceImpl.class).asEagerSingleton();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
package org.elasticsearch.cloud.gce.network;
|
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.Strings;
|
||||||
import org.elasticsearch.common.component.AbstractComponent;
|
import org.elasticsearch.common.component.AbstractComponent;
|
||||||
import org.elasticsearch.common.network.NetworkService.CustomNameResolver;
|
import org.elasticsearch.common.network.NetworkService.CustomNameResolver;
|
||||||
|
@ -41,7 +41,7 @@ import java.net.URISyntaxException;
|
||||||
*/
|
*/
|
||||||
public class GceNameResolver extends AbstractComponent implements CustomNameResolver {
|
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
|
* 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}.
|
* Construct a {@link CustomNameResolver}.
|
||||||
*/
|
*/
|
||||||
public GceNameResolver(Settings settings, GceMetadataService gceMetadataService) {
|
public GceNameResolver(Settings settings, GceMetadataServiceImpl gceMetadataService) {
|
||||||
super(settings);
|
super(settings);
|
||||||
this.gceMetadataService = gceMetadataService;
|
this.gceMetadataService = gceMetadataService;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,7 @@ import com.sun.net.httpserver.Headers;
|
||||||
import com.sun.net.httpserver.HttpServer;
|
import com.sun.net.httpserver.HttpServer;
|
||||||
import com.sun.net.httpserver.HttpsConfigurator;
|
import com.sun.net.httpserver.HttpsConfigurator;
|
||||||
import com.sun.net.httpserver.HttpsServer;
|
import com.sun.net.httpserver.HttpsServer;
|
||||||
import org.elasticsearch.cloud.gce.GceInstancesService;
|
|
||||||
import org.elasticsearch.cloud.gce.GceInstancesServiceImpl;
|
import org.elasticsearch.cloud.gce.GceInstancesServiceImpl;
|
||||||
import org.elasticsearch.cloud.gce.GceMetadataService;
|
|
||||||
import org.elasticsearch.cloud.gce.GceMetadataServiceImpl;
|
import org.elasticsearch.cloud.gce.GceMetadataServiceImpl;
|
||||||
import org.elasticsearch.common.SuppressForbidden;
|
import org.elasticsearch.common.SuppressForbidden;
|
||||||
import org.elasticsearch.common.io.FileSystemUtils;
|
import org.elasticsearch.common.io.FileSystemUtils;
|
||||||
|
|
Loading…
Reference in New Issue