Don't use shaded APIs

This commit is contained in:
Robert Muir 2015-06-04 16:25:34 -04:00
parent 5390c01b1c
commit 2e103f6a1c
5 changed files with 21 additions and 24 deletions

View File

@ -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<String, BlobMetaData> listBlobsByPrefix(@Nullable String blobNamePrefix) throws IOException {
ImmutableMap.Builder<String, BlobMetaData> blobsBuilder = ImmutableMap.builder();
public Map<String, BlobMetaData> listBlobsByPrefix(@Nullable String blobNamePrefix) throws IOException {
MapBuilder<String, BlobMetaData> 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<String, BlobMetaData> listBlobs() throws IOException {
public Map<String, BlobMetaData> listBlobs() throws IOException {
return listBlobsByPrefix(null);
}

View File

@ -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<String, String> ec2Attributes = Maps.newHashMap();
Map<String, String> ec2Attributes = new HashMap<>();
URLConnection urlConnection;
InputStream in = null;

View File

@ -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<String> groups;
private final Set<String> groups;
private final ImmutableMap<String, String> tags;
private final Map<String, String> tags;
private final ImmutableSet<String> availabilityZones;
private final Set<String> 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<String> availabilityZones = Sets.newHashSet(settings.getAsArray("discovery.ec2.availability_zones"));
Set<String> 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<DiscoveryNode> buildDynamicNodes() {
List<DiscoveryNode> discoNodes = Lists.newArrayList();
List<DiscoveryNode> discoNodes = new ArrayList<>();
DescribeInstancesResult descInstances;
try {

View File

@ -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<Module> modules(Settings settings) {
Collection<Module> modules = Lists.newArrayList();
Collection<Module> 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<Class<? extends LifecycleComponent>> services() {
Collection<Class<? extends LifecycleComponent>> services = Lists.newArrayList();
Collection<Class<? extends LifecycleComponent>> services = new ArrayList<>();
if (settings.getAsBoolean("cloud.enabled", true)) {
services.add(AwsModule.getS3ServiceClass(settings));
services.add(AwsEc2Service.class);

View File

@ -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