Don't use shaded APIs

This commit is contained in:
Robert Muir 2015-06-04 16:27:29 -04:00
parent 7efb36da54
commit 7d67dfd61d
10 changed files with 43 additions and 41 deletions

View File

@ -27,10 +27,10 @@ import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.services.compute.Compute; import com.google.api.services.compute.Compute;
import com.google.api.services.compute.model.Instance; import com.google.api.services.compute.model.Instance;
import com.google.api.services.compute.model.InstanceList; import com.google.api.services.compute.model.InstanceList;
import com.google.common.base.Function;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import org.elasticsearch.ElasticsearchException; import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.common.base.Function;
import org.elasticsearch.common.collect.Iterables;
import org.elasticsearch.common.collect.Lists;
import org.elasticsearch.common.component.AbstractLifecycleComponent; import org.elasticsearch.common.component.AbstractLifecycleComponent;
import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
@ -38,6 +38,7 @@ import org.elasticsearch.common.settings.SettingsFilter;
import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.unit.TimeValue;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@ -67,7 +68,7 @@ public class GceComputeServiceImpl extends AbstractLifecycleComponent<GceCompute
Compute.Instances.List list = client().instances().list(project, zoneId); Compute.Instances.List list = client().instances().list(project, zoneId);
InstanceList instanceList = list.execute(); InstanceList instanceList = list.execute();
if (instanceList.isEmpty()) { if (instanceList.isEmpty()) {
return Lists.newArrayList(); return new ArrayList();
} }
return instanceList.getItems(); return instanceList.getItems();
@ -75,7 +76,7 @@ public class GceComputeServiceImpl extends AbstractLifecycleComponent<GceCompute
logger.warn("Problem fetching instance list for zone {}", zoneId); logger.warn("Problem fetching instance list for zone {}", zoneId);
logger.debug("Full exception:", e); logger.debug("Full exception:", e);
return Lists.newArrayList(); return new ArrayList();
} }
} }
}); });

View File

@ -26,7 +26,6 @@ import org.elasticsearch.Version;
import org.elasticsearch.cloud.gce.GceComputeService; import org.elasticsearch.cloud.gce.GceComputeService;
import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.Strings; import org.elasticsearch.common.Strings;
import org.elasticsearch.common.collect.Lists;
import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.network.NetworkService; import org.elasticsearch.common.network.NetworkService;
@ -38,6 +37,8 @@ import org.elasticsearch.transport.TransportService;
import java.io.IOException; import java.io.IOException;
import java.net.InetAddress; import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@ -86,7 +87,7 @@ public class GceUnicastHostsProvider extends AbstractComponent implements Unicas
this.tags = settings.getAsArray(Fields.TAGS); this.tags = settings.getAsArray(Fields.TAGS);
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("using tags {}", Lists.newArrayList(this.tags)); logger.debug("using tags {}", Arrays.asList(this.tags));
} }
} }
@ -108,7 +109,7 @@ public class GceUnicastHostsProvider extends AbstractComponent implements Unicas
} }
logger.debug("start building nodes list using GCE API"); logger.debug("start building nodes list using GCE API");
cachedDiscoNodes = Lists.newArrayList(); cachedDiscoNodes = new ArrayList<>();
String ipAddress = null; String ipAddress = null;
try { try {
InetAddress inetAddress = networkService.resolvePublishHostAddress(null); InetAddress inetAddress = networkService.resolvePublishHostAddress(null);

View File

@ -20,12 +20,12 @@
package org.elasticsearch.plugin.cloud.gce; package org.elasticsearch.plugin.cloud.gce;
import org.elasticsearch.cloud.gce.GceModule; import org.elasticsearch.cloud.gce.GceModule;
import org.elasticsearch.common.collect.Lists;
import org.elasticsearch.common.component.LifecycleComponent; import org.elasticsearch.common.component.LifecycleComponent;
import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.inject.Module;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.plugins.AbstractPlugin; import org.elasticsearch.plugins.AbstractPlugin;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
/** /**
@ -51,7 +51,7 @@ public class CloudGcePlugin extends AbstractPlugin {
@Override @Override
public Collection<Class<? extends Module>> modules() { public Collection<Class<? extends Module>> modules() {
Collection<Class<? extends Module>> modules = Lists.newArrayList(); Collection<Class<? extends Module>> modules = new ArrayList<>();
if (settings.getAsBoolean("cloud.enabled", true)) { if (settings.getAsBoolean("cloud.enabled", true)) {
modules.add(GceModule.class); modules.add(GceModule.class);
} }
@ -60,7 +60,7 @@ public class CloudGcePlugin extends AbstractPlugin {
@Override @Override
public Collection<Class<? extends LifecycleComponent>> services() { public Collection<Class<? extends LifecycleComponent>> services() {
Collection<Class<? extends LifecycleComponent>> services = Lists.newArrayList(); Collection<Class<? extends LifecycleComponent>> services = new ArrayList<>();
if (settings.getAsBoolean("cloud.enabled", true)) { if (settings.getAsBoolean("cloud.enabled", true)) {
// services.add(GceComputeServiceImpl.class); // services.add(GceComputeServiceImpl.class);
} }

View File

@ -19,10 +19,10 @@
package org.elasticsearch.discovery.gce; package org.elasticsearch.discovery.gce;
import com.google.common.collect.Lists;
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
import org.elasticsearch.cloud.gce.GceComputeService; import org.elasticsearch.cloud.gce.GceComputeService;
import org.elasticsearch.cloud.gce.GceComputeService.Fields; import org.elasticsearch.cloud.gce.GceComputeService.Fields;
import org.elasticsearch.common.collect.Lists;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.discovery.gce.mock.*; import org.elasticsearch.discovery.gce.mock.*;
import org.elasticsearch.plugins.PluginsService; import org.elasticsearch.plugins.PluginsService;

View File

@ -23,9 +23,9 @@ import com.google.api.services.compute.model.Instance;
import com.google.api.services.compute.model.Metadata; import com.google.api.services.compute.model.Metadata;
import com.google.api.services.compute.model.NetworkInterface; import com.google.api.services.compute.model.NetworkInterface;
import com.google.api.services.compute.model.Tags; import com.google.api.services.compute.model.Tags;
import com.google.common.collect.Lists;
import org.elasticsearch.ElasticsearchException; import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.cloud.gce.GceComputeService; import org.elasticsearch.cloud.gce.GceComputeService;
import org.elasticsearch.common.collect.Lists;
import org.elasticsearch.common.component.AbstractLifecycleComponent; import org.elasticsearch.common.component.AbstractLifecycleComponent;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.discovery.gce.GceComputeEngineTest; import org.elasticsearch.discovery.gce.GceComputeEngineTest;
@ -42,7 +42,7 @@ import static com.carrotsearch.randomizedtesting.RandomizedTest.randomInt;
public abstract class GceComputeServiceAbstractMock extends AbstractLifecycleComponent<GceComputeServiceAbstractMock> public abstract class GceComputeServiceAbstractMock extends AbstractLifecycleComponent<GceComputeServiceAbstractMock>
implements GceComputeService { implements GceComputeService {
protected abstract List<ArrayList<String>> getTags(); protected abstract List<List<String>> getTags();
protected abstract List<String> getZones(); protected abstract List<String> getZones();
private final List<String> zoneList; private final List<String> zoneList;

View File

@ -19,29 +19,29 @@
package org.elasticsearch.discovery.gce.mock; package org.elasticsearch.discovery.gce.mock;
import org.elasticsearch.common.collect.Lists;
import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
/** /**
* *
*/ */
public class GceComputeServiceTwoNodesDifferentTagsMock extends GceComputeServiceAbstractMock { public class GceComputeServiceTwoNodesDifferentTagsMock extends GceComputeServiceAbstractMock {
private static List<ArrayList<String>> tags = Lists.newArrayList( private static List<List<String>> tags = Arrays.asList(
Lists.newArrayList("dev"), Arrays.asList("dev"),
Lists.newArrayList("elasticsearch","dev")); Arrays.asList("elasticsearch", "dev"));
@Override @Override
protected List<ArrayList<String>> getTags() { protected List<List<String>> getTags() {
return tags; return tags;
} }
@Override @Override
protected List<String> getZones() { protected List<String> getZones() {
return Lists.newArrayList(); return new ArrayList();
} }
@Inject @Inject

View File

@ -19,22 +19,22 @@
package org.elasticsearch.discovery.gce.mock; package org.elasticsearch.discovery.gce.mock;
import org.elasticsearch.common.collect.Lists;
import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
/** /**
* *
*/ */
public class GceComputeServiceTwoNodesOneZoneMock extends GceComputeServiceAbstractMock { public class GceComputeServiceTwoNodesOneZoneMock extends GceComputeServiceAbstractMock {
private static List<String> zones = Lists.newArrayList("us-central1-a","us-central1-a"); private static List<String> zones = Arrays.asList("us-central1-a", "us-central1-a");
@Override @Override
protected List<ArrayList<String>> getTags() { protected List<List<String>> getTags() {
return Lists.newArrayList(); return new ArrayList<>();
} }
@Override @Override

View File

@ -19,30 +19,30 @@
package org.elasticsearch.discovery.gce.mock; package org.elasticsearch.discovery.gce.mock;
import org.elasticsearch.common.collect.Lists;
import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
/** /**
* *
*/ */
public class GceComputeServiceTwoNodesSameTagsMock extends GceComputeServiceAbstractMock { public class GceComputeServiceTwoNodesSameTagsMock extends GceComputeServiceAbstractMock {
private static List<ArrayList<String>> tags = Lists.newArrayList( private static List<List<String>> tags = Arrays.asList(
Lists.newArrayList("elasticsearch","dev"), Arrays.asList("elasticsearch", "dev"),
Lists.newArrayList("elasticsearch","dev")); Arrays.asList("elasticsearch", "dev"));
@Override @Override
protected List<ArrayList<String>> getTags() { protected List<List<String>> getTags() {
return tags; return tags;
} }
@Override @Override
protected List<String> getZones() { protected List<String> getZones() {
return Lists.newArrayList(); return new ArrayList<>();
} }
@Inject @Inject

View File

@ -19,22 +19,22 @@
package org.elasticsearch.discovery.gce.mock; package org.elasticsearch.discovery.gce.mock;
import org.elasticsearch.common.collect.Lists;
import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
/** /**
* *
*/ */
public class GceComputeServiceTwoNodesTwoZonesMock extends GceComputeServiceAbstractMock { public class GceComputeServiceTwoNodesTwoZonesMock extends GceComputeServiceAbstractMock {
private static List<String> zones = Lists.newArrayList("us-central1-a","europe-west1-a"); private static List<String> zones = Arrays.asList("us-central1-a", "europe-west1-a");
@Override @Override
protected List<ArrayList<String>> getTags() { protected List<List<String>> getTags() {
return Lists.newArrayList(); return new ArrayList();
} }
@Override @Override

View File

@ -20,9 +20,9 @@
package org.elasticsearch.discovery.gce.mock; package org.elasticsearch.discovery.gce.mock;
import com.google.api.services.compute.model.Instance; import com.google.api.services.compute.model.Instance;
import org.elasticsearch.common.base.Function; import com.google.common.base.Function;
import org.elasticsearch.common.collect.Iterables; import com.google.common.collect.Iterables;
import org.elasticsearch.common.collect.Lists; import com.google.common.collect.Lists;
import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
@ -36,13 +36,13 @@ import java.util.List;
public class GceComputeServiceZeroNodeMock extends GceComputeServiceAbstractMock { public class GceComputeServiceZeroNodeMock extends GceComputeServiceAbstractMock {
@Override @Override
protected List<ArrayList<String>> getTags() { protected List<List<String>> getTags() {
return Lists.newArrayList(); return new ArrayList();
} }
@Override @Override
protected List<String> getZones() { protected List<String> getZones() {
return Lists.newArrayList(); return new ArrayList();
} }
private final List<String> zoneList; private final List<String> zoneList;
@ -55,7 +55,7 @@ public class GceComputeServiceZeroNodeMock extends GceComputeServiceAbstractMock
@Override @Override
public List<Instance> apply(String zoneId) { public List<Instance> apply(String zoneId) {
// If we return null here we will get a trace as explained in issue 43 // If we return null here we will get a trace as explained in issue 43
return Lists.newArrayList(); return new ArrayList();
} }
}); });