diff --git a/TESTING.asciidoc b/TESTING.asciidoc
index 13ceef4bdd7..108c6ba9765 100644
--- a/TESTING.asciidoc
+++ b/TESTING.asciidoc
@@ -338,8 +338,8 @@ time to setup all the VMs one at a time. Run this to download and setup the VMs
we use for testing by default:
--------------------------------------------------------
-vagrant up --provision trusty && vagrant halt trusty
-vagrant up --provision centos-7 && vagrant halt centos-7
+vagrant up --provision trusty --provider virtualbox && vagrant halt trusty
+vagrant up --provision centos-7 --provider virtualbox && vagrant halt centos-7
--------------------------------------------------------
or run this to download and setup all the VMs:
@@ -347,7 +347,7 @@ or run this to download and setup all the VMs:
-------------------------------------------------------------------------------
vagrant halt
for box in $(vagrant status | grep 'poweroff\|not created' | cut -f1 -d' '); do
- vagrant up --provision $box
+ vagrant up --provision $box --provider virtualbox
vagrant halt $box
done
-------------------------------------------------------------------------------
@@ -420,13 +420,13 @@ This is just regular vagrant so you can run normal multi box vagrant commands
to test things manually. Just run:
---------------------------------------
-vagrant up trusty && vagrant ssh trusty
+vagrant up trusty --provider virtualbox && vagrant ssh trusty
---------------------------------------
to get an Ubuntu or
-------------------------------------------
-vagrant up centos-7 && vagrant ssh centos-7
+vagrant up centos-7 --provider virtualbox && vagrant ssh centos-7
-------------------------------------------
to get a CentOS. Once you are done with them you should halt them:
@@ -469,7 +469,7 @@ vagrant ssh precise -c 'sudo rm -rf /bin'; echo oops
All you've got to do to get another one is
----------------------------------------------
-vagrant destroy -f trusty && vagrant up trusty
+vagrant destroy -f trusty && vagrant up trusty --provider virtualbox
----------------------------------------------
The whole process takes a minute and a half on a modern laptop, two and a half
@@ -508,7 +508,7 @@ mvn -pl distribution/rpm package
and in another window:
----------------------------------------------------
-vagrant up centos-7 && vagrant ssh centos-7
+vagrant up centos-7 --provider virtualbox && vagrant ssh centos-7
cd $RPM
sudo bats $BATS/*rpm*.bats
----------------------------------------------------
@@ -520,20 +520,34 @@ If you wanted to retest all the release artifacts on a single VM you could:
mvn -amd -pl distribution install -DskipTests
# Copy them all the testroot
mvn -Dtests.vagrant -pl qa/vagrant pre-integration-test
-vagrant up trusty && vagrant ssh trusty
+vagrant up trusty --provider virtualbox && vagrant ssh trusty
cd $TESTROOT
sudo bats $BATS/*.bats
-------------------------------------------------
== Coverage analysis
-To run tests instrumented with jacoco and produce a coverage report in
-`target/site/jacoco/`:
+Tests can be run instrumented with jacoco to produce a coverage report in
+`target/site/jacoco/`.
+
+Unit test coverage:
---------------------------------------------------------------------------
mvn -Dtests.coverage test jacoco:report
---------------------------------------------------------------------------
+Integration test coverage:
+
+---------------------------------------------------------------------------
+mvn -Dtests.coverage -Dskip.unit.tests verify jacoco:report
+---------------------------------------------------------------------------
+
+Combined (Unit+Integration) coverage:
+
+---------------------------------------------------------------------------
+mvn -Dtests.coverage verify jacoco:report
+---------------------------------------------------------------------------
+
== Debugging from an IDE
If you want to run elasticsearch from your IDE, you should execute ./run.sh
diff --git a/core/pom.xml b/core/pom.xml
index c9f8656eacb..4b55f93aa19 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -105,8 +105,6 @@
-
-
com.google.guava
guava
@@ -165,7 +163,6 @@
commons-cli
commons-cli
-
org.codehaus.groovy
diff --git a/core/src/main/java/org/apache/lucene/queries/MinDocQuery.java b/core/src/main/java/org/apache/lucene/queries/MinDocQuery.java
index 169c017804b..1e9ecf7ae6f 100644
--- a/core/src/main/java/org/apache/lucene/queries/MinDocQuery.java
+++ b/core/src/main/java/org/apache/lucene/queries/MinDocQuery.java
@@ -27,7 +27,6 @@ import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.Weight;
-import org.apache.lucene.util.Bits;
import java.io.IOException;
@@ -60,7 +59,7 @@ public final class MinDocQuery extends Query {
public Weight createWeight(IndexSearcher searcher, boolean needsScores) throws IOException {
return new ConstantScoreWeight(this) {
@Override
- public Scorer scorer(LeafReaderContext context, final Bits acceptDocs) throws IOException {
+ public Scorer scorer(LeafReaderContext context) throws IOException {
final int maxDoc = context.reader().maxDoc();
if (context.docBase + maxDoc <= minDoc) {
return null;
@@ -89,12 +88,6 @@ public final class MinDocQuery extends Query {
} else {
doc = target;
}
- while (doc < maxDoc) {
- if (acceptDocs == null || acceptDocs.get(doc)) {
- break;
- }
- doc += 1;
- }
if (doc >= maxDoc) {
doc = NO_MORE_DOCS;
}
diff --git a/core/src/main/java/org/apache/lucene/queryparser/classic/MapperQueryParser.java b/core/src/main/java/org/apache/lucene/queryparser/classic/MapperQueryParser.java
index 6974dc0e5ae..493423c1fd1 100644
--- a/core/src/main/java/org/apache/lucene/queryparser/classic/MapperQueryParser.java
+++ b/core/src/main/java/org/apache/lucene/queryparser/classic/MapperQueryParser.java
@@ -279,7 +279,7 @@ public class MapperQueryParser extends QueryParser {
if (q != null) {
added = true;
applyBoost(mField, q);
- applySlop(q, slop);
+ q = applySlop(q, slop);
disMaxQuery.add(q);
}
}
@@ -293,7 +293,7 @@ public class MapperQueryParser extends QueryParser {
Query q = super.getFieldQuery(mField, queryText, slop);
if (q != null) {
applyBoost(mField, q);
- applySlop(q, slop);
+ q = applySlop(q, slop);
clauses.add(new BooleanClause(q, BooleanClause.Occur.SHOULD));
}
}
@@ -718,15 +718,6 @@ public class MapperQueryParser extends QueryParser {
return super.getWildcardQuery(field, aggStr.toString());
}
- @Override
- protected WildcardQuery newWildcardQuery(Term t) {
- // Backport: https://issues.apache.org/jira/browse/LUCENE-6677
- assert Version.LATEST == Version.LUCENE_5_2_1;
- WildcardQuery query = new WildcardQuery(t, maxDeterminizedStates);
- query.setRewriteMethod(multiTermRewriteMethod);
- return query;
- }
-
@Override
protected Query getRegexpQuery(String field, String termStr) throws ParseException {
if (lowercaseExpandedTerms) {
@@ -815,14 +806,24 @@ public class MapperQueryParser extends QueryParser {
}
}
- private void applySlop(Query q, int slop) {
- if (q instanceof FilteredQuery) {
- applySlop(((FilteredQuery)q).getQuery(), slop);
- }
+ private Query applySlop(Query q, int slop) {
if (q instanceof PhraseQuery) {
- ((PhraseQuery) q).setSlop(slop);
+ PhraseQuery pq = (PhraseQuery) q;
+ PhraseQuery.Builder builder = new PhraseQuery.Builder();
+ builder.setSlop(slop);
+ final Term[] terms = pq.getTerms();
+ final int[] positions = pq.getPositions();
+ for (int i = 0; i < terms.length; ++i) {
+ builder.add(terms[i], positions[i]);
+ }
+ pq = builder.build();
+ pq.setBoost(q.getBoost());
+ return pq;
} else if (q instanceof MultiPhraseQuery) {
((MultiPhraseQuery) q).setSlop(slop);
+ return q;
+ } else {
+ return q;
}
}
diff --git a/core/src/main/java/org/apache/lucene/search/postingshighlight/CustomSeparatorBreakIterator.java b/core/src/main/java/org/apache/lucene/search/postingshighlight/CustomSeparatorBreakIterator.java
deleted file mode 100644
index efdddf5260e..00000000000
--- a/core/src/main/java/org/apache/lucene/search/postingshighlight/CustomSeparatorBreakIterator.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
-Licensed to Elasticsearch under one or more contributor
-license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright
-ownership. Elasticsearch licenses this file to you under
-the Apache License, Version 2.0 (the "License"); you may
-not use this file except in compliance with the License.
-You may obtain a copy of the License at
- *
- http://www.apache.org/licenses/LICENSE-2.0
- *
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
- */
-
-package org.apache.lucene.search.postingshighlight;
-
-import java.text.BreakIterator;
-import java.text.CharacterIterator;
-
-/**
- * A {@link BreakIterator} that breaks the text whenever a certain separator, provided as a constructor argument, is found.
- */
-public class CustomSeparatorBreakIterator extends BreakIterator {
-
- private final char separator;
- private CharacterIterator text;
- private int current;
-
- public CustomSeparatorBreakIterator(char separator) {
- this.separator = separator;
- }
-
- @Override
- public int current() {
- return current;
- }
-
- @Override
- public int first() {
- text.setIndex(text.getBeginIndex());
- return current = text.getIndex();
- }
-
- @Override
- public int last() {
- text.setIndex(text.getEndIndex());
- return current = text.getIndex();
- }
-
- @Override
- public int next() {
- if (text.getIndex() == text.getEndIndex()) {
- return DONE;
- } else {
- return advanceForward();
- }
- }
-
- private int advanceForward() {
- char c;
- while( (c = text.next()) != CharacterIterator.DONE) {
- if (c == separator) {
- return current = text.getIndex() + 1;
- }
- }
- assert text.getIndex() == text.getEndIndex();
- return current = text.getIndex();
- }
-
- @Override
- public int following(int pos) {
- if (pos < text.getBeginIndex() || pos > text.getEndIndex()) {
- throw new IllegalArgumentException("offset out of bounds");
- } else if (pos == text.getEndIndex()) {
- // this conflicts with the javadocs, but matches actual behavior (Oracle has a bug in something)
- // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=9000909
- text.setIndex(text.getEndIndex());
- current = text.getIndex();
- return DONE;
- } else {
- text.setIndex(pos);
- current = text.getIndex();
- return advanceForward();
- }
- }
-
- @Override
- public int previous() {
- if (text.getIndex() == text.getBeginIndex()) {
- return DONE;
- } else {
- return advanceBackward();
- }
- }
-
- private int advanceBackward() {
- char c;
- while( (c = text.previous()) != CharacterIterator.DONE) {
- if (c == separator) {
- return current = text.getIndex() + 1;
- }
- }
- assert text.getIndex() == text.getBeginIndex();
- return current = text.getIndex();
- }
-
- @Override
- public int preceding(int pos) {
- if (pos < text.getBeginIndex() || pos > text.getEndIndex()) {
- throw new IllegalArgumentException("offset out of bounds");
- } else if (pos == text.getBeginIndex()) {
- // this conflicts with the javadocs, but matches actual behavior (Oracle has a bug in something)
- // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=9000909
- text.setIndex(text.getBeginIndex());
- current = text.getIndex();
- return DONE;
- } else {
- text.setIndex(pos);
- current = text.getIndex();
- return advanceBackward();
- }
- }
-
- @Override
- public int next(int n) {
- if (n < 0) {
- for (int i = 0; i < -n; i++) {
- previous();
- }
- } else {
- for (int i = 0; i < n; i++) {
- next();
- }
- }
- return current();
- }
-
- @Override
- public CharacterIterator getText() {
- return text;
- }
-
- @Override
- public void setText(CharacterIterator newText) {
- text = newText;
- current = text.getBeginIndex();
- }
-}
diff --git a/core/src/main/java/org/apache/lucene/search/suggest/analyzing/XAnalyzingSuggester.java b/core/src/main/java/org/apache/lucene/search/suggest/analyzing/XAnalyzingSuggester.java
index ec26fffb228..98401cd2e14 100644
--- a/core/src/main/java/org/apache/lucene/search/suggest/analyzing/XAnalyzingSuggester.java
+++ b/core/src/main/java/org/apache/lucene/search/suggest/analyzing/XAnalyzingSuggester.java
@@ -28,6 +28,7 @@ import org.apache.lucene.search.suggest.Lookup;
import org.apache.lucene.store.*;
import org.apache.lucene.util.*;
import org.apache.lucene.util.automaton.Automaton;
+import org.apache.lucene.util.automaton.LimitedFiniteStringsIterator;
import org.apache.lucene.util.automaton.Operations;
import org.apache.lucene.util.automaton.Transition;
import org.apache.lucene.util.fst.*;
@@ -465,16 +466,12 @@ public long ramBytesUsed() {
byte buffer[] = new byte[8];
try {
ByteArrayDataOutput output = new ByteArrayDataOutput(buffer);
- BytesRef surfaceForm;
- while ((surfaceForm = iterator.next()) != null) {
- Set paths = toFiniteStrings(surfaceForm, ts2a);
-
- maxAnalyzedPathsForOneInput = Math.max(maxAnalyzedPathsForOneInput, paths.size());
-
- for (IntsRef path : paths) {
-
- Util.toBytesRef(path, scratch);
+ for (BytesRef surfaceForm; (surfaceForm = iterator.next()) != null;) {
+ LimitedFiniteStringsIterator finiteStrings =
+ new LimitedFiniteStringsIterator(toAutomaton(surfaceForm, ts2a), maxGraphExpansions);
+ for (IntsRef string; (string = finiteStrings.next()) != null; count++) {
+ Util.toBytesRef(string, scratch);
// length of the analyzed text (FST input)
if (scratch.length() > Short.MAX_VALUE-2) {
@@ -526,7 +523,7 @@ public long ramBytesUsed() {
writer.write(buffer, 0, output.getPosition());
}
- count++;
+ maxAnalyzedPathsForOneInput = Math.max(maxAnalyzedPathsForOneInput, finiteStrings.size());
}
writer.close();
@@ -912,23 +909,17 @@ public long ramBytesUsed() {
return prefixPaths;
}
- public final Set toFiniteStrings(final BytesRef surfaceForm, final TokenStreamToAutomaton ts2a) throws IOException {
- // Analyze surface form:
- TokenStream ts = indexAnalyzer.tokenStream("", surfaceForm.utf8ToString());
- return toFiniteStrings(ts2a, ts);
- }
-
- public final Set toFiniteStrings(final TokenStreamToAutomaton ts2a, final TokenStream ts) throws IOException {
- Automaton automaton = null;
- try {
-
- // Create corresponding automaton: labels are bytes
- // from each analyzed token, with byte 0 used as
- // separator between tokens:
- automaton = ts2a.toAutomaton(ts);
- } finally {
- IOUtils.closeWhileHandlingException(ts);
+ final Automaton toAutomaton(final BytesRef surfaceForm, final TokenStreamToAutomaton ts2a) throws IOException {
+ try (TokenStream ts = indexAnalyzer.tokenStream("", surfaceForm.utf8ToString())) {
+ return toAutomaton(ts, ts2a);
}
+ }
+
+ final Automaton toAutomaton(TokenStream ts, final TokenStreamToAutomaton ts2a) throws IOException {
+ // Create corresponding automaton: labels are bytes
+ // from each analyzed token, with byte 0 used as
+ // separator between tokens:
+ Automaton automaton = ts2a.toAutomaton(ts);
automaton = replaceSep(automaton);
automaton = convertAutomaton(automaton);
@@ -940,11 +931,24 @@ public long ramBytesUsed() {
// more than one path, eg if the analyzer created a
// graph using SynFilter or WDF):
- // TODO: we could walk & add simultaneously, so we
- // don't have to alloc [possibly biggish]
- // intermediate HashSet in RAM:
+ return automaton;
+ }
- return Operations.getFiniteStrings(automaton, maxGraphExpansions);
+ // EDIT: Adrien, needed by lookup providers
+ // NOTE: these XForks are unmaintainable, we need to get rid of them...
+ public Set toFiniteStrings(TokenStream stream) throws IOException {
+ final TokenStreamToAutomaton ts2a = getTokenStreamToAutomaton();
+ Automaton automaton;
+ try (TokenStream ts = stream) {
+ automaton = toAutomaton(ts, ts2a);
+ }
+ LimitedFiniteStringsIterator finiteStrings =
+ new LimitedFiniteStringsIterator(automaton, maxGraphExpansions);
+ Set set = new HashSet<>();
+ for (IntsRef string = finiteStrings.next(); string != null; string = finiteStrings.next()) {
+ set.add(IntsRef.deepCopyOf(string));
+ }
+ return Collections.unmodifiableSet(set);
}
final Automaton toLookupAutomaton(final CharSequence key) throws IOException {
diff --git a/core/src/main/java/org/apache/lucene/search/suggest/analyzing/XFuzzySuggester.java b/core/src/main/java/org/apache/lucene/search/suggest/analyzing/XFuzzySuggester.java
index 5170057a67c..20f95c646fc 100644
--- a/core/src/main/java/org/apache/lucene/search/suggest/analyzing/XFuzzySuggester.java
+++ b/core/src/main/java/org/apache/lucene/search/suggest/analyzing/XFuzzySuggester.java
@@ -28,9 +28,10 @@ import org.apache.lucene.util.fst.FST;
import org.apache.lucene.util.fst.PairOutputs;
import java.io.IOException;
-import java.util.Arrays;
+import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
+
+import static org.apache.lucene.util.automaton.Operations.DEFAULT_MAX_DETERMINIZED_STATES;
/**
* Implements a fuzzy {@link AnalyzingSuggester}. The similarity measurement is
@@ -221,42 +222,37 @@ public final class XFuzzySuggester extends XAnalyzingSuggester {
}
Automaton toLevenshteinAutomata(Automaton automaton) {
- final Set ref = Operations.getFiniteStrings(automaton, -1);
- Automaton subs[] = new Automaton[ref.size()];
- int upto = 0;
- for (IntsRef path : ref) {
- if (path.length <= nonFuzzyPrefix || path.length < minFuzzyLength) {
- subs[upto] = Automata.makeString(path.ints, path.offset, path.length);
- upto++;
+ List subs = new ArrayList<>();
+ FiniteStringsIterator finiteStrings = new FiniteStringsIterator(automaton);
+ for (IntsRef string; (string = finiteStrings.next()) != null;) {
+ if (string.length <= nonFuzzyPrefix || string.length < minFuzzyLength) {
+ subs.add(Automata.makeString(string.ints, string.offset, string.length));
} else {
- int ints[] = new int[path.length-nonFuzzyPrefix];
- System.arraycopy(path.ints, path.offset+nonFuzzyPrefix, ints, 0, ints.length);
+ int ints[] = new int[string.length-nonFuzzyPrefix];
+ System.arraycopy(string.ints, string.offset+nonFuzzyPrefix, ints, 0, ints.length);
// TODO: maybe add alphaMin to LevenshteinAutomata,
// and pass 1 instead of 0? We probably don't want
// to allow the trailing dedup bytes to be
// edited... but then 0 byte is "in general" allowed
// on input (but not in UTF8).
LevenshteinAutomata lev = new LevenshteinAutomata(ints, unicodeAware ? Character.MAX_CODE_POINT : 255, transpositions);
- subs[upto] = lev.toAutomaton(maxEdits, UnicodeUtil.newString(path.ints, path.offset, nonFuzzyPrefix));
- upto++;
+ subs.add(lev.toAutomaton(maxEdits, UnicodeUtil.newString(string.ints, string.offset, nonFuzzyPrefix)));
}
}
- if (subs.length == 0) {
+ if (subs.isEmpty()) {
// automaton is empty, there is no accepted paths through it
return Automata.makeEmpty(); // matches nothing
- } else if (subs.length == 1) {
+ } else if (subs.size() == 1) {
// no synonyms or anything: just a single path through the tokenstream
- return subs[0];
+ return subs.get(0);
} else {
// multiple paths: this is really scary! is it slow?
// maybe we should not do this and throw UOE?
- Automaton a = Operations.union(Arrays.asList(subs));
+ Automaton a = Operations.union(subs);
// TODO: we could call toLevenshteinAutomata() before det?
// this only happens if you have multiple paths anyway (e.g. synonyms)
-
- // This automaton should not blow up during determinize:
- return Operations.determinize(a, Integer.MAX_VALUE);
+ return Operations.determinize(a, DEFAULT_MAX_DETERMINIZED_STATES);
}
}
}
diff --git a/core/src/main/java/org/elasticsearch/Version.java b/core/src/main/java/org/elasticsearch/Version.java
index d12fcd3274b..624aa02e416 100644
--- a/core/src/main/java/org/elasticsearch/Version.java
+++ b/core/src/main/java/org/elasticsearch/Version.java
@@ -258,7 +258,7 @@ public class Version {
public static final int V_2_0_0_ID = 2000099;
public static final Version V_2_0_0 = new Version(V_2_0_0_ID, true, org.apache.lucene.util.Version.LUCENE_5_2_1);
public static final int V_2_1_0_ID = 2010099;
- public static final Version V_2_1_0 = new Version(V_2_1_0_ID, true, org.apache.lucene.util.Version.LUCENE_5_2_1);
+ public static final Version V_2_1_0 = new Version(V_2_1_0_ID, true, org.apache.lucene.util.Version.LUCENE_5_3_0);
public static final Version CURRENT = V_2_1_0;
diff --git a/core/src/main/java/org/elasticsearch/action/ActionModule.java b/core/src/main/java/org/elasticsearch/action/ActionModule.java
index c613f617774..7be0b032259 100644
--- a/core/src/main/java/org/elasticsearch/action/ActionModule.java
+++ b/core/src/main/java/org/elasticsearch/action/ActionModule.java
@@ -180,6 +180,7 @@ import org.elasticsearch.action.suggest.TransportSuggestAction;
import org.elasticsearch.action.support.ActionFilter;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.AutoCreateIndex;
+import org.elasticsearch.action.support.DestructiveOperations;
import org.elasticsearch.action.support.TransportAction;
import org.elasticsearch.action.termvectors.MultiTermVectorsAction;
import org.elasticsearch.action.termvectors.TermVectorsAction;
@@ -252,6 +253,7 @@ public class ActionModule extends AbstractModule {
}
bind(ActionFilters.class).asEagerSingleton();
bind(AutoCreateIndex.class).asEagerSingleton();
+ bind(DestructiveOperations.class).asEagerSingleton();
registerAction(NodesInfoAction.INSTANCE, TransportNodesInfoAction.class);
registerAction(NodesStatsAction.INSTANCE, TransportNodesStatsAction.class);
registerAction(NodesHotThreadsAction.INSTANCE, TransportNodesHotThreadsAction.class);
diff --git a/core/src/main/java/org/elasticsearch/action/ActionWriteResponse.java b/core/src/main/java/org/elasticsearch/action/ActionWriteResponse.java
index a63f6dcd9fa..f4152ac85e4 100644
--- a/core/src/main/java/org/elasticsearch/action/ActionWriteResponse.java
+++ b/core/src/main/java/org/elasticsearch/action/ActionWriteResponse.java
@@ -39,7 +39,7 @@ import java.util.Collections;
/**
* Base class for write action responses.
*/
-public abstract class ActionWriteResponse extends ActionResponse {
+public class ActionWriteResponse extends ActionResponse {
public final static ActionWriteResponse.ShardInfo.Failure[] EMPTY = new ActionWriteResponse.ShardInfo.Failure[0];
diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthResponse.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthResponse.java
index 755fb330f7b..ea2f6d7a581 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthResponse.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthResponse.java
@@ -19,7 +19,6 @@
package org.elasticsearch.action.admin.cluster.health;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionResponse;
@@ -39,6 +38,7 @@ import org.elasticsearch.rest.RestStatus;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
@@ -270,7 +270,7 @@ public class ClusterHealthResponse extends ActionResponse implements Iterable, Streama
ClusterShardHealth shardHealth = readClusterShardHealth(in);
shards.put(shardHealth.getId(), shardHealth);
}
- validationFailures = ImmutableList.copyOf(in.readStringArray());
+ validationFailures = Arrays.asList(in.readStringArray());
}
@Override
diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/repositories/get/GetRepositoriesResponse.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/repositories/get/GetRepositoriesResponse.java
index 2d930309d02..c933156fcb0 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/cluster/repositories/get/GetRepositoriesResponse.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/repositories/get/GetRepositoriesResponse.java
@@ -19,7 +19,6 @@
package org.elasticsearch.action.admin.cluster.repositories.get;
-import com.google.common.collect.ImmutableList;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.cluster.metadata.RepositoryMetaData;
import org.elasticsearch.common.io.stream.StreamInput;
@@ -27,6 +26,8 @@ import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.settings.Settings;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@@ -35,13 +36,13 @@ import java.util.List;
*/
public class GetRepositoriesResponse extends ActionResponse implements Iterable {
- private ImmutableList repositories = ImmutableList.of();
+ private List repositories = Collections.emptyList();
GetRepositoriesResponse() {
}
- GetRepositoriesResponse(ImmutableList repositories) {
+ GetRepositoriesResponse(List repositories) {
this.repositories = repositories;
}
@@ -59,7 +60,7 @@ public class GetRepositoriesResponse extends ActionResponse implements Iterable<
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
int size = in.readVInt();
- ImmutableList.Builder repositoryListBuilder = ImmutableList.builder();
+ List repositoryListBuilder = new ArrayList<>();
for (int j = 0; j < size; j++) {
repositoryListBuilder.add(new RepositoryMetaData(
in.readString(),
@@ -67,7 +68,7 @@ public class GetRepositoriesResponse extends ActionResponse implements Iterable<
Settings.readSettingsFromStream(in))
);
}
- repositories = repositoryListBuilder.build();
+ repositories = Collections.unmodifiableList(repositoryListBuilder);
}
@Override
diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/repositories/get/TransportGetRepositoriesAction.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/repositories/get/TransportGetRepositoriesAction.java
index bf7d7e4e9c1..1e2e2fd7335 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/cluster/repositories/get/TransportGetRepositoriesAction.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/repositories/get/TransportGetRepositoriesAction.java
@@ -19,7 +19,6 @@
package org.elasticsearch.action.admin.cluster.repositories.get;
-import com.google.common.collect.ImmutableList;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.TransportMasterNodeReadAction;
@@ -37,6 +36,10 @@ import org.elasticsearch.repositories.RepositoryMissingException;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
/**
* Transport action for get repositories operation
*/
@@ -71,11 +74,11 @@ public class TransportGetRepositoriesAction extends TransportMasterNodeReadActio
if (repositories != null) {
listener.onResponse(new GetRepositoriesResponse(repositories.repositories()));
} else {
- listener.onResponse(new GetRepositoriesResponse(ImmutableList.of()));
+ listener.onResponse(new GetRepositoriesResponse(Collections.emptyList()));
}
} else {
if (repositories != null) {
- ImmutableList.Builder repositoryListBuilder = ImmutableList.builder();
+ List repositoryListBuilder = new ArrayList<>();
for (String repository : request.repositories()) {
RepositoryMetaData repositoryMetaData = repositories.repository(repository);
if (repositoryMetaData == null) {
@@ -84,7 +87,7 @@ public class TransportGetRepositoriesAction extends TransportMasterNodeReadActio
}
repositoryListBuilder.add(repositoryMetaData);
}
- listener.onResponse(new GetRepositoriesResponse(repositoryListBuilder.build()));
+ listener.onResponse(new GetRepositoriesResponse(Collections.unmodifiableList(repositoryListBuilder)));
} else {
listener.onFailure(new RepositoryMissingException(request.repositories()[0]));
}
diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/get/GetSnapshotsResponse.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/get/GetSnapshotsResponse.java
index 71b8fa34a2a..4ca88daad54 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/get/GetSnapshotsResponse.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/get/GetSnapshotsResponse.java
@@ -19,7 +19,6 @@
package org.elasticsearch.action.admin.cluster.snapshots.get;
-import com.google.common.collect.ImmutableList;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
@@ -29,6 +28,8 @@ import org.elasticsearch.common.xcontent.XContentBuilderString;
import org.elasticsearch.snapshots.SnapshotInfo;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
/**
@@ -36,12 +37,12 @@ import java.util.List;
*/
public class GetSnapshotsResponse extends ActionResponse implements ToXContent {
- private ImmutableList snapshots = ImmutableList.of();
+ private List snapshots = Collections.emptyList();
GetSnapshotsResponse() {
}
- GetSnapshotsResponse(ImmutableList snapshots) {
+ GetSnapshotsResponse(List snapshots) {
this.snapshots = snapshots;
}
@@ -58,11 +59,11 @@ public class GetSnapshotsResponse extends ActionResponse implements ToXContent {
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
int size = in.readVInt();
- ImmutableList.Builder builder = ImmutableList.builder();
+ List builder = new ArrayList<>();
for (int i = 0; i < size; i++) {
builder.add(SnapshotInfo.readSnapshotInfo(in));
}
- snapshots = builder.build();
+ snapshots = Collections.unmodifiableList(builder);
}
@Override
diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/get/TransportGetSnapshotsAction.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/get/TransportGetSnapshotsAction.java
index 40a00c73d4f..b21e16d2d66 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/get/TransportGetSnapshotsAction.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/get/TransportGetSnapshotsAction.java
@@ -19,7 +19,6 @@
package org.elasticsearch.action.admin.cluster.snapshots.get;
-import com.google.common.collect.ImmutableList;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.TransportMasterNodeAction;
@@ -37,6 +36,8 @@ import org.elasticsearch.snapshots.SnapshotsService;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
/**
@@ -71,7 +72,7 @@ public class TransportGetSnapshotsAction extends TransportMasterNodeAction listener) {
try {
- ImmutableList.Builder snapshotInfoBuilder = ImmutableList.builder();
+ List snapshotInfoBuilder = new ArrayList<>();
if (isAllSnapshots(request.snapshots())) {
List snapshots = snapshotsService.snapshots(request.repository());
for (Snapshot snapshot : snapshots) {
@@ -88,7 +89,7 @@ public class TransportGetSnapshotsAction extends TransportMasterNodeAction shards;
+ private List shards;
private ImmutableMap indicesStatus;
@@ -57,7 +57,7 @@ public class SnapshotStatus implements ToXContent, Streamable {
private SnapshotStats stats;
- SnapshotStatus(SnapshotId snapshotId, State state, ImmutableList shards) {
+ SnapshotStatus(SnapshotId snapshotId, State state, List shards) {
this.snapshotId = snapshotId;
this.state = state;
this.shards = shards;
@@ -127,11 +127,11 @@ public class SnapshotStatus implements ToXContent, Streamable {
snapshotId = SnapshotId.readSnapshotId(in);
state = State.fromValue(in.readByte());
int size = in.readVInt();
- ImmutableList.Builder builder = ImmutableList.builder();
+ List builder = new ArrayList<>();
for (int i = 0; i < size; i++) {
builder.add(SnapshotIndexShardStatus.readShardSnapshotStatus(in));
}
- shards = builder.build();
+ shards = Collections.unmodifiableList(builder);
updateShardStats();
}
diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/SnapshotsStatusResponse.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/SnapshotsStatusResponse.java
index 6191a45d6b3..e5692374fcb 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/SnapshotsStatusResponse.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/SnapshotsStatusResponse.java
@@ -19,7 +19,6 @@
package org.elasticsearch.action.admin.cluster.snapshots.status;
-import com.google.common.collect.ImmutableList;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
@@ -28,18 +27,21 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilderString;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
/**
* Snapshot status response
*/
public class SnapshotsStatusResponse extends ActionResponse implements ToXContent {
- private ImmutableList snapshots = ImmutableList.of();
+ private List snapshots = Collections.emptyList();
SnapshotsStatusResponse() {
}
- SnapshotsStatusResponse(ImmutableList snapshots) {
+ SnapshotsStatusResponse(List snapshots) {
this.snapshots = snapshots;
}
@@ -48,7 +50,7 @@ public class SnapshotsStatusResponse extends ActionResponse implements ToXConten
*
* @return the list of snapshots
*/
- public ImmutableList getSnapshots() {
+ public List getSnapshots() {
return snapshots;
}
@@ -56,11 +58,11 @@ public class SnapshotsStatusResponse extends ActionResponse implements ToXConten
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
int size = in.readVInt();
- ImmutableList.Builder builder = ImmutableList.builder();
+ List builder = new ArrayList<>();
for (int i = 0; i < size; i++) {
builder.add(SnapshotStatus.readSnapshotStatus(in));
}
- snapshots = builder.build();
+ snapshots = Collections.unmodifiableList(builder);
}
@Override
diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportSnapshotsStatusAction.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportSnapshotsStatusAction.java
index 65ceaa2c533..12a8135cf44 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportSnapshotsStatusAction.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportSnapshotsStatusAction.java
@@ -19,7 +19,6 @@
package org.elasticsearch.action.admin.cluster.snapshots.status;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
@@ -42,6 +41,8 @@ import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -138,7 +139,7 @@ public class TransportSnapshotsStatusAction extends TransportMasterNodeAction currentSnapshots,
TransportNodesSnapshotsStatus.NodesSnapshotStatus nodeSnapshotStatuses) throws IOException {
// First process snapshot that are currently processed
- ImmutableList.Builder builder = ImmutableList.builder();
+ List builder = new ArrayList<>();
Set currentSnapshotIds = newHashSet();
if (!currentSnapshots.isEmpty()) {
Map nodeSnapshotStatusMap;
@@ -150,7 +151,7 @@ public class TransportSnapshotsStatusAction extends TransportMasterNodeAction shardStatusBuilder = ImmutableList.builder();
+ List shardStatusBuilder = new ArrayList<>();
for (ImmutableMap.Entry shardEntry : entry.shards().entrySet()) {
SnapshotsInProgress.ShardSnapshotStatus status = shardEntry.getValue();
if (status.nodeId() != null) {
@@ -189,7 +190,7 @@ public class TransportSnapshotsStatusAction extends TransportMasterNodeAction shardStatusBuilder = ImmutableList.builder();
+ List shardStatusBuilder = new ArrayList<>();
if (snapshot.state().completed()) {
ImmutableMap shardStatues = snapshotsService.snapshotShards(snapshotId);
for (ImmutableMap.Entry shardStatus : shardStatues.entrySet()) {
@@ -222,13 +223,13 @@ public class TransportSnapshotsStatusAction extends TransportMasterNodeAction> aliasMetaData = metaData.findAliases(aliases, indexAsArray);
+ ImmutableOpenMap> aliasMetaData = metaData.findAliases(aliases, indexAsArray);
List finalAliases = new ArrayList<>();
- for (ObjectCursor> curAliases : aliasMetaData.values()) {
+ for (ObjectCursor> curAliases : aliasMetaData.values()) {
for (AliasMetaData aliasMeta: curAliases.value) {
finalAliases.add(aliasMeta.alias());
}
diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/alias/get/GetAliasesResponse.java b/core/src/main/java/org/elasticsearch/action/admin/indices/alias/get/GetAliasesResponse.java
index 106e864a367..e23faa1cbbf 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/indices/alias/get/GetAliasesResponse.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/indices/alias/get/GetAliasesResponse.java
@@ -20,7 +20,6 @@
package org.elasticsearch.action.admin.indices.alias.get;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
-import com.google.common.collect.ImmutableList;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.cluster.metadata.AliasMetaData;
import org.elasticsearch.common.collect.ImmutableOpenMap;
@@ -29,6 +28,7 @@ import org.elasticsearch.common.io.stream.StreamOutput;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
/**
@@ -61,7 +61,7 @@ public class GetAliasesResponse extends ActionResponse {
for (int j = 0; j < valueSize; j++) {
value.add(AliasMetaData.Builder.readFrom(in));
}
- aliasesBuilder.put(key, ImmutableList.copyOf(value));
+ aliasesBuilder.put(key, Collections.unmodifiableList(value));
}
aliases = aliasesBuilder.build();
}
diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/alias/get/TransportGetAliasesAction.java b/core/src/main/java/org/elasticsearch/action/admin/indices/alias/get/TransportGetAliasesAction.java
index 496b8a3e8d1..7c7dfb039bf 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/indices/alias/get/TransportGetAliasesAction.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/indices/alias/get/TransportGetAliasesAction.java
@@ -64,7 +64,7 @@ public class TransportGetAliasesAction extends TransportMasterNodeReadAction listener) {
String[] concreteIndices = indexNameExpressionResolver.concreteIndices(state, request);
- @SuppressWarnings("unchecked") // ImmutableList to List results incompatible type
+ @SuppressWarnings("unchecked")
ImmutableOpenMap> result = (ImmutableOpenMap) state.metaData().findAliases(request.aliases(), concreteIndices);
listener.onResponse(new GetAliasesResponse(result));
}
diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/close/TransportCloseIndexAction.java b/core/src/main/java/org/elasticsearch/action/admin/indices/close/TransportCloseIndexAction.java
index 6eb0c0665c1..e4793027559 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/indices/close/TransportCloseIndexAction.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/indices/close/TransportCloseIndexAction.java
@@ -48,10 +48,10 @@ public class TransportCloseIndexAction extends TransportMasterNodeAction {
+
private FlushRequest request = new FlushRequest();
- ShardFlushRequest() {
- }
-
- ShardFlushRequest(ShardId shardId, FlushRequest request) {
- super(shardId, request);
+ public ShardFlushRequest(FlushRequest request) {
+ super(request);
this.request = request;
}
+ public ShardFlushRequest() {
+ }
+
+ FlushRequest getRequest() {
+ return request;
+ }
@Override
public void readFrom(StreamInput in) throws IOException {
@@ -53,7 +53,5 @@ class ShardFlushRequest extends BroadcastShardRequest {
request.writeTo(out);
}
- FlushRequest getRequest() {
- return request;
- }
+
}
diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/flush/ShardFlushResponse.java b/core/src/main/java/org/elasticsearch/action/admin/indices/flush/ShardFlushResponse.java
deleted file mode 100644
index 6f2cc6a5522..00000000000
--- a/core/src/main/java/org/elasticsearch/action/admin/indices/flush/ShardFlushResponse.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.elasticsearch.action.admin.indices.flush;
-
-import org.elasticsearch.action.support.broadcast.BroadcastShardResponse;
-import org.elasticsearch.index.shard.ShardId;
-
-/**
- *
- */
-class ShardFlushResponse extends BroadcastShardResponse {
-
- ShardFlushResponse() {
-
- }
-
- ShardFlushResponse(ShardId shardId) {
- super(shardId);
- }
-}
\ No newline at end of file
diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportFlushAction.java b/core/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportFlushAction.java
index 323a6cc2382..2882b508a81 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportFlushAction.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportFlushAction.java
@@ -19,99 +19,45 @@
package org.elasticsearch.action.admin.indices.flush;
+import org.elasticsearch.action.ActionWriteResponse;
import org.elasticsearch.action.ShardOperationFailedException;
import org.elasticsearch.action.support.ActionFilters;
-import org.elasticsearch.action.support.DefaultShardOperationFailedException;
-import org.elasticsearch.action.support.broadcast.BroadcastShardOperationFailedException;
-import org.elasticsearch.action.support.broadcast.TransportBroadcastAction;
+import org.elasticsearch.action.support.replication.TransportBroadcastReplicationAction;
import org.elasticsearch.cluster.ClusterService;
-import org.elasticsearch.cluster.ClusterState;
-import org.elasticsearch.cluster.block.ClusterBlockException;
-import org.elasticsearch.cluster.block.ClusterBlockLevel;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
-import org.elasticsearch.cluster.routing.GroupShardsIterator;
-import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.index.shard.IndexShard;
-import org.elasticsearch.indices.IndicesService;
+import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
-import java.util.ArrayList;
import java.util.List;
-import java.util.concurrent.atomic.AtomicReferenceArray;
/**
* Flush Action.
*/
-public class TransportFlushAction extends TransportBroadcastAction {
-
- private final IndicesService indicesService;
+public class TransportFlushAction extends TransportBroadcastReplicationAction {
@Inject
public TransportFlushAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
- TransportService transportService, IndicesService indicesService,
- ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
- super(settings, FlushAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
- FlushRequest.class, ShardFlushRequest.class, ThreadPool.Names.FLUSH);
- this.indicesService = indicesService;
+ TransportService transportService, ActionFilters actionFilters,
+ IndexNameExpressionResolver indexNameExpressionResolver,
+ TransportShardFlushAction replicatedFlushAction) {
+ super(FlushAction.NAME, FlushRequest.class, settings, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver, replicatedFlushAction);
}
@Override
- protected FlushResponse newResponse(FlushRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) {
- int successfulShards = 0;
- int failedShards = 0;
- List shardFailures = null;
- for (int i = 0; i < shardsResponses.length(); i++) {
- Object shardResponse = shardsResponses.get(i);
- if (shardResponse == null) {
- // a non active shard, ignore
- } else if (shardResponse instanceof BroadcastShardOperationFailedException) {
- failedShards++;
- if (shardFailures == null) {
- shardFailures = new ArrayList<>();
- }
- shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse));
- } else {
- successfulShards++;
- }
- }
- return new FlushResponse(shardsResponses.length(), successfulShards, failedShards, shardFailures);
+ protected ActionWriteResponse newShardResponse() {
+ return new ActionWriteResponse();
}
@Override
- protected ShardFlushRequest newShardRequest(int numShards, ShardRouting shard, FlushRequest request) {
- return new ShardFlushRequest(shard.shardId(), request);
+ protected ShardFlushRequest newShardRequest(FlushRequest request, ShardId shardId) {
+ return new ShardFlushRequest(request).setShardId(shardId);
}
@Override
- protected ShardFlushResponse newShardResponse() {
- return new ShardFlushResponse();
- }
-
- @Override
- protected ShardFlushResponse shardOperation(ShardFlushRequest request) {
- IndexShard indexShard = indicesService.indexServiceSafe(request.shardId().getIndex()).shardSafe(request.shardId().id());
- indexShard.flush(request.getRequest());
- return new ShardFlushResponse(request.shardId());
- }
-
- /**
- * The refresh request works against *all* shards.
- */
- @Override
- protected GroupShardsIterator shards(ClusterState clusterState, FlushRequest request, String[] concreteIndices) {
- return clusterState.routingTable().allActiveShardsGrouped(concreteIndices, true, true);
- }
-
- @Override
- protected ClusterBlockException checkGlobalBlock(ClusterState state, FlushRequest request) {
- return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE);
- }
-
- @Override
- protected ClusterBlockException checkRequestBlock(ClusterState state, FlushRequest countRequest, String[] concreteIndices) {
- return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_WRITE, concreteIndices);
+ protected FlushResponse newResponse(int successfulShards, int failedShards, int totalNumCopies, List shardFailures) {
+ return new FlushResponse(totalNumCopies, successfulShards, failedShards, shardFailures);
}
}
diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportShardFlushAction.java b/core/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportShardFlushAction.java
new file mode 100644
index 00000000000..239a487614f
--- /dev/null
+++ b/core/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportShardFlushAction.java
@@ -0,0 +1,102 @@
+/*
+ * 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.flush;
+
+import org.elasticsearch.action.ActionWriteResponse;
+import org.elasticsearch.action.support.ActionFilters;
+import org.elasticsearch.action.support.replication.TransportReplicationAction;
+import org.elasticsearch.cluster.ClusterService;
+import org.elasticsearch.cluster.ClusterState;
+import org.elasticsearch.cluster.action.index.MappingUpdatedAction;
+import org.elasticsearch.cluster.action.shard.ShardStateAction;
+import org.elasticsearch.cluster.block.ClusterBlockException;
+import org.elasticsearch.cluster.block.ClusterBlockLevel;
+import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
+import org.elasticsearch.cluster.routing.ShardIterator;
+import org.elasticsearch.common.collect.Tuple;
+import org.elasticsearch.common.inject.Inject;
+import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.index.shard.IndexShard;
+import org.elasticsearch.index.shard.ShardId;
+import org.elasticsearch.indices.IndicesService;
+import org.elasticsearch.threadpool.ThreadPool;
+import org.elasticsearch.transport.TransportService;
+
+/**
+ *
+ */
+public class TransportShardFlushAction extends TransportReplicationAction {
+
+ public static final String NAME = FlushAction.NAME + "[s]";
+
+ @Inject
+ public TransportShardFlushAction(Settings settings, TransportService transportService, ClusterService clusterService,
+ IndicesService indicesService, ThreadPool threadPool, ShardStateAction shardStateAction,
+ MappingUpdatedAction mappingUpdatedAction, ActionFilters actionFilters,
+ IndexNameExpressionResolver indexNameExpressionResolver) {
+ super(settings, NAME, transportService, clusterService, indicesService, threadPool, shardStateAction, mappingUpdatedAction,
+ actionFilters, indexNameExpressionResolver, ShardFlushRequest.class, ShardFlushRequest.class, ThreadPool.Names.FLUSH);
+ }
+
+ @Override
+ protected ActionWriteResponse newResponseInstance() {
+ return new ActionWriteResponse();
+ }
+
+ @Override
+ protected Tuple shardOperationOnPrimary(ClusterState clusterState, PrimaryOperationRequest shardRequest) throws Throwable {
+ IndexShard indexShard = indicesService.indexServiceSafe(shardRequest.shardId.getIndex()).shardSafe(shardRequest.shardId.id());
+ indexShard.flush(shardRequest.request.getRequest());
+ logger.trace("{} flush request executed on primary", indexShard.shardId());
+ return new Tuple<>(new ActionWriteResponse(), shardRequest.request);
+ }
+
+ @Override
+ protected void shardOperationOnReplica(ShardId shardId, ShardFlushRequest request) {
+ IndexShard indexShard = indicesService.indexServiceSafe(request.shardId().getIndex()).shardSafe(request.shardId().id());
+ indexShard.flush(request.getRequest());
+ logger.trace("{} flush request executed on replica", indexShard.shardId());
+ }
+
+ @Override
+ protected boolean checkWriteConsistency() {
+ return false;
+ }
+
+ @Override
+ protected ShardIterator shards(ClusterState clusterState, InternalRequest request) {
+ return clusterState.getRoutingTable().indicesRouting().get(request.concreteIndex()).getShards().get(request.request().shardId().getId()).shardsIt();
+ }
+
+ @Override
+ protected ClusterBlockException checkGlobalBlock(ClusterState state) {
+ return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE);
+ }
+
+ @Override
+ protected ClusterBlockException checkRequestBlock(ClusterState state, InternalRequest request) {
+ return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_WRITE, new String[]{request.concreteIndex()});
+ }
+
+ @Override
+ protected boolean shouldExecuteReplication(Settings settings) {
+ return true;
+ }
+}
diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/get/GetIndexResponse.java b/core/src/main/java/org/elasticsearch/action/admin/indices/get/GetIndexResponse.java
index 3bc0ad0e1ff..0930f8f1d4e 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/indices/get/GetIndexResponse.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/indices/get/GetIndexResponse.java
@@ -20,7 +20,6 @@
package org.elasticsearch.action.admin.indices.get;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
-import com.google.common.collect.ImmutableList;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.cluster.metadata.AliasMetaData;
@@ -32,21 +31,24 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.search.warmer.IndexWarmersMetaData;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
/**
* A response for a delete index action.
*/
public class GetIndexResponse extends ActionResponse {
- private ImmutableOpenMap> warmers = ImmutableOpenMap.of();
+ private ImmutableOpenMap> warmers = ImmutableOpenMap.of();
private ImmutableOpenMap> mappings = ImmutableOpenMap.of();
- private ImmutableOpenMap> aliases = ImmutableOpenMap.of();
+ private ImmutableOpenMap> aliases = ImmutableOpenMap.of();
private ImmutableOpenMap settings = ImmutableOpenMap.of();
private String[] indices;
- GetIndexResponse(String[] indices, ImmutableOpenMap> warmers,
+ GetIndexResponse(String[] indices, ImmutableOpenMap> warmers,
ImmutableOpenMap> mappings,
- ImmutableOpenMap> aliases, ImmutableOpenMap settings) {
+ ImmutableOpenMap> aliases, ImmutableOpenMap settings) {
this.indices = indices;
if (warmers != null) {
this.warmers = warmers;
@@ -73,11 +75,11 @@ public class GetIndexResponse extends ActionResponse {
return indices();
}
- public ImmutableOpenMap> warmers() {
+ public ImmutableOpenMap> warmers() {
return warmers;
}
- public ImmutableOpenMap> getWarmers() {
+ public ImmutableOpenMap> getWarmers() {
return warmers();
}
@@ -89,11 +91,11 @@ public class GetIndexResponse extends ActionResponse {
return mappings();
}
- public ImmutableOpenMap> aliases() {
+ public ImmutableOpenMap> aliases() {
return aliases;
}
- public ImmutableOpenMap> getAliases() {
+ public ImmutableOpenMap> getAliases() {
return aliases();
}
@@ -110,11 +112,11 @@ public class GetIndexResponse extends ActionResponse {
super.readFrom(in);
this.indices = in.readStringArray();
int warmersSize = in.readVInt();
- ImmutableOpenMap.Builder> warmersMapBuilder = ImmutableOpenMap.builder();
+ ImmutableOpenMap.Builder> warmersMapBuilder = ImmutableOpenMap.builder();
for (int i = 0; i < warmersSize; i++) {
String key = in.readString();
int valueSize = in.readVInt();
- ImmutableList.Builder warmerEntryBuilder = ImmutableList.builder();
+ List warmerEntryBuilder = new ArrayList<>();
for (int j = 0; j < valueSize; j++) {
warmerEntryBuilder.add(new IndexWarmersMetaData.Entry(
in.readString(),
@@ -123,7 +125,7 @@ public class GetIndexResponse extends ActionResponse {
in.readBytesReference())
);
}
- warmersMapBuilder.put(key, warmerEntryBuilder.build());
+ warmersMapBuilder.put(key, Collections.unmodifiableList(warmerEntryBuilder));
}
warmers = warmersMapBuilder.build();
int mappingsSize = in.readVInt();
@@ -139,15 +141,15 @@ public class GetIndexResponse extends ActionResponse {
}
mappings = mappingsMapBuilder.build();
int aliasesSize = in.readVInt();
- ImmutableOpenMap.Builder> aliasesMapBuilder = ImmutableOpenMap.builder();
+ ImmutableOpenMap.Builder> aliasesMapBuilder = ImmutableOpenMap.builder();
for (int i = 0; i < aliasesSize; i++) {
String key = in.readString();
int valueSize = in.readVInt();
- ImmutableList.Builder aliasEntryBuilder = ImmutableList.builder();
+ List aliasEntryBuilder = new ArrayList<>();
for (int j = 0; j < valueSize; j++) {
aliasEntryBuilder.add(AliasMetaData.Builder.readFrom(in));
}
- aliasesMapBuilder.put(key, aliasEntryBuilder.build());
+ aliasesMapBuilder.put(key, Collections.unmodifiableList(aliasEntryBuilder));
}
aliases = aliasesMapBuilder.build();
int settingsSize = in.readVInt();
@@ -164,7 +166,7 @@ public class GetIndexResponse extends ActionResponse {
super.writeTo(out);
out.writeStringArray(indices);
out.writeVInt(warmers.size());
- for (ObjectObjectCursor> indexEntry : warmers) {
+ for (ObjectObjectCursor> indexEntry : warmers) {
out.writeString(indexEntry.key);
out.writeVInt(indexEntry.value.size());
for (IndexWarmersMetaData.Entry warmerEntry : indexEntry.value) {
@@ -184,7 +186,7 @@ public class GetIndexResponse extends ActionResponse {
}
}
out.writeVInt(aliases.size());
- for (ObjectObjectCursor> indexEntry : aliases) {
+ for (ObjectObjectCursor> indexEntry : aliases) {
out.writeString(indexEntry.key);
out.writeVInt(indexEntry.value.size());
for (AliasMetaData aliasEntry : indexEntry.value) {
diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/get/TransportGetIndexAction.java b/core/src/main/java/org/elasticsearch/action/admin/indices/get/TransportGetIndexAction.java
index 89360ce42b0..e398541fa99 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/indices/get/TransportGetIndexAction.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/indices/get/TransportGetIndexAction.java
@@ -19,7 +19,6 @@
package org.elasticsearch.action.admin.indices.get;
-import com.google.common.collect.ImmutableList;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.admin.indices.get.GetIndexRequest.Feature;
@@ -41,6 +40,8 @@ import org.elasticsearch.search.warmer.IndexWarmersMetaData.Entry;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
+import java.util.List;
+
/**
* Get index action.
*/
@@ -71,9 +72,9 @@ public class TransportGetIndexAction extends TransportClusterInfoAction listener) {
- ImmutableOpenMap> warmersResult = ImmutableOpenMap.of();
+ ImmutableOpenMap> warmersResult = ImmutableOpenMap.of();
ImmutableOpenMap> mappingsResult = ImmutableOpenMap.of();
- ImmutableOpenMap> aliasesResult = ImmutableOpenMap.of();
+ ImmutableOpenMap> aliasesResult = ImmutableOpenMap.of();
ImmutableOpenMap settings = ImmutableOpenMap.of();
Feature[] features = request.features();
boolean doneAliases = false;
diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/open/TransportOpenIndexAction.java b/core/src/main/java/org/elasticsearch/action/admin/indices/open/TransportOpenIndexAction.java
index 1e3abb0257f..3ba8c2e80c4 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/indices/open/TransportOpenIndexAction.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/indices/open/TransportOpenIndexAction.java
@@ -47,10 +47,11 @@ public class TransportOpenIndexAction extends TransportMasterNodeAction {
public static final RefreshAction INSTANCE = new RefreshAction();
diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/refresh/RefreshRequest.java b/core/src/main/java/org/elasticsearch/action/admin/indices/refresh/RefreshRequest.java
index 8f871307135..b0cb49c8874 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/indices/refresh/RefreshRequest.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/indices/refresh/RefreshRequest.java
@@ -33,7 +33,6 @@ import org.elasticsearch.action.support.broadcast.BroadcastRequest;
*/
public class RefreshRequest extends BroadcastRequest {
-
RefreshRequest() {
}
@@ -48,5 +47,4 @@ public class RefreshRequest extends BroadcastRequest {
public RefreshRequest(String... indices) {
super(indices);
}
-
}
diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/refresh/RefreshResponse.java b/core/src/main/java/org/elasticsearch/action/admin/indices/refresh/RefreshResponse.java
index 28295fdd0a0..ba3ec31c6a5 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/indices/refresh/RefreshResponse.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/indices/refresh/RefreshResponse.java
@@ -21,34 +21,18 @@ package org.elasticsearch.action.admin.indices.refresh;
import org.elasticsearch.action.ShardOperationFailedException;
import org.elasticsearch.action.support.broadcast.BroadcastResponse;
-import org.elasticsearch.common.io.stream.StreamInput;
-import org.elasticsearch.common.io.stream.StreamOutput;
-import java.io.IOException;
import java.util.List;
/**
* The response of a refresh action.
- *
- *
*/
public class RefreshResponse extends BroadcastResponse {
RefreshResponse() {
-
}
RefreshResponse(int totalShards, int successfulShards, int failedShards, List shardFailures) {
super(totalShards, successfulShards, failedShards, shardFailures);
}
-
- @Override
- public void readFrom(StreamInput in) throws IOException {
- super.readFrom(in);
- }
-
- @Override
- public void writeTo(StreamOutput out) throws IOException {
- super.writeTo(out);
- }
}
diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/refresh/ShardRefreshRequest.java b/core/src/main/java/org/elasticsearch/action/admin/indices/refresh/ShardRefreshRequest.java
deleted file mode 100644
index 37ea2cc46de..00000000000
--- a/core/src/main/java/org/elasticsearch/action/admin/indices/refresh/ShardRefreshRequest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.elasticsearch.action.admin.indices.refresh;
-
-import org.elasticsearch.action.support.broadcast.BroadcastShardRequest;
-import org.elasticsearch.index.shard.ShardId;
-
-/**
- *
- */
-class ShardRefreshRequest extends BroadcastShardRequest {
-
- ShardRefreshRequest() {
- }
-
- ShardRefreshRequest(ShardId shardId, RefreshRequest request) {
- super(shardId, request);
- }
-
-}
diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/refresh/ShardRefreshResponse.java b/core/src/main/java/org/elasticsearch/action/admin/indices/refresh/ShardRefreshResponse.java
deleted file mode 100644
index 4de0f5877dd..00000000000
--- a/core/src/main/java/org/elasticsearch/action/admin/indices/refresh/ShardRefreshResponse.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.elasticsearch.action.admin.indices.refresh;
-
-import org.elasticsearch.action.support.broadcast.BroadcastShardResponse;
-import org.elasticsearch.index.shard.ShardId;
-
-/**
- *
- */
-class ShardRefreshResponse extends BroadcastShardResponse {
-
- ShardRefreshResponse() {
- }
-
- ShardRefreshResponse(ShardId shardId) {
- super(shardId);
- }
-}
\ No newline at end of file
diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/refresh/TransportRefreshAction.java b/core/src/main/java/org/elasticsearch/action/admin/indices/refresh/TransportRefreshAction.java
index 2eead86e202..2ba385dd7d1 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/indices/refresh/TransportRefreshAction.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/indices/refresh/TransportRefreshAction.java
@@ -19,100 +19,46 @@
package org.elasticsearch.action.admin.indices.refresh;
+import org.elasticsearch.action.ActionWriteResponse;
import org.elasticsearch.action.ShardOperationFailedException;
import org.elasticsearch.action.support.ActionFilters;
-import org.elasticsearch.action.support.DefaultShardOperationFailedException;
-import org.elasticsearch.action.support.broadcast.BroadcastShardOperationFailedException;
-import org.elasticsearch.action.support.broadcast.TransportBroadcastAction;
+import org.elasticsearch.action.support.replication.ReplicationRequest;
+import org.elasticsearch.action.support.replication.TransportBroadcastReplicationAction;
import org.elasticsearch.cluster.ClusterService;
-import org.elasticsearch.cluster.ClusterState;
-import org.elasticsearch.cluster.block.ClusterBlockException;
-import org.elasticsearch.cluster.block.ClusterBlockLevel;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
-import org.elasticsearch.cluster.routing.GroupShardsIterator;
-import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.index.shard.IndexShard;
-import org.elasticsearch.indices.IndicesService;
+import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
-import java.util.ArrayList;
import java.util.List;
-import java.util.concurrent.atomic.AtomicReferenceArray;
/**
* Refresh action.
*/
-public class TransportRefreshAction extends TransportBroadcastAction {
-
- private final IndicesService indicesService;
+public class TransportRefreshAction extends TransportBroadcastReplicationAction {
@Inject
public TransportRefreshAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
- TransportService transportService, IndicesService indicesService,
- ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
- super(settings, RefreshAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
- RefreshRequest.class, ShardRefreshRequest.class, ThreadPool.Names.REFRESH);
- this.indicesService = indicesService;
+ TransportService transportService, ActionFilters actionFilters,
+ IndexNameExpressionResolver indexNameExpressionResolver,
+ TransportShardRefreshAction shardRefreshAction) {
+ super(RefreshAction.NAME, RefreshRequest.class, settings, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver, shardRefreshAction);
}
@Override
- protected RefreshResponse newResponse(RefreshRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) {
- int successfulShards = 0;
- int failedShards = 0;
- List shardFailures = null;
- for (int i = 0; i < shardsResponses.length(); i++) {
- Object shardResponse = shardsResponses.get(i);
- if (shardResponse == null) {
- // non active shard, ignore
- } else if (shardResponse instanceof BroadcastShardOperationFailedException) {
- failedShards++;
- if (shardFailures == null) {
- shardFailures = new ArrayList<>();
- }
- shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse));
- } else {
- successfulShards++;
- }
- }
- return new RefreshResponse(shardsResponses.length(), successfulShards, failedShards, shardFailures);
+ protected ActionWriteResponse newShardResponse() {
+ return new ActionWriteResponse();
}
@Override
- protected ShardRefreshRequest newShardRequest(int numShards, ShardRouting shard, RefreshRequest request) {
- return new ShardRefreshRequest(shard.shardId(), request);
+ protected ReplicationRequest newShardRequest(RefreshRequest request, ShardId shardId) {
+ return new ReplicationRequest(request).setShardId(shardId);
}
@Override
- protected ShardRefreshResponse newShardResponse() {
- return new ShardRefreshResponse();
- }
-
- @Override
- protected ShardRefreshResponse shardOperation(ShardRefreshRequest request) {
- IndexShard indexShard = indicesService.indexServiceSafe(request.shardId().getIndex()).shardSafe(request.shardId().id());
- indexShard.refresh("api");
- logger.trace("{} refresh request executed", indexShard.shardId());
- return new ShardRefreshResponse(request.shardId());
- }
-
- /**
- * The refresh request works against *all* shards.
- */
- @Override
- protected GroupShardsIterator shards(ClusterState clusterState, RefreshRequest request, String[] concreteIndices) {
- return clusterState.routingTable().allAssignedShardsGrouped(concreteIndices, true, true);
- }
-
- @Override
- protected ClusterBlockException checkGlobalBlock(ClusterState state, RefreshRequest request) {
- return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE);
- }
-
- @Override
- protected ClusterBlockException checkRequestBlock(ClusterState state, RefreshRequest countRequest, String[] concreteIndices) {
- return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_WRITE, concreteIndices);
+ protected RefreshResponse newResponse(int successfulShards, int failedShards, int totalNumCopies, List shardFailures) {
+ return new RefreshResponse(totalNumCopies, successfulShards, failedShards, shardFailures);
}
}
diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/refresh/TransportShardRefreshAction.java b/core/src/main/java/org/elasticsearch/action/admin/indices/refresh/TransportShardRefreshAction.java
new file mode 100644
index 00000000000..ac3911abfbf
--- /dev/null
+++ b/core/src/main/java/org/elasticsearch/action/admin/indices/refresh/TransportShardRefreshAction.java
@@ -0,0 +1,103 @@
+/*
+ * 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.refresh;
+
+import org.elasticsearch.action.ActionWriteResponse;
+import org.elasticsearch.action.support.ActionFilters;
+import org.elasticsearch.action.support.replication.ReplicationRequest;
+import org.elasticsearch.action.support.replication.TransportReplicationAction;
+import org.elasticsearch.cluster.ClusterService;
+import org.elasticsearch.cluster.ClusterState;
+import org.elasticsearch.cluster.action.index.MappingUpdatedAction;
+import org.elasticsearch.cluster.action.shard.ShardStateAction;
+import org.elasticsearch.cluster.block.ClusterBlockException;
+import org.elasticsearch.cluster.block.ClusterBlockLevel;
+import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
+import org.elasticsearch.cluster.routing.ShardIterator;
+import org.elasticsearch.common.collect.Tuple;
+import org.elasticsearch.common.inject.Inject;
+import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.index.shard.IndexShard;
+import org.elasticsearch.index.shard.ShardId;
+import org.elasticsearch.indices.IndicesService;
+import org.elasticsearch.threadpool.ThreadPool;
+import org.elasticsearch.transport.TransportService;
+
+/**
+ *
+ */
+public class TransportShardRefreshAction extends TransportReplicationAction {
+
+ public static final String NAME = RefreshAction.NAME + "[s]";
+
+ @Inject
+ public TransportShardRefreshAction(Settings settings, TransportService transportService, ClusterService clusterService,
+ IndicesService indicesService, ThreadPool threadPool, ShardStateAction shardStateAction,
+ MappingUpdatedAction mappingUpdatedAction, ActionFilters actionFilters,
+ IndexNameExpressionResolver indexNameExpressionResolver) {
+ super(settings, NAME, transportService, clusterService, indicesService, threadPool, shardStateAction, mappingUpdatedAction,
+ actionFilters, indexNameExpressionResolver, ReplicationRequest.class, ReplicationRequest.class, ThreadPool.Names.REFRESH);
+ }
+
+ @Override
+ protected ActionWriteResponse newResponseInstance() {
+ return new ActionWriteResponse();
+ }
+
+ @Override
+ protected Tuple shardOperationOnPrimary(ClusterState clusterState, PrimaryOperationRequest shardRequest) throws Throwable {
+ IndexShard indexShard = indicesService.indexServiceSafe(shardRequest.shardId.getIndex()).shardSafe(shardRequest.shardId.id());
+ indexShard.refresh("api");
+ logger.trace("{} refresh request executed on primary", indexShard.shardId());
+ return new Tuple<>(new ActionWriteResponse(), shardRequest.request);
+ }
+
+ @Override
+ protected void shardOperationOnReplica(ShardId shardId, ReplicationRequest request) {
+ IndexShard indexShard = indicesService.indexServiceSafe(shardId.getIndex()).shardSafe(shardId.id());
+ indexShard.refresh("api");
+ logger.trace("{} refresh request executed on replica", indexShard.shardId());
+ }
+
+ @Override
+ protected boolean checkWriteConsistency() {
+ return false;
+ }
+
+ @Override
+ protected ShardIterator shards(ClusterState clusterState, InternalRequest request) {
+ return clusterState.getRoutingTable().indicesRouting().get(request.concreteIndex()).getShards().get(request.request().shardId().getId()).shardsIt();
+ }
+
+ @Override
+ protected ClusterBlockException checkGlobalBlock(ClusterState state) {
+ return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE);
+ }
+
+ @Override
+ protected ClusterBlockException checkRequestBlock(ClusterState state, InternalRequest request) {
+ return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_WRITE, new String[]{request.concreteIndex()});
+ }
+
+ @Override
+ protected boolean shouldExecuteReplication(Settings settings) {
+ return true;
+ }
+}
diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/segments/ShardSegments.java b/core/src/main/java/org/elasticsearch/action/admin/indices/segments/ShardSegments.java
index 4b3264fca40..3e39cfd561f 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/indices/segments/ShardSegments.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/indices/segments/ShardSegments.java
@@ -19,7 +19,6 @@
package org.elasticsearch.action.admin.indices.segments;
-import com.google.common.collect.ImmutableList;
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
@@ -28,6 +27,7 @@ import org.elasticsearch.index.engine.Segment;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@@ -91,7 +91,7 @@ public class ShardSegments implements Streamable, Iterable {
shardRouting = readShardRoutingEntry(in);
int size = in.readVInt();
if (size == 0) {
- segments = ImmutableList.of();
+ segments = Collections.emptyList();
} else {
segments = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoresResponse.java b/core/src/main/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoresResponse.java
index 50d305efe90..84b39d4c689 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoresResponse.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoresResponse.java
@@ -21,7 +21,6 @@ package org.elasticsearch.action.admin.indices.shards;
import com.carrotsearch.hppc.cursors.IntObjectCursor;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
-import com.google.common.collect.ImmutableList;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.ShardOperationFailedException;
@@ -38,6 +37,7 @@ import org.elasticsearch.common.xcontent.XContentBuilderString;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import static org.elasticsearch.action.admin.indices.shards.IndicesShardStoresResponse.StoreStatus.*;
@@ -258,15 +258,15 @@ public class IndicesShardStoresResponse extends ActionResponse implements ToXCon
}
private ImmutableOpenMap>> storeStatuses;
- private ImmutableList failures;
+ private List failures;
- public IndicesShardStoresResponse(ImmutableOpenMap>> storeStatuses, ImmutableList failures) {
+ public IndicesShardStoresResponse(ImmutableOpenMap>> storeStatuses, List failures) {
this.storeStatuses = storeStatuses;
this.failures = failures;
}
IndicesShardStoresResponse() {
- this(ImmutableOpenMap.>>of(), ImmutableList.of());
+ this(ImmutableOpenMap.>>of(), Collections.emptyList());
}
/**
@@ -281,7 +281,7 @@ public class IndicesShardStoresResponse extends ActionResponse implements ToXCon
* Returns node {@link Failure}s encountered
* while executing the request
*/
- public ImmutableList getFailures() {
+ public List getFailures() {
return failures;
}
@@ -306,12 +306,12 @@ public class IndicesShardStoresResponse extends ActionResponse implements ToXCon
storeStatusesBuilder.put(index, shardEntries.build());
}
int numFailure = in.readVInt();
- ImmutableList.Builder failureBuilder = ImmutableList.builder();
+ List failureBuilder = new ArrayList<>();
for (int i = 0; i < numFailure; i++) {
failureBuilder.add(Failure.readFailure(in));
}
storeStatuses = storeStatusesBuilder.build();
- failures = failureBuilder.build();
+ failures = Collections.unmodifiableList(failureBuilder);
}
@Override
diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/shards/TransportIndicesShardStoresAction.java b/core/src/main/java/org/elasticsearch/action/admin/indices/shards/TransportIndicesShardStoresAction.java
index b783ce112ac..01613d69086 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/indices/shards/TransportIndicesShardStoresAction.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/indices/shards/TransportIndicesShardStoresAction.java
@@ -18,7 +18,6 @@
*/
package org.elasticsearch.action.admin.indices.shards;
-import com.google.common.collect.ImmutableList;
import org.apache.lucene.util.CollectionUtil;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.FailedNodeException;
@@ -34,7 +33,11 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.node.DiscoveryNodes;
-import org.elasticsearch.cluster.routing.*;
+import org.elasticsearch.cluster.routing.IndexRoutingTable;
+import org.elasticsearch.cluster.routing.IndexShardRoutingTable;
+import org.elasticsearch.cluster.routing.RoutingNodes;
+import org.elasticsearch.cluster.routing.RoutingTable;
+import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.common.collect.ImmutableOpenIntMap;
import org.elasticsearch.common.collect.ImmutableOpenMap;
import org.elasticsearch.common.inject.Inject;
@@ -48,7 +51,11 @@ import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Queue;
+import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;
/**
@@ -157,7 +164,7 @@ public class TransportIndicesShardStoresAction extends TransportMasterNodeReadAc
void finish() {
ImmutableOpenMap.Builder>> indicesStoreStatusesBuilder = ImmutableOpenMap.builder();
- ImmutableList.Builder failureBuilder = ImmutableList.builder();
+ java.util.List failureBuilder = new ArrayList<>();
for (Response fetchResponse : fetchResponses) {
ImmutableOpenIntMap> indexStoreStatuses = indicesStoreStatusesBuilder.get(fetchResponse.shardId.getIndex());
final ImmutableOpenIntMap.Builder> indexShardsBuilder;
@@ -183,7 +190,7 @@ public class TransportIndicesShardStoresAction extends TransportMasterNodeReadAc
failureBuilder.add(new IndicesShardStoresResponse.Failure(failure.nodeId(), fetchResponse.shardId.getIndex(), fetchResponse.shardId.id(), failure.getCause()));
}
}
- listener.onResponse(new IndicesShardStoresResponse(indicesStoreStatusesBuilder.build(), failureBuilder.build()));
+ listener.onResponse(new IndicesShardStoresResponse(indicesStoreStatusesBuilder.build(), Collections.unmodifiableList(failureBuilder)));
}
private IndicesShardStoresResponse.StoreStatus.Allocation getAllocation(String index, int shardID, DiscoveryNode node) {
diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ValidateQueryResponse.java b/core/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ValidateQueryResponse.java
index 3d1ef78d2bf..2d3c0a0a90e 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ValidateQueryResponse.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ValidateQueryResponse.java
@@ -19,7 +19,6 @@
package org.elasticsearch.action.admin.indices.validate.query;
-import com.google.common.collect.ImmutableList;
import org.elasticsearch.action.ShardOperationFailedException;
import org.elasticsearch.action.support.broadcast.BroadcastResponse;
import org.elasticsearch.common.io.stream.StreamInput;
@@ -27,6 +26,7 @@ import org.elasticsearch.common.io.stream.StreamOutput;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import static org.elasticsearch.action.admin.indices.validate.query.QueryExplanation.readQueryExplanation;
@@ -51,7 +51,7 @@ public class ValidateQueryResponse extends BroadcastResponse {
this.valid = valid;
this.queryExplanations = queryExplanations;
if (queryExplanations == null) {
- this.queryExplanations = ImmutableList.of();
+ this.queryExplanations = Collections.emptyList();
}
}
@@ -67,7 +67,7 @@ public class ValidateQueryResponse extends BroadcastResponse {
*/
public List extends QueryExplanation> getQueryExplanation() {
if (queryExplanations == null) {
- return ImmutableList.of();
+ return Collections.emptyList();
}
return queryExplanations;
}
diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/validate/template/TransportRenderSearchTemplateAction.java b/core/src/main/java/org/elasticsearch/action/admin/indices/validate/template/TransportRenderSearchTemplateAction.java
index d469e29ca96..ab3090a5a81 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/indices/validate/template/TransportRenderSearchTemplateAction.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/indices/validate/template/TransportRenderSearchTemplateAction.java
@@ -55,7 +55,7 @@ public class TransportRenderSearchTemplateAction extends HandledTransportAction<
@Override
protected void doRun() throws Exception {
- ExecutableScript executable = scriptService.executable(request.template(), ScriptContext.Standard.SEARCH);
+ ExecutableScript executable = scriptService.executable(request.template(), ScriptContext.Standard.SEARCH, request);
BytesReference processedTemplate = (BytesReference) executable.run();
RenderSearchTemplateResponse response = new RenderSearchTemplateResponse();
response.source(processedTemplate);
diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/warmer/get/GetWarmersResponse.java b/core/src/main/java/org/elasticsearch/action/admin/indices/warmer/get/GetWarmersResponse.java
index cb45d36d39b..3ed444c88dd 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/indices/warmer/get/GetWarmersResponse.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/indices/warmer/get/GetWarmersResponse.java
@@ -20,7 +20,6 @@
package org.elasticsearch.action.admin.indices.warmer.get;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
-import com.google.common.collect.ImmutableList;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.common.bytes.BytesReference;
@@ -30,6 +29,9 @@ import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.search.warmer.IndexWarmersMetaData;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
/**
* Holds a warmer-name to a list of {@link IndexWarmersMetaData} mapping for each warmer specified
@@ -38,20 +40,20 @@ import java.io.IOException;
*/
public class GetWarmersResponse extends ActionResponse {
- private ImmutableOpenMap> warmers = ImmutableOpenMap.of();
+ private ImmutableOpenMap> warmers = ImmutableOpenMap.of();
- GetWarmersResponse(ImmutableOpenMap> warmers) {
+ GetWarmersResponse(ImmutableOpenMap> warmers) {
this.warmers = warmers;
}
GetWarmersResponse() {
}
- public ImmutableOpenMap> warmers() {
+ public ImmutableOpenMap> warmers() {
return warmers;
}
- public ImmutableOpenMap> getWarmers() {
+ public ImmutableOpenMap> getWarmers() {
return warmers();
}
@@ -59,11 +61,11 @@ public class GetWarmersResponse extends ActionResponse {
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
int size = in.readVInt();
- ImmutableOpenMap.Builder> indexMapBuilder = ImmutableOpenMap.builder();
+ ImmutableOpenMap.Builder> indexMapBuilder = ImmutableOpenMap.builder();
for (int i = 0; i < size; i++) {
String key = in.readString();
int valueSize = in.readVInt();
- ImmutableList.Builder warmerEntryBuilder = ImmutableList.builder();
+ List warmerEntryBuilder = new ArrayList<>();
for (int j = 0; j < valueSize; j++) {
String name = in.readString();
String[] types = in.readStringArray();
@@ -77,7 +79,7 @@ public class GetWarmersResponse extends ActionResponse {
source)
);
}
- indexMapBuilder.put(key, warmerEntryBuilder.build());
+ indexMapBuilder.put(key, Collections.unmodifiableList(warmerEntryBuilder));
}
warmers = indexMapBuilder.build();
}
@@ -86,7 +88,7 @@ public class GetWarmersResponse extends ActionResponse {
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeVInt(warmers.size());
- for (ObjectObjectCursor> indexEntry : warmers) {
+ for (ObjectObjectCursor> indexEntry : warmers) {
out.writeString(indexEntry.key);
out.writeVInt(indexEntry.value.size());
for (IndexWarmersMetaData.Entry warmerEntry : indexEntry.value) {
diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/warmer/get/TransportGetWarmersAction.java b/core/src/main/java/org/elasticsearch/action/admin/indices/warmer/get/TransportGetWarmersAction.java
index 0504e329a1e..50d972b3e61 100644
--- a/core/src/main/java/org/elasticsearch/action/admin/indices/warmer/get/TransportGetWarmersAction.java
+++ b/core/src/main/java/org/elasticsearch/action/admin/indices/warmer/get/TransportGetWarmersAction.java
@@ -19,7 +19,6 @@
package org.elasticsearch.action.admin.indices.warmer.get;
-import com.google.common.collect.ImmutableList;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.info.TransportClusterInfoAction;
@@ -35,6 +34,8 @@ import org.elasticsearch.search.warmer.IndexWarmersMetaData;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
+import java.util.List;
+
/**
* Internal Actions executed on the master fetching the warmer from the cluster state metadata.
*
@@ -66,7 +67,7 @@ public class TransportGetWarmersAction extends TransportClusterInfoAction listener) {
- ImmutableOpenMap> result = state.metaData().findWarmers(
+ ImmutableOpenMap> result = state.metaData().findWarmers(
concreteIndices, request.types(), request.warmers()
);
listener.onResponse(new GetWarmersResponse(result));
diff --git a/core/src/main/java/org/elasticsearch/action/bulk/BulkShardRequest.java b/core/src/main/java/org/elasticsearch/action/bulk/BulkShardRequest.java
index a1eb616b1ee..6bda7b259ee 100644
--- a/core/src/main/java/org/elasticsearch/action/bulk/BulkShardRequest.java
+++ b/core/src/main/java/org/elasticsearch/action/bulk/BulkShardRequest.java
@@ -22,6 +22,7 @@ package org.elasticsearch.action.bulk;
import org.elasticsearch.action.support.replication.ReplicationRequest;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
+import org.elasticsearch.index.shard.ShardId;
import java.io.IOException;
import java.util.ArrayList;
@@ -32,8 +33,6 @@ import java.util.List;
*/
public class BulkShardRequest extends ReplicationRequest {
- private int shardId;
-
private BulkItemRequest[] items;
private boolean refresh;
@@ -44,7 +43,7 @@ public class BulkShardRequest extends ReplicationRequest {
BulkShardRequest(BulkRequest bulkRequest, String index, int shardId, boolean refresh, BulkItemRequest[] items) {
super(bulkRequest);
this.index = index;
- this.shardId = shardId;
+ this.setShardId(new ShardId(index, shardId));
this.items = items;
this.refresh = refresh;
}
@@ -53,10 +52,6 @@ public class BulkShardRequest extends ReplicationRequest {
return this.refresh;
}
- int shardId() {
- return shardId;
- }
-
BulkItemRequest[] items() {
return items;
}
@@ -75,7 +70,6 @@ public class BulkShardRequest extends ReplicationRequest {
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
- out.writeVInt(shardId);
out.writeVInt(items.length);
for (BulkItemRequest item : items) {
if (item != null) {
@@ -91,7 +85,6 @@ public class BulkShardRequest extends ReplicationRequest {
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
- shardId = in.readVInt();
items = new BulkItemRequest[in.readVInt()];
for (int i = 0; i < items.length; i++) {
if (in.readBoolean()) {
diff --git a/core/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java b/core/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java
index 2ca2dfe142a..a9aa3dcb31d 100644
--- a/core/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java
+++ b/core/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java
@@ -109,7 +109,7 @@ public class TransportShardBulkAction extends TransportReplicationAction listener) {
request.request().routing(state.metaData().resolveIndexRouting(request.request().routing(), request.request().index()));
diff --git a/core/src/main/java/org/elasticsearch/action/index/TransportIndexAction.java b/core/src/main/java/org/elasticsearch/action/index/TransportIndexAction.java
index 97620829f3a..83e70c2f504 100644
--- a/core/src/main/java/org/elasticsearch/action/index/TransportIndexAction.java
+++ b/core/src/main/java/org/elasticsearch/action/index/TransportIndexAction.java
@@ -120,11 +120,6 @@ public class TransportIndexAction extends TransportReplicationAction indexResponseActionListener) {
MetaData metaData = clusterService.state().metaData();
diff --git a/core/src/main/java/org/elasticsearch/action/percolate/PercolateShardResponse.java b/core/src/main/java/org/elasticsearch/action/percolate/PercolateShardResponse.java
index c626cda581e..5416e2f66d7 100644
--- a/core/src/main/java/org/elasticsearch/action/percolate/PercolateShardResponse.java
+++ b/core/src/main/java/org/elasticsearch/action/percolate/PercolateShardResponse.java
@@ -18,7 +18,6 @@
*/
package org.elasticsearch.action.percolate;
-import com.google.common.collect.ImmutableList;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.action.support.broadcast.BroadcastShardResponse;
import org.elasticsearch.common.bytes.BytesReference;
@@ -35,6 +34,7 @@ import org.elasticsearch.search.query.QuerySearchResult;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -45,7 +45,7 @@ public class PercolateShardResponse extends BroadcastShardResponse {
private static final BytesRef[] EMPTY_MATCHES = new BytesRef[0];
private static final float[] EMPTY_SCORES = new float[0];
- private static final List