Merge branch 'master' into feature/query-refactoring
Conflicts: core/src/main/java/org/elasticsearch/index/query/PrefixQueryParser.java core/src/main/java/org/elasticsearch/index/query/RegexpQueryParser.java
This commit is contained in:
commit
c0490215c7
|
@ -1 +0,0 @@
|
|||
b8056886c1067b096c5ef05a024f1c5e9008e293
|
|
@ -0,0 +1 @@
|
|||
574a15e35eba5f986a0564ae197c78e843ece954
|
|
@ -1 +0,0 @@
|
|||
ad61cd1bba067e6634ddd3e160edf0727391ac30
|
|
@ -0,0 +1 @@
|
|||
15adf7ddece077d7dc429db058981f528d1c899a
|
93
core/pom.xml
93
core/pom.xml
|
@ -6,7 +6,7 @@
|
|||
<parent>
|
||||
<groupId>org.elasticsearch</groupId>
|
||||
<artifactId>elasticsearch-parent</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<version>2.0.0-beta1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.elasticsearch</groupId>
|
||||
|
@ -299,39 +299,6 @@
|
|||
</testResources>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<executable>${jvm.executable}</executable>
|
||||
<arguments>
|
||||
<argument>-Des.security.manager.enabled=false</argument>
|
||||
<argument>-classpath</argument>
|
||||
<classpath/>
|
||||
<argument>org.elasticsearch.bootstrap.Bootstrap</argument>
|
||||
<argument>-Xms256m</argument>
|
||||
<argument>-Xmx1g</argument>
|
||||
<argument>-Djava.awt.headless=true</argument>
|
||||
<argument>-XX:+UseParNewGC</argument>
|
||||
<argument>-XX:+UseConcMarkSweepGC</argument>
|
||||
<argument>-XX:CMSInitiatingOccupancyFraction=75</argument>
|
||||
<argument>-XX:+UseCMSInitiatingOccupancyOnly</argument>
|
||||
<argument>-XX:+HeapDumpOnOutOfMemoryError</argument>
|
||||
<argument>-XX:+DisableExplicitGC</argument>
|
||||
<argument>-Dfile.encoding=UTF-8</argument>
|
||||
<argument>-Djna.nosys=true</argument>
|
||||
<argument>-Delasticsearch</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
|
@ -392,6 +359,7 @@
|
|||
<include>com.tdunning:t-digest</include>
|
||||
<include>org.apache.commons:commons-lang3</include>
|
||||
<include>commons-cli:commons-cli</include>
|
||||
<include>com.twitter:jsr166e</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<transformers>
|
||||
|
@ -1024,11 +992,24 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- integration tests -->
|
||||
<!-- execution and integration tests -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<!-- start up elasticsearch in foreground -->
|
||||
<execution>
|
||||
<id>execute</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<target if="${run}">
|
||||
<ant antfile="${elasticsearch.integ.antfile}" target="start-foreground"/>
|
||||
</target>
|
||||
</configuration>
|
||||
</execution>
|
||||
<!-- start up external cluster -->
|
||||
<execution>
|
||||
<id>integ-setup</id>
|
||||
|
@ -1038,8 +1019,7 @@
|
|||
</goals>
|
||||
<configuration>
|
||||
<target>
|
||||
<ant antfile="${elasticsearch.tools.directory}/ant/integration-tests.xml"
|
||||
target="start-external-cluster"/>
|
||||
<ant antfile="${elasticsearch.integ.antfile}" target="start-external-cluster"/>
|
||||
</target>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
@ -1052,22 +1032,14 @@
|
|||
</goals>
|
||||
<configuration>
|
||||
<target>
|
||||
<ant antfile="${elasticsearch.tools.directory}/ant/integration-tests.xml"
|
||||
target="stop-external-cluster"/>
|
||||
<ant antfile="${elasticsearch.integ.antfile}" target="stop-external-cluster"/>
|
||||
<!-- TODO: remove this and the xslt when junit4 is fixed -->
|
||||
<ant antfile="${elasticsearch.integ.antfile}" target="fixup-failsafe-summary"/>
|
||||
</target>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<tests.cluster>127.0.0.1:9300</tests.cluster>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
|
@ -1111,6 +1083,31 @@
|
|||
</activation>
|
||||
<!-- not including license-maven-plugin is sufficent to expose default license -->
|
||||
</profile>
|
||||
<profile>
|
||||
<id>release</id> <!-- named after the parents release profile to be activated -->
|
||||
<activation>
|
||||
<property>
|
||||
<name>package.rpm</name>
|
||||
<value>true</value>
|
||||
</property>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>rpm-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-rpm</id>
|
||||
<goals>
|
||||
<goal>attached-rpm</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>sign-rpm</id>
|
||||
<activation>
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
|
||||
package org.apache.lucene.queryparser.classic;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.analysis.TokenStream;
|
||||
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
|
||||
|
@ -33,6 +31,8 @@ import org.apache.lucene.search.MatchNoDocsQuery;
|
|||
import org.apache.lucene.search.MultiPhraseQuery;
|
||||
import org.apache.lucene.search.PhraseQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.WildcardQuery;
|
||||
import org.apache.lucene.util.Version;
|
||||
import org.apache.lucene.util.automaton.RegExp;
|
||||
import org.elasticsearch.common.lucene.search.Queries;
|
||||
import org.elasticsearch.common.unit.Fuzziness;
|
||||
|
@ -42,6 +42,9 @@ import org.elasticsearch.index.mapper.core.DateFieldMapper;
|
|||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
import org.elasticsearch.index.query.support.QueryParsers;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
@ -128,7 +131,7 @@ public class MapperQueryParser extends QueryParser {
|
|||
setLowercaseExpandedTerms(settings.lowercaseExpandedTerms());
|
||||
setPhraseSlop(settings.phraseSlop());
|
||||
setDefaultOperator(settings.defaultOperator());
|
||||
setFuzzyMinSim(settings.fuzzyMinSim());
|
||||
setFuzzyMinSim(settings.getFuzziness().asFloat());
|
||||
setFuzzyPrefixLength(settings.fuzzyPrefixLength());
|
||||
setLocale(settings.locale());
|
||||
this.analyzeWildcard = settings.analyzeWildcard();
|
||||
|
@ -721,6 +724,15 @@ public class MapperQueryParser extends QueryParser {
|
|||
return super.getWildcardQuery(field, aggStr.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected WildcardQuery newWildcardQuery(Term t) {
|
||||
// Backport: https://issues.apache.org/jira/browse/LUCENE-6677
|
||||
assert Version.LATEST == Version.LUCENE_5_2_1;
|
||||
WildcardQuery query = new WildcardQuery(t, maxDeterminizedStates);
|
||||
query.setRewriteMethod(multiTermRewriteMethod);
|
||||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Query getRegexpQuery(String field, String termStr) throws ParseException {
|
||||
if (lowercaseExpandedTerms) {
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.apache.lucene.analysis.Analyzer;
|
|||
import org.apache.lucene.search.FuzzyQuery;
|
||||
import org.apache.lucene.search.MultiTermQuery;
|
||||
import org.apache.lucene.util.automaton.Operations;
|
||||
import org.elasticsearch.common.unit.Fuzziness;
|
||||
import org.joda.time.DateTimeZone;
|
||||
|
||||
import java.util.Collection;
|
||||
|
@ -49,7 +50,7 @@ public class QueryParserSettings {
|
|||
private boolean lowercaseExpandedTerms = true;
|
||||
private boolean enablePositionIncrements = true;
|
||||
private int phraseSlop = 0;
|
||||
private float fuzzyMinSim = FuzzyQuery.defaultMinSimilarity;
|
||||
private Fuzziness fuzziness = Fuzziness.AUTO;
|
||||
private int fuzzyPrefixLength = FuzzyQuery.defaultPrefixLength;
|
||||
private int fuzzyMaxExpansions = FuzzyQuery.defaultMaxExpansions;
|
||||
private int maxDeterminizedStates = Operations.DEFAULT_MAX_DETERMINIZED_STATES;
|
||||
|
@ -158,14 +159,6 @@ public class QueryParserSettings {
|
|||
this.phraseSlop = phraseSlop;
|
||||
}
|
||||
|
||||
public float fuzzyMinSim() {
|
||||
return fuzzyMinSim;
|
||||
}
|
||||
|
||||
public void fuzzyMinSim(float fuzzyMinSim) {
|
||||
this.fuzzyMinSim = fuzzyMinSim;
|
||||
}
|
||||
|
||||
public int fuzzyPrefixLength() {
|
||||
return fuzzyPrefixLength;
|
||||
}
|
||||
|
@ -340,7 +333,7 @@ public class QueryParserSettings {
|
|||
if (enablePositionIncrements != that.enablePositionIncrements) return false;
|
||||
if (escape != that.escape) return false;
|
||||
if (analyzeWildcard != that.analyzeWildcard) return false;
|
||||
if (Float.compare(that.fuzzyMinSim, fuzzyMinSim) != 0) return false;
|
||||
if (fuzziness != null ? fuzziness.equals(that.fuzziness) == false : fuzziness != null) return false;
|
||||
if (fuzzyPrefixLength != that.fuzzyPrefixLength) return false;
|
||||
if (fuzzyMaxExpansions != that.fuzzyMaxExpansions) return false;
|
||||
if (fuzzyRewriteMethod != null ? !fuzzyRewriteMethod.equals(that.fuzzyRewriteMethod) : that.fuzzyRewriteMethod != null)
|
||||
|
@ -395,7 +388,7 @@ public class QueryParserSettings {
|
|||
result = 31 * result + (lowercaseExpandedTerms ? 1 : 0);
|
||||
result = 31 * result + (enablePositionIncrements ? 1 : 0);
|
||||
result = 31 * result + phraseSlop;
|
||||
result = 31 * result + (fuzzyMinSim != +0.0f ? Float.floatToIntBits(fuzzyMinSim) : 0);
|
||||
result = 31 * result + (fuzziness.hashCode());
|
||||
result = 31 * result + fuzzyPrefixLength;
|
||||
result = 31 * result + (escape ? 1 : 0);
|
||||
result = 31 * result + (defaultAnalyzer != null ? defaultAnalyzer.hashCode() : 0);
|
||||
|
@ -413,4 +406,12 @@ public class QueryParserSettings {
|
|||
result = 31 * result + (timeZone != null ? timeZone.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setFuzziness(Fuzziness fuzziness) {
|
||||
this.fuzziness = fuzziness;
|
||||
}
|
||||
|
||||
public Fuzziness getFuzziness() {
|
||||
return fuzziness;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,12 @@ import org.elasticsearch.common.io.stream.StreamOutput;
|
|||
import org.elasticsearch.common.logging.support.LoggerMessageFormat;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.IndexNotFoundException;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.index.shard.ShardNotFoundException;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
import org.elasticsearch.rest.action.admin.indices.alias.delete.AliasesNotFoundException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Constructor;
|
||||
|
@ -39,6 +44,11 @@ import java.util.*;
|
|||
public class ElasticsearchException extends RuntimeException implements ToXContent {
|
||||
|
||||
public static final String REST_EXCEPTION_SKIP_CAUSE = "rest.exception.skip_cause";
|
||||
private static final String INDEX_HEADER_KEY = "es.index";
|
||||
private static final String SHARD_HEADER_KEY = "es.shard";
|
||||
private static final String RESOURCE_HEADER_TYPE_KEY = "es.resource.type";
|
||||
private static final String RESOURCE_HEADER_ID_KEY = "es.resource.id";
|
||||
|
||||
private static final Map<String, Constructor<? extends ElasticsearchException>> MAPPING;
|
||||
private final Map<String, List<String>> headers = new HashMap<>();
|
||||
|
||||
|
@ -252,7 +262,14 @@ public class ElasticsearchException extends RuntimeException implements ToXConte
|
|||
} else {
|
||||
builder.field("type", getExceptionName());
|
||||
builder.field("reason", getMessage());
|
||||
for (String key : headers.keySet()) {
|
||||
if (key.startsWith("es.")) {
|
||||
List<String> values = headers.get(key);
|
||||
xContentHeader(builder, key.substring("es.".length()), values);
|
||||
}
|
||||
}
|
||||
innerToXContent(builder, params);
|
||||
renderHeader(builder, params);
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
|
@ -277,6 +294,38 @@ public class ElasticsearchException extends RuntimeException implements ToXConte
|
|||
}
|
||||
}
|
||||
|
||||
protected final void renderHeader(XContentBuilder builder, Params params) throws IOException {
|
||||
boolean hasHeader = false;
|
||||
for (String key : headers.keySet()) {
|
||||
if (key.startsWith("es.")) {
|
||||
continue;
|
||||
}
|
||||
if (hasHeader == false) {
|
||||
builder.startObject("header");
|
||||
hasHeader = true;
|
||||
}
|
||||
List<String> values = headers.get(key);
|
||||
xContentHeader(builder, key, values);
|
||||
}
|
||||
if (hasHeader) {
|
||||
builder.endObject();
|
||||
}
|
||||
}
|
||||
|
||||
private void xContentHeader(XContentBuilder builder, String key, List<String> values) throws IOException {
|
||||
if (values != null && values.isEmpty() == false) {
|
||||
if(values.size() == 1) {
|
||||
builder.field(key, values.get(0));
|
||||
} else {
|
||||
builder.startArray(key);
|
||||
for (String value : values) {
|
||||
builder.value(value);
|
||||
}
|
||||
builder.endArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Statis toXContent helper method that also renders non {@link org.elasticsearch.ElasticsearchException} instances as XContent.
|
||||
*/
|
||||
|
@ -342,7 +391,15 @@ public class ElasticsearchException extends RuntimeException implements ToXConte
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ExceptionsHelper.detailedMessage(this).trim();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
if (headers.containsKey(INDEX_HEADER_KEY)) {
|
||||
builder.append('[').append(getIndex()).append(']');
|
||||
if (headers.containsKey(SHARD_HEADER_KEY)) {
|
||||
builder.append('[').append(getShardId()).append(']');
|
||||
}
|
||||
builder.append(' ');
|
||||
}
|
||||
return builder.append(ExceptionsHelper.detailedMessage(this).trim()).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -396,7 +453,6 @@ public class ElasticsearchException extends RuntimeException implements ToXConte
|
|||
org.elasticsearch.indices.recovery.RecoverFilesRecoveryException.class,
|
||||
org.elasticsearch.index.translog.TruncatedTranslogException.class,
|
||||
org.elasticsearch.repositories.RepositoryException.class,
|
||||
org.elasticsearch.index.shard.IndexShardException.class,
|
||||
org.elasticsearch.index.engine.DocumentSourceMissingException.class,
|
||||
org.elasticsearch.index.engine.DocumentMissingException.class,
|
||||
org.elasticsearch.common.util.concurrent.EsRejectedExecutionException.class,
|
||||
|
@ -421,12 +477,10 @@ public class ElasticsearchException extends RuntimeException implements ToXConte
|
|||
org.elasticsearch.index.snapshots.IndexShardSnapshotException.class,
|
||||
org.elasticsearch.search.query.QueryPhaseExecutionException.class,
|
||||
org.elasticsearch.cluster.metadata.ProcessClusterEventTimeoutException.class,
|
||||
org.elasticsearch.index.shard.IndexShardCreationException.class,
|
||||
org.elasticsearch.index.percolator.PercolatorException.class,
|
||||
org.elasticsearch.snapshots.ConcurrentSnapshotExecutionException.class,
|
||||
org.elasticsearch.indices.IndexTemplateAlreadyExistsException.class,
|
||||
org.elasticsearch.indices.InvalidIndexNameException.class,
|
||||
org.elasticsearch.index.IndexException.class,
|
||||
org.elasticsearch.indices.recovery.DelayRecoveryException.class,
|
||||
org.elasticsearch.indices.AliasFilterParsingException.class,
|
||||
org.elasticsearch.indices.InvalidIndexTemplateException.class,
|
||||
|
@ -443,7 +497,6 @@ public class ElasticsearchException extends RuntimeException implements ToXConte
|
|||
org.elasticsearch.cluster.block.ClusterBlockException.class,
|
||||
org.elasticsearch.action.FailedNodeException.class,
|
||||
org.elasticsearch.indices.TypeMissingException.class,
|
||||
org.elasticsearch.index.IndexShardMissingException.class,
|
||||
org.elasticsearch.indices.InvalidTypeNameException.class,
|
||||
org.elasticsearch.transport.netty.SizeHeaderFrameDecoder.HttpOnTransportException.class,
|
||||
org.elasticsearch.common.util.CancellableThreads.ExecutionCancelledException.class,
|
||||
|
@ -493,7 +546,6 @@ public class ElasticsearchException extends RuntimeException implements ToXConte
|
|||
org.elasticsearch.ElasticsearchTimeoutException.class,
|
||||
org.elasticsearch.search.SearchContextMissingException.class,
|
||||
org.elasticsearch.transport.SendRequestTransportException.class,
|
||||
org.elasticsearch.indices.IndexMissingException.class,
|
||||
org.elasticsearch.index.IndexShardAlreadyExistsException.class,
|
||||
org.elasticsearch.indices.IndexAlreadyExistsException.class,
|
||||
org.elasticsearch.index.engine.DocumentAlreadyExistsException.class,
|
||||
|
@ -504,7 +556,7 @@ public class ElasticsearchException extends RuntimeException implements ToXConte
|
|||
org.elasticsearch.index.shard.IndexShardNotStartedException.class,
|
||||
org.elasticsearch.index.mapper.StrictDynamicMappingException.class,
|
||||
org.elasticsearch.index.engine.EngineClosedException.class,
|
||||
org.elasticsearch.rest.action.admin.indices.alias.delete.AliasesMissingException.class,
|
||||
AliasesNotFoundException.class,
|
||||
org.elasticsearch.transport.ResponseHandlerFailureTransportException.class,
|
||||
org.elasticsearch.search.SearchParseException.class,
|
||||
org.elasticsearch.search.fetch.FetchPhaseExecutionException.class,
|
||||
|
@ -520,7 +572,6 @@ public class ElasticsearchException extends RuntimeException implements ToXConte
|
|||
org.elasticsearch.index.engine.RecoveryEngineException.class,
|
||||
org.elasticsearch.common.blobstore.BlobStoreException.class,
|
||||
org.elasticsearch.index.snapshots.IndexShardRestoreException.class,
|
||||
org.elasticsearch.index.store.StoreException.class,
|
||||
org.elasticsearch.index.query.QueryParsingException.class,
|
||||
org.elasticsearch.action.support.replication.TransportReplicationAction.RetryOnPrimaryException.class,
|
||||
org.elasticsearch.index.engine.DeleteByQueryFailedEngineException.class,
|
||||
|
@ -534,6 +585,9 @@ public class ElasticsearchException extends RuntimeException implements ToXConte
|
|||
org.elasticsearch.index.engine.CreateFailedEngineException.class,
|
||||
org.elasticsearch.index.shard.IllegalIndexShardStateException.class,
|
||||
ElasticsearchSecurityException.class,
|
||||
ResourceNotFoundException.class,
|
||||
IndexNotFoundException.class,
|
||||
ShardNotFoundException.class,
|
||||
NotSerializableExceptionWrapper.class
|
||||
};
|
||||
Map<String, Constructor<? extends ElasticsearchException>> mapping = new HashMap<>(exceptions.length);
|
||||
|
@ -553,4 +607,73 @@ public class ElasticsearchException extends RuntimeException implements ToXConte
|
|||
MAPPING = Collections.unmodifiableMap(mapping);
|
||||
}
|
||||
|
||||
public String getIndex() {
|
||||
List<String> index = getHeader(INDEX_HEADER_KEY);
|
||||
if (index != null && index.isEmpty() == false) {
|
||||
return index.get(0);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public ShardId getShardId() {
|
||||
List<String> shard = getHeader(SHARD_HEADER_KEY);
|
||||
if (shard != null && shard.isEmpty() == false) {
|
||||
return new ShardId(getIndex(), Integer.parseInt(shard.get(0)));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setIndex(Index index) {
|
||||
if (index != null) {
|
||||
addHeader(INDEX_HEADER_KEY, index.getName());
|
||||
}
|
||||
}
|
||||
|
||||
public void setIndex(String index) {
|
||||
if (index != null) {
|
||||
addHeader(INDEX_HEADER_KEY, index);
|
||||
}
|
||||
}
|
||||
|
||||
public void setShard(ShardId shardId) {
|
||||
if (shardId != null) {
|
||||
addHeader(INDEX_HEADER_KEY, shardId.getIndex());
|
||||
addHeader(SHARD_HEADER_KEY, Integer.toString(shardId.id()));
|
||||
}
|
||||
}
|
||||
|
||||
public void setResources(String type, String... id) {
|
||||
assert type != null;
|
||||
addHeader(RESOURCE_HEADER_ID_KEY, id);
|
||||
addHeader(RESOURCE_HEADER_TYPE_KEY, type);
|
||||
}
|
||||
|
||||
public List<String> getResourceId() {
|
||||
return getHeader(RESOURCE_HEADER_ID_KEY);
|
||||
}
|
||||
|
||||
public String getResourceType() {
|
||||
List<String> header = getHeader(RESOURCE_HEADER_TYPE_KEY);
|
||||
if (header != null && header.isEmpty() == false) {
|
||||
assert header.size() == 1;
|
||||
return header.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void renderThrowable(XContentBuilder builder, Params params, Throwable t) throws IOException {
|
||||
builder.startObject("error");
|
||||
final ElasticsearchException[] rootCauses = ElasticsearchException.guessRootCauses(t);
|
||||
builder.field("root_cause");
|
||||
builder.startArray();
|
||||
for (ElasticsearchException rootCause : rootCauses){
|
||||
builder.startObject();
|
||||
rootCause.toXContent(builder, new ToXContent.DelegatingMapParams(Collections.singletonMap(ElasticsearchException.REST_EXCEPTION_SKIP_CAUSE, "true"), params));
|
||||
builder.endObject();
|
||||
}
|
||||
builder.endArray();
|
||||
ElasticsearchException.toXContent(builder, params, t);
|
||||
builder.endObject();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,8 +26,6 @@ import org.elasticsearch.action.ShardOperationFailedException;
|
|||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.IndexException;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -240,12 +238,12 @@ public final class ExceptionsHelper {
|
|||
|
||||
static class GroupBy {
|
||||
final String reason;
|
||||
final Index index;
|
||||
final String index;
|
||||
final Class<? extends Throwable> causeType;
|
||||
|
||||
public GroupBy(Throwable t) {
|
||||
if (t instanceof IndexException) {
|
||||
index = ((IndexException) t).index();
|
||||
if (t instanceof ElasticsearchException) {
|
||||
index = ((ElasticsearchException) t).getIndex();
|
||||
} else {
|
||||
index = null;
|
||||
}
|
||||
|
|
|
@ -16,31 +16,32 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index;
|
||||
package org.elasticsearch;
|
||||
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.index.shard.IndexShardException;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
* Generic ResourceNotFoundException corresponding to the {@link RestStatus#NOT_FOUND} status code
|
||||
*/
|
||||
public class IndexShardMissingException extends IndexShardException {
|
||||
public class ResourceNotFoundException extends ElasticsearchException {
|
||||
|
||||
public IndexShardMissingException(ShardId shardId) {
|
||||
super(shardId, "missing");
|
||||
public ResourceNotFoundException(String msg, Object... args) {
|
||||
super(msg, args);
|
||||
}
|
||||
|
||||
public IndexShardMissingException(StreamInput in) throws IOException{
|
||||
protected ResourceNotFoundException(String msg, Throwable cause, Object... args) {
|
||||
super(msg, cause, args);
|
||||
}
|
||||
|
||||
public ResourceNotFoundException(StreamInput in) throws IOException {
|
||||
super(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestStatus status() {
|
||||
public final RestStatus status() {
|
||||
return RestStatus.NOT_FOUND;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -241,13 +241,17 @@ public class Version {
|
|||
public static final int V_1_6_0_ID = 1060099;
|
||||
public static final Version V_1_6_0 = new Version(V_1_6_0_ID, false, org.apache.lucene.util.Version.LUCENE_4_10_4);
|
||||
public static final int V_1_6_1_ID = 1060199;
|
||||
public static final Version V_1_6_1 = new Version(V_1_6_1_ID, true, org.apache.lucene.util.Version.LUCENE_4_10_4);
|
||||
public static final Version V_1_6_1 = new Version(V_1_6_1_ID, false, org.apache.lucene.util.Version.LUCENE_4_10_4);
|
||||
public static final int V_1_6_2_ID = 1060299;
|
||||
public static final Version V_1_6_2 = new Version(V_1_6_2_ID, true, org.apache.lucene.util.Version.LUCENE_4_10_4);
|
||||
public static final int V_1_7_0_ID = 1070099;
|
||||
public static final Version V_1_7_0 = new Version(V_1_7_0_ID, true, org.apache.lucene.util.Version.LUCENE_4_10_4);
|
||||
public static final int V_2_0_0_ID = 2000099;
|
||||
public static final Version V_2_0_0 = new Version(V_2_0_0_ID, true, org.apache.lucene.util.Version.LUCENE_5_2_1);
|
||||
public static final Version V_1_7_0 = new Version(V_1_7_0_ID, false, org.apache.lucene.util.Version.LUCENE_4_10_4);
|
||||
public static final int V_1_7_1_ID = 1070199;
|
||||
public static final Version V_1_7_1 = new Version(V_1_7_1_ID, true, org.apache.lucene.util.Version.LUCENE_4_10_4);
|
||||
public static final int V_2_0_0_beta1_ID = 2000001;
|
||||
public static final Version V_2_0_0_beta1 = new Version(V_2_0_0_beta1_ID, true, org.apache.lucene.util.Version.LUCENE_5_2_1);
|
||||
|
||||
public static final Version CURRENT = V_2_0_0;
|
||||
public static final Version CURRENT = V_2_0_0_beta1;
|
||||
|
||||
static {
|
||||
assert CURRENT.luceneVersion.equals(Lucene.VERSION) : "Version must be upgraded to [" + Lucene.VERSION + "] is still set to [" + CURRENT.luceneVersion + "]";
|
||||
|
@ -259,10 +263,14 @@ public class Version {
|
|||
|
||||
public static Version fromId(int id) {
|
||||
switch (id) {
|
||||
case V_2_0_0_ID:
|
||||
return V_2_0_0;
|
||||
case V_2_0_0_beta1_ID:
|
||||
return V_2_0_0_beta1;
|
||||
case V_1_7_1_ID:
|
||||
return V_1_7_1;
|
||||
case V_1_7_0_ID:
|
||||
return V_1_7_0;
|
||||
case V_1_6_2_ID:
|
||||
return V_1_6_2;
|
||||
case V_1_6_1_ID:
|
||||
return V_1_6_1;
|
||||
case V_1_6_0_ID:
|
||||
|
@ -472,7 +480,7 @@ public class Version {
|
|||
public static Version indexCreated(Settings indexSettings) {
|
||||
final Version indexVersion = indexSettings.getAsVersion(IndexMetaData.SETTING_VERSION_CREATED, null);
|
||||
if (indexVersion == null) {
|
||||
throw new IllegalStateException("[" + IndexMetaData.SETTING_VERSION_CREATED + "] is not present in the index settings for index with uuid: [" + indexSettings.get(IndexMetaData.SETTING_UUID) + "]");
|
||||
throw new IllegalStateException("[" + IndexMetaData.SETTING_VERSION_CREATED + "] is not present in the index settings for index with uuid: [" + indexSettings.get(IndexMetaData.SETTING_INDEX_UUID) + "]");
|
||||
}
|
||||
return indexVersion;
|
||||
}
|
||||
|
@ -499,7 +507,7 @@ public class Version {
|
|||
if (snapshot = version.endsWith("-SNAPSHOT")) {
|
||||
version = version.substring(0, version.length() - 9);
|
||||
}
|
||||
String[] parts = version.split("\\.");
|
||||
String[] parts = version.split("\\.|\\-");
|
||||
if (parts.length < 3 || parts.length > 4) {
|
||||
throw new IllegalArgumentException("the version needs to contain major, minor and revision, and optionally the build: " + version);
|
||||
}
|
||||
|
@ -515,10 +523,10 @@ public class Version {
|
|||
int build = 99;
|
||||
if (parts.length == 4) {
|
||||
String buildStr = parts[3];
|
||||
if (buildStr.startsWith("Beta")) {
|
||||
if (buildStr.startsWith("Beta") || buildStr.startsWith("beta")) {
|
||||
build = Integer.parseInt(buildStr.substring(4));
|
||||
}
|
||||
if (buildStr.startsWith("RC")) {
|
||||
if (buildStr.startsWith("RC") || buildStr.startsWith("rc")) {
|
||||
build = Integer.parseInt(buildStr.substring(2)) + 50;
|
||||
}
|
||||
}
|
||||
|
@ -589,10 +597,20 @@ public class Version {
|
|||
public String number() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(major).append('.').append(minor).append('.').append(revision);
|
||||
if (build < 50) {
|
||||
sb.append(".Beta").append(build);
|
||||
if (isBeta()) {
|
||||
if (major >= 2) {
|
||||
sb.append("-beta");
|
||||
} else {
|
||||
sb.append(".Beta");
|
||||
}
|
||||
sb.append(build);
|
||||
} else if (build < 99) {
|
||||
sb.append(".RC").append(build - 50);
|
||||
if (major >= 2) {
|
||||
sb.append("-rc");
|
||||
} else {
|
||||
sb.append(".RC");
|
||||
}
|
||||
sb.append(build - 50);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
@ -635,6 +653,14 @@ public class Version {
|
|||
return id;
|
||||
}
|
||||
|
||||
public boolean isBeta() {
|
||||
return build < 50;
|
||||
}
|
||||
|
||||
public boolean isRC() {
|
||||
return build > 50 && build < 99;
|
||||
}
|
||||
|
||||
public static class Module extends AbstractModule {
|
||||
|
||||
private final Version version;
|
||||
|
|
|
@ -96,6 +96,8 @@ 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;
|
||||
|
@ -242,6 +244,7 @@ public class ActionModule extends AbstractModule {
|
|||
|
||||
registerAction(IndicesStatsAction.INSTANCE, TransportIndicesStatsAction.class);
|
||||
registerAction(IndicesSegmentsAction.INSTANCE, TransportIndicesSegmentsAction.class);
|
||||
registerAction(IndicesShardStoresAction.INSTANCE, TransportIndicesShardStoresAction.class);
|
||||
registerAction(CreateIndexAction.INSTANCE, TransportCreateIndexAction.class);
|
||||
registerAction(DeleteIndexAction.INSTANCE, TransportDeleteIndexAction.class);
|
||||
registerAction(GetIndexAction.INSTANCE, TransportGetIndexAction.class);
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.elasticsearch.action.support.IndicesOptions;
|
|||
*
|
||||
* Forces this class return index/type/id getters
|
||||
*/
|
||||
public interface DocumentRequest<T> {
|
||||
public interface DocumentRequest<T> extends IndicesRequest {
|
||||
|
||||
/**
|
||||
* Get the index that this request operates on
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
|
||||
package org.elasticsearch.action;
|
||||
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.index.shard.IndexShardException;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
|
||||
|
@ -29,18 +29,19 @@ import java.io.IOException;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public class NoShardAvailableActionException extends IndexShardException {
|
||||
public class NoShardAvailableActionException extends ElasticsearchException {
|
||||
|
||||
public NoShardAvailableActionException(ShardId shardId) {
|
||||
super(shardId, null);
|
||||
this(shardId, null);
|
||||
}
|
||||
|
||||
public NoShardAvailableActionException(ShardId shardId, String msg) {
|
||||
super(shardId, msg);
|
||||
this(shardId, msg, null);
|
||||
}
|
||||
|
||||
public NoShardAvailableActionException(ShardId shardId, String msg, Throwable cause) {
|
||||
super(shardId, msg, cause);
|
||||
super(msg, cause);
|
||||
setShard(shardId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -32,8 +32,6 @@ import java.util.Objects;
|
|||
*/
|
||||
public class RoutingMissingException extends ElasticsearchException {
|
||||
|
||||
private final String index;
|
||||
|
||||
private final String type;
|
||||
|
||||
private final String id;
|
||||
|
@ -43,20 +41,16 @@ public class RoutingMissingException extends ElasticsearchException {
|
|||
Objects.requireNonNull(index, "index must not be null");
|
||||
Objects.requireNonNull(type, "type must not be null");
|
||||
Objects.requireNonNull(id, "id must not be null");
|
||||
this.index = index;
|
||||
setIndex(index);
|
||||
this.type = type;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String index() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public String type() {
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String id() {
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
@ -67,7 +61,6 @@ public class RoutingMissingException extends ElasticsearchException {
|
|||
|
||||
public RoutingMissingException(StreamInput in) throws IOException{
|
||||
super(in);
|
||||
index = in.readString();
|
||||
type = in.readString();
|
||||
id = in.readString();
|
||||
}
|
||||
|
@ -75,7 +68,6 @@ public class RoutingMissingException extends ElasticsearchException {
|
|||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeString(index);
|
||||
out.writeString(type);
|
||||
out.writeString(id);
|
||||
}
|
||||
|
|
|
@ -107,11 +107,11 @@ public class ClusterHealthResponse extends ActionResponse implements Iterable<Cl
|
|||
status = ClusterHealthStatus.GREEN;
|
||||
|
||||
for (ClusterIndexHealth indexHealth : indices.values()) {
|
||||
activePrimaryShards += indexHealth.activePrimaryShards;
|
||||
activeShards += indexHealth.activeShards;
|
||||
relocatingShards += indexHealth.relocatingShards;
|
||||
initializingShards += indexHealth.initializingShards;
|
||||
unassignedShards += indexHealth.unassignedShards;
|
||||
activePrimaryShards += indexHealth.getActivePrimaryShards();
|
||||
activeShards += indexHealth.getActiveShards();
|
||||
relocatingShards += indexHealth.getRelocatingShards();
|
||||
initializingShards += indexHealth.getInitializingShards();
|
||||
unassignedShards += indexHealth.getUnassignedShards();
|
||||
if (indexHealth.getStatus() == ClusterHealthStatus.RED) {
|
||||
status = ClusterHealthStatus.RED;
|
||||
} else if (indexHealth.getStatus() == ClusterHealthStatus.YELLOW && status != ClusterHealthStatus.RED) {
|
||||
|
|
|
@ -50,4 +50,16 @@ public enum ClusterHealthStatus {
|
|||
throw new IllegalArgumentException("No cluster health status for value [" + value + "]");
|
||||
}
|
||||
}
|
||||
|
||||
public static ClusterHealthStatus fromString(String status) {
|
||||
if (status.equalsIgnoreCase("green")) {
|
||||
return GREEN;
|
||||
} else if (status.equalsIgnoreCase("yellow")) {
|
||||
return YELLOW;
|
||||
} else if (status.equalsIgnoreCase("red")) {
|
||||
return RED;
|
||||
} else {
|
||||
throw new IllegalArgumentException("unknown cluster health status [" + status + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,21 +51,21 @@ public class ClusterIndexHealth implements Iterable<ClusterShardHealth>, Streama
|
|||
|
||||
private int numberOfReplicas;
|
||||
|
||||
int activeShards = 0;
|
||||
private int activeShards = 0;
|
||||
|
||||
int relocatingShards = 0;
|
||||
private int relocatingShards = 0;
|
||||
|
||||
int initializingShards = 0;
|
||||
private int initializingShards = 0;
|
||||
|
||||
int unassignedShards = 0;
|
||||
private int unassignedShards = 0;
|
||||
|
||||
int activePrimaryShards = 0;
|
||||
private int activePrimaryShards = 0;
|
||||
|
||||
ClusterHealthStatus status = ClusterHealthStatus.RED;
|
||||
private ClusterHealthStatus status = ClusterHealthStatus.RED;
|
||||
|
||||
final Map<Integer, ClusterShardHealth> shards = Maps.newHashMap();
|
||||
private final Map<Integer, ClusterShardHealth> shards = Maps.newHashMap();
|
||||
|
||||
List<String> validationFailures;
|
||||
private List<String> validationFailures;
|
||||
|
||||
private ClusterIndexHealth() {
|
||||
}
|
||||
|
@ -77,33 +77,8 @@ public class ClusterIndexHealth implements Iterable<ClusterShardHealth>, Streama
|
|||
this.validationFailures = indexRoutingTable.validate(indexMetaData);
|
||||
|
||||
for (IndexShardRoutingTable shardRoutingTable : indexRoutingTable) {
|
||||
ClusterShardHealth shardHealth = new ClusterShardHealth(shardRoutingTable.shardId().id());
|
||||
for (ShardRouting shardRouting : shardRoutingTable) {
|
||||
if (shardRouting.active()) {
|
||||
shardHealth.activeShards++;
|
||||
if (shardRouting.relocating()) {
|
||||
// the shard is relocating, the one it is relocating to will be in initializing state, so we don't count it
|
||||
shardHealth.relocatingShards++;
|
||||
}
|
||||
if (shardRouting.primary()) {
|
||||
shardHealth.primaryActive = true;
|
||||
}
|
||||
} else if (shardRouting.initializing()) {
|
||||
shardHealth.initializingShards++;
|
||||
} else if (shardRouting.unassigned()) {
|
||||
shardHealth.unassignedShards++;
|
||||
}
|
||||
}
|
||||
if (shardHealth.primaryActive) {
|
||||
if (shardHealth.activeShards == shardRoutingTable.size()) {
|
||||
shardHealth.status = ClusterHealthStatus.GREEN;
|
||||
} else {
|
||||
shardHealth.status = ClusterHealthStatus.YELLOW;
|
||||
}
|
||||
} else {
|
||||
shardHealth.status = ClusterHealthStatus.RED;
|
||||
}
|
||||
shards.put(shardHealth.getId(), shardHealth);
|
||||
int shardId = shardRoutingTable.shardId().id();
|
||||
shards.put(shardId, new ClusterShardHealth(shardId, shardRoutingTable));
|
||||
}
|
||||
|
||||
// update the index status
|
||||
|
@ -113,10 +88,10 @@ public class ClusterIndexHealth implements Iterable<ClusterShardHealth>, Streama
|
|||
if (shardHealth.isPrimaryActive()) {
|
||||
activePrimaryShards++;
|
||||
}
|
||||
activeShards += shardHealth.activeShards;
|
||||
relocatingShards += shardHealth.relocatingShards;
|
||||
initializingShards += shardHealth.initializingShards;
|
||||
unassignedShards += shardHealth.unassignedShards;
|
||||
activeShards += shardHealth.getActiveShards();
|
||||
relocatingShards += shardHealth.getRelocatingShards();
|
||||
initializingShards += shardHealth.getInitializingShards();
|
||||
unassignedShards += shardHealth.getUnassignedShards();
|
||||
|
||||
if (shardHealth.getStatus() == ClusterHealthStatus.RED) {
|
||||
status = ClusterHealthStatus.RED;
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
|
||||
package org.elasticsearch.action.admin.cluster.health;
|
||||
|
||||
import org.elasticsearch.cluster.routing.IndexShardRoutingTable;
|
||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.io.stream.Streamable;
|
||||
|
@ -34,22 +36,47 @@ public class ClusterShardHealth implements Streamable {
|
|||
|
||||
ClusterHealthStatus status = ClusterHealthStatus.RED;
|
||||
|
||||
int activeShards = 0;
|
||||
private int activeShards = 0;
|
||||
|
||||
int relocatingShards = 0;
|
||||
private int relocatingShards = 0;
|
||||
|
||||
int initializingShards = 0;
|
||||
private int initializingShards = 0;
|
||||
|
||||
int unassignedShards = 0;
|
||||
private int unassignedShards = 0;
|
||||
|
||||
boolean primaryActive = false;
|
||||
private boolean primaryActive = false;
|
||||
|
||||
private ClusterShardHealth() {
|
||||
|
||||
}
|
||||
|
||||
ClusterShardHealth(int shardId) {
|
||||
public ClusterShardHealth(int shardId, final IndexShardRoutingTable shardRoutingTable) {
|
||||
this.shardId = shardId;
|
||||
for (ShardRouting shardRouting : shardRoutingTable) {
|
||||
if (shardRouting.active()) {
|
||||
activeShards++;
|
||||
if (shardRouting.relocating()) {
|
||||
// the shard is relocating, the one it is relocating to will be in initializing state, so we don't count it
|
||||
relocatingShards++;
|
||||
}
|
||||
if (shardRouting.primary()) {
|
||||
primaryActive = true;
|
||||
}
|
||||
} else if (shardRouting.initializing()) {
|
||||
initializingShards++;
|
||||
} else if (shardRouting.unassigned()) {
|
||||
unassignedShards++;
|
||||
}
|
||||
}
|
||||
if (primaryActive) {
|
||||
if (activeShards == shardRoutingTable.size()) {
|
||||
status = ClusterHealthStatus.GREEN;
|
||||
} else {
|
||||
status = ClusterHealthStatus.YELLOW;
|
||||
}
|
||||
} else {
|
||||
status = ClusterHealthStatus.RED;
|
||||
}
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
|
|
|
@ -25,13 +25,14 @@ import org.elasticsearch.action.support.IndicesOptions;
|
|||
import org.elasticsearch.action.support.master.TransportMasterNodeReadAction;
|
||||
import org.elasticsearch.cluster.*;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.routing.UnassignedInfo;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.gateway.GatewayAllocator;
|
||||
import org.elasticsearch.indices.IndexMissingException;
|
||||
import org.elasticsearch.index.IndexNotFoundException;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
|
@ -44,9 +45,10 @@ public class TransportClusterHealthAction extends TransportMasterNodeReadAction<
|
|||
private final GatewayAllocator gatewayAllocator;
|
||||
|
||||
@Inject
|
||||
public TransportClusterHealthAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
|
||||
ClusterName clusterName, ActionFilters actionFilters, GatewayAllocator gatewayAllocator) {
|
||||
super(settings, ClusterHealthAction.NAME, transportService, clusterService, threadPool, actionFilters, ClusterHealthRequest.class);
|
||||
public TransportClusterHealthAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, ClusterName clusterName, ActionFilters actionFilters,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver, GatewayAllocator gatewayAllocator) {
|
||||
super(settings, ClusterHealthAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, ClusterHealthRequest.class);
|
||||
this.clusterName = clusterName;
|
||||
this.gatewayAllocator = gatewayAllocator;
|
||||
}
|
||||
|
@ -199,9 +201,9 @@ public class TransportClusterHealthAction extends TransportMasterNodeReadAction<
|
|||
}
|
||||
if (request.indices().length > 0) {
|
||||
try {
|
||||
clusterState.metaData().concreteIndices(IndicesOptions.strictExpand(), request.indices());
|
||||
indexNameExpressionResolver.concreteIndices(clusterState, IndicesOptions.strictExpand(), request.indices());
|
||||
waitForCounter++;
|
||||
} catch (IndexMissingException e) {
|
||||
} catch (IndexNotFoundException e) {
|
||||
response.status = ClusterHealthStatus.RED; // no indices, make sure its RED
|
||||
// missing indices, wait a bit more...
|
||||
}
|
||||
|
@ -266,8 +268,8 @@ public class TransportClusterHealthAction extends TransportMasterNodeReadAction<
|
|||
|
||||
String[] concreteIndices;
|
||||
try {
|
||||
concreteIndices = clusterState.metaData().concreteIndices(request.indicesOptions(), request.indices());
|
||||
} catch (IndexMissingException e) {
|
||||
concreteIndices = indexNameExpressionResolver.concreteIndices(clusterState, request);
|
||||
} catch (IndexNotFoundException e) {
|
||||
// one of the specified indices is not there - treat it as RED.
|
||||
ClusterHealthResponse response = new ClusterHealthResponse(clusterName.value(), Strings.EMPTY_ARRAY, clusterState,
|
||||
numberOfPendingTasks, numberOfInFlightFetch, UnassignedInfo.getNumberOfDelayedUnassigned(settings, clusterState),
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.elasticsearch.action.support.nodes.BaseNodeRequest;
|
|||
import org.elasticsearch.action.support.nodes.TransportNodesAction;
|
||||
import org.elasticsearch.cluster.ClusterName;
|
||||
import org.elasticsearch.cluster.ClusterService;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
|
@ -45,9 +46,10 @@ public class TransportNodesHotThreadsAction extends TransportNodesAction<NodesHo
|
|||
|
||||
@Inject
|
||||
public TransportNodesHotThreadsAction(Settings settings, ClusterName clusterName, ThreadPool threadPool,
|
||||
ClusterService clusterService, TransportService transportService, ActionFilters actionFilters) {
|
||||
ClusterService clusterService, TransportService transportService,
|
||||
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, NodesHotThreadsAction.NAME, clusterName, threadPool, clusterService, transportService, actionFilters,
|
||||
NodesHotThreadsRequest.class, NodeRequest.class, ThreadPool.Names.GENERIC);
|
||||
indexNameExpressionResolver, NodesHotThreadsRequest.class, NodeRequest.class, ThreadPool.Names.GENERIC);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.elasticsearch.action.admin.cluster.node.info;
|
||||
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
|
|
|
@ -28,6 +28,8 @@ import org.elasticsearch.common.xcontent.XContentBuilderString;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class PluginsInfo implements Streamable, ToXContent {
|
||||
|
@ -45,7 +47,17 @@ public class PluginsInfo implements Streamable, ToXContent {
|
|||
infos = new ArrayList<>(size);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an ordered list based on plugins name
|
||||
*/
|
||||
public List<PluginInfo> getInfos() {
|
||||
Collections.sort(infos, new Comparator<PluginInfo>() {
|
||||
@Override
|
||||
public int compare(final PluginInfo o1, final PluginInfo o2) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
});
|
||||
|
||||
return infos;
|
||||
}
|
||||
|
||||
|
@ -70,7 +82,7 @@ public class PluginsInfo implements Streamable, ToXContent {
|
|||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
out.writeInt(infos.size());
|
||||
for (PluginInfo plugin : infos) {
|
||||
for (PluginInfo plugin : getInfos()) {
|
||||
plugin.writeTo(out);
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +90,7 @@ public class PluginsInfo implements Streamable, ToXContent {
|
|||
@Override
|
||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
builder.startArray(Fields.PLUGINS);
|
||||
for (PluginInfo pluginInfo : infos) {
|
||||
for (PluginInfo pluginInfo : getInfos()) {
|
||||
pluginInfo.toXContent(builder, params);
|
||||
}
|
||||
builder.endArray();
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.elasticsearch.action.support.nodes.BaseNodeRequest;
|
|||
import org.elasticsearch.action.support.nodes.TransportNodesAction;
|
||||
import org.elasticsearch.cluster.ClusterName;
|
||||
import org.elasticsearch.cluster.ClusterService;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
|
@ -47,9 +48,9 @@ public class TransportNodesInfoAction extends TransportNodesAction<NodesInfoRequ
|
|||
@Inject
|
||||
public TransportNodesInfoAction(Settings settings, ClusterName clusterName, ThreadPool threadPool,
|
||||
ClusterService clusterService, TransportService transportService,
|
||||
NodeService nodeService, ActionFilters actionFilters) {
|
||||
NodeService nodeService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, NodesInfoAction.NAME, clusterName, threadPool, clusterService, transportService, actionFilters,
|
||||
NodesInfoRequest.class, NodeInfoRequest.class, ThreadPool.Names.MANAGEMENT);
|
||||
indexNameExpressionResolver, NodesInfoRequest.class, NodeInfoRequest.class, ThreadPool.Names.MANAGEMENT);
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.elasticsearch.action.support.nodes.BaseNodeRequest;
|
|||
import org.elasticsearch.action.support.nodes.TransportNodesAction;
|
||||
import org.elasticsearch.cluster.ClusterName;
|
||||
import org.elasticsearch.cluster.ClusterService;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
|
@ -47,8 +48,8 @@ public class TransportNodesStatsAction extends TransportNodesAction<NodesStatsRe
|
|||
@Inject
|
||||
public TransportNodesStatsAction(Settings settings, ClusterName clusterName, ThreadPool threadPool,
|
||||
ClusterService clusterService, TransportService transportService,
|
||||
NodeService nodeService, ActionFilters actionFilters) {
|
||||
super(settings, NodesStatsAction.NAME, clusterName, threadPool, clusterService, transportService, actionFilters,
|
||||
NodeService nodeService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, NodesStatsAction.NAME, clusterName, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
|
||||
NodesStatsRequest.class, NodeStatsRequest.class, ThreadPool.Names.MANAGEMENT);
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.cluster.ClusterState;
|
|||
import org.elasticsearch.cluster.ack.ClusterStateUpdateResponse;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.repositories.RepositoriesService;
|
||||
|
@ -42,8 +43,9 @@ public class TransportDeleteRepositoryAction extends TransportMasterNodeAction<D
|
|||
|
||||
@Inject
|
||||
public TransportDeleteRepositoryAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
RepositoriesService repositoriesService, ThreadPool threadPool, ActionFilters actionFilters) {
|
||||
super(settings, DeleteRepositoryAction.NAME, transportService, clusterService, threadPool, actionFilters, DeleteRepositoryRequest.class);
|
||||
RepositoriesService repositoriesService, ThreadPool threadPool, ActionFilters actionFilters,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, DeleteRepositoryAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, DeleteRepositoryRequest.class);
|
||||
this.repositoriesService = repositoriesService;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
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.metadata.RepositoriesMetaData;
|
||||
import org.elasticsearch.cluster.metadata.RepositoryMetaData;
|
||||
|
@ -43,8 +44,8 @@ public class TransportGetRepositoriesAction extends TransportMasterNodeReadActio
|
|||
|
||||
@Inject
|
||||
public TransportGetRepositoriesAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, ActionFilters actionFilters) {
|
||||
super(settings, GetRepositoriesAction.NAME, transportService, clusterService, threadPool, actionFilters, GetRepositoriesRequest.class);
|
||||
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, GetRepositoriesAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, GetRepositoriesRequest.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.cluster.ClusterState;
|
|||
import org.elasticsearch.cluster.ack.ClusterStateUpdateResponse;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.repositories.RepositoriesService;
|
||||
|
@ -42,8 +43,9 @@ public class TransportPutRepositoryAction extends TransportMasterNodeAction<PutR
|
|||
|
||||
@Inject
|
||||
public TransportPutRepositoryAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
RepositoriesService repositoriesService, ThreadPool threadPool, ActionFilters actionFilters) {
|
||||
super(settings, PutRepositoryAction.NAME, transportService, clusterService, threadPool, actionFilters, PutRepositoryRequest.class);
|
||||
RepositoriesService repositoriesService, ThreadPool threadPool, ActionFilters actionFilters,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, PutRepositoryAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, PutRepositoryRequest.class);
|
||||
this.repositoriesService = repositoriesService;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.repositories.RepositoriesService;
|
||||
|
@ -45,8 +46,9 @@ public class TransportVerifyRepositoryAction extends TransportMasterNodeAction<V
|
|||
|
||||
@Inject
|
||||
public TransportVerifyRepositoryAction(Settings settings, ClusterName clusterName, TransportService transportService, ClusterService clusterService,
|
||||
RepositoriesService repositoriesService, ThreadPool threadPool, ActionFilters actionFilters) {
|
||||
super(settings, VerifyRepositoryAction.NAME, transportService, clusterService, threadPool, actionFilters, VerifyRepositoryRequest.class);
|
||||
RepositoriesService repositoriesService, ThreadPool threadPool, ActionFilters actionFilters,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, VerifyRepositoryAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, VerifyRepositoryRequest.class);
|
||||
this.repositoriesService = repositoriesService;
|
||||
this.clusterName = clusterName;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.routing.allocation.AllocationService;
|
||||
import org.elasticsearch.cluster.routing.allocation.RoutingAllocation;
|
||||
import org.elasticsearch.cluster.routing.allocation.RoutingExplanations;
|
||||
|
@ -44,8 +45,8 @@ public class TransportClusterRerouteAction extends TransportMasterNodeAction<Clu
|
|||
|
||||
@Inject
|
||||
public TransportClusterRerouteAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
|
||||
AllocationService allocationService, ActionFilters actionFilters) {
|
||||
super(settings, ClusterRerouteAction.NAME, transportService, clusterService, threadPool, actionFilters, ClusterRerouteRequest.class);
|
||||
AllocationService allocationService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, ClusterRerouteAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, ClusterRerouteRequest.class);
|
||||
this.allocationService = allocationService;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.elasticsearch.cluster.ClusterState;
|
|||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.block.ClusterBlocks;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.cluster.routing.allocation.AllocationService;
|
||||
|
@ -57,8 +58,9 @@ public class TransportClusterUpdateSettingsAction extends TransportMasterNodeAct
|
|||
|
||||
@Inject
|
||||
public TransportClusterUpdateSettingsAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
|
||||
AllocationService allocationService, @ClusterDynamicSettings DynamicSettings dynamicSettings, ActionFilters actionFilters) {
|
||||
super(settings, ClusterUpdateSettingsAction.NAME, transportService, clusterService, threadPool, actionFilters, ClusterUpdateSettingsRequest.class);
|
||||
AllocationService allocationService, @ClusterDynamicSettings DynamicSettings dynamicSettings,
|
||||
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, ClusterUpdateSettingsAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, ClusterUpdateSettingsRequest.class);
|
||||
this.allocationService = allocationService;
|
||||
this.dynamicSettings = dynamicSettings;
|
||||
}
|
||||
|
|
|
@ -84,17 +84,7 @@ public class ClusterSearchShardsResponse extends ActionResponse implements ToXCo
|
|||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
builder.startObject("nodes");
|
||||
for (DiscoveryNode node : nodes) {
|
||||
builder.startObject(node.getId(), XContentBuilder.FieldCaseConversion.NONE);
|
||||
builder.field("name", node.name());
|
||||
builder.field("transport_address", node.getAddress());
|
||||
if (!node.attributes().isEmpty()) {
|
||||
builder.startObject("attributes");
|
||||
for (Map.Entry<String, String> attr : node.attributes().entrySet()) {
|
||||
builder.field(attr.getKey(), attr.getValue());
|
||||
}
|
||||
builder.endObject();
|
||||
}
|
||||
builder.endObject();
|
||||
node.toXContent(builder, params);
|
||||
}
|
||||
builder.endObject();
|
||||
builder.startArray("shards");
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
||||
import org.elasticsearch.cluster.routing.ShardIterator;
|
||||
|
@ -45,8 +46,9 @@ import static com.google.common.collect.Sets.newHashSet;
|
|||
public class TransportClusterSearchShardsAction extends TransportMasterNodeReadAction<ClusterSearchShardsRequest, ClusterSearchShardsResponse> {
|
||||
|
||||
@Inject
|
||||
public TransportClusterSearchShardsAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters) {
|
||||
super(settings, ClusterSearchShardsAction.NAME, transportService, clusterService, threadPool, actionFilters, ClusterSearchShardsRequest.class);
|
||||
public TransportClusterSearchShardsAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, ClusterSearchShardsAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, ClusterSearchShardsRequest.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -57,7 +59,7 @@ public class TransportClusterSearchShardsAction extends TransportMasterNodeReadA
|
|||
|
||||
@Override
|
||||
protected ClusterBlockException checkBlock(ClusterSearchShardsRequest request, ClusterState state) {
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, state.metaData().concreteIndices(request.indicesOptions(), request.indices()));
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, indexNameExpressionResolver.concreteIndices(state, request));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -68,10 +70,10 @@ public class TransportClusterSearchShardsAction extends TransportMasterNodeReadA
|
|||
@Override
|
||||
protected void masterOperation(final ClusterSearchShardsRequest request, final ClusterState state, final ActionListener<ClusterSearchShardsResponse> listener) {
|
||||
ClusterState clusterState = clusterService.state();
|
||||
String[] concreteIndices = clusterState.metaData().concreteIndices(request.indicesOptions(), request.indices());
|
||||
Map<String, Set<String>> routingMap = clusterState.metaData().resolveSearchRouting(request.routing(), request.indices());
|
||||
String[] concreteIndices = indexNameExpressionResolver.concreteIndices(clusterState, request);
|
||||
Map<String, Set<String>> routingMap = indexNameExpressionResolver.resolveSearchRouting(state, request.routing(), request.indices());
|
||||
Set<String> nodeIds = newHashSet();
|
||||
GroupShardsIterator groupShardsIterator = clusterService.operationRouting().searchShards(clusterState, request.indices(), concreteIndices, routingMap, request.preference());
|
||||
GroupShardsIterator groupShardsIterator = clusterService.operationRouting().searchShards(clusterState, concreteIndices, routingMap, request.preference());
|
||||
ShardRouting shard;
|
||||
ClusterSearchShardsGroup[] groupResponses = new ClusterSearchShardsGroup[groupShardsIterator.size()];
|
||||
int currentGroup = 0;
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.SnapshotId;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -42,8 +43,9 @@ public class TransportCreateSnapshotAction extends TransportMasterNodeAction<Cre
|
|||
|
||||
@Inject
|
||||
public TransportCreateSnapshotAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, SnapshotsService snapshotsService, ActionFilters actionFilters) {
|
||||
super(settings, CreateSnapshotAction.NAME, transportService, clusterService, threadPool, actionFilters, CreateSnapshotRequest.class);
|
||||
ThreadPool threadPool, SnapshotsService snapshotsService, ActionFilters actionFilters,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, CreateSnapshotAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, CreateSnapshotRequest.class);
|
||||
this.snapshotsService = snapshotsService;
|
||||
}
|
||||
|
||||
|
@ -64,7 +66,7 @@ public class TransportCreateSnapshotAction extends TransportMasterNodeAction<Cre
|
|||
if (clusterBlockException != null) {
|
||||
return clusterBlockException;
|
||||
}
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.READ, state.metaData().concreteIndices(request.indicesOptions(), request.indices()));
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.READ, indexNameExpressionResolver.concreteIndices(state, request));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.SnapshotId;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -41,8 +42,9 @@ public class TransportDeleteSnapshotAction extends TransportMasterNodeAction<Del
|
|||
|
||||
@Inject
|
||||
public TransportDeleteSnapshotAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, SnapshotsService snapshotsService, ActionFilters actionFilters) {
|
||||
super(settings, DeleteSnapshotAction.NAME, transportService, clusterService, threadPool, actionFilters, DeleteSnapshotRequest.class);
|
||||
ThreadPool threadPool, SnapshotsService snapshotsService, ActionFilters actionFilters,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, DeleteSnapshotAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, DeleteSnapshotRequest.class);
|
||||
this.snapshotsService = snapshotsService;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.SnapshotId;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -46,8 +47,9 @@ public class TransportGetSnapshotsAction extends TransportMasterNodeAction<GetSn
|
|||
|
||||
@Inject
|
||||
public TransportGetSnapshotsAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, SnapshotsService snapshotsService, ActionFilters actionFilters) {
|
||||
super(settings, GetSnapshotsAction.NAME, transportService, clusterService, threadPool, actionFilters, GetSnapshotsRequest.class);
|
||||
ThreadPool threadPool, SnapshotsService snapshotsService, ActionFilters actionFilters,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, GetSnapshotsAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, GetSnapshotsRequest.class);
|
||||
this.snapshotsService = snapshotsService;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.SnapshotId;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -42,8 +43,9 @@ public class TransportRestoreSnapshotAction extends TransportMasterNodeAction<Re
|
|||
|
||||
@Inject
|
||||
public TransportRestoreSnapshotAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, RestoreService restoreService, ActionFilters actionFilters) {
|
||||
super(settings, RestoreSnapshotAction.NAME, transportService, clusterService, threadPool, actionFilters, RestoreSnapshotRequest.class);
|
||||
ThreadPool threadPool, RestoreService restoreService, ActionFilters actionFilters,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, RestoreSnapshotAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, RestoreSnapshotRequest.class);
|
||||
this.restoreService = restoreService;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.action.support.ActionFilters;
|
|||
import org.elasticsearch.action.support.nodes.*;
|
||||
import org.elasticsearch.cluster.ClusterName;
|
||||
import org.elasticsearch.cluster.ClusterService;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.SnapshotId;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
|
@ -55,8 +56,11 @@ public class TransportNodesSnapshotsStatus extends TransportNodesAction<Transpor
|
|||
private final SnapshotShardsService snapshotShardsService;
|
||||
|
||||
@Inject
|
||||
public TransportNodesSnapshotsStatus(Settings settings, ClusterName clusterName, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, SnapshotShardsService snapshotShardsService, ActionFilters actionFilters) {
|
||||
super(settings, ACTION_NAME, clusterName, threadPool, clusterService, transportService, actionFilters,
|
||||
public TransportNodesSnapshotsStatus(Settings settings, ClusterName clusterName, ThreadPool threadPool,
|
||||
ClusterService clusterService, TransportService transportService,
|
||||
SnapshotShardsService snapshotShardsService, ActionFilters actionFilters,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, ACTION_NAME, clusterName, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
|
||||
Request.class, NodeRequest.class, ThreadPool.Names.GENERIC);
|
||||
this.snapshotShardsService = snapshotShardsService;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.SnapshotId;
|
||||
import org.elasticsearch.cluster.SnapshotsInProgress;
|
||||
import org.elasticsearch.common.Strings;
|
||||
|
@ -57,8 +58,11 @@ public class TransportSnapshotsStatusAction extends TransportMasterNodeAction<Sn
|
|||
private final TransportNodesSnapshotsStatus transportNodesSnapshotsStatus;
|
||||
|
||||
@Inject
|
||||
public TransportSnapshotsStatusAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, SnapshotsService snapshotsService, TransportNodesSnapshotsStatus transportNodesSnapshotsStatus, ActionFilters actionFilters) {
|
||||
super(settings, SnapshotsStatusAction.NAME, transportService, clusterService, threadPool, actionFilters, SnapshotsStatusRequest.class);
|
||||
public TransportSnapshotsStatusAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, SnapshotsService snapshotsService,
|
||||
TransportNodesSnapshotsStatus transportNodesSnapshotsStatus,
|
||||
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, SnapshotsStatusAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, SnapshotsStatusRequest.class);
|
||||
this.snapshotsService = snapshotsService;
|
||||
this.transportNodesSnapshotsStatus = transportNodesSnapshotsStatus;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData.Custom;
|
||||
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||
|
@ -45,8 +46,8 @@ public class TransportClusterStateAction extends TransportMasterNodeReadAction<C
|
|||
|
||||
@Inject
|
||||
public TransportClusterStateAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
|
||||
ClusterName clusterName, ActionFilters actionFilters) {
|
||||
super(settings, ClusterStateAction.NAME, transportService, clusterService, threadPool, actionFilters, ClusterStateRequest.class);
|
||||
ClusterName clusterName, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, ClusterStateAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, ClusterStateRequest.class);
|
||||
this.clusterName = clusterName;
|
||||
}
|
||||
|
||||
|
@ -76,7 +77,7 @@ public class TransportClusterStateAction extends TransportMasterNodeReadAction<C
|
|||
logger.trace("Serving cluster state request using version {}", currentState.version());
|
||||
ClusterState.Builder builder = ClusterState.builder(currentState.getClusterName());
|
||||
builder.version(currentState.version());
|
||||
builder.uuid(currentState.uuid());
|
||||
builder.stateUUID(currentState.stateUUID());
|
||||
if (request.nodes()) {
|
||||
builder.nodes(currentState.nodes());
|
||||
}
|
||||
|
@ -105,7 +106,7 @@ public class TransportClusterStateAction extends TransportMasterNodeReadAction<C
|
|||
}
|
||||
|
||||
if (request.indices().length > 0) {
|
||||
String[] indices = currentState.metaData().concreteIndices(request.indicesOptions(), request.indices());
|
||||
String[] indices = indexNameExpressionResolver.concreteIndices(currentState, request);
|
||||
for (String filteredIndex : indices) {
|
||||
IndexMetaData indexMetaData = currentState.metaData().index(filteredIndex);
|
||||
if (indexMetaData != null) {
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.elasticsearch.action.support.nodes.TransportNodesAction;
|
|||
import org.elasticsearch.cluster.ClusterName;
|
||||
import org.elasticsearch.cluster.ClusterService;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.routing.IndexRoutingTable;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
|
@ -65,9 +66,10 @@ public class TransportClusterStatsAction extends TransportNodesAction<ClusterSta
|
|||
@Inject
|
||||
public TransportClusterStatsAction(Settings settings, ClusterName clusterName, ThreadPool threadPool,
|
||||
ClusterService clusterService, TransportService transportService,
|
||||
NodeService nodeService, IndicesService indicesService, ActionFilters actionFilters) {
|
||||
NodeService nodeService, IndicesService indicesService,
|
||||
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, ClusterStatsAction.NAME, clusterName, threadPool, clusterService, transportService, actionFilters,
|
||||
ClusterStatsRequest.class, ClusterStatsNodeRequest.class, ThreadPool.Names.MANAGEMENT);
|
||||
indexNameExpressionResolver, ClusterStatsRequest.class, ClusterStatsNodeRequest.class, ThreadPool.Names.MANAGEMENT);
|
||||
this.nodeService = nodeService;
|
||||
this.indicesService = indicesService;
|
||||
}
|
||||
|
@ -82,7 +84,7 @@ public class TransportClusterStatsAction extends TransportNodesAction<ClusterSta
|
|||
}
|
||||
}
|
||||
return new ClusterStatsResponse(System.currentTimeMillis(), clusterName,
|
||||
clusterService.state().metaData().uuid(), nodeStats.toArray(new ClusterStatsNodeResponse[nodeStats.size()]));
|
||||
clusterService.state().metaData().clusterUUID(), nodeStats.toArray(new ClusterStatsNodeResponse[nodeStats.size()]));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
|
@ -38,8 +39,9 @@ public class TransportPendingClusterTasksAction extends TransportMasterNodeReadA
|
|||
private final ClusterService clusterService;
|
||||
|
||||
@Inject
|
||||
public TransportPendingClusterTasksAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters) {
|
||||
super(settings, PendingClusterTasksAction.NAME, transportService, clusterService, threadPool, actionFilters, PendingClusterTasksRequest.class);
|
||||
public TransportPendingClusterTasksAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, PendingClusterTasksAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, PendingClusterTasksRequest.class);
|
||||
this.clusterService = clusterService;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,10 +30,11 @@ import org.elasticsearch.cluster.ack.ClusterStateUpdateResponse;
|
|||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.AliasAction;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.MetaDataIndexAliasesService;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.rest.action.admin.indices.alias.delete.AliasesMissingException;
|
||||
import org.elasticsearch.rest.action.admin.indices.alias.delete.AliasesNotFoundException;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
|
@ -48,8 +49,9 @@ public class TransportIndicesAliasesAction extends TransportMasterNodeAction<Ind
|
|||
|
||||
@Inject
|
||||
public TransportIndicesAliasesAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, MetaDataIndexAliasesService indexAliasesService, ActionFilters actionFilters) {
|
||||
super(settings, IndicesAliasesAction.NAME, transportService, clusterService, threadPool, actionFilters, IndicesAliasesRequest.class);
|
||||
ThreadPool threadPool, MetaDataIndexAliasesService indexAliasesService,
|
||||
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, IndicesAliasesAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, IndicesAliasesRequest.class);
|
||||
this.indexAliasesService = indexAliasesService;
|
||||
}
|
||||
|
||||
|
@ -85,7 +87,7 @@ public class TransportIndicesAliasesAction extends TransportMasterNodeAction<Ind
|
|||
Set<String> aliases = new HashSet<>();
|
||||
for (AliasActions action : actions) {
|
||||
//expand indices
|
||||
String[] concreteIndices = state.metaData().concreteIndices(request.indicesOptions(), action.indices());
|
||||
String[] concreteIndices = indexNameExpressionResolver.concreteIndices(state, request.indicesOptions(), action.indices());
|
||||
//collect the aliases
|
||||
Collections.addAll(aliases, action.aliases());
|
||||
for (String index : concreteIndices) {
|
||||
|
@ -100,7 +102,7 @@ public class TransportIndicesAliasesAction extends TransportMasterNodeAction<Ind
|
|||
}
|
||||
}
|
||||
if (hasOnlyDeletesButNoneCanBeDone && actions.size() != 0) {
|
||||
throw new AliasesMissingException(aliases.toArray(new String[aliases.size()]));
|
||||
throw new AliasesNotFoundException(aliases.toArray(new String[aliases.size()]));
|
||||
}
|
||||
request.aliasActions().clear();
|
||||
IndicesAliasesClusterStateUpdateRequest updateRequest = new IndicesAliasesClusterStateUpdateRequest()
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
|
@ -36,8 +37,9 @@ import org.elasticsearch.transport.TransportService;
|
|||
public class TransportAliasesExistAction extends TransportMasterNodeReadAction<GetAliasesRequest, AliasesExistResponse> {
|
||||
|
||||
@Inject
|
||||
public TransportAliasesExistAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters) {
|
||||
super(settings, AliasesExistAction.NAME, transportService, clusterService, threadPool, actionFilters, GetAliasesRequest.class);
|
||||
public TransportAliasesExistAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, AliasesExistAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, GetAliasesRequest.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -48,7 +50,7 @@ public class TransportAliasesExistAction extends TransportMasterNodeReadAction<G
|
|||
|
||||
@Override
|
||||
protected ClusterBlockException checkBlock(GetAliasesRequest request, ClusterState state) {
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, state.metaData().concreteIndices(request.indicesOptions(), request.indices()));
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, indexNameExpressionResolver.concreteIndices(state, request));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -58,7 +60,7 @@ public class TransportAliasesExistAction extends TransportMasterNodeReadAction<G
|
|||
|
||||
@Override
|
||||
protected void masterOperation(GetAliasesRequest request, ClusterState state, ActionListener<AliasesExistResponse> listener) {
|
||||
String[] concreteIndices = state.metaData().concreteIndices(request.indicesOptions(), request.indices());
|
||||
String[] concreteIndices = indexNameExpressionResolver.concreteIndices(state, request);
|
||||
boolean result = state.metaData().hasAliases(request.aliases(), concreteIndices);
|
||||
listener.onResponse(new AliasesExistResponse(result));
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.elasticsearch.cluster.ClusterState;
|
|||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.AliasMetaData;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -39,8 +40,9 @@ import java.util.List;
|
|||
public class TransportGetAliasesAction extends TransportMasterNodeReadAction<GetAliasesRequest, GetAliasesResponse> {
|
||||
|
||||
@Inject
|
||||
public TransportGetAliasesAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters) {
|
||||
super(settings, GetAliasesAction.NAME, transportService, clusterService, threadPool, actionFilters, GetAliasesRequest.class);
|
||||
public TransportGetAliasesAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, GetAliasesAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, GetAliasesRequest.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -51,7 +53,7 @@ public class TransportGetAliasesAction extends TransportMasterNodeReadAction<Get
|
|||
|
||||
@Override
|
||||
protected ClusterBlockException checkBlock(GetAliasesRequest request, ClusterState state) {
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, state.metaData().concreteIndices(request.indicesOptions(), request.indices()));
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, indexNameExpressionResolver.concreteIndices(state, request));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -61,7 +63,7 @@ public class TransportGetAliasesAction extends TransportMasterNodeReadAction<Get
|
|||
|
||||
@Override
|
||||
protected void masterOperation(GetAliasesRequest request, ClusterState state, ActionListener<GetAliasesResponse> listener) {
|
||||
String[] concreteIndices = state.metaData().concreteIndices(request.indicesOptions(), request.indices());
|
||||
String[] concreteIndices = indexNameExpressionResolver.concreteIndices(state, request);
|
||||
@SuppressWarnings("unchecked") // ImmutableList to List results incompatible type
|
||||
ImmutableOpenMap<String, List<AliasMetaData>> result = (ImmutableOpenMap) state.metaData().findAliases(request.aliases(), concreteIndices);
|
||||
listener.onResponse(new GetAliasesResponse(result));
|
||||
|
|
|
@ -34,14 +34,14 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
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.mapper.FieldMapper;
|
||||
import org.elasticsearch.index.mapper.MappedFieldType;
|
||||
import org.elasticsearch.index.mapper.internal.AllFieldMapper;
|
||||
import org.elasticsearch.index.IndexService;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.indices.IndicesService;
|
||||
import org.elasticsearch.indices.analysis.IndicesAnalysisService;
|
||||
|
@ -63,8 +63,9 @@ public class TransportAnalyzeAction extends TransportSingleCustomOperationAction
|
|||
|
||||
@Inject
|
||||
public TransportAnalyzeAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService,
|
||||
IndicesService indicesService, IndicesAnalysisService indicesAnalysisService, ActionFilters actionFilters) {
|
||||
super(settings, AnalyzeAction.NAME, threadPool, clusterService, transportService, actionFilters, AnalyzeRequest.class, ThreadPool.Names.INDEX);
|
||||
IndicesService indicesService, IndicesAnalysisService indicesAnalysisService, ActionFilters actionFilters,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, AnalyzeAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver, AnalyzeRequest.class, ThreadPool.Names.INDEX);
|
||||
this.indicesService = indicesService;
|
||||
this.indicesAnalysisService = indicesAnalysisService;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
|
@ -55,8 +56,9 @@ public class TransportClearIndicesCacheAction extends TransportBroadcastAction<C
|
|||
@Inject
|
||||
public TransportClearIndicesCacheAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
|
||||
TransportService transportService, IndicesService indicesService,
|
||||
IndicesRequestCache indicesQueryCache, ActionFilters actionFilters) {
|
||||
super(settings, ClearIndicesCacheAction.NAME, threadPool, clusterService, transportService, actionFilters,
|
||||
IndicesRequestCache indicesQueryCache, ActionFilters actionFilters,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, ClearIndicesCacheAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
|
||||
ClearIndicesCacheRequest.class, ShardClearIndicesCacheRequest.class, ThreadPool.Names.MANAGEMENT);
|
||||
this.indicesService = indicesService;
|
||||
this.indicesRequestCache = indicesQueryCache;
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.cluster.ClusterState;
|
|||
import org.elasticsearch.cluster.ack.ClusterStateUpdateResponse;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.MetaDataIndexStateService;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -45,8 +46,10 @@ public class TransportCloseIndexAction extends TransportMasterNodeAction<CloseIn
|
|||
|
||||
@Inject
|
||||
public TransportCloseIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, MetaDataIndexStateService indexStateService, NodeSettingsService nodeSettingsService, ActionFilters actionFilters) {
|
||||
super(settings, CloseIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, CloseIndexRequest.class);
|
||||
ThreadPool threadPool, MetaDataIndexStateService indexStateService,
|
||||
NodeSettingsService nodeSettingsService, ActionFilters actionFilters,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, CloseIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, CloseIndexRequest.class);
|
||||
this.indexStateService = indexStateService;
|
||||
this.destructiveOperations = new DestructiveOperations(logger, settings, nodeSettingsService);
|
||||
}
|
||||
|
@ -70,12 +73,12 @@ public class TransportCloseIndexAction extends TransportMasterNodeAction<CloseIn
|
|||
|
||||
@Override
|
||||
protected ClusterBlockException checkBlock(CloseIndexRequest request, ClusterState state) {
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_WRITE, state.metaData().concreteIndices(request.indicesOptions(), request.indices()));
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_WRITE, indexNameExpressionResolver.concreteIndices(state, request));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void masterOperation(final CloseIndexRequest request, final ClusterState state, final ActionListener<CloseIndexResponse> listener) {
|
||||
final String[] concreteIndices = state.metaData().concreteIndices(request.indicesOptions(), request.indices());
|
||||
final String[] concreteIndices = indexNameExpressionResolver.concreteIndices(state, request);
|
||||
CloseIndexClusterStateUpdateRequest updateRequest = new CloseIndexClusterStateUpdateRequest()
|
||||
.ackTimeout(request.timeout()).masterNodeTimeout(request.masterNodeTimeout())
|
||||
.indices(concreteIndices);
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.cluster.ClusterState;
|
|||
import org.elasticsearch.cluster.ack.ClusterStateUpdateResponse;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.MetaDataCreateIndexService;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -43,8 +44,9 @@ public class TransportCreateIndexAction extends TransportMasterNodeAction<Create
|
|||
|
||||
@Inject
|
||||
public TransportCreateIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, MetaDataCreateIndexService createIndexService, ActionFilters actionFilters) {
|
||||
super(settings, CreateIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, CreateIndexRequest.class);
|
||||
ThreadPool threadPool, MetaDataCreateIndexService createIndexService,
|
||||
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, CreateIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, CreateIndexRequest.class);
|
||||
this.createIndexService = createIndexService;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.MetaDataDeleteIndexService;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -46,8 +47,9 @@ public class TransportDeleteIndexAction extends TransportMasterNodeAction<Delete
|
|||
@Inject
|
||||
public TransportDeleteIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, MetaDataDeleteIndexService deleteIndexService,
|
||||
NodeSettingsService nodeSettingsService, ActionFilters actionFilters) {
|
||||
super(settings, DeleteIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, DeleteIndexRequest.class);
|
||||
NodeSettingsService nodeSettingsService, ActionFilters actionFilters,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, DeleteIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, DeleteIndexRequest.class);
|
||||
this.deleteIndexService = deleteIndexService;
|
||||
this.destructiveOperations = new DestructiveOperations(logger, settings, nodeSettingsService);
|
||||
}
|
||||
|
@ -70,12 +72,12 @@ public class TransportDeleteIndexAction extends TransportMasterNodeAction<Delete
|
|||
|
||||
@Override
|
||||
protected ClusterBlockException checkBlock(DeleteIndexRequest request, ClusterState state) {
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_WRITE, state.metaData().concreteIndices(request.indicesOptions(), request.indices()));
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_WRITE, indexNameExpressionResolver.concreteIndices(state, request));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void masterOperation(final DeleteIndexRequest request, final ClusterState state, final ActionListener<DeleteIndexResponse> listener) {
|
||||
String[] concreteIndices = state.metaData().concreteIndices(request.indicesOptions(), request.indices());
|
||||
String[] concreteIndices = indexNameExpressionResolver.concreteIndices(state, request);
|
||||
if (concreteIndices.length == 0) {
|
||||
listener.onResponse(new DeleteIndexResponse(true));
|
||||
return;
|
||||
|
|
|
@ -27,9 +27,10 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.indices.IndexMissingException;
|
||||
import org.elasticsearch.index.IndexNotFoundException;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
|
@ -40,8 +41,8 @@ public class TransportIndicesExistsAction extends TransportMasterNodeReadAction<
|
|||
|
||||
@Inject
|
||||
public TransportIndicesExistsAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, ActionFilters actionFilters) {
|
||||
super(settings, IndicesExistsAction.NAME, transportService, clusterService, threadPool, actionFilters, IndicesExistsRequest.class);
|
||||
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, IndicesExistsAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, IndicesExistsRequest.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -59,7 +60,7 @@ public class TransportIndicesExistsAction extends TransportMasterNodeReadAction<
|
|||
protected ClusterBlockException checkBlock(IndicesExistsRequest request, ClusterState state) {
|
||||
//make sure through indices options that the concrete indices call never throws IndexMissingException
|
||||
IndicesOptions indicesOptions = IndicesOptions.fromOptions(true, true, request.indicesOptions().expandWildcardsOpen(), request.indicesOptions().expandWildcardsClosed());
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, clusterService.state().metaData().concreteIndices(indicesOptions, request.indices()));
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, indexNameExpressionResolver.concreteIndices(state, indicesOptions, request.indices()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -67,9 +68,9 @@ public class TransportIndicesExistsAction extends TransportMasterNodeReadAction<
|
|||
boolean exists;
|
||||
try {
|
||||
// Similar as the previous behaviour, but now also aliases and wildcards are supported.
|
||||
clusterService.state().metaData().concreteIndices(request.indicesOptions(), request.indices());
|
||||
indexNameExpressionResolver.concreteIndices(state, request);
|
||||
exists = true;
|
||||
} catch (IndexMissingException e) {
|
||||
} catch (IndexNotFoundException e) {
|
||||
exists = false;
|
||||
}
|
||||
listener.onResponse(new IndicesExistsResponse(exists));
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.MappingMetaData;
|
||||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
|
@ -39,8 +40,8 @@ public class TransportTypesExistsAction extends TransportMasterNodeReadAction<Ty
|
|||
|
||||
@Inject
|
||||
public TransportTypesExistsAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, ActionFilters actionFilters) {
|
||||
super(settings, TypesExistsAction.NAME, transportService, clusterService, threadPool, actionFilters, TypesExistsRequest.class);
|
||||
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, TypesExistsAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, TypesExistsRequest.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -56,12 +57,12 @@ public class TransportTypesExistsAction extends TransportMasterNodeReadAction<Ty
|
|||
|
||||
@Override
|
||||
protected ClusterBlockException checkBlock(TypesExistsRequest request, ClusterState state) {
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, state.metaData().concreteIndices(request.indicesOptions(), request.indices()));
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, indexNameExpressionResolver.concreteIndices(state, request));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void masterOperation(final TypesExistsRequest request, final ClusterState state, final ActionListener<TypesExistsResponse> listener) {
|
||||
String[] concreteIndices = state.metaData().concreteIndices(request.indicesOptions(), request.indices());
|
||||
String[] concreteIndices = indexNameExpressionResolver.concreteIndices(state, request.indicesOptions(), request.indices());
|
||||
if (concreteIndices.length == 0) {
|
||||
listener.onResponse(new TypesExistsResponse(false));
|
||||
return;
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
|
@ -50,8 +51,10 @@ public class TransportFlushAction extends TransportBroadcastAction<FlushRequest,
|
|||
private final IndicesService indicesService;
|
||||
|
||||
@Inject
|
||||
public TransportFlushAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, IndicesService indicesService, ActionFilters actionFilters) {
|
||||
super(settings, FlushAction.NAME, threadPool, clusterService, transportService, actionFilters,
|
||||
public TransportFlushAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
|
||||
TransportService transportService, IndicesService indicesService,
|
||||
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, FlushAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
|
||||
FlushRequest.class, ShardFlushRequest.class, ThreadPool.Names.FLUSH);
|
||||
this.indicesService = indicesService;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.elasticsearch.cluster.block.ClusterBlockException;
|
|||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.AliasMetaData;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.MappingMetaData;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||
|
@ -47,8 +48,8 @@ public class TransportGetIndexAction extends TransportClusterInfoAction<GetIndex
|
|||
|
||||
@Inject
|
||||
public TransportGetIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, ActionFilters actionFilters) {
|
||||
super(settings, GetIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, GetIndexRequest.class);
|
||||
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, GetIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, GetIndexRequest.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -59,7 +60,7 @@ public class TransportGetIndexAction extends TransportClusterInfoAction<GetIndex
|
|||
|
||||
@Override
|
||||
protected ClusterBlockException checkBlock(GetIndexRequest request, ClusterState state) {
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, state.metaData().concreteIndices(request.indicesOptions(), request.indices()));
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, indexNameExpressionResolver.concreteIndices(state, request));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.elasticsearch.action.support.ActionFilters;
|
|||
import org.elasticsearch.action.support.HandledTransportAction;
|
||||
import org.elasticsearch.cluster.ClusterService;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.common.collect.MapBuilder;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -42,8 +43,10 @@ public class TransportGetFieldMappingsAction extends HandledTransportAction<GetF
|
|||
private final TransportGetFieldMappingsIndexAction shardAction;
|
||||
|
||||
@Inject
|
||||
public TransportGetFieldMappingsAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, TransportGetFieldMappingsIndexAction shardAction, ActionFilters actionFilters) {
|
||||
super(settings, GetFieldMappingsAction.NAME, threadPool, transportService, actionFilters, GetFieldMappingsRequest.class);
|
||||
public TransportGetFieldMappingsAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, TransportGetFieldMappingsIndexAction shardAction,
|
||||
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, GetFieldMappingsAction.NAME, threadPool, transportService, actionFilters, indexNameExpressionResolver, GetFieldMappingsRequest.class);
|
||||
this.clusterService = clusterService;
|
||||
this.shardAction = shardAction;
|
||||
}
|
||||
|
@ -51,7 +54,7 @@ public class TransportGetFieldMappingsAction extends HandledTransportAction<GetF
|
|||
@Override
|
||||
protected void doExecute(GetFieldMappingsRequest request, final ActionListener<GetFieldMappingsResponse> listener) {
|
||||
ClusterState clusterState = clusterService.state();
|
||||
String[] concreteIndices = clusterState.metaData().concreteIndices(request.indicesOptions(), request.indices());
|
||||
String[] concreteIndices = indexNameExpressionResolver.concreteIndices(clusterState, request);
|
||||
final AtomicInteger indexCounter = new AtomicInteger();
|
||||
final AtomicInteger completionCounter = new AtomicInteger(concreteIndices.length);
|
||||
final AtomicReferenceArray<Object> indexResponses = new AtomicReferenceArray<>(concreteIndices.length);
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.routing.ShardsIterator;
|
||||
import org.elasticsearch.common.collect.MapBuilder;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
|
@ -65,11 +66,10 @@ public class TransportGetFieldMappingsIndexAction extends TransportSingleCustomO
|
|||
private final IndicesService indicesService;
|
||||
|
||||
@Inject
|
||||
public TransportGetFieldMappingsIndexAction(Settings settings, ClusterService clusterService,
|
||||
TransportService transportService,
|
||||
IndicesService indicesService,
|
||||
ThreadPool threadPool, ActionFilters actionFilters) {
|
||||
super(settings, ACTION_NAME, threadPool, clusterService, transportService, actionFilters, GetFieldMappingsIndexRequest.class, ThreadPool.Names.MANAGEMENT);
|
||||
public TransportGetFieldMappingsIndexAction(Settings settings, ClusterService clusterService, TransportService transportService,
|
||||
IndicesService indicesService, ThreadPool threadPool, ActionFilters actionFilters,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, ACTION_NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver, GetFieldMappingsIndexRequest.class, ThreadPool.Names.MANAGEMENT);
|
||||
this.clusterService = clusterService;
|
||||
this.indicesService = indicesService;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.MappingMetaData;
|
||||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
|
@ -38,8 +39,9 @@ import org.elasticsearch.transport.TransportService;
|
|||
public class TransportGetMappingsAction extends TransportClusterInfoAction<GetMappingsRequest, GetMappingsResponse> {
|
||||
|
||||
@Inject
|
||||
public TransportGetMappingsAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters) {
|
||||
super(settings, GetMappingsAction.NAME, transportService, clusterService, threadPool, actionFilters, GetMappingsRequest.class);
|
||||
public TransportGetMappingsAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, GetMappingsAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, GetMappingsRequest.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -50,7 +52,7 @@ public class TransportGetMappingsAction extends TransportClusterInfoAction<GetMa
|
|||
|
||||
@Override
|
||||
protected ClusterBlockException checkBlock(GetMappingsRequest request, ClusterState state) {
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, state.metaData().concreteIndices(request.indicesOptions(), request.indices()));
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, indexNameExpressionResolver.concreteIndices(state, request));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.cluster.ClusterState;
|
|||
import org.elasticsearch.cluster.ack.ClusterStateUpdateResponse;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.MetaDataMappingService;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -42,8 +43,9 @@ public class TransportPutMappingAction extends TransportMasterNodeAction<PutMapp
|
|||
|
||||
@Inject
|
||||
public TransportPutMappingAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, MetaDataMappingService metaDataMappingService, ActionFilters actionFilters) {
|
||||
super(settings, PutMappingAction.NAME, transportService, clusterService, threadPool, actionFilters, PutMappingRequest.class);
|
||||
ThreadPool threadPool, MetaDataMappingService metaDataMappingService,
|
||||
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, PutMappingAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, PutMappingRequest.class);
|
||||
this.metaDataMappingService = metaDataMappingService;
|
||||
}
|
||||
|
||||
|
@ -60,12 +62,12 @@ public class TransportPutMappingAction extends TransportMasterNodeAction<PutMapp
|
|||
|
||||
@Override
|
||||
protected ClusterBlockException checkBlock(PutMappingRequest request, ClusterState state) {
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_WRITE, clusterService.state().metaData().concreteIndices(request.indicesOptions(), request.indices()));
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_WRITE, indexNameExpressionResolver.concreteIndices(state, request));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void masterOperation(final PutMappingRequest request, final ClusterState state, final ActionListener<PutMappingResponse> listener) {
|
||||
final String[] concreteIndices = clusterService.state().metaData().concreteIndices(request.indicesOptions(), request.indices());
|
||||
final String[] concreteIndices = indexNameExpressionResolver.concreteIndices(state, request);
|
||||
PutMappingClusterStateUpdateRequest updateRequest = new PutMappingClusterStateUpdateRequest()
|
||||
.ackTimeout(request.timeout()).masterNodeTimeout(request.masterNodeTimeout())
|
||||
.indices(concreteIndices).type(request.type())
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.cluster.ClusterState;
|
|||
import org.elasticsearch.cluster.ack.ClusterStateUpdateResponse;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.MetaDataIndexStateService;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -45,8 +46,9 @@ public class TransportOpenIndexAction extends TransportMasterNodeAction<OpenInde
|
|||
|
||||
@Inject
|
||||
public TransportOpenIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, MetaDataIndexStateService indexStateService, NodeSettingsService nodeSettingsService, ActionFilters actionFilters) {
|
||||
super(settings, OpenIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, OpenIndexRequest.class);
|
||||
ThreadPool threadPool, MetaDataIndexStateService indexStateService,
|
||||
NodeSettingsService nodeSettingsService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, OpenIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, OpenIndexRequest.class);
|
||||
this.indexStateService = indexStateService;
|
||||
this.destructiveOperations = new DestructiveOperations(logger, settings, nodeSettingsService);
|
||||
}
|
||||
|
@ -70,12 +72,12 @@ public class TransportOpenIndexAction extends TransportMasterNodeAction<OpenInde
|
|||
|
||||
@Override
|
||||
protected ClusterBlockException checkBlock(OpenIndexRequest request, ClusterState state) {
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_WRITE, state.metaData().concreteIndices(request.indicesOptions(), request.indices()));
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_WRITE, indexNameExpressionResolver.concreteIndices(state, request));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void masterOperation(final OpenIndexRequest request, final ClusterState state, final ActionListener<OpenIndexResponse> listener) {
|
||||
final String[] concreteIndices = state.metaData().concreteIndices(request.indicesOptions(), request.indices());
|
||||
final String[] concreteIndices = indexNameExpressionResolver.concreteIndices(state, request);
|
||||
OpenIndexClusterStateUpdateRequest updateRequest = new OpenIndexClusterStateUpdateRequest()
|
||||
.ackTimeout(request.timeout()).masterNodeTimeout(request.masterNodeTimeout())
|
||||
.indices(concreteIndices);
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
|
@ -51,8 +52,9 @@ public class TransportOptimizeAction extends TransportBroadcastAction<OptimizeRe
|
|||
|
||||
@Inject
|
||||
public TransportOptimizeAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
|
||||
TransportService transportService, IndicesService indicesService, ActionFilters actionFilters) {
|
||||
super(settings, OptimizeAction.NAME, threadPool, clusterService, transportService, actionFilters,
|
||||
TransportService transportService, IndicesService indicesService,
|
||||
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, OptimizeAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
|
||||
OptimizeRequest.class, ShardOptimizeRequest.class, ThreadPool.Names.OPTIMIZE);
|
||||
this.indicesService = indicesService;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
|
@ -57,8 +58,9 @@ public class TransportRecoveryAction extends TransportBroadcastAction<RecoveryRe
|
|||
|
||||
@Inject
|
||||
public TransportRecoveryAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
|
||||
TransportService transportService, IndicesService indicesService, ActionFilters actionFilters) {
|
||||
super(settings, RecoveryAction.NAME, threadPool, clusterService, transportService, actionFilters,
|
||||
TransportService transportService, IndicesService indicesService,
|
||||
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, RecoveryAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
|
||||
RecoveryRequest.class, ShardRecoveryRequest.class, ThreadPool.Names.MANAGEMENT);
|
||||
this.indicesService = indicesService;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
|
@ -51,8 +52,9 @@ public class TransportRefreshAction extends TransportBroadcastAction<RefreshRequ
|
|||
|
||||
@Inject
|
||||
public TransportRefreshAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
|
||||
TransportService transportService, IndicesService indicesService, ActionFilters actionFilters) {
|
||||
super(settings, RefreshAction.NAME, threadPool, clusterService, transportService, actionFilters,
|
||||
TransportService transportService, IndicesService indicesService,
|
||||
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, RefreshAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
|
||||
RefreshRequest.class, ShardRefreshRequest.class, ThreadPool.Names.REFRESH);
|
||||
this.indicesService = indicesService;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
|
@ -57,8 +58,8 @@ public class TransportIndicesSegmentsAction extends TransportBroadcastAction<Ind
|
|||
|
||||
@Inject
|
||||
public TransportIndicesSegmentsAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService,
|
||||
IndicesService indicesService, ActionFilters actionFilters) {
|
||||
super(settings, IndicesSegmentsAction.NAME, threadPool, clusterService, transportService, actionFilters,
|
||||
IndicesService indicesService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, IndicesSegmentsAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
|
||||
IndicesSegmentsRequest.class, TransportIndicesSegmentsAction.IndexShardSegmentRequest.class, ThreadPool.Names.MANAGEMENT);
|
||||
this.indicesService = indicesService;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.cluster.ClusterState;
|
|||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.regex.Regex;
|
||||
|
@ -46,8 +47,9 @@ public class TransportGetSettingsAction extends TransportMasterNodeReadAction<Ge
|
|||
|
||||
@Inject
|
||||
public TransportGetSettingsAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, SettingsFilter settingsFilter, ActionFilters actionFilters) {
|
||||
super(settings, GetSettingsAction.NAME, transportService, clusterService, threadPool, actionFilters, GetSettingsRequest.class);
|
||||
ThreadPool threadPool, SettingsFilter settingsFilter, ActionFilters actionFilters,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, GetSettingsAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, GetSettingsRequest.class);
|
||||
this.settingsFilter = settingsFilter;
|
||||
}
|
||||
|
||||
|
@ -59,7 +61,7 @@ public class TransportGetSettingsAction extends TransportMasterNodeReadAction<Ge
|
|||
|
||||
@Override
|
||||
protected ClusterBlockException checkBlock(GetSettingsRequest request, ClusterState state) {
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, state.metaData().concreteIndices(request.indicesOptions(), request.indices()));
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, indexNameExpressionResolver.concreteIndices(state, request));
|
||||
}
|
||||
|
||||
|
||||
|
@ -70,7 +72,7 @@ public class TransportGetSettingsAction extends TransportMasterNodeReadAction<Ge
|
|||
|
||||
@Override
|
||||
protected void masterOperation(GetSettingsRequest request, ClusterState state, ActionListener<GetSettingsResponse> listener) {
|
||||
String[] concreteIndices = state.metaData().concreteIndices(request.indicesOptions(), request.indices());
|
||||
String[] concreteIndices = indexNameExpressionResolver.concreteIndices(state, request);
|
||||
ImmutableOpenMap.Builder<String, Settings> indexToSettingsBuilder = ImmutableOpenMap.builder();
|
||||
for (String concreteIndex : concreteIndices) {
|
||||
IndexMetaData indexMetaData = state.getMetaData().index(concreteIndex);
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.cluster.ack.ClusterStateUpdateResponse;
|
|||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.MetaDataUpdateSettingsService;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -43,8 +44,8 @@ public class TransportUpdateSettingsAction extends TransportMasterNodeAction<Upd
|
|||
|
||||
@Inject
|
||||
public TransportUpdateSettingsAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
|
||||
MetaDataUpdateSettingsService updateSettingsService, ActionFilters actionFilters) {
|
||||
super(settings, UpdateSettingsAction.NAME, transportService, clusterService, threadPool, actionFilters, UpdateSettingsRequest.class);
|
||||
MetaDataUpdateSettingsService updateSettingsService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, UpdateSettingsAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, UpdateSettingsRequest.class);
|
||||
this.updateSettingsService = updateSettingsService;
|
||||
}
|
||||
|
||||
|
@ -64,7 +65,7 @@ public class TransportUpdateSettingsAction extends TransportMasterNodeAction<Upd
|
|||
if (request.settings().getAsMap().size() == 1 && (request.settings().get(IndexMetaData.SETTING_BLOCKS_METADATA) != null || request.settings().get(IndexMetaData.SETTING_READ_ONLY) != null )) {
|
||||
return null;
|
||||
}
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_WRITE, state.metaData().concreteIndices(request.indicesOptions(), request.indices()));
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_WRITE, indexNameExpressionResolver.concreteIndices(state, request));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -74,7 +75,7 @@ public class TransportUpdateSettingsAction extends TransportMasterNodeAction<Upd
|
|||
|
||||
@Override
|
||||
protected void masterOperation(final UpdateSettingsRequest request, final ClusterState state, final ActionListener<UpdateSettingsResponse> listener) {
|
||||
final String[] concreteIndices = clusterService.state().metaData().concreteIndices(request.indicesOptions(), request.indices());
|
||||
final String[] concreteIndices = indexNameExpressionResolver.concreteIndices(state, request);
|
||||
UpdateSettingsClusterStateUpdateRequest clusterStateUpdateRequest = new UpdateSettingsClusterStateUpdateRequest()
|
||||
.indices(concreteIndices)
|
||||
.settings(request.settings())
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* 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.admin.indices.shards;
|
||||
|
||||
import org.elasticsearch.action.Action;
|
||||
import org.elasticsearch.action.support.IndicesOptions;
|
||||
import org.elasticsearch.action.support.master.MasterNodeReadOperationRequestBuilder;
|
||||
import org.elasticsearch.client.ElasticsearchClient;
|
||||
|
||||
/**
|
||||
* Request builder for {@link IndicesShardStoresRequest}
|
||||
*/
|
||||
public class IndicesShardStoreRequestBuilder extends MasterNodeReadOperationRequestBuilder<IndicesShardStoresRequest, IndicesShardStoresResponse, IndicesShardStoreRequestBuilder> {
|
||||
|
||||
public IndicesShardStoreRequestBuilder(ElasticsearchClient client, Action<IndicesShardStoresRequest, IndicesShardStoresResponse, IndicesShardStoreRequestBuilder> action, String... indices) {
|
||||
super(client, action, new IndicesShardStoresRequest(indices));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the indices for the shard stores request
|
||||
*/
|
||||
public IndicesShardStoreRequestBuilder setIndices(String... indices) {
|
||||
request.indices(indices);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies what type of requested indices to ignore and wildcard indices expressions
|
||||
* By default, expands wildcards to both open and closed indices
|
||||
*/
|
||||
public IndicesShardStoreRequestBuilder setIndicesOptions(IndicesOptions indicesOptions) {
|
||||
request.indicesOptions(indicesOptions);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set statuses to filter shards to get stores info on.
|
||||
* @param shardStatuses acceptable values are "green", "yellow", "red" and "all"
|
||||
* see {@link org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus} for details
|
||||
*/
|
||||
public IndicesShardStoreRequestBuilder setShardStatuses(String... shardStatuses) {
|
||||
request.shardStatuses(shardStatuses);
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* 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.admin.indices.shards;
|
||||
|
||||
import org.elasticsearch.action.Action;
|
||||
import org.elasticsearch.client.ElasticsearchClient;
|
||||
|
||||
/**
|
||||
* Action for {@link TransportIndicesShardStoresAction}
|
||||
*
|
||||
* Exposes shard store information for requested indices.
|
||||
* Shard store information reports which nodes hold shard copies, how recent they are
|
||||
* and any exceptions on opening the shard index or from previous engine failures
|
||||
*/
|
||||
public class IndicesShardStoresAction extends Action<IndicesShardStoresRequest, IndicesShardStoresResponse, IndicesShardStoreRequestBuilder> {
|
||||
|
||||
public static final IndicesShardStoresAction INSTANCE = new IndicesShardStoresAction();
|
||||
public static final String NAME = "indices:monitor/shard_stores";
|
||||
|
||||
private IndicesShardStoresAction() {
|
||||
super(NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IndicesShardStoresResponse newResponse() {
|
||||
return new IndicesShardStoresResponse();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IndicesShardStoreRequestBuilder newRequestBuilder(ElasticsearchClient client) {
|
||||
return new IndicesShardStoreRequestBuilder(client, this);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,132 @@
|
|||
/*
|
||||
* 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.admin.indices.shards;
|
||||
|
||||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.action.IndicesRequest;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.action.support.IndicesOptions;
|
||||
import org.elasticsearch.action.support.master.MasterNodeReadRequest;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
|
||||
/**
|
||||
* Request for {@link IndicesShardStoresAction}
|
||||
*/
|
||||
public class IndicesShardStoresRequest extends MasterNodeReadRequest<IndicesShardStoresRequest> implements IndicesRequest.Replaceable {
|
||||
|
||||
private String[] indices = Strings.EMPTY_ARRAY;
|
||||
private IndicesOptions indicesOptions = IndicesOptions.strictExpand();
|
||||
private EnumSet<ClusterHealthStatus> statuses = EnumSet.of(ClusterHealthStatus.YELLOW, ClusterHealthStatus.RED);
|
||||
|
||||
/**
|
||||
* Create a request for shard stores info for <code>indices</code>
|
||||
*/
|
||||
public IndicesShardStoresRequest(String... indices) {
|
||||
this.indices = indices;
|
||||
}
|
||||
|
||||
IndicesShardStoresRequest() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set statuses to filter shards to get stores info on.
|
||||
* see {@link ClusterHealthStatus} for details.
|
||||
* Defaults to "yellow" and "red" status
|
||||
* @param shardStatuses acceptable values are "green", "yellow", "red" and "all"
|
||||
*/
|
||||
public IndicesShardStoresRequest shardStatuses(String... shardStatuses) {
|
||||
statuses = EnumSet.noneOf(ClusterHealthStatus.class);
|
||||
for (String statusString : shardStatuses) {
|
||||
if ("all".equalsIgnoreCase(statusString)) {
|
||||
statuses = EnumSet.allOf(ClusterHealthStatus.class);
|
||||
return this;
|
||||
}
|
||||
statuses.add(ClusterHealthStatus.fromString(statusString));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies what type of requested indices to ignore and wildcard indices expressions
|
||||
* By default, expands wildcards to both open and closed indices
|
||||
*/
|
||||
public IndicesShardStoresRequest indicesOptions(IndicesOptions indicesOptions) {
|
||||
this.indicesOptions = indicesOptions;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the indices for the shard stores request
|
||||
*/
|
||||
@Override
|
||||
public IndicesShardStoresRequest indices(String... indices) {
|
||||
this.indices = indices;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the shard criteria to get store information on
|
||||
*/
|
||||
public EnumSet<ClusterHealthStatus> shardStatuses() {
|
||||
return statuses;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] indices() {
|
||||
return indices;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IndicesOptions indicesOptions() {
|
||||
return indicesOptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionRequestValidationException validate() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeStringArrayNullable(indices);
|
||||
out.writeVInt(statuses.size());
|
||||
for (ClusterHealthStatus status : statuses) {
|
||||
out.writeByte(status.value());
|
||||
}
|
||||
indicesOptions.writeIndicesOptions(out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
indices = in.readStringArray();
|
||||
int nStatus = in.readVInt();
|
||||
statuses = EnumSet.noneOf(ClusterHealthStatus.class);
|
||||
for (int i = 0; i < nStatus; i++) {
|
||||
statuses.add(ClusterHealthStatus.fromValue(in.readByte()));
|
||||
}
|
||||
indicesOptions = IndicesOptions.readIndicesOptions(in);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,385 @@
|
|||
/*
|
||||
* 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.admin.indices.shards;
|
||||
|
||||
import com.carrotsearch.hppc.cursors.IntObjectCursor;
|
||||
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.action.ActionResponse;
|
||||
import org.elasticsearch.action.ShardOperationFailedException;
|
||||
import org.elasticsearch.action.support.DefaultShardOperationFailedException;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.common.collect.ImmutableOpenIntMap;
|
||||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.io.stream.Streamable;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
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 static org.elasticsearch.action.admin.indices.shards.IndicesShardStoresResponse.StoreStatus.*;
|
||||
|
||||
/**
|
||||
* Response for {@link IndicesShardStoresAction}
|
||||
*
|
||||
* Consists of {@link StoreStatus}s for requested indices grouped by
|
||||
* indices and shard ids and a list of encountered node {@link Failure}s
|
||||
*/
|
||||
public class IndicesShardStoresResponse extends ActionResponse implements ToXContent {
|
||||
|
||||
/**
|
||||
* Shard store information from a node
|
||||
*/
|
||||
public static class StoreStatus implements Streamable, ToXContent, Comparable<StoreStatus> {
|
||||
private DiscoveryNode node;
|
||||
private long version;
|
||||
private Throwable storeException;
|
||||
private Allocation allocation;
|
||||
|
||||
/**
|
||||
* The status of the shard store with respect to the cluster
|
||||
*/
|
||||
public enum Allocation {
|
||||
|
||||
/**
|
||||
* Allocated as primary
|
||||
*/
|
||||
PRIMARY((byte) 0),
|
||||
|
||||
/**
|
||||
* Allocated as a replica
|
||||
*/
|
||||
REPLICA((byte) 1),
|
||||
|
||||
/**
|
||||
* Not allocated
|
||||
*/
|
||||
UNUSED((byte) 2);
|
||||
|
||||
private final byte id;
|
||||
|
||||
Allocation(byte id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
private static Allocation fromId(byte id) {
|
||||
switch (id) {
|
||||
case 0: return PRIMARY;
|
||||
case 1: return REPLICA;
|
||||
case 2: return UNUSED;
|
||||
default: throw new IllegalArgumentException("unknown id for allocation [" + id + "]");
|
||||
}
|
||||
}
|
||||
|
||||
public String value() {
|
||||
switch (id) {
|
||||
case 0: return "primary";
|
||||
case 1: return "replica";
|
||||
case 2: return "unused";
|
||||
default: throw new IllegalArgumentException("unknown id for allocation [" + id + "]");
|
||||
}
|
||||
}
|
||||
|
||||
private static Allocation readFrom(StreamInput in) throws IOException {
|
||||
return fromId(in.readByte());
|
||||
}
|
||||
|
||||
private void writeTo(StreamOutput out) throws IOException {
|
||||
out.writeByte(id);
|
||||
}
|
||||
}
|
||||
|
||||
private StoreStatus() {
|
||||
}
|
||||
|
||||
public StoreStatus(DiscoveryNode node, long version, Allocation allocation, Throwable storeException) {
|
||||
this.node = node;
|
||||
this.version = version;
|
||||
this.allocation = allocation;
|
||||
this.storeException = storeException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Node the store belongs to
|
||||
*/
|
||||
public DiscoveryNode getNode() {
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Version of the store, used to select the store that will be
|
||||
* used as a primary.
|
||||
*/
|
||||
public long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exception while trying to open the
|
||||
* shard index or from when the shard failed
|
||||
*/
|
||||
public Throwable getStoreException() {
|
||||
return storeException;
|
||||
}
|
||||
|
||||
/**
|
||||
* The allocation status of the store.
|
||||
* {@link Allocation#PRIMARY} indicates a primary shard copy
|
||||
* {@link Allocation#REPLICA} indicates a replica shard copy
|
||||
* {@link Allocation#UNUSED} indicates an unused shard copy
|
||||
*/
|
||||
public Allocation getAllocation() {
|
||||
return allocation;
|
||||
}
|
||||
|
||||
static StoreStatus readStoreStatus(StreamInput in) throws IOException {
|
||||
StoreStatus storeStatus = new StoreStatus();
|
||||
storeStatus.readFrom(in);
|
||||
return storeStatus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
node = DiscoveryNode.readNode(in);
|
||||
version = in.readLong();
|
||||
allocation = Allocation.readFrom(in);
|
||||
if (in.readBoolean()) {
|
||||
storeException = in.readThrowable();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
node.writeTo(out);
|
||||
out.writeLong(version);
|
||||
allocation.writeTo(out);
|
||||
if (storeException != null) {
|
||||
out.writeBoolean(true);
|
||||
out.writeThrowable(storeException);
|
||||
} else {
|
||||
out.writeBoolean(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
node.toXContent(builder, params);
|
||||
builder.field(Fields.VERSION, version);
|
||||
builder.field(Fields.ALLOCATED, allocation.value());
|
||||
if (storeException != null) {
|
||||
builder.startObject(Fields.STORE_EXCEPTION);
|
||||
ElasticsearchException.toXContent(builder, params, storeException);
|
||||
builder.endObject();
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(StoreStatus other) {
|
||||
if (storeException != null && other.storeException == null) {
|
||||
return 1;
|
||||
} else if (other.storeException != null && storeException == null) {
|
||||
return -1;
|
||||
} else {
|
||||
int compare = Long.compare(other.version, version);
|
||||
if (compare == 0) {
|
||||
return Integer.compare(allocation.id, other.allocation.id);
|
||||
}
|
||||
return compare;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Single node failure while retrieving shard store information
|
||||
*/
|
||||
public static class Failure extends DefaultShardOperationFailedException {
|
||||
private String nodeId;
|
||||
|
||||
public Failure(String nodeId, String index, int shardId, Throwable reason) {
|
||||
super(index, shardId, reason);
|
||||
this.nodeId = nodeId;
|
||||
}
|
||||
|
||||
private Failure() {
|
||||
}
|
||||
|
||||
public String nodeId() {
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
public static Failure readFailure(StreamInput in) throws IOException {
|
||||
Failure failure = new Failure();
|
||||
failure.readFrom(in);
|
||||
return failure;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
nodeId = in.readString();
|
||||
super.readFrom(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
out.writeString(nodeId);
|
||||
super.writeTo(out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
builder.field("node", nodeId());
|
||||
super.toXContent(builder, params);
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
|
||||
private ImmutableOpenMap<String, ImmutableOpenIntMap<List<StoreStatus>>> storeStatuses;
|
||||
private ImmutableList<Failure> failures;
|
||||
|
||||
public IndicesShardStoresResponse(ImmutableOpenMap<String, ImmutableOpenIntMap<List<StoreStatus>>> storeStatuses, ImmutableList<Failure> failures) {
|
||||
this.storeStatuses = storeStatuses;
|
||||
this.failures = failures;
|
||||
}
|
||||
|
||||
IndicesShardStoresResponse() {
|
||||
this(ImmutableOpenMap.<String, ImmutableOpenIntMap<List<StoreStatus>>>of(), ImmutableList.<Failure>of());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@link StoreStatus}s
|
||||
* grouped by their index names and shard ids.
|
||||
*/
|
||||
public ImmutableOpenMap<String, ImmutableOpenIntMap<List<StoreStatus>>> getStoreStatuses() {
|
||||
return storeStatuses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns node {@link Failure}s encountered
|
||||
* while executing the request
|
||||
*/
|
||||
public ImmutableList<Failure> getFailures() {
|
||||
return failures;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
int numResponse = in.readVInt();
|
||||
ImmutableOpenMap.Builder<String, ImmutableOpenIntMap<List<StoreStatus>>> storeStatusesBuilder = ImmutableOpenMap.builder();
|
||||
for (int i = 0; i < numResponse; i++) {
|
||||
String index = in.readString();
|
||||
int indexEntries = in.readVInt();
|
||||
ImmutableOpenIntMap.Builder<List<StoreStatus>> shardEntries = ImmutableOpenIntMap.builder();
|
||||
for (int shardCount = 0; shardCount < indexEntries; shardCount++) {
|
||||
int shardID = in.readInt();
|
||||
int nodeEntries = in.readVInt();
|
||||
List<StoreStatus> storeStatuses = new ArrayList<>(nodeEntries);
|
||||
for (int nodeCount = 0; nodeCount < nodeEntries; nodeCount++) {
|
||||
storeStatuses.add(readStoreStatus(in));
|
||||
}
|
||||
shardEntries.put(shardID, storeStatuses);
|
||||
}
|
||||
storeStatusesBuilder.put(index, shardEntries.build());
|
||||
}
|
||||
int numFailure = in.readVInt();
|
||||
ImmutableList.Builder<Failure> failureBuilder = ImmutableList.builder();
|
||||
for (int i = 0; i < numFailure; i++) {
|
||||
failureBuilder.add(Failure.readFailure(in));
|
||||
}
|
||||
storeStatuses = storeStatusesBuilder.build();
|
||||
failures = failureBuilder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeVInt(storeStatuses.size());
|
||||
for (ObjectObjectCursor<String, ImmutableOpenIntMap<List<StoreStatus>>> indexShards : storeStatuses) {
|
||||
out.writeString(indexShards.key);
|
||||
out.writeVInt(indexShards.value.size());
|
||||
for (IntObjectCursor<List<StoreStatus>> shardStatusesEntry : indexShards.value) {
|
||||
out.writeInt(shardStatusesEntry.key);
|
||||
out.writeVInt(shardStatusesEntry.value.size());
|
||||
for (StoreStatus storeStatus : shardStatusesEntry.value) {
|
||||
storeStatus.writeTo(out);
|
||||
}
|
||||
}
|
||||
}
|
||||
out.writeVInt(failures.size());
|
||||
for (ShardOperationFailedException failure : failures) {
|
||||
failure.writeTo(out);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
if (failures.size() > 0) {
|
||||
builder.startArray(Fields.FAILURES);
|
||||
for (ShardOperationFailedException failure : failures) {
|
||||
builder.startObject();
|
||||
failure.toXContent(builder, params);
|
||||
builder.endObject();
|
||||
}
|
||||
builder.endArray();
|
||||
}
|
||||
|
||||
builder.startObject(Fields.INDICES);
|
||||
for (ObjectObjectCursor<String, ImmutableOpenIntMap<List<StoreStatus>>> indexShards : storeStatuses) {
|
||||
builder.startObject(indexShards.key);
|
||||
|
||||
builder.startObject(Fields.SHARDS);
|
||||
for (IntObjectCursor<List<StoreStatus>> shardStatusesEntry : indexShards.value) {
|
||||
builder.startObject(String.valueOf(shardStatusesEntry.key));
|
||||
builder.startArray(Fields.STORES);
|
||||
for (StoreStatus storeStatus : shardStatusesEntry.value) {
|
||||
builder.startObject();
|
||||
storeStatus.toXContent(builder, params);
|
||||
builder.endObject();
|
||||
}
|
||||
builder.endArray();
|
||||
|
||||
builder.endObject();
|
||||
}
|
||||
builder.endObject();
|
||||
|
||||
builder.endObject();
|
||||
}
|
||||
builder.endObject();
|
||||
return builder;
|
||||
}
|
||||
|
||||
static final class Fields {
|
||||
static final XContentBuilderString INDICES = new XContentBuilderString("indices");
|
||||
static final XContentBuilderString SHARDS = new XContentBuilderString("shards");
|
||||
static final XContentBuilderString FAILURES = new XContentBuilderString("failures");
|
||||
static final XContentBuilderString STORES = new XContentBuilderString("stores");
|
||||
// StoreStatus fields
|
||||
static final XContentBuilderString VERSION = new XContentBuilderString("version");
|
||||
static final XContentBuilderString STORE_EXCEPTION = new XContentBuilderString("store_exception");
|
||||
static final XContentBuilderString ALLOCATED = new XContentBuilderString("allocation");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,229 @@
|
|||
/*
|
||||
* 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.admin.indices.shards;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.apache.lucene.util.CollectionUtil;
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.FailedNodeException;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterShardHealth;
|
||||
import org.elasticsearch.action.support.ActionFilters;
|
||||
import org.elasticsearch.action.support.master.TransportMasterNodeReadAction;
|
||||
import org.elasticsearch.cluster.ClusterService;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
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.node.DiscoveryNode;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.cluster.routing.*;
|
||||
import org.elasticsearch.common.collect.ImmutableOpenIntMap;
|
||||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.concurrent.CountDown;
|
||||
import org.elasticsearch.gateway.AsyncShardFetch;
|
||||
import org.elasticsearch.gateway.TransportNodesListGatewayStartedShards;
|
||||
import org.elasticsearch.gateway.TransportNodesListGatewayStartedShards.NodeGatewayStartedShards;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
/**
|
||||
* Transport action that reads the cluster state for shards with the requested criteria (see {@link ClusterHealthStatus}) of specific indices
|
||||
* and fetches store information from all the nodes using {@link TransportNodesListGatewayStartedShards}
|
||||
*/
|
||||
public class TransportIndicesShardStoresAction extends TransportMasterNodeReadAction<IndicesShardStoresRequest, IndicesShardStoresResponse> {
|
||||
|
||||
private final TransportNodesListGatewayStartedShards listShardStoresInfo;
|
||||
|
||||
@Inject
|
||||
public TransportIndicesShardStoresAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver, TransportNodesListGatewayStartedShards listShardStoresInfo) {
|
||||
super(settings, IndicesShardStoresAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, IndicesShardStoresRequest.class);
|
||||
this.listShardStoresInfo = listShardStoresInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String executor() {
|
||||
return ThreadPool.Names.SAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IndicesShardStoresResponse newResponse() {
|
||||
return new IndicesShardStoresResponse();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void masterOperation(IndicesShardStoresRequest request, ClusterState state, ActionListener<IndicesShardStoresResponse> listener) {
|
||||
final RoutingTable routingTables = state.routingTable();
|
||||
final RoutingNodes routingNodes = state.routingNodes();
|
||||
final String[] concreteIndices = indexNameExpressionResolver.concreteIndices(state, request);
|
||||
final Set<ShardId> shardIdsToFetch = new HashSet<>();
|
||||
|
||||
// collect relevant shard ids of the requested indices for fetching store infos
|
||||
for (String index : concreteIndices) {
|
||||
IndexRoutingTable indexShardRoutingTables = routingTables.index(index);
|
||||
if (indexShardRoutingTables == null) {
|
||||
continue;
|
||||
}
|
||||
for (IndexShardRoutingTable routing : indexShardRoutingTables) {
|
||||
ClusterShardHealth shardHealth = new ClusterShardHealth(routing.shardId().id(), routing);
|
||||
if (request.shardStatuses().contains(shardHealth.getStatus())) {
|
||||
shardIdsToFetch.add(routing.shardId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// async fetch store infos from all the nodes
|
||||
// NOTE: instead of fetching shard store info one by one from every node (nShards * nNodes requests)
|
||||
// we could fetch all shard store info from every node once (nNodes requests)
|
||||
// we have to implement a TransportNodesAction instead of using TransportNodesListGatewayStartedShards
|
||||
// for fetching shard stores info, that operates on a list of shards instead of a single shard
|
||||
new AsyncShardStoresInfoFetches(state.nodes(), routingNodes, state.metaData(), shardIdsToFetch, listener).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ClusterBlockException checkBlock(IndicesShardStoresRequest request, ClusterState state) {
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, indexNameExpressionResolver.concreteIndices(state, request));
|
||||
}
|
||||
|
||||
private class AsyncShardStoresInfoFetches {
|
||||
private final DiscoveryNodes nodes;
|
||||
private final RoutingNodes routingNodes;
|
||||
private final MetaData metaData;
|
||||
private final Set<ShardId> shardIds;
|
||||
private final ActionListener<IndicesShardStoresResponse> listener;
|
||||
private CountDown expectedOps;
|
||||
private final Queue<InternalAsyncFetch.Response> fetchResponses;
|
||||
|
||||
AsyncShardStoresInfoFetches(DiscoveryNodes nodes, RoutingNodes routingNodes, MetaData metaData, Set<ShardId> shardIds, ActionListener<IndicesShardStoresResponse> listener) {
|
||||
this.nodes = nodes;
|
||||
this.routingNodes = routingNodes;
|
||||
this.metaData = metaData;
|
||||
this.shardIds = shardIds;
|
||||
this.listener = listener;
|
||||
this.fetchResponses = new ConcurrentLinkedQueue<>();
|
||||
this.expectedOps = new CountDown(shardIds.size());
|
||||
}
|
||||
|
||||
void start() {
|
||||
if (shardIds.isEmpty()) {
|
||||
listener.onResponse(new IndicesShardStoresResponse());
|
||||
} else {
|
||||
for (ShardId shardId : shardIds) {
|
||||
InternalAsyncFetch fetch = new InternalAsyncFetch(logger, "shard_stores", shardId, listShardStoresInfo);
|
||||
fetch.fetchData(nodes, metaData, Collections.<String>emptySet());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class InternalAsyncFetch extends AsyncShardFetch<NodeGatewayStartedShards> {
|
||||
|
||||
InternalAsyncFetch(ESLogger logger, String type, ShardId shardId, TransportNodesListGatewayStartedShards action) {
|
||||
super(logger, type, shardId, action);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected synchronized void processAsyncFetch(ShardId shardId, NodeGatewayStartedShards[] responses, FailedNodeException[] failures) {
|
||||
fetchResponses.add(new Response(shardId, responses, failures));
|
||||
if (expectedOps.countDown()) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
void finish() {
|
||||
ImmutableOpenMap.Builder<String, ImmutableOpenIntMap<java.util.List<IndicesShardStoresResponse.StoreStatus>>> indicesStoreStatusesBuilder = ImmutableOpenMap.builder();
|
||||
ImmutableList.Builder<IndicesShardStoresResponse.Failure> failureBuilder = ImmutableList.builder();
|
||||
for (Response fetchResponse : fetchResponses) {
|
||||
ImmutableOpenIntMap<java.util.List<IndicesShardStoresResponse.StoreStatus>> indexStoreStatuses = indicesStoreStatusesBuilder.get(fetchResponse.shardId.getIndex());
|
||||
final ImmutableOpenIntMap.Builder<java.util.List<IndicesShardStoresResponse.StoreStatus>> indexShardsBuilder;
|
||||
if (indexStoreStatuses == null) {
|
||||
indexShardsBuilder = ImmutableOpenIntMap.builder();
|
||||
} else {
|
||||
indexShardsBuilder = ImmutableOpenIntMap.builder(indexStoreStatuses);
|
||||
}
|
||||
java.util.List<IndicesShardStoresResponse.StoreStatus> storeStatuses = indexShardsBuilder.get(fetchResponse.shardId.id());
|
||||
if (storeStatuses == null) {
|
||||
storeStatuses = new ArrayList<>();
|
||||
}
|
||||
for (NodeGatewayStartedShards response : fetchResponse.responses) {
|
||||
if (shardExistsInNode(response)) {
|
||||
IndicesShardStoresResponse.StoreStatus.Allocation allocation = getAllocation(fetchResponse.shardId.getIndex(), fetchResponse.shardId.id(), response.getNode());
|
||||
storeStatuses.add(new IndicesShardStoresResponse.StoreStatus(response.getNode(), response.version(), allocation, response.storeException()));
|
||||
}
|
||||
}
|
||||
CollectionUtil.timSort(storeStatuses);
|
||||
indexShardsBuilder.put(fetchResponse.shardId.id(), storeStatuses);
|
||||
indicesStoreStatusesBuilder.put(fetchResponse.shardId.getIndex(), indexShardsBuilder.build());
|
||||
for (FailedNodeException failure : fetchResponse.failures) {
|
||||
failureBuilder.add(new IndicesShardStoresResponse.Failure(failure.nodeId(), fetchResponse.shardId.getIndex(), fetchResponse.shardId.id(), failure.getCause()));
|
||||
}
|
||||
}
|
||||
listener.onResponse(new IndicesShardStoresResponse(indicesStoreStatusesBuilder.build(), failureBuilder.build()));
|
||||
}
|
||||
|
||||
private IndicesShardStoresResponse.StoreStatus.Allocation getAllocation(String index, int shardID, DiscoveryNode node) {
|
||||
for (ShardRouting shardRouting : routingNodes.node(node.id())) {
|
||||
ShardId shardId = shardRouting.shardId();
|
||||
if (shardId.id() == shardID && shardId.getIndex().equals(index)) {
|
||||
if (shardRouting.primary()) {
|
||||
return IndicesShardStoresResponse.StoreStatus.Allocation.PRIMARY;
|
||||
} else if (shardRouting.assignedToNode()) {
|
||||
return IndicesShardStoresResponse.StoreStatus.Allocation.REPLICA;
|
||||
} else {
|
||||
return IndicesShardStoresResponse.StoreStatus.Allocation.UNUSED;
|
||||
}
|
||||
}
|
||||
}
|
||||
return IndicesShardStoresResponse.StoreStatus.Allocation.UNUSED;
|
||||
}
|
||||
|
||||
/**
|
||||
* A shard exists/existed in a node only if shard state file exists in the node
|
||||
*/
|
||||
private boolean shardExistsInNode(final NodeGatewayStartedShards response) {
|
||||
return response.storeException() != null || response.version() != -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void reroute(ShardId shardId, String reason) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
public class Response {
|
||||
private final ShardId shardId;
|
||||
private final NodeGatewayStartedShards[] responses;
|
||||
private final FailedNodeException[] failures;
|
||||
|
||||
public Response(ShardId shardId, NodeGatewayStartedShards[] responses, FailedNodeException[] failures) {
|
||||
this.shardId = shardId;
|
||||
this.responses = responses;
|
||||
this.failures = failures;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -30,6 +30,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
|
@ -37,9 +38,9 @@ import org.elasticsearch.common.io.stream.StreamInput;
|
|||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.IndexService;
|
||||
import org.elasticsearch.index.IndexShardMissingException;
|
||||
import org.elasticsearch.index.shard.IndexShard;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.index.shard.ShardNotFoundException;
|
||||
import org.elasticsearch.indices.IndicesService;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
@ -57,9 +58,10 @@ public class TransportIndicesStatsAction extends TransportBroadcastAction<Indice
|
|||
private final IndicesService indicesService;
|
||||
|
||||
@Inject
|
||||
public TransportIndicesStatsAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService,
|
||||
IndicesService indicesService, ActionFilters actionFilters) {
|
||||
super(settings, IndicesStatsAction.NAME, threadPool, clusterService, transportService, actionFilters,
|
||||
public TransportIndicesStatsAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
|
||||
TransportService transportService, IndicesService indicesService,
|
||||
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, IndicesStatsAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
|
||||
IndicesStatsRequest.class, IndexShardStatsRequest.class, ThreadPool.Names.MANAGEMENT);
|
||||
this.indicesService = indicesService;
|
||||
}
|
||||
|
@ -123,7 +125,7 @@ public class TransportIndicesStatsAction extends TransportBroadcastAction<Indice
|
|||
IndexShard indexShard = indexService.shardSafe(request.shardId().id());
|
||||
// if we don't have the routing entry yet, we need it stats wise, we treat it as if the shard is not ready yet
|
||||
if (indexShard.routingEntry() == null) {
|
||||
throw new IndexShardMissingException(indexShard.shardId());
|
||||
throw new ShardNotFoundException(indexShard.shardId());
|
||||
}
|
||||
|
||||
CommonStatsFlags flags = new CommonStatsFlags().clear();
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.MetaDataIndexTemplateService;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -40,8 +41,9 @@ public class TransportDeleteIndexTemplateAction extends TransportMasterNodeActio
|
|||
|
||||
@Inject
|
||||
public TransportDeleteIndexTemplateAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, MetaDataIndexTemplateService indexTemplateService, ActionFilters actionFilters) {
|
||||
super(settings, DeleteIndexTemplateAction.NAME, transportService, clusterService, threadPool, actionFilters, DeleteIndexTemplateRequest.class);
|
||||
ThreadPool threadPool, MetaDataIndexTemplateService indexTemplateService,
|
||||
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, DeleteIndexTemplateAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, DeleteIndexTemplateRequest.class);
|
||||
this.indexTemplateService = indexTemplateService;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateMetaData;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.regex.Regex;
|
||||
|
@ -42,8 +43,9 @@ import java.util.List;
|
|||
public class TransportGetIndexTemplatesAction extends TransportMasterNodeReadAction<GetIndexTemplatesRequest, GetIndexTemplatesResponse> {
|
||||
|
||||
@Inject
|
||||
public TransportGetIndexTemplatesAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters) {
|
||||
super(settings, GetIndexTemplatesAction.NAME, transportService, clusterService, threadPool, actionFilters, GetIndexTemplatesRequest.class);
|
||||
public TransportGetIndexTemplatesAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, GetIndexTemplatesAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, GetIndexTemplatesRequest.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.MetaDataIndexTemplateService;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -40,8 +41,9 @@ public class TransportPutIndexTemplateAction extends TransportMasterNodeAction<P
|
|||
|
||||
@Inject
|
||||
public TransportPutIndexTemplateAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, MetaDataIndexTemplateService indexTemplateService, ActionFilters actionFilters) {
|
||||
super(settings, PutIndexTemplateAction.NAME, transportService, clusterService, threadPool, actionFilters, PutIndexTemplateRequest.class);
|
||||
ThreadPool threadPool, MetaDataIndexTemplateService indexTemplateService,
|
||||
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, PutIndexTemplateAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, PutIndexTemplateRequest.class);
|
||||
this.indexTemplateService = indexTemplateService;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
|
@ -56,8 +57,8 @@ public class TransportUpgradeStatusAction extends TransportBroadcastAction<Upgra
|
|||
|
||||
@Inject
|
||||
public TransportUpgradeStatusAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService,
|
||||
IndicesService indicesService, ActionFilters actionFilters) {
|
||||
super(settings, UpgradeStatusAction.NAME, threadPool, clusterService, transportService, actionFilters,
|
||||
IndicesService indicesService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, UpgradeStatusAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
|
||||
UpgradeStatusRequest.class, IndexShardUpgradeStatusRequest.class, ThreadPool.Names.MANAGEMENT);
|
||||
this.indicesService = indicesService;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
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.common.inject.Inject;
|
||||
|
@ -61,8 +62,8 @@ public class TransportUpgradeAction extends TransportBroadcastAction<UpgradeRequ
|
|||
@Inject
|
||||
public TransportUpgradeAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
|
||||
TransportService transportService, IndicesService indicesService, ActionFilters actionFilters,
|
||||
TransportUpgradeSettingsAction upgradeSettingsAction) {
|
||||
super(settings, UpgradeAction.NAME, threadPool, clusterService, transportService, actionFilters,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver, TransportUpgradeSettingsAction upgradeSettingsAction) {
|
||||
super(settings, UpgradeAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
|
||||
UpgradeRequest.class, ShardUpgradeRequest.class, ThreadPool.Names.OPTIMIZE);
|
||||
this.indicesService = indicesService;
|
||||
this.upgradeSettingsAction = upgradeSettingsAction;
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.cluster.ClusterState;
|
|||
import org.elasticsearch.cluster.ack.ClusterStateUpdateResponse;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.MetaDataUpdateSettingsService;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -42,8 +43,8 @@ public class TransportUpgradeSettingsAction extends TransportMasterNodeAction<Up
|
|||
|
||||
@Inject
|
||||
public TransportUpgradeSettingsAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
|
||||
MetaDataUpdateSettingsService updateSettingsService, ActionFilters actionFilters) {
|
||||
super(settings, UpgradeSettingsAction.NAME, transportService, clusterService, threadPool, actionFilters, UpgradeSettingsRequest.class);
|
||||
MetaDataUpdateSettingsService updateSettingsService, IndexNameExpressionResolver indexNameExpressionResolver, ActionFilters actionFilters) {
|
||||
super(settings, UpgradeSettingsAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, UpgradeSettingsRequest.class);
|
||||
this.updateSettingsService = updateSettingsService;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
|
@ -45,6 +46,7 @@ import org.elasticsearch.index.query.QueryParsingException;
|
|||
import org.elasticsearch.index.shard.IndexShard;
|
||||
import org.elasticsearch.indices.IndicesService;
|
||||
import org.elasticsearch.script.ScriptService;
|
||||
import org.elasticsearch.search.SearchService;
|
||||
import org.elasticsearch.search.internal.DefaultSearchContext;
|
||||
import org.elasticsearch.search.internal.SearchContext;
|
||||
import org.elasticsearch.search.internal.ShardSearchLocalRequest;
|
||||
|
@ -74,9 +76,12 @@ public class TransportValidateQueryAction extends TransportBroadcastAction<Valid
|
|||
private final BigArrays bigArrays;
|
||||
|
||||
@Inject
|
||||
public TransportValidateQueryAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, IndicesService indicesService, ScriptService scriptService, PageCacheRecycler pageCacheRecycler, BigArrays bigArrays, ActionFilters actionFilters) {
|
||||
public TransportValidateQueryAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
|
||||
TransportService transportService, IndicesService indicesService,
|
||||
ScriptService scriptService, PageCacheRecycler pageCacheRecycler,
|
||||
BigArrays bigArrays, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, ValidateQueryAction.NAME, threadPool, clusterService, transportService, actionFilters,
|
||||
ValidateQueryRequest.class, ShardValidateQueryRequest.class, ThreadPool.Names.SEARCH);
|
||||
indexNameExpressionResolver, ValidateQueryRequest.class, ShardValidateQueryRequest.class, ThreadPool.Names.SEARCH);
|
||||
this.indicesService = indicesService;
|
||||
this.scriptService = scriptService;
|
||||
this.pageCacheRecycler = pageCacheRecycler;
|
||||
|
@ -91,7 +96,7 @@ public class TransportValidateQueryAction extends TransportBroadcastAction<Valid
|
|||
|
||||
@Override
|
||||
protected ShardValidateQueryRequest newShardRequest(int numShards, ShardRouting shard, ValidateQueryRequest request) {
|
||||
String[] filteringAliases = clusterService.state().metaData().filteringAliases(shard.index(), request.indices());
|
||||
String[] filteringAliases = indexNameExpressionResolver.filteringAliases(clusterService.state(), shard.index(), request.indices());
|
||||
return new ShardValidateQueryRequest(shard.shardId(), filteringAliases, request);
|
||||
}
|
||||
|
||||
|
@ -103,8 +108,8 @@ public class TransportValidateQueryAction extends TransportBroadcastAction<Valid
|
|||
@Override
|
||||
protected GroupShardsIterator shards(ClusterState clusterState, ValidateQueryRequest request, String[] concreteIndices) {
|
||||
// Hard-code routing to limit request to a single shard, but still, randomize it...
|
||||
Map<String, Set<String>> routingMap = clusterState.metaData().resolveSearchRouting(Integer.toString(ThreadLocalRandom.current().nextInt(1000)), request.indices());
|
||||
return clusterService.operationRouting().searchShards(clusterState, request.indices(), concreteIndices, routingMap, "_local");
|
||||
Map<String, Set<String>> routingMap = indexNameExpressionResolver.resolveSearchRouting(clusterState, Integer.toString(ThreadLocalRandom.current().nextInt(1000)), request.indices());
|
||||
return clusterService.operationRouting().searchShards(clusterState, concreteIndices, routingMap, "_local");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -168,7 +173,8 @@ public class TransportValidateQueryAction extends TransportBroadcastAction<Valid
|
|||
DefaultSearchContext searchContext = new DefaultSearchContext(0,
|
||||
new ShardSearchLocalRequest(request.types(), request.nowInMillis(), request.filteringAliases()),
|
||||
null, searcher, indexService, indexShard,
|
||||
scriptService, pageCacheRecycler, bigArrays, threadPool.estimatedTimeInMillisCounter(), parseFieldMatcher
|
||||
scriptService, pageCacheRecycler, bigArrays, threadPool.estimatedTimeInMillisCounter(), parseFieldMatcher,
|
||||
SearchService.NO_TIMEOUT
|
||||
);
|
||||
SearchContext.setCurrent(searchContext);
|
||||
try {
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.action.admin.indices.validate.template;
|
|||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.support.ActionFilters;
|
||||
import org.elasticsearch.action.support.HandledTransportAction;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -38,8 +39,8 @@ public class TransportRenderSearchTemplateAction extends HandledTransportAction<
|
|||
|
||||
@Inject
|
||||
protected TransportRenderSearchTemplateAction(ScriptService scriptService, Settings settings, ThreadPool threadPool,
|
||||
TransportService transportService, ActionFilters actionFilters) {
|
||||
super(settings, RenderSearchTemplateAction.NAME, threadPool, transportService, actionFilters, RenderSearchTemplateRequest.class);
|
||||
TransportService transportService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, RenderSearchTemplateAction.NAME, threadPool, transportService, actionFilters, indexNameExpressionResolver, RenderSearchTemplateRequest.class);
|
||||
this.scriptService = scriptService;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,12 +28,12 @@ import org.elasticsearch.cluster.ClusterState;
|
|||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.regex.Regex;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.indices.IndexMissingException;
|
||||
import org.elasticsearch.index.IndexNotFoundException;
|
||||
import org.elasticsearch.search.warmer.IndexWarmerMissingException;
|
||||
import org.elasticsearch.search.warmer.IndexWarmersMetaData;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
|
@ -50,8 +50,9 @@ import java.util.List;
|
|||
public class TransportDeleteWarmerAction extends TransportMasterNodeAction<DeleteWarmerRequest, DeleteWarmerResponse> {
|
||||
|
||||
@Inject
|
||||
public TransportDeleteWarmerAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters) {
|
||||
super(settings, DeleteWarmerAction.NAME, transportService, clusterService, threadPool, actionFilters, DeleteWarmerRequest.class);
|
||||
public TransportDeleteWarmerAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, DeleteWarmerAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, DeleteWarmerRequest.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -67,12 +68,12 @@ public class TransportDeleteWarmerAction extends TransportMasterNodeAction<Delet
|
|||
|
||||
@Override
|
||||
protected ClusterBlockException checkBlock(DeleteWarmerRequest request, ClusterState state) {
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_WRITE, clusterService.state().metaData().concreteIndices(request.indicesOptions(), request.indices()));
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_WRITE, indexNameExpressionResolver.concreteIndices(state, request));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void masterOperation(final DeleteWarmerRequest request, final ClusterState state, final ActionListener<DeleteWarmerResponse> listener) {
|
||||
final String[] concreteIndices = clusterService.state().metaData().concreteIndices(request.indicesOptions(), request.indices());
|
||||
final String[] concreteIndices = indexNameExpressionResolver.concreteIndices(state, request);
|
||||
clusterService.submitStateUpdateTask("delete_warmer [" + Arrays.toString(request.names()) + "]", new AckedClusterStateUpdateTask<DeleteWarmerResponse>(request, listener) {
|
||||
|
||||
@Override
|
||||
|
@ -94,7 +95,7 @@ public class TransportDeleteWarmerAction extends TransportMasterNodeAction<Delet
|
|||
for (String index : concreteIndices) {
|
||||
IndexMetaData indexMetaData = currentState.metaData().index(index);
|
||||
if (indexMetaData == null) {
|
||||
throw new IndexMissingException(new Index(index));
|
||||
throw new IndexNotFoundException(index);
|
||||
}
|
||||
IndexWarmersMetaData warmers = indexMetaData.custom(IndexWarmersMetaData.TYPE);
|
||||
if (warmers != null) {
|
||||
|
@ -130,7 +131,7 @@ public class TransportDeleteWarmerAction extends TransportMasterNodeAction<Delet
|
|||
for (String index : concreteIndices) {
|
||||
IndexMetaData indexMetaData = currentState.metaData().index(index);
|
||||
if (indexMetaData == null) {
|
||||
throw new IndexMissingException(new Index(index));
|
||||
throw new IndexNotFoundException(index);
|
||||
}
|
||||
IndexWarmersMetaData warmers = indexMetaData.custom(IndexWarmersMetaData.TYPE);
|
||||
if (warmers != null) {
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -42,8 +43,9 @@ import org.elasticsearch.transport.TransportService;
|
|||
public class TransportGetWarmersAction extends TransportClusterInfoAction<GetWarmersRequest, GetWarmersResponse> {
|
||||
|
||||
@Inject
|
||||
public TransportGetWarmersAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters) {
|
||||
super(settings, GetWarmersAction.NAME, transportService, clusterService, threadPool, actionFilters, GetWarmersRequest.class);
|
||||
public TransportGetWarmersAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, GetWarmersAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, GetWarmersRequest.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -54,7 +56,7 @@ public class TransportGetWarmersAction extends TransportClusterInfoAction<GetWar
|
|||
|
||||
@Override
|
||||
protected ClusterBlockException checkBlock(GetWarmersRequest request, ClusterState state) {
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, state.metaData().concreteIndices(request.indicesOptions(), request.indices()));
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, indexNameExpressionResolver.concreteIndices(state, request));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -32,12 +32,12 @@ import org.elasticsearch.cluster.ClusterState;
|
|||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.indices.IndexMissingException;
|
||||
import org.elasticsearch.index.IndexNotFoundException;
|
||||
import org.elasticsearch.search.warmer.IndexWarmersMetaData;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
@ -57,8 +57,8 @@ public class TransportPutWarmerAction extends TransportMasterNodeAction<PutWarme
|
|||
|
||||
@Inject
|
||||
public TransportPutWarmerAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
|
||||
TransportSearchAction searchAction, ActionFilters actionFilters) {
|
||||
super(settings, PutWarmerAction.NAME, transportService, clusterService, threadPool, actionFilters, PutWarmerRequest.class);
|
||||
TransportSearchAction searchAction, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, PutWarmerAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, PutWarmerRequest.class);
|
||||
this.searchAction = searchAction;
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class TransportPutWarmerAction extends TransportMasterNodeAction<PutWarme
|
|||
|
||||
@Override
|
||||
protected ClusterBlockException checkBlock(PutWarmerRequest request, ClusterState state) {
|
||||
String[] concreteIndices = clusterService.state().metaData().concreteIndices(request.searchRequest().indicesOptions(), request.searchRequest().indices());
|
||||
String[] concreteIndices = indexNameExpressionResolver.concreteIndices(state, request);
|
||||
ClusterBlockException status = state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_WRITE, concreteIndices);
|
||||
if (status != null) {
|
||||
return status;
|
||||
|
@ -112,7 +112,7 @@ public class TransportPutWarmerAction extends TransportMasterNodeAction<PutWarme
|
|||
@Override
|
||||
public ClusterState execute(ClusterState currentState) {
|
||||
MetaData metaData = currentState.metaData();
|
||||
String[] concreteIndices = metaData.concreteIndices(request.searchRequest().indicesOptions(), request.searchRequest().indices());
|
||||
String[] concreteIndices = indexNameExpressionResolver.concreteIndices(currentState, request.searchRequest().indicesOptions(), request.searchRequest().indices());
|
||||
|
||||
BytesReference source = null;
|
||||
if (request.searchRequest().source() != null && request.searchRequest().source().length() > 0) {
|
||||
|
@ -127,7 +127,7 @@ public class TransportPutWarmerAction extends TransportMasterNodeAction<PutWarme
|
|||
for (String index : concreteIndices) {
|
||||
IndexMetaData indexMetaData = metaData.index(index);
|
||||
if (indexMetaData == null) {
|
||||
throw new IndexMissingException(new Index(index));
|
||||
throw new IndexNotFoundException(index);
|
||||
}
|
||||
IndexWarmersMetaData warmers = indexMetaData.custom(IndexWarmersMetaData.TYPE);
|
||||
if (warmers == null) {
|
||||
|
|
|
@ -36,12 +36,12 @@ import org.elasticsearch.action.index.IndexRequest;
|
|||
import org.elasticsearch.action.support.ActionFilters;
|
||||
import org.elasticsearch.action.support.AutoCreateIndex;
|
||||
import org.elasticsearch.action.support.HandledTransportAction;
|
||||
import org.elasticsearch.action.support.IndicesOptions;
|
||||
import org.elasticsearch.action.update.UpdateRequest;
|
||||
import org.elasticsearch.cluster.ClusterService;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.MappingMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
||||
|
@ -50,10 +50,10 @@ import org.elasticsearch.common.inject.Inject;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.concurrent.AtomicArray;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.IndexNotFoundException;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.indices.IndexAlreadyExistsException;
|
||||
import org.elasticsearch.indices.IndexClosedException;
|
||||
import org.elasticsearch.indices.IndexMissingException;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
|
@ -73,8 +73,9 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
|||
|
||||
@Inject
|
||||
public TransportBulkAction(Settings settings, ThreadPool threadPool, TransportService transportService, ClusterService clusterService,
|
||||
TransportShardBulkAction shardBulkAction, TransportCreateIndexAction createIndexAction, ActionFilters actionFilters) {
|
||||
super(settings, BulkAction.NAME, threadPool, transportService, actionFilters, BulkRequest.class);
|
||||
TransportShardBulkAction shardBulkAction, TransportCreateIndexAction createIndexAction,
|
||||
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, BulkAction.NAME, threadPool, transportService, actionFilters, indexNameExpressionResolver, BulkRequest.class);
|
||||
this.clusterService = clusterService;
|
||||
this.shardBulkAction = shardBulkAction;
|
||||
this.createIndexAction = createIndexAction;
|
||||
|
@ -204,7 +205,7 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
|||
// TODO use timeout to wait here if its blocked...
|
||||
clusterState.blocks().globalBlockedRaiseException(ClusterBlockLevel.WRITE);
|
||||
|
||||
final ConcreteIndices concreteIndices = new ConcreteIndices(clusterState.metaData());
|
||||
final ConcreteIndices concreteIndices = new ConcreteIndices(clusterState, indexNameExpressionResolver);
|
||||
MetaData metaData = clusterState.metaData();
|
||||
for (int i = 0; i < bulkRequest.requests.size(); i++) {
|
||||
ActionRequest request = bulkRequest.requests.get(i);
|
||||
|
@ -215,7 +216,7 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
|||
continue;
|
||||
}
|
||||
|
||||
String concreteIndex = concreteIndices.resolveIfAbsent(req.index(), req.indicesOptions());
|
||||
String concreteIndex = concreteIndices.resolveIfAbsent(req);
|
||||
if (request instanceof IndexRequest) {
|
||||
IndexRequest indexRequest = (IndexRequest) request;
|
||||
MappingMetaData mappingMd = null;
|
||||
|
@ -232,7 +233,7 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
|||
bulkRequest.requests.set(i, null);
|
||||
}
|
||||
} else {
|
||||
concreteIndices.resolveIfAbsent(req.index(), req.indicesOptions());
|
||||
concreteIndices.resolveIfAbsent(req);
|
||||
req.routing(clusterState.metaData().resolveIndexRouting(req.routing(), req.index()));
|
||||
}
|
||||
}
|
||||
|
@ -361,13 +362,11 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
|||
Exception unavailableException = null;
|
||||
if (concreteIndex == null) {
|
||||
try {
|
||||
concreteIndex = concreteIndices.resolveIfAbsent(request.index(), request.indicesOptions());
|
||||
} catch (IndexClosedException ice) {
|
||||
unavailableException = ice;
|
||||
} catch (IndexMissingException ime) {
|
||||
concreteIndex = concreteIndices.resolveIfAbsent(request);
|
||||
} catch (IndexClosedException | IndexNotFoundException ex) {
|
||||
// Fix for issue where bulk request references an index that
|
||||
// cannot be auto-created see issue #8125
|
||||
unavailableException = ime;
|
||||
unavailableException = ex;
|
||||
}
|
||||
}
|
||||
if (unavailableException == null) {
|
||||
|
@ -398,22 +397,24 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
|||
|
||||
|
||||
private static class ConcreteIndices {
|
||||
private final ClusterState state;
|
||||
private final IndexNameExpressionResolver indexNameExpressionResolver;
|
||||
private final Map<String, String> indices = new HashMap<>();
|
||||
private final MetaData metaData;
|
||||
|
||||
ConcreteIndices(MetaData metaData) {
|
||||
this.metaData = metaData;
|
||||
ConcreteIndices(ClusterState state, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
this.state = state;
|
||||
this.indexNameExpressionResolver = indexNameExpressionResolver;
|
||||
}
|
||||
|
||||
String getConcreteIndex(String indexOrAlias) {
|
||||
return indices.get(indexOrAlias);
|
||||
}
|
||||
|
||||
String resolveIfAbsent(String indexOrAlias, IndicesOptions indicesOptions) {
|
||||
String concreteIndex = indices.get(indexOrAlias);
|
||||
String resolveIfAbsent(DocumentRequest request) {
|
||||
String concreteIndex = indices.get(request.index());
|
||||
if (concreteIndex == null) {
|
||||
concreteIndex = metaData.concreteSingleIndex(indexOrAlias, indicesOptions);
|
||||
indices.put(indexOrAlias, concreteIndex);
|
||||
concreteIndex = indexNameExpressionResolver.concreteSingleIndex(state, request);
|
||||
indices.put(request.index(), concreteIndex);
|
||||
}
|
||||
return concreteIndex;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.action.index.MappingUpdatedAction;
|
||||
import org.elasticsearch.cluster.action.shard.ShardStateAction;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.MappingMetaData;
|
||||
import org.elasticsearch.cluster.routing.ShardIterator;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
|
@ -78,9 +79,10 @@ public class TransportShardBulkAction extends TransportReplicationAction<BulkSha
|
|||
@Inject
|
||||
public TransportShardBulkAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
IndicesService indicesService, ThreadPool threadPool, ShardStateAction shardStateAction,
|
||||
MappingUpdatedAction mappingUpdatedAction, UpdateHelper updateHelper, ActionFilters actionFilters) {
|
||||
MappingUpdatedAction mappingUpdatedAction, UpdateHelper updateHelper, ActionFilters actionFilters,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, ACTION_NAME, transportService, clusterService, indicesService, threadPool, shardStateAction, mappingUpdatedAction,
|
||||
actionFilters,
|
||||
actionFilters, indexNameExpressionResolver,
|
||||
BulkShardRequest.class, BulkShardRequest.class, ThreadPool.Names.BULK);
|
||||
this.updateHelper = updateHelper;
|
||||
this.allowIdGeneration = settings.getAsBoolean("action.allow_id_generation", true);
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.action.index.MappingUpdatedAction;
|
||||
import org.elasticsearch.cluster.action.shard.ShardStateAction;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.MappingMetaData;
|
||||
import org.elasticsearch.cluster.routing.ShardIterator;
|
||||
import org.elasticsearch.common.collect.Tuple;
|
||||
|
@ -59,9 +60,9 @@ public class TransportDeleteAction extends TransportReplicationAction<DeleteRequ
|
|||
public TransportDeleteAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
IndicesService indicesService, ThreadPool threadPool, ShardStateAction shardStateAction,
|
||||
TransportCreateIndexAction createIndexAction, ActionFilters actionFilters,
|
||||
MappingUpdatedAction mappingUpdatedAction) {
|
||||
IndexNameExpressionResolver indexNameExpressionResolver, MappingUpdatedAction mappingUpdatedAction) {
|
||||
super(settings, DeleteAction.NAME, transportService, clusterService, indicesService, threadPool, shardStateAction,
|
||||
mappingUpdatedAction, actionFilters,
|
||||
mappingUpdatedAction, actionFilters, indexNameExpressionResolver,
|
||||
DeleteRequest.class, DeleteRequest.class, ThreadPool.Names.INDEX);
|
||||
this.createIndexAction = createIndexAction;
|
||||
this.autoCreateIndex = new AutoCreateIndex(settings);
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
||||
import org.elasticsearch.cluster.routing.ShardIterator;
|
||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||
|
@ -44,6 +45,7 @@ import org.elasticsearch.index.query.QueryParseContext;
|
|||
import org.elasticsearch.index.shard.IndexShard;
|
||||
import org.elasticsearch.indices.IndicesService;
|
||||
import org.elasticsearch.script.ScriptService;
|
||||
import org.elasticsearch.search.SearchService;
|
||||
import org.elasticsearch.search.SearchShardTarget;
|
||||
import org.elasticsearch.search.internal.DefaultSearchContext;
|
||||
import org.elasticsearch.search.internal.SearchContext;
|
||||
|
@ -71,8 +73,9 @@ public class TransportExistsAction extends TransportBroadcastAction<ExistsReques
|
|||
@Inject
|
||||
public TransportExistsAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService,
|
||||
IndicesService indicesService, ScriptService scriptService,
|
||||
PageCacheRecycler pageCacheRecycler, BigArrays bigArrays, ActionFilters actionFilters) {
|
||||
super(settings, ExistsAction.NAME, threadPool, clusterService, transportService, actionFilters,
|
||||
PageCacheRecycler pageCacheRecycler, BigArrays bigArrays, ActionFilters actionFilters,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, ExistsAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
|
||||
ExistsRequest.class, ShardExistsRequest.class, ThreadPool.Names.SEARCH);
|
||||
this.indicesService = indicesService;
|
||||
this.scriptService = scriptService;
|
||||
|
@ -88,7 +91,7 @@ public class TransportExistsAction extends TransportBroadcastAction<ExistsReques
|
|||
|
||||
@Override
|
||||
protected ShardExistsRequest newShardRequest(int numShards, ShardRouting shard, ExistsRequest request) {
|
||||
String[] filteringAliases = clusterService.state().metaData().filteringAliases(shard.index(), request.indices());
|
||||
String[] filteringAliases = indexNameExpressionResolver.filteringAliases(clusterService.state(), shard.index(), request.indices());
|
||||
return new ShardExistsRequest(shard.shardId(), filteringAliases, request);
|
||||
}
|
||||
|
||||
|
@ -99,8 +102,8 @@ public class TransportExistsAction extends TransportBroadcastAction<ExistsReques
|
|||
|
||||
@Override
|
||||
protected GroupShardsIterator shards(ClusterState clusterState, ExistsRequest request, String[] concreteIndices) {
|
||||
Map<String, Set<String>> routingMap = clusterState.metaData().resolveSearchRouting(request.routing(), request.indices());
|
||||
return clusterService.operationRouting().searchShards(clusterState, request.indices(), concreteIndices, routingMap, request.preference());
|
||||
Map<String, Set<String>> routingMap = indexNameExpressionResolver.resolveSearchRouting(clusterState, request.routing(), request.indices());
|
||||
return clusterService.operationRouting().searchShards(clusterState, concreteIndices, routingMap, request.preference());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -151,7 +154,9 @@ public class TransportExistsAction extends TransportBroadcastAction<ExistsReques
|
|||
SearchContext context = new DefaultSearchContext(0,
|
||||
new ShardSearchLocalRequest(request.types(), request.nowInMillis(), request.filteringAliases()),
|
||||
shardTarget, indexShard.acquireSearcher("exists"), indexService, indexShard,
|
||||
scriptService, pageCacheRecycler, bigArrays, threadPool.estimatedTimeInMillisCounter(), parseFieldMatcher);
|
||||
scriptService, pageCacheRecycler, bigArrays, threadPool.estimatedTimeInMillisCounter(), parseFieldMatcher,
|
||||
SearchService.NO_TIMEOUT
|
||||
);
|
||||
SearchContext.setCurrent(context);
|
||||
|
||||
try {
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.elasticsearch.action.support.single.shard.TransportSingleShardAction;
|
|||
import org.elasticsearch.cache.recycler.PageCacheRecycler;
|
||||
import org.elasticsearch.cluster.ClusterService;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.routing.ShardIterator;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -42,6 +43,7 @@ import org.elasticsearch.index.shard.IndexShard;
|
|||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.indices.IndicesService;
|
||||
import org.elasticsearch.script.ScriptService;
|
||||
import org.elasticsearch.search.SearchService;
|
||||
import org.elasticsearch.search.internal.DefaultSearchContext;
|
||||
import org.elasticsearch.search.internal.SearchContext;
|
||||
import org.elasticsearch.search.internal.ShardSearchLocalRequest;
|
||||
|
@ -70,8 +72,8 @@ public class TransportExplainAction extends TransportSingleShardAction<ExplainRe
|
|||
public TransportExplainAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
|
||||
TransportService transportService, IndicesService indicesService,
|
||||
ScriptService scriptService, PageCacheRecycler pageCacheRecycler,
|
||||
BigArrays bigArrays, ActionFilters actionFilters) {
|
||||
super(settings, ExplainAction.NAME, threadPool, clusterService, transportService, actionFilters,
|
||||
BigArrays bigArrays, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, ExplainAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
|
||||
ExplainRequest.class, ThreadPool.Names.GET);
|
||||
this.indicesService = indicesService;
|
||||
this.scriptService = scriptService;
|
||||
|
@ -92,7 +94,7 @@ public class TransportExplainAction extends TransportSingleShardAction<ExplainRe
|
|||
|
||||
@Override
|
||||
protected void resolveRequest(ClusterState state, InternalRequest request) {
|
||||
request.request().filteringAlias(state.metaData().filteringAliases(request.concreteIndex(), request.request().index()));
|
||||
request.request().filteringAlias(indexNameExpressionResolver.filteringAliases(state, request.concreteIndex(), request.request().index()));
|
||||
// Fail fast on the node that received the request.
|
||||
if (request.request().routing() == null && state.getMetaData().routingRequired(request.concreteIndex(), request.request().type())) {
|
||||
throw new RoutingMissingException(request.concreteIndex(), request.request().type(), request.request().id());
|
||||
|
@ -113,7 +115,8 @@ public class TransportExplainAction extends TransportSingleShardAction<ExplainRe
|
|||
0, new ShardSearchLocalRequest(new String[]{request.type()}, request.nowInMillis, request.filteringAlias()),
|
||||
null, result.searcher(), indexService, indexShard,
|
||||
scriptService, pageCacheRecycler,
|
||||
bigArrays, threadPool.estimatedTimeInMillisCounter(), parseFieldMatcher
|
||||
bigArrays, threadPool.estimatedTimeInMillisCounter(), parseFieldMatcher,
|
||||
SearchService.NO_TIMEOUT
|
||||
);
|
||||
SearchContext.setCurrent(context);
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
|
@ -55,8 +56,10 @@ public class TransportFieldStatsTransportAction extends TransportBroadcastAction
|
|||
private final IndicesService indicesService;
|
||||
|
||||
@Inject
|
||||
public TransportFieldStatsTransportAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, ActionFilters actionFilters, IndicesService indicesService) {
|
||||
super(settings, FieldStatsAction.NAME, threadPool, clusterService, transportService, actionFilters, FieldStatsRequest.class, FieldStatsShardRequest.class, ThreadPool.Names.MANAGEMENT);
|
||||
public TransportFieldStatsTransportAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
|
||||
TransportService transportService, ActionFilters actionFilters,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver, IndicesService indicesService) {
|
||||
super(settings, FieldStatsAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver, FieldStatsRequest.class, FieldStatsShardRequest.class, ThreadPool.Names.MANAGEMENT);
|
||||
this.indicesService = indicesService;
|
||||
}
|
||||
|
||||
|
@ -171,7 +174,7 @@ public class TransportFieldStatsTransportAction extends TransportBroadcastAction
|
|||
|
||||
@Override
|
||||
protected GroupShardsIterator shards(ClusterState clusterState, FieldStatsRequest request, String[] concreteIndices) {
|
||||
return clusterService.operationRouting().searchShards(clusterState, request.indices(), concreteIndices, null, null);
|
||||
return clusterService.operationRouting().searchShards(clusterState, concreteIndices, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,7 +20,9 @@
|
|||
package org.elasticsearch.action.get;
|
||||
|
||||
import com.google.common.collect.Iterators;
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.action.ActionResponse;
|
||||
import org.elasticsearch.action.percolate.PercolateResponse;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.io.stream.Streamable;
|
||||
|
@ -29,6 +31,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
|||
import org.elasticsearch.common.xcontent.XContentBuilderString;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class MultiGetResponse extends ActionResponse implements Iterable<MultiGetItemResponse>, ToXContent {
|
||||
|
@ -40,17 +43,17 @@ public class MultiGetResponse extends ActionResponse implements Iterable<MultiGe
|
|||
private String index;
|
||||
private String type;
|
||||
private String id;
|
||||
private String message;
|
||||
private Throwable throwable;
|
||||
|
||||
Failure() {
|
||||
|
||||
}
|
||||
|
||||
public Failure(String index, String type, String id, String message) {
|
||||
public Failure(String index, String type, String id, Throwable throwable) {
|
||||
this.index = index;
|
||||
this.type = type;
|
||||
this.id = id;
|
||||
this.message = message;
|
||||
this.throwable = throwable;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -78,7 +81,7 @@ public class MultiGetResponse extends ActionResponse implements Iterable<MultiGe
|
|||
* The failure message.
|
||||
*/
|
||||
public String getMessage() {
|
||||
return this.message;
|
||||
return throwable != null ? throwable.getMessage() : null;
|
||||
}
|
||||
|
||||
public static Failure readFailure(StreamInput in) throws IOException {
|
||||
|
@ -92,7 +95,7 @@ public class MultiGetResponse extends ActionResponse implements Iterable<MultiGe
|
|||
index = in.readString();
|
||||
type = in.readOptionalString();
|
||||
id = in.readString();
|
||||
message = in.readString();
|
||||
throwable = in.readThrowable();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -100,7 +103,11 @@ public class MultiGetResponse extends ActionResponse implements Iterable<MultiGe
|
|||
out.writeString(index);
|
||||
out.writeOptionalString(type);
|
||||
out.writeString(id);
|
||||
out.writeString(message);
|
||||
out.writeThrowable(throwable);
|
||||
}
|
||||
|
||||
public Throwable getFailure() {
|
||||
return throwable;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,7 +139,7 @@ public class MultiGetResponse extends ActionResponse implements Iterable<MultiGe
|
|||
builder.field(Fields._INDEX, failure.getIndex());
|
||||
builder.field(Fields._TYPE, failure.getType());
|
||||
builder.field(Fields._ID, failure.getId());
|
||||
builder.field(Fields.ERROR, failure.getMessage());
|
||||
ElasticsearchException.renderThrowable(builder, params, failure.getFailure());
|
||||
builder.endObject();
|
||||
} else {
|
||||
GetResponse getResponse = response.getResponse();
|
||||
|
@ -151,6 +158,8 @@ public class MultiGetResponse extends ActionResponse implements Iterable<MultiGe
|
|||
static final XContentBuilderString _TYPE = new XContentBuilderString("_type");
|
||||
static final XContentBuilderString _ID = new XContentBuilderString("_id");
|
||||
static final XContentBuilderString ERROR = new XContentBuilderString("error");
|
||||
static final XContentBuilderString ROOT_CAUSE = new XContentBuilderString("root_cause");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.elasticsearch.action.support.single.shard.TransportSingleShardAction;
|
|||
import org.elasticsearch.cluster.ClusterService;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.routing.Preference;
|
||||
import org.elasticsearch.cluster.routing.ShardIterator;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
|
@ -47,8 +48,9 @@ public class TransportGetAction extends TransportSingleShardAction<GetRequest, G
|
|||
|
||||
@Inject
|
||||
public TransportGetAction(Settings settings, ClusterService clusterService, TransportService transportService,
|
||||
IndicesService indicesService, ThreadPool threadPool, ActionFilters actionFilters) {
|
||||
super(settings, GetAction.NAME, threadPool, clusterService, transportService, actionFilters,
|
||||
IndicesService indicesService, ThreadPool threadPool, ActionFilters actionFilters,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, GetAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
|
||||
GetRequest.class, ThreadPool.Names.GET);
|
||||
this.indicesService = indicesService;
|
||||
|
||||
|
|
|
@ -26,9 +26,11 @@ import org.elasticsearch.action.support.HandledTransportAction;
|
|||
import org.elasticsearch.cluster.ClusterService;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.concurrent.AtomicArray;
|
||||
import org.elasticsearch.index.IndexNotFoundException;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
@ -44,8 +46,10 @@ public class TransportMultiGetAction extends HandledTransportAction<MultiGetRequ
|
|||
private final TransportShardMultiGetAction shardAction;
|
||||
|
||||
@Inject
|
||||
public TransportMultiGetAction(Settings settings, ThreadPool threadPool, TransportService transportService, ClusterService clusterService, TransportShardMultiGetAction shardAction, ActionFilters actionFilters) {
|
||||
super(settings, MultiGetAction.NAME, threadPool, transportService, actionFilters, MultiGetRequest.class);
|
||||
public TransportMultiGetAction(Settings settings, ThreadPool threadPool, TransportService transportService,
|
||||
ClusterService clusterService, TransportShardMultiGetAction shardAction,
|
||||
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, MultiGetAction.NAME, threadPool, transportService, actionFilters, indexNameExpressionResolver, MultiGetRequest.class);
|
||||
this.clusterService = clusterService;
|
||||
this.shardAction = shardAction;
|
||||
}
|
||||
|
@ -62,14 +66,14 @@ public class TransportMultiGetAction extends HandledTransportAction<MultiGetRequ
|
|||
for (int i = 0; i < request.items.size(); i++) {
|
||||
MultiGetRequest.Item item = request.items.get(i);
|
||||
if (!clusterState.metaData().hasConcreteIndex(item.index())) {
|
||||
responses.set(i, new MultiGetItemResponse(null, new MultiGetResponse.Failure(item.index(), item.type(), item.id(), "[" + item.index() + "] missing")));
|
||||
responses.set(i, new MultiGetItemResponse(null, new MultiGetResponse.Failure(item.index(), item.type(), item.id(), new IndexNotFoundException(item.index()))));
|
||||
continue;
|
||||
}
|
||||
item.routing(clusterState.metaData().resolveIndexRouting(item.routing(), item.index()));
|
||||
String concreteSingleIndex = clusterState.metaData().concreteSingleIndex(item.index(), item.indicesOptions());
|
||||
String concreteSingleIndex = indexNameExpressionResolver.concreteSingleIndex(clusterState, item);
|
||||
if (item.routing() == null && clusterState.getMetaData().routingRequired(concreteSingleIndex, item.type())) {
|
||||
responses.set(i, new MultiGetItemResponse(null, new MultiGetResponse.Failure(concreteSingleIndex, item.type(), item.id(),
|
||||
"routing is required for [" + concreteSingleIndex + "]/[" + item.type() + "]/[" + item.id() + "]")));
|
||||
new IllegalArgumentException("routing is required for [" + concreteSingleIndex + "]/[" + item.type() + "]/[" + item.id() + "]"))));
|
||||
continue;
|
||||
}
|
||||
ShardId shardId = clusterService.operationRouting()
|
||||
|
@ -104,11 +108,10 @@ public class TransportMultiGetAction extends HandledTransportAction<MultiGetRequ
|
|||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
// create failures for all relevant requests
|
||||
String message = ExceptionsHelper.detailedMessage(e);
|
||||
for (int i = 0; i < shardRequest.locations.size(); i++) {
|
||||
MultiGetRequest.Item item = shardRequest.items.get(i);
|
||||
responses.set(shardRequest.locations.get(i), new MultiGetItemResponse(null,
|
||||
new MultiGetResponse.Failure(shardRequest.index(), item.type(), item.id(), message)));
|
||||
new MultiGetResponse.Failure(shardRequest.index(), item.type(), item.id(), e)));
|
||||
}
|
||||
if (counter.decrementAndGet() == 0) {
|
||||
finishHim();
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.elasticsearch.action.support.TransportActions;
|
|||
import org.elasticsearch.action.support.single.shard.TransportSingleShardAction;
|
||||
import org.elasticsearch.cluster.ClusterService;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.routing.ShardIterator;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -47,8 +48,9 @@ public class TransportShardMultiGetAction extends TransportSingleShardAction<Mul
|
|||
|
||||
@Inject
|
||||
public TransportShardMultiGetAction(Settings settings, ClusterService clusterService, TransportService transportService,
|
||||
IndicesService indicesService, ThreadPool threadPool, ActionFilters actionFilters) {
|
||||
super(settings, ACTION_NAME, threadPool, clusterService, transportService, actionFilters,
|
||||
IndicesService indicesService, ThreadPool threadPool, ActionFilters actionFilters,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, ACTION_NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
|
||||
MultiGetShardRequest.class, ThreadPool.Names.GET);
|
||||
this.indicesService = indicesService;
|
||||
|
||||
|
@ -103,7 +105,7 @@ public class TransportShardMultiGetAction extends TransportSingleShardAction<Mul
|
|||
throw (ElasticsearchException) t;
|
||||
} else {
|
||||
logger.debug("{} failed to execute multi_get for [{}]/[{}]", t, shardId, item.type(), item.id());
|
||||
response.add(request.locations.get(i), new MultiGetResponse.Failure(request.index(), item.type(), item.id(), ExceptionsHelper.detailedMessage(t)));
|
||||
response.add(request.locations.get(i), new MultiGetResponse.Failure(request.index(), item.type(), item.id(), t));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.elasticsearch.cluster.ClusterState;
|
|||
import org.elasticsearch.cluster.action.index.MappingUpdatedAction;
|
||||
import org.elasticsearch.cluster.action.shard.ShardStateAction;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.MappingMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.routing.ShardIterator;
|
||||
|
@ -72,9 +73,10 @@ public class TransportIndexAction extends TransportReplicationAction<IndexReques
|
|||
@Inject
|
||||
public TransportIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
IndicesService indicesService, ThreadPool threadPool, ShardStateAction shardStateAction,
|
||||
TransportCreateIndexAction createIndexAction, MappingUpdatedAction mappingUpdatedAction, ActionFilters actionFilters) {
|
||||
TransportCreateIndexAction createIndexAction, MappingUpdatedAction mappingUpdatedAction,
|
||||
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, IndexAction.NAME, transportService, clusterService, indicesService, threadPool, shardStateAction, mappingUpdatedAction,
|
||||
actionFilters, IndexRequest.class, IndexRequest.class, ThreadPool.Names.INDEX);
|
||||
actionFilters, indexNameExpressionResolver, IndexRequest.class, IndexRequest.class, ThreadPool.Names.INDEX);
|
||||
this.createIndexAction = createIndexAction;
|
||||
this.autoCreateIndex = new AutoCreateIndex(settings);
|
||||
this.allowIdGeneration = settings.getAsBoolean("action.allow_id_generation", true);
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.elasticsearch.action.delete.DeleteResponse;
|
|||
import org.elasticsearch.action.support.ActionFilters;
|
||||
import org.elasticsearch.action.support.DelegatingActionListener;
|
||||
import org.elasticsearch.action.support.HandledTransportAction;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.script.ScriptService;
|
||||
|
@ -39,8 +40,8 @@ public class TransportDeleteIndexedScriptAction extends HandledTransportAction<D
|
|||
|
||||
@Inject
|
||||
public TransportDeleteIndexedScriptAction(Settings settings, ThreadPool threadPool, ScriptService scriptService,
|
||||
TransportService transportService, ActionFilters actionFilters) {
|
||||
super(settings, DeleteIndexedScriptAction.NAME, threadPool, transportService, actionFilters, DeleteIndexedScriptRequest.class);
|
||||
TransportService transportService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, DeleteIndexedScriptAction.NAME, threadPool, transportService, actionFilters, indexNameExpressionResolver, DeleteIndexedScriptRequest.class);
|
||||
this.scriptService = scriptService;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.elasticsearch.action.ActionListener;
|
|||
import org.elasticsearch.action.get.GetResponse;
|
||||
import org.elasticsearch.action.support.ActionFilters;
|
||||
import org.elasticsearch.action.support.HandledTransportAction;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.script.ScriptService;
|
||||
|
@ -38,8 +39,8 @@ public class TransportGetIndexedScriptAction extends HandledTransportAction<GetI
|
|||
|
||||
@Inject
|
||||
public TransportGetIndexedScriptAction(Settings settings, ThreadPool threadPool, ScriptService scriptService,
|
||||
TransportService transportService, ActionFilters actionFilters) {
|
||||
super(settings, GetIndexedScriptAction.NAME, threadPool,transportService, actionFilters, GetIndexedScriptRequest.class);
|
||||
TransportService transportService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, GetIndexedScriptAction.NAME, threadPool,transportService, actionFilters, indexNameExpressionResolver, GetIndexedScriptRequest.class);
|
||||
this.scriptService = scriptService;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.elasticsearch.action.index.IndexResponse;
|
|||
import org.elasticsearch.action.support.ActionFilters;
|
||||
import org.elasticsearch.action.support.DelegatingActionListener;
|
||||
import org.elasticsearch.action.support.HandledTransportAction;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.script.ScriptService;
|
||||
|
@ -38,9 +39,10 @@ public class TransportPutIndexedScriptAction extends HandledTransportAction<PutI
|
|||
private final ScriptService scriptService;
|
||||
|
||||
@Inject
|
||||
public TransportPutIndexedScriptAction(Settings settings, ThreadPool threadPool,
|
||||
ScriptService scriptService, TransportService transportService, ActionFilters actionFilters) {
|
||||
super(settings, PutIndexedScriptAction.NAME, threadPool, transportService, actionFilters, PutIndexedScriptRequest.class);
|
||||
public TransportPutIndexedScriptAction(Settings settings, ThreadPool threadPool, ScriptService scriptService,
|
||||
TransportService transportService, ActionFilters actionFilters,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, PutIndexedScriptAction.NAME, threadPool, transportService, actionFilters, indexNameExpressionResolver, PutIndexedScriptRequest.class);
|
||||
this.scriptService = scriptService;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.elasticsearch.action.percolate;
|
||||
|
||||
import com.google.common.collect.Iterators;
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.action.ActionResponse;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
|
@ -72,15 +73,13 @@ public class MultiPercolateResponse extends ActionResponse implements Iterable<M
|
|||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
builder.startArray(Fields.RESPONSES);
|
||||
for (MultiPercolateResponse.Item item : items) {
|
||||
builder.startObject();
|
||||
if (item.isFailure()) {
|
||||
builder.startObject();
|
||||
builder.field(Fields.ERROR, item.getErrorMessage());
|
||||
builder.endObject();
|
||||
ElasticsearchException.renderThrowable(builder, params, item.getFailure());
|
||||
} else {
|
||||
builder.startObject();
|
||||
item.getResponse().toXContent(builder, params);
|
||||
builder.endObject();
|
||||
}
|
||||
builder.endObject();
|
||||
}
|
||||
builder.endArray();
|
||||
return builder;
|
||||
|
@ -112,34 +111,19 @@ public class MultiPercolateResponse extends ActionResponse implements Iterable<M
|
|||
public static class Item implements Streamable {
|
||||
|
||||
private PercolateResponse response;
|
||||
private String errorMessage;
|
||||
private Throwable throwable;
|
||||
|
||||
Item(PercolateResponse response) {
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
Item(String errorMessage) {
|
||||
this.errorMessage = errorMessage;
|
||||
Item(Throwable Throwable) {
|
||||
this.throwable = Throwable;
|
||||
}
|
||||
|
||||
Item() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The percolator response or <code>null</code> if there was error.
|
||||
*/
|
||||
@Nullable
|
||||
public PercolateResponse response() {
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return An error description if there was an error or <code>null</code> if the percolate request was successful
|
||||
*/
|
||||
@Nullable
|
||||
public String errorMessage() {
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The percolator response or <code>null</code> if there was error.
|
||||
|
@ -154,7 +138,7 @@ public class MultiPercolateResponse extends ActionResponse implements Iterable<M
|
|||
*/
|
||||
@Nullable
|
||||
public String getErrorMessage() {
|
||||
return errorMessage;
|
||||
return throwable == null ? null : throwable.getMessage();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -162,7 +146,11 @@ public class MultiPercolateResponse extends ActionResponse implements Iterable<M
|
|||
* <code>false</code> is returned.
|
||||
*/
|
||||
public boolean isFailure() {
|
||||
return errorMessage != null;
|
||||
return throwable != null;
|
||||
}
|
||||
|
||||
public Throwable getFailure() {
|
||||
return throwable;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -171,7 +159,7 @@ public class MultiPercolateResponse extends ActionResponse implements Iterable<M
|
|||
response = new PercolateResponse();
|
||||
response.readFrom(in);
|
||||
} else {
|
||||
errorMessage = in.readString();
|
||||
throwable = in.readThrowable();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -182,10 +170,9 @@ public class MultiPercolateResponse extends ActionResponse implements Iterable<M
|
|||
response.writeTo(out);
|
||||
} else {
|
||||
out.writeBoolean(false);
|
||||
out.writeString(errorMessage);
|
||||
out.writeThrowable(throwable);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static final class Fields {
|
||||
|
|
|
@ -37,6 +37,7 @@ public class PercolateShardRequest extends BroadcastShardRequest {
|
|||
private BytesReference docSource;
|
||||
private boolean onlyCount;
|
||||
private int numberOfShards;
|
||||
private long startTime;
|
||||
|
||||
PercolateShardRequest() {
|
||||
}
|
||||
|
@ -48,6 +49,7 @@ public class PercolateShardRequest extends BroadcastShardRequest {
|
|||
this.docSource = request.docSource();
|
||||
this.onlyCount = request.onlyCount();
|
||||
this.numberOfShards = numberOfShards;
|
||||
this.startTime = request.startTime;
|
||||
}
|
||||
|
||||
PercolateShardRequest(ShardId shardId, OriginalIndices originalIndices) {
|
||||
|
@ -60,6 +62,7 @@ public class PercolateShardRequest extends BroadcastShardRequest {
|
|||
this.source = request.source();
|
||||
this.docSource = request.docSource();
|
||||
this.onlyCount = request.onlyCount();
|
||||
this.startTime = request.startTime;
|
||||
}
|
||||
|
||||
public String documentType() {
|
||||
|
@ -98,6 +101,10 @@ public class PercolateShardRequest extends BroadcastShardRequest {
|
|||
return numberOfShards;
|
||||
}
|
||||
|
||||
public long getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
OriginalIndices originalIndices() {
|
||||
return originalIndices;
|
||||
}
|
||||
|
@ -110,6 +117,7 @@ public class PercolateShardRequest extends BroadcastShardRequest {
|
|||
docSource = in.readBytesReference();
|
||||
onlyCount = in.readBoolean();
|
||||
numberOfShards = in.readVInt();
|
||||
startTime = in.readLong(); // no vlong, this can be negative!
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -120,6 +128,7 @@ public class PercolateShardRequest extends BroadcastShardRequest {
|
|||
out.writeBytesReference(docSource);
|
||||
out.writeBoolean(onlyCount);
|
||||
out.writeVInt(numberOfShards);
|
||||
out.writeLong(startTime);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
package org.elasticsearch.action.percolate;
|
||||
|
||||
import com.carrotsearch.hppc.IntArrayList;
|
||||
import org.elasticsearch.ExceptionsHelper;
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.UnavailableShardsException;
|
||||
import org.elasticsearch.action.get.*;
|
||||
|
@ -30,14 +29,15 @@ import org.elasticsearch.action.support.broadcast.BroadcastShardOperationFailedE
|
|||
import org.elasticsearch.cluster.ClusterService;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
||||
import org.elasticsearch.cluster.routing.ShardIterator;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.concurrent.AtomicArray;
|
||||
import org.elasticsearch.index.IndexNotFoundException;
|
||||
import org.elasticsearch.index.engine.DocumentMissingException;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.indices.IndexMissingException;
|
||||
import org.elasticsearch.percolator.PercolatorService;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
@ -59,8 +59,8 @@ public class TransportMultiPercolateAction extends HandledTransportAction<MultiP
|
|||
@Inject
|
||||
public TransportMultiPercolateAction(Settings settings, ThreadPool threadPool, TransportShardMultiPercolateAction shardMultiPercolateAction,
|
||||
ClusterService clusterService, TransportService transportService, PercolatorService percolatorService,
|
||||
TransportMultiGetAction multiGetAction, ActionFilters actionFilters) {
|
||||
super(settings, MultiPercolateAction.NAME, threadPool, transportService, actionFilters, MultiPercolateRequest.class);
|
||||
TransportMultiGetAction multiGetAction, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, MultiPercolateAction.NAME, threadPool, transportService, actionFilters, indexNameExpressionResolver, MultiPercolateRequest.class);
|
||||
this.shardMultiPercolateAction = shardMultiPercolateAction;
|
||||
this.clusterService = clusterService;
|
||||
this.percolatorService = percolatorService;
|
||||
|
@ -164,17 +164,17 @@ public class TransportMultiPercolateAction extends HandledTransportAction<MultiP
|
|||
PercolateRequest percolateRequest = (PercolateRequest) element;
|
||||
String[] concreteIndices;
|
||||
try {
|
||||
concreteIndices = clusterState.metaData().concreteIndices(percolateRequest.indicesOptions(), percolateRequest.indices());
|
||||
} catch (IndexMissingException e) {
|
||||
concreteIndices = indexNameExpressionResolver.concreteIndices(clusterState, percolateRequest);
|
||||
} catch (IndexNotFoundException e) {
|
||||
reducedResponses.set(slot, e);
|
||||
responsesByItemAndShard.set(slot, new AtomicReferenceArray(0));
|
||||
expectedOperationsPerItem.set(slot, new AtomicInteger(0));
|
||||
continue;
|
||||
}
|
||||
Map<String, Set<String>> routing = clusterState.metaData().resolveSearchRouting(percolateRequest.routing(), percolateRequest.indices());
|
||||
Map<String, Set<String>> routing = indexNameExpressionResolver.resolveSearchRouting(clusterState, percolateRequest.routing(), percolateRequest.indices());
|
||||
// TODO: I only need shardIds, ShardIterator(ShardRouting) is only needed in TransportShardMultiPercolateAction
|
||||
GroupShardsIterator shards = clusterService.operationRouting().searchShards(
|
||||
clusterState, percolateRequest.indices(), concreteIndices, routing, percolateRequest.preference()
|
||||
clusterState, concreteIndices, routing, percolateRequest.preference()
|
||||
);
|
||||
if (shards.size() == 0) {
|
||||
reducedResponses.set(slot, new UnavailableShardsException(null, "No shards available"));
|
||||
|
@ -184,7 +184,7 @@ public class TransportMultiPercolateAction extends HandledTransportAction<MultiP
|
|||
}
|
||||
|
||||
// The shard id is used as index in the atomic ref array, so we need to find out how many shards there are regardless of routing:
|
||||
int numShards = clusterService.operationRouting().searchShardsCount(clusterState, percolateRequest.indices(), concreteIndices, null, null);
|
||||
int numShards = clusterService.operationRouting().searchShardsCount(clusterState, concreteIndices, null);
|
||||
responsesByItemAndShard.set(slot, new AtomicReferenceArray(numShards));
|
||||
expectedOperationsPerItem.set(slot, new AtomicInteger(shards.size()));
|
||||
for (ShardIterator shard : shards) {
|
||||
|
@ -311,9 +311,9 @@ public class TransportMultiPercolateAction extends HandledTransportAction<MultiP
|
|||
if (element instanceof PercolateResponse) {
|
||||
finalResponse[slot] = new MultiPercolateResponse.Item((PercolateResponse) element);
|
||||
} else if (element instanceof Throwable) {
|
||||
finalResponse[slot] = new MultiPercolateResponse.Item(ExceptionsHelper.detailedMessage((Throwable) element));
|
||||
finalResponse[slot] = new MultiPercolateResponse.Item((Throwable)element);
|
||||
} else if (element instanceof MultiGetResponse.Failure) {
|
||||
finalResponse[slot] = new MultiPercolateResponse.Item(((MultiGetResponse.Failure)element).getMessage());
|
||||
finalResponse[slot] = new MultiPercolateResponse.Item(((MultiGetResponse.Failure)element).getFailure());
|
||||
}
|
||||
}
|
||||
finalListener.onResponse(new MultiPercolateResponse(finalResponse));
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.elasticsearch.cluster.ClusterService;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
|
@ -60,9 +61,9 @@ public class TransportPercolateAction extends TransportBroadcastAction<Percolate
|
|||
@Inject
|
||||
public TransportPercolateAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
|
||||
TransportService transportService, PercolatorService percolatorService,
|
||||
TransportGetAction getAction, ActionFilters actionFilters) {
|
||||
TransportGetAction getAction, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, PercolateAction.NAME, threadPool, clusterService, transportService, actionFilters,
|
||||
PercolateRequest.class, PercolateShardRequest.class, ThreadPool.Names.PERCOLATE);
|
||||
indexNameExpressionResolver, PercolateRequest.class, PercolateShardRequest.class, ThreadPool.Names.PERCOLATE);
|
||||
this.percolatorService = percolatorService;
|
||||
this.getAction = getAction;
|
||||
}
|
||||
|
@ -167,8 +168,8 @@ public class TransportPercolateAction extends TransportBroadcastAction<Percolate
|
|||
|
||||
@Override
|
||||
protected GroupShardsIterator shards(ClusterState clusterState, PercolateRequest request, String[] concreteIndices) {
|
||||
Map<String, Set<String>> routingMap = clusterState.metaData().resolveSearchRouting(request.routing(), request.indices());
|
||||
return clusterService.operationRouting().searchShards(clusterState, request.indices(), concreteIndices, routingMap, request.preference());
|
||||
Map<String, Set<String>> routingMap = indexNameExpressionResolver.resolveSearchRouting(clusterState, request.routing(), request.indices());
|
||||
return clusterService.operationRouting().searchShards(clusterState, concreteIndices, routingMap, request.preference());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue