diff --git a/src/main/java/org/elasticsearch/cloud/aws/blobstore/S3BlobContainer.java b/src/main/java/org/elasticsearch/cloud/aws/blobstore/S3BlobContainer.java index bac558ee854..1c0b23e8b1f 100644 --- a/src/main/java/org/elasticsearch/cloud/aws/blobstore/S3BlobContainer.java +++ b/src/main/java/org/elasticsearch/cloud/aws/blobstore/S3BlobContainer.java @@ -27,12 +27,13 @@ import org.elasticsearch.common.blobstore.BlobPath; import org.elasticsearch.common.blobstore.BlobStoreException; import org.elasticsearch.common.blobstore.support.AbstractBlobContainer; import org.elasticsearch.common.blobstore.support.PlainBlobMetaData; -import org.elasticsearch.common.collect.ImmutableMap; +import org.elasticsearch.common.collect.MapBuilder; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.util.Map; /** * @@ -104,8 +105,8 @@ public class S3BlobContainer extends AbstractBlobContainer { } @Override - public ImmutableMap listBlobsByPrefix(@Nullable String blobNamePrefix) throws IOException { - ImmutableMap.Builder blobsBuilder = ImmutableMap.builder(); + public Map listBlobsByPrefix(@Nullable String blobNamePrefix) throws IOException { + MapBuilder blobsBuilder = MapBuilder.newMapBuilder(); ObjectListing prevListing = null; while (true) { ObjectListing list; @@ -128,7 +129,7 @@ public class S3BlobContainer extends AbstractBlobContainer { break; } } - return blobsBuilder.build(); + return blobsBuilder.immutableMap(); } @Override @@ -150,7 +151,7 @@ public class S3BlobContainer extends AbstractBlobContainer { } @Override - public ImmutableMap listBlobs() throws IOException { + public Map listBlobs() throws IOException { return listBlobsByPrefix(null); } diff --git a/src/main/java/org/elasticsearch/cloud/aws/node/Ec2CustomNodeAttributes.java b/src/main/java/org/elasticsearch/cloud/aws/node/Ec2CustomNodeAttributes.java index 84e35b69b92..f8f66d001fa 100644 --- a/src/main/java/org/elasticsearch/cloud/aws/node/Ec2CustomNodeAttributes.java +++ b/src/main/java/org/elasticsearch/cloud/aws/node/Ec2CustomNodeAttributes.java @@ -23,7 +23,6 @@ import org.apache.lucene.util.IOUtils; import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.cloud.aws.AwsEc2Service; import org.elasticsearch.cluster.node.DiscoveryNodeService; -import org.elasticsearch.common.collect.Maps; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.settings.Settings; @@ -34,6 +33,7 @@ import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; import java.nio.charset.StandardCharsets; +import java.util.HashMap; import java.util.Map; /** @@ -49,7 +49,7 @@ public class Ec2CustomNodeAttributes extends AbstractComponent implements Discov if (!settings.getAsBoolean("cloud.node.auto_attributes", false)) { return null; } - Map ec2Attributes = Maps.newHashMap(); + Map ec2Attributes = new HashMap<>(); URLConnection urlConnection; InputStream in = null; diff --git a/src/main/java/org/elasticsearch/discovery/ec2/AwsEc2UnicastHostsProvider.java b/src/main/java/org/elasticsearch/discovery/ec2/AwsEc2UnicastHostsProvider.java index 7ac049a509b..4ffd73c2158 100644 --- a/src/main/java/org/elasticsearch/discovery/ec2/AwsEc2UnicastHostsProvider.java +++ b/src/main/java/org/elasticsearch/discovery/ec2/AwsEc2UnicastHostsProvider.java @@ -26,10 +26,6 @@ import org.elasticsearch.Version; import org.elasticsearch.cloud.aws.AwsEc2Service; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.collect.Sets; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -60,11 +56,11 @@ public class AwsEc2UnicastHostsProvider extends AbstractComponent implements Uni private final boolean bindAnyGroup; - private final ImmutableSet groups; + private final Set groups; - private final ImmutableMap tags; + private final Map tags; - private final ImmutableSet availabilityZones; + private final Set availabilityZones; private final HostType hostType; @@ -78,15 +74,17 @@ public class AwsEc2UnicastHostsProvider extends AbstractComponent implements Uni this.hostType = HostType.valueOf(settings.get("discovery.ec2.host_type", "private_ip").toUpperCase(Locale.ROOT)); this.bindAnyGroup = settings.getAsBoolean("discovery.ec2.any_group", true); - this.groups = ImmutableSet.copyOf(settings.getAsArray("discovery.ec2.groups")); + this.groups = new HashSet<>(); + groups.addAll(Arrays.asList(settings.getAsArray("discovery.ec2.groups"))); this.tags = settings.getByPrefix("discovery.ec2.tag.").getAsMap(); - Set availabilityZones = Sets.newHashSet(settings.getAsArray("discovery.ec2.availability_zones")); + Set availabilityZones = new HashSet(); + availabilityZones.addAll(Arrays.asList(settings.getAsArray("discovery.ec2.availability_zones"))); if (settings.get("discovery.ec2.availability_zones") != null) { availabilityZones.addAll(Strings.commaDelimitedListToSet(settings.get("discovery.ec2.availability_zones"))); } - this.availabilityZones = ImmutableSet.copyOf(availabilityZones); + this.availabilityZones = availabilityZones; if (logger.isDebugEnabled()) { logger.debug("using host_type [{}], tags [{}], groups [{}] with any_group [{}], availability_zones [{}]", hostType, tags, groups, bindAnyGroup, availabilityZones); @@ -95,7 +93,7 @@ public class AwsEc2UnicastHostsProvider extends AbstractComponent implements Uni @Override public List buildDynamicNodes() { - List discoNodes = Lists.newArrayList(); + List discoNodes = new ArrayList<>(); DescribeInstancesResult descInstances; try { diff --git a/src/main/java/org/elasticsearch/plugin/cloud/aws/CloudAwsPlugin.java b/src/main/java/org/elasticsearch/plugin/cloud/aws/CloudAwsPlugin.java index 8d8438547ba..4d912530333 100644 --- a/src/main/java/org/elasticsearch/plugin/cloud/aws/CloudAwsPlugin.java +++ b/src/main/java/org/elasticsearch/plugin/cloud/aws/CloudAwsPlugin.java @@ -21,8 +21,6 @@ package org.elasticsearch.plugin.cloud.aws; import org.elasticsearch.cloud.aws.AwsEc2Service; import org.elasticsearch.cloud.aws.AwsModule; -import org.elasticsearch.cloud.aws.AwsS3Service; -import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.component.LifecycleComponent; import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.settings.Settings; @@ -31,6 +29,7 @@ import org.elasticsearch.repositories.RepositoriesModule; import org.elasticsearch.repositories.s3.S3Repository; import org.elasticsearch.repositories.s3.S3RepositoryModule; +import java.util.ArrayList; import java.util.Collection; /** @@ -56,7 +55,7 @@ public class CloudAwsPlugin extends AbstractPlugin { @Override public Collection modules(Settings settings) { - Collection modules = Lists.newArrayList(); + Collection modules = new ArrayList<>(); if (settings.getAsBoolean("cloud.enabled", true)) { modules.add(new AwsModule(settings)); } @@ -65,7 +64,7 @@ public class CloudAwsPlugin extends AbstractPlugin { @Override public Collection> services() { - Collection> services = Lists.newArrayList(); + Collection> services = new ArrayList<>(); if (settings.getAsBoolean("cloud.enabled", true)) { services.add(AwsModule.getS3ServiceClass(settings)); services.add(AwsEc2Service.class); diff --git a/src/test/java/org/elasticsearch/cloud/aws/blobstore/S3OutputStreamTest.java b/src/test/java/org/elasticsearch/cloud/aws/blobstore/S3OutputStreamTest.java index 668ba747cbc..5723f58a4ce 100644 --- a/src/test/java/org/elasticsearch/cloud/aws/blobstore/S3OutputStreamTest.java +++ b/src/test/java/org/elasticsearch/cloud/aws/blobstore/S3OutputStreamTest.java @@ -19,7 +19,6 @@ package org.elasticsearch.cloud.aws.blobstore; -import org.elasticsearch.common.base.Charsets; import org.elasticsearch.test.ElasticsearchTestCase; import org.junit.Test; @@ -40,7 +39,7 @@ public class S3OutputStreamTest extends ElasticsearchTestCase { @Test public void testWriteLessDataThanBufferSize() throws IOException { MockDefaultS3OutputStream out = newS3OutputStream(BUFFER_SIZE); - byte[] content = randomUnicodeOfLengthBetween(1, 512).getBytes(Charsets.UTF_8); + byte[] content = randomUnicodeOfLengthBetween(1, 512).getBytes("UTF-8"); copy(content, out); // Checks length & content