finalize structure, tests pass
This commit is contained in:
parent
98849a2c58
commit
6a71eab51f
162
pom.xml
162
pom.xml
|
@ -34,6 +34,11 @@
|
|||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>elasticsearch</id>
|
||||
<name>elasticsearch repo</name>
|
||||
<url>http://elasticsearch.googlecode.com/svn/maven</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
|
@ -69,6 +74,93 @@
|
|||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- START: dependencies that are shaded -->
|
||||
<dependency>
|
||||
<groupId>com.googlecode.concurrentlinkedhashmap</groupId>
|
||||
<artifactId>concurrentlinkedhashmap-lru</artifactId>
|
||||
<version>1.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>r09</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.elasticsearch</groupId>
|
||||
<artifactId>es-trove</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.elasticsearch</groupId>
|
||||
<artifactId>es-jsr166y</artifactId>
|
||||
<version>20110918</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.elasticsearch</groupId>
|
||||
<artifactId>es-jsr166e</artifactId>
|
||||
<version>20110918</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
<!-- joda 2.0 moved to using volatile fields for datetime, which hurts performance for facets! -->
|
||||
<version>1.6.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mvel</groupId>
|
||||
<artifactId>mvel2</artifactId>
|
||||
<version>2.1.Beta7</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-core-asl</artifactId>
|
||||
<version>1.9.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-smile</artifactId>
|
||||
<version>1.9.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<version>1.6</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jboss.netty</groupId>
|
||||
<artifactId>netty</artifactId>
|
||||
<version>3.2.7.Final</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- END: dependencies that are shaded -->
|
||||
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
|
@ -76,6 +168,42 @@
|
|||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.6.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>1.6.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.java.dev.jna</groupId>
|
||||
<artifactId>jna</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>jline</groupId>
|
||||
<artifactId>jline</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>sigar</groupId>
|
||||
<artifactId>sigar</artifactId>
|
||||
<version>1.6.4</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/sigar/sigar-1.6.4.jar</systemPath>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
|
@ -99,6 +227,40 @@
|
|||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${basedir}/src/main/java</directory>
|
||||
<includes>
|
||||
<include>**/*.json</include>
|
||||
<include>**/*.yml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>${basedir}/src/main/resources</directory>
|
||||
<includes>
|
||||
<include>**/*.*</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<testResources>
|
||||
<testResource>
|
||||
<directory>${basedir}/src/test/java</directory>
|
||||
<includes>
|
||||
<include>**/*.json</include>
|
||||
<include>**/*.yml</include>
|
||||
<include>**/*.txt</include>
|
||||
</includes>
|
||||
</testResource>
|
||||
<testResource>
|
||||
<directory>${basedir}/src/test/resources</directory>
|
||||
<includes>
|
||||
<include>**/*.*</include>
|
||||
</includes>
|
||||
</testResource>
|
||||
</testResources>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -39,7 +39,8 @@ public class TruncateTokenFilter extends TokenFilter {
|
|||
this.size = size;
|
||||
}
|
||||
|
||||
@Override public final boolean incrementToken() throws IOException {
|
||||
@Override
|
||||
public final boolean incrementToken() throws IOException {
|
||||
if (input.incrementToken()) {
|
||||
final int length = termAttribute.length();
|
||||
if (length > size) {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -50,7 +50,8 @@ public class UniqueTokenFilter extends TokenFilter {
|
|||
this.onlyOnSamePosition = onlyOnSamePosition;
|
||||
}
|
||||
|
||||
@Override public final boolean incrementToken() throws IOException {
|
||||
@Override
|
||||
public final boolean incrementToken() throws IOException {
|
||||
while (input.incrementToken()) {
|
||||
final char term[] = termAttribute.buffer();
|
||||
final int length = termAttribute.length();
|
||||
|
@ -79,7 +80,8 @@ public class UniqueTokenFilter extends TokenFilter {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override public final void reset() throws IOException {
|
||||
@Override
|
||||
public final void reset() throws IOException {
|
||||
super.reset();
|
||||
previous.clear();
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -45,7 +45,7 @@ import java.io.IOException;
|
|||
* - trailing "'s" are removed for each subword
|
||||
* - "O'Neil's" -> "O", "Neil"
|
||||
* - Note: this step isn't performed in a separate filter because of possible subword combinations.
|
||||
*
|
||||
* <p/>
|
||||
* The <b>combinations</b> parameter affects how subwords are combined:
|
||||
* - combinations="0" causes no subword combinations.
|
||||
* - "PowerShot" -> 0:"Power", 1:"Shot" (0 and 1 are the token positions)
|
||||
|
@ -53,7 +53,7 @@ import java.io.IOException;
|
|||
* - "PowerShot" -> 0:"Power", 1:"Shot" 1:"PowerShot"
|
||||
* - "A's+B's&C's" -> 0:"A", 1:"B", 2:"C", 2:"ABC"
|
||||
* - "Super-Duper-XL500-42-AutoCoder!" -> 0:"Super", 1:"Duper", 2:"XL", 2:"SuperDuperXL", 3:"500" 4:"42", 5:"Auto", 6:"Coder", 6:"AutoCoder"
|
||||
*
|
||||
* <p/>
|
||||
* One use for WordDelimiterFilter is to help match words with different subword delimiters.
|
||||
* For example, if the source text contained "wi-fi" one may want "wifi" "WiFi" "wi-fi" "wi+fi" queries to all match.
|
||||
* One way of doing so is to specify combinations="1" in the analyzer used for indexing, and combinations="0" (the default)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -23,63 +23,63 @@ import org.apache.lucene.analysis.TokenFilter;
|
|||
import org.apache.lucene.analysis.TokenStream;
|
||||
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.Matcher;
|
||||
import java.io.IOException;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* A TokenFilter which applies a Pattern to each token in the stream,
|
||||
* replacing match occurances with the specified replacement string.
|
||||
*
|
||||
* <p/>
|
||||
* <p>
|
||||
* <b>Note:</b> Depending on the input and the pattern used and the input
|
||||
* TokenStream, this TokenFilter may produce Tokens whose text is the empty
|
||||
* string.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @see Pattern
|
||||
*/
|
||||
public final class PatternReplaceFilter extends TokenFilter {
|
||||
private final Pattern p;
|
||||
private final String replacement;
|
||||
private final boolean all;
|
||||
private final CharTermAttribute termAtt = addAttribute(CharTermAttribute.class);
|
||||
private final Matcher m;
|
||||
private final Pattern p;
|
||||
private final String replacement;
|
||||
private final boolean all;
|
||||
private final CharTermAttribute termAtt = addAttribute(CharTermAttribute.class);
|
||||
private final Matcher m;
|
||||
|
||||
/**
|
||||
* Constructs an instance to replace either the first, or all occurances
|
||||
*
|
||||
* @param in the TokenStream to process
|
||||
* @param p the patterm to apply to each Token
|
||||
* @param replacement the "replacement string" to substitute, if null a
|
||||
* blank string will be used. Note that this is not the literal
|
||||
* string that will be used, '$' and '\' have special meaning.
|
||||
* @param all if true, all matches will be replaced otherwise just the first match.
|
||||
* @see Matcher#quoteReplacement
|
||||
*/
|
||||
public PatternReplaceFilter(TokenStream in,
|
||||
Pattern p,
|
||||
String replacement,
|
||||
boolean all) {
|
||||
super(in);
|
||||
this.p=p;
|
||||
this.replacement = (null == replacement) ? "" : replacement;
|
||||
this.all=all;
|
||||
this.m = p.matcher(termAtt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean incrementToken() throws IOException {
|
||||
if (!input.incrementToken()) return false;
|
||||
|
||||
m.reset();
|
||||
if (m.find()) {
|
||||
// replaceAll/replaceFirst will reset() this previous find.
|
||||
String transformed = all ? m.replaceAll(replacement) : m.replaceFirst(replacement);
|
||||
termAtt.setEmpty().append(transformed);
|
||||
/**
|
||||
* Constructs an instance to replace either the first, or all occurances
|
||||
*
|
||||
* @param in the TokenStream to process
|
||||
* @param p the patterm to apply to each Token
|
||||
* @param replacement the "replacement string" to substitute, if null a
|
||||
* blank string will be used. Note that this is not the literal
|
||||
* string that will be used, '$' and '\' have special meaning.
|
||||
* @param all if true, all matches will be replaced otherwise just the first match.
|
||||
* @see Matcher#quoteReplacement
|
||||
*/
|
||||
public PatternReplaceFilter(TokenStream in,
|
||||
Pattern p,
|
||||
String replacement,
|
||||
boolean all) {
|
||||
super(in);
|
||||
this.p = p;
|
||||
this.replacement = (null == replacement) ? "" : replacement;
|
||||
this.all = all;
|
||||
this.m = p.matcher(termAtt);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean incrementToken() throws IOException {
|
||||
if (!input.incrementToken()) return false;
|
||||
|
||||
m.reset();
|
||||
if (m.find()) {
|
||||
// replaceAll/replaceFirst will reset() this previous find.
|
||||
String transformed = all ? m.replaceAll(replacement) : m.replaceFirst(replacement);
|
||||
termAtt.setEmpty().append(transformed);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -22,7 +22,7 @@ package org.apache.lucene.index;
|
|||
import org.apache.lucene.search.IndexSearcher;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class ExtendedIndexSearcher extends IndexSearcher {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -74,7 +74,8 @@ public class TrackingConcurrentMergeScheduler extends ConcurrentMergeScheduler {
|
|||
return currentMergesSizeInBytes.count();
|
||||
}
|
||||
|
||||
@Override protected void doMerge(MergePolicy.OneMerge merge) throws IOException {
|
||||
@Override
|
||||
protected void doMerge(MergePolicy.OneMerge merge) throws IOException {
|
||||
int totalNumDocs = merge.totalNumDocs();
|
||||
long totalSizeInBytes = merge.totalBytesSize();
|
||||
long time = System.currentTimeMillis();
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
|
|
@ -54,9 +54,9 @@ import java.util.*;
|
|||
|
||||
/**
|
||||
* High-performance single-document main memory Apache Lucene fulltext search index.
|
||||
*
|
||||
* <p/>
|
||||
* <h4>Overview</h4>
|
||||
*
|
||||
* <p/>
|
||||
* This class is a replacement/substitute for a large subset of
|
||||
* {@link RAMDirectory} functionality. It is designed to
|
||||
* enable maximum efficiency for on-the-fly matchmaking combining structured and
|
||||
|
@ -71,7 +71,7 @@ import java.util.*;
|
|||
* <pre>
|
||||
* float score = search(String text, Query query)
|
||||
* </pre>
|
||||
* <p>
|
||||
* <p/>
|
||||
* Each instance can hold at most one Lucene "document", with a document containing
|
||||
* zero or more "fields", each field having a name and a fulltext value. The
|
||||
* fulltext value is tokenized (split and transformed) into zero or more index terms
|
||||
|
@ -82,7 +82,7 @@ import java.util.*;
|
|||
* being reduced to "fish" (stemming), resolve synonyms/inflexions/thesauri
|
||||
* (upon indexing and/or querying), etc. For details, see
|
||||
* <a target="_blank" href="http://today.java.net/pub/a/today/2003/07/30/LuceneIntro.html">Lucene Analyzer Intro</a>.
|
||||
* <p>
|
||||
* <p/>
|
||||
* Arbitrary Lucene queries can be run against this class - see <a target="_blank"
|
||||
* href="../../../../../../../queryparsersyntax.html">Lucene Query Syntax</a>
|
||||
* as well as <a target="_blank"
|
||||
|
@ -90,7 +90,7 @@ import java.util.*;
|
|||
* Note that a Lucene query selects on the field names and associated (indexed)
|
||||
* tokenized terms, not on the original fulltext(s) - the latter are not stored
|
||||
* but rather thrown away immediately after tokenization.
|
||||
* <p>
|
||||
* <p/>
|
||||
* For some interesting background information on search technology, see Bob Wyman's
|
||||
* <a target="_blank"
|
||||
* href="http://bobwyman.pubsub.com/main/2005/05/mary_hodder_poi.html">Prospective Search</a>,
|
||||
|
@ -99,10 +99,10 @@ import java.util.*;
|
|||
* A Call to Arms - Custom subscriptions</a>, and Tim Bray's
|
||||
* <a target="_blank"
|
||||
* href="http://www.tbray.org/ongoing/When/200x/2003/07/30/OnSearchTOC">On Search, the Series</a>.
|
||||
*
|
||||
*
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <h4>Example Usage</h4>
|
||||
*
|
||||
* <p/>
|
||||
* <pre>
|
||||
* Analyzer analyzer = PatternAnalyzer.DEFAULT_ANALYZER;
|
||||
* //Analyzer analyzer = new SimpleAnalyzer();
|
||||
|
@ -118,10 +118,10 @@ import java.util.*;
|
|||
* }
|
||||
* System.out.println("indexData=" + index.toString());
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <h4>Example XQuery Usage</h4>
|
||||
*
|
||||
* <p/>
|
||||
* <pre>
|
||||
* (: An XQuery that finds all books authored by James that have something to do with "salmon fishing manuals", sorted by relevance :)
|
||||
* declare namespace lucene = "java:nux.xom.pool.FullTextUtil";
|
||||
|
@ -132,10 +132,10 @@ import java.util.*;
|
|||
* order by $score descending
|
||||
* return $book
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <h4>No thread safety guarantees</h4>
|
||||
*
|
||||
* <p/>
|
||||
* An instance can be queried multiple times with the same or different queries,
|
||||
* but an instance is not thread-safe. If desired use idioms such as:
|
||||
* <pre>
|
||||
|
@ -144,14 +144,14 @@ import java.util.*;
|
|||
* // read and/or write index (i.e. add fields and/or query)
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <h4>Performance Notes</h4>
|
||||
*
|
||||
* <p/>
|
||||
* Internally there's a new data structure geared towards efficient indexing
|
||||
* and searching, plus the necessary support code to seamlessly plug into the Lucene
|
||||
* framework.
|
||||
* <p>
|
||||
* <p/>
|
||||
* This class performs very well for very small texts (e.g. 10 chars)
|
||||
* as well as for large texts (e.g. 10 MB) and everything in between.
|
||||
* Typically, it is about 10-100 times faster than <code>RAMDirectory</code>.
|
||||
|
@ -159,11 +159,11 @@ import java.util.*;
|
|||
* large efficiency overheads for small to medium sized texts, both in time and space.
|
||||
* Indexing a field with N tokens takes O(N) in the best case, and O(N logN) in the worst
|
||||
* case. Memory consumption is probably larger than for <code>RAMDirectory</code>.
|
||||
* <p>
|
||||
* <p/>
|
||||
* Example throughput of many simple term queries over a single MemoryIndex:
|
||||
* ~500000 queries/sec on a MacBook Pro, jdk 1.5.0_06, server VM.
|
||||
* As always, your mileage may vary.
|
||||
* <p>
|
||||
* <p/>
|
||||
* If you're curious about
|
||||
* the whereabouts of bottlenecks, run java 1.5 with the non-perturbing '-server
|
||||
* -agentlib:hprof=cpu=samples,depth=10' flags, then study the trace log and
|
||||
|
@ -1019,7 +1019,7 @@ public class CustomMemoryIndex implements Serializable {
|
|||
}
|
||||
info.sortTerms();
|
||||
mapper.setExpectations(field, info.sortedTerms.length, stride != 1, true);
|
||||
for (int i = info.sortedTerms.length; --i >= 0;) {
|
||||
for (int i = info.sortedTerms.length; --i >= 0; ) {
|
||||
|
||||
ArrayIntList positions = info.sortedTerms[i].getValue();
|
||||
int size = positions.size();
|
||||
|
@ -1058,7 +1058,7 @@ public class CustomMemoryIndex implements Serializable {
|
|||
|
||||
public String[] getTerms() {
|
||||
String[] terms = new String[sortedTerms.length];
|
||||
for (int i = sortedTerms.length; --i >= 0;) {
|
||||
for (int i = sortedTerms.length; --i >= 0; ) {
|
||||
terms[i] = sortedTerms[i].getKey();
|
||||
}
|
||||
return terms;
|
||||
|
@ -1066,7 +1066,7 @@ public class CustomMemoryIndex implements Serializable {
|
|||
|
||||
public int[] getTermFrequencies() {
|
||||
int[] freqs = new int[sortedTerms.length];
|
||||
for (int i = sortedTerms.length; --i >= 0;) {
|
||||
for (int i = sortedTerms.length; --i >= 0; ) {
|
||||
freqs[i] = numPositions(sortedTerms[i].getValue());
|
||||
}
|
||||
return freqs;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -26,16 +26,17 @@ import org.apache.lucene.search.TermRangeFilter;
|
|||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
|
||||
import static org.elasticsearch.index.query.support.QueryParsers.*;
|
||||
import static org.elasticsearch.index.query.support.QueryParsers.wrapSmartNameFilter;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class ExistsFieldQueryExtension implements FieldQueryExtension {
|
||||
|
||||
public static final String NAME = "_exists_";
|
||||
|
||||
@Override public Query query(QueryParseContext parseContext, String queryText) {
|
||||
@Override
|
||||
public Query query(QueryParseContext parseContext, String queryText) {
|
||||
String fieldName = queryText;
|
||||
Filter filter = null;
|
||||
MapperService.SmartNameFieldMappers smartNameFieldMappers = parseContext.smartFieldMappers(fieldName);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -23,7 +23,7 @@ import org.apache.lucene.search.Query;
|
|||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public interface FieldQueryExtension {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -19,6 +19,7 @@
|
|||
|
||||
package org.apache.lucene.queryParser;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.analysis.TokenStream;
|
||||
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
|
||||
|
@ -26,7 +27,6 @@ import org.apache.lucene.index.Term;
|
|||
import org.apache.lucene.search.BooleanClause;
|
||||
import org.apache.lucene.search.FuzzyQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.elasticsearch.common.collect.ImmutableMap;
|
||||
import org.elasticsearch.common.io.FastStringReader;
|
||||
import org.elasticsearch.common.lucene.Lucene;
|
||||
import org.elasticsearch.common.lucene.search.Queries;
|
||||
|
@ -40,17 +40,18 @@ import java.io.StringReader;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.elasticsearch.common.lucene.search.Queries.*;
|
||||
import static org.elasticsearch.index.query.support.QueryParsers.*;
|
||||
import static org.elasticsearch.common.lucene.search.Queries.fixNegativeQueryIfNeeded;
|
||||
import static org.elasticsearch.common.lucene.search.Queries.optimizeQuery;
|
||||
import static org.elasticsearch.index.query.support.QueryParsers.wrapSmartNameQuery;
|
||||
|
||||
/**
|
||||
* A query parser that uses the {@link MapperService} in order to build smarter
|
||||
* queries based on the mapping information.
|
||||
*
|
||||
* <p/>
|
||||
* <p>Also breaks fields with [type].[name] into a boolean query that must include the type
|
||||
* as well as the query on the name.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class MapperQueryParser extends QueryParser {
|
||||
|
||||
|
@ -95,7 +96,8 @@ public class MapperQueryParser extends QueryParser {
|
|||
this.analyzeWildcard = settings.analyzeWildcard();
|
||||
}
|
||||
|
||||
@Override protected Query newTermQuery(Term term) {
|
||||
@Override
|
||||
protected Query newTermQuery(Term term) {
|
||||
if (currentMapper != null) {
|
||||
Query termQuery = currentMapper.queryStringTermQuery(term);
|
||||
if (termQuery != null) {
|
||||
|
@ -105,11 +107,13 @@ public class MapperQueryParser extends QueryParser {
|
|||
return super.newTermQuery(term);
|
||||
}
|
||||
|
||||
@Override protected Query newMatchAllDocsQuery() {
|
||||
@Override
|
||||
protected Query newMatchAllDocsQuery() {
|
||||
return Queries.MATCH_ALL_QUERY;
|
||||
}
|
||||
|
||||
@Override public Query getFieldQuery(String field, String queryText, boolean quoted) throws ParseException {
|
||||
@Override
|
||||
public Query getFieldQuery(String field, String queryText, boolean quoted) throws ParseException {
|
||||
FieldQueryExtension fieldQueryExtension = fieldQueryExtensions.get(field);
|
||||
if (fieldQueryExtension != null) {
|
||||
return fieldQueryExtension.query(parseContext, queryText);
|
||||
|
@ -138,7 +142,8 @@ public class MapperQueryParser extends QueryParser {
|
|||
}
|
||||
}
|
||||
|
||||
@Override protected Query getRangeQuery(String field, String part1, String part2, boolean inclusive) throws ParseException {
|
||||
@Override
|
||||
protected Query getRangeQuery(String field, String part1, String part2, boolean inclusive) throws ParseException {
|
||||
if ("*".equals(part1)) {
|
||||
part1 = null;
|
||||
}
|
||||
|
@ -157,7 +162,8 @@ public class MapperQueryParser extends QueryParser {
|
|||
return newRangeQuery(field, part1, part2, inclusive);
|
||||
}
|
||||
|
||||
@Override protected Query getFuzzyQuery(String field, String termStr, float minSimilarity) throws ParseException {
|
||||
@Override
|
||||
protected Query getFuzzyQuery(String field, String termStr, float minSimilarity) throws ParseException {
|
||||
currentMapper = null;
|
||||
MapperService.SmartNameFieldMappers fieldMappers = parseContext.smartFieldMappers(field);
|
||||
if (fieldMappers != null) {
|
||||
|
@ -170,7 +176,8 @@ public class MapperQueryParser extends QueryParser {
|
|||
return super.getFuzzyQuery(field, termStr, minSimilarity);
|
||||
}
|
||||
|
||||
@Override protected Query getPrefixQuery(String field, String termStr) throws ParseException {
|
||||
@Override
|
||||
protected Query getPrefixQuery(String field, String termStr) throws ParseException {
|
||||
String indexedNameField = field;
|
||||
currentMapper = null;
|
||||
Analyzer oldAnalyzer = analyzer;
|
||||
|
@ -232,7 +239,8 @@ public class MapperQueryParser extends QueryParser {
|
|||
|
||||
}
|
||||
|
||||
@Override protected Query getWildcardQuery(String field, String termStr) throws ParseException {
|
||||
@Override
|
||||
protected Query getWildcardQuery(String field, String termStr) throws ParseException {
|
||||
if (AllFieldMapper.NAME.equals(field) && termStr.equals("*")) {
|
||||
return newMatchAllDocsQuery();
|
||||
}
|
||||
|
@ -319,7 +327,8 @@ public class MapperQueryParser extends QueryParser {
|
|||
return super.getWildcardQuery(field, aggStr.toString());
|
||||
}
|
||||
|
||||
@Override protected Query getBooleanQuery(List<BooleanClause> clauses, boolean disableCoord) throws ParseException {
|
||||
@Override
|
||||
protected Query getBooleanQuery(List<BooleanClause> clauses, boolean disableCoord) throws ParseException {
|
||||
Query q = super.getBooleanQuery(clauses, disableCoord);
|
||||
if (q == null) {
|
||||
return null;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -27,16 +27,17 @@ import org.elasticsearch.common.lucene.search.NotFilter;
|
|||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
|
||||
import static org.elasticsearch.index.query.support.QueryParsers.*;
|
||||
import static org.elasticsearch.index.query.support.QueryParsers.wrapSmartNameFilter;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class MissingFieldQueryExtension implements FieldQueryExtension {
|
||||
|
||||
public static final String NAME = "_missing_";
|
||||
|
||||
@Override public Query query(QueryParseContext parseContext, String queryText) {
|
||||
@Override
|
||||
public Query query(QueryParseContext parseContext, String queryText) {
|
||||
String fieldName = queryText;
|
||||
|
||||
Filter filter = null;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -19,18 +19,14 @@
|
|||
|
||||
package org.apache.lucene.queryParser;
|
||||
|
||||
import org.apache.lucene.search.BooleanClause;
|
||||
import org.apache.lucene.search.DisjunctionMaxQuery;
|
||||
import org.apache.lucene.search.MultiPhraseQuery;
|
||||
import org.apache.lucene.search.PhraseQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.*;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class MultiFieldMapperQueryParser extends MapperQueryParser {
|
||||
|
||||
|
@ -50,7 +46,8 @@ public class MultiFieldMapperQueryParser extends MapperQueryParser {
|
|||
this.settings = settings;
|
||||
}
|
||||
|
||||
@Override public Query getFieldQuery(String xField, String queryText, boolean quoted) throws ParseException {
|
||||
@Override
|
||||
public Query getFieldQuery(String xField, String queryText, boolean quoted) throws ParseException {
|
||||
if (xField != null) {
|
||||
return super.getFieldQuery(xField, queryText, quoted);
|
||||
}
|
||||
|
@ -84,7 +81,8 @@ public class MultiFieldMapperQueryParser extends MapperQueryParser {
|
|||
}
|
||||
}
|
||||
|
||||
@Override public Query getFieldQuery(String xField, String queryText, int slop) throws ParseException {
|
||||
@Override
|
||||
public Query getFieldQuery(String xField, String queryText, int slop) throws ParseException {
|
||||
if (xField != null) {
|
||||
Query q = super.getFieldQuery(xField, queryText, true);
|
||||
applySlop(q, slop);
|
||||
|
@ -122,7 +120,8 @@ public class MultiFieldMapperQueryParser extends MapperQueryParser {
|
|||
}
|
||||
}
|
||||
|
||||
@Override protected Query getRangeQuery(String xField, String part1, String part2, boolean inclusive) throws ParseException {
|
||||
@Override
|
||||
protected Query getRangeQuery(String xField, String part1, String part2, boolean inclusive) throws ParseException {
|
||||
if (xField != null) {
|
||||
return super.getRangeQuery(xField, part1, part2, inclusive);
|
||||
}
|
||||
|
@ -156,7 +155,8 @@ public class MultiFieldMapperQueryParser extends MapperQueryParser {
|
|||
}
|
||||
}
|
||||
|
||||
@Override protected Query getPrefixQuery(String xField, String termStr) throws ParseException {
|
||||
@Override
|
||||
protected Query getPrefixQuery(String xField, String termStr) throws ParseException {
|
||||
if (xField != null) {
|
||||
return super.getPrefixQuery(xField, termStr);
|
||||
}
|
||||
|
@ -190,7 +190,8 @@ public class MultiFieldMapperQueryParser extends MapperQueryParser {
|
|||
}
|
||||
}
|
||||
|
||||
@Override protected Query getWildcardQuery(String xField, String termStr) throws ParseException {
|
||||
@Override
|
||||
protected Query getWildcardQuery(String xField, String termStr) throws ParseException {
|
||||
if (xField != null) {
|
||||
return super.getWildcardQuery(xField, termStr);
|
||||
}
|
||||
|
@ -224,7 +225,8 @@ public class MultiFieldMapperQueryParser extends MapperQueryParser {
|
|||
}
|
||||
}
|
||||
|
||||
@Override protected Query getFuzzyQuery(String xField, String termStr, float minSimilarity) throws ParseException {
|
||||
@Override
|
||||
protected Query getFuzzyQuery(String xField, String termStr, float minSimilarity) throws ParseException {
|
||||
if (xField != null) {
|
||||
return super.getFuzzyQuery(xField, termStr, minSimilarity);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -19,12 +19,12 @@
|
|||
|
||||
package org.apache.lucene.queryParser;
|
||||
|
||||
import org.elasticsearch.common.trove.map.hash.TObjectFloatHashMap;
|
||||
import gnu.trove.map.hash.TObjectFloatHashMap;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class MultiFieldQueryParserSettings extends QueryParserSettings {
|
||||
|
||||
|
@ -65,7 +65,8 @@ public class MultiFieldQueryParserSettings extends QueryParserSettings {
|
|||
this.useDisMax = useDisMax;
|
||||
}
|
||||
|
||||
@Override public boolean equals(Object o) {
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
|
@ -85,7 +86,8 @@ public class MultiFieldQueryParserSettings extends QueryParserSettings {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override public int hashCode() {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + (fields != null ? fields.hashCode() : 0);
|
||||
result = 31 * result + (boosts != null ? boosts.hashCode() : 0);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -24,7 +24,7 @@ import org.apache.lucene.search.FuzzyQuery;
|
|||
import org.apache.lucene.search.MultiTermQuery;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class QueryParserSettings {
|
||||
|
||||
|
@ -173,7 +173,8 @@ public class QueryParserSettings {
|
|||
this.minimumShouldMatch = minimumShouldMatch;
|
||||
}
|
||||
|
||||
@Override public boolean equals(Object o) {
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
|
@ -201,7 +202,8 @@ public class QueryParserSettings {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override public int hashCode() {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = queryString != null ? queryString.hashCode() : 0;
|
||||
result = 31 * result + (defaultField != null ? defaultField.hashCode() : 0);
|
||||
result = 31 * result + (boost != +0.0f ? Float.floatToIntBits(boost) : 0);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -24,7 +24,7 @@ import org.apache.lucene.index.IndexReader;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
// LUCENE MONITOR: Against ConstantScoreQuery, basically added logic in the doc iterator to take deletions into account
|
||||
// So it can basically be cached safely even with a reader that changes deletions but remain with teh same cache key
|
||||
|
@ -49,7 +49,8 @@ public class DeletionAwareConstantScoreQuery extends ConstantScoreQuery {
|
|||
similarity = getSimilarity(searcher);
|
||||
}
|
||||
|
||||
@Override public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException {
|
||||
@Override
|
||||
public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException {
|
||||
final DocIdSet dis = filter.getDocIdSet(reader);
|
||||
if (dis == null)
|
||||
return null;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -30,7 +30,7 @@ import java.util.Set;
|
|||
import java.util.TreeSet;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
// LUCENE MONITOR: Against TermsFilter
|
||||
public class PublicTermsFilter extends Filter {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -28,7 +28,7 @@ import java.text.Collator;
|
|||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
*
|
||||
*/
|
||||
// LUCENE TRACK, Had to copy over in order ot improve same order tie break to take shards into account
|
||||
public class ShardFieldDocSortedHitQueue extends PriorityQueue<ShardFieldDoc> {
|
||||
|
@ -110,7 +110,8 @@ public class ShardFieldDocSortedHitQueue extends PriorityQueue<ShardFieldDoc> {
|
|||
* @param b ScoreDoc
|
||||
* @return <code>true</code> if document <code>a</code> should be sorted after document <code>b</code>.
|
||||
*/
|
||||
@SuppressWarnings("unchecked") @Override
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected final boolean lessThan(final ShardFieldDoc docA, final ShardFieldDoc docB) {
|
||||
final int n = fields.length;
|
||||
int c = 0;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -21,14 +21,7 @@ package org.apache.lucene.search.vectorhighlight;
|
|||
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.ConstantScoreQuery;
|
||||
import org.apache.lucene.search.DisjunctionMaxQuery;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.FilteredQuery;
|
||||
import org.apache.lucene.search.MultiTermQueryWrapperFilter;
|
||||
import org.apache.lucene.search.PublicTermsFilter;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.TermQuery;
|
||||
import org.apache.lucene.search.*;
|
||||
import org.apache.lucene.search.spans.SpanTermQuery;
|
||||
import org.elasticsearch.common.lucene.search.MultiPhrasePrefixQuery;
|
||||
import org.elasticsearch.common.lucene.search.TermFilter;
|
||||
|
@ -41,7 +34,7 @@ import java.lang.reflect.Field;
|
|||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
// LUCENE MONITOR
|
||||
public class CustomFieldQuery extends FieldQuery {
|
||||
|
@ -68,7 +61,8 @@ public class CustomFieldQuery extends FieldQuery {
|
|||
highlightFilters.remove();
|
||||
}
|
||||
|
||||
@Override void flatten(Query sourceQuery, IndexReader reader, Collection<Query> flatQueries) throws IOException {
|
||||
@Override
|
||||
void flatten(Query sourceQuery, IndexReader reader, Collection<Query> flatQueries) throws IOException {
|
||||
if (sourceQuery instanceof DisjunctionMaxQuery) {
|
||||
DisjunctionMaxQuery dmq = (DisjunctionMaxQuery) sourceQuery;
|
||||
for (Query query : dmq) {
|
||||
|
|
|
@ -27,7 +27,7 @@ import java.nio.ByteBuffer;
|
|||
* A byte buffer allocator simple allocates byte buffers, and handles releasing
|
||||
* them. Implementation can include special direct buffer cleaning when releasing
|
||||
* a buffer, as well as caching of byte buffers.
|
||||
*
|
||||
* <p/>
|
||||
* <p>There are two types of buffers that can be allocated, small and big. This
|
||||
* comes in handy when knowing in advance (more or less) the size of the buffers
|
||||
* needed (large files or small), as well as in caching implementations.
|
||||
|
|
|
@ -33,16 +33,16 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
|
||||
/**
|
||||
* A memory based directory that uses {@link java.nio.ByteBuffer} in order to store the directory content.
|
||||
*
|
||||
* <p/>
|
||||
* <p>The benefit of using {@link java.nio.ByteBuffer} is the fact that it can be stored in "native" memory
|
||||
* outside of the JVM heap, thus not incurring the GC overhead of large in memory index.
|
||||
*
|
||||
* <p/>
|
||||
* <p>Each "file" is segmented into one or more byte buffers.
|
||||
*
|
||||
* <p/>
|
||||
* <p>If constructed with {@link ByteBufferAllocator}, it allows to control the allocation and release of
|
||||
* byte buffer. For example, custom implementations can include caching of byte buffers.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class ByteBufferDirectory extends Directory {
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.nio.ByteBuffer;
|
|||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class ByteBufferFile {
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.io.IOException;
|
|||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class ByteBufferIndexInput extends IndexInput {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -24,7 +24,7 @@ import org.elasticsearch.rest.RestStatus;
|
|||
/**
|
||||
* A base class for all elasticsearch exceptions.
|
||||
*
|
||||
* @author kimchy (Shay Banon)
|
||||
*
|
||||
*/
|
||||
public class ElasticSearchException extends RuntimeException {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -22,7 +22,7 @@ package org.elasticsearch;
|
|||
/**
|
||||
* A generic exception indicating failure to generate.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class ElasticSearchGenerationException extends ElasticSearchException {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -22,7 +22,7 @@ package org.elasticsearch;
|
|||
import org.elasticsearch.rest.RestStatus;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
*
|
||||
*/
|
||||
public class ElasticSearchIllegalArgumentException extends ElasticSearchException {
|
||||
|
||||
|
@ -38,7 +38,8 @@ public class ElasticSearchIllegalArgumentException extends ElasticSearchExceptio
|
|||
super(msg, cause);
|
||||
}
|
||||
|
||||
@Override public RestStatus status() {
|
||||
@Override
|
||||
public RestStatus status() {
|
||||
return RestStatus.BAD_REQUEST;
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -20,7 +20,7 @@
|
|||
package org.elasticsearch;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
*
|
||||
*/
|
||||
public class ElasticSearchIllegalStateException extends ElasticSearchException {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -22,7 +22,7 @@ package org.elasticsearch;
|
|||
/**
|
||||
* The same as {@link InterruptedException} simply a runtime one.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class ElasticSearchInterruptedException extends ElasticSearchException {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -20,7 +20,7 @@
|
|||
package org.elasticsearch;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
*
|
||||
*/
|
||||
public class ElasticSearchNullPointerException extends ElasticSearchException {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -20,7 +20,7 @@
|
|||
package org.elasticsearch;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
*
|
||||
*/
|
||||
public class ElasticSearchParseException extends ElasticSearchException {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -22,7 +22,7 @@ package org.elasticsearch;
|
|||
/**
|
||||
* The same as {@link java.util.concurrent.TimeoutException} simply a runtime one.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class ElasticSearchTimeoutException extends ElasticSearchException {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -20,7 +20,7 @@
|
|||
package org.elasticsearch;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
*
|
||||
*/
|
||||
public interface ElasticSearchWrapperException {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -23,7 +23,7 @@ import org.elasticsearch.common.logging.ESLogger;
|
|||
import org.elasticsearch.common.logging.Loggers;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public final class ExceptionsHelper {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -131,7 +131,8 @@ public class Version {
|
|||
System.out.println("ElasticSearch Version: " + Version.CURRENT + ", JVM: " + JvmInfo.jvmInfo().vmVersion());
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(number());
|
||||
if (snapshot()) {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -22,7 +22,7 @@ package org.elasticsearch.action;
|
|||
import org.elasticsearch.ElasticSearchException;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
*
|
||||
*/
|
||||
public interface Action<Request extends ActionRequest, Response extends ActionResponse> {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -29,7 +29,7 @@ import java.util.concurrent.TimeUnit;
|
|||
/**
|
||||
* An extension to {@link Future} allowing for simplified "get" operations.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public interface ActionFuture<T> extends Future<T> {
|
||||
|
||||
|
@ -37,7 +37,7 @@ public interface ActionFuture<T> extends Future<T> {
|
|||
* Similar to {@link #get()}, just wrapping the {@link InterruptedException} with
|
||||
* {@link org.elasticsearch.ElasticSearchInterruptedException}, and throwing the actual
|
||||
* cause of the {@link java.util.concurrent.ExecutionException}.
|
||||
*
|
||||
* <p/>
|
||||
* <p>Note, the actual cause is unwrapped to the actual failure (for example, unwrapped
|
||||
* from {@link org.elasticsearch.transport.RemoteTransportException}. The root failure is
|
||||
* still accessible using {@link #getRootFailure()}.
|
||||
|
@ -48,7 +48,7 @@ public interface ActionFuture<T> extends Future<T> {
|
|||
* Similar to {@link #get(long, java.util.concurrent.TimeUnit)}, just wrapping the {@link InterruptedException} with
|
||||
* {@link org.elasticsearch.ElasticSearchInterruptedException}, and throwing the actual
|
||||
* cause of the {@link java.util.concurrent.ExecutionException}.
|
||||
*
|
||||
* <p/>
|
||||
* <p>Note, the actual cause is unwrapped to the actual failure (for example, unwrapped
|
||||
* from {@link org.elasticsearch.transport.RemoteTransportException}. The root failure is
|
||||
* still accessible using {@link #getRootFailure()}.
|
||||
|
@ -59,7 +59,7 @@ public interface ActionFuture<T> extends Future<T> {
|
|||
* Similar to {@link #get(long, java.util.concurrent.TimeUnit)}, just wrapping the {@link InterruptedException} with
|
||||
* {@link org.elasticsearch.ElasticSearchInterruptedException}, and throwing the actual
|
||||
* cause of the {@link java.util.concurrent.ExecutionException}.
|
||||
*
|
||||
* <p/>
|
||||
* <p>Note, the actual cause is unwrapped to the actual failure (for example, unwrapped
|
||||
* from {@link org.elasticsearch.transport.RemoteTransportException}. The root failure is
|
||||
* still accessible using {@link #getRootFailure()}.
|
||||
|
@ -72,7 +72,7 @@ public interface ActionFuture<T> extends Future<T> {
|
|||
* Similar to {@link #get(long, java.util.concurrent.TimeUnit)}, just wrapping the {@link InterruptedException} with
|
||||
* {@link org.elasticsearch.ElasticSearchInterruptedException}, and throwing the actual
|
||||
* cause of the {@link java.util.concurrent.ExecutionException}.
|
||||
*
|
||||
* <p/>
|
||||
* <p>Note, the actual cause is unwrapped to the actual failure (for example, unwrapped
|
||||
* from {@link org.elasticsearch.transport.RemoteTransportException}. The root failure is
|
||||
* still accessible using {@link #getRootFailure()}.
|
||||
|
@ -83,7 +83,7 @@ public interface ActionFuture<T> extends Future<T> {
|
|||
* Similar to {@link #get(long, java.util.concurrent.TimeUnit)}, just wrapping the {@link InterruptedException} with
|
||||
* {@link org.elasticsearch.ElasticSearchInterruptedException}, and throwing the actual
|
||||
* cause of the {@link java.util.concurrent.ExecutionException}.
|
||||
*
|
||||
* <p/>
|
||||
* <p>Note, the actual cause is unwrapped to the actual failure (for example, unwrapped
|
||||
* from {@link org.elasticsearch.transport.RemoteTransportException}. The root failure is
|
||||
* still accessible using {@link #getRootFailure()}.
|
||||
|
@ -93,5 +93,6 @@ public interface ActionFuture<T> extends Future<T> {
|
|||
/**
|
||||
* The root (possibly) wrapped failure.
|
||||
*/
|
||||
@Nullable Throwable getRootFailure();
|
||||
@Nullable
|
||||
Throwable getRootFailure();
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -22,7 +22,7 @@ package org.elasticsearch.action;
|
|||
/**
|
||||
* A listener for action responses or failures.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public interface ActionListener<Response> {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -22,7 +22,7 @@ package org.elasticsearch.action;
|
|||
import org.elasticsearch.common.io.stream.Streamable;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public interface ActionRequest extends Streamable {
|
||||
|
||||
|
@ -30,7 +30,7 @@ public interface ActionRequest extends Streamable {
|
|||
|
||||
/**
|
||||
* Should the response listener be executed on a thread or not.
|
||||
*
|
||||
* <p/>
|
||||
* <p>When not executing on a thread, it will either be executed on the calling thread, or
|
||||
* on an expensive, IO based, thread.
|
||||
*/
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -25,7 +25,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class ActionRequestValidationException extends ElasticSearchException {
|
||||
|
||||
|
@ -49,7 +49,8 @@ public class ActionRequestValidationException extends ElasticSearchException {
|
|||
return validationErrors;
|
||||
}
|
||||
|
||||
@Override public String getMessage() {
|
||||
@Override
|
||||
public String getMessage() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Validation Failed: ");
|
||||
int index = 0;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -22,7 +22,7 @@ package org.elasticsearch.action;
|
|||
import org.elasticsearch.common.io.stream.Streamable;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public interface ActionResponse extends Streamable {
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -20,7 +20,7 @@
|
|||
package org.elasticsearch.action;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class Actions {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -22,7 +22,7 @@ package org.elasticsearch.action;
|
|||
import org.elasticsearch.ElasticSearchException;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
*
|
||||
*/
|
||||
public class FailedNodeException extends ElasticSearchException {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -22,7 +22,7 @@ package org.elasticsearch.action;
|
|||
/**
|
||||
* An {@link ActionFuture} that listeners can be added to.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public interface ListenableActionFuture<T> extends ActionFuture<T> {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -23,7 +23,7 @@ import org.elasticsearch.index.shard.IndexShardException;
|
|||
import org.elasticsearch.index.shard.ShardId;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
*
|
||||
*/
|
||||
public class NoShardAvailableActionException extends IndexShardException {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -20,7 +20,7 @@
|
|||
package org.elasticsearch.action;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
*
|
||||
*/
|
||||
public class NoSuchNodeException extends FailedNodeException {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -22,7 +22,7 @@ package org.elasticsearch.action;
|
|||
import org.elasticsearch.ElasticSearchException;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
*
|
||||
*/
|
||||
public class PrimaryMissingActionException extends ElasticSearchException {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -22,7 +22,7 @@ package org.elasticsearch.action;
|
|||
import org.elasticsearch.ElasticSearchException;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class RoutingMissingException extends ElasticSearchException {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -26,7 +26,7 @@ import java.io.Serializable;
|
|||
/**
|
||||
* An exception indicating that a failure occurred performing an operation on the shard.
|
||||
*
|
||||
* @author kimchy (Shay Banon)
|
||||
*
|
||||
*/
|
||||
public interface ShardOperationFailedException extends Streamable, Serializable {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -22,7 +22,7 @@ package org.elasticsearch.action;
|
|||
import org.elasticsearch.ElasticSearchIllegalArgumentException;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
*
|
||||
*/
|
||||
public enum ThreadingModel {
|
||||
NONE((byte) 0),
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -22,7 +22,6 @@ package org.elasticsearch.action;
|
|||
import org.elasticsearch.ElasticSearchException;
|
||||
|
||||
/**
|
||||
* @author paikan (benjamin.deveze)
|
||||
*/
|
||||
public class TimestampParsingException extends ElasticSearchException {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -69,23 +69,16 @@ import org.elasticsearch.action.mlt.TransportMoreLikeThisAction;
|
|||
import org.elasticsearch.action.percolate.TransportPercolateAction;
|
||||
import org.elasticsearch.action.search.TransportSearchAction;
|
||||
import org.elasticsearch.action.search.TransportSearchScrollAction;
|
||||
import org.elasticsearch.action.search.type.TransportSearchCache;
|
||||
import org.elasticsearch.action.search.type.TransportSearchDfsQueryAndFetchAction;
|
||||
import org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction;
|
||||
import org.elasticsearch.action.search.type.TransportSearchQueryAndFetchAction;
|
||||
import org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction;
|
||||
import org.elasticsearch.action.search.type.TransportSearchScanAction;
|
||||
import org.elasticsearch.action.search.type.TransportSearchScrollQueryAndFetchAction;
|
||||
import org.elasticsearch.action.search.type.TransportSearchScrollQueryThenFetchAction;
|
||||
import org.elasticsearch.action.search.type.TransportSearchScrollScanAction;
|
||||
import org.elasticsearch.action.search.type.*;
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class TransportActionModule extends AbstractModule {
|
||||
|
||||
@Override protected void configure() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
|
||||
bind(TransportNodesInfoAction.class).asEagerSingleton();
|
||||
bind(TransportNodesStatsAction.class).asEagerSingleton();
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -20,7 +20,7 @@
|
|||
package org.elasticsearch.action;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class TransportActions {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -23,7 +23,7 @@ import org.elasticsearch.ElasticSearchException;
|
|||
import org.elasticsearch.index.shard.ShardId;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class UnavailableShardsException extends ElasticSearchException {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -25,7 +25,7 @@ import org.elasticsearch.ElasticSearchIllegalArgumentException;
|
|||
* Write Consistency Level control how many replicas should be active for a write operation to occur (a write operation
|
||||
* can be index, or delete).
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public enum WriteConsistencyLevel {
|
||||
DEFAULT((byte) 0),
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -29,10 +29,10 @@ import org.elasticsearch.common.unit.TimeValue;
|
|||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.elasticsearch.common.unit.TimeValue.*;
|
||||
import static org.elasticsearch.common.unit.TimeValue.readTimeValue;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class ClusterHealthRequest extends MasterNodeOperationRequest {
|
||||
|
||||
|
@ -124,11 +124,13 @@ public class ClusterHealthRequest extends MasterNodeOperationRequest {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override public ActionRequestValidationException validate() {
|
||||
@Override
|
||||
public ActionRequestValidationException validate() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
int size = in.readVInt();
|
||||
if (size == 0) {
|
||||
|
@ -148,7 +150,8 @@ public class ClusterHealthRequest extends MasterNodeOperationRequest {
|
|||
waitForNodes = in.readUTF();
|
||||
}
|
||||
|
||||
@Override public void writeTo(StreamOutput out) throws IOException {
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
if (indices == null) {
|
||||
out.writeVInt(0);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -19,9 +19,9 @@
|
|||
|
||||
package org.elasticsearch.action.admin.cluster.health;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.elasticsearch.action.ActionResponse;
|
||||
import org.elasticsearch.common.collect.ImmutableList;
|
||||
import org.elasticsearch.common.collect.Maps;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
|
||||
|
@ -30,11 +30,11 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.elasticsearch.action.admin.cluster.health.ClusterIndexHealth.*;
|
||||
import static org.elasticsearch.common.collect.Lists.*;
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
import static org.elasticsearch.action.admin.cluster.health.ClusterIndexHealth.readClusterIndexHealth;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class ClusterHealthResponse implements ActionResponse, Iterable<ClusterIndexHealth> {
|
||||
|
||||
|
@ -194,11 +194,13 @@ public class ClusterHealthResponse implements ActionResponse, Iterable<ClusterIn
|
|||
return indices();
|
||||
}
|
||||
|
||||
@Override public Iterator<ClusterIndexHealth> iterator() {
|
||||
@Override
|
||||
public Iterator<ClusterIndexHealth> iterator() {
|
||||
return indices.values().iterator();
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
clusterName = in.readUTF();
|
||||
activePrimaryShards = in.readVInt();
|
||||
activeShards = in.readVInt();
|
||||
|
@ -224,7 +226,8 @@ public class ClusterHealthResponse implements ActionResponse, Iterable<ClusterIn
|
|||
}
|
||||
}
|
||||
|
||||
@Override public void writeTo(StreamOutput out) throws IOException {
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
out.writeUTF(clusterName);
|
||||
out.writeVInt(activePrimaryShards);
|
||||
out.writeVInt(activeShards);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -22,7 +22,7 @@ package org.elasticsearch.action.admin.cluster.health;
|
|||
import org.elasticsearch.ElasticSearchIllegalArgumentException;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public enum ClusterHealthStatus {
|
||||
GREEN((byte) 0),
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -19,8 +19,8 @@
|
|||
|
||||
package org.elasticsearch.action.admin.cluster.health;
|
||||
|
||||
import org.elasticsearch.common.collect.ImmutableList;
|
||||
import org.elasticsearch.common.collect.Maps;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.io.stream.Streamable;
|
||||
|
@ -30,10 +30,10 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.elasticsearch.action.admin.cluster.health.ClusterShardHealth.*;
|
||||
import static org.elasticsearch.action.admin.cluster.health.ClusterShardHealth.readClusterShardHealth;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class ClusterIndexHealth implements Iterable<ClusterShardHealth>, Streamable {
|
||||
|
||||
|
@ -157,7 +157,8 @@ public class ClusterIndexHealth implements Iterable<ClusterShardHealth>, Streama
|
|||
return shards();
|
||||
}
|
||||
|
||||
@Override public Iterator<ClusterShardHealth> iterator() {
|
||||
@Override
|
||||
public Iterator<ClusterShardHealth> iterator() {
|
||||
return shards.values().iterator();
|
||||
}
|
||||
|
||||
|
@ -167,7 +168,8 @@ public class ClusterIndexHealth implements Iterable<ClusterShardHealth>, Streama
|
|||
return indexHealth;
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
index = in.readUTF();
|
||||
numberOfShards = in.readVInt();
|
||||
numberOfReplicas = in.readVInt();
|
||||
|
@ -193,7 +195,8 @@ public class ClusterIndexHealth implements Iterable<ClusterShardHealth>, Streama
|
|||
}
|
||||
}
|
||||
|
||||
@Override public void writeTo(StreamOutput out) throws IOException {
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
out.writeUTF(index);
|
||||
out.writeVInt(numberOfShards);
|
||||
out.writeVInt(numberOfReplicas);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -26,7 +26,7 @@ import org.elasticsearch.common.io.stream.Streamable;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class ClusterShardHealth implements Streamable {
|
||||
|
||||
|
@ -114,7 +114,8 @@ public class ClusterShardHealth implements Streamable {
|
|||
return ret;
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
shardId = in.readVInt();
|
||||
status = ClusterHealthStatus.fromValue(in.readByte());
|
||||
activeShards = in.readVInt();
|
||||
|
@ -124,7 +125,8 @@ public class ClusterShardHealth implements Streamable {
|
|||
primaryActive = in.readBoolean();
|
||||
}
|
||||
|
||||
@Override public void writeTo(StreamOutput out) throws IOException {
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
out.writeVInt(shardId);
|
||||
out.writeByte(status.value());
|
||||
out.writeVInt(activeShards);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -38,35 +38,41 @@ import org.elasticsearch.threadpool.ThreadPool;
|
|||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class TransportClusterHealthAction extends TransportMasterNodeOperationAction<ClusterHealthRequest, ClusterHealthResponse> {
|
||||
|
||||
private final ClusterName clusterName;
|
||||
|
||||
@Inject public TransportClusterHealthAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
|
||||
ClusterName clusterName) {
|
||||
@Inject
|
||||
public TransportClusterHealthAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
|
||||
ClusterName clusterName) {
|
||||
super(settings, transportService, clusterService, threadPool);
|
||||
this.clusterName = clusterName;
|
||||
}
|
||||
|
||||
@Override protected String executor() {
|
||||
@Override
|
||||
protected String executor() {
|
||||
return ThreadPool.Names.CACHED;
|
||||
}
|
||||
|
||||
@Override protected String transportAction() {
|
||||
@Override
|
||||
protected String transportAction() {
|
||||
return TransportActions.Admin.Cluster.HEALTH;
|
||||
}
|
||||
|
||||
@Override protected ClusterHealthRequest newRequest() {
|
||||
@Override
|
||||
protected ClusterHealthRequest newRequest() {
|
||||
return new ClusterHealthRequest();
|
||||
}
|
||||
|
||||
@Override protected ClusterHealthResponse newResponse() {
|
||||
@Override
|
||||
protected ClusterHealthResponse newResponse() {
|
||||
return new ClusterHealthResponse();
|
||||
}
|
||||
|
||||
@Override protected ClusterHealthResponse masterOperation(ClusterHealthRequest request, ClusterState unusedState) throws ElasticSearchException {
|
||||
@Override
|
||||
protected ClusterHealthResponse masterOperation(ClusterHealthRequest request, ClusterState unusedState) throws ElasticSearchException {
|
||||
int waitFor = 5;
|
||||
if (request.waitForStatus() == null) {
|
||||
waitFor--;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -19,10 +19,10 @@
|
|||
|
||||
package org.elasticsearch.action.admin.cluster.node.info;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.elasticsearch.action.support.nodes.NodeOperationResponse;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.collect.ImmutableMap;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
|
@ -40,7 +40,7 @@ import java.util.Map;
|
|||
/**
|
||||
* Node information (static, does not change over time).
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class NodeInfo extends NodeOperationResponse {
|
||||
|
||||
|
@ -183,7 +183,8 @@ public class NodeInfo extends NodeOperationResponse {
|
|||
return nodeInfo;
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
|
||||
int size = in.readVInt();
|
||||
|
@ -212,7 +213,8 @@ public class NodeInfo extends NodeOperationResponse {
|
|||
}
|
||||
}
|
||||
|
||||
@Override public void writeTo(StreamOutput out) throws IOException {
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeVInt(attributes.size());
|
||||
for (Map.Entry<String, String> entry : attributes.entrySet()) {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -24,7 +24,7 @@ import org.elasticsearch.action.support.nodes.NodesOperationRequest;
|
|||
/**
|
||||
* A request to get node (cluster) level information.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class NodesInfoRequest extends NodesOperationRequest {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -27,7 +27,7 @@ import org.elasticsearch.common.io.stream.StreamOutput;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
*
|
||||
*/
|
||||
public class NodesInfoResponse extends NodesOperationResponse<NodeInfo> {
|
||||
|
||||
|
@ -38,7 +38,8 @@ public class NodesInfoResponse extends NodesOperationResponse<NodeInfo> {
|
|||
super(clusterName, nodes);
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
nodes = new NodeInfo[in.readVInt()];
|
||||
for (int i = 0; i < nodes.length; i++) {
|
||||
|
@ -46,7 +47,8 @@ public class NodesInfoResponse extends NodesOperationResponse<NodeInfo> {
|
|||
}
|
||||
}
|
||||
|
||||
@Override public void writeTo(StreamOutput out) throws IOException {
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeVInt(nodes.length);
|
||||
for (NodeInfo node : nodes) {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -36,32 +36,37 @@ import java.util.List;
|
|||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class TransportNodesInfoAction extends TransportNodesOperationAction<NodesInfoRequest, NodesInfoResponse, TransportNodesInfoAction.NodeInfoRequest, NodeInfo> {
|
||||
|
||||
private final NodeService nodeService;
|
||||
|
||||
@Inject public TransportNodesInfoAction(Settings settings, ClusterName clusterName, ThreadPool threadPool,
|
||||
ClusterService clusterService, TransportService transportService,
|
||||
NodeService nodeService) {
|
||||
@Inject
|
||||
public TransportNodesInfoAction(Settings settings, ClusterName clusterName, ThreadPool threadPool,
|
||||
ClusterService clusterService, TransportService transportService,
|
||||
NodeService nodeService) {
|
||||
super(settings, clusterName, threadPool, clusterService, transportService);
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
@Override protected String executor() {
|
||||
@Override
|
||||
protected String executor() {
|
||||
return ThreadPool.Names.MANAGEMENT;
|
||||
}
|
||||
|
||||
@Override protected String transportAction() {
|
||||
@Override
|
||||
protected String transportAction() {
|
||||
return TransportActions.Admin.Cluster.Node.INFO;
|
||||
}
|
||||
|
||||
@Override protected String transportNodeAction() {
|
||||
@Override
|
||||
protected String transportNodeAction() {
|
||||
return "/cluster/nodes/info/node";
|
||||
}
|
||||
|
||||
@Override protected NodesInfoResponse newResponse(NodesInfoRequest nodesInfoRequest, AtomicReferenceArray responses) {
|
||||
@Override
|
||||
protected NodesInfoResponse newResponse(NodesInfoRequest nodesInfoRequest, AtomicReferenceArray responses) {
|
||||
final List<NodeInfo> nodesInfos = new ArrayList<NodeInfo>();
|
||||
for (int i = 0; i < responses.length(); i++) {
|
||||
Object resp = responses.get(i);
|
||||
|
@ -72,27 +77,33 @@ public class TransportNodesInfoAction extends TransportNodesOperationAction<Node
|
|||
return new NodesInfoResponse(clusterName, nodesInfos.toArray(new NodeInfo[nodesInfos.size()]));
|
||||
}
|
||||
|
||||
@Override protected NodesInfoRequest newRequest() {
|
||||
@Override
|
||||
protected NodesInfoRequest newRequest() {
|
||||
return new NodesInfoRequest();
|
||||
}
|
||||
|
||||
@Override protected NodeInfoRequest newNodeRequest() {
|
||||
@Override
|
||||
protected NodeInfoRequest newNodeRequest() {
|
||||
return new NodeInfoRequest();
|
||||
}
|
||||
|
||||
@Override protected NodeInfoRequest newNodeRequest(String nodeId, NodesInfoRequest request) {
|
||||
@Override
|
||||
protected NodeInfoRequest newNodeRequest(String nodeId, NodesInfoRequest request) {
|
||||
return new NodeInfoRequest(nodeId);
|
||||
}
|
||||
|
||||
@Override protected NodeInfo newNodeResponse() {
|
||||
@Override
|
||||
protected NodeInfo newNodeResponse() {
|
||||
return new NodeInfo();
|
||||
}
|
||||
|
||||
@Override protected NodeInfo nodeOperation(NodeInfoRequest nodeInfoRequest) throws ElasticSearchException {
|
||||
@Override
|
||||
protected NodeInfo nodeOperation(NodeInfoRequest nodeInfoRequest) throws ElasticSearchException {
|
||||
return nodeService.info();
|
||||
}
|
||||
|
||||
@Override protected boolean accumulateExceptions() {
|
||||
@Override
|
||||
protected boolean accumulateExceptions() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -26,12 +26,12 @@ import org.elasticsearch.common.unit.TimeValue;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.elasticsearch.common.unit.TimeValue.*;
|
||||
import static org.elasticsearch.common.unit.TimeValue.readTimeValue;
|
||||
|
||||
/**
|
||||
* A request to restart one ore more nodes (or the whole cluster).
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class NodesRestartRequest extends NodesOperationRequest {
|
||||
|
||||
|
@ -67,12 +67,14 @@ public class NodesRestartRequest extends NodesOperationRequest {
|
|||
return this.delay;
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
delay = readTimeValue(in);
|
||||
}
|
||||
|
||||
@Override public void writeTo(StreamOutput out) throws IOException {
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
delay.writeTo(out);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -29,7 +29,7 @@ import org.elasticsearch.common.io.stream.StreamOutput;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class NodesRestartResponse extends NodesOperationResponse<NodesRestartResponse.NodeRestartResponse> {
|
||||
|
||||
|
@ -40,7 +40,8 @@ public class NodesRestartResponse extends NodesOperationResponse<NodesRestartRes
|
|||
super(clusterName, nodes);
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
nodes = new NodeRestartResponse[in.readVInt()];
|
||||
for (int i = 0; i < nodes.length; i++) {
|
||||
|
@ -48,7 +49,8 @@ public class NodesRestartResponse extends NodesOperationResponse<NodesRestartRes
|
|||
}
|
||||
}
|
||||
|
||||
@Override public void writeTo(StreamOutput out) throws IOException {
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeVInt(nodes.length);
|
||||
for (NodeRestartResponse node : nodes) {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -41,11 +41,11 @@ import java.util.List;
|
|||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||
|
||||
import static org.elasticsearch.common.collect.Lists.*;
|
||||
import static org.elasticsearch.common.unit.TimeValue.*;
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
import static org.elasticsearch.common.unit.TimeValue.readTimeValue;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class TransportNodesRestartAction extends TransportNodesOperationAction<NodesRestartRequest, NodesRestartResponse, TransportNodesRestartAction.NodeRestartRequest, NodesRestartResponse.NodeRestartResponse> {
|
||||
|
||||
|
@ -55,31 +55,37 @@ public class TransportNodesRestartAction extends TransportNodesOperationAction<N
|
|||
|
||||
private AtomicBoolean restartRequested = new AtomicBoolean();
|
||||
|
||||
@Inject public TransportNodesRestartAction(Settings settings, ClusterName clusterName, ThreadPool threadPool,
|
||||
ClusterService clusterService, TransportService transportService,
|
||||
Node node) {
|
||||
@Inject
|
||||
public TransportNodesRestartAction(Settings settings, ClusterName clusterName, ThreadPool threadPool,
|
||||
ClusterService clusterService, TransportService transportService,
|
||||
Node node) {
|
||||
super(settings, clusterName, threadPool, clusterService, transportService);
|
||||
this.node = node;
|
||||
disabled = componentSettings.getAsBoolean("disabled", false);
|
||||
}
|
||||
|
||||
@Override protected void doExecute(NodesRestartRequest nodesRestartRequest, ActionListener<NodesRestartResponse> listener) {
|
||||
@Override
|
||||
protected void doExecute(NodesRestartRequest nodesRestartRequest, ActionListener<NodesRestartResponse> listener) {
|
||||
listener.onFailure(new ElasticSearchIllegalStateException("restart is disabled (for now) ...."));
|
||||
}
|
||||
|
||||
@Override protected String executor() {
|
||||
@Override
|
||||
protected String executor() {
|
||||
return ThreadPool.Names.CACHED;
|
||||
}
|
||||
|
||||
@Override protected String transportAction() {
|
||||
@Override
|
||||
protected String transportAction() {
|
||||
return TransportActions.Admin.Cluster.Node.RESTART;
|
||||
}
|
||||
|
||||
@Override protected String transportNodeAction() {
|
||||
@Override
|
||||
protected String transportNodeAction() {
|
||||
return "/cluster/nodes/restart/node";
|
||||
}
|
||||
|
||||
@Override protected NodesRestartResponse newResponse(NodesRestartRequest nodesShutdownRequest, AtomicReferenceArray responses) {
|
||||
@Override
|
||||
protected NodesRestartResponse newResponse(NodesRestartRequest nodesShutdownRequest, AtomicReferenceArray responses) {
|
||||
final List<NodesRestartResponse.NodeRestartResponse> nodeRestartResponses = newArrayList();
|
||||
for (int i = 0; i < responses.length(); i++) {
|
||||
Object resp = responses.get(i);
|
||||
|
@ -90,23 +96,28 @@ public class TransportNodesRestartAction extends TransportNodesOperationAction<N
|
|||
return new NodesRestartResponse(clusterName, nodeRestartResponses.toArray(new NodesRestartResponse.NodeRestartResponse[nodeRestartResponses.size()]));
|
||||
}
|
||||
|
||||
@Override protected NodesRestartRequest newRequest() {
|
||||
@Override
|
||||
protected NodesRestartRequest newRequest() {
|
||||
return new NodesRestartRequest();
|
||||
}
|
||||
|
||||
@Override protected NodeRestartRequest newNodeRequest() {
|
||||
@Override
|
||||
protected NodeRestartRequest newNodeRequest() {
|
||||
return new NodeRestartRequest();
|
||||
}
|
||||
|
||||
@Override protected NodeRestartRequest newNodeRequest(String nodeId, NodesRestartRequest request) {
|
||||
@Override
|
||||
protected NodeRestartRequest newNodeRequest(String nodeId, NodesRestartRequest request) {
|
||||
return new NodeRestartRequest(nodeId, request.delay);
|
||||
}
|
||||
|
||||
@Override protected NodesRestartResponse.NodeRestartResponse newNodeResponse() {
|
||||
@Override
|
||||
protected NodesRestartResponse.NodeRestartResponse newNodeResponse() {
|
||||
return new NodesRestartResponse.NodeRestartResponse();
|
||||
}
|
||||
|
||||
@Override protected NodesRestartResponse.NodeRestartResponse nodeOperation(NodeRestartRequest request) throws ElasticSearchException {
|
||||
@Override
|
||||
protected NodesRestartResponse.NodeRestartResponse nodeOperation(NodeRestartRequest request) throws ElasticSearchException {
|
||||
if (disabled) {
|
||||
throw new ElasticSearchIllegalStateException("Restart is disabled");
|
||||
}
|
||||
|
@ -115,7 +126,8 @@ public class TransportNodesRestartAction extends TransportNodesOperationAction<N
|
|||
}
|
||||
logger.info("Restarting in [{}]", request.delay);
|
||||
threadPool.schedule(request.delay, ThreadPool.Names.CACHED, new Runnable() {
|
||||
@Override public void run() {
|
||||
@Override
|
||||
public void run() {
|
||||
boolean restartWithWrapper = false;
|
||||
if (System.getProperty("elasticsearch-service") != null) {
|
||||
try {
|
||||
|
@ -143,7 +155,8 @@ public class TransportNodesRestartAction extends TransportNodesOperationAction<N
|
|||
return new NodesRestartResponse.NodeRestartResponse(clusterService.state().nodes().localNode());
|
||||
}
|
||||
|
||||
@Override protected boolean accumulateExceptions() {
|
||||
@Override
|
||||
protected boolean accumulateExceptions() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -159,12 +172,14 @@ public class TransportNodesRestartAction extends TransportNodesOperationAction<N
|
|||
this.delay = delay;
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
delay = readTimeValue(in);
|
||||
}
|
||||
|
||||
@Override public void writeTo(StreamOutput out) throws IOException {
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
delay.writeTo(out);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -28,10 +28,10 @@ import org.elasticsearch.common.unit.TimeValue;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.elasticsearch.common.unit.TimeValue.*;
|
||||
import static org.elasticsearch.common.unit.TimeValue.readTimeValue;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class NodesShutdownRequest extends MasterNodeOperationRequest {
|
||||
|
||||
|
@ -87,11 +87,13 @@ public class NodesShutdownRequest extends MasterNodeOperationRequest {
|
|||
return exit;
|
||||
}
|
||||
|
||||
@Override public ActionRequestValidationException validate() {
|
||||
@Override
|
||||
public ActionRequestValidationException validate() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
delay = readTimeValue(in);
|
||||
int size = in.readVInt();
|
||||
|
@ -104,7 +106,8 @@ public class NodesShutdownRequest extends MasterNodeOperationRequest {
|
|||
exit = in.readBoolean();
|
||||
}
|
||||
|
||||
@Override public void writeTo(StreamOutput out) throws IOException {
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
delay.writeTo(out);
|
||||
if (nodesIds == null) {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -28,7 +28,7 @@ import org.elasticsearch.common.io.stream.StreamOutput;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class NodesShutdownResponse implements ActionResponse {
|
||||
|
||||
|
@ -60,7 +60,8 @@ public class NodesShutdownResponse implements ActionResponse {
|
|||
return nodes();
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
clusterName = ClusterName.readClusterName(in);
|
||||
nodes = new DiscoveryNode[in.readVInt()];
|
||||
for (int i = 0; i < nodes.length; i++) {
|
||||
|
@ -68,7 +69,8 @@ public class NodesShutdownResponse implements ActionResponse {
|
|||
}
|
||||
}
|
||||
|
||||
@Override public void writeTo(StreamOutput out) throws IOException {
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
clusterName.writeTo(out);
|
||||
out.writeVInt(nodes.length);
|
||||
for (DiscoveryNode node : nodes) {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -19,6 +19,7 @@
|
|||
|
||||
package org.elasticsearch.action.admin.cluster.node.shutdown;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.elasticsearch.ElasticSearchException;
|
||||
import org.elasticsearch.ElasticSearchIllegalStateException;
|
||||
import org.elasticsearch.action.TransportActions;
|
||||
|
@ -27,7 +28,6 @@ import org.elasticsearch.cluster.ClusterName;
|
|||
import org.elasticsearch.cluster.ClusterService;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.common.collect.Sets;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
|
@ -37,18 +37,14 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.node.Node;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.BaseTransportRequestHandler;
|
||||
import org.elasticsearch.transport.TransportChannel;
|
||||
import org.elasticsearch.transport.TransportException;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
import org.elasticsearch.transport.VoidTransportResponseHandler;
|
||||
import org.elasticsearch.transport.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class TransportNodesShutdownAction extends TransportMasterNodeOperationAction<NodesShutdownRequest, NodesShutdownResponse> {
|
||||
|
||||
|
@ -60,8 +56,9 @@ public class TransportNodesShutdownAction extends TransportMasterNodeOperationAc
|
|||
|
||||
private final TimeValue delay;
|
||||
|
||||
@Inject public TransportNodesShutdownAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
|
||||
Node node, ClusterName clusterName) {
|
||||
@Inject
|
||||
public TransportNodesShutdownAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
|
||||
Node node, ClusterName clusterName) {
|
||||
super(settings, transportService, clusterService, threadPool);
|
||||
this.node = node;
|
||||
this.clusterName = clusterName;
|
||||
|
@ -71,23 +68,28 @@ public class TransportNodesShutdownAction extends TransportMasterNodeOperationAc
|
|||
this.transportService.registerHandler(NodeShutdownRequestHandler.ACTION, new NodeShutdownRequestHandler());
|
||||
}
|
||||
|
||||
@Override protected String executor() {
|
||||
@Override
|
||||
protected String executor() {
|
||||
return ThreadPool.Names.CACHED;
|
||||
}
|
||||
|
||||
@Override protected String transportAction() {
|
||||
@Override
|
||||
protected String transportAction() {
|
||||
return TransportActions.Admin.Cluster.Node.SHUTDOWN;
|
||||
}
|
||||
|
||||
@Override protected NodesShutdownRequest newRequest() {
|
||||
@Override
|
||||
protected NodesShutdownRequest newRequest() {
|
||||
return new NodesShutdownRequest();
|
||||
}
|
||||
|
||||
@Override protected NodesShutdownResponse newResponse() {
|
||||
@Override
|
||||
protected NodesShutdownResponse newResponse() {
|
||||
return new NodesShutdownResponse();
|
||||
}
|
||||
|
||||
@Override protected void processBeforeDelegationToMaster(NodesShutdownRequest request, ClusterState state) {
|
||||
@Override
|
||||
protected void processBeforeDelegationToMaster(NodesShutdownRequest request, ClusterState state) {
|
||||
String[] nodesIds = request.nodesIds;
|
||||
if (nodesIds != null) {
|
||||
for (int i = 0; i < nodesIds.length; i++) {
|
||||
|
@ -99,7 +101,8 @@ public class TransportNodesShutdownAction extends TransportMasterNodeOperationAc
|
|||
}
|
||||
}
|
||||
|
||||
@Override protected NodesShutdownResponse masterOperation(final NodesShutdownRequest request, final ClusterState state) throws ElasticSearchException {
|
||||
@Override
|
||||
protected NodesShutdownResponse masterOperation(final NodesShutdownRequest request, final ClusterState state) throws ElasticSearchException {
|
||||
if (disabled) {
|
||||
throw new ElasticSearchIllegalStateException("Shutdown is disabled");
|
||||
}
|
||||
|
@ -109,7 +112,8 @@ public class TransportNodesShutdownAction extends TransportMasterNodeOperationAc
|
|||
nodes.addAll(state.nodes().dataNodes().values());
|
||||
nodes.addAll(state.nodes().masterNodes().values());
|
||||
Thread t = new Thread(new Runnable() {
|
||||
@Override public void run() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep(request.delay.millis());
|
||||
} catch (InterruptedException e) {
|
||||
|
@ -127,12 +131,14 @@ public class TransportNodesShutdownAction extends TransportMasterNodeOperationAc
|
|||
} else {
|
||||
logger.trace("[cluster_shutdown]: sending shutdown request to [{}]", node);
|
||||
transportService.sendRequest(node, NodeShutdownRequestHandler.ACTION, new NodeShutdownRequest(request.exit), new VoidTransportResponseHandler(ThreadPool.Names.SAME) {
|
||||
@Override public void handleResponse(VoidStreamable response) {
|
||||
@Override
|
||||
public void handleResponse(VoidStreamable response) {
|
||||
logger.trace("[cluster_shutdown]: received shutdown response from [{}]", node);
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
@Override public void handleException(TransportException exp) {
|
||||
@Override
|
||||
public void handleException(TransportException exp) {
|
||||
logger.warn("[cluster_shutdown]: received failed shutdown response from [{}]", exp, node);
|
||||
latch.countDown();
|
||||
}
|
||||
|
@ -149,11 +155,13 @@ public class TransportNodesShutdownAction extends TransportMasterNodeOperationAc
|
|||
// now, kill the master
|
||||
logger.trace("[cluster_shutdown]: shutting down the master [{}]", state.nodes().masterNode());
|
||||
transportService.sendRequest(state.nodes().masterNode(), NodeShutdownRequestHandler.ACTION, new NodeShutdownRequest(request.exit), new VoidTransportResponseHandler(ThreadPool.Names.SAME) {
|
||||
@Override public void handleResponse(VoidStreamable response) {
|
||||
@Override
|
||||
public void handleResponse(VoidStreamable response) {
|
||||
logger.trace("[cluster_shutdown]: received shutdown response from master");
|
||||
}
|
||||
|
||||
@Override public void handleException(TransportException exp) {
|
||||
@Override
|
||||
public void handleException(TransportException exp) {
|
||||
logger.warn("[cluster_shutdown]: received failed shutdown response master", exp);
|
||||
}
|
||||
});
|
||||
|
@ -172,7 +180,8 @@ public class TransportNodesShutdownAction extends TransportMasterNodeOperationAc
|
|||
}
|
||||
|
||||
Thread t = new Thread(new Runnable() {
|
||||
@Override public void run() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep(request.delay.millis());
|
||||
} catch (InterruptedException e) {
|
||||
|
@ -190,12 +199,14 @@ public class TransportNodesShutdownAction extends TransportMasterNodeOperationAc
|
|||
|
||||
logger.trace("[partial_cluster_shutdown]: sending shutdown request to [{}]", node);
|
||||
transportService.sendRequest(node, NodeShutdownRequestHandler.ACTION, new NodeShutdownRequest(request.exit), new VoidTransportResponseHandler(ThreadPool.Names.SAME) {
|
||||
@Override public void handleResponse(VoidStreamable response) {
|
||||
@Override
|
||||
public void handleResponse(VoidStreamable response) {
|
||||
logger.trace("[partial_cluster_shutdown]: received shutdown response from [{}]", node);
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
@Override public void handleException(TransportException exp) {
|
||||
@Override
|
||||
public void handleException(TransportException exp) {
|
||||
logger.warn("[partial_cluster_shutdown]: received failed shutdown response from [{}]", exp, node);
|
||||
latch.countDown();
|
||||
}
|
||||
|
@ -220,21 +231,25 @@ public class TransportNodesShutdownAction extends TransportMasterNodeOperationAc
|
|||
|
||||
static final String ACTION = "/cluster/nodes/shutdown/node";
|
||||
|
||||
@Override public NodeShutdownRequest newInstance() {
|
||||
@Override
|
||||
public NodeShutdownRequest newInstance() {
|
||||
return new NodeShutdownRequest();
|
||||
}
|
||||
|
||||
@Override public String executor() {
|
||||
@Override
|
||||
public String executor() {
|
||||
return ThreadPool.Names.SAME;
|
||||
}
|
||||
|
||||
@Override public void messageReceived(final NodeShutdownRequest request, TransportChannel channel) throws Exception {
|
||||
@Override
|
||||
public void messageReceived(final NodeShutdownRequest request, TransportChannel channel) throws Exception {
|
||||
if (disabled) {
|
||||
throw new ElasticSearchIllegalStateException("Shutdown is disabled");
|
||||
}
|
||||
logger.info("shutting down in [{}]", delay);
|
||||
Thread t = new Thread(new Runnable() {
|
||||
@Override public void run() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep(delay.millis());
|
||||
} catch (InterruptedException e) {
|
||||
|
@ -290,11 +305,13 @@ public class TransportNodesShutdownAction extends TransportMasterNodeOperationAc
|
|||
this.exit = exit;
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
exit = in.readBoolean();
|
||||
}
|
||||
|
||||
@Override public void writeTo(StreamOutput out) throws IOException {
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
out.writeBoolean(exit);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -37,7 +37,7 @@ import java.io.IOException;
|
|||
/**
|
||||
* Node statistics (static, does not change over time).
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class NodeStats extends NodeOperationResponse {
|
||||
|
||||
|
@ -163,7 +163,8 @@ public class NodeStats extends NodeOperationResponse {
|
|||
return nodeInfo;
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
if (in.readBoolean()) {
|
||||
indices = NodeIndicesStats.readIndicesStats(in);
|
||||
|
@ -188,7 +189,8 @@ public class NodeStats extends NodeOperationResponse {
|
|||
}
|
||||
}
|
||||
|
||||
@Override public void writeTo(StreamOutput out) throws IOException {
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
if (indices == null) {
|
||||
out.writeBoolean(false);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -24,7 +24,7 @@ import org.elasticsearch.action.support.nodes.NodesOperationRequest;
|
|||
/**
|
||||
* A request to get node (cluster) level stats.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class NodesStatsRequest extends NodesOperationRequest {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -27,7 +27,7 @@ import org.elasticsearch.common.io.stream.StreamOutput;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class NodesStatsResponse extends NodesOperationResponse<NodeStats> {
|
||||
|
||||
|
@ -38,7 +38,8 @@ public class NodesStatsResponse extends NodesOperationResponse<NodeStats> {
|
|||
super(clusterName, nodes);
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
nodes = new NodeStats[in.readVInt()];
|
||||
for (int i = 0; i < nodes.length; i++) {
|
||||
|
@ -46,7 +47,8 @@ public class NodesStatsResponse extends NodesOperationResponse<NodeStats> {
|
|||
}
|
||||
}
|
||||
|
||||
@Override public void writeTo(StreamOutput out) throws IOException {
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeVInt(nodes.length);
|
||||
for (NodeStats node : nodes) {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -19,13 +19,13 @@
|
|||
|
||||
package org.elasticsearch.action.admin.cluster.node.stats;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.elasticsearch.ElasticSearchException;
|
||||
import org.elasticsearch.action.TransportActions;
|
||||
import org.elasticsearch.action.support.nodes.NodeOperationRequest;
|
||||
import org.elasticsearch.action.support.nodes.TransportNodesOperationAction;
|
||||
import org.elasticsearch.cluster.ClusterName;
|
||||
import org.elasticsearch.cluster.ClusterService;
|
||||
import org.elasticsearch.common.collect.Lists;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.node.service.NodeService;
|
||||
|
@ -36,32 +36,37 @@ import java.util.List;
|
|||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class TransportNodesStatsAction extends TransportNodesOperationAction<NodesStatsRequest, NodesStatsResponse, TransportNodesStatsAction.NodeStatsRequest, NodeStats> {
|
||||
|
||||
private final NodeService nodeService;
|
||||
|
||||
@Inject public TransportNodesStatsAction(Settings settings, ClusterName clusterName, ThreadPool threadPool,
|
||||
ClusterService clusterService, TransportService transportService,
|
||||
NodeService nodeService) {
|
||||
@Inject
|
||||
public TransportNodesStatsAction(Settings settings, ClusterName clusterName, ThreadPool threadPool,
|
||||
ClusterService clusterService, TransportService transportService,
|
||||
NodeService nodeService) {
|
||||
super(settings, clusterName, threadPool, clusterService, transportService);
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
@Override protected String executor() {
|
||||
@Override
|
||||
protected String executor() {
|
||||
return ThreadPool.Names.MANAGEMENT;
|
||||
}
|
||||
|
||||
@Override protected String transportAction() {
|
||||
@Override
|
||||
protected String transportAction() {
|
||||
return TransportActions.Admin.Cluster.Node.STATS;
|
||||
}
|
||||
|
||||
@Override protected String transportNodeAction() {
|
||||
@Override
|
||||
protected String transportNodeAction() {
|
||||
return "/cluster/nodes/stats/node";
|
||||
}
|
||||
|
||||
@Override protected NodesStatsResponse newResponse(NodesStatsRequest nodesInfoRequest, AtomicReferenceArray responses) {
|
||||
@Override
|
||||
protected NodesStatsResponse newResponse(NodesStatsRequest nodesInfoRequest, AtomicReferenceArray responses) {
|
||||
final List<NodeStats> nodeStats = Lists.newArrayList();
|
||||
for (int i = 0; i < responses.length(); i++) {
|
||||
Object resp = responses.get(i);
|
||||
|
@ -72,27 +77,33 @@ public class TransportNodesStatsAction extends TransportNodesOperationAction<Nod
|
|||
return new NodesStatsResponse(clusterName, nodeStats.toArray(new NodeStats[nodeStats.size()]));
|
||||
}
|
||||
|
||||
@Override protected NodesStatsRequest newRequest() {
|
||||
@Override
|
||||
protected NodesStatsRequest newRequest() {
|
||||
return new NodesStatsRequest();
|
||||
}
|
||||
|
||||
@Override protected NodeStatsRequest newNodeRequest() {
|
||||
@Override
|
||||
protected NodeStatsRequest newNodeRequest() {
|
||||
return new NodeStatsRequest();
|
||||
}
|
||||
|
||||
@Override protected NodeStatsRequest newNodeRequest(String nodeId, NodesStatsRequest request) {
|
||||
@Override
|
||||
protected NodeStatsRequest newNodeRequest(String nodeId, NodesStatsRequest request) {
|
||||
return new NodeStatsRequest(nodeId);
|
||||
}
|
||||
|
||||
@Override protected NodeStats newNodeResponse() {
|
||||
@Override
|
||||
protected NodeStats newNodeResponse() {
|
||||
return new NodeStats();
|
||||
}
|
||||
|
||||
@Override protected NodeStats nodeOperation(NodeStatsRequest request) throws ElasticSearchException {
|
||||
@Override
|
||||
protected NodeStats nodeOperation(NodeStatsRequest request) throws ElasticSearchException {
|
||||
return nodeService.stats();
|
||||
}
|
||||
|
||||
@Override protected boolean accumulateExceptions() {
|
||||
@Override
|
||||
protected boolean accumulateExceptions() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -28,11 +28,12 @@ import org.elasticsearch.common.io.stream.StreamOutput;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class BroadcastPingRequest extends BroadcastOperationRequest {
|
||||
|
||||
@Nullable protected String queryHint;
|
||||
@Nullable
|
||||
protected String queryHint;
|
||||
|
||||
BroadcastPingRequest() {
|
||||
}
|
||||
|
@ -42,12 +43,14 @@ public class BroadcastPingRequest extends BroadcastOperationRequest {
|
|||
this.queryHint = null;
|
||||
}
|
||||
|
||||
@Override public BroadcastPingRequest operationThreading(BroadcastOperationThreading operationThreading) {
|
||||
@Override
|
||||
public BroadcastPingRequest operationThreading(BroadcastOperationThreading operationThreading) {
|
||||
super.operationThreading(operationThreading);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override public BroadcastPingRequest listenerThreaded(boolean threadedListener) {
|
||||
@Override
|
||||
public BroadcastPingRequest listenerThreaded(boolean threadedListener) {
|
||||
super.listenerThreaded(threadedListener);
|
||||
return this;
|
||||
}
|
||||
|
@ -61,14 +64,16 @@ public class BroadcastPingRequest extends BroadcastOperationRequest {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
if (in.readBoolean()) {
|
||||
queryHint = in.readUTF();
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void writeTo(StreamOutput out) throws IOException {
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
if (queryHint == null) {
|
||||
out.writeBoolean(false);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -28,7 +28,7 @@ import java.io.IOException;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
*
|
||||
*/
|
||||
public class BroadcastPingResponse extends BroadcastOperationResponse {
|
||||
|
||||
|
@ -40,11 +40,13 @@ public class BroadcastPingResponse extends BroadcastOperationResponse {
|
|||
super(totalShards, successfulShards, failedShards, shardFailures);
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
}
|
||||
|
||||
@Override public void writeTo(StreamOutput out) throws IOException {
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -26,7 +26,7 @@ import org.elasticsearch.common.io.stream.StreamOutput;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
*
|
||||
*/
|
||||
public class BroadcastShardPingRequest extends BroadcastShardOperationRequest {
|
||||
|
||||
|
@ -38,11 +38,13 @@ public class BroadcastShardPingRequest extends BroadcastShardOperationRequest {
|
|||
super(index, shardId);
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
}
|
||||
|
||||
@Override public void writeTo(StreamOutput out) throws IOException {
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -26,7 +26,7 @@ import org.elasticsearch.common.io.stream.StreamOutput;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
*
|
||||
*/
|
||||
public class BroadcastShardPingResponse extends BroadcastShardOperationResponse {
|
||||
|
||||
|
@ -38,11 +38,13 @@ public class BroadcastShardPingResponse extends BroadcastShardOperationResponse
|
|||
super(index, shardId);
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
}
|
||||
|
||||
@Override public void writeTo(StreamOutput out) throws IOException {
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -37,38 +37,45 @@ import org.elasticsearch.transport.TransportService;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||
|
||||
import static org.elasticsearch.common.collect.Lists.*;
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
*
|
||||
*/
|
||||
public class TransportBroadcastPingAction extends TransportBroadcastOperationAction<BroadcastPingRequest, BroadcastPingResponse, BroadcastShardPingRequest, BroadcastShardPingResponse> {
|
||||
|
||||
@Inject public TransportBroadcastPingAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService) {
|
||||
@Inject
|
||||
public TransportBroadcastPingAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService) {
|
||||
super(settings, threadPool, clusterService, transportService);
|
||||
}
|
||||
|
||||
@Override protected String executor() {
|
||||
@Override
|
||||
protected String executor() {
|
||||
return ThreadPool.Names.CACHED;
|
||||
}
|
||||
|
||||
@Override protected String transportAction() {
|
||||
@Override
|
||||
protected String transportAction() {
|
||||
return TransportActions.Admin.Cluster.Ping.BROADCAST;
|
||||
}
|
||||
|
||||
@Override protected String transportShardAction() {
|
||||
@Override
|
||||
protected String transportShardAction() {
|
||||
return "/cluster/ping/broadcast/shard";
|
||||
}
|
||||
|
||||
@Override protected BroadcastPingRequest newRequest() {
|
||||
@Override
|
||||
protected BroadcastPingRequest newRequest() {
|
||||
return new BroadcastPingRequest();
|
||||
}
|
||||
|
||||
@Override protected GroupShardsIterator shards(BroadcastPingRequest request, String[] concreteIndices, ClusterState clusterState) {
|
||||
@Override
|
||||
protected GroupShardsIterator shards(BroadcastPingRequest request, String[] concreteIndices, ClusterState clusterState) {
|
||||
return clusterService.operationRouting().searchShards(clusterState, request.indices(), concreteIndices, request.queryHint(), null, null);
|
||||
}
|
||||
|
||||
@Override protected BroadcastPingResponse newResponse(BroadcastPingRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) {
|
||||
@Override
|
||||
protected BroadcastPingResponse newResponse(BroadcastPingRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) {
|
||||
int successfulShards = 0;
|
||||
int failedShards = 0;
|
||||
List<ShardOperationFailedException> shardFailures = null;
|
||||
|
@ -89,19 +96,23 @@ public class TransportBroadcastPingAction extends TransportBroadcastOperationAct
|
|||
return new BroadcastPingResponse(shardsResponses.length(), successfulShards, failedShards, shardFailures);
|
||||
}
|
||||
|
||||
@Override protected BroadcastShardPingRequest newShardRequest() {
|
||||
@Override
|
||||
protected BroadcastShardPingRequest newShardRequest() {
|
||||
return new BroadcastShardPingRequest();
|
||||
}
|
||||
|
||||
@Override protected BroadcastShardPingRequest newShardRequest(ShardRouting shard, BroadcastPingRequest request) {
|
||||
@Override
|
||||
protected BroadcastShardPingRequest newShardRequest(ShardRouting shard, BroadcastPingRequest request) {
|
||||
return new BroadcastShardPingRequest(shard.index(), shard.id());
|
||||
}
|
||||
|
||||
@Override protected BroadcastShardPingResponse newShardResponse() {
|
||||
@Override
|
||||
protected BroadcastShardPingResponse newShardResponse() {
|
||||
return new BroadcastShardPingResponse();
|
||||
}
|
||||
|
||||
@Override protected BroadcastShardPingResponse shardOperation(BroadcastShardPingRequest broadcastShardPingRequest) throws ElasticSearchException {
|
||||
@Override
|
||||
protected BroadcastShardPingResponse shardOperation(BroadcastShardPingRequest broadcastShardPingRequest) throws ElasticSearchException {
|
||||
return new BroadcastShardPingResponse();
|
||||
}
|
||||
}
|
|
@ -28,7 +28,7 @@ import org.elasticsearch.common.unit.TimeValue;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class IndexReplicationPingRequest extends IndexReplicationOperationRequest {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -27,7 +27,7 @@ import org.elasticsearch.common.io.stream.Streamable;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
*
|
||||
*/
|
||||
public class IndexReplicationPingResponse implements ActionResponse, Streamable {
|
||||
|
||||
|
@ -63,13 +63,15 @@ public class IndexReplicationPingResponse implements ActionResponse, Streamable
|
|||
return successfulShards + failedShards;
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
index = in.readUTF();
|
||||
successfulShards = in.readVInt();
|
||||
failedShards = in.readVInt();
|
||||
}
|
||||
|
||||
@Override public void writeTo(StreamOutput out) throws IOException {
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
out.writeUTF(index);
|
||||
out.writeVInt(successfulShards);
|
||||
out.writeVInt(failedShards);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -24,7 +24,7 @@ import org.elasticsearch.action.support.replication.ReplicationType;
|
|||
import org.elasticsearch.common.unit.TimeValue;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
*
|
||||
*/
|
||||
public class ReplicationPingRequest extends IndicesReplicationOperationRequest {
|
||||
|
||||
|
@ -36,7 +36,8 @@ public class ReplicationPingRequest extends IndicesReplicationOperationRequest {
|
|||
|
||||
}
|
||||
|
||||
@Override public ReplicationPingRequest listenerThreaded(boolean threadedListener) {
|
||||
@Override
|
||||
public ReplicationPingRequest listenerThreaded(boolean threadedListener) {
|
||||
super.listenerThreaded(threadedListener);
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -29,7 +29,7 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
*
|
||||
*/
|
||||
public class ReplicationPingResponse implements ActionResponse, Streamable {
|
||||
|
||||
|
@ -47,7 +47,8 @@ public class ReplicationPingResponse implements ActionResponse, Streamable {
|
|||
return responses.get(index);
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
int size = in.readVInt();
|
||||
for (int i = 0; i < size; i++) {
|
||||
IndexReplicationPingResponse response = new IndexReplicationPingResponse();
|
||||
|
@ -56,7 +57,8 @@ public class ReplicationPingResponse implements ActionResponse, Streamable {
|
|||
}
|
||||
}
|
||||
|
||||
@Override public void writeTo(StreamOutput out) throws IOException {
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
out.writeVInt(responses.size());
|
||||
for (IndexReplicationPingResponse response : responses.values()) {
|
||||
response.writeTo(out);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -27,7 +27,7 @@ import org.elasticsearch.common.io.stream.StreamOutput;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class ShardReplicationPingRequest extends ShardReplicationOperationRequest {
|
||||
|
||||
|
@ -51,32 +51,38 @@ public class ShardReplicationPingRequest extends ShardReplicationOperationReques
|
|||
return this.shardId;
|
||||
}
|
||||
|
||||
@Override public ShardReplicationPingRequest listenerThreaded(boolean threadedListener) {
|
||||
@Override
|
||||
public ShardReplicationPingRequest listenerThreaded(boolean threadedListener) {
|
||||
super.listenerThreaded(threadedListener);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override public ShardReplicationPingRequest operationThreaded(boolean threadedOperation) {
|
||||
@Override
|
||||
public ShardReplicationPingRequest operationThreaded(boolean threadedOperation) {
|
||||
super.operationThreaded(threadedOperation);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override public ShardReplicationPingRequest replicationType(ReplicationType replicationType) {
|
||||
@Override
|
||||
public ShardReplicationPingRequest replicationType(ReplicationType replicationType) {
|
||||
super.replicationType(replicationType);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
shardId = in.readVInt();
|
||||
}
|
||||
|
||||
@Override public void writeTo(StreamOutput out) throws IOException {
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeVInt(shardId);
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "replication_ping {[" + index + "][" + shardId + "]}";
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -27,7 +27,7 @@ import org.elasticsearch.common.io.stream.Streamable;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
*
|
||||
*/
|
||||
public class ShardReplicationPingResponse implements ActionResponse, Streamable {
|
||||
|
||||
|
@ -35,9 +35,11 @@ public class ShardReplicationPingResponse implements ActionResponse, Streamable
|
|||
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
}
|
||||
|
||||
@Override public void writeTo(StreamOutput out) throws IOException {
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -36,17 +36,20 @@ import java.util.concurrent.atomic.AtomicReferenceArray;
|
|||
*/
|
||||
public class TransportIndexReplicationPingAction extends TransportIndexReplicationOperationAction<IndexReplicationPingRequest, IndexReplicationPingResponse, ShardReplicationPingRequest, ShardReplicationPingRequest, ShardReplicationPingResponse> {
|
||||
|
||||
@Inject public TransportIndexReplicationPingAction(Settings settings, ClusterService clusterService,
|
||||
TransportService transportService, ThreadPool threadPool,
|
||||
TransportShardReplicationPingAction shardReplicationPingAction) {
|
||||
@Inject
|
||||
public TransportIndexReplicationPingAction(Settings settings, ClusterService clusterService,
|
||||
TransportService transportService, ThreadPool threadPool,
|
||||
TransportShardReplicationPingAction shardReplicationPingAction) {
|
||||
super(settings, transportService, clusterService, threadPool, shardReplicationPingAction);
|
||||
}
|
||||
|
||||
@Override protected IndexReplicationPingRequest newRequestInstance() {
|
||||
@Override
|
||||
protected IndexReplicationPingRequest newRequestInstance() {
|
||||
return new IndexReplicationPingRequest();
|
||||
}
|
||||
|
||||
@Override protected IndexReplicationPingResponse newResponseInstance(IndexReplicationPingRequest request, AtomicReferenceArray shardsResponses) {
|
||||
@Override
|
||||
protected IndexReplicationPingResponse newResponseInstance(IndexReplicationPingRequest request, AtomicReferenceArray shardsResponses) {
|
||||
int successfulShards = 0;
|
||||
int failedShards = 0;
|
||||
for (int i = 0; i < shardsResponses.length(); i++) {
|
||||
|
@ -59,15 +62,18 @@ public class TransportIndexReplicationPingAction extends TransportIndexReplicati
|
|||
return new IndexReplicationPingResponse(request.index(), successfulShards, failedShards);
|
||||
}
|
||||
|
||||
@Override protected boolean accumulateExceptions() {
|
||||
@Override
|
||||
protected boolean accumulateExceptions() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override protected String transportAction() {
|
||||
@Override
|
||||
protected String transportAction() {
|
||||
return "ping/replication/index";
|
||||
}
|
||||
|
||||
@Override protected GroupShardsIterator shards(IndexReplicationPingRequest indexRequest) {
|
||||
@Override
|
||||
protected GroupShardsIterator shards(IndexReplicationPingRequest indexRequest) {
|
||||
IndexRoutingTable indexRouting = clusterService.state().routingTable().index(indexRequest.index());
|
||||
if (indexRouting == null) {
|
||||
throw new IndexMissingException(new Index(indexRequest.index()));
|
||||
|
@ -75,7 +81,8 @@ public class TransportIndexReplicationPingAction extends TransportIndexReplicati
|
|||
return indexRouting.groupByShardsIt();
|
||||
}
|
||||
|
||||
@Override protected ShardReplicationPingRequest newShardRequestInstance(IndexReplicationPingRequest indexRequest, int shardId) {
|
||||
@Override
|
||||
protected ShardReplicationPingRequest newShardRequestInstance(IndexReplicationPingRequest indexRequest, int shardId) {
|
||||
return new ShardReplicationPingRequest(indexRequest, shardId);
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -34,15 +34,18 @@ import java.util.concurrent.atomic.AtomicReferenceArray;
|
|||
*/
|
||||
public class TransportReplicationPingAction extends TransportIndicesReplicationOperationAction<ReplicationPingRequest, ReplicationPingResponse, IndexReplicationPingRequest, IndexReplicationPingResponse, ShardReplicationPingRequest, ShardReplicationPingRequest, ShardReplicationPingResponse> {
|
||||
|
||||
@Inject public TransportReplicationPingAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, TransportIndexReplicationPingAction indexAction) {
|
||||
@Inject
|
||||
public TransportReplicationPingAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, TransportIndexReplicationPingAction indexAction) {
|
||||
super(settings, transportService, clusterService, threadPool, indexAction);
|
||||
}
|
||||
|
||||
@Override protected ReplicationPingRequest newRequestInstance() {
|
||||
@Override
|
||||
protected ReplicationPingRequest newRequestInstance() {
|
||||
return new ReplicationPingRequest();
|
||||
}
|
||||
|
||||
@Override protected ReplicationPingResponse newResponseInstance(ReplicationPingRequest request, AtomicReferenceArray indexResponses) {
|
||||
@Override
|
||||
protected ReplicationPingResponse newResponseInstance(ReplicationPingRequest request, AtomicReferenceArray indexResponses) {
|
||||
ReplicationPingResponse response = new ReplicationPingResponse();
|
||||
for (int i = 0; i < indexResponses.length(); i++) {
|
||||
IndexReplicationPingResponse indexResponse = (IndexReplicationPingResponse) indexResponses.get(i);
|
||||
|
@ -53,15 +56,18 @@ public class TransportReplicationPingAction extends TransportIndicesReplicationO
|
|||
return response;
|
||||
}
|
||||
|
||||
@Override protected boolean accumulateExceptions() {
|
||||
@Override
|
||||
protected boolean accumulateExceptions() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override protected String transportAction() {
|
||||
@Override
|
||||
protected String transportAction() {
|
||||
return TransportActions.Admin.Cluster.Ping.REPLICATION;
|
||||
}
|
||||
|
||||
@Override protected IndexReplicationPingRequest newIndexRequestInstance(ReplicationPingRequest request, String index, Set<String> routing) {
|
||||
@Override
|
||||
protected IndexReplicationPingRequest newIndexRequestInstance(ReplicationPingRequest request, String index, Set<String> routing) {
|
||||
return new IndexReplicationPingRequest(request, index);
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -31,48 +31,58 @@ import org.elasticsearch.threadpool.ThreadPool;
|
|||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class TransportShardReplicationPingAction extends TransportShardReplicationOperationAction<ShardReplicationPingRequest, ShardReplicationPingRequest, ShardReplicationPingResponse> {
|
||||
|
||||
@Inject public TransportShardReplicationPingAction(Settings settings, TransportService transportService,
|
||||
ClusterService clusterService, IndicesService indicesService, ThreadPool threadPool,
|
||||
ShardStateAction shardStateAction) {
|
||||
@Inject
|
||||
public TransportShardReplicationPingAction(Settings settings, TransportService transportService,
|
||||
ClusterService clusterService, IndicesService indicesService, ThreadPool threadPool,
|
||||
ShardStateAction shardStateAction) {
|
||||
super(settings, transportService, clusterService, indicesService, threadPool, shardStateAction);
|
||||
}
|
||||
|
||||
@Override protected String executor() {
|
||||
@Override
|
||||
protected String executor() {
|
||||
return ThreadPool.Names.CACHED;
|
||||
}
|
||||
|
||||
@Override protected boolean checkWriteConsistency() {
|
||||
@Override
|
||||
protected boolean checkWriteConsistency() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override protected ShardReplicationPingRequest newRequestInstance() {
|
||||
@Override
|
||||
protected ShardReplicationPingRequest newRequestInstance() {
|
||||
return new ShardReplicationPingRequest();
|
||||
}
|
||||
|
||||
@Override protected ShardReplicationPingRequest newReplicaRequestInstance() {
|
||||
@Override
|
||||
protected ShardReplicationPingRequest newReplicaRequestInstance() {
|
||||
return new ShardReplicationPingRequest();
|
||||
}
|
||||
|
||||
@Override protected ShardReplicationPingResponse newResponseInstance() {
|
||||
@Override
|
||||
protected ShardReplicationPingResponse newResponseInstance() {
|
||||
return new ShardReplicationPingResponse();
|
||||
}
|
||||
|
||||
@Override protected String transportAction() {
|
||||
@Override
|
||||
protected String transportAction() {
|
||||
return "ping/replication/shard";
|
||||
}
|
||||
|
||||
@Override protected PrimaryResponse<ShardReplicationPingResponse, ShardReplicationPingRequest> shardOperationOnPrimary(ClusterState clusterState, PrimaryOperationRequest shardRequest) {
|
||||
@Override
|
||||
protected PrimaryResponse<ShardReplicationPingResponse, ShardReplicationPingRequest> shardOperationOnPrimary(ClusterState clusterState, PrimaryOperationRequest shardRequest) {
|
||||
return new PrimaryResponse<ShardReplicationPingResponse, ShardReplicationPingRequest>(shardRequest.request, new ShardReplicationPingResponse(), null);
|
||||
}
|
||||
|
||||
@Override protected void shardOperationOnReplica(ReplicaOperationRequest shardRequest) {
|
||||
@Override
|
||||
protected void shardOperationOnReplica(ReplicaOperationRequest shardRequest) {
|
||||
}
|
||||
|
||||
@Override protected ShardIterator shards(ClusterState clusterState, ShardReplicationPingRequest request) {
|
||||
@Override
|
||||
protected ShardIterator shards(ClusterState clusterState, ShardReplicationPingRequest request) {
|
||||
return clusterService.state().routingTable().index(request.index()).shard(request.shardId()).shardsIt();
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -26,7 +26,7 @@ import org.elasticsearch.common.io.stream.StreamOutput;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
*
|
||||
*/
|
||||
public class SinglePingRequest extends SingleShardOperationRequest {
|
||||
|
||||
|
@ -61,23 +61,27 @@ public class SinglePingRequest extends SingleShardOperationRequest {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override public SinglePingRequest listenerThreaded(boolean threadedListener) {
|
||||
@Override
|
||||
public SinglePingRequest listenerThreaded(boolean threadedListener) {
|
||||
super.listenerThreaded(threadedListener);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override public SinglePingRequest operationThreaded(boolean threadedOperation) {
|
||||
@Override
|
||||
public SinglePingRequest operationThreaded(boolean threadedOperation) {
|
||||
super.operationThreaded(threadedOperation);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
type = in.readUTF();
|
||||
id = in.readUTF();
|
||||
}
|
||||
|
||||
@Override public void writeTo(StreamOutput out) throws IOException {
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeUTF(type);
|
||||
out.writeUTF(id);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -26,13 +26,15 @@ import org.elasticsearch.common.io.stream.StreamOutput;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
*
|
||||
*/
|
||||
public class SinglePingResponse implements ActionResponse {
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
}
|
||||
|
||||
@Override public void writeTo(StreamOutput out) throws IOException {
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -31,40 +31,48 @@ import org.elasticsearch.threadpool.ThreadPool;
|
|||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class TransportSinglePingAction extends TransportShardSingleOperationAction<SinglePingRequest, SinglePingResponse> {
|
||||
|
||||
@Inject public TransportSinglePingAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService) {
|
||||
@Inject
|
||||
public TransportSinglePingAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService) {
|
||||
super(settings, threadPool, clusterService, transportService);
|
||||
}
|
||||
|
||||
@Override protected String executor() {
|
||||
@Override
|
||||
protected String executor() {
|
||||
return ThreadPool.Names.CACHED;
|
||||
}
|
||||
|
||||
@Override protected String transportAction() {
|
||||
@Override
|
||||
protected String transportAction() {
|
||||
return TransportActions.Admin.Cluster.Ping.SINGLE;
|
||||
}
|
||||
|
||||
@Override protected String transportShardAction() {
|
||||
@Override
|
||||
protected String transportShardAction() {
|
||||
return "/cluster/ping/single/shard";
|
||||
}
|
||||
|
||||
@Override protected ShardIterator shards(ClusterState clusterState, SinglePingRequest request) throws ElasticSearchException {
|
||||
@Override
|
||||
protected ShardIterator shards(ClusterState clusterState, SinglePingRequest request) throws ElasticSearchException {
|
||||
return clusterService.operationRouting()
|
||||
.getShards(clusterService.state(), request.index(), request.type, request.id, null, null);
|
||||
}
|
||||
|
||||
@Override protected SinglePingResponse shardOperation(SinglePingRequest request, int shardId) throws ElasticSearchException {
|
||||
@Override
|
||||
protected SinglePingResponse shardOperation(SinglePingRequest request, int shardId) throws ElasticSearchException {
|
||||
return new SinglePingResponse();
|
||||
}
|
||||
|
||||
@Override protected SinglePingRequest newRequest() {
|
||||
@Override
|
||||
protected SinglePingRequest newRequest() {
|
||||
return new SinglePingRequest();
|
||||
}
|
||||
|
||||
@Override protected SinglePingResponse newResponse() {
|
||||
@Override
|
||||
protected SinglePingResponse newResponse() {
|
||||
return new SinglePingResponse();
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -33,15 +33,18 @@ public class ClusterRerouteRequest extends MasterNodeOperationRequest {
|
|||
public ClusterRerouteRequest() {
|
||||
}
|
||||
|
||||
@Override public ActionRequestValidationException validate() {
|
||||
@Override
|
||||
public ActionRequestValidationException validate() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
}
|
||||
|
||||
@Override public void writeTo(StreamOutput out) throws IOException {
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -32,9 +32,11 @@ public class ClusterRerouteResponse implements ActionResponse {
|
|||
ClusterRerouteResponse() {
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
}
|
||||
|
||||
@Override public void writeTo(StreamOutput out) throws IOException {
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -35,7 +35,7 @@ import org.elasticsearch.transport.TransportService;
|
|||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static org.elasticsearch.cluster.ClusterState.*;
|
||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -43,34 +43,41 @@ public class TransportClusterRerouteAction extends TransportMasterNodeOperationA
|
|||
|
||||
private final AllocationService allocationService;
|
||||
|
||||
@Inject public TransportClusterRerouteAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
|
||||
AllocationService allocationService) {
|
||||
@Inject
|
||||
public TransportClusterRerouteAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
|
||||
AllocationService allocationService) {
|
||||
super(settings, transportService, clusterService, threadPool);
|
||||
this.allocationService = allocationService;
|
||||
}
|
||||
|
||||
@Override protected String executor() {
|
||||
@Override
|
||||
protected String executor() {
|
||||
return ThreadPool.Names.CACHED;
|
||||
}
|
||||
|
||||
@Override protected String transportAction() {
|
||||
@Override
|
||||
protected String transportAction() {
|
||||
return TransportActions.Admin.Cluster.REROUTE;
|
||||
}
|
||||
|
||||
@Override protected ClusterRerouteRequest newRequest() {
|
||||
@Override
|
||||
protected ClusterRerouteRequest newRequest() {
|
||||
return new ClusterRerouteRequest();
|
||||
}
|
||||
|
||||
@Override protected ClusterRerouteResponse newResponse() {
|
||||
@Override
|
||||
protected ClusterRerouteResponse newResponse() {
|
||||
return new ClusterRerouteResponse();
|
||||
}
|
||||
|
||||
@Override protected ClusterRerouteResponse masterOperation(ClusterRerouteRequest request, ClusterState state) throws ElasticSearchException {
|
||||
@Override
|
||||
protected ClusterRerouteResponse masterOperation(ClusterRerouteRequest request, ClusterState state) throws ElasticSearchException {
|
||||
final AtomicReference<Throwable> failureRef = new AtomicReference<Throwable>();
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
|
||||
clusterService.submitStateUpdateTask("cluster_reroute (api)", new ProcessedClusterStateUpdateTask() {
|
||||
@Override public ClusterState execute(ClusterState currentState) {
|
||||
@Override
|
||||
public ClusterState execute(ClusterState currentState) {
|
||||
try {
|
||||
RoutingAllocation.Result routingResult = allocationService.reroute(currentState);
|
||||
return newClusterStateBuilder().state(currentState).routingResult(routingResult).build();
|
||||
|
@ -83,7 +90,8 @@ public class TransportClusterRerouteAction extends TransportMasterNodeOperationA
|
|||
}
|
||||
}
|
||||
|
||||
@Override public void clusterStateProcessed(ClusterState clusterState) {
|
||||
@Override
|
||||
public void clusterStateProcessed(ClusterState clusterState) {
|
||||
latch.countDown();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -33,9 +33,10 @@ import org.elasticsearch.common.xcontent.XContentType;
|
|||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.elasticsearch.action.Actions.*;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.Builder.*;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.*;
|
||||
import static org.elasticsearch.action.Actions.addValidationError;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.Builder.EMPTY_SETTINGS;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.readSettingsFromStream;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.writeSettingsToStream;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -47,7 +48,8 @@ public class ClusterUpdateSettingsRequest extends MasterNodeOperationRequest {
|
|||
public ClusterUpdateSettingsRequest() {
|
||||
}
|
||||
|
||||
@Override public ActionRequestValidationException validate() {
|
||||
@Override
|
||||
public ActionRequestValidationException validate() {
|
||||
ActionRequestValidationException validationException = null;
|
||||
if (transientSettings.getAsMap().isEmpty() && persistentSettings.getAsMap().isEmpty()) {
|
||||
validationException = addValidationError("no settings to update", validationException);
|
||||
|
@ -116,13 +118,15 @@ public class ClusterUpdateSettingsRequest extends MasterNodeOperationRequest {
|
|||
}
|
||||
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
transientSettings = readSettingsFromStream(in);
|
||||
persistentSettings = readSettingsFromStream(in);
|
||||
}
|
||||
|
||||
@Override public void writeTo(StreamOutput out) throws IOException {
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
writeSettingsToStream(transientSettings, out);
|
||||
writeSettingsToStream(persistentSettings, out);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -34,9 +34,11 @@ public class ClusterUpdateSettingsResponse implements ActionResponse, Streamable
|
|||
ClusterUpdateSettingsResponse() {
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
}
|
||||
|
||||
@Override public void writeTo(StreamOutput out) throws IOException {
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* 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
|
||||
|
@ -39,43 +39,50 @@ import java.util.Map;
|
|||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static org.elasticsearch.cluster.ClusterState.*;
|
||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*
|
||||
*/
|
||||
public class TransportClusterUpdateSettingsAction extends TransportMasterNodeOperationAction<ClusterUpdateSettingsRequest, ClusterUpdateSettingsResponse> {
|
||||
|
||||
private final AllocationService allocationService;
|
||||
|
||||
@Inject public TransportClusterUpdateSettingsAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
|
||||
AllocationService allocationService) {
|
||||
@Inject
|
||||
public TransportClusterUpdateSettingsAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
|
||||
AllocationService allocationService) {
|
||||
super(settings, transportService, clusterService, threadPool);
|
||||
this.allocationService = allocationService;
|
||||
}
|
||||
|
||||
@Override protected String executor() {
|
||||
@Override
|
||||
protected String executor() {
|
||||
return ThreadPool.Names.MANAGEMENT;
|
||||
}
|
||||
|
||||
@Override protected String transportAction() {
|
||||
@Override
|
||||
protected String transportAction() {
|
||||
return TransportActions.Admin.Cluster.UPDATE_SETTINGS;
|
||||
}
|
||||
|
||||
@Override protected ClusterUpdateSettingsRequest newRequest() {
|
||||
@Override
|
||||
protected ClusterUpdateSettingsRequest newRequest() {
|
||||
return new ClusterUpdateSettingsRequest();
|
||||
}
|
||||
|
||||
@Override protected ClusterUpdateSettingsResponse newResponse() {
|
||||
@Override
|
||||
protected ClusterUpdateSettingsResponse newResponse() {
|
||||
return new ClusterUpdateSettingsResponse();
|
||||
}
|
||||
|
||||
@Override protected ClusterUpdateSettingsResponse masterOperation(final ClusterUpdateSettingsRequest request, ClusterState state) throws ElasticSearchException {
|
||||
@Override
|
||||
protected ClusterUpdateSettingsResponse masterOperation(final ClusterUpdateSettingsRequest request, ClusterState state) throws ElasticSearchException {
|
||||
final AtomicReference<Throwable> failureRef = new AtomicReference<Throwable>();
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
|
||||
clusterService.submitStateUpdateTask("cluster_update_settings", new ProcessedClusterStateUpdateTask() {
|
||||
@Override public ClusterState execute(ClusterState currentState) {
|
||||
@Override
|
||||
public ClusterState execute(ClusterState currentState) {
|
||||
try {
|
||||
boolean changed = false;
|
||||
ImmutableSettings.Builder transientSettings = ImmutableSettings.settingsBuilder();
|
||||
|
@ -119,10 +126,12 @@ public class TransportClusterUpdateSettingsAction extends TransportMasterNodeOpe
|
|||
}
|
||||
}
|
||||
|
||||
@Override public void clusterStateProcessed(ClusterState clusterState) {
|
||||
@Override
|
||||
public void clusterStateProcessed(ClusterState clusterState) {
|
||||
// now, reroute
|
||||
clusterService.submitStateUpdateTask("reroute_after_cluster_update_settings", new ClusterStateUpdateTask() {
|
||||
@Override public ClusterState execute(ClusterState currentState) {
|
||||
@Override
|
||||
public ClusterState execute(ClusterState currentState) {
|
||||
try {
|
||||
// now, reroute in case things change that require it (like number of replicas)
|
||||
RoutingAllocation.Result routingResult = allocationService.reroute(currentState);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue