diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/repositories/get/GetRepositoriesResponse.java b/src/main/java/org/elasticsearch/action/admin/cluster/repositories/get/GetRepositoriesResponse.java index 3064487ddd5..2d930309d02 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/repositories/get/GetRepositoriesResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/repositories/get/GetRepositoriesResponse.java @@ -28,6 +28,7 @@ import org.elasticsearch.common.settings.Settings; import java.io.IOException; import java.util.Iterator; +import java.util.List; /** * Get repositories response @@ -49,7 +50,7 @@ public class GetRepositoriesResponse extends ActionResponse implements Iterable< * * @return list or repositories */ - public ImmutableList repositories() { + public List repositories() { return repositories; } diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/get/GetSnapshotsResponse.java b/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/get/GetSnapshotsResponse.java index f0cedd9d1d7..71b8fa34a2a 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/get/GetSnapshotsResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/get/GetSnapshotsResponse.java @@ -29,6 +29,7 @@ import org.elasticsearch.common.xcontent.XContentBuilderString; import org.elasticsearch.snapshots.SnapshotInfo; import java.io.IOException; +import java.util.List; /** * Get snapshots response @@ -49,7 +50,7 @@ public class GetSnapshotsResponse extends ActionResponse implements ToXContent { * * @return the list of snapshots */ - public ImmutableList getSnapshots() { + public List getSnapshots() { return snapshots; } diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/get/TransportGetSnapshotsAction.java b/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/get/TransportGetSnapshotsAction.java index 6f480219857..96492fafbe3 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/get/TransportGetSnapshotsAction.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/get/TransportGetSnapshotsAction.java @@ -36,6 +36,8 @@ import org.elasticsearch.snapshots.SnapshotsService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.util.List; + /** * Transport Action for get snapshots operation */ @@ -69,12 +71,12 @@ public class TransportGetSnapshotsAction extends TransportMasterNodeAction snapshotInfoBuilder = ImmutableList.builder(); if (isAllSnapshots(request.snapshots())) { - ImmutableList snapshots = snapshotsService.snapshots(request.repository()); + List snapshots = snapshotsService.snapshots(request.repository()); for (Snapshot snapshot : snapshots) { snapshotInfoBuilder.add(new SnapshotInfo(snapshot)); } } else if (isCurrentSnapshots(request.snapshots())) { - ImmutableList snapshots = snapshotsService.currentSnapshots(request.repository()); + List snapshots = snapshotsService.currentSnapshots(request.repository()); for (Snapshot snapshot : snapshots) { snapshotInfoBuilder.add(new SnapshotInfo(snapshot)); } diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportSnapshotsStatusAction.java b/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportSnapshotsStatusAction.java index a38e894e90f..1964d688c8b 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportSnapshotsStatusAction.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportSnapshotsStatusAction.java @@ -41,6 +41,7 @@ import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import java.io.IOException; +import java.util.List; import java.util.Map; import java.util.Set; @@ -81,7 +82,7 @@ public class TransportSnapshotsStatusAction extends TransportMasterNodeAction listener) throws Exception { - ImmutableList currentSnapshots = snapshotsService.currentSnapshots(request.repository(), request.snapshots()); + List currentSnapshots = snapshotsService.currentSnapshots(request.repository(), request.snapshots()); if (currentSnapshots.isEmpty()) { listener.onResponse(buildResponse(request, currentSnapshots, null)); @@ -110,7 +111,7 @@ public class TransportSnapshotsStatusAction extends TransportMasterNodeAction currentSnapshots = + List currentSnapshots = snapshotsService.currentSnapshots(request.repository(), request.snapshots()); listener.onResponse(buildResponse(request, currentSnapshots, nodeSnapshotStatuses)); } catch (Throwable e) { @@ -130,7 +131,7 @@ public class TransportSnapshotsStatusAction extends TransportMasterNodeAction currentSnapshots, + private SnapshotsStatusResponse buildResponse(SnapshotsStatusRequest request, List currentSnapshots, TransportNodesSnapshotsStatus.NodesSnapshotStatus nodeSnapshotStatuses) throws IOException { // First process snapshot that are currently processed ImmutableList.Builder builder = ImmutableList.builder(); diff --git a/src/main/java/org/elasticsearch/client/transport/TransportClient.java b/src/main/java/org/elasticsearch/client/transport/TransportClient.java index d63e94d2ffe..c84d3692596 100644 --- a/src/main/java/org/elasticsearch/client/transport/TransportClient.java +++ b/src/main/java/org/elasticsearch/client/transport/TransportClient.java @@ -19,8 +19,6 @@ package org.elasticsearch.client.transport; -import com.google.common.collect.ImmutableList; - import org.elasticsearch.Version; import org.elasticsearch.action.Action; import org.elasticsearch.action.ActionListener; @@ -56,6 +54,7 @@ import org.elasticsearch.transport.TransportModule; import org.elasticsearch.transport.TransportService; import org.elasticsearch.transport.netty.NettyTransport; +import java.util.List; import java.util.concurrent.TimeUnit; import static org.elasticsearch.common.settings.Settings.settingsBuilder; @@ -180,7 +179,7 @@ public class TransportClient extends AbstractClient { * Returns the current registered transport addresses to use (added using * {@link #addTransportAddress(org.elasticsearch.common.transport.TransportAddress)}. */ - public ImmutableList transportAddresses() { + public List transportAddresses() { return nodesService.transportAddresses(); } @@ -190,7 +189,7 @@ public class TransportClient extends AbstractClient { *

The nodes include all the nodes that are currently alive based on the transport * addresses provided. */ - public ImmutableList connectedNodes() { + public List connectedNodes() { return nodesService.connectedNodes(); } @@ -198,14 +197,14 @@ public class TransportClient extends AbstractClient { * The list of filtered nodes that were not connected to, for example, due to * mismatch in cluster name. */ - public ImmutableList filteredNodes() { + public List filteredNodes() { return nodesService.filteredNodes(); } /** * Returns the listed nodes in the transport client (ones added to it). */ - public ImmutableList listedNodes() { + public List listedNodes() { return nodesService.listedNodes(); } diff --git a/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java b/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java index 44d6e0d7851..4ffc2abae2b 100644 --- a/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java +++ b/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java @@ -77,8 +77,8 @@ public class TransportClientNodesService extends AbstractComponent { private final Object mutex = new Object(); - private volatile ImmutableList nodes = ImmutableList.of(); - private volatile ImmutableList filteredNodes = ImmutableList.of(); + private volatile List nodes = ImmutableList.of(); + private volatile List filteredNodes = ImmutableList.of(); private final AtomicInteger tempNodeIdGenerator = new AtomicInteger(); @@ -118,7 +118,7 @@ public class TransportClientNodesService extends AbstractComponent { this.nodesSamplerFuture = threadPool.schedule(nodesSamplerInterval, ThreadPool.Names.GENERIC, new ScheduledNodeSampler()); } - public ImmutableList transportAddresses() { + public List transportAddresses() { ImmutableList.Builder lstBuilder = ImmutableList.builder(); for (DiscoveryNode listedNode : listedNodes) { lstBuilder.add(listedNode.address()); @@ -126,15 +126,15 @@ public class TransportClientNodesService extends AbstractComponent { return lstBuilder.build(); } - public ImmutableList connectedNodes() { + public List connectedNodes() { return this.nodes; } - public ImmutableList filteredNodes() { + public List filteredNodes() { return this.filteredNodes; } - public ImmutableList listedNodes() { + public List listedNodes() { return this.listedNodes; } @@ -193,7 +193,7 @@ public class TransportClientNodesService extends AbstractComponent { } public void execute(NodeListenerCallback callback, ActionListener listener) { - ImmutableList nodes = this.nodes; + List nodes = this.nodes; ensureNodesAreAvailable(nodes); int index = getNodeNumber(); RetryListener retryListener = new RetryListener<>(callback, listener, nodes, index); @@ -209,12 +209,12 @@ public class TransportClientNodesService extends AbstractComponent { public static class RetryListener implements ActionListener { private final NodeListenerCallback callback; private final ActionListener listener; - private final ImmutableList nodes; + private final List nodes; private final int index; private volatile int i; - public RetryListener(NodeListenerCallback callback, ActionListener listener, ImmutableList nodes, int index) { + public RetryListener(NodeListenerCallback callback, ActionListener listener, List nodes, int index) { this.callback = callback; this.listener = listener; this.nodes = nodes; @@ -274,7 +274,7 @@ public class TransportClientNodesService extends AbstractComponent { return index; } - private void ensureNodesAreAvailable(ImmutableList nodes) { + private void ensureNodesAreAvailable(List nodes) { if (nodes.isEmpty()) { String message = String.format(Locale.ROOT, "None of the configured nodes are available: %s", nodes); throw new NoNodeAvailableException(message); @@ -297,7 +297,7 @@ public class TransportClientNodesService extends AbstractComponent { * validates a set of potentially newly discovered nodes and returns an immutable * list of the nodes that has passed. */ - protected ImmutableList validateNewNodes(Set nodes) { + protected List validateNewNodes(Set nodes) { for (Iterator it = nodes.iterator(); it.hasNext(); ) { DiscoveryNode node = it.next(); if (!transportService.nodeConnected(node)) { diff --git a/src/main/java/org/elasticsearch/cluster/metadata/RestoreMetaData.java b/src/main/java/org/elasticsearch/cluster/metadata/RestoreMetaData.java index 51fd5e0514a..a0d562f06da 100644 --- a/src/main/java/org/elasticsearch/cluster/metadata/RestoreMetaData.java +++ b/src/main/java/org/elasticsearch/cluster/metadata/RestoreMetaData.java @@ -31,6 +31,7 @@ import org.elasticsearch.index.shard.ShardId; import java.io.IOException; import java.util.EnumSet; +import java.util.List; import java.util.Map; /** @@ -67,7 +68,7 @@ public class RestoreMetaData extends AbstractDiffable implement * * @return list of currently running restore processes */ - public ImmutableList entries() { + public List entries() { return this.entries; } diff --git a/src/main/java/org/elasticsearch/cluster/metadata/SnapshotMetaData.java b/src/main/java/org/elasticsearch/cluster/metadata/SnapshotMetaData.java index b23c58710a0..a161220e653 100644 --- a/src/main/java/org/elasticsearch/cluster/metadata/SnapshotMetaData.java +++ b/src/main/java/org/elasticsearch/cluster/metadata/SnapshotMetaData.java @@ -33,6 +33,7 @@ import org.elasticsearch.index.shard.ShardId; import java.io.IOException; import java.util.EnumSet; +import java.util.List; import java.util.Map; import static com.google.common.collect.Maps.newHashMap; @@ -319,7 +320,7 @@ public class SnapshotMetaData extends AbstractDiffable implements MetaDa this.entries = ImmutableList.copyOf(entries); } - public ImmutableList entries() { + public List entries() { return this.entries; } diff --git a/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java b/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java index 4d8b4b6bce0..1b95aed4636 100644 --- a/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java +++ b/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java @@ -508,7 +508,7 @@ public class DiscoveryNodes extends AbstractDiffable implements return !removed.isEmpty(); } - public ImmutableList removedNodes() { + public List removedNodes() { return removed; } @@ -516,7 +516,7 @@ public class DiscoveryNodes extends AbstractDiffable implements return !added.isEmpty(); } - public ImmutableList addedNodes() { + public List addedNodes() { return added; } diff --git a/src/main/java/org/elasticsearch/cluster/routing/IndexShardRoutingTable.java b/src/main/java/org/elasticsearch/cluster/routing/IndexShardRoutingTable.java index 2371b96f5b0..e76c8d924bc 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/IndexShardRoutingTable.java +++ b/src/main/java/org/elasticsearch/cluster/routing/IndexShardRoutingTable.java @@ -63,10 +63,10 @@ public class IndexShardRoutingTable implements Iterable { final boolean primaryAllocatedPostApi; - IndexShardRoutingTable(ShardId shardId, ImmutableList shards, boolean primaryAllocatedPostApi) { + IndexShardRoutingTable(ShardId shardId, List shards, boolean primaryAllocatedPostApi) { this.shardId = shardId; this.shuffler = new RotationShardShuffler(ThreadLocalRandom.current().nextInt()); - this.shards = shards; + this.shards = ImmutableList.copyOf(shards); this.primaryAllocatedPostApi = primaryAllocatedPostApi; ShardRouting primary = null; @@ -173,7 +173,7 @@ public class IndexShardRoutingTable implements Iterable { } @Override - public UnmodifiableIterator iterator() { + public Iterator iterator() { return shards.iterator(); } @@ -192,56 +192,56 @@ public class IndexShardRoutingTable implements Iterable { } /** - * Returns a {@link ImmutableList} of shards + * Returns a {@link List} of shards * - * @return a {@link ImmutableList} of shards + * @return a {@link List} of shards */ - public ImmutableList shards() { + public List shards() { return this.shards; } /** - * Returns a {@link ImmutableList} of shards + * Returns a {@link List} of shards * - * @return a {@link ImmutableList} of shards + * @return a {@link List} of shards */ - public ImmutableList getShards() { + public List getShards() { return shards(); } /** - * Returns a {@link ImmutableList} of active shards + * Returns a {@link List} of active shards * - * @return a {@link ImmutableList} of shards + * @return a {@link List} of shards */ - public ImmutableList activeShards() { + public List activeShards() { return this.activeShards; } /** - * Returns a {@link ImmutableList} of active shards + * Returns a {@link List} of active shards * - * @return a {@link ImmutableList} of shards + * @return a {@link List} of shards */ - public ImmutableList getActiveShards() { + public List getActiveShards() { return activeShards(); } /** - * Returns a {@link ImmutableList} of assigned shards + * Returns a {@link List} of assigned shards * - * @return a {@link ImmutableList} of shards + * @return a {@link List} of shards */ - public ImmutableList assignedShards() { + public List assignedShards() { return this.assignedShards; } /** - * Returns a {@link ImmutableList} of assigned shards + * Returns a {@link List} of assigned shards * - * @return a {@link ImmutableList} of shards + * @return a {@link List} of shards */ - public ImmutableList getAssignedShards() { + public List getAssignedShards() { return this.assignedShards; } diff --git a/src/main/java/org/elasticsearch/common/blobstore/BlobContainer.java b/src/main/java/org/elasticsearch/common/blobstore/BlobContainer.java index b7ca80c5eb6..72630e6d955 100644 --- a/src/main/java/org/elasticsearch/common/blobstore/BlobContainer.java +++ b/src/main/java/org/elasticsearch/common/blobstore/BlobContainer.java @@ -24,6 +24,7 @@ import com.google.common.collect.ImmutableMap; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.util.Map; /** * @@ -59,12 +60,12 @@ public interface BlobContainer { /** * Lists all blobs in the container */ - ImmutableMap listBlobs() throws IOException; + Map listBlobs() throws IOException; /** * Lists all blobs in the container that match specified prefix */ - ImmutableMap listBlobsByPrefix(String blobNamePrefix) throws IOException; + Map listBlobsByPrefix(String blobNamePrefix) throws IOException; /** * Atomically renames source blob into target blob diff --git a/src/main/java/org/elasticsearch/common/blobstore/support/AbstractBlobContainer.java b/src/main/java/org/elasticsearch/common/blobstore/support/AbstractBlobContainer.java index 7d898eabc84..01ad86133aa 100644 --- a/src/main/java/org/elasticsearch/common/blobstore/support/AbstractBlobContainer.java +++ b/src/main/java/org/elasticsearch/common/blobstore/support/AbstractBlobContainer.java @@ -25,6 +25,7 @@ import org.elasticsearch.common.blobstore.BlobMetaData; import org.elasticsearch.common.blobstore.BlobPath; import java.io.IOException; +import java.util.Map; /** * @@ -44,7 +45,7 @@ public abstract class AbstractBlobContainer implements BlobContainer { @Override public void deleteBlobsByPrefix(final String blobNamePrefix) throws IOException { - ImmutableMap blobs = listBlobsByPrefix(blobNamePrefix); + Map blobs = listBlobsByPrefix(blobNamePrefix); for (BlobMetaData blob : blobs.values()) { deleteBlob(blob.name()); } diff --git a/src/main/java/org/elasticsearch/common/util/CollectionUtils.java b/src/main/java/org/elasticsearch/common/util/CollectionUtils.java index de5171d50dc..7421a4ca16d 100644 --- a/src/main/java/org/elasticsearch/common/util/CollectionUtils.java +++ b/src/main/java/org/elasticsearch/common/util/CollectionUtils.java @@ -24,13 +24,17 @@ import com.carrotsearch.hppc.FloatArrayList; import com.carrotsearch.hppc.LongArrayList; import com.carrotsearch.hppc.ObjectArrayList; import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Iterators; +import com.google.common.collect.Lists; import org.apache.lucene.util.*; +import org.elasticsearch.common.inject.Module; import java.util.*; /** Collections-related utility methods. */ public enum CollectionUtils { - ; + CollectionUtils; public static void sort(LongArrayList list) { sort(list.buffer, list.size()); @@ -357,5 +361,15 @@ public enum CollectionUtils { } + /** + * Combines multiple iterators into a single iterator. + */ + public static Iterator concat(Iterator... iterators) { + return Iterators.concat(iterators); + } + + public static ArrayList newArrayList(E... elements) { + return Lists.newArrayList(elements); + } } diff --git a/src/main/java/org/elasticsearch/index/analysis/Analysis.java b/src/main/java/org/elasticsearch/index/analysis/Analysis.java index 9570372c5ac..322d7c0ea07 100644 --- a/src/main/java/org/elasticsearch/index/analysis/Analysis.java +++ b/src/main/java/org/elasticsearch/index/analysis/Analysis.java @@ -152,7 +152,7 @@ public class Analysis { .put("_turkish_", TurkishAnalyzer.getDefaultStopSet()) .immutableMap(); - public static CharArraySet parseWords(Environment env, Settings settings, String name, CharArraySet defaultWords, ImmutableMap> namedWords, boolean ignoreCase) { + public static CharArraySet parseWords(Environment env, Settings settings, String name, CharArraySet defaultWords, Map> namedWords, boolean ignoreCase) { String value = settings.get(name); if (value != null) { if ("_none_".equals(value)) { @@ -184,7 +184,7 @@ public class Analysis { return parseWords(env, settings, "stopwords", defaultStopWords, namedStopWords, ignoreCase); } - private static CharArraySet resolveNamedWords(Collection words, ImmutableMap> namedWords, boolean ignoreCase) { + private static CharArraySet resolveNamedWords(Collection words, Map> namedWords, boolean ignoreCase) { if (namedWords == null) { return new CharArraySet(words, ignoreCase); } diff --git a/src/main/java/org/elasticsearch/index/gateway/CommitPoint.java b/src/main/java/org/elasticsearch/index/gateway/CommitPoint.java index d5ec4fbb40f..c7203850ba1 100644 --- a/src/main/java/org/elasticsearch/index/gateway/CommitPoint.java +++ b/src/main/java/org/elasticsearch/index/gateway/CommitPoint.java @@ -105,11 +105,11 @@ public class CommitPoint { return this.type; } - public ImmutableList indexFiles() { + public List indexFiles() { return this.indexFiles; } - public ImmutableList translogFiles() { + public List translogFiles() { return this.translogFiles; } diff --git a/src/main/java/org/elasticsearch/index/gateway/CommitPoints.java b/src/main/java/org/elasticsearch/index/gateway/CommitPoints.java index a056a7ccc37..5ad4babd2dc 100644 --- a/src/main/java/org/elasticsearch/index/gateway/CommitPoints.java +++ b/src/main/java/org/elasticsearch/index/gateway/CommitPoints.java @@ -49,7 +49,7 @@ public class CommitPoints implements Iterable { this.commitPoints = ImmutableList.copyOf(commitPoints); } - public ImmutableList commits() { + public List commits() { return this.commitPoints; } diff --git a/src/main/java/org/elasticsearch/index/mapper/DocumentParser.java b/src/main/java/org/elasticsearch/index/mapper/DocumentParser.java index d07457602b2..c1dead0bb3e 100644 --- a/src/main/java/org/elasticsearch/index/mapper/DocumentParser.java +++ b/src/main/java/org/elasticsearch/index/mapper/DocumentParser.java @@ -43,6 +43,7 @@ import org.elasticsearch.index.mapper.object.RootObjectMapper; import java.io.Closeable; import java.io.IOException; import java.util.Collections; +import java.util.List; import java.util.Map; import java.util.Set; @@ -598,7 +599,7 @@ class DocumentParser implements Closeable { } /** Creates instances of the fields that the current field should be copied to */ - private static void parseCopyFields(ParseContext context, FieldMapper fieldMapper, ImmutableList copyToFields) throws IOException { + private static void parseCopyFields(ParseContext context, FieldMapper fieldMapper, List copyToFields) throws IOException { if (!context.isWithinCopyTo() && copyToFields.isEmpty() == false) { context = context.createCopyToContext(); for (String field : copyToFields) { diff --git a/src/main/java/org/elasticsearch/index/mapper/core/AbstractFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/AbstractFieldMapper.java index db0be598d91..5182ea23a8d 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/AbstractFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/AbstractFieldMapper.java @@ -891,7 +891,7 @@ public abstract class AbstractFieldMapper implements FieldMapper { } } - public ImmutableList copyToFields() { + public List copyToFields() { return copyToFields; } } diff --git a/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardRepository.java b/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardRepository.java index d498119c5fa..572cda21d09 100644 --- a/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardRepository.java +++ b/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardRepository.java @@ -318,7 +318,7 @@ public class BlobStoreIndexShardRepository extends AbstractComponent implements * Delete shard snapshot */ public void delete() { - final ImmutableMap blobs; + final Map blobs; try { blobs = blobContainer.listBlobs(); } catch (IOException e) { @@ -372,7 +372,7 @@ public class BlobStoreIndexShardRepository extends AbstractComponent implements * @param fileListGeneration the generation number of the snapshot index file * @param blobs list of blobs in the container */ - protected void finalize(List snapshots, int fileListGeneration, ImmutableMap blobs) { + protected void finalize(List snapshots, int fileListGeneration, Map blobs) { BlobStoreIndexShardSnapshots newSnapshots = new BlobStoreIndexShardSnapshots(snapshots); // delete old index files first for (String blobName : blobs.keySet()) { @@ -437,7 +437,7 @@ public class BlobStoreIndexShardRepository extends AbstractComponent implements * @param blobs list of blobs in the repository * @return next available blob number */ - protected long findLatestFileNameGeneration(ImmutableMap blobs) { + protected long findLatestFileNameGeneration(Map blobs) { long generation = -1; for (String name : blobs.keySet()) { if (!name.startsWith(DATA_BLOB_PREFIX)) { @@ -462,7 +462,7 @@ public class BlobStoreIndexShardRepository extends AbstractComponent implements * @param blobs list of blobs in repository * @return tuple of BlobStoreIndexShardSnapshots and the last snapshot index generation */ - protected Tuple buildBlobStoreIndexShardSnapshots(ImmutableMap blobs) { + protected Tuple buildBlobStoreIndexShardSnapshots(Map blobs) { int latest = -1; for (String name : blobs.keySet()) { if (name.startsWith(SNAPSHOT_INDEX_PREFIX)) { @@ -538,7 +538,7 @@ public class BlobStoreIndexShardRepository extends AbstractComponent implements logger.debug("[{}] [{}] snapshot to [{}] ...", shardId, snapshotId, repositoryName); store.incRef(); try { - final ImmutableMap blobs; + final Map blobs; try { blobs = blobContainer.listBlobs(); } catch (IOException e) { @@ -570,7 +570,7 @@ public class BlobStoreIndexShardRepository extends AbstractComponent implements logger.trace("[{}] [{}] Processing [{}]", shardId, snapshotId, fileName); final StoreFileMetaData md = metadata.get(fileName); FileInfo existingFileInfo = null; - ImmutableList filesInfo = snapshots.findPhysicalIndexFiles(fileName); + List filesInfo = snapshots.findPhysicalIndexFiles(fileName); if (filesInfo != null) { for (FileInfo fileInfo : filesInfo) { try { @@ -696,7 +696,7 @@ public class BlobStoreIndexShardRepository extends AbstractComponent implements * @param blobs list of blobs * @return true if file exists in the list of blobs */ - private boolean snapshotFileExistsInBlobs(BlobStoreIndexShardSnapshot.FileInfo fileInfo, ImmutableMap blobs) { + private boolean snapshotFileExistsInBlobs(BlobStoreIndexShardSnapshot.FileInfo fileInfo, Map blobs) { BlobMetaData blobMetaData = blobs.get(fileInfo.name()); if (blobMetaData != null) { return blobMetaData.length() == fileInfo.length(); diff --git a/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshot.java b/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshot.java index e2acff96f57..475031aefc8 100644 --- a/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshot.java +++ b/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshot.java @@ -364,7 +364,7 @@ public class BlobStoreIndexShardSnapshot { * * @return list of files */ - public ImmutableList indexFiles() { + public List indexFiles() { return indexFiles; } diff --git a/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshots.java b/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshots.java index 11a8689bb26..907d23d19b7 100644 --- a/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshots.java +++ b/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshots.java @@ -108,7 +108,7 @@ public class BlobStoreIndexShardSnapshots implements Iterable, To * * @return list of snapshots */ - public ImmutableList snapshots() { + public List snapshots() { return this.shardSnapshots; } @@ -118,7 +118,7 @@ public class BlobStoreIndexShardSnapshots implements Iterable, To * @param physicalName original name * @return a list of file infos that match specified physical file or null if the file is not present in any of snapshots */ - public ImmutableList findPhysicalIndexFiles(String physicalName) { + public List findPhysicalIndexFiles(String physicalName) { return physicalFiles.get(physicalName); } diff --git a/src/main/java/org/elasticsearch/index/snapshots/blobstore/SnapshotFiles.java b/src/main/java/org/elasticsearch/index/snapshots/blobstore/SnapshotFiles.java index 0dad85d2d54..aa265f17fbd 100644 --- a/src/main/java/org/elasticsearch/index/snapshots/blobstore/SnapshotFiles.java +++ b/src/main/java/org/elasticsearch/index/snapshots/blobstore/SnapshotFiles.java @@ -21,6 +21,7 @@ package org.elasticsearch.index.snapshots.blobstore; import com.google.common.collect.ImmutableList; import org.elasticsearch.index.snapshots.blobstore.BlobStoreIndexShardSnapshot.FileInfo; +import java.util.List; import java.util.Map; import static com.google.common.collect.Maps.newHashMap; @@ -32,7 +33,7 @@ public class SnapshotFiles { private final String snapshot; - private final ImmutableList indexFiles; + private final List indexFiles; private Map physicalFiles = null; @@ -40,7 +41,7 @@ public class SnapshotFiles { return snapshot; } - public SnapshotFiles(String snapshot, ImmutableList indexFiles ) { + public SnapshotFiles(String snapshot, List indexFiles ) { this.snapshot = snapshot; this.indexFiles = indexFiles; } @@ -48,7 +49,7 @@ public class SnapshotFiles { /** * Returns a list of file in the snapshot */ - public ImmutableList indexFiles() { + public List indexFiles() { return indexFiles; } diff --git a/src/main/java/org/elasticsearch/plugins/PluginsService.java b/src/main/java/org/elasticsearch/plugins/PluginsService.java index 42146d6c26b..5929de5f092 100644 --- a/src/main/java/org/elasticsearch/plugins/PluginsService.java +++ b/src/main/java/org/elasticsearch/plugins/PluginsService.java @@ -415,7 +415,7 @@ public class PluginsService extends AbstractComponent { } } - private ImmutableList> loadPluginsFromClasspath(Settings settings) { + private List> loadPluginsFromClasspath(Settings settings) { ImmutableList.Builder> plugins = ImmutableList.builder(); // Trying JVM plugins: looking for es-plugin.properties files diff --git a/src/main/java/org/elasticsearch/repositories/Repository.java b/src/main/java/org/elasticsearch/repositories/Repository.java index cced4040648..f2d2386bbfb 100644 --- a/src/main/java/org/elasticsearch/repositories/Repository.java +++ b/src/main/java/org/elasticsearch/repositories/Repository.java @@ -26,6 +26,7 @@ import org.elasticsearch.snapshots.Snapshot; import org.elasticsearch.snapshots.SnapshotShardFailure; import java.io.IOException; +import java.util.List; /** * Snapshot repository interface. @@ -36,7 +37,7 @@ import java.io.IOException; *

* Typical snapshot usage pattern: *

    - *
  • Master calls {@link #initializeSnapshot(org.elasticsearch.cluster.metadata.SnapshotId, com.google.common.collect.ImmutableList, org.elasticsearch.cluster.metadata.MetaData)} + *
  • Master calls {@link #initializeSnapshot(org.elasticsearch.cluster.metadata.SnapshotId, List, org.elasticsearch.cluster.metadata.MetaData)} * with list of indices that will be included into the snapshot
  • *
  • Data nodes call {@link org.elasticsearch.index.snapshots.IndexShardRepository#snapshot(org.elasticsearch.cluster.metadata.SnapshotId, org.elasticsearch.index.shard.ShardId, org.elasticsearch.index.deletionpolicy.SnapshotIndexCommit, org.elasticsearch.index.snapshots.IndexShardSnapshotStatus)} for each shard
  • *
  • When all shard calls return master calls {@link #finalizeSnapshot} @@ -62,14 +63,14 @@ public interface Repository extends LifecycleComponent { * @param indices list of indices * @return information about snapshot */ - MetaData readSnapshotMetaData(SnapshotId snapshotId, ImmutableList indices) throws IOException; + MetaData readSnapshotMetaData(SnapshotId snapshotId, List indices) throws IOException; /** * Returns the list of snapshots currently stored in the repository * * @return snapshot list */ - ImmutableList snapshots(); + List snapshots(); /** * Starts snapshotting process @@ -78,7 +79,7 @@ public interface Repository extends LifecycleComponent { * @param indices list of indices to be snapshotted * @param metaData cluster metadata */ - void initializeSnapshot(SnapshotId snapshotId, ImmutableList indices, MetaData metaData); + void initializeSnapshot(SnapshotId snapshotId, List indices, MetaData metaData); /** * Finalizes snapshotting process @@ -91,7 +92,7 @@ public interface Repository extends LifecycleComponent { * @param shardFailures list of shard failures * @return snapshot description */ - Snapshot finalizeSnapshot(SnapshotId snapshotId, ImmutableList indices, long startTime, String failure, int totalShards, ImmutableList shardFailures); + Snapshot finalizeSnapshot(SnapshotId snapshotId, List indices, long startTime, String failure, int totalShards, List shardFailures); /** * Deletes snapshot diff --git a/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java b/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java index a505b4b5493..d08d6fbcb87 100644 --- a/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java +++ b/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java @@ -75,6 +75,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.nio.file.NoSuchFileException; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Map; @@ -235,7 +236,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent indices, MetaData metaData) { + public void initializeSnapshot(SnapshotId snapshotId, List indices, MetaData metaData) { try { String snapshotBlobName = snapshotBlobName(snapshotId); if (snapshotsBlobContainer.blobExists(snapshotBlobName)) { @@ -268,7 +269,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent indices = ImmutableList.of(); + List indices = Collections.EMPTY_LIST; try { indices = readSnapshot(snapshotId).indices(); } catch (SnapshotMissingException ex) { @@ -288,7 +289,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent snapshotIds = snapshots(); + List snapshotIds = snapshots(); if (snapshotIds.contains(snapshotId)) { ImmutableList.Builder builder = ImmutableList.builder(); for (SnapshotId id : snapshotIds) { @@ -352,7 +353,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent indices, long startTime, String failure, int totalShards, ImmutableList shardFailures) { + public Snapshot finalizeSnapshot(SnapshotId snapshotId, List indices, long startTime, String failure, int totalShards, List shardFailures) { try { String tempBlobName = tempSnapshotBlobName(snapshotId); String blobName = snapshotBlobName(snapshotId); @@ -361,7 +362,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent snapshotIds = snapshots(); + List snapshotIds = snapshots(); if (!snapshotIds.contains(snapshotId)) { snapshotIds = ImmutableList.builder().addAll(snapshotIds).add(snapshotId).build(); } @@ -376,10 +377,10 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent snapshots() { + public List snapshots() { try { List snapshots = newArrayList(); - ImmutableMap blobs; + Map blobs; try { blobs = snapshotsBlobContainer.listBlobsByPrefix(SNAPSHOT_PREFIX); } catch (UnsupportedOperationException ex) { @@ -401,7 +402,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent indices) throws IOException { + public MetaData readSnapshotMetaData(SnapshotId snapshotId, List indices) throws IOException { return readSnapshotMetaData(snapshotId, indices, false); } @@ -421,7 +422,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent indices, boolean ignoreIndexErrors) throws IOException { + private MetaData readSnapshotMetaData(SnapshotId snapshotId, List indices, boolean ignoreIndexErrors) throws IOException { MetaData metaData; try (InputStream blob = snapshotsBlobContainer.openInput(metaDataBlobName(snapshotId))) { byte[] data = ByteStreams.toByteArray(blob); @@ -597,7 +598,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent snapshots) throws IOException { + protected void writeSnapshotList(List snapshots) throws IOException { BytesStreamOutput bStream = new BytesStreamOutput(); StreamOutput stream = compressIfNeeded(bStream); XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON, stream); @@ -623,7 +624,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent readSnapshotList() throws IOException { + protected List readSnapshotList() throws IOException { try (InputStream blob = snapshotsBlobContainer.openInput(SNAPSHOTS_FILE)) { final byte[] data = ByteStreams.toByteArray(blob); ArrayList snapshots = new ArrayList<>(); diff --git a/src/main/java/org/elasticsearch/repositories/uri/URLRepository.java b/src/main/java/org/elasticsearch/repositories/uri/URLRepository.java index 093c9b58667..c2db2391703 100644 --- a/src/main/java/org/elasticsearch/repositories/uri/URLRepository.java +++ b/src/main/java/org/elasticsearch/repositories/uri/URLRepository.java @@ -33,6 +33,7 @@ import org.elasticsearch.repositories.blobstore.BlobStoreRepository; import java.io.IOException; import java.net.URL; +import java.util.List; /** * Read-only URL-based implementation of the BlobStoreRepository @@ -90,7 +91,7 @@ public class URLRepository extends BlobStoreRepository { } @Override - public ImmutableList snapshots() { + public List snapshots() { if (listDirectories) { return super.snapshots(); } else { diff --git a/src/main/java/org/elasticsearch/snapshots/RestoreInfo.java b/src/main/java/org/elasticsearch/snapshots/RestoreInfo.java index b6ac2396539..548a8d2a55b 100644 --- a/src/main/java/org/elasticsearch/snapshots/RestoreInfo.java +++ b/src/main/java/org/elasticsearch/snapshots/RestoreInfo.java @@ -28,6 +28,7 @@ import org.elasticsearch.common.xcontent.XContentBuilderString; import org.elasticsearch.rest.RestStatus; import java.io.IOException; +import java.util.List; /** * Information about successfully completed restore operation. @@ -69,7 +70,7 @@ public class RestoreInfo implements ToXContent, Streamable { * * @return list of restored indices */ - public ImmutableList indices() { + public List indices() { return indices; } diff --git a/src/main/java/org/elasticsearch/snapshots/RestoreService.java b/src/main/java/org/elasticsearch/snapshots/RestoreService.java index 9f814acfcb8..9f880365c1d 100644 --- a/src/main/java/org/elasticsearch/snapshots/RestoreService.java +++ b/src/main/java/org/elasticsearch/snapshots/RestoreService.java @@ -156,7 +156,7 @@ public class RestoreService extends AbstractComponent implements ClusterStateLis Repository repository = repositoriesService.repository(request.repository()); final SnapshotId snapshotId = new SnapshotId(request.repository(), request.name()); final Snapshot snapshot = repository.readSnapshot(snapshotId); - ImmutableList filteredIndices = SnapshotUtils.filterIndices(snapshot.indices(), request.indices(), request.indicesOptions()); + List filteredIndices = SnapshotUtils.filterIndices(snapshot.indices(), request.indices(), request.indicesOptions()); MetaData metaDataIn = repository.readSnapshotMetaData(snapshotId, filteredIndices); final MetaData metaData; @@ -658,7 +658,7 @@ public class RestoreService extends AbstractComponent implements ClusterStateLis return failedShards; } - private Map renamedIndices(RestoreRequest request, ImmutableList filteredIndices) { + private Map renamedIndices(RestoreRequest request, List filteredIndices) { Map renamedIndices = newHashMap(); for (String index : filteredIndices) { String renamedIndex = index; diff --git a/src/main/java/org/elasticsearch/snapshots/Snapshot.java b/src/main/java/org/elasticsearch/snapshots/Snapshot.java index 3feed76c5ff..01ef6a5ba0b 100644 --- a/src/main/java/org/elasticsearch/snapshots/Snapshot.java +++ b/src/main/java/org/elasticsearch/snapshots/Snapshot.java @@ -28,6 +28,7 @@ import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; import java.util.ArrayList; +import java.util.List; /** * Represent information about snapshot @@ -42,7 +43,7 @@ public class Snapshot implements Comparable, ToXContent { private final String reason; - private final ImmutableList indices; + private final List indices; private final long startTime; @@ -52,12 +53,12 @@ public class Snapshot implements Comparable, ToXContent { private final int successfulShards; - private final ImmutableList shardFailures; + private final List shardFailures; - private final static ImmutableList NO_FAILURES = ImmutableList.of(); + private final static List NO_FAILURES = ImmutableList.of(); - private Snapshot(String name, ImmutableList indices, SnapshotState state, String reason, Version version, long startTime, long endTime, - int totalShard, int successfulShards, ImmutableList shardFailures) { + private Snapshot(String name, List indices, SnapshotState state, String reason, Version version, long startTime, long endTime, + int totalShard, int successfulShards, List shardFailures) { assert name != null; assert indices != null; assert state != null; @@ -75,17 +76,17 @@ public class Snapshot implements Comparable, ToXContent { } - public Snapshot(String name, ImmutableList indices, long startTime) { + public Snapshot(String name, List indices, long startTime) { this(name, indices, SnapshotState.IN_PROGRESS, null, Version.CURRENT, startTime, 0L, 0, 0, NO_FAILURES); } - public Snapshot(String name, ImmutableList indices, long startTime, String reason, long endTime, - int totalShard, ImmutableList shardFailures) { + public Snapshot(String name, List indices, long startTime, String reason, long endTime, + int totalShard, List shardFailures) { this(name, indices, snapshotState(reason, shardFailures), reason, Version.CURRENT, startTime, endTime, totalShard, totalShard - shardFailures.size(), shardFailures); } - private static SnapshotState snapshotState(String reason, ImmutableList shardFailures) { + private static SnapshotState snapshotState(String reason, List shardFailures) { if (reason == null) { if (shardFailures.isEmpty()) { return SnapshotState.SUCCESS; @@ -138,7 +139,7 @@ public class Snapshot implements Comparable, ToXContent { * * @return list of indices */ - public ImmutableList indices() { + public List indices() { return indices; } @@ -183,7 +184,7 @@ public class Snapshot implements Comparable, ToXContent { /** * Returns shard failures */ - public ImmutableList shardFailures() { + public List shardFailures() { return shardFailures; } @@ -275,7 +276,7 @@ public class Snapshot implements Comparable, ToXContent { long endTime = 0; int totalShard = 0; int successfulShards = 0; - ImmutableList shardFailures = NO_FAILURES; + List shardFailures = NO_FAILURES; XContentParser.Token token = parser.currentToken(); if (token == XContentParser.Token.START_OBJECT) { diff --git a/src/main/java/org/elasticsearch/snapshots/SnapshotInfo.java b/src/main/java/org/elasticsearch/snapshots/SnapshotInfo.java index 1a280908f06..f07acb0acb5 100644 --- a/src/main/java/org/elasticsearch/snapshots/SnapshotInfo.java +++ b/src/main/java/org/elasticsearch/snapshots/SnapshotInfo.java @@ -19,6 +19,8 @@ package org.elasticsearch.snapshots; import java.io.IOException; +import java.util.List; + import org.elasticsearch.action.ShardOperationFailedException; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -44,7 +46,7 @@ public class SnapshotInfo implements ToXContent, Streamable { private String reason; - private ImmutableList indices; + private List indices; private long startTime; @@ -54,7 +56,7 @@ public class SnapshotInfo implements ToXContent, Streamable { private int successfulShards; - private ImmutableList shardFailures; + private List shardFailures; SnapshotInfo() { @@ -109,7 +111,7 @@ public class SnapshotInfo implements ToXContent, Streamable { * * @return list of indices */ - public ImmutableList indices() { + public List indices() { return indices; } @@ -165,7 +167,7 @@ public class SnapshotInfo implements ToXContent, Streamable { * * @return shard failures */ - public ImmutableList shardFailures() { + public List shardFailures() { return shardFailures; } diff --git a/src/main/java/org/elasticsearch/snapshots/SnapshotUtils.java b/src/main/java/org/elasticsearch/snapshots/SnapshotUtils.java index 3f1e23afa60..d65225ba0d0 100644 --- a/src/main/java/org/elasticsearch/snapshots/SnapshotUtils.java +++ b/src/main/java/org/elasticsearch/snapshots/SnapshotUtils.java @@ -25,6 +25,7 @@ import org.elasticsearch.index.Index; import org.elasticsearch.indices.IndexMissingException; import java.util.HashSet; +import java.util.List; import java.util.Set; /** @@ -40,7 +41,7 @@ public class SnapshotUtils { * @param indicesOptions ignore indices flag * @return filtered out indices */ - public static ImmutableList filterIndices(ImmutableList availableIndices, String[] selectedIndices, IndicesOptions indicesOptions) { + public static List filterIndices(List availableIndices, String[] selectedIndices, IndicesOptions indicesOptions) { if (selectedIndices == null || selectedIndices.length == 0) { return availableIndices; } diff --git a/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java b/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java index ae22fbfa055..aa8b34e83fc 100644 --- a/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java +++ b/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java @@ -80,7 +80,7 @@ import static com.google.common.collect.Sets.newHashSet; *
  • When cluster state is updated the {@link #beginSnapshot(ClusterState, SnapshotMetaData.Entry, boolean, CreateSnapshotListener)} method * kicks in and initializes the snapshot in the repository and then populates list of shards that needs to be snapshotted in cluster state
  • *
  • Each data node is watching for these shards and when new shards scheduled for snapshotting appear in the cluster state, data nodes - * start processing them through {@link #processIndexShardSnapshots(SnapshotMetaData)} method
  • + * start processing them through {@link SnapshotsService#processIndexShardSnapshots(ClusterChangedEvent)} method *
  • Once shard snapshot is created data node updates state of the shard in the cluster state using the {@link #updateIndexShardSnapshotStatus(UpdateIndexShardSnapshotStatusRequest)} method
  • *
  • When last shard is completed master node in {@link #innerUpdateSnapshotState} method marks the snapshot as completed
  • *
  • After cluster state is updated, the {@link #endSnapshot(SnapshotMetaData.Entry)} finalizes snapshot in the repository, @@ -135,7 +135,7 @@ public class SnapshotsService extends AbstractLifecycleComponent entries = currentSnapshots(snapshotId.getRepository(), new String[]{snapshotId.getSnapshot()}); + List entries = currentSnapshots(snapshotId.getRepository(), new String[]{snapshotId.getSnapshot()}); if (!entries.isEmpty()) { return inProgressSnapshot(entries.iterator().next()); } @@ -148,14 +148,14 @@ public class SnapshotsService extends AbstractLifecycleComponent snapshots(String repositoryName) { + public List snapshots(String repositoryName) { Set snapshotSet = newHashSet(); - ImmutableList entries = currentSnapshots(repositoryName, null); + List entries = currentSnapshots(repositoryName, null); for (SnapshotMetaData.Entry entry : entries) { snapshotSet.add(inProgressSnapshot(entry)); } Repository repository = repositoriesService.repository(repositoryName); - ImmutableList snapshotIds = repository.snapshots(); + List snapshotIds = repository.snapshots(); for (SnapshotId snapshotId : snapshotIds) { snapshotSet.add(repository.readSnapshot(snapshotId)); } @@ -170,9 +170,9 @@ public class SnapshotsService extends AbstractLifecycleComponent currentSnapshots(String repositoryName) { + public List currentSnapshots(String repositoryName) { List snapshotList = newArrayList(); - ImmutableList entries = currentSnapshots(repositoryName, null); + List entries = currentSnapshots(repositoryName, null); for (SnapshotMetaData.Entry entry : entries) { snapshotList.add(inProgressSnapshot(entry)); } @@ -421,7 +421,7 @@ public class SnapshotsService extends AbstractLifecycleComponent currentSnapshots(String repository, String[] snapshots) { + public List currentSnapshots(String repository, String[] snapshots) { MetaData metaData = clusterService.state().metaData(); SnapshotMetaData snapshotMetaData = metaData.custom(SnapshotMetaData.TYPE); if (snapshotMetaData == null || snapshotMetaData.entries().isEmpty()) { @@ -524,7 +524,7 @@ public class SnapshotsService extends AbstractLifecycleComponent shardFailures, ShardId shardId) { + private SnapshotShardFailure findShardFailure(List shardFailures, ShardId shardId) { for (SnapshotShardFailure shardFailure : shardFailures) { if (shardId.getIndex().equals(shardFailure.index()) && shardId.getId() == shardFailure.shardId()) { return shardFailure; diff --git a/src/test/java/org/elasticsearch/common/blobstore/BlobStoreTest.java b/src/test/java/org/elasticsearch/common/blobstore/BlobStoreTest.java index bcffd188b65..54def2b8660 100644 --- a/src/test/java/org/elasticsearch/common/blobstore/BlobStoreTest.java +++ b/src/test/java/org/elasticsearch/common/blobstore/BlobStoreTest.java @@ -90,7 +90,7 @@ public class BlobStoreTest extends ElasticsearchTestCase { generatedBlobs.put(name, (long) length); byte[] data = createRandomBlob(container, name, length); - ImmutableMap blobs = container.listBlobs(); + Map blobs = container.listBlobs(); assertThat(blobs.size(), equalTo(numberOfFooBlobs + numberOfBarBlobs)); for (Map.Entry generated : generatedBlobs.entrySet()) { BlobMetaData blobMetaData = blobs.get(generated.getKey()); diff --git a/src/test/java/org/elasticsearch/index/mapper/copyto/CopyToMapperTests.java b/src/test/java/org/elasticsearch/index/mapper/copyto/CopyToMapperTests.java index 19c25e07450..116bf9cfdfa 100644 --- a/src/test/java/org/elasticsearch/index/mapper/copyto/CopyToMapperTests.java +++ b/src/test/java/org/elasticsearch/index/mapper/copyto/CopyToMapperTests.java @@ -220,7 +220,7 @@ public class CopyToMapperTests extends ElasticsearchSingleNodeTest { DocumentMapperParser parser = createIndex("test").mapperService().documentMapperParser(); DocumentMapper docMapperBefore = parser.parse(mappingBefore); - ImmutableList fields = docMapperBefore.mappers().getMapper("copy_test").copyTo().copyToFields(); + List fields = docMapperBefore.mappers().getMapper("copy_test").copyTo().copyToFields(); assertThat(fields.size(), equalTo(2)); assertThat(fields.get(0), equalTo("foo")); diff --git a/src/test/java/org/elasticsearch/snapshots/AbstractSnapshotTests.java b/src/test/java/org/elasticsearch/snapshots/AbstractSnapshotTests.java index 024065a1d2f..a6a401b4a45 100644 --- a/src/test/java/org/elasticsearch/snapshots/AbstractSnapshotTests.java +++ b/src/test/java/org/elasticsearch/snapshots/AbstractSnapshotTests.java @@ -41,6 +41,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; +import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @@ -100,7 +101,7 @@ public abstract class AbstractSnapshotTests extends ElasticsearchIntegrationTest long start = System.currentTimeMillis(); SnapshotId snapshotId = new SnapshotId(repository, snapshot); while (System.currentTimeMillis() - start < timeout.millis()) { - ImmutableList snapshotInfos = client().admin().cluster().prepareGetSnapshots(repository).setSnapshots(snapshot).get().getSnapshots(); + List snapshotInfos = client().admin().cluster().prepareGetSnapshots(repository).setSnapshots(snapshot).get().getSnapshots(); assertThat(snapshotInfos.size(), equalTo(1)); if (snapshotInfos.get(0).state().completed()) { // Make sure that snapshot clean up operations are finished diff --git a/src/test/java/org/elasticsearch/snapshots/RepositoriesTests.java b/src/test/java/org/elasticsearch/snapshots/RepositoriesTests.java index 163ee868697..74e99c995a2 100644 --- a/src/test/java/org/elasticsearch/snapshots/RepositoriesTests.java +++ b/src/test/java/org/elasticsearch/snapshots/RepositoriesTests.java @@ -39,6 +39,7 @@ import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.junit.Test; import java.nio.file.Path; +import java.util.List; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertThrows; @@ -116,7 +117,7 @@ public class RepositoriesTests extends AbstractSnapshotTests { assertThat(repositoriesResponse.repositories().size(), equalTo(0)); } - private RepositoryMetaData findRepository(ImmutableList repositories, String name) { + private RepositoryMetaData findRepository(List repositories, String name) { for (RepositoryMetaData repository : repositories) { if (repository.name().equals(name)) { return repository; diff --git a/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreTests.java b/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreTests.java index d7df586988d..b9fb2bf1fe4 100644 --- a/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreTests.java +++ b/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreTests.java @@ -1135,7 +1135,7 @@ public class SharedClusterSnapshotRestoreTests extends AbstractSnapshotTests { logger.info("Number of failed shards [{}]", snapshotInfo.shardFailures().size()); logger.info("--> done"); - ImmutableList snapshotInfos = client().admin().cluster().prepareGetSnapshots("test-repo").setSnapshots("test-snap").get().getSnapshots(); + List snapshotInfos = client().admin().cluster().prepareGetSnapshots("test-repo").setSnapshots("test-snap").get().getSnapshots(); assertThat(snapshotInfos.size(), equalTo(1)); assertThat(snapshotInfos.get(0).state(), equalTo(SnapshotState.SUCCESS)); @@ -1218,7 +1218,7 @@ public class SharedClusterSnapshotRestoreTests extends AbstractSnapshotTests { logger.info("Number of failed shards [{}]", snapshotInfo.shardFailures().size()); logger.info("--> done"); - ImmutableList snapshotInfos = client().admin().cluster().prepareGetSnapshots("test-repo").setSnapshots("test-snap").get().getSnapshots(); + List snapshotInfos = client().admin().cluster().prepareGetSnapshots("test-repo").setSnapshots("test-snap").get().getSnapshots(); assertThat(snapshotInfos.size(), equalTo(1)); assertThat(snapshotInfos.get(0).state(), equalTo(SnapshotState.SUCCESS)); diff --git a/src/test/java/org/elasticsearch/snapshots/SnapshotUtilsTests.java b/src/test/java/org/elasticsearch/snapshots/SnapshotUtilsTests.java index 8304028f2bc..71957c5cc26 100644 --- a/src/test/java/org/elasticsearch/snapshots/SnapshotUtilsTests.java +++ b/src/test/java/org/elasticsearch/snapshots/SnapshotUtilsTests.java @@ -23,6 +23,8 @@ import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.test.ElasticsearchTestCase; import org.junit.Test; +import java.util.List; + import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsInAnyOrder; @@ -50,8 +52,8 @@ public class SnapshotUtilsTests extends ElasticsearchTestCase { } private void assertIndexNameFiltering(String[] indices, String[] filter, IndicesOptions indicesOptions, String[] expected) { - ImmutableList indicesList = ImmutableList.copyOf(indices); - ImmutableList actual = SnapshotUtils.filterIndices(indicesList, filter, indicesOptions); + List indicesList = ImmutableList.copyOf(indices); + List actual = SnapshotUtils.filterIndices(indicesList, filter, indicesOptions); assertThat(actual, containsInAnyOrder(expected)); } } diff --git a/src/test/java/org/elasticsearch/snapshots/mockstore/BlobContainerWrapper.java b/src/test/java/org/elasticsearch/snapshots/mockstore/BlobContainerWrapper.java index 9d80fa1fa7c..6ab2cdf782b 100644 --- a/src/test/java/org/elasticsearch/snapshots/mockstore/BlobContainerWrapper.java +++ b/src/test/java/org/elasticsearch/snapshots/mockstore/BlobContainerWrapper.java @@ -26,6 +26,7 @@ import org.elasticsearch.common.blobstore.BlobPath; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.util.Map; /** * @@ -68,12 +69,12 @@ public class BlobContainerWrapper implements BlobContainer { } @Override - public ImmutableMap listBlobs() throws IOException { + public Map listBlobs() throws IOException { return delegate.listBlobs(); } @Override - public ImmutableMap listBlobsByPrefix(String blobNamePrefix) throws IOException { + public Map listBlobsByPrefix(String blobNamePrefix) throws IOException { return delegate.listBlobsByPrefix(blobNamePrefix); } diff --git a/src/test/java/org/elasticsearch/snapshots/mockstore/MockRepository.java b/src/test/java/org/elasticsearch/snapshots/mockstore/MockRepository.java index e699ae2e100..12e51475c9d 100644 --- a/src/test/java/org/elasticsearch/snapshots/mockstore/MockRepository.java +++ b/src/test/java/org/elasticsearch/snapshots/mockstore/MockRepository.java @@ -46,6 +46,8 @@ import java.io.UnsupportedEncodingException; import java.nio.file.Path; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; +import java.util.List; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicLong; @@ -95,7 +97,7 @@ public class MockRepository extends FsRepository { } @Override - public void initializeSnapshot(SnapshotId snapshotId, ImmutableList indices, MetaData metaData) { + public void initializeSnapshot(SnapshotId snapshotId, List indices, MetaData metaData) { if (blockOnInitialization ) { blockExecution(); } @@ -292,13 +294,13 @@ public class MockRepository extends FsRepository { } @Override - public ImmutableMap listBlobs() throws IOException { + public Map listBlobs() throws IOException { maybeIOExceptionOrBlock(""); return super.listBlobs(); } @Override - public ImmutableMap listBlobsByPrefix(String blobNamePrefix) throws IOException { + public Map listBlobsByPrefix(String blobNamePrefix) throws IOException { maybeIOExceptionOrBlock(blobNamePrefix); return super.listBlobsByPrefix(blobNamePrefix); }