mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-30 20:08:29 +00:00
Merge branch 'master' into feature/query-refactoring
Conflicts: core/src/main/java/org/apache/lucene/queryparser/classic/MapperQueryParser.java core/src/main/java/org/elasticsearch/index/query/AndQueryBuilder.java core/src/main/java/org/elasticsearch/index/query/AndQueryParser.java core/src/main/java/org/elasticsearch/index/query/BoolQueryParser.java core/src/main/java/org/elasticsearch/index/query/DisMaxQueryBuilder.java core/src/main/java/org/elasticsearch/index/query/DisMaxQueryParser.java core/src/main/java/org/elasticsearch/index/query/GeoPolygonQueryParser.java core/src/main/java/org/elasticsearch/index/query/HasChildQueryParser.java core/src/main/java/org/elasticsearch/index/query/HasParentQueryParser.java core/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryParser.java core/src/main/java/org/elasticsearch/index/query/MultiMatchQueryBuilder.java core/src/main/java/org/elasticsearch/index/query/NestedQueryParser.java core/src/main/java/org/elasticsearch/index/query/OrQueryBuilder.java core/src/main/java/org/elasticsearch/index/query/OrQueryParser.java core/src/main/java/org/elasticsearch/index/query/PrefixQueryParser.java core/src/main/java/org/elasticsearch/index/query/RegexpQueryParser.java core/src/main/java/org/elasticsearch/index/query/SpanNearQueryParser.java core/src/main/java/org/elasticsearch/index/query/SpanOrQueryParser.java core/src/main/java/org/elasticsearch/index/query/TermQueryParser.java core/src/main/java/org/elasticsearch/index/query/TermsQueryParser.java core/src/main/java/org/elasticsearch/index/query/support/InnerHitsQueryParserHelper.java core/src/test/java/org/elasticsearch/index/query/SimpleIndexQueryParserTests.java
This commit is contained in:
commit
78d097de39
core/src/main/java/org/elasticsearch
action
ActionModule.java
admin
cluster
health
node
snapshots/status
stats
indices
alias
analyze
cache/clear
flush
mapping/get
optimize
refresh
segments
stats
template/get
upgrade
get
post
validate/query
warmer/delete
bulk
exists
percolate
MultiPercolateRequest.javaPercolateRequest.javaPercolateSourceBuilder.javaTransportPercolateAction.java
search
suggest
support
termvectors/dfs
update
client/transport
cluster
ClusterChangedEvent.javaDiffableUtils.java
metadata
IndexNameExpressionResolver.javaMetaData.javaMetaDataCreateIndexService.javaMetaDataIndexAliasesService.javaMetaDataIndexTemplateService.javaMetaDataMappingService.java
node
routing
common
Strings.javaValidationException.java
inject
@ -19,9 +19,7 @@
|
||||
|
||||
package org.elasticsearch.action;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction;
|
||||
import org.elasticsearch.action.admin.cluster.health.TransportClusterHealthAction;
|
||||
import org.elasticsearch.action.admin.cluster.node.hotthreads.NodesHotThreadsAction;
|
||||
@ -85,7 +83,11 @@ import org.elasticsearch.action.admin.indices.flush.FlushAction;
|
||||
import org.elasticsearch.action.admin.indices.flush.TransportFlushAction;
|
||||
import org.elasticsearch.action.admin.indices.get.GetIndexAction;
|
||||
import org.elasticsearch.action.admin.indices.get.TransportGetIndexAction;
|
||||
import org.elasticsearch.action.admin.indices.mapping.get.*;
|
||||
import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsAction;
|
||||
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsAction;
|
||||
import org.elasticsearch.action.admin.indices.mapping.get.TransportGetFieldMappingsAction;
|
||||
import org.elasticsearch.action.admin.indices.mapping.get.TransportGetFieldMappingsIndexAction;
|
||||
import org.elasticsearch.action.admin.indices.mapping.get.TransportGetMappingsAction;
|
||||
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingAction;
|
||||
import org.elasticsearch.action.admin.indices.mapping.put.TransportPutMappingAction;
|
||||
import org.elasticsearch.action.admin.indices.open.OpenIndexAction;
|
||||
@ -96,14 +98,14 @@ import org.elasticsearch.action.admin.indices.recovery.RecoveryAction;
|
||||
import org.elasticsearch.action.admin.indices.recovery.TransportRecoveryAction;
|
||||
import org.elasticsearch.action.admin.indices.refresh.RefreshAction;
|
||||
import org.elasticsearch.action.admin.indices.refresh.TransportRefreshAction;
|
||||
import org.elasticsearch.action.admin.indices.shards.IndicesShardStoresAction;
|
||||
import org.elasticsearch.action.admin.indices.shards.TransportIndicesShardStoresAction;
|
||||
import org.elasticsearch.action.admin.indices.segments.IndicesSegmentsAction;
|
||||
import org.elasticsearch.action.admin.indices.segments.TransportIndicesSegmentsAction;
|
||||
import org.elasticsearch.action.admin.indices.settings.get.GetSettingsAction;
|
||||
import org.elasticsearch.action.admin.indices.settings.get.TransportGetSettingsAction;
|
||||
import org.elasticsearch.action.admin.indices.settings.put.TransportUpdateSettingsAction;
|
||||
import org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsAction;
|
||||
import org.elasticsearch.action.admin.indices.shards.IndicesShardStoresAction;
|
||||
import org.elasticsearch.action.admin.indices.shards.TransportIndicesShardStoresAction;
|
||||
import org.elasticsearch.action.admin.indices.stats.IndicesStatsAction;
|
||||
import org.elasticsearch.action.admin.indices.stats.TransportIndicesStatsAction;
|
||||
import org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateAction;
|
||||
@ -139,7 +141,11 @@ import org.elasticsearch.action.explain.ExplainAction;
|
||||
import org.elasticsearch.action.explain.TransportExplainAction;
|
||||
import org.elasticsearch.action.fieldstats.FieldStatsAction;
|
||||
import org.elasticsearch.action.fieldstats.TransportFieldStatsTransportAction;
|
||||
import org.elasticsearch.action.get.*;
|
||||
import org.elasticsearch.action.get.GetAction;
|
||||
import org.elasticsearch.action.get.MultiGetAction;
|
||||
import org.elasticsearch.action.get.TransportGetAction;
|
||||
import org.elasticsearch.action.get.TransportMultiGetAction;
|
||||
import org.elasticsearch.action.get.TransportShardMultiGetAction;
|
||||
import org.elasticsearch.action.index.IndexAction;
|
||||
import org.elasticsearch.action.index.TransportIndexAction;
|
||||
import org.elasticsearch.action.indexedscripts.delete.DeleteIndexedScriptAction;
|
||||
@ -148,16 +154,38 @@ import org.elasticsearch.action.indexedscripts.get.GetIndexedScriptAction;
|
||||
import org.elasticsearch.action.indexedscripts.get.TransportGetIndexedScriptAction;
|
||||
import org.elasticsearch.action.indexedscripts.put.PutIndexedScriptAction;
|
||||
import org.elasticsearch.action.indexedscripts.put.TransportPutIndexedScriptAction;
|
||||
import org.elasticsearch.action.percolate.*;
|
||||
import org.elasticsearch.action.search.*;
|
||||
import org.elasticsearch.action.search.type.*;
|
||||
import org.elasticsearch.action.percolate.MultiPercolateAction;
|
||||
import org.elasticsearch.action.percolate.PercolateAction;
|
||||
import org.elasticsearch.action.percolate.TransportMultiPercolateAction;
|
||||
import org.elasticsearch.action.percolate.TransportPercolateAction;
|
||||
import org.elasticsearch.action.percolate.TransportShardMultiPercolateAction;
|
||||
import org.elasticsearch.action.search.ClearScrollAction;
|
||||
import org.elasticsearch.action.search.MultiSearchAction;
|
||||
import org.elasticsearch.action.search.SearchAction;
|
||||
import org.elasticsearch.action.search.SearchScrollAction;
|
||||
import org.elasticsearch.action.search.TransportClearScrollAction;
|
||||
import org.elasticsearch.action.search.TransportMultiSearchAction;
|
||||
import org.elasticsearch.action.search.TransportSearchAction;
|
||||
import org.elasticsearch.action.search.TransportSearchScrollAction;
|
||||
import org.elasticsearch.action.search.type.TransportSearchDfsQueryAndFetchAction;
|
||||
import org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction;
|
||||
import org.elasticsearch.action.search.type.TransportSearchQueryAndFetchAction;
|
||||
import org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction;
|
||||
import org.elasticsearch.action.search.type.TransportSearchScanAction;
|
||||
import org.elasticsearch.action.search.type.TransportSearchScrollQueryAndFetchAction;
|
||||
import org.elasticsearch.action.search.type.TransportSearchScrollQueryThenFetchAction;
|
||||
import org.elasticsearch.action.search.type.TransportSearchScrollScanAction;
|
||||
import org.elasticsearch.action.suggest.SuggestAction;
|
||||
import org.elasticsearch.action.suggest.TransportSuggestAction;
|
||||
import org.elasticsearch.action.support.ActionFilter;
|
||||
import org.elasticsearch.action.support.ActionFilters;
|
||||
import org.elasticsearch.action.support.AutoCreateIndex;
|
||||
import org.elasticsearch.action.support.TransportAction;
|
||||
import org.elasticsearch.action.termvectors.*;
|
||||
import org.elasticsearch.action.termvectors.MultiTermVectorsAction;
|
||||
import org.elasticsearch.action.termvectors.TermVectorsAction;
|
||||
import org.elasticsearch.action.termvectors.TransportMultiTermVectorsAction;
|
||||
import org.elasticsearch.action.termvectors.TransportShardMultiTermsVectorAction;
|
||||
import org.elasticsearch.action.termvectors.TransportTermVectorsAction;
|
||||
import org.elasticsearch.action.termvectors.dfs.TransportDfsOnlyAction;
|
||||
import org.elasticsearch.action.update.TransportUpdateAction;
|
||||
import org.elasticsearch.action.update.UpdateAction;
|
||||
@ -165,6 +193,7 @@ import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.common.inject.multibindings.MapBinder;
|
||||
import org.elasticsearch.common.inject.multibindings.Multibinder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -174,7 +203,7 @@ import java.util.Map;
|
||||
public class ActionModule extends AbstractModule {
|
||||
|
||||
private final Map<String, ActionEntry> actions = Maps.newHashMap();
|
||||
private final List<Class<? extends ActionFilter>> actionFilters = Lists.newArrayList();
|
||||
private final List<Class<? extends ActionFilter>> actionFilters = new ArrayList<>();
|
||||
|
||||
static class ActionEntry<Request extends ActionRequest, Response extends ActionResponse> {
|
||||
public final GenericAction<Request, Response> action;
|
||||
|
@ -31,16 +31,19 @@ import org.elasticsearch.cluster.routing.ShardRouting;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.*;
|
||||
import org.elasticsearch.common.xcontent.StatusToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilderString;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
import static org.elasticsearch.action.admin.cluster.health.ClusterIndexHealth.readClusterIndexHealth;
|
||||
|
||||
/**
|
||||
@ -152,7 +155,7 @@ public class ClusterHealthResponse extends ActionResponse implements Iterable<Cl
|
||||
* All the validation failures, including index level validation failures.
|
||||
*/
|
||||
public List<String> getAllValidationFailures() {
|
||||
List<String> allFailures = newArrayList(getValidationFailures());
|
||||
List<String> allFailures = new ArrayList<>(getValidationFailures());
|
||||
for (ClusterIndexHealth indexHealth : indices.values()) {
|
||||
allFailures.addAll(indexHealth.getValidationFailures());
|
||||
}
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package org.elasticsearch.action.admin.cluster.node.hotthreads;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.action.support.ActionFilters;
|
||||
import org.elasticsearch.action.support.nodes.BaseNodeRequest;
|
||||
@ -36,6 +35,7 @@ import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||
|
||||
@ -54,7 +54,7 @@ public class TransportNodesHotThreadsAction extends TransportNodesAction<NodesHo
|
||||
|
||||
@Override
|
||||
protected NodesHotThreadsResponse newResponse(NodesHotThreadsRequest request, AtomicReferenceArray responses) {
|
||||
final List<NodeHotThreads> nodes = Lists.newArrayList();
|
||||
final List<NodeHotThreads> nodes = new ArrayList<>();
|
||||
for (int i = 0; i < responses.length(); i++) {
|
||||
Object resp = responses.get(i);
|
||||
if (resp instanceof NodeHotThreads) {
|
||||
|
4
core/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/TransportNodesStatsAction.java
4
core/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/TransportNodesStatsAction.java
@ -19,7 +19,6 @@
|
||||
|
||||
package org.elasticsearch.action.admin.cluster.node.stats;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.elasticsearch.action.support.ActionFilters;
|
||||
import org.elasticsearch.action.support.nodes.BaseNodeRequest;
|
||||
import org.elasticsearch.action.support.nodes.TransportNodesAction;
|
||||
@ -35,6 +34,7 @@ import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||
|
||||
@ -56,7 +56,7 @@ public class TransportNodesStatsAction extends TransportNodesAction<NodesStatsRe
|
||||
|
||||
@Override
|
||||
protected NodesStatsResponse newResponse(NodesStatsRequest nodesInfoRequest, AtomicReferenceArray responses) {
|
||||
final List<NodeStats> nodeStats = Lists.newArrayList();
|
||||
final List<NodeStats> nodeStats = new ArrayList<>();
|
||||
for (int i = 0; i < responses.length(); i++) {
|
||||
Object resp = responses.get(i);
|
||||
if (resp instanceof NodeStats) {
|
||||
|
@ -21,8 +21,8 @@ package org.elasticsearch.action.admin.cluster.snapshots.status;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.elasticsearch.cluster.metadata.SnapshotId;
|
||||
import org.elasticsearch.cluster.SnapshotsInProgress.State;
|
||||
import org.elasticsearch.cluster.metadata.SnapshotId;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.io.stream.Streamable;
|
||||
@ -32,11 +32,11 @@ import org.elasticsearch.common.xcontent.XContentBuilderString;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
import static com.google.common.collect.Sets.newHashSet;
|
||||
|
||||
/**
|
||||
@ -109,7 +109,7 @@ public class SnapshotStatus implements ToXContent, Streamable {
|
||||
}
|
||||
|
||||
for (String index : indices) {
|
||||
List<SnapshotIndexShardStatus> shards = newArrayList();
|
||||
List<SnapshotIndexShardStatus> shards = new ArrayList<>();
|
||||
for (SnapshotIndexShardStatus shard : this.shards) {
|
||||
if (shard.getIndex().equals(index)) {
|
||||
shards.add(shard);
|
||||
|
@ -20,12 +20,15 @@
|
||||
package org.elasticsearch.action.admin.cluster.snapshots.status;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.action.ActionRequest;
|
||||
import org.elasticsearch.action.FailedNodeException;
|
||||
import org.elasticsearch.action.support.ActionFilters;
|
||||
import org.elasticsearch.action.support.nodes.*;
|
||||
import org.elasticsearch.action.support.nodes.BaseNodeRequest;
|
||||
import org.elasticsearch.action.support.nodes.BaseNodeResponse;
|
||||
import org.elasticsearch.action.support.nodes.BaseNodesRequest;
|
||||
import org.elasticsearch.action.support.nodes.BaseNodesResponse;
|
||||
import org.elasticsearch.action.support.nodes.TransportNodesAction;
|
||||
import org.elasticsearch.cluster.ClusterName;
|
||||
import org.elasticsearch.cluster.ClusterService;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
@ -42,6 +45,7 @@ import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||
@ -82,8 +86,8 @@ public class TransportNodesSnapshotsStatus extends TransportNodesAction<Transpor
|
||||
|
||||
@Override
|
||||
protected NodesSnapshotStatus newResponse(Request request, AtomicReferenceArray responses) {
|
||||
final List<NodeSnapshotStatus> nodesList = Lists.newArrayList();
|
||||
final List<FailedNodeException> failures = Lists.newArrayList();
|
||||
final List<NodeSnapshotStatus> nodesList = new ArrayList<>();
|
||||
final List<FailedNodeException> failures = new ArrayList<>();
|
||||
for (int i = 0; i < responses.length(); i++) {
|
||||
Object resp = responses.get(i);
|
||||
if (resp instanceof NodeSnapshotStatus) { // will also filter out null response for unallocated ones
|
||||
|
@ -106,7 +106,7 @@ public class TransportClusterStatsAction extends TransportNodesAction<ClusterSta
|
||||
for (IndexShard indexShard : indexService) {
|
||||
if (indexShard.routingEntry() != null && indexShard.routingEntry().active()) {
|
||||
// only report on fully started shards
|
||||
shardsStats.add(new ShardStats(indexShard, indexShard.routingEntry(), SHARD_STATS_FLAGS));
|
||||
shardsStats.add(new ShardStats(indexShard, SHARD_STATS_FLAGS));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,8 +21,6 @@ package org.elasticsearch.action.admin.indices.alias;
|
||||
|
||||
import com.carrotsearch.hppc.cursors.ObjectCursor;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.action.AliasesRequest;
|
||||
import org.elasticsearch.action.CompositeIndicesRequest;
|
||||
@ -54,7 +52,7 @@ import static org.elasticsearch.cluster.metadata.AliasAction.readAliasAction;
|
||||
*/
|
||||
public class IndicesAliasesRequest extends AcknowledgedRequest<IndicesAliasesRequest> implements CompositeIndicesRequest {
|
||||
|
||||
private List<AliasActions> allAliasActions = Lists.newArrayList();
|
||||
private List<AliasActions> allAliasActions = new ArrayList<>();
|
||||
|
||||
//indices options that require every specified index to exist, expand wildcards only to open indices and
|
||||
//don't allow that no indices are resolved from wildcard expressions
|
||||
|
@ -18,7 +18,6 @@
|
||||
*/
|
||||
package org.elasticsearch.action.admin.indices.analyze;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.analysis.TokenStream;
|
||||
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
|
||||
@ -39,7 +38,13 @@ import org.elasticsearch.cluster.routing.ShardsIterator;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.IndexService;
|
||||
import org.elasticsearch.index.analysis.*;
|
||||
import org.elasticsearch.index.analysis.CharFilterFactory;
|
||||
import org.elasticsearch.index.analysis.CharFilterFactoryFactory;
|
||||
import org.elasticsearch.index.analysis.CustomAnalyzer;
|
||||
import org.elasticsearch.index.analysis.TokenFilterFactory;
|
||||
import org.elasticsearch.index.analysis.TokenFilterFactoryFactory;
|
||||
import org.elasticsearch.index.analysis.TokenizerFactory;
|
||||
import org.elasticsearch.index.analysis.TokenizerFactoryFactory;
|
||||
import org.elasticsearch.index.mapper.MappedFieldType;
|
||||
import org.elasticsearch.index.mapper.internal.AllFieldMapper;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
@ -49,6 +54,7 @@ import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -210,7 +216,7 @@ public class TransportAnalyzeAction extends TransportSingleShardAction<AnalyzeRe
|
||||
throw new IllegalArgumentException("failed to find analyzer");
|
||||
}
|
||||
|
||||
List<AnalyzeResponse.AnalyzeToken> tokens = Lists.newArrayList();
|
||||
List<AnalyzeResponse.AnalyzeToken> tokens = new ArrayList<>();
|
||||
TokenStream stream = null;
|
||||
int lastPosition = -1;
|
||||
int lastOffset = 0;
|
||||
|
@ -40,11 +40,10 @@ import org.elasticsearch.indices.cache.request.IndicesRequestCache;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
|
||||
/**
|
||||
* Indices clear cache action.
|
||||
*/
|
||||
@ -76,7 +75,7 @@ public class TransportClearIndicesCacheAction extends TransportBroadcastAction<C
|
||||
} else if (shardResponse instanceof BroadcastShardOperationFailedException) {
|
||||
failedShards++;
|
||||
if (shardFailures == null) {
|
||||
shardFailures = newArrayList();
|
||||
shardFailures = new ArrayList<>();
|
||||
}
|
||||
shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse));
|
||||
} else {
|
||||
|
@ -38,11 +38,10 @@ import org.elasticsearch.indices.IndicesService;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
|
||||
/**
|
||||
* Flush Action.
|
||||
*/
|
||||
@ -71,7 +70,7 @@ public class TransportFlushAction extends TransportBroadcastAction<FlushRequest,
|
||||
} else if (shardResponse instanceof BroadcastShardOperationFailedException) {
|
||||
failedShards++;
|
||||
if (shardFailures == null) {
|
||||
shardFailures = newArrayList();
|
||||
shardFailures = new ArrayList<>();
|
||||
}
|
||||
shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse));
|
||||
} else {
|
||||
|
@ -22,7 +22,6 @@ package org.elasticsearch.action.admin.indices.mapping.get;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse.FieldMappingMetaData;
|
||||
import org.elasticsearch.action.support.ActionFilters;
|
||||
@ -55,6 +54,8 @@ import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import static org.elasticsearch.common.util.CollectionUtils.newLinkedList;
|
||||
|
||||
/**
|
||||
* Transport action used to retrieve the mappings related to fields that belong to a specific index
|
||||
*/
|
||||
@ -178,7 +179,7 @@ public class TransportGetFieldMappingsIndexAction extends TransportSingleShardAc
|
||||
} else if (Regex.isSimpleMatchPattern(field)) {
|
||||
// go through the field mappers 3 times, to make sure we give preference to the resolve order: full name, index name, name.
|
||||
// also make sure we only store each mapper once.
|
||||
Collection<FieldMapper> remainingFieldMappers = Lists.newLinkedList(allFieldMappers);
|
||||
Collection<FieldMapper> remainingFieldMappers = newLinkedList(allFieldMappers);
|
||||
for (Iterator<FieldMapper> it = remainingFieldMappers.iterator(); it.hasNext(); ) {
|
||||
final FieldMapper fieldMapper = it.next();
|
||||
if (Regex.simpleMatch(field, fieldMapper.fieldType().names().fullName())) {
|
||||
|
@ -38,11 +38,10 @@ import org.elasticsearch.indices.IndicesService;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
|
||||
/**
|
||||
* Optimize index/indices action.
|
||||
*/
|
||||
@ -71,7 +70,7 @@ public class TransportOptimizeAction extends TransportBroadcastAction<OptimizeRe
|
||||
} else if (shardResponse instanceof BroadcastShardOperationFailedException) {
|
||||
failedShards++;
|
||||
if (shardFailures == null) {
|
||||
shardFailures = newArrayList();
|
||||
shardFailures = new ArrayList<>();
|
||||
}
|
||||
shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse));
|
||||
} else {
|
||||
|
@ -38,11 +38,10 @@ import org.elasticsearch.indices.IndicesService;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
|
||||
/**
|
||||
* Refresh action.
|
||||
*/
|
||||
@ -71,7 +70,7 @@ public class TransportRefreshAction extends TransportBroadcastAction<RefreshRequ
|
||||
} else if (shardResponse instanceof BroadcastShardOperationFailedException) {
|
||||
failedShards++;
|
||||
if (shardFailures == null) {
|
||||
shardFailures = newArrayList();
|
||||
shardFailures = new ArrayList<>();
|
||||
}
|
||||
shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse));
|
||||
} else {
|
||||
|
@ -19,9 +19,9 @@
|
||||
|
||||
package org.elasticsearch.action.admin.indices.segments;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -39,7 +39,7 @@ public class IndexSegments implements Iterable<IndexShardSegments> {
|
||||
for (ShardSegments shard : shards) {
|
||||
List<ShardSegments> lst = tmpIndexShards.get(shard.getShardRouting().id());
|
||||
if (lst == null) {
|
||||
lst = Lists.newArrayList();
|
||||
lst = new ArrayList<>();
|
||||
tmpIndexShards.put(shard.getShardRouting().id(), lst);
|
||||
}
|
||||
lst.add(shard);
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package org.elasticsearch.action.admin.indices.segments;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.apache.lucene.util.Accountable;
|
||||
@ -35,6 +34,7 @@ import org.elasticsearch.common.xcontent.XContentBuilderString;
|
||||
import org.elasticsearch.index.engine.Segment;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -67,7 +67,7 @@ public class IndicesSegmentResponse extends BroadcastResponse implements ToXCont
|
||||
}
|
||||
|
||||
for (String index : indices) {
|
||||
List<ShardSegments> shards = Lists.newArrayList();
|
||||
List<ShardSegments> shards = new ArrayList<>();
|
||||
for (ShardSegments shard : this.shards) {
|
||||
if (shard.getShardRouting().index().equals(index)) {
|
||||
shards.add(shard);
|
||||
|
@ -44,11 +44,10 @@ import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -87,7 +86,7 @@ public class TransportIndicesSegmentsAction extends TransportBroadcastAction<Ind
|
||||
int successfulShards = 0;
|
||||
int failedShards = 0;
|
||||
List<ShardOperationFailedException> shardFailures = null;
|
||||
final List<ShardSegments> shards = newArrayList();
|
||||
final List<ShardSegments> shards = new ArrayList<>();
|
||||
for (int i = 0; i < shardsResponses.length(); i++) {
|
||||
Object shardResponse = shardsResponses.get(i);
|
||||
if (shardResponse == null) {
|
||||
@ -95,7 +94,7 @@ public class TransportIndicesSegmentsAction extends TransportBroadcastAction<Ind
|
||||
} else if (shardResponse instanceof BroadcastShardOperationFailedException) {
|
||||
failedShards++;
|
||||
if (shardFailures == null) {
|
||||
shardFailures = newArrayList();
|
||||
shardFailures = new ArrayList<>();
|
||||
}
|
||||
shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse));
|
||||
} else {
|
||||
|
@ -19,9 +19,9 @@
|
||||
|
||||
package org.elasticsearch.action.admin.indices.stats;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -57,7 +57,7 @@ public class IndexStats implements Iterable<IndexShardStats> {
|
||||
for (ShardStats shard : shards) {
|
||||
List<ShardStats> lst = tmpIndexShards.get(shard.getShardRouting().id());
|
||||
if (lst == null) {
|
||||
lst = Lists.newArrayList();
|
||||
lst = new ArrayList<>();
|
||||
tmpIndexShards.put(shard.getShardRouting().id(), lst);
|
||||
}
|
||||
lst.add(shard);
|
||||
|
@ -20,7 +20,6 @@
|
||||
package org.elasticsearch.action.admin.indices.stats;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.elasticsearch.action.ShardOperationFailedException;
|
||||
@ -35,6 +34,7 @@ import org.elasticsearch.common.xcontent.XContentBuilderString;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -94,7 +94,7 @@ public class IndicesStatsResponse extends BroadcastResponse implements ToXConten
|
||||
}
|
||||
|
||||
for (String index : indices) {
|
||||
List<ShardStats> shards = Lists.newArrayList();
|
||||
List<ShardStats> shards = new ArrayList<>();
|
||||
for (ShardStats shard : this.shards) {
|
||||
if (shard.getShardRouting().index().equals(index)) {
|
||||
shards.add(shard);
|
||||
|
@ -29,6 +29,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilderString;
|
||||
import org.elasticsearch.index.engine.CommitStats;
|
||||
import org.elasticsearch.index.shard.IndexShard;
|
||||
import org.elasticsearch.index.shard.ShardPath;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@ -37,20 +38,23 @@ import static org.elasticsearch.cluster.routing.ShardRouting.readShardRoutingEnt
|
||||
/**
|
||||
*/
|
||||
public class ShardStats extends BroadcastShardResponse implements ToXContent {
|
||||
|
||||
private ShardRouting shardRouting;
|
||||
|
||||
CommonStats commonStats;
|
||||
|
||||
private CommonStats commonStats;
|
||||
@Nullable
|
||||
CommitStats commitStats;
|
||||
private CommitStats commitStats;
|
||||
private String dataPath;
|
||||
private String statePath;
|
||||
private boolean isCustomDataPath;
|
||||
|
||||
ShardStats() {
|
||||
}
|
||||
|
||||
public ShardStats(IndexShard indexShard, ShardRouting shardRouting, CommonStatsFlags flags) {
|
||||
public ShardStats(IndexShard indexShard, CommonStatsFlags flags) {
|
||||
super(indexShard.shardId());
|
||||
this.shardRouting = shardRouting;
|
||||
this.shardRouting = indexShard.routingEntry();
|
||||
this.dataPath = indexShard.shardPath().getRootDataPath().toString();
|
||||
this.statePath = indexShard.shardPath().getRootStatePath().toString();
|
||||
this.isCustomDataPath = indexShard.shardPath().isCustomDataPath();
|
||||
this.commonStats = new CommonStats(indexShard, flags);
|
||||
this.commitStats = indexShard.commitStats();
|
||||
}
|
||||
@ -70,6 +74,18 @@ public class ShardStats extends BroadcastShardResponse implements ToXContent {
|
||||
return this.commitStats;
|
||||
}
|
||||
|
||||
public String getDataPath() {
|
||||
return dataPath;
|
||||
}
|
||||
|
||||
public String getStatePath() {
|
||||
return statePath;
|
||||
}
|
||||
|
||||
public boolean isCustomDataPath() {
|
||||
return isCustomDataPath;
|
||||
}
|
||||
|
||||
public static ShardStats readShardStats(StreamInput in) throws IOException {
|
||||
ShardStats stats = new ShardStats();
|
||||
stats.readFrom(in);
|
||||
@ -82,6 +98,9 @@ public class ShardStats extends BroadcastShardResponse implements ToXContent {
|
||||
shardRouting = readShardRoutingEntry(in);
|
||||
commonStats = CommonStats.readCommonStats(in);
|
||||
commitStats = CommitStats.readOptionalCommitStatsFrom(in);
|
||||
statePath = in.readString();
|
||||
dataPath = in.readString();
|
||||
isCustomDataPath = in.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -90,6 +109,9 @@ public class ShardStats extends BroadcastShardResponse implements ToXContent {
|
||||
shardRouting.writeTo(out);
|
||||
commonStats.writeTo(out);
|
||||
out.writeOptionalStreamable(commitStats);
|
||||
out.writeString(statePath);
|
||||
out.writeString(dataPath);
|
||||
out.writeBoolean(isCustomDataPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -105,12 +127,21 @@ public class ShardStats extends BroadcastShardResponse implements ToXContent {
|
||||
if (commitStats != null) {
|
||||
commitStats.toXContent(builder, params);
|
||||
}
|
||||
builder.startObject(Fields.SHARD_PATH);
|
||||
builder.field(Fields.STATE_PATH, statePath);
|
||||
builder.field(Fields.DATA_PATH, dataPath);
|
||||
builder.field(Fields.IS_CUSTOM_DATA_PATH, isCustomDataPath);
|
||||
builder.endObject();
|
||||
return builder;
|
||||
}
|
||||
|
||||
static final class Fields {
|
||||
static final XContentBuilderString ROUTING = new XContentBuilderString("routing");
|
||||
static final XContentBuilderString STATE = new XContentBuilderString("state");
|
||||
static final XContentBuilderString STATE_PATH = new XContentBuilderString("state_path");
|
||||
static final XContentBuilderString DATA_PATH = new XContentBuilderString("data_path");
|
||||
static final XContentBuilderString IS_CUSTOM_DATA_PATH = new XContentBuilderString("is_custom_data_path");
|
||||
static final XContentBuilderString SHARD_PATH = new XContentBuilderString("shard_path");
|
||||
static final XContentBuilderString PRIMARY = new XContentBuilderString("primary");
|
||||
static final XContentBuilderString NODE = new XContentBuilderString("node");
|
||||
static final XContentBuilderString RELOCATING_NODE = new XContentBuilderString("relocating_node");
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package org.elasticsearch.action.admin.indices.stats;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.elasticsearch.action.ShardOperationFailedException;
|
||||
import org.elasticsearch.action.support.ActionFilters;
|
||||
import org.elasticsearch.action.support.DefaultShardOperationFailedException;
|
||||
@ -46,11 +45,10 @@ import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class TransportIndicesStatsAction extends TransportBroadcastAction<IndicesStatsRequest, IndicesStatsResponse, TransportIndicesStatsAction.IndexShardStatsRequest, ShardStats> {
|
||||
@ -90,7 +88,7 @@ public class TransportIndicesStatsAction extends TransportBroadcastAction<Indice
|
||||
int successfulShards = 0;
|
||||
int failedShards = 0;
|
||||
List<ShardOperationFailedException> shardFailures = null;
|
||||
final List<ShardStats> shards = Lists.newArrayList();
|
||||
final List<ShardStats> shards = new ArrayList<>();
|
||||
for (int i = 0; i < shardsResponses.length(); i++) {
|
||||
Object shardResponse = shardsResponses.get(i);
|
||||
if (shardResponse == null) {
|
||||
@ -98,7 +96,7 @@ public class TransportIndicesStatsAction extends TransportBroadcastAction<Indice
|
||||
} else if (shardResponse instanceof BroadcastShardOperationFailedException) {
|
||||
failedShards++;
|
||||
if (shardFailures == null) {
|
||||
shardFailures = newArrayList();
|
||||
shardFailures = new ArrayList<>();
|
||||
}
|
||||
shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse));
|
||||
} else {
|
||||
@ -189,7 +187,7 @@ public class TransportIndicesStatsAction extends TransportBroadcastAction<Indice
|
||||
flags.set(CommonStatsFlags.Flag.Recovery);
|
||||
}
|
||||
|
||||
return new ShardStats(indexShard, indexShard.routingEntry(), flags);
|
||||
return new ShardStats(indexShard, flags);
|
||||
}
|
||||
|
||||
static class IndexShardStatsRequest extends BroadcastShardRequest {
|
||||
|
@ -18,13 +18,13 @@
|
||||
*/
|
||||
package org.elasticsearch.action.admin.indices.template.get;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.elasticsearch.action.ActionResponse;
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateMetaData;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -49,7 +49,7 @@ public class GetIndexTemplatesResponse extends ActionResponse {
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
int size = in.readVInt();
|
||||
indexTemplates = Lists.newArrayListWithExpectedSize(size);
|
||||
indexTemplates = new ArrayList<>(size);
|
||||
for (int i = 0 ; i < size ; i++) {
|
||||
indexTemplates.add(0, IndexTemplateMetaData.Builder.readFrom(in));
|
||||
}
|
||||
|
@ -19,7 +19,6 @@
|
||||
package org.elasticsearch.action.admin.indices.template.get;
|
||||
|
||||
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.support.ActionFilters;
|
||||
import org.elasticsearch.action.support.master.TransportMasterNodeReadAction;
|
||||
@ -35,6 +34,8 @@ import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -69,9 +70,9 @@ public class TransportGetIndexTemplatesAction extends TransportMasterNodeReadAct
|
||||
|
||||
// If we did not ask for a specific name, then we return all templates
|
||||
if (request.names().length == 0) {
|
||||
results = Lists.newArrayList(state.metaData().templates().values().toArray(IndexTemplateMetaData.class));
|
||||
results = Arrays.asList(state.metaData().templates().values().toArray(IndexTemplateMetaData.class));
|
||||
} else {
|
||||
results = Lists.newArrayList();
|
||||
results = new ArrayList<>();
|
||||
}
|
||||
|
||||
for (String name : request.names()) {
|
||||
|
@ -19,9 +19,9 @@
|
||||
|
||||
package org.elasticsearch.action.admin.indices.upgrade.get;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -39,7 +39,7 @@ public class IndexUpgradeStatus implements Iterable<IndexShardUpgradeStatus> {
|
||||
for (ShardUpgradeStatus shard : shards) {
|
||||
List<ShardUpgradeStatus> lst = tmpIndexShards.get(shard.getShardRouting().id());
|
||||
if (lst == null) {
|
||||
lst = Lists.newArrayList();
|
||||
lst = new ArrayList<>();
|
||||
tmpIndexShards.put(shard.getShardRouting().id(), lst);
|
||||
}
|
||||
lst.add(shard);
|
||||
|
@ -43,11 +43,10 @@ import org.elasticsearch.indices.IndicesService;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -86,7 +85,7 @@ public class TransportUpgradeStatusAction extends TransportBroadcastAction<Upgra
|
||||
int successfulShards = 0;
|
||||
int failedShards = 0;
|
||||
List<ShardOperationFailedException> shardFailures = null;
|
||||
final List<ShardUpgradeStatus> shards = newArrayList();
|
||||
final List<ShardUpgradeStatus> shards = new ArrayList<>();
|
||||
for (int i = 0; i < shardsResponses.length(); i++) {
|
||||
Object shardResponse = shardsResponses.get(i);
|
||||
if (shardResponse == null) {
|
||||
@ -94,7 +93,7 @@ public class TransportUpgradeStatusAction extends TransportBroadcastAction<Upgra
|
||||
} else if (shardResponse instanceof BroadcastShardOperationFailedException) {
|
||||
failedShards++;
|
||||
if (shardFailures == null) {
|
||||
shardFailures = newArrayList();
|
||||
shardFailures = new ArrayList<>();
|
||||
}
|
||||
shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse));
|
||||
} else {
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package org.elasticsearch.action.admin.indices.upgrade.get;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.elasticsearch.action.ShardOperationFailedException;
|
||||
@ -31,6 +30,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilderString;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -63,7 +63,7 @@ public class UpgradeStatusResponse extends BroadcastResponse implements ToXConte
|
||||
}
|
||||
|
||||
for (String index : indices) {
|
||||
List<ShardUpgradeStatus> shards = Lists.newArrayList();
|
||||
List<ShardUpgradeStatus> shards = new ArrayList<>();
|
||||
for (ShardUpgradeStatus shard : this.shards) {
|
||||
if (shard.getShardRouting().index().equals(index)) {
|
||||
shards.add(shard);
|
||||
|
9
core/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/TransportUpgradeAction.java
9
core/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/TransportUpgradeAction.java
@ -33,7 +33,10 @@ import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.routing.*;
|
||||
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
||||
import org.elasticsearch.cluster.routing.IndexRoutingTable;
|
||||
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||
import org.elasticsearch.common.collect.Tuple;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
@ -42,12 +45,12 @@ import org.elasticsearch.indices.IndicesService;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
import static com.google.common.collect.Maps.newHashMap;
|
||||
import static com.google.common.collect.Sets.newHashSet;
|
||||
|
||||
@ -84,7 +87,7 @@ public class TransportUpgradeAction extends TransportBroadcastAction<UpgradeRequ
|
||||
} else if (shardResponse instanceof BroadcastShardOperationFailedException) {
|
||||
failedShards++;
|
||||
if (shardFailures == null) {
|
||||
shardFailures = newArrayList();
|
||||
shardFailures = new ArrayList<>();
|
||||
}
|
||||
shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse));
|
||||
} else {
|
||||
|
@ -55,14 +55,13 @@ import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -137,7 +136,7 @@ public class TransportValidateQueryAction extends TransportBroadcastAction<Valid
|
||||
} else if (shardResponse instanceof BroadcastShardOperationFailedException) {
|
||||
failedShards++;
|
||||
if (shardFailures == null) {
|
||||
shardFailures = newArrayList();
|
||||
shardFailures = new ArrayList<>();
|
||||
}
|
||||
shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse));
|
||||
} else {
|
||||
@ -145,7 +144,7 @@ public class TransportValidateQueryAction extends TransportBroadcastAction<Valid
|
||||
valid = valid && validateQueryResponse.isValid();
|
||||
if (request.explain() || request.rewrite()) {
|
||||
if (queryExplanations == null) {
|
||||
queryExplanations = newArrayList();
|
||||
queryExplanations = new ArrayList<>();
|
||||
}
|
||||
queryExplanations.add(new QueryExplanation(
|
||||
validateQueryResponse.getIndex(),
|
||||
@ -198,7 +197,7 @@ public class TransportValidateQueryAction extends TransportBroadcastAction<Valid
|
||||
valid = false;
|
||||
error = e.getMessage();
|
||||
} finally {
|
||||
SearchContext.current().close();
|
||||
searchContext.close();
|
||||
SearchContext.removeCurrent();
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
*/
|
||||
package org.elasticsearch.action.admin.indices.warmer.delete;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.support.ActionFilters;
|
||||
import org.elasticsearch.action.support.master.TransportMasterNodeAction;
|
||||
@ -39,6 +38,7 @@ import org.elasticsearch.search.warmer.IndexWarmersMetaData;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@ -92,6 +92,14 @@ public class TransportDeleteWarmerAction extends TransportMasterNodeAction<Delet
|
||||
MetaData.Builder mdBuilder = MetaData.builder(currentState.metaData());
|
||||
|
||||
boolean globalFoundAtLeastOne = false;
|
||||
boolean deleteAll = false;
|
||||
for (int i=0; i<request.names().length; i++){
|
||||
if (request.names()[i].equals(MetaData.ALL)) {
|
||||
deleteAll = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (String index : concreteIndices) {
|
||||
IndexMetaData indexMetaData = currentState.metaData().index(index);
|
||||
if (indexMetaData == null) {
|
||||
@ -99,11 +107,11 @@ public class TransportDeleteWarmerAction extends TransportMasterNodeAction<Delet
|
||||
}
|
||||
IndexWarmersMetaData warmers = indexMetaData.custom(IndexWarmersMetaData.TYPE);
|
||||
if (warmers != null) {
|
||||
List<IndexWarmersMetaData.Entry> entries = Lists.newArrayList();
|
||||
List<IndexWarmersMetaData.Entry> entries = new ArrayList<>();
|
||||
for (IndexWarmersMetaData.Entry entry : warmers.entries()) {
|
||||
boolean keepWarmer = true;
|
||||
for (String warmer : request.names()) {
|
||||
if (Regex.simpleMatch(warmer, entry.name()) || warmer.equals("_all")) {
|
||||
if (Regex.simpleMatch(warmer, entry.name()) || warmer.equals(MetaData.ALL)) {
|
||||
globalFoundAtLeastOne = true;
|
||||
keepWarmer = false;
|
||||
// don't add it...
|
||||
@ -123,7 +131,7 @@ public class TransportDeleteWarmerAction extends TransportMasterNodeAction<Delet
|
||||
}
|
||||
}
|
||||
|
||||
if (!globalFoundAtLeastOne) {
|
||||
if (globalFoundAtLeastOne == false && deleteAll == false) {
|
||||
throw new IndexWarmerMissingException(request.names());
|
||||
}
|
||||
|
||||
@ -137,11 +145,13 @@ public class TransportDeleteWarmerAction extends TransportMasterNodeAction<Delet
|
||||
if (warmers != null) {
|
||||
for (IndexWarmersMetaData.Entry entry : warmers.entries()) {
|
||||
for (String warmer : request.names()) {
|
||||
if (Regex.simpleMatch(warmer, entry.name()) || warmer.equals("_all")) {
|
||||
if (Regex.simpleMatch(warmer, entry.name()) || warmer.equals(MetaData.ALL)) {
|
||||
logger.info("[{}] delete warmer [{}]", index, entry.name());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(deleteAll){
|
||||
logger.debug("no warmers to delete on index [{}]", index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,8 +19,6 @@
|
||||
|
||||
package org.elasticsearch.action.bulk;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import org.elasticsearch.action.ActionRequest;
|
||||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.action.CompositeIndicesRequest;
|
||||
@ -57,7 +55,7 @@ public class BulkRequest extends ActionRequest<BulkRequest> implements Composite
|
||||
|
||||
private static final int REQUEST_OVERHEAD = 50;
|
||||
|
||||
final List<ActionRequest> requests = Lists.newArrayList();
|
||||
final List<ActionRequest> requests = new ArrayList<>();
|
||||
List<Object> payloads = null;
|
||||
|
||||
protected TimeValue timeout = BulkShardRequest.DEFAULT_TIMEOUT;
|
||||
@ -186,7 +184,7 @@ public class BulkRequest extends ActionRequest<BulkRequest> implements Composite
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<? extends IndicesRequest> subRequests() {
|
||||
List<IndicesRequest> indicesRequests = Lists.newArrayList();
|
||||
List<IndicesRequest> indicesRequests = new ArrayList<>();
|
||||
for (ActionRequest request : requests) {
|
||||
assert request instanceof IndicesRequest;
|
||||
indicesRequests.add((IndicesRequest) request);
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package org.elasticsearch.action.bulk;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
@ -57,7 +56,13 @@ import org.elasticsearch.indices.IndexClosedException;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
@ -251,7 +256,7 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
||||
ShardId shardId = clusterService.operationRouting().indexShards(clusterState, concreteIndex, indexRequest.type(), indexRequest.id(), indexRequest.routing()).shardId();
|
||||
List<BulkItemRequest> list = requestsByShard.get(shardId);
|
||||
if (list == null) {
|
||||
list = Lists.newArrayList();
|
||||
list = new ArrayList<>();
|
||||
requestsByShard.put(shardId, list);
|
||||
}
|
||||
list.add(new BulkItemRequest(i, request));
|
||||
@ -265,7 +270,7 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
||||
for (ShardIterator shardIt : groupShards) {
|
||||
List<BulkItemRequest> list = requestsByShard.get(shardIt.shardId());
|
||||
if (list == null) {
|
||||
list = Lists.newArrayList();
|
||||
list = new ArrayList<>();
|
||||
requestsByShard.put(shardIt.shardId(), list);
|
||||
}
|
||||
list.add(new BulkItemRequest(i, new DeleteRequest(deleteRequest)));
|
||||
@ -274,7 +279,7 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
||||
ShardId shardId = clusterService.operationRouting().deleteShards(clusterState, concreteIndex, deleteRequest.type(), deleteRequest.id(), deleteRequest.routing()).shardId();
|
||||
List<BulkItemRequest> list = requestsByShard.get(shardId);
|
||||
if (list == null) {
|
||||
list = Lists.newArrayList();
|
||||
list = new ArrayList<>();
|
||||
requestsByShard.put(shardId, list);
|
||||
}
|
||||
list.add(new BulkItemRequest(i, request));
|
||||
@ -292,7 +297,7 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
||||
ShardId shardId = clusterService.operationRouting().indexShards(clusterState, concreteIndex, updateRequest.type(), updateRequest.id(), updateRequest.routing()).shardId();
|
||||
List<BulkItemRequest> list = requestsByShard.get(shardId);
|
||||
if (list == null) {
|
||||
list = Lists.newArrayList();
|
||||
list = new ArrayList<>();
|
||||
requestsByShard.put(shardId, list);
|
||||
}
|
||||
list.add(new BulkItemRequest(i, request));
|
||||
|
@ -54,13 +54,13 @@ import org.elasticsearch.search.query.QueryPhaseExecutionException;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
import static org.elasticsearch.action.exists.ExistsRequest.DEFAULT_MIN_SCORE;
|
||||
|
||||
public class TransportExistsAction extends TransportBroadcastAction<ExistsRequest, ExistsResponse, ShardExistsRequest, ShardExistsResponse> {
|
||||
@ -131,7 +131,7 @@ public class TransportExistsAction extends TransportBroadcastAction<ExistsReques
|
||||
} else if (shardResponse instanceof BroadcastShardOperationFailedException) {
|
||||
failedShards++;
|
||||
if (shardFailures == null) {
|
||||
shardFailures = newArrayList();
|
||||
shardFailures = new ArrayList<>();
|
||||
}
|
||||
shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse));
|
||||
} else {
|
||||
@ -174,9 +174,8 @@ public class TransportExistsAction extends TransportBroadcastAction<ExistsReques
|
||||
}
|
||||
context.preProcess();
|
||||
try {
|
||||
Lucene.EarlyTerminatingCollector existsCollector = Lucene.createExistsCollector();
|
||||
Lucene.exists(context.searcher(), context.query(), existsCollector);
|
||||
return new ShardExistsResponse(request.shardId(), existsCollector.exists());
|
||||
boolean exists = Lucene.exists(context, context.query(), Lucene.createExistsCollector());
|
||||
return new ShardExistsResponse(request.shardId(), exists);
|
||||
} catch (Exception e) {
|
||||
throw new QueryPhaseExecutionException(context, "failed to execute exists", e);
|
||||
}
|
||||
|
@ -18,7 +18,6 @@
|
||||
*/
|
||||
package org.elasticsearch.action.percolate;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.action.ActionRequest;
|
||||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
@ -35,6 +34,7 @@ import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -50,7 +50,7 @@ public class MultiPercolateRequest extends ActionRequest<MultiPercolateRequest>
|
||||
private String[] indices;
|
||||
private String documentType;
|
||||
private IndicesOptions indicesOptions = IndicesOptions.strictExpandOpenAndForbidClosed();
|
||||
private List<PercolateRequest> requests = Lists.newArrayList();
|
||||
private List<PercolateRequest> requests = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Embeds a percolate request to this multi percolate request
|
||||
@ -163,7 +163,7 @@ public class MultiPercolateRequest extends ActionRequest<MultiPercolateRequest>
|
||||
|
||||
@Override
|
||||
public List<? extends IndicesRequest> subRequests() {
|
||||
List<IndicesRequest> indicesRequests = Lists.newArrayList();
|
||||
List<IndicesRequest> indicesRequests = new ArrayList<>();
|
||||
for (PercolateRequest percolateRequest : this.requests) {
|
||||
indicesRequests.addAll(percolateRequest.subRequests());
|
||||
}
|
||||
|
@ -18,7 +18,6 @@
|
||||
*/
|
||||
package org.elasticsearch.action.percolate;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.elasticsearch.ElasticsearchGenerationException;
|
||||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.action.CompositeIndicesRequest;
|
||||
@ -35,6 +34,7 @@ import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -79,7 +79,7 @@ public class PercolateRequest extends BroadcastRequest<PercolateRequest> impleme
|
||||
|
||||
@Override
|
||||
public List<? extends IndicesRequest> subRequests() {
|
||||
List<IndicesRequest> requests = Lists.newArrayList();
|
||||
List<IndicesRequest> requests = new ArrayList<>();
|
||||
requests.add(this);
|
||||
if (getRequest != null) {
|
||||
requests.add(getRequest);
|
||||
|
@ -19,8 +19,6 @@
|
||||
|
||||
package org.elasticsearch.action.percolate;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import org.elasticsearch.ElasticsearchGenerationException;
|
||||
import org.elasticsearch.action.support.ToXContentToBytes;
|
||||
import org.elasticsearch.client.Requests;
|
||||
@ -38,6 +36,7 @@ import org.elasticsearch.search.sort.ScoreSortBuilder;
|
||||
import org.elasticsearch.search.sort.SortBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -99,7 +98,7 @@ public class PercolateSourceBuilder extends ToXContentToBytes {
|
||||
*/
|
||||
public PercolateSourceBuilder addSort(SortBuilder sort) {
|
||||
if (sorts == null) {
|
||||
sorts = Lists.newArrayList();
|
||||
sorts = new ArrayList<>();
|
||||
}
|
||||
sorts.add(sort);
|
||||
return this;
|
||||
@ -127,7 +126,7 @@ public class PercolateSourceBuilder extends ToXContentToBytes {
|
||||
*/
|
||||
public PercolateSourceBuilder addAggregation(AbstractAggregationBuilder aggregationBuilder) {
|
||||
if (aggregations == null) {
|
||||
aggregations = Lists.newArrayList();
|
||||
aggregations = new ArrayList<>();
|
||||
}
|
||||
aggregations.add(aggregationBuilder);
|
||||
return this;
|
||||
|
@ -43,13 +43,12 @@ import org.elasticsearch.percolator.PercolatorService;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -126,7 +125,7 @@ public class TransportPercolateAction extends TransportBroadcastAction<Percolate
|
||||
} else if (shardResponse instanceof BroadcastShardOperationFailedException) {
|
||||
failedShards++;
|
||||
if (shardFailures == null) {
|
||||
shardFailures = newArrayList();
|
||||
shardFailures = new ArrayList<>();
|
||||
}
|
||||
shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse));
|
||||
} else {
|
||||
@ -135,7 +134,7 @@ public class TransportPercolateAction extends TransportBroadcastAction<Percolate
|
||||
if (!percolateShardResponse.isEmpty()) {
|
||||
if (shardResults == null) {
|
||||
percolatorTypeId = percolateShardResponse.percolatorTypeId();
|
||||
shardResults = newArrayList();
|
||||
shardResults = new ArrayList<>();
|
||||
}
|
||||
shardResults.add(percolateShardResponse);
|
||||
}
|
||||
|
@ -25,10 +25,10 @@ import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
import static org.elasticsearch.action.ValidateActions.addValidationError;
|
||||
|
||||
/**
|
||||
@ -47,7 +47,7 @@ public class ClearScrollRequest extends ActionRequest<ClearScrollRequest> {
|
||||
|
||||
public void addScrollId(String scrollId) {
|
||||
if (scrollIds == null) {
|
||||
scrollIds = newArrayList();
|
||||
scrollIds = new ArrayList<>();
|
||||
}
|
||||
scrollIds.add(scrollId);
|
||||
}
|
||||
|
@ -19,8 +19,6 @@
|
||||
|
||||
package org.elasticsearch.action.search;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import org.elasticsearch.action.ActionRequest;
|
||||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.action.CompositeIndicesRequest;
|
||||
@ -41,16 +39,14 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.elasticsearch.action.ValidateActions.addValidationError;
|
||||
import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeBooleanValue;
|
||||
import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeStringArrayValue;
|
||||
import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeStringValue;
|
||||
import static org.elasticsearch.common.xcontent.support.XContentMapValues.*;
|
||||
|
||||
/**
|
||||
* A multi search API request.
|
||||
*/
|
||||
public class MultiSearchRequest extends ActionRequest<MultiSearchRequest> implements CompositeIndicesRequest {
|
||||
|
||||
private List<SearchRequest> requests = Lists.newArrayList();
|
||||
private List<SearchRequest> requests = new ArrayList<>();
|
||||
|
||||
private IndicesOptions indicesOptions = IndicesOptions.strictExpandOpenAndForbidClosed();
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
package org.elasticsearch.action.search;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.search.type.ScrollIdForNode;
|
||||
import org.elasticsearch.action.support.ActionFilters;
|
||||
import org.elasticsearch.action.support.HandledTransportAction;
|
||||
import org.elasticsearch.cluster.ClusterService;
|
||||
@ -27,7 +28,6 @@ import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.common.collect.Tuple;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.concurrent.CountDown;
|
||||
@ -69,7 +69,7 @@ public class TransportClearScrollAction extends HandledTransportAction<ClearScro
|
||||
final DiscoveryNodes nodes;
|
||||
final CountDown expectedOps;
|
||||
final ClearScrollRequest request;
|
||||
final List<Tuple<String, Long>[]> contexts = new ArrayList<>();
|
||||
final List<ScrollIdForNode[]> contexts = new ArrayList<>();
|
||||
final ActionListener<ClearScrollResponse> listener;
|
||||
final AtomicReference<Throwable> expHolder;
|
||||
final AtomicInteger numberOfFreedSearchContexts = new AtomicInteger(0);
|
||||
@ -81,7 +81,7 @@ public class TransportClearScrollAction extends HandledTransportAction<ClearScro
|
||||
expectedOps = nodes.size();
|
||||
} else {
|
||||
for (String parsedScrollId : request.getScrollIds()) {
|
||||
Tuple<String, Long>[] context = parseScrollId(parsedScrollId).getContext();
|
||||
ScrollIdForNode[] context = parseScrollId(parsedScrollId).getContext();
|
||||
expectedOps += context.length;
|
||||
this.contexts.add(context);
|
||||
}
|
||||
@ -114,15 +114,15 @@ public class TransportClearScrollAction extends HandledTransportAction<ClearScro
|
||||
});
|
||||
}
|
||||
} else {
|
||||
for (Tuple<String, Long>[] context : contexts) {
|
||||
for (Tuple<String, Long> target : context) {
|
||||
final DiscoveryNode node = nodes.get(target.v1());
|
||||
for (ScrollIdForNode[] context : contexts) {
|
||||
for (ScrollIdForNode target : context) {
|
||||
final DiscoveryNode node = nodes.get(target.getNode());
|
||||
if (node == null) {
|
||||
onFreedContext(false);
|
||||
continue;
|
||||
}
|
||||
|
||||
searchServiceTransportAction.sendFreeContext(node, target.v2(), request, new ActionListener<SearchServiceTransportAction.SearchFreeContextResponse>() {
|
||||
searchServiceTransportAction.sendFreeContext(node, target.getScrollId(), request, new ActionListener<SearchServiceTransportAction.SearchFreeContextResponse>() {
|
||||
@Override
|
||||
public void onResponse(SearchServiceTransportAction.SearchFreeContextResponse freed) {
|
||||
onFreedContext(freed.isFreed());
|
||||
|
@ -19,9 +19,6 @@
|
||||
|
||||
package org.elasticsearch.action.search.type;
|
||||
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.common.collect.Tuple;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -39,11 +36,11 @@ public class ParsedScrollId {
|
||||
|
||||
private final String type;
|
||||
|
||||
private final Tuple<String, Long>[] context;
|
||||
private final ScrollIdForNode[] context;
|
||||
|
||||
private final Map<String, String> attributes;
|
||||
|
||||
public ParsedScrollId(String source, String type, Tuple<String, Long>[] context, Map<String, String> attributes) {
|
||||
public ParsedScrollId(String source, String type, ScrollIdForNode[] context, Map<String, String> attributes) {
|
||||
this.source = source;
|
||||
this.type = type;
|
||||
this.context = context;
|
||||
@ -58,7 +55,7 @@ public class ParsedScrollId {
|
||||
return type;
|
||||
}
|
||||
|
||||
public Tuple<String, Long>[] getContext() {
|
||||
public ScrollIdForNode[] getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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.action.search.type;
|
||||
|
||||
public class ScrollIdForNode {
|
||||
private final String node;
|
||||
private final long scrollId;
|
||||
|
||||
public ScrollIdForNode(String node, long scrollId) {
|
||||
this.node = node;
|
||||
this.scrollId = scrollId;
|
||||
}
|
||||
|
||||
public String getNode() {
|
||||
return node;
|
||||
}
|
||||
|
||||
public long getScrollId() {
|
||||
return scrollId;
|
||||
}
|
||||
}
|
@ -30,7 +30,6 @@ import org.elasticsearch.cluster.routing.ShardRouting;
|
||||
import org.elasticsearch.common.Base64;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.collect.Tuple;
|
||||
import org.elasticsearch.common.util.concurrent.AtomicArray;
|
||||
import org.elasticsearch.search.SearchPhaseResult;
|
||||
import org.elasticsearch.search.internal.InternalScrollSearchRequest;
|
||||
@ -103,14 +102,14 @@ public abstract class TransportSearchHelper {
|
||||
throw new IllegalArgumentException("Malformed scrollId [" + scrollId + "]");
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked"}) Tuple<String, Long>[] context = new Tuple[contextSize];
|
||||
ScrollIdForNode[] context = new ScrollIdForNode[contextSize];
|
||||
for (int i = 0; i < contextSize; i++) {
|
||||
String element = elements[index++];
|
||||
int sep = element.indexOf(':');
|
||||
if (sep == -1) {
|
||||
throw new IllegalArgumentException("Malformed scrollId [" + scrollId + "]");
|
||||
}
|
||||
context[i] = new Tuple<>(element.substring(sep + 1), Long.parseLong(element.substring(0, sep)));
|
||||
context[i] = new ScrollIdForNode(element.substring(sep + 1), Long.parseLong(element.substring(0, sep)));
|
||||
}
|
||||
Map<String, String> attributes;
|
||||
int attributesSize = Integer.parseInt(elements[index++]);
|
||||
|
@ -25,7 +25,6 @@ import org.elasticsearch.action.search.*;
|
||||
import org.elasticsearch.cluster.ClusterService;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.common.collect.Tuple;
|
||||
import org.elasticsearch.common.component.AbstractComponent;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
@ -115,15 +114,15 @@ public class TransportSearchScrollQueryAndFetchAction extends AbstractComponent
|
||||
return;
|
||||
}
|
||||
|
||||
Tuple<String, Long>[] context = scrollId.getContext();
|
||||
ScrollIdForNode[] context = scrollId.getContext();
|
||||
for (int i = 0; i < context.length; i++) {
|
||||
Tuple<String, Long> target = context[i];
|
||||
DiscoveryNode node = nodes.get(target.v1());
|
||||
ScrollIdForNode target = context[i];
|
||||
DiscoveryNode node = nodes.get(target.getNode());
|
||||
if (node != null) {
|
||||
executePhase(i, node, target.v2());
|
||||
executePhase(i, node, target.getScrollId());
|
||||
} else {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Node [" + target.v1() + "] not available for scroll request [" + scrollId.getSource() + "]");
|
||||
logger.debug("Node [" + target.getNode() + "] not available for scroll request [" + scrollId.getSource() + "]");
|
||||
}
|
||||
successfulOps.decrementAndGet();
|
||||
if (counter.decrementAndGet() == 0) {
|
||||
@ -132,11 +131,11 @@ public class TransportSearchScrollQueryAndFetchAction extends AbstractComponent
|
||||
}
|
||||
}
|
||||
|
||||
for (Tuple<String, Long> target : scrollId.getContext()) {
|
||||
DiscoveryNode node = nodes.get(target.v1());
|
||||
for (ScrollIdForNode target : scrollId.getContext()) {
|
||||
DiscoveryNode node = nodes.get(target.getNode());
|
||||
if (node == null) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Node [" + target.v1() + "] not available for scroll request [" + scrollId.getSource() + "]");
|
||||
logger.debug("Node [" + target.getNode() + "] not available for scroll request [" + scrollId.getSource() + "]");
|
||||
}
|
||||
successfulOps.decrementAndGet();
|
||||
if (counter.decrementAndGet() == 0) {
|
||||
|
@ -26,7 +26,6 @@ import org.elasticsearch.action.search.*;
|
||||
import org.elasticsearch.cluster.ClusterService;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.common.collect.Tuple;
|
||||
import org.elasticsearch.common.component.AbstractComponent;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
@ -124,15 +123,15 @@ public class TransportSearchScrollQueryThenFetchAction extends AbstractComponent
|
||||
}
|
||||
final AtomicInteger counter = new AtomicInteger(scrollId.getContext().length);
|
||||
|
||||
Tuple<String, Long>[] context = scrollId.getContext();
|
||||
ScrollIdForNode[] context = scrollId.getContext();
|
||||
for (int i = 0; i < context.length; i++) {
|
||||
Tuple<String, Long> target = context[i];
|
||||
DiscoveryNode node = nodes.get(target.v1());
|
||||
ScrollIdForNode target = context[i];
|
||||
DiscoveryNode node = nodes.get(target.getNode());
|
||||
if (node != null) {
|
||||
executeQueryPhase(i, counter, node, target.v2());
|
||||
executeQueryPhase(i, counter, node, target.getScrollId());
|
||||
} else {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Node [" + target.v1() + "] not available for scroll request [" + scrollId.getSource() + "]");
|
||||
logger.debug("Node [" + target.getNode() + "] not available for scroll request [" + scrollId.getSource() + "]");
|
||||
}
|
||||
successfulOps.decrementAndGet();
|
||||
if (counter.decrementAndGet() == 0) {
|
||||
|
@ -28,7 +28,6 @@ import org.elasticsearch.action.search.ShardSearchFailure;
|
||||
import org.elasticsearch.cluster.ClusterService;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.common.collect.Tuple;
|
||||
import org.elasticsearch.common.component.AbstractComponent;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
@ -125,15 +124,15 @@ public class TransportSearchScrollScanAction extends AbstractComponent {
|
||||
return;
|
||||
}
|
||||
|
||||
Tuple<String, Long>[] context = scrollId.getContext();
|
||||
ScrollIdForNode[] context = scrollId.getContext();
|
||||
for (int i = 0; i < context.length; i++) {
|
||||
Tuple<String, Long> target = context[i];
|
||||
DiscoveryNode node = nodes.get(target.v1());
|
||||
ScrollIdForNode target = context[i];
|
||||
DiscoveryNode node = nodes.get(target.getNode());
|
||||
if (node != null) {
|
||||
executePhase(i, node, target.v2());
|
||||
executePhase(i, node, target.getScrollId());
|
||||
} else {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Node [" + target.v1() + "] not available for scroll request [" + scrollId.getSource() + "]");
|
||||
logger.debug("Node [" + target.getScrollId() + "] not available for scroll request [" + scrollId.getSource() + "]");
|
||||
}
|
||||
successfulOps.decrementAndGet();
|
||||
if (counter.decrementAndGet() == 0) {
|
||||
@ -142,11 +141,11 @@ public class TransportSearchScrollScanAction extends AbstractComponent {
|
||||
}
|
||||
}
|
||||
|
||||
for (Tuple<String, Long> target : scrollId.getContext()) {
|
||||
DiscoveryNode node = nodes.get(target.v1());
|
||||
for (ScrollIdForNode target : scrollId.getContext()) {
|
||||
DiscoveryNode node = nodes.get(target.getNode());
|
||||
if (node == null) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Node [" + target.v1() + "] not available for scroll request [" + scrollId.getSource() + "]");
|
||||
logger.debug("Node [" + target.getNode() + "] not available for scroll request [" + scrollId.getSource() + "]");
|
||||
}
|
||||
successfulOps.decrementAndGet();
|
||||
if (counter.decrementAndGet() == 0) {
|
||||
|
@ -48,14 +48,13 @@ import org.elasticsearch.search.suggest.SuggestionSearchContext;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
|
||||
/**
|
||||
* Defines the transport of a suggestion request across the cluster
|
||||
*/
|
||||
@ -115,7 +114,7 @@ public class TransportSuggestAction extends TransportBroadcastAction<SuggestRequ
|
||||
} else if (shardResponse instanceof BroadcastShardOperationFailedException) {
|
||||
failedShards++;
|
||||
if (shardFailures == null) {
|
||||
shardFailures = newArrayList();
|
||||
shardFailures = new ArrayList<>();
|
||||
}
|
||||
shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse));
|
||||
} else {
|
||||
|
@ -19,13 +19,13 @@
|
||||
|
||||
package org.elasticsearch.action.support;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.ListenableActionFuture;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -66,7 +66,7 @@ public abstract class AbstractListenableActionFuture<T, L> extends AdapterAction
|
||||
((List) this.listeners).add(listener);
|
||||
} else {
|
||||
Object orig = listeners;
|
||||
listeners = Lists.newArrayListWithCapacity(2);
|
||||
listeners = new ArrayList<>(2);
|
||||
((List) listeners).add(orig);
|
||||
((List) listeners).add(listener);
|
||||
}
|
||||
|
@ -47,7 +47,6 @@ import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||
public abstract class TransportBroadcastAction<Request extends BroadcastRequest, Response extends BroadcastResponse, ShardRequest extends BroadcastShardRequest, ShardResponse extends BroadcastShardResponse>
|
||||
extends HandledTransportAction<Request, Response> {
|
||||
|
||||
protected final ThreadPool threadPool;
|
||||
protected final ClusterService clusterService;
|
||||
protected final TransportService transportService;
|
||||
|
||||
@ -59,7 +58,6 @@ public abstract class TransportBroadcastAction<Request extends BroadcastRequest,
|
||||
super(settings, actionName, threadPool, transportService, actionFilters, indexNameExpressionResolver, request);
|
||||
this.clusterService = clusterService;
|
||||
this.transportService = transportService;
|
||||
this.threadPool = threadPool;
|
||||
this.transportShardAction = actionName + "[s]";
|
||||
|
||||
transportService.registerRequestHandler(transportShardAction, shardRequest, shardExecutor, new ShardTransportHandler());
|
||||
|
@ -46,7 +46,6 @@ public abstract class ReplicationRequest<T extends ReplicationRequest> extends A
|
||||
protected TimeValue timeout = DEFAULT_TIMEOUT;
|
||||
protected String index;
|
||||
|
||||
private boolean threadedOperation = true;
|
||||
private WriteConsistencyLevel consistencyLevel = WriteConsistencyLevel.DEFAULT;
|
||||
private volatile boolean canHaveDuplicates = false;
|
||||
|
||||
@ -76,7 +75,6 @@ public abstract class ReplicationRequest<T extends ReplicationRequest> extends A
|
||||
super(originalRequest);
|
||||
this.timeout = request.timeout();
|
||||
this.index = request.index();
|
||||
this.threadedOperation = request.operationThreaded();
|
||||
this.consistencyLevel = request.consistencyLevel();
|
||||
}
|
||||
|
||||
@ -91,23 +89,6 @@ public abstract class ReplicationRequest<T extends ReplicationRequest> extends A
|
||||
return canHaveDuplicates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls if the operation will be executed on a separate thread when executed locally.
|
||||
*/
|
||||
public final boolean operationThreaded() {
|
||||
return threadedOperation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls if the operation will be executed on a separate thread when executed locally. Defaults
|
||||
* to <tt>true</tt> when running in embedded mode.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public final T operationThreaded(boolean threadedOperation) {
|
||||
this.threadedOperation = threadedOperation;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* A timeout to wait if the index operation can't be performed immediately. Defaults to <tt>1m</tt>.
|
||||
*/
|
||||
|
@ -35,16 +35,6 @@ public abstract class ReplicationRequestBuilder<Request extends ReplicationReque
|
||||
super(client, action, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls if the operation will be executed on a separate thread when executed locally. Defaults
|
||||
* to <tt>true</tt> when running in embedded mode.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public final RequestBuilder setOperationThreaded(boolean threadedOperation) {
|
||||
request.operationThreaded(threadedOperation);
|
||||
return (RequestBuilder) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* A timeout to wait if the index operation can't be performed immediately. Defaults to <tt>1m</tt>.
|
||||
*/
|
||||
|
@ -211,8 +211,6 @@ public abstract class TransportReplicationAction<Request extends ReplicationRequ
|
||||
class OperationTransportHandler implements TransportRequestHandler<Request> {
|
||||
@Override
|
||||
public void messageReceived(final Request request, final TransportChannel channel) throws Exception {
|
||||
// if we have a local operation, execute it on a thread since we don't spawn
|
||||
request.operationThreaded(true);
|
||||
execute(request, new ActionListener<Response>() {
|
||||
@Override
|
||||
public void onResponse(Response result) {
|
||||
@ -440,21 +438,17 @@ public abstract class TransportReplicationAction<Request extends ReplicationRequ
|
||||
protected void routeRequestOrPerformLocally(final ShardRouting primary, final ShardIterator shardsIt) {
|
||||
if (primary.currentNodeId().equals(observer.observedState().nodes().localNodeId())) {
|
||||
try {
|
||||
if (internalRequest.request().operationThreaded()) {
|
||||
threadPool.executor(executor).execute(new AbstractRunnable() {
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
finishAsFailed(t);
|
||||
}
|
||||
threadPool.executor(executor).execute(new AbstractRunnable() {
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
finishAsFailed(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doRun() throws Exception {
|
||||
performOnPrimary(primary, shardsIt);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
performOnPrimary(primary, shardsIt);
|
||||
}
|
||||
@Override
|
||||
protected void doRun() throws Exception {
|
||||
performOnPrimary(primary, shardsIt);
|
||||
}
|
||||
});
|
||||
} catch (Throwable t) {
|
||||
finishAsFailed(t);
|
||||
}
|
||||
@ -506,9 +500,6 @@ public abstract class TransportReplicationAction<Request extends ReplicationRequ
|
||||
finishAsFailed(failure);
|
||||
return;
|
||||
}
|
||||
// make it threaded operation so we fork on the discovery listener thread
|
||||
internalRequest.request().operationThreaded(true);
|
||||
|
||||
observer.waitForNextChange(new ClusterStateObserver.Listener() {
|
||||
@Override
|
||||
public void onNewClusterState(ClusterState state) {
|
||||
@ -904,43 +895,33 @@ public abstract class TransportReplicationAction<Request extends ReplicationRequ
|
||||
|
||||
});
|
||||
} else {
|
||||
if (replicaRequest.operationThreaded()) {
|
||||
try {
|
||||
threadPool.executor(executor).execute(new AbstractRunnable() {
|
||||
@Override
|
||||
protected void doRun() {
|
||||
try {
|
||||
shardOperationOnReplica(shard.shardId(), replicaRequest);
|
||||
onReplicaSuccess();
|
||||
} catch (Throwable e) {
|
||||
onReplicaFailure(nodeId, e);
|
||||
failReplicaIfNeeded(shard.index(), shard.id(), e);
|
||||
}
|
||||
try {
|
||||
threadPool.executor(executor).execute(new AbstractRunnable() {
|
||||
@Override
|
||||
protected void doRun() {
|
||||
try {
|
||||
shardOperationOnReplica(shard.shardId(), replicaRequest);
|
||||
onReplicaSuccess();
|
||||
} catch (Throwable e) {
|
||||
onReplicaFailure(nodeId, e);
|
||||
failReplicaIfNeeded(shard.index(), shard.id(), e);
|
||||
}
|
||||
}
|
||||
|
||||
// we must never reject on because of thread pool capacity on replicas
|
||||
@Override
|
||||
public boolean isForceExecution() {
|
||||
return true;
|
||||
}
|
||||
// we must never reject on because of thread pool capacity on replicas
|
||||
@Override
|
||||
public boolean isForceExecution() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
onReplicaFailure(nodeId, t);
|
||||
}
|
||||
});
|
||||
} catch (Throwable e) {
|
||||
failReplicaIfNeeded(shard.index(), shard.id(), e);
|
||||
onReplicaFailure(nodeId, e);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
shardOperationOnReplica(shard.shardId(), replicaRequest);
|
||||
onReplicaSuccess();
|
||||
} catch (Throwable e) {
|
||||
failReplicaIfNeeded(shard.index(), shard.id(), e);
|
||||
onReplicaFailure(nodeId, e);
|
||||
}
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
onReplicaFailure(nodeId, t);
|
||||
}
|
||||
});
|
||||
} catch (Throwable e) {
|
||||
failReplicaIfNeeded(shard.index(), shard.id(), e);
|
||||
onReplicaFailure(nodeId, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,13 +42,12 @@ import org.elasticsearch.search.dfs.DfsSearchResult;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
|
||||
/**
|
||||
* Get the dfs only with no fetch phase. This is for internal use only.
|
||||
*/
|
||||
@ -115,7 +114,7 @@ public class TransportDfsOnlyAction extends TransportBroadcastAction<DfsOnlyRequ
|
||||
} else if (shardResponse instanceof BroadcastShardOperationFailedException) {
|
||||
failedShards++;
|
||||
if (shardFailures == null) {
|
||||
shardFailures = newArrayList();
|
||||
shardFailures = new ArrayList<>();
|
||||
}
|
||||
shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse));
|
||||
} else {
|
||||
|
@ -131,7 +131,6 @@ public class UpdateHelper extends AbstractComponent {
|
||||
.routing(request.routing())
|
||||
.parent(request.parent())
|
||||
.consistencyLevel(request.consistencyLevel());
|
||||
indexRequest.operationThreaded(false);
|
||||
if (request.versionType() != VersionType.INTERNAL) {
|
||||
// in all but the internal versioning mode, we want to create the new document using the given version.
|
||||
indexRequest.version(request.version()).versionType(request.versionType());
|
||||
@ -227,13 +226,11 @@ public class UpdateHelper extends AbstractComponent {
|
||||
.consistencyLevel(request.consistencyLevel())
|
||||
.timestamp(timestamp).ttl(ttl)
|
||||
.refresh(request.refresh());
|
||||
indexRequest.operationThreaded(false);
|
||||
return new Result(indexRequest, Operation.INDEX, updatedSourceAsMap, updateSourceContentType);
|
||||
} else if ("delete".equals(operation)) {
|
||||
DeleteRequest deleteRequest = Requests.deleteRequest(request.index()).type(request.type()).id(request.id()).routing(routing).parent(parent)
|
||||
.version(updateVersion).versionType(request.versionType())
|
||||
.consistencyLevel(request.consistencyLevel());
|
||||
deleteRequest.operationThreaded(false);
|
||||
return new Result(deleteRequest, Operation.DELETE, updatedSourceAsMap, updateSourceContentType);
|
||||
} else if ("none".equals(operation)) {
|
||||
UpdateResponse update = new UpdateResponse(getResult.getIndex(), getResult.getType(), getResult.getId(), getResult.getVersion(), false);
|
||||
|
@ -78,7 +78,7 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
||||
|
||||
private boolean scriptedUpsert = false;
|
||||
private boolean docAsUpsert = false;
|
||||
private boolean detectNoop = false;
|
||||
private boolean detectNoop = true;
|
||||
|
||||
@Nullable
|
||||
private IndexRequest doc;
|
||||
@ -243,7 +243,7 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
||||
* The script to execute. Note, make sure not to send different script each
|
||||
* times and instead use script params if possible with the same
|
||||
* (automatically compiled) script.
|
||||
*
|
||||
*
|
||||
* @deprecated Use {@link #script(Script)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
@ -256,7 +256,7 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
||||
* The script to execute. Note, make sure not to send different script each
|
||||
* times and instead use script params if possible with the same
|
||||
* (automatically compiled) script.
|
||||
*
|
||||
*
|
||||
* @deprecated Use {@link #script(Script)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
@ -267,7 +267,7 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
||||
|
||||
/**
|
||||
* The language of the script to execute.
|
||||
*
|
||||
*
|
||||
* @deprecated Use {@link #script(Script)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
@ -286,7 +286,7 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
||||
|
||||
/**
|
||||
* Add a script parameter.
|
||||
*
|
||||
*
|
||||
* @deprecated Use {@link #script(Script)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
@ -311,7 +311,7 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
||||
|
||||
/**
|
||||
* Sets the script parameters to use with the script.
|
||||
*
|
||||
*
|
||||
* @deprecated Use {@link #script(Script)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
@ -338,7 +338,7 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
||||
* The script to execute. Note, make sure not to send different script each
|
||||
* times and instead use script params if possible with the same
|
||||
* (automatically compiled) script.
|
||||
*
|
||||
*
|
||||
* @deprecated Use {@link #script(Script)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
@ -360,7 +360,7 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
||||
* The script type
|
||||
* @param scriptParams
|
||||
* The script parameters
|
||||
*
|
||||
*
|
||||
* @deprecated Use {@link #script(Script)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
@ -623,7 +623,7 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
||||
}
|
||||
|
||||
/**
|
||||
* Should this update attempt to detect if it is a noop?
|
||||
* Should this update attempt to detect if it is a noop? Defaults to true.
|
||||
* @return this for chaining
|
||||
*/
|
||||
public UpdateRequest detectNoop(boolean detectNoop) {
|
||||
@ -631,6 +631,9 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should this update attempt to detect if it is a noop? Defaults to true.
|
||||
*/
|
||||
public boolean detectNoop() {
|
||||
return detectNoop;
|
||||
}
|
||||
@ -699,16 +702,15 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
||||
this.docAsUpsert = shouldUpsertDoc;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public boolean scriptedUpsert(){
|
||||
return this.scriptedUpsert;
|
||||
}
|
||||
|
||||
|
||||
public UpdateRequest scriptedUpsert(boolean scriptedUpsert) {
|
||||
this.scriptedUpsert = scriptedUpsert;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
|
@ -308,6 +308,7 @@ public class UpdateRequestBuilder extends InstanceShardOperationRequestBuilder<U
|
||||
|
||||
/**
|
||||
* Sets whether to perform extra effort to detect noop updates via docAsUpsert.
|
||||
* Defautls to true.
|
||||
*/
|
||||
public UpdateRequestBuilder setDetectNoop(boolean detectNoop) {
|
||||
request.detectNoop(detectNoop);
|
||||
@ -322,4 +323,14 @@ public class UpdateRequestBuilder extends InstanceShardOperationRequestBuilder<U
|
||||
request.scriptedUpsert(scriptedUpsert);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the new ttl of the document. Note that if detectNoop is true (the default)
|
||||
* and the source of the document isn't changed then the ttl update won't take
|
||||
* effect.
|
||||
*/
|
||||
public UpdateRequestBuilder setTtl(Long ttl) {
|
||||
request.doc().ttl(ttl);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ package org.elasticsearch.client.transport;
|
||||
|
||||
import com.carrotsearch.hppc.cursors.ObjectCursor;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.elasticsearch.ExceptionsHelper;
|
||||
import org.elasticsearch.Version;
|
||||
@ -43,9 +42,20 @@ import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
|
||||
import org.elasticsearch.common.util.concurrent.FutureUtils;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.*;
|
||||
import org.elasticsearch.transport.BaseTransportResponseHandler;
|
||||
import org.elasticsearch.transport.ConnectTransportException;
|
||||
import org.elasticsearch.transport.FutureTransportResponseHandler;
|
||||
import org.elasticsearch.transport.TransportException;
|
||||
import org.elasticsearch.transport.TransportRequestOptions;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
@ -143,7 +153,7 @@ public class TransportClientNodesService extends AbstractComponent {
|
||||
if (closed) {
|
||||
throw new IllegalStateException("transport client is closed, can't add an address");
|
||||
}
|
||||
List<TransportAddress> filtered = Lists.newArrayListWithExpectedSize(transportAddresses.length);
|
||||
List<TransportAddress> filtered = new ArrayList<>(transportAddresses.length);
|
||||
for (TransportAddress transportAddress : transportAddresses) {
|
||||
boolean found = false;
|
||||
for (DiscoveryNode otherNode : listedNodes) {
|
||||
|
@ -21,11 +21,11 @@ package org.elasticsearch.cluster;
|
||||
|
||||
import com.carrotsearch.hppc.cursors.ObjectCursor;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
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.List;
|
||||
|
||||
@ -93,7 +93,7 @@ public class ClusterChangedEvent {
|
||||
String index = cursor.value;
|
||||
if (!previousState.metaData().hasIndex(index)) {
|
||||
if (created == null) {
|
||||
created = Lists.newArrayList();
|
||||
created = new ArrayList<>();
|
||||
}
|
||||
created.add(index);
|
||||
}
|
||||
@ -126,7 +126,7 @@ public class ClusterChangedEvent {
|
||||
String index = cursor.value;
|
||||
if (!state.metaData().hasIndex(index)) {
|
||||
if (deleted == null) {
|
||||
deleted = Lists.newArrayList();
|
||||
deleted = new ArrayList<>();
|
||||
}
|
||||
deleted.add(index);
|
||||
}
|
||||
|
@ -27,11 +27,11 @@ import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
import static com.google.common.collect.Maps.newHashMap;
|
||||
|
||||
public final class DiffableUtils {
|
||||
@ -232,13 +232,13 @@ public final class DiffableUtils {
|
||||
protected final Map<String, T> adds;
|
||||
|
||||
protected MapDiff() {
|
||||
deletes = newArrayList();
|
||||
deletes = new ArrayList<>();
|
||||
diffs = newHashMap();
|
||||
adds = newHashMap();
|
||||
}
|
||||
|
||||
protected MapDiff(StreamInput in, KeyedReader<T> reader) throws IOException {
|
||||
deletes = newArrayList();
|
||||
deletes = new ArrayList<>();
|
||||
diffs = newHashMap();
|
||||
adds = newHashMap();
|
||||
int deletesCount = in.readVInt();
|
||||
|
@ -41,10 +41,17 @@ import org.joda.time.DateTimeZone;
|
||||
import org.joda.time.format.DateTimeFormat;
|
||||
import org.joda.time.format.DateTimeFormatter;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
import static com.google.common.collect.Maps.filterEntries;
|
||||
import static com.google.common.collect.Maps.newHashMap;
|
||||
|
||||
@ -268,7 +275,7 @@ public class IndexNameExpressionResolver extends AbstractComponent {
|
||||
if (filteringRequired) {
|
||||
// If filtering required - add it to the list of filters
|
||||
if (filteringAliases == null) {
|
||||
filteringAliases = newArrayList();
|
||||
filteringAliases = new ArrayList<>();
|
||||
}
|
||||
filteringAliases.add(alias);
|
||||
} else {
|
||||
|
@ -23,7 +23,10 @@ import com.carrotsearch.hppc.ObjectHashSet;
|
||||
import com.carrotsearch.hppc.cursors.ObjectCursor;
|
||||
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.*;
|
||||
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;
|
||||
import org.elasticsearch.cluster.Diff;
|
||||
import org.elasticsearch.cluster.Diffable;
|
||||
@ -45,7 +48,12 @@ import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.regex.Regex;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.loader.SettingsLoader;
|
||||
import org.elasticsearch.common.xcontent.*;
|
||||
import org.elasticsearch.common.xcontent.FromXContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.discovery.DiscoverySettings;
|
||||
import org.elasticsearch.index.IndexNotFoundException;
|
||||
import org.elasticsearch.indices.recovery.RecoverySettings;
|
||||
@ -55,7 +63,18 @@ import org.elasticsearch.rest.RestStatus;
|
||||
import org.elasticsearch.search.warmer.IndexWarmersMetaData;
|
||||
|
||||
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.Comparator;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import static org.elasticsearch.common.settings.Settings.*;
|
||||
|
||||
@ -246,7 +265,7 @@ public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, Fr
|
||||
Iterable<String> intersection = HppcMaps.intersection(ObjectHashSet.from(concreteIndices), indices.keys());
|
||||
for (String index : intersection) {
|
||||
IndexMetaData indexMetaData = indices.get(index);
|
||||
List<AliasMetaData> filteredValues = Lists.newArrayList();
|
||||
List<AliasMetaData> filteredValues = new ArrayList<>();
|
||||
for (ObjectCursor<AliasMetaData> cursor : indexMetaData.getAliases().values()) {
|
||||
AliasMetaData value = cursor.value;
|
||||
if (matchAllAliases || Regex.simpleMatch(aliases, value.alias())) {
|
||||
@ -295,7 +314,7 @@ public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, Fr
|
||||
Iterable<String> intersection = HppcMaps.intersection(ObjectHashSet.from(concreteIndices), indices.keys());
|
||||
for (String index : intersection) {
|
||||
IndexMetaData indexMetaData = indices.get(index);
|
||||
List<AliasMetaData> filteredValues = Lists.newArrayList();
|
||||
List<AliasMetaData> filteredValues = new ArrayList<>();
|
||||
for (ObjectCursor<AliasMetaData> cursor : indexMetaData.getAliases().values()) {
|
||||
AliasMetaData value = cursor.value;
|
||||
if (Regex.simpleMatch(aliases, value.alias())) {
|
||||
@ -978,14 +997,14 @@ public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, Fr
|
||||
// TODO: I think we can remove these arrays. it isn't worth the effort, for operations on all indices.
|
||||
// When doing an operation across all indices, most of the time is spent on actually going to all shards and
|
||||
// do the required operations, the bottleneck isn't resolving expressions into concrete indices.
|
||||
List<String> allIndicesLst = Lists.newArrayList();
|
||||
List<String> allIndicesLst = new ArrayList<>();
|
||||
for (ObjectCursor<IndexMetaData> cursor : indices.values()) {
|
||||
allIndicesLst.add(cursor.value.index());
|
||||
}
|
||||
String[] allIndices = allIndicesLst.toArray(new String[allIndicesLst.size()]);
|
||||
|
||||
List<String> allOpenIndicesLst = Lists.newArrayList();
|
||||
List<String> allClosedIndicesLst = Lists.newArrayList();
|
||||
List<String> allOpenIndicesLst = new ArrayList<>();
|
||||
List<String> allClosedIndicesLst = new ArrayList<>();
|
||||
for (ObjectCursor<IndexMetaData> cursor : indices.values()) {
|
||||
IndexMetaData indexMetaData = cursor.value;
|
||||
if (indexMetaData.state() == IndexMetaData.State.OPEN) {
|
||||
|
@ -22,7 +22,6 @@ package org.elasticsearch.cluster.metadata;
|
||||
import com.carrotsearch.hppc.cursors.ObjectCursor;
|
||||
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.apache.lucene.util.CollectionUtil;
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
@ -80,7 +79,12 @@ import java.io.UnsupportedEncodingException;
|
||||
import java.nio.file.DirectoryStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@ -248,7 +252,7 @@ public class MetaDataCreateIndexService extends AbstractComponent {
|
||||
|
||||
Map<String, AliasMetaData> templatesAliases = Maps.newHashMap();
|
||||
|
||||
List<String> templateNames = Lists.newArrayList();
|
||||
List<String> templateNames = new ArrayList<>();
|
||||
|
||||
for (Map.Entry<String, String> entry : request.mappings().entrySet()) {
|
||||
mappings.put(entry.getKey(), parseMapping(entry.getValue()));
|
||||
@ -494,7 +498,7 @@ public class MetaDataCreateIndexService extends AbstractComponent {
|
||||
}
|
||||
|
||||
private List<IndexTemplateMetaData> findTemplates(CreateIndexClusterStateUpdateRequest request, ClusterState state, IndexTemplateFilter indexTemplateFilter) throws IOException {
|
||||
List<IndexTemplateMetaData> templates = Lists.newArrayList();
|
||||
List<IndexTemplateMetaData> templates = new ArrayList<>();
|
||||
for (ObjectCursor<IndexTemplateMetaData> cursor : state.metaData().templates().values()) {
|
||||
IndexTemplateMetaData template = cursor.value;
|
||||
if (indexTemplateFilter.apply(request, template)) {
|
||||
@ -527,7 +531,7 @@ public class MetaDataCreateIndexService extends AbstractComponent {
|
||||
|
||||
List<String> getIndexSettingsValidationErrors(Settings settings) {
|
||||
String customPath = settings.get(IndexMetaData.SETTING_DATA_PATH, null);
|
||||
List<String> validationErrors = Lists.newArrayList();
|
||||
List<String> validationErrors = new ArrayList<>();
|
||||
if (customPath != null && env.sharedDataFile() == null) {
|
||||
validationErrors.add("path.shared_data must be set in order to use custom data paths");
|
||||
} else if (customPath != null) {
|
||||
|
@ -20,7 +20,6 @@
|
||||
package org.elasticsearch.cluster.metadata;
|
||||
|
||||
import com.carrotsearch.hppc.cursors.ObjectCursor;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesClusterStateUpdateRequest;
|
||||
@ -34,10 +33,11 @@ import org.elasticsearch.common.component.AbstractComponent;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.IndexNotFoundException;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.index.IndexService;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.indices.IndicesService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -69,7 +69,7 @@ public class MetaDataIndexAliasesService extends AbstractComponent {
|
||||
|
||||
@Override
|
||||
public ClusterState execute(final ClusterState currentState) {
|
||||
List<String> indicesToClose = Lists.newArrayList();
|
||||
List<String> indicesToClose = new ArrayList<>();
|
||||
Map<String, IndexService> indices = Maps.newHashMap();
|
||||
try {
|
||||
for (AliasAction aliasAction : request.actions()) {
|
||||
|
@ -19,7 +19,6 @@
|
||||
package org.elasticsearch.cluster.metadata;
|
||||
|
||||
import com.carrotsearch.hppc.cursors.ObjectCursor;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.elasticsearch.action.admin.indices.alias.Alias;
|
||||
@ -39,6 +38,7 @@ import org.elasticsearch.indices.IndexTemplateAlreadyExistsException;
|
||||
import org.elasticsearch.indices.IndexTemplateMissingException;
|
||||
import org.elasticsearch.indices.InvalidIndexTemplateException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@ -179,7 +179,7 @@ public class MetaDataIndexTemplateService extends AbstractComponent {
|
||||
}
|
||||
|
||||
private void validate(PutRequest request) {
|
||||
List<String> validationErrors = Lists.newArrayList();
|
||||
List<String> validationErrors = new ArrayList<>();
|
||||
if (request.name.contains(" ")) {
|
||||
validationErrors.add("name must not contain a space");
|
||||
}
|
||||
@ -240,7 +240,7 @@ public class MetaDataIndexTemplateService extends AbstractComponent {
|
||||
String template;
|
||||
Settings settings = Settings.Builder.EMPTY_SETTINGS;
|
||||
Map<String, String> mappings = Maps.newHashMap();
|
||||
List<Alias> aliases = Lists.newArrayList();
|
||||
List<Alias> aliases = new ArrayList<>();
|
||||
Map<String, IndexMetaData.Custom> customs = Maps.newHashMap();
|
||||
|
||||
TimeValue masterTimeout = MasterNodeRequest.DEFAULT_MASTER_NODE_TIMEOUT;
|
||||
|
@ -20,7 +20,6 @@
|
||||
package org.elasticsearch.cluster.metadata;
|
||||
|
||||
import com.carrotsearch.hppc.cursors.ObjectCursor;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.elasticsearch.Version;
|
||||
@ -47,7 +46,12 @@ import org.elasticsearch.indices.IndicesService;
|
||||
import org.elasticsearch.indices.InvalidTypeNameException;
|
||||
import org.elasticsearch.percolator.PercolatorService;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.collect.Maps.newHashMap;
|
||||
/**
|
||||
@ -226,7 +230,7 @@ public class MetaDataMappingService extends AbstractComponent {
|
||||
if (task instanceof RefreshTask) {
|
||||
RefreshTask refreshTask = (RefreshTask) task;
|
||||
try {
|
||||
List<String> updatedTypes = Lists.newArrayList();
|
||||
List<String> updatedTypes = new ArrayList<>();
|
||||
for (String type : refreshTask.types) {
|
||||
if (processedRefreshes.contains(type)) {
|
||||
continue;
|
||||
@ -342,7 +346,7 @@ public class MetaDataMappingService extends AbstractComponent {
|
||||
|
||||
@Override
|
||||
public ClusterState execute(final ClusterState currentState) throws Exception {
|
||||
List<String> indicesToClose = Lists.newArrayList();
|
||||
List<String> indicesToClose = new ArrayList<>();
|
||||
try {
|
||||
for (String index : request.indices()) {
|
||||
if (!currentState.metaData().hasIndex(index)) {
|
||||
|
@ -35,12 +35,11 @@ import org.elasticsearch.common.regex.Regex;
|
||||
import org.elasticsearch.common.transport.TransportAddress;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
|
||||
/**
|
||||
* This class holds all {@link DiscoveryNode} in the cluster and provides convenience methods to
|
||||
* access, modify merge / diff discovery nodes.
|
||||
@ -414,8 +413,8 @@ public class DiscoveryNodes extends AbstractDiffable<DiscoveryNodes> implements
|
||||
* Returns the changes comparing this nodes to the provided nodes.
|
||||
*/
|
||||
public Delta delta(DiscoveryNodes other) {
|
||||
List<DiscoveryNode> removed = newArrayList();
|
||||
List<DiscoveryNode> added = newArrayList();
|
||||
List<DiscoveryNode> removed = new ArrayList<>();
|
||||
List<DiscoveryNode> added = new ArrayList<>();
|
||||
for (DiscoveryNode node : other) {
|
||||
if (!this.nodeExists(node.id())) {
|
||||
removed.add(node);
|
||||
|
@ -25,7 +25,6 @@ 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;
|
||||
import org.elasticsearch.cluster.AbstractDiffable;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
@ -42,8 +41,6 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
import static com.google.common.collect.Lists.*;
|
||||
|
||||
/**
|
||||
* The {@link IndexRoutingTable} represents routing information for a single
|
||||
* index. The routing table maintains a list of all shards in the index. A
|
||||
@ -265,7 +262,7 @@ public class IndexRoutingTable extends AbstractDiffable<IndexRoutingTable> imple
|
||||
* @return a {@link List} of shards that match one of the given {@link ShardRoutingState states}
|
||||
*/
|
||||
public List<ShardRouting> shardsWithState(ShardRoutingState state) {
|
||||
List<ShardRouting> shards = newArrayList();
|
||||
List<ShardRouting> shards = new ArrayList<>();
|
||||
for (IndexShardRoutingTable shardRoutingTable : this) {
|
||||
shards.addAll(shardRoutingTable.shardsWithState(state));
|
||||
}
|
||||
|
@ -30,11 +30,15 @@ import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
|
||||
/**
|
||||
* {@link IndexShardRoutingTable} encapsulates all instances of a single shard.
|
||||
* Each Elasticsearch index consists of multiple shards, each shard encapsulates
|
||||
@ -554,7 +558,7 @@ public class IndexShardRoutingTable implements Iterable<ShardRouting> {
|
||||
}
|
||||
|
||||
public List<ShardRouting> replicaShardsWithState(ShardRoutingState... states) {
|
||||
List<ShardRouting> shards = newArrayList();
|
||||
List<ShardRouting> shards = new ArrayList<>();
|
||||
for (ShardRouting shardEntry : replicas) {
|
||||
for (ShardRoutingState state : states) {
|
||||
if (shardEntry.state() == state) {
|
||||
@ -569,7 +573,7 @@ public class IndexShardRoutingTable implements Iterable<ShardRouting> {
|
||||
if (state == ShardRoutingState.INITIALIZING) {
|
||||
return allInitializingShards;
|
||||
}
|
||||
List<ShardRouting> shards = newArrayList();
|
||||
List<ShardRouting> shards = new ArrayList<>();
|
||||
for (ShardRouting shardEntry : this) {
|
||||
if (shardEntry.state() == state) {
|
||||
shards.add(shardEntry);
|
||||
@ -585,12 +589,12 @@ public class IndexShardRoutingTable implements Iterable<ShardRouting> {
|
||||
|
||||
public Builder(IndexShardRoutingTable indexShard) {
|
||||
this.shardId = indexShard.shardId;
|
||||
this.shards = newArrayList(indexShard.shards);
|
||||
this.shards = new ArrayList<>(indexShard.shards);
|
||||
}
|
||||
|
||||
public Builder(ShardId shardId) {
|
||||
this.shardId = shardId;
|
||||
this.shards = newArrayList();
|
||||
this.shards = new ArrayList<>();
|
||||
}
|
||||
|
||||
public Builder addShard(ShardRouting shardEntry) {
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package org.elasticsearch.cluster.routing;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
@ -36,6 +35,7 @@ import org.elasticsearch.index.IndexNotFoundException;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.index.shard.ShardNotFoundException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
@ -90,7 +90,7 @@ public class OperationRouting extends AbstractComponent {
|
||||
set.add(iterator);
|
||||
}
|
||||
}
|
||||
return new GroupShardsIterator(Lists.newArrayList(set));
|
||||
return new GroupShardsIterator(new ArrayList<>(set));
|
||||
}
|
||||
|
||||
private static final Map<String, Set<String>> EMPTY_ROUTING = Collections.emptyMap();
|
||||
|
@ -27,8 +27,6 @@ import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
|
||||
/**
|
||||
* A {@link RoutingNode} represents a cluster node associated with a single {@link DiscoveryNode} including all shards
|
||||
* that are hosted on that nodes. Each {@link RoutingNode} has a unique node id that can be used to identify the node.
|
||||
@ -118,7 +116,7 @@ public class RoutingNode implements Iterable<ShardRouting> {
|
||||
* @return List of shards
|
||||
*/
|
||||
public List<ShardRouting> shardsWithState(ShardRoutingState... states) {
|
||||
List<ShardRouting> shards = newArrayList();
|
||||
List<ShardRouting> shards = new ArrayList<>();
|
||||
for (ShardRouting shardEntry : this) {
|
||||
for (ShardRoutingState state : states) {
|
||||
if (shardEntry.state() == state) {
|
||||
@ -136,7 +134,7 @@ public class RoutingNode implements Iterable<ShardRouting> {
|
||||
* @return a list of shards
|
||||
*/
|
||||
public List<ShardRouting> shardsWithState(String index, ShardRoutingState... states) {
|
||||
List<ShardRouting> shards = newArrayList();
|
||||
List<ShardRouting> shards = new ArrayList<>();
|
||||
|
||||
for (ShardRouting shardEntry : this) {
|
||||
if (!shardEntry.index().equals(index)) {
|
||||
|
@ -22,19 +22,25 @@ package org.elasticsearch.cluster.routing;
|
||||
import com.carrotsearch.hppc.ObjectIntHashMap;
|
||||
import com.carrotsearch.hppc.cursors.ObjectCursor;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.*;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Iterators;
|
||||
import org.apache.lucene.util.CollectionUtil;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlocks;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
import static com.google.common.collect.Maps.newHashMap;
|
||||
import static com.google.common.collect.Sets.newHashSet;
|
||||
|
||||
@ -97,7 +103,7 @@ public class RoutingNodes implements Iterable<RoutingNode> {
|
||||
if (shard.assignedToNode()) {
|
||||
List<ShardRouting> entries = nodesToShards.get(shard.currentNodeId());
|
||||
if (entries == null) {
|
||||
entries = newArrayList();
|
||||
entries = new ArrayList<>();
|
||||
nodesToShards.put(shard.currentNodeId(), entries);
|
||||
}
|
||||
final ShardRouting sr = getRouting(shard, readOnly);
|
||||
@ -107,7 +113,7 @@ public class RoutingNodes implements Iterable<RoutingNode> {
|
||||
entries = nodesToShards.get(shard.relocatingNodeId());
|
||||
relocatingShards++;
|
||||
if (entries == null) {
|
||||
entries = newArrayList();
|
||||
entries = new ArrayList<>();
|
||||
nodesToShards.put(shard.relocatingNodeId(), entries);
|
||||
}
|
||||
// add the counterpart shard with relocatingNodeId reflecting the source from which
|
||||
@ -285,7 +291,7 @@ public class RoutingNodes implements Iterable<RoutingNode> {
|
||||
}
|
||||
|
||||
public List<ShardRouting> shards(Predicate<ShardRouting> predicate) {
|
||||
List<ShardRouting> shards = newArrayList();
|
||||
List<ShardRouting> shards = new ArrayList<>();
|
||||
for (RoutingNode routingNode : this) {
|
||||
for (ShardRouting shardRouting : routingNode) {
|
||||
if (predicate.apply(shardRouting)) {
|
||||
@ -298,7 +304,7 @@ public class RoutingNodes implements Iterable<RoutingNode> {
|
||||
|
||||
public List<ShardRouting> shardsWithState(ShardRoutingState... state) {
|
||||
// TODO these are used on tests only - move into utils class
|
||||
List<ShardRouting> shards = newArrayList();
|
||||
List<ShardRouting> shards = new ArrayList<>();
|
||||
for (RoutingNode routingNode : this) {
|
||||
shards.addAll(routingNode.shardsWithState(state));
|
||||
}
|
||||
@ -313,7 +319,7 @@ public class RoutingNodes implements Iterable<RoutingNode> {
|
||||
|
||||
public List<ShardRouting> shardsWithState(String index, ShardRoutingState... state) {
|
||||
// TODO these are used on tests only - move into utils class
|
||||
List<ShardRouting> shards = newArrayList();
|
||||
List<ShardRouting> shards = new ArrayList<>();
|
||||
for (RoutingNode routingNode : this) {
|
||||
shards.addAll(routingNode.shardsWithState(index, state));
|
||||
}
|
||||
@ -452,7 +458,7 @@ public class RoutingNodes implements Iterable<RoutingNode> {
|
||||
}
|
||||
List<ShardRouting> shards = assignedShards.get(shard.shardId());
|
||||
if (shards == null) {
|
||||
shards = Lists.newArrayList();
|
||||
shards = new ArrayList<>();
|
||||
assignedShards.put(shard.shardId(), shards);
|
||||
}
|
||||
assert assertInstanceNotInList(shard, shards);
|
||||
@ -724,7 +730,7 @@ public class RoutingNodes implements Iterable<RoutingNode> {
|
||||
}
|
||||
// Assert that the active shard routing are identical.
|
||||
Set<Map.Entry<String, Integer>> entries = indicesAndShards.entrySet();
|
||||
final List<ShardRouting> shards = newArrayList();
|
||||
final List<ShardRouting> shards = new ArrayList<>();
|
||||
for (Map.Entry<String, Integer> e : entries) {
|
||||
String index = e.getKey();
|
||||
for (int i = 0; i < e.getValue(); i++) {
|
||||
|
@ -21,8 +21,12 @@ package org.elasticsearch.cluster.routing;
|
||||
|
||||
import com.carrotsearch.hppc.IntSet;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.*;
|
||||
import org.elasticsearch.cluster.*;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.UnmodifiableIterator;
|
||||
import org.elasticsearch.cluster.Diff;
|
||||
import org.elasticsearch.cluster.Diffable;
|
||||
import org.elasticsearch.cluster.DiffableUtils;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
@ -35,7 +39,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
import static com.google.common.collect.Maps.newHashMap;
|
||||
|
||||
/**
|
||||
@ -107,7 +110,7 @@ public class RoutingTable implements Iterable<IndexRoutingTable>, Diffable<Routi
|
||||
}
|
||||
|
||||
public List<ShardRouting> shardsWithState(ShardRoutingState state) {
|
||||
List<ShardRouting> shards = newArrayList();
|
||||
List<ShardRouting> shards = new ArrayList<>();
|
||||
for (IndexRoutingTable indexRoutingTable : this) {
|
||||
shards.addAll(indexRoutingTable.shardsWithState(state));
|
||||
}
|
||||
@ -120,7 +123,7 @@ public class RoutingTable implements Iterable<IndexRoutingTable>, Diffable<Routi
|
||||
* @return All the shards
|
||||
*/
|
||||
public List<ShardRouting> allShards() {
|
||||
List<ShardRouting> shards = Lists.newArrayList();
|
||||
List<ShardRouting> shards = new ArrayList<>();
|
||||
String[] indices = indicesRouting.keySet().toArray(new String[indicesRouting.keySet().size()]);
|
||||
for (String index : indices) {
|
||||
List<ShardRouting> allShardsIndex = allShards(index);
|
||||
@ -137,7 +140,7 @@ public class RoutingTable implements Iterable<IndexRoutingTable>, Diffable<Routi
|
||||
* @throws IndexNotFoundException If the index passed does not exists
|
||||
*/
|
||||
public List<ShardRouting> allShards(String index) {
|
||||
List<ShardRouting> shards = Lists.newArrayList();
|
||||
List<ShardRouting> shards = new ArrayList<>();
|
||||
IndexRoutingTable indexRoutingTable = index(index);
|
||||
if (indexRoutingTable == null) {
|
||||
throw new IndexNotFoundException(index);
|
||||
|
@ -21,17 +21,15 @@ package org.elasticsearch.cluster.routing;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.io.stream.Streamable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
import static com.google.common.collect.Lists.newArrayListWithCapacity;
|
||||
import static com.google.common.collect.Maps.newHashMap;
|
||||
|
||||
/**
|
||||
@ -57,7 +55,7 @@ public class RoutingTableValidation implements Streamable {
|
||||
if (failures().isEmpty() && indicesFailures().isEmpty()) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
List<String> allFailures = newArrayList(failures());
|
||||
List<String> allFailures = new ArrayList<>(failures());
|
||||
for (Map.Entry<String, List<String>> entry : indicesFailures().entrySet()) {
|
||||
for (String failure : entry.getValue()) {
|
||||
allFailures.add("Index [" + entry.getKey() + "]: " + failure);
|
||||
@ -94,7 +92,7 @@ public class RoutingTableValidation implements Streamable {
|
||||
public void addFailure(String failure) {
|
||||
valid = false;
|
||||
if (failures == null) {
|
||||
failures = newArrayList();
|
||||
failures = new ArrayList<>();
|
||||
}
|
||||
failures.add(failure);
|
||||
}
|
||||
@ -106,7 +104,7 @@ public class RoutingTableValidation implements Streamable {
|
||||
}
|
||||
List<String> indexFailures = indicesFailures.get(index);
|
||||
if (indexFailures == null) {
|
||||
indexFailures = Lists.newArrayList();
|
||||
indexFailures = new ArrayList<>();
|
||||
indicesFailures.put(index, indexFailures);
|
||||
}
|
||||
indexFailures.add(failure);
|
||||
@ -124,7 +122,7 @@ public class RoutingTableValidation implements Streamable {
|
||||
if (size == 0) {
|
||||
failures = ImmutableList.of();
|
||||
} else {
|
||||
failures = Lists.newArrayListWithCapacity(size);
|
||||
failures = new ArrayList<>(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
failures.add(in.readString());
|
||||
}
|
||||
@ -137,7 +135,7 @@ public class RoutingTableValidation implements Streamable {
|
||||
for (int i = 0; i < size; i++) {
|
||||
String index = in.readString();
|
||||
int size2 = in.readVInt();
|
||||
List<String> indexFailures = newArrayListWithCapacity(size2);
|
||||
List<String> indexFailures = new ArrayList<>(size2);
|
||||
for (int j = 0; j < size2; j++) {
|
||||
indexFailures.add(in.readString());
|
||||
}
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package org.elasticsearch.cluster.routing.allocation;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
@ -28,6 +27,7 @@ import org.elasticsearch.common.io.stream.Streamable;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -88,7 +88,7 @@ public class AllocationExplanation implements Streamable {
|
||||
public AllocationExplanation add(ShardId shardId, NodeExplanation nodeExplanation) {
|
||||
List<NodeExplanation> list = explanations.get(shardId);
|
||||
if (list == null) {
|
||||
list = Lists.newArrayList();
|
||||
list = new ArrayList<>();
|
||||
explanations.put(shardId, list);
|
||||
}
|
||||
list.add(nodeExplanation);
|
||||
@ -121,7 +121,7 @@ public class AllocationExplanation implements Streamable {
|
||||
for (int i = 0; i < size; i++) {
|
||||
ShardId shardId = ShardId.readShardId(in);
|
||||
int size2 = in.readVInt();
|
||||
List<NodeExplanation> ne = Lists.newArrayListWithCapacity(size2);
|
||||
List<NodeExplanation> ne = new ArrayList<>(size2);
|
||||
for (int j = 0; j < size2; j++) {
|
||||
DiscoveryNode node = null;
|
||||
if (in.readBoolean()) {
|
||||
|
@ -21,12 +21,16 @@ package org.elasticsearch.cluster.routing.allocation;
|
||||
|
||||
import com.carrotsearch.hppc.cursors.ObjectCursor;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.elasticsearch.cluster.ClusterInfoService;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.cluster.routing.*;
|
||||
import org.elasticsearch.cluster.routing.IndexRoutingTable;
|
||||
import org.elasticsearch.cluster.routing.RoutingNode;
|
||||
import org.elasticsearch.cluster.routing.RoutingNodes;
|
||||
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||
import org.elasticsearch.cluster.routing.UnassignedInfo;
|
||||
import org.elasticsearch.cluster.routing.allocation.allocator.ShardsAllocators;
|
||||
import org.elasticsearch.cluster.routing.allocation.command.AllocationCommands;
|
||||
import org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders;
|
||||
@ -36,7 +40,6 @@ import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@ -235,7 +238,7 @@ public class AllocationService extends AbstractComponent {
|
||||
}
|
||||
|
||||
// go over and remove dangling replicas that are initializing for primary shards
|
||||
List<ShardRouting> shardsToFail = Lists.newArrayList();
|
||||
List<ShardRouting> shardsToFail = new ArrayList<>();
|
||||
for (ShardRouting shardEntry : routingNodes.unassigned()) {
|
||||
if (shardEntry.primary()) {
|
||||
for (ShardRouting routing : routingNodes.assignedShards(shardEntry)) {
|
||||
|
@ -25,10 +25,9 @@ import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
|
||||
/**
|
||||
* Class used to encapsulate a number of {@link RerouteExplanation}
|
||||
* explanations.
|
||||
@ -37,7 +36,7 @@ public class RoutingExplanations implements ToXContent {
|
||||
private final List<RerouteExplanation> explanations;
|
||||
|
||||
public RoutingExplanations() {
|
||||
this.explanations = newArrayList();
|
||||
this.explanations = new ArrayList<>();
|
||||
}
|
||||
|
||||
public RoutingExplanations add(RerouteExplanation explanation) {
|
||||
|
@ -20,8 +20,8 @@
|
||||
package org.elasticsearch.cluster.routing.allocation.command;
|
||||
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.cluster.routing.allocation.RoutingExplanations;
|
||||
import org.elasticsearch.cluster.routing.allocation.RoutingAllocation;
|
||||
import org.elasticsearch.cluster.routing.allocation.RoutingExplanations;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
@ -30,13 +30,12 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
|
||||
/**
|
||||
* A simple {@link AllocationCommand} composite managing several
|
||||
* {@link AllocationCommand} implementations
|
||||
@ -73,7 +72,7 @@ public class AllocationCommands {
|
||||
registerFactory(MoveAllocationCommand.NAME, new MoveAllocationCommand.Factory());
|
||||
}
|
||||
|
||||
private final List<AllocationCommand> commands = newArrayList();
|
||||
private final List<AllocationCommand> commands = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Creates a new set of {@link AllocationCommands}
|
||||
|
@ -19,13 +19,13 @@
|
||||
|
||||
package org.elasticsearch.cluster.routing.allocation.decider;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
@ -226,7 +226,7 @@ public abstract class Decision implements ToXContent {
|
||||
*/
|
||||
public static class Multi extends Decision {
|
||||
|
||||
private final List<Decision> decisions = Lists.newArrayList();
|
||||
private final List<Decision> decisions = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Add a decision to this {@link Multi}decision instance
|
||||
|
@ -943,7 +943,8 @@ public class Strings {
|
||||
boolean changed = false;
|
||||
for (int i = 0; i < value.length(); i++) {
|
||||
char c = value.charAt(i);
|
||||
if (c == '_') {
|
||||
//e.g. _name stays as-is, _first_name becomes _firstName
|
||||
if (c == '_' && i > 0) {
|
||||
if (!changed) {
|
||||
if (sb != null) {
|
||||
sb.setLength(0);
|
||||
|
@ -36,7 +36,7 @@ public class ValidationException extends IllegalArgumentException {
|
||||
* Add a new validation error to the accumulating validation errors
|
||||
* @param error the error to add
|
||||
*/
|
||||
public void addValidationError(String error) {
|
||||
public final void addValidationError(String error) {
|
||||
validationErrors.add(error);
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ public class ValidationException extends IllegalArgumentException {
|
||||
* Add a sequence of validation errors to the accumulating validation errors
|
||||
* @param errors the errors to add
|
||||
*/
|
||||
public void addValidationErrors(Iterable<String> errors) {
|
||||
public final void addValidationErrors(Iterable<String> errors) {
|
||||
for (String error : errors) {
|
||||
validationErrors.add(error);
|
||||
}
|
||||
@ -52,14 +52,13 @@ public class ValidationException extends IllegalArgumentException {
|
||||
|
||||
/**
|
||||
* Returns the validation errors accumulated
|
||||
* @return
|
||||
*/
|
||||
public List<String> validationErrors() {
|
||||
public final List<String> validationErrors() {
|
||||
return validationErrors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
public final String getMessage() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Validation Failed: ");
|
||||
int index = 0;
|
||||
|
@ -17,10 +17,33 @@
|
||||
package org.elasticsearch.common.inject;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.elasticsearch.common.inject.internal.*;
|
||||
import org.elasticsearch.common.inject.spi.*;
|
||||
import org.elasticsearch.common.inject.internal.Annotations;
|
||||
import org.elasticsearch.common.inject.internal.BindingImpl;
|
||||
import org.elasticsearch.common.inject.internal.Errors;
|
||||
import org.elasticsearch.common.inject.internal.ErrorsException;
|
||||
import org.elasticsearch.common.inject.internal.ExposedBindingImpl;
|
||||
import org.elasticsearch.common.inject.internal.InstanceBindingImpl;
|
||||
import org.elasticsearch.common.inject.internal.InternalFactory;
|
||||
import org.elasticsearch.common.inject.internal.LinkedBindingImpl;
|
||||
import org.elasticsearch.common.inject.internal.LinkedProviderBindingImpl;
|
||||
import org.elasticsearch.common.inject.internal.ProviderInstanceBindingImpl;
|
||||
import org.elasticsearch.common.inject.internal.ProviderMethod;
|
||||
import org.elasticsearch.common.inject.internal.Scoping;
|
||||
import org.elasticsearch.common.inject.internal.UntargettedBindingImpl;
|
||||
import org.elasticsearch.common.inject.spi.BindingTargetVisitor;
|
||||
import org.elasticsearch.common.inject.spi.ConstructorBinding;
|
||||
import org.elasticsearch.common.inject.spi.ConvertedConstantBinding;
|
||||
import org.elasticsearch.common.inject.spi.ExposedBinding;
|
||||
import org.elasticsearch.common.inject.spi.InjectionPoint;
|
||||
import org.elasticsearch.common.inject.spi.InstanceBinding;
|
||||
import org.elasticsearch.common.inject.spi.LinkedKeyBinding;
|
||||
import org.elasticsearch.common.inject.spi.PrivateElements;
|
||||
import org.elasticsearch.common.inject.spi.ProviderBinding;
|
||||
import org.elasticsearch.common.inject.spi.ProviderInstanceBinding;
|
||||
import org.elasticsearch.common.inject.spi.ProviderKeyBinding;
|
||||
import org.elasticsearch.common.inject.spi.UntargettedBinding;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@ -32,9 +55,9 @@ import java.util.Set;
|
||||
*/
|
||||
class BindingProcessor extends AbstractProcessor {
|
||||
|
||||
private final List<CreationListener> creationListeners = Lists.newArrayList();
|
||||
private final List<CreationListener> creationListeners = new ArrayList<>();
|
||||
private final Initializer initializer;
|
||||
private final List<Runnable> uninitializedBindings = Lists.newArrayList();
|
||||
private final List<Runnable> uninitializedBindings = new ArrayList<>();
|
||||
|
||||
BindingProcessor(Errors errors, Initializer initializer) {
|
||||
super(errors);
|
||||
|
@ -16,12 +16,12 @@
|
||||
|
||||
package org.elasticsearch.common.inject;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.elasticsearch.common.inject.internal.Errors;
|
||||
import org.elasticsearch.common.inject.spi.Element;
|
||||
import org.elasticsearch.common.inject.spi.MembersInjectorLookup;
|
||||
import org.elasticsearch.common.inject.spi.ProviderLookup;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -32,7 +32,7 @@ import java.util.List;
|
||||
*/
|
||||
class DeferredLookups implements Lookups {
|
||||
private final InjectorImpl injector;
|
||||
private final List<Element> lookups = Lists.newArrayList();
|
||||
private final List<Element> lookups = new ArrayList<>();
|
||||
|
||||
public DeferredLookups(InjectorImpl injector) {
|
||||
this.injector = injector;
|
||||
|
@ -17,12 +17,12 @@
|
||||
package org.elasticsearch.common.inject;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
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.List;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
@ -64,7 +64,7 @@ final class EncounterImpl<T> implements TypeEncounter<T> {
|
||||
checkState(valid, "Encounters may not be used after hear() returns.");
|
||||
|
||||
if (membersInjectors == null) {
|
||||
membersInjectors = Lists.newArrayList();
|
||||
membersInjectors = new ArrayList<>();
|
||||
}
|
||||
|
||||
membersInjectors.add(membersInjector);
|
||||
@ -75,7 +75,7 @@ final class EncounterImpl<T> implements TypeEncounter<T> {
|
||||
checkState(valid, "Encounters may not be used after hear() returns.");
|
||||
|
||||
if (injectionListeners == null) {
|
||||
injectionListeners = Lists.newArrayList();
|
||||
injectionListeners = new ArrayList<>();
|
||||
}
|
||||
|
||||
injectionListeners.add(injectionListener);
|
||||
|
@ -17,9 +17,13 @@
|
||||
package org.elasticsearch.common.inject;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.elasticsearch.common.inject.internal.*;
|
||||
import org.elasticsearch.common.inject.internal.BindingImpl;
|
||||
import org.elasticsearch.common.inject.internal.Errors;
|
||||
import org.elasticsearch.common.inject.internal.InstanceBindingImpl;
|
||||
import org.elasticsearch.common.inject.internal.InternalFactory;
|
||||
import org.elasticsearch.common.inject.internal.MatcherAndConverter;
|
||||
import org.elasticsearch.common.inject.internal.SourceProvider;
|
||||
import org.elasticsearch.common.inject.spi.InjectionPoint;
|
||||
import org.elasticsearch.common.inject.spi.TypeListenerBinding;
|
||||
|
||||
@ -43,8 +47,8 @@ class InheritingState implements State {
|
||||
private final Map<Key<?>, Binding<?>> explicitBindings
|
||||
= Collections.unmodifiableMap(explicitBindingsMutable);
|
||||
private final Map<Class<? extends Annotation>, Scope> scopes = Maps.newHashMap();
|
||||
private final List<MatcherAndConverter> converters = Lists.newArrayList();
|
||||
private final List<TypeListenerBinding> listenerBindings = Lists.newArrayList();
|
||||
private final List<MatcherAndConverter> converters = new ArrayList<>();
|
||||
private final List<TypeListenerBinding> listenerBindings = new ArrayList<>();
|
||||
private WeakKeySet blacklistedKeys = new WeakKeySet();
|
||||
private final Object lock;
|
||||
|
||||
|
@ -16,12 +16,12 @@
|
||||
|
||||
package org.elasticsearch.common.inject;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.elasticsearch.common.inject.internal.Errors;
|
||||
import org.elasticsearch.common.inject.internal.ErrorsException;
|
||||
import org.elasticsearch.common.inject.spi.InjectionPoint;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
@ -95,7 +95,7 @@ class Initializer {
|
||||
void injectAll(final Errors errors) {
|
||||
// loop over a defensive copy since ensureInjected() mutates the set. Unfortunately, that copy
|
||||
// is made complicated by a bug in IBM's JDK, wherein entrySet().toArray(Object[]) doesn't work
|
||||
for (InjectableReference<?> reference : Lists.newArrayList(pendingInjection.values())) {
|
||||
for (InjectableReference<?> reference : new ArrayList<>(pendingInjection.values())) {
|
||||
try {
|
||||
reference.get(errors);
|
||||
} catch (ErrorsException e) {
|
||||
|
@ -17,7 +17,6 @@
|
||||
package org.elasticsearch.common.inject;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.elasticsearch.common.inject.internal.Errors;
|
||||
import org.elasticsearch.common.inject.internal.ErrorsException;
|
||||
import org.elasticsearch.common.inject.internal.InternalContext;
|
||||
@ -25,6 +24,7 @@ import org.elasticsearch.common.inject.spi.InjectionPoint;
|
||||
import org.elasticsearch.common.inject.spi.InjectionRequest;
|
||||
import org.elasticsearch.common.inject.spi.StaticInjectionRequest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@ -37,7 +37,7 @@ import java.util.Set;
|
||||
*/
|
||||
class InjectionRequestProcessor extends AbstractProcessor {
|
||||
|
||||
private final List<StaticInjection> staticInjections = Lists.newArrayList();
|
||||
private final List<StaticInjection> staticInjections = new ArrayList<>();
|
||||
private final Initializer initializer;
|
||||
|
||||
InjectionRequestProcessor(Errors errors, Initializer initializer) {
|
||||
|
@ -18,15 +18,37 @@ package org.elasticsearch.common.inject;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.elasticsearch.common.Classes;
|
||||
import org.elasticsearch.common.inject.internal.*;
|
||||
import org.elasticsearch.common.inject.spi.*;
|
||||
import org.elasticsearch.common.inject.internal.Annotations;
|
||||
import org.elasticsearch.common.inject.internal.BindingImpl;
|
||||
import org.elasticsearch.common.inject.internal.Errors;
|
||||
import org.elasticsearch.common.inject.internal.ErrorsException;
|
||||
import org.elasticsearch.common.inject.internal.InstanceBindingImpl;
|
||||
import org.elasticsearch.common.inject.internal.InternalContext;
|
||||
import org.elasticsearch.common.inject.internal.InternalFactory;
|
||||
import org.elasticsearch.common.inject.internal.LinkedBindingImpl;
|
||||
import org.elasticsearch.common.inject.internal.LinkedProviderBindingImpl;
|
||||
import org.elasticsearch.common.inject.internal.MatcherAndConverter;
|
||||
import org.elasticsearch.common.inject.internal.Nullable;
|
||||
import org.elasticsearch.common.inject.internal.Scoping;
|
||||
import org.elasticsearch.common.inject.internal.SourceProvider;
|
||||
import org.elasticsearch.common.inject.internal.ToStringBuilder;
|
||||
import org.elasticsearch.common.inject.spi.BindingTargetVisitor;
|
||||
import org.elasticsearch.common.inject.spi.ConvertedConstantBinding;
|
||||
import org.elasticsearch.common.inject.spi.Dependency;
|
||||
import org.elasticsearch.common.inject.spi.InjectionPoint;
|
||||
import org.elasticsearch.common.inject.spi.ProviderBinding;
|
||||
import org.elasticsearch.common.inject.spi.ProviderKeyBinding;
|
||||
import org.elasticsearch.common.inject.util.Providers;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.*;
|
||||
import java.lang.reflect.GenericArrayType;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -681,7 +703,7 @@ class InjectorImpl implements Injector, Lookups {
|
||||
<T> void put(TypeLiteral<T> type, Binding<T> binding) {
|
||||
List<Binding<?>> bindingsForType = multimap.get(type);
|
||||
if (bindingsForType == null) {
|
||||
bindingsForType = Lists.newArrayList();
|
||||
bindingsForType = new ArrayList<>();
|
||||
multimap.put(type, bindingsForType);
|
||||
}
|
||||
bindingsForType.add(binding);
|
||||
|
@ -17,10 +17,23 @@
|
||||
package org.elasticsearch.common.inject;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.elasticsearch.common.inject.internal.*;
|
||||
import org.elasticsearch.common.inject.spi.*;
|
||||
import org.elasticsearch.common.inject.internal.Errors;
|
||||
import org.elasticsearch.common.inject.internal.ErrorsException;
|
||||
import org.elasticsearch.common.inject.internal.InternalContext;
|
||||
import org.elasticsearch.common.inject.internal.InternalFactory;
|
||||
import org.elasticsearch.common.inject.internal.PrivateElementsImpl;
|
||||
import org.elasticsearch.common.inject.internal.ProviderInstanceBindingImpl;
|
||||
import org.elasticsearch.common.inject.internal.Scoping;
|
||||
import org.elasticsearch.common.inject.internal.SourceProvider;
|
||||
import org.elasticsearch.common.inject.internal.Stopwatch;
|
||||
import org.elasticsearch.common.inject.spi.Dependency;
|
||||
import org.elasticsearch.common.inject.spi.Element;
|
||||
import org.elasticsearch.common.inject.spi.Elements;
|
||||
import org.elasticsearch.common.inject.spi.InjectionPoint;
|
||||
import org.elasticsearch.common.inject.spi.PrivateElements;
|
||||
import org.elasticsearch.common.inject.spi.TypeListenerBinding;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -59,8 +72,8 @@ class InjectorShell {
|
||||
}
|
||||
|
||||
static class Builder {
|
||||
private final List<Element> elements = Lists.newArrayList();
|
||||
private final List<Module> modules = Lists.newArrayList();
|
||||
private final List<Element> elements = new ArrayList<>();
|
||||
private final List<Module> modules = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* lazily constructed
|
||||
@ -148,7 +161,7 @@ class InjectorShell {
|
||||
bindingProcessor.process(injector, elements);
|
||||
stopwatch.resetAndLog("Binding creation");
|
||||
|
||||
List<InjectorShell> injectorShells = Lists.newArrayList();
|
||||
List<InjectorShell> injectorShells = new ArrayList<>();
|
||||
injectorShells.add(new InjectorShell(this, elements, injector));
|
||||
|
||||
// recursively build child shells
|
||||
|
@ -17,7 +17,6 @@
|
||||
package org.elasticsearch.common.inject;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
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.InjectionPoint;
|
||||
import org.elasticsearch.common.inject.spi.TypeListenerBinding;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@ -106,7 +106,7 @@ class MembersInjectorStore {
|
||||
*/
|
||||
ImmutableList<SingleMemberInjector> getInjectors(
|
||||
Set<InjectionPoint> injectionPoints, Errors errors) {
|
||||
List<SingleMemberInjector> injectors = Lists.newArrayList();
|
||||
List<SingleMemberInjector> injectors = new ArrayList<>();
|
||||
for (InjectionPoint injectionPoint : injectionPoints) {
|
||||
try {
|
||||
Errors errorsForMember = injectionPoint.isOptional()
|
||||
|
@ -19,8 +19,7 @@
|
||||
|
||||
package org.elasticsearch.common.inject;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
@ -29,7 +28,7 @@ import java.util.List;
|
||||
*/
|
||||
public class ModulesBuilder implements Iterable<Module> {
|
||||
|
||||
private final List<Module> modules = Lists.newArrayList();
|
||||
private final List<Module> modules = new ArrayList<>();
|
||||
|
||||
public ModulesBuilder add(Module... newModules) {
|
||||
for (Module module : newModules) {
|
||||
|
@ -16,10 +16,10 @@
|
||||
|
||||
package org.elasticsearch.common.inject;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.elasticsearch.common.inject.internal.Errors;
|
||||
import org.elasticsearch.common.inject.spi.PrivateElements;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -30,7 +30,7 @@ import java.util.List;
|
||||
class PrivateElementProcessor extends AbstractProcessor {
|
||||
|
||||
private final Stage stage;
|
||||
private final List<InjectorShell.Builder> injectorShellBuilders = Lists.newArrayList();
|
||||
private final List<InjectorShell.Builder> injectorShellBuilders = new ArrayList<>();
|
||||
|
||||
PrivateElementProcessor(Errors errors, Stage stage) {
|
||||
super(errors);
|
||||
|
@ -16,7 +16,6 @@
|
||||
|
||||
package org.elasticsearch.common.inject.assistedinject;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.inject.TypeLiteral;
|
||||
|
||||
@ -24,7 +23,11 @@ import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Internal respresentation of a constructor annotated with
|
||||
@ -45,7 +48,7 @@ class AssistedConstructor<T> {
|
||||
|
||||
Annotation[][] annotations = constructor.getParameterAnnotations();
|
||||
|
||||
List<Type> typeList = Lists.newArrayList();
|
||||
List<Type> typeList = new ArrayList<>();
|
||||
allParameters = new ArrayList<>();
|
||||
|
||||
// categorize params as @Assisted or @Injected
|
||||
|
@ -18,16 +18,25 @@ package org.elasticsearch.common.inject.assistedinject;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.elasticsearch.common.inject.*;
|
||||
import org.elasticsearch.common.inject.ConfigurationException;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.inject.Injector;
|
||||
import org.elasticsearch.common.inject.Key;
|
||||
import org.elasticsearch.common.inject.Provider;
|
||||
import org.elasticsearch.common.inject.TypeLiteral;
|
||||
import org.elasticsearch.common.inject.internal.Errors;
|
||||
import org.elasticsearch.common.inject.spi.Dependency;
|
||||
import org.elasticsearch.common.inject.spi.HasDependencies;
|
||||
import org.elasticsearch.common.inject.spi.Message;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.*;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -209,7 +218,7 @@ public class FactoryProvider<F> implements Provider<F>, HasDependencies {
|
||||
|
||||
private static Map<Method, AssistedConstructor<?>> createMethodMapping(
|
||||
TypeLiteral<?> factoryType, TypeLiteral<?> implementationType) {
|
||||
List<AssistedConstructor<?>> constructors = Lists.newArrayList();
|
||||
List<AssistedConstructor<?>> constructors = new ArrayList<>();
|
||||
|
||||
for (Constructor<?> constructor : implementationType.getRawType().getDeclaredConstructors()) {
|
||||
if (constructor.getAnnotation(AssistedInject.class) != null) {
|
||||
@ -248,7 +257,7 @@ public class FactoryProvider<F> implements Provider<F>, HasDependencies {
|
||||
method, implementationType);
|
||||
}
|
||||
|
||||
List<Type> parameterTypes = Lists.newArrayList();
|
||||
List<Type> parameterTypes = new ArrayList<>();
|
||||
for (TypeLiteral<?> parameterType : factoryType.getParameterTypes(method)) {
|
||||
parameterTypes.add(parameterType.getType());
|
||||
}
|
||||
@ -281,7 +290,7 @@ public class FactoryProvider<F> implements Provider<F>, HasDependencies {
|
||||
|
||||
@Override
|
||||
public Set<Dependency<?>> getDependencies() {
|
||||
List<Dependency<?>> dependencies = Lists.newArrayList();
|
||||
List<Dependency<?>> dependencies = new ArrayList<>();
|
||||
for (AssistedConstructor<?> constructor : factoryMethodToConstructor.values()) {
|
||||
for (Parameter parameter : constructor.getAllParameters()) {
|
||||
if (!parameter.isProvidedByFactory()) {
|
||||
|
@ -19,8 +19,17 @@ 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 com.google.common.collect.Lists;
|
||||
import org.elasticsearch.common.inject.*;
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.common.inject.Binder;
|
||||
import org.elasticsearch.common.inject.Binding;
|
||||
import org.elasticsearch.common.inject.ConfigurationException;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.inject.Injector;
|
||||
import org.elasticsearch.common.inject.Key;
|
||||
import org.elasticsearch.common.inject.Module;
|
||||
import org.elasticsearch.common.inject.Provider;
|
||||
import org.elasticsearch.common.inject.ProvisionException;
|
||||
import org.elasticsearch.common.inject.TypeLiteral;
|
||||
import org.elasticsearch.common.inject.internal.Errors;
|
||||
import org.elasticsearch.common.inject.internal.ErrorsException;
|
||||
import org.elasticsearch.common.inject.spi.Message;
|
||||
@ -30,6 +39,7 @@ import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@ -118,7 +128,7 @@ final class FactoryProvider2<F> implements InvocationHandler, Provider<F> {
|
||||
List<TypeLiteral<?>> params = factoryType.getParameterTypes(method);
|
||||
Annotation[][] paramAnnotations = method.getParameterAnnotations();
|
||||
int p = 0;
|
||||
List<Key<?>> keys = Lists.newArrayList();
|
||||
List<Key<?>> keys = new ArrayList<>();
|
||||
for (TypeLiteral<?> param : params) {
|
||||
Key<?> paramKey = getKey(param, method, paramAnnotations[p++], errors);
|
||||
keys.add(assistKey(method, paramKey, errors));
|
||||
|
@ -18,10 +18,20 @@ package org.elasticsearch.common.inject.internal;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.lucene.util.CollectionUtil;
|
||||
import org.elasticsearch.common.inject.*;
|
||||
import org.elasticsearch.common.inject.spi.*;
|
||||
import org.elasticsearch.common.inject.ConfigurationException;
|
||||
import org.elasticsearch.common.inject.CreationException;
|
||||
import org.elasticsearch.common.inject.Key;
|
||||
import org.elasticsearch.common.inject.MembersInjector;
|
||||
import org.elasticsearch.common.inject.Provider;
|
||||
import org.elasticsearch.common.inject.ProvisionException;
|
||||
import org.elasticsearch.common.inject.Scope;
|
||||
import org.elasticsearch.common.inject.TypeLiteral;
|
||||
import org.elasticsearch.common.inject.spi.Dependency;
|
||||
import org.elasticsearch.common.inject.spi.InjectionListener;
|
||||
import org.elasticsearch.common.inject.spi.InjectionPoint;
|
||||
import org.elasticsearch.common.inject.spi.Message;
|
||||
import org.elasticsearch.common.inject.spi.TypeListenerBinding;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Serializable;
|
||||
@ -31,7 +41,12 @@ import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Member;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.Formatter;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* A collection of error messages. If this type is passed as a method parameter, the method is
|
||||
@ -361,7 +376,7 @@ public final class Errors implements Serializable {
|
||||
}
|
||||
|
||||
private Message merge(Message message) {
|
||||
List<Object> sources = Lists.newArrayList();
|
||||
List<Object> sources = new ArrayList<>();
|
||||
sources.addAll(getSources());
|
||||
sources.addAll(message.getSources());
|
||||
return new Message(sources, message.getMessage(), message.getCause());
|
||||
@ -384,7 +399,7 @@ public final class Errors implements Serializable {
|
||||
}
|
||||
|
||||
public List<Object> getSources() {
|
||||
List<Object> sources = Lists.newArrayList();
|
||||
List<Object> sources = new ArrayList<>();
|
||||
for (Errors e = this; e != null; e = e.parent) {
|
||||
if (e.source != SourceProvider.UNKNOWN_SOURCE) {
|
||||
sources.add(0, e.source);
|
||||
@ -421,7 +436,7 @@ public final class Errors implements Serializable {
|
||||
|
||||
public Errors addMessage(Message message) {
|
||||
if (root.errors == null) {
|
||||
root.errors = Lists.newArrayList();
|
||||
root.errors = new ArrayList<>();
|
||||
}
|
||||
root.errors.add(message);
|
||||
return this;
|
||||
@ -439,7 +454,7 @@ public final class Errors implements Serializable {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
List<Message> result = Lists.newArrayList(root.errors);
|
||||
List<Message> result = new ArrayList<>(root.errors);
|
||||
CollectionUtil.timSort(result, new Comparator<Message>() {
|
||||
@Override
|
||||
public int compare(Message a, Message b) {
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
package org.elasticsearch.common.inject.internal;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.elasticsearch.common.util.CollectionUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
@ -98,7 +98,7 @@ public final class Join {
|
||||
public static String join(
|
||||
String delimiter, @Nullable Object firstToken, Object... otherTokens) {
|
||||
checkNotNull(otherTokens);
|
||||
return join(delimiter, Lists.newArrayList(firstToken, otherTokens));
|
||||
return join(delimiter, CollectionUtils.asArrayList(firstToken, otherTokens));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -208,7 +208,7 @@ public final class Join {
|
||||
public static <T extends Appendable> T join(T appendable, String delimiter,
|
||||
@Nullable Object firstToken, Object... otherTokens) {
|
||||
checkNotNull(otherTokens);
|
||||
return join(appendable, delimiter, Lists.newArrayList(firstToken, otherTokens));
|
||||
return join(appendable, delimiter, CollectionUtils.asArrayList(firstToken, otherTokens));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -18,7 +18,6 @@ package org.elasticsearch.common.inject.internal;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.elasticsearch.common.inject.Binder;
|
||||
import org.elasticsearch.common.inject.Injector;
|
||||
@ -28,6 +27,7 @@ import org.elasticsearch.common.inject.spi.Element;
|
||||
import org.elasticsearch.common.inject.spi.ElementVisitor;
|
||||
import org.elasticsearch.common.inject.spi.PrivateElements;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -47,8 +47,8 @@ public final class PrivateElementsImpl implements PrivateElements {
|
||||
|
||||
private final Object source;
|
||||
|
||||
private List<Element> elementsMutable = Lists.newArrayList();
|
||||
private List<ExposureBuilder<?>> exposureBuilders = Lists.newArrayList();
|
||||
private List<Element> elementsMutable = new ArrayList<>();
|
||||
private List<ExposureBuilder<?>> exposureBuilders = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* lazily instantiated
|
||||
|
@ -17,8 +17,12 @@
|
||||
package org.elasticsearch.common.inject.internal;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.elasticsearch.common.inject.*;
|
||||
import org.elasticsearch.common.inject.Binder;
|
||||
import org.elasticsearch.common.inject.Key;
|
||||
import org.elasticsearch.common.inject.Module;
|
||||
import org.elasticsearch.common.inject.Provider;
|
||||
import org.elasticsearch.common.inject.Provides;
|
||||
import org.elasticsearch.common.inject.TypeLiteral;
|
||||
import org.elasticsearch.common.inject.spi.Dependency;
|
||||
import org.elasticsearch.common.inject.spi.Message;
|
||||
import org.elasticsearch.common.inject.util.Modules;
|
||||
@ -26,6 +30,7 @@ import org.elasticsearch.common.inject.util.Modules;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Member;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
@ -74,7 +79,7 @@ public final class ProviderMethodsModule implements Module {
|
||||
}
|
||||
|
||||
public List<ProviderMethod<?>> getProviderMethods(Binder binder) {
|
||||
List<ProviderMethod<?>> result = Lists.newArrayList();
|
||||
List<ProviderMethod<?>> result = new ArrayList<>();
|
||||
for (Class<?> c = delegate.getClass(); c != Object.class; c = c.getSuperclass()) {
|
||||
for (Method method : c.getDeclaredMethods()) {
|
||||
if (method.getAnnotation(Provides.class) != null) {
|
||||
@ -90,8 +95,8 @@ public final class ProviderMethodsModule implements Module {
|
||||
Errors errors = new Errors(method);
|
||||
|
||||
// prepare the parameter providers
|
||||
List<Dependency<?>> dependencies = Lists.newArrayList();
|
||||
List<Provider<?>> parameterProviders = Lists.newArrayList();
|
||||
List<Dependency<?>> dependencies = new ArrayList<>();
|
||||
List<Provider<?>> parameterProviders = new ArrayList<>();
|
||||
List<TypeLiteral<?>> parameterTypes = typeLiteral.getParameterTypes(method);
|
||||
Annotation[][] parameterAnnotations = method.getParameterAnnotations();
|
||||
for (int i = 0; i < parameterTypes.size(); i++) {
|
||||
|
@ -18,8 +18,8 @@ package org.elasticsearch.common.inject.internal;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -58,7 +58,7 @@ public class SourceProvider {
|
||||
* Returns the class names as Strings
|
||||
*/
|
||||
private static List<String> asStrings(Class... classes) {
|
||||
List<String> strings = Lists.newArrayList();
|
||||
List<String> strings = new ArrayList<>();
|
||||
for (Class c : classes) {
|
||||
strings.add(c.getName());
|
||||
}
|
||||
|
@ -18,8 +18,15 @@ package org.elasticsearch.common.inject.multibindings;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.elasticsearch.common.inject.*;
|
||||
import org.elasticsearch.common.inject.Binder;
|
||||
import org.elasticsearch.common.inject.Binding;
|
||||
import org.elasticsearch.common.inject.ConfigurationException;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.inject.Injector;
|
||||
import org.elasticsearch.common.inject.Key;
|
||||
import org.elasticsearch.common.inject.Module;
|
||||
import org.elasticsearch.common.inject.Provider;
|
||||
import org.elasticsearch.common.inject.TypeLiteral;
|
||||
import org.elasticsearch.common.inject.binder.LinkedBindingBuilder;
|
||||
import org.elasticsearch.common.inject.internal.Errors;
|
||||
import org.elasticsearch.common.inject.spi.Dependency;
|
||||
@ -29,6 +36,7 @@ import org.elasticsearch.common.inject.util.Types;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
@ -229,8 +237,8 @@ public abstract class Multibinder<T> {
|
||||
*/
|
||||
@Inject
|
||||
void initialize(Injector injector) {
|
||||
providers = Lists.newArrayList();
|
||||
List<Dependency<?>> dependencies = Lists.newArrayList();
|
||||
providers = new ArrayList<>();
|
||||
List<Dependency<?>> dependencies = new ArrayList<>();
|
||||
for (Binding<?> entry : injector.findBindingsByType(elementType)) {
|
||||
|
||||
if (keyMatches(entry.getKey())) {
|
||||
|
@ -18,9 +18,9 @@ package org.elasticsearch.common.inject.spi;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.elasticsearch.common.inject.Key;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@ -60,7 +60,7 @@ public final class Dependency<T> {
|
||||
* Returns the dependencies from the given injection points.
|
||||
*/
|
||||
public static Set<Dependency<?>> forInjectionPoints(Set<InjectionPoint> injectionPoints) {
|
||||
List<Dependency<?>> dependencies = Lists.newArrayList();
|
||||
List<Dependency<?>> dependencies = new ArrayList<>();
|
||||
for (InjectionPoint injectionPoint : injectionPoints) {
|
||||
dependencies.addAll(injectionPoint.getDependencies());
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user