Merge pull request #13227 from jasontedor/immutable-lists-be-gone

Remove and forbid use of com.google.common.collect.ImmutableList
This commit is contained in:
Jason Tedor 2015-08-31 15:29:35 -04:00
commit aea00a62f3
115 changed files with 581 additions and 627 deletions

View File

@ -19,7 +19,6 @@
package org.elasticsearch.action.admin.cluster.health;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionResponse;
@ -39,6 +38,7 @@ import org.elasticsearch.rest.RestStatus;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
@ -270,7 +270,7 @@ public class ClusterHealthResponse extends ActionResponse implements Iterable<Cl
timedOut = in.readBoolean();
size = in.readVInt();
if (size == 0) {
validationFailures = ImmutableList.of();
validationFailures = Collections.emptyList();
} else {
for (int i = 0; i < size; i++) {
validationFailures.add(in.readString());

View File

@ -19,12 +19,10 @@
package org.elasticsearch.action.admin.cluster.health;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.routing.IndexRoutingTable;
import org.elasticsearch.cluster.routing.IndexShardRoutingTable;
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Streamable;
@ -33,6 +31,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilderString;
import java.io.IOException;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
@ -179,7 +178,7 @@ public class ClusterIndexHealth implements Iterable<ClusterShardHealth>, Streama
ClusterShardHealth shardHealth = readClusterShardHealth(in);
shards.put(shardHealth.getId(), shardHealth);
}
validationFailures = ImmutableList.copyOf(in.readStringArray());
validationFailures = Arrays.asList(in.readStringArray());
}
@Override

View File

@ -19,7 +19,6 @@
package org.elasticsearch.action.admin.cluster.repositories.get;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.cluster.metadata.RepositoryMetaData;
import org.elasticsearch.common.io.stream.StreamInput;
@ -27,6 +26,8 @@ import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.settings.Settings;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@ -35,13 +36,13 @@ import java.util.List;
*/
public class GetRepositoriesResponse extends ActionResponse implements Iterable<RepositoryMetaData> {
private ImmutableList<RepositoryMetaData> repositories = ImmutableList.of();
private List<RepositoryMetaData> repositories = Collections.emptyList();
GetRepositoriesResponse() {
}
GetRepositoriesResponse(ImmutableList<RepositoryMetaData> repositories) {
GetRepositoriesResponse(List<RepositoryMetaData> repositories) {
this.repositories = repositories;
}
@ -59,7 +60,7 @@ public class GetRepositoriesResponse extends ActionResponse implements Iterable<
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
int size = in.readVInt();
ImmutableList.Builder<RepositoryMetaData> repositoryListBuilder = ImmutableList.builder();
List<RepositoryMetaData> repositoryListBuilder = new ArrayList<>();
for (int j = 0; j < size; j++) {
repositoryListBuilder.add(new RepositoryMetaData(
in.readString(),
@ -67,7 +68,7 @@ public class GetRepositoriesResponse extends ActionResponse implements Iterable<
Settings.readSettingsFromStream(in))
);
}
repositories = repositoryListBuilder.build();
repositories = Collections.unmodifiableList(repositoryListBuilder);
}
@Override

View File

@ -19,7 +19,6 @@
package org.elasticsearch.action.admin.cluster.repositories.get;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.TransportMasterNodeReadAction;
@ -37,6 +36,10 @@ import org.elasticsearch.repositories.RepositoryMissingException;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Transport action for get repositories operation
*/
@ -71,11 +74,11 @@ public class TransportGetRepositoriesAction extends TransportMasterNodeReadActio
if (repositories != null) {
listener.onResponse(new GetRepositoriesResponse(repositories.repositories()));
} else {
listener.onResponse(new GetRepositoriesResponse(ImmutableList.<RepositoryMetaData>of()));
listener.onResponse(new GetRepositoriesResponse(Collections.<RepositoryMetaData>emptyList()));
}
} else {
if (repositories != null) {
ImmutableList.Builder<RepositoryMetaData> repositoryListBuilder = ImmutableList.builder();
List<RepositoryMetaData> repositoryListBuilder = new ArrayList<>();
for (String repository : request.repositories()) {
RepositoryMetaData repositoryMetaData = repositories.repository(repository);
if (repositoryMetaData == null) {
@ -84,7 +87,7 @@ public class TransportGetRepositoriesAction extends TransportMasterNodeReadActio
}
repositoryListBuilder.add(repositoryMetaData);
}
listener.onResponse(new GetRepositoriesResponse(repositoryListBuilder.build()));
listener.onResponse(new GetRepositoriesResponse(Collections.unmodifiableList(repositoryListBuilder)));
} else {
listener.onFailure(new RepositoryMissingException(request.repositories()[0]));
}

View File

@ -19,7 +19,6 @@
package org.elasticsearch.action.admin.cluster.snapshots.get;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
@ -29,6 +28,8 @@ import org.elasticsearch.common.xcontent.XContentBuilderString;
import org.elasticsearch.snapshots.SnapshotInfo;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
@ -36,12 +37,12 @@ import java.util.List;
*/
public class GetSnapshotsResponse extends ActionResponse implements ToXContent {
private ImmutableList<SnapshotInfo> snapshots = ImmutableList.of();
private List<SnapshotInfo> snapshots = Collections.emptyList();
GetSnapshotsResponse() {
}
GetSnapshotsResponse(ImmutableList<SnapshotInfo> snapshots) {
GetSnapshotsResponse(List<SnapshotInfo> snapshots) {
this.snapshots = snapshots;
}
@ -58,11 +59,11 @@ public class GetSnapshotsResponse extends ActionResponse implements ToXContent {
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
int size = in.readVInt();
ImmutableList.Builder<SnapshotInfo> builder = ImmutableList.builder();
List<SnapshotInfo> builder = new ArrayList<>();
for (int i = 0; i < size; i++) {
builder.add(SnapshotInfo.readSnapshotInfo(in));
}
snapshots = builder.build();
snapshots = Collections.unmodifiableList(builder);
}
@Override

View File

@ -19,7 +19,6 @@
package org.elasticsearch.action.admin.cluster.snapshots.get;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.TransportMasterNodeAction;
@ -37,6 +36,8 @@ import org.elasticsearch.snapshots.SnapshotsService;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
@ -71,7 +72,7 @@ public class TransportGetSnapshotsAction extends TransportMasterNodeAction<GetSn
@Override
protected void masterOperation(final GetSnapshotsRequest request, ClusterState state, final ActionListener<GetSnapshotsResponse> listener) {
try {
ImmutableList.Builder<SnapshotInfo> snapshotInfoBuilder = ImmutableList.builder();
List<SnapshotInfo> snapshotInfoBuilder = new ArrayList<>();
if (isAllSnapshots(request.snapshots())) {
List<Snapshot> snapshots = snapshotsService.snapshots(request.repository());
for (Snapshot snapshot : snapshots) {
@ -88,7 +89,7 @@ public class TransportGetSnapshotsAction extends TransportMasterNodeAction<GetSn
snapshotInfoBuilder.add(new SnapshotInfo(snapshotsService.snapshot(snapshotId)));
}
}
listener.onResponse(new GetSnapshotsResponse(snapshotInfoBuilder.build()));
listener.onResponse(new GetSnapshotsResponse(Collections.unmodifiableList(snapshotInfoBuilder)));
} catch (Throwable t) {
listener.onFailure(t);
}

View File

@ -19,7 +19,6 @@
package org.elasticsearch.action.admin.cluster.snapshots.status;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.elasticsearch.cluster.SnapshotsInProgress.State;
import org.elasticsearch.cluster.metadata.SnapshotId;
@ -33,6 +32,7 @@ import org.elasticsearch.common.xcontent.XContentFactory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -48,7 +48,7 @@ public class SnapshotStatus implements ToXContent, Streamable {
private State state;
private ImmutableList<SnapshotIndexShardStatus> shards;
private List<SnapshotIndexShardStatus> shards;
private ImmutableMap<String, SnapshotIndexStatus> indicesStatus;
@ -57,7 +57,7 @@ public class SnapshotStatus implements ToXContent, Streamable {
private SnapshotStats stats;
SnapshotStatus(SnapshotId snapshotId, State state, ImmutableList<SnapshotIndexShardStatus> shards) {
SnapshotStatus(SnapshotId snapshotId, State state, List<SnapshotIndexShardStatus> shards) {
this.snapshotId = snapshotId;
this.state = state;
this.shards = shards;
@ -127,11 +127,11 @@ public class SnapshotStatus implements ToXContent, Streamable {
snapshotId = SnapshotId.readSnapshotId(in);
state = State.fromValue(in.readByte());
int size = in.readVInt();
ImmutableList.Builder<SnapshotIndexShardStatus> builder = ImmutableList.builder();
List<SnapshotIndexShardStatus> builder = new ArrayList<>();
for (int i = 0; i < size; i++) {
builder.add(SnapshotIndexShardStatus.readShardSnapshotStatus(in));
}
shards = builder.build();
shards = Collections.unmodifiableList(builder);
updateShardStats();
}

View File

@ -19,7 +19,6 @@
package org.elasticsearch.action.admin.cluster.snapshots.status;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
@ -28,18 +27,21 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilderString;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Snapshot status response
*/
public class SnapshotsStatusResponse extends ActionResponse implements ToXContent {
private ImmutableList<SnapshotStatus> snapshots = ImmutableList.of();
private List<SnapshotStatus> snapshots = Collections.emptyList();
SnapshotsStatusResponse() {
}
SnapshotsStatusResponse(ImmutableList<SnapshotStatus> snapshots) {
SnapshotsStatusResponse(List<SnapshotStatus> snapshots) {
this.snapshots = snapshots;
}
@ -48,7 +50,7 @@ public class SnapshotsStatusResponse extends ActionResponse implements ToXConten
*
* @return the list of snapshots
*/
public ImmutableList<SnapshotStatus> getSnapshots() {
public List<SnapshotStatus> getSnapshots() {
return snapshots;
}
@ -56,11 +58,11 @@ public class SnapshotsStatusResponse extends ActionResponse implements ToXConten
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
int size = in.readVInt();
ImmutableList.Builder<SnapshotStatus> builder = ImmutableList.builder();
List<SnapshotStatus> builder = new ArrayList<>();
for (int i = 0; i < size; i++) {
builder.add(SnapshotStatus.readSnapshotStatus(in));
}
snapshots = builder.build();
snapshots = Collections.unmodifiableList(builder);
}
@Override

View File

@ -19,7 +19,6 @@
package org.elasticsearch.action.admin.cluster.snapshots.status;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
@ -42,6 +41,8 @@ import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -138,7 +139,7 @@ public class TransportSnapshotsStatusAction extends TransportMasterNodeAction<Sn
private SnapshotsStatusResponse buildResponse(SnapshotsStatusRequest request, List<SnapshotsInProgress.Entry> currentSnapshots,
TransportNodesSnapshotsStatus.NodesSnapshotStatus nodeSnapshotStatuses) throws IOException {
// First process snapshot that are currently processed
ImmutableList.Builder<SnapshotStatus> builder = ImmutableList.builder();
List<SnapshotStatus> builder = new ArrayList<>();
Set<SnapshotId> currentSnapshotIds = newHashSet();
if (!currentSnapshots.isEmpty()) {
Map<String, TransportNodesSnapshotsStatus.NodeSnapshotStatus> nodeSnapshotStatusMap;
@ -150,7 +151,7 @@ public class TransportSnapshotsStatusAction extends TransportMasterNodeAction<Sn
for (SnapshotsInProgress.Entry entry : currentSnapshots) {
currentSnapshotIds.add(entry.snapshotId());
ImmutableList.Builder<SnapshotIndexShardStatus> shardStatusBuilder = ImmutableList.builder();
List<SnapshotIndexShardStatus> shardStatusBuilder = new ArrayList<>();
for (ImmutableMap.Entry<ShardId, SnapshotsInProgress.ShardSnapshotStatus> shardEntry : entry.shards().entrySet()) {
SnapshotsInProgress.ShardSnapshotStatus status = shardEntry.getValue();
if (status.nodeId() != null) {
@ -189,7 +190,7 @@ public class TransportSnapshotsStatusAction extends TransportMasterNodeAction<Sn
SnapshotIndexShardStatus shardStatus = new SnapshotIndexShardStatus(shardEntry.getKey(), stage);
shardStatusBuilder.add(shardStatus);
}
builder.add(new SnapshotStatus(entry.snapshotId(), entry.state(), shardStatusBuilder.build()));
builder.add(new SnapshotStatus(entry.snapshotId(), entry.state(), Collections.unmodifiableList(shardStatusBuilder)));
}
}
// Now add snapshots on disk that are not currently running
@ -202,7 +203,7 @@ public class TransportSnapshotsStatusAction extends TransportMasterNodeAction<Sn
continue;
}
Snapshot snapshot = snapshotsService.snapshot(snapshotId);
ImmutableList.Builder<SnapshotIndexShardStatus> shardStatusBuilder = ImmutableList.builder();
List<SnapshotIndexShardStatus> shardStatusBuilder = new ArrayList<>();
if (snapshot.state().completed()) {
ImmutableMap<ShardId, IndexShardSnapshotStatus> shardStatues = snapshotsService.snapshotShards(snapshotId);
for (ImmutableMap.Entry<ShardId, IndexShardSnapshotStatus> shardStatus : shardStatues.entrySet()) {
@ -222,13 +223,13 @@ public class TransportSnapshotsStatusAction extends TransportMasterNodeAction<Sn
default:
throw new IllegalArgumentException("Unknown snapshot state " + snapshot.state());
}
builder.add(new SnapshotStatus(snapshotId, state, shardStatusBuilder.build()));
builder.add(new SnapshotStatus(snapshotId, state, Collections.unmodifiableList(shardStatusBuilder)));
}
}
}
}
return new SnapshotsStatusResponse(builder.build());
return new SnapshotsStatusResponse(Collections.unmodifiableList(builder));
}
}

View File

@ -20,7 +20,6 @@
package org.elasticsearch.action.admin.indices.alias;
import com.carrotsearch.hppc.cursors.ObjectCursor;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.AliasesRequest;
import org.elasticsearch.action.CompositeIndicesRequest;
@ -179,9 +178,9 @@ public class IndicesAliasesRequest extends AcknowledgedRequest<IndicesAliasesReq
if (expandAliasesWildcards()) {
//for DELETE we expand the aliases
String[] indexAsArray = {concreteIndex};
ImmutableOpenMap<String, ImmutableList<AliasMetaData>> aliasMetaData = metaData.findAliases(aliases, indexAsArray);
ImmutableOpenMap<String, List<AliasMetaData>> aliasMetaData = metaData.findAliases(aliases, indexAsArray);
List<String> finalAliases = new ArrayList<>();
for (ObjectCursor<ImmutableList<AliasMetaData>> curAliases : aliasMetaData.values()) {
for (ObjectCursor<List<AliasMetaData>> curAliases : aliasMetaData.values()) {
for (AliasMetaData aliasMeta: curAliases.value) {
finalAliases.add(aliasMeta.alias());
}

View File

@ -20,7 +20,6 @@
package org.elasticsearch.action.admin.indices.alias.get;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.cluster.metadata.AliasMetaData;
import org.elasticsearch.common.collect.ImmutableOpenMap;
@ -29,6 +28,7 @@ import org.elasticsearch.common.io.stream.StreamOutput;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
@ -61,7 +61,7 @@ public class GetAliasesResponse extends ActionResponse {
for (int j = 0; j < valueSize; j++) {
value.add(AliasMetaData.Builder.readFrom(in));
}
aliasesBuilder.put(key, ImmutableList.copyOf(value));
aliasesBuilder.put(key, Collections.unmodifiableList(value));
}
aliases = aliasesBuilder.build();
}

View File

@ -64,7 +64,7 @@ public class TransportGetAliasesAction extends TransportMasterNodeReadAction<Get
@Override
protected void masterOperation(GetAliasesRequest request, ClusterState state, ActionListener<GetAliasesResponse> listener) {
String[] concreteIndices = indexNameExpressionResolver.concreteIndices(state, request);
@SuppressWarnings("unchecked") // ImmutableList to List results incompatible type
@SuppressWarnings("unchecked")
ImmutableOpenMap<String, List<AliasMetaData>> result = (ImmutableOpenMap) state.metaData().findAliases(request.aliases(), concreteIndices);
listener.onResponse(new GetAliasesResponse(result));
}

View File

@ -20,7 +20,6 @@
package org.elasticsearch.action.admin.indices.get;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.cluster.metadata.AliasMetaData;
@ -32,21 +31,24 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.search.warmer.IndexWarmersMetaData;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* A response for a delete index action.
*/
public class GetIndexResponse extends ActionResponse {
private ImmutableOpenMap<String, ImmutableList<IndexWarmersMetaData.Entry>> warmers = ImmutableOpenMap.of();
private ImmutableOpenMap<String, List<IndexWarmersMetaData.Entry>> warmers = ImmutableOpenMap.of();
private ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>> mappings = ImmutableOpenMap.of();
private ImmutableOpenMap<String, ImmutableList<AliasMetaData>> aliases = ImmutableOpenMap.of();
private ImmutableOpenMap<String, List<AliasMetaData>> aliases = ImmutableOpenMap.of();
private ImmutableOpenMap<String, Settings> settings = ImmutableOpenMap.of();
private String[] indices;
GetIndexResponse(String[] indices, ImmutableOpenMap<String, ImmutableList<IndexWarmersMetaData.Entry>> warmers,
GetIndexResponse(String[] indices, ImmutableOpenMap<String, List<IndexWarmersMetaData.Entry>> warmers,
ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>> mappings,
ImmutableOpenMap<String, ImmutableList<AliasMetaData>> aliases, ImmutableOpenMap<String, Settings> settings) {
ImmutableOpenMap<String, List<AliasMetaData>> aliases, ImmutableOpenMap<String, Settings> settings) {
this.indices = indices;
if (warmers != null) {
this.warmers = warmers;
@ -73,11 +75,11 @@ public class GetIndexResponse extends ActionResponse {
return indices();
}
public ImmutableOpenMap<String, ImmutableList<IndexWarmersMetaData.Entry>> warmers() {
public ImmutableOpenMap<String, List<IndexWarmersMetaData.Entry>> warmers() {
return warmers;
}
public ImmutableOpenMap<String, ImmutableList<IndexWarmersMetaData.Entry>> getWarmers() {
public ImmutableOpenMap<String, List<IndexWarmersMetaData.Entry>> getWarmers() {
return warmers();
}
@ -89,11 +91,11 @@ public class GetIndexResponse extends ActionResponse {
return mappings();
}
public ImmutableOpenMap<String, ImmutableList<AliasMetaData>> aliases() {
public ImmutableOpenMap<String, List<AliasMetaData>> aliases() {
return aliases;
}
public ImmutableOpenMap<String, ImmutableList<AliasMetaData>> getAliases() {
public ImmutableOpenMap<String, List<AliasMetaData>> getAliases() {
return aliases();
}
@ -110,11 +112,11 @@ public class GetIndexResponse extends ActionResponse {
super.readFrom(in);
this.indices = in.readStringArray();
int warmersSize = in.readVInt();
ImmutableOpenMap.Builder<String, ImmutableList<IndexWarmersMetaData.Entry>> warmersMapBuilder = ImmutableOpenMap.builder();
ImmutableOpenMap.Builder<String, List<IndexWarmersMetaData.Entry>> warmersMapBuilder = ImmutableOpenMap.builder();
for (int i = 0; i < warmersSize; i++) {
String key = in.readString();
int valueSize = in.readVInt();
ImmutableList.Builder<IndexWarmersMetaData.Entry> warmerEntryBuilder = ImmutableList.builder();
List<IndexWarmersMetaData.Entry> warmerEntryBuilder = new ArrayList<>();
for (int j = 0; j < valueSize; j++) {
warmerEntryBuilder.add(new IndexWarmersMetaData.Entry(
in.readString(),
@ -123,7 +125,7 @@ public class GetIndexResponse extends ActionResponse {
in.readBytesReference())
);
}
warmersMapBuilder.put(key, warmerEntryBuilder.build());
warmersMapBuilder.put(key, Collections.unmodifiableList(warmerEntryBuilder));
}
warmers = warmersMapBuilder.build();
int mappingsSize = in.readVInt();
@ -139,15 +141,15 @@ public class GetIndexResponse extends ActionResponse {
}
mappings = mappingsMapBuilder.build();
int aliasesSize = in.readVInt();
ImmutableOpenMap.Builder<String, ImmutableList<AliasMetaData>> aliasesMapBuilder = ImmutableOpenMap.builder();
ImmutableOpenMap.Builder<String, List<AliasMetaData>> aliasesMapBuilder = ImmutableOpenMap.builder();
for (int i = 0; i < aliasesSize; i++) {
String key = in.readString();
int valueSize = in.readVInt();
ImmutableList.Builder<AliasMetaData> aliasEntryBuilder = ImmutableList.builder();
List<AliasMetaData> aliasEntryBuilder = new ArrayList<>();
for (int j = 0; j < valueSize; j++) {
aliasEntryBuilder.add(AliasMetaData.Builder.readFrom(in));
}
aliasesMapBuilder.put(key, aliasEntryBuilder.build());
aliasesMapBuilder.put(key, Collections.unmodifiableList(aliasEntryBuilder));
}
aliases = aliasesMapBuilder.build();
int settingsSize = in.readVInt();
@ -164,7 +166,7 @@ public class GetIndexResponse extends ActionResponse {
super.writeTo(out);
out.writeStringArray(indices);
out.writeVInt(warmers.size());
for (ObjectObjectCursor<String, ImmutableList<IndexWarmersMetaData.Entry>> indexEntry : warmers) {
for (ObjectObjectCursor<String, List<IndexWarmersMetaData.Entry>> indexEntry : warmers) {
out.writeString(indexEntry.key);
out.writeVInt(indexEntry.value.size());
for (IndexWarmersMetaData.Entry warmerEntry : indexEntry.value) {
@ -184,7 +186,7 @@ public class GetIndexResponse extends ActionResponse {
}
}
out.writeVInt(aliases.size());
for (ObjectObjectCursor<String, ImmutableList<AliasMetaData>> indexEntry : aliases) {
for (ObjectObjectCursor<String, List<AliasMetaData>> indexEntry : aliases) {
out.writeString(indexEntry.key);
out.writeVInt(indexEntry.value.size());
for (AliasMetaData aliasEntry : indexEntry.value) {

View File

@ -19,7 +19,6 @@
package org.elasticsearch.action.admin.indices.get;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.admin.indices.get.GetIndexRequest.Feature;
@ -41,6 +40,8 @@ import org.elasticsearch.search.warmer.IndexWarmersMetaData.Entry;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import java.util.List;
/**
* Get index action.
*/
@ -71,9 +72,9 @@ public class TransportGetIndexAction extends TransportClusterInfoAction<GetIndex
@Override
protected void doMasterOperation(final GetIndexRequest request, String[] concreteIndices, final ClusterState state,
final ActionListener<GetIndexResponse> listener) {
ImmutableOpenMap<String, ImmutableList<Entry>> warmersResult = ImmutableOpenMap.of();
ImmutableOpenMap<String, List<Entry>> warmersResult = ImmutableOpenMap.of();
ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>> mappingsResult = ImmutableOpenMap.of();
ImmutableOpenMap<String, ImmutableList<AliasMetaData>> aliasesResult = ImmutableOpenMap.of();
ImmutableOpenMap<String, List<AliasMetaData>> aliasesResult = ImmutableOpenMap.of();
ImmutableOpenMap<String, Settings> settings = ImmutableOpenMap.of();
Feature[] features = request.features();
boolean doneAliases = false;

View File

@ -19,7 +19,6 @@
package org.elasticsearch.action.admin.indices.segments;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
@ -28,6 +27,7 @@ import org.elasticsearch.index.engine.Segment;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@ -91,7 +91,7 @@ public class ShardSegments implements Streamable, Iterable<Segment> {
shardRouting = readShardRoutingEntry(in);
int size = in.readVInt();
if (size == 0) {
segments = ImmutableList.of();
segments = Collections.emptyList();
} else {
segments = new ArrayList<>(size);
for (int i = 0; i < size; i++) {

View File

@ -21,7 +21,6 @@ package org.elasticsearch.action.admin.indices.shards;
import com.carrotsearch.hppc.cursors.IntObjectCursor;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.ShardOperationFailedException;
@ -38,6 +37,7 @@ import org.elasticsearch.common.xcontent.XContentBuilderString;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static org.elasticsearch.action.admin.indices.shards.IndicesShardStoresResponse.StoreStatus.*;
@ -258,15 +258,15 @@ public class IndicesShardStoresResponse extends ActionResponse implements ToXCon
}
private ImmutableOpenMap<String, ImmutableOpenIntMap<List<StoreStatus>>> storeStatuses;
private ImmutableList<Failure> failures;
private List<Failure> failures;
public IndicesShardStoresResponse(ImmutableOpenMap<String, ImmutableOpenIntMap<List<StoreStatus>>> storeStatuses, ImmutableList<Failure> failures) {
public IndicesShardStoresResponse(ImmutableOpenMap<String, ImmutableOpenIntMap<List<StoreStatus>>> storeStatuses, List<Failure> failures) {
this.storeStatuses = storeStatuses;
this.failures = failures;
}
IndicesShardStoresResponse() {
this(ImmutableOpenMap.<String, ImmutableOpenIntMap<List<StoreStatus>>>of(), ImmutableList.<Failure>of());
this(ImmutableOpenMap.<String, ImmutableOpenIntMap<List<StoreStatus>>>of(), Collections.<Failure>emptyList());
}
/**
@ -281,7 +281,7 @@ public class IndicesShardStoresResponse extends ActionResponse implements ToXCon
* Returns node {@link Failure}s encountered
* while executing the request
*/
public ImmutableList<Failure> getFailures() {
public List<Failure> getFailures() {
return failures;
}
@ -306,12 +306,12 @@ public class IndicesShardStoresResponse extends ActionResponse implements ToXCon
storeStatusesBuilder.put(index, shardEntries.build());
}
int numFailure = in.readVInt();
ImmutableList.Builder<Failure> failureBuilder = ImmutableList.builder();
List<Failure> failureBuilder = new ArrayList<>();
for (int i = 0; i < numFailure; i++) {
failureBuilder.add(Failure.readFailure(in));
}
storeStatuses = storeStatusesBuilder.build();
failures = failureBuilder.build();
failures = Collections.unmodifiableList(failureBuilder);
}
@Override

View File

@ -18,7 +18,6 @@
*/
package org.elasticsearch.action.admin.indices.shards;
import com.google.common.collect.ImmutableList;
import org.apache.lucene.util.CollectionUtil;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.FailedNodeException;
@ -34,7 +33,11 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.cluster.routing.*;
import org.elasticsearch.cluster.routing.IndexRoutingTable;
import org.elasticsearch.cluster.routing.IndexShardRoutingTable;
import org.elasticsearch.cluster.routing.RoutingNodes;
import org.elasticsearch.cluster.routing.RoutingTable;
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.common.collect.ImmutableOpenIntMap;
import org.elasticsearch.common.collect.ImmutableOpenMap;
import org.elasticsearch.common.inject.Inject;
@ -48,7 +51,11 @@ import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Queue;
import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;
/**
@ -157,7 +164,7 @@ public class TransportIndicesShardStoresAction extends TransportMasterNodeReadAc
void finish() {
ImmutableOpenMap.Builder<String, ImmutableOpenIntMap<java.util.List<IndicesShardStoresResponse.StoreStatus>>> indicesStoreStatusesBuilder = ImmutableOpenMap.builder();
ImmutableList.Builder<IndicesShardStoresResponse.Failure> failureBuilder = ImmutableList.builder();
java.util.List<IndicesShardStoresResponse.Failure> failureBuilder = new ArrayList<>();
for (Response fetchResponse : fetchResponses) {
ImmutableOpenIntMap<java.util.List<IndicesShardStoresResponse.StoreStatus>> indexStoreStatuses = indicesStoreStatusesBuilder.get(fetchResponse.shardId.getIndex());
final ImmutableOpenIntMap.Builder<java.util.List<IndicesShardStoresResponse.StoreStatus>> indexShardsBuilder;
@ -183,7 +190,7 @@ public class TransportIndicesShardStoresAction extends TransportMasterNodeReadAc
failureBuilder.add(new IndicesShardStoresResponse.Failure(failure.nodeId(), fetchResponse.shardId.getIndex(), fetchResponse.shardId.id(), failure.getCause()));
}
}
listener.onResponse(new IndicesShardStoresResponse(indicesStoreStatusesBuilder.build(), failureBuilder.build()));
listener.onResponse(new IndicesShardStoresResponse(indicesStoreStatusesBuilder.build(), Collections.unmodifiableList(failureBuilder)));
}
private IndicesShardStoresResponse.StoreStatus.Allocation getAllocation(String index, int shardID, DiscoveryNode node) {

View File

@ -19,7 +19,6 @@
package org.elasticsearch.action.admin.indices.validate.query;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.action.ShardOperationFailedException;
import org.elasticsearch.action.support.broadcast.BroadcastResponse;
import org.elasticsearch.common.io.stream.StreamInput;
@ -27,6 +26,7 @@ import org.elasticsearch.common.io.stream.StreamOutput;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static org.elasticsearch.action.admin.indices.validate.query.QueryExplanation.readQueryExplanation;
@ -51,7 +51,7 @@ public class ValidateQueryResponse extends BroadcastResponse {
this.valid = valid;
this.queryExplanations = queryExplanations;
if (queryExplanations == null) {
this.queryExplanations = ImmutableList.of();
this.queryExplanations = Collections.emptyList();
}
}
@ -67,7 +67,7 @@ public class ValidateQueryResponse extends BroadcastResponse {
*/
public List<? extends QueryExplanation> getQueryExplanation() {
if (queryExplanations == null) {
return ImmutableList.of();
return Collections.emptyList();
}
return queryExplanations;
}

View File

@ -20,7 +20,6 @@
package org.elasticsearch.action.admin.indices.warmer.get;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.common.bytes.BytesReference;
@ -30,6 +29,9 @@ import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.search.warmer.IndexWarmersMetaData;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Holds a warmer-name to a list of {@link IndexWarmersMetaData} mapping for each warmer specified
@ -38,20 +40,20 @@ import java.io.IOException;
*/
public class GetWarmersResponse extends ActionResponse {
private ImmutableOpenMap<String, ImmutableList<IndexWarmersMetaData.Entry>> warmers = ImmutableOpenMap.of();
private ImmutableOpenMap<String, List<IndexWarmersMetaData.Entry>> warmers = ImmutableOpenMap.of();
GetWarmersResponse(ImmutableOpenMap<String, ImmutableList<IndexWarmersMetaData.Entry>> warmers) {
GetWarmersResponse(ImmutableOpenMap<String, List<IndexWarmersMetaData.Entry>> warmers) {
this.warmers = warmers;
}
GetWarmersResponse() {
}
public ImmutableOpenMap<String, ImmutableList<IndexWarmersMetaData.Entry>> warmers() {
public ImmutableOpenMap<String, List<IndexWarmersMetaData.Entry>> warmers() {
return warmers;
}
public ImmutableOpenMap<String, ImmutableList<IndexWarmersMetaData.Entry>> getWarmers() {
public ImmutableOpenMap<String, List<IndexWarmersMetaData.Entry>> getWarmers() {
return warmers();
}
@ -59,11 +61,11 @@ public class GetWarmersResponse extends ActionResponse {
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
int size = in.readVInt();
ImmutableOpenMap.Builder<String, ImmutableList<IndexWarmersMetaData.Entry>> indexMapBuilder = ImmutableOpenMap.builder();
ImmutableOpenMap.Builder<String, List<IndexWarmersMetaData.Entry>> indexMapBuilder = ImmutableOpenMap.builder();
for (int i = 0; i < size; i++) {
String key = in.readString();
int valueSize = in.readVInt();
ImmutableList.Builder<IndexWarmersMetaData.Entry> warmerEntryBuilder = ImmutableList.builder();
List<IndexWarmersMetaData.Entry> warmerEntryBuilder = new ArrayList<>();
for (int j = 0; j < valueSize; j++) {
String name = in.readString();
String[] types = in.readStringArray();
@ -77,7 +79,7 @@ public class GetWarmersResponse extends ActionResponse {
source)
);
}
indexMapBuilder.put(key, warmerEntryBuilder.build());
indexMapBuilder.put(key, Collections.unmodifiableList(warmerEntryBuilder));
}
warmers = indexMapBuilder.build();
}
@ -86,7 +88,7 @@ public class GetWarmersResponse extends ActionResponse {
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeVInt(warmers.size());
for (ObjectObjectCursor<String, ImmutableList<IndexWarmersMetaData.Entry>> indexEntry : warmers) {
for (ObjectObjectCursor<String, List<IndexWarmersMetaData.Entry>> indexEntry : warmers) {
out.writeString(indexEntry.key);
out.writeVInt(indexEntry.value.size());
for (IndexWarmersMetaData.Entry warmerEntry : indexEntry.value) {

View File

@ -19,7 +19,6 @@
package org.elasticsearch.action.admin.indices.warmer.get;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.info.TransportClusterInfoAction;
@ -35,6 +34,8 @@ import org.elasticsearch.search.warmer.IndexWarmersMetaData;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import java.util.List;
/**
* Internal Actions executed on the master fetching the warmer from the cluster state metadata.
*
@ -66,7 +67,7 @@ public class TransportGetWarmersAction extends TransportClusterInfoAction<GetWar
@Override
protected void doMasterOperation(final GetWarmersRequest request, String[] concreteIndices, final ClusterState state, final ActionListener<GetWarmersResponse> listener) {
ImmutableOpenMap<String, ImmutableList<IndexWarmersMetaData.Entry>> result = state.metaData().findWarmers(
ImmutableOpenMap<String, List<IndexWarmersMetaData.Entry>> result = state.metaData().findWarmers(
concreteIndices, request.types(), request.warmers()
);
listener.onResponse(new GetWarmersResponse(result));

View File

@ -18,7 +18,6 @@
*/
package org.elasticsearch.action.percolate;
import com.google.common.collect.ImmutableList;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.action.support.broadcast.BroadcastShardResponse;
import org.elasticsearch.common.bytes.BytesReference;
@ -35,6 +34,7 @@ import org.elasticsearch.search.query.QuerySearchResult;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -45,7 +45,7 @@ public class PercolateShardResponse extends BroadcastShardResponse {
private static final BytesRef[] EMPTY_MATCHES = new BytesRef[0];
private static final float[] EMPTY_SCORES = new float[0];
private static final List<Map<String, HighlightField>> EMPTY_HL = ImmutableList.of();
private static final List<Map<String, HighlightField>> EMPTY_HL = Collections.emptyList();
private long count;
private float[] scores;

View File

@ -19,7 +19,6 @@
package org.elasticsearch.action.update;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionRunnable;
@ -58,6 +57,7 @@ import org.elasticsearch.indices.IndicesService;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import java.util.Collections;
import java.util.Map;
/**
@ -153,10 +153,10 @@ public class TransportUpdateAction extends TransportInstanceSingleOperationActio
ShardRouting shard;
while ((shard = shardIterator.nextOrNull()) != null) {
if (shard.primary()) {
return new PlainShardIterator(shardIterator.shardId(), ImmutableList.of(shard));
return new PlainShardIterator(shardIterator.shardId(), Collections.singletonList(shard));
}
}
return new PlainShardIterator(shardIterator.shardId(), ImmutableList.<ShardRouting>of());
return new PlainShardIterator(shardIterator.shardId(), Collections.<ShardRouting>emptyList());
}
@Override

View File

@ -19,7 +19,6 @@
package org.elasticsearch.bootstrap;
import com.google.common.collect.ImmutableList;
import com.sun.jna.*;
import com.sun.jna.win32.StdCallLibrary;
@ -29,6 +28,7 @@ import org.elasticsearch.common.logging.Loggers;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@ -85,8 +85,8 @@ final class JNAKernel32Library {
return result;
}
ImmutableList<Object> getCallbacks() {
return ImmutableList.builder().addAll(callbacks).build();
List<Object> getCallbacks() {
return Collections.<Object>unmodifiableList(callbacks);
}
/**

View File

@ -20,7 +20,6 @@
package org.elasticsearch.client.transport;
import com.carrotsearch.hppc.cursors.ObjectCursor;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Sets;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.Version;
@ -50,6 +49,7 @@ import org.elasticsearch.transport.TransportRequestOptions;
import org.elasticsearch.transport.TransportService;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@ -83,12 +83,12 @@ public class TransportClientNodesService extends AbstractComponent {
private final Headers headers;
// nodes that are added to be discovered
private volatile ImmutableList<DiscoveryNode> listedNodes = ImmutableList.of();
private volatile List<DiscoveryNode> listedNodes = Collections.emptyList();
private final Object mutex = new Object();
private volatile List<DiscoveryNode> nodes = ImmutableList.of();
private volatile List<DiscoveryNode> filteredNodes = ImmutableList.of();
private volatile List<DiscoveryNode> nodes = Collections.emptyList();
private volatile List<DiscoveryNode> filteredNodes = Collections.emptyList();
private final AtomicInteger tempNodeIdGenerator = new AtomicInteger();
@ -129,11 +129,11 @@ public class TransportClientNodesService extends AbstractComponent {
}
public List<TransportAddress> transportAddresses() {
ImmutableList.Builder<TransportAddress> lstBuilder = ImmutableList.builder();
List<TransportAddress> lstBuilder = new ArrayList<>();
for (DiscoveryNode listedNode : listedNodes) {
lstBuilder.add(listedNode.address());
}
return lstBuilder.build();
return Collections.unmodifiableList(lstBuilder);
}
public List<DiscoveryNode> connectedNodes() {
@ -170,14 +170,14 @@ public class TransportClientNodesService extends AbstractComponent {
if (filtered.isEmpty()) {
return this;
}
ImmutableList.Builder<DiscoveryNode> builder = ImmutableList.builder();
List<DiscoveryNode> builder = new ArrayList<>();
builder.addAll(listedNodes());
for (TransportAddress transportAddress : filtered) {
DiscoveryNode node = new DiscoveryNode("#transport#-" + tempNodeIdGenerator.incrementAndGet(), transportAddress, minCompatibilityVersion);
logger.debug("adding address [{}]", node);
builder.add(node);
}
listedNodes = builder.build();
listedNodes = Collections.unmodifiableList(builder);
nodesSampler.sample();
}
return this;
@ -188,7 +188,7 @@ public class TransportClientNodesService extends AbstractComponent {
if (closed) {
throw new IllegalStateException("transport client is closed, can't remove an address");
}
ImmutableList.Builder<DiscoveryNode> builder = ImmutableList.builder();
List<DiscoveryNode> builder = new ArrayList<>();
for (DiscoveryNode otherNode : listedNodes) {
if (!otherNode.address().equals(transportAddress)) {
builder.add(otherNode);
@ -196,7 +196,7 @@ public class TransportClientNodesService extends AbstractComponent {
logger.debug("removing address [{}]", otherNode);
}
}
listedNodes = builder.build();
listedNodes = Collections.unmodifiableList(builder);
nodesSampler.sample();
}
return this;
@ -271,7 +271,7 @@ public class TransportClientNodesService extends AbstractComponent {
for (DiscoveryNode listedNode : listedNodes) {
transportService.disconnectFromNode(listedNode);
}
nodes = ImmutableList.of();
nodes = Collections.emptyList();
}
}
@ -321,7 +321,7 @@ public class TransportClientNodesService extends AbstractComponent {
}
}
return new ImmutableList.Builder<DiscoveryNode>().addAll(nodes).build();
return Collections.unmodifiableList(new ArrayList<>(nodes));
}
}
@ -386,7 +386,7 @@ public class TransportClientNodesService extends AbstractComponent {
}
nodes = validateNewNodes(newNodes);
filteredNodes = ImmutableList.copyOf(newFilteredNodes);
filteredNodes = Collections.unmodifiableList(new ArrayList<>(newFilteredNodes));
}
}
@ -486,7 +486,7 @@ public class TransportClientNodesService extends AbstractComponent {
}
nodes = validateNewNodes(newNodes);
filteredNodes = ImmutableList.copyOf(newFilteredNodes);
filteredNodes = Collections.unmodifiableList(new ArrayList<>(newFilteredNodes));
}
}

View File

@ -20,13 +20,13 @@
package org.elasticsearch.cluster;
import com.carrotsearch.hppc.cursors.ObjectCursor;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.node.DiscoveryNodes;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
@ -86,7 +86,7 @@ public class ClusterChangedEvent {
return Arrays.asList(state.metaData().indices().keys().toArray(String.class));
}
if (!metaDataChanged()) {
return ImmutableList.of();
return Collections.emptyList();
}
List<String> created = null;
for (ObjectCursor<String> cursor : state.metaData().indices().keys()) {
@ -98,7 +98,7 @@ public class ClusterChangedEvent {
created.add(index);
}
}
return created == null ? ImmutableList.<String>of() : created;
return created == null ? Collections.<String>emptyList() : created;
}
/**
@ -116,10 +116,10 @@ public class ClusterChangedEvent {
// See discussion on https://github.com/elastic/elasticsearch/pull/9952 and
// https://github.com/elastic/elasticsearch/issues/11665
if (hasNewMaster() || previousState == null) {
return ImmutableList.of();
return Collections.emptyList();
}
if (!metaDataChanged()) {
return ImmutableList.of();
return Collections.emptyList();
}
List<String> deleted = null;
for (ObjectCursor<String> cursor : previousState.metaData().indices().keys()) {
@ -131,7 +131,7 @@ public class ClusterChangedEvent {
deleted.add(index);
}
}
return deleted == null ? ImmutableList.<String>of() : deleted;
return deleted == null ? Collections.<String>emptyList() : deleted;
}
public boolean metaDataChanged() {

View File

@ -19,7 +19,6 @@
package org.elasticsearch.cluster;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.elasticsearch.cluster.ClusterState.Custom;
import org.elasticsearch.cluster.metadata.SnapshotId;
@ -30,6 +29,9 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.index.shard.ShardId;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@ -42,14 +44,14 @@ public class RestoreInProgress extends AbstractDiffable<Custom> implements Custo
public static final RestoreInProgress PROTO = new RestoreInProgress();
private final ImmutableList<Entry> entries;
private final List<Entry> entries;
/**
* Constructs new restore metadata
*
* @param entries list of currently running restore processes
*/
public RestoreInProgress(ImmutableList<Entry> entries) {
public RestoreInProgress(List<Entry> entries) {
this.entries = entries;
}
@ -59,7 +61,7 @@ public class RestoreInProgress extends AbstractDiffable<Custom> implements Custo
* @param entries list of currently running restore processes
*/
public RestoreInProgress(Entry... entries) {
this.entries = ImmutableList.copyOf(entries);
this.entries = Arrays.asList(entries);
}
/**
@ -111,7 +113,7 @@ public class RestoreInProgress extends AbstractDiffable<Custom> implements Custo
private final State state;
private final SnapshotId snapshotId;
private final ImmutableMap<ShardId, ShardRestoreStatus> shards;
private final ImmutableList<String> indices;
private final List<String> indices;
/**
* Creates new restore metadata
@ -121,7 +123,7 @@ public class RestoreInProgress extends AbstractDiffable<Custom> implements Custo
* @param indices list of indices being restored
* @param shards list of shards being restored and thier current restore status
*/
public Entry(SnapshotId snapshotId, State state, ImmutableList<String> indices, ImmutableMap<ShardId, ShardRestoreStatus> shards) {
public Entry(SnapshotId snapshotId, State state, List<String> indices, ImmutableMap<ShardId, ShardRestoreStatus> shards) {
this.snapshotId = snapshotId;
this.state = state;
this.indices = indices;
@ -164,7 +166,7 @@ public class RestoreInProgress extends AbstractDiffable<Custom> implements Custo
*
* @return list of indices
*/
public ImmutableList<String> indices() {
public List<String> indices() {
return indices;
}
@ -413,7 +415,7 @@ public class RestoreInProgress extends AbstractDiffable<Custom> implements Custo
SnapshotId snapshotId = SnapshotId.readSnapshotId(in);
State state = State.fromValue(in.readByte());
int indices = in.readVInt();
ImmutableList.Builder<String> indexBuilder = ImmutableList.builder();
List<String> indexBuilder = new ArrayList<>();
for (int j = 0; j < indices; j++) {
indexBuilder.add(in.readString());
}
@ -424,7 +426,7 @@ public class RestoreInProgress extends AbstractDiffable<Custom> implements Custo
ShardRestoreStatus shardState = ShardRestoreStatus.readShardRestoreStatus(in);
builder.put(shardId, shardState);
}
entries[i] = new Entry(snapshotId, state, indexBuilder.build(), builder.build());
entries[i] = new Entry(snapshotId, state, Collections.unmodifiableList(indexBuilder), builder.build());
}
return new RestoreInProgress(entries);
}

View File

@ -19,7 +19,6 @@
package org.elasticsearch.cluster;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.elasticsearch.cluster.ClusterState.Custom;
import org.elasticsearch.cluster.metadata.SnapshotId;
@ -31,7 +30,10 @@ import org.elasticsearch.common.xcontent.XContentBuilderString;
import org.elasticsearch.index.shard.ShardId;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@ -67,11 +69,11 @@ public class SnapshotsInProgress extends AbstractDiffable<Custom> implements Cus
private final SnapshotId snapshotId;
private final boolean includeGlobalState;
private final ImmutableMap<ShardId, ShardSnapshotStatus> shards;
private final ImmutableList<String> indices;
private final ImmutableMap<String, ImmutableList<ShardId>> waitingIndices;
private final List<String> indices;
private final ImmutableMap<String, List<ShardId>> waitingIndices;
private final long startTime;
public Entry(SnapshotId snapshotId, boolean includeGlobalState, State state, ImmutableList<String> indices, long startTime, ImmutableMap<ShardId, ShardSnapshotStatus> shards) {
public Entry(SnapshotId snapshotId, boolean includeGlobalState, State state, List<String> indices, long startTime, ImmutableMap<ShardId, ShardSnapshotStatus> shards) {
this.state = state;
this.snapshotId = snapshotId;
this.includeGlobalState = includeGlobalState;
@ -106,11 +108,11 @@ public class SnapshotsInProgress extends AbstractDiffable<Custom> implements Cus
return state;
}
public ImmutableList<String> indices() {
public List<String> indices() {
return indices;
}
public ImmutableMap<String, ImmutableList<ShardId>> waitingIndices() {
public ImmutableMap<String, List<ShardId>> waitingIndices() {
return waitingIndices;
}
@ -152,22 +154,22 @@ public class SnapshotsInProgress extends AbstractDiffable<Custom> implements Cus
return result;
}
private ImmutableMap<String, ImmutableList<ShardId>> findWaitingIndices(ImmutableMap<ShardId, ShardSnapshotStatus> shards) {
Map<String, ImmutableList.Builder<ShardId>> waitingIndicesMap = newHashMap();
private ImmutableMap<String, List<ShardId>> findWaitingIndices(ImmutableMap<ShardId, ShardSnapshotStatus> shards) {
Map<String, List<ShardId>> waitingIndicesMap = newHashMap();
for (ImmutableMap.Entry<ShardId, ShardSnapshotStatus> entry : shards.entrySet()) {
if (entry.getValue().state() == State.WAITING) {
ImmutableList.Builder<ShardId> waitingShards = waitingIndicesMap.get(entry.getKey().getIndex());
List<ShardId> waitingShards = waitingIndicesMap.get(entry.getKey().getIndex());
if (waitingShards == null) {
waitingShards = ImmutableList.builder();
waitingShards = new ArrayList<>();
waitingIndicesMap.put(entry.getKey().getIndex(), waitingShards);
}
waitingShards.add(entry.getKey());
}
}
if (!waitingIndicesMap.isEmpty()) {
ImmutableMap.Builder<String, ImmutableList<ShardId>> waitingIndicesBuilder = ImmutableMap.builder();
for (Map.Entry<String, ImmutableList.Builder<ShardId>> entry : waitingIndicesMap.entrySet()) {
waitingIndicesBuilder.put(entry.getKey(), entry.getValue().build());
ImmutableMap.Builder<String, List<ShardId>> waitingIndicesBuilder = ImmutableMap.builder();
for (Map.Entry<String, List<ShardId>> entry : waitingIndicesMap.entrySet()) {
waitingIndicesBuilder.put(entry.getKey(), Collections.unmodifiableList(entry.getValue()));
}
return waitingIndicesBuilder.build();
} else {
@ -324,15 +326,15 @@ public class SnapshotsInProgress extends AbstractDiffable<Custom> implements Cus
}
}
private final ImmutableList<Entry> entries;
private final List<Entry> entries;
public SnapshotsInProgress(ImmutableList<Entry> entries) {
public SnapshotsInProgress(List<Entry> entries) {
this.entries = entries;
}
public SnapshotsInProgress(Entry... entries) {
this.entries = ImmutableList.copyOf(entries);
this.entries = Arrays.asList(entries);
}
public List<Entry> entries() {
@ -361,7 +363,7 @@ public class SnapshotsInProgress extends AbstractDiffable<Custom> implements Cus
boolean includeGlobalState = in.readBoolean();
State state = State.fromValue(in.readByte());
int indices = in.readVInt();
ImmutableList.Builder<String> indexBuilder = ImmutableList.builder();
List<String> indexBuilder = new ArrayList<>();
for (int j = 0; j < indices; j++) {
indexBuilder.add(in.readString());
}
@ -374,7 +376,7 @@ public class SnapshotsInProgress extends AbstractDiffable<Custom> implements Cus
State shardState = State.fromValue(in.readByte());
builder.put(shardId, new ShardSnapshotStatus(nodeId, shardState));
}
entries[i] = new Entry(snapshotId, includeGlobalState, state, indexBuilder.build(), startTime, builder.build());
entries[i] = new Entry(snapshotId, includeGlobalState, state, Collections.unmodifiableList(indexBuilder), startTime, builder.build());
}
return new SnapshotsInProgress(entries);
}

View File

@ -20,7 +20,6 @@
package org.elasticsearch.cluster.metadata;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.action.IndicesRequest;
import org.elasticsearch.action.support.IndicesOptions;
@ -57,13 +56,13 @@ import static com.google.common.collect.Maps.newHashMap;
public class IndexNameExpressionResolver extends AbstractComponent {
private final ImmutableList<ExpressionResolver> expressionResolvers;
private final List<ExpressionResolver> expressionResolvers;
private final DateMathExpressionResolver dateMathExpressionResolver;
@Inject
public IndexNameExpressionResolver(Settings settings) {
super(settings);
expressionResolvers = ImmutableList.of(
expressionResolvers = Arrays.asList(
dateMathExpressionResolver = new DateMathExpressionResolver(settings),
new WildcardExpressionResolver()
);

View File

@ -24,7 +24,6 @@ import com.carrotsearch.hppc.cursors.ObjectCursor;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.UnmodifiableIterator;
import org.apache.lucene.util.CollectionUtil;
@ -253,7 +252,7 @@ public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, Fr
* @param concreteIndices The concrete indexes the index aliases must point to order to be returned.
* @return the found index aliases grouped by index
*/
public ImmutableOpenMap<String, ImmutableList<AliasMetaData>> findAliases(final String[] aliases, String[] concreteIndices) {
public ImmutableOpenMap<String, List<AliasMetaData>> findAliases(final String[] aliases, String[] concreteIndices) {
assert aliases != null;
assert concreteIndices != null;
if (concreteIndices.length == 0) {
@ -261,7 +260,7 @@ public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, Fr
}
boolean matchAllAliases = matchAllAliases(aliases);
ImmutableOpenMap.Builder<String, ImmutableList<AliasMetaData>> mapBuilder = ImmutableOpenMap.builder();
ImmutableOpenMap.Builder<String, List<AliasMetaData>> mapBuilder = ImmutableOpenMap.builder();
Iterable<String> intersection = HppcMaps.intersection(ObjectHashSet.from(concreteIndices), indices.keys());
for (String index : intersection) {
IndexMetaData indexMetaData = indices.get(index);
@ -281,7 +280,7 @@ public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, Fr
return o1.alias().compareTo(o2.alias());
}
});
mapBuilder.put(index, ImmutableList.copyOf(filteredValues));
mapBuilder.put(index, Collections.unmodifiableList(filteredValues));
}
}
return mapBuilder.build();
@ -364,7 +363,7 @@ public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, Fr
return indexMapBuilder.build();
}
public ImmutableOpenMap<String, ImmutableList<IndexWarmersMetaData.Entry>> findWarmers(String[] concreteIndices, final String[] types, final String[] uncheckedWarmers) {
public ImmutableOpenMap<String, List<IndexWarmersMetaData.Entry>> findWarmers(String[] concreteIndices, final String[] types, final String[] uncheckedWarmers) {
assert uncheckedWarmers != null;
assert concreteIndices != null;
if (concreteIndices.length == 0) {
@ -373,7 +372,7 @@ public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, Fr
// special _all check to behave the same like not specifying anything for the warmers (not for the indices)
final String[] warmers = Strings.isAllOrWildcard(uncheckedWarmers) ? Strings.EMPTY_ARRAY : uncheckedWarmers;
ImmutableOpenMap.Builder<String, ImmutableList<IndexWarmersMetaData.Entry>> mapBuilder = ImmutableOpenMap.builder();
ImmutableOpenMap.Builder<String, List<IndexWarmersMetaData.Entry>> mapBuilder = ImmutableOpenMap.builder();
Iterable<String> intersection = HppcMaps.intersection(ObjectHashSet.from(concreteIndices), indices.keys());
for (String index : intersection) {
IndexMetaData indexMetaData = indices.get(index);
@ -382,6 +381,7 @@ public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, Fr
continue;
}
// TODO: make this a List so we don't have to copy below
Collection<IndexWarmersMetaData.Entry> filteredWarmers = Collections2.filter(indexWarmersMetaData.entries(), new Predicate<IndexWarmersMetaData.Entry>() {
@Override
@ -399,7 +399,7 @@ public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, Fr
});
if (!filteredWarmers.isEmpty()) {
mapBuilder.put(index, ImmutableList.copyOf(filteredWarmers));
mapBuilder.put(index, Collections.unmodifiableList(new ArrayList<>(filteredWarmers)));
}
}
return mapBuilder.build();

View File

@ -19,7 +19,6 @@
package org.elasticsearch.cluster.metadata;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.cluster.AbstractDiffable;
import org.elasticsearch.cluster.metadata.MetaData.Custom;
@ -33,9 +32,9 @@ import org.elasticsearch.common.xcontent.XContentParser;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
/**
* Contains metadata about registered snapshot repositories
@ -46,7 +45,7 @@ public class RepositoriesMetaData extends AbstractDiffable<Custom> implements Me
public static final RepositoriesMetaData PROTO = new RepositoriesMetaData();
private final ImmutableList<RepositoryMetaData> repositories;
private final List<RepositoryMetaData> repositories;
/**
* Constructs new repository metadata
@ -54,7 +53,7 @@ public class RepositoriesMetaData extends AbstractDiffable<Custom> implements Me
* @param repositories list of repositories
*/
public RepositoriesMetaData(RepositoryMetaData... repositories) {
this.repositories = ImmutableList.copyOf(repositories);
this.repositories = Arrays.asList(repositories);
}
/**
@ -62,7 +61,7 @@ public class RepositoriesMetaData extends AbstractDiffable<Custom> implements Me
*
* @return list of repositories
*/
public ImmutableList<RepositoryMetaData> repositories() {
public List<RepositoryMetaData> repositories() {
return this.repositories;
}

View File

@ -19,7 +19,6 @@
package org.elasticsearch.cluster.node;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.elasticsearch.Version;
@ -35,6 +34,8 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
import java.io.IOException;
import java.net.InetAddress;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import static org.elasticsearch.common.transport.TransportAddressSerializers.addressToStream;
@ -92,7 +93,7 @@ public class DiscoveryNode implements Streamable, ToXContent {
return Booleans.isExplicitTrue(data);
}
public static final ImmutableList<DiscoveryNode> EMPTY_LIST = ImmutableList.of();
public static final List<DiscoveryNode> EMPTY_LIST = Collections.emptyList();
private String nodeName = "";
private String nodeId;

View File

@ -22,7 +22,6 @@ package org.elasticsearch.cluster.node;
import com.carrotsearch.hppc.ObjectHashSet;
import com.carrotsearch.hppc.cursors.ObjectCursor;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.UnmodifiableIterator;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.AbstractDiffable;
@ -36,6 +35,7 @@ import org.elasticsearch.common.transport.TransportAddress;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -433,7 +433,7 @@ public class DiscoveryNodes extends AbstractDiffable<DiscoveryNodes> implements
newMasterNode = masterNode();
}
}
return new Delta(previousMasterNode, newMasterNode, localNodeId, ImmutableList.copyOf(removed), ImmutableList.copyOf(added));
return new Delta(previousMasterNode, newMasterNode, localNodeId, Collections.unmodifiableList(removed), Collections.unmodifiableList(added));
}
@Override
@ -472,14 +472,14 @@ public class DiscoveryNodes extends AbstractDiffable<DiscoveryNodes> implements
private final String localNodeId;
private final DiscoveryNode previousMasterNode;
private final DiscoveryNode newMasterNode;
private final ImmutableList<DiscoveryNode> removed;
private final ImmutableList<DiscoveryNode> added;
private final List<DiscoveryNode> removed;
private final List<DiscoveryNode> added;
public Delta(String localNodeId, ImmutableList<DiscoveryNode> removed, ImmutableList<DiscoveryNode> added) {
public Delta(String localNodeId, List<DiscoveryNode> removed, List<DiscoveryNode> added) {
this(null, null, localNodeId, removed, added);
}
public Delta(@Nullable DiscoveryNode previousMasterNode, @Nullable DiscoveryNode newMasterNode, String localNodeId, ImmutableList<DiscoveryNode> removed, ImmutableList<DiscoveryNode> added) {
public Delta(@Nullable DiscoveryNode previousMasterNode, @Nullable DiscoveryNode newMasterNode, String localNodeId, List<DiscoveryNode> removed, List<DiscoveryNode> added) {
this.previousMasterNode = previousMasterNode;
this.newMasterNode = newMasterNode;
this.localNodeId = localNodeId;

View File

@ -22,7 +22,6 @@ package org.elasticsearch.cluster.routing;
import com.carrotsearch.hppc.IntSet;
import com.carrotsearch.hppc.cursors.IntCursor;
import com.carrotsearch.hppc.cursors.IntObjectCursor;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Sets;
import com.google.common.collect.UnmodifiableIterator;
import org.apache.lucene.util.CollectionUtil;
@ -36,6 +35,7 @@ import org.elasticsearch.index.shard.ShardId;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
@ -73,7 +73,7 @@ public class IndexRoutingTable extends AbstractDiffable<IndexRoutingTable> imple
this.index = index;
this.shuffler = new RotationShardShuffler(ThreadLocalRandom.current().nextInt());
this.shards = shards;
ImmutableList.Builder<ShardRouting> allActiveShards = ImmutableList.builder();
List<ShardRouting> allActiveShards = new ArrayList<>();
for (IntObjectCursor<IndexShardRoutingTable> cursor : shards) {
for (ShardRouting shardRouting : cursor.value) {
shardRouting.freeze();
@ -82,7 +82,7 @@ public class IndexRoutingTable extends AbstractDiffable<IndexRoutingTable> imple
}
}
}
this.allActiveShards = allActiveShards.build();
this.allActiveShards = Collections.unmodifiableList(allActiveShards);
}
/**

View File

@ -19,7 +19,6 @@
package org.elasticsearch.cluster.routing;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
import org.elasticsearch.cluster.node.DiscoveryNode;
@ -32,6 +31,7 @@ import org.elasticsearch.index.shard.ShardId;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@ -52,30 +52,30 @@ public class IndexShardRoutingTable implements Iterable<ShardRouting> {
final ShardId shardId;
final ShardRouting primary;
final ImmutableList<ShardRouting> primaryAsList;
final ImmutableList<ShardRouting> replicas;
final ImmutableList<ShardRouting> shards;
final ImmutableList<ShardRouting> activeShards;
final ImmutableList<ShardRouting> assignedShards;
final static ImmutableList<ShardRouting> NO_SHARDS = ImmutableList.of();
final List<ShardRouting> primaryAsList;
final List<ShardRouting> replicas;
final List<ShardRouting> shards;
final List<ShardRouting> activeShards;
final List<ShardRouting> assignedShards;
final static List<ShardRouting> NO_SHARDS = Collections.emptyList();
final boolean allShardsStarted;
/**
* The initializing list, including ones that are initializing on a target node because of relocation.
* If we can come up with a better variable name, it would be nice...
*/
final ImmutableList<ShardRouting> allInitializingShards;
final List<ShardRouting> allInitializingShards;
IndexShardRoutingTable(ShardId shardId, List<ShardRouting> shards) {
this.shardId = shardId;
this.shuffler = new RotationShardShuffler(ThreadLocalRandom.current().nextInt());
this.shards = ImmutableList.copyOf(shards);
this.shards = Collections.unmodifiableList(shards);
ShardRouting primary = null;
ImmutableList.Builder<ShardRouting> replicas = ImmutableList.builder();
ImmutableList.Builder<ShardRouting> activeShards = ImmutableList.builder();
ImmutableList.Builder<ShardRouting> assignedShards = ImmutableList.builder();
ImmutableList.Builder<ShardRouting> allInitializingShards = ImmutableList.builder();
List<ShardRouting> replicas = new ArrayList<>();
List<ShardRouting> activeShards = new ArrayList<>();
List<ShardRouting> assignedShards = new ArrayList<>();
List<ShardRouting> allInitializingShards = new ArrayList<>();
boolean allShardsStarted = true;
for (ShardRouting shard : shards) {
if (shard.primary()) {
@ -104,14 +104,14 @@ public class IndexShardRoutingTable implements Iterable<ShardRouting> {
this.primary = primary;
if (primary != null) {
this.primaryAsList = ImmutableList.of(primary);
this.primaryAsList = Collections.singletonList(primary);
} else {
this.primaryAsList = ImmutableList.of();
this.primaryAsList = Collections.emptyList();
}
this.replicas = replicas.build();
this.activeShards = activeShards.build();
this.assignedShards = assignedShards.build();
this.allInitializingShards = allInitializingShards.build();
this.replicas = Collections.unmodifiableList(replicas);
this.activeShards = Collections.unmodifiableList(activeShards);
this.assignedShards = Collections.unmodifiableList(assignedShards);
this.allInitializingShards = Collections.unmodifiableList(allInitializingShards);
}
/**
@ -145,7 +145,7 @@ public class IndexShardRoutingTable implements Iterable<ShardRouting> {
shardRoutings.add(new ShardRouting(shards.get(i), highestVersion));
}
}
return new IndexShardRoutingTable(shardId, ImmutableList.copyOf(shardRoutings));
return new IndexShardRoutingTable(shardId, Collections.unmodifiableList(shardRoutings));
}
/**
@ -468,11 +468,11 @@ public class IndexShardRoutingTable implements Iterable<ShardRouting> {
static class AttributesRoutings {
public final ImmutableList<ShardRouting> withSameAttribute;
public final ImmutableList<ShardRouting> withoutSameAttribute;
public final List<ShardRouting> withSameAttribute;
public final List<ShardRouting> withoutSameAttribute;
public final int totalSize;
AttributesRoutings(ImmutableList<ShardRouting> withSameAttribute, ImmutableList<ShardRouting> withoutSameAttribute) {
AttributesRoutings(List<ShardRouting> withSameAttribute, List<ShardRouting> withoutSameAttribute) {
this.withSameAttribute = withSameAttribute;
this.withoutSameAttribute = withoutSameAttribute;
this.totalSize = withoutSameAttribute.size() + withSameAttribute.size();
@ -488,9 +488,9 @@ public class IndexShardRoutingTable implements Iterable<ShardRouting> {
if (shardRoutings == null) {
synchronized (shardsByAttributeMutex) {
ArrayList<ShardRouting> from = new ArrayList<>(activeShards);
ImmutableList<ShardRouting> to = collectAttributeShards(key, nodes, from);
List<ShardRouting> to = collectAttributeShards(key, nodes, from);
shardRoutings = new AttributesRoutings(to, ImmutableList.copyOf(from));
shardRoutings = new AttributesRoutings(to, Collections.unmodifiableList(from));
activeShardsByAttributes = MapBuilder.newMapBuilder(activeShardsByAttributes).put(key, shardRoutings).immutableMap();
}
}
@ -502,15 +502,15 @@ public class IndexShardRoutingTable implements Iterable<ShardRouting> {
if (shardRoutings == null) {
synchronized (shardsByAttributeMutex) {
ArrayList<ShardRouting> from = new ArrayList<>(allInitializingShards);
ImmutableList<ShardRouting> to = collectAttributeShards(key, nodes, from);
shardRoutings = new AttributesRoutings(to, ImmutableList.copyOf(from));
List<ShardRouting> to = collectAttributeShards(key, nodes, from);
shardRoutings = new AttributesRoutings(to, Collections.unmodifiableList(from));
initializingShardsByAttributes = MapBuilder.newMapBuilder(initializingShardsByAttributes).put(key, shardRoutings).immutableMap();
}
}
return shardRoutings;
}
private static ImmutableList<ShardRouting> collectAttributeShards(AttributesKey key, DiscoveryNodes nodes, ArrayList<ShardRouting> from) {
private static List<ShardRouting> collectAttributeShards(AttributesKey key, DiscoveryNodes nodes, ArrayList<ShardRouting> from) {
final ArrayList<ShardRouting> to = new ArrayList<>();
for (final String attribute : key.attributes) {
final String localAttributeValue = nodes.localNode().attributes().get(attribute);
@ -527,7 +527,7 @@ public class IndexShardRoutingTable implements Iterable<ShardRouting> {
}
}
}
return ImmutableList.copyOf(to);
return Collections.unmodifiableList(to);
}
public ShardIterator preferAttributesActiveInitializingShardsIt(String[] attributes, DiscoveryNodes nodes) {
@ -616,7 +616,7 @@ public class IndexShardRoutingTable implements Iterable<ShardRouting> {
}
public IndexShardRoutingTable build() {
return new IndexShardRoutingTable(shardId, ImmutableList.copyOf(shards));
return new IndexShardRoutingTable(shardId, Collections.unmodifiableList(new ArrayList<>(shards)));
}
public static IndexShardRoutingTable readFrom(StreamInput in) throws IOException {

View File

@ -19,7 +19,6 @@
package org.elasticsearch.cluster.routing;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
@ -27,6 +26,7 @@ import org.elasticsearch.common.io.stream.Streamable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@ -53,7 +53,7 @@ public class RoutingTableValidation implements Streamable {
public List<String> allFailures() {
if (failures().isEmpty() && indicesFailures().isEmpty()) {
return ImmutableList.of();
return Collections.emptyList();
}
List<String> allFailures = new ArrayList<>(failures());
for (Map.Entry<String, List<String>> entry : indicesFailures().entrySet()) {
@ -66,7 +66,7 @@ public class RoutingTableValidation implements Streamable {
public List<String> failures() {
if (failures == null) {
return ImmutableList.of();
return Collections.emptyList();
}
return failures;
}
@ -80,11 +80,11 @@ public class RoutingTableValidation implements Streamable {
public List<String> indexFailures(String index) {
if (indicesFailures == null) {
return ImmutableList.of();
return Collections.emptyList();
}
List<String> indexFailures = indicesFailures.get(index);
if (indexFailures == null) {
return ImmutableList.of();
return Collections.emptyList();
}
return indexFailures;
}
@ -120,7 +120,7 @@ public class RoutingTableValidation implements Streamable {
valid = in.readBoolean();
int size = in.readVInt();
if (size == 0) {
failures = ImmutableList.of();
failures = Collections.emptyList();
} else {
failures = new ArrayList<>(size);
for (int i = 0; i < size; i++) {

View File

@ -20,7 +20,6 @@
package org.elasticsearch.cluster.routing.allocation;
import com.carrotsearch.hppc.cursors.ObjectCursor;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.cluster.ClusterInfoService;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexMetaData;
@ -40,6 +39,7 @@ import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -89,7 +89,7 @@ public class AllocationService extends AbstractComponent {
}
public RoutingAllocation.Result applyFailedShard(ClusterState clusterState, ShardRouting failedShard) {
return applyFailedShards(clusterState, ImmutableList.of(new FailedRerouteAllocation.FailedShard(failedShard, null, null)));
return applyFailedShards(clusterState, Collections.singletonList(new FailedRerouteAllocation.FailedShard(failedShard, null, null)));
}
/**

View File

@ -19,26 +19,28 @@
package org.elasticsearch.common.blobstore;
import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
/**
*
*/
public class BlobPath implements Iterable<String> {
private final ImmutableList<String> paths;
private final List<String> paths;
public BlobPath() {
this.paths = ImmutableList.of();
this.paths = Collections.emptyList();
}
public static BlobPath cleanPath() {
return new BlobPath();
}
private BlobPath(ImmutableList<String> paths) {
private BlobPath(List<String> paths) {
this.paths = paths;
}
@ -52,8 +54,10 @@ public class BlobPath implements Iterable<String> {
}
public BlobPath add(String path) {
ImmutableList.Builder<String> builder = ImmutableList.builder();
return new BlobPath(builder.addAll(paths).add(path).build());
List<String> paths = new ArrayList<>();
paths.addAll(this.paths);
paths.add(path);
return new BlobPath(Collections.unmodifiableList(paths));
}
public String buildAsString(String separator) {

View File

@ -16,13 +16,13 @@
package org.elasticsearch.common.inject;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.common.inject.internal.Errors;
import org.elasticsearch.common.inject.spi.InjectionListener;
import org.elasticsearch.common.inject.spi.Message;
import org.elasticsearch.common.inject.spi.TypeEncounter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static com.google.common.base.Preconditions.checkState;
@ -47,16 +47,16 @@ final class EncounterImpl<T> implements TypeEncounter<T> {
valid = false;
}
public ImmutableList<MembersInjector<? super T>> getMembersInjectors() {
public List<MembersInjector<? super T>> getMembersInjectors() {
return membersInjectors == null
? ImmutableList.<MembersInjector<? super T>>of()
: ImmutableList.copyOf(membersInjectors);
? Collections.<MembersInjector<? super T>>emptyList()
: Collections.unmodifiableList(membersInjectors);
}
public ImmutableList<InjectionListener<? super T>> getInjectionListeners() {
public List<InjectionListener<? super T>> getInjectionListeners() {
return injectionListeners == null
? ImmutableList.<InjectionListener<? super T>>of()
: ImmutableList.copyOf(injectionListeners);
? Collections.<InjectionListener<? super T>>emptyList()
: Collections.unmodifiableList(injectionListeners);
}
@Override

View File

@ -16,7 +16,6 @@
package org.elasticsearch.common.inject;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.common.inject.internal.Errors;
import org.elasticsearch.common.inject.internal.ErrorsException;
import org.elasticsearch.common.inject.internal.InternalContext;
@ -85,7 +84,7 @@ class InjectionRequestProcessor extends AbstractProcessor {
final InjectorImpl injector;
final Object source;
final StaticInjectionRequest request;
ImmutableList<SingleMemberInjector> memberInjectors;
List<SingleMemberInjector> memberInjectors;
public StaticInjection(InjectorImpl injector, StaticInjectionRequest request) {
this.injector = injector;

View File

@ -16,7 +16,6 @@
package org.elasticsearch.common.inject;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import org.elasticsearch.common.Classes;
@ -49,6 +48,7 @@ import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@ -164,7 +164,7 @@ class InjectorImpl implements Injector, Lookups {
@Override
public Injector createChildInjector(Module... modules) {
return createChildInjector(ImmutableList.copyOf(modules));
return createChildInjector(Arrays.asList(modules));
}
/**
@ -716,7 +716,7 @@ class InjectorImpl implements Injector, Lookups {
List<Binding<?>> bindings = multimap.get(type);
return bindings != null
? Collections.<Binding<T>>unmodifiableList((List) multimap.get(type))
: ImmutableList.<Binding<T>>of();
: Collections.<Binding<T>>emptyList();
}
}

View File

@ -16,7 +16,6 @@
package org.elasticsearch.common.inject;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import org.elasticsearch.common.inject.internal.Errors;
import org.elasticsearch.common.inject.internal.ErrorsException;
@ -24,6 +23,8 @@ import org.elasticsearch.common.inject.internal.InternalContext;
import org.elasticsearch.common.inject.spi.InjectionListener;
import org.elasticsearch.common.inject.spi.InjectionPoint;
import java.util.List;
/**
* Injects members of instances of a given type.
*
@ -32,12 +33,12 @@ import org.elasticsearch.common.inject.spi.InjectionPoint;
class MembersInjectorImpl<T> implements MembersInjector<T> {
private final TypeLiteral<T> typeLiteral;
private final InjectorImpl injector;
private final ImmutableList<SingleMemberInjector> memberInjectors;
private final ImmutableList<MembersInjector<? super T>> userMembersInjectors;
private final ImmutableList<InjectionListener<? super T>> injectionListeners;
private final List<SingleMemberInjector> memberInjectors;
private final List<MembersInjector<? super T>> userMembersInjectors;
private final List<InjectionListener<? super T>> injectionListeners;
MembersInjectorImpl(InjectorImpl injector, TypeLiteral<T> typeLiteral,
EncounterImpl<T> encounter, ImmutableList<SingleMemberInjector> memberInjectors) {
EncounterImpl<T> encounter, List<SingleMemberInjector> memberInjectors) {
this.injector = injector;
this.typeLiteral = typeLiteral;
this.memberInjectors = memberInjectors;
@ -45,7 +46,7 @@ class MembersInjectorImpl<T> implements MembersInjector<T> {
this.injectionListeners = encounter.getInjectionListeners();
}
public ImmutableList<SingleMemberInjector> getMemberInjectors() {
public List<SingleMemberInjector> getMemberInjectors() {
return memberInjectors;
}

View File

@ -16,7 +16,6 @@
package org.elasticsearch.common.inject;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.common.inject.internal.Errors;
import org.elasticsearch.common.inject.internal.ErrorsException;
import org.elasticsearch.common.inject.internal.FailableCache;
@ -25,6 +24,7 @@ import org.elasticsearch.common.inject.spi.TypeListenerBinding;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
@ -35,7 +35,7 @@ import java.util.Set;
*/
class MembersInjectorStore {
private final InjectorImpl injector;
private final ImmutableList<TypeListenerBinding> typeListenerBindings;
private final List<TypeListenerBinding> typeListenerBindings;
private final FailableCache<TypeLiteral<?>, MembersInjectorImpl<?>> cache
= new FailableCache<TypeLiteral<?>, MembersInjectorImpl<?>>() {
@ -49,7 +49,7 @@ class MembersInjectorStore {
MembersInjectorStore(InjectorImpl injector,
List<TypeListenerBinding> typeListenerBindings) {
this.injector = injector;
this.typeListenerBindings = ImmutableList.copyOf(typeListenerBindings);
this.typeListenerBindings = Collections.unmodifiableList(typeListenerBindings);
}
/**
@ -82,7 +82,7 @@ class MembersInjectorStore {
errors.merge(e.getErrorMessages());
injectionPoints = e.getPartialValue();
}
ImmutableList<SingleMemberInjector> injectors = getInjectors(injectionPoints, errors);
List<SingleMemberInjector> injectors = getInjectors(injectionPoints, errors);
errors.throwIfNewErrors(numErrorsBefore);
EncounterImpl<T> encounter = new EncounterImpl<>(errors, injector.lookups);
@ -104,7 +104,7 @@ class MembersInjectorStore {
/**
* Returns the injectors for the specified injection points.
*/
ImmutableList<SingleMemberInjector> getInjectors(
List<SingleMemberInjector> getInjectors(
Set<InjectionPoint> injectionPoints, Errors errors) {
List<SingleMemberInjector> injectors = new ArrayList<>();
for (InjectionPoint injectionPoint : injectionPoints) {
@ -120,6 +120,6 @@ class MembersInjectorStore {
// ignored for now
}
}
return ImmutableList.copyOf(injectors);
return Collections.unmodifiableList(injectors);
}
}

View File

@ -16,12 +16,12 @@
package org.elasticsearch.common.inject;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import org.elasticsearch.common.inject.internal.Errors;
import org.elasticsearch.common.inject.spi.Message;
import java.util.Collection;
import java.util.Collections;
import static com.google.common.base.Preconditions.checkArgument;
@ -47,7 +47,7 @@ public final class ProvisionException extends RuntimeException {
public ProvisionException(String message, Throwable cause) {
super(cause);
this.messages = ImmutableSet.of(new Message(ImmutableList.of(), message, cause));
this.messages = ImmutableSet.of(new Message(Collections.emptyList(), message, cause));
}
public ProvisionException(String message) {

View File

@ -16,7 +16,6 @@
package org.elasticsearch.common.inject;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import org.elasticsearch.common.inject.internal.BindingImpl;
import org.elasticsearch.common.inject.internal.Errors;
@ -24,6 +23,7 @@ import org.elasticsearch.common.inject.internal.MatcherAndConverter;
import org.elasticsearch.common.inject.spi.TypeListenerBinding;
import java.lang.annotation.Annotation;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@ -89,7 +89,7 @@ interface State {
@Override
public List<TypeListenerBinding> getTypeListenerBindings() {
return ImmutableList.of();
return Collections.emptyList();
}
@Override

View File

@ -16,11 +16,12 @@
package org.elasticsearch.common.inject;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.common.inject.internal.MoreTypes;
import org.elasticsearch.common.inject.util.Types;
import java.lang.reflect.*;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import static com.google.common.base.Preconditions.checkArgument;
@ -174,7 +175,7 @@ public class TypeLiteral<T> {
for (int t = 0; t < types.length; t++) {
result[t] = resolve(types[t]);
}
return ImmutableList.copyOf(result);
return Arrays.asList(result);
}
/**

View File

@ -16,7 +16,6 @@
package org.elasticsearch.common.inject.assistedinject;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import org.elasticsearch.common.inject.AbstractModule;
@ -41,6 +40,7 @@ import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import static com.google.common.base.Preconditions.checkState;
@ -91,7 +91,7 @@ final class FactoryProvider2<F> implements InvocationHandler, Provider<F> {
*/
private final Key<?> producedType;
private final ImmutableMap<Method, Key<?>> returnTypesByMethod;
private final ImmutableMap<Method, ImmutableList<Key<?>>> paramTypes;
private final ImmutableMap<Method, List<Key<?>>> paramTypes;
/**
* the hosting injector, or null if we haven't been initialized yet
@ -118,7 +118,7 @@ final class FactoryProvider2<F> implements InvocationHandler, Provider<F> {
try {
ImmutableMap.Builder<Method, Key<?>> returnTypesBuilder = ImmutableMap.builder();
ImmutableMap.Builder<Method, ImmutableList<Key<?>>> paramTypesBuilder
ImmutableMap.Builder<Method, List<Key<?>>> paramTypesBuilder
= ImmutableMap.builder();
// TODO: also grab methods from superinterfaces
for (Method method : factoryRawType.getMethods()) {
@ -133,7 +133,7 @@ final class FactoryProvider2<F> implements InvocationHandler, Provider<F> {
Key<?> paramKey = getKey(param, method, paramAnnotations[p++], errors);
keys.add(assistKey(method, paramKey, errors));
}
paramTypesBuilder.put(method, ImmutableList.copyOf(keys));
paramTypesBuilder.put(method, Collections.unmodifiableList(keys));
}
returnTypesByMethod = returnTypesBuilder.build();
paramTypes = paramTypesBuilder.build();
@ -175,7 +175,7 @@ final class FactoryProvider2<F> implements InvocationHandler, Provider<F> {
@Inject
void initialize(Injector injector) {
if (this.injector != null) {
throw new ConfigurationException(ImmutableList.of(new Message(FactoryProvider2.class,
throw new ConfigurationException(Collections.singletonList(new Message(FactoryProvider2.class,
"Factories.create() factories may only be used in one Injector!")));
}

View File

@ -16,7 +16,6 @@
package org.elasticsearch.common.inject.internal;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import org.apache.lucene.util.CollectionUtil;
import org.elasticsearch.common.inject.ConfigurationException;
@ -42,7 +41,9 @@ import java.lang.reflect.Field;
import java.lang.reflect.Member;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Formatter;
import java.util.List;
@ -451,7 +452,7 @@ public final class Errors implements Serializable {
public List<Message> getMessages() {
if (root.errors == null) {
return ImmutableList.of();
return Collections.emptyList();
}
List<Message> result = new ArrayList<>(root.errors);
@ -568,7 +569,7 @@ public final class Errors implements Serializable {
abstract String toString(T t);
}
private static final Collection<Converter<?>> converters = ImmutableList.of(
private static final Collection<Converter<?>> converters = Arrays.asList(
new Converter<Class>(Class.class) {
@Override
public String toString(Class c) {

View File

@ -16,7 +16,6 @@
package org.elasticsearch.common.inject.internal;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import org.elasticsearch.common.inject.Binder;
@ -28,6 +27,7 @@ import org.elasticsearch.common.inject.spi.ElementVisitor;
import org.elasticsearch.common.inject.spi.PrivateElements;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -53,7 +53,7 @@ public final class PrivateElementsImpl implements PrivateElements {
/**
* lazily instantiated
*/
private ImmutableList<Element> elements;
private List<Element> elements;
/**
* lazily instantiated
@ -73,7 +73,7 @@ public final class PrivateElementsImpl implements PrivateElements {
@Override
public List<Element> getElements() {
if (elements == null) {
elements = ImmutableList.copyOf(elementsMutable);
elements = Collections.unmodifiableList(elementsMutable);
elementsMutable = null;
}

View File

@ -16,7 +16,6 @@
package org.elasticsearch.common.inject.multibindings;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import org.elasticsearch.common.inject.Binder;
import org.elasticsearch.common.inject.Binding;
@ -328,6 +327,6 @@ public abstract class Multibinder<T> {
NullPointerException npe = new NullPointerException(name);
throw new ConfigurationException(ImmutableSet.of(
new Message(ImmutableList.of(), npe.toString(), npe)));
new Message(Collections.emptyList(), npe.toString(), npe)));
}
}

View File

@ -16,7 +16,6 @@
package org.elasticsearch.common.inject.spi;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Sets;
import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.common.inject.Binder;
@ -260,7 +259,7 @@ public final class Elements {
@Override
public void addError(Throwable t) {
String message = "An exception was caught and reported. Message: " + t.getMessage();
elements.add(new Message(ImmutableList.of(getSource()), message, t));
elements.add(new Message(Collections.singletonList(getSource()), message, t));
}
@Override

View File

@ -16,7 +16,6 @@
package org.elasticsearch.common.inject.spi;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import org.elasticsearch.common.inject.ConfigurationException;
import org.elasticsearch.common.inject.Inject;
@ -38,6 +37,7 @@ import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@ -56,10 +56,10 @@ public final class InjectionPoint {
private final boolean optional;
private final Member member;
private final ImmutableList<Dependency<?>> dependencies;
private final List<Dependency<?>> dependencies;
private InjectionPoint(Member member,
ImmutableList<Dependency<?>> dependencies, boolean optional) {
List<Dependency<?>> dependencies, boolean optional) {
this.member = member;
this.dependencies = dependencies;
this.optional = optional;
@ -97,11 +97,11 @@ public final class InjectionPoint {
}
errors.throwConfigurationExceptionIfErrorsExist();
this.dependencies = ImmutableList.<Dependency<?>>of(
this.dependencies = Collections.<Dependency<?>>singletonList(
newDependency(key, Nullability.allowsNull(annotations), -1));
}
private ImmutableList<Dependency<?>> forMember(Member member, TypeLiteral<?> type,
private List<Dependency<?>> forMember(Member member, TypeLiteral<?> type,
Annotation[][] parameterAnnotations) {
Errors errors = new Errors(member);
Iterator<Annotation[]> annotationsIterator = Arrays.asList(parameterAnnotations).iterator();
@ -121,7 +121,7 @@ public final class InjectionPoint {
}
errors.throwConfigurationExceptionIfErrorsExist();
return ImmutableList.copyOf(dependencies);
return Collections.unmodifiableList(dependencies);
}
// This metohd is necessary to create a Dependency<T> with proper generic type information

View File

@ -17,13 +17,14 @@
package org.elasticsearch.common.inject.spi;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.common.inject.Binder;
import org.elasticsearch.common.inject.internal.Errors;
import org.elasticsearch.common.inject.internal.SourceProvider;
import java.io.ObjectStreamException;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import static com.google.common.base.Preconditions.checkNotNull;
@ -50,17 +51,17 @@ public final class Message implements Serializable, Element {
* @since 2.0
*/
public Message(List<Object> sources, String message, Throwable cause) {
this.sources = ImmutableList.copyOf(sources);
this.sources = Collections.unmodifiableList(sources);
this.message = checkNotNull(message, "message");
this.cause = cause;
}
public Message(Object source, String message) {
this(ImmutableList.of(source), message, null);
this(Collections.singletonList(source), message, null);
}
public Message(String message) {
this(ImmutableList.of(), message, null);
this(Collections.emptyList(), message, null);
}
@Override
@ -138,7 +139,7 @@ public final class Message implements Serializable, Element {
for (int i = 0; i < sourcesAsStrings.length; i++) {
sourcesAsStrings[i] = Errors.convert(sourcesAsStrings[i]).toString();
}
return new Message(ImmutableList.copyOf(sourcesAsStrings), message, cause);
return new Message(Arrays.asList(sourcesAsStrings), message, cause);
}
private static final long serialVersionUID = 0;

View File

@ -19,7 +19,6 @@
package org.elasticsearch.common.logging.log4j;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.apache.log4j.PropertyConfigurator;
import org.elasticsearch.ElasticsearchException;
@ -35,6 +34,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.Arrays;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
@ -47,7 +47,7 @@ import static org.elasticsearch.common.settings.Settings.settingsBuilder;
*/
public class LogConfigurator {
static final List<String> ALLOWED_SUFFIXES = ImmutableList.of(".yml", ".yaml", ".json", ".properties");
static final List<String> ALLOWED_SUFFIXES = Arrays.asList(".yml", ".yaml", ".json", ".properties");
private static boolean loaded;

View File

@ -19,10 +19,10 @@
package org.elasticsearch.common.util.concurrent;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.ElasticsearchGenerationException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.atomic.AtomicReferenceArray;
@ -93,7 +93,7 @@ public class AtomicArray<E> {
public List<Entry<E>> asList() {
if (nonNullList == null) {
if (array == null || array.length() == 0) {
nonNullList = ImmutableList.of();
nonNullList = Collections.emptyList();
} else {
List<Entry<E>> list = new ArrayList<>(array.length());
for (int i = 0; i < array.length(); i++) {

View File

@ -23,7 +23,6 @@ import com.fasterxml.jackson.core.Base64Variant;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.SerializableString;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.xcontent.json.BaseJsonGenerator;
@ -34,6 +33,8 @@ import java.io.OutputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Queue;
@ -61,7 +62,7 @@ public class FilteringJsonGenerator extends BaseJsonGenerator {
public FilteringJsonGenerator(JsonGenerator generator, String[] filters) {
super(generator);
ImmutableList.Builder<String[]> builder = ImmutableList.builder();
List<String[]> builder = new ArrayList<>();
if (filters != null) {
for (String filter : filters) {
String[] matcher = Strings.delimitedListToStringArray(filter, ".");
@ -72,7 +73,7 @@ public class FilteringJsonGenerator extends BaseJsonGenerator {
}
// Creates a root context that matches all filtering rules
this.context = get(null, null, builder.build());
this.context = get(null, null, Collections.unmodifiableList(builder));
}
/**

View File

@ -28,6 +28,8 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
import org.elasticsearch.env.NodeEnvironment;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
@ -139,7 +141,7 @@ public class DanglingIndicesState extends AbstractComponent {
return;
}
try {
allocateDangledIndices.allocateDangled(ImmutableList.copyOf(danglingIndices.values()), new LocalAllocateDangledIndices.Listener() {
allocateDangledIndices.allocateDangled(Collections.unmodifiableCollection(new ArrayList<>(danglingIndices.values())), new LocalAllocateDangledIndices.Listener() {
@Override
public void onResponse(LocalAllocateDangledIndices.AllocateDangledResponse response) {
logger.trace("allocated dangled");

View File

@ -19,7 +19,6 @@
package org.elasticsearch.index.fielddata;
import com.google.common.collect.ImmutableList;
import org.apache.lucene.index.SortedNumericDocValues;
import org.apache.lucene.util.BytesRef;
@ -30,6 +29,7 @@ import org.joda.time.DateTimeZone;
import org.joda.time.MutableDateTime;
import java.util.AbstractList;
import java.util.Collections;
import java.util.List;
@ -85,7 +85,7 @@ public interface ScriptDocValues<T> extends List<T> {
@Override
public List<String> getValues() {
return ImmutableList.copyOf(this);
return Collections.unmodifiableList(this);
}
@Override
@ -128,7 +128,7 @@ public interface ScriptDocValues<T> extends List<T> {
@Override
public List<Long> getValues() {
return ImmutableList.copyOf(this);
return Collections.unmodifiableList(this);
}
public MutableDateTime getDate() {
@ -175,7 +175,7 @@ public interface ScriptDocValues<T> extends List<T> {
@Override
public List<Double> getValues() {
return ImmutableList.copyOf(this);
return Collections.unmodifiableList(this);
}
@Override
@ -238,7 +238,7 @@ public interface ScriptDocValues<T> extends List<T> {
@Override
public List<GeoPoint> getValues() {
return ImmutableList.copyOf(this);
return Collections.unmodifiableList(this);
}
@Override

View File

@ -19,7 +19,6 @@
package org.elasticsearch.index.get;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Sets;
import org.apache.lucene.index.Term;
@ -49,6 +48,7 @@ import org.elasticsearch.search.lookup.SearchLookup;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@ -258,7 +258,7 @@ public final class ShardGetService extends AbstractIndexShardComponent {
if (value instanceof List) {
fields.put(field, new GetField(field, (List) value));
} else {
fields.put(field, new GetField(field, ImmutableList.of(value)));
fields.put(field, new GetField(field, Collections.singletonList(value)));
}
}
}
@ -383,7 +383,7 @@ public final class ShardGetService extends AbstractIndexShardComponent {
if (value instanceof List) {
fields.put(field, new GetField(field, (List) value));
} else {
fields.put(field, new GetField(field, ImmutableList.of(value)));
fields.put(field, new GetField(field, Collections.singletonList(value)));
}
}
}

View File

@ -22,7 +22,6 @@ package org.elasticsearch.index.mapper;
import com.carrotsearch.hppc.cursors.ObjectCursor;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterators;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
@ -695,9 +694,9 @@ public abstract class FieldMapper extends Mapper {
*/
public static class CopyTo {
private final ImmutableList<String> copyToFields;
private final List<String> copyToFields;
private CopyTo(ImmutableList<String> copyToFields) {
private CopyTo(List<String> copyToFields) {
this.copyToFields = copyToFields;
}
@ -713,7 +712,7 @@ public abstract class FieldMapper extends Mapper {
}
public static class Builder {
private final ImmutableList.Builder<String> copyToBuilders = ImmutableList.builder();
private final List<String> copyToBuilders = new ArrayList<>();
public Builder add(String field) {
copyToBuilders.add(field);
@ -721,7 +720,7 @@ public abstract class FieldMapper extends Mapper {
}
public CopyTo build() {
return new CopyTo(copyToBuilders.build());
return new CopyTo(Collections.unmodifiableList(copyToBuilders));
}
}

View File

@ -22,7 +22,6 @@ package org.elasticsearch.index.mapper;
import com.carrotsearch.hppc.ObjectHashSet;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterators;
@ -31,8 +30,12 @@ import org.apache.lucene.analysis.DelegatingAnalyzerWrapper;
import org.apache.lucene.index.IndexOptions;
import org.apache.lucene.index.Term;
import org.apache.lucene.queries.TermsQuery;
import org.apache.lucene.search.*;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.ConstantScoreQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.ElasticsearchGenerationException;
import org.elasticsearch.Version;
@ -59,7 +62,13 @@ import org.elasticsearch.script.ScriptService;
import java.io.Closeable;
import java.io.IOException;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.locks.ReentrantReadWriteLock;
@ -519,7 +528,7 @@ public class MapperService extends AbstractIndexComponent implements Closeable {
public Collection<String> simpleMatchToIndexNames(String pattern) {
if (Regex.isSimpleMatchPattern(pattern) == false) {
// no wildcards
return ImmutableList.of(pattern);
return Collections.singletonList(pattern);
}
return fieldTypes.simpleMatchToIndexNames(pattern);
}

View File

@ -1,124 +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.index.mapper;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.UnmodifiableIterator;
import org.elasticsearch.index.mapper.object.ObjectMapper;
/**
* A holder for several {@link org.elasticsearch.index.mapper.object.ObjectMapper}.
*/
public class ObjectMappers implements Iterable<ObjectMapper> {
private final ImmutableList<ObjectMapper> objectMappers;
private final boolean hasNested;
public ObjectMappers() {
this(ImmutableList.<ObjectMapper>of());
}
public ObjectMappers(ObjectMapper objectMapper) {
this(new ObjectMapper[]{objectMapper});
}
public ObjectMappers(ObjectMapper[] objectMappers) {
this(ImmutableList.copyOf(objectMappers));
}
public ObjectMappers(ImmutableList<ObjectMapper> objectMappers) {
this.objectMappers = objectMappers;
boolean hasNested = false;
for (ObjectMapper objectMapper : objectMappers) {
if (objectMapper.nested().isNested()) {
hasNested = true;
break;
}
}
this.hasNested = hasNested;
}
/**
* Is one of the object mappers has a nested mapping set?
*/
public boolean hasNested() {
return this.hasNested;
}
public ObjectMapper mapper() {
if (objectMappers.isEmpty()) {
return null;
}
return objectMappers.get(0);
}
public boolean isEmpty() {
return objectMappers.isEmpty();
}
public ImmutableList<ObjectMapper> mappers() {
return this.objectMappers;
}
@Override
public UnmodifiableIterator<ObjectMapper> iterator() {
return objectMappers.iterator();
}
/**
* Concats and returns a new {@link org.elasticsearch.index.mapper.ObjectMappers}.
*/
public ObjectMappers concat(ObjectMapper mapper) {
return new ObjectMappers(new ImmutableList.Builder<ObjectMapper>().addAll(objectMappers).add(mapper).build());
}
/**
* Concats and returns a new {@link org.elasticsearch.index.mapper.ObjectMappers}.
*/
public ObjectMappers concat(ObjectMappers mappers) {
return new ObjectMappers(new ImmutableList.Builder<ObjectMapper>().addAll(objectMappers).addAll(mappers).build());
}
public ObjectMappers remove(Iterable<ObjectMapper> mappers) {
ImmutableList.Builder<ObjectMapper> builder = new ImmutableList.Builder<>();
for (ObjectMapper objectMapper : objectMappers) {
boolean found = false;
for (ObjectMapper mapper : mappers) {
if (objectMapper == mapper) { // identify equality
found = true;
}
}
if (!found) {
builder.add(objectMapper);
}
}
return new ObjectMappers(builder.build());
}
public ObjectMappers remove(ObjectMapper mapper) {
ImmutableList.Builder<ObjectMapper> builder = new ImmutableList.Builder<>();
for (ObjectMapper objectMapper : objectMappers) {
if (objectMapper != mapper) { // identify equality
builder.add(objectMapper);
}
}
return new ObjectMappers(builder.build());
}
}

View File

@ -19,7 +19,6 @@
package org.elasticsearch.index.query;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import org.apache.lucene.queries.TermsQuery;
@ -34,6 +33,7 @@ import org.elasticsearch.index.mapper.internal.UidFieldMapper;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/**
@ -96,7 +96,7 @@ public class IdsQueryParser implements QueryParser {
}
} else if (token.isValue()) {
if ("type".equals(currentFieldName) || "_type".equals(currentFieldName)) {
types = ImmutableList.of(parser.text());
types = Collections.singletonList(parser.text());
} else if ("boost".equals(currentFieldName)) {
boost = parser.floatValue();
} else if ("_name".equals(currentFieldName)) {

View File

@ -19,12 +19,12 @@
package org.elasticsearch.index.search.stats;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.search.SearchParseElement;
import org.elasticsearch.search.internal.SearchContext;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
@ -35,7 +35,7 @@ public class StatsGroupsParseElement implements SearchParseElement {
public void parse(XContentParser parser, SearchContext context) throws Exception {
XContentParser.Token token = parser.currentToken();
if (token.isValue()) {
context.groupStats(ImmutableList.of(parser.text()));
context.groupStats(Collections.singletonList(parser.text()));
} else if (token == XContentParser.Token.START_ARRAY) {
List<String> groupStats = new ArrayList<>(4);
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {

View File

@ -19,10 +19,11 @@
package org.elasticsearch.index.shard;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.index.store.StoreFileMetaData;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
@ -30,7 +31,7 @@ import java.util.List;
*/
public class CommitPoint {
public static final CommitPoint NULL = new CommitPoint(-1, "_null_", Type.GENERATED, ImmutableList.<CommitPoint.FileInfo>of(), ImmutableList.<CommitPoint.FileInfo>of());
public static final CommitPoint NULL = new CommitPoint(-1, "_null_", Type.GENERATED, Collections.<CommitPoint.FileInfo>emptyList(), Collections.<CommitPoint.FileInfo>emptyList());
public static class FileInfo {
private final String name;
@ -81,16 +82,16 @@ public class CommitPoint {
private final Type type;
private final ImmutableList<FileInfo> indexFiles;
private final List<FileInfo> indexFiles;
private final ImmutableList<FileInfo> translogFiles;
private final List<FileInfo> translogFiles;
public CommitPoint(long version, String name, Type type, List<FileInfo> indexFiles, List<FileInfo> translogFiles) {
this.version = version;
this.name = name;
this.type = type;
this.indexFiles = ImmutableList.copyOf(indexFiles);
this.translogFiles = ImmutableList.copyOf(translogFiles);
this.indexFiles = Collections.unmodifiableList(new ArrayList<>(indexFiles));
this.translogFiles = Collections.unmodifiableList(new ArrayList<>(translogFiles));
}
public long version() {

View File

@ -19,7 +19,6 @@
package org.elasticsearch.index.shard;
import com.google.common.collect.ImmutableList;
import org.apache.lucene.util.CollectionUtil;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
@ -28,6 +27,7 @@ import org.elasticsearch.common.xcontent.XContentType;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
@ -37,7 +37,7 @@ import java.util.List;
*/
public class CommitPoints implements Iterable<CommitPoint> {
private final ImmutableList<CommitPoint> commitPoints;
private final List<CommitPoint> commitPoints;
public CommitPoints(List<CommitPoint> commitPoints) {
CollectionUtil.introSort(commitPoints, new Comparator<CommitPoint>() {
@ -46,7 +46,7 @@ public class CommitPoints implements Iterable<CommitPoint> {
return (o2.version() < o1.version() ? -1 : (o2.version() == o1.version() ? 0 : 1));
}
});
this.commitPoints = ImmutableList.copyOf(commitPoints);
this.commitPoints = Collections.unmodifiableList(new ArrayList<>(commitPoints));
}
public List<CommitPoint> commits() {

View File

@ -19,7 +19,6 @@
package org.elasticsearch.index.snapshots.blobstore;
import com.google.common.collect.ImmutableList;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.Version;
import org.elasticsearch.ElasticsearchParseException;
@ -38,6 +37,7 @@ import org.elasticsearch.index.store.StoreFileMetaData;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
@ -326,7 +326,7 @@ public class BlobStoreIndexShardSnapshot implements ToXContent, FromXContentBuil
private final long totalSize;
private final ImmutableList<FileInfo> indexFiles;
private final List<FileInfo> indexFiles;
/**
* Constructs new shard snapshot metadata from snapshot metadata
@ -345,7 +345,7 @@ public class BlobStoreIndexShardSnapshot implements ToXContent, FromXContentBuil
assert indexVersion >= 0;
this.snapshot = snapshot;
this.indexVersion = indexVersion;
this.indexFiles = ImmutableList.copyOf(indexFiles);
this.indexFiles = Collections.unmodifiableList(new ArrayList<>(indexFiles));
this.startTime = startTime;
this.time = time;
this.numberOfFiles = numberOfFiles;
@ -358,7 +358,7 @@ public class BlobStoreIndexShardSnapshot implements ToXContent, FromXContentBuil
private BlobStoreIndexShardSnapshot() {
this.snapshot = "";
this.indexVersion = 0;
this.indexFiles = ImmutableList.of();
this.indexFiles = Collections.emptyList();
this.startTime = 0;
this.time = 0;
this.numberOfFiles = 0;
@ -523,7 +523,7 @@ public class BlobStoreIndexShardSnapshot implements ToXContent, FromXContentBuil
}
}
}
return new BlobStoreIndexShardSnapshot(snapshot, indexVersion, ImmutableList.copyOf(indexFiles),
return new BlobStoreIndexShardSnapshot(snapshot, indexVersion, Collections.unmodifiableList(indexFiles),
startTime, time, numberOfFiles, totalSize);
}
}

View File

@ -19,7 +19,6 @@
package org.elasticsearch.index.snapshots.blobstore;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.common.ParseField;
@ -33,6 +32,7 @@ import org.elasticsearch.index.snapshots.blobstore.BlobStoreIndexShardSnapshot.F
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@ -49,12 +49,12 @@ public class BlobStoreIndexShardSnapshots implements Iterable<SnapshotFiles>, To
public static final BlobStoreIndexShardSnapshots PROTO = new BlobStoreIndexShardSnapshots();
private final ImmutableList<SnapshotFiles> shardSnapshots;
private final List<SnapshotFiles> shardSnapshots;
private final ImmutableMap<String, FileInfo> files;
private final ImmutableMap<String, ImmutableList<FileInfo>> physicalFiles;
private final ImmutableMap<String, List<FileInfo>> physicalFiles;
public BlobStoreIndexShardSnapshots(List<SnapshotFiles> shardSnapshots) {
this.shardSnapshots = ImmutableList.copyOf(shardSnapshots);
this.shardSnapshots = Collections.unmodifiableList(new ArrayList<>(shardSnapshots));
// Map between blob names and file info
Map<String, FileInfo> newFiles = newHashMap();
// Map between original physical names and file info
@ -78,15 +78,15 @@ public class BlobStoreIndexShardSnapshots implements Iterable<SnapshotFiles>, To
physicalFileList.add(newFiles.get(fileInfo.name()));
}
}
ImmutableMap.Builder<String, ImmutableList<FileInfo>> mapBuilder = ImmutableMap.builder();
ImmutableMap.Builder<String, List<FileInfo>> mapBuilder = ImmutableMap.builder();
for (Map.Entry<String, List<FileInfo>> entry : physicalFiles.entrySet()) {
mapBuilder.put(entry.getKey(), ImmutableList.copyOf(entry.getValue()));
mapBuilder.put(entry.getKey(), Collections.unmodifiableList(new ArrayList<>(entry.getValue())));
}
this.physicalFiles = mapBuilder.build();
this.files = ImmutableMap.copyOf(newFiles);
}
private BlobStoreIndexShardSnapshots(ImmutableMap<String, FileInfo> files, ImmutableList<SnapshotFiles> shardSnapshots) {
private BlobStoreIndexShardSnapshots(ImmutableMap<String, FileInfo> files, List<SnapshotFiles> shardSnapshots) {
this.shardSnapshots = shardSnapshots;
this.files = files;
Map<String, List<FileInfo>> physicalFiles = newHashMap();
@ -100,15 +100,15 @@ public class BlobStoreIndexShardSnapshots implements Iterable<SnapshotFiles>, To
physicalFileList.add(files.get(fileInfo.name()));
}
}
ImmutableMap.Builder<String, ImmutableList<FileInfo>> mapBuilder = ImmutableMap.builder();
ImmutableMap.Builder<String, List<FileInfo>> mapBuilder = ImmutableMap.builder();
for (Map.Entry<String, List<FileInfo>> entry : physicalFiles.entrySet()) {
mapBuilder.put(entry.getKey(), ImmutableList.copyOf(entry.getValue()));
mapBuilder.put(entry.getKey(), Collections.unmodifiableList(new ArrayList<>(entry.getValue())));
}
this.physicalFiles = mapBuilder.build();
}
private BlobStoreIndexShardSnapshots() {
shardSnapshots = ImmutableList.of();
shardSnapshots = Collections.emptyList();
files = ImmutableMap.of();
physicalFiles = ImmutableMap.of();
}
@ -289,17 +289,17 @@ public class BlobStoreIndexShardSnapshots implements Iterable<SnapshotFiles>, To
}
ImmutableMap<String, FileInfo> files = filesBuilder.build();
ImmutableList.Builder<SnapshotFiles> snapshots = ImmutableList.builder();
List<SnapshotFiles> snapshots = new ArrayList<>();
for (Map.Entry<String, List<String>> entry : snapshotsMap.entrySet()) {
ImmutableList.Builder<FileInfo> fileInfosBuilder = ImmutableList.builder();
List<FileInfo> fileInfosBuilder = new ArrayList<>();
for (String file : entry.getValue()) {
FileInfo fileInfo = files.get(file);
assert fileInfo != null;
fileInfosBuilder.add(fileInfo);
}
snapshots.add(new SnapshotFiles(entry.getKey(), fileInfosBuilder.build()));
snapshots.add(new SnapshotFiles(entry.getKey(), Collections.unmodifiableList(fileInfosBuilder)));
}
return new BlobStoreIndexShardSnapshots(files, snapshots.build());
return new BlobStoreIndexShardSnapshots(files, Collections.unmodifiableList(snapshots));
}
}

View File

@ -18,7 +18,6 @@
*/
package org.elasticsearch.index.snapshots.blobstore;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.index.snapshots.blobstore.BlobStoreIndexShardSnapshot.FileInfo;
import java.util.List;

View File

@ -19,7 +19,6 @@
package org.elasticsearch.index.store;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import org.apache.lucene.codecs.CodecUtil;
@ -1005,9 +1004,9 @@ public class Store extends AbstractIndexShardComponent implements Closeable, Ref
* NOTE: this diff will not contain the <tt>segments.gen</tt> file. This file is omitted on recovery.
*/
public RecoveryDiff recoveryDiff(MetadataSnapshot recoveryTargetSnapshot) {
final ImmutableList.Builder<StoreFileMetaData> identical = ImmutableList.builder();
final ImmutableList.Builder<StoreFileMetaData> different = ImmutableList.builder();
final ImmutableList.Builder<StoreFileMetaData> missing = ImmutableList.builder();
final List<StoreFileMetaData> identical = new ArrayList<>();
final List<StoreFileMetaData> different = new ArrayList<>();
final List<StoreFileMetaData> missing = new ArrayList<>();
final Map<String, List<StoreFileMetaData>> perSegment = new HashMap<>();
final List<StoreFileMetaData> perCommitStoreFiles = new ArrayList<>();
@ -1053,7 +1052,7 @@ public class Store extends AbstractIndexShardComponent implements Closeable, Ref
different.addAll(identicalFiles);
}
}
RecoveryDiff recoveryDiff = new RecoveryDiff(identical.build(), different.build(), missing.build());
RecoveryDiff recoveryDiff = new RecoveryDiff(Collections.unmodifiableList(identical), Collections.unmodifiableList(different), Collections.unmodifiableList(missing));
assert recoveryDiff.size() == this.metadata.size() - (metadata.containsKey(IndexFileNames.OLD_SEGMENTS_GEN) ? 1 : 0)
: "some files are missing recoveryDiff size: [" + recoveryDiff.size() + "] metadata size: [" + this.metadata.size() + "] contains segments.gen: [" + metadata.containsKey(IndexFileNames.OLD_SEGMENTS_GEN) + "]";
return recoveryDiff;

View File

@ -19,7 +19,6 @@
package org.elasticsearch.indices.recovery;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.routing.RestoreSource;
import org.elasticsearch.common.Nullable;
@ -34,6 +33,8 @@ import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.shard.ShardId;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
@ -712,7 +713,7 @@ public class RecoveryState implements ToXContent, Streamable {
private long targetThrottleTimeInNanos = UNKNOWN;
public synchronized List<File> fileDetails() {
return ImmutableList.copyOf(fileDetails.values());
return Collections.unmodifiableList(new ArrayList<>(fileDetails.values()));
}
public synchronized void reset() {

View File

@ -20,7 +20,6 @@
package org.elasticsearch.node.internal;
import com.google.common.base.Charsets;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Sets;
import com.google.common.collect.UnmodifiableIterator;
import org.elasticsearch.cluster.ClusterName;
@ -39,6 +38,7 @@ import java.io.InputStreamReader;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -52,7 +52,7 @@ import static org.elasticsearch.common.settings.Settings.settingsBuilder;
*/
public class InternalSettingsPreparer {
static final List<String> ALLOWED_SUFFIXES = ImmutableList.of(".yml", ".yaml", ".json", ".properties");
static final List<String> ALLOWED_SUFFIXES = Arrays.asList(".yml", ".yaml", ".json", ".properties");
public static final String SECRET_PROMPT_VALUE = "${prompt.secret}";
public static final String TEXT_PROMPT_VALUE = "${prompt.text}";

View File

@ -19,7 +19,6 @@
package org.elasticsearch.percolator;
import com.carrotsearch.hppc.ObjectObjectAssociativeContainer;
import com.google.common.collect.ImmutableList;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexableField;
@ -155,7 +154,7 @@ public class PercolateContext extends SearchContext {
Map<String, SearchHitField> fields = new HashMap<>();
for (IndexableField field : parsedDocument.rootDoc().getFields()) {
fields.put(field.name(), new InternalSearchHitField(field.name(), ImmutableList.of()));
fields.put(field.name(), new InternalSearchHitField(field.name(), Collections.emptyList()));
}
hitContext().reset(
new InternalSearchHit(0, "unknown", new StringText(parsedDocument.type()), fields),

View File

@ -19,7 +19,6 @@
package org.elasticsearch.plugins;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.apache.lucene.analysis.util.CharFilterFactory;
@ -328,7 +327,7 @@ public class PluginsService extends AbstractComponent {
}
private List<Tuple<PluginInfo,Plugin>> loadBundles(List<Bundle> bundles) {
ImmutableList.Builder<Tuple<PluginInfo, Plugin>> plugins = ImmutableList.builder();
List<Tuple<PluginInfo, Plugin>> plugins = new ArrayList<>();
for (Bundle bundle : bundles) {
// jar-hell check the bundle against the parent classloader
@ -363,7 +362,7 @@ public class PluginsService extends AbstractComponent {
}
}
return plugins.build();
return Collections.unmodifiableList(plugins);
}
/**

View File

@ -19,7 +19,6 @@
package org.elasticsearch.repositories.blobstore;
import com.google.common.collect.ImmutableList;
import com.google.common.io.ByteStreams;
import org.apache.lucene.store.RateLimiter;
import org.elasticsearch.ElasticsearchParseException;
@ -330,13 +329,13 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent<Rep
// Delete snapshot from the snapshot list
List<SnapshotId> snapshotIds = snapshots();
if (snapshotIds.contains(snapshotId)) {
ImmutableList.Builder<SnapshotId> builder = ImmutableList.builder();
List<SnapshotId> builder = new ArrayList<>();
for (SnapshotId id : snapshotIds) {
if (!snapshotId.equals(id)) {
builder.add(id);
}
}
snapshotIds = builder.build();
snapshotIds = Collections.unmodifiableList(builder);
}
writeSnapshotList(snapshotIds);
// Now delete all indices
@ -377,7 +376,9 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent<Rep
snapshotFormat.write(blobStoreSnapshot, snapshotsBlobContainer, snapshotId.getSnapshot());
List<SnapshotId> snapshotIds = snapshots();
if (!snapshotIds.contains(snapshotId)) {
snapshotIds = ImmutableList.<SnapshotId>builder().addAll(snapshotIds).add(snapshotId).build();
snapshotIds = new ArrayList<>(snapshotIds);
snapshotIds.add(snapshotId);
snapshotIds = Collections.unmodifiableList(snapshotIds);
}
writeSnapshotList(snapshotIds);
return blobStoreSnapshot;
@ -416,7 +417,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent<Rep
}
snapshots.add(new SnapshotId(repositoryName, name));
}
return ImmutableList.copyOf(snapshots);
return Collections.unmodifiableList(snapshots);
} catch (IOException ex) {
throw new RepositoryException(repositoryName, "failed to list snapshots in repository", ex);
}
@ -607,7 +608,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent<Rep
}
}
}
return ImmutableList.copyOf(snapshots);
return Collections.unmodifiableList(snapshots);
}
}

View File

@ -19,7 +19,6 @@
package org.elasticsearch.rest.action.admin.indices.get;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.action.admin.indices.get.GetIndexRequest;
import org.elasticsearch.action.admin.indices.get.GetIndexRequest.Feature;
@ -46,6 +45,7 @@ import org.elasticsearch.rest.action.support.RestBuilderListener;
import org.elasticsearch.search.warmer.IndexWarmersMetaData;
import java.io.IOException;
import java.util.List;
import static org.elasticsearch.rest.RestRequest.Method.GET;
import static org.elasticsearch.rest.RestStatus.OK;
@ -117,7 +117,7 @@ public class RestGetIndicesAction extends BaseRestHandler {
return new BytesRestResponse(OK, builder);
}
private void writeAliases(ImmutableList<AliasMetaData> aliases, XContentBuilder builder, Params params) throws IOException {
private void writeAliases(List<AliasMetaData> aliases, XContentBuilder builder, Params params) throws IOException {
builder.startObject(Fields.ALIASES);
if (aliases != null) {
for (AliasMetaData alias : aliases) {
@ -144,7 +144,7 @@ public class RestGetIndicesAction extends BaseRestHandler {
builder.endObject();
}
private void writeWarmers(ImmutableList<IndexWarmersMetaData.Entry> warmers, XContentBuilder builder, Params params) throws IOException {
private void writeWarmers(List<IndexWarmersMetaData.Entry> warmers, XContentBuilder builder, Params params) throws IOException {
builder.startObject(Fields.WARMERS);
if (warmers != null) {
for (IndexWarmersMetaData.Entry warmer : warmers) {

View File

@ -19,7 +19,6 @@
package org.elasticsearch.rest.action.admin.indices.warmer.get;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.action.admin.indices.warmer.get.GetWarmersRequest;
import org.elasticsearch.action.admin.indices.warmer.get.GetWarmersResponse;
import org.elasticsearch.action.support.IndicesOptions;
@ -32,6 +31,8 @@ import org.elasticsearch.rest.*;
import org.elasticsearch.rest.action.support.RestBuilderListener;
import org.elasticsearch.search.warmer.IndexWarmersMetaData;
import java.util.List;
import static org.elasticsearch.rest.RestRequest.Method.GET;
import static org.elasticsearch.rest.RestStatus.OK;
@ -68,7 +69,7 @@ public class RestGetWarmerAction extends BaseRestHandler {
}
builder.startObject();
for (ObjectObjectCursor<String, ImmutableList<IndexWarmersMetaData.Entry>> entry : response.warmers()) {
for (ObjectObjectCursor<String, List<IndexWarmersMetaData.Entry>> entry : response.warmers()) {
builder.startObject(entry.key, XContentBuilder.FieldCaseConversion.NONE);
builder.startObject(IndexWarmersMetaData.TYPE, XContentBuilder.FieldCaseConversion.NONE);
for (IndexWarmersMetaData.Entry warmerEntry : entry.value) {

View File

@ -18,7 +18,6 @@
*/
package org.elasticsearch.search.aggregations;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.io.stream.StreamInput;
@ -35,6 +34,7 @@ import org.elasticsearch.search.aggregations.support.AggregationPath;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@ -225,7 +225,7 @@ public abstract class InternalAggregation implements Aggregation, ToXContent, St
metaData = in.readMap();
int size = in.readVInt();
if (size == 0) {
pipelineAggregators = ImmutableList.of();
pipelineAggregators = Collections.emptyList();
} else {
pipelineAggregators = new ArrayList<>(size);
for (int i = 0; i < size; i++) {

View File

@ -19,7 +19,6 @@
package org.elasticsearch.search.aggregations;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterators;
import com.google.common.collect.Maps;
@ -35,6 +34,7 @@ import org.elasticsearch.search.aggregations.support.AggregationPath;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@ -56,7 +56,7 @@ public class InternalAggregations implements Aggregations, ToXContent, Streamabl
}
};
private List<InternalAggregation> aggregations = ImmutableList.of();
private List<InternalAggregation> aggregations = Collections.emptyList();
private Map<String, InternalAggregation> aggregationsAsMap;
@ -211,7 +211,7 @@ public class InternalAggregations implements Aggregations, ToXContent, Streamabl
public void readFrom(StreamInput in) throws IOException {
int size = in.readVInt();
if (size == 0) {
aggregations = ImmutableList.of();
aggregations = Collections.emptyList();
aggregationsAsMap = ImmutableMap.of();
} else {
aggregations = new ArrayList<>(size);

View File

@ -21,7 +21,6 @@ package org.elasticsearch.search.builder;
import com.carrotsearch.hppc.ObjectFloatHashMap;
import com.google.common.base.Charsets;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.ElasticsearchGenerationException;
import org.elasticsearch.action.support.QuerySourceBuilder;
import org.elasticsearch.action.support.ToXContentToBytes;
@ -540,7 +539,7 @@ public class SearchSourceBuilder extends ToXContentToBytes {
* per field.
*/
public SearchSourceBuilder noFields() {
this.fieldNames = ImmutableList.of();
this.fieldNames = Collections.emptyList();
return this;
}

View File

@ -19,7 +19,6 @@
package org.elasticsearch.search.fetch;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.ReaderUtil;
@ -59,6 +58,7 @@ import org.elasticsearch.search.lookup.SourceLookup;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@ -285,7 +285,7 @@ public class FetchPhase implements SearchPhase {
nestedParsedSource = (List<Map<String, Object>>) extractedValue;
} else if (extractedValue instanceof Map) {
// nested field has an object value in the _source. This just means the nested field has just one inner object, which is valid, but uncommon.
nestedParsedSource = ImmutableList.of((Map < String, Object >) extractedValue);
nestedParsedSource = Collections.singletonList((Map<String, Object>) extractedValue);
} else {
throw new IllegalStateException("extracted source isn't an object or an array");
}

View File

@ -19,7 +19,6 @@
package org.elasticsearch.search.highlight;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.apache.lucene.search.Query;
import org.elasticsearch.common.component.AbstractComponent;
@ -34,7 +33,10 @@ import org.elasticsearch.search.fetch.FetchSubPhase;
import org.elasticsearch.search.internal.InternalSearchHit;
import org.elasticsearch.search.internal.SearchContext;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import static com.google.common.collect.Maps.newHashMap;
@ -44,7 +46,7 @@ import static com.google.common.collect.Maps.newHashMap;
*/
public class HighlightPhase extends AbstractComponent implements FetchSubPhase {
private static final ImmutableList<String> STANDARD_HIGHLIGHTERS_BY_PRECEDENCE = ImmutableList.of("fvh", "postings", "plain");
private static final List<String> STANDARD_HIGHLIGHTERS_BY_PRECEDENCE = Arrays.asList("fvh", "postings", "plain");
private final Highlighters highlighters;
@ -82,7 +84,7 @@ public class HighlightPhase extends AbstractComponent implements FetchSubPhase {
DocumentMapper documentMapper = context.mapperService().documentMapper(hitContext.hit().type());
fieldNamesToHighlight = documentMapper.mappers().simpleMatchToFullName(field.field());
} else {
fieldNamesToHighlight = ImmutableList.of(field.field());
fieldNamesToHighlight = Collections.singletonList(field.field());
}
if (context.highlight().forceSource(field)) {

View File

@ -18,7 +18,6 @@
*/
package org.elasticsearch.search.highlight;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import org.apache.lucene.search.highlight.DefaultEncoder;
import org.apache.lucene.search.highlight.Encoder;
@ -30,6 +29,7 @@ import org.elasticsearch.search.internal.SearchContext;
import org.elasticsearch.search.lookup.SourceLookup;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
public final class HighlightUtils {
@ -52,7 +52,7 @@ public final class HighlightUtils {
textsToHighlight = fieldVisitor.fields().get(mapper.fieldType().names().indexName());
if (textsToHighlight == null) {
// Can happen if the document doesn't have the field to highlight
textsToHighlight = ImmutableList.of();
textsToHighlight = Collections.emptyList();
}
} else {
SourceLookup sourceLookup = searchContext.lookup().source();

View File

@ -20,7 +20,6 @@
package org.elasticsearch.search.internal;
import com.carrotsearch.hppc.ObjectObjectAssociativeContainer;
import com.google.common.collect.ImmutableList;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.Collector;
@ -586,7 +585,7 @@ public class DefaultSearchContext extends SearchContext {
@Override
public void emptyFieldNames() {
this.fieldNames = ImmutableList.of();
this.fieldNames = Collections.emptyList();
}
@Override

View File

@ -18,7 +18,6 @@
*/
package org.elasticsearch.search.internal;
import com.google.common.collect.ImmutableList;
import org.apache.lucene.search.Filter;
import org.apache.lucene.search.Sort;
import org.apache.lucene.util.Counter;
@ -36,6 +35,7 @@ import org.elasticsearch.search.rescore.RescoreSearchContext;
import org.elasticsearch.search.suggest.SuggestionSearchContext;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
@ -240,7 +240,7 @@ public class SubSearchContext extends FilteredSearchContext {
@Override
public void emptyFieldNames() {
this.fieldNames = ImmutableList.of();
this.fieldNames = Collections.emptyList();
}
@Override

View File

@ -20,7 +20,6 @@
package org.elasticsearch.search.warmer;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.cluster.AbstractDiffable;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.Nullable;
@ -120,14 +119,14 @@ public class IndexWarmersMetaData extends AbstractDiffable<IndexMetaData.Custom>
}
}
private final ImmutableList<Entry> entries;
private final List<Entry> entries;
public IndexWarmersMetaData(Entry... entries) {
this.entries = ImmutableList.copyOf(entries);
this.entries = Arrays.asList(entries);
}
public ImmutableList<Entry> entries() {
public List<Entry> entries() {
return this.entries;
}

View File

@ -18,7 +18,6 @@
*/
package org.elasticsearch.snapshots;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Streamable;
@ -28,6 +27,8 @@ import org.elasticsearch.common.xcontent.XContentBuilderString;
import org.elasticsearch.rest.RestStatus;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
@ -39,7 +40,7 @@ public class RestoreInfo implements ToXContent, Streamable {
private String name;
private ImmutableList<String> indices;
private List<String> indices;
private int totalShards;
@ -49,7 +50,7 @@ public class RestoreInfo implements ToXContent, Streamable {
}
public RestoreInfo(String name, ImmutableList<String> indices, int totalShards, int successfulShards) {
public RestoreInfo(String name, List<String> indices, int totalShards, int successfulShards) {
this.name = name;
this.indices = indices;
this.totalShards = totalShards;
@ -147,11 +148,11 @@ public class RestoreInfo implements ToXContent, Streamable {
public void readFrom(StreamInput in) throws IOException {
name = in.readString();
int size = in.readVInt();
ImmutableList.Builder<String> indicesListBuilder = ImmutableList.builder();
List<String> indicesListBuilder = new ArrayList<>();
for (int i = 0; i < size; i++) {
indicesListBuilder.add(in.readString());
}
indices = indicesListBuilder.build();
indices = Collections.unmodifiableList(indicesListBuilder);
totalShards = in.readVInt();
successfulShards = in.readVInt();
}

View File

@ -22,7 +22,6 @@ import com.carrotsearch.hppc.IntHashSet;
import com.carrotsearch.hppc.IntSet;
import com.carrotsearch.hppc.cursors.ObjectCursor;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import org.elasticsearch.Version;
@ -80,6 +79,7 @@ import org.elasticsearch.transport.TransportService;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@ -295,7 +295,7 @@ public class RestoreService extends AbstractComponent implements ClusterStateLis
}
shards = shardsBuilder.build();
RestoreInProgress.Entry restoreEntry = new RestoreInProgress.Entry(snapshotId, RestoreInProgress.State.INIT, ImmutableList.copyOf(renamedIndices.keySet()), shards);
RestoreInProgress.Entry restoreEntry = new RestoreInProgress.Entry(snapshotId, RestoreInProgress.State.INIT, Collections.unmodifiableList(new ArrayList<>(renamedIndices.keySet())), shards);
builder.putCustom(RestoreInProgress.TYPE, new RestoreInProgress(restoreEntry));
} else {
shards = ImmutableMap.of();
@ -308,7 +308,7 @@ public class RestoreService extends AbstractComponent implements ClusterStateLis
if (completed(shards)) {
// We don't have any indices to restore - we are done
restoreInfo = new RestoreInfo(request.name(), ImmutableList.copyOf(renamedIndices.keySet()),
restoreInfo = new RestoreInfo(request.name(), Collections.unmodifiableList(new ArrayList<>(renamedIndices.keySet())),
shards.size(), shards.size() - failedShards(shards));
}

View File

@ -19,7 +19,6 @@
package org.elasticsearch.snapshots;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.Version;
import org.elasticsearch.common.ParseFieldMatcher;
@ -57,7 +56,7 @@ public class Snapshot implements Comparable<Snapshot>, ToXContent, FromXContentB
private final List<SnapshotShardFailure> shardFailures;
private final static List<SnapshotShardFailure> NO_FAILURES = ImmutableList.of();
private final static List<SnapshotShardFailure> NO_FAILURES = Collections.emptyList();
public final static Snapshot PROTO = new Snapshot();
@ -287,7 +286,7 @@ public class Snapshot implements Comparable<Snapshot>, ToXContent, FromXContentB
Version version = Version.CURRENT;
SnapshotState state = SnapshotState.IN_PROGRESS;
String reason = null;
ImmutableList<String> indices = ImmutableList.of();
List<String> indices = Collections.emptyList();
long startTime = 0;
long endTime = 0;
int totalShard = 0;
@ -331,13 +330,13 @@ public class Snapshot implements Comparable<Snapshot>, ToXContent, FromXContentB
while (parser.nextToken() != XContentParser.Token.END_ARRAY) {
indicesArray.add(parser.text());
}
indices = ImmutableList.copyOf(indicesArray);
indices = Collections.unmodifiableList(indicesArray);
} else if ("failures".equals(currentFieldName)) {
ArrayList<SnapshotShardFailure> shardFailureArrayList = new ArrayList<>();
while (parser.nextToken() != XContentParser.Token.END_ARRAY) {
shardFailureArrayList.add(SnapshotShardFailure.fromXContent(parser));
}
shardFailures = ImmutableList.copyOf(shardFailureArrayList);
shardFailures = Collections.unmodifiableList(shardFailureArrayList);
} else {
// It was probably created by newer version - ignoring
parser.skipChildren();

View File

@ -19,6 +19,8 @@
package org.elasticsearch.snapshots;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.elasticsearch.Version;
@ -32,7 +34,6 @@ import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilderString;
import org.elasticsearch.rest.RestStatus;
import com.google.common.collect.ImmutableList;
/**
* Information about snapshot
@ -260,11 +261,11 @@ public class SnapshotInfo implements ToXContent, Streamable {
public void readFrom(StreamInput in) throws IOException {
name = in.readString();
int size = in.readVInt();
ImmutableList.Builder<String> indicesListBuilder = ImmutableList.builder();
List<String> indicesListBuilder = new ArrayList<>();
for (int i = 0; i < size; i++) {
indicesListBuilder.add(in.readString());
}
indices = indicesListBuilder.build();
indices = Collections.unmodifiableList(indicesListBuilder);
state = SnapshotState.fromValue(in.readByte());
reason = in.readOptionalString();
startTime = in.readVLong();
@ -273,13 +274,13 @@ public class SnapshotInfo implements ToXContent, Streamable {
successfulShards = in.readVInt();
size = in.readVInt();
if (size > 0) {
ImmutableList.Builder<SnapshotShardFailure> failureBuilder = ImmutableList.builder();
List<SnapshotShardFailure> failureBuilder = new ArrayList<>();
for (int i = 0; i < size; i++) {
failureBuilder.add(SnapshotShardFailure.readSnapshotShardFailure(in));
}
shardFailures = failureBuilder.build();
shardFailures = Collections.unmodifiableList(failureBuilder);
} else {
shardFailures = ImmutableList.of();
shardFailures = Collections.emptyList();
}
version = Version.readVersion(in);
}

View File

@ -18,11 +18,13 @@
*/
package org.elasticsearch.snapshots;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.common.regex.Regex;
import org.elasticsearch.index.IndexNotFoundException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@ -114,8 +116,8 @@ public class SnapshotUtils {
}
}
if (result == null) {
return ImmutableList.copyOf(selectedIndices);
return Collections.unmodifiableList(new ArrayList<>(Arrays.asList(selectedIndices)));
}
return ImmutableList.copyOf(result);
return Collections.unmodifiableList(new ArrayList<>(result));
}
}

View File

@ -19,7 +19,6 @@
package org.elasticsearch.snapshots;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.apache.lucene.util.CollectionUtil;
import org.elasticsearch.ExceptionsHelper;
@ -63,6 +62,8 @@ import org.elasticsearch.threadpool.ThreadPool;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@ -150,7 +151,7 @@ public class SnapshotsService extends AbstractLifecycleComponent<SnapshotsServic
}
ArrayList<Snapshot> snapshotList = new ArrayList<>(snapshotSet);
CollectionUtil.timSort(snapshotList);
return ImmutableList.copyOf(snapshotList);
return Collections.unmodifiableList(snapshotList);
}
/**
@ -166,7 +167,7 @@ public class SnapshotsService extends AbstractLifecycleComponent<SnapshotsServic
snapshotList.add(inProgressSnapshot(entry));
}
CollectionUtil.timSort(snapshotList);
return ImmutableList.copyOf(snapshotList);
return Collections.unmodifiableList(snapshotList);
}
/**
@ -192,7 +193,7 @@ public class SnapshotsService extends AbstractLifecycleComponent<SnapshotsServic
SnapshotsInProgress snapshots = currentState.custom(SnapshotsInProgress.TYPE);
if (snapshots == null || snapshots.entries().isEmpty()) {
// Store newSnapshot here to be processed in clusterStateProcessed
ImmutableList<String> indices = ImmutableList.copyOf(indexNameExpressionResolver.concreteIndices(currentState, request.indicesOptions(), request.indices()));
List<String> indices = Arrays.asList(indexNameExpressionResolver.concreteIndices(currentState, request.indicesOptions(), request.indices()));
logger.trace("[{}][{}] creating snapshot for indices [{}]", request.repository(), request.name(), indices);
newSnapshot = new SnapshotsInProgress.Entry(snapshotId, request.includeGlobalState(), State.INIT, indices, System.currentTimeMillis(), null);
snapshots = new SnapshotsInProgress(newSnapshot);
@ -311,7 +312,7 @@ public class SnapshotsService extends AbstractLifecycleComponent<SnapshotsServic
@Override
public ClusterState execute(ClusterState currentState) {
SnapshotsInProgress snapshots = currentState.custom(SnapshotsInProgress.TYPE);
ImmutableList.Builder<SnapshotsInProgress.Entry> entries = ImmutableList.builder();
List<SnapshotsInProgress.Entry> entries = new ArrayList<>();
for (SnapshotsInProgress.Entry entry : snapshots.entries()) {
if (entry.snapshotId().equals(snapshot.snapshotId())) {
// Replace the snapshot that was just created
@ -348,7 +349,7 @@ public class SnapshotsService extends AbstractLifecycleComponent<SnapshotsServic
entries.add(entry);
}
}
return ClusterState.builder(currentState).putCustom(SnapshotsInProgress.TYPE, new SnapshotsInProgress(entries.build())).build();
return ClusterState.builder(currentState).putCustom(SnapshotsInProgress.TYPE, new SnapshotsInProgress(Collections.unmodifiableList(entries))).build();
}
@Override
@ -357,7 +358,7 @@ public class SnapshotsService extends AbstractLifecycleComponent<SnapshotsServic
removeSnapshotFromClusterState(snapshot.snapshotId(), null, t);
try {
repositoriesService.repository(snapshot.snapshotId().getRepository()).finalizeSnapshot(
snapshot.snapshotId(), snapshot.indices(), snapshot.startTime(), ExceptionsHelper.detailedMessage(t), 0, ImmutableList.<SnapshotShardFailure>of());
snapshot.snapshotId(), snapshot.indices(), snapshot.startTime(), ExceptionsHelper.detailedMessage(t), 0, Collections.<SnapshotShardFailure>emptyList());
} catch (Throwable t2) {
logger.warn("[{}] failed to close snapshot in repository", snapshot.snapshotId());
}
@ -387,7 +388,7 @@ public class SnapshotsService extends AbstractLifecycleComponent<SnapshotsServic
if (snapshotCreated) {
try {
repositoriesService.repository(snapshot.snapshotId().getRepository()).finalizeSnapshot(snapshot.snapshotId(), snapshot.indices(), snapshot.startTime(),
ExceptionsHelper.detailedMessage(t), 0, ImmutableList.<SnapshotShardFailure>of());
ExceptionsHelper.detailedMessage(t), 0, Collections.<SnapshotShardFailure>emptyList());
} catch (Throwable t2) {
logger.warn("[{}] failed to close snapshot in repository", snapshot.snapshotId());
}
@ -413,7 +414,7 @@ public class SnapshotsService extends AbstractLifecycleComponent<SnapshotsServic
public List<SnapshotsInProgress.Entry> currentSnapshots(String repository, String[] snapshots) {
SnapshotsInProgress snapshotsInProgress = clusterService.state().custom(SnapshotsInProgress.TYPE);
if (snapshotsInProgress == null || snapshotsInProgress.entries().isEmpty()) {
return ImmutableList.of();
return Collections.emptyList();
}
if ("_all".equals(repository)) {
return snapshotsInProgress.entries();
@ -423,7 +424,7 @@ public class SnapshotsService extends AbstractLifecycleComponent<SnapshotsServic
// Check this snapshot against the query
SnapshotsInProgress.Entry entry = snapshotsInProgress.entries().get(0);
if (!entry.snapshotId().getRepository().equals(repository)) {
return ImmutableList.of();
return Collections.emptyList();
}
if (snapshots != null && snapshots.length > 0) {
for (String snapshot : snapshots) {
@ -431,12 +432,12 @@ public class SnapshotsService extends AbstractLifecycleComponent<SnapshotsServic
return snapshotsInProgress.entries();
}
}
return ImmutableList.of();
return Collections.emptyList();
} else {
return snapshotsInProgress.entries();
}
}
ImmutableList.Builder<SnapshotsInProgress.Entry> builder = ImmutableList.builder();
List<SnapshotsInProgress.Entry> builder = new ArrayList<>();
for (SnapshotsInProgress.Entry entry : snapshotsInProgress.entries()) {
if (!entry.snapshotId().getRepository().equals(repository)) {
continue;
@ -452,7 +453,7 @@ public class SnapshotsService extends AbstractLifecycleComponent<SnapshotsServic
builder.add(entry);
}
}
return builder.build();
return Collections.unmodifiableList(builder);
}
/**
@ -787,7 +788,7 @@ public class SnapshotsService extends AbstractLifecycleComponent<SnapshotsServic
shardFailures.add(new SnapshotShardFailure(status.nodeId(), shardId.getIndex(), shardId.id(), status.reason()));
}
}
Snapshot snapshot = repository.finalizeSnapshot(snapshotId, entry.indices(), entry.startTime(), failure, entry.shards().size(), ImmutableList.copyOf(shardFailures));
Snapshot snapshot = repository.finalizeSnapshot(snapshotId, entry.indices(), entry.startTime(), failure, entry.shards().size(), Collections.unmodifiableList(shardFailures));
removeSnapshotFromClusterState(snapshotId, new SnapshotInfo(snapshot), null);
} catch (Throwable t) {
logger.warn("[{}] failed to finalize snapshot", t, snapshotId);
@ -1009,7 +1010,7 @@ public class SnapshotsService extends AbstractLifecycleComponent<SnapshotsServic
* @param indices list of indices to be snapshotted
* @return list of shard to be included into current snapshot
*/
private ImmutableMap<ShardId, SnapshotsInProgress.ShardSnapshotStatus> shards(ClusterState clusterState, ImmutableList<String> indices) {
private ImmutableMap<ShardId, SnapshotsInProgress.ShardSnapshotStatus> shards(ClusterState clusterState, List<String> indices) {
ImmutableMap.Builder<ShardId, SnapshotsInProgress.ShardSnapshotStatus> builder = ImmutableMap.builder();
MetaData metaData = clusterState.metaData();
for (String index : indices) {

View File

@ -23,7 +23,6 @@ import com.google.common.base.Charsets;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.node.DiscoveryNode;
@ -58,13 +57,31 @@ import org.elasticsearch.common.util.concurrent.EsExecutors;
import org.elasticsearch.common.util.concurrent.KeyedLock;
import org.elasticsearch.monitor.jvm.JvmInfo;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.*;
import org.elasticsearch.transport.BindTransportException;
import org.elasticsearch.transport.BytesTransportRequest;
import org.elasticsearch.transport.ConnectTransportException;
import org.elasticsearch.transport.NodeNotConnectedException;
import org.elasticsearch.transport.Transport;
import org.elasticsearch.transport.TransportException;
import org.elasticsearch.transport.TransportRequest;
import org.elasticsearch.transport.TransportRequestOptions;
import org.elasticsearch.transport.TransportServiceAdapter;
import org.elasticsearch.transport.support.TransportStatus;
import org.jboss.netty.bootstrap.ClientBootstrap;
import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.*;
import org.jboss.netty.channel.AdaptiveReceiveBufferSizePredictorFactory;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelFuture;
import org.jboss.netty.channel.ChannelFutureListener;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.channel.Channels;
import org.jboss.netty.channel.ExceptionEvent;
import org.jboss.netty.channel.FixedReceiveBufferSizePredictorFactory;
import org.jboss.netty.channel.ReceiveBufferSizePredictorFactory;
import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
import org.jboss.netty.channel.socket.nio.NioWorkerPool;
@ -78,8 +95,20 @@ import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.net.UnknownHostException;
import java.nio.channels.CancelledKeyException;
import java.util.*;
import java.util.concurrent.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.ReadWriteLock;
@ -947,7 +976,13 @@ public class NettyTransport extends AbstractLifecycleComponent<Transport> implem
}
} catch (RuntimeException e) {
// clean the futures
for (ChannelFuture future : ImmutableList.<ChannelFuture>builder().add(connectRecovery).add(connectBulk).add(connectReg).add(connectState).add(connectPing).build()) {
List<ChannelFuture> futures = new ArrayList<>();
futures.addAll(Arrays.asList(connectRecovery));
futures.addAll(Arrays.asList(connectBulk));
futures.addAll(Arrays.asList(connectReg));
futures.addAll(Arrays.asList(connectState));
futures.addAll(Arrays.asList(connectPing));
for (ChannelFuture future : Collections.unmodifiableList(futures)) {
future.cancel();
if (future.getChannel() != null && future.getChannel().isOpen()) {
try {
@ -1130,7 +1165,7 @@ public class NettyTransport extends AbstractLifecycleComponent<Transport> implem
public static class NodeChannels {
ImmutableList<Channel> allChannels = ImmutableList.of();
List<Channel> allChannels = Collections.emptyList();
private Channel[] recovery;
private final AtomicInteger recoveryCounter = new AtomicInteger();
private Channel[] bulk;
@ -1151,7 +1186,13 @@ public class NettyTransport extends AbstractLifecycleComponent<Transport> implem
}
public void start() {
this.allChannels = ImmutableList.<Channel>builder().add(recovery).add(bulk).add(reg).add(state).add(ping).build();
List<Channel> newAllChannels = new ArrayList<>();
newAllChannels.addAll(Arrays.asList(recovery));
newAllChannels.addAll(Arrays.asList(bulk));
newAllChannels.addAll(Arrays.asList(reg));
newAllChannels.addAll(Arrays.asList(state));
newAllChannels.addAll(Arrays.asList(ping));
this.allChannels = Collections.unmodifiableList(newAllChannels);
}
public boolean hasChannel(Channel channel) {

View File

@ -19,7 +19,6 @@
package org.elasticsearch.action.admin.indices.get;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.action.admin.indices.alias.Alias;
import org.elasticsearch.action.admin.indices.get.GetIndexRequest.Feature;
import org.elasticsearch.cluster.metadata.AliasMetaData;
@ -239,10 +238,10 @@ public class GetIndexIT extends ESIntegTestCase {
}
private void assertWarmers(GetIndexResponse response, String indexName) {
ImmutableOpenMap<String, ImmutableList<Entry>> warmers = response.warmers();
ImmutableOpenMap<String, List<Entry>> warmers = response.warmers();
assertThat(warmers, notNullValue());
assertThat(warmers.size(), equalTo(1));
ImmutableList<Entry> indexWarmers = warmers.get(indexName);
List<Entry> indexWarmers = warmers.get(indexName);
assertThat(indexWarmers, notNullValue());
assertThat(indexWarmers.size(), equalTo(1));
Entry warmer = indexWarmers.get(0);
@ -297,10 +296,10 @@ public class GetIndexIT extends ESIntegTestCase {
}
private void assertAliases(GetIndexResponse response, String indexName) {
ImmutableOpenMap<String, ImmutableList<AliasMetaData>> aliases = response.aliases();
ImmutableOpenMap<String, List<AliasMetaData>> aliases = response.aliases();
assertThat(aliases, notNullValue());
assertThat(aliases.size(), equalTo(1));
ImmutableList<AliasMetaData> indexAliases = aliases.get(indexName);
List<AliasMetaData> indexAliases = aliases.get(indexName);
assertThat(indexAliases, notNullValue());
assertThat(indexAliases.size(), equalTo(1));
AliasMetaData alias = indexAliases.get(0);

View File

@ -19,7 +19,6 @@
package org.elasticsearch.action.admin.indices.shards;
import com.google.common.collect.ImmutableList;
import org.apache.lucene.util.CollectionUtil;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.node.DiscoveryNode;
@ -42,7 +41,7 @@ public class IndicesShardStoreResponseTest extends ESTestCase {
@Test
public void testBasicSerialization() throws Exception {
ImmutableOpenMap.Builder<String, ImmutableOpenIntMap<List<IndicesShardStoresResponse.StoreStatus>>> indexStoreStatuses = ImmutableOpenMap.builder();
ImmutableList.Builder<IndicesShardStoresResponse.Failure> failures = ImmutableList.builder();
List<IndicesShardStoresResponse.Failure> failures = new ArrayList<>();
ImmutableOpenIntMap.Builder<List<IndicesShardStoresResponse.StoreStatus>> storeStatuses = ImmutableOpenIntMap.builder();
DiscoveryNode node1 = new DiscoveryNode("node1", DummyTransportAddress.INSTANCE, Version.CURRENT);
@ -59,7 +58,7 @@ public class IndicesShardStoreResponseTest extends ESTestCase {
failures.add(new IndicesShardStoresResponse.Failure("node1", "test", 3, new NodeDisconnectedException(node1, "")));
IndicesShardStoresResponse storesResponse = new IndicesShardStoresResponse(indexStoreStatuses.build(), failures.build());
IndicesShardStoresResponse storesResponse = new IndicesShardStoresResponse(indexStoreStatuses.build(), Collections.unmodifiableList(failures));
XContentBuilder contentBuilder = XContentFactory.jsonBuilder();
contentBuilder.startObject();
storesResponse.toXContent(contentBuilder, ToXContent.EMPTY_PARAMS);

View File

@ -19,7 +19,6 @@
package org.elasticsearch.bwcompat;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.action.admin.indices.alias.Alias;
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
@ -33,6 +32,8 @@ import org.elasticsearch.search.warmer.IndexWarmersMetaData.Entry;
import org.elasticsearch.test.ESBackcompatTestCase;
import org.junit.Test;
import java.util.List;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.equalTo;
@ -46,10 +47,10 @@ public class GetIndexBackwardsCompatibilityIT extends ESBackcompatTestCase {
assertAcked(createIndexResponse);
GetIndexResponse getIndexResponse = client().admin().indices().prepareGetIndex().addIndices("test").addFeatures(Feature.ALIASES)
.execute().actionGet();
ImmutableOpenMap<String, ImmutableList<AliasMetaData>> aliasesMap = getIndexResponse.aliases();
ImmutableOpenMap<String, List<AliasMetaData>> aliasesMap = getIndexResponse.aliases();
assertThat(aliasesMap, notNullValue());
assertThat(aliasesMap.size(), equalTo(1));
ImmutableList<AliasMetaData> aliasesList = aliasesMap.get("test");
List<AliasMetaData> aliasesList = aliasesMap.get("test");
assertThat(aliasesList, notNullValue());
assertThat(aliasesList.size(), equalTo(1));
AliasMetaData alias = aliasesList.get(0);
@ -100,10 +101,10 @@ public class GetIndexBackwardsCompatibilityIT extends ESBackcompatTestCase {
ensureSearchable("test");
GetIndexResponse getIndexResponse = client().admin().indices().prepareGetIndex().addIndices("test").addFeatures(Feature.WARMERS)
.execute().actionGet();
ImmutableOpenMap<String, ImmutableList<Entry>> warmersMap = getIndexResponse.warmers();
ImmutableOpenMap<String, List<Entry>> warmersMap = getIndexResponse.warmers();
assertThat(warmersMap, notNullValue());
assertThat(warmersMap.size(), equalTo(1));
ImmutableList<Entry> warmersList = warmersMap.get("test");
List<Entry> warmersList = warmersMap.get("test");
assertThat(warmersList, notNullValue());
assertThat(warmersList.size(), equalTo(1));
Entry warmer = warmersList.get(0);

View File

@ -20,7 +20,6 @@
package org.elasticsearch.cluster;
import com.carrotsearch.hppc.cursors.ObjectCursor;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.block.ClusterBlock;
@ -44,6 +43,7 @@ import org.elasticsearch.search.warmer.IndexWarmersMetaData;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.Test;
import java.util.Collections;
import java.util.List;
import static org.elasticsearch.cluster.metadata.AliasMetaData.newAliasMetaDataBuilder;
@ -659,14 +659,14 @@ public class ClusterStateDiffIT extends ESIntegTestCase {
new SnapshotId(randomName("repo"), randomName("snap")),
randomBoolean(),
SnapshotsInProgress.State.fromValue((byte) randomIntBetween(0, 6)),
ImmutableList.<String>of(),
Collections.<String>emptyList(),
Math.abs(randomLong()),
ImmutableMap.<ShardId, SnapshotsInProgress.ShardSnapshotStatus>of()));
case 1:
return new RestoreInProgress(new RestoreInProgress.Entry(
new SnapshotId(randomName("repo"), randomName("snap")),
RestoreInProgress.State.fromValue((byte) randomIntBetween(0, 3)),
ImmutableList.<String>of(),
Collections.<String>emptyList(),
ImmutableMap.<ShardId, RestoreInProgress.ShardRestoreStatus>of()));
default:
throw new IllegalArgumentException("Shouldn't be here");

View File

@ -46,8 +46,8 @@ import org.elasticsearch.test.ESIntegTestCase;
import org.junit.Test;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
@ -100,7 +100,7 @@ public class AckIT extends ESIntegTestCase {
for (Client client : clients()) {
GetWarmersResponse getWarmersResponse = client.admin().indices().prepareGetWarmers().setLocal(true).get();
assertThat(getWarmersResponse.warmers().size(), equalTo(1));
ObjectObjectCursor<String, ImmutableList<IndexWarmersMetaData.Entry>> entry = getWarmersResponse.warmers().iterator().next();
ObjectObjectCursor<String, List<IndexWarmersMetaData.Entry>> entry = getWarmersResponse.warmers().iterator().next();
assertThat(entry.key, equalTo("test"));
assertThat(entry.value.size(), equalTo(1));
assertThat(entry.value.get(0).name(), equalTo("custom_warmer"));

View File

@ -21,7 +21,6 @@ package org.elasticsearch.cluster.routing;
import com.carrotsearch.hppc.IntHashSet;
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterState;
@ -38,6 +37,7 @@ import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.test.ESAllocationTestCase;
import org.junit.Test;
import java.util.Collections;
import java.util.EnumSet;
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
@ -251,7 +251,7 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
assertThat(clusterState.getRoutingNodes().hasUnassigned(), equalTo(false));
// fail shard
ShardRouting shardToFail = clusterState.getRoutingNodes().shardsWithState(STARTED).get(0);
clusterState = ClusterState.builder(clusterState).routingResult(allocation.applyFailedShards(clusterState, ImmutableList.of(new FailedRerouteAllocation.FailedShard(shardToFail, "test fail", null)))).build();
clusterState = ClusterState.builder(clusterState).routingResult(allocation.applyFailedShards(clusterState, Collections.singletonList(new FailedRerouteAllocation.FailedShard(shardToFail, "test fail", null)))).build();
// verify the reason and details
assertThat(clusterState.getRoutingNodes().hasUnassigned(), equalTo(true));
assertThat(clusterState.getRoutingNodes().shardsWithState(UNASSIGNED).size(), equalTo(1));

View File

@ -19,7 +19,6 @@
package org.elasticsearch.cluster.routing.allocation;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexMetaData;
@ -35,6 +34,7 @@ import org.elasticsearch.test.ESAllocationTestCase;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Collections;
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
@ -562,7 +562,7 @@ public class FailedShardsRoutingTests extends ESAllocationTestCase {
assertThat(clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size(), equalTo(2));
// start another replica shard, while keep one initializing
clusterState = ClusterState.builder(clusterState).routingTable(allocation.applyStartedShards(clusterState, ImmutableList.of(clusterState.getRoutingNodes().shardsWithState(INITIALIZING).get(0))).routingTable()).build();
clusterState = ClusterState.builder(clusterState).routingTable(allocation.applyStartedShards(clusterState, Collections.singletonList(clusterState.getRoutingNodes().shardsWithState(INITIALIZING).get(0))).routingTable()).build();
assertThat(clusterState.getRoutingNodes().shardsWithState(STARTED).size(), equalTo(2));
assertThat(clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size(), equalTo(1));

View File

@ -19,7 +19,6 @@
package org.elasticsearch.cluster.structure;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.ClusterName;
@ -37,6 +36,8 @@ import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.test.ESAllocationTestCase;
import org.junit.Test;
import java.util.Collections;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.*;
@ -46,28 +47,28 @@ public class RoutingIteratorTests extends ESAllocationTestCase {
@Test
public void testEmptyIterator() {
ShardShuffler shuffler = new RotationShardShuffler(0);
ShardIterator shardIterator = new PlainShardIterator(new ShardId("test1", 0), shuffler.shuffle(ImmutableList.<ShardRouting>of()));
ShardIterator shardIterator = new PlainShardIterator(new ShardId("test1", 0), shuffler.shuffle(Collections.<ShardRouting>emptyList()));
assertThat(shardIterator.remaining(), equalTo(0));
assertThat(shardIterator.nextOrNull(), nullValue());
assertThat(shardIterator.remaining(), equalTo(0));
assertThat(shardIterator.nextOrNull(), nullValue());
assertThat(shardIterator.remaining(), equalTo(0));
shardIterator = new PlainShardIterator(new ShardId("test1", 0), shuffler.shuffle(ImmutableList.<ShardRouting>of()));
shardIterator = new PlainShardIterator(new ShardId("test1", 0), shuffler.shuffle(Collections.<ShardRouting>emptyList()));
assertThat(shardIterator.remaining(), equalTo(0));
assertThat(shardIterator.nextOrNull(), nullValue());
assertThat(shardIterator.remaining(), equalTo(0));
assertThat(shardIterator.nextOrNull(), nullValue());
assertThat(shardIterator.remaining(), equalTo(0));
shardIterator = new PlainShardIterator(new ShardId("test1", 0), shuffler.shuffle(ImmutableList.<ShardRouting>of()));
shardIterator = new PlainShardIterator(new ShardId("test1", 0), shuffler.shuffle(Collections.<ShardRouting>emptyList()));
assertThat(shardIterator.remaining(), equalTo(0));
assertThat(shardIterator.nextOrNull(), nullValue());
assertThat(shardIterator.remaining(), equalTo(0));
assertThat(shardIterator.nextOrNull(), nullValue());
assertThat(shardIterator.remaining(), equalTo(0));
shardIterator = new PlainShardIterator(new ShardId("test1", 0), shuffler.shuffle(ImmutableList.<ShardRouting>of()));
shardIterator = new PlainShardIterator(new ShardId("test1", 0), shuffler.shuffle(Collections.<ShardRouting>emptyList()));
assertThat(shardIterator.remaining(), equalTo(0));
assertThat(shardIterator.nextOrNull(), nullValue());
assertThat(shardIterator.remaining(), equalTo(0));

Some files were not shown because too many files have changed in this diff Show More