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>
|
<parent>
|
||||||
<groupId>org.elasticsearch</groupId>
|
<groupId>org.elasticsearch</groupId>
|
||||||
<artifactId>elasticsearch-parent</artifactId>
|
<artifactId>elasticsearch-parent</artifactId>
|
||||||
<version>2.0.0-SNAPSHOT</version>
|
<version>2.0.0-beta1-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>org.elasticsearch</groupId>
|
<groupId>org.elasticsearch</groupId>
|
||||||
|
@ -299,39 +299,6 @@
|
||||||
</testResources>
|
</testResources>
|
||||||
|
|
||||||
<plugins>
|
<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>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
|
@ -392,6 +359,7 @@
|
||||||
<include>com.tdunning:t-digest</include>
|
<include>com.tdunning:t-digest</include>
|
||||||
<include>org.apache.commons:commons-lang3</include>
|
<include>org.apache.commons:commons-lang3</include>
|
||||||
<include>commons-cli:commons-cli</include>
|
<include>commons-cli:commons-cli</include>
|
||||||
|
<include>com.twitter:jsr166e</include>
|
||||||
</includes>
|
</includes>
|
||||||
</artifactSet>
|
</artifactSet>
|
||||||
<transformers>
|
<transformers>
|
||||||
|
@ -1024,11 +992,24 @@
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<!-- integration tests -->
|
<!-- execution and integration tests -->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-antrun-plugin</artifactId>
|
<artifactId>maven-antrun-plugin</artifactId>
|
||||||
<executions>
|
<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 -->
|
<!-- start up external cluster -->
|
||||||
<execution>
|
<execution>
|
||||||
<id>integ-setup</id>
|
<id>integ-setup</id>
|
||||||
|
@ -1038,8 +1019,7 @@
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<target>
|
<target>
|
||||||
<ant antfile="${elasticsearch.tools.directory}/ant/integration-tests.xml"
|
<ant antfile="${elasticsearch.integ.antfile}" target="start-external-cluster"/>
|
||||||
target="start-external-cluster"/>
|
|
||||||
</target>
|
</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
@ -1052,22 +1032,14 @@
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<target>
|
<target>
|
||||||
<ant antfile="${elasticsearch.tools.directory}/ant/integration-tests.xml"
|
<ant antfile="${elasticsearch.integ.antfile}" target="stop-external-cluster"/>
|
||||||
target="stop-external-cluster"/>
|
<!-- TODO: remove this and the xslt when junit4 is fixed -->
|
||||||
|
<ant antfile="${elasticsearch.integ.antfile}" target="fixup-failsafe-summary"/>
|
||||||
</target>
|
</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</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>
|
</plugins>
|
||||||
<pluginManagement>
|
<pluginManagement>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
@ -1111,6 +1083,31 @@
|
||||||
</activation>
|
</activation>
|
||||||
<!-- not including license-maven-plugin is sufficent to expose default license -->
|
<!-- not including license-maven-plugin is sufficent to expose default license -->
|
||||||
</profile>
|
</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>
|
<profile>
|
||||||
<id>sign-rpm</id>
|
<id>sign-rpm</id>
|
||||||
<activation>
|
<activation>
|
||||||
|
|
|
@ -19,8 +19,6 @@
|
||||||
|
|
||||||
package org.apache.lucene.queryparser.classic;
|
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.Analyzer;
|
||||||
import org.apache.lucene.analysis.TokenStream;
|
import org.apache.lucene.analysis.TokenStream;
|
||||||
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
|
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.MultiPhraseQuery;
|
||||||
import org.apache.lucene.search.PhraseQuery;
|
import org.apache.lucene.search.PhraseQuery;
|
||||||
import org.apache.lucene.search.Query;
|
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.apache.lucene.util.automaton.RegExp;
|
||||||
import org.elasticsearch.common.lucene.search.Queries;
|
import org.elasticsearch.common.lucene.search.Queries;
|
||||||
import org.elasticsearch.common.unit.Fuzziness;
|
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.QueryParseContext;
|
||||||
import org.elasticsearch.index.query.support.QueryParsers;
|
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.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -128,7 +131,7 @@ public class MapperQueryParser extends QueryParser {
|
||||||
setLowercaseExpandedTerms(settings.lowercaseExpandedTerms());
|
setLowercaseExpandedTerms(settings.lowercaseExpandedTerms());
|
||||||
setPhraseSlop(settings.phraseSlop());
|
setPhraseSlop(settings.phraseSlop());
|
||||||
setDefaultOperator(settings.defaultOperator());
|
setDefaultOperator(settings.defaultOperator());
|
||||||
setFuzzyMinSim(settings.fuzzyMinSim());
|
setFuzzyMinSim(settings.getFuzziness().asFloat());
|
||||||
setFuzzyPrefixLength(settings.fuzzyPrefixLength());
|
setFuzzyPrefixLength(settings.fuzzyPrefixLength());
|
||||||
setLocale(settings.locale());
|
setLocale(settings.locale());
|
||||||
this.analyzeWildcard = settings.analyzeWildcard();
|
this.analyzeWildcard = settings.analyzeWildcard();
|
||||||
|
@ -721,6 +724,15 @@ public class MapperQueryParser extends QueryParser {
|
||||||
return super.getWildcardQuery(field, aggStr.toString());
|
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
|
@Override
|
||||||
protected Query getRegexpQuery(String field, String termStr) throws ParseException {
|
protected Query getRegexpQuery(String field, String termStr) throws ParseException {
|
||||||
if (lowercaseExpandedTerms) {
|
if (lowercaseExpandedTerms) {
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.apache.lucene.analysis.Analyzer;
|
||||||
import org.apache.lucene.search.FuzzyQuery;
|
import org.apache.lucene.search.FuzzyQuery;
|
||||||
import org.apache.lucene.search.MultiTermQuery;
|
import org.apache.lucene.search.MultiTermQuery;
|
||||||
import org.apache.lucene.util.automaton.Operations;
|
import org.apache.lucene.util.automaton.Operations;
|
||||||
|
import org.elasticsearch.common.unit.Fuzziness;
|
||||||
import org.joda.time.DateTimeZone;
|
import org.joda.time.DateTimeZone;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -49,7 +50,7 @@ public class QueryParserSettings {
|
||||||
private boolean lowercaseExpandedTerms = true;
|
private boolean lowercaseExpandedTerms = true;
|
||||||
private boolean enablePositionIncrements = true;
|
private boolean enablePositionIncrements = true;
|
||||||
private int phraseSlop = 0;
|
private int phraseSlop = 0;
|
||||||
private float fuzzyMinSim = FuzzyQuery.defaultMinSimilarity;
|
private Fuzziness fuzziness = Fuzziness.AUTO;
|
||||||
private int fuzzyPrefixLength = FuzzyQuery.defaultPrefixLength;
|
private int fuzzyPrefixLength = FuzzyQuery.defaultPrefixLength;
|
||||||
private int fuzzyMaxExpansions = FuzzyQuery.defaultMaxExpansions;
|
private int fuzzyMaxExpansions = FuzzyQuery.defaultMaxExpansions;
|
||||||
private int maxDeterminizedStates = Operations.DEFAULT_MAX_DETERMINIZED_STATES;
|
private int maxDeterminizedStates = Operations.DEFAULT_MAX_DETERMINIZED_STATES;
|
||||||
|
@ -158,14 +159,6 @@ public class QueryParserSettings {
|
||||||
this.phraseSlop = phraseSlop;
|
this.phraseSlop = phraseSlop;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float fuzzyMinSim() {
|
|
||||||
return fuzzyMinSim;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void fuzzyMinSim(float fuzzyMinSim) {
|
|
||||||
this.fuzzyMinSim = fuzzyMinSim;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int fuzzyPrefixLength() {
|
public int fuzzyPrefixLength() {
|
||||||
return fuzzyPrefixLength;
|
return fuzzyPrefixLength;
|
||||||
}
|
}
|
||||||
|
@ -340,7 +333,7 @@ public class QueryParserSettings {
|
||||||
if (enablePositionIncrements != that.enablePositionIncrements) return false;
|
if (enablePositionIncrements != that.enablePositionIncrements) return false;
|
||||||
if (escape != that.escape) return false;
|
if (escape != that.escape) return false;
|
||||||
if (analyzeWildcard != that.analyzeWildcard) 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 (fuzzyPrefixLength != that.fuzzyPrefixLength) return false;
|
||||||
if (fuzzyMaxExpansions != that.fuzzyMaxExpansions) return false;
|
if (fuzzyMaxExpansions != that.fuzzyMaxExpansions) return false;
|
||||||
if (fuzzyRewriteMethod != null ? !fuzzyRewriteMethod.equals(that.fuzzyRewriteMethod) : that.fuzzyRewriteMethod != null)
|
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 + (lowercaseExpandedTerms ? 1 : 0);
|
||||||
result = 31 * result + (enablePositionIncrements ? 1 : 0);
|
result = 31 * result + (enablePositionIncrements ? 1 : 0);
|
||||||
result = 31 * result + phraseSlop;
|
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 + fuzzyPrefixLength;
|
||||||
result = 31 * result + (escape ? 1 : 0);
|
result = 31 * result + (escape ? 1 : 0);
|
||||||
result = 31 * result + (defaultAnalyzer != null ? defaultAnalyzer.hashCode() : 0);
|
result = 31 * result + (defaultAnalyzer != null ? defaultAnalyzer.hashCode() : 0);
|
||||||
|
@ -413,4 +406,12 @@ public class QueryParserSettings {
|
||||||
result = 31 * result + (timeZone != null ? timeZone.hashCode() : 0);
|
result = 31 * result + (timeZone != null ? timeZone.hashCode() : 0);
|
||||||
return result;
|
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.logging.support.LoggerMessageFormat;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
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.RestStatus;
|
||||||
|
import org.elasticsearch.rest.action.admin.indices.alias.delete.AliasesNotFoundException;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
|
@ -39,6 +44,11 @@ import java.util.*;
|
||||||
public class ElasticsearchException extends RuntimeException implements ToXContent {
|
public class ElasticsearchException extends RuntimeException implements ToXContent {
|
||||||
|
|
||||||
public static final String REST_EXCEPTION_SKIP_CAUSE = "rest.exception.skip_cause";
|
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 static final Map<String, Constructor<? extends ElasticsearchException>> MAPPING;
|
||||||
private final Map<String, List<String>> headers = new HashMap<>();
|
private final Map<String, List<String>> headers = new HashMap<>();
|
||||||
|
|
||||||
|
@ -252,7 +262,14 @@ public class ElasticsearchException extends RuntimeException implements ToXConte
|
||||||
} else {
|
} else {
|
||||||
builder.field("type", getExceptionName());
|
builder.field("type", getExceptionName());
|
||||||
builder.field("reason", getMessage());
|
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);
|
innerToXContent(builder, params);
|
||||||
|
renderHeader(builder, params);
|
||||||
}
|
}
|
||||||
return builder;
|
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.
|
* 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
|
@Override
|
||||||
public String toString() {
|
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.indices.recovery.RecoverFilesRecoveryException.class,
|
||||||
org.elasticsearch.index.translog.TruncatedTranslogException.class,
|
org.elasticsearch.index.translog.TruncatedTranslogException.class,
|
||||||
org.elasticsearch.repositories.RepositoryException.class,
|
org.elasticsearch.repositories.RepositoryException.class,
|
||||||
org.elasticsearch.index.shard.IndexShardException.class,
|
|
||||||
org.elasticsearch.index.engine.DocumentSourceMissingException.class,
|
org.elasticsearch.index.engine.DocumentSourceMissingException.class,
|
||||||
org.elasticsearch.index.engine.DocumentMissingException.class,
|
org.elasticsearch.index.engine.DocumentMissingException.class,
|
||||||
org.elasticsearch.common.util.concurrent.EsRejectedExecutionException.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.index.snapshots.IndexShardSnapshotException.class,
|
||||||
org.elasticsearch.search.query.QueryPhaseExecutionException.class,
|
org.elasticsearch.search.query.QueryPhaseExecutionException.class,
|
||||||
org.elasticsearch.cluster.metadata.ProcessClusterEventTimeoutException.class,
|
org.elasticsearch.cluster.metadata.ProcessClusterEventTimeoutException.class,
|
||||||
org.elasticsearch.index.shard.IndexShardCreationException.class,
|
|
||||||
org.elasticsearch.index.percolator.PercolatorException.class,
|
org.elasticsearch.index.percolator.PercolatorException.class,
|
||||||
org.elasticsearch.snapshots.ConcurrentSnapshotExecutionException.class,
|
org.elasticsearch.snapshots.ConcurrentSnapshotExecutionException.class,
|
||||||
org.elasticsearch.indices.IndexTemplateAlreadyExistsException.class,
|
org.elasticsearch.indices.IndexTemplateAlreadyExistsException.class,
|
||||||
org.elasticsearch.indices.InvalidIndexNameException.class,
|
org.elasticsearch.indices.InvalidIndexNameException.class,
|
||||||
org.elasticsearch.index.IndexException.class,
|
|
||||||
org.elasticsearch.indices.recovery.DelayRecoveryException.class,
|
org.elasticsearch.indices.recovery.DelayRecoveryException.class,
|
||||||
org.elasticsearch.indices.AliasFilterParsingException.class,
|
org.elasticsearch.indices.AliasFilterParsingException.class,
|
||||||
org.elasticsearch.indices.InvalidIndexTemplateException.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.cluster.block.ClusterBlockException.class,
|
||||||
org.elasticsearch.action.FailedNodeException.class,
|
org.elasticsearch.action.FailedNodeException.class,
|
||||||
org.elasticsearch.indices.TypeMissingException.class,
|
org.elasticsearch.indices.TypeMissingException.class,
|
||||||
org.elasticsearch.index.IndexShardMissingException.class,
|
|
||||||
org.elasticsearch.indices.InvalidTypeNameException.class,
|
org.elasticsearch.indices.InvalidTypeNameException.class,
|
||||||
org.elasticsearch.transport.netty.SizeHeaderFrameDecoder.HttpOnTransportException.class,
|
org.elasticsearch.transport.netty.SizeHeaderFrameDecoder.HttpOnTransportException.class,
|
||||||
org.elasticsearch.common.util.CancellableThreads.ExecutionCancelledException.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.ElasticsearchTimeoutException.class,
|
||||||
org.elasticsearch.search.SearchContextMissingException.class,
|
org.elasticsearch.search.SearchContextMissingException.class,
|
||||||
org.elasticsearch.transport.SendRequestTransportException.class,
|
org.elasticsearch.transport.SendRequestTransportException.class,
|
||||||
org.elasticsearch.indices.IndexMissingException.class,
|
|
||||||
org.elasticsearch.index.IndexShardAlreadyExistsException.class,
|
org.elasticsearch.index.IndexShardAlreadyExistsException.class,
|
||||||
org.elasticsearch.indices.IndexAlreadyExistsException.class,
|
org.elasticsearch.indices.IndexAlreadyExistsException.class,
|
||||||
org.elasticsearch.index.engine.DocumentAlreadyExistsException.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.shard.IndexShardNotStartedException.class,
|
||||||
org.elasticsearch.index.mapper.StrictDynamicMappingException.class,
|
org.elasticsearch.index.mapper.StrictDynamicMappingException.class,
|
||||||
org.elasticsearch.index.engine.EngineClosedException.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.transport.ResponseHandlerFailureTransportException.class,
|
||||||
org.elasticsearch.search.SearchParseException.class,
|
org.elasticsearch.search.SearchParseException.class,
|
||||||
org.elasticsearch.search.fetch.FetchPhaseExecutionException.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.index.engine.RecoveryEngineException.class,
|
||||||
org.elasticsearch.common.blobstore.BlobStoreException.class,
|
org.elasticsearch.common.blobstore.BlobStoreException.class,
|
||||||
org.elasticsearch.index.snapshots.IndexShardRestoreException.class,
|
org.elasticsearch.index.snapshots.IndexShardRestoreException.class,
|
||||||
org.elasticsearch.index.store.StoreException.class,
|
|
||||||
org.elasticsearch.index.query.QueryParsingException.class,
|
org.elasticsearch.index.query.QueryParsingException.class,
|
||||||
org.elasticsearch.action.support.replication.TransportReplicationAction.RetryOnPrimaryException.class,
|
org.elasticsearch.action.support.replication.TransportReplicationAction.RetryOnPrimaryException.class,
|
||||||
org.elasticsearch.index.engine.DeleteByQueryFailedEngineException.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.engine.CreateFailedEngineException.class,
|
||||||
org.elasticsearch.index.shard.IllegalIndexShardStateException.class,
|
org.elasticsearch.index.shard.IllegalIndexShardStateException.class,
|
||||||
ElasticsearchSecurityException.class,
|
ElasticsearchSecurityException.class,
|
||||||
|
ResourceNotFoundException.class,
|
||||||
|
IndexNotFoundException.class,
|
||||||
|
ShardNotFoundException.class,
|
||||||
NotSerializableExceptionWrapper.class
|
NotSerializableExceptionWrapper.class
|
||||||
};
|
};
|
||||||
Map<String, Constructor<? extends ElasticsearchException>> mapping = new HashMap<>(exceptions.length);
|
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);
|
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.Nullable;
|
||||||
import org.elasticsearch.common.logging.ESLogger;
|
import org.elasticsearch.common.logging.ESLogger;
|
||||||
import org.elasticsearch.common.logging.Loggers;
|
import org.elasticsearch.common.logging.Loggers;
|
||||||
import org.elasticsearch.index.Index;
|
|
||||||
import org.elasticsearch.index.IndexException;
|
|
||||||
import org.elasticsearch.rest.RestStatus;
|
import org.elasticsearch.rest.RestStatus;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -240,12 +238,12 @@ public final class ExceptionsHelper {
|
||||||
|
|
||||||
static class GroupBy {
|
static class GroupBy {
|
||||||
final String reason;
|
final String reason;
|
||||||
final Index index;
|
final String index;
|
||||||
final Class<? extends Throwable> causeType;
|
final Class<? extends Throwable> causeType;
|
||||||
|
|
||||||
public GroupBy(Throwable t) {
|
public GroupBy(Throwable t) {
|
||||||
if (t instanceof IndexException) {
|
if (t instanceof ElasticsearchException) {
|
||||||
index = ((IndexException) t).index();
|
index = ((ElasticsearchException) t).getIndex();
|
||||||
} else {
|
} else {
|
||||||
index = null;
|
index = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,31 +16,32 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
package org.elasticsearch;
|
||||||
package org.elasticsearch.index;
|
|
||||||
|
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
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 org.elasticsearch.rest.RestStatus;
|
||||||
|
|
||||||
import java.io.IOException;
|
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) {
|
public ResourceNotFoundException(String msg, Object... args) {
|
||||||
super(shardId, "missing");
|
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);
|
super(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RestStatus status() {
|
public final RestStatus status() {
|
||||||
return RestStatus.NOT_FOUND;
|
return RestStatus.NOT_FOUND;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -241,13 +241,17 @@ public class Version {
|
||||||
public static final int V_1_6_0_ID = 1060099;
|
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 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 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 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 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_2_0_0_ID = 2000099;
|
public static final int V_1_7_1_ID = 1070199;
|
||||||
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_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 {
|
static {
|
||||||
assert CURRENT.luceneVersion.equals(Lucene.VERSION) : "Version must be upgraded to [" + Lucene.VERSION + "] is still set to [" + CURRENT.luceneVersion + "]";
|
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) {
|
public static Version fromId(int id) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case V_2_0_0_ID:
|
case V_2_0_0_beta1_ID:
|
||||||
return V_2_0_0;
|
return V_2_0_0_beta1;
|
||||||
|
case V_1_7_1_ID:
|
||||||
|
return V_1_7_1;
|
||||||
case V_1_7_0_ID:
|
case V_1_7_0_ID:
|
||||||
return V_1_7_0;
|
return V_1_7_0;
|
||||||
|
case V_1_6_2_ID:
|
||||||
|
return V_1_6_2;
|
||||||
case V_1_6_1_ID:
|
case V_1_6_1_ID:
|
||||||
return V_1_6_1;
|
return V_1_6_1;
|
||||||
case V_1_6_0_ID:
|
case V_1_6_0_ID:
|
||||||
|
@ -472,7 +480,7 @@ public class Version {
|
||||||
public static Version indexCreated(Settings indexSettings) {
|
public static Version indexCreated(Settings indexSettings) {
|
||||||
final Version indexVersion = indexSettings.getAsVersion(IndexMetaData.SETTING_VERSION_CREATED, null);
|
final Version indexVersion = indexSettings.getAsVersion(IndexMetaData.SETTING_VERSION_CREATED, null);
|
||||||
if (indexVersion == 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;
|
return indexVersion;
|
||||||
}
|
}
|
||||||
|
@ -499,7 +507,7 @@ public class Version {
|
||||||
if (snapshot = version.endsWith("-SNAPSHOT")) {
|
if (snapshot = version.endsWith("-SNAPSHOT")) {
|
||||||
version = version.substring(0, version.length() - 9);
|
version = version.substring(0, version.length() - 9);
|
||||||
}
|
}
|
||||||
String[] parts = version.split("\\.");
|
String[] parts = version.split("\\.|\\-");
|
||||||
if (parts.length < 3 || parts.length > 4) {
|
if (parts.length < 3 || parts.length > 4) {
|
||||||
throw new IllegalArgumentException("the version needs to contain major, minor and revision, and optionally the build: " + version);
|
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;
|
int build = 99;
|
||||||
if (parts.length == 4) {
|
if (parts.length == 4) {
|
||||||
String buildStr = parts[3];
|
String buildStr = parts[3];
|
||||||
if (buildStr.startsWith("Beta")) {
|
if (buildStr.startsWith("Beta") || buildStr.startsWith("beta")) {
|
||||||
build = Integer.parseInt(buildStr.substring(4));
|
build = Integer.parseInt(buildStr.substring(4));
|
||||||
}
|
}
|
||||||
if (buildStr.startsWith("RC")) {
|
if (buildStr.startsWith("RC") || buildStr.startsWith("rc")) {
|
||||||
build = Integer.parseInt(buildStr.substring(2)) + 50;
|
build = Integer.parseInt(buildStr.substring(2)) + 50;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -589,10 +597,20 @@ public class Version {
|
||||||
public String number() {
|
public String number() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append(major).append('.').append(minor).append('.').append(revision);
|
sb.append(major).append('.').append(minor).append('.').append(revision);
|
||||||
if (build < 50) {
|
if (isBeta()) {
|
||||||
sb.append(".Beta").append(build);
|
if (major >= 2) {
|
||||||
|
sb.append("-beta");
|
||||||
|
} else {
|
||||||
|
sb.append(".Beta");
|
||||||
|
}
|
||||||
|
sb.append(build);
|
||||||
} else if (build < 99) {
|
} 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();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
@ -635,6 +653,14 @@ public class Version {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isBeta() {
|
||||||
|
return build < 50;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRC() {
|
||||||
|
return build > 50 && build < 99;
|
||||||
|
}
|
||||||
|
|
||||||
public static class Module extends AbstractModule {
|
public static class Module extends AbstractModule {
|
||||||
|
|
||||||
private final Version version;
|
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.recovery.TransportRecoveryAction;
|
||||||
import org.elasticsearch.action.admin.indices.refresh.RefreshAction;
|
import org.elasticsearch.action.admin.indices.refresh.RefreshAction;
|
||||||
import org.elasticsearch.action.admin.indices.refresh.TransportRefreshAction;
|
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.IndicesSegmentsAction;
|
||||||
import org.elasticsearch.action.admin.indices.segments.TransportIndicesSegmentsAction;
|
import org.elasticsearch.action.admin.indices.segments.TransportIndicesSegmentsAction;
|
||||||
import org.elasticsearch.action.admin.indices.settings.get.GetSettingsAction;
|
import org.elasticsearch.action.admin.indices.settings.get.GetSettingsAction;
|
||||||
|
@ -242,6 +244,7 @@ public class ActionModule extends AbstractModule {
|
||||||
|
|
||||||
registerAction(IndicesStatsAction.INSTANCE, TransportIndicesStatsAction.class);
|
registerAction(IndicesStatsAction.INSTANCE, TransportIndicesStatsAction.class);
|
||||||
registerAction(IndicesSegmentsAction.INSTANCE, TransportIndicesSegmentsAction.class);
|
registerAction(IndicesSegmentsAction.INSTANCE, TransportIndicesSegmentsAction.class);
|
||||||
|
registerAction(IndicesShardStoresAction.INSTANCE, TransportIndicesShardStoresAction.class);
|
||||||
registerAction(CreateIndexAction.INSTANCE, TransportCreateIndexAction.class);
|
registerAction(CreateIndexAction.INSTANCE, TransportCreateIndexAction.class);
|
||||||
registerAction(DeleteIndexAction.INSTANCE, TransportDeleteIndexAction.class);
|
registerAction(DeleteIndexAction.INSTANCE, TransportDeleteIndexAction.class);
|
||||||
registerAction(GetIndexAction.INSTANCE, TransportGetIndexAction.class);
|
registerAction(GetIndexAction.INSTANCE, TransportGetIndexAction.class);
|
||||||
|
|
|
@ -25,7 +25,7 @@ import org.elasticsearch.action.support.IndicesOptions;
|
||||||
*
|
*
|
||||||
* Forces this class return index/type/id getters
|
* 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
|
* Get the index that this request operates on
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
|
|
||||||
package org.elasticsearch.action;
|
package org.elasticsearch.action;
|
||||||
|
|
||||||
|
import org.elasticsearch.ElasticsearchException;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.index.shard.IndexShardException;
|
|
||||||
import org.elasticsearch.index.shard.ShardId;
|
import org.elasticsearch.index.shard.ShardId;
|
||||||
import org.elasticsearch.rest.RestStatus;
|
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) {
|
public NoShardAvailableActionException(ShardId shardId) {
|
||||||
super(shardId, null);
|
this(shardId, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NoShardAvailableActionException(ShardId shardId, String msg) {
|
public NoShardAvailableActionException(ShardId shardId, String msg) {
|
||||||
super(shardId, msg);
|
this(shardId, msg, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NoShardAvailableActionException(ShardId shardId, String msg, Throwable cause) {
|
public NoShardAvailableActionException(ShardId shardId, String msg, Throwable cause) {
|
||||||
super(shardId, msg, cause);
|
super(msg, cause);
|
||||||
|
setShard(shardId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -32,8 +32,6 @@ import java.util.Objects;
|
||||||
*/
|
*/
|
||||||
public class RoutingMissingException extends ElasticsearchException {
|
public class RoutingMissingException extends ElasticsearchException {
|
||||||
|
|
||||||
private final String index;
|
|
||||||
|
|
||||||
private final String type;
|
private final String type;
|
||||||
|
|
||||||
private final String id;
|
private final String id;
|
||||||
|
@ -43,20 +41,16 @@ public class RoutingMissingException extends ElasticsearchException {
|
||||||
Objects.requireNonNull(index, "index must not be null");
|
Objects.requireNonNull(index, "index must not be null");
|
||||||
Objects.requireNonNull(type, "type must not be null");
|
Objects.requireNonNull(type, "type must not be null");
|
||||||
Objects.requireNonNull(id, "id must not be null");
|
Objects.requireNonNull(id, "id must not be null");
|
||||||
this.index = index;
|
setIndex(index);
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String index() {
|
public String getType() {
|
||||||
return index;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String type() {
|
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String id() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +61,6 @@ public class RoutingMissingException extends ElasticsearchException {
|
||||||
|
|
||||||
public RoutingMissingException(StreamInput in) throws IOException{
|
public RoutingMissingException(StreamInput in) throws IOException{
|
||||||
super(in);
|
super(in);
|
||||||
index = in.readString();
|
|
||||||
type = in.readString();
|
type = in.readString();
|
||||||
id = in.readString();
|
id = in.readString();
|
||||||
}
|
}
|
||||||
|
@ -75,7 +68,6 @@ public class RoutingMissingException extends ElasticsearchException {
|
||||||
@Override
|
@Override
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
public void writeTo(StreamOutput out) throws IOException {
|
||||||
super.writeTo(out);
|
super.writeTo(out);
|
||||||
out.writeString(index);
|
|
||||||
out.writeString(type);
|
out.writeString(type);
|
||||||
out.writeString(id);
|
out.writeString(id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,11 +107,11 @@ public class ClusterHealthResponse extends ActionResponse implements Iterable<Cl
|
||||||
status = ClusterHealthStatus.GREEN;
|
status = ClusterHealthStatus.GREEN;
|
||||||
|
|
||||||
for (ClusterIndexHealth indexHealth : indices.values()) {
|
for (ClusterIndexHealth indexHealth : indices.values()) {
|
||||||
activePrimaryShards += indexHealth.activePrimaryShards;
|
activePrimaryShards += indexHealth.getActivePrimaryShards();
|
||||||
activeShards += indexHealth.activeShards;
|
activeShards += indexHealth.getActiveShards();
|
||||||
relocatingShards += indexHealth.relocatingShards;
|
relocatingShards += indexHealth.getRelocatingShards();
|
||||||
initializingShards += indexHealth.initializingShards;
|
initializingShards += indexHealth.getInitializingShards();
|
||||||
unassignedShards += indexHealth.unassignedShards;
|
unassignedShards += indexHealth.getUnassignedShards();
|
||||||
if (indexHealth.getStatus() == ClusterHealthStatus.RED) {
|
if (indexHealth.getStatus() == ClusterHealthStatus.RED) {
|
||||||
status = ClusterHealthStatus.RED;
|
status = ClusterHealthStatus.RED;
|
||||||
} else if (indexHealth.getStatus() == ClusterHealthStatus.YELLOW && 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 + "]");
|
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;
|
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() {
|
private ClusterIndexHealth() {
|
||||||
}
|
}
|
||||||
|
@ -77,33 +77,8 @@ public class ClusterIndexHealth implements Iterable<ClusterShardHealth>, Streama
|
||||||
this.validationFailures = indexRoutingTable.validate(indexMetaData);
|
this.validationFailures = indexRoutingTable.validate(indexMetaData);
|
||||||
|
|
||||||
for (IndexShardRoutingTable shardRoutingTable : indexRoutingTable) {
|
for (IndexShardRoutingTable shardRoutingTable : indexRoutingTable) {
|
||||||
ClusterShardHealth shardHealth = new ClusterShardHealth(shardRoutingTable.shardId().id());
|
int shardId = shardRoutingTable.shardId().id();
|
||||||
for (ShardRouting shardRouting : shardRoutingTable) {
|
shards.put(shardId, new ClusterShardHealth(shardId, 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the index status
|
// update the index status
|
||||||
|
@ -113,10 +88,10 @@ public class ClusterIndexHealth implements Iterable<ClusterShardHealth>, Streama
|
||||||
if (shardHealth.isPrimaryActive()) {
|
if (shardHealth.isPrimaryActive()) {
|
||||||
activePrimaryShards++;
|
activePrimaryShards++;
|
||||||
}
|
}
|
||||||
activeShards += shardHealth.activeShards;
|
activeShards += shardHealth.getActiveShards();
|
||||||
relocatingShards += shardHealth.relocatingShards;
|
relocatingShards += shardHealth.getRelocatingShards();
|
||||||
initializingShards += shardHealth.initializingShards;
|
initializingShards += shardHealth.getInitializingShards();
|
||||||
unassignedShards += shardHealth.unassignedShards;
|
unassignedShards += shardHealth.getUnassignedShards();
|
||||||
|
|
||||||
if (shardHealth.getStatus() == ClusterHealthStatus.RED) {
|
if (shardHealth.getStatus() == ClusterHealthStatus.RED) {
|
||||||
status = ClusterHealthStatus.RED;
|
status = ClusterHealthStatus.RED;
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
package org.elasticsearch.action.admin.cluster.health;
|
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.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.io.stream.Streamable;
|
import org.elasticsearch.common.io.stream.Streamable;
|
||||||
|
@ -34,22 +36,47 @@ public class ClusterShardHealth implements Streamable {
|
||||||
|
|
||||||
ClusterHealthStatus status = ClusterHealthStatus.RED;
|
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() {
|
private ClusterShardHealth() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ClusterShardHealth(int shardId) {
|
public ClusterShardHealth(int shardId, final IndexShardRoutingTable shardRoutingTable) {
|
||||||
this.shardId = shardId;
|
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() {
|
public int getId() {
|
||||||
|
|
|
@ -25,13 +25,14 @@ import org.elasticsearch.action.support.IndicesOptions;
|
||||||
import org.elasticsearch.action.support.master.TransportMasterNodeReadAction;
|
import org.elasticsearch.action.support.master.TransportMasterNodeReadAction;
|
||||||
import org.elasticsearch.cluster.*;
|
import org.elasticsearch.cluster.*;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.routing.UnassignedInfo;
|
import org.elasticsearch.cluster.routing.UnassignedInfo;
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.gateway.GatewayAllocator;
|
import org.elasticsearch.gateway.GatewayAllocator;
|
||||||
import org.elasticsearch.indices.IndexMissingException;
|
import org.elasticsearch.index.IndexNotFoundException;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.transport.TransportService;
|
import org.elasticsearch.transport.TransportService;
|
||||||
|
|
||||||
|
@ -44,9 +45,10 @@ public class TransportClusterHealthAction extends TransportMasterNodeReadAction<
|
||||||
private final GatewayAllocator gatewayAllocator;
|
private final GatewayAllocator gatewayAllocator;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportClusterHealthAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
|
public TransportClusterHealthAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
ClusterName clusterName, ActionFilters actionFilters, GatewayAllocator gatewayAllocator) {
|
ThreadPool threadPool, ClusterName clusterName, ActionFilters actionFilters,
|
||||||
super(settings, ClusterHealthAction.NAME, transportService, clusterService, threadPool, actionFilters, ClusterHealthRequest.class);
|
IndexNameExpressionResolver indexNameExpressionResolver, GatewayAllocator gatewayAllocator) {
|
||||||
|
super(settings, ClusterHealthAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, ClusterHealthRequest.class);
|
||||||
this.clusterName = clusterName;
|
this.clusterName = clusterName;
|
||||||
this.gatewayAllocator = gatewayAllocator;
|
this.gatewayAllocator = gatewayAllocator;
|
||||||
}
|
}
|
||||||
|
@ -199,9 +201,9 @@ public class TransportClusterHealthAction extends TransportMasterNodeReadAction<
|
||||||
}
|
}
|
||||||
if (request.indices().length > 0) {
|
if (request.indices().length > 0) {
|
||||||
try {
|
try {
|
||||||
clusterState.metaData().concreteIndices(IndicesOptions.strictExpand(), request.indices());
|
indexNameExpressionResolver.concreteIndices(clusterState, IndicesOptions.strictExpand(), request.indices());
|
||||||
waitForCounter++;
|
waitForCounter++;
|
||||||
} catch (IndexMissingException e) {
|
} catch (IndexNotFoundException e) {
|
||||||
response.status = ClusterHealthStatus.RED; // no indices, make sure its RED
|
response.status = ClusterHealthStatus.RED; // no indices, make sure its RED
|
||||||
// missing indices, wait a bit more...
|
// missing indices, wait a bit more...
|
||||||
}
|
}
|
||||||
|
@ -266,8 +268,8 @@ public class TransportClusterHealthAction extends TransportMasterNodeReadAction<
|
||||||
|
|
||||||
String[] concreteIndices;
|
String[] concreteIndices;
|
||||||
try {
|
try {
|
||||||
concreteIndices = clusterState.metaData().concreteIndices(request.indicesOptions(), request.indices());
|
concreteIndices = indexNameExpressionResolver.concreteIndices(clusterState, request);
|
||||||
} catch (IndexMissingException e) {
|
} catch (IndexNotFoundException e) {
|
||||||
// one of the specified indices is not there - treat it as RED.
|
// one of the specified indices is not there - treat it as RED.
|
||||||
ClusterHealthResponse response = new ClusterHealthResponse(clusterName.value(), Strings.EMPTY_ARRAY, clusterState,
|
ClusterHealthResponse response = new ClusterHealthResponse(clusterName.value(), Strings.EMPTY_ARRAY, clusterState,
|
||||||
numberOfPendingTasks, numberOfInFlightFetch, UnassignedInfo.getNumberOfDelayedUnassigned(settings, 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.action.support.nodes.TransportNodesAction;
|
||||||
import org.elasticsearch.cluster.ClusterName;
|
import org.elasticsearch.cluster.ClusterName;
|
||||||
import org.elasticsearch.cluster.ClusterService;
|
import org.elasticsearch.cluster.ClusterService;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
|
@ -45,9 +46,10 @@ public class TransportNodesHotThreadsAction extends TransportNodesAction<NodesHo
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportNodesHotThreadsAction(Settings settings, ClusterName clusterName, ThreadPool threadPool,
|
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,
|
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
|
@Override
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.action.admin.cluster.node.info;
|
package org.elasticsearch.action.admin.cluster.node.info;
|
||||||
|
|
||||||
import org.elasticsearch.Version;
|
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
|
|
|
@ -28,6 +28,8 @@ import org.elasticsearch.common.xcontent.XContentBuilderString;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class PluginsInfo implements Streamable, ToXContent {
|
public class PluginsInfo implements Streamable, ToXContent {
|
||||||
|
@ -45,7 +47,17 @@ public class PluginsInfo implements Streamable, ToXContent {
|
||||||
infos = new ArrayList<>(size);
|
infos = new ArrayList<>(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return an ordered list based on plugins name
|
||||||
|
*/
|
||||||
public List<PluginInfo> getInfos() {
|
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;
|
return infos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +82,7 @@ public class PluginsInfo implements Streamable, ToXContent {
|
||||||
@Override
|
@Override
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
public void writeTo(StreamOutput out) throws IOException {
|
||||||
out.writeInt(infos.size());
|
out.writeInt(infos.size());
|
||||||
for (PluginInfo plugin : infos) {
|
for (PluginInfo plugin : getInfos()) {
|
||||||
plugin.writeTo(out);
|
plugin.writeTo(out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,7 +90,7 @@ public class PluginsInfo implements Streamable, ToXContent {
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
builder.startArray(Fields.PLUGINS);
|
builder.startArray(Fields.PLUGINS);
|
||||||
for (PluginInfo pluginInfo : infos) {
|
for (PluginInfo pluginInfo : getInfos()) {
|
||||||
pluginInfo.toXContent(builder, params);
|
pluginInfo.toXContent(builder, params);
|
||||||
}
|
}
|
||||||
builder.endArray();
|
builder.endArray();
|
||||||
|
|
|
@ -24,6 +24,7 @@ import org.elasticsearch.action.support.nodes.BaseNodeRequest;
|
||||||
import org.elasticsearch.action.support.nodes.TransportNodesAction;
|
import org.elasticsearch.action.support.nodes.TransportNodesAction;
|
||||||
import org.elasticsearch.cluster.ClusterName;
|
import org.elasticsearch.cluster.ClusterName;
|
||||||
import org.elasticsearch.cluster.ClusterService;
|
import org.elasticsearch.cluster.ClusterService;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
|
@ -47,9 +48,9 @@ public class TransportNodesInfoAction extends TransportNodesAction<NodesInfoRequ
|
||||||
@Inject
|
@Inject
|
||||||
public TransportNodesInfoAction(Settings settings, ClusterName clusterName, ThreadPool threadPool,
|
public TransportNodesInfoAction(Settings settings, ClusterName clusterName, ThreadPool threadPool,
|
||||||
ClusterService clusterService, TransportService transportService,
|
ClusterService clusterService, TransportService transportService,
|
||||||
NodeService nodeService, ActionFilters actionFilters) {
|
NodeService nodeService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
super(settings, NodesInfoAction.NAME, clusterName, threadPool, clusterService, transportService, actionFilters,
|
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;
|
this.nodeService = nodeService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.elasticsearch.action.support.nodes.BaseNodeRequest;
|
||||||
import org.elasticsearch.action.support.nodes.TransportNodesAction;
|
import org.elasticsearch.action.support.nodes.TransportNodesAction;
|
||||||
import org.elasticsearch.cluster.ClusterName;
|
import org.elasticsearch.cluster.ClusterName;
|
||||||
import org.elasticsearch.cluster.ClusterService;
|
import org.elasticsearch.cluster.ClusterService;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
|
@ -47,8 +48,8 @@ public class TransportNodesStatsAction extends TransportNodesAction<NodesStatsRe
|
||||||
@Inject
|
@Inject
|
||||||
public TransportNodesStatsAction(Settings settings, ClusterName clusterName, ThreadPool threadPool,
|
public TransportNodesStatsAction(Settings settings, ClusterName clusterName, ThreadPool threadPool,
|
||||||
ClusterService clusterService, TransportService transportService,
|
ClusterService clusterService, TransportService transportService,
|
||||||
NodeService nodeService, ActionFilters actionFilters) {
|
NodeService nodeService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
super(settings, NodesStatsAction.NAME, clusterName, threadPool, clusterService, transportService, actionFilters,
|
super(settings, NodesStatsAction.NAME, clusterName, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
|
||||||
NodesStatsRequest.class, NodeStatsRequest.class, ThreadPool.Names.MANAGEMENT);
|
NodesStatsRequest.class, NodeStatsRequest.class, ThreadPool.Names.MANAGEMENT);
|
||||||
this.nodeService = nodeService;
|
this.nodeService = nodeService;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.ack.ClusterStateUpdateResponse;
|
import org.elasticsearch.cluster.ack.ClusterStateUpdateResponse;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.repositories.RepositoriesService;
|
import org.elasticsearch.repositories.RepositoriesService;
|
||||||
|
@ -42,8 +43,9 @@ public class TransportDeleteRepositoryAction extends TransportMasterNodeAction<D
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportDeleteRepositoryAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
public TransportDeleteRepositoryAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
RepositoriesService repositoriesService, ThreadPool threadPool, ActionFilters actionFilters) {
|
RepositoriesService repositoriesService, ThreadPool threadPool, ActionFilters actionFilters,
|
||||||
super(settings, DeleteRepositoryAction.NAME, transportService, clusterService, threadPool, actionFilters, DeleteRepositoryRequest.class);
|
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, DeleteRepositoryAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, DeleteRepositoryRequest.class);
|
||||||
this.repositoriesService = repositoriesService;
|
this.repositoriesService = repositoriesService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.MetaData;
|
import org.elasticsearch.cluster.metadata.MetaData;
|
||||||
import org.elasticsearch.cluster.metadata.RepositoriesMetaData;
|
import org.elasticsearch.cluster.metadata.RepositoriesMetaData;
|
||||||
import org.elasticsearch.cluster.metadata.RepositoryMetaData;
|
import org.elasticsearch.cluster.metadata.RepositoryMetaData;
|
||||||
|
@ -43,8 +44,8 @@ public class TransportGetRepositoriesAction extends TransportMasterNodeReadActio
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportGetRepositoriesAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
public TransportGetRepositoriesAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
ThreadPool threadPool, ActionFilters actionFilters) {
|
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
super(settings, GetRepositoriesAction.NAME, transportService, clusterService, threadPool, actionFilters, GetRepositoriesRequest.class);
|
super(settings, GetRepositoriesAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, GetRepositoriesRequest.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.ack.ClusterStateUpdateResponse;
|
import org.elasticsearch.cluster.ack.ClusterStateUpdateResponse;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.repositories.RepositoriesService;
|
import org.elasticsearch.repositories.RepositoriesService;
|
||||||
|
@ -42,8 +43,9 @@ public class TransportPutRepositoryAction extends TransportMasterNodeAction<PutR
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportPutRepositoryAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
public TransportPutRepositoryAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
RepositoriesService repositoriesService, ThreadPool threadPool, ActionFilters actionFilters) {
|
RepositoriesService repositoriesService, ThreadPool threadPool, ActionFilters actionFilters,
|
||||||
super(settings, PutRepositoryAction.NAME, transportService, clusterService, threadPool, actionFilters, PutRepositoryRequest.class);
|
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, PutRepositoryAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, PutRepositoryRequest.class);
|
||||||
this.repositoriesService = repositoriesService;
|
this.repositoriesService = repositoriesService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.repositories.RepositoriesService;
|
import org.elasticsearch.repositories.RepositoriesService;
|
||||||
|
@ -45,8 +46,9 @@ public class TransportVerifyRepositoryAction extends TransportMasterNodeAction<V
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportVerifyRepositoryAction(Settings settings, ClusterName clusterName, TransportService transportService, ClusterService clusterService,
|
public TransportVerifyRepositoryAction(Settings settings, ClusterName clusterName, TransportService transportService, ClusterService clusterService,
|
||||||
RepositoriesService repositoriesService, ThreadPool threadPool, ActionFilters actionFilters) {
|
RepositoriesService repositoriesService, ThreadPool threadPool, ActionFilters actionFilters,
|
||||||
super(settings, VerifyRepositoryAction.NAME, transportService, clusterService, threadPool, actionFilters, VerifyRepositoryRequest.class);
|
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, VerifyRepositoryAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, VerifyRepositoryRequest.class);
|
||||||
this.repositoriesService = repositoriesService;
|
this.repositoriesService = repositoriesService;
|
||||||
this.clusterName = clusterName;
|
this.clusterName = clusterName;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
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.AllocationService;
|
||||||
import org.elasticsearch.cluster.routing.allocation.RoutingAllocation;
|
import org.elasticsearch.cluster.routing.allocation.RoutingAllocation;
|
||||||
import org.elasticsearch.cluster.routing.allocation.RoutingExplanations;
|
import org.elasticsearch.cluster.routing.allocation.RoutingExplanations;
|
||||||
|
@ -44,8 +45,8 @@ public class TransportClusterRerouteAction extends TransportMasterNodeAction<Clu
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportClusterRerouteAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
|
public TransportClusterRerouteAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
|
||||||
AllocationService allocationService, ActionFilters actionFilters) {
|
AllocationService allocationService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
super(settings, ClusterRerouteAction.NAME, transportService, clusterService, threadPool, actionFilters, ClusterRerouteRequest.class);
|
super(settings, ClusterRerouteAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, ClusterRerouteRequest.class);
|
||||||
this.allocationService = allocationService;
|
this.allocationService = allocationService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlocks;
|
import org.elasticsearch.cluster.block.ClusterBlocks;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.MetaData;
|
import org.elasticsearch.cluster.metadata.MetaData;
|
||||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||||
import org.elasticsearch.cluster.routing.allocation.AllocationService;
|
import org.elasticsearch.cluster.routing.allocation.AllocationService;
|
||||||
|
@ -57,8 +58,9 @@ public class TransportClusterUpdateSettingsAction extends TransportMasterNodeAct
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportClusterUpdateSettingsAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
|
public TransportClusterUpdateSettingsAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
|
||||||
AllocationService allocationService, @ClusterDynamicSettings DynamicSettings dynamicSettings, ActionFilters actionFilters) {
|
AllocationService allocationService, @ClusterDynamicSettings DynamicSettings dynamicSettings,
|
||||||
super(settings, ClusterUpdateSettingsAction.NAME, transportService, clusterService, threadPool, actionFilters, ClusterUpdateSettingsRequest.class);
|
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, ClusterUpdateSettingsAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, ClusterUpdateSettingsRequest.class);
|
||||||
this.allocationService = allocationService;
|
this.allocationService = allocationService;
|
||||||
this.dynamicSettings = dynamicSettings;
|
this.dynamicSettings = dynamicSettings;
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,17 +84,7 @@ public class ClusterSearchShardsResponse extends ActionResponse implements ToXCo
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
builder.startObject("nodes");
|
builder.startObject("nodes");
|
||||||
for (DiscoveryNode node : nodes) {
|
for (DiscoveryNode node : nodes) {
|
||||||
builder.startObject(node.getId(), XContentBuilder.FieldCaseConversion.NONE);
|
node.toXContent(builder, params);
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
builder.startArray("shards");
|
builder.startArray("shards");
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||||
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
||||||
import org.elasticsearch.cluster.routing.ShardIterator;
|
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> {
|
public class TransportClusterSearchShardsAction extends TransportMasterNodeReadAction<ClusterSearchShardsRequest, ClusterSearchShardsResponse> {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportClusterSearchShardsAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters) {
|
public TransportClusterSearchShardsAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
super(settings, ClusterSearchShardsAction.NAME, transportService, clusterService, threadPool, actionFilters, ClusterSearchShardsRequest.class);
|
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, ClusterSearchShardsAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, ClusterSearchShardsRequest.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -57,7 +59,7 @@ public class TransportClusterSearchShardsAction extends TransportMasterNodeReadA
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ClusterBlockException checkBlock(ClusterSearchShardsRequest request, ClusterState state) {
|
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
|
@Override
|
||||||
|
@ -68,10 +70,10 @@ public class TransportClusterSearchShardsAction extends TransportMasterNodeReadA
|
||||||
@Override
|
@Override
|
||||||
protected void masterOperation(final ClusterSearchShardsRequest request, final ClusterState state, final ActionListener<ClusterSearchShardsResponse> listener) {
|
protected void masterOperation(final ClusterSearchShardsRequest request, final ClusterState state, final ActionListener<ClusterSearchShardsResponse> listener) {
|
||||||
ClusterState clusterState = clusterService.state();
|
ClusterState clusterState = clusterService.state();
|
||||||
String[] concreteIndices = clusterState.metaData().concreteIndices(request.indicesOptions(), request.indices());
|
String[] concreteIndices = indexNameExpressionResolver.concreteIndices(clusterState, request);
|
||||||
Map<String, Set<String>> routingMap = clusterState.metaData().resolveSearchRouting(request.routing(), request.indices());
|
Map<String, Set<String>> routingMap = indexNameExpressionResolver.resolveSearchRouting(state, request.routing(), request.indices());
|
||||||
Set<String> nodeIds = newHashSet();
|
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;
|
ShardRouting shard;
|
||||||
ClusterSearchShardsGroup[] groupResponses = new ClusterSearchShardsGroup[groupShardsIterator.size()];
|
ClusterSearchShardsGroup[] groupResponses = new ClusterSearchShardsGroup[groupShardsIterator.size()];
|
||||||
int currentGroup = 0;
|
int currentGroup = 0;
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.SnapshotId;
|
import org.elasticsearch.cluster.metadata.SnapshotId;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
@ -42,8 +43,9 @@ public class TransportCreateSnapshotAction extends TransportMasterNodeAction<Cre
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportCreateSnapshotAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
public TransportCreateSnapshotAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
ThreadPool threadPool, SnapshotsService snapshotsService, ActionFilters actionFilters) {
|
ThreadPool threadPool, SnapshotsService snapshotsService, ActionFilters actionFilters,
|
||||||
super(settings, CreateSnapshotAction.NAME, transportService, clusterService, threadPool, actionFilters, CreateSnapshotRequest.class);
|
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, CreateSnapshotAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, CreateSnapshotRequest.class);
|
||||||
this.snapshotsService = snapshotsService;
|
this.snapshotsService = snapshotsService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +66,7 @@ public class TransportCreateSnapshotAction extends TransportMasterNodeAction<Cre
|
||||||
if (clusterBlockException != null) {
|
if (clusterBlockException != null) {
|
||||||
return clusterBlockException;
|
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
|
@Override
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.SnapshotId;
|
import org.elasticsearch.cluster.metadata.SnapshotId;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
@ -41,8 +42,9 @@ public class TransportDeleteSnapshotAction extends TransportMasterNodeAction<Del
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportDeleteSnapshotAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
public TransportDeleteSnapshotAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
ThreadPool threadPool, SnapshotsService snapshotsService, ActionFilters actionFilters) {
|
ThreadPool threadPool, SnapshotsService snapshotsService, ActionFilters actionFilters,
|
||||||
super(settings, DeleteSnapshotAction.NAME, transportService, clusterService, threadPool, actionFilters, DeleteSnapshotRequest.class);
|
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, DeleteSnapshotAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, DeleteSnapshotRequest.class);
|
||||||
this.snapshotsService = snapshotsService;
|
this.snapshotsService = snapshotsService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.SnapshotId;
|
import org.elasticsearch.cluster.metadata.SnapshotId;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
@ -46,8 +47,9 @@ public class TransportGetSnapshotsAction extends TransportMasterNodeAction<GetSn
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportGetSnapshotsAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
public TransportGetSnapshotsAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
ThreadPool threadPool, SnapshotsService snapshotsService, ActionFilters actionFilters) {
|
ThreadPool threadPool, SnapshotsService snapshotsService, ActionFilters actionFilters,
|
||||||
super(settings, GetSnapshotsAction.NAME, transportService, clusterService, threadPool, actionFilters, GetSnapshotsRequest.class);
|
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, GetSnapshotsAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, GetSnapshotsRequest.class);
|
||||||
this.snapshotsService = snapshotsService;
|
this.snapshotsService = snapshotsService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.SnapshotId;
|
import org.elasticsearch.cluster.metadata.SnapshotId;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
@ -42,8 +43,9 @@ public class TransportRestoreSnapshotAction extends TransportMasterNodeAction<Re
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportRestoreSnapshotAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
public TransportRestoreSnapshotAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
ThreadPool threadPool, RestoreService restoreService, ActionFilters actionFilters) {
|
ThreadPool threadPool, RestoreService restoreService, ActionFilters actionFilters,
|
||||||
super(settings, RestoreSnapshotAction.NAME, transportService, clusterService, threadPool, actionFilters, RestoreSnapshotRequest.class);
|
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, RestoreSnapshotAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, RestoreSnapshotRequest.class);
|
||||||
this.restoreService = restoreService;
|
this.restoreService = restoreService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.action.support.ActionFilters;
|
||||||
import org.elasticsearch.action.support.nodes.*;
|
import org.elasticsearch.action.support.nodes.*;
|
||||||
import org.elasticsearch.cluster.ClusterName;
|
import org.elasticsearch.cluster.ClusterName;
|
||||||
import org.elasticsearch.cluster.ClusterService;
|
import org.elasticsearch.cluster.ClusterService;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.SnapshotId;
|
import org.elasticsearch.cluster.metadata.SnapshotId;
|
||||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
@ -55,8 +56,11 @@ public class TransportNodesSnapshotsStatus extends TransportNodesAction<Transpor
|
||||||
private final SnapshotShardsService snapshotShardsService;
|
private final SnapshotShardsService snapshotShardsService;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportNodesSnapshotsStatus(Settings settings, ClusterName clusterName, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, SnapshotShardsService snapshotShardsService, ActionFilters actionFilters) {
|
public TransportNodesSnapshotsStatus(Settings settings, ClusterName clusterName, ThreadPool threadPool,
|
||||||
super(settings, ACTION_NAME, clusterName, threadPool, clusterService, transportService, actionFilters,
|
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);
|
Request.class, NodeRequest.class, ThreadPool.Names.GENERIC);
|
||||||
this.snapshotShardsService = snapshotShardsService;
|
this.snapshotShardsService = snapshotShardsService;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.SnapshotId;
|
import org.elasticsearch.cluster.metadata.SnapshotId;
|
||||||
import org.elasticsearch.cluster.SnapshotsInProgress;
|
import org.elasticsearch.cluster.SnapshotsInProgress;
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
|
@ -57,8 +58,11 @@ public class TransportSnapshotsStatusAction extends TransportMasterNodeAction<Sn
|
||||||
private final TransportNodesSnapshotsStatus transportNodesSnapshotsStatus;
|
private final TransportNodesSnapshotsStatus transportNodesSnapshotsStatus;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportSnapshotsStatusAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, SnapshotsService snapshotsService, TransportNodesSnapshotsStatus transportNodesSnapshotsStatus, ActionFilters actionFilters) {
|
public TransportSnapshotsStatusAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
super(settings, SnapshotsStatusAction.NAME, transportService, clusterService, threadPool, actionFilters, SnapshotsStatusRequest.class);
|
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.snapshotsService = snapshotsService;
|
||||||
this.transportNodesSnapshotsStatus = transportNodesSnapshotsStatus;
|
this.transportNodesSnapshotsStatus = transportNodesSnapshotsStatus;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.MetaData;
|
import org.elasticsearch.cluster.metadata.MetaData;
|
||||||
import org.elasticsearch.cluster.metadata.MetaData.Custom;
|
import org.elasticsearch.cluster.metadata.MetaData.Custom;
|
||||||
import org.elasticsearch.cluster.routing.RoutingTable;
|
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||||
|
@ -45,8 +46,8 @@ public class TransportClusterStateAction extends TransportMasterNodeReadAction<C
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportClusterStateAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
|
public TransportClusterStateAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
|
||||||
ClusterName clusterName, ActionFilters actionFilters) {
|
ClusterName clusterName, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
super(settings, ClusterStateAction.NAME, transportService, clusterService, threadPool, actionFilters, ClusterStateRequest.class);
|
super(settings, ClusterStateAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, ClusterStateRequest.class);
|
||||||
this.clusterName = clusterName;
|
this.clusterName = clusterName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +77,7 @@ public class TransportClusterStateAction extends TransportMasterNodeReadAction<C
|
||||||
logger.trace("Serving cluster state request using version {}", currentState.version());
|
logger.trace("Serving cluster state request using version {}", currentState.version());
|
||||||
ClusterState.Builder builder = ClusterState.builder(currentState.getClusterName());
|
ClusterState.Builder builder = ClusterState.builder(currentState.getClusterName());
|
||||||
builder.version(currentState.version());
|
builder.version(currentState.version());
|
||||||
builder.uuid(currentState.uuid());
|
builder.stateUUID(currentState.stateUUID());
|
||||||
if (request.nodes()) {
|
if (request.nodes()) {
|
||||||
builder.nodes(currentState.nodes());
|
builder.nodes(currentState.nodes());
|
||||||
}
|
}
|
||||||
|
@ -105,7 +106,7 @@ public class TransportClusterStateAction extends TransportMasterNodeReadAction<C
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.indices().length > 0) {
|
if (request.indices().length > 0) {
|
||||||
String[] indices = currentState.metaData().concreteIndices(request.indicesOptions(), request.indices());
|
String[] indices = indexNameExpressionResolver.concreteIndices(currentState, request);
|
||||||
for (String filteredIndex : indices) {
|
for (String filteredIndex : indices) {
|
||||||
IndexMetaData indexMetaData = currentState.metaData().index(filteredIndex);
|
IndexMetaData indexMetaData = currentState.metaData().index(filteredIndex);
|
||||||
if (indexMetaData != null) {
|
if (indexMetaData != null) {
|
||||||
|
|
|
@ -31,6 +31,7 @@ import org.elasticsearch.action.support.nodes.TransportNodesAction;
|
||||||
import org.elasticsearch.cluster.ClusterName;
|
import org.elasticsearch.cluster.ClusterName;
|
||||||
import org.elasticsearch.cluster.ClusterService;
|
import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.routing.IndexRoutingTable;
|
import org.elasticsearch.cluster.routing.IndexRoutingTable;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
|
@ -65,9 +66,10 @@ public class TransportClusterStatsAction extends TransportNodesAction<ClusterSta
|
||||||
@Inject
|
@Inject
|
||||||
public TransportClusterStatsAction(Settings settings, ClusterName clusterName, ThreadPool threadPool,
|
public TransportClusterStatsAction(Settings settings, ClusterName clusterName, ThreadPool threadPool,
|
||||||
ClusterService clusterService, TransportService transportService,
|
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,
|
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.nodeService = nodeService;
|
||||||
this.indicesService = indicesService;
|
this.indicesService = indicesService;
|
||||||
}
|
}
|
||||||
|
@ -82,7 +84,7 @@ public class TransportClusterStatsAction extends TransportNodesAction<ClusterSta
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new ClusterStatsResponse(System.currentTimeMillis(), clusterName,
|
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
|
@Override
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
|
@ -38,8 +39,9 @@ public class TransportPendingClusterTasksAction extends TransportMasterNodeReadA
|
||||||
private final ClusterService clusterService;
|
private final ClusterService clusterService;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportPendingClusterTasksAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters) {
|
public TransportPendingClusterTasksAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
super(settings, PendingClusterTasksAction.NAME, transportService, clusterService, threadPool, actionFilters, PendingClusterTasksRequest.class);
|
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, PendingClusterTasksAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, PendingClusterTasksRequest.class);
|
||||||
this.clusterService = clusterService;
|
this.clusterService = clusterService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,10 +30,11 @@ import org.elasticsearch.cluster.ack.ClusterStateUpdateResponse;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
import org.elasticsearch.cluster.metadata.AliasAction;
|
import org.elasticsearch.cluster.metadata.AliasAction;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.MetaDataIndexAliasesService;
|
import org.elasticsearch.cluster.metadata.MetaDataIndexAliasesService;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
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.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.transport.TransportService;
|
import org.elasticsearch.transport.TransportService;
|
||||||
|
|
||||||
|
@ -48,8 +49,9 @@ public class TransportIndicesAliasesAction extends TransportMasterNodeAction<Ind
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportIndicesAliasesAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
public TransportIndicesAliasesAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
ThreadPool threadPool, MetaDataIndexAliasesService indexAliasesService, ActionFilters actionFilters) {
|
ThreadPool threadPool, MetaDataIndexAliasesService indexAliasesService,
|
||||||
super(settings, IndicesAliasesAction.NAME, transportService, clusterService, threadPool, actionFilters, IndicesAliasesRequest.class);
|
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, IndicesAliasesAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, IndicesAliasesRequest.class);
|
||||||
this.indexAliasesService = indexAliasesService;
|
this.indexAliasesService = indexAliasesService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +87,7 @@ public class TransportIndicesAliasesAction extends TransportMasterNodeAction<Ind
|
||||||
Set<String> aliases = new HashSet<>();
|
Set<String> aliases = new HashSet<>();
|
||||||
for (AliasActions action : actions) {
|
for (AliasActions action : actions) {
|
||||||
//expand indices
|
//expand indices
|
||||||
String[] concreteIndices = state.metaData().concreteIndices(request.indicesOptions(), action.indices());
|
String[] concreteIndices = indexNameExpressionResolver.concreteIndices(state, request.indicesOptions(), action.indices());
|
||||||
//collect the aliases
|
//collect the aliases
|
||||||
Collections.addAll(aliases, action.aliases());
|
Collections.addAll(aliases, action.aliases());
|
||||||
for (String index : concreteIndices) {
|
for (String index : concreteIndices) {
|
||||||
|
@ -100,7 +102,7 @@ public class TransportIndicesAliasesAction extends TransportMasterNodeAction<Ind
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasOnlyDeletesButNoneCanBeDone && actions.size() != 0) {
|
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();
|
request.aliasActions().clear();
|
||||||
IndicesAliasesClusterStateUpdateRequest updateRequest = new IndicesAliasesClusterStateUpdateRequest()
|
IndicesAliasesClusterStateUpdateRequest updateRequest = new IndicesAliasesClusterStateUpdateRequest()
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
|
@ -36,8 +37,9 @@ import org.elasticsearch.transport.TransportService;
|
||||||
public class TransportAliasesExistAction extends TransportMasterNodeReadAction<GetAliasesRequest, AliasesExistResponse> {
|
public class TransportAliasesExistAction extends TransportMasterNodeReadAction<GetAliasesRequest, AliasesExistResponse> {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportAliasesExistAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters) {
|
public TransportAliasesExistAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
super(settings, AliasesExistAction.NAME, transportService, clusterService, threadPool, actionFilters, GetAliasesRequest.class);
|
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, AliasesExistAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, GetAliasesRequest.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -48,7 +50,7 @@ public class TransportAliasesExistAction extends TransportMasterNodeReadAction<G
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ClusterBlockException checkBlock(GetAliasesRequest request, ClusterState state) {
|
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
|
@Override
|
||||||
|
@ -58,7 +60,7 @@ public class TransportAliasesExistAction extends TransportMasterNodeReadAction<G
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void masterOperation(GetAliasesRequest request, ClusterState state, ActionListener<AliasesExistResponse> listener) {
|
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);
|
boolean result = state.metaData().hasAliases(request.aliases(), concreteIndices);
|
||||||
listener.onResponse(new AliasesExistResponse(result));
|
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.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
import org.elasticsearch.cluster.metadata.AliasMetaData;
|
import org.elasticsearch.cluster.metadata.AliasMetaData;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
@ -39,8 +40,9 @@ import java.util.List;
|
||||||
public class TransportGetAliasesAction extends TransportMasterNodeReadAction<GetAliasesRequest, GetAliasesResponse> {
|
public class TransportGetAliasesAction extends TransportMasterNodeReadAction<GetAliasesRequest, GetAliasesResponse> {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportGetAliasesAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters) {
|
public TransportGetAliasesAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
super(settings, GetAliasesAction.NAME, transportService, clusterService, threadPool, actionFilters, GetAliasesRequest.class);
|
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, GetAliasesAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, GetAliasesRequest.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -51,7 +53,7 @@ public class TransportGetAliasesAction extends TransportMasterNodeReadAction<Get
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ClusterBlockException checkBlock(GetAliasesRequest request, ClusterState state) {
|
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
|
@Override
|
||||||
|
@ -61,7 +63,7 @@ public class TransportGetAliasesAction extends TransportMasterNodeReadAction<Get
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void masterOperation(GetAliasesRequest request, ClusterState state, ActionListener<GetAliasesResponse> listener) {
|
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
|
@SuppressWarnings("unchecked") // ImmutableList to List results incompatible type
|
||||||
ImmutableOpenMap<String, List<AliasMetaData>> result = (ImmutableOpenMap) state.metaData().findAliases(request.aliases(), concreteIndices);
|
ImmutableOpenMap<String, List<AliasMetaData>> result = (ImmutableOpenMap) state.metaData().findAliases(request.aliases(), concreteIndices);
|
||||||
listener.onResponse(new GetAliasesResponse(result));
|
listener.onResponse(new GetAliasesResponse(result));
|
||||||
|
|
|
@ -34,14 +34,14 @@ import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.routing.ShardsIterator;
|
import org.elasticsearch.cluster.routing.ShardsIterator;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
import org.elasticsearch.index.IndexService;
|
||||||
import org.elasticsearch.index.analysis.*;
|
import org.elasticsearch.index.analysis.*;
|
||||||
import org.elasticsearch.index.mapper.FieldMapper;
|
|
||||||
import org.elasticsearch.index.mapper.MappedFieldType;
|
import org.elasticsearch.index.mapper.MappedFieldType;
|
||||||
import org.elasticsearch.index.mapper.internal.AllFieldMapper;
|
import org.elasticsearch.index.mapper.internal.AllFieldMapper;
|
||||||
import org.elasticsearch.index.IndexService;
|
|
||||||
import org.elasticsearch.index.shard.ShardId;
|
import org.elasticsearch.index.shard.ShardId;
|
||||||
import org.elasticsearch.indices.IndicesService;
|
import org.elasticsearch.indices.IndicesService;
|
||||||
import org.elasticsearch.indices.analysis.IndicesAnalysisService;
|
import org.elasticsearch.indices.analysis.IndicesAnalysisService;
|
||||||
|
@ -63,8 +63,9 @@ public class TransportAnalyzeAction extends TransportSingleCustomOperationAction
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportAnalyzeAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService,
|
public TransportAnalyzeAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService,
|
||||||
IndicesService indicesService, IndicesAnalysisService indicesAnalysisService, ActionFilters actionFilters) {
|
IndicesService indicesService, IndicesAnalysisService indicesAnalysisService, ActionFilters actionFilters,
|
||||||
super(settings, AnalyzeAction.NAME, threadPool, clusterService, transportService, actionFilters, AnalyzeRequest.class, ThreadPool.Names.INDEX);
|
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, AnalyzeAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver, AnalyzeRequest.class, ThreadPool.Names.INDEX);
|
||||||
this.indicesService = indicesService;
|
this.indicesService = indicesService;
|
||||||
this.indicesAnalysisService = indicesAnalysisService;
|
this.indicesAnalysisService = indicesAnalysisService;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
||||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
@ -55,8 +56,9 @@ public class TransportClearIndicesCacheAction extends TransportBroadcastAction<C
|
||||||
@Inject
|
@Inject
|
||||||
public TransportClearIndicesCacheAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
|
public TransportClearIndicesCacheAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
|
||||||
TransportService transportService, IndicesService indicesService,
|
TransportService transportService, IndicesService indicesService,
|
||||||
IndicesRequestCache indicesQueryCache, ActionFilters actionFilters) {
|
IndicesRequestCache indicesQueryCache, ActionFilters actionFilters,
|
||||||
super(settings, ClearIndicesCacheAction.NAME, threadPool, clusterService, transportService, actionFilters,
|
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, ClearIndicesCacheAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
|
||||||
ClearIndicesCacheRequest.class, ShardClearIndicesCacheRequest.class, ThreadPool.Names.MANAGEMENT);
|
ClearIndicesCacheRequest.class, ShardClearIndicesCacheRequest.class, ThreadPool.Names.MANAGEMENT);
|
||||||
this.indicesService = indicesService;
|
this.indicesService = indicesService;
|
||||||
this.indicesRequestCache = indicesQueryCache;
|
this.indicesRequestCache = indicesQueryCache;
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.ack.ClusterStateUpdateResponse;
|
import org.elasticsearch.cluster.ack.ClusterStateUpdateResponse;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.MetaDataIndexStateService;
|
import org.elasticsearch.cluster.metadata.MetaDataIndexStateService;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
@ -45,8 +46,10 @@ public class TransportCloseIndexAction extends TransportMasterNodeAction<CloseIn
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportCloseIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
public TransportCloseIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
ThreadPool threadPool, MetaDataIndexStateService indexStateService, NodeSettingsService nodeSettingsService, ActionFilters actionFilters) {
|
ThreadPool threadPool, MetaDataIndexStateService indexStateService,
|
||||||
super(settings, CloseIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, CloseIndexRequest.class);
|
NodeSettingsService nodeSettingsService, ActionFilters actionFilters,
|
||||||
|
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, CloseIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, CloseIndexRequest.class);
|
||||||
this.indexStateService = indexStateService;
|
this.indexStateService = indexStateService;
|
||||||
this.destructiveOperations = new DestructiveOperations(logger, settings, nodeSettingsService);
|
this.destructiveOperations = new DestructiveOperations(logger, settings, nodeSettingsService);
|
||||||
}
|
}
|
||||||
|
@ -70,12 +73,12 @@ public class TransportCloseIndexAction extends TransportMasterNodeAction<CloseIn
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ClusterBlockException checkBlock(CloseIndexRequest request, ClusterState state) {
|
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
|
@Override
|
||||||
protected void masterOperation(final CloseIndexRequest request, final ClusterState state, final ActionListener<CloseIndexResponse> listener) {
|
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()
|
CloseIndexClusterStateUpdateRequest updateRequest = new CloseIndexClusterStateUpdateRequest()
|
||||||
.ackTimeout(request.timeout()).masterNodeTimeout(request.masterNodeTimeout())
|
.ackTimeout(request.timeout()).masterNodeTimeout(request.masterNodeTimeout())
|
||||||
.indices(concreteIndices);
|
.indices(concreteIndices);
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.ack.ClusterStateUpdateResponse;
|
import org.elasticsearch.cluster.ack.ClusterStateUpdateResponse;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.MetaDataCreateIndexService;
|
import org.elasticsearch.cluster.metadata.MetaDataCreateIndexService;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
@ -43,8 +44,9 @@ public class TransportCreateIndexAction extends TransportMasterNodeAction<Create
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportCreateIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
public TransportCreateIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
ThreadPool threadPool, MetaDataCreateIndexService createIndexService, ActionFilters actionFilters) {
|
ThreadPool threadPool, MetaDataCreateIndexService createIndexService,
|
||||||
super(settings, CreateIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, CreateIndexRequest.class);
|
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, CreateIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, CreateIndexRequest.class);
|
||||||
this.createIndexService = createIndexService;
|
this.createIndexService = createIndexService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.MetaDataDeleteIndexService;
|
import org.elasticsearch.cluster.metadata.MetaDataDeleteIndexService;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
@ -46,8 +47,9 @@ public class TransportDeleteIndexAction extends TransportMasterNodeAction<Delete
|
||||||
@Inject
|
@Inject
|
||||||
public TransportDeleteIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
public TransportDeleteIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
ThreadPool threadPool, MetaDataDeleteIndexService deleteIndexService,
|
ThreadPool threadPool, MetaDataDeleteIndexService deleteIndexService,
|
||||||
NodeSettingsService nodeSettingsService, ActionFilters actionFilters) {
|
NodeSettingsService nodeSettingsService, ActionFilters actionFilters,
|
||||||
super(settings, DeleteIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, DeleteIndexRequest.class);
|
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, DeleteIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, DeleteIndexRequest.class);
|
||||||
this.deleteIndexService = deleteIndexService;
|
this.deleteIndexService = deleteIndexService;
|
||||||
this.destructiveOperations = new DestructiveOperations(logger, settings, nodeSettingsService);
|
this.destructiveOperations = new DestructiveOperations(logger, settings, nodeSettingsService);
|
||||||
}
|
}
|
||||||
|
@ -70,12 +72,12 @@ public class TransportDeleteIndexAction extends TransportMasterNodeAction<Delete
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ClusterBlockException checkBlock(DeleteIndexRequest request, ClusterState state) {
|
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
|
@Override
|
||||||
protected void masterOperation(final DeleteIndexRequest request, final ClusterState state, final ActionListener<DeleteIndexResponse> listener) {
|
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) {
|
if (concreteIndices.length == 0) {
|
||||||
listener.onResponse(new DeleteIndexResponse(true));
|
listener.onResponse(new DeleteIndexResponse(true));
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -27,9 +27,10 @@ import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.indices.IndexMissingException;
|
import org.elasticsearch.index.IndexNotFoundException;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.transport.TransportService;
|
import org.elasticsearch.transport.TransportService;
|
||||||
|
|
||||||
|
@ -40,8 +41,8 @@ public class TransportIndicesExistsAction extends TransportMasterNodeReadAction<
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportIndicesExistsAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
public TransportIndicesExistsAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
ThreadPool threadPool, ActionFilters actionFilters) {
|
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
super(settings, IndicesExistsAction.NAME, transportService, clusterService, threadPool, actionFilters, IndicesExistsRequest.class);
|
super(settings, IndicesExistsAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, IndicesExistsRequest.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -59,7 +60,7 @@ public class TransportIndicesExistsAction extends TransportMasterNodeReadAction<
|
||||||
protected ClusterBlockException checkBlock(IndicesExistsRequest request, ClusterState state) {
|
protected ClusterBlockException checkBlock(IndicesExistsRequest request, ClusterState state) {
|
||||||
//make sure through indices options that the concrete indices call never throws IndexMissingException
|
//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());
|
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
|
@Override
|
||||||
|
@ -67,9 +68,9 @@ public class TransportIndicesExistsAction extends TransportMasterNodeReadAction<
|
||||||
boolean exists;
|
boolean exists;
|
||||||
try {
|
try {
|
||||||
// Similar as the previous behaviour, but now also aliases and wildcards are supported.
|
// 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;
|
exists = true;
|
||||||
} catch (IndexMissingException e) {
|
} catch (IndexNotFoundException e) {
|
||||||
exists = false;
|
exists = false;
|
||||||
}
|
}
|
||||||
listener.onResponse(new IndicesExistsResponse(exists));
|
listener.onResponse(new IndicesExistsResponse(exists));
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.MappingMetaData;
|
import org.elasticsearch.cluster.metadata.MappingMetaData;
|
||||||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
@ -39,8 +40,8 @@ public class TransportTypesExistsAction extends TransportMasterNodeReadAction<Ty
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportTypesExistsAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
public TransportTypesExistsAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
ThreadPool threadPool, ActionFilters actionFilters) {
|
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
super(settings, TypesExistsAction.NAME, transportService, clusterService, threadPool, actionFilters, TypesExistsRequest.class);
|
super(settings, TypesExistsAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, TypesExistsRequest.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -56,12 +57,12 @@ public class TransportTypesExistsAction extends TransportMasterNodeReadAction<Ty
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ClusterBlockException checkBlock(TypesExistsRequest request, ClusterState state) {
|
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
|
@Override
|
||||||
protected void masterOperation(final TypesExistsRequest request, final ClusterState state, final ActionListener<TypesExistsResponse> listener) {
|
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) {
|
if (concreteIndices.length == 0) {
|
||||||
listener.onResponse(new TypesExistsResponse(false));
|
listener.onResponse(new TypesExistsResponse(false));
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
||||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
@ -50,8 +51,10 @@ public class TransportFlushAction extends TransportBroadcastAction<FlushRequest,
|
||||||
private final IndicesService indicesService;
|
private final IndicesService indicesService;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportFlushAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, IndicesService indicesService, ActionFilters actionFilters) {
|
public TransportFlushAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
|
||||||
super(settings, FlushAction.NAME, threadPool, clusterService, transportService, actionFilters,
|
TransportService transportService, IndicesService indicesService,
|
||||||
|
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, FlushAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
|
||||||
FlushRequest.class, ShardFlushRequest.class, ThreadPool.Names.FLUSH);
|
FlushRequest.class, ShardFlushRequest.class, ThreadPool.Names.FLUSH);
|
||||||
this.indicesService = indicesService;
|
this.indicesService = indicesService;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
import org.elasticsearch.cluster.metadata.AliasMetaData;
|
import org.elasticsearch.cluster.metadata.AliasMetaData;
|
||||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.MappingMetaData;
|
import org.elasticsearch.cluster.metadata.MappingMetaData;
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||||
|
@ -47,8 +48,8 @@ public class TransportGetIndexAction extends TransportClusterInfoAction<GetIndex
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportGetIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
public TransportGetIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
ThreadPool threadPool, ActionFilters actionFilters) {
|
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
super(settings, GetIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, GetIndexRequest.class);
|
super(settings, GetIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, GetIndexRequest.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -59,7 +60,7 @@ public class TransportGetIndexAction extends TransportClusterInfoAction<GetIndex
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ClusterBlockException checkBlock(GetIndexRequest request, ClusterState state) {
|
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
|
@Override
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.elasticsearch.action.support.ActionFilters;
|
||||||
import org.elasticsearch.action.support.HandledTransportAction;
|
import org.elasticsearch.action.support.HandledTransportAction;
|
||||||
import org.elasticsearch.cluster.ClusterService;
|
import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.common.collect.MapBuilder;
|
import org.elasticsearch.common.collect.MapBuilder;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
@ -42,8 +43,10 @@ public class TransportGetFieldMappingsAction extends HandledTransportAction<GetF
|
||||||
private final TransportGetFieldMappingsIndexAction shardAction;
|
private final TransportGetFieldMappingsIndexAction shardAction;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportGetFieldMappingsAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, TransportGetFieldMappingsIndexAction shardAction, ActionFilters actionFilters) {
|
public TransportGetFieldMappingsAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
super(settings, GetFieldMappingsAction.NAME, threadPool, transportService, actionFilters, GetFieldMappingsRequest.class);
|
ThreadPool threadPool, TransportGetFieldMappingsIndexAction shardAction,
|
||||||
|
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, GetFieldMappingsAction.NAME, threadPool, transportService, actionFilters, indexNameExpressionResolver, GetFieldMappingsRequest.class);
|
||||||
this.clusterService = clusterService;
|
this.clusterService = clusterService;
|
||||||
this.shardAction = shardAction;
|
this.shardAction = shardAction;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +54,7 @@ public class TransportGetFieldMappingsAction extends HandledTransportAction<GetF
|
||||||
@Override
|
@Override
|
||||||
protected void doExecute(GetFieldMappingsRequest request, final ActionListener<GetFieldMappingsResponse> listener) {
|
protected void doExecute(GetFieldMappingsRequest request, final ActionListener<GetFieldMappingsResponse> listener) {
|
||||||
ClusterState clusterState = clusterService.state();
|
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 indexCounter = new AtomicInteger();
|
||||||
final AtomicInteger completionCounter = new AtomicInteger(concreteIndices.length);
|
final AtomicInteger completionCounter = new AtomicInteger(concreteIndices.length);
|
||||||
final AtomicReferenceArray<Object> indexResponses = new AtomicReferenceArray<>(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.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.routing.ShardsIterator;
|
import org.elasticsearch.cluster.routing.ShardsIterator;
|
||||||
import org.elasticsearch.common.collect.MapBuilder;
|
import org.elasticsearch.common.collect.MapBuilder;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
@ -65,11 +66,10 @@ public class TransportGetFieldMappingsIndexAction extends TransportSingleCustomO
|
||||||
private final IndicesService indicesService;
|
private final IndicesService indicesService;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportGetFieldMappingsIndexAction(Settings settings, ClusterService clusterService,
|
public TransportGetFieldMappingsIndexAction(Settings settings, ClusterService clusterService, TransportService transportService,
|
||||||
TransportService transportService,
|
IndicesService indicesService, ThreadPool threadPool, ActionFilters actionFilters,
|
||||||
IndicesService indicesService,
|
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
ThreadPool threadPool, ActionFilters actionFilters) {
|
super(settings, ACTION_NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver, GetFieldMappingsIndexRequest.class, ThreadPool.Names.MANAGEMENT);
|
||||||
super(settings, ACTION_NAME, threadPool, clusterService, transportService, actionFilters, GetFieldMappingsIndexRequest.class, ThreadPool.Names.MANAGEMENT);
|
|
||||||
this.clusterService = clusterService;
|
this.clusterService = clusterService;
|
||||||
this.indicesService = indicesService;
|
this.indicesService = indicesService;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.MappingMetaData;
|
import org.elasticsearch.cluster.metadata.MappingMetaData;
|
||||||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
@ -38,8 +39,9 @@ import org.elasticsearch.transport.TransportService;
|
||||||
public class TransportGetMappingsAction extends TransportClusterInfoAction<GetMappingsRequest, GetMappingsResponse> {
|
public class TransportGetMappingsAction extends TransportClusterInfoAction<GetMappingsRequest, GetMappingsResponse> {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportGetMappingsAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters) {
|
public TransportGetMappingsAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
super(settings, GetMappingsAction.NAME, transportService, clusterService, threadPool, actionFilters, GetMappingsRequest.class);
|
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, GetMappingsAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, GetMappingsRequest.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -50,7 +52,7 @@ public class TransportGetMappingsAction extends TransportClusterInfoAction<GetMa
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ClusterBlockException checkBlock(GetMappingsRequest request, ClusterState state) {
|
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
|
@Override
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.ack.ClusterStateUpdateResponse;
|
import org.elasticsearch.cluster.ack.ClusterStateUpdateResponse;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.MetaDataMappingService;
|
import org.elasticsearch.cluster.metadata.MetaDataMappingService;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
@ -42,8 +43,9 @@ public class TransportPutMappingAction extends TransportMasterNodeAction<PutMapp
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportPutMappingAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
public TransportPutMappingAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
ThreadPool threadPool, MetaDataMappingService metaDataMappingService, ActionFilters actionFilters) {
|
ThreadPool threadPool, MetaDataMappingService metaDataMappingService,
|
||||||
super(settings, PutMappingAction.NAME, transportService, clusterService, threadPool, actionFilters, PutMappingRequest.class);
|
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, PutMappingAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, PutMappingRequest.class);
|
||||||
this.metaDataMappingService = metaDataMappingService;
|
this.metaDataMappingService = metaDataMappingService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,12 +62,12 @@ public class TransportPutMappingAction extends TransportMasterNodeAction<PutMapp
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ClusterBlockException checkBlock(PutMappingRequest request, ClusterState state) {
|
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
|
@Override
|
||||||
protected void masterOperation(final PutMappingRequest request, final ClusterState state, final ActionListener<PutMappingResponse> listener) {
|
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()
|
PutMappingClusterStateUpdateRequest updateRequest = new PutMappingClusterStateUpdateRequest()
|
||||||
.ackTimeout(request.timeout()).masterNodeTimeout(request.masterNodeTimeout())
|
.ackTimeout(request.timeout()).masterNodeTimeout(request.masterNodeTimeout())
|
||||||
.indices(concreteIndices).type(request.type())
|
.indices(concreteIndices).type(request.type())
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.ack.ClusterStateUpdateResponse;
|
import org.elasticsearch.cluster.ack.ClusterStateUpdateResponse;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.MetaDataIndexStateService;
|
import org.elasticsearch.cluster.metadata.MetaDataIndexStateService;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
@ -45,8 +46,9 @@ public class TransportOpenIndexAction extends TransportMasterNodeAction<OpenInde
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportOpenIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
public TransportOpenIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
ThreadPool threadPool, MetaDataIndexStateService indexStateService, NodeSettingsService nodeSettingsService, ActionFilters actionFilters) {
|
ThreadPool threadPool, MetaDataIndexStateService indexStateService,
|
||||||
super(settings, OpenIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, OpenIndexRequest.class);
|
NodeSettingsService nodeSettingsService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, OpenIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, OpenIndexRequest.class);
|
||||||
this.indexStateService = indexStateService;
|
this.indexStateService = indexStateService;
|
||||||
this.destructiveOperations = new DestructiveOperations(logger, settings, nodeSettingsService);
|
this.destructiveOperations = new DestructiveOperations(logger, settings, nodeSettingsService);
|
||||||
}
|
}
|
||||||
|
@ -70,12 +72,12 @@ public class TransportOpenIndexAction extends TransportMasterNodeAction<OpenInde
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ClusterBlockException checkBlock(OpenIndexRequest request, ClusterState state) {
|
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
|
@Override
|
||||||
protected void masterOperation(final OpenIndexRequest request, final ClusterState state, final ActionListener<OpenIndexResponse> listener) {
|
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()
|
OpenIndexClusterStateUpdateRequest updateRequest = new OpenIndexClusterStateUpdateRequest()
|
||||||
.ackTimeout(request.timeout()).masterNodeTimeout(request.masterNodeTimeout())
|
.ackTimeout(request.timeout()).masterNodeTimeout(request.masterNodeTimeout())
|
||||||
.indices(concreteIndices);
|
.indices(concreteIndices);
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
||||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
@ -51,8 +52,9 @@ public class TransportOptimizeAction extends TransportBroadcastAction<OptimizeRe
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportOptimizeAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
|
public TransportOptimizeAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
|
||||||
TransportService transportService, IndicesService indicesService, ActionFilters actionFilters) {
|
TransportService transportService, IndicesService indicesService,
|
||||||
super(settings, OptimizeAction.NAME, threadPool, clusterService, transportService, actionFilters,
|
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, OptimizeAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
|
||||||
OptimizeRequest.class, ShardOptimizeRequest.class, ThreadPool.Names.OPTIMIZE);
|
OptimizeRequest.class, ShardOptimizeRequest.class, ThreadPool.Names.OPTIMIZE);
|
||||||
this.indicesService = indicesService;
|
this.indicesService = indicesService;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
||||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
@ -57,8 +58,9 @@ public class TransportRecoveryAction extends TransportBroadcastAction<RecoveryRe
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportRecoveryAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
|
public TransportRecoveryAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
|
||||||
TransportService transportService, IndicesService indicesService, ActionFilters actionFilters) {
|
TransportService transportService, IndicesService indicesService,
|
||||||
super(settings, RecoveryAction.NAME, threadPool, clusterService, transportService, actionFilters,
|
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, RecoveryAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
|
||||||
RecoveryRequest.class, ShardRecoveryRequest.class, ThreadPool.Names.MANAGEMENT);
|
RecoveryRequest.class, ShardRecoveryRequest.class, ThreadPool.Names.MANAGEMENT);
|
||||||
this.indicesService = indicesService;
|
this.indicesService = indicesService;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
||||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
@ -51,8 +52,9 @@ public class TransportRefreshAction extends TransportBroadcastAction<RefreshRequ
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportRefreshAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
|
public TransportRefreshAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
|
||||||
TransportService transportService, IndicesService indicesService, ActionFilters actionFilters) {
|
TransportService transportService, IndicesService indicesService,
|
||||||
super(settings, RefreshAction.NAME, threadPool, clusterService, transportService, actionFilters,
|
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, RefreshAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
|
||||||
RefreshRequest.class, ShardRefreshRequest.class, ThreadPool.Names.REFRESH);
|
RefreshRequest.class, ShardRefreshRequest.class, ThreadPool.Names.REFRESH);
|
||||||
this.indicesService = indicesService;
|
this.indicesService = indicesService;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
||||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
@ -57,8 +58,8 @@ public class TransportIndicesSegmentsAction extends TransportBroadcastAction<Ind
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportIndicesSegmentsAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService,
|
public TransportIndicesSegmentsAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService,
|
||||||
IndicesService indicesService, ActionFilters actionFilters) {
|
IndicesService indicesService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
super(settings, IndicesSegmentsAction.NAME, threadPool, clusterService, transportService, actionFilters,
|
super(settings, IndicesSegmentsAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
|
||||||
IndicesSegmentsRequest.class, TransportIndicesSegmentsAction.IndexShardSegmentRequest.class, ThreadPool.Names.MANAGEMENT);
|
IndicesSegmentsRequest.class, TransportIndicesSegmentsAction.IndexShardSegmentRequest.class, ThreadPool.Names.MANAGEMENT);
|
||||||
this.indicesService = indicesService;
|
this.indicesService = indicesService;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.regex.Regex;
|
import org.elasticsearch.common.regex.Regex;
|
||||||
|
@ -46,8 +47,9 @@ public class TransportGetSettingsAction extends TransportMasterNodeReadAction<Ge
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportGetSettingsAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
public TransportGetSettingsAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
ThreadPool threadPool, SettingsFilter settingsFilter, ActionFilters actionFilters) {
|
ThreadPool threadPool, SettingsFilter settingsFilter, ActionFilters actionFilters,
|
||||||
super(settings, GetSettingsAction.NAME, transportService, clusterService, threadPool, actionFilters, GetSettingsRequest.class);
|
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, GetSettingsAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, GetSettingsRequest.class);
|
||||||
this.settingsFilter = settingsFilter;
|
this.settingsFilter = settingsFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +61,7 @@ public class TransportGetSettingsAction extends TransportMasterNodeReadAction<Ge
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ClusterBlockException checkBlock(GetSettingsRequest request, ClusterState state) {
|
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
|
@Override
|
||||||
protected void masterOperation(GetSettingsRequest request, ClusterState state, ActionListener<GetSettingsResponse> listener) {
|
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();
|
ImmutableOpenMap.Builder<String, Settings> indexToSettingsBuilder = ImmutableOpenMap.builder();
|
||||||
for (String concreteIndex : concreteIndices) {
|
for (String concreteIndex : concreteIndices) {
|
||||||
IndexMetaData indexMetaData = state.getMetaData().index(concreteIndex);
|
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.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.MetaDataUpdateSettingsService;
|
import org.elasticsearch.cluster.metadata.MetaDataUpdateSettingsService;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
@ -43,8 +44,8 @@ public class TransportUpdateSettingsAction extends TransportMasterNodeAction<Upd
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportUpdateSettingsAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
|
public TransportUpdateSettingsAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
|
||||||
MetaDataUpdateSettingsService updateSettingsService, ActionFilters actionFilters) {
|
MetaDataUpdateSettingsService updateSettingsService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
super(settings, UpdateSettingsAction.NAME, transportService, clusterService, threadPool, actionFilters, UpdateSettingsRequest.class);
|
super(settings, UpdateSettingsAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, UpdateSettingsRequest.class);
|
||||||
this.updateSettingsService = updateSettingsService;
|
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 )) {
|
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 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
|
@Override
|
||||||
|
@ -74,7 +75,7 @@ public class TransportUpdateSettingsAction extends TransportMasterNodeAction<Upd
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void masterOperation(final UpdateSettingsRequest request, final ClusterState state, final ActionListener<UpdateSettingsResponse> listener) {
|
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()
|
UpdateSettingsClusterStateUpdateRequest clusterStateUpdateRequest = new UpdateSettingsClusterStateUpdateRequest()
|
||||||
.indices(concreteIndices)
|
.indices(concreteIndices)
|
||||||
.settings(request.settings())
|
.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.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
||||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
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.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.index.IndexService;
|
import org.elasticsearch.index.IndexService;
|
||||||
import org.elasticsearch.index.IndexShardMissingException;
|
|
||||||
import org.elasticsearch.index.shard.IndexShard;
|
import org.elasticsearch.index.shard.IndexShard;
|
||||||
import org.elasticsearch.index.shard.ShardId;
|
import org.elasticsearch.index.shard.ShardId;
|
||||||
|
import org.elasticsearch.index.shard.ShardNotFoundException;
|
||||||
import org.elasticsearch.indices.IndicesService;
|
import org.elasticsearch.indices.IndicesService;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.transport.TransportService;
|
import org.elasticsearch.transport.TransportService;
|
||||||
|
@ -57,9 +58,10 @@ public class TransportIndicesStatsAction extends TransportBroadcastAction<Indice
|
||||||
private final IndicesService indicesService;
|
private final IndicesService indicesService;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportIndicesStatsAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService,
|
public TransportIndicesStatsAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
|
||||||
IndicesService indicesService, ActionFilters actionFilters) {
|
TransportService transportService, IndicesService indicesService,
|
||||||
super(settings, IndicesStatsAction.NAME, threadPool, clusterService, transportService, actionFilters,
|
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, IndicesStatsAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
|
||||||
IndicesStatsRequest.class, IndexShardStatsRequest.class, ThreadPool.Names.MANAGEMENT);
|
IndicesStatsRequest.class, IndexShardStatsRequest.class, ThreadPool.Names.MANAGEMENT);
|
||||||
this.indicesService = indicesService;
|
this.indicesService = indicesService;
|
||||||
}
|
}
|
||||||
|
@ -123,7 +125,7 @@ public class TransportIndicesStatsAction extends TransportBroadcastAction<Indice
|
||||||
IndexShard indexShard = indexService.shardSafe(request.shardId().id());
|
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 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) {
|
if (indexShard.routingEntry() == null) {
|
||||||
throw new IndexShardMissingException(indexShard.shardId());
|
throw new ShardNotFoundException(indexShard.shardId());
|
||||||
}
|
}
|
||||||
|
|
||||||
CommonStatsFlags flags = new CommonStatsFlags().clear();
|
CommonStatsFlags flags = new CommonStatsFlags().clear();
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.MetaDataIndexTemplateService;
|
import org.elasticsearch.cluster.metadata.MetaDataIndexTemplateService;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
@ -40,8 +41,9 @@ public class TransportDeleteIndexTemplateAction extends TransportMasterNodeActio
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportDeleteIndexTemplateAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
public TransportDeleteIndexTemplateAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
ThreadPool threadPool, MetaDataIndexTemplateService indexTemplateService, ActionFilters actionFilters) {
|
ThreadPool threadPool, MetaDataIndexTemplateService indexTemplateService,
|
||||||
super(settings, DeleteIndexTemplateAction.NAME, transportService, clusterService, threadPool, actionFilters, DeleteIndexTemplateRequest.class);
|
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, DeleteIndexTemplateAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, DeleteIndexTemplateRequest.class);
|
||||||
this.indexTemplateService = indexTemplateService;
|
this.indexTemplateService = indexTemplateService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.IndexTemplateMetaData;
|
import org.elasticsearch.cluster.metadata.IndexTemplateMetaData;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.regex.Regex;
|
import org.elasticsearch.common.regex.Regex;
|
||||||
|
@ -42,8 +43,9 @@ import java.util.List;
|
||||||
public class TransportGetIndexTemplatesAction extends TransportMasterNodeReadAction<GetIndexTemplatesRequest, GetIndexTemplatesResponse> {
|
public class TransportGetIndexTemplatesAction extends TransportMasterNodeReadAction<GetIndexTemplatesRequest, GetIndexTemplatesResponse> {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportGetIndexTemplatesAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters) {
|
public TransportGetIndexTemplatesAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
super(settings, GetIndexTemplatesAction.NAME, transportService, clusterService, threadPool, actionFilters, GetIndexTemplatesRequest.class);
|
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, GetIndexTemplatesAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, GetIndexTemplatesRequest.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.MetaDataIndexTemplateService;
|
import org.elasticsearch.cluster.metadata.MetaDataIndexTemplateService;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
@ -40,8 +41,9 @@ public class TransportPutIndexTemplateAction extends TransportMasterNodeAction<P
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportPutIndexTemplateAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
public TransportPutIndexTemplateAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
ThreadPool threadPool, MetaDataIndexTemplateService indexTemplateService, ActionFilters actionFilters) {
|
ThreadPool threadPool, MetaDataIndexTemplateService indexTemplateService,
|
||||||
super(settings, PutIndexTemplateAction.NAME, transportService, clusterService, threadPool, actionFilters, PutIndexTemplateRequest.class);
|
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, PutIndexTemplateAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, PutIndexTemplateRequest.class);
|
||||||
this.indexTemplateService = indexTemplateService;
|
this.indexTemplateService = indexTemplateService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
||||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
@ -56,8 +57,8 @@ public class TransportUpgradeStatusAction extends TransportBroadcastAction<Upgra
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportUpgradeStatusAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService,
|
public TransportUpgradeStatusAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService,
|
||||||
IndicesService indicesService, ActionFilters actionFilters) {
|
IndicesService indicesService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
super(settings, UpgradeStatusAction.NAME, threadPool, clusterService, transportService, actionFilters,
|
super(settings, UpgradeStatusAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
|
||||||
UpgradeStatusRequest.class, IndexShardUpgradeStatusRequest.class, ThreadPool.Names.MANAGEMENT);
|
UpgradeStatusRequest.class, IndexShardUpgradeStatusRequest.class, ThreadPool.Names.MANAGEMENT);
|
||||||
this.indicesService = indicesService;
|
this.indicesService = indicesService;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.MetaData;
|
import org.elasticsearch.cluster.metadata.MetaData;
|
||||||
import org.elasticsearch.cluster.routing.*;
|
import org.elasticsearch.cluster.routing.*;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
@ -61,8 +62,8 @@ public class TransportUpgradeAction extends TransportBroadcastAction<UpgradeRequ
|
||||||
@Inject
|
@Inject
|
||||||
public TransportUpgradeAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
|
public TransportUpgradeAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
|
||||||
TransportService transportService, IndicesService indicesService, ActionFilters actionFilters,
|
TransportService transportService, IndicesService indicesService, ActionFilters actionFilters,
|
||||||
TransportUpgradeSettingsAction upgradeSettingsAction) {
|
IndexNameExpressionResolver indexNameExpressionResolver, TransportUpgradeSettingsAction upgradeSettingsAction) {
|
||||||
super(settings, UpgradeAction.NAME, threadPool, clusterService, transportService, actionFilters,
|
super(settings, UpgradeAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
|
||||||
UpgradeRequest.class, ShardUpgradeRequest.class, ThreadPool.Names.OPTIMIZE);
|
UpgradeRequest.class, ShardUpgradeRequest.class, ThreadPool.Names.OPTIMIZE);
|
||||||
this.indicesService = indicesService;
|
this.indicesService = indicesService;
|
||||||
this.upgradeSettingsAction = upgradeSettingsAction;
|
this.upgradeSettingsAction = upgradeSettingsAction;
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.ack.ClusterStateUpdateResponse;
|
import org.elasticsearch.cluster.ack.ClusterStateUpdateResponse;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.MetaDataUpdateSettingsService;
|
import org.elasticsearch.cluster.metadata.MetaDataUpdateSettingsService;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
@ -42,8 +43,8 @@ public class TransportUpgradeSettingsAction extends TransportMasterNodeAction<Up
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportUpgradeSettingsAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
|
public TransportUpgradeSettingsAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
|
||||||
MetaDataUpdateSettingsService updateSettingsService, ActionFilters actionFilters) {
|
MetaDataUpdateSettingsService updateSettingsService, IndexNameExpressionResolver indexNameExpressionResolver, ActionFilters actionFilters) {
|
||||||
super(settings, UpgradeSettingsAction.NAME, transportService, clusterService, threadPool, actionFilters, UpgradeSettingsRequest.class);
|
super(settings, UpgradeSettingsAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, UpgradeSettingsRequest.class);
|
||||||
this.updateSettingsService = updateSettingsService;
|
this.updateSettingsService = updateSettingsService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
||||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
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.index.shard.IndexShard;
|
||||||
import org.elasticsearch.indices.IndicesService;
|
import org.elasticsearch.indices.IndicesService;
|
||||||
import org.elasticsearch.script.ScriptService;
|
import org.elasticsearch.script.ScriptService;
|
||||||
|
import org.elasticsearch.search.SearchService;
|
||||||
import org.elasticsearch.search.internal.DefaultSearchContext;
|
import org.elasticsearch.search.internal.DefaultSearchContext;
|
||||||
import org.elasticsearch.search.internal.SearchContext;
|
import org.elasticsearch.search.internal.SearchContext;
|
||||||
import org.elasticsearch.search.internal.ShardSearchLocalRequest;
|
import org.elasticsearch.search.internal.ShardSearchLocalRequest;
|
||||||
|
@ -74,9 +76,12 @@ public class TransportValidateQueryAction extends TransportBroadcastAction<Valid
|
||||||
private final BigArrays bigArrays;
|
private final BigArrays bigArrays;
|
||||||
|
|
||||||
@Inject
|
@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,
|
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.indicesService = indicesService;
|
||||||
this.scriptService = scriptService;
|
this.scriptService = scriptService;
|
||||||
this.pageCacheRecycler = pageCacheRecycler;
|
this.pageCacheRecycler = pageCacheRecycler;
|
||||||
|
@ -91,7 +96,7 @@ public class TransportValidateQueryAction extends TransportBroadcastAction<Valid
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ShardValidateQueryRequest newShardRequest(int numShards, ShardRouting shard, ValidateQueryRequest request) {
|
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);
|
return new ShardValidateQueryRequest(shard.shardId(), filteringAliases, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,8 +108,8 @@ public class TransportValidateQueryAction extends TransportBroadcastAction<Valid
|
||||||
@Override
|
@Override
|
||||||
protected GroupShardsIterator shards(ClusterState clusterState, ValidateQueryRequest request, String[] concreteIndices) {
|
protected GroupShardsIterator shards(ClusterState clusterState, ValidateQueryRequest request, String[] concreteIndices) {
|
||||||
// Hard-code routing to limit request to a single shard, but still, randomize it...
|
// 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());
|
Map<String, Set<String>> routingMap = indexNameExpressionResolver.resolveSearchRouting(clusterState, Integer.toString(ThreadLocalRandom.current().nextInt(1000)), request.indices());
|
||||||
return clusterService.operationRouting().searchShards(clusterState, request.indices(), concreteIndices, routingMap, "_local");
|
return clusterService.operationRouting().searchShards(clusterState, concreteIndices, routingMap, "_local");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -168,7 +173,8 @@ public class TransportValidateQueryAction extends TransportBroadcastAction<Valid
|
||||||
DefaultSearchContext searchContext = new DefaultSearchContext(0,
|
DefaultSearchContext searchContext = new DefaultSearchContext(0,
|
||||||
new ShardSearchLocalRequest(request.types(), request.nowInMillis(), request.filteringAliases()),
|
new ShardSearchLocalRequest(request.types(), request.nowInMillis(), request.filteringAliases()),
|
||||||
null, searcher, indexService, indexShard,
|
null, searcher, indexService, indexShard,
|
||||||
scriptService, pageCacheRecycler, bigArrays, threadPool.estimatedTimeInMillisCounter(), parseFieldMatcher
|
scriptService, pageCacheRecycler, bigArrays, threadPool.estimatedTimeInMillisCounter(), parseFieldMatcher,
|
||||||
|
SearchService.NO_TIMEOUT
|
||||||
);
|
);
|
||||||
SearchContext.setCurrent(searchContext);
|
SearchContext.setCurrent(searchContext);
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.action.admin.indices.validate.template;
|
||||||
import org.elasticsearch.action.ActionListener;
|
import org.elasticsearch.action.ActionListener;
|
||||||
import org.elasticsearch.action.support.ActionFilters;
|
import org.elasticsearch.action.support.ActionFilters;
|
||||||
import org.elasticsearch.action.support.HandledTransportAction;
|
import org.elasticsearch.action.support.HandledTransportAction;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.common.bytes.BytesReference;
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
@ -38,8 +39,8 @@ public class TransportRenderSearchTemplateAction extends HandledTransportAction<
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected TransportRenderSearchTemplateAction(ScriptService scriptService, Settings settings, ThreadPool threadPool,
|
protected TransportRenderSearchTemplateAction(ScriptService scriptService, Settings settings, ThreadPool threadPool,
|
||||||
TransportService transportService, ActionFilters actionFilters) {
|
TransportService transportService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
super(settings, RenderSearchTemplateAction.NAME, threadPool, transportService, actionFilters, RenderSearchTemplateRequest.class);
|
super(settings, RenderSearchTemplateAction.NAME, threadPool, transportService, actionFilters, indexNameExpressionResolver, RenderSearchTemplateRequest.class);
|
||||||
this.scriptService = scriptService;
|
this.scriptService = scriptService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,12 +28,12 @@ import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.MetaData;
|
import org.elasticsearch.cluster.metadata.MetaData;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.regex.Regex;
|
import org.elasticsearch.common.regex.Regex;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.index.Index;
|
import org.elasticsearch.index.IndexNotFoundException;
|
||||||
import org.elasticsearch.indices.IndexMissingException;
|
|
||||||
import org.elasticsearch.search.warmer.IndexWarmerMissingException;
|
import org.elasticsearch.search.warmer.IndexWarmerMissingException;
|
||||||
import org.elasticsearch.search.warmer.IndexWarmersMetaData;
|
import org.elasticsearch.search.warmer.IndexWarmersMetaData;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
|
@ -50,8 +50,9 @@ import java.util.List;
|
||||||
public class TransportDeleteWarmerAction extends TransportMasterNodeAction<DeleteWarmerRequest, DeleteWarmerResponse> {
|
public class TransportDeleteWarmerAction extends TransportMasterNodeAction<DeleteWarmerRequest, DeleteWarmerResponse> {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportDeleteWarmerAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters) {
|
public TransportDeleteWarmerAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
super(settings, DeleteWarmerAction.NAME, transportService, clusterService, threadPool, actionFilters, DeleteWarmerRequest.class);
|
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, DeleteWarmerAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, DeleteWarmerRequest.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -67,12 +68,12 @@ public class TransportDeleteWarmerAction extends TransportMasterNodeAction<Delet
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ClusterBlockException checkBlock(DeleteWarmerRequest request, ClusterState state) {
|
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
|
@Override
|
||||||
protected void masterOperation(final DeleteWarmerRequest request, final ClusterState state, final ActionListener<DeleteWarmerResponse> listener) {
|
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) {
|
clusterService.submitStateUpdateTask("delete_warmer [" + Arrays.toString(request.names()) + "]", new AckedClusterStateUpdateTask<DeleteWarmerResponse>(request, listener) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -94,7 +95,7 @@ public class TransportDeleteWarmerAction extends TransportMasterNodeAction<Delet
|
||||||
for (String index : concreteIndices) {
|
for (String index : concreteIndices) {
|
||||||
IndexMetaData indexMetaData = currentState.metaData().index(index);
|
IndexMetaData indexMetaData = currentState.metaData().index(index);
|
||||||
if (indexMetaData == null) {
|
if (indexMetaData == null) {
|
||||||
throw new IndexMissingException(new Index(index));
|
throw new IndexNotFoundException(index);
|
||||||
}
|
}
|
||||||
IndexWarmersMetaData warmers = indexMetaData.custom(IndexWarmersMetaData.TYPE);
|
IndexWarmersMetaData warmers = indexMetaData.custom(IndexWarmersMetaData.TYPE);
|
||||||
if (warmers != null) {
|
if (warmers != null) {
|
||||||
|
@ -130,7 +131,7 @@ public class TransportDeleteWarmerAction extends TransportMasterNodeAction<Delet
|
||||||
for (String index : concreteIndices) {
|
for (String index : concreteIndices) {
|
||||||
IndexMetaData indexMetaData = currentState.metaData().index(index);
|
IndexMetaData indexMetaData = currentState.metaData().index(index);
|
||||||
if (indexMetaData == null) {
|
if (indexMetaData == null) {
|
||||||
throw new IndexMissingException(new Index(index));
|
throw new IndexNotFoundException(index);
|
||||||
}
|
}
|
||||||
IndexWarmersMetaData warmers = indexMetaData.custom(IndexWarmersMetaData.TYPE);
|
IndexWarmersMetaData warmers = indexMetaData.custom(IndexWarmersMetaData.TYPE);
|
||||||
if (warmers != null) {
|
if (warmers != null) {
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
@ -42,8 +43,9 @@ import org.elasticsearch.transport.TransportService;
|
||||||
public class TransportGetWarmersAction extends TransportClusterInfoAction<GetWarmersRequest, GetWarmersResponse> {
|
public class TransportGetWarmersAction extends TransportClusterInfoAction<GetWarmersRequest, GetWarmersResponse> {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportGetWarmersAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters) {
|
public TransportGetWarmersAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
super(settings, GetWarmersAction.NAME, transportService, clusterService, threadPool, actionFilters, GetWarmersRequest.class);
|
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, GetWarmersAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, GetWarmersRequest.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -54,7 +56,7 @@ public class TransportGetWarmersAction extends TransportClusterInfoAction<GetWar
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ClusterBlockException checkBlock(GetWarmersRequest request, ClusterState state) {
|
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
|
@Override
|
||||||
|
|
|
@ -32,12 +32,12 @@ import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.MetaData;
|
import org.elasticsearch.cluster.metadata.MetaData;
|
||||||
import org.elasticsearch.common.bytes.BytesReference;
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.index.Index;
|
import org.elasticsearch.index.IndexNotFoundException;
|
||||||
import org.elasticsearch.indices.IndexMissingException;
|
|
||||||
import org.elasticsearch.search.warmer.IndexWarmersMetaData;
|
import org.elasticsearch.search.warmer.IndexWarmersMetaData;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.transport.TransportService;
|
import org.elasticsearch.transport.TransportService;
|
||||||
|
@ -57,8 +57,8 @@ public class TransportPutWarmerAction extends TransportMasterNodeAction<PutWarme
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportPutWarmerAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
|
public TransportPutWarmerAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
|
||||||
TransportSearchAction searchAction, ActionFilters actionFilters) {
|
TransportSearchAction searchAction, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
super(settings, PutWarmerAction.NAME, transportService, clusterService, threadPool, actionFilters, PutWarmerRequest.class);
|
super(settings, PutWarmerAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, PutWarmerRequest.class);
|
||||||
this.searchAction = searchAction;
|
this.searchAction = searchAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ public class TransportPutWarmerAction extends TransportMasterNodeAction<PutWarme
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ClusterBlockException checkBlock(PutWarmerRequest request, ClusterState state) {
|
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);
|
ClusterBlockException status = state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_WRITE, concreteIndices);
|
||||||
if (status != null) {
|
if (status != null) {
|
||||||
return status;
|
return status;
|
||||||
|
@ -112,7 +112,7 @@ public class TransportPutWarmerAction extends TransportMasterNodeAction<PutWarme
|
||||||
@Override
|
@Override
|
||||||
public ClusterState execute(ClusterState currentState) {
|
public ClusterState execute(ClusterState currentState) {
|
||||||
MetaData metaData = currentState.metaData();
|
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;
|
BytesReference source = null;
|
||||||
if (request.searchRequest().source() != null && request.searchRequest().source().length() > 0) {
|
if (request.searchRequest().source() != null && request.searchRequest().source().length() > 0) {
|
||||||
|
@ -127,7 +127,7 @@ public class TransportPutWarmerAction extends TransportMasterNodeAction<PutWarme
|
||||||
for (String index : concreteIndices) {
|
for (String index : concreteIndices) {
|
||||||
IndexMetaData indexMetaData = metaData.index(index);
|
IndexMetaData indexMetaData = metaData.index(index);
|
||||||
if (indexMetaData == null) {
|
if (indexMetaData == null) {
|
||||||
throw new IndexMissingException(new Index(index));
|
throw new IndexNotFoundException(index);
|
||||||
}
|
}
|
||||||
IndexWarmersMetaData warmers = indexMetaData.custom(IndexWarmersMetaData.TYPE);
|
IndexWarmersMetaData warmers = indexMetaData.custom(IndexWarmersMetaData.TYPE);
|
||||||
if (warmers == null) {
|
if (warmers == null) {
|
||||||
|
|
|
@ -36,12 +36,12 @@ import org.elasticsearch.action.index.IndexRequest;
|
||||||
import org.elasticsearch.action.support.ActionFilters;
|
import org.elasticsearch.action.support.ActionFilters;
|
||||||
import org.elasticsearch.action.support.AutoCreateIndex;
|
import org.elasticsearch.action.support.AutoCreateIndex;
|
||||||
import org.elasticsearch.action.support.HandledTransportAction;
|
import org.elasticsearch.action.support.HandledTransportAction;
|
||||||
import org.elasticsearch.action.support.IndicesOptions;
|
|
||||||
import org.elasticsearch.action.update.UpdateRequest;
|
import org.elasticsearch.action.update.UpdateRequest;
|
||||||
import org.elasticsearch.cluster.ClusterService;
|
import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.MappingMetaData;
|
import org.elasticsearch.cluster.metadata.MappingMetaData;
|
||||||
import org.elasticsearch.cluster.metadata.MetaData;
|
import org.elasticsearch.cluster.metadata.MetaData;
|
||||||
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
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.settings.Settings;
|
||||||
import org.elasticsearch.common.util.concurrent.AtomicArray;
|
import org.elasticsearch.common.util.concurrent.AtomicArray;
|
||||||
import org.elasticsearch.index.Index;
|
import org.elasticsearch.index.Index;
|
||||||
|
import org.elasticsearch.index.IndexNotFoundException;
|
||||||
import org.elasticsearch.index.shard.ShardId;
|
import org.elasticsearch.index.shard.ShardId;
|
||||||
import org.elasticsearch.indices.IndexAlreadyExistsException;
|
import org.elasticsearch.indices.IndexAlreadyExistsException;
|
||||||
import org.elasticsearch.indices.IndexClosedException;
|
import org.elasticsearch.indices.IndexClosedException;
|
||||||
import org.elasticsearch.indices.IndexMissingException;
|
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.transport.TransportService;
|
import org.elasticsearch.transport.TransportService;
|
||||||
|
|
||||||
|
@ -73,8 +73,9 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportBulkAction(Settings settings, ThreadPool threadPool, TransportService transportService, ClusterService clusterService,
|
public TransportBulkAction(Settings settings, ThreadPool threadPool, TransportService transportService, ClusterService clusterService,
|
||||||
TransportShardBulkAction shardBulkAction, TransportCreateIndexAction createIndexAction, ActionFilters actionFilters) {
|
TransportShardBulkAction shardBulkAction, TransportCreateIndexAction createIndexAction,
|
||||||
super(settings, BulkAction.NAME, threadPool, transportService, actionFilters, BulkRequest.class);
|
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, BulkAction.NAME, threadPool, transportService, actionFilters, indexNameExpressionResolver, BulkRequest.class);
|
||||||
this.clusterService = clusterService;
|
this.clusterService = clusterService;
|
||||||
this.shardBulkAction = shardBulkAction;
|
this.shardBulkAction = shardBulkAction;
|
||||||
this.createIndexAction = createIndexAction;
|
this.createIndexAction = createIndexAction;
|
||||||
|
@ -204,7 +205,7 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
||||||
// TODO use timeout to wait here if its blocked...
|
// TODO use timeout to wait here if its blocked...
|
||||||
clusterState.blocks().globalBlockedRaiseException(ClusterBlockLevel.WRITE);
|
clusterState.blocks().globalBlockedRaiseException(ClusterBlockLevel.WRITE);
|
||||||
|
|
||||||
final ConcreteIndices concreteIndices = new ConcreteIndices(clusterState.metaData());
|
final ConcreteIndices concreteIndices = new ConcreteIndices(clusterState, indexNameExpressionResolver);
|
||||||
MetaData metaData = clusterState.metaData();
|
MetaData metaData = clusterState.metaData();
|
||||||
for (int i = 0; i < bulkRequest.requests.size(); i++) {
|
for (int i = 0; i < bulkRequest.requests.size(); i++) {
|
||||||
ActionRequest request = bulkRequest.requests.get(i);
|
ActionRequest request = bulkRequest.requests.get(i);
|
||||||
|
@ -215,7 +216,7 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
String concreteIndex = concreteIndices.resolveIfAbsent(req.index(), req.indicesOptions());
|
String concreteIndex = concreteIndices.resolveIfAbsent(req);
|
||||||
if (request instanceof IndexRequest) {
|
if (request instanceof IndexRequest) {
|
||||||
IndexRequest indexRequest = (IndexRequest) request;
|
IndexRequest indexRequest = (IndexRequest) request;
|
||||||
MappingMetaData mappingMd = null;
|
MappingMetaData mappingMd = null;
|
||||||
|
@ -232,7 +233,7 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
||||||
bulkRequest.requests.set(i, null);
|
bulkRequest.requests.set(i, null);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
concreteIndices.resolveIfAbsent(req.index(), req.indicesOptions());
|
concreteIndices.resolveIfAbsent(req);
|
||||||
req.routing(clusterState.metaData().resolveIndexRouting(req.routing(), req.index()));
|
req.routing(clusterState.metaData().resolveIndexRouting(req.routing(), req.index()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -361,13 +362,11 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
||||||
Exception unavailableException = null;
|
Exception unavailableException = null;
|
||||||
if (concreteIndex == null) {
|
if (concreteIndex == null) {
|
||||||
try {
|
try {
|
||||||
concreteIndex = concreteIndices.resolveIfAbsent(request.index(), request.indicesOptions());
|
concreteIndex = concreteIndices.resolveIfAbsent(request);
|
||||||
} catch (IndexClosedException ice) {
|
} catch (IndexClosedException | IndexNotFoundException ex) {
|
||||||
unavailableException = ice;
|
|
||||||
} catch (IndexMissingException ime) {
|
|
||||||
// Fix for issue where bulk request references an index that
|
// Fix for issue where bulk request references an index that
|
||||||
// cannot be auto-created see issue #8125
|
// cannot be auto-created see issue #8125
|
||||||
unavailableException = ime;
|
unavailableException = ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (unavailableException == null) {
|
if (unavailableException == null) {
|
||||||
|
@ -398,22 +397,24 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
||||||
|
|
||||||
|
|
||||||
private static class ConcreteIndices {
|
private static class ConcreteIndices {
|
||||||
|
private final ClusterState state;
|
||||||
|
private final IndexNameExpressionResolver indexNameExpressionResolver;
|
||||||
private final Map<String, String> indices = new HashMap<>();
|
private final Map<String, String> indices = new HashMap<>();
|
||||||
private final MetaData metaData;
|
|
||||||
|
|
||||||
ConcreteIndices(MetaData metaData) {
|
ConcreteIndices(ClusterState state, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
this.metaData = metaData;
|
this.state = state;
|
||||||
|
this.indexNameExpressionResolver = indexNameExpressionResolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
String getConcreteIndex(String indexOrAlias) {
|
String getConcreteIndex(String indexOrAlias) {
|
||||||
return indices.get(indexOrAlias);
|
return indices.get(indexOrAlias);
|
||||||
}
|
}
|
||||||
|
|
||||||
String resolveIfAbsent(String indexOrAlias, IndicesOptions indicesOptions) {
|
String resolveIfAbsent(DocumentRequest request) {
|
||||||
String concreteIndex = indices.get(indexOrAlias);
|
String concreteIndex = indices.get(request.index());
|
||||||
if (concreteIndex == null) {
|
if (concreteIndex == null) {
|
||||||
concreteIndex = metaData.concreteSingleIndex(indexOrAlias, indicesOptions);
|
concreteIndex = indexNameExpressionResolver.concreteSingleIndex(state, request);
|
||||||
indices.put(indexOrAlias, concreteIndex);
|
indices.put(request.index(), concreteIndex);
|
||||||
}
|
}
|
||||||
return concreteIndex;
|
return concreteIndex;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.action.index.MappingUpdatedAction;
|
import org.elasticsearch.cluster.action.index.MappingUpdatedAction;
|
||||||
import org.elasticsearch.cluster.action.shard.ShardStateAction;
|
import org.elasticsearch.cluster.action.shard.ShardStateAction;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.MappingMetaData;
|
import org.elasticsearch.cluster.metadata.MappingMetaData;
|
||||||
import org.elasticsearch.cluster.routing.ShardIterator;
|
import org.elasticsearch.cluster.routing.ShardIterator;
|
||||||
import org.elasticsearch.common.bytes.BytesReference;
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
|
@ -78,9 +79,10 @@ public class TransportShardBulkAction extends TransportReplicationAction<BulkSha
|
||||||
@Inject
|
@Inject
|
||||||
public TransportShardBulkAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
public TransportShardBulkAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
IndicesService indicesService, ThreadPool threadPool, ShardStateAction shardStateAction,
|
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,
|
super(settings, ACTION_NAME, transportService, clusterService, indicesService, threadPool, shardStateAction, mappingUpdatedAction,
|
||||||
actionFilters,
|
actionFilters, indexNameExpressionResolver,
|
||||||
BulkShardRequest.class, BulkShardRequest.class, ThreadPool.Names.BULK);
|
BulkShardRequest.class, BulkShardRequest.class, ThreadPool.Names.BULK);
|
||||||
this.updateHelper = updateHelper;
|
this.updateHelper = updateHelper;
|
||||||
this.allowIdGeneration = settings.getAsBoolean("action.allow_id_generation", true);
|
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.ClusterState;
|
||||||
import org.elasticsearch.cluster.action.index.MappingUpdatedAction;
|
import org.elasticsearch.cluster.action.index.MappingUpdatedAction;
|
||||||
import org.elasticsearch.cluster.action.shard.ShardStateAction;
|
import org.elasticsearch.cluster.action.shard.ShardStateAction;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.MappingMetaData;
|
import org.elasticsearch.cluster.metadata.MappingMetaData;
|
||||||
import org.elasticsearch.cluster.routing.ShardIterator;
|
import org.elasticsearch.cluster.routing.ShardIterator;
|
||||||
import org.elasticsearch.common.collect.Tuple;
|
import org.elasticsearch.common.collect.Tuple;
|
||||||
|
@ -59,9 +60,9 @@ public class TransportDeleteAction extends TransportReplicationAction<DeleteRequ
|
||||||
public TransportDeleteAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
public TransportDeleteAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
IndicesService indicesService, ThreadPool threadPool, ShardStateAction shardStateAction,
|
IndicesService indicesService, ThreadPool threadPool, ShardStateAction shardStateAction,
|
||||||
TransportCreateIndexAction createIndexAction, ActionFilters actionFilters,
|
TransportCreateIndexAction createIndexAction, ActionFilters actionFilters,
|
||||||
MappingUpdatedAction mappingUpdatedAction) {
|
IndexNameExpressionResolver indexNameExpressionResolver, MappingUpdatedAction mappingUpdatedAction) {
|
||||||
super(settings, DeleteAction.NAME, transportService, clusterService, indicesService, threadPool, shardStateAction,
|
super(settings, DeleteAction.NAME, transportService, clusterService, indicesService, threadPool, shardStateAction,
|
||||||
mappingUpdatedAction, actionFilters,
|
mappingUpdatedAction, actionFilters, indexNameExpressionResolver,
|
||||||
DeleteRequest.class, DeleteRequest.class, ThreadPool.Names.INDEX);
|
DeleteRequest.class, DeleteRequest.class, ThreadPool.Names.INDEX);
|
||||||
this.createIndexAction = createIndexAction;
|
this.createIndexAction = createIndexAction;
|
||||||
this.autoCreateIndex = new AutoCreateIndex(settings);
|
this.autoCreateIndex = new AutoCreateIndex(settings);
|
||||||
|
|
|
@ -31,6 +31,7 @@ import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
||||||
import org.elasticsearch.cluster.routing.ShardIterator;
|
import org.elasticsearch.cluster.routing.ShardIterator;
|
||||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
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.index.shard.IndexShard;
|
||||||
import org.elasticsearch.indices.IndicesService;
|
import org.elasticsearch.indices.IndicesService;
|
||||||
import org.elasticsearch.script.ScriptService;
|
import org.elasticsearch.script.ScriptService;
|
||||||
|
import org.elasticsearch.search.SearchService;
|
||||||
import org.elasticsearch.search.SearchShardTarget;
|
import org.elasticsearch.search.SearchShardTarget;
|
||||||
import org.elasticsearch.search.internal.DefaultSearchContext;
|
import org.elasticsearch.search.internal.DefaultSearchContext;
|
||||||
import org.elasticsearch.search.internal.SearchContext;
|
import org.elasticsearch.search.internal.SearchContext;
|
||||||
|
@ -71,8 +73,9 @@ public class TransportExistsAction extends TransportBroadcastAction<ExistsReques
|
||||||
@Inject
|
@Inject
|
||||||
public TransportExistsAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService,
|
public TransportExistsAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService,
|
||||||
IndicesService indicesService, ScriptService scriptService,
|
IndicesService indicesService, ScriptService scriptService,
|
||||||
PageCacheRecycler pageCacheRecycler, BigArrays bigArrays, ActionFilters actionFilters) {
|
PageCacheRecycler pageCacheRecycler, BigArrays bigArrays, ActionFilters actionFilters,
|
||||||
super(settings, ExistsAction.NAME, threadPool, clusterService, transportService, actionFilters,
|
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, ExistsAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
|
||||||
ExistsRequest.class, ShardExistsRequest.class, ThreadPool.Names.SEARCH);
|
ExistsRequest.class, ShardExistsRequest.class, ThreadPool.Names.SEARCH);
|
||||||
this.indicesService = indicesService;
|
this.indicesService = indicesService;
|
||||||
this.scriptService = scriptService;
|
this.scriptService = scriptService;
|
||||||
|
@ -88,7 +91,7 @@ public class TransportExistsAction extends TransportBroadcastAction<ExistsReques
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ShardExistsRequest newShardRequest(int numShards, ShardRouting shard, ExistsRequest request) {
|
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);
|
return new ShardExistsRequest(shard.shardId(), filteringAliases, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,8 +102,8 @@ public class TransportExistsAction extends TransportBroadcastAction<ExistsReques
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected GroupShardsIterator shards(ClusterState clusterState, ExistsRequest request, String[] concreteIndices) {
|
protected GroupShardsIterator shards(ClusterState clusterState, ExistsRequest request, String[] concreteIndices) {
|
||||||
Map<String, Set<String>> routingMap = clusterState.metaData().resolveSearchRouting(request.routing(), request.indices());
|
Map<String, Set<String>> routingMap = indexNameExpressionResolver.resolveSearchRouting(clusterState, request.routing(), request.indices());
|
||||||
return clusterService.operationRouting().searchShards(clusterState, request.indices(), concreteIndices, routingMap, request.preference());
|
return clusterService.operationRouting().searchShards(clusterState, concreteIndices, routingMap, request.preference());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -151,7 +154,9 @@ public class TransportExistsAction extends TransportBroadcastAction<ExistsReques
|
||||||
SearchContext context = new DefaultSearchContext(0,
|
SearchContext context = new DefaultSearchContext(0,
|
||||||
new ShardSearchLocalRequest(request.types(), request.nowInMillis(), request.filteringAliases()),
|
new ShardSearchLocalRequest(request.types(), request.nowInMillis(), request.filteringAliases()),
|
||||||
shardTarget, indexShard.acquireSearcher("exists"), indexService, indexShard,
|
shardTarget, indexShard.acquireSearcher("exists"), indexService, indexShard,
|
||||||
scriptService, pageCacheRecycler, bigArrays, threadPool.estimatedTimeInMillisCounter(), parseFieldMatcher);
|
scriptService, pageCacheRecycler, bigArrays, threadPool.estimatedTimeInMillisCounter(), parseFieldMatcher,
|
||||||
|
SearchService.NO_TIMEOUT
|
||||||
|
);
|
||||||
SearchContext.setCurrent(context);
|
SearchContext.setCurrent(context);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.elasticsearch.action.support.single.shard.TransportSingleShardAction;
|
||||||
import org.elasticsearch.cache.recycler.PageCacheRecycler;
|
import org.elasticsearch.cache.recycler.PageCacheRecycler;
|
||||||
import org.elasticsearch.cluster.ClusterService;
|
import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.routing.ShardIterator;
|
import org.elasticsearch.cluster.routing.ShardIterator;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
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.index.shard.ShardId;
|
||||||
import org.elasticsearch.indices.IndicesService;
|
import org.elasticsearch.indices.IndicesService;
|
||||||
import org.elasticsearch.script.ScriptService;
|
import org.elasticsearch.script.ScriptService;
|
||||||
|
import org.elasticsearch.search.SearchService;
|
||||||
import org.elasticsearch.search.internal.DefaultSearchContext;
|
import org.elasticsearch.search.internal.DefaultSearchContext;
|
||||||
import org.elasticsearch.search.internal.SearchContext;
|
import org.elasticsearch.search.internal.SearchContext;
|
||||||
import org.elasticsearch.search.internal.ShardSearchLocalRequest;
|
import org.elasticsearch.search.internal.ShardSearchLocalRequest;
|
||||||
|
@ -70,8 +72,8 @@ public class TransportExplainAction extends TransportSingleShardAction<ExplainRe
|
||||||
public TransportExplainAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
|
public TransportExplainAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
|
||||||
TransportService transportService, IndicesService indicesService,
|
TransportService transportService, IndicesService indicesService,
|
||||||
ScriptService scriptService, PageCacheRecycler pageCacheRecycler,
|
ScriptService scriptService, PageCacheRecycler pageCacheRecycler,
|
||||||
BigArrays bigArrays, ActionFilters actionFilters) {
|
BigArrays bigArrays, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
super(settings, ExplainAction.NAME, threadPool, clusterService, transportService, actionFilters,
|
super(settings, ExplainAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
|
||||||
ExplainRequest.class, ThreadPool.Names.GET);
|
ExplainRequest.class, ThreadPool.Names.GET);
|
||||||
this.indicesService = indicesService;
|
this.indicesService = indicesService;
|
||||||
this.scriptService = scriptService;
|
this.scriptService = scriptService;
|
||||||
|
@ -92,7 +94,7 @@ public class TransportExplainAction extends TransportSingleShardAction<ExplainRe
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void resolveRequest(ClusterState state, InternalRequest request) {
|
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.
|
// Fail fast on the node that received the request.
|
||||||
if (request.request().routing() == null && state.getMetaData().routingRequired(request.concreteIndex(), request.request().type())) {
|
if (request.request().routing() == null && state.getMetaData().routingRequired(request.concreteIndex(), request.request().type())) {
|
||||||
throw new RoutingMissingException(request.concreteIndex(), request.request().type(), request.request().id());
|
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()),
|
0, new ShardSearchLocalRequest(new String[]{request.type()}, request.nowInMillis, request.filteringAlias()),
|
||||||
null, result.searcher(), indexService, indexShard,
|
null, result.searcher(), indexService, indexShard,
|
||||||
scriptService, pageCacheRecycler,
|
scriptService, pageCacheRecycler,
|
||||||
bigArrays, threadPool.estimatedTimeInMillisCounter(), parseFieldMatcher
|
bigArrays, threadPool.estimatedTimeInMillisCounter(), parseFieldMatcher,
|
||||||
|
SearchService.NO_TIMEOUT
|
||||||
);
|
);
|
||||||
SearchContext.setCurrent(context);
|
SearchContext.setCurrent(context);
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
||||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
@ -55,8 +56,10 @@ public class TransportFieldStatsTransportAction extends TransportBroadcastAction
|
||||||
private final IndicesService indicesService;
|
private final IndicesService indicesService;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportFieldStatsTransportAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, ActionFilters actionFilters, IndicesService indicesService) {
|
public TransportFieldStatsTransportAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
|
||||||
super(settings, FieldStatsAction.NAME, threadPool, clusterService, transportService, actionFilters, FieldStatsRequest.class, FieldStatsShardRequest.class, ThreadPool.Names.MANAGEMENT);
|
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;
|
this.indicesService = indicesService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +174,7 @@ public class TransportFieldStatsTransportAction extends TransportBroadcastAction
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected GroupShardsIterator shards(ClusterState clusterState, FieldStatsRequest request, String[] concreteIndices) {
|
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
|
@Override
|
||||||
|
|
|
@ -20,7 +20,9 @@
|
||||||
package org.elasticsearch.action.get;
|
package org.elasticsearch.action.get;
|
||||||
|
|
||||||
import com.google.common.collect.Iterators;
|
import com.google.common.collect.Iterators;
|
||||||
|
import org.elasticsearch.ElasticsearchException;
|
||||||
import org.elasticsearch.action.ActionResponse;
|
import org.elasticsearch.action.ActionResponse;
|
||||||
|
import org.elasticsearch.action.percolate.PercolateResponse;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.io.stream.Streamable;
|
import org.elasticsearch.common.io.stream.Streamable;
|
||||||
|
@ -29,6 +31,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilderString;
|
import org.elasticsearch.common.xcontent.XContentBuilderString;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
public class MultiGetResponse extends ActionResponse implements Iterable<MultiGetItemResponse>, ToXContent {
|
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 index;
|
||||||
private String type;
|
private String type;
|
||||||
private String id;
|
private String id;
|
||||||
private String message;
|
private Throwable throwable;
|
||||||
|
|
||||||
Failure() {
|
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.index = index;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.message = message;
|
this.throwable = throwable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,7 +81,7 @@ public class MultiGetResponse extends ActionResponse implements Iterable<MultiGe
|
||||||
* The failure message.
|
* The failure message.
|
||||||
*/
|
*/
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
return this.message;
|
return throwable != null ? throwable.getMessage() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Failure readFailure(StreamInput in) throws IOException {
|
public static Failure readFailure(StreamInput in) throws IOException {
|
||||||
|
@ -92,7 +95,7 @@ public class MultiGetResponse extends ActionResponse implements Iterable<MultiGe
|
||||||
index = in.readString();
|
index = in.readString();
|
||||||
type = in.readOptionalString();
|
type = in.readOptionalString();
|
||||||
id = in.readString();
|
id = in.readString();
|
||||||
message = in.readString();
|
throwable = in.readThrowable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -100,7 +103,11 @@ public class MultiGetResponse extends ActionResponse implements Iterable<MultiGe
|
||||||
out.writeString(index);
|
out.writeString(index);
|
||||||
out.writeOptionalString(type);
|
out.writeOptionalString(type);
|
||||||
out.writeString(id);
|
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._INDEX, failure.getIndex());
|
||||||
builder.field(Fields._TYPE, failure.getType());
|
builder.field(Fields._TYPE, failure.getType());
|
||||||
builder.field(Fields._ID, failure.getId());
|
builder.field(Fields._ID, failure.getId());
|
||||||
builder.field(Fields.ERROR, failure.getMessage());
|
ElasticsearchException.renderThrowable(builder, params, failure.getFailure());
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
} else {
|
} else {
|
||||||
GetResponse getResponse = response.getResponse();
|
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 _TYPE = new XContentBuilderString("_type");
|
||||||
static final XContentBuilderString _ID = new XContentBuilderString("_id");
|
static final XContentBuilderString _ID = new XContentBuilderString("_id");
|
||||||
static final XContentBuilderString ERROR = new XContentBuilderString("error");
|
static final XContentBuilderString ERROR = new XContentBuilderString("error");
|
||||||
|
static final XContentBuilderString ROOT_CAUSE = new XContentBuilderString("root_cause");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.elasticsearch.action.support.single.shard.TransportSingleShardAction;
|
||||||
import org.elasticsearch.cluster.ClusterService;
|
import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.routing.Preference;
|
import org.elasticsearch.cluster.routing.Preference;
|
||||||
import org.elasticsearch.cluster.routing.ShardIterator;
|
import org.elasticsearch.cluster.routing.ShardIterator;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
@ -47,8 +48,9 @@ public class TransportGetAction extends TransportSingleShardAction<GetRequest, G
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportGetAction(Settings settings, ClusterService clusterService, TransportService transportService,
|
public TransportGetAction(Settings settings, ClusterService clusterService, TransportService transportService,
|
||||||
IndicesService indicesService, ThreadPool threadPool, ActionFilters actionFilters) {
|
IndicesService indicesService, ThreadPool threadPool, ActionFilters actionFilters,
|
||||||
super(settings, GetAction.NAME, threadPool, clusterService, transportService, actionFilters,
|
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, GetAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
|
||||||
GetRequest.class, ThreadPool.Names.GET);
|
GetRequest.class, ThreadPool.Names.GET);
|
||||||
this.indicesService = indicesService;
|
this.indicesService = indicesService;
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,11 @@ import org.elasticsearch.action.support.HandledTransportAction;
|
||||||
import org.elasticsearch.cluster.ClusterService;
|
import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.util.concurrent.AtomicArray;
|
import org.elasticsearch.common.util.concurrent.AtomicArray;
|
||||||
|
import org.elasticsearch.index.IndexNotFoundException;
|
||||||
import org.elasticsearch.index.shard.ShardId;
|
import org.elasticsearch.index.shard.ShardId;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.transport.TransportService;
|
import org.elasticsearch.transport.TransportService;
|
||||||
|
@ -44,8 +46,10 @@ public class TransportMultiGetAction extends HandledTransportAction<MultiGetRequ
|
||||||
private final TransportShardMultiGetAction shardAction;
|
private final TransportShardMultiGetAction shardAction;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportMultiGetAction(Settings settings, ThreadPool threadPool, TransportService transportService, ClusterService clusterService, TransportShardMultiGetAction shardAction, ActionFilters actionFilters) {
|
public TransportMultiGetAction(Settings settings, ThreadPool threadPool, TransportService transportService,
|
||||||
super(settings, MultiGetAction.NAME, threadPool, transportService, actionFilters, MultiGetRequest.class);
|
ClusterService clusterService, TransportShardMultiGetAction shardAction,
|
||||||
|
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, MultiGetAction.NAME, threadPool, transportService, actionFilters, indexNameExpressionResolver, MultiGetRequest.class);
|
||||||
this.clusterService = clusterService;
|
this.clusterService = clusterService;
|
||||||
this.shardAction = shardAction;
|
this.shardAction = shardAction;
|
||||||
}
|
}
|
||||||
|
@ -62,14 +66,14 @@ public class TransportMultiGetAction extends HandledTransportAction<MultiGetRequ
|
||||||
for (int i = 0; i < request.items.size(); i++) {
|
for (int i = 0; i < request.items.size(); i++) {
|
||||||
MultiGetRequest.Item item = request.items.get(i);
|
MultiGetRequest.Item item = request.items.get(i);
|
||||||
if (!clusterState.metaData().hasConcreteIndex(item.index())) {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
item.routing(clusterState.metaData().resolveIndexRouting(item.routing(), item.index()));
|
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())) {
|
if (item.routing() == null && clusterState.getMetaData().routingRequired(concreteSingleIndex, item.type())) {
|
||||||
responses.set(i, new MultiGetItemResponse(null, new MultiGetResponse.Failure(concreteSingleIndex, item.type(), item.id(),
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
ShardId shardId = clusterService.operationRouting()
|
ShardId shardId = clusterService.operationRouting()
|
||||||
|
@ -104,11 +108,10 @@ public class TransportMultiGetAction extends HandledTransportAction<MultiGetRequ
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable e) {
|
public void onFailure(Throwable e) {
|
||||||
// create failures for all relevant requests
|
// create failures for all relevant requests
|
||||||
String message = ExceptionsHelper.detailedMessage(e);
|
|
||||||
for (int i = 0; i < shardRequest.locations.size(); i++) {
|
for (int i = 0; i < shardRequest.locations.size(); i++) {
|
||||||
MultiGetRequest.Item item = shardRequest.items.get(i);
|
MultiGetRequest.Item item = shardRequest.items.get(i);
|
||||||
responses.set(shardRequest.locations.get(i), new MultiGetItemResponse(null,
|
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) {
|
if (counter.decrementAndGet() == 0) {
|
||||||
finishHim();
|
finishHim();
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.elasticsearch.action.support.TransportActions;
|
||||||
import org.elasticsearch.action.support.single.shard.TransportSingleShardAction;
|
import org.elasticsearch.action.support.single.shard.TransportSingleShardAction;
|
||||||
import org.elasticsearch.cluster.ClusterService;
|
import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.routing.ShardIterator;
|
import org.elasticsearch.cluster.routing.ShardIterator;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
@ -47,8 +48,9 @@ public class TransportShardMultiGetAction extends TransportSingleShardAction<Mul
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportShardMultiGetAction(Settings settings, ClusterService clusterService, TransportService transportService,
|
public TransportShardMultiGetAction(Settings settings, ClusterService clusterService, TransportService transportService,
|
||||||
IndicesService indicesService, ThreadPool threadPool, ActionFilters actionFilters) {
|
IndicesService indicesService, ThreadPool threadPool, ActionFilters actionFilters,
|
||||||
super(settings, ACTION_NAME, threadPool, clusterService, transportService, actionFilters,
|
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, ACTION_NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
|
||||||
MultiGetShardRequest.class, ThreadPool.Names.GET);
|
MultiGetShardRequest.class, ThreadPool.Names.GET);
|
||||||
this.indicesService = indicesService;
|
this.indicesService = indicesService;
|
||||||
|
|
||||||
|
@ -103,7 +105,7 @@ public class TransportShardMultiGetAction extends TransportSingleShardAction<Mul
|
||||||
throw (ElasticsearchException) t;
|
throw (ElasticsearchException) t;
|
||||||
} else {
|
} else {
|
||||||
logger.debug("{} failed to execute multi_get for [{}]/[{}]", t, shardId, item.type(), item.id());
|
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.index.MappingUpdatedAction;
|
||||||
import org.elasticsearch.cluster.action.shard.ShardStateAction;
|
import org.elasticsearch.cluster.action.shard.ShardStateAction;
|
||||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.MappingMetaData;
|
import org.elasticsearch.cluster.metadata.MappingMetaData;
|
||||||
import org.elasticsearch.cluster.metadata.MetaData;
|
import org.elasticsearch.cluster.metadata.MetaData;
|
||||||
import org.elasticsearch.cluster.routing.ShardIterator;
|
import org.elasticsearch.cluster.routing.ShardIterator;
|
||||||
|
@ -72,9 +73,10 @@ public class TransportIndexAction extends TransportReplicationAction<IndexReques
|
||||||
@Inject
|
@Inject
|
||||||
public TransportIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
public TransportIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
IndicesService indicesService, ThreadPool threadPool, ShardStateAction shardStateAction,
|
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,
|
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.createIndexAction = createIndexAction;
|
||||||
this.autoCreateIndex = new AutoCreateIndex(settings);
|
this.autoCreateIndex = new AutoCreateIndex(settings);
|
||||||
this.allowIdGeneration = settings.getAsBoolean("action.allow_id_generation", true);
|
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.ActionFilters;
|
||||||
import org.elasticsearch.action.support.DelegatingActionListener;
|
import org.elasticsearch.action.support.DelegatingActionListener;
|
||||||
import org.elasticsearch.action.support.HandledTransportAction;
|
import org.elasticsearch.action.support.HandledTransportAction;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.script.ScriptService;
|
import org.elasticsearch.script.ScriptService;
|
||||||
|
@ -39,8 +40,8 @@ public class TransportDeleteIndexedScriptAction extends HandledTransportAction<D
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportDeleteIndexedScriptAction(Settings settings, ThreadPool threadPool, ScriptService scriptService,
|
public TransportDeleteIndexedScriptAction(Settings settings, ThreadPool threadPool, ScriptService scriptService,
|
||||||
TransportService transportService, ActionFilters actionFilters) {
|
TransportService transportService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
super(settings, DeleteIndexedScriptAction.NAME, threadPool, transportService, actionFilters, DeleteIndexedScriptRequest.class);
|
super(settings, DeleteIndexedScriptAction.NAME, threadPool, transportService, actionFilters, indexNameExpressionResolver, DeleteIndexedScriptRequest.class);
|
||||||
this.scriptService = scriptService;
|
this.scriptService = scriptService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ import org.elasticsearch.action.ActionListener;
|
||||||
import org.elasticsearch.action.get.GetResponse;
|
import org.elasticsearch.action.get.GetResponse;
|
||||||
import org.elasticsearch.action.support.ActionFilters;
|
import org.elasticsearch.action.support.ActionFilters;
|
||||||
import org.elasticsearch.action.support.HandledTransportAction;
|
import org.elasticsearch.action.support.HandledTransportAction;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.script.ScriptService;
|
import org.elasticsearch.script.ScriptService;
|
||||||
|
@ -38,8 +39,8 @@ public class TransportGetIndexedScriptAction extends HandledTransportAction<GetI
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportGetIndexedScriptAction(Settings settings, ThreadPool threadPool, ScriptService scriptService,
|
public TransportGetIndexedScriptAction(Settings settings, ThreadPool threadPool, ScriptService scriptService,
|
||||||
TransportService transportService, ActionFilters actionFilters) {
|
TransportService transportService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
super(settings, GetIndexedScriptAction.NAME, threadPool,transportService, actionFilters, GetIndexedScriptRequest.class);
|
super(settings, GetIndexedScriptAction.NAME, threadPool,transportService, actionFilters, indexNameExpressionResolver, GetIndexedScriptRequest.class);
|
||||||
this.scriptService = scriptService;
|
this.scriptService = scriptService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ import org.elasticsearch.action.index.IndexResponse;
|
||||||
import org.elasticsearch.action.support.ActionFilters;
|
import org.elasticsearch.action.support.ActionFilters;
|
||||||
import org.elasticsearch.action.support.DelegatingActionListener;
|
import org.elasticsearch.action.support.DelegatingActionListener;
|
||||||
import org.elasticsearch.action.support.HandledTransportAction;
|
import org.elasticsearch.action.support.HandledTransportAction;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.script.ScriptService;
|
import org.elasticsearch.script.ScriptService;
|
||||||
|
@ -38,9 +39,10 @@ public class TransportPutIndexedScriptAction extends HandledTransportAction<PutI
|
||||||
private final ScriptService scriptService;
|
private final ScriptService scriptService;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TransportPutIndexedScriptAction(Settings settings, ThreadPool threadPool,
|
public TransportPutIndexedScriptAction(Settings settings, ThreadPool threadPool, ScriptService scriptService,
|
||||||
ScriptService scriptService, TransportService transportService, ActionFilters actionFilters) {
|
TransportService transportService, ActionFilters actionFilters,
|
||||||
super(settings, PutIndexedScriptAction.NAME, threadPool, transportService, actionFilters, PutIndexedScriptRequest.class);
|
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
|
super(settings, PutIndexedScriptAction.NAME, threadPool, transportService, actionFilters, indexNameExpressionResolver, PutIndexedScriptRequest.class);
|
||||||
this.scriptService = scriptService;
|
this.scriptService = scriptService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
package org.elasticsearch.action.percolate;
|
package org.elasticsearch.action.percolate;
|
||||||
|
|
||||||
import com.google.common.collect.Iterators;
|
import com.google.common.collect.Iterators;
|
||||||
|
import org.elasticsearch.ElasticsearchException;
|
||||||
import org.elasticsearch.action.ActionResponse;
|
import org.elasticsearch.action.ActionResponse;
|
||||||
import org.elasticsearch.common.Nullable;
|
import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
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 {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
builder.startArray(Fields.RESPONSES);
|
builder.startArray(Fields.RESPONSES);
|
||||||
for (MultiPercolateResponse.Item item : items) {
|
for (MultiPercolateResponse.Item item : items) {
|
||||||
|
builder.startObject();
|
||||||
if (item.isFailure()) {
|
if (item.isFailure()) {
|
||||||
builder.startObject();
|
ElasticsearchException.renderThrowable(builder, params, item.getFailure());
|
||||||
builder.field(Fields.ERROR, item.getErrorMessage());
|
|
||||||
builder.endObject();
|
|
||||||
} else {
|
} else {
|
||||||
builder.startObject();
|
|
||||||
item.getResponse().toXContent(builder, params);
|
item.getResponse().toXContent(builder, params);
|
||||||
builder.endObject();
|
|
||||||
}
|
}
|
||||||
|
builder.endObject();
|
||||||
}
|
}
|
||||||
builder.endArray();
|
builder.endArray();
|
||||||
return builder;
|
return builder;
|
||||||
|
@ -112,34 +111,19 @@ public class MultiPercolateResponse extends ActionResponse implements Iterable<M
|
||||||
public static class Item implements Streamable {
|
public static class Item implements Streamable {
|
||||||
|
|
||||||
private PercolateResponse response;
|
private PercolateResponse response;
|
||||||
private String errorMessage;
|
private Throwable throwable;
|
||||||
|
|
||||||
Item(PercolateResponse response) {
|
Item(PercolateResponse response) {
|
||||||
this.response = response;
|
this.response = response;
|
||||||
}
|
}
|
||||||
|
|
||||||
Item(String errorMessage) {
|
Item(Throwable Throwable) {
|
||||||
this.errorMessage = errorMessage;
|
this.throwable = Throwable;
|
||||||
}
|
}
|
||||||
|
|
||||||
Item() {
|
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.
|
* @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
|
@Nullable
|
||||||
public String getErrorMessage() {
|
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.
|
* <code>false</code> is returned.
|
||||||
*/
|
*/
|
||||||
public boolean isFailure() {
|
public boolean isFailure() {
|
||||||
return errorMessage != null;
|
return throwable != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Throwable getFailure() {
|
||||||
|
return throwable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -171,7 +159,7 @@ public class MultiPercolateResponse extends ActionResponse implements Iterable<M
|
||||||
response = new PercolateResponse();
|
response = new PercolateResponse();
|
||||||
response.readFrom(in);
|
response.readFrom(in);
|
||||||
} else {
|
} else {
|
||||||
errorMessage = in.readString();
|
throwable = in.readThrowable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,10 +170,9 @@ public class MultiPercolateResponse extends ActionResponse implements Iterable<M
|
||||||
response.writeTo(out);
|
response.writeTo(out);
|
||||||
} else {
|
} else {
|
||||||
out.writeBoolean(false);
|
out.writeBoolean(false);
|
||||||
out.writeString(errorMessage);
|
out.writeThrowable(throwable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static final class Fields {
|
static final class Fields {
|
||||||
|
|
|
@ -37,6 +37,7 @@ public class PercolateShardRequest extends BroadcastShardRequest {
|
||||||
private BytesReference docSource;
|
private BytesReference docSource;
|
||||||
private boolean onlyCount;
|
private boolean onlyCount;
|
||||||
private int numberOfShards;
|
private int numberOfShards;
|
||||||
|
private long startTime;
|
||||||
|
|
||||||
PercolateShardRequest() {
|
PercolateShardRequest() {
|
||||||
}
|
}
|
||||||
|
@ -48,6 +49,7 @@ public class PercolateShardRequest extends BroadcastShardRequest {
|
||||||
this.docSource = request.docSource();
|
this.docSource = request.docSource();
|
||||||
this.onlyCount = request.onlyCount();
|
this.onlyCount = request.onlyCount();
|
||||||
this.numberOfShards = numberOfShards;
|
this.numberOfShards = numberOfShards;
|
||||||
|
this.startTime = request.startTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
PercolateShardRequest(ShardId shardId, OriginalIndices originalIndices) {
|
PercolateShardRequest(ShardId shardId, OriginalIndices originalIndices) {
|
||||||
|
@ -60,6 +62,7 @@ public class PercolateShardRequest extends BroadcastShardRequest {
|
||||||
this.source = request.source();
|
this.source = request.source();
|
||||||
this.docSource = request.docSource();
|
this.docSource = request.docSource();
|
||||||
this.onlyCount = request.onlyCount();
|
this.onlyCount = request.onlyCount();
|
||||||
|
this.startTime = request.startTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String documentType() {
|
public String documentType() {
|
||||||
|
@ -98,6 +101,10 @@ public class PercolateShardRequest extends BroadcastShardRequest {
|
||||||
return numberOfShards;
|
return numberOfShards;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getStartTime() {
|
||||||
|
return startTime;
|
||||||
|
}
|
||||||
|
|
||||||
OriginalIndices originalIndices() {
|
OriginalIndices originalIndices() {
|
||||||
return originalIndices;
|
return originalIndices;
|
||||||
}
|
}
|
||||||
|
@ -110,6 +117,7 @@ public class PercolateShardRequest extends BroadcastShardRequest {
|
||||||
docSource = in.readBytesReference();
|
docSource = in.readBytesReference();
|
||||||
onlyCount = in.readBoolean();
|
onlyCount = in.readBoolean();
|
||||||
numberOfShards = in.readVInt();
|
numberOfShards = in.readVInt();
|
||||||
|
startTime = in.readLong(); // no vlong, this can be negative!
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -120,6 +128,7 @@ public class PercolateShardRequest extends BroadcastShardRequest {
|
||||||
out.writeBytesReference(docSource);
|
out.writeBytesReference(docSource);
|
||||||
out.writeBoolean(onlyCount);
|
out.writeBoolean(onlyCount);
|
||||||
out.writeVInt(numberOfShards);
|
out.writeVInt(numberOfShards);
|
||||||
|
out.writeLong(startTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
package org.elasticsearch.action.percolate;
|
package org.elasticsearch.action.percolate;
|
||||||
|
|
||||||
import com.carrotsearch.hppc.IntArrayList;
|
import com.carrotsearch.hppc.IntArrayList;
|
||||||
import org.elasticsearch.ExceptionsHelper;
|
|
||||||
import org.elasticsearch.action.ActionListener;
|
import org.elasticsearch.action.ActionListener;
|
||||||
import org.elasticsearch.action.UnavailableShardsException;
|
import org.elasticsearch.action.UnavailableShardsException;
|
||||||
import org.elasticsearch.action.get.*;
|
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.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
||||||
import org.elasticsearch.cluster.routing.ShardIterator;
|
import org.elasticsearch.cluster.routing.ShardIterator;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.util.concurrent.AtomicArray;
|
import org.elasticsearch.common.util.concurrent.AtomicArray;
|
||||||
|
import org.elasticsearch.index.IndexNotFoundException;
|
||||||
import org.elasticsearch.index.engine.DocumentMissingException;
|
import org.elasticsearch.index.engine.DocumentMissingException;
|
||||||
import org.elasticsearch.index.shard.ShardId;
|
import org.elasticsearch.index.shard.ShardId;
|
||||||
import org.elasticsearch.indices.IndexMissingException;
|
|
||||||
import org.elasticsearch.percolator.PercolatorService;
|
import org.elasticsearch.percolator.PercolatorService;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.transport.TransportService;
|
import org.elasticsearch.transport.TransportService;
|
||||||
|
@ -59,8 +59,8 @@ public class TransportMultiPercolateAction extends HandledTransportAction<MultiP
|
||||||
@Inject
|
@Inject
|
||||||
public TransportMultiPercolateAction(Settings settings, ThreadPool threadPool, TransportShardMultiPercolateAction shardMultiPercolateAction,
|
public TransportMultiPercolateAction(Settings settings, ThreadPool threadPool, TransportShardMultiPercolateAction shardMultiPercolateAction,
|
||||||
ClusterService clusterService, TransportService transportService, PercolatorService percolatorService,
|
ClusterService clusterService, TransportService transportService, PercolatorService percolatorService,
|
||||||
TransportMultiGetAction multiGetAction, ActionFilters actionFilters) {
|
TransportMultiGetAction multiGetAction, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
super(settings, MultiPercolateAction.NAME, threadPool, transportService, actionFilters, MultiPercolateRequest.class);
|
super(settings, MultiPercolateAction.NAME, threadPool, transportService, actionFilters, indexNameExpressionResolver, MultiPercolateRequest.class);
|
||||||
this.shardMultiPercolateAction = shardMultiPercolateAction;
|
this.shardMultiPercolateAction = shardMultiPercolateAction;
|
||||||
this.clusterService = clusterService;
|
this.clusterService = clusterService;
|
||||||
this.percolatorService = percolatorService;
|
this.percolatorService = percolatorService;
|
||||||
|
@ -164,17 +164,17 @@ public class TransportMultiPercolateAction extends HandledTransportAction<MultiP
|
||||||
PercolateRequest percolateRequest = (PercolateRequest) element;
|
PercolateRequest percolateRequest = (PercolateRequest) element;
|
||||||
String[] concreteIndices;
|
String[] concreteIndices;
|
||||||
try {
|
try {
|
||||||
concreteIndices = clusterState.metaData().concreteIndices(percolateRequest.indicesOptions(), percolateRequest.indices());
|
concreteIndices = indexNameExpressionResolver.concreteIndices(clusterState, percolateRequest);
|
||||||
} catch (IndexMissingException e) {
|
} catch (IndexNotFoundException e) {
|
||||||
reducedResponses.set(slot, e);
|
reducedResponses.set(slot, e);
|
||||||
responsesByItemAndShard.set(slot, new AtomicReferenceArray(0));
|
responsesByItemAndShard.set(slot, new AtomicReferenceArray(0));
|
||||||
expectedOperationsPerItem.set(slot, new AtomicInteger(0));
|
expectedOperationsPerItem.set(slot, new AtomicInteger(0));
|
||||||
continue;
|
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
|
// TODO: I only need shardIds, ShardIterator(ShardRouting) is only needed in TransportShardMultiPercolateAction
|
||||||
GroupShardsIterator shards = clusterService.operationRouting().searchShards(
|
GroupShardsIterator shards = clusterService.operationRouting().searchShards(
|
||||||
clusterState, percolateRequest.indices(), concreteIndices, routing, percolateRequest.preference()
|
clusterState, concreteIndices, routing, percolateRequest.preference()
|
||||||
);
|
);
|
||||||
if (shards.size() == 0) {
|
if (shards.size() == 0) {
|
||||||
reducedResponses.set(slot, new UnavailableShardsException(null, "No shards available"));
|
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:
|
// 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));
|
responsesByItemAndShard.set(slot, new AtomicReferenceArray(numShards));
|
||||||
expectedOperationsPerItem.set(slot, new AtomicInteger(shards.size()));
|
expectedOperationsPerItem.set(slot, new AtomicInteger(shards.size()));
|
||||||
for (ShardIterator shard : shards) {
|
for (ShardIterator shard : shards) {
|
||||||
|
@ -311,9 +311,9 @@ public class TransportMultiPercolateAction extends HandledTransportAction<MultiP
|
||||||
if (element instanceof PercolateResponse) {
|
if (element instanceof PercolateResponse) {
|
||||||
finalResponse[slot] = new MultiPercolateResponse.Item((PercolateResponse) element);
|
finalResponse[slot] = new MultiPercolateResponse.Item((PercolateResponse) element);
|
||||||
} else if (element instanceof Throwable) {
|
} 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) {
|
} 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));
|
finalListener.onResponse(new MultiPercolateResponse(finalResponse));
|
||||||
|
|
|
@ -31,6 +31,7 @@ import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
||||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||||
import org.elasticsearch.common.bytes.BytesReference;
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
|
@ -60,9 +61,9 @@ public class TransportPercolateAction extends TransportBroadcastAction<Percolate
|
||||||
@Inject
|
@Inject
|
||||||
public TransportPercolateAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
|
public TransportPercolateAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
|
||||||
TransportService transportService, PercolatorService percolatorService,
|
TransportService transportService, PercolatorService percolatorService,
|
||||||
TransportGetAction getAction, ActionFilters actionFilters) {
|
TransportGetAction getAction, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||||
super(settings, PercolateAction.NAME, threadPool, clusterService, transportService, actionFilters,
|
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.percolatorService = percolatorService;
|
||||||
this.getAction = getAction;
|
this.getAction = getAction;
|
||||||
}
|
}
|
||||||
|
@ -167,8 +168,8 @@ public class TransportPercolateAction extends TransportBroadcastAction<Percolate
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected GroupShardsIterator shards(ClusterState clusterState, PercolateRequest request, String[] concreteIndices) {
|
protected GroupShardsIterator shards(ClusterState clusterState, PercolateRequest request, String[] concreteIndices) {
|
||||||
Map<String, Set<String>> routingMap = clusterState.metaData().resolveSearchRouting(request.routing(), request.indices());
|
Map<String, Set<String>> routingMap = indexNameExpressionResolver.resolveSearchRouting(clusterState, request.routing(), request.indices());
|
||||||
return clusterService.operationRouting().searchShards(clusterState, request.indices(), concreteIndices, routingMap, request.preference());
|
return clusterService.operationRouting().searchShards(clusterState, concreteIndices, routingMap, request.preference());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue