diff --git a/pom.xml b/pom.xml index 03baf557f51..d75a985fe49 100644 --- a/pom.xml +++ b/pom.xml @@ -34,6 +34,11 @@ + + elasticsearch + elasticsearch repo + http://elasticsearch.googlecode.com/svn/maven + @@ -69,6 +74,93 @@ compile + + + com.googlecode.concurrentlinkedhashmap + concurrentlinkedhashmap-lru + 1.2 + provided + + + + com.google.guava + guava + r09 + provided + + + + org.elasticsearch + es-trove + 3.0.0 + provided + + + + org.elasticsearch + es-jsr166y + 20110918 + provided + + + + org.elasticsearch + es-jsr166e + 20110918 + provided + + + + commons-codec + commons-codec + 1.5 + provided + + + + joda-time + joda-time + + 1.6.2 + provided + + + + org.mvel + mvel2 + 2.1.Beta7 + provided + + + + org.codehaus.jackson + jackson-core-asl + 1.9.2 + provided + + + + org.codehaus.jackson + jackson-smile + 1.9.2 + provided + + + + org.yaml + snakeyaml + 1.6 + provided + + + + org.jboss.netty + netty + 3.2.7.Final + provided + + + log4j log4j @@ -76,6 +168,42 @@ provided + + org.slf4j + slf4j-api + 1.6.2 + provided + + + + org.slf4j + slf4j-log4j12 + 1.6.2 + provided + + + + net.java.dev.jna + jna + 3.3.0 + provided + + + + jline + jline + 1.0 + provided + + + + sigar + sigar + 1.6.4 + system + ${basedir}/lib/sigar/sigar-1.6.4.jar + + org.testng testng @@ -99,6 +227,40 @@ + + + + ${basedir}/src/main/java + + **/*.json + **/*.yml + + + + ${basedir}/src/main/resources + + **/*.* + + + + + + + ${basedir}/src/test/java + + **/*.json + **/*.yml + **/*.txt + + + + ${basedir}/src/test/resources + + **/*.* + + + + org.apache.maven.plugins diff --git a/src/main/java/org/apache/lucene/analysis/miscellaneous/TruncateTokenFilter.java b/src/main/java/org/apache/lucene/analysis/miscellaneous/TruncateTokenFilter.java index e6a3e350c7e..4d946606201 100644 --- a/src/main/java/org/apache/lucene/analysis/miscellaneous/TruncateTokenFilter.java +++ b/src/main/java/org/apache/lucene/analysis/miscellaneous/TruncateTokenFilter.java @@ -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) { diff --git a/src/main/java/org/apache/lucene/analysis/miscellaneous/UniqueTokenFilter.java b/src/main/java/org/apache/lucene/analysis/miscellaneous/UniqueTokenFilter.java index bdbbe8c27f5..020c26b0d2f 100644 --- a/src/main/java/org/apache/lucene/analysis/miscellaneous/UniqueTokenFilter.java +++ b/src/main/java/org/apache/lucene/analysis/miscellaneous/UniqueTokenFilter.java @@ -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(); } diff --git a/src/main/java/org/apache/lucene/analysis/miscellaneous/WordDelimiterFilter.java b/src/main/java/org/apache/lucene/analysis/miscellaneous/WordDelimiterFilter.java index ef0e143479a..e5d05e99482 100644 --- a/src/main/java/org/apache/lucene/analysis/miscellaneous/WordDelimiterFilter.java +++ b/src/main/java/org/apache/lucene/analysis/miscellaneous/WordDelimiterFilter.java @@ -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. - * + *

* The combinations 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" - * + *

* 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) diff --git a/src/main/java/org/apache/lucene/analysis/miscellaneous/WordDelimiterIterator.java b/src/main/java/org/apache/lucene/analysis/miscellaneous/WordDelimiterIterator.java index 943ccfb6097..867422c920e 100644 --- a/src/main/java/org/apache/lucene/analysis/miscellaneous/WordDelimiterIterator.java +++ b/src/main/java/org/apache/lucene/analysis/miscellaneous/WordDelimiterIterator.java @@ -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 diff --git a/src/main/java/org/apache/lucene/analysis/pattern/PatternReplaceFilter.java b/src/main/java/org/apache/lucene/analysis/pattern/PatternReplaceFilter.java index 9ddc816e6b7..ef7565215b1 100644 --- a/src/main/java/org/apache/lucene/analysis/pattern/PatternReplaceFilter.java +++ b/src/main/java/org/apache/lucene/analysis/pattern/PatternReplaceFilter.java @@ -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. - * + *

*

* Note: Depending on the input and the pattern used and the input * TokenStream, this TokenFilter may produce Tokens whose text is the empty * string. *

- * + * * @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; + } } diff --git a/src/main/java/org/apache/lucene/analysis/pattern/PatternTokenizer.java b/src/main/java/org/apache/lucene/analysis/pattern/PatternTokenizer.java index 7a6397a5170..09d32506976 100644 --- a/src/main/java/org/apache/lucene/analysis/pattern/PatternTokenizer.java +++ b/src/main/java/org/apache/lucene/analysis/pattern/PatternTokenizer.java @@ -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 diff --git a/src/main/java/org/apache/lucene/index/ExtendedIndexSearcher.java b/src/main/java/org/apache/lucene/index/ExtendedIndexSearcher.java index 00f4c1a3737..adb84ebd02d 100644 --- a/src/main/java/org/apache/lucene/index/ExtendedIndexSearcher.java +++ b/src/main/java/org/apache/lucene/index/ExtendedIndexSearcher.java @@ -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 { diff --git a/src/main/java/org/apache/lucene/index/TrackingConcurrentMergeScheduler.java b/src/main/java/org/apache/lucene/index/TrackingConcurrentMergeScheduler.java index 51f3ae43149..cd0799a9798 100644 --- a/src/main/java/org/apache/lucene/index/TrackingConcurrentMergeScheduler.java +++ b/src/main/java/org/apache/lucene/index/TrackingConcurrentMergeScheduler.java @@ -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(); diff --git a/src/main/java/org/apache/lucene/index/TrackingSerialMergeScheduler.java b/src/main/java/org/apache/lucene/index/TrackingSerialMergeScheduler.java index 84a8b0a6b96..b1a34c954f3 100644 --- a/src/main/java/org/apache/lucene/index/TrackingSerialMergeScheduler.java +++ b/src/main/java/org/apache/lucene/index/TrackingSerialMergeScheduler.java @@ -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 diff --git a/src/main/java/org/apache/lucene/index/memory/CustomMemoryIndex.java b/src/main/java/org/apache/lucene/index/memory/CustomMemoryIndex.java index 9a68836010b..3954d5d0758 100644 --- a/src/main/java/org/apache/lucene/index/memory/CustomMemoryIndex.java +++ b/src/main/java/org/apache/lucene/index/memory/CustomMemoryIndex.java @@ -54,9 +54,9 @@ import java.util.*; /** * High-performance single-document main memory Apache Lucene fulltext search index. - * + *

*

Overview

- * + *

* 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.*; *

  * float score = search(String text, Query query)
  * 
- *

+ *

* 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 * Lucene Analyzer Intro. - *

+ *

* Arbitrary Lucene queries can be run against this class - see Lucene Query Syntax * as well as + *

* For some interesting background information on search technology, see Bob Wyman's * Prospective Search, @@ -99,10 +99,10 @@ import java.util.*; * A Call to Arms - Custom subscriptions, and Tim Bray's * On Search, the Series. - * - * + *

+ *

*

Example Usage

- * + *

*

  * Analyzer analyzer = PatternAnalyzer.DEFAULT_ANALYZER;
  * //Analyzer analyzer = new SimpleAnalyzer();
@@ -118,10 +118,10 @@ import java.util.*;
  * }
  * System.out.println("indexData=" + index.toString());
  * 
- * - * + *

+ *

*

Example XQuery Usage

- * + *

*

  * (: 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
  * 
- * - * + *

+ *

*

No thread safety guarantees

- * + *

* 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: *

@@ -144,14 +144,14 @@ import java.util.*;
  *    // read and/or write index (i.e. add fields and/or query)
  * }
  * 
- * - * + *

+ *

*

Performance Notes

- * + *

* 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. - *

+ *

* 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 RAMDirectory. @@ -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 RAMDirectory. - *

+ *

* 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. - *

+ *

* 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; diff --git a/src/main/java/org/apache/lucene/queryParser/ExistsFieldQueryExtension.java b/src/main/java/org/apache/lucene/queryParser/ExistsFieldQueryExtension.java index d05b3bc5ee4..25b1b4d5195 100644 --- a/src/main/java/org/apache/lucene/queryParser/ExistsFieldQueryExtension.java +++ b/src/main/java/org/apache/lucene/queryParser/ExistsFieldQueryExtension.java @@ -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); diff --git a/src/main/java/org/apache/lucene/queryParser/FieldQueryExtension.java b/src/main/java/org/apache/lucene/queryParser/FieldQueryExtension.java index 719709d21a9..b34e55b1d21 100644 --- a/src/main/java/org/apache/lucene/queryParser/FieldQueryExtension.java +++ b/src/main/java/org/apache/lucene/queryParser/FieldQueryExtension.java @@ -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 { diff --git a/src/main/java/org/apache/lucene/queryParser/MapperQueryParser.java b/src/main/java/org/apache/lucene/queryParser/MapperQueryParser.java index 61424dfddf4..3bed69cf610 100644 --- a/src/main/java/org/apache/lucene/queryParser/MapperQueryParser.java +++ b/src/main/java/org/apache/lucene/queryParser/MapperQueryParser.java @@ -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. - * + *

*

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 clauses, boolean disableCoord) throws ParseException { + @Override + protected Query getBooleanQuery(List clauses, boolean disableCoord) throws ParseException { Query q = super.getBooleanQuery(clauses, disableCoord); if (q == null) { return null; diff --git a/src/main/java/org/apache/lucene/queryParser/MissingFieldQueryExtension.java b/src/main/java/org/apache/lucene/queryParser/MissingFieldQueryExtension.java index d1650e98b1a..2ebf8065842 100644 --- a/src/main/java/org/apache/lucene/queryParser/MissingFieldQueryExtension.java +++ b/src/main/java/org/apache/lucene/queryParser/MissingFieldQueryExtension.java @@ -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; diff --git a/src/main/java/org/apache/lucene/queryParser/MultiFieldMapperQueryParser.java b/src/main/java/org/apache/lucene/queryParser/MultiFieldMapperQueryParser.java index c4db1d17560..691a88ff6f7 100644 --- a/src/main/java/org/apache/lucene/queryParser/MultiFieldMapperQueryParser.java +++ b/src/main/java/org/apache/lucene/queryParser/MultiFieldMapperQueryParser.java @@ -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); } diff --git a/src/main/java/org/apache/lucene/queryParser/MultiFieldQueryParserSettings.java b/src/main/java/org/apache/lucene/queryParser/MultiFieldQueryParserSettings.java index 24d93d3a600..58517b2f74f 100644 --- a/src/main/java/org/apache/lucene/queryParser/MultiFieldQueryParserSettings.java +++ b/src/main/java/org/apache/lucene/queryParser/MultiFieldQueryParserSettings.java @@ -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); diff --git a/src/main/java/org/apache/lucene/queryParser/QueryParserSettings.java b/src/main/java/org/apache/lucene/queryParser/QueryParserSettings.java index 89628255341..825cc0fc4bb 100644 --- a/src/main/java/org/apache/lucene/queryParser/QueryParserSettings.java +++ b/src/main/java/org/apache/lucene/queryParser/QueryParserSettings.java @@ -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); diff --git a/src/main/java/org/apache/lucene/search/DeletionAwareConstantScoreQuery.java b/src/main/java/org/apache/lucene/search/DeletionAwareConstantScoreQuery.java index b8c1f130619..3142f047345 100644 --- a/src/main/java/org/apache/lucene/search/DeletionAwareConstantScoreQuery.java +++ b/src/main/java/org/apache/lucene/search/DeletionAwareConstantScoreQuery.java @@ -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; diff --git a/src/main/java/org/apache/lucene/search/PublicTermsFilter.java b/src/main/java/org/apache/lucene/search/PublicTermsFilter.java index fcc7b6138cc..4cf98881b94 100644 --- a/src/main/java/org/apache/lucene/search/PublicTermsFilter.java +++ b/src/main/java/org/apache/lucene/search/PublicTermsFilter.java @@ -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 { diff --git a/src/main/java/org/apache/lucene/search/ShardFieldDocSortedHitQueue.java b/src/main/java/org/apache/lucene/search/ShardFieldDocSortedHitQueue.java index 1eaac6a6a9b..1aa325f20bb 100644 --- a/src/main/java/org/apache/lucene/search/ShardFieldDocSortedHitQueue.java +++ b/src/main/java/org/apache/lucene/search/ShardFieldDocSortedHitQueue.java @@ -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 { @@ -110,7 +110,8 @@ public class ShardFieldDocSortedHitQueue extends PriorityQueue { * @param b ScoreDoc * @return true if document a should be sorted after document b. */ - @SuppressWarnings("unchecked") @Override + @SuppressWarnings("unchecked") + @Override protected final boolean lessThan(final ShardFieldDoc docA, final ShardFieldDoc docB) { final int n = fields.length; int c = 0; diff --git a/src/main/java/org/apache/lucene/search/vectorhighlight/CustomFieldQuery.java b/src/main/java/org/apache/lucene/search/vectorhighlight/CustomFieldQuery.java index 35be0aace07..79c44f73fbf 100644 --- a/src/main/java/org/apache/lucene/search/vectorhighlight/CustomFieldQuery.java +++ b/src/main/java/org/apache/lucene/search/vectorhighlight/CustomFieldQuery.java @@ -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 flatQueries) throws IOException { + @Override + void flatten(Query sourceQuery, IndexReader reader, Collection flatQueries) throws IOException { if (sourceQuery instanceof DisjunctionMaxQuery) { DisjunctionMaxQuery dmq = (DisjunctionMaxQuery) sourceQuery; for (Query query : dmq) { diff --git a/src/main/java/org/apache/lucene/store/bytebuffer/ByteBufferAllocator.java b/src/main/java/org/apache/lucene/store/bytebuffer/ByteBufferAllocator.java index fe4c053c306..6c78edaf65d 100644 --- a/src/main/java/org/apache/lucene/store/bytebuffer/ByteBufferAllocator.java +++ b/src/main/java/org/apache/lucene/store/bytebuffer/ByteBufferAllocator.java @@ -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. - * + *

*

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. diff --git a/src/main/java/org/apache/lucene/store/bytebuffer/ByteBufferDirectory.java b/src/main/java/org/apache/lucene/store/bytebuffer/ByteBufferDirectory.java index 836033841f1..362e8e8fd59 100644 --- a/src/main/java/org/apache/lucene/store/bytebuffer/ByteBufferDirectory.java +++ b/src/main/java/org/apache/lucene/store/bytebuffer/ByteBufferDirectory.java @@ -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. - * + *

*

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. - * + *

*

Each "file" is segmented into one or more byte buffers. - * + *

*

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 { diff --git a/src/main/java/org/apache/lucene/store/bytebuffer/ByteBufferFile.java b/src/main/java/org/apache/lucene/store/bytebuffer/ByteBufferFile.java index f85e1fbb082..215a403617b 100644 --- a/src/main/java/org/apache/lucene/store/bytebuffer/ByteBufferFile.java +++ b/src/main/java/org/apache/lucene/store/bytebuffer/ByteBufferFile.java @@ -23,7 +23,7 @@ import java.nio.ByteBuffer; import java.util.concurrent.CopyOnWriteArrayList; /** - * @author kimchy (shay.banon) + * */ public class ByteBufferFile { diff --git a/src/main/java/org/apache/lucene/store/bytebuffer/ByteBufferIndexInput.java b/src/main/java/org/apache/lucene/store/bytebuffer/ByteBufferIndexInput.java index fe7f0252f41..520650d54e0 100644 --- a/src/main/java/org/apache/lucene/store/bytebuffer/ByteBufferIndexInput.java +++ b/src/main/java/org/apache/lucene/store/bytebuffer/ByteBufferIndexInput.java @@ -23,7 +23,7 @@ import java.io.IOException; import java.nio.ByteBuffer; /** - * @author kimchy (shay.banon) + * */ public class ByteBufferIndexInput extends IndexInput { diff --git a/src/main/java/org/elasticsearch/ElasticSearchException.java b/src/main/java/org/elasticsearch/ElasticSearchException.java index 189b789d67a..608801815af 100644 --- a/src/main/java/org/elasticsearch/ElasticSearchException.java +++ b/src/main/java/org/elasticsearch/ElasticSearchException.java @@ -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 { diff --git a/src/main/java/org/elasticsearch/ElasticSearchGenerationException.java b/src/main/java/org/elasticsearch/ElasticSearchGenerationException.java index 24feddb5064..561c288a429 100644 --- a/src/main/java/org/elasticsearch/ElasticSearchGenerationException.java +++ b/src/main/java/org/elasticsearch/ElasticSearchGenerationException.java @@ -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 { diff --git a/src/main/java/org/elasticsearch/ElasticSearchIllegalArgumentException.java b/src/main/java/org/elasticsearch/ElasticSearchIllegalArgumentException.java index 48ab291de8d..678b50f5b6e 100644 --- a/src/main/java/org/elasticsearch/ElasticSearchIllegalArgumentException.java +++ b/src/main/java/org/elasticsearch/ElasticSearchIllegalArgumentException.java @@ -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; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/ElasticSearchIllegalStateException.java b/src/main/java/org/elasticsearch/ElasticSearchIllegalStateException.java index 356c02fc7ae..27ec38afdc0 100644 --- a/src/main/java/org/elasticsearch/ElasticSearchIllegalStateException.java +++ b/src/main/java/org/elasticsearch/ElasticSearchIllegalStateException.java @@ -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 { diff --git a/src/main/java/org/elasticsearch/ElasticSearchInterruptedException.java b/src/main/java/org/elasticsearch/ElasticSearchInterruptedException.java index 87657c48eb8..4dea314467d 100644 --- a/src/main/java/org/elasticsearch/ElasticSearchInterruptedException.java +++ b/src/main/java/org/elasticsearch/ElasticSearchInterruptedException.java @@ -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 { diff --git a/src/main/java/org/elasticsearch/ElasticSearchNullPointerException.java b/src/main/java/org/elasticsearch/ElasticSearchNullPointerException.java index 55859d71269..567b5fffad6 100644 --- a/src/main/java/org/elasticsearch/ElasticSearchNullPointerException.java +++ b/src/main/java/org/elasticsearch/ElasticSearchNullPointerException.java @@ -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 { diff --git a/src/main/java/org/elasticsearch/ElasticSearchParseException.java b/src/main/java/org/elasticsearch/ElasticSearchParseException.java index 9129252f8fe..92ecf0162ea 100644 --- a/src/main/java/org/elasticsearch/ElasticSearchParseException.java +++ b/src/main/java/org/elasticsearch/ElasticSearchParseException.java @@ -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 { diff --git a/src/main/java/org/elasticsearch/ElasticSearchTimeoutException.java b/src/main/java/org/elasticsearch/ElasticSearchTimeoutException.java index 6caccaaa292..9e5e33b38e8 100644 --- a/src/main/java/org/elasticsearch/ElasticSearchTimeoutException.java +++ b/src/main/java/org/elasticsearch/ElasticSearchTimeoutException.java @@ -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 { diff --git a/src/main/java/org/elasticsearch/ElasticSearchWrapperException.java b/src/main/java/org/elasticsearch/ElasticSearchWrapperException.java index 28694071f1a..483983dd916 100644 --- a/src/main/java/org/elasticsearch/ElasticSearchWrapperException.java +++ b/src/main/java/org/elasticsearch/ElasticSearchWrapperException.java @@ -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 { diff --git a/src/main/java/org/elasticsearch/ExceptionsHelper.java b/src/main/java/org/elasticsearch/ExceptionsHelper.java index 88204fb3f90..fa2cdc13be2 100644 --- a/src/main/java/org/elasticsearch/ExceptionsHelper.java +++ b/src/main/java/org/elasticsearch/ExceptionsHelper.java @@ -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 { diff --git a/src/main/java/org/elasticsearch/Version.java b/src/main/java/org/elasticsearch/Version.java index 05a4a3ef61c..4df0bded3f6 100644 --- a/src/main/java/org/elasticsearch/Version.java +++ b/src/main/java/org/elasticsearch/Version.java @@ -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()) { diff --git a/src/main/java/org/elasticsearch/action/Action.java b/src/main/java/org/elasticsearch/action/Action.java index ac72b813c78..bc3ca22cfbb 100644 --- a/src/main/java/org/elasticsearch/action/Action.java +++ b/src/main/java/org/elasticsearch/action/Action.java @@ -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 { diff --git a/src/main/java/org/elasticsearch/action/ActionFuture.java b/src/main/java/org/elasticsearch/action/ActionFuture.java index fc38fec353d..819714ef883 100644 --- a/src/main/java/org/elasticsearch/action/ActionFuture.java +++ b/src/main/java/org/elasticsearch/action/ActionFuture.java @@ -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 extends Future { @@ -37,7 +37,7 @@ public interface ActionFuture extends Future { * 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}. - * + *

*

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 extends Future { * 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}. - * + *

*

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 extends Future { * 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}. - * + *

*

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 extends Future { * 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}. - * + *

*

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 extends Future { * 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}. - * + *

*

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 extends Future { /** * The root (possibly) wrapped failure. */ - @Nullable Throwable getRootFailure(); + @Nullable + Throwable getRootFailure(); } diff --git a/src/main/java/org/elasticsearch/action/ActionListener.java b/src/main/java/org/elasticsearch/action/ActionListener.java index b594480c590..44c4967c19b 100644 --- a/src/main/java/org/elasticsearch/action/ActionListener.java +++ b/src/main/java/org/elasticsearch/action/ActionListener.java @@ -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 { diff --git a/src/main/java/org/elasticsearch/action/ActionRequest.java b/src/main/java/org/elasticsearch/action/ActionRequest.java index 3011d62f576..40d6584a275 100644 --- a/src/main/java/org/elasticsearch/action/ActionRequest.java +++ b/src/main/java/org/elasticsearch/action/ActionRequest.java @@ -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. - * + *

*

When not executing on a thread, it will either be executed on the calling thread, or * on an expensive, IO based, thread. */ diff --git a/src/main/java/org/elasticsearch/action/ActionRequestValidationException.java b/src/main/java/org/elasticsearch/action/ActionRequestValidationException.java index 79d4c45ee6b..900db4824b5 100644 --- a/src/main/java/org/elasticsearch/action/ActionRequestValidationException.java +++ b/src/main/java/org/elasticsearch/action/ActionRequestValidationException.java @@ -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; diff --git a/src/main/java/org/elasticsearch/action/ActionResponse.java b/src/main/java/org/elasticsearch/action/ActionResponse.java index 3ecda5471f2..88cf95d66b2 100644 --- a/src/main/java/org/elasticsearch/action/ActionResponse.java +++ b/src/main/java/org/elasticsearch/action/ActionResponse.java @@ -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 { } diff --git a/src/main/java/org/elasticsearch/action/Actions.java b/src/main/java/org/elasticsearch/action/Actions.java index 226e8dfa382..4aaa912eb80 100644 --- a/src/main/java/org/elasticsearch/action/Actions.java +++ b/src/main/java/org/elasticsearch/action/Actions.java @@ -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 { diff --git a/src/main/java/org/elasticsearch/action/FailedNodeException.java b/src/main/java/org/elasticsearch/action/FailedNodeException.java index 622182b2d19..fc7f86a5e83 100644 --- a/src/main/java/org/elasticsearch/action/FailedNodeException.java +++ b/src/main/java/org/elasticsearch/action/FailedNodeException.java @@ -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 { diff --git a/src/main/java/org/elasticsearch/action/ListenableActionFuture.java b/src/main/java/org/elasticsearch/action/ListenableActionFuture.java index 9aef24ca6ad..86614716808 100644 --- a/src/main/java/org/elasticsearch/action/ListenableActionFuture.java +++ b/src/main/java/org/elasticsearch/action/ListenableActionFuture.java @@ -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 extends ActionFuture { diff --git a/src/main/java/org/elasticsearch/action/NoShardAvailableActionException.java b/src/main/java/org/elasticsearch/action/NoShardAvailableActionException.java index 19976e4de6a..833e35ee9bd 100644 --- a/src/main/java/org/elasticsearch/action/NoShardAvailableActionException.java +++ b/src/main/java/org/elasticsearch/action/NoShardAvailableActionException.java @@ -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 { diff --git a/src/main/java/org/elasticsearch/action/NoSuchNodeException.java b/src/main/java/org/elasticsearch/action/NoSuchNodeException.java index 414da698b98..8851ca77c9d 100644 --- a/src/main/java/org/elasticsearch/action/NoSuchNodeException.java +++ b/src/main/java/org/elasticsearch/action/NoSuchNodeException.java @@ -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 { diff --git a/src/main/java/org/elasticsearch/action/PrimaryMissingActionException.java b/src/main/java/org/elasticsearch/action/PrimaryMissingActionException.java index 1dd03db884c..3ed6eb35123 100644 --- a/src/main/java/org/elasticsearch/action/PrimaryMissingActionException.java +++ b/src/main/java/org/elasticsearch/action/PrimaryMissingActionException.java @@ -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 { diff --git a/src/main/java/org/elasticsearch/action/RoutingMissingException.java b/src/main/java/org/elasticsearch/action/RoutingMissingException.java index 1e6678dfe2b..117a226da8f 100644 --- a/src/main/java/org/elasticsearch/action/RoutingMissingException.java +++ b/src/main/java/org/elasticsearch/action/RoutingMissingException.java @@ -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 { diff --git a/src/main/java/org/elasticsearch/action/ShardOperationFailedException.java b/src/main/java/org/elasticsearch/action/ShardOperationFailedException.java index 645103f9488..651ea6e638a 100644 --- a/src/main/java/org/elasticsearch/action/ShardOperationFailedException.java +++ b/src/main/java/org/elasticsearch/action/ShardOperationFailedException.java @@ -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 { diff --git a/src/main/java/org/elasticsearch/action/ThreadingModel.java b/src/main/java/org/elasticsearch/action/ThreadingModel.java index a04f2e76239..8a21955340b 100644 --- a/src/main/java/org/elasticsearch/action/ThreadingModel.java +++ b/src/main/java/org/elasticsearch/action/ThreadingModel.java @@ -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), diff --git a/src/main/java/org/elasticsearch/action/TimestampParsingException.java b/src/main/java/org/elasticsearch/action/TimestampParsingException.java index e11c606231c..2332fc5c7df 100644 --- a/src/main/java/org/elasticsearch/action/TimestampParsingException.java +++ b/src/main/java/org/elasticsearch/action/TimestampParsingException.java @@ -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 { diff --git a/src/main/java/org/elasticsearch/action/TransportActionModule.java b/src/main/java/org/elasticsearch/action/TransportActionModule.java index f06bf1a13bf..8b19f9d6fe3 100644 --- a/src/main/java/org/elasticsearch/action/TransportActionModule.java +++ b/src/main/java/org/elasticsearch/action/TransportActionModule.java @@ -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(); diff --git a/src/main/java/org/elasticsearch/action/TransportActions.java b/src/main/java/org/elasticsearch/action/TransportActions.java index 6b77ea74e46..a10a445d76b 100644 --- a/src/main/java/org/elasticsearch/action/TransportActions.java +++ b/src/main/java/org/elasticsearch/action/TransportActions.java @@ -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 { diff --git a/src/main/java/org/elasticsearch/action/UnavailableShardsException.java b/src/main/java/org/elasticsearch/action/UnavailableShardsException.java index b611ffb56ee..0ff6d95c3d3 100644 --- a/src/main/java/org/elasticsearch/action/UnavailableShardsException.java +++ b/src/main/java/org/elasticsearch/action/UnavailableShardsException.java @@ -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 { diff --git a/src/main/java/org/elasticsearch/action/WriteConsistencyLevel.java b/src/main/java/org/elasticsearch/action/WriteConsistencyLevel.java index 63a301ef1eb..644df74e6cf 100644 --- a/src/main/java/org/elasticsearch/action/WriteConsistencyLevel.java +++ b/src/main/java/org/elasticsearch/action/WriteConsistencyLevel.java @@ -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), diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequest.java b/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequest.java index 8dd124ece5b..768ae1f9563 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequest.java @@ -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); diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthResponse.java b/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthResponse.java index 636de3bac20..42426179795 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthResponse.java @@ -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 { @@ -194,11 +194,13 @@ public class ClusterHealthResponse implements ActionResponse, Iterable iterator() { + @Override + public Iterator 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, Streamable { @@ -157,7 +157,8 @@ public class ClusterIndexHealth implements Iterable, Streama return shards(); } - @Override public Iterator iterator() { + @Override + public Iterator iterator() { return shards.values().iterator(); } @@ -167,7 +168,8 @@ public class ClusterIndexHealth implements Iterable, 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, 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); diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterShardHealth.java b/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterShardHealth.java index 371326e0f70..6d65c498985 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterShardHealth.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterShardHealth.java @@ -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); diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/health/TransportClusterHealthAction.java b/src/main/java/org/elasticsearch/action/admin/cluster/health/TransportClusterHealthAction.java index 0748190a169..16abebf050d 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/health/TransportClusterHealthAction.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/health/TransportClusterHealthAction.java @@ -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 { 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--; diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodeInfo.java b/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodeInfo.java index 8fc88e120f2..526675f8cfb 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodeInfo.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodeInfo.java @@ -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 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 entry : attributes.entrySet()) { diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoRequest.java b/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoRequest.java index d41388c6fa8..b49b427069e 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoRequest.java @@ -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 { diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoResponse.java b/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoResponse.java index d58e94217d0..b942104837a 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoResponse.java @@ -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 { @@ -38,7 +38,8 @@ public class NodesInfoResponse extends NodesOperationResponse { 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 { } } - @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) { diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/node/info/TransportNodesInfoAction.java b/src/main/java/org/elasticsearch/action/admin/cluster/node/info/TransportNodesInfoAction.java index 29ea65e6a3d..83a0753cc24 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/node/info/TransportNodesInfoAction.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/node/info/TransportNodesInfoAction.java @@ -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 { 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 nodesInfos = new ArrayList(); for (int i = 0; i < responses.length(); i++) { Object resp = responses.get(i); @@ -72,27 +77,33 @@ public class TransportNodesInfoAction extends TransportNodesOperationAction { @@ -40,7 +40,8 @@ public class NodesRestartResponse extends NodesOperationResponse { @@ -55,31 +55,37 @@ public class TransportNodesRestartAction extends TransportNodesOperationAction listener) { + @Override + protected void doExecute(NodesRestartRequest nodesRestartRequest, ActionListener 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 nodeRestartResponses = newArrayList(); for (int i = 0; i < responses.length(); i++) { Object resp = responses.get(i); @@ -90,23 +96,28 @@ public class TransportNodesRestartAction extends TransportNodesOperationAction { @@ -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); } } diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStats.java b/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStats.java index 1f296aa3b7b..f7158fc668c 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStats.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStats.java @@ -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); diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodesStatsRequest.java b/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodesStatsRequest.java index 6f86f930279..42fbf59fc8c 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodesStatsRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodesStatsRequest.java @@ -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 { diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodesStatsResponse.java b/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodesStatsResponse.java index 430a140c768..39d451b21b3 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodesStatsResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodesStatsResponse.java @@ -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 { @@ -38,7 +38,8 @@ public class NodesStatsResponse extends NodesOperationResponse { 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 { } } - @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) { diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/TransportNodesStatsAction.java b/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/TransportNodesStatsAction.java index cd985dddcc5..c60827f9f10 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/TransportNodesStatsAction.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/TransportNodesStatsAction.java @@ -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 { 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 = Lists.newArrayList(); for (int i = 0; i < responses.length(); i++) { Object resp = responses.get(i); @@ -72,27 +77,33 @@ public class TransportNodesStatsAction extends TransportNodesOperationAction { - @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 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(); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/IndexReplicationPingRequest.java b/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/IndexReplicationPingRequest.java index 2c8ee02a1a0..d912f837fa2 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/IndexReplicationPingRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/IndexReplicationPingRequest.java @@ -28,7 +28,7 @@ import org.elasticsearch.common.unit.TimeValue; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class IndexReplicationPingRequest extends IndexReplicationOperationRequest { diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/IndexReplicationPingResponse.java b/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/IndexReplicationPingResponse.java index 05af8124c7d..4f4ce5b3554 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/IndexReplicationPingResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/IndexReplicationPingResponse.java @@ -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); diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/ReplicationPingRequest.java b/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/ReplicationPingRequest.java index e572a951de0..0de2c47179d 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/ReplicationPingRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/ReplicationPingRequest.java @@ -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; } diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/ReplicationPingResponse.java b/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/ReplicationPingResponse.java index 60812d85bc5..9535c9248fb 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/ReplicationPingResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/ReplicationPingResponse.java @@ -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); diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/ShardReplicationPingRequest.java b/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/ShardReplicationPingRequest.java index aa9454d935d..498b0f43d41 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/ShardReplicationPingRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/ShardReplicationPingRequest.java @@ -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 + "]}"; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/ShardReplicationPingResponse.java b/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/ShardReplicationPingResponse.java index 3829f06f990..048f42e50fc 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/ShardReplicationPingResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/ShardReplicationPingResponse.java @@ -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 { } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/TransportIndexReplicationPingAction.java b/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/TransportIndexReplicationPingAction.java index 1d04b5d10c2..65d0c903f53 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/TransportIndexReplicationPingAction.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/TransportIndexReplicationPingAction.java @@ -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 { - @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); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/TransportReplicationPingAction.java b/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/TransportReplicationPingAction.java index 3c65046ca67..a29eb9c7621 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/TransportReplicationPingAction.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/TransportReplicationPingAction.java @@ -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 { - @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 routing) { + @Override + protected IndexReplicationPingRequest newIndexRequestInstance(ReplicationPingRequest request, String index, Set routing) { return new IndexReplicationPingRequest(request, index); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/TransportShardReplicationPingAction.java b/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/TransportShardReplicationPingAction.java index 4ed03482d41..b992491c60c 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/TransportShardReplicationPingAction.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/ping/replication/TransportShardReplicationPingAction.java @@ -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 { - @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 shardOperationOnPrimary(ClusterState clusterState, PrimaryOperationRequest shardRequest) { + @Override + protected PrimaryResponse shardOperationOnPrimary(ClusterState clusterState, PrimaryOperationRequest shardRequest) { return new PrimaryResponse(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(); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/ping/single/SinglePingRequest.java b/src/main/java/org/elasticsearch/action/admin/cluster/ping/single/SinglePingRequest.java index 5cda2aae92c..fbf5675ad05 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/ping/single/SinglePingRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/ping/single/SinglePingRequest.java @@ -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); diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/ping/single/SinglePingResponse.java b/src/main/java/org/elasticsearch/action/admin/cluster/ping/single/SinglePingResponse.java index 798b5051c3f..ecc6d6c4a26 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/ping/single/SinglePingResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/ping/single/SinglePingResponse.java @@ -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 { } } diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/ping/single/TransportSinglePingAction.java b/src/main/java/org/elasticsearch/action/admin/cluster/ping/single/TransportSinglePingAction.java index 00d5f5085e9..2503f9b14b4 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/ping/single/TransportSinglePingAction.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/ping/single/TransportSinglePingAction.java @@ -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 { - @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(); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteRequest.java b/src/main/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteRequest.java index 3afd9b50f97..d204a25194e 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteRequest.java @@ -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); } } diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteResponse.java b/src/main/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteResponse.java index 87016b7083a..133fd82ca92 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteResponse.java @@ -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 { } } diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/reroute/TransportClusterRerouteAction.java b/src/main/java/org/elasticsearch/action/admin/cluster/reroute/TransportClusterRerouteAction.java index c872294bd70..61ecfd38129 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/reroute/TransportClusterRerouteAction.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/reroute/TransportClusterRerouteAction.java @@ -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 failureRef = new AtomicReference(); 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(); } }); diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/settings/ClusterUpdateSettingsRequest.java b/src/main/java/org/elasticsearch/action/admin/cluster/settings/ClusterUpdateSettingsRequest.java index 0ce4b2253f5..79e6dc33575 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/settings/ClusterUpdateSettingsRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/settings/ClusterUpdateSettingsRequest.java @@ -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); diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/settings/ClusterUpdateSettingsResponse.java b/src/main/java/org/elasticsearch/action/admin/cluster/settings/ClusterUpdateSettingsResponse.java index 44b527e8a25..709693a9249 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/settings/ClusterUpdateSettingsResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/settings/ClusterUpdateSettingsResponse.java @@ -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 { } } diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/settings/TransportClusterUpdateSettingsAction.java b/src/main/java/org/elasticsearch/action/admin/cluster/settings/TransportClusterUpdateSettingsAction.java index 7a4800cdaa0..7531a1b22a5 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/settings/TransportClusterUpdateSettingsAction.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/settings/TransportClusterUpdateSettingsAction.java @@ -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 { 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 failureRef = new AtomicReference(); 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); diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/state/ClusterStateRequest.java b/src/main/java/org/elasticsearch/action/admin/cluster/state/ClusterStateRequest.java index 081367d8888..a9a94302413 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/state/ClusterStateRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/state/ClusterStateRequest.java @@ -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 ClusterStateRequest extends MasterNodeOperationRequest { @@ -49,7 +49,8 @@ public class ClusterStateRequest extends MasterNodeOperationRequest { public ClusterStateRequest() { } - @Override public ActionRequestValidationException validate() { + @Override + public ActionRequestValidationException validate() { return null; } @@ -116,7 +117,8 @@ public class ClusterStateRequest extends MasterNodeOperationRequest { return this.local; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); filterRoutingTable = in.readBoolean(); filterNodes = in.readBoolean(); @@ -139,7 +141,8 @@ public class ClusterStateRequest extends MasterNodeOperationRequest { local = in.readBoolean(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeBoolean(filterRoutingTable); out.writeBoolean(filterNodes); diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/state/ClusterStateResponse.java b/src/main/java/org/elasticsearch/action/admin/cluster/state/ClusterStateResponse.java index 524e4fd3ee8..7bb0a1551ae 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/state/ClusterStateResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/state/ClusterStateResponse.java @@ -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 ClusterStateResponse implements ActionResponse { @@ -60,12 +60,14 @@ public class ClusterStateResponse implements ActionResponse { return clusterName(); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { clusterName = ClusterName.readClusterName(in); clusterState = ClusterState.Builder.readFrom(in, null); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { clusterName.writeTo(out); ClusterState.Builder.writeTo(clusterState, out); } diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/state/TransportClusterStateAction.java b/src/main/java/org/elasticsearch/action/admin/cluster/state/TransportClusterStateAction.java index 3ae027125b7..dcdfdc519db 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/state/TransportClusterStateAction.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/state/TransportClusterStateAction.java @@ -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,43 +33,50 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; -import static org.elasticsearch.cluster.ClusterState.*; -import static org.elasticsearch.cluster.metadata.MetaData.*; +import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; +import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; /** - * @author kimchy (shay.banon) + * */ public class TransportClusterStateAction extends TransportMasterNodeOperationAction { private final ClusterName clusterName; - @Inject public TransportClusterStateAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, - ClusterName clusterName) { + @Inject + public TransportClusterStateAction(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.STATE; } - @Override protected ClusterStateRequest newRequest() { + @Override + protected ClusterStateRequest newRequest() { return new ClusterStateRequest(); } - @Override protected ClusterStateResponse newResponse() { + @Override + protected ClusterStateResponse newResponse() { return new ClusterStateResponse(); } - @Override protected boolean localExecute(ClusterStateRequest request) { + @Override + protected boolean localExecute(ClusterStateRequest request) { return request.local(); } - @Override protected ClusterStateResponse masterOperation(ClusterStateRequest request, ClusterState state) throws ElasticSearchException { + @Override + protected ClusterStateResponse masterOperation(ClusterStateRequest request, ClusterState state) throws ElasticSearchException { ClusterState currentState = clusterService.state(); ClusterState.Builder builder = newClusterStateBuilder(); if (!request.filterNodes()) { diff --git a/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesRequest.java index bbb568e67e0..ff2da4df521 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesRequest.java @@ -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,11 +19,11 @@ package org.elasticsearch.action.admin.indices.alias; +import com.google.common.collect.Lists; import org.elasticsearch.ElasticSearchGenerationException; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.support.master.MasterNodeOperationRequest; import org.elasticsearch.cluster.metadata.AliasAction; -import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.unit.TimeValue; @@ -37,14 +37,14 @@ import java.io.IOException; import java.util.List; import java.util.Map; -import static org.elasticsearch.action.Actions.*; -import static org.elasticsearch.cluster.metadata.AliasAction.*; +import static org.elasticsearch.action.Actions.addValidationError; +import static org.elasticsearch.cluster.metadata.AliasAction.readAliasAction; import static org.elasticsearch.common.unit.TimeValue.readTimeValue; /** * A request to add/remove aliases for one or more indices. * - * @author kimchy (shay.banon) + * */ public class IndicesAliasesRequest extends MasterNodeOperationRequest { @@ -168,7 +168,8 @@ public class IndicesAliasesRequest extends MasterNodeOperationRequest { return timeout(TimeValue.parseTimeValue(timeout, TimeValue.timeValueSeconds(10))); } - @Override public ActionRequestValidationException validate() { + @Override + public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if (aliasActions.isEmpty()) { validationException = addValidationError("Must specify at least one alias action", validationException); @@ -176,7 +177,8 @@ public class IndicesAliasesRequest extends MasterNodeOperationRequest { return validationException; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); int size = in.readVInt(); for (int i = 0; i < size; i++) { @@ -185,7 +187,8 @@ public class IndicesAliasesRequest extends MasterNodeOperationRequest { timeout = readTimeValue(in); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeVInt(aliasActions.size()); for (AliasAction aliasAction : aliasActions) { diff --git a/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesResponse.java b/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesResponse.java index 52c0dce66d0..f564386dd30 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesResponse.java @@ -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.io.IOException; /** * A response for a add/remove alias action. * - * @author kimchy (shay.banon) + * */ public class IndicesAliasesResponse implements ActionResponse, Streamable { @@ -52,11 +52,13 @@ public class IndicesAliasesResponse implements ActionResponse, Streamable { } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { acknowledged = in.readBoolean(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(acknowledged); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/action/admin/indices/alias/TransportIndicesAliasesAction.java b/src/main/java/org/elasticsearch/action/admin/indices/alias/TransportIndicesAliasesAction.java index 8c426d5d4ac..25cee1ae4d5 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/alias/TransportIndicesAliasesAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/alias/TransportIndicesAliasesAction.java @@ -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.indices.alias; +import com.google.common.collect.Sets; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.action.TransportActions; import org.elasticsearch.action.support.master.TransportMasterNodeOperationAction; @@ -28,7 +29,6 @@ import org.elasticsearch.cluster.block.ClusterBlockException; import org.elasticsearch.cluster.block.ClusterBlockLevel; import org.elasticsearch.cluster.metadata.AliasAction; import org.elasticsearch.cluster.metadata.MetaDataIndexAliasesService; -import org.elasticsearch.common.collect.Sets; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; @@ -39,35 +39,41 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicReference; /** - * @author kimchy (shay.banon) + * */ public class TransportIndicesAliasesAction extends TransportMasterNodeOperationAction { private final MetaDataIndexAliasesService indexAliasesService; - @Inject public TransportIndicesAliasesAction(Settings settings, TransportService transportService, ClusterService clusterService, - ThreadPool threadPool, MetaDataIndexAliasesService indexAliasesService) { + @Inject + public TransportIndicesAliasesAction(Settings settings, TransportService transportService, ClusterService clusterService, + ThreadPool threadPool, MetaDataIndexAliasesService indexAliasesService) { super(settings, transportService, clusterService, threadPool); this.indexAliasesService = indexAliasesService; } - @Override protected String executor() { + @Override + protected String executor() { return ThreadPool.Names.MANAGEMENT; } - @Override protected String transportAction() { + @Override + protected String transportAction() { return TransportActions.Admin.Indices.ALIASES; } - @Override protected IndicesAliasesRequest newRequest() { + @Override + protected IndicesAliasesRequest newRequest() { return new IndicesAliasesRequest(); } - @Override protected IndicesAliasesResponse newResponse() { + @Override + protected IndicesAliasesResponse newResponse() { return new IndicesAliasesResponse(); } - @Override protected ClusterBlockException checkBlock(IndicesAliasesRequest request, ClusterState state) { + @Override + protected ClusterBlockException checkBlock(IndicesAliasesRequest request, ClusterState state) { Set indices = Sets.newHashSet(); for (AliasAction aliasAction : request.aliasActions()) { indices.add(aliasAction.index()); @@ -75,17 +81,20 @@ public class TransportIndicesAliasesAction extends TransportMasterNodeOperationA return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA, indices.toArray(new String[indices.size()])); } - @Override protected IndicesAliasesResponse masterOperation(IndicesAliasesRequest request, ClusterState state) throws ElasticSearchException { + @Override + protected IndicesAliasesResponse masterOperation(IndicesAliasesRequest request, ClusterState state) throws ElasticSearchException { final AtomicReference responseRef = new AtomicReference(); final AtomicReference failureRef = new AtomicReference(); final CountDownLatch latch = new CountDownLatch(1); indexAliasesService.indicesAliases(new MetaDataIndexAliasesService.Request(request.aliasActions().toArray(new AliasAction[request.aliasActions().size()]), request.timeout()), new MetaDataIndexAliasesService.Listener() { - @Override public void onResponse(MetaDataIndexAliasesService.Response response) { + @Override + public void onResponse(MetaDataIndexAliasesService.Response response) { responseRef.set(new IndicesAliasesResponse(response.acknowledged())); latch.countDown(); } - @Override public void onFailure(Throwable t) { + @Override + public void onFailure(Throwable t) { failureRef.set(t); latch.countDown(); } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/analyze/AnalyzeRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/analyze/AnalyzeRequest.java index a5189c12aec..7b9ae0d1edf 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/analyze/AnalyzeRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/analyze/AnalyzeRequest.java @@ -26,13 +26,11 @@ import org.elasticsearch.common.io.stream.StreamOutput; import java.io.IOException; -import static org.elasticsearch.action.Actions.*; +import static org.elasticsearch.action.Actions.addValidationError; /** * A request to analyze a text associated with a specific index. Allow to provide * the actual analyzer name to perform the analysis with. - * - * @author kimchy */ public class AnalyzeRequest extends SingleCustomOperationRequest { @@ -94,12 +92,14 @@ public class AnalyzeRequest extends SingleCustomOperationRequest { * if this operation hits a node with a local relevant shard, should it be preferred * to be executed on, or just do plain round robin. Defaults to true */ - @Override public AnalyzeRequest preferLocal(boolean preferLocal) { + @Override + public AnalyzeRequest preferLocal(boolean preferLocal) { super.preferLocal(preferLocal); return this; } - @Override public ActionRequestValidationException validate() { + @Override + public ActionRequestValidationException validate() { ActionRequestValidationException validationException = super.validate(); if (index == null) { validationException = addValidationError("index is missing", validationException); @@ -110,7 +110,8 @@ public class AnalyzeRequest extends SingleCustomOperationRequest { return validationException; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); index = in.readUTF(); text = in.readUTF(); @@ -122,7 +123,8 @@ public class AnalyzeRequest extends SingleCustomOperationRequest { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeUTF(index); out.writeUTF(text); diff --git a/src/main/java/org/elasticsearch/action/admin/indices/analyze/AnalyzeResponse.java b/src/main/java/org/elasticsearch/action/admin/indices/analyze/AnalyzeResponse.java index a41a5dddc27..aa2ed9c4648 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/analyze/AnalyzeResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/analyze/AnalyzeResponse.java @@ -32,7 +32,7 @@ import java.util.Iterator; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class AnalyzeResponse implements ActionResponse, Iterable, ToXContent { @@ -100,7 +100,8 @@ public class AnalyzeResponse implements ActionResponse, Iterable iterator() { + @Override + public Iterator iterator() { return tokens.iterator(); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { String format = params.param("format", "detailed"); if ("detailed".equals(format)) { builder.startArray("tokens"); @@ -180,7 +184,8 @@ public class AnalyzeResponse implements ActionResponse, Iterable(size); for (int i = 0; i < size; i++) { @@ -188,7 +193,8 @@ public class AnalyzeResponse implements ActionResponse, Iterable { private final IndicesService indicesService; - @Inject public TransportAnalyzeAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, - IndicesService indicesService) { + @Inject + public TransportAnalyzeAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, + IndicesService indicesService) { super(settings, threadPool, clusterService, transportService); this.indicesService = indicesService; } - @Override protected String executor() { + @Override + protected String executor() { return ThreadPool.Names.INDEX; } - @Override protected AnalyzeRequest newRequest() { + @Override + protected AnalyzeRequest newRequest() { return new AnalyzeRequest(); } - @Override protected AnalyzeResponse newResponse() { + @Override + protected AnalyzeResponse newResponse() { return new AnalyzeResponse(); } - @Override protected String transportAction() { + @Override + protected String transportAction() { return TransportActions.Admin.Indices.ANALYZE; } - @Override protected String transportShardAction() { + @Override + protected String transportShardAction() { return "indices/analyze/shard"; } - @Override protected ShardsIterator shards(ClusterState clusterState, AnalyzeRequest request) { + @Override + protected ShardsIterator shards(ClusterState clusterState, AnalyzeRequest request) { request.index(clusterState.metaData().concreteIndex(request.index())); return clusterState.routingTable().index(request.index()).randomAllActiveShardsIt(); } - @Override protected AnalyzeResponse shardOperation(AnalyzeRequest request, int shardId) throws ElasticSearchException { + @Override + protected AnalyzeResponse shardOperation(AnalyzeRequest request, int shardId) throws ElasticSearchException { IndexService indexService = indicesService.indexServiceSafe(request.index()); Analyzer analyzer = null; String field = null; diff --git a/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/ClearIndicesCacheRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/ClearIndicesCacheRequest.java index 7704af11de9..c956107836a 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/ClearIndicesCacheRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/ClearIndicesCacheRequest.java @@ -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 ClearIndicesCacheRequest extends BroadcastOperationRequest { @@ -49,7 +49,8 @@ public class ClearIndicesCacheRequest extends BroadcastOperationRequest { /** * Should the listener be called on a separate thread if needed. */ - @Override public ClearIndicesCacheRequest listenerThreaded(boolean threadedListener) { + @Override + public ClearIndicesCacheRequest listenerThreaded(boolean threadedListener) { super.listenerThreaded(threadedListener); return this; } @@ -57,7 +58,8 @@ public class ClearIndicesCacheRequest extends BroadcastOperationRequest { /** * Controls the operation threading model. */ - @Override public ClearIndicesCacheRequest operationThreading(BroadcastOperationThreading operationThreading) { + @Override + public ClearIndicesCacheRequest operationThreading(BroadcastOperationThreading operationThreading) { super.operationThreading(operationThreading); return this; } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/ClearIndicesCacheResponse.java b/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/ClearIndicesCacheResponse.java index a5613a38ed7..e5d4d290598 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/ClearIndicesCacheResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/ClearIndicesCacheResponse.java @@ -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.List; /** * The response of a refresh action. * - * @author kimchy (shay.banon) + * */ public class ClearIndicesCacheResponse extends BroadcastOperationResponse { @@ -42,11 +42,13 @@ public class ClearIndicesCacheResponse 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); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/ShardClearIndicesCacheRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/ShardClearIndicesCacheRequest.java index 3ec0976ac61..d988d8910d9 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/ShardClearIndicesCacheRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/ShardClearIndicesCacheRequest.java @@ -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) + * */ class ShardClearIndicesCacheRequest extends BroadcastShardOperationRequest { @@ -73,7 +73,8 @@ class ShardClearIndicesCacheRequest extends BroadcastShardOperationRequest { return this; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); filterCache = in.readBoolean(); fieldDataCache = in.readBoolean(); @@ -88,7 +89,8 @@ class ShardClearIndicesCacheRequest extends BroadcastShardOperationRequest { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeBoolean(filterCache); out.writeBoolean(fieldDataCache); diff --git a/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/ShardClearIndicesCacheResponse.java b/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/ShardClearIndicesCacheResponse.java index c1a28c97424..d6f372833e5 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/ShardClearIndicesCacheResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/ShardClearIndicesCacheResponse.java @@ -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) + * */ class ShardClearIndicesCacheResponse extends BroadcastShardOperationResponse { @@ -37,11 +37,13 @@ class ShardClearIndicesCacheResponse 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); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/TransportClearIndicesCacheAction.java b/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/TransportClearIndicesCacheAction.java index 9ee04075109..db563c26621 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/TransportClearIndicesCacheAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/TransportClearIndicesCacheAction.java @@ -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,45 +39,52 @@ 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; /** * Indices clear cache action. * - * @author kimchy (shay.banon) + * */ public class TransportClearIndicesCacheAction extends TransportBroadcastOperationAction { private final IndicesService indicesService; - @Inject public TransportClearIndicesCacheAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, - TransportService transportService, IndicesService indicesService) { + @Inject + public TransportClearIndicesCacheAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, + TransportService transportService, IndicesService indicesService) { super(settings, threadPool, clusterService, transportService); this.indicesService = indicesService; } - @Override protected String executor() { + @Override + protected String executor() { return ThreadPool.Names.MANAGEMENT; } - @Override protected String transportAction() { + @Override + protected String transportAction() { return TransportActions.Admin.Indices.Cache.CLEAR; } - @Override protected String transportShardAction() { + @Override + protected String transportShardAction() { return "indices/cache/clear/shard"; } - @Override protected ClearIndicesCacheRequest newRequest() { + @Override + protected ClearIndicesCacheRequest newRequest() { return new ClearIndicesCacheRequest(); } - @Override protected boolean ignoreNonActiveExceptions() { + @Override + protected boolean ignoreNonActiveExceptions() { return true; } - @Override protected ClearIndicesCacheResponse newResponse(ClearIndicesCacheRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) { + @Override + protected ClearIndicesCacheResponse newResponse(ClearIndicesCacheRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) { int successfulShards = 0; int failedShards = 0; List shardFailures = null; @@ -98,19 +105,23 @@ public class TransportClearIndicesCacheAction extends TransportBroadcastOperatio return new ClearIndicesCacheResponse(shardsResponses.length(), successfulShards, failedShards, shardFailures); } - @Override protected ShardClearIndicesCacheRequest newShardRequest() { + @Override + protected ShardClearIndicesCacheRequest newShardRequest() { return new ShardClearIndicesCacheRequest(); } - @Override protected ShardClearIndicesCacheRequest newShardRequest(ShardRouting shard, ClearIndicesCacheRequest request) { + @Override + protected ShardClearIndicesCacheRequest newShardRequest(ShardRouting shard, ClearIndicesCacheRequest request) { return new ShardClearIndicesCacheRequest(shard.index(), shard.id(), request); } - @Override protected ShardClearIndicesCacheResponse newShardResponse() { + @Override + protected ShardClearIndicesCacheResponse newShardResponse() { return new ShardClearIndicesCacheResponse(); } - @Override protected ShardClearIndicesCacheResponse shardOperation(ShardClearIndicesCacheRequest request) throws ElasticSearchException { + @Override + protected ShardClearIndicesCacheResponse shardOperation(ShardClearIndicesCacheRequest request) throws ElasticSearchException { IndexService service = indicesService.indexService(request.index()); if (service != null) { // we always clear the query cache @@ -156,7 +167,8 @@ public class TransportClearIndicesCacheAction extends TransportBroadcastOperatio /** * The refresh request works against *all* shards. */ - @Override protected GroupShardsIterator shards(ClearIndicesCacheRequest request, String[] concreteIndices, ClusterState clusterState) { + @Override + protected GroupShardsIterator shards(ClearIndicesCacheRequest request, String[] concreteIndices, ClusterState clusterState) { return clusterState.routingTable().allActiveShardsGrouped(concreteIndices, true); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexRequest.java index 068074735fd..66c172995e8 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexRequest.java @@ -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,13 +27,14 @@ import org.elasticsearch.common.unit.TimeValue; import java.io.IOException; -import static org.elasticsearch.action.Actions.*; -import static org.elasticsearch.common.unit.TimeValue.*; +import static org.elasticsearch.action.Actions.addValidationError; +import static org.elasticsearch.common.unit.TimeValue.readTimeValue; +import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; /** * A request to close an index. * - * @author kimchy (shay.banon) + * */ public class CloseIndexRequest extends MasterNodeOperationRequest { @@ -51,7 +52,8 @@ public class CloseIndexRequest extends MasterNodeOperationRequest { this.index = index; } - @Override public ActionRequestValidationException validate() { + @Override + public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if (index == null) { validationException = addValidationError("index is missing", validationException); @@ -91,13 +93,15 @@ public class CloseIndexRequest extends MasterNodeOperationRequest { return timeout(TimeValue.parseTimeValue(timeout, null)); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); index = in.readUTF(); timeout = readTimeValue(in); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeUTF(index); timeout.writeTo(out); diff --git a/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexResponse.java b/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexResponse.java index ce1524b194c..37c522f200a 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexResponse.java @@ -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.io.IOException; /** * A response for a close index action. * - * @author kimchy (shay.banon) + * */ public class CloseIndexResponse implements ActionResponse, Streamable { @@ -50,11 +50,13 @@ public class CloseIndexResponse implements ActionResponse, Streamable { return acknowledged(); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { acknowledged = in.readBoolean(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(acknowledged); } } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/close/TransportCloseIndexAction.java b/src/main/java/org/elasticsearch/action/admin/indices/close/TransportCloseIndexAction.java index 9e9003a6373..73c46bbae87 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/close/TransportCloseIndexAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/close/TransportCloseIndexAction.java @@ -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,49 +38,58 @@ import java.util.concurrent.atomic.AtomicReference; /** * Delete index action. * - * @author kimchy (shay.banon) + * */ public class TransportCloseIndexAction extends TransportMasterNodeOperationAction { private final MetaDataStateIndexService stateIndexService; - @Inject public TransportCloseIndexAction(Settings settings, TransportService transportService, ClusterService clusterService, - ThreadPool threadPool, MetaDataStateIndexService stateIndexService) { + @Inject + public TransportCloseIndexAction(Settings settings, TransportService transportService, ClusterService clusterService, + ThreadPool threadPool, MetaDataStateIndexService stateIndexService) { super(settings, transportService, clusterService, threadPool); this.stateIndexService = stateIndexService; } - @Override protected String executor() { + @Override + protected String executor() { return ThreadPool.Names.MANAGEMENT; } - @Override protected String transportAction() { + @Override + protected String transportAction() { return TransportActions.Admin.Indices.CLOSE; } - @Override protected CloseIndexRequest newRequest() { + @Override + protected CloseIndexRequest newRequest() { return new CloseIndexRequest(); } - @Override protected CloseIndexResponse newResponse() { + @Override + protected CloseIndexResponse newResponse() { return new CloseIndexResponse(); } - @Override protected ClusterBlockException checkBlock(CloseIndexRequest request, ClusterState state) { + @Override + protected ClusterBlockException checkBlock(CloseIndexRequest request, ClusterState state) { return state.blocks().indexBlockedException(ClusterBlockLevel.METADATA, request.index()); } - @Override protected CloseIndexResponse masterOperation(CloseIndexRequest request, ClusterState state) throws ElasticSearchException { + @Override + protected CloseIndexResponse masterOperation(CloseIndexRequest request, ClusterState state) throws ElasticSearchException { final AtomicReference responseRef = new AtomicReference(); final AtomicReference failureRef = new AtomicReference(); final CountDownLatch latch = new CountDownLatch(1); stateIndexService.closeIndex(new MetaDataStateIndexService.Request(request.index()).timeout(request.timeout()), new MetaDataStateIndexService.Listener() { - @Override public void onResponse(MetaDataStateIndexService.Response response) { + @Override + public void onResponse(MetaDataStateIndexService.Response response) { responseRef.set(new CloseIndexResponse(response.acknowledged())); latch.countDown(); } - @Override public void onFailure(Throwable t) { + @Override + public void onFailure(Throwable t) { failureRef.set(t); latch.countDown(); } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequest.java index 2c61376dd9a..4172c79a418 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequest.java @@ -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,18 +37,19 @@ import java.io.IOException; import java.util.Map; import java.util.concurrent.TimeUnit; -import static org.elasticsearch.action.Actions.*; -import static org.elasticsearch.common.collect.Maps.*; -import static org.elasticsearch.common.settings.ImmutableSettings.Builder.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.elasticsearch.common.unit.TimeValue.*; +import static com.google.common.collect.Maps.newHashMap; +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; +import static org.elasticsearch.common.unit.TimeValue.readTimeValue; /** * A request to create an index. Best created with {@link org.elasticsearch.client.Requests#createIndexRequest(String)}. - * + *

*

The index created can optionally be created with {@link #settings(org.elasticsearch.common.settings.Settings)}. * - * @author kimchy (shay.banon) + * * @see org.elasticsearch.client.IndicesAdminClient#create(CreateIndexRequest) * @see org.elasticsearch.client.Requests#createIndexRequest(String) * @see CreateIndexResponse @@ -83,7 +84,8 @@ public class CreateIndexRequest extends MasterNodeOperationRequest { this.settings = settings; } - @Override public ActionRequestValidationException validate() { + @Override + public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if (index == null) { validationException = addValidationError("index is missing", validationException); @@ -245,7 +247,8 @@ public class CreateIndexRequest extends MasterNodeOperationRequest { return timeout(TimeValue.parseTimeValue(timeout, null)); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); cause = in.readUTF(); index = in.readUTF(); @@ -257,7 +260,8 @@ public class CreateIndexRequest extends MasterNodeOperationRequest { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeUTF(cause); out.writeUTF(index); diff --git a/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexResponse.java b/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexResponse.java index b8b23c2c9cd..ea9de0deef6 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexResponse.java @@ -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.io.IOException; /** * A response for a create index action. * - * @author kimchy (shay.banon) + * */ public class CreateIndexResponse implements ActionResponse, Streamable { @@ -58,11 +58,13 @@ public class CreateIndexResponse implements ActionResponse, Streamable { return acknowledged(); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { acknowledged = in.readBoolean(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(acknowledged); } } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/create/TransportCreateIndexAction.java b/src/main/java/org/elasticsearch/action/admin/indices/create/TransportCreateIndexAction.java index b6e6550430c..b2367985261 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/create/TransportCreateIndexAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/create/TransportCreateIndexAction.java @@ -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,39 +38,46 @@ import java.util.concurrent.atomic.AtomicReference; /** * Create index action. * - * @author kimchy (shay.banon) + * */ public class TransportCreateIndexAction extends TransportMasterNodeOperationAction { private final MetaDataCreateIndexService createIndexService; - @Inject public TransportCreateIndexAction(Settings settings, TransportService transportService, ClusterService clusterService, - ThreadPool threadPool, MetaDataCreateIndexService createIndexService) { + @Inject + public TransportCreateIndexAction(Settings settings, TransportService transportService, ClusterService clusterService, + ThreadPool threadPool, MetaDataCreateIndexService createIndexService) { super(settings, transportService, clusterService, threadPool); this.createIndexService = createIndexService; } - @Override protected String executor() { + @Override + protected String executor() { return ThreadPool.Names.MANAGEMENT; } - @Override protected String transportAction() { + @Override + protected String transportAction() { return TransportActions.Admin.Indices.CREATE; } - @Override protected CreateIndexRequest newRequest() { + @Override + protected CreateIndexRequest newRequest() { return new CreateIndexRequest(); } - @Override protected CreateIndexResponse newResponse() { + @Override + protected CreateIndexResponse newResponse() { return new CreateIndexResponse(); } - @Override protected ClusterBlockException checkBlock(CreateIndexRequest request, ClusterState state) { + @Override + protected ClusterBlockException checkBlock(CreateIndexRequest request, ClusterState state) { return state.blocks().indexBlockedException(ClusterBlockLevel.METADATA, request.index()); } - @Override protected CreateIndexResponse masterOperation(CreateIndexRequest request, ClusterState state) throws ElasticSearchException { + @Override + protected CreateIndexResponse masterOperation(CreateIndexRequest request, ClusterState state) throws ElasticSearchException { String cause = request.cause(); if (cause.length() == 0) { cause = "api"; @@ -80,12 +87,14 @@ public class TransportCreateIndexAction extends TransportMasterNodeOperationActi final AtomicReference failureRef = new AtomicReference(); final CountDownLatch latch = new CountDownLatch(1); createIndexService.createIndex(new MetaDataCreateIndexService.Request(cause, request.index()).settings(request.settings()).mappings(request.mappings()).timeout(request.timeout()), new MetaDataCreateIndexService.Listener() { - @Override public void onResponse(MetaDataCreateIndexService.Response response) { + @Override + public void onResponse(MetaDataCreateIndexService.Response response) { responseRef.set(new CreateIndexResponse(response.acknowledged())); latch.countDown(); } - @Override public void onFailure(Throwable t) { + @Override + public void onFailure(Throwable t) { failureRef.set(t); latch.countDown(); } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/create/package-info.java b/src/main/java/org/elasticsearch/action/admin/indices/create/package-info.java index 179ddaa99b7..790e172d170 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/create/package-info.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/create/package-info.java @@ -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 diff --git a/src/main/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexRequest.java index 9e82634da12..276ac28ca9d 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexRequest.java @@ -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,13 +27,14 @@ import org.elasticsearch.common.unit.TimeValue; import java.io.IOException; -import static org.elasticsearch.action.Actions.*; -import static org.elasticsearch.common.unit.TimeValue.*; +import static org.elasticsearch.action.Actions.addValidationError; +import static org.elasticsearch.common.unit.TimeValue.readTimeValue; +import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; /** * A request to delete an index. Best created with {@link org.elasticsearch.client.Requests#deleteIndexRequest(String)}. * - * @author kimchy (shay.banon) + * */ public class DeleteIndexRequest extends MasterNodeOperationRequest { @@ -55,7 +56,8 @@ public class DeleteIndexRequest extends MasterNodeOperationRequest { this.indices = indices; } - @Override public ActionRequestValidationException validate() { + @Override + public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if (indices == null) { validationException = addValidationError("index / indices is missing", validationException); @@ -100,7 +102,8 @@ public class DeleteIndexRequest extends MasterNodeOperationRequest { return timeout(TimeValue.parseTimeValue(timeout, null)); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); indices = new String[in.readVInt()]; for (int i = 0; i < indices.length; i++) { @@ -109,7 +112,8 @@ public class DeleteIndexRequest extends MasterNodeOperationRequest { timeout = readTimeValue(in); } - @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); diff --git a/src/main/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexResponse.java b/src/main/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexResponse.java index 4679ddf8195..127e217a31a 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexResponse.java @@ -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.io.IOException; /** * A response for a delete index action. * - * @author kimchy (shay.banon) + * */ public class DeleteIndexResponse implements ActionResponse, Streamable { @@ -58,11 +58,13 @@ public class DeleteIndexResponse implements ActionResponse, Streamable { return acknowledged(); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { acknowledged = in.readBoolean(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(acknowledged); } } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/delete/TransportDeleteIndexAction.java b/src/main/java/org/elasticsearch/action/admin/indices/delete/TransportDeleteIndexAction.java index ec85d2ee073..7a41f517d23 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/delete/TransportDeleteIndexAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/delete/TransportDeleteIndexAction.java @@ -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.util.concurrent.atomic.AtomicReference; /** * Delete index action. * - * @author kimchy (shay.banon) + * */ public class TransportDeleteIndexAction extends TransportMasterNodeOperationAction { @@ -55,8 +55,9 @@ public class TransportDeleteIndexAction extends TransportMasterNodeOperationActi private final boolean disableDeleteAllIndices; - @Inject public TransportDeleteIndexAction(Settings settings, TransportService transportService, ClusterService clusterService, - ThreadPool threadPool, MetaDataDeleteIndexService deleteIndexService, TransportDeleteMappingAction deleteMappingAction) { + @Inject + public TransportDeleteIndexAction(Settings settings, TransportService transportService, ClusterService clusterService, + ThreadPool threadPool, MetaDataDeleteIndexService deleteIndexService, TransportDeleteMappingAction deleteMappingAction) { super(settings, transportService, clusterService, threadPool); this.deleteIndexService = deleteIndexService; this.deleteMappingAction = deleteMappingAction; @@ -64,23 +65,28 @@ public class TransportDeleteIndexAction extends TransportMasterNodeOperationActi this.disableDeleteAllIndices = settings.getAsBoolean("action.disable_delete_all_indices", false); } - @Override protected String executor() { + @Override + protected String executor() { return ThreadPool.Names.MANAGEMENT; } - @Override protected String transportAction() { + @Override + protected String transportAction() { return TransportActions.Admin.Indices.DELETE; } - @Override protected DeleteIndexRequest newRequest() { + @Override + protected DeleteIndexRequest newRequest() { return new DeleteIndexRequest(); } - @Override protected DeleteIndexResponse newResponse() { + @Override + protected DeleteIndexResponse newResponse() { return new DeleteIndexResponse(); } - @Override protected void doExecute(DeleteIndexRequest request, ActionListener listener) { + @Override + protected void doExecute(DeleteIndexRequest request, ActionListener listener) { if (disableDeleteAllIndices && (request.indices() == null || request.indices().length == 0)) { throw new ElasticSearchIllegalArgumentException("deleting all indices is disabled"); } @@ -88,11 +94,13 @@ public class TransportDeleteIndexAction extends TransportMasterNodeOperationActi super.doExecute(request, listener); } - @Override protected ClusterBlockException checkBlock(DeleteIndexRequest request, ClusterState state) { + @Override + protected ClusterBlockException checkBlock(DeleteIndexRequest request, ClusterState state) { return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA, request.indices()); } - @Override protected DeleteIndexResponse masterOperation(DeleteIndexRequest request, final ClusterState state) throws ElasticSearchException { + @Override + protected DeleteIndexResponse masterOperation(DeleteIndexRequest request, final ClusterState state) throws ElasticSearchException { if (request.indices().length == 0) { return new DeleteIndexResponse(true); } @@ -101,17 +109,20 @@ public class TransportDeleteIndexAction extends TransportMasterNodeOperationActi final CountDownLatch latch = new CountDownLatch(request.indices().length); for (final String index : request.indices()) { deleteIndexService.deleteIndex(new MetaDataDeleteIndexService.Request(index).timeout(request.timeout()), new MetaDataDeleteIndexService.Listener() { - @Override public void onResponse(MetaDataDeleteIndexService.Response response) { + @Override + public void onResponse(MetaDataDeleteIndexService.Response response) { responseRef.set(new DeleteIndexResponse(response.acknowledged())); // YACK, but here we go: If this index is also percolated, make sure to delete all percolated queries from the _percolator index IndexMetaData percolatorMetaData = state.metaData().index(PercolatorService.INDEX_NAME); if (percolatorMetaData != null && percolatorMetaData.mappings().containsKey(index)) { deleteMappingAction.execute(new DeleteMappingRequest(PercolatorService.INDEX_NAME).type(index), new ActionListener() { - @Override public void onResponse(DeleteMappingResponse deleteMappingResponse) { + @Override + public void onResponse(DeleteMappingResponse deleteMappingResponse) { latch.countDown(); } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { latch.countDown(); } }); @@ -120,7 +131,8 @@ public class TransportDeleteIndexAction extends TransportMasterNodeOperationActi } } - @Override public void onFailure(Throwable t) { + @Override + public void onFailure(Throwable t) { failureRef.set(t); latch.countDown(); } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/delete/package-info.java b/src/main/java/org/elasticsearch/action/admin/indices/delete/package-info.java index c8c7618ea2a..1adc714118a 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/delete/package-info.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/delete/package-info.java @@ -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 diff --git a/src/main/java/org/elasticsearch/action/admin/indices/exists/IndicesExistsRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/exists/IndicesExistsRequest.java index 7bf87d96dce..ddd1e641b17 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/exists/IndicesExistsRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/exists/IndicesExistsRequest.java @@ -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; -import static org.elasticsearch.action.Actions.*; +import static org.elasticsearch.action.Actions.addValidationError; public class IndicesExistsRequest extends MasterNodeOperationRequest { @@ -44,7 +44,8 @@ public class IndicesExistsRequest extends MasterNodeOperationRequest { this.indices = indices; } - @Override public ActionRequestValidationException validate() { + @Override + public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if (indices == null || indices.length == 0) { validationException = addValidationError("index/indices is missing", validationException); @@ -52,7 +53,8 @@ public class IndicesExistsRequest extends MasterNodeOperationRequest { return validationException; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); indices = new String[in.readVInt()]; for (int i = 0; i < indices.length; i++) { @@ -60,7 +62,8 @@ public class IndicesExistsRequest extends MasterNodeOperationRequest { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeVInt(indices.length); for (String index : indices) { diff --git a/src/main/java/org/elasticsearch/action/admin/indices/exists/IndicesExistsResponse.java b/src/main/java/org/elasticsearch/action/admin/indices/exists/IndicesExistsResponse.java index c979ea715a7..cf1c3d82263 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/exists/IndicesExistsResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/exists/IndicesExistsResponse.java @@ -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,11 +45,13 @@ public class IndicesExistsResponse implements ActionResponse, Streamable { return exists(); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { exists = in.readBoolean(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(exists); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/action/admin/indices/exists/TransportIndicesExistsAction.java b/src/main/java/org/elasticsearch/action/admin/indices/exists/TransportIndicesExistsAction.java index 1bdf3d74c66..30b68140eb6 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/exists/TransportIndicesExistsAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/exists/TransportIndicesExistsAction.java @@ -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,42 +35,50 @@ import org.elasticsearch.transport.TransportService; /** * Indices exists action. * - * @author kimchy (shay.banon) + * */ public class TransportIndicesExistsAction extends TransportMasterNodeOperationAction { - @Inject public TransportIndicesExistsAction(Settings settings, TransportService transportService, ClusterService clusterService, - ThreadPool threadPool) { + @Inject + public TransportIndicesExistsAction(Settings settings, TransportService transportService, ClusterService clusterService, + ThreadPool threadPool) { super(settings, transportService, clusterService, threadPool); } - @Override protected String executor() { + @Override + protected String executor() { return ThreadPool.Names.MANAGEMENT; } - @Override protected String transportAction() { + @Override + protected String transportAction() { return TransportActions.Admin.Indices.EXISTS; } - @Override protected IndicesExistsRequest newRequest() { + @Override + protected IndicesExistsRequest newRequest() { return new IndicesExistsRequest(); } - @Override protected IndicesExistsResponse newResponse() { + @Override + protected IndicesExistsResponse newResponse() { return new IndicesExistsResponse(); } - @Override protected void doExecute(IndicesExistsRequest request, ActionListener listener) { + @Override + protected void doExecute(IndicesExistsRequest request, ActionListener listener) { // don't call this since it will throw IndexMissingException //request.indices(clusterService.state().metaData().concreteIndices(request.indices())); super.doExecute(request, listener); } - @Override protected ClusterBlockException checkBlock(IndicesExistsRequest request, ClusterState state) { + @Override + protected ClusterBlockException checkBlock(IndicesExistsRequest request, ClusterState state) { return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA, request.indices()); } - @Override protected IndicesExistsResponse masterOperation(IndicesExistsRequest request, ClusterState state) throws ElasticSearchException { + @Override + protected IndicesExistsResponse masterOperation(IndicesExistsRequest request, ClusterState state) throws ElasticSearchException { boolean exists = true; for (String index : request.indices()) { if (!state.metaData().hasConcreteIndex(index)) { diff --git a/src/main/java/org/elasticsearch/action/admin/indices/flush/FlushRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/flush/FlushRequest.java index 7f4da8bfa84..41b3e53961f 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/flush/FlushRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/flush/FlushRequest.java @@ -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,10 +30,10 @@ import java.io.IOException; * A flush request to flush one or more indices. The flush process of an index basically frees memory from the index * by flushing data to the index storage and clearing the internal transaction log. By default, ElasticSearch uses * memory heuristics in order to automatically trigger flush operations as required in order to clear memory. - * + *

*

Best created with {@link org.elasticsearch.client.Requests#flushRequest(String...)}. * - * @author kimchy (shay.banon) + * * @see org.elasticsearch.client.Requests#flushRequest(String...) * @see org.elasticsearch.client.IndicesAdminClient#flush(FlushRequest) * @see FlushResponse @@ -108,7 +108,8 @@ public class FlushRequest extends BroadcastOperationRequest { /** * Should the listener be called on a separate thread if needed. */ - @Override public FlushRequest listenerThreaded(boolean threadedListener) { + @Override + public FlushRequest listenerThreaded(boolean threadedListener) { super.listenerThreaded(threadedListener); return this; } @@ -116,19 +117,22 @@ public class FlushRequest extends BroadcastOperationRequest { /** * Controls the operation threading model. */ - @Override public FlushRequest operationThreading(BroadcastOperationThreading operationThreading) { + @Override + public FlushRequest operationThreading(BroadcastOperationThreading operationThreading) { super.operationThreading(operationThreading); return this; } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeBoolean(refresh); out.writeBoolean(full); out.writeBoolean(force); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); refresh = in.readBoolean(); full = in.readBoolean(); diff --git a/src/main/java/org/elasticsearch/action/admin/indices/flush/FlushResponse.java b/src/main/java/org/elasticsearch/action/admin/indices/flush/FlushResponse.java index f3a6fce085a..fdfb5b55ca5 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/flush/FlushResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/flush/FlushResponse.java @@ -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.List; /** * A response to flush action. * - * @author kimchy (shay.banon) + * */ public class FlushResponse extends BroadcastOperationResponse { @@ -42,11 +42,13 @@ public class FlushResponse 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); } } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/flush/ShardFlushRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/flush/ShardFlushRequest.java index 3104d72ad0b..1803b0cff77 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/flush/ShardFlushRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/flush/ShardFlushRequest.java @@ -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) + * */ class ShardFlushRequest extends BroadcastShardOperationRequest { @@ -56,14 +56,16 @@ class ShardFlushRequest extends BroadcastShardOperationRequest { return this.force; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); refresh = in.readBoolean(); full = in.readBoolean(); force = in.readBoolean(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeBoolean(refresh); out.writeBoolean(full); diff --git a/src/main/java/org/elasticsearch/action/admin/indices/flush/ShardFlushResponse.java b/src/main/java/org/elasticsearch/action/admin/indices/flush/ShardFlushResponse.java index c175e7b4669..e16729c9aae 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/flush/ShardFlushResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/flush/ShardFlushResponse.java @@ -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) + * */ class ShardFlushResponse extends BroadcastShardOperationResponse { @@ -38,11 +38,13 @@ class ShardFlushResponse 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); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportFlushAction.java b/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportFlushAction.java index d85ad209f3b..ac5d7dc093d 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportFlushAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportFlushAction.java @@ -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 @@ -40,43 +40,50 @@ 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; /** * Flush Action. * - * @author kimchy (shay.banon) + * */ public class TransportFlushAction extends TransportBroadcastOperationAction { private final IndicesService indicesService; - @Inject public TransportFlushAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, IndicesService indicesService) { + @Inject + public TransportFlushAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, IndicesService indicesService) { super(settings, threadPool, clusterService, transportService); this.indicesService = indicesService; } - @Override protected String executor() { + @Override + protected String executor() { return ThreadPool.Names.MANAGEMENT; } - @Override protected String transportAction() { + @Override + protected String transportAction() { return TransportActions.Admin.Indices.FLUSH; } - @Override protected String transportShardAction() { + @Override + protected String transportShardAction() { return "indices/flush/shard"; } - @Override protected FlushRequest newRequest() { + @Override + protected FlushRequest newRequest() { return new FlushRequest(); } - @Override protected boolean ignoreNonActiveExceptions() { + @Override + protected boolean ignoreNonActiveExceptions() { return true; } - @Override protected FlushResponse newResponse(FlushRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) { + @Override + protected FlushResponse newResponse(FlushRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) { int successfulShards = 0; int failedShards = 0; List shardFailures = null; @@ -97,19 +104,23 @@ public class TransportFlushAction extends TransportBroadcastOperationAction { private final IndicesService indicesService; - @Inject public TransportGatewaySnapshotAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, - TransportService transportService, IndicesService indicesService) { + @Inject + public TransportGatewaySnapshotAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, + TransportService transportService, IndicesService indicesService) { super(settings, threadPool, clusterService, transportService); this.indicesService = indicesService; } - @Override protected String executor() { + @Override + protected String executor() { return ThreadPool.Names.MANAGEMENT; } - @Override protected String transportAction() { + @Override + protected String transportAction() { return TransportActions.Admin.Indices.Gateway.SNAPSHOT; } - @Override protected String transportShardAction() { + @Override + protected String transportShardAction() { return "indices/gateway/snapshot/shard"; } - @Override protected GatewaySnapshotRequest newRequest() { + @Override + protected GatewaySnapshotRequest newRequest() { return new GatewaySnapshotRequest(); } - @Override protected boolean ignoreNonActiveExceptions() { + @Override + protected boolean ignoreNonActiveExceptions() { return true; } - @Override protected GatewaySnapshotResponse newResponse(GatewaySnapshotRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) { + @Override + protected GatewaySnapshotResponse newResponse(GatewaySnapshotRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) { int successfulShards = 0; int failedShards = 0; List shardFailures = null; @@ -94,19 +101,23 @@ public class TransportGatewaySnapshotAction extends TransportBroadcastOperationA return new GatewaySnapshotResponse(shardsResponses.length(), successfulShards, failedShards, shardFailures); } - @Override protected ShardGatewaySnapshotRequest newShardRequest() { + @Override + protected ShardGatewaySnapshotRequest newShardRequest() { return new ShardGatewaySnapshotRequest(); } - @Override protected ShardGatewaySnapshotRequest newShardRequest(ShardRouting shard, GatewaySnapshotRequest request) { + @Override + protected ShardGatewaySnapshotRequest newShardRequest(ShardRouting shard, GatewaySnapshotRequest request) { return new ShardGatewaySnapshotRequest(shard.index(), shard.id()); } - @Override protected ShardGatewaySnapshotResponse newShardResponse() { + @Override + protected ShardGatewaySnapshotResponse newShardResponse() { return new ShardGatewaySnapshotResponse(); } - @Override protected ShardGatewaySnapshotResponse shardOperation(ShardGatewaySnapshotRequest request) throws ElasticSearchException { + @Override + protected ShardGatewaySnapshotResponse shardOperation(ShardGatewaySnapshotRequest request) throws ElasticSearchException { IndexShardGatewayService shardGatewayService = indicesService.indexServiceSafe(request.index()) .shardInjectorSafe(request.shardId()).getInstance(IndexShardGatewayService.class); shardGatewayService.snapshot("api"); @@ -116,7 +127,8 @@ public class TransportGatewaySnapshotAction extends TransportBroadcastOperationA /** * The snapshot request works against all primary shards. */ - @Override protected GroupShardsIterator shards(GatewaySnapshotRequest request, String[] concreteIndices, ClusterState clusterState) { + @Override + protected GroupShardsIterator shards(GatewaySnapshotRequest request, String[] concreteIndices, ClusterState clusterState) { return clusterState.routingTable().activePrimaryShardsGrouped(concreteIndices, true); } } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/package-info.java b/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/package-info.java index 21204f16c89..d1d73b97c08 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/package-info.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/package-info.java @@ -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 diff --git a/src/main/java/org/elasticsearch/action/admin/indices/mapping/delete/DeleteMappingRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/mapping/delete/DeleteMappingRequest.java index 603ac7c9f14..854c55359e5 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/mapping/delete/DeleteMappingRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/mapping/delete/DeleteMappingRequest.java @@ -26,10 +26,10 @@ import org.elasticsearch.common.io.stream.StreamOutput; import java.io.IOException; -import static org.elasticsearch.action.Actions.*; +import static org.elasticsearch.action.Actions.addValidationError; /** - * @author kimchy (shay.banon) + * */ public class DeleteMappingRequest extends MasterNodeOperationRequest { @@ -48,7 +48,8 @@ public class DeleteMappingRequest extends MasterNodeOperationRequest { this.indices = indices; } - @Override public ActionRequestValidationException validate() { + @Override + public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if (mappingType == null) { validationException = addValidationError("mapping type is missing", validationException); @@ -86,7 +87,8 @@ public class DeleteMappingRequest extends MasterNodeOperationRequest { return this; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); indices = new String[in.readVInt()]; for (int i = 0; i < indices.length; i++) { @@ -97,7 +99,8 @@ public class DeleteMappingRequest extends MasterNodeOperationRequest { } } - @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); diff --git a/src/main/java/org/elasticsearch/action/admin/indices/mapping/delete/DeleteMappingResponse.java b/src/main/java/org/elasticsearch/action/admin/indices/mapping/delete/DeleteMappingResponse.java index 85c63ab47a0..7823b00a738 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/mapping/delete/DeleteMappingResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/mapping/delete/DeleteMappingResponse.java @@ -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.io.IOException; /** * The response of remove mapping operation. * - * @author kimchy (shay.banon) + * */ public class DeleteMappingResponse implements ActionResponse, Streamable { @@ -37,9 +37,11 @@ public class DeleteMappingResponse 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 { } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/action/admin/indices/mapping/delete/TransportDeleteMappingAction.java b/src/main/java/org/elasticsearch/action/admin/indices/mapping/delete/TransportDeleteMappingAction.java index a28ca784122..09639790c27 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/mapping/delete/TransportDeleteMappingAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/mapping/delete/TransportDeleteMappingAction.java @@ -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 @@ -46,7 +46,7 @@ import java.util.concurrent.atomic.AtomicReference; /** * Delete mapping action. * - * @author kimchy (shay.banon) + * */ public class TransportDeleteMappingAction extends TransportMasterNodeOperationAction { @@ -56,61 +56,73 @@ public class TransportDeleteMappingAction extends TransportMasterNodeOperationAc private final TransportRefreshAction refreshAction; - @Inject public TransportDeleteMappingAction(Settings settings, TransportService transportService, ClusterService clusterService, - ThreadPool threadPool, MetaDataMappingService metaDataMappingService, - TransportDeleteByQueryAction deleteByQueryAction, TransportRefreshAction refreshAction) { + @Inject + public TransportDeleteMappingAction(Settings settings, TransportService transportService, ClusterService clusterService, + ThreadPool threadPool, MetaDataMappingService metaDataMappingService, + TransportDeleteByQueryAction deleteByQueryAction, TransportRefreshAction refreshAction) { super(settings, transportService, clusterService, threadPool); this.metaDataMappingService = metaDataMappingService; this.deleteByQueryAction = deleteByQueryAction; this.refreshAction = refreshAction; } - @Override protected String executor() { + @Override + protected String executor() { return ThreadPool.Names.MANAGEMENT; } - @Override protected String transportAction() { + @Override + protected String transportAction() { return TransportActions.Admin.Indices.Mapping.DELETE; } - @Override protected DeleteMappingRequest newRequest() { + @Override + protected DeleteMappingRequest newRequest() { return new DeleteMappingRequest(); } - @Override protected DeleteMappingResponse newResponse() { + @Override + protected DeleteMappingResponse newResponse() { return new DeleteMappingResponse(); } - @Override protected void doExecute(DeleteMappingRequest request, ActionListener listener) { + @Override + protected void doExecute(DeleteMappingRequest request, ActionListener listener) { // update to concrete indices request.indices(clusterService.state().metaData().concreteIndices(request.indices())); super.doExecute(request, listener); } - @Override protected ClusterBlockException checkBlock(DeleteMappingRequest request, ClusterState state) { + @Override + protected ClusterBlockException checkBlock(DeleteMappingRequest request, ClusterState state) { return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA, request.indices()); } - @Override protected DeleteMappingResponse masterOperation(final DeleteMappingRequest request, final ClusterState state) throws ElasticSearchException { + @Override + protected DeleteMappingResponse masterOperation(final DeleteMappingRequest request, final ClusterState state) throws ElasticSearchException { final AtomicReference failureRef = new AtomicReference(); final CountDownLatch latch = new CountDownLatch(1); deleteByQueryAction.execute(Requests.deleteByQueryRequest(request.indices()).query(QueryBuilders.filteredQuery(QueryBuilders.matchAllQuery(), FilterBuilders.typeFilter(request.type()))), new ActionListener() { - @Override public void onResponse(DeleteByQueryResponse deleteByQueryResponse) { + @Override + public void onResponse(DeleteByQueryResponse deleteByQueryResponse) { refreshAction.execute(Requests.refreshRequest(request.indices()), new ActionListener() { - @Override public void onResponse(RefreshResponse refreshResponse) { + @Override + public void onResponse(RefreshResponse refreshResponse) { metaDataMappingService.removeMapping(new MetaDataMappingService.RemoveRequest(request.indices(), request.type())); latch.countDown(); } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { metaDataMappingService.removeMapping(new MetaDataMappingService.RemoveRequest(request.indices(), request.type())); latch.countDown(); } }); } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { failureRef.set(e); latch.countDown(); } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/mapping/package-info.java b/src/main/java/org/elasticsearch/action/admin/indices/mapping/package-info.java index 0676efde518..f660d504489 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/mapping/package-info.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/mapping/package-info.java @@ -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 diff --git a/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequest.java index 88f67d149ea..400427b0b83 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequest.java @@ -35,18 +35,18 @@ import java.io.IOException; import java.util.Map; import java.util.concurrent.TimeUnit; -import static org.elasticsearch.action.Actions.*; -import static org.elasticsearch.common.unit.TimeValue.*; +import static org.elasticsearch.action.Actions.addValidationError; +import static org.elasticsearch.common.unit.TimeValue.readTimeValue; /** * Puts mapping definition registered under a specific type into one or more indices. Best created with * {@link org.elasticsearch.client.Requests#putMappingRequest(String...)}. - * + *

*

If the mappings already exists, the new mappings will be merged with the new one. If there are elements * that can't be merged are detected, the request will be rejected unless the {@link #ignoreConflicts(boolean)} * is set. In such a case, the duplicate mappings will be rejected. * - * @author kimchy (shay.banon) + * * @see org.elasticsearch.client.Requests#putMappingRequest(String...) * @see org.elasticsearch.client.IndicesAdminClient#putMapping(PutMappingRequest) * @see PutMappingResponse @@ -74,7 +74,8 @@ public class PutMappingRequest extends MasterNodeOperationRequest { this.indices = indices; } - @Override public ActionRequestValidationException validate() { + @Override + public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if (mappingType == null) { validationException = addValidationError("mapping type is missing", validationException); @@ -110,7 +111,8 @@ public class PutMappingRequest extends MasterNodeOperationRequest { /** * The type of the mappings. */ - @Required public PutMappingRequest type(String mappingType) { + @Required + public PutMappingRequest type(String mappingType) { this.mappingType = mappingType; return this; } @@ -125,7 +127,8 @@ public class PutMappingRequest extends MasterNodeOperationRequest { /** * The mapping source definition. */ - @Required public PutMappingRequest source(XContentBuilder mappingBuilder) { + @Required + public PutMappingRequest source(XContentBuilder mappingBuilder) { try { return source(mappingBuilder.string()); } catch (IOException e) { @@ -136,7 +139,8 @@ public class PutMappingRequest extends MasterNodeOperationRequest { /** * The mapping source definition. */ - @Required public PutMappingRequest source(Map mappingSource) { + @Required + public PutMappingRequest source(Map mappingSource) { try { XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); builder.map(mappingSource); @@ -149,7 +153,8 @@ public class PutMappingRequest extends MasterNodeOperationRequest { /** * The mapping source definition. */ - @Required public PutMappingRequest source(String mappingSource) { + @Required + public PutMappingRequest source(String mappingSource) { this.mappingSource = mappingSource; return this; } @@ -198,7 +203,8 @@ public class PutMappingRequest extends MasterNodeOperationRequest { return this; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); indices = new String[in.readVInt()]; for (int i = 0; i < indices.length; i++) { @@ -212,7 +218,8 @@ public class PutMappingRequest extends MasterNodeOperationRequest { ignoreConflicts = in.readBoolean(); } - @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); diff --git a/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingResponse.java b/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingResponse.java index 9dcaec0d8ff..fad38492cfb 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingResponse.java @@ -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.io.IOException; /** * The response of put mapping operation. * - * @author kimchy (shay.banon) + * */ public class PutMappingResponse implements ActionResponse, Streamable { @@ -59,11 +59,13 @@ public class PutMappingResponse implements ActionResponse, Streamable { return acknowledged(); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { acknowledged = in.readBoolean(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(acknowledged); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/TransportPutMappingAction.java b/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/TransportPutMappingAction.java index 6091daaa081..666465dd723 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/TransportPutMappingAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/TransportPutMappingAction.java @@ -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,44 +39,52 @@ import java.util.concurrent.atomic.AtomicReference; /** * Put mapping action. * - * @author kimchy (shay.banon) + * */ public class TransportPutMappingAction extends TransportMasterNodeOperationAction { private final MetaDataMappingService metaDataMappingService; - @Inject public TransportPutMappingAction(Settings settings, TransportService transportService, ClusterService clusterService, - ThreadPool threadPool, MetaDataMappingService metaDataMappingService) { + @Inject + public TransportPutMappingAction(Settings settings, TransportService transportService, ClusterService clusterService, + ThreadPool threadPool, MetaDataMappingService metaDataMappingService) { super(settings, transportService, clusterService, threadPool); this.metaDataMappingService = metaDataMappingService; } - @Override protected String executor() { + @Override + protected String executor() { return ThreadPool.Names.MANAGEMENT; } - @Override protected String transportAction() { + @Override + protected String transportAction() { return TransportActions.Admin.Indices.Mapping.PUT; } - @Override protected PutMappingRequest newRequest() { + @Override + protected PutMappingRequest newRequest() { return new PutMappingRequest(); } - @Override protected PutMappingResponse newResponse() { + @Override + protected PutMappingResponse newResponse() { return new PutMappingResponse(); } - @Override protected void doExecute(PutMappingRequest request, ActionListener listener) { + @Override + protected void doExecute(PutMappingRequest request, ActionListener listener) { request.indices(clusterService.state().metaData().concreteIndices(request.indices())); super.doExecute(request, listener); } - @Override protected ClusterBlockException checkBlock(PutMappingRequest request, ClusterState state) { + @Override + protected ClusterBlockException checkBlock(PutMappingRequest request, ClusterState state) { return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA, request.indices()); } - @Override protected PutMappingResponse masterOperation(PutMappingRequest request, ClusterState state) throws ElasticSearchException { + @Override + protected PutMappingResponse masterOperation(PutMappingRequest request, ClusterState state) throws ElasticSearchException { ClusterState clusterState = clusterService.state(); // update to concrete indices @@ -86,12 +94,14 @@ public class TransportPutMappingAction extends TransportMasterNodeOperationActio final AtomicReference failureRef = new AtomicReference(); final CountDownLatch latch = new CountDownLatch(1); metaDataMappingService.putMapping(new MetaDataMappingService.PutRequest(request.indices(), request.type(), request.source()).ignoreConflicts(request.ignoreConflicts()).timeout(request.timeout()), new MetaDataMappingService.Listener() { - @Override public void onResponse(MetaDataMappingService.Response response) { + @Override + public void onResponse(MetaDataMappingService.Response response) { responseRef.set(new PutMappingResponse(response.acknowledged())); latch.countDown(); } - @Override public void onFailure(Throwable t) { + @Override + public void onFailure(Throwable t) { failureRef.set(t); latch.countDown(); } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/package-info.java b/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/package-info.java index 93d8886da1b..b59faa59aef 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/package-info.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/package-info.java @@ -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 diff --git a/src/main/java/org/elasticsearch/action/admin/indices/open/OpenIndexRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/open/OpenIndexRequest.java index 2052fcb7e93..d9bdd78710e 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/open/OpenIndexRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/open/OpenIndexRequest.java @@ -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,13 +27,14 @@ import org.elasticsearch.common.unit.TimeValue; import java.io.IOException; -import static org.elasticsearch.action.Actions.*; -import static org.elasticsearch.common.unit.TimeValue.*; +import static org.elasticsearch.action.Actions.addValidationError; +import static org.elasticsearch.common.unit.TimeValue.readTimeValue; +import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; /** * A request to open an index. * - * @author kimchy (shay.banon) + * */ public class OpenIndexRequest extends MasterNodeOperationRequest { @@ -51,7 +52,8 @@ public class OpenIndexRequest extends MasterNodeOperationRequest { this.index = index; } - @Override public ActionRequestValidationException validate() { + @Override + public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if (index == null) { validationException = addValidationError("index is missing", validationException); @@ -91,13 +93,15 @@ public class OpenIndexRequest extends MasterNodeOperationRequest { return timeout(TimeValue.parseTimeValue(timeout, null)); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); index = in.readUTF(); timeout = readTimeValue(in); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeUTF(index); timeout.writeTo(out); diff --git a/src/main/java/org/elasticsearch/action/admin/indices/open/OpenIndexResponse.java b/src/main/java/org/elasticsearch/action/admin/indices/open/OpenIndexResponse.java index 4c928bdd6a3..a0a7cb78610 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/open/OpenIndexResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/open/OpenIndexResponse.java @@ -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.io.IOException; /** * A response for a open index action. * - * @author kimchy (shay.banon) + * */ public class OpenIndexResponse implements ActionResponse, Streamable { @@ -50,11 +50,13 @@ public class OpenIndexResponse implements ActionResponse, Streamable { return acknowledged(); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { acknowledged = in.readBoolean(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(acknowledged); } } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/open/TransportOpenIndexAction.java b/src/main/java/org/elasticsearch/action/admin/indices/open/TransportOpenIndexAction.java index b2604b8f409..5dd400ce6c6 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/open/TransportOpenIndexAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/open/TransportOpenIndexAction.java @@ -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,49 +38,58 @@ import java.util.concurrent.atomic.AtomicReference; /** * Delete index action. * - * @author kimchy (shay.banon) + * */ public class TransportOpenIndexAction extends TransportMasterNodeOperationAction { private final MetaDataStateIndexService stateIndexService; - @Inject public TransportOpenIndexAction(Settings settings, TransportService transportService, ClusterService clusterService, - ThreadPool threadPool, MetaDataStateIndexService stateIndexService) { + @Inject + public TransportOpenIndexAction(Settings settings, TransportService transportService, ClusterService clusterService, + ThreadPool threadPool, MetaDataStateIndexService stateIndexService) { super(settings, transportService, clusterService, threadPool); this.stateIndexService = stateIndexService; } - @Override protected String executor() { + @Override + protected String executor() { return ThreadPool.Names.MANAGEMENT; } - @Override protected String transportAction() { + @Override + protected String transportAction() { return TransportActions.Admin.Indices.OPEN; } - @Override protected OpenIndexRequest newRequest() { + @Override + protected OpenIndexRequest newRequest() { return new OpenIndexRequest(); } - @Override protected OpenIndexResponse newResponse() { + @Override + protected OpenIndexResponse newResponse() { return new OpenIndexResponse(); } - @Override protected ClusterBlockException checkBlock(OpenIndexRequest request, ClusterState state) { + @Override + protected ClusterBlockException checkBlock(OpenIndexRequest request, ClusterState state) { return state.blocks().indexBlockedException(ClusterBlockLevel.METADATA, request.index()); } - @Override protected OpenIndexResponse masterOperation(OpenIndexRequest request, ClusterState state) throws ElasticSearchException { + @Override + protected OpenIndexResponse masterOperation(OpenIndexRequest request, ClusterState state) throws ElasticSearchException { final AtomicReference responseRef = new AtomicReference(); final AtomicReference failureRef = new AtomicReference(); final CountDownLatch latch = new CountDownLatch(1); stateIndexService.openIndex(new MetaDataStateIndexService.Request(request.index()).timeout(request.timeout()), new MetaDataStateIndexService.Listener() { - @Override public void onResponse(MetaDataStateIndexService.Response response) { + @Override + public void onResponse(MetaDataStateIndexService.Response response) { responseRef.set(new OpenIndexResponse(response.acknowledged())); latch.countDown(); } - @Override public void onFailure(Throwable t) { + @Override + public void onFailure(Throwable t) { failureRef.set(t); latch.countDown(); } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/optimize/OptimizeRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/optimize/OptimizeRequest.java index 5aa558cae32..b488681364d 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/optimize/OptimizeRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/optimize/OptimizeRequest.java @@ -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,14 +29,14 @@ import java.io.IOException; /** * A request to optimize one or more indices. In order to optimize on all the indices, pass an empty array or * null for the indices. - * + *

*

{@link #waitForMerge(boolean)} allows to control if the call will block until the optimize completes and * defaults to true. - * + *

*

{@link #maxNumSegments(int)} allows to control the number of segments to optimize down to. By default, will * cause the optimize process to optimize down to half the configured number of segments. * - * @author kimchy (shay.banon) + * * @see org.elasticsearch.client.Requests#optimizeRequest(String...) * @see org.elasticsearch.client.IndicesAdminClient#optimize(OptimizeRequest) * @see OptimizeResponse @@ -76,12 +76,14 @@ public class OptimizeRequest extends BroadcastOperationRequest { } - @Override public OptimizeRequest listenerThreaded(boolean threadedListener) { + @Override + public OptimizeRequest listenerThreaded(boolean threadedListener) { super.listenerThreaded(threadedListener); return this; } - @Override public OptimizeRequest operationThreading(BroadcastOperationThreading operationThreading) { + @Override + public OptimizeRequest operationThreading(BroadcastOperationThreading operationThreading) { super.operationThreading(operationThreading); return this; } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/optimize/OptimizeResponse.java b/src/main/java/org/elasticsearch/action/admin/indices/optimize/OptimizeResponse.java index 0817fb0e18e..27c76888f14 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/optimize/OptimizeResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/optimize/OptimizeResponse.java @@ -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.List; /** * A response for optimize action. * - * @author kimchy (shay.banon) + * */ public class OptimizeResponse extends BroadcastOperationResponse { @@ -42,11 +42,13 @@ public class OptimizeResponse 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); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/action/admin/indices/optimize/ShardOptimizeRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/optimize/ShardOptimizeRequest.java index a33d0bc543e..b847709b344 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/optimize/ShardOptimizeRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/optimize/ShardOptimizeRequest.java @@ -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) + * */ class ShardOptimizeRequest extends BroadcastShardOperationRequest { @@ -72,7 +72,8 @@ class ShardOptimizeRequest extends BroadcastShardOperationRequest { return refresh; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); waitForMerge = in.readBoolean(); maxNumSegments = in.readInt(); @@ -81,7 +82,8 @@ class ShardOptimizeRequest extends BroadcastShardOperationRequest { refresh = in.readBoolean(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeBoolean(waitForMerge); out.writeInt(maxNumSegments); diff --git a/src/main/java/org/elasticsearch/action/admin/indices/optimize/ShardOptimizeResponse.java b/src/main/java/org/elasticsearch/action/admin/indices/optimize/ShardOptimizeResponse.java index 5b43e62e82a..b5dbaa98ffb 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/optimize/ShardOptimizeResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/optimize/ShardOptimizeResponse.java @@ -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) + * */ class ShardOptimizeResponse extends BroadcastShardOperationResponse { @@ -37,11 +37,13 @@ class ShardOptimizeResponse 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); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/action/admin/indices/optimize/TransportOptimizeAction.java b/src/main/java/org/elasticsearch/action/admin/indices/optimize/TransportOptimizeAction.java index 4703e13f504..53b623327d9 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/optimize/TransportOptimizeAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/optimize/TransportOptimizeAction.java @@ -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 @@ -40,12 +40,12 @@ 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; /** * Optimize index/indices action. * - * @author kimchy (shay.banon) + * */ public class TransportOptimizeAction extends TransportBroadcastOperationAction { @@ -53,33 +53,40 @@ public class TransportOptimizeAction extends TransportBroadcastOperationAction shardFailures = null; @@ -100,19 +107,23 @@ public class TransportOptimizeAction extends TransportBroadcastOperationAction { private final IndicesService indicesService; - @Inject public TransportRefreshAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, - TransportService transportService, IndicesService indicesService) { + @Inject + public TransportRefreshAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, + TransportService transportService, IndicesService indicesService) { super(settings, threadPool, clusterService, transportService); this.indicesService = indicesService; } - @Override protected String executor() { + @Override + protected String executor() { return ThreadPool.Names.MANAGEMENT; } - @Override protected String transportAction() { + @Override + protected String transportAction() { return TransportActions.Admin.Indices.REFRESH; } - @Override protected String transportShardAction() { + @Override + protected String transportShardAction() { return "indices/refresh/shard"; } - @Override protected RefreshRequest newRequest() { + @Override + protected RefreshRequest newRequest() { return new RefreshRequest(); } - @Override protected boolean ignoreNonActiveExceptions() { + @Override + protected boolean ignoreNonActiveExceptions() { return true; } - @Override protected boolean ignoreException(Throwable t) { + @Override + protected boolean ignoreException(Throwable t) { Throwable actual = ExceptionsHelper.unwrapCause(t); if (actual instanceof IllegalIndexShardStateException) { return true; @@ -91,7 +98,8 @@ public class TransportRefreshAction extends TransportBroadcastOperationAction shardFailures = null; @@ -112,19 +120,23 @@ public class TransportRefreshAction extends TransportBroadcastOperationAction { return shards(); } - @Override public Iterator iterator() { + @Override + public Iterator iterator() { return indexShards.values().iterator(); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/action/admin/indices/segments/IndexShardSegments.java b/src/main/java/org/elasticsearch/action/admin/indices/segments/IndexShardSegments.java index e75cea1954b..b971d072c0b 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/segments/IndexShardSegments.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/segments/IndexShardSegments.java @@ -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,7 +19,7 @@ package org.elasticsearch.action.admin.indices.segments; -import org.elasticsearch.common.collect.Iterators; +import com.google.common.collect.Iterators; import org.elasticsearch.index.shard.ShardId; import java.util.Iterator; @@ -55,7 +55,8 @@ public class IndexShardSegments implements Iterable { return this.shards; } - @Override public Iterator iterator() { + @Override + public Iterator iterator() { return Iterators.forArray(shards); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/action/admin/indices/segments/IndicesSegmentResponse.java b/src/main/java/org/elasticsearch/action/admin/indices/segments/IndicesSegmentResponse.java index c36f0cacdd0..28422b0e9ea 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/segments/IndicesSegmentResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/segments/IndicesSegmentResponse.java @@ -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.elasticsearch.action.admin.indices.segments; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; import org.elasticsearch.action.ShardOperationFailedException; import org.elasticsearch.action.support.broadcast.BroadcastOperationResponse; import org.elasticsearch.cluster.ClusterState; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.collect.Maps; -import org.elasticsearch.common.collect.Sets; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.xcontent.ToXContent; @@ -81,7 +81,8 @@ public class IndicesSegmentResponse extends BroadcastOperationResponse implement } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); shards = new ShardSegments[in.readVInt()]; for (int i = 0; i < shards.length; i++) { @@ -89,7 +90,8 @@ public class IndicesSegmentResponse extends BroadcastOperationResponse implement } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeVInt(shards.length); for (ShardSegments shard : shards) { @@ -97,7 +99,8 @@ public class IndicesSegmentResponse extends BroadcastOperationResponse implement } } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(Fields.INDICES); for (IndexSegments indexSegments : indices().values()) { diff --git a/src/main/java/org/elasticsearch/action/admin/indices/segments/IndicesSegmentsRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/segments/IndicesSegmentsRequest.java index 901758095c4..43565ef7031 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/segments/IndicesSegmentsRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/segments/IndicesSegmentsRequest.java @@ -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 diff --git a/src/main/java/org/elasticsearch/action/admin/indices/segments/ShardSegments.java b/src/main/java/org/elasticsearch/action/admin/indices/segments/ShardSegments.java index a96660077f1..33baa5bc629 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/segments/ShardSegments.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/segments/ShardSegments.java @@ -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.indices.segments; +import com.google.common.collect.ImmutableList; import org.elasticsearch.action.support.broadcast.BroadcastShardOperationResponse; import org.elasticsearch.cluster.routing.ShardRouting; -import org.elasticsearch.common.collect.ImmutableList; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.index.engine.Segment; @@ -31,7 +31,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import static org.elasticsearch.cluster.routing.ImmutableShardRouting.*; +import static org.elasticsearch.cluster.routing.ImmutableShardRouting.readShardRoutingEntry; public class ShardSegments extends BroadcastShardOperationResponse implements Iterable { @@ -48,7 +48,8 @@ public class ShardSegments extends BroadcastShardOperationResponse implements It this.segments = segments; } - @Override public Iterator iterator() { + @Override + public Iterator iterator() { return segments.iterator(); } @@ -94,7 +95,8 @@ public class ShardSegments extends BroadcastShardOperationResponse implements It return shard; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); shardRouting = readShardRoutingEntry(in); int size = in.readVInt(); @@ -108,7 +110,8 @@ public class ShardSegments extends BroadcastShardOperationResponse implements It } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); shardRouting.writeTo(out); out.writeVInt(segments.size()); diff --git a/src/main/java/org/elasticsearch/action/admin/indices/segments/TransportIndicesSegmentsAction.java b/src/main/java/org/elasticsearch/action/admin/indices/segments/TransportIndicesSegmentsAction.java index 66b5104a2fd..07d7fee2375 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/segments/TransportIndicesSegmentsAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/segments/TransportIndicesSegmentsAction.java @@ -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 @@ -44,49 +44,57 @@ import java.io.IOException; 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 TransportIndicesSegmentsAction extends TransportBroadcastOperationAction { private final IndicesService indicesService; - @Inject public TransportIndicesSegmentsAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, - IndicesService indicesService) { + @Inject + public TransportIndicesSegmentsAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, + IndicesService indicesService) { super(settings, threadPool, clusterService, transportService); this.indicesService = indicesService; } - @Override protected String executor() { + @Override + protected String executor() { return ThreadPool.Names.MANAGEMENT; } - @Override protected String transportAction() { + @Override + protected String transportAction() { return TransportActions.Admin.Indices.SEGMENTS; } - @Override protected String transportShardAction() { + @Override + protected String transportShardAction() { return "indices/segments/shard"; } - @Override protected IndicesSegmentsRequest newRequest() { + @Override + protected IndicesSegmentsRequest newRequest() { return new IndicesSegmentsRequest(); } - @Override protected boolean ignoreNonActiveExceptions() { + @Override + protected boolean ignoreNonActiveExceptions() { return true; } /** * Segments goes across *all* active shards. */ - @Override protected GroupShardsIterator shards(IndicesSegmentsRequest request, String[] concreteIndices, ClusterState clusterState) { + @Override + protected GroupShardsIterator shards(IndicesSegmentsRequest request, String[] concreteIndices, ClusterState clusterState) { return clusterState.routingTable().allActiveShardsGrouped(concreteIndices, true); } - @Override protected IndicesSegmentResponse newResponse(IndicesSegmentsRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) { + @Override + protected IndicesSegmentResponse newResponse(IndicesSegmentsRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) { int successfulShards = 0; int failedShards = 0; List shardFailures = null; @@ -109,19 +117,23 @@ public class TransportIndicesSegmentsAction extends TransportBroadcastOperationA return new IndicesSegmentResponse(shards.toArray(new ShardSegments[shards.size()]), clusterState, shardsResponses.length(), successfulShards, failedShards, shardFailures); } - @Override protected IndexShardSegmentRequest newShardRequest() { + @Override + protected IndexShardSegmentRequest newShardRequest() { return new IndexShardSegmentRequest(); } - @Override protected IndexShardSegmentRequest newShardRequest(ShardRouting shard, IndicesSegmentsRequest request) { + @Override + protected IndexShardSegmentRequest newShardRequest(ShardRouting shard, IndicesSegmentsRequest request) { return new IndexShardSegmentRequest(shard.index(), shard.id(), request); } - @Override protected ShardSegments newShardResponse() { + @Override + protected ShardSegments newShardResponse() { return new ShardSegments(); } - @Override protected ShardSegments shardOperation(IndexShardSegmentRequest request) throws ElasticSearchException { + @Override + protected ShardSegments shardOperation(IndexShardSegmentRequest request) throws ElasticSearchException { InternalIndexService indexService = (InternalIndexService) indicesService.indexServiceSafe(request.index()); InternalIndexShard indexShard = (InternalIndexShard) indexService.shardSafe(request.shardId()); return new ShardSegments(indexShard.routingEntry(), indexShard.engine().segments()); @@ -136,11 +148,13 @@ public class TransportIndicesSegmentsAction extends TransportBroadcastOperationA 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); } } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/settings/TransportUpdateSettingsAction.java b/src/main/java/org/elasticsearch/action/admin/indices/settings/TransportUpdateSettingsAction.java index 7fdf438356a..99b7de6cba2 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/settings/TransportUpdateSettingsAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/settings/TransportUpdateSettingsAction.java @@ -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,44 +34,52 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicReference; /** - * @author kimchy (shay.banon) + * */ public class TransportUpdateSettingsAction extends TransportMasterNodeOperationAction { private final MetaDataUpdateSettingsService updateSettingsService; - @Inject public TransportUpdateSettingsAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, - MetaDataUpdateSettingsService updateSettingsService) { + @Inject + public TransportUpdateSettingsAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, + MetaDataUpdateSettingsService updateSettingsService) { super(settings, transportService, clusterService, threadPool); this.updateSettingsService = updateSettingsService; } - @Override protected String executor() { + @Override + protected String executor() { return ThreadPool.Names.MANAGEMENT; } - @Override protected String transportAction() { + @Override + protected String transportAction() { return TransportActions.Admin.Indices.UPDATE_SETTINGS; } - @Override protected UpdateSettingsRequest newRequest() { + @Override + protected UpdateSettingsRequest newRequest() { return new UpdateSettingsRequest(); } - @Override protected UpdateSettingsResponse newResponse() { + @Override + protected UpdateSettingsResponse newResponse() { return new UpdateSettingsResponse(); } - @Override protected UpdateSettingsResponse masterOperation(UpdateSettingsRequest request, ClusterState state) throws ElasticSearchException { + @Override + protected UpdateSettingsResponse masterOperation(UpdateSettingsRequest request, ClusterState state) throws ElasticSearchException { final AtomicReference failureRef = new AtomicReference(); final CountDownLatch latch = new CountDownLatch(1); updateSettingsService.updateSettings(request.settings(), request.indices(), new MetaDataUpdateSettingsService.Listener() { - @Override public void onSuccess() { + @Override + public void onSuccess() { latch.countDown(); } - @Override public void onFailure(Throwable t) { + @Override + public void onFailure(Throwable t) { failureRef.set(t); latch.countDown(); } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/settings/UpdateSettingsRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/settings/UpdateSettingsRequest.java index e8c091d75ac..149fcf4d446 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/settings/UpdateSettingsRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/settings/UpdateSettingsRequest.java @@ -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,12 +33,13 @@ 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; /** - * @author kimchy + * */ public class UpdateSettingsRequest extends MasterNodeOperationRequest { @@ -64,7 +65,8 @@ public class UpdateSettingsRequest extends MasterNodeOperationRequest { this.settings = settings; } - @Override public ActionRequestValidationException validate() { + @Override + public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if (settings.getAsMap().isEmpty()) { validationException = addValidationError("no settings to update", validationException); @@ -123,7 +125,8 @@ public class UpdateSettingsRequest extends MasterNodeOperationRequest { return this; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); indices = new String[in.readVInt()]; for (int i = 0; i < indices.length; i++) { @@ -132,7 +135,8 @@ public class UpdateSettingsRequest extends MasterNodeOperationRequest { settings = readSettingsFromStream(in); } - @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); diff --git a/src/main/java/org/elasticsearch/action/admin/indices/settings/UpdateSettingsResponse.java b/src/main/java/org/elasticsearch/action/admin/indices/settings/UpdateSettingsResponse.java index f84645f292e..5f86c98fba5 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/settings/UpdateSettingsResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/settings/UpdateSettingsResponse.java @@ -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,16 +29,18 @@ import java.io.IOException; /** * A response for a update settings action. * - * @author kimchy (shay.banon) + * */ public class UpdateSettingsResponse implements ActionResponse, Streamable { UpdateSettingsResponse() { } - @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 { } } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/stats/CommonStats.java b/src/main/java/org/elasticsearch/action/admin/indices/stats/CommonStats.java index 3c7abd733a4..a95fa74957a 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/stats/CommonStats.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/stats/CommonStats.java @@ -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 @@ -40,21 +40,29 @@ import java.io.IOException; */ public class CommonStats implements Streamable, ToXContent { - @Nullable DocsStats docs; + @Nullable + DocsStats docs; - @Nullable StoreStats store; + @Nullable + StoreStats store; - @Nullable IndexingStats indexing; + @Nullable + IndexingStats indexing; - @Nullable GetStats get; + @Nullable + GetStats get; - @Nullable SearchStats search; + @Nullable + SearchStats search; - @Nullable MergeStats merge; + @Nullable + MergeStats merge; - @Nullable RefreshStats refresh; + @Nullable + RefreshStats refresh; - @Nullable FlushStats flush; + @Nullable + FlushStats flush; public void add(CommonStats stats) { if (docs == null) { @@ -123,67 +131,83 @@ public class CommonStats implements Streamable, ToXContent { } } - @Nullable public DocsStats docs() { + @Nullable + public DocsStats docs() { return this.docs; } - @Nullable public DocsStats getDocs() { + @Nullable + public DocsStats getDocs() { return this.docs; } - @Nullable public StoreStats store() { + @Nullable + public StoreStats store() { return store; } - @Nullable public StoreStats getStore() { + @Nullable + public StoreStats getStore() { return store; } - @Nullable public IndexingStats indexing() { + @Nullable + public IndexingStats indexing() { return indexing; } - @Nullable public IndexingStats getIndexing() { + @Nullable + public IndexingStats getIndexing() { return indexing; } - @Nullable public GetStats get() { + @Nullable + public GetStats get() { return get; } - @Nullable public GetStats getGet() { + @Nullable + public GetStats getGet() { return get; } - @Nullable public SearchStats search() { + @Nullable + public SearchStats search() { return search; } - @Nullable public SearchStats getSearch() { + @Nullable + public SearchStats getSearch() { return search; } - @Nullable public MergeStats merge() { + @Nullable + public MergeStats merge() { return merge; } - @Nullable public MergeStats getMerge() { + @Nullable + public MergeStats getMerge() { return merge; } - @Nullable public RefreshStats refresh() { + @Nullable + public RefreshStats refresh() { return refresh; } - @Nullable public RefreshStats getRefresh() { + @Nullable + public RefreshStats getRefresh() { return refresh; } - @Nullable public FlushStats flush() { + @Nullable + public FlushStats flush() { return flush; } - @Nullable public FlushStats getFlush() { + @Nullable + public FlushStats getFlush() { return flush; } @@ -193,7 +217,8 @@ public class CommonStats implements Streamable, ToXContent { return stats; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { if (in.readBoolean()) { docs = DocsStats.readDocStats(in); } @@ -220,7 +245,8 @@ public class CommonStats implements Streamable, ToXContent { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { if (docs == null) { out.writeBoolean(false); } else { @@ -272,7 +298,8 @@ public class CommonStats implements Streamable, ToXContent { } // note, requires a wrapping object - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { if (docs != null) { docs.toXContent(builder, params); } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/stats/IndexShardStats.java b/src/main/java/org/elasticsearch/action/admin/indices/stats/IndexShardStats.java index 5771d29fa81..f32f2b83742 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/stats/IndexShardStats.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/stats/IndexShardStats.java @@ -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,7 +19,7 @@ package org.elasticsearch.action.admin.indices.stats; -import org.elasticsearch.common.collect.Iterators; +import com.google.common.collect.Iterators; import org.elasticsearch.index.shard.ShardId; import java.util.Iterator; @@ -57,7 +57,8 @@ public class IndexShardStats implements Iterable { return shards[position]; } - @Override public Iterator iterator() { + @Override + public Iterator iterator() { return Iterators.forArray(shards); } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/stats/IndexStats.java b/src/main/java/org/elasticsearch/action/admin/indices/stats/IndexStats.java index 0578d1b90f1..691fdfb129b 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/stats/IndexStats.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/stats/IndexStats.java @@ -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.indices.stats; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.collect.Maps; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import java.util.Iterator; import java.util.List; @@ -69,7 +69,8 @@ public class IndexStats implements Iterable { return indexShards; } - @Override public Iterator iterator() { + @Override + public Iterator iterator() { return indexShards().values().iterator(); } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/stats/IndicesStats.java b/src/main/java/org/elasticsearch/action/admin/indices/stats/IndicesStats.java index 66809ea406d..262b873b01a 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/stats/IndicesStats.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/stats/IndicesStats.java @@ -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.elasticsearch.action.admin.indices.stats; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; import org.elasticsearch.action.ShardOperationFailedException; import org.elasticsearch.action.support.broadcast.BroadcastOperationResponse; import org.elasticsearch.cluster.ClusterState; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.collect.Maps; -import org.elasticsearch.common.collect.Sets; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.xcontent.ToXContent; @@ -135,7 +135,8 @@ public class IndicesStats extends BroadcastOperationResponse implements ToXConte return stats; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); shards = new ShardStats[in.readVInt()]; for (int i = 0; i < shards.length; i++) { @@ -143,7 +144,8 @@ public class IndicesStats extends BroadcastOperationResponse implements ToXConte } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeVInt(shards.length); for (ShardStats shard : shards) { @@ -151,7 +153,8 @@ public class IndicesStats extends BroadcastOperationResponse implements ToXConte } } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject("_all"); builder.startObject("primaries"); diff --git a/src/main/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsRequest.java index cc58ffbcd96..f594d52ea58 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsRequest.java @@ -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,10 +27,10 @@ import java.io.IOException; /** * A request to get indices level stats. Allow to enable different stats to be returned. - * + *

*

By default, the {@link #docs(boolean)}, {@link #store(boolean)}, {@link #indexing(boolean)} * are enabled. Other stats can be enabled as well. - * + *

*

All the stats to be returned can be cleared using {@link #clear()}, at which point, specific * stats can be enabled. */ @@ -171,7 +171,8 @@ public class IndicesStatsRequest extends BroadcastOperationRequest { return this.flush; } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeBoolean(docs); out.writeBoolean(store); @@ -199,7 +200,8 @@ public class IndicesStatsRequest extends BroadcastOperationRequest { } } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); docs = in.readBoolean(); store = in.readBoolean(); diff --git a/src/main/java/org/elasticsearch/action/admin/indices/stats/ShardStats.java b/src/main/java/org/elasticsearch/action/admin/indices/stats/ShardStats.java index 09564160568..dc437931d35 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/stats/ShardStats.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/stats/ShardStats.java @@ -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; -import static org.elasticsearch.cluster.routing.ImmutableShardRouting.*; +import static org.elasticsearch.cluster.routing.ImmutableShardRouting.readShardRoutingEntry; /** */ @@ -73,13 +73,15 @@ public class ShardStats extends BroadcastShardOperationResponse { return stats; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); shardRouting = readShardRoutingEntry(in); stats = CommonStats.readCommonStats(in); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); shardRouting.writeTo(out); stats.writeTo(out); diff --git a/src/main/java/org/elasticsearch/action/admin/indices/stats/TransportIndicesStatsAction.java b/src/main/java/org/elasticsearch/action/admin/indices/stats/TransportIndicesStatsAction.java index b2841953f52..aaec96d5eaf 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/stats/TransportIndicesStatsAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/stats/TransportIndicesStatsAction.java @@ -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.indices.stats; +import com.google.common.collect.Lists; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.action.ShardOperationFailedException; import org.elasticsearch.action.TransportActions; @@ -30,7 +31,6 @@ import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.routing.GroupShardsIterator; import org.elasticsearch.cluster.routing.ShardRouting; -import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -45,7 +45,7 @@ import java.io.IOException; 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; /** */ @@ -53,40 +53,48 @@ public class TransportIndicesStatsAction extends TransportBroadcastOperationActi private final IndicesService indicesService; - @Inject public TransportIndicesStatsAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, - IndicesService indicesService) { + @Inject + public TransportIndicesStatsAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, + IndicesService indicesService) { super(settings, threadPool, clusterService, transportService); this.indicesService = indicesService; } - @Override protected String executor() { + @Override + protected String executor() { return ThreadPool.Names.MANAGEMENT; } - @Override protected String transportAction() { + @Override + protected String transportAction() { return TransportActions.Admin.Indices.STATS; } - @Override protected String transportShardAction() { + @Override + protected String transportShardAction() { return "indices/stats/shard"; } - @Override protected IndicesStatsRequest newRequest() { + @Override + protected IndicesStatsRequest newRequest() { return new IndicesStatsRequest(); } - @Override protected boolean ignoreNonActiveExceptions() { + @Override + protected boolean ignoreNonActiveExceptions() { return true; } /** * Status goes across *all* shards. */ - @Override protected GroupShardsIterator shards(IndicesStatsRequest request, String[] concreteIndices, ClusterState clusterState) { + @Override + protected GroupShardsIterator shards(IndicesStatsRequest request, String[] concreteIndices, ClusterState clusterState) { return clusterState.routingTable().allAssignedShardsGrouped(concreteIndices, true); } - @Override protected IndicesStats newResponse(IndicesStatsRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) { + @Override + protected IndicesStats newResponse(IndicesStatsRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) { int successfulShards = 0; int failedShards = 0; List shardFailures = null; @@ -109,19 +117,23 @@ public class TransportIndicesStatsAction extends TransportBroadcastOperationActi return new IndicesStats(shards.toArray(new ShardStats[shards.size()]), clusterState, shardsResponses.length(), successfulShards, failedShards, shardFailures); } - @Override protected IndexShardStatsRequest newShardRequest() { + @Override + protected IndexShardStatsRequest newShardRequest() { return new IndexShardStatsRequest(); } - @Override protected IndexShardStatsRequest newShardRequest(ShardRouting shard, IndicesStatsRequest request) { + @Override + protected IndexShardStatsRequest newShardRequest(ShardRouting shard, IndicesStatsRequest request) { return new IndexShardStatsRequest(shard.index(), shard.id(), request); } - @Override protected ShardStats newShardResponse() { + @Override + protected ShardStats newShardResponse() { return new ShardStats(); } - @Override protected ShardStats shardOperation(IndexShardStatsRequest request) throws ElasticSearchException { + @Override + protected ShardStats shardOperation(IndexShardStatsRequest request) throws ElasticSearchException { InternalIndexService indexService = (InternalIndexService) indicesService.indexServiceSafe(request.index()); InternalIndexShard indexShard = (InternalIndexShard) indexService.shardSafe(request.shardId()); ShardStats stats = new ShardStats(indexShard.routingEntry()); @@ -166,13 +178,15 @@ public class TransportIndicesStatsAction extends TransportBroadcastOperationActi this.request = request; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); request = new IndicesStatsRequest(); request.readFrom(in); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); request.writeTo(out); } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/status/DocsStatus.java b/src/main/java/org/elasticsearch/action/admin/indices/status/DocsStatus.java index d6aa2c2a996..aca640c2799 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/status/DocsStatus.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/status/DocsStatus.java @@ -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.admin.indices.status; /** - * @author kimchy (shay.banon) + * */ public class DocsStatus { diff --git a/src/main/java/org/elasticsearch/action/admin/indices/status/GatewayRecoveryStatus.java b/src/main/java/org/elasticsearch/action/admin/indices/status/GatewayRecoveryStatus.java index 101b3bc8403..75b2e242f09 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/status/GatewayRecoveryStatus.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/status/GatewayRecoveryStatus.java @@ -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.common.unit.ByteSizeValue; import org.elasticsearch.common.unit.TimeValue; /** - * @author kimchy (shay.banon) + * */ public class GatewayRecoveryStatus { diff --git a/src/main/java/org/elasticsearch/action/admin/indices/status/GatewaySnapshotStatus.java b/src/main/java/org/elasticsearch/action/admin/indices/status/GatewaySnapshotStatus.java index d6010c95469..1fe87a01466 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/status/GatewaySnapshotStatus.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/status/GatewaySnapshotStatus.java @@ -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.common.unit.ByteSizeValue; import org.elasticsearch.common.unit.TimeValue; /** - * @author kimchy (shay.banon) + * */ public class GatewaySnapshotStatus { diff --git a/src/main/java/org/elasticsearch/action/admin/indices/status/IndexShardStatus.java b/src/main/java/org/elasticsearch/action/admin/indices/status/IndexShardStatus.java index a86a4e5167d..350df3615fe 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/status/IndexShardStatus.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/status/IndexShardStatus.java @@ -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,7 +19,7 @@ package org.elasticsearch.action.admin.indices.status; -import org.elasticsearch.common.collect.Iterators; +import com.google.common.collect.Iterators; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.index.flush.FlushStats; import org.elasticsearch.index.merge.MergeStats; @@ -29,7 +29,7 @@ import org.elasticsearch.index.shard.ShardId; import java.util.Iterator; /** - * @author kimchy (shay.banon) + * */ public class IndexShardStatus implements Iterable { @@ -207,7 +207,8 @@ public class IndexShardStatus implements Iterable { return flushStats(); } - @Override public Iterator iterator() { + @Override + public Iterator iterator() { return Iterators.forArray(shards); } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/status/IndexStatus.java b/src/main/java/org/elasticsearch/action/admin/indices/status/IndexStatus.java index 3b85a28ce7c..ad3c26f6e00 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/status/IndexStatus.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/status/IndexStatus.java @@ -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,7 +19,7 @@ package org.elasticsearch.action.admin.indices.status; -import org.elasticsearch.common.collect.Maps; +import com.google.common.collect.Maps; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.index.flush.FlushStats; import org.elasticsearch.index.merge.MergeStats; @@ -29,10 +29,10 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import static org.elasticsearch.common.collect.Lists.*; +import static com.google.common.collect.Lists.newArrayList; /** - * @author kimchy (shay.banon) + * */ public class IndexStatus implements Iterable { @@ -215,7 +215,8 @@ public class IndexStatus implements Iterable { return flushStats(); } - @Override public Iterator iterator() { + @Override + public Iterator iterator() { return indexShards.values().iterator(); } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/status/IndicesStatusRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/status/IndicesStatusRequest.java index e1e72939610..4483cd51960 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/status/IndicesStatusRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/status/IndicesStatusRequest.java @@ -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 IndicesStatusRequest extends BroadcastOperationRequest { @@ -68,22 +68,26 @@ public class IndicesStatusRequest extends BroadcastOperationRequest { return this.snapshot; } - @Override public IndicesStatusRequest listenerThreaded(boolean listenerThreaded) { + @Override + public IndicesStatusRequest listenerThreaded(boolean listenerThreaded) { super.listenerThreaded(listenerThreaded); return this; } - @Override public BroadcastOperationRequest operationThreading(BroadcastOperationThreading operationThreading) { + @Override + public BroadcastOperationRequest operationThreading(BroadcastOperationThreading operationThreading) { return super.operationThreading(operationThreading); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeBoolean(recovery); out.writeBoolean(snapshot); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); recovery = in.readBoolean(); snapshot = in.readBoolean(); diff --git a/src/main/java/org/elasticsearch/action/admin/indices/status/IndicesStatusResponse.java b/src/main/java/org/elasticsearch/action/admin/indices/status/IndicesStatusResponse.java index 35318ed65af..3fa9470e790 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/status/IndicesStatusResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/status/IndicesStatusResponse.java @@ -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,11 +19,11 @@ package org.elasticsearch.action.admin.indices.status; +import com.google.common.collect.Sets; import org.elasticsearch.action.ShardOperationFailedException; import org.elasticsearch.action.support.broadcast.BroadcastOperationResponse; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.collect.Sets; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.settings.SettingsFilter; @@ -39,12 +39,12 @@ import java.util.List; import java.util.Map; import java.util.Set; -import static org.elasticsearch.action.admin.indices.status.ShardStatus.*; -import static org.elasticsearch.common.collect.Lists.*; -import static org.elasticsearch.common.collect.Maps.*; +import static com.google.common.collect.Lists.newArrayList; +import static com.google.common.collect.Maps.newHashMap; +import static org.elasticsearch.action.admin.indices.status.ShardStatus.readIndexShardStatus; /** - * @author kimchy (shay.banon) + * */ public class IndicesStatusResponse extends BroadcastOperationResponse implements ToXContent { @@ -104,7 +104,8 @@ public class IndicesStatusResponse extends BroadcastOperationResponse implements return indicesStatus; } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeVInt(shards().length); for (ShardStatus status : shards()) { @@ -112,7 +113,8 @@ public class IndicesStatusResponse extends BroadcastOperationResponse implements } } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); shards = new ShardStatus[in.readVInt()]; for (int i = 0; i < shards.length; i++) { @@ -120,7 +122,8 @@ public class IndicesStatusResponse extends BroadcastOperationResponse implements } } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { return toXContent(builder, params, null); } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/status/PeerRecoveryStatus.java b/src/main/java/org/elasticsearch/action/admin/indices/status/PeerRecoveryStatus.java index 4e361a3734e..38224b5e33e 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/status/PeerRecoveryStatus.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/status/PeerRecoveryStatus.java @@ -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.common.unit.ByteSizeValue; import org.elasticsearch.common.unit.TimeValue; /** - * @author kimchy (shay.banon) + * */ public class PeerRecoveryStatus { diff --git a/src/main/java/org/elasticsearch/action/admin/indices/status/ShardStatus.java b/src/main/java/org/elasticsearch/action/admin/indices/status/ShardStatus.java index 4d16711d7c2..c905b777f7b 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/status/ShardStatus.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/status/ShardStatus.java @@ -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,13 +31,13 @@ import org.elasticsearch.index.shard.IndexShardState; import java.io.IOException; -import static org.elasticsearch.cluster.routing.ImmutableShardRouting.*; -import static org.elasticsearch.common.unit.ByteSizeValue.*; +import static org.elasticsearch.cluster.routing.ImmutableShardRouting.readShardRoutingEntry; +import static org.elasticsearch.common.unit.ByteSizeValue.readBytesSizeValue; /** * Shard instance (actual allocated shard) status. * - * @author kimchy (shay.banon) + * */ public class ShardStatus extends BroadcastShardOperationResponse { @@ -245,7 +245,8 @@ public class ShardStatus extends BroadcastShardOperationResponse { return shardStatus; } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); shardRouting.writeTo(out); out.writeByte(state.id()); @@ -322,7 +323,8 @@ public class ShardStatus extends BroadcastShardOperationResponse { } } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); shardRouting = readShardRoutingEntry(in); state = IndexShardState.fromId(in.readByte()); diff --git a/src/main/java/org/elasticsearch/action/admin/indices/status/TransportIndicesStatusAction.java b/src/main/java/org/elasticsearch/action/admin/indices/status/TransportIndicesStatusAction.java index 0dad125120b..5646cba8db0 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/status/TransportIndicesStatusAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/status/TransportIndicesStatusAction.java @@ -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,10 +50,10 @@ import java.io.IOException; 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 TransportIndicesStatusAction extends TransportBroadcastOperationAction { @@ -61,41 +61,49 @@ public class TransportIndicesStatusAction extends TransportBroadcastOperationAct private final RecoveryTarget peerRecoveryTarget; - @Inject public TransportIndicesStatusAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, - IndicesService indicesService, RecoveryTarget peerRecoveryTarget) { + @Inject + public TransportIndicesStatusAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, + IndicesService indicesService, RecoveryTarget peerRecoveryTarget) { super(settings, threadPool, clusterService, transportService); this.peerRecoveryTarget = peerRecoveryTarget; this.indicesService = indicesService; } - @Override protected String executor() { + @Override + protected String executor() { return ThreadPool.Names.MANAGEMENT; } - @Override protected String transportAction() { + @Override + protected String transportAction() { return TransportActions.Admin.Indices.STATUS; } - @Override protected String transportShardAction() { + @Override + protected String transportShardAction() { return "indices/status/shard"; } - @Override protected IndicesStatusRequest newRequest() { + @Override + protected IndicesStatusRequest newRequest() { return new IndicesStatusRequest(); } - @Override protected boolean ignoreNonActiveExceptions() { + @Override + protected boolean ignoreNonActiveExceptions() { return true; } /** * Status goes across *all* shards. */ - @Override protected GroupShardsIterator shards(IndicesStatusRequest request, String[] concreteIndices, ClusterState clusterState) { + @Override + protected GroupShardsIterator shards(IndicesStatusRequest request, String[] concreteIndices, ClusterState clusterState) { return clusterState.routingTable().allAssignedShardsGrouped(concreteIndices, true); } - @Override protected IndicesStatusResponse newResponse(IndicesStatusRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) { + @Override + protected IndicesStatusResponse newResponse(IndicesStatusRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) { int successfulShards = 0; int failedShards = 0; List shardFailures = null; @@ -118,19 +126,23 @@ public class TransportIndicesStatusAction extends TransportBroadcastOperationAct return new IndicesStatusResponse(shards.toArray(new ShardStatus[shards.size()]), clusterState, shardsResponses.length(), successfulShards, failedShards, shardFailures); } - @Override protected IndexShardStatusRequest newShardRequest() { + @Override + protected IndexShardStatusRequest newShardRequest() { return new IndexShardStatusRequest(); } - @Override protected IndexShardStatusRequest newShardRequest(ShardRouting shard, IndicesStatusRequest request) { + @Override + protected IndexShardStatusRequest newShardRequest(ShardRouting shard, IndicesStatusRequest request) { return new IndexShardStatusRequest(shard.index(), shard.id(), request); } - @Override protected ShardStatus newShardResponse() { + @Override + protected ShardStatus newShardResponse() { return new ShardStatus(); } - @Override protected ShardStatus shardOperation(IndexShardStatusRequest request) throws ElasticSearchException { + @Override + protected ShardStatus shardOperation(IndexShardStatusRequest request) throws ElasticSearchException { InternalIndexService indexService = (InternalIndexService) indicesService.indexServiceSafe(request.index()); InternalIndexShard indexShard = (InternalIndexShard) indexService.shardSafe(request.shardId()); ShardStatus shardStatus = new ShardStatus(indexShard.routingEntry()); @@ -264,13 +276,15 @@ public class TransportIndicesStatusAction extends TransportBroadcastOperationAct snapshot = request.snapshot(); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); recovery = in.readBoolean(); snapshot = in.readBoolean(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeBoolean(recovery); out.writeBoolean(snapshot); diff --git a/src/main/java/org/elasticsearch/action/admin/indices/template/delete/DeleteIndexTemplateRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/template/delete/DeleteIndexTemplateRequest.java index e4d862e758e..07d0e18b33e 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/template/delete/DeleteIndexTemplateRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/template/delete/DeleteIndexTemplateRequest.java @@ -27,13 +27,14 @@ import org.elasticsearch.common.unit.TimeValue; import java.io.IOException; -import static org.elasticsearch.action.Actions.*; -import static org.elasticsearch.common.unit.TimeValue.*; +import static org.elasticsearch.action.Actions.addValidationError; +import static org.elasticsearch.common.unit.TimeValue.readTimeValue; +import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; /** * A request to delete an index template. * - * @author kimchy (shay.banon) + * */ public class DeleteIndexTemplateRequest extends MasterNodeOperationRequest { @@ -51,7 +52,8 @@ public class DeleteIndexTemplateRequest extends MasterNodeOperationRequest { this.name = name; } - @Override public ActionRequestValidationException validate() { + @Override + public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if (name == null) { validationException = addValidationError("name is missing", validationException); @@ -91,13 +93,15 @@ public class DeleteIndexTemplateRequest extends MasterNodeOperationRequest { return timeout(TimeValue.parseTimeValue(timeout, null)); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); name = in.readUTF(); timeout = readTimeValue(in); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeUTF(name); timeout.writeTo(out); diff --git a/src/main/java/org/elasticsearch/action/admin/indices/template/delete/DeleteIndexTemplateResponse.java b/src/main/java/org/elasticsearch/action/admin/indices/template/delete/DeleteIndexTemplateResponse.java index 968b36166ff..d6c56ec8c24 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/template/delete/DeleteIndexTemplateResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/template/delete/DeleteIndexTemplateResponse.java @@ -29,7 +29,7 @@ import java.io.IOException; /** * A response for a delete index template. * - * @author kimchy (shay.banon) + * */ public class DeleteIndexTemplateResponse implements ActionResponse, Streamable { @@ -50,11 +50,13 @@ public class DeleteIndexTemplateResponse implements ActionResponse, Streamable { return acknowledged(); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { acknowledged = in.readBoolean(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(acknowledged); } } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/template/delete/TransportDeleteIndexTemplateAction.java b/src/main/java/org/elasticsearch/action/admin/indices/template/delete/TransportDeleteIndexTemplateAction.java index 89879942987..2ac0a23aa1c 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/template/delete/TransportDeleteIndexTemplateAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/template/delete/TransportDeleteIndexTemplateAction.java @@ -38,50 +38,59 @@ import java.util.concurrent.atomic.AtomicReference; /** * Delete index action. * - * @author kimchy (shay.banon) + * */ public class TransportDeleteIndexTemplateAction extends TransportMasterNodeOperationAction { private final MetaDataIndexTemplateService indexTemplateService; - @Inject public TransportDeleteIndexTemplateAction(Settings settings, TransportService transportService, ClusterService clusterService, - ThreadPool threadPool, MetaDataIndexTemplateService indexTemplateService) { + @Inject + public TransportDeleteIndexTemplateAction(Settings settings, TransportService transportService, ClusterService clusterService, + ThreadPool threadPool, MetaDataIndexTemplateService indexTemplateService) { super(settings, transportService, clusterService, threadPool); this.indexTemplateService = indexTemplateService; } - @Override protected String executor() { + @Override + protected String executor() { return ThreadPool.Names.MANAGEMENT; } - @Override protected String transportAction() { + @Override + protected String transportAction() { return TransportActions.Admin.Indices.DELETE_INDEX_TEMPLATE; } - @Override protected DeleteIndexTemplateRequest newRequest() { + @Override + protected DeleteIndexTemplateRequest newRequest() { return new DeleteIndexTemplateRequest(); } - @Override protected DeleteIndexTemplateResponse newResponse() { + @Override + protected DeleteIndexTemplateResponse newResponse() { return new DeleteIndexTemplateResponse(); } - @Override protected ClusterBlockException checkBlock(DeleteIndexTemplateRequest request, ClusterState state) { + @Override + protected ClusterBlockException checkBlock(DeleteIndexTemplateRequest request, ClusterState state) { return state.blocks().indexBlockedException(ClusterBlockLevel.METADATA, ""); } - @Override protected DeleteIndexTemplateResponse masterOperation(DeleteIndexTemplateRequest request, ClusterState state) throws ElasticSearchException { + @Override + protected DeleteIndexTemplateResponse masterOperation(DeleteIndexTemplateRequest request, ClusterState state) throws ElasticSearchException { final AtomicReference responseRef = new AtomicReference(); final AtomicReference failureRef = new AtomicReference(); final CountDownLatch latch = new CountDownLatch(1); indexTemplateService.removeTemplate(new MetaDataIndexTemplateService.RemoveRequest(request.name()), new MetaDataIndexTemplateService.RemoveListener() { - @Override public void onResponse(MetaDataIndexTemplateService.RemoveResponse response) { + @Override + public void onResponse(MetaDataIndexTemplateService.RemoveResponse response) { responseRef.set(new DeleteIndexTemplateResponse(response.acknowledged())); latch.countDown(); } - @Override public void onFailure(Throwable t) { + @Override + public void onFailure(Throwable t) { failureRef.set(t); latch.countDown(); } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateRequest.java index d2567839d2d..308ab2d0225 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateRequest.java @@ -37,14 +37,15 @@ import java.io.IOException; import java.util.Map; import java.util.concurrent.TimeUnit; -import static org.elasticsearch.action.Actions.*; -import static org.elasticsearch.common.collect.Maps.*; -import static org.elasticsearch.common.settings.ImmutableSettings.Builder.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.elasticsearch.common.unit.TimeValue.*; +import static com.google.common.collect.Maps.newHashMap; +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; +import static org.elasticsearch.common.unit.TimeValue.readTimeValue; /** - * @author kimchy (shay.banon) + * */ public class PutIndexTemplateRequest extends MasterNodeOperationRequest { @@ -74,7 +75,8 @@ public class PutIndexTemplateRequest extends MasterNodeOperationRequest { this.name = name; } - @Override public ActionRequestValidationException validate() { + @Override + public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if (name == null) { validationException = addValidationError("name is missing", validationException); @@ -261,7 +263,8 @@ public class PutIndexTemplateRequest extends MasterNodeOperationRequest { return timeout(TimeValue.parseTimeValue(timeout, null)); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); cause = in.readUTF(); name = in.readUTF(); @@ -276,7 +279,8 @@ public class PutIndexTemplateRequest extends MasterNodeOperationRequest { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeUTF(cause); out.writeUTF(name); diff --git a/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateResponse.java b/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateResponse.java index 591df8b7051..4d7777ee4ec 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateResponse.java @@ -29,7 +29,7 @@ import java.io.IOException; /** * A response for a put index template action. * - * @author kimchy (shay.banon) + * */ public class PutIndexTemplateResponse implements ActionResponse, Streamable { @@ -50,11 +50,13 @@ public class PutIndexTemplateResponse implements ActionResponse, Streamable { return acknowledged(); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { acknowledged = in.readBoolean(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(acknowledged); } } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/template/put/TransportPutIndexTemplateAction.java b/src/main/java/org/elasticsearch/action/admin/indices/template/put/TransportPutIndexTemplateAction.java index fb2cef8f831..4b9d0887fb9 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/template/put/TransportPutIndexTemplateAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/template/put/TransportPutIndexTemplateAction.java @@ -38,39 +38,46 @@ import java.util.concurrent.atomic.AtomicReference; /** * Put index template action. * - * @author kimchy (shay.banon) + * */ public class TransportPutIndexTemplateAction extends TransportMasterNodeOperationAction { private final MetaDataIndexTemplateService indexTemplateService; - @Inject public TransportPutIndexTemplateAction(Settings settings, TransportService transportService, ClusterService clusterService, - ThreadPool threadPool, MetaDataIndexTemplateService indexTemplateService) { + @Inject + public TransportPutIndexTemplateAction(Settings settings, TransportService transportService, ClusterService clusterService, + ThreadPool threadPool, MetaDataIndexTemplateService indexTemplateService) { super(settings, transportService, clusterService, threadPool); this.indexTemplateService = indexTemplateService; } - @Override protected String executor() { + @Override + protected String executor() { return ThreadPool.Names.MANAGEMENT; } - @Override protected String transportAction() { + @Override + protected String transportAction() { return TransportActions.Admin.Indices.PUT_INDEX_TEMPLATE; } - @Override protected PutIndexTemplateRequest newRequest() { + @Override + protected PutIndexTemplateRequest newRequest() { return new PutIndexTemplateRequest(); } - @Override protected PutIndexTemplateResponse newResponse() { + @Override + protected PutIndexTemplateResponse newResponse() { return new PutIndexTemplateResponse(); } - @Override protected ClusterBlockException checkBlock(PutIndexTemplateRequest request, ClusterState state) { + @Override + protected ClusterBlockException checkBlock(PutIndexTemplateRequest request, ClusterState state) { return state.blocks().indexBlockedException(ClusterBlockLevel.METADATA, ""); } - @Override protected PutIndexTemplateResponse masterOperation(PutIndexTemplateRequest request, ClusterState state) throws ElasticSearchException { + @Override + protected PutIndexTemplateResponse masterOperation(PutIndexTemplateRequest request, ClusterState state) throws ElasticSearchException { String cause = request.cause(); if (cause.length() == 0) { cause = "api"; @@ -86,12 +93,14 @@ public class TransportPutIndexTemplateAction extends TransportMasterNodeOperatio .mappings(request.mappings()), new MetaDataIndexTemplateService.PutListener() { - @Override public void onResponse(MetaDataIndexTemplateService.PutResponse response) { + @Override + public void onResponse(MetaDataIndexTemplateService.PutResponse response) { responseRef.set(new PutIndexTemplateResponse(response.acknowledged())); latch.countDown(); } - @Override public void onFailure(Throwable t) { + @Override + public void onFailure(Throwable t) { failureRef.set(t); latch.countDown(); } diff --git a/src/main/java/org/elasticsearch/action/admin/package-info.java b/src/main/java/org/elasticsearch/action/admin/package-info.java index 6611abb3264..71d28c6ae14 100644 --- a/src/main/java/org/elasticsearch/action/admin/package-info.java +++ b/src/main/java/org/elasticsearch/action/admin/package-info.java @@ -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 diff --git a/src/main/java/org/elasticsearch/action/bulk/BulkItemRequest.java b/src/main/java/org/elasticsearch/action/bulk/BulkItemRequest.java index c2ddf4d9ab3..24233054c34 100644 --- a/src/main/java/org/elasticsearch/action/bulk/BulkItemRequest.java +++ b/src/main/java/org/elasticsearch/action/bulk/BulkItemRequest.java @@ -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.Streamable; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class BulkItemRequest implements Streamable { @@ -60,7 +60,8 @@ public class BulkItemRequest implements Streamable { return item; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { id = in.readVInt(); byte type = in.readByte(); if (type == 0) { @@ -71,7 +72,8 @@ public class BulkItemRequest implements Streamable { request.readFrom(in); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeVInt(id); if (request instanceof IndexRequest) { out.writeByte((byte) 0); diff --git a/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java b/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java index d707ad86add..fbbc5edfb1c 100644 --- a/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java +++ b/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java @@ -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,7 +32,7 @@ import java.io.IOException; * Represents a single item response for an action executed as part of the bulk API. Holds the index/type/id * of the relevant action, and if it has failed or not (with the failure message incase it failed). * - * @author kimchy (shay.banon) + * */ public class BulkItemResponse implements Streamable { @@ -287,7 +287,8 @@ public class BulkItemResponse implements Streamable { return response; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { id = in.readVInt(); opType = in.readUTF(); @@ -305,7 +306,8 @@ public class BulkItemResponse implements Streamable { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeVInt(id); out.writeUTF(opType); if (response == null) { diff --git a/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java b/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java index 4ce6c184361..a5a49a7a83e 100644 --- a/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java +++ b/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java @@ -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.bulk; +import com.google.common.collect.Lists; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.WriteConsistencyLevel; @@ -26,7 +27,6 @@ import org.elasticsearch.action.delete.DeleteRequest; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.support.replication.ReplicationType; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.unit.TimeValue; @@ -38,13 +38,13 @@ import org.elasticsearch.index.VersionType; import java.io.IOException; import java.util.List; -import static org.elasticsearch.action.Actions.*; +import static org.elasticsearch.action.Actions.addValidationError; /** * A bulk request holds an ordered {@link IndexRequest}s and {@link DeleteRequest}s and allows to executes * it in a single batch. * - * @author kimchy (shay.banon) + * * @see org.elasticsearch.client.Client#bulk(BulkRequest) */ public class BulkRequest implements ActionRequest { @@ -249,7 +249,8 @@ public class BulkRequest implements ActionRequest { return requests.size(); } - @Override public ActionRequestValidationException validate() { + @Override + public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if (requests.isEmpty()) { validationException = addValidationError("no requests added", validationException); @@ -267,16 +268,19 @@ public class BulkRequest implements ActionRequest { return validationException; } - @Override public boolean listenerThreaded() { + @Override + public boolean listenerThreaded() { return listenerThreaded; } - @Override public BulkRequest listenerThreaded(boolean listenerThreaded) { + @Override + public BulkRequest listenerThreaded(boolean listenerThreaded) { this.listenerThreaded = listenerThreaded; return this; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { replicationType = ReplicationType.fromId(in.readByte()); consistencyLevel = WriteConsistencyLevel.fromId(in.readByte()); int size = in.readVInt(); @@ -295,7 +299,8 @@ public class BulkRequest implements ActionRequest { refresh = in.readBoolean(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeByte(replicationType.id()); out.writeByte(consistencyLevel.id()); out.writeVInt(requests.size()); diff --git a/src/main/java/org/elasticsearch/action/bulk/BulkResponse.java b/src/main/java/org/elasticsearch/action/bulk/BulkResponse.java index 67c2ed2df31..843253581f6 100644 --- a/src/main/java/org/elasticsearch/action/bulk/BulkResponse.java +++ b/src/main/java/org/elasticsearch/action/bulk/BulkResponse.java @@ -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.bulk; +import com.google.common.collect.Iterators; import org.elasticsearch.action.ActionResponse; -import org.elasticsearch.common.collect.Iterators; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.unit.TimeValue; @@ -33,7 +33,7 @@ import java.util.Iterator; * bulk requests. Each item holds the index/type/id is operated on, and if it failed or not (with the * failure message). * - * @author kimchy (shay.banon) + * */ public class BulkResponse implements ActionResponse, Iterable { @@ -110,11 +110,13 @@ public class BulkResponse implements ActionResponse, Iterable return responses; } - @Override public Iterator iterator() { + @Override + public Iterator iterator() { return Iterators.forArray(responses); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { responses = new BulkItemResponse[in.readVInt()]; for (int i = 0; i < responses.length; i++) { responses[i] = BulkItemResponse.readBulkItem(in); @@ -122,7 +124,8 @@ public class BulkResponse implements ActionResponse, Iterable tookInMillis = in.readVLong(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeVInt(responses.length); for (BulkItemResponse response : responses) { response.writeTo(out); diff --git a/src/main/java/org/elasticsearch/action/bulk/BulkShardRequest.java b/src/main/java/org/elasticsearch/action/bulk/BulkShardRequest.java index 0a60ea50a78..b12b4c0ba65 100644 --- a/src/main/java/org/elasticsearch/action/bulk/BulkShardRequest.java +++ b/src/main/java/org/elasticsearch/action/bulk/BulkShardRequest.java @@ -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 BulkShardRequest extends ShardReplicationOperationRequest { @@ -61,13 +61,15 @@ public class BulkShardRequest extends ShardReplicationOperationRequest { /** * Before we fork on a local thread, make sure we copy over the bytes if they are unsafe */ - @Override public void beforeLocalFork() { + @Override + public void beforeLocalFork() { for (BulkItemRequest item : items) { ((ShardReplicationOperationRequest) item.request()).beforeLocalFork(); } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeVInt(shardId); out.writeVInt(items.length); @@ -82,7 +84,8 @@ public class BulkShardRequest extends ShardReplicationOperationRequest { out.writeBoolean(refresh); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); shardId = in.readVInt(); items = new BulkItemRequest[in.readVInt()]; diff --git a/src/main/java/org/elasticsearch/action/bulk/BulkShardResponse.java b/src/main/java/org/elasticsearch/action/bulk/BulkShardResponse.java index e6915221227..f3d5d665d21 100644 --- a/src/main/java/org/elasticsearch/action/bulk/BulkShardResponse.java +++ b/src/main/java/org/elasticsearch/action/bulk/BulkShardResponse.java @@ -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.index.shard.ShardId; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class BulkShardResponse implements ActionResponse { @@ -51,7 +51,8 @@ public class BulkShardResponse implements ActionResponse { return responses; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { shardId = ShardId.readShardId(in); responses = new BulkItemResponse[in.readVInt()]; for (int i = 0; i < responses.length; i++) { @@ -59,7 +60,8 @@ public class BulkShardResponse implements ActionResponse { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { shardId.writeTo(out); out.writeVInt(responses.length); for (BulkItemResponse response : responses) { diff --git a/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java b/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java index c30e7c4670a..84e37db2fcc 100644 --- a/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java +++ b/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java @@ -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,9 @@ package org.elasticsearch.action.bulk; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionRequest; @@ -35,9 +38,6 @@ import org.elasticsearch.cluster.metadata.MappingMetaData; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.routing.GroupShardsIterator; import org.elasticsearch.cluster.routing.ShardIterator; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.collect.Maps; -import org.elasticsearch.common.collect.Sets; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.shard.ShardId; @@ -54,7 +54,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; /** - * @author kimchy (shay.banon) + * */ public class TransportBulkAction extends BaseAction { @@ -68,8 +68,9 @@ public class TransportBulkAction extends BaseAction { private final TransportCreateIndexAction createIndexAction; - @Inject public TransportBulkAction(Settings settings, ThreadPool threadPool, TransportService transportService, ClusterService clusterService, - TransportShardBulkAction shardBulkAction, TransportCreateIndexAction createIndexAction) { + @Inject + public TransportBulkAction(Settings settings, ThreadPool threadPool, TransportService transportService, ClusterService clusterService, + TransportShardBulkAction shardBulkAction, TransportCreateIndexAction createIndexAction) { super(settings, threadPool); this.clusterService = clusterService; this.shardBulkAction = shardBulkAction; @@ -81,7 +82,8 @@ public class TransportBulkAction extends BaseAction { transportService.registerHandler(TransportActions.BULK, new TransportHandler()); } - @Override protected void doExecute(final BulkRequest bulkRequest, final ActionListener listener) { + @Override + protected void doExecute(final BulkRequest bulkRequest, final ActionListener listener) { final long startTime = System.currentTimeMillis(); Set indices = Sets.newHashSet(); for (ActionRequest request : bulkRequest.requests) { @@ -104,13 +106,15 @@ public class TransportBulkAction extends BaseAction { for (String index : indices) { if (!clusterService.state().metaData().hasConcreteIndex(index)) { createIndexAction.execute(new CreateIndexRequest(index).cause("auto(bulk api)"), new ActionListener() { - @Override public void onResponse(CreateIndexResponse result) { + @Override + public void onResponse(CreateIndexResponse result) { if (counter.decrementAndGet() == 0) { executeBulk(bulkRequest, startTime, listener); } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { if (ExceptionsHelper.unwrapCause(e) instanceof IndexAlreadyExistsException) { // we have the index, do it if (counter.decrementAndGet() == 0) { @@ -206,7 +210,8 @@ public class TransportBulkAction extends BaseAction { bulkShardRequest.replicationType(bulkRequest.replicationType()); bulkShardRequest.consistencyLevel(bulkRequest.consistencyLevel()); shardBulkAction.execute(bulkShardRequest, new ActionListener() { - @Override public void onResponse(BulkShardResponse bulkShardResponse) { + @Override + public void onResponse(BulkShardResponse bulkShardResponse) { synchronized (responses) { for (BulkItemResponse bulkItemResponse : bulkShardResponse.responses()) { responses[bulkItemResponse.itemId()] = bulkItemResponse; @@ -217,7 +222,8 @@ public class TransportBulkAction extends BaseAction { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { // create failures for all relevant requests String message = ExceptionsHelper.detailedMessage(e); synchronized (responses) { @@ -247,15 +253,18 @@ public class TransportBulkAction extends BaseAction { class TransportHandler extends BaseTransportRequestHandler { - @Override public BulkRequest newInstance() { + @Override + public BulkRequest newInstance() { return new BulkRequest(); } - @Override public void messageReceived(final BulkRequest request, final TransportChannel channel) throws Exception { + @Override + public void messageReceived(final BulkRequest request, final TransportChannel channel) throws Exception { // no need to use threaded listener, since we just send a response request.listenerThreaded(false); execute(request, new ActionListener() { - @Override public void onResponse(BulkResponse result) { + @Override + public void onResponse(BulkResponse result) { try { channel.sendResponse(result); } catch (Exception e) { @@ -263,7 +272,8 @@ public class TransportBulkAction extends BaseAction { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(e); } catch (Exception e1) { @@ -273,7 +283,8 @@ public class TransportBulkAction extends BaseAction { }); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } } diff --git a/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java b/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java index 77aa7ad2b81..d639d1407ca 100644 --- a/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java +++ b/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java @@ -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 @@ -56,57 +56,68 @@ import java.io.IOException; /** * Performs the index operation. * - * @author kimchy (shay.banon) + * */ public class TransportShardBulkAction extends TransportShardReplicationOperationAction { private final MappingUpdatedAction mappingUpdatedAction; - @Inject public TransportShardBulkAction(Settings settings, TransportService transportService, ClusterService clusterService, - IndicesService indicesService, ThreadPool threadPool, ShardStateAction shardStateAction, - MappingUpdatedAction mappingUpdatedAction) { + @Inject + public TransportShardBulkAction(Settings settings, TransportService transportService, ClusterService clusterService, + IndicesService indicesService, ThreadPool threadPool, ShardStateAction shardStateAction, + MappingUpdatedAction mappingUpdatedAction) { super(settings, transportService, clusterService, indicesService, threadPool, shardStateAction); this.mappingUpdatedAction = mappingUpdatedAction; } - @Override protected String executor() { + @Override + protected String executor() { return ThreadPool.Names.INDEX; } - @Override protected boolean checkWriteConsistency() { + @Override + protected boolean checkWriteConsistency() { return true; } - @Override protected TransportRequestOptions transportOptions() { + @Override + protected TransportRequestOptions transportOptions() { // low type since we don't want the large bulk requests to cause high latency on typical requests return TransportRequestOptions.options().withCompress(true).withLowType(); } - @Override protected BulkShardRequest newRequestInstance() { + @Override + protected BulkShardRequest newRequestInstance() { return new BulkShardRequest(); } - @Override protected BulkShardRequest newReplicaRequestInstance() { + @Override + protected BulkShardRequest newReplicaRequestInstance() { return new BulkShardRequest(); } - @Override protected BulkShardResponse newResponseInstance() { + @Override + protected BulkShardResponse newResponseInstance() { return new BulkShardResponse(); } - @Override protected String transportAction() { + @Override + protected String transportAction() { return "indices/index/shard/bulk"; } - @Override protected void checkBlock(BulkShardRequest request, ClusterState state) { + @Override + protected void checkBlock(BulkShardRequest request, ClusterState state) { state.blocks().indexBlockedRaiseException(ClusterBlockLevel.WRITE, request.index()); } - @Override protected ShardIterator shards(ClusterState clusterState, BulkShardRequest request) { + @Override + protected ShardIterator shards(ClusterState clusterState, BulkShardRequest request) { return clusterState.routingTable().index(request.index()).shard(request.shardId()).shardsIt(); } - @Override protected PrimaryResponse shardOperationOnPrimary(ClusterState clusterState, PrimaryOperationRequest shardRequest) { + @Override + protected PrimaryResponse shardOperationOnPrimary(ClusterState clusterState, PrimaryOperationRequest shardRequest) { final BulkShardRequest request = shardRequest.request; IndexShard indexShard = indicesService.indexServiceSafe(shardRequest.request.index()).shardSafe(shardRequest.shardId); @@ -209,7 +220,8 @@ public class TransportShardBulkAction extends TransportShardReplicationOperation return new PrimaryResponse(shardRequest.request, response, ops); } - @Override protected void postPrimaryOperation(BulkShardRequest request, PrimaryResponse response) { + @Override + protected void postPrimaryOperation(BulkShardRequest request, PrimaryResponse response) { IndexService indexService = indicesService.indexServiceSafe(request.index()); Engine.IndexingOperation[] ops = (Engine.IndexingOperation[]) response.payload(); if (ops == null) { @@ -241,7 +253,8 @@ public class TransportShardBulkAction extends TransportShardReplicationOperation } } - @Override protected void shardOperationOnReplica(ReplicaOperationRequest shardRequest) { + @Override + protected void shardOperationOnReplica(ReplicaOperationRequest shardRequest) { IndexShard indexShard = indicesService.indexServiceSafe(shardRequest.request.index()).shardSafe(shardRequest.shardId); final BulkShardRequest request = shardRequest.request; for (int i = 0; i < request.items().length; i++) { @@ -295,11 +308,13 @@ public class TransportShardBulkAction extends TransportShardReplicationOperation documentMapper.refreshSource(); mappingUpdatedAction.execute(new MappingUpdatedAction.MappingUpdatedRequest(request.index(), request.type(), documentMapper.mappingSource()), new ActionListener() { - @Override public void onResponse(MappingUpdatedAction.MappingUpdatedResponse mappingUpdatedResponse) { + @Override + public void onResponse(MappingUpdatedAction.MappingUpdatedResponse mappingUpdatedResponse) { // all is well } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { logger.warn("Failed to update master on updated mapping for index [" + request.index() + "], type [" + request.type() + "] and source [" + documentMapper.mappingSource().string() + "]", e); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/action/count/CountRequest.java b/src/main/java/org/elasticsearch/action/count/CountRequest.java index d2bf0424768..4a352aaef8e 100644 --- a/src/main/java/org/elasticsearch/action/count/CountRequest.java +++ b/src/main/java/org/elasticsearch/action/count/CountRequest.java @@ -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 @@ -44,11 +44,11 @@ import java.util.Map; /** * A request to count the number of documents matching a specific query. Best created with * {@link org.elasticsearch.client.Requests#countRequest(String...)}. - * + *

*

The request requires the query source to be set either using {@link #query(org.elasticsearch.index.query.QueryBuilder)}, * or {@link #query(byte[])}. * - * @author kimchy (shay.banon) + * * @see CountResponse * @see org.elasticsearch.client.Client#count(CountRequest) * @see org.elasticsearch.client.Requests#countRequest(String...) @@ -61,8 +61,10 @@ public class CountRequest extends BroadcastOperationRequest { private float minScore = DEFAULT_MIN_SCORE; - @Nullable protected String queryHint; - @Nullable protected String routing; + @Nullable + protected String queryHint; + @Nullable + protected String routing; private byte[] querySource; private int querySourceOffset; @@ -83,7 +85,8 @@ public class CountRequest extends BroadcastOperationRequest { this.queryHint = null; } - @Override public ActionRequestValidationException validate() { + @Override + public ActionRequestValidationException validate() { ActionRequestValidationException validationException = super.validate(); return validationException; } @@ -95,12 +98,14 @@ public class CountRequest extends BroadcastOperationRequest { /** * Controls the operation threading model. */ - @Override public CountRequest operationThreading(BroadcastOperationThreading operationThreading) { + @Override + public CountRequest operationThreading(BroadcastOperationThreading operationThreading) { super.operationThreading(operationThreading); return this; } - @Override protected void beforeStart() { + @Override + protected void beforeStart() { if (querySourceUnsafe) { querySource = Arrays.copyOfRange(querySource, querySourceOffset, querySourceOffset + querySourceLength); querySourceOffset = 0; @@ -111,7 +116,8 @@ public class CountRequest extends BroadcastOperationRequest { /** * Should the listener be called on a separate thread if needed. */ - @Override public CountRequest listenerThreaded(boolean threadedListener) { + @Override + public CountRequest listenerThreaded(boolean threadedListener) { super.listenerThreaded(threadedListener); return this; } @@ -165,7 +171,8 @@ public class CountRequest extends BroadcastOperationRequest { * * @see org.elasticsearch.index.query.QueryBuilders */ - @Required public CountRequest query(QueryBuilder queryBuilder) { + @Required + public CountRequest query(QueryBuilder queryBuilder) { BytesStream bos = queryBuilder.buildAsUnsafeBytes(); this.querySource = bos.underlyingBytes(); this.querySourceOffset = 0; @@ -177,7 +184,8 @@ public class CountRequest extends BroadcastOperationRequest { /** * The query source to execute in the form of a map. */ - @Required public CountRequest query(Map querySource) { + @Required + public CountRequest query(Map querySource) { try { XContentBuilder builder = XContentFactory.contentBuilder(contentType); builder.map(querySource); @@ -187,7 +195,8 @@ public class CountRequest extends BroadcastOperationRequest { } } - @Required public CountRequest query(XContentBuilder builder) { + @Required + public CountRequest query(XContentBuilder builder) { try { this.querySource = builder.underlyingBytes(); this.querySourceOffset = 0; @@ -203,7 +212,8 @@ public class CountRequest extends BroadcastOperationRequest { * The query source to execute. It is preferable to use either {@link #query(byte[])} * or {@link #query(org.elasticsearch.index.query.QueryBuilder)}. */ - @Required public CountRequest query(String querySource) { + @Required + public CountRequest query(String querySource) { UnicodeUtil.UTF8Result result = Unicode.fromStringAsUtf8(querySource); this.querySource = result.result; this.querySourceOffset = 0; @@ -215,14 +225,16 @@ public class CountRequest extends BroadcastOperationRequest { /** * The query source to execute. */ - @Required public CountRequest query(byte[] querySource) { + @Required + public CountRequest query(byte[] querySource) { return query(querySource, 0, querySource.length, false); } /** * The query source to execute. */ - @Required public CountRequest query(byte[] querySource, int offset, int length, boolean unsafe) { + @Required + public CountRequest query(byte[] querySource, int offset, int length, boolean unsafe) { this.querySource = querySource; this.querySourceOffset = offset; this.querySourceLength = length; @@ -268,7 +280,8 @@ public class CountRequest extends BroadcastOperationRequest { return this; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); minScore = in.readFloat(); @@ -294,7 +307,8 @@ public class CountRequest extends BroadcastOperationRequest { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeFloat(minScore); @@ -320,7 +334,8 @@ public class CountRequest extends BroadcastOperationRequest { } } - @Override public String toString() { + @Override + public String toString() { return "[" + Arrays.toString(indices) + "]" + Arrays.toString(types) + ", querySource[" + Unicode.fromBytes(querySource) + "]"; } } diff --git a/src/main/java/org/elasticsearch/action/count/CountResponse.java b/src/main/java/org/elasticsearch/action/count/CountResponse.java index 5402dd2cfb7..dcc80157ec0 100644 --- a/src/main/java/org/elasticsearch/action/count/CountResponse.java +++ b/src/main/java/org/elasticsearch/action/count/CountResponse.java @@ -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.List; /** * The response of the count action. * - * @author kimchy (shay.banon) + * */ public class CountResponse extends BroadcastOperationResponse { @@ -59,12 +59,14 @@ public class CountResponse extends BroadcastOperationResponse { return count; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); count = in.readVLong(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeVLong(count); } diff --git a/src/main/java/org/elasticsearch/action/count/ShardCountRequest.java b/src/main/java/org/elasticsearch/action/count/ShardCountRequest.java index 0fd2a1be5d6..6aa5f7569bf 100644 --- a/src/main/java/org/elasticsearch/action/count/ShardCountRequest.java +++ b/src/main/java/org/elasticsearch/action/count/ShardCountRequest.java @@ -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.io.IOException; /** * Internal count request executed directly against a specific index shard. * - * @author kimchy (shay.banon) + * */ class ShardCountRequest extends BroadcastShardOperationRequest { @@ -42,7 +42,8 @@ class ShardCountRequest extends BroadcastShardOperationRequest { private String[] types = Strings.EMPTY_ARRAY; - @Nullable private String[] filteringAliases; + @Nullable + private String[] filteringAliases; ShardCountRequest() { @@ -82,7 +83,8 @@ class ShardCountRequest extends BroadcastShardOperationRequest { return filteringAliases; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); minScore = in.readFloat(); querySourceLength = in.readVInt(); @@ -105,7 +107,8 @@ class ShardCountRequest extends BroadcastShardOperationRequest { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeFloat(minScore); out.writeVInt(querySourceLength); diff --git a/src/main/java/org/elasticsearch/action/count/ShardCountResponse.java b/src/main/java/org/elasticsearch/action/count/ShardCountResponse.java index d5a8217bed4..6f7a6a939d3 100644 --- a/src/main/java/org/elasticsearch/action/count/ShardCountResponse.java +++ b/src/main/java/org/elasticsearch/action/count/ShardCountResponse.java @@ -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; /** * Internal count response of a shard count request executed directly against a specific shard. * - * @author kimchy (shay.banon) + * */ class ShardCountResponse extends BroadcastShardOperationResponse { @@ -47,12 +47,14 @@ class ShardCountResponse extends BroadcastShardOperationResponse { return this.count; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); count = in.readVLong(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeVLong(count); } diff --git a/src/main/java/org/elasticsearch/action/count/TransportCountAction.java b/src/main/java/org/elasticsearch/action/count/TransportCountAction.java index f9d8dc8b1d7..117730cae4c 100644 --- a/src/main/java/org/elasticsearch/action/count/TransportCountAction.java +++ b/src/main/java/org/elasticsearch/action/count/TransportCountAction.java @@ -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 @@ -42,61 +42,72 @@ import java.util.Map; import java.util.Set; 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 TransportCountAction extends TransportBroadcastOperationAction { private final IndicesService indicesService; - @Inject public TransportCountAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, IndicesService indicesService) { + @Inject + public TransportCountAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, IndicesService indicesService) { super(settings, threadPool, clusterService, transportService); this.indicesService = indicesService; } - @Override protected String executor() { + @Override + protected String executor() { return ThreadPool.Names.SEARCH; } - @Override protected String transportAction() { + @Override + protected String transportAction() { return TransportActions.COUNT; } - @Override protected String transportShardAction() { + @Override + protected String transportShardAction() { return "indices/count/shard"; } - @Override protected CountRequest newRequest() { + @Override + protected CountRequest newRequest() { return new CountRequest(); } - @Override protected ShardCountRequest newShardRequest() { + @Override + protected ShardCountRequest newShardRequest() { return new ShardCountRequest(); } - @Override protected ShardCountRequest newShardRequest(ShardRouting shard, CountRequest request) { + @Override + protected ShardCountRequest newShardRequest(ShardRouting shard, CountRequest request) { String[] filteringAliases = clusterService.state().metaData().filteringAliases(shard.index(), request.indices()); return new ShardCountRequest(shard.index(), shard.id(), filteringAliases, request); } - @Override protected ShardCountResponse newShardResponse() { + @Override + protected ShardCountResponse newShardResponse() { return new ShardCountResponse(); } - @Override protected GroupShardsIterator shards(CountRequest request, String[] concreteIndices, ClusterState clusterState) { + @Override + protected GroupShardsIterator shards(CountRequest request, String[] concreteIndices, ClusterState clusterState) { Map> routingMap = clusterState.metaData().resolveSearchRouting(request.routing(), request.indices()); return clusterService.operationRouting().searchShards(clusterState, request.indices(), concreteIndices, request.queryHint(), routingMap, null); } - @Override protected void checkBlock(CountRequest request, String[] concreteIndices, ClusterState state) { + @Override + protected void checkBlock(CountRequest request, String[] concreteIndices, ClusterState state) { for (String index : concreteIndices) { state.blocks().indexBlocked(ClusterBlockLevel.READ, index); } } - @Override protected CountResponse newResponse(CountRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) { + @Override + protected CountResponse newResponse(CountRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) { int successfulShards = 0; int failedShards = 0; long count = 0; @@ -119,7 +130,8 @@ public class TransportCountAction extends TransportBroadcastOperationAction *

The operation requires the {@link #index()}, {@link #type(String)} and {@link #id(String)} to * be set. * - * @author kimchy (shay.banon) + * * @see DeleteResponse * @see org.elasticsearch.client.Client#delete(DeleteRequest) * @see org.elasticsearch.client.Requests#deleteRequest(String) @@ -50,7 +50,8 @@ public class DeleteRequest extends ShardReplicationOperationRequest { private String type; private String id; - @Nullable private String routing; + @Nullable + private String routing; private boolean refresh; private long version; private VersionType versionType = VersionType.INTERNAL; @@ -79,7 +80,8 @@ public class DeleteRequest extends ShardReplicationOperationRequest { public DeleteRequest() { } - @Override public ActionRequestValidationException validate() { + @Override + public ActionRequestValidationException validate() { ActionRequestValidationException validationException = super.validate(); if (type == null) { validationException = addValidationError("type is missing", validationException); @@ -93,7 +95,8 @@ public class DeleteRequest extends ShardReplicationOperationRequest { /** * Sets the index the delete will happen on. */ - @Override public DeleteRequest index(String index) { + @Override + public DeleteRequest index(String index) { super.index(index); return this; } @@ -101,7 +104,8 @@ public class DeleteRequest extends ShardReplicationOperationRequest { /** * Should the listener be called on a separate thread if needed. */ - @Override public DeleteRequest listenerThreaded(boolean threadedListener) { + @Override + public DeleteRequest listenerThreaded(boolean threadedListener) { super.listenerThreaded(threadedListener); return this; } @@ -110,7 +114,8 @@ public class DeleteRequest extends ShardReplicationOperationRequest { * Controls if the operation will be executed on a separate thread when executed locally. Defaults * to true when running in embedded mode. */ - @Override public DeleteRequest operationThreaded(boolean threadedOperation) { + @Override + public DeleteRequest operationThreaded(boolean threadedOperation) { super.operationThreaded(threadedOperation); return this; } @@ -118,7 +123,8 @@ public class DeleteRequest extends ShardReplicationOperationRequest { /** * Set the replication type for this operation. */ - @Override public DeleteRequest replicationType(ReplicationType replicationType) { + @Override + public DeleteRequest replicationType(ReplicationType replicationType) { super.replicationType(replicationType); return this; } @@ -126,7 +132,8 @@ public class DeleteRequest extends ShardReplicationOperationRequest { /** * Sets the consistency level of write. Defaults to {@link org.elasticsearch.action.WriteConsistencyLevel#DEFAULT} */ - @Override public DeleteRequest consistencyLevel(WriteConsistencyLevel consistencyLevel) { + @Override + public DeleteRequest consistencyLevel(WriteConsistencyLevel consistencyLevel) { super.consistencyLevel(consistencyLevel); return this; } @@ -141,7 +148,8 @@ public class DeleteRequest extends ShardReplicationOperationRequest { /** * Sets the type of the document to delete. */ - @Required public DeleteRequest type(String type) { + @Required + public DeleteRequest type(String type) { this.type = type; return this; } @@ -156,7 +164,8 @@ public class DeleteRequest extends ShardReplicationOperationRequest { /** * Sets the id of the document to delete. */ - @Required public DeleteRequest id(String id) { + @Required + public DeleteRequest id(String id) { this.id = id; return this; } @@ -237,7 +246,8 @@ public class DeleteRequest extends ShardReplicationOperationRequest { return this.versionType; } - @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(); @@ -249,7 +259,8 @@ public class DeleteRequest extends ShardReplicationOperationRequest { versionType = VersionType.fromValue(in.readByte()); } - @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); @@ -264,7 +275,8 @@ public class DeleteRequest extends ShardReplicationOperationRequest { out.writeByte(versionType.getValue()); } - @Override public String toString() { + @Override + public String toString() { return "delete {[" + index + "][" + type + "][" + id + "]}"; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/action/delete/DeleteResponse.java b/src/main/java/org/elasticsearch/action/delete/DeleteResponse.java index 2980d42efa8..cef5fa62306 100644 --- a/src/main/java/org/elasticsearch/action/delete/DeleteResponse.java +++ b/src/main/java/org/elasticsearch/action/delete/DeleteResponse.java @@ -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.io.IOException; /** * The response of the delete action. * - * @author kimchy (shay.banon) + * * @see org.elasticsearch.action.delete.DeleteRequest * @see org.elasticsearch.client.Client#delete(DeleteRequest) */ @@ -127,7 +127,8 @@ public class DeleteResponse implements ActionResponse, Streamable { return notFound; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { index = in.readUTF(); id = in.readUTF(); type = in.readUTF(); @@ -135,7 +136,8 @@ public class DeleteResponse implements ActionResponse, Streamable { notFound = in.readBoolean(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(index); out.writeUTF(id); out.writeUTF(type); diff --git a/src/main/java/org/elasticsearch/action/delete/TransportDeleteAction.java b/src/main/java/org/elasticsearch/action/delete/TransportDeleteAction.java index b91bbfa1791..a67e90b2388 100644 --- a/src/main/java/org/elasticsearch/action/delete/TransportDeleteAction.java +++ b/src/main/java/org/elasticsearch/action/delete/TransportDeleteAction.java @@ -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 @@ -48,7 +48,7 @@ import org.elasticsearch.transport.TransportService; /** * Performs the delete operation. * - * @author kimchy (shay.banon) + * */ public class TransportDeleteAction extends TransportShardReplicationOperationAction { @@ -58,28 +58,33 @@ public class TransportDeleteAction extends TransportShardReplicationOperationAct private final TransportIndexDeleteAction indexDeleteAction; - @Inject public TransportDeleteAction(Settings settings, TransportService transportService, ClusterService clusterService, - IndicesService indicesService, ThreadPool threadPool, ShardStateAction shardStateAction, - TransportCreateIndexAction createIndexAction, TransportIndexDeleteAction indexDeleteAction) { + @Inject + public TransportDeleteAction(Settings settings, TransportService transportService, ClusterService clusterService, + IndicesService indicesService, ThreadPool threadPool, ShardStateAction shardStateAction, + TransportCreateIndexAction createIndexAction, TransportIndexDeleteAction indexDeleteAction) { super(settings, transportService, clusterService, indicesService, threadPool, shardStateAction); this.createIndexAction = createIndexAction; this.indexDeleteAction = indexDeleteAction; this.autoCreateIndex = settings.getAsBoolean("action.auto_create_index", true); } - @Override protected String executor() { + @Override + protected String executor() { return ThreadPool.Names.INDEX; } - @Override protected void doExecute(final DeleteRequest request, final ActionListener listener) { + @Override + protected void doExecute(final DeleteRequest request, final ActionListener listener) { if (autoCreateIndex && !clusterService.state().metaData().hasConcreteIndex(request.index())) { request.beforeLocalFork(); createIndexAction.execute(new CreateIndexRequest(request.index()), new ActionListener() { - @Override public void onResponse(CreateIndexResponse result) { + @Override + public void onResponse(CreateIndexResponse result) { innerExecute(request, listener); } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { if (ExceptionsHelper.unwrapCause(e) instanceof IndexAlreadyExistsException) { // we have the index, do it innerExecute(request, listener); @@ -103,7 +108,8 @@ public class TransportDeleteAction extends TransportShardReplicationOperationAct if (mappingMd != null && mappingMd.routing().required()) { if (request.routing() == null) { indexDeleteAction.execute(new IndexDeleteRequest(request), new ActionListener() { - @Override public void onResponse(IndexDeleteResponse indexDeleteResponse) { + @Override + public void onResponse(IndexDeleteResponse indexDeleteResponse) { // go over the response, see if we have found one, and the version if found long version = 0; boolean found = false; @@ -117,7 +123,8 @@ public class TransportDeleteAction extends TransportShardReplicationOperationAct listener.onResponse(new DeleteResponse(request.index(), request.type(), request.id(), version, !found)); } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { listener.onFailure(e); } }); @@ -128,31 +135,38 @@ public class TransportDeleteAction extends TransportShardReplicationOperationAct super.doExecute(request, listener); } - @Override protected boolean checkWriteConsistency() { + @Override + protected boolean checkWriteConsistency() { return true; } - @Override protected DeleteRequest newRequestInstance() { + @Override + protected DeleteRequest newRequestInstance() { return new DeleteRequest(); } - @Override protected DeleteRequest newReplicaRequestInstance() { + @Override + protected DeleteRequest newReplicaRequestInstance() { return new DeleteRequest(); } - @Override protected DeleteResponse newResponseInstance() { + @Override + protected DeleteResponse newResponseInstance() { return new DeleteResponse(); } - @Override protected String transportAction() { + @Override + protected String transportAction() { return TransportActions.DELETE; } - @Override protected void checkBlock(DeleteRequest request, ClusterState state) { + @Override + protected void checkBlock(DeleteRequest request, ClusterState state) { state.blocks().indexBlockedRaiseException(ClusterBlockLevel.WRITE, request.index()); } - @Override protected PrimaryResponse shardOperationOnPrimary(ClusterState clusterState, PrimaryOperationRequest shardRequest) { + @Override + protected PrimaryResponse shardOperationOnPrimary(ClusterState clusterState, PrimaryOperationRequest shardRequest) { DeleteRequest request = shardRequest.request; IndexShard indexShard = indicesService.indexServiceSafe(shardRequest.request.index()).shardSafe(shardRequest.shardId); Engine.Delete delete = indexShard.prepareDelete(request.type(), request.id(), request.version()) @@ -174,7 +188,8 @@ public class TransportDeleteAction extends TransportShardReplicationOperationAct return new PrimaryResponse(shardRequest.request, response, null); } - @Override protected void shardOperationOnReplica(ReplicaOperationRequest shardRequest) { + @Override + protected void shardOperationOnReplica(ReplicaOperationRequest shardRequest) { DeleteRequest request = shardRequest.request; IndexShard indexShard = indicesService.indexServiceSafe(shardRequest.request.index()).shardSafe(shardRequest.shardId); Engine.Delete delete = indexShard.prepareDelete(request.type(), request.id(), request.version()) @@ -192,7 +207,8 @@ public class TransportDeleteAction extends TransportShardReplicationOperationAct } - @Override protected ShardIterator shards(ClusterState clusterState, DeleteRequest request) { + @Override + protected ShardIterator shards(ClusterState clusterState, DeleteRequest request) { return clusterService.operationRouting() .deleteShards(clusterService.state(), request.index(), request.type(), request.id(), request.routing()); } diff --git a/src/main/java/org/elasticsearch/action/delete/index/IndexDeleteRequest.java b/src/main/java/org/elasticsearch/action/delete/index/IndexDeleteRequest.java index 9f6907920bf..f5b2d1e56b8 100644 --- a/src/main/java/org/elasticsearch/action/delete/index/IndexDeleteRequest.java +++ b/src/main/java/org/elasticsearch/action/delete/index/IndexDeleteRequest.java @@ -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 IndexDeleteRequest extends IndexReplicationOperationRequest { @@ -69,7 +69,8 @@ public class IndexDeleteRequest extends IndexReplicationOperationRequest { return this.version; } - @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(); @@ -77,7 +78,8 @@ public class IndexDeleteRequest extends IndexReplicationOperationRequest { version = in.readLong(); } - @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); diff --git a/src/main/java/org/elasticsearch/action/delete/index/IndexDeleteResponse.java b/src/main/java/org/elasticsearch/action/delete/index/IndexDeleteResponse.java index 3acdf581f25..264e49957c7 100644 --- a/src/main/java/org/elasticsearch/action/delete/index/IndexDeleteResponse.java +++ b/src/main/java/org/elasticsearch/action/delete/index/IndexDeleteResponse.java @@ -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.io.IOException; /** * Delete by query response executed on a specific index. * - * @author kimchy (shay.banon) + * */ public class IndexDeleteResponse implements ActionResponse, Streamable { @@ -112,7 +112,8 @@ public class IndexDeleteResponse implements ActionResponse, Streamable { return this.deleteResponses; } - @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(); @@ -123,7 +124,8 @@ public class IndexDeleteResponse implements ActionResponse, Streamable { } } - @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); diff --git a/src/main/java/org/elasticsearch/action/delete/index/ShardDeleteRequest.java b/src/main/java/org/elasticsearch/action/delete/index/ShardDeleteRequest.java index d1d7da50128..1a98942b571 100644 --- a/src/main/java/org/elasticsearch/action/delete/index/ShardDeleteRequest.java +++ b/src/main/java/org/elasticsearch/action/delete/index/ShardDeleteRequest.java @@ -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.io.stream.StreamOutput; import java.io.IOException; -import static org.elasticsearch.action.Actions.*; +import static org.elasticsearch.action.Actions.addValidationError; /** * Delete by query request to execute on a specific shard. * - * @author kimchy (shay.banon) + * */ public class ShardDeleteRequest extends ShardReplicationOperationRequest { @@ -56,7 +56,8 @@ public class ShardDeleteRequest extends ShardReplicationOperationRequest { ShardDeleteRequest() { } - @Override public ActionRequestValidationException validate() { + @Override + public ActionRequestValidationException validate() { ActionRequestValidationException validationException = super.validate(); if (type == null) { addValidationError("type is missing", validationException); @@ -91,7 +92,8 @@ public class ShardDeleteRequest extends ShardReplicationOperationRequest { return this.version; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); shardId = in.readVInt(); type = in.readUTF(); @@ -100,7 +102,8 @@ public class ShardDeleteRequest extends ShardReplicationOperationRequest { version = in.readLong(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeVInt(shardId); out.writeUTF(type); diff --git a/src/main/java/org/elasticsearch/action/delete/index/ShardDeleteResponse.java b/src/main/java/org/elasticsearch/action/delete/index/ShardDeleteResponse.java index b42ad1be57f..8536e2caba4 100644 --- a/src/main/java/org/elasticsearch/action/delete/index/ShardDeleteResponse.java +++ b/src/main/java/org/elasticsearch/action/delete/index/ShardDeleteResponse.java @@ -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.io.IOException; /** * Delete response executed on a specific shard. * - * @author kimchy (shay.banon) + * */ public class ShardDeleteResponse implements ActionResponse, Streamable { @@ -53,12 +53,14 @@ public class ShardDeleteResponse implements ActionResponse, Streamable { return notFound; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { version = in.readLong(); notFound = in.readBoolean(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeLong(version); out.writeBoolean(notFound); } diff --git a/src/main/java/org/elasticsearch/action/delete/index/TransportIndexDeleteAction.java b/src/main/java/org/elasticsearch/action/delete/index/TransportIndexDeleteAction.java index ff691c6a355..c0fb6dc4e1f 100644 --- a/src/main/java/org/elasticsearch/action/delete/index/TransportIndexDeleteAction.java +++ b/src/main/java/org/elasticsearch/action/delete/index/TransportIndexDeleteAction.java @@ -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,20 +33,23 @@ import java.util.ArrayList; import java.util.concurrent.atomic.AtomicReferenceArray; /** - * @author kimchy (shay.banon) + * */ public class TransportIndexDeleteAction extends TransportIndexReplicationOperationAction { - @Inject public TransportIndexDeleteAction(Settings settings, ClusterService clusterService, TransportService transportService, - ThreadPool threadPool, TransportShardDeleteAction deleteAction) { + @Inject + public TransportIndexDeleteAction(Settings settings, ClusterService clusterService, TransportService transportService, + ThreadPool threadPool, TransportShardDeleteAction deleteAction) { super(settings, transportService, clusterService, threadPool, deleteAction); } - @Override protected IndexDeleteRequest newRequestInstance() { + @Override + protected IndexDeleteRequest newRequestInstance() { return new IndexDeleteRequest(); } - @Override protected IndexDeleteResponse newResponseInstance(IndexDeleteRequest request, AtomicReferenceArray shardsResponses) { + @Override + protected IndexDeleteResponse newResponseInstance(IndexDeleteRequest request, AtomicReferenceArray shardsResponses) { int successfulShards = 0; int failedShards = 0; ArrayList responses = new ArrayList(); @@ -61,23 +64,28 @@ public class TransportIndexDeleteAction extends TransportIndexReplicationOperati return new IndexDeleteResponse(request.index(), successfulShards, failedShards, responses.toArray(new ShardDeleteResponse[responses.size()])); } - @Override protected boolean accumulateExceptions() { + @Override + protected boolean accumulateExceptions() { return false; } - @Override protected String transportAction() { + @Override + protected String transportAction() { return "indices/index/delete"; } - @Override protected void checkBlock(IndexDeleteRequest request, ClusterState state) { + @Override + protected void checkBlock(IndexDeleteRequest request, ClusterState state) { state.blocks().indexBlockedRaiseException(ClusterBlockLevel.WRITE, request.index()); } - @Override protected GroupShardsIterator shards(IndexDeleteRequest request) { + @Override + protected GroupShardsIterator shards(IndexDeleteRequest request) { return clusterService.operationRouting().broadcastDeleteShards(clusterService.state(), request.index()); } - @Override protected ShardDeleteRequest newShardRequestInstance(IndexDeleteRequest request, int shardId) { + @Override + protected ShardDeleteRequest newShardRequestInstance(IndexDeleteRequest request, int shardId) { return new ShardDeleteRequest(request, shardId); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/action/delete/index/TransportShardDeleteAction.java b/src/main/java/org/elasticsearch/action/delete/index/TransportShardDeleteAction.java index 57e89a53ec1..9a0c016e8b1 100644 --- a/src/main/java/org/elasticsearch/action/delete/index/TransportShardDeleteAction.java +++ b/src/main/java/org/elasticsearch/action/delete/index/TransportShardDeleteAction.java @@ -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,45 +36,54 @@ import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (Shay Banon) + * */ public class TransportShardDeleteAction extends TransportShardReplicationOperationAction { - @Inject public TransportShardDeleteAction(Settings settings, TransportService transportService, - ClusterService clusterService, IndicesService indicesService, ThreadPool threadPool, - ShardStateAction shardStateAction) { + @Inject + public TransportShardDeleteAction(Settings settings, TransportService transportService, + ClusterService clusterService, IndicesService indicesService, ThreadPool threadPool, + ShardStateAction shardStateAction) { super(settings, transportService, clusterService, indicesService, threadPool, shardStateAction); } - @Override protected boolean checkWriteConsistency() { + @Override + protected boolean checkWriteConsistency() { return true; } - @Override protected ShardDeleteRequest newRequestInstance() { + @Override + protected ShardDeleteRequest newRequestInstance() { return new ShardDeleteRequest(); } - @Override protected ShardDeleteRequest newReplicaRequestInstance() { + @Override + protected ShardDeleteRequest newReplicaRequestInstance() { return new ShardDeleteRequest(); } - @Override protected ShardDeleteResponse newResponseInstance() { + @Override + protected ShardDeleteResponse newResponseInstance() { return new ShardDeleteResponse(); } - @Override protected String transportAction() { + @Override + protected String transportAction() { return "indices/index/b_shard/delete"; } - @Override protected String executor() { + @Override + protected String executor() { return ThreadPool.Names.INDEX; } - @Override protected void checkBlock(ShardDeleteRequest request, ClusterState state) { + @Override + protected void checkBlock(ShardDeleteRequest request, ClusterState state) { state.blocks().indexBlockedRaiseException(ClusterBlockLevel.WRITE, request.index()); } - @Override protected PrimaryResponse shardOperationOnPrimary(ClusterState clusterState, PrimaryOperationRequest shardRequest) { + @Override + protected PrimaryResponse shardOperationOnPrimary(ClusterState clusterState, PrimaryOperationRequest shardRequest) { ShardDeleteRequest request = shardRequest.request; IndexShard indexShard = indicesService.indexServiceSafe(shardRequest.request.index()).shardSafe(shardRequest.shardId); Engine.Delete delete = indexShard.prepareDelete(request.type(), request.id(), request.version()) @@ -96,7 +105,8 @@ public class TransportShardDeleteAction extends TransportShardReplicationOperati return new PrimaryResponse(shardRequest.request, response, null); } - @Override protected void shardOperationOnReplica(ReplicaOperationRequest shardRequest) { + @Override + protected void shardOperationOnReplica(ReplicaOperationRequest shardRequest) { ShardDeleteRequest request = shardRequest.request; IndexShard indexShard = indicesService.indexServiceSafe(shardRequest.request.index()).shardSafe(shardRequest.shardId); Engine.Delete delete = indexShard.prepareDelete(request.type(), request.id(), request.version()) @@ -113,7 +123,8 @@ public class TransportShardDeleteAction extends TransportShardReplicationOperati } - @Override protected ShardIterator shards(ClusterState clusterState, ShardDeleteRequest request) { + @Override + protected ShardIterator shards(ClusterState clusterState, ShardDeleteRequest request) { GroupShardsIterator group = clusterService.operationRouting().broadcastDeleteShards(clusterService.state(), request.index()); for (ShardIterator shardIt : group) { if (shardIt.shardId().id() == request.shardId()) { diff --git a/src/main/java/org/elasticsearch/action/delete/package-info.java b/src/main/java/org/elasticsearch/action/delete/package-info.java index 3a78f839bf7..cf23bb769b7 100644 --- a/src/main/java/org/elasticsearch/action/delete/package-info.java +++ b/src/main/java/org/elasticsearch/action/delete/package-info.java @@ -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 diff --git a/src/main/java/org/elasticsearch/action/deletebyquery/DeleteByQueryRequest.java b/src/main/java/org/elasticsearch/action/deletebyquery/DeleteByQueryRequest.java index 54308a30ea1..7ecf5ed8b47 100644 --- a/src/main/java/org/elasticsearch/action/deletebyquery/DeleteByQueryRequest.java +++ b/src/main/java/org/elasticsearch/action/deletebyquery/DeleteByQueryRequest.java @@ -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 @@ -43,16 +43,16 @@ import java.io.IOException; import java.util.Arrays; import java.util.Map; -import static org.elasticsearch.action.Actions.*; +import static org.elasticsearch.action.Actions.addValidationError; /** * A request to delete all documents that matching a specific query. Best created with * {@link org.elasticsearch.client.Requests#deleteByQueryRequest(String...)}. - * + *

*

The request requires the query source to be set either using {@link #query(org.elasticsearch.index.query.QueryBuilder)}, * or {@link #query(byte[])}. * - * @author kimchy (shay.banon) + * * @see DeleteByQueryResponse * @see org.elasticsearch.client.Requests#deleteByQueryRequest(String...) * @see org.elasticsearch.client.Client#deleteByQuery(DeleteByQueryRequest) @@ -67,7 +67,8 @@ public class DeleteByQueryRequest extends IndicesReplicationOperationRequest { private boolean querySourceUnsafe; private String[] types = Strings.EMPTY_ARRAY; - @Nullable private String routing; + @Nullable + private String routing; /** * Constructs a new delete by query request to run against the provided indices. No indices means @@ -83,12 +84,14 @@ public class DeleteByQueryRequest extends IndicesReplicationOperationRequest { /** * Should the listener be called on a separate thread if needed. */ - @Override public DeleteByQueryRequest listenerThreaded(boolean threadedListener) { + @Override + public DeleteByQueryRequest listenerThreaded(boolean threadedListener) { super.listenerThreaded(threadedListener); return this; } - @Override public ActionRequestValidationException validate() { + @Override + public ActionRequestValidationException validate() { ActionRequestValidationException validationException = super.validate(); if (querySource == null) { validationException = addValidationError("query is missing", validationException); @@ -121,7 +124,8 @@ public class DeleteByQueryRequest extends IndicesReplicationOperationRequest { * * @see org.elasticsearch.index.query.QueryBuilders */ - @Required public DeleteByQueryRequest query(QueryBuilder queryBuilder) { + @Required + public DeleteByQueryRequest query(QueryBuilder queryBuilder) { BytesStream bos = queryBuilder.buildAsUnsafeBytes(); this.querySource = bos.underlyingBytes(); this.querySourceOffset = 0; @@ -134,7 +138,8 @@ public class DeleteByQueryRequest extends IndicesReplicationOperationRequest { * The query source to execute. It is preferable to use either {@link #query(byte[])} * or {@link #query(org.elasticsearch.index.query.QueryBuilder)}. */ - @Required public DeleteByQueryRequest query(String querySource) { + @Required + public DeleteByQueryRequest query(String querySource) { UnicodeUtil.UTF8Result result = Unicode.fromStringAsUtf8(querySource); this.querySource = result.result; this.querySourceOffset = 0; @@ -146,7 +151,8 @@ public class DeleteByQueryRequest extends IndicesReplicationOperationRequest { /** * The query source to execute in the form of a map. */ - @Required public DeleteByQueryRequest query(Map querySource) { + @Required + public DeleteByQueryRequest query(Map querySource) { try { XContentBuilder builder = XContentFactory.contentBuilder(contentType); builder.map(querySource); @@ -156,7 +162,8 @@ public class DeleteByQueryRequest extends IndicesReplicationOperationRequest { } } - @Required public DeleteByQueryRequest query(XContentBuilder builder) { + @Required + public DeleteByQueryRequest query(XContentBuilder builder) { try { this.querySource = builder.underlyingBytes(); this.querySourceOffset = 0; @@ -171,14 +178,16 @@ public class DeleteByQueryRequest extends IndicesReplicationOperationRequest { /** * The query source to execute. */ - @Required public DeleteByQueryRequest query(byte[] querySource) { + @Required + public DeleteByQueryRequest query(byte[] querySource) { return query(querySource, 0, querySource.length, false); } /** * The query source to execute. */ - @Required public DeleteByQueryRequest query(byte[] querySource, int offset, int length, boolean unsafe) { + @Required + public DeleteByQueryRequest query(byte[] querySource, int offset, int length, boolean unsafe) { this.querySource = querySource; this.querySourceOffset = offset; this.querySourceLength = length; @@ -196,7 +205,8 @@ public class DeleteByQueryRequest extends IndicesReplicationOperationRequest { /** * A comma separated list of routing values to control the shards the search will be executed on. */ - @Override public String routing() { + @Override + public String routing() { return this.routing; } @@ -304,7 +314,8 @@ public class DeleteByQueryRequest extends IndicesReplicationOperationRequest { } } - @Override public String toString() { + @Override + public String toString() { return "[" + Arrays.toString(indices) + "][" + Arrays.toString(types) + "], querySource[" + Unicode.fromBytes(querySource) + "]"; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/action/deletebyquery/DeleteByQueryResponse.java b/src/main/java/org/elasticsearch/action/deletebyquery/DeleteByQueryResponse.java index cc76a04ac4d..808cf5f1e74 100644 --- a/src/main/java/org/elasticsearch/action/deletebyquery/DeleteByQueryResponse.java +++ b/src/main/java/org/elasticsearch/action/deletebyquery/DeleteByQueryResponse.java @@ -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,13 +28,13 @@ import java.io.IOException; import java.util.Iterator; import java.util.Map; -import static org.elasticsearch.common.collect.Maps.*; +import static com.google.common.collect.Maps.newHashMap; /** * The response of delete by query action. Holds the {@link IndexDeleteByQueryResponse}s from all the * different indices. * - * @author kimchy (shay.banon) + * */ public class DeleteByQueryResponse implements ActionResponse, Streamable, Iterable { @@ -44,7 +44,8 @@ public class DeleteByQueryResponse implements ActionResponse, Streamable, Iterab } - @Override public Iterator iterator() { + @Override + public Iterator iterator() { return indices.values().iterator(); } @@ -69,7 +70,8 @@ public class DeleteByQueryResponse implements ActionResponse, Streamable, Iterab return indices.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++) { IndexDeleteByQueryResponse response = new IndexDeleteByQueryResponse(); @@ -78,7 +80,8 @@ public class DeleteByQueryResponse implements ActionResponse, Streamable, Iterab } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeVInt(indices.size()); for (IndexDeleteByQueryResponse indexResponse : indices.values()) { indexResponse.writeTo(out); diff --git a/src/main/java/org/elasticsearch/action/deletebyquery/IndexDeleteByQueryRequest.java b/src/main/java/org/elasticsearch/action/deletebyquery/IndexDeleteByQueryRequest.java index 3f5953ec9c8..48134cc2478 100644 --- a/src/main/java/org/elasticsearch/action/deletebyquery/IndexDeleteByQueryRequest.java +++ b/src/main/java/org/elasticsearch/action/deletebyquery/IndexDeleteByQueryRequest.java @@ -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.deletebyquery; +import gnu.trove.set.hash.THashSet; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.support.replication.IndexReplicationOperationRequest; import org.elasticsearch.common.Nullable; @@ -26,26 +27,27 @@ import org.elasticsearch.common.Required; import org.elasticsearch.common.Strings; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.trove.set.hash.THashSet; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.index.query.QueryBuilder; import java.io.IOException; import java.util.Set; -import static org.elasticsearch.action.Actions.*; +import static org.elasticsearch.action.Actions.addValidationError; /** * Delete by query request to execute on a specific index. * - * @author kimchy (shay.banon) + * */ public class IndexDeleteByQueryRequest extends IndexReplicationOperationRequest { private byte[] querySource; private String[] types = Strings.EMPTY_ARRAY; - @Nullable private Set routing; - @Nullable private String[] filteringAliases; + @Nullable + private Set routing; + @Nullable + private String[] filteringAliases; IndexDeleteByQueryRequest(DeleteByQueryRequest request, String index, @Nullable Set routing, @Nullable String[] filteringAliases) { this.index = index; @@ -65,7 +67,8 @@ public class IndexDeleteByQueryRequest extends IndexReplicationOperationRequest return querySource; } - @Override public ActionRequestValidationException validate() { + @Override + public ActionRequestValidationException validate() { ActionRequestValidationException validationException = super.validate(); if (querySource == null) { validationException = addValidationError("querySource is missing", validationException); @@ -73,11 +76,13 @@ public class IndexDeleteByQueryRequest extends IndexReplicationOperationRequest return validationException; } - @Required public IndexDeleteByQueryRequest querySource(QueryBuilder queryBuilder) { + @Required + public IndexDeleteByQueryRequest querySource(QueryBuilder queryBuilder) { return querySource(queryBuilder.buildAsBytes()); } - @Required public IndexDeleteByQueryRequest querySource(byte[] querySource) { + @Required + public IndexDeleteByQueryRequest querySource(byte[] querySource) { this.querySource = querySource; return this; } diff --git a/src/main/java/org/elasticsearch/action/deletebyquery/IndexDeleteByQueryResponse.java b/src/main/java/org/elasticsearch/action/deletebyquery/IndexDeleteByQueryResponse.java index ed967cda9cc..145ba46f72d 100644 --- a/src/main/java/org/elasticsearch/action/deletebyquery/IndexDeleteByQueryResponse.java +++ b/src/main/java/org/elasticsearch/action/deletebyquery/IndexDeleteByQueryResponse.java @@ -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.io.IOException; /** * Delete by query response executed on a specific index. * - * @author kimchy (shay.banon) + * */ public class IndexDeleteByQueryResponse implements ActionResponse, Streamable { @@ -105,13 +105,15 @@ public class IndexDeleteByQueryResponse implements ActionResponse, Streamable { return 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); diff --git a/src/main/java/org/elasticsearch/action/deletebyquery/ShardDeleteByQueryRequest.java b/src/main/java/org/elasticsearch/action/deletebyquery/ShardDeleteByQueryRequest.java index 5ff263c6242..f9f5baebf43 100644 --- a/src/main/java/org/elasticsearch/action/deletebyquery/ShardDeleteByQueryRequest.java +++ b/src/main/java/org/elasticsearch/action/deletebyquery/ShardDeleteByQueryRequest.java @@ -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.deletebyquery; +import gnu.trove.set.hash.THashSet; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.support.replication.ShardReplicationOperationRequest; import org.elasticsearch.common.Nullable; @@ -26,26 +27,27 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.Unicode; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.trove.set.hash.THashSet; import java.io.IOException; import java.util.Arrays; import java.util.Set; -import static org.elasticsearch.action.Actions.*; +import static org.elasticsearch.action.Actions.addValidationError; /** * Delete by query request to execute on a specific shard. * - * @author kimchy (shay.banon) + * */ public class ShardDeleteByQueryRequest extends ShardReplicationOperationRequest { private int shardId; private byte[] querySource; private String[] types = Strings.EMPTY_ARRAY; - @Nullable private Set routing; - @Nullable private String[] filteringAliases; + @Nullable + private Set routing; + @Nullable + private String[] filteringAliases; ShardDeleteByQueryRequest(IndexDeleteByQueryRequest request, int shardId) { this.index = request.index(); @@ -62,7 +64,8 @@ public class ShardDeleteByQueryRequest extends ShardReplicationOperationRequest ShardDeleteByQueryRequest() { } - @Override public ActionRequestValidationException validate() { + @Override + public ActionRequestValidationException validate() { ActionRequestValidationException validationException = super.validate(); if (querySource == null) { addValidationError("querySource is missing", validationException); @@ -90,7 +93,8 @@ public class ShardDeleteByQueryRequest extends ShardReplicationOperationRequest return filteringAliases; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); querySource = new byte[in.readVInt()]; in.readFully(querySource); @@ -118,7 +122,8 @@ public class ShardDeleteByQueryRequest extends ShardReplicationOperationRequest } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeVInt(querySource.length); out.writeBytes(querySource); @@ -145,7 +150,8 @@ public class ShardDeleteByQueryRequest extends ShardReplicationOperationRequest } } - @Override public String toString() { + @Override + public String toString() { String sSource = "_na_"; try { sSource = Unicode.fromBytes(querySource); diff --git a/src/main/java/org/elasticsearch/action/deletebyquery/ShardDeleteByQueryResponse.java b/src/main/java/org/elasticsearch/action/deletebyquery/ShardDeleteByQueryResponse.java index 264e584b350..3cea46f3bb3 100644 --- a/src/main/java/org/elasticsearch/action/deletebyquery/ShardDeleteByQueryResponse.java +++ b/src/main/java/org/elasticsearch/action/deletebyquery/ShardDeleteByQueryResponse.java @@ -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,13 +29,15 @@ import java.io.IOException; /** * Delete by query response executed on a specific shard. * - * @author kimchy (shay.banon) + * */ public class ShardDeleteByQueryResponse 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 { } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/action/deletebyquery/TransportDeleteByQueryAction.java b/src/main/java/org/elasticsearch/action/deletebyquery/TransportDeleteByQueryAction.java index e0405286bb7..e8d523dfb3d 100644 --- a/src/main/java/org/elasticsearch/action/deletebyquery/TransportDeleteByQueryAction.java +++ b/src/main/java/org/elasticsearch/action/deletebyquery/TransportDeleteByQueryAction.java @@ -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,16 +36,19 @@ import java.util.concurrent.atomic.AtomicReferenceArray; */ public class TransportDeleteByQueryAction extends TransportIndicesReplicationOperationAction { - @Inject public TransportDeleteByQueryAction(Settings settings, ClusterService clusterService, TransportService transportService, - ThreadPool threadPool, TransportIndexDeleteByQueryAction indexDeleteByQueryAction) { + @Inject + public TransportDeleteByQueryAction(Settings settings, ClusterService clusterService, TransportService transportService, + ThreadPool threadPool, TransportIndexDeleteByQueryAction indexDeleteByQueryAction) { super(settings, transportService, clusterService, threadPool, indexDeleteByQueryAction); } - @Override protected DeleteByQueryRequest newRequestInstance() { + @Override + protected DeleteByQueryRequest newRequestInstance() { return new DeleteByQueryRequest(); } - @Override protected DeleteByQueryResponse newResponseInstance(DeleteByQueryRequest request, AtomicReferenceArray indexResponses) { + @Override + protected DeleteByQueryResponse newResponseInstance(DeleteByQueryRequest request, AtomicReferenceArray indexResponses) { DeleteByQueryResponse response = new DeleteByQueryResponse(); for (int i = 0; i < indexResponses.length(); i++) { IndexDeleteByQueryResponse indexResponse = (IndexDeleteByQueryResponse) indexResponses.get(i); @@ -56,21 +59,25 @@ public class TransportDeleteByQueryAction extends TransportIndicesReplicationOpe return response; } - @Override protected boolean accumulateExceptions() { + @Override + protected boolean accumulateExceptions() { return false; } - @Override protected String transportAction() { + @Override + protected String transportAction() { return TransportActions.DELETE_BY_QUERY; } - @Override protected void checkBlock(DeleteByQueryRequest request, String[] concreteIndices, ClusterState state) { + @Override + protected void checkBlock(DeleteByQueryRequest request, String[] concreteIndices, ClusterState state) { for (String index : concreteIndices) { state.blocks().indexBlockedRaiseException(ClusterBlockLevel.WRITE, index); } } - @Override protected IndexDeleteByQueryRequest newIndexRequestInstance(DeleteByQueryRequest request, String index, Set routing) { + @Override + protected IndexDeleteByQueryRequest newIndexRequestInstance(DeleteByQueryRequest request, String index, Set routing) { String[] filteringAliases = clusterService.state().metaData().filteringAliases(index, request.indices()); return new IndexDeleteByQueryRequest(request, index, routing, filteringAliases); } diff --git a/src/main/java/org/elasticsearch/action/deletebyquery/TransportIndexDeleteByQueryAction.java b/src/main/java/org/elasticsearch/action/deletebyquery/TransportIndexDeleteByQueryAction.java index c2001537f6e..cf4de3a1300 100644 --- a/src/main/java/org/elasticsearch/action/deletebyquery/TransportIndexDeleteByQueryAction.java +++ b/src/main/java/org/elasticsearch/action/deletebyquery/TransportIndexDeleteByQueryAction.java @@ -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,20 +32,23 @@ import org.elasticsearch.transport.TransportService; import java.util.concurrent.atomic.AtomicReferenceArray; /** - * @author kimchy (shay.banon) + * */ public class TransportIndexDeleteByQueryAction extends TransportIndexReplicationOperationAction { - @Inject public TransportIndexDeleteByQueryAction(Settings settings, ClusterService clusterService, TransportService transportService, - ThreadPool threadPool, TransportShardDeleteByQueryAction shardDeleteByQueryAction) { + @Inject + public TransportIndexDeleteByQueryAction(Settings settings, ClusterService clusterService, TransportService transportService, + ThreadPool threadPool, TransportShardDeleteByQueryAction shardDeleteByQueryAction) { super(settings, transportService, clusterService, threadPool, shardDeleteByQueryAction); } - @Override protected IndexDeleteByQueryRequest newRequestInstance() { + @Override + protected IndexDeleteByQueryRequest newRequestInstance() { return new IndexDeleteByQueryRequest(); } - @Override protected IndexDeleteByQueryResponse newResponseInstance(IndexDeleteByQueryRequest request, AtomicReferenceArray shardsResponses) { + @Override + protected IndexDeleteByQueryResponse newResponseInstance(IndexDeleteByQueryRequest request, AtomicReferenceArray shardsResponses) { int successfulShards = 0; int failedShards = 0; for (int i = 0; i < shardsResponses.length(); i++) { @@ -58,23 +61,28 @@ public class TransportIndexDeleteByQueryAction extends TransportIndexReplication return new IndexDeleteByQueryResponse(request.index(), successfulShards, failedShards); } - @Override protected boolean accumulateExceptions() { + @Override + protected boolean accumulateExceptions() { return false; } - @Override protected String transportAction() { + @Override + protected String transportAction() { return "indices/index/deleteByQuery"; } - @Override protected void checkBlock(IndexDeleteByQueryRequest request, ClusterState state) { + @Override + protected void checkBlock(IndexDeleteByQueryRequest request, ClusterState state) { state.blocks().indexBlockedRaiseException(ClusterBlockLevel.WRITE, request.index()); } - @Override protected GroupShardsIterator shards(IndexDeleteByQueryRequest request) { + @Override + protected GroupShardsIterator shards(IndexDeleteByQueryRequest request) { return clusterService.operationRouting().deleteByQueryShards(clusterService.state(), request.index(), request.routing()); } - @Override protected ShardDeleteByQueryRequest newShardRequestInstance(IndexDeleteByQueryRequest request, int shardId) { + @Override + protected ShardDeleteByQueryRequest newShardRequestInstance(IndexDeleteByQueryRequest request, int shardId) { return new ShardDeleteByQueryRequest(request, shardId); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/action/deletebyquery/TransportShardDeleteByQueryAction.java b/src/main/java/org/elasticsearch/action/deletebyquery/TransportShardDeleteByQueryAction.java index f295b77f746..d4958569020 100644 --- a/src/main/java/org/elasticsearch/action/deletebyquery/TransportShardDeleteByQueryAction.java +++ b/src/main/java/org/elasticsearch/action/deletebyquery/TransportShardDeleteByQueryAction.java @@ -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,45 +36,54 @@ import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (Shay Banon) + * */ public class TransportShardDeleteByQueryAction extends TransportShardReplicationOperationAction { - @Inject public TransportShardDeleteByQueryAction(Settings settings, TransportService transportService, - ClusterService clusterService, IndicesService indicesService, ThreadPool threadPool, - ShardStateAction shardStateAction) { + @Inject + public TransportShardDeleteByQueryAction(Settings settings, TransportService transportService, + ClusterService clusterService, IndicesService indicesService, ThreadPool threadPool, + ShardStateAction shardStateAction) { super(settings, transportService, clusterService, indicesService, threadPool, shardStateAction); } - @Override protected boolean checkWriteConsistency() { + @Override + protected boolean checkWriteConsistency() { return true; } - @Override protected String executor() { + @Override + protected String executor() { return ThreadPool.Names.INDEX; } - @Override protected ShardDeleteByQueryRequest newRequestInstance() { + @Override + protected ShardDeleteByQueryRequest newRequestInstance() { return new ShardDeleteByQueryRequest(); } - @Override protected ShardDeleteByQueryRequest newReplicaRequestInstance() { + @Override + protected ShardDeleteByQueryRequest newReplicaRequestInstance() { return new ShardDeleteByQueryRequest(); } - @Override protected ShardDeleteByQueryResponse newResponseInstance() { + @Override + protected ShardDeleteByQueryResponse newResponseInstance() { return new ShardDeleteByQueryResponse(); } - @Override protected String transportAction() { + @Override + protected String transportAction() { return "indices/index/shard/deleteByQuery"; } - @Override protected void checkBlock(ShardDeleteByQueryRequest request, ClusterState state) { + @Override + protected void checkBlock(ShardDeleteByQueryRequest request, ClusterState state) { state.blocks().indexBlockedRaiseException(ClusterBlockLevel.WRITE, request.index()); } - @Override protected PrimaryResponse shardOperationOnPrimary(ClusterState clusterState, PrimaryOperationRequest shardRequest) { + @Override + protected PrimaryResponse shardOperationOnPrimary(ClusterState clusterState, PrimaryOperationRequest shardRequest) { ShardDeleteByQueryRequest request = shardRequest.request; IndexShard indexShard = indicesService.indexServiceSafe(shardRequest.request.index()).shardSafe(shardRequest.shardId); Engine.DeleteByQuery deleteByQuery = indexShard.prepareDeleteByQuery(request.querySource(), request.filteringAliases(), request.types()); @@ -83,14 +92,16 @@ public class TransportShardDeleteByQueryAction extends TransportShardReplication } - @Override protected void shardOperationOnReplica(ReplicaOperationRequest shardRequest) { + @Override + protected void shardOperationOnReplica(ReplicaOperationRequest shardRequest) { ShardDeleteByQueryRequest request = shardRequest.request; IndexShard indexShard = indicesService.indexServiceSafe(shardRequest.request.index()).shardSafe(shardRequest.shardId); Engine.DeleteByQuery deleteByQuery = indexShard.prepareDeleteByQuery(request.querySource(), request.filteringAliases(), request.types()); indexShard.deleteByQuery(deleteByQuery); } - @Override protected ShardIterator shards(ClusterState clusterState, ShardDeleteByQueryRequest request) { + @Override + protected ShardIterator shards(ClusterState clusterState, ShardDeleteByQueryRequest request) { GroupShardsIterator group = clusterService.operationRouting().deleteByQueryShards(clusterService.state(), request.index(), request.routing()); for (ShardIterator shardIt : group) { if (shardIt.shardId().id() == request.shardId()) { diff --git a/src/main/java/org/elasticsearch/action/deletebyquery/package-info.java b/src/main/java/org/elasticsearch/action/deletebyquery/package-info.java index 1a0bd668b3f..11de5d664c2 100644 --- a/src/main/java/org/elasticsearch/action/deletebyquery/package-info.java +++ b/src/main/java/org/elasticsearch/action/deletebyquery/package-info.java @@ -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 diff --git a/src/main/java/org/elasticsearch/action/get/GetRequest.java b/src/main/java/org/elasticsearch/action/get/GetRequest.java index 2c291e3ed6a..ac02194aa58 100644 --- a/src/main/java/org/elasticsearch/action/get/GetRequest.java +++ b/src/main/java/org/elasticsearch/action/get/GetRequest.java @@ -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,11 +32,11 @@ import java.io.IOException; /** * A request to get a document (its source) from an index based on its type (optional) and id. Best created using * {@link org.elasticsearch.client.Requests#getRequest(String)}. - * + *

*

The operation requires the {@link #index()}, {@link #type(String)} and {@link #id(String)} * to be set. * - * @author kimchy (shay.banon) + * * @see org.elasticsearch.action.get.GetResponse * @see org.elasticsearch.client.Requests#getRequest(String) * @see org.elasticsearch.client.Client#get(GetRequest) @@ -80,7 +80,8 @@ public class GetRequest extends SingleShardOperationRequest { this.id = id; } - @Override public ActionRequestValidationException validate() { + @Override + public ActionRequestValidationException validate() { ActionRequestValidationException validationException = super.validate(); if (type == null) { validationException = Actions.addValidationError("type is missing", validationException); @@ -94,7 +95,8 @@ public class GetRequest extends SingleShardOperationRequest { /** * Sets the index of the document to fetch. */ - @Required public GetRequest index(String index) { + @Required + public GetRequest index(String index) { this.index = index; return this; } @@ -113,7 +115,8 @@ public class GetRequest extends SingleShardOperationRequest { /** * Sets the id of the document to fetch. */ - @Required public GetRequest id(String id) { + @Required + public GetRequest id(String id) { this.id = id; return this; } @@ -196,7 +199,8 @@ public class GetRequest extends SingleShardOperationRequest { /** * Should the listener be called on a separate thread if needed. */ - @Override public GetRequest listenerThreaded(boolean threadedListener) { + @Override + public GetRequest listenerThreaded(boolean threadedListener) { super.listenerThreaded(threadedListener); return this; } @@ -204,12 +208,14 @@ public class GetRequest extends SingleShardOperationRequest { /** * Controls if the operation will be executed on a separate thread when executed locally. */ - @Override public GetRequest operationThreaded(boolean threadedOperation) { + @Override + public GetRequest 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(); @@ -237,7 +243,8 @@ public class GetRequest extends SingleShardOperationRequest { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeUTF(type); @@ -273,7 +280,8 @@ public class GetRequest extends SingleShardOperationRequest { } } - @Override public String toString() { + @Override + public String toString() { return "[" + index + "][" + type + "][" + id + "]: routing [" + routing + "]"; } } diff --git a/src/main/java/org/elasticsearch/action/get/GetResponse.java b/src/main/java/org/elasticsearch/action/get/GetResponse.java index bb2ff5d9fb6..5ba4a524f3b 100644 --- a/src/main/java/org/elasticsearch/action/get/GetResponse.java +++ b/src/main/java/org/elasticsearch/action/get/GetResponse.java @@ -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.util.Map; /** * The response of a get action. * - * @author kimchy (shay.banon) + * * @see GetRequest * @see org.elasticsearch.client.Client#get(GetRequest) */ @@ -174,19 +174,23 @@ public class GetResponse implements ActionResponse, Streamable, Iterable iterator() { + @Override + public Iterator iterator() { return getResult.iterator(); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { return getResult.toXContent(builder, params); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { getResult = GetResult.readGetResult(in); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { getResult.writeTo(out); } } diff --git a/src/main/java/org/elasticsearch/action/get/MultiGetItemResponse.java b/src/main/java/org/elasticsearch/action/get/MultiGetItemResponse.java index 5a4397e85a1..b16ec14eff4 100644 --- a/src/main/java/org/elasticsearch/action/get/MultiGetItemResponse.java +++ b/src/main/java/org/elasticsearch/action/get/MultiGetItemResponse.java @@ -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 @@ -141,7 +141,8 @@ public class MultiGetItemResponse implements Streamable { return response; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { if (in.readBoolean()) { failure = MultiGetResponse.Failure.readFailure(in); } else { @@ -150,7 +151,8 @@ public class MultiGetItemResponse implements Streamable { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { if (failure != null) { out.writeBoolean(true); failure.writeTo(out); diff --git a/src/main/java/org/elasticsearch/action/get/MultiGetRequest.java b/src/main/java/org/elasticsearch/action/get/MultiGetRequest.java index 96fc637d260..10bba6e0dec 100644 --- a/src/main/java/org/elasticsearch/action/get/MultiGetRequest.java +++ b/src/main/java/org/elasticsearch/action/get/MultiGetRequest.java @@ -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 @@ -107,7 +107,8 @@ public class MultiGetRequest implements ActionRequest { return item; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { index = in.readUTF(); if (in.readBoolean()) { type = in.readUTF(); @@ -125,7 +126,8 @@ public class MultiGetRequest implements ActionRequest { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(index); if (type == null) { out.writeBoolean(false); @@ -169,16 +171,19 @@ public class MultiGetRequest implements ActionRequest { return this; } - @Override public boolean listenerThreaded() { + @Override + public boolean listenerThreaded() { return listenerThreaded; } - @Override public MultiGetRequest listenerThreaded(boolean listenerThreaded) { + @Override + public MultiGetRequest listenerThreaded(boolean listenerThreaded) { this.listenerThreaded = listenerThreaded; return this; } - @Override public ActionRequestValidationException validate() { + @Override + public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if (items.isEmpty()) { validationException = Actions.addValidationError("no documents to get", validationException); @@ -292,7 +297,8 @@ public class MultiGetRequest implements ActionRequest { } } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { if (in.readBoolean()) { preference = in.readUTF(); } @@ -311,7 +317,8 @@ public class MultiGetRequest implements ActionRequest { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { if (preference == null) { out.writeBoolean(false); } else { diff --git a/src/main/java/org/elasticsearch/action/get/MultiGetResponse.java b/src/main/java/org/elasticsearch/action/get/MultiGetResponse.java index 54955b0d8e5..a23832be597 100644 --- a/src/main/java/org/elasticsearch/action/get/MultiGetResponse.java +++ b/src/main/java/org/elasticsearch/action/get/MultiGetResponse.java @@ -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.get; +import com.google.common.collect.Iterators; import org.elasticsearch.action.ActionResponse; -import org.elasticsearch.common.collect.Iterators; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Streamable; @@ -115,7 +115,8 @@ public class MultiGetResponse implements ActionResponse, Iterable iterator() { + @Override + public Iterator iterator() { return Iterators.forArray(responses); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); builder.startArray(Fields.DOCS); for (MultiGetItemResponse response : responses) { @@ -184,14 +188,16 @@ public class MultiGetResponse implements ActionResponse, Iterable(size); @@ -74,7 +75,8 @@ public class MultiGetShardResponse implements ActionResponse { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeVInt(locations.size()); for (int i = 0; i < locations.size(); i++) { out.writeVInt(locations.get(i)); diff --git a/src/main/java/org/elasticsearch/action/get/TransportGetAction.java b/src/main/java/org/elasticsearch/action/get/TransportGetAction.java index 8437ad17b4f..202670c3f6d 100644 --- a/src/main/java/org/elasticsearch/action/get/TransportGetAction.java +++ b/src/main/java/org/elasticsearch/action/get/TransportGetAction.java @@ -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,7 +41,7 @@ import org.elasticsearch.transport.TransportService; /** * Performs the get operation. * - * @author kimchy (shay.banon) + * */ public class TransportGetAction extends TransportShardSingleOperationAction { @@ -49,36 +49,43 @@ public class TransportGetAction extends TransportShardSingleOperationAction listener) { + @Override + protected void doExecute(GetRequest request, ActionListener listener) { if (request.realtime == null) { request.realtime = this.realtime; } @@ -89,7 +96,8 @@ public class TransportGetAction extends TransportShardSingleOperationAction listener) { + @Override + protected void doExecute(final MultiGetRequest request, final ActionListener listener) { ClusterState clusterState = clusterService.state(); Map shardRequests = new HashMap(); for (int i = 0; i < request.items.size(); i++) { @@ -76,7 +78,8 @@ public class TransportMultiGetAction extends BaseAction() { - @Override public void onResponse(MultiGetShardResponse response) { + @Override + public void onResponse(MultiGetShardResponse response) { synchronized (responses) { for (int i = 0; i < response.locations.size(); i++) { responses[response.locations.get(i)] = new MultiGetItemResponse(response.responses.get(i), response.failures.get(i)); @@ -87,7 +90,8 @@ public class TransportMultiGetAction extends BaseAction { - @Override public MultiGetRequest newInstance() { + @Override + public MultiGetRequest newInstance() { return new MultiGetRequest(); } - @Override public void messageReceived(final MultiGetRequest request, final TransportChannel channel) throws Exception { + @Override + public void messageReceived(final MultiGetRequest request, final TransportChannel channel) throws Exception { // no need to use threaded listener, since we just send a response request.listenerThreaded(false); execute(request, new ActionListener() { - @Override public void onResponse(MultiGetResponse response) { + @Override + public void onResponse(MultiGetResponse response) { try { channel.sendResponse(response); } catch (Exception e) { @@ -126,7 +133,8 @@ public class TransportMultiGetAction extends BaseAction listener) { + @Override + protected void doExecute(MultiGetShardRequest request, ActionListener listener) { if (request.realtime == null) { request.realtime = this.realtime; } super.doExecute(request, listener); } - @Override protected MultiGetShardResponse shardOperation(MultiGetShardRequest request, int shardId) throws ElasticSearchException { + @Override + protected MultiGetShardResponse shardOperation(MultiGetShardRequest request, int shardId) throws ElasticSearchException { IndexService indexService = indicesService.indexServiceSafe(request.index()); IndexShard indexShard = indexService.shardSafe(shardId); diff --git a/src/main/java/org/elasticsearch/action/get/package-info.java b/src/main/java/org/elasticsearch/action/get/package-info.java index 27394ee10b4..cebfbcbb49c 100644 --- a/src/main/java/org/elasticsearch/action/get/package-info.java +++ b/src/main/java/org/elasticsearch/action/get/package-info.java @@ -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 diff --git a/src/main/java/org/elasticsearch/action/index/IndexRequest.java b/src/main/java/org/elasticsearch/action/index/IndexRequest.java index 08e5be638fb..a65340fea65 100644 --- a/src/main/java/org/elasticsearch/action/index/IndexRequest.java +++ b/src/main/java/org/elasticsearch/action/index/IndexRequest.java @@ -50,22 +50,22 @@ import java.io.IOException; import java.util.Arrays; import java.util.Map; -import static org.elasticsearch.action.Actions.*; +import static org.elasticsearch.action.Actions.addValidationError; /** * Index request to index a typed JSON document into a specific index and make it searchable. Best * created using {@link org.elasticsearch.client.Requests#indexRequest(String)}. - * + *

*

The index requires the {@link #index()}, {@link #type(String)}, {@link #id(String)} and * {@link #source(byte[])} to be set. - * + *

*

The source (content to index) can be set in its bytes form using ({@link #source(byte[])}), * its string form ({@link #source(String)}) or using a {@link org.elasticsearch.common.xcontent.XContentBuilder} * ({@link #source(org.elasticsearch.common.xcontent.XContentBuilder)}). - * + *

*

If the {@link #id(String)} is not set, it will be automatically generated. * - * @author kimchy (shay.banon) + * * @see IndexResponse * @see org.elasticsearch.client.Requests#indexRequest(String) * @see org.elasticsearch.client.Client#index(IndexRequest) @@ -116,9 +116,12 @@ public class IndexRequest extends ShardReplicationOperationRequest { private String type; private String id; - @Nullable private String routing; - @Nullable private String parent; - @Nullable private String timestamp; + @Nullable + private String routing; + @Nullable + private String parent; + @Nullable + private String timestamp; private long ttl = -1; private byte[] source; @@ -159,7 +162,8 @@ public class IndexRequest extends ShardReplicationOperationRequest { this.id = id; } - @Override public ActionRequestValidationException validate() { + @Override + public ActionRequestValidationException validate() { ActionRequestValidationException validationException = super.validate(); if (type == null) { validationException = addValidationError("type is missing", validationException); @@ -173,7 +177,8 @@ public class IndexRequest extends ShardReplicationOperationRequest { /** * Before we fork on a local thread, make sure we copy over the bytes if they are unsafe */ - @Override public void beforeLocalFork() { + @Override + public void beforeLocalFork() { // only fork if copy over if source is unsafe if (sourceUnsafe) { source(); @@ -183,7 +188,8 @@ public class IndexRequest extends ShardReplicationOperationRequest { /** * Sets the index the index operation will happen on. */ - @Override public IndexRequest index(String index) { + @Override + public IndexRequest index(String index) { super.index(index); return this; } @@ -199,7 +205,8 @@ public class IndexRequest extends ShardReplicationOperationRequest { /** * Should the listener be called on a separate thread if needed. */ - @Override public IndexRequest listenerThreaded(boolean threadedListener) { + @Override + public IndexRequest listenerThreaded(boolean threadedListener) { super.listenerThreaded(threadedListener); return this; } @@ -208,7 +215,8 @@ public class IndexRequest extends ShardReplicationOperationRequest { * Controls if the operation will be executed on a separate thread when executed locally. Defaults * to true when running in embedded mode. */ - @Override public IndexRequest operationThreaded(boolean threadedOperation) { + @Override + public IndexRequest operationThreaded(boolean threadedOperation) { super.operationThreaded(threadedOperation); return this; } @@ -223,7 +231,8 @@ public class IndexRequest extends ShardReplicationOperationRequest { /** * Sets the type of the indexed document. */ - @Required public IndexRequest type(String type) { + @Required + public IndexRequest type(String type) { this.type = type; return this; } @@ -341,7 +350,8 @@ public class IndexRequest extends ShardReplicationOperationRequest { * * @param source The map to index */ - @Required public IndexRequest source(Map source) throws ElasticSearchGenerationException { + @Required + public IndexRequest source(Map source) throws ElasticSearchGenerationException { return source(source, contentType); } @@ -350,7 +360,8 @@ public class IndexRequest extends ShardReplicationOperationRequest { * * @param source The map to index */ - @Required public IndexRequest source(Map source, XContentType contentType) throws ElasticSearchGenerationException { + @Required + public IndexRequest source(Map source, XContentType contentType) throws ElasticSearchGenerationException { try { XContentBuilder builder = XContentFactory.contentBuilder(contentType); builder.map(source); @@ -362,11 +373,12 @@ public class IndexRequest extends ShardReplicationOperationRequest { /** * Sets the document source to index. - * + *

*

Note, its preferable to either set it using {@link #source(org.elasticsearch.common.xcontent.XContentBuilder)} * or using the {@link #source(byte[])}. */ - @Required public IndexRequest source(String source) { + @Required + public IndexRequest source(String source) { UnicodeUtil.UTF8Result result = Unicode.fromStringAsUtf8(source); this.source = result.result; this.sourceOffset = 0; @@ -378,7 +390,8 @@ public class IndexRequest extends ShardReplicationOperationRequest { /** * Sets the content source to index. */ - @Required public IndexRequest source(XContentBuilder sourceBuilder) { + @Required + public IndexRequest source(XContentBuilder sourceBuilder) { try { source = sourceBuilder.underlyingBytes(); sourceOffset = 0; @@ -390,7 +403,8 @@ public class IndexRequest extends ShardReplicationOperationRequest { return this; } - @Required public IndexRequest source(String field1, Object value1) { + @Required + public IndexRequest source(String field1, Object value1) { try { XContentBuilder builder = XContentFactory.contentBuilder(contentType); builder.startObject().field(field1, value1).endObject(); @@ -400,7 +414,8 @@ public class IndexRequest extends ShardReplicationOperationRequest { } } - @Required public IndexRequest source(String field1, Object value1, String field2, Object value2) { + @Required + public IndexRequest source(String field1, Object value1, String field2, Object value2) { try { XContentBuilder builder = XContentFactory.contentBuilder(contentType); builder.startObject().field(field1, value1).field(field2, value2).endObject(); @@ -410,7 +425,8 @@ public class IndexRequest extends ShardReplicationOperationRequest { } } - @Required public IndexRequest source(String field1, Object value1, String field2, Object value2, String field3, Object value3) { + @Required + public IndexRequest source(String field1, Object value1, String field2, Object value2, String field3, Object value3) { try { XContentBuilder builder = XContentFactory.contentBuilder(contentType); builder.startObject().field(field1, value1).field(field2, value2).field(field3, value3).endObject(); @@ -420,7 +436,8 @@ public class IndexRequest extends ShardReplicationOperationRequest { } } - @Required public IndexRequest source(String field1, Object value1, String field2, Object value2, String field3, Object value3, String field4, Object value4) { + @Required + public IndexRequest source(String field1, Object value1, String field2, Object value2, String field3, Object value3, String field4, Object value4) { try { XContentBuilder builder = XContentFactory.contentBuilder(contentType); builder.startObject().field(field1, value1).field(field2, value2).field(field3, value3).field(field4, value4).endObject(); @@ -445,7 +462,8 @@ public class IndexRequest extends ShardReplicationOperationRequest { * @param offset The offset in the byte array * @param length The length of the data */ - @Required public IndexRequest source(byte[] source, int offset, int length) { + @Required + public IndexRequest source(byte[] source, int offset, int length) { return source(source, offset, length, false); } @@ -457,7 +475,8 @@ public class IndexRequest extends ShardReplicationOperationRequest { * @param length The length of the data * @param unsafe Is the byte array safe to be used form a different thread */ - @Required public IndexRequest source(byte[] source, int offset, int length, boolean unsafe) { + @Required + public IndexRequest source(byte[] source, int offset, int length, boolean unsafe) { this.source = source; this.sourceOffset = offset; this.sourceLength = length; @@ -505,7 +524,8 @@ public class IndexRequest extends ShardReplicationOperationRequest { /** * Set the replication type for this operation. */ - @Override public IndexRequest replicationType(ReplicationType replicationType) { + @Override + public IndexRequest replicationType(ReplicationType replicationType) { super.replicationType(replicationType); return this; } @@ -513,7 +533,8 @@ public class IndexRequest extends ShardReplicationOperationRequest { /** * Sets the consistency level of write. Defaults to {@link org.elasticsearch.action.WriteConsistencyLevel#DEFAULT} */ - @Override public IndexRequest consistencyLevel(WriteConsistencyLevel consistencyLevel) { + @Override + public IndexRequest consistencyLevel(WriteConsistencyLevel consistencyLevel) { super.consistencyLevel(consistencyLevel); return this; } @@ -654,7 +675,8 @@ public class IndexRequest extends ShardReplicationOperationRequest { } } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); type = in.readUTF(); if (in.readBoolean()) { @@ -685,7 +707,8 @@ public class IndexRequest extends ShardReplicationOperationRequest { versionType = VersionType.fromValue(in.readByte()); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeUTF(type); if (id == null) { @@ -727,7 +750,8 @@ public class IndexRequest extends ShardReplicationOperationRequest { out.writeByte(versionType.getValue()); } - @Override public String toString() { + @Override + public String toString() { String sSource = "_na_"; try { sSource = Unicode.fromBytes(source, sourceOffset, sourceLength); diff --git a/src/main/java/org/elasticsearch/action/index/IndexResponse.java b/src/main/java/org/elasticsearch/action/index/IndexResponse.java index 0c14ac1f13c..7cce896d115 100644 --- a/src/main/java/org/elasticsearch/action/index/IndexResponse.java +++ b/src/main/java/org/elasticsearch/action/index/IndexResponse.java @@ -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.index; +import com.google.common.collect.ImmutableList; import org.elasticsearch.action.ActionResponse; -import org.elasticsearch.common.collect.ImmutableList; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Streamable; @@ -32,7 +32,7 @@ import java.util.List; /** * A response of an index operation, * - * @author kimchy (shay.banon) + * * @see org.elasticsearch.action.index.IndexRequest * @see org.elasticsearch.client.Client#index(IndexRequest) */ @@ -136,7 +136,8 @@ public class IndexResponse implements ActionResponse, Streamable { this.matches = matches; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { index = in.readUTF(); id = in.readUTF(); type = in.readUTF(); @@ -164,7 +165,8 @@ public class IndexResponse implements ActionResponse, Streamable { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(index); out.writeUTF(id); out.writeUTF(type); diff --git a/src/main/java/org/elasticsearch/action/index/TransportIndexAction.java b/src/main/java/org/elasticsearch/action/index/TransportIndexAction.java index 097e4014fed..f1ed9f5d846 100644 --- a/src/main/java/org/elasticsearch/action/index/TransportIndexAction.java +++ b/src/main/java/org/elasticsearch/action/index/TransportIndexAction.java @@ -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 @@ -56,7 +56,7 @@ import java.util.concurrent.TimeUnit; /** * Performs the index operation. - * + *

*

Allows for the following settings: *

    *
  • autoCreateIndex: When set to true, will automatically create an index if one does not exists. @@ -64,7 +64,7 @@ import java.util.concurrent.TimeUnit; *
  • allowIdGeneration: If the id is set not, should it be generated. Defaults to true. *
* - * @author kimchy (shay.banon) + * */ public class TransportIndexAction extends TransportShardReplicationOperationAction { @@ -78,9 +78,10 @@ public class TransportIndexAction extends TransportShardReplicationOperationActi private final boolean waitForMappingChange; - @Inject public TransportIndexAction(Settings settings, TransportService transportService, ClusterService clusterService, - IndicesService indicesService, ThreadPool threadPool, ShardStateAction shardStateAction, - TransportCreateIndexAction createIndexAction, MappingUpdatedAction mappingUpdatedAction) { + @Inject + public TransportIndexAction(Settings settings, TransportService transportService, ClusterService clusterService, + IndicesService indicesService, ThreadPool threadPool, ShardStateAction shardStateAction, + TransportCreateIndexAction createIndexAction, MappingUpdatedAction mappingUpdatedAction) { super(settings, transportService, clusterService, indicesService, threadPool, shardStateAction); this.createIndexAction = createIndexAction; this.mappingUpdatedAction = mappingUpdatedAction; @@ -89,15 +90,18 @@ public class TransportIndexAction extends TransportShardReplicationOperationActi this.waitForMappingChange = settings.getAsBoolean("action.wait_on_mapping_change", true); } - @Override protected void doExecute(final IndexRequest request, final ActionListener listener) { + @Override + protected void doExecute(final IndexRequest request, final ActionListener listener) { if (autoCreateIndex && !clusterService.state().metaData().hasConcreteIndex(request.index())) { request.beforeLocalFork(); // we fork on another thread... createIndexAction.execute(new CreateIndexRequest(request.index()).cause("auto(index api)"), new ActionListener() { - @Override public void onResponse(CreateIndexResponse result) { + @Override + public void onResponse(CreateIndexResponse result) { innerExecute(request, listener); } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { if (ExceptionsHelper.unwrapCause(e) instanceof IndexAlreadyExistsException) { // we have the index, do it try { @@ -128,40 +132,49 @@ public class TransportIndexAction extends TransportShardReplicationOperationActi super.doExecute(request, listener); } - @Override protected boolean checkWriteConsistency() { + @Override + protected boolean checkWriteConsistency() { return true; } - @Override protected IndexRequest newRequestInstance() { + @Override + protected IndexRequest newRequestInstance() { return new IndexRequest(); } - @Override protected IndexRequest newReplicaRequestInstance() { + @Override + protected IndexRequest newReplicaRequestInstance() { return new IndexRequest(); } - @Override protected IndexResponse newResponseInstance() { + @Override + protected IndexResponse newResponseInstance() { return new IndexResponse(); } - @Override protected String transportAction() { + @Override + protected String transportAction() { return TransportActions.INDEX; } - @Override protected String executor() { + @Override + protected String executor() { return ThreadPool.Names.INDEX; } - @Override protected void checkBlock(IndexRequest request, ClusterState state) { + @Override + protected void checkBlock(IndexRequest request, ClusterState state) { state.blocks().indexBlockedRaiseException(ClusterBlockLevel.WRITE, request.index()); } - @Override protected ShardIterator shards(ClusterState clusterState, IndexRequest request) { + @Override + protected ShardIterator shards(ClusterState clusterState, IndexRequest request) { return clusterService.operationRouting() .indexShards(clusterService.state(), request.index(), request.type(), request.id(), request.routing()); } - @Override protected PrimaryResponse shardOperationOnPrimary(ClusterState clusterState, PrimaryOperationRequest shardRequest) { + @Override + protected PrimaryResponse shardOperationOnPrimary(ClusterState clusterState, PrimaryOperationRequest shardRequest) { final IndexRequest request = shardRequest.request; // validate, if routing is required, that we got routing @@ -211,7 +224,8 @@ public class TransportIndexAction extends TransportShardReplicationOperationActi return new PrimaryResponse(shardRequest.request, response, op); } - @Override protected void postPrimaryOperation(IndexRequest request, PrimaryResponse response) { + @Override + protected void postPrimaryOperation(IndexRequest request, PrimaryResponse response) { Engine.IndexingOperation op = (Engine.IndexingOperation) response.payload(); if (!Strings.hasLength(request.percolate())) { return; @@ -225,7 +239,8 @@ public class TransportIndexAction extends TransportShardReplicationOperationActi } } - @Override protected void shardOperationOnReplica(ReplicaOperationRequest shardRequest) { + @Override + protected void shardOperationOnReplica(ReplicaOperationRequest shardRequest) { IndexShard indexShard = indicesService.indexServiceSafe(shardRequest.request.index()).shardSafe(shardRequest.shardId); IndexRequest request = shardRequest.request; SourceToParse sourceToParse = SourceToParse.source(request.underlyingSource(), request.underlyingSourceOffset(), request.underlyingSourceLength()).type(request.type()).id(request.id()) @@ -261,12 +276,14 @@ public class TransportIndexAction extends TransportShardReplicationOperationActi documentMapper.refreshSource(); mappingUpdatedAction.execute(new MappingUpdatedAction.MappingUpdatedRequest(request.index(), request.type(), documentMapper.mappingSource()), new ActionListener() { - @Override public void onResponse(MappingUpdatedAction.MappingUpdatedResponse mappingUpdatedResponse) { + @Override + public void onResponse(MappingUpdatedAction.MappingUpdatedResponse mappingUpdatedResponse) { // all is well latch.countDown(); } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { latch.countDown(); try { logger.warn("Failed to update master on updated mapping for index [" + request.index() + "], type [" + request.type() + "] and source [" + documentMapper.mappingSource().string() + "]", e); diff --git a/src/main/java/org/elasticsearch/action/index/package-info.java b/src/main/java/org/elasticsearch/action/index/package-info.java index 6b526aaec81..cc6817ca7b9 100644 --- a/src/main/java/org/elasticsearch/action/index/package-info.java +++ b/src/main/java/org/elasticsearch/action/index/package-info.java @@ -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 diff --git a/src/main/java/org/elasticsearch/action/mlt/MoreLikeThisRequest.java b/src/main/java/org/elasticsearch/action/mlt/MoreLikeThisRequest.java index e45fe77b301..7d26810ddaa 100644 --- a/src/main/java/org/elasticsearch/action/mlt/MoreLikeThisRequest.java +++ b/src/main/java/org/elasticsearch/action/mlt/MoreLikeThisRequest.java @@ -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 @@ -44,15 +44,15 @@ import java.io.IOException; import java.util.Arrays; import java.util.Map; -import static org.elasticsearch.search.Scroll.*; +import static org.elasticsearch.search.Scroll.readScroll; /** * A more like this request allowing to search for documents that a "like" the provided document. The document * to check against to fetched based on the index, type and id provided. Best created with {@link org.elasticsearch.client.Requests#moreLikeThisRequest(String)}. - * + *

*

Note, the {@link #index()}, {@link #type(String)} and {@link #id(String)} are required. * - * @author kimchy (shay.banon) + * * @see org.elasticsearch.client.Client#moreLikeThis(MoreLikeThisRequest) * @see org.elasticsearch.client.Requests#moreLikeThisRequest(String) * @see org.elasticsearch.action.search.SearchResponse @@ -126,7 +126,8 @@ public class MoreLikeThisRequest implements ActionRequest { /** * The type of document to load from which the "like" query will execute with. */ - @Required public MoreLikeThisRequest type(String type) { + @Required + public MoreLikeThisRequest type(String type) { this.type = type; return this; } @@ -141,7 +142,8 @@ public class MoreLikeThisRequest implements ActionRequest { /** * The id of document to load from which the "like" query will execute with. */ - @Required public MoreLikeThisRequest id(String id) { + @Required + public MoreLikeThisRequest id(String id) { this.id = id; return this; } @@ -210,10 +212,10 @@ public class MoreLikeThisRequest implements ActionRequest { /** * Any word in this set is considered "uninteresting" and ignored. - * + *

*

Even if your Analyzer allows stopwords, you might want to tell the MoreLikeThis code to ignore them, as * for the purposes of document similarity it seems reasonable to assume that "a stop word is never interesting". - * + *

*

Defaults to no stop words. */ public MoreLikeThisRequest stopWords(String... stopWords) { @@ -223,10 +225,10 @@ public class MoreLikeThisRequest implements ActionRequest { /** * Any word in this set is considered "uninteresting" and ignored. - * + *

*

Even if your Analyzer allows stopwords, you might want to tell the MoreLikeThis code to ignore them, as * for the purposes of document similarity it seems reasonable to assume that "a stop word is never interesting". - * + *

*

Defaults to no stop words. */ public String[] stopWords() { @@ -520,7 +522,8 @@ public class MoreLikeThisRequest implements ActionRequest { return this.searchFrom; } - @Override public ActionRequestValidationException validate() { + @Override + public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if (index == null) { validationException = Actions.addValidationError("index is missing", validationException); @@ -537,19 +540,22 @@ public class MoreLikeThisRequest implements ActionRequest { /** * Should the listener be called on a separate thread if needed. */ - @Override public boolean listenerThreaded() { + @Override + public boolean listenerThreaded() { return threadedListener; } /** * Should the listener be called on a separate thread if needed. */ - @Override public ActionRequest listenerThreaded(boolean listenerThreaded) { + @Override + public ActionRequest listenerThreaded(boolean listenerThreaded) { this.threadedListener = listenerThreaded; return this; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { index = in.readUTF(); type = in.readUTF(); id = in.readUTF(); @@ -623,7 +629,8 @@ public class MoreLikeThisRequest implements ActionRequest { searchFrom = in.readVInt(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(index); out.writeUTF(type); out.writeUTF(id); diff --git a/src/main/java/org/elasticsearch/action/mlt/TransportMoreLikeThisAction.java b/src/main/java/org/elasticsearch/action/mlt/TransportMoreLikeThisAction.java index 10fcedad4c9..de775d2cc2b 100644 --- a/src/main/java/org/elasticsearch/action/mlt/TransportMoreLikeThisAction.java +++ b/src/main/java/org/elasticsearch/action/mlt/TransportMoreLikeThisAction.java @@ -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,11 +36,7 @@ import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.get.GetField; -import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.mapper.FieldMapper; -import org.elasticsearch.index.mapper.FieldMappers; -import org.elasticsearch.index.mapper.InternalMapper; -import org.elasticsearch.index.mapper.SourceToParse; +import org.elasticsearch.index.mapper.*; import org.elasticsearch.index.mapper.internal.SourceFieldMapper; import org.elasticsearch.index.query.BoolQueryBuilder; import org.elasticsearch.index.query.MoreLikeThisFieldQueryBuilder; @@ -54,15 +50,16 @@ import java.util.Collections; import java.util.Iterator; import java.util.Set; -import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.common.collect.Sets.*; +import static com.google.common.collect.Sets.newHashSet; +import static org.elasticsearch.client.Requests.getRequest; +import static org.elasticsearch.client.Requests.searchRequest; import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.elasticsearch.search.builder.SearchSourceBuilder.*; +import static org.elasticsearch.search.builder.SearchSourceBuilder.searchSource; /** * The more like this action. * - * @author kimchy (shay.banon) + * */ public class TransportMoreLikeThisAction extends BaseAction { @@ -74,8 +71,9 @@ public class TransportMoreLikeThisAction extends BaseAction listener) { + @Override + protected void doExecute(final MoreLikeThisRequest request, final ActionListener listener) { // update to actual index name ClusterState clusterState = clusterService.state(); // update to the concrete index @@ -107,7 +106,8 @@ public class TransportMoreLikeThisAction extends BaseAction() { - @Override public void onResponse(GetResponse getResponse) { + @Override + public void onResponse(GetResponse getResponse) { if (!getResponse.exists()) { listener.onFailure(new ElasticSearchException("document missing")); return; @@ -187,18 +187,21 @@ public class TransportMoreLikeThisAction extends BaseAction() { - @Override public void onResponse(SearchResponse response) { + @Override + public void onResponse(SearchResponse response) { listener.onResponse(response); } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { listener.onFailure(e); } }); } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { listener.onFailure(e); } }); @@ -209,7 +212,8 @@ public class TransportMoreLikeThisAction extends BaseAction { - @Override public MoreLikeThisRequest newInstance() { + @Override + public MoreLikeThisRequest newInstance() { return new MoreLikeThisRequest(); } - @Override public void messageReceived(MoreLikeThisRequest request, final TransportChannel channel) throws Exception { + @Override + public void messageReceived(MoreLikeThisRequest request, final TransportChannel channel) throws Exception { // no need to have a threaded listener since we just send back a response request.listenerThreaded(false); execute(request, new ActionListener() { - @Override public void onResponse(SearchResponse result) { + @Override + public void onResponse(SearchResponse result) { try { channel.sendResponse(result); } catch (Exception e) { @@ -264,7 +271,8 @@ public class TransportMoreLikeThisAction extends BaseActiontrue */ - @Override public PercolateRequest preferLocal(boolean preferLocal) { + @Override + public PercolateRequest preferLocal(boolean preferLocal) { super.preferLocal(preferLocal); return this; } - @Override public ActionRequestValidationException validate() { + @Override + public ActionRequestValidationException validate() { ActionRequestValidationException validationException = super.validate(); if (index == null) { validationException = addValidationError("index is missing", validationException); @@ -187,7 +196,8 @@ public class PercolateRequest extends SingleCustomOperationRequest { return validationException; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); index = in.readUTF(); type = in.readUTF(); @@ -199,7 +209,8 @@ public class PercolateRequest extends SingleCustomOperationRequest { in.readFully(source); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeUTF(index); out.writeUTF(type); diff --git a/src/main/java/org/elasticsearch/action/percolate/PercolateResponse.java b/src/main/java/org/elasticsearch/action/percolate/PercolateResponse.java index 6eb772f3ad0..f56a9d1bb97 100644 --- a/src/main/java/org/elasticsearch/action/percolate/PercolateResponse.java +++ b/src/main/java/org/elasticsearch/action/percolate/PercolateResponse.java @@ -29,7 +29,7 @@ import java.util.Iterator; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class PercolateResponse implements ActionResponse, Iterable { @@ -47,11 +47,13 @@ public class PercolateResponse implements ActionResponse, Iterable { return this.matches; } - @Override public Iterator iterator() { + @Override + public Iterator iterator() { return matches.iterator(); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { int size = in.readVInt(); matches = new ArrayList(size); for (int i = 0; i < size; i++) { @@ -59,7 +61,8 @@ public class PercolateResponse implements ActionResponse, Iterable { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeVInt(matches.size()); for (String match : matches) { out.writeUTF(match); diff --git a/src/main/java/org/elasticsearch/action/percolate/TransportPercolateAction.java b/src/main/java/org/elasticsearch/action/percolate/TransportPercolateAction.java index bd01741b8a4..2d532a5c594 100644 --- a/src/main/java/org/elasticsearch/action/percolate/TransportPercolateAction.java +++ b/src/main/java/org/elasticsearch/action/percolate/TransportPercolateAction.java @@ -35,44 +35,52 @@ import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (shay.banon) + * */ public class TransportPercolateAction extends TransportSingleCustomOperationAction { private final IndicesService indicesService; - @Inject public TransportPercolateAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, - IndicesService indicesService) { + @Inject + public TransportPercolateAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, + IndicesService indicesService) { super(settings, threadPool, clusterService, transportService); this.indicesService = indicesService; } - @Override protected String executor() { + @Override + protected String executor() { return ThreadPool.Names.PERCOLATE; } - @Override protected PercolateRequest newRequest() { + @Override + protected PercolateRequest newRequest() { return new PercolateRequest(); } - @Override protected PercolateResponse newResponse() { + @Override + protected PercolateResponse newResponse() { return new PercolateResponse(); } - @Override protected String transportAction() { + @Override + protected String transportAction() { return TransportActions.PERCOLATE; } - @Override protected String transportShardAction() { + @Override + protected String transportShardAction() { return "indices/percolate/shard"; } - @Override protected ShardsIterator shards(ClusterState clusterState, PercolateRequest request) { + @Override + protected ShardsIterator shards(ClusterState clusterState, PercolateRequest request) { request.index(clusterState.metaData().concreteIndex(request.index())); return clusterState.routingTable().index(request.index()).randomAllActiveShardsIt(); } - @Override protected PercolateResponse shardOperation(PercolateRequest request, int shardId) throws ElasticSearchException { + @Override + protected PercolateResponse shardOperation(PercolateRequest request, int shardId) throws ElasticSearchException { IndexService indexService = indicesService.indexServiceSafe(request.index()); PercolatorService percolatorService = indexService.percolateService(); diff --git a/src/main/java/org/elasticsearch/action/search/ReduceSearchPhaseException.java b/src/main/java/org/elasticsearch/action/search/ReduceSearchPhaseException.java index 6ea9d508558..69ca9d186eb 100644 --- a/src/main/java/org/elasticsearch/action/search/ReduceSearchPhaseException.java +++ b/src/main/java/org/elasticsearch/action/search/ReduceSearchPhaseException.java @@ -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 @@ package org.elasticsearch.action.search; * A failure during a reduce phase (when receiving results from several shards, and reducing them * into one or more results and possible actions). * - * @author kimchy (shay.banon) + * */ public class ReduceSearchPhaseException extends SearchPhaseExecutionException { diff --git a/src/main/java/org/elasticsearch/action/search/SearchOperationThreading.java b/src/main/java/org/elasticsearch/action/search/SearchOperationThreading.java index 75c40ac1495..7dedce08beb 100644 --- a/src/main/java/org/elasticsearch/action/search/SearchOperationThreading.java +++ b/src/main/java/org/elasticsearch/action/search/SearchOperationThreading.java @@ -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.Nullable; * Controls the operation threading model for search operation that are performed * locally on the executing node. * - * @author kimchy (shay.banon) + * */ public enum SearchOperationThreading { /** diff --git a/src/main/java/org/elasticsearch/action/search/SearchPhaseExecutionException.java b/src/main/java/org/elasticsearch/action/search/SearchPhaseExecutionException.java index 4a8e8c83e05..acc04e24ee2 100644 --- a/src/main/java/org/elasticsearch/action/search/SearchPhaseExecutionException.java +++ b/src/main/java/org/elasticsearch/action/search/SearchPhaseExecutionException.java @@ -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.search; import org.elasticsearch.ElasticSearchException; /** - * @author kimchy (shay.banon) + * */ public class SearchPhaseExecutionException extends ElasticSearchException { diff --git a/src/main/java/org/elasticsearch/action/search/SearchRequest.java b/src/main/java/org/elasticsearch/action/search/SearchRequest.java index f14b3080f45..d621850864e 100644 --- a/src/main/java/org/elasticsearch/action/search/SearchRequest.java +++ b/src/main/java/org/elasticsearch/action/search/SearchRequest.java @@ -43,20 +43,20 @@ import java.io.IOException; import java.util.Arrays; import java.util.Map; -import static org.elasticsearch.action.Actions.*; -import static org.elasticsearch.common.unit.TimeValue.*; -import static org.elasticsearch.search.Scroll.*; +import static org.elasticsearch.action.Actions.addValidationError; +import static org.elasticsearch.common.unit.TimeValue.readTimeValue; +import static org.elasticsearch.search.Scroll.readScroll; /** * A request to execute search against one or more indices (or all). Best created using * {@link org.elasticsearch.client.Requests#searchRequest(String...)}. - * + *

*

Note, the search {@link #source(org.elasticsearch.search.builder.SearchSourceBuilder)} * is required. The search source is the different search options, including facets and such. - * + *

*

There is an option to specify an addition search source using the {@link #extraSource(org.elasticsearch.search.builder.SearchSourceBuilder)}. * - * @author kimchy (shay.banon) + * * @see org.elasticsearch.client.Requests#searchRequest(String...) * @see org.elasticsearch.client.Client#search(SearchRequest) * @see SearchResponse @@ -69,9 +69,12 @@ public class SearchRequest implements ActionRequest { private String[] indices; - @Nullable private String queryHint; - @Nullable private String routing; - @Nullable private String preference; + @Nullable + private String queryHint; + @Nullable + private String routing; + @Nullable + private String preference; private byte[] source; private int sourceOffset; @@ -111,7 +114,8 @@ public class SearchRequest implements ActionRequest { this.source = source; } - @Override public ActionRequestValidationException validate() { + @Override + public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if (source == null && extraSource == null) { validationException = addValidationError("search source is missing", validationException); @@ -143,7 +147,8 @@ public class SearchRequest implements ActionRequest { /** * Should the listener be called on a separate thread if needed. */ - @Override public boolean listenerThreaded() { + @Override + public boolean listenerThreaded() { return listenerThreaded; } @@ -158,7 +163,8 @@ public class SearchRequest implements ActionRequest { /** * Should the listener be called on a separate thread if needed. */ - @Override public SearchRequest listenerThreaded(boolean listenerThreaded) { + @Override + public SearchRequest listenerThreaded(boolean listenerThreaded) { this.listenerThreaded = listenerThreaded; return this; } @@ -518,7 +524,8 @@ public class SearchRequest implements ActionRequest { return timeout(TimeValue.parseTimeValue(timeout, null)); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { operationThreading = SearchOperationThreading.fromId(in.readByte()); searchType = SearchType.fromId(in.readByte()); @@ -573,7 +580,8 @@ public class SearchRequest implements ActionRequest { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeByte(operationThreading.id()); out.writeByte(searchType.id()); diff --git a/src/main/java/org/elasticsearch/action/search/SearchResponse.java b/src/main/java/org/elasticsearch/action/search/SearchResponse.java index fad9161bd57..e5a59d3cdac 100644 --- a/src/main/java/org/elasticsearch/action/search/SearchResponse.java +++ b/src/main/java/org/elasticsearch/action/search/SearchResponse.java @@ -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,13 +34,13 @@ import org.elasticsearch.search.internal.InternalSearchResponse; import java.io.IOException; -import static org.elasticsearch.action.search.ShardSearchFailure.*; -import static org.elasticsearch.search.internal.InternalSearchResponse.*; +import static org.elasticsearch.action.search.ShardSearchFailure.readShardSearchFailure; +import static org.elasticsearch.search.internal.InternalSearchResponse.readInternalSearchResponse; /** * A response of a search request. * - * @author kimchy (shay.banon) + * */ public class SearchResponse implements ActionResponse, ToXContent { @@ -243,7 +243,8 @@ public class SearchResponse implements ActionResponse, ToXContent { static final XContentBuilderString TIMED_OUT = new XContentBuilderString("timed_out"); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { if (scrollId != null) { builder.field(Fields._SCROLL_ID, scrollId); } @@ -280,7 +281,8 @@ public class SearchResponse implements ActionResponse, ToXContent { return response; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { internalResponse = readInternalSearchResponse(in); totalShards = in.readVInt(); successfulShards = in.readVInt(); @@ -299,7 +301,8 @@ public class SearchResponse implements ActionResponse, ToXContent { tookInMillis = in.readVLong(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { internalResponse.writeTo(out); out.writeVInt(totalShards); out.writeVInt(successfulShards); @@ -318,7 +321,8 @@ public class SearchResponse implements ActionResponse, ToXContent { out.writeVLong(tookInMillis); } - @Override public String toString() { + @Override + public String toString() { try { XContentBuilder builder = XContentFactory.jsonBuilder().prettyPrint(); builder.startObject(); diff --git a/src/main/java/org/elasticsearch/action/search/SearchScrollRequest.java b/src/main/java/org/elasticsearch/action/search/SearchScrollRequest.java index afc21040864..55ebce5c7d6 100644 --- a/src/main/java/org/elasticsearch/action/search/SearchScrollRequest.java +++ b/src/main/java/org/elasticsearch/action/search/SearchScrollRequest.java @@ -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,11 @@ import org.elasticsearch.search.Scroll; import java.io.IOException; -import static org.elasticsearch.action.Actions.*; -import static org.elasticsearch.search.Scroll.*; +import static org.elasticsearch.action.Actions.addValidationError; +import static org.elasticsearch.search.Scroll.readScroll; /** - * @author kimchy (Shay Banon) + * */ public class SearchScrollRequest implements ActionRequest { @@ -50,7 +50,8 @@ public class SearchScrollRequest implements ActionRequest { this.scrollId = scrollId; } - @Override public ActionRequestValidationException validate() { + @Override + public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if (scrollId == null) { validationException = addValidationError("scrollId is missing", validationException); @@ -76,14 +77,16 @@ public class SearchScrollRequest implements ActionRequest { /** * Should the listener be called on a separate thread if needed. */ - @Override public boolean listenerThreaded() { + @Override + public boolean listenerThreaded() { return listenerThreaded; } /** * Should the listener be called on a separate thread if needed. */ - @Override public SearchScrollRequest listenerThreaded(boolean threadedListener) { + @Override + public SearchScrollRequest listenerThreaded(boolean threadedListener) { this.listenerThreaded = threadedListener; return this; } @@ -124,7 +127,8 @@ public class SearchScrollRequest implements ActionRequest { return scroll(new Scroll(TimeValue.parseTimeValue(keepAlive, null))); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { operationThreading = SearchOperationThreading.fromId(in.readByte()); scrollId = in.readUTF(); if (in.readBoolean()) { @@ -132,7 +136,8 @@ public class SearchScrollRequest implements ActionRequest { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeByte(operationThreading.id()); out.writeUTF(scrollId); if (scroll == null) { diff --git a/src/main/java/org/elasticsearch/action/search/SearchType.java b/src/main/java/org/elasticsearch/action/search/SearchType.java index 389ed360f1c..efc110c78b6 100644 --- a/src/main/java/org/elasticsearch/action/search/SearchType.java +++ b/src/main/java/org/elasticsearch/action/search/SearchType.java @@ -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.ElasticSearchIllegalArgumentException; /** * Search type represent the manner at which the search operation is executed. * - * @author kimchy (shay.banon) + * */ public enum SearchType { /** diff --git a/src/main/java/org/elasticsearch/action/search/ShardSearchFailure.java b/src/main/java/org/elasticsearch/action/search/ShardSearchFailure.java index a750898f00e..fcee4c33776 100644 --- a/src/main/java/org/elasticsearch/action/search/ShardSearchFailure.java +++ b/src/main/java/org/elasticsearch/action/search/ShardSearchFailure.java @@ -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,12 +31,12 @@ import org.elasticsearch.search.SearchShardTarget; import java.io.IOException; -import static org.elasticsearch.search.SearchShardTarget.*; +import static org.elasticsearch.search.SearchShardTarget.readSearchShardTarget; /** * Represents a failure to search on a specific shard. * - * @author kimchy (shay.banon) + * */ public class ShardSearchFailure implements ShardOperationFailedException { @@ -74,7 +74,8 @@ public class ShardSearchFailure implements ShardOperationFailedException { /** * The search shard target the failure occurred on. */ - @Nullable public SearchShardTarget shard() { + @Nullable + public SearchShardTarget shard() { return this.shardTarget; } @@ -85,7 +86,8 @@ public class ShardSearchFailure implements ShardOperationFailedException { /** * The index the search failed on. */ - @Override public String index() { + @Override + public String index() { if (shardTarget != null) { return shardTarget.index(); } @@ -95,7 +97,8 @@ public class ShardSearchFailure implements ShardOperationFailedException { /** * The shard id the search failed on. */ - @Override public int shardId() { + @Override + public int shardId() { if (shardTarget != null) { return shardTarget.shardId(); } @@ -109,7 +112,8 @@ public class ShardSearchFailure implements ShardOperationFailedException { return this.reason; } - @Override public String toString() { + @Override + public String toString() { return "shard [" + (shardTarget == null ? "_na" : shardTarget) + "], reason [" + reason + "]"; } @@ -119,7 +123,8 @@ public class ShardSearchFailure implements ShardOperationFailedException { return shardSearchFailure; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { if (in.readBoolean()) { shardTarget = readSearchShardTarget(in); } @@ -127,7 +132,8 @@ public class ShardSearchFailure implements ShardOperationFailedException { status = RestStatus.readFrom(in); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { if (shardTarget == null) { out.writeBoolean(false); } else { diff --git a/src/main/java/org/elasticsearch/action/search/TransportSearchAction.java b/src/main/java/org/elasticsearch/action/search/TransportSearchAction.java index d3a16cf1697..09c5ad45fda 100644 --- a/src/main/java/org/elasticsearch/action/search/TransportSearchAction.java +++ b/src/main/java/org/elasticsearch/action/search/TransportSearchAction.java @@ -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,12 +21,7 @@ package org.elasticsearch.action.search; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.TransportActions; -import org.elasticsearch.action.search.type.TransportSearchCountAction; -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.*; import org.elasticsearch.action.support.BaseAction; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.ClusterState; @@ -44,7 +39,7 @@ import java.util.Set; import static org.elasticsearch.action.search.SearchType.*; /** - * @author kimchy (shay.banon) + * */ public class TransportSearchAction extends BaseAction { @@ -64,14 +59,15 @@ public class TransportSearchAction extends BaseAction listener) { + @Override + protected void doExecute(SearchRequest searchRequest, ActionListener listener) { // optimize search type for cases where there is only one shard group to search on if (optimizeSingleShard && searchRequest.searchType() != SCAN && searchRequest.searchType() != COUNT) { try { @@ -123,11 +120,13 @@ public class TransportSearchAction extends BaseAction { - @Override public SearchRequest newInstance() { + @Override + public SearchRequest newInstance() { return new SearchRequest(); } - @Override public void messageReceived(SearchRequest request, final TransportChannel channel) throws Exception { + @Override + public void messageReceived(SearchRequest request, final TransportChannel channel) throws Exception { // no need for a threaded listener request.listenerThreaded(false); // we don't spawn, so if we get a request with no threading, change it to single threaded @@ -135,7 +134,8 @@ public class TransportSearchAction extends BaseAction() { - @Override public void onResponse(SearchResponse result) { + @Override + public void onResponse(SearchResponse result) { try { channel.sendResponse(result); } catch (Exception e) { @@ -143,7 +143,8 @@ public class TransportSearchAction extends BaseAction { @@ -48,10 +48,11 @@ public class TransportSearchScrollAction extends BaseAction listener) { + @Override + protected void doExecute(SearchScrollRequest request, ActionListener listener) { try { ParsedScrollId scrollId = parseScrollId(request.scrollId()); if (scrollId.type().equals(QUERY_THEN_FETCH_TYPE)) { @@ -79,13 +81,16 @@ public class TransportSearchScrollAction extends BaseAction { - @Override public SearchScrollRequest newInstance() { + @Override + public SearchScrollRequest newInstance() { return new SearchScrollRequest(); } - @Override public void messageReceived(SearchScrollRequest request, final TransportChannel channel) throws Exception { + @Override + public void messageReceived(SearchScrollRequest request, final TransportChannel channel) throws Exception { execute(request, new ActionListener() { - @Override public void onResponse(SearchResponse result) { + @Override + public void onResponse(SearchResponse result) { try { channel.sendResponse(result); } catch (Exception e) { @@ -93,7 +98,8 @@ public class TransportSearchScrollAction extends BaseAction listener) { + @Override + protected void doExecute(SearchRequest searchRequest, ActionListener listener) { new AsyncAction(searchRequest, listener).start(); } @@ -66,19 +68,23 @@ public class TransportSearchCountAction extends TransportSearchTypeAction { super(request, listener); } - @Override protected String firstPhaseName() { + @Override + protected String firstPhaseName() { return "query"; } - @Override protected void sendExecuteFirstPhase(DiscoveryNode node, InternalSearchRequest request, SearchServiceListener listener) { + @Override + protected void sendExecuteFirstPhase(DiscoveryNode node, InternalSearchRequest request, SearchServiceListener listener) { searchService.sendExecuteQuery(node, request, listener); } - @Override protected void processFirstPhaseResult(ShardRouting shard, QuerySearchResult result) { + @Override + protected void processFirstPhaseResult(ShardRouting shard, QuerySearchResult result) { queryFetchResults.put(result.shardTarget(), result); } - @Override protected void moveToSecondPhase() throws Exception { + @Override + protected void moveToSecondPhase() throws Exception { // no need to sort, since we know we have no hits back final InternalSearchResponse internalResponse = searchPhaseController.merge(EMPTY_DOCS, queryFetchResults, ImmutableMap.of()); String scrollId = null; diff --git a/src/main/java/org/elasticsearch/action/search/type/TransportSearchDfsQueryAndFetchAction.java b/src/main/java/org/elasticsearch/action/search/type/TransportSearchDfsQueryAndFetchAction.java index 115e51f96b6..20bc390d890 100644 --- a/src/main/java/org/elasticsearch/action/search/type/TransportSearchDfsQueryAndFetchAction.java +++ b/src/main/java/org/elasticsearch/action/search/type/TransportSearchDfsQueryAndFetchAction.java @@ -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,11 +20,7 @@ package org.elasticsearch.action.search.type; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.search.ReduceSearchPhaseException; -import org.elasticsearch.action.search.SearchOperationThreading; -import org.elasticsearch.action.search.SearchRequest; -import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.action.search.ShardSearchFailure; +import org.elasticsearch.action.search.*; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.routing.ShardRouting; @@ -46,19 +42,21 @@ import java.util.Collection; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; -import static org.elasticsearch.action.search.type.TransportSearchHelper.*; +import static org.elasticsearch.action.search.type.TransportSearchHelper.buildScrollId; /** - * @author kimchy (shay.banon) + * */ public class TransportSearchDfsQueryAndFetchAction extends TransportSearchTypeAction { - @Inject public TransportSearchDfsQueryAndFetchAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, - TransportSearchCache transportSearchCache, SearchServiceTransportAction searchService, SearchPhaseController searchPhaseController) { + @Inject + public TransportSearchDfsQueryAndFetchAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, + TransportSearchCache transportSearchCache, SearchServiceTransportAction searchService, SearchPhaseController searchPhaseController) { super(settings, threadPool, clusterService, transportSearchCache, searchService, searchPhaseController); } - @Override protected void doExecute(SearchRequest searchRequest, ActionListener listener) { + @Override + protected void doExecute(SearchRequest searchRequest, ActionListener listener) { new AsyncAction(searchRequest, listener).start(); } @@ -73,19 +71,23 @@ public class TransportSearchDfsQueryAndFetchAction extends TransportSearchTypeAc super(request, listener); } - @Override protected String firstPhaseName() { + @Override + protected String firstPhaseName() { return "dfs"; } - @Override protected void sendExecuteFirstPhase(DiscoveryNode node, InternalSearchRequest request, SearchServiceListener listener) { + @Override + protected void sendExecuteFirstPhase(DiscoveryNode node, InternalSearchRequest request, SearchServiceListener listener) { searchService.sendExecuteDfs(node, request, listener); } - @Override protected void processFirstPhaseResult(ShardRouting shard, DfsSearchResult result) { + @Override + protected void processFirstPhaseResult(ShardRouting shard, DfsSearchResult result) { dfsResults.add(result); } - @Override protected void moveToSecondPhase() { + @Override + protected void moveToSecondPhase() { final AggregatedDfs dfs = searchPhaseController.aggregateDfs(dfsResults); final AtomicInteger counter = new AtomicInteger(dfsResults.size()); @@ -102,7 +104,8 @@ public class TransportSearchDfsQueryAndFetchAction extends TransportSearchTypeAc if (localOperations > 0) { if (request.operationThreading() == SearchOperationThreading.SINGLE_THREAD) { threadPool.executor(ThreadPool.Names.SEARCH).execute(new Runnable() { - @Override public void run() { + @Override + public void run() { for (final DfsSearchResult dfsResult : dfsResults) { DiscoveryNode node = nodes.get(dfsResult.shardTarget().nodeId()); if (node.id().equals(nodes.localNodeId())) { @@ -120,7 +123,8 @@ public class TransportSearchDfsQueryAndFetchAction extends TransportSearchTypeAc final QuerySearchRequest querySearchRequest = new QuerySearchRequest(dfsResult.id(), dfs); if (localAsync) { threadPool.executor(ThreadPool.Names.SEARCH).execute(new Runnable() { - @Override public void run() { + @Override + public void run() { executeSecondPhase(dfsResult, counter, node, querySearchRequest); } }); @@ -135,7 +139,8 @@ public class TransportSearchDfsQueryAndFetchAction extends TransportSearchTypeAc void executeSecondPhase(final DfsSearchResult dfsResult, final AtomicInteger counter, DiscoveryNode node, final QuerySearchRequest querySearchRequest) { searchService.sendExecuteFetch(node, querySearchRequest, new SearchServiceListener() { - @Override public void onResult(QueryFetchSearchResult result) { + @Override + public void onResult(QueryFetchSearchResult result) { result.shardTarget(dfsResult.shardTarget()); queryFetchResults.put(result.shardTarget(), result); if (counter.decrementAndGet() == 0) { @@ -143,7 +148,8 @@ public class TransportSearchDfsQueryAndFetchAction extends TransportSearchTypeAc } } - @Override public void onFailure(Throwable t) { + @Override + public void onFailure(Throwable t) { if (logger.isDebugEnabled()) { logger.debug("[{}] Failed to execute query phase", t, querySearchRequest.id()); } diff --git a/src/main/java/org/elasticsearch/action/search/type/TransportSearchDfsQueryThenFetchAction.java b/src/main/java/org/elasticsearch/action/search/type/TransportSearchDfsQueryThenFetchAction.java index 41858bb44eb..9a83b5b4138 100644 --- a/src/main/java/org/elasticsearch/action/search/type/TransportSearchDfsQueryThenFetchAction.java +++ b/src/main/java/org/elasticsearch/action/search/type/TransportSearchDfsQueryThenFetchAction.java @@ -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.elasticsearch.action.search.type; +import gnu.trove.ExtTIntArrayList; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.search.ReduceSearchPhaseException; -import org.elasticsearch.action.search.SearchOperationThreading; -import org.elasticsearch.action.search.SearchRequest; -import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.action.search.ShardSearchFailure; +import org.elasticsearch.action.search.*; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.trove.ExtTIntArrayList; import org.elasticsearch.search.SearchShardTarget; import org.elasticsearch.search.action.SearchServiceListener; import org.elasticsearch.search.action.SearchServiceTransportAction; @@ -51,16 +47,18 @@ import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; /** - * @author kimchy (shay.banon) + * */ public class TransportSearchDfsQueryThenFetchAction extends TransportSearchTypeAction { - @Inject public TransportSearchDfsQueryThenFetchAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, - TransportSearchCache transportSearchCache, SearchServiceTransportAction searchService, SearchPhaseController searchPhaseController) { + @Inject + public TransportSearchDfsQueryThenFetchAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, + TransportSearchCache transportSearchCache, SearchServiceTransportAction searchService, SearchPhaseController searchPhaseController) { super(settings, threadPool, clusterService, transportSearchCache, searchService, searchPhaseController); } - @Override protected void doExecute(SearchRequest searchRequest, ActionListener listener) { + @Override + protected void doExecute(SearchRequest searchRequest, ActionListener listener) { new AsyncAction(searchRequest, listener).start(); } @@ -78,19 +76,23 @@ public class TransportSearchDfsQueryThenFetchAction extends TransportSearchTypeA super(request, listener); } - @Override protected String firstPhaseName() { + @Override + protected String firstPhaseName() { return "dfs"; } - @Override protected void sendExecuteFirstPhase(DiscoveryNode node, InternalSearchRequest request, SearchServiceListener listener) { + @Override + protected void sendExecuteFirstPhase(DiscoveryNode node, InternalSearchRequest request, SearchServiceListener listener) { searchService.sendExecuteDfs(node, request, listener); } - @Override protected void processFirstPhaseResult(ShardRouting shard, DfsSearchResult result) { + @Override + protected void processFirstPhaseResult(ShardRouting shard, DfsSearchResult result) { dfsResults.add(result); } - @Override protected void moveToSecondPhase() { + @Override + protected void moveToSecondPhase() { final AggregatedDfs dfs = searchPhaseController.aggregateDfs(dfsResults); final AtomicInteger counter = new AtomicInteger(dfsResults.size()); @@ -109,7 +111,8 @@ public class TransportSearchDfsQueryThenFetchAction extends TransportSearchTypeA if (localOperations > 0) { if (request.operationThreading() == SearchOperationThreading.SINGLE_THREAD) { threadPool.executor(ThreadPool.Names.SEARCH).execute(new Runnable() { - @Override public void run() { + @Override + public void run() { for (final DfsSearchResult dfsResult : dfsResults) { DiscoveryNode node = nodes.get(dfsResult.shardTarget().nodeId()); if (node.id().equals(nodes.localNodeId())) { @@ -127,7 +130,8 @@ public class TransportSearchDfsQueryThenFetchAction extends TransportSearchTypeA final QuerySearchRequest querySearchRequest = new QuerySearchRequest(dfsResult.id(), dfs); if (localAsync) { threadPool.executor(ThreadPool.Names.SEARCH).execute(new Runnable() { - @Override public void run() { + @Override + public void run() { executeQuery(dfsResult, counter, querySearchRequest, node); } }); @@ -142,7 +146,8 @@ public class TransportSearchDfsQueryThenFetchAction extends TransportSearchTypeA void executeQuery(final DfsSearchResult dfsResult, final AtomicInteger counter, final QuerySearchRequest querySearchRequest, DiscoveryNode node) { searchService.sendExecuteQuery(node, querySearchRequest, new SearchServiceListener() { - @Override public void onResult(QuerySearchResult result) { + @Override + public void onResult(QuerySearchResult result) { result.shardTarget(dfsResult.shardTarget()); queryResults.put(result.shardTarget(), result); if (counter.decrementAndGet() == 0) { @@ -150,7 +155,8 @@ public class TransportSearchDfsQueryThenFetchAction extends TransportSearchTypeA } } - @Override public void onFailure(Throwable t) { + @Override + public void onFailure(Throwable t) { if (logger.isDebugEnabled()) { logger.debug("[{}] Failed to execute query phase", t, querySearchRequest.id()); } @@ -196,7 +202,8 @@ public class TransportSearchDfsQueryThenFetchAction extends TransportSearchTypeA if (localOperations > 0) { if (request.operationThreading() == SearchOperationThreading.SINGLE_THREAD) { threadPool.executor(ThreadPool.Names.SEARCH).execute(new Runnable() { - @Override public void run() { + @Override + public void run() { for (final Map.Entry entry : docIdsToLoad.entrySet()) { DiscoveryNode node = nodes.get(entry.getKey().nodeId()); if (node.id().equals(nodes.localNodeId())) { @@ -214,7 +221,8 @@ public class TransportSearchDfsQueryThenFetchAction extends TransportSearchTypeA final FetchSearchRequest fetchSearchRequest = new FetchSearchRequest(queryResults.get(entry.getKey()).id(), entry.getValue()); if (localAsync) { threadPool.executor(ThreadPool.Names.SEARCH).execute(new Runnable() { - @Override public void run() { + @Override + public void run() { executeFetch(entry.getKey(), counter, fetchSearchRequest, node); } }); @@ -229,7 +237,8 @@ public class TransportSearchDfsQueryThenFetchAction extends TransportSearchTypeA void executeFetch(final SearchShardTarget shardTarget, final AtomicInteger counter, final FetchSearchRequest fetchSearchRequest, DiscoveryNode node) { searchService.sendExecuteFetch(node, fetchSearchRequest, new SearchServiceListener() { - @Override public void onResult(FetchSearchResult result) { + @Override + public void onResult(FetchSearchResult result) { result.shardTarget(shardTarget); fetchResults.put(result.shardTarget(), result); if (counter.decrementAndGet() == 0) { @@ -237,7 +246,8 @@ public class TransportSearchDfsQueryThenFetchAction extends TransportSearchTypeA } } - @Override public void onFailure(Throwable t) { + @Override + public void onFailure(Throwable t) { if (logger.isDebugEnabled()) { logger.debug("[{}] Failed to execute fetch phase", t, fetchSearchRequest.id()); } diff --git a/src/main/java/org/elasticsearch/action/search/type/TransportSearchHelper.java b/src/main/java/org/elasticsearch/action/search/type/TransportSearchHelper.java index 5bce195f5ea..3cd71fd8231 100644 --- a/src/main/java/org/elasticsearch/action/search/type/TransportSearchHelper.java +++ b/src/main/java/org/elasticsearch/action/search/type/TransportSearchHelper.java @@ -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,8 @@ package org.elasticsearch.action.search.type; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.ElasticSearchIllegalStateException; import org.elasticsearch.action.search.SearchRequest; @@ -30,8 +32,6 @@ import org.elasticsearch.common.Base64; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Strings; import org.elasticsearch.common.Unicode; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.Maps; import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.search.SearchPhaseResult; import org.elasticsearch.search.internal.InternalScrollSearchRequest; @@ -42,7 +42,7 @@ import java.util.Collection; import java.util.Map; /** - * @author kimchy (Shay Banon) + * */ public abstract class TransportSearchHelper { diff --git a/src/main/java/org/elasticsearch/action/search/type/TransportSearchQueryAndFetchAction.java b/src/main/java/org/elasticsearch/action/search/type/TransportSearchQueryAndFetchAction.java index 1352302190f..92665a0d7f9 100644 --- a/src/main/java/org/elasticsearch/action/search/type/TransportSearchQueryAndFetchAction.java +++ b/src/main/java/org/elasticsearch/action/search/type/TransportSearchQueryAndFetchAction.java @@ -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,19 +38,21 @@ import org.elasticsearch.threadpool.ThreadPool; import java.util.Map; -import static org.elasticsearch.action.search.type.TransportSearchHelper.*; +import static org.elasticsearch.action.search.type.TransportSearchHelper.buildScrollId; /** - * @author kimchy (shay.banon) + * */ public class TransportSearchQueryAndFetchAction extends TransportSearchTypeAction { - @Inject public TransportSearchQueryAndFetchAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, - TransportSearchCache transportSearchCache, SearchServiceTransportAction searchService, SearchPhaseController searchPhaseController) { + @Inject + public TransportSearchQueryAndFetchAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, + TransportSearchCache transportSearchCache, SearchServiceTransportAction searchService, SearchPhaseController searchPhaseController) { super(settings, threadPool, clusterService, transportSearchCache, searchService, searchPhaseController); } - @Override protected void doExecute(SearchRequest searchRequest, ActionListener listener) { + @Override + protected void doExecute(SearchRequest searchRequest, ActionListener listener) { new AsyncAction(searchRequest, listener).start(); } @@ -63,19 +65,23 @@ public class TransportSearchQueryAndFetchAction extends TransportSearchTypeActio super(request, listener); } - @Override protected String firstPhaseName() { + @Override + protected String firstPhaseName() { return "query_fetch"; } - @Override protected void sendExecuteFirstPhase(DiscoveryNode node, InternalSearchRequest request, SearchServiceListener listener) { + @Override + protected void sendExecuteFirstPhase(DiscoveryNode node, InternalSearchRequest request, SearchServiceListener listener) { searchService.sendExecuteFetch(node, request, listener); } - @Override protected void processFirstPhaseResult(ShardRouting shard, QueryFetchSearchResult result) { + @Override + protected void processFirstPhaseResult(ShardRouting shard, QueryFetchSearchResult result) { queryFetchResults.put(result.shardTarget(), result); } - @Override protected void moveToSecondPhase() throws Exception { + @Override + protected void moveToSecondPhase() throws Exception { sortedShardList = searchPhaseController.sortDocs(queryFetchResults.values()); final InternalSearchResponse internalResponse = searchPhaseController.merge(sortedShardList, queryFetchResults, queryFetchResults); String scrollId = null; diff --git a/src/main/java/org/elasticsearch/action/search/type/TransportSearchQueryThenFetchAction.java b/src/main/java/org/elasticsearch/action/search/type/TransportSearchQueryThenFetchAction.java index 67bf4377765..18d7b9183a2 100644 --- a/src/main/java/org/elasticsearch/action/search/type/TransportSearchQueryThenFetchAction.java +++ b/src/main/java/org/elasticsearch/action/search/type/TransportSearchQueryThenFetchAction.java @@ -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.elasticsearch.action.search.type; +import gnu.trove.ExtTIntArrayList; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.search.ReduceSearchPhaseException; -import org.elasticsearch.action.search.SearchOperationThreading; -import org.elasticsearch.action.search.SearchRequest; -import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.action.search.ShardSearchFailure; +import org.elasticsearch.action.search.*; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.trove.ExtTIntArrayList; import org.elasticsearch.search.SearchShardTarget; import org.elasticsearch.search.action.SearchServiceListener; import org.elasticsearch.search.action.SearchServiceTransportAction; @@ -47,16 +43,18 @@ import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; /** - * @author kimchy (shay.banon) + * */ public class TransportSearchQueryThenFetchAction extends TransportSearchTypeAction { - @Inject public TransportSearchQueryThenFetchAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, - TransportSearchCache transportSearchCache, SearchServiceTransportAction searchService, SearchPhaseController searchPhaseController) { + @Inject + public TransportSearchQueryThenFetchAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, + TransportSearchCache transportSearchCache, SearchServiceTransportAction searchService, SearchPhaseController searchPhaseController) { super(settings, threadPool, clusterService, transportSearchCache, searchService, searchPhaseController); } - @Override protected void doExecute(SearchRequest searchRequest, ActionListener listener) { + @Override + protected void doExecute(SearchRequest searchRequest, ActionListener listener) { new AsyncAction(searchRequest, listener).start(); } @@ -72,19 +70,23 @@ public class TransportSearchQueryThenFetchAction extends TransportSearchTypeActi super(request, listener); } - @Override protected String firstPhaseName() { + @Override + protected String firstPhaseName() { return "query"; } - @Override protected void sendExecuteFirstPhase(DiscoveryNode node, InternalSearchRequest request, SearchServiceListener listener) { + @Override + protected void sendExecuteFirstPhase(DiscoveryNode node, InternalSearchRequest request, SearchServiceListener listener) { searchService.sendExecuteQuery(node, request, listener); } - @Override protected void processFirstPhaseResult(ShardRouting shard, QuerySearchResult result) { + @Override + protected void processFirstPhaseResult(ShardRouting shard, QuerySearchResult result) { queryResults.put(result.shardTarget(), result); } - @Override protected void moveToSecondPhase() { + @Override + protected void moveToSecondPhase() { sortedShardList = searchPhaseController.sortDocs(queryResults.values()); final Map docIdsToLoad = searchPhaseController.docIdsToLoad(sortedShardList); this.docIdsToLoad = docIdsToLoad; @@ -110,7 +112,8 @@ public class TransportSearchQueryThenFetchAction extends TransportSearchTypeActi if (localOperations > 0) { if (request.operationThreading() == SearchOperationThreading.SINGLE_THREAD) { threadPool.executor(ThreadPool.Names.SEARCH).execute(new Runnable() { - @Override public void run() { + @Override + public void run() { for (final Map.Entry entry : docIdsToLoad.entrySet()) { DiscoveryNode node = nodes.get(entry.getKey().nodeId()); if (node.id().equals(nodes.localNodeId())) { @@ -128,7 +131,8 @@ public class TransportSearchQueryThenFetchAction extends TransportSearchTypeActi final FetchSearchRequest fetchSearchRequest = new FetchSearchRequest(queryResults.get(entry.getKey()).id(), entry.getValue()); if (localAsync) { threadPool.executor(ThreadPool.Names.SEARCH).execute(new Runnable() { - @Override public void run() { + @Override + public void run() { executeFetch(entry.getKey(), counter, fetchSearchRequest, node); } }); @@ -143,7 +147,8 @@ public class TransportSearchQueryThenFetchAction extends TransportSearchTypeActi void executeFetch(final SearchShardTarget shardTarget, final AtomicInteger counter, final FetchSearchRequest fetchSearchRequest, DiscoveryNode node) { searchService.sendExecuteFetch(node, fetchSearchRequest, new SearchServiceListener() { - @Override public void onResult(FetchSearchResult result) { + @Override + public void onResult(FetchSearchResult result) { result.shardTarget(shardTarget); fetchResults.put(result.shardTarget(), result); if (counter.decrementAndGet() == 0) { @@ -151,7 +156,8 @@ public class TransportSearchQueryThenFetchAction extends TransportSearchTypeActi } } - @Override public void onFailure(Throwable t) { + @Override + public void onFailure(Throwable t) { if (logger.isDebugEnabled()) { logger.debug("[{}] Failed to execute fetch phase", t, fetchSearchRequest.id()); } diff --git a/src/main/java/org/elasticsearch/action/search/type/TransportSearchScanAction.java b/src/main/java/org/elasticsearch/action/search/type/TransportSearchScanAction.java index bab1b50b473..39e5612bf9a 100644 --- a/src/main/java/org/elasticsearch/action/search/type/TransportSearchScanAction.java +++ b/src/main/java/org/elasticsearch/action/search/type/TransportSearchScanAction.java @@ -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.search.type; +import com.google.common.collect.ImmutableMap; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.routing.ShardRouting; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.search.SearchShardTarget; @@ -42,16 +42,18 @@ import org.elasticsearch.threadpool.ThreadPool; import java.util.Map; -import static org.elasticsearch.action.search.type.TransportSearchHelper.*; +import static org.elasticsearch.action.search.type.TransportSearchHelper.buildScrollId; public class TransportSearchScanAction extends TransportSearchTypeAction { - @Inject public TransportSearchScanAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, - TransportSearchCache transportSearchCache, SearchServiceTransportAction searchService, SearchPhaseController searchPhaseController) { + @Inject + public TransportSearchScanAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, + TransportSearchCache transportSearchCache, SearchServiceTransportAction searchService, SearchPhaseController searchPhaseController) { super(settings, threadPool, clusterService, transportSearchCache, searchService, searchPhaseController); } - @Override protected void doExecute(SearchRequest searchRequest, ActionListener listener) { + @Override + protected void doExecute(SearchRequest searchRequest, ActionListener listener) { new AsyncAction(searchRequest, listener).start(); } @@ -63,19 +65,23 @@ public class TransportSearchScanAction extends TransportSearchTypeAction { super(request, listener); } - @Override protected String firstPhaseName() { + @Override + protected String firstPhaseName() { return "init_scan"; } - @Override protected void sendExecuteFirstPhase(DiscoveryNode node, InternalSearchRequest request, SearchServiceListener listener) { + @Override + protected void sendExecuteFirstPhase(DiscoveryNode node, InternalSearchRequest request, SearchServiceListener listener) { searchService.sendExecuteScan(node, request, listener); } - @Override protected void processFirstPhaseResult(ShardRouting shard, QuerySearchResult result) { + @Override + protected void processFirstPhaseResult(ShardRouting shard, QuerySearchResult result) { queryResults.put(result.shardTarget(), result); } - @Override protected void moveToSecondPhase() throws Exception { + @Override + protected void moveToSecondPhase() throws Exception { final InternalSearchResponse internalResponse = searchPhaseController.merge(EMPTY_DOCS, queryResults, ImmutableMap.of()); String scrollId = null; if (request.scroll() != null) { diff --git a/src/main/java/org/elasticsearch/action/search/type/TransportSearchScrollQueryAndFetchAction.java b/src/main/java/org/elasticsearch/action/search/type/TransportSearchScrollQueryAndFetchAction.java index 596eb4ddf4d..8ee85f779d3 100644 --- a/src/main/java/org/elasticsearch/action/search/type/TransportSearchScrollQueryAndFetchAction.java +++ b/src/main/java/org/elasticsearch/action/search/type/TransportSearchScrollQueryAndFetchAction.java @@ -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,10 +41,11 @@ import java.util.Collection; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; -import static org.elasticsearch.action.search.type.TransportSearchHelper.*; +import static org.elasticsearch.action.search.type.TransportSearchHelper.buildShardFailures; +import static org.elasticsearch.action.search.type.TransportSearchHelper.internalScrollSearchRequest; /** - * @author kimchy (shay.banon) + * */ public class TransportSearchScrollQueryAndFetchAction extends AbstractComponent { @@ -58,9 +59,10 @@ public class TransportSearchScrollQueryAndFetchAction extends AbstractComponent private final TransportSearchCache searchCache; - @Inject public TransportSearchScrollQueryAndFetchAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, - TransportSearchCache searchCache, - SearchServiceTransportAction searchService, SearchPhaseController searchPhaseController) { + @Inject + public TransportSearchScrollQueryAndFetchAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, + TransportSearchCache searchCache, + SearchServiceTransportAction searchService, SearchPhaseController searchPhaseController) { super(settings); this.threadPool = threadPool; this.clusterService = clusterService; @@ -131,7 +133,8 @@ public class TransportSearchScrollQueryAndFetchAction extends AbstractComponent if (localOperations > 0) { if (request.operationThreading() == SearchOperationThreading.SINGLE_THREAD) { threadPool.executor(ThreadPool.Names.SEARCH).execute(new Runnable() { - @Override public void run() { + @Override + public void run() { for (Tuple target : scrollId.context()) { DiscoveryNode node = nodes.get(target.v1()); if (node != null && nodes.localNodeId().equals(node.id())) { @@ -147,7 +150,8 @@ public class TransportSearchScrollQueryAndFetchAction extends AbstractComponent if (node != null && nodes.localNodeId().equals(node.id())) { if (localAsync) { threadPool.executor(ThreadPool.Names.SEARCH).execute(new Runnable() { - @Override public void run() { + @Override + public void run() { executePhase(node, target.v2()); } }); @@ -176,14 +180,16 @@ public class TransportSearchScrollQueryAndFetchAction extends AbstractComponent private void executePhase(DiscoveryNode node, final long searchId) { searchService.sendExecuteFetch(node, internalScrollSearchRequest(searchId, request), new SearchServiceListener() { - @Override public void onResult(QueryFetchSearchResult result) { + @Override + public void onResult(QueryFetchSearchResult result) { queryFetchResults.put(result.shardTarget(), result); if (counter.decrementAndGet() == 0) { finishHim(); } } - @Override public void onFailure(Throwable t) { + @Override + public void onFailure(Throwable t) { if (logger.isDebugEnabled()) { logger.debug("[{}] Failed to execute query phase", t, searchId); } diff --git a/src/main/java/org/elasticsearch/action/search/type/TransportSearchScrollQueryThenFetchAction.java b/src/main/java/org/elasticsearch/action/search/type/TransportSearchScrollQueryThenFetchAction.java index f76cf0d1ed2..0be070da77b 100644 --- a/src/main/java/org/elasticsearch/action/search/type/TransportSearchScrollQueryThenFetchAction.java +++ b/src/main/java/org/elasticsearch/action/search/type/TransportSearchScrollQueryThenFetchAction.java @@ -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.search.type; +import gnu.trove.ExtTIntArrayList; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.search.*; import org.elasticsearch.cluster.ClusterService; @@ -28,7 +29,6 @@ import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.trove.ExtTIntArrayList; import org.elasticsearch.search.SearchShardTarget; import org.elasticsearch.search.action.SearchServiceListener; import org.elasticsearch.search.action.SearchServiceTransportAction; @@ -45,10 +45,11 @@ import java.util.Collection; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; -import static org.elasticsearch.action.search.type.TransportSearchHelper.*; +import static org.elasticsearch.action.search.type.TransportSearchHelper.buildShardFailures; +import static org.elasticsearch.action.search.type.TransportSearchHelper.internalScrollSearchRequest; /** - * @author kimchy (shay.banon) + * */ public class TransportSearchScrollQueryThenFetchAction extends AbstractComponent { @@ -62,9 +63,10 @@ public class TransportSearchScrollQueryThenFetchAction extends AbstractComponent private final TransportSearchCache searchCache; - @Inject public TransportSearchScrollQueryThenFetchAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, - TransportSearchCache searchCache, - SearchServiceTransportAction searchService, SearchPhaseController searchPhaseController) { + @Inject + public TransportSearchScrollQueryThenFetchAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, + TransportSearchCache searchCache, + SearchServiceTransportAction searchService, SearchPhaseController searchPhaseController) { super(settings); this.threadPool = threadPool; this.clusterService = clusterService; @@ -137,7 +139,8 @@ public class TransportSearchScrollQueryThenFetchAction extends AbstractComponent if (localOperations > 0) { if (request.operationThreading() == SearchOperationThreading.SINGLE_THREAD) { threadPool.executor(ThreadPool.Names.SEARCH).execute(new Runnable() { - @Override public void run() { + @Override + public void run() { for (Tuple target : scrollId.context()) { DiscoveryNode node = nodes.get(target.v1()); if (node != null && nodes.localNodeId().equals(node.id())) { @@ -153,7 +156,8 @@ public class TransportSearchScrollQueryThenFetchAction extends AbstractComponent if (node != null && nodes.localNodeId().equals(node.id())) { if (localAsync) { threadPool.executor(ThreadPool.Names.SEARCH).execute(new Runnable() { - @Override public void run() { + @Override + public void run() { executeQueryPhase(counter, node, target.v2()); } }); @@ -168,14 +172,16 @@ public class TransportSearchScrollQueryThenFetchAction extends AbstractComponent private void executeQueryPhase(final AtomicInteger counter, DiscoveryNode node, final long searchId) { searchService.sendExecuteQuery(node, internalScrollSearchRequest(searchId, request), new SearchServiceListener() { - @Override public void onResult(QuerySearchResult result) { + @Override + public void onResult(QuerySearchResult result) { queryResults.put(result.shardTarget(), result); if (counter.decrementAndGet() == 0) { executeFetchPhase(); } } - @Override public void onFailure(Throwable t) { + @Override + public void onFailure(Throwable t) { if (logger.isDebugEnabled()) { logger.debug("[{}] Failed to execute query phase", t, searchId); } @@ -204,7 +210,8 @@ public class TransportSearchScrollQueryThenFetchAction extends AbstractComponent FetchSearchRequest fetchSearchRequest = new FetchSearchRequest(queryResults.get(shardTarget).id(), docIds); DiscoveryNode node = nodes.get(shardTarget.nodeId()); searchService.sendExecuteFetch(node, fetchSearchRequest, new SearchServiceListener() { - @Override public void onResult(FetchSearchResult result) { + @Override + public void onResult(FetchSearchResult result) { result.shardTarget(entry.getKey()); fetchResults.put(result.shardTarget(), result); if (counter.decrementAndGet() == 0) { @@ -212,7 +219,8 @@ public class TransportSearchScrollQueryThenFetchAction extends AbstractComponent } } - @Override public void onFailure(Throwable t) { + @Override + public void onFailure(Throwable t) { if (logger.isDebugEnabled()) { logger.debug("Failed to execute fetch phase", t); } diff --git a/src/main/java/org/elasticsearch/action/search/type/TransportSearchScrollScanAction.java b/src/main/java/org/elasticsearch/action/search/type/TransportSearchScrollScanAction.java index 4def8bea7b7..4b9bfa1be0a 100644 --- a/src/main/java/org/elasticsearch/action/search/type/TransportSearchScrollScanAction.java +++ b/src/main/java/org/elasticsearch/action/search/type/TransportSearchScrollScanAction.java @@ -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,10 +45,11 @@ import java.util.Collection; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; -import static org.elasticsearch.action.search.type.TransportSearchHelper.*; +import static org.elasticsearch.action.search.type.TransportSearchHelper.buildShardFailures; +import static org.elasticsearch.action.search.type.TransportSearchHelper.internalScrollSearchRequest; /** - * @author kimchy (shay.banon) + * */ public class TransportSearchScrollScanAction extends AbstractComponent { @@ -62,9 +63,10 @@ public class TransportSearchScrollScanAction extends AbstractComponent { private final TransportSearchCache searchCache; - @Inject public TransportSearchScrollScanAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, - TransportSearchCache searchCache, - SearchServiceTransportAction searchService, SearchPhaseController searchPhaseController) { + @Inject + public TransportSearchScrollScanAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, + TransportSearchCache searchCache, + SearchServiceTransportAction searchService, SearchPhaseController searchPhaseController) { super(settings); this.threadPool = threadPool; this.clusterService = clusterService; @@ -137,7 +139,8 @@ public class TransportSearchScrollScanAction extends AbstractComponent { if (localOperations > 0) { if (request.operationThreading() == SearchOperationThreading.SINGLE_THREAD) { threadPool.executor(ThreadPool.Names.SEARCH).execute(new Runnable() { - @Override public void run() { + @Override + public void run() { for (Tuple target : scrollId.context()) { DiscoveryNode node = nodes.get(target.v1()); if (node != null && nodes.localNodeId().equals(node.id())) { @@ -153,7 +156,8 @@ public class TransportSearchScrollScanAction extends AbstractComponent { if (node != null && nodes.localNodeId().equals(node.id())) { if (localAsync) { threadPool.executor(ThreadPool.Names.SEARCH).execute(new Runnable() { - @Override public void run() { + @Override + public void run() { executePhase(node, target.v2()); } }); @@ -182,14 +186,16 @@ public class TransportSearchScrollScanAction extends AbstractComponent { private void executePhase(DiscoveryNode node, final long searchId) { searchService.sendExecuteScan(node, internalScrollSearchRequest(searchId, request), new SearchServiceListener() { - @Override public void onResult(QueryFetchSearchResult result) { + @Override + public void onResult(QueryFetchSearchResult result) { queryFetchResults.put(result.shardTarget(), result); if (counter.decrementAndGet() == 0) { finishHim(); } } - @Override public void onFailure(Throwable t) { + @Override + public void onFailure(Throwable t) { if (logger.isDebugEnabled()) { logger.debug("[{}] Failed to execute query phase", t, searchId); } diff --git a/src/main/java/org/elasticsearch/action/search/type/TransportSearchTypeAction.java b/src/main/java/org/elasticsearch/action/search/type/TransportSearchTypeAction.java index 2dfb0af68d7..0f94415741b 100644 --- a/src/main/java/org/elasticsearch/action/search/type/TransportSearchTypeAction.java +++ b/src/main/java/org/elasticsearch/action/search/type/TransportSearchTypeAction.java @@ -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,9 @@ package org.elasticsearch.action.search.type; +import gnu.trove.ExtTIntArrayList; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.search.ReduceSearchPhaseException; -import org.elasticsearch.action.search.SearchOperationThreading; -import org.elasticsearch.action.search.SearchPhaseExecutionException; -import org.elasticsearch.action.search.SearchRequest; -import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.action.search.ShardSearchFailure; +import org.elasticsearch.action.search.*; import org.elasticsearch.action.support.BaseAction; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.ClusterState; @@ -37,7 +33,6 @@ import org.elasticsearch.cluster.routing.ShardIterator; import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.trove.ExtTIntArrayList; import org.elasticsearch.search.SearchPhaseResult; import org.elasticsearch.search.SearchShardTarget; import org.elasticsearch.search.action.SearchServiceListener; @@ -54,10 +49,10 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; -import static org.elasticsearch.action.search.type.TransportSearchHelper.*; +import static org.elasticsearch.action.search.type.TransportSearchHelper.internalSearchRequest; /** - * @author kimchy (shay.banon) + * */ public abstract class TransportSearchTypeAction extends BaseAction { @@ -152,7 +147,8 @@ public abstract class TransportSearchTypeAction extends BaseAction() { - @Override public void onResult(FirstResult result) { + @Override + public void onResult(FirstResult result) { onFirstPhaseResult(shard, result, shardIt); } - @Override public void onFailure(Throwable t) { + @Override + public void onFailure(Throwable t) { onFirstPhaseResult(shard, shardIt, t); } }); diff --git a/src/main/java/org/elasticsearch/action/support/AbstractListenableActionFuture.java b/src/main/java/org/elasticsearch/action/support/AbstractListenableActionFuture.java index ddd9fa00487..6676d26ae77 100644 --- a/src/main/java/org/elasticsearch/action/support/AbstractListenableActionFuture.java +++ b/src/main/java/org/elasticsearch/action/support/AbstractListenableActionFuture.java @@ -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,16 +19,16 @@ package org.elasticsearch.action.support; +import com.google.common.collect.Lists; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ListenableActionFuture; -import org.elasticsearch.common.collect.Lists; import org.elasticsearch.threadpool.ThreadPool; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public abstract class AbstractListenableActionFuture extends AdapterActionFuture implements ListenableActionFuture { @@ -86,7 +86,8 @@ public abstract class AbstractListenableActionFuture extends AdapterAction } } - @Override protected void done() { + @Override + protected void done() { super.done(); synchronized (this) { executedListeners = true; @@ -110,7 +111,8 @@ public abstract class AbstractListenableActionFuture extends AdapterAction threadPool.cached().execute((Runnable) listener); } else { threadPool.cached().execute(new Runnable() { - @Override public void run() { + @Override + public void run() { ActionListener lst = (ActionListener) listener; try { lst.onResponse(actionGet()); diff --git a/src/main/java/org/elasticsearch/action/support/AdapterActionFuture.java b/src/main/java/org/elasticsearch/action/support/AdapterActionFuture.java index c5a7debad9f..5371f47b9e8 100644 --- a/src/main/java/org/elasticsearch/action/support/AdapterActionFuture.java +++ b/src/main/java/org/elasticsearch/action/support/AdapterActionFuture.java @@ -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.support; +import com.google.common.util.concurrent.AbstractFuture; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.ElasticSearchInterruptedException; import org.elasticsearch.ElasticSearchTimeoutException; import org.elasticsearch.action.ActionFuture; import org.elasticsearch.action.ActionListener; import org.elasticsearch.common.unit.TimeValue; -import org.elasticsearch.common.util.concurrent.AbstractFuture; import org.elasticsearch.common.util.concurrent.UncategorizedExecutionException; import java.util.concurrent.ExecutionException; @@ -33,13 +33,14 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; /** - * @author kimchy (shay.banon) + * */ public abstract class AdapterActionFuture extends AbstractFuture implements ActionFuture, ActionListener { private Throwable rootFailure; - @Override public T actionGet() throws ElasticSearchException { + @Override + public T actionGet() throws ElasticSearchException { try { return get(); } catch (InterruptedException e) { @@ -49,19 +50,23 @@ public abstract class AdapterActionFuture extends AbstractFuture implem } } - @Override public T actionGet(String timeout) throws ElasticSearchException { + @Override + public T actionGet(String timeout) throws ElasticSearchException { return actionGet(TimeValue.parseTimeValue(timeout, null)); } - @Override public T actionGet(long timeoutMillis) throws ElasticSearchException { + @Override + public T actionGet(long timeoutMillis) throws ElasticSearchException { return actionGet(timeoutMillis, TimeUnit.MILLISECONDS); } - @Override public T actionGet(TimeValue timeout) throws ElasticSearchException { + @Override + public T actionGet(TimeValue timeout) throws ElasticSearchException { return actionGet(timeout.millis(), TimeUnit.MILLISECONDS); } - @Override public T actionGet(long timeout, TimeUnit unit) throws ElasticSearchException { + @Override + public T actionGet(long timeout, TimeUnit unit) throws ElasticSearchException { try { return get(timeout, unit); } catch (TimeoutException e) { @@ -86,17 +91,20 @@ public abstract class AdapterActionFuture extends AbstractFuture implem } } - @Override public void onResponse(L result) { + @Override + public void onResponse(L result) { set(convert(result)); } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { setException(e); } protected abstract T convert(L listenerResponse); - @Override public Throwable getRootFailure() { + @Override + public Throwable getRootFailure() { return rootFailure; } } diff --git a/src/main/java/org/elasticsearch/action/support/BaseAction.java b/src/main/java/org/elasticsearch/action/support/BaseAction.java index e9a9dbfa221..1247d924006 100644 --- a/src/main/java/org/elasticsearch/action/support/BaseAction.java +++ b/src/main/java/org/elasticsearch/action/support/BaseAction.java @@ -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,10 +25,10 @@ import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; -import static org.elasticsearch.action.support.PlainActionFuture.*; +import static org.elasticsearch.action.support.PlainActionFuture.newFuture; /** - * @author kimchy (shay.banon) + * */ public abstract class BaseAction extends AbstractComponent implements Action { @@ -39,7 +39,8 @@ public abstract class BaseAction execute(Request request) throws ElasticSearchException { + @Override + public ActionFuture execute(Request request) throws ElasticSearchException { PlainActionFuture future = newFuture(); // since we don't have a listener, and we release a possible lock with the future // there is no need to execute it under a listener thread @@ -48,7 +49,8 @@ public abstract class BaseAction listener) { + @Override + public void execute(Request request, ActionListener listener) { if (request.listenerThreaded()) { listener = new ThreadedActionListener(threadPool, listener); } @@ -77,9 +79,11 @@ public abstract class BaseAction extends AdapterActionFuture { @@ -28,7 +28,8 @@ public class PlainActionFuture extends AdapterActionFuture { return new PlainActionFuture(); } - @Override protected T convert(T listenerResponse) { + @Override + protected T convert(T listenerResponse) { return listenerResponse; } } diff --git a/src/main/java/org/elasticsearch/action/support/PlainListenableActionFuture.java b/src/main/java/org/elasticsearch/action/support/PlainListenableActionFuture.java index a8089f15bd8..445c96f206c 100644 --- a/src/main/java/org/elasticsearch/action/support/PlainListenableActionFuture.java +++ b/src/main/java/org/elasticsearch/action/support/PlainListenableActionFuture.java @@ -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.support; import org.elasticsearch.threadpool.ThreadPool; /** - * @author kimchy (shay.banon) + * */ public class PlainListenableActionFuture extends AbstractListenableActionFuture { @@ -30,7 +30,8 @@ public class PlainListenableActionFuture extends AbstractListenableActionFutu super(listenerThreaded, threadPool); } - @Override protected T convert(T response) { + @Override + protected T convert(T response) { return response; } } diff --git a/src/main/java/org/elasticsearch/action/support/broadcast/BroadcastOperationRequest.java b/src/main/java/org/elasticsearch/action/support/broadcast/BroadcastOperationRequest.java index f3fe492d3aa..1b2c24bb20b 100644 --- a/src/main/java/org/elasticsearch/action/support/broadcast/BroadcastOperationRequest.java +++ b/src/main/java/org/elasticsearch/action/support/broadcast/BroadcastOperationRequest.java @@ -28,7 +28,7 @@ import org.elasticsearch.common.io.stream.StreamOutput; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public abstract class BroadcastOperationRequest implements ActionRequest { @@ -55,21 +55,24 @@ public abstract class BroadcastOperationRequest implements ActionRequest { return this; } - @Override public ActionRequestValidationException validate() { + @Override + public ActionRequestValidationException validate() { return null; } /** * Should the listener be called on a separate thread if needed. */ - @Override public boolean listenerThreaded() { + @Override + public boolean listenerThreaded() { return this.listenerThreaded; } /** * Should the listener be called on a separate thread if needed. */ - @Override public BroadcastOperationRequest listenerThreaded(boolean listenerThreaded) { + @Override + public BroadcastOperationRequest listenerThreaded(boolean listenerThreaded) { this.listenerThreaded = listenerThreaded; return this; } @@ -104,7 +107,8 @@ public abstract class BroadcastOperationRequest implements ActionRequest { } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { if (indices == null) { out.writeVInt(0); } else { @@ -116,7 +120,8 @@ public abstract class BroadcastOperationRequest implements ActionRequest { out.writeByte(operationThreading.id()); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { int size = in.readVInt(); if (size == 0) { indices = Strings.EMPTY_ARRAY; diff --git a/src/main/java/org/elasticsearch/action/support/broadcast/BroadcastOperationResponse.java b/src/main/java/org/elasticsearch/action/support/broadcast/BroadcastOperationResponse.java index 27ca932511a..1fd9d00fa14 100644 --- a/src/main/java/org/elasticsearch/action/support/broadcast/BroadcastOperationResponse.java +++ b/src/main/java/org/elasticsearch/action/support/broadcast/BroadcastOperationResponse.java @@ -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.support.broadcast; +import com.google.common.collect.ImmutableList; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.ShardOperationFailedException; -import org.elasticsearch.common.collect.ImmutableList; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -29,12 +29,12 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; -import static org.elasticsearch.action.support.DefaultShardOperationFailedException.*; +import static org.elasticsearch.action.support.DefaultShardOperationFailedException.readShardOperationFailed; /** * Base class for all broadcast operation based responses. * - * @author kimchy (shay.banon) + * */ public abstract class BroadcastOperationResponse implements ActionResponse { @@ -118,7 +118,8 @@ public abstract class BroadcastOperationResponse implements ActionResponse { return shardFailures; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { totalShards = in.readVInt(); successfulShards = in.readVInt(); failedShards = in.readVInt(); @@ -131,7 +132,8 @@ public abstract class BroadcastOperationResponse implements ActionResponse { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeVInt(totalShards); out.writeVInt(successfulShards); out.writeVInt(failedShards); diff --git a/src/main/java/org/elasticsearch/action/support/broadcast/BroadcastOperationThreading.java b/src/main/java/org/elasticsearch/action/support/broadcast/BroadcastOperationThreading.java index 5a167e2c81c..45a66e42720 100644 --- a/src/main/java/org/elasticsearch/action/support/broadcast/BroadcastOperationThreading.java +++ b/src/main/java/org/elasticsearch/action/support/broadcast/BroadcastOperationThreading.java @@ -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; * Controls the operation threading model for broadcast operation that are performed * locally on the executing node. * - * @author kimchy (shay.banon) + * */ public enum BroadcastOperationThreading { /** diff --git a/src/main/java/org/elasticsearch/action/support/broadcast/BroadcastShardOperationFailedException.java b/src/main/java/org/elasticsearch/action/support/broadcast/BroadcastShardOperationFailedException.java index 52fc31da7f0..6a4f4f1d65f 100644 --- a/src/main/java/org/elasticsearch/action/support/broadcast/BroadcastShardOperationFailedException.java +++ b/src/main/java/org/elasticsearch/action/support/broadcast/BroadcastShardOperationFailedException.java @@ -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.index.shard.ShardId; /** * An exception indicating that a failure occurred performing an operation on the shard. * - * @author kimchy (shay.banon) + * */ public class BroadcastShardOperationFailedException extends IndexShardException implements ElasticSearchWrapperException { diff --git a/src/main/java/org/elasticsearch/action/support/broadcast/BroadcastShardOperationRequest.java b/src/main/java/org/elasticsearch/action/support/broadcast/BroadcastShardOperationRequest.java index 40ac5b32c79..0ce7209d896 100644 --- a/src/main/java/org/elasticsearch/action/support/broadcast/BroadcastShardOperationRequest.java +++ b/src/main/java/org/elasticsearch/action/support/broadcast/BroadcastShardOperationRequest.java @@ -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 abstract class BroadcastShardOperationRequest implements Streamable { @@ -50,12 +50,14 @@ public abstract class BroadcastShardOperationRequest implements Streamable { return this.shardId; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { index = in.readUTF(); shardId = in.readVInt(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(index); out.writeVInt(shardId); } diff --git a/src/main/java/org/elasticsearch/action/support/broadcast/BroadcastShardOperationResponse.java b/src/main/java/org/elasticsearch/action/support/broadcast/BroadcastShardOperationResponse.java index 8cefb082fa2..2e19741619d 100644 --- a/src/main/java/org/elasticsearch/action/support/broadcast/BroadcastShardOperationResponse.java +++ b/src/main/java/org/elasticsearch/action/support/broadcast/BroadcastShardOperationResponse.java @@ -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 abstract class BroadcastShardOperationResponse implements Streamable { @@ -59,12 +59,14 @@ public abstract class BroadcastShardOperationResponse implements Streamable { return shardId(); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { index = in.readUTF(); shardId = in.readVInt(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(index); out.writeVInt(shardId); } diff --git a/src/main/java/org/elasticsearch/action/support/broadcast/TransportBroadcastOperationAction.java b/src/main/java/org/elasticsearch/action/support/broadcast/TransportBroadcastOperationAction.java index d8bd9cf0aa2..57cbe6bdfa4 100644 --- a/src/main/java/org/elasticsearch/action/support/broadcast/TransportBroadcastOperationAction.java +++ b/src/main/java/org/elasticsearch/action/support/broadcast/TransportBroadcastOperationAction.java @@ -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,17 +32,13 @@ import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.transport.BaseTransportRequestHandler; -import org.elasticsearch.transport.BaseTransportResponseHandler; -import org.elasticsearch.transport.TransportChannel; -import org.elasticsearch.transport.TransportException; -import org.elasticsearch.transport.TransportService; +import org.elasticsearch.transport.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReferenceArray; /** - * @author kimchy (shay.banon) + * */ public abstract class TransportBroadcastOperationAction extends BaseAction { @@ -71,7 +67,8 @@ public abstract class TransportBroadcastOperationAction listener) { + @Override + protected void doExecute(Request request, ActionListener listener) { new AsyncBroadcastAction(request, listener).start(); } @@ -178,7 +175,8 @@ public abstract class TransportBroadcastOperationAction() { - @Override public ShardResponse newInstance() { + @Override + public ShardResponse newInstance() { return newShardResponse(); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } - @Override public void handleResponse(ShardResponse response) { + @Override + public void handleResponse(ShardResponse response) { onOperation(shard, response); } - @Override public void handleException(TransportException e) { + @Override + public void handleException(TransportException e) { onOperation(shard, shardIt, e); } }); @@ -262,14 +265,16 @@ public abstract class TransportBroadcastOperationAction { - @Override public Request newInstance() { + @Override + public Request newInstance() { return newRequest(); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } - @Override public void messageReceived(Request request, final TransportChannel channel) throws Exception { + @Override + public void messageReceived(Request request, final TransportChannel channel) throws Exception { // we just send back a response, no need to fork a listener request.listenerThreaded(false); // we don't spawn, so if we get a request with no threading, change it to single threaded @@ -349,7 +357,8 @@ public abstract class TransportBroadcastOperationAction() { - @Override public void onResponse(Response response) { + @Override + public void onResponse(Response response) { try { channel.sendResponse(response); } catch (Exception e) { @@ -357,7 +366,8 @@ public abstract class TransportBroadcastOperationAction { - @Override public ShardRequest newInstance() { + @Override + public ShardRequest newInstance() { return newShardRequest(); } - @Override public String executor() { + @Override + public String executor() { return executor; } - @Override public void messageReceived(final ShardRequest request, final TransportChannel channel) throws Exception { + @Override + public void messageReceived(final ShardRequest request, final TransportChannel channel) throws Exception { channel.sendResponse(shardOperation(request)); } } diff --git a/src/main/java/org/elasticsearch/action/support/master/MasterNodeOperationRequest.java b/src/main/java/org/elasticsearch/action/support/master/MasterNodeOperationRequest.java index 74e1cce1e30..5be65a3ef9b 100644 --- a/src/main/java/org/elasticsearch/action/support/master/MasterNodeOperationRequest.java +++ b/src/main/java/org/elasticsearch/action/support/master/MasterNodeOperationRequest.java @@ -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,18 +29,20 @@ import java.io.IOException; /** * A based request for master based operation. * - * @author kimchy (shay.banon) + * */ public abstract class MasterNodeOperationRequest implements ActionRequest { private TimeValue masterNodeTimeout = TimeValue.timeValueSeconds(30); - @Override public boolean listenerThreaded() { + @Override + public boolean listenerThreaded() { // always threaded return true; } - @Override public MasterNodeOperationRequest listenerThreaded(boolean listenerThreaded) { + @Override + public MasterNodeOperationRequest listenerThreaded(boolean listenerThreaded) { // really, does not mean anything in this case return this; } @@ -64,11 +66,13 @@ public abstract class MasterNodeOperationRequest implements ActionRequest { return this.masterNodeTimeout; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { masterNodeTimeout = TimeValue.readTimeValue(in); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { masterNodeTimeout.writeTo(out); } } diff --git a/src/main/java/org/elasticsearch/action/support/master/TransportMasterNodeOperationAction.java b/src/main/java/org/elasticsearch/action/support/master/TransportMasterNodeOperationAction.java index c549dabab97..8e5eee0ab65 100644 --- a/src/main/java/org/elasticsearch/action/support/master/TransportMasterNodeOperationAction.java +++ b/src/main/java/org/elasticsearch/action/support/master/TransportMasterNodeOperationAction.java @@ -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,7 @@ import org.elasticsearch.transport.*; /** * A base class for operations that needs to be performed on the master node. * - * @author kimchy (shay.banon) + * */ public abstract class TransportMasterNodeOperationAction extends BaseAction { @@ -83,7 +83,8 @@ public abstract class TransportMasterNodeOperationAction listener) { + @Override + protected void doExecute(final Request request, final ActionListener listener) { innerExecute(request, listener, false); } @@ -99,7 +100,8 @@ public abstract class TransportMasterNodeOperationAction() { - @Override public Response newInstance() { + @Override + public Response newInstance() { return newResponse(); } - @Override public void handleResponse(Response response) { + @Override + public void handleResponse(Response response) { listener.onResponse(response); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } - @Override public void handleException(final TransportException exp) { + @Override + public void handleException(final TransportException exp) { if (exp.unwrapCause() instanceof ConnectTransportException) { // we want to retry here a bit to see if a new master is elected clusterService.add(request.masterNodeTimeout(), new TimeoutClusterStateListener() { - @Override public void postAdded() { + @Override + public void postAdded() { ClusterState clusterStateV2 = clusterService.state(); if (!clusterState.nodes().masterNodeId().equals(clusterStateV2.nodes().masterNodeId())) { // master changes while adding the listener, try here @@ -199,17 +214,20 @@ public abstract class TransportMasterNodeOperationAction { - @Override public Request newInstance() { + @Override + public Request newInstance() { return newRequest(); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } - @Override public void messageReceived(final Request request, final TransportChannel channel) throws Exception { + @Override + public void messageReceived(final Request request, final TransportChannel channel) throws Exception { // we just send back a response, no need to fork a listener request.listenerThreaded(false); execute(request, new ActionListener() { - @Override public void onResponse(Response response) { + @Override + public void onResponse(Response response) { try { channel.sendResponse(response); } catch (Exception e) { @@ -246,7 +268,8 @@ public abstract class TransportMasterNodeOperationAction implements ActionResponse, Iterable { @@ -68,7 +68,8 @@ public abstract class NodesOperationResponse iterator() { + @Override + public Iterator iterator() { return nodesMap().values().iterator(); } @@ -86,11 +87,13 @@ public abstract class NodesOperationResponse extends BaseAction { @@ -58,8 +52,9 @@ public abstract class TransportNodesOperationAction listener) { + @Override + protected void doExecute(Request request, ActionListener listener) { new AsyncAction(request, listener).start(); } @@ -134,7 +130,8 @@ public abstract class TransportNodesOperationAction() { - @Override public NodeResponse newInstance() { + @Override + public NodeResponse newInstance() { return newNodeResponse(); } - @Override public void handleResponse(NodeResponse response) { + @Override + public void handleResponse(NodeResponse response) { onOperation(response); } - @Override public void handleException(TransportException exp) { + @Override + public void handleException(TransportException exp) { onFailure(node.id(), exp); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } }); @@ -222,14 +225,17 @@ public abstract class TransportNodesOperationAction { - @Override public Request newInstance() { + @Override + public Request newInstance() { return newRequest(); } - @Override public void messageReceived(final Request request, final TransportChannel channel) throws Exception { + @Override + public void messageReceived(final Request request, final TransportChannel channel) throws Exception { request.listenerThreaded(false); execute(request, new ActionListener() { - @Override public void onResponse(Response response) { + @Override + public void onResponse(Response response) { TransportResponseOptions options = TransportResponseOptions.options().withCompress(transportCompress()); try { channel.sendResponse(response, options); @@ -238,7 +244,8 @@ public abstract class TransportNodesOperationAction { - @Override public NodeRequest newInstance() { + @Override + public NodeRequest newInstance() { return newNodeRequest(); } - @Override public void messageReceived(final NodeRequest request, final TransportChannel channel) throws Exception { + @Override + public void messageReceived(final NodeRequest request, final TransportChannel channel) throws Exception { channel.sendResponse(nodeOperation(request)); } - @Override public String toString() { + @Override + public String toString() { return transportNodeAction; } - @Override public String executor() { + @Override + public String executor() { return executor; } } diff --git a/src/main/java/org/elasticsearch/action/support/replication/IndexReplicationOperationRequest.java b/src/main/java/org/elasticsearch/action/support/replication/IndexReplicationOperationRequest.java index ba1f3eb07ce..ef57723f327 100644 --- a/src/main/java/org/elasticsearch/action/support/replication/IndexReplicationOperationRequest.java +++ b/src/main/java/org/elasticsearch/action/support/replication/IndexReplicationOperationRequest.java @@ -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.action.Actions.*; +import static org.elasticsearch.action.Actions.addValidationError; /** - * @author kimchy (Shay Banon) + * */ public class IndexReplicationOperationRequest implements ActionRequest { @@ -57,7 +57,8 @@ public class IndexReplicationOperationRequest implements ActionRequest { return this; } - @Override public boolean listenerThreaded() { + @Override + public boolean listenerThreaded() { return this.threadedListener; } @@ -69,12 +70,14 @@ public class IndexReplicationOperationRequest implements ActionRequest { return this.consistencyLevel; } - @Override public IndexReplicationOperationRequest listenerThreaded(boolean threadedListener) { + @Override + public IndexReplicationOperationRequest listenerThreaded(boolean threadedListener) { this.threadedListener = threadedListener; return this; } - @Override public ActionRequestValidationException validate() { + @Override + public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if (index == null) { validationException = addValidationError("index name missing", validationException); @@ -82,14 +85,16 @@ public class IndexReplicationOperationRequest implements ActionRequest { return validationException; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { replicationType = ReplicationType.fromId(in.readByte()); consistencyLevel = WriteConsistencyLevel.fromId(in.readByte()); timeout = TimeValue.readTimeValue(in); index = in.readUTF(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeByte(replicationType.id()); out.writeByte(consistencyLevel.id()); timeout.writeTo(out); diff --git a/src/main/java/org/elasticsearch/action/support/replication/IndicesReplicationOperationRequest.java b/src/main/java/org/elasticsearch/action/support/replication/IndicesReplicationOperationRequest.java index 16671712dcd..bac676de527 100644 --- a/src/main/java/org/elasticsearch/action/support/replication/IndicesReplicationOperationRequest.java +++ b/src/main/java/org/elasticsearch/action/support/replication/IndicesReplicationOperationRequest.java @@ -30,7 +30,7 @@ import org.elasticsearch.common.unit.TimeValue; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class IndicesReplicationOperationRequest implements ActionRequest { @@ -39,7 +39,8 @@ public class IndicesReplicationOperationRequest implements ActionRequest { protected String[] indices; private boolean threadedListener = false; - @Nullable private String routing; + @Nullable + private String routing; protected ReplicationType replicationType = ReplicationType.DEFAULT; @@ -58,21 +59,24 @@ public class IndicesReplicationOperationRequest implements ActionRequest { return this; } - @Override public ActionRequestValidationException validate() { + @Override + public ActionRequestValidationException validate() { return null; } /** * Should the listener be called on a separate thread if needed. */ - @Override public boolean listenerThreaded() { + @Override + public boolean listenerThreaded() { return this.threadedListener; } /** * Should the listener be called on a separate thread if needed. */ - @Override public IndicesReplicationOperationRequest listenerThreaded(boolean threadedListener) { + @Override + public IndicesReplicationOperationRequest listenerThreaded(boolean threadedListener) { this.threadedListener = threadedListener; return this; } @@ -89,7 +93,8 @@ public class IndicesReplicationOperationRequest implements ActionRequest { return null; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { replicationType = ReplicationType.fromId(in.readByte()); consistencyLevel = WriteConsistencyLevel.fromId(in.readByte()); timeout = TimeValue.readTimeValue(in); @@ -99,7 +104,8 @@ public class IndicesReplicationOperationRequest implements ActionRequest { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeByte(replicationType.id()); out.writeByte(consistencyLevel.id()); timeout.writeTo(out); diff --git a/src/main/java/org/elasticsearch/action/support/replication/ReplicationShardOperationFailedException.java b/src/main/java/org/elasticsearch/action/support/replication/ReplicationShardOperationFailedException.java index c4c2c953351..112f11d6d5f 100644 --- a/src/main/java/org/elasticsearch/action/support/replication/ReplicationShardOperationFailedException.java +++ b/src/main/java/org/elasticsearch/action/support/replication/ReplicationShardOperationFailedException.java @@ -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.index.shard.ShardId; /** * An exception indicating that a failure occurred performing an operation on the shard. * - * @author kimchy (shay.banon) + * */ public class ReplicationShardOperationFailedException extends IndexShardException implements ElasticSearchWrapperException { diff --git a/src/main/java/org/elasticsearch/action/support/replication/ReplicationType.java b/src/main/java/org/elasticsearch/action/support/replication/ReplicationType.java index 6ded1dc519f..2bd2f07a11a 100644 --- a/src/main/java/org/elasticsearch/action/support/replication/ReplicationType.java +++ b/src/main/java/org/elasticsearch/action/support/replication/ReplicationType.java @@ -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 diff --git a/src/main/java/org/elasticsearch/action/support/replication/ShardReplicationOperationRequest.java b/src/main/java/org/elasticsearch/action/support/replication/ShardReplicationOperationRequest.java index fb5947356ff..722bafc55fc 100644 --- a/src/main/java/org/elasticsearch/action/support/replication/ShardReplicationOperationRequest.java +++ b/src/main/java/org/elasticsearch/action/support/replication/ShardReplicationOperationRequest.java @@ -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.action.Actions.*; +import static org.elasticsearch.action.Actions.addValidationError; /** - * @author kimchy (shay.banon) + * */ public abstract class ShardReplicationOperationRequest implements ActionRequest { @@ -64,14 +64,16 @@ public abstract class ShardReplicationOperationRequest implements ActionRequest /** * Should the listener be called on a separate thread if needed. */ - @Override public boolean listenerThreaded() { + @Override + public boolean listenerThreaded() { return threadedListener; } /** * Should the listener be called on a separate thread if needed. */ - @Override public ShardReplicationOperationRequest listenerThreaded(boolean threadedListener) { + @Override + public ShardReplicationOperationRequest listenerThreaded(boolean threadedListener) { this.threadedListener = threadedListener; return this; } @@ -117,7 +119,8 @@ public abstract class ShardReplicationOperationRequest implements ActionRequest return this; } - @Override public ActionRequestValidationException validate() { + @Override + public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if (index == null) { validationException = addValidationError("index is missing", validationException); @@ -125,7 +128,8 @@ public abstract class ShardReplicationOperationRequest implements ActionRequest return validationException; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { replicationType = ReplicationType.fromId(in.readByte()); consistencyLevel = WriteConsistencyLevel.fromId(in.readByte()); timeout = TimeValue.readTimeValue(in); @@ -133,7 +137,8 @@ public abstract class ShardReplicationOperationRequest implements ActionRequest // no need to serialize threaded* parameters, since they only matter locally } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeByte(replicationType.id()); out.writeByte(consistencyLevel.id()); timeout.writeTo(out); diff --git a/src/main/java/org/elasticsearch/action/support/replication/TransportIndexReplicationOperationAction.java b/src/main/java/org/elasticsearch/action/support/replication/TransportIndexReplicationOperationAction.java index a3174ac7e9a..41ff5c31cc9 100644 --- a/src/main/java/org/elasticsearch/action/support/replication/TransportIndexReplicationOperationAction.java +++ b/src/main/java/org/elasticsearch/action/support/replication/TransportIndexReplicationOperationAction.java @@ -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,7 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReferenceArray; /** - * @author kimchy (shay.banon) + * */ public abstract class TransportIndexReplicationOperationAction extends BaseAction { @@ -48,8 +48,9 @@ public abstract class TransportIndexReplicationOperationAction shardAction; - @Inject public TransportIndexReplicationOperationAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, - TransportShardReplicationOperationAction shardAction) { + @Inject + public TransportIndexReplicationOperationAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, + TransportShardReplicationOperationAction shardAction) { super(settings, threadPool); this.clusterService = clusterService; this.shardAction = shardAction; @@ -57,7 +58,8 @@ public abstract class TransportIndexReplicationOperationAction listener) { + @Override + protected void doExecute(final Request request, final ActionListener listener) { ClusterState clusterState = clusterService.state(); // update to concrete index @@ -86,14 +88,16 @@ public abstract class TransportIndexReplicationOperationAction() { - @Override public void onResponse(ShardResponse result) { + @Override + public void onResponse(ShardResponse result) { shardsResponses.set(indexCounter.getAndIncrement(), result); if (completionCounter.decrementAndGet() == 0) { listener.onResponse(newResponseInstance(request, shardsResponses)); } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { int index = indexCounter.getAndIncrement(); if (accumulateExceptions()) { shardsResponses.set(index, e); @@ -124,19 +128,23 @@ public abstract class TransportIndexReplicationOperationAction { - @Override public Request newInstance() { + @Override + public Request newInstance() { return newRequestInstance(); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } - @Override public void messageReceived(final Request request, final TransportChannel channel) throws Exception { + @Override + public void messageReceived(final Request request, final TransportChannel channel) throws Exception { // no need to use threaded listener, since we just send a response request.listenerThreaded(false); execute(request, new ActionListener() { - @Override public void onResponse(Response result) { + @Override + public void onResponse(Response result) { try { channel.sendResponse(result); } catch (Exception e) { @@ -144,7 +152,8 @@ public abstract class TransportIndexReplicationOperationAction indexAction) { + @Inject + public TransportIndicesReplicationOperationAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, + TransportIndexReplicationOperationAction indexAction) { super(settings, threadPool); this.clusterService = clusterService; this.indexAction = indexAction; @@ -61,7 +62,8 @@ public abstract class TransportIndicesReplicationOperationAction listener) { + @Override + protected void doExecute(final Request request, final ActionListener listener) { ClusterState clusterState = clusterService.state(); // get actual indices @@ -85,14 +87,16 @@ public abstract class TransportIndicesReplicationOperationAction() { - @Override public void onResponse(IndexResponse result) { + @Override + public void onResponse(IndexResponse result) { indexResponses.set(indexCounter.getAndIncrement(), result); if (completionCounter.decrementAndGet() == 0) { listener.onResponse(newResponseInstance(request, indexResponses)); } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { e.printStackTrace(); int index = indexCounter.getAndIncrement(); if (accumulateExceptions()) { @@ -122,19 +126,23 @@ public abstract class TransportIndicesReplicationOperationAction { - @Override public Request newInstance() { + @Override + public Request newInstance() { return newRequestInstance(); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } - @Override public void messageReceived(final Request request, final TransportChannel channel) throws Exception { + @Override + public void messageReceived(final Request request, final TransportChannel channel) throws Exception { // no need for a threaded listener, since we just send a response request.listenerThreaded(false); execute(request, new ActionListener() { - @Override public void onResponse(Response result) { + @Override + public void onResponse(Response result) { try { channel.sendResponse(result); } catch (Exception e) { @@ -142,7 +150,8 @@ public abstract class TransportIndicesReplicationOperationAction listener) { + @Override + protected void doExecute(Request request, ActionListener listener) { new AsyncShardOperationAction(request, listener).start(); } @@ -195,21 +185,25 @@ public abstract class TransportShardReplicationOperationAction { - @Override public Request newInstance() { + @Override + public Request newInstance() { return newRequestInstance(); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } - @Override public void messageReceived(final Request request, final TransportChannel channel) throws Exception { + @Override + public void messageReceived(final Request request, final TransportChannel channel) throws Exception { // no need to have a threaded listener since we just send back a response request.listenerThreaded(false); // if we have a local operation, execute it on a thread since we don't spawn request.operationThreaded(true); execute(request, new ActionListener() { - @Override public void onResponse(Response result) { + @Override + public void onResponse(Response result) { try { channel.sendResponse(result); } catch (Exception e) { @@ -217,7 +211,8 @@ public abstract class TransportShardReplicationOperationAction { - @Override public ReplicaOperationRequest newInstance() { + @Override + public ReplicaOperationRequest newInstance() { return new ReplicaOperationRequest(); } - @Override public String executor() { + @Override + public String executor() { return executor; } - @Override public void messageReceived(final ReplicaOperationRequest request, final TransportChannel channel) throws Exception { + @Override + public void messageReceived(final ReplicaOperationRequest request, final TransportChannel channel) throws Exception { shardOperationOnReplica(request); channel.sendResponse(VoidStreamable.INSTANCE); } @@ -258,13 +256,15 @@ public abstract class TransportShardReplicationOperationAction() { - @Override public Response newInstance() { + @Override + public Response newInstance() { return newResponseInstance(); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } - @Override public void handleResponse(Response response) { + @Override + public void handleResponse(Response response) { listener.onResponse(response); } - @Override public void handleException(TransportException exp) { + @Override + public void handleException(TransportException exp) { // if we got disconnected from the node, or the node / shard is not in the right state (being closed) if (exp.unwrapCause() instanceof ConnectTransportException || exp.unwrapCause() instanceof NodeClosedException || exp.unwrapCause() instanceof IllegalIndexShardStateException) { @@ -449,26 +456,30 @@ public abstract class TransportShardReplicationOperationAction extends BaseAction { @@ -69,7 +65,8 @@ public abstract class TransportSingleCustomOperationAction listener) { + @Override + protected void doExecute(Request request, ActionListener listener) { new AsyncSingleAction(request, listener).start(); } @@ -137,7 +134,8 @@ public abstract class TransportSingleCustomOperationAction() { - @Override public Response newInstance() { + @Override + public Response newInstance() { return newResponse(); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } - @Override public void handleResponse(final Response response) { + @Override + public void handleResponse(final Response response) { listener.onResponse(response); } - @Override public void handleException(TransportException exp) { + @Override + public void handleException(TransportException exp) { onFailure(shard, exp); } }); @@ -235,17 +238,20 @@ public abstract class TransportSingleCustomOperationAction { - @Override public Request newInstance() { + @Override + public Request newInstance() { return newRequest(); } - @Override public void messageReceived(Request request, final TransportChannel channel) throws Exception { + @Override + public void messageReceived(Request request, final TransportChannel channel) throws Exception { // no need to have a threaded listener since we just send back a response request.listenerThreaded(false); // if we have a local operation, execute it on a thread since we don't spawn request.operationThreaded(true); execute(request, new ActionListener() { - @Override public void onResponse(Response result) { + @Override + public void onResponse(Response result) { try { channel.sendResponse(result); } catch (Exception e) { @@ -253,7 +259,8 @@ public abstract class TransportSingleCustomOperationAction { - @Override public ShardSingleOperationRequest newInstance() { + @Override + public ShardSingleOperationRequest newInstance() { return new ShardSingleOperationRequest(); } - @Override public String executor() { + @Override + public String executor() { return executor; } - @Override public void messageReceived(final ShardSingleOperationRequest request, final TransportChannel channel) throws Exception { + @Override + public void messageReceived(final ShardSingleOperationRequest request, final TransportChannel channel) throws Exception { Response response = shardOperation(request.request(), request.shardId()); channel.sendResponse(response); } @@ -306,13 +317,15 @@ public abstract class TransportSingleCustomOperationAction extends BaseAction { @@ -70,7 +66,8 @@ public abstract class TransportShardSingleOperationAction listener) { + @Override + protected void doExecute(Request request, ActionListener listener) { new AsyncSingleAction(request, listener).start(); } @@ -146,7 +143,8 @@ public abstract class TransportShardSingleOperationAction() { - @Override public Response newInstance() { + @Override + public Response newInstance() { return newResponse(); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } - @Override public void handleResponse(final Response response) { + @Override + public void handleResponse(final Response response) { listener.onResponse(response); } - @Override public void handleException(TransportException exp) { + @Override + public void handleException(TransportException exp) { onFailure(shardRouting, exp); } }); @@ -189,21 +191,25 @@ public abstract class TransportShardSingleOperationAction { - @Override public Request newInstance() { + @Override + public Request newInstance() { return newRequest(); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } - @Override public void messageReceived(Request request, final TransportChannel channel) throws Exception { + @Override + public void messageReceived(Request request, final TransportChannel channel) throws Exception { // no need to have a threaded listener since we just send back a response request.listenerThreaded(false); // if we have a local operation, execute it on a thread since we don't spawn request.operationThreaded(true); execute(request, new ActionListener() { - @Override public void onResponse(Response result) { + @Override + public void onResponse(Response result) { try { channel.sendResponse(result); } catch (Exception e) { @@ -211,7 +217,8 @@ public abstract class TransportShardSingleOperationAction { - @Override public ShardSingleOperationRequest newInstance() { + @Override + public ShardSingleOperationRequest newInstance() { return new ShardSingleOperationRequest(); } - @Override public String executor() { + @Override + public String executor() { return executor; } - @Override public void messageReceived(final ShardSingleOperationRequest request, final TransportChannel channel) throws Exception { + @Override + public void messageReceived(final ShardSingleOperationRequest request, final TransportChannel channel) throws Exception { Response response = shardOperation(request.request(), request.shardId()); channel.sendResponse(response); } @@ -260,13 +270,15 @@ public abstract class TransportShardSingleOperationAction *

All operations performed are asynchronous by nature. Each action/operation has two flavors, the first * simply returns an {@link org.elasticsearch.action.ActionFuture}, while the second accepts an * {@link org.elasticsearch.action.ActionListener}. - * + *

*

A client can either be retrieved from a {@link org.elasticsearch.node.Node} started, or connected remotely * to one or more nodes using {@link org.elasticsearch.client.transport.TransportClient}. * - * @author kimchy (shay.banon) + * * @see org.elasticsearch.node.Node#client() * @see org.elasticsearch.client.transport.TransportClient */ @@ -82,7 +82,7 @@ public interface Client { /** * Index a JSON source associated with a given index and type. - * + *

*

The id is optional, if it is not provided, one will be generated automatically. * * @param request The index request @@ -93,7 +93,7 @@ public interface Client { /** * Index a document associated with a given index and type. - * + *

*

The id is optional, if it is not provided, one will be generated automatically. * * @param request The index request @@ -104,14 +104,14 @@ public interface Client { /** * Index a document associated with a given index and type. - * + *

*

The id is optional, if it is not provided, one will be generated automatically. */ IndexRequestBuilder prepareIndex(); /** * Index a document associated with a given index and type. - * + *

*

The id is optional, if it is not provided, one will be generated automatically. * * @param index The index to index the document to @@ -121,7 +121,7 @@ public interface Client { /** * Index a document associated with a given index and type. - * + *

*

The id is optional, if it is not provided, one will be generated automatically. * * @param index The index to index the document to diff --git a/src/main/java/org/elasticsearch/client/ClusterAdminClient.java b/src/main/java/org/elasticsearch/client/ClusterAdminClient.java index 47e67eb7a54..a56e753bc6d 100644 --- a/src/main/java/org/elasticsearch/client/ClusterAdminClient.java +++ b/src/main/java/org/elasticsearch/client/ClusterAdminClient.java @@ -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 @@ -58,7 +58,7 @@ import org.elasticsearch.client.action.admin.cluster.state.ClusterStateRequestBu /** * Administrative actions/operations against indices. * - * @author kimchy (shay.banon) + * * @see AdminClient#cluster() */ public interface ClusterAdminClient { diff --git a/src/main/java/org/elasticsearch/client/IndicesAdminClient.java b/src/main/java/org/elasticsearch/client/IndicesAdminClient.java index 37a2b271ce6..3bd99224320 100644 --- a/src/main/java/org/elasticsearch/client/IndicesAdminClient.java +++ b/src/main/java/org/elasticsearch/client/IndicesAdminClient.java @@ -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 @@ -85,7 +85,7 @@ import org.elasticsearch.client.action.admin.indices.template.put.PutIndexTempla /** * Administrative actions/operations against indices. * - * @author kimchy (shay.banon) + * * @see AdminClient#indices() */ public interface IndicesAdminClient { diff --git a/src/main/java/org/elasticsearch/client/Requests.java b/src/main/java/org/elasticsearch/client/Requests.java index 2f9808ff8ac..e19bcc80654 100644 --- a/src/main/java/org/elasticsearch/client/Requests.java +++ b/src/main/java/org/elasticsearch/client/Requests.java @@ -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 @@ -60,7 +60,7 @@ import org.elasticsearch.common.xcontent.XContentType; /** * A handy one stop shop for creating requests (make sure to import static this class). * - * @author kimchy (shay.banon) + * */ public class Requests { diff --git a/src/main/java/org/elasticsearch/client/action/RequestBuilder.java b/src/main/java/org/elasticsearch/client/action/RequestBuilder.java index 563a967a67f..5fc6baa867d 100644 --- a/src/main/java/org/elasticsearch/client/action/RequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/RequestBuilder.java @@ -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.action.ActionResponse; import org.elasticsearch.action.ListenableActionFuture; /** - * @author kimchy (shay.banon) + * */ public interface RequestBuilder { diff --git a/src/main/java/org/elasticsearch/client/action/admin/cluster/health/ClusterHealthRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/admin/cluster/health/ClusterHealthRequestBuilder.java index 1a40edbee03..00dd52a3df5 100644 --- a/src/main/java/org/elasticsearch/client/action/admin/cluster/health/ClusterHealthRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/admin/cluster/health/ClusterHealthRequestBuilder.java @@ -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.client.action.admin.cluster.support.BaseClusterRequestB import org.elasticsearch.common.unit.TimeValue; /** - * @author kimchy (shay.banon) + * */ public class ClusterHealthRequestBuilder extends BaseClusterRequestBuilder { @@ -92,7 +92,8 @@ public class ClusterHealthRequestBuilder extends BaseClusterRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.health(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/action/admin/cluster/node/info/NodesInfoRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/admin/cluster/node/info/NodesInfoRequestBuilder.java index 7ce3fa7b925..be95fe549e5 100644 --- a/src/main/java/org/elasticsearch/client/action/admin/cluster/node/info/NodesInfoRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/admin/cluster/node/info/NodesInfoRequestBuilder.java @@ -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.client.ClusterAdminClient; import org.elasticsearch.client.action.admin.cluster.support.BaseClusterRequestBuilder; /** - * @author kimchy (shay.banon) + * */ public class NodesInfoRequestBuilder extends BaseClusterRequestBuilder { @@ -39,7 +39,8 @@ public class NodesInfoRequestBuilder extends BaseClusterRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.nodesInfo(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/action/admin/cluster/node/restart/NodesRestartRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/admin/cluster/node/restart/NodesRestartRequestBuilder.java index ea37be3c281..d8ddb9a71b4 100644 --- a/src/main/java/org/elasticsearch/client/action/admin/cluster/node/restart/NodesRestartRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/admin/cluster/node/restart/NodesRestartRequestBuilder.java @@ -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.client.action.admin.cluster.support.BaseClusterRequestB import org.elasticsearch.common.unit.TimeValue; /** - * @author kimchy (shay.banon) + * */ public class NodesRestartRequestBuilder extends BaseClusterRequestBuilder { @@ -59,7 +59,8 @@ public class NodesRestartRequestBuilder extends BaseClusterRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.nodesRestart(request, listener); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/action/admin/cluster/node/shutdown/NodesShutdownRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/admin/cluster/node/shutdown/NodesShutdownRequestBuilder.java index ffe4ac462ed..2c2ba568869 100644 --- a/src/main/java/org/elasticsearch/client/action/admin/cluster/node/shutdown/NodesShutdownRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/admin/cluster/node/shutdown/NodesShutdownRequestBuilder.java @@ -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.client.action.admin.cluster.support.BaseClusterRequestB import org.elasticsearch.common.unit.TimeValue; /** - * @author kimchy (shay.banon) + * */ public class NodesShutdownRequestBuilder extends BaseClusterRequestBuilder { @@ -76,7 +76,8 @@ public class NodesShutdownRequestBuilder extends BaseClusterRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.nodesShutdown(request, listener); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/action/admin/cluster/node/stats/NodesStatsRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/admin/cluster/node/stats/NodesStatsRequestBuilder.java index 0c97c2969c2..66fdd816f3e 100644 --- a/src/main/java/org/elasticsearch/client/action/admin/cluster/node/stats/NodesStatsRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/admin/cluster/node/stats/NodesStatsRequestBuilder.java @@ -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.client.ClusterAdminClient; import org.elasticsearch.client.action.admin.cluster.support.BaseClusterRequestBuilder; /** - * @author kimchy (shay.banon) + * */ public class NodesStatsRequestBuilder extends BaseClusterRequestBuilder { @@ -39,7 +39,8 @@ public class NodesStatsRequestBuilder extends BaseClusterRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.nodesStats(request, listener); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/action/admin/cluster/ping/broadcast/BroadcastPingRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/admin/cluster/ping/broadcast/BroadcastPingRequestBuilder.java index 2d3ff4fb61f..e0e63be6a05 100644 --- a/src/main/java/org/elasticsearch/client/action/admin/cluster/ping/broadcast/BroadcastPingRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/admin/cluster/ping/broadcast/BroadcastPingRequestBuilder.java @@ -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.client.ClusterAdminClient; import org.elasticsearch.client.action.admin.cluster.support.BaseClusterRequestBuilder; /** - * @author kimchy (shay.banon) + * */ public class BroadcastPingRequestBuilder extends BaseClusterRequestBuilder { @@ -56,7 +56,8 @@ public class BroadcastPingRequestBuilder extends BaseClusterRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.ping(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/action/admin/cluster/ping/replication/ReplicationPingRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/admin/cluster/ping/replication/ReplicationPingRequestBuilder.java index bda02272766..624b62993ac 100644 --- a/src/main/java/org/elasticsearch/client/action/admin/cluster/ping/replication/ReplicationPingRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/admin/cluster/ping/replication/ReplicationPingRequestBuilder.java @@ -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.client.action.admin.cluster.support.BaseClusterRequestB import org.elasticsearch.common.unit.TimeValue; /** - * @author kimchy (shay.banon) + * */ public class ReplicationPingRequestBuilder extends BaseClusterRequestBuilder { @@ -61,7 +61,8 @@ public class ReplicationPingRequestBuilder extends BaseClusterRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.ping(request, listener); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/action/admin/cluster/ping/single/SinglePingRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/admin/cluster/ping/single/SinglePingRequestBuilder.java index 9e481278354..da73bffbc5b 100644 --- a/src/main/java/org/elasticsearch/client/action/admin/cluster/ping/single/SinglePingRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/admin/cluster/ping/single/SinglePingRequestBuilder.java @@ -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.client.ClusterAdminClient; import org.elasticsearch.client.action.admin.cluster.support.BaseClusterRequestBuilder; /** - * @author kimchy (shay.banon) + * */ public class SinglePingRequestBuilder extends BaseClusterRequestBuilder { @@ -59,7 +59,8 @@ public class SinglePingRequestBuilder extends BaseClusterRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.ping(request, listener); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/action/admin/cluster/reroute/ClusterRerouteRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/admin/cluster/reroute/ClusterRerouteRequestBuilder.java index da63e1aae39..50b0702b879 100644 --- a/src/main/java/org/elasticsearch/client/action/admin/cluster/reroute/ClusterRerouteRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/admin/cluster/reroute/ClusterRerouteRequestBuilder.java @@ -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 ClusterRerouteRequestBuilder extends BaseClusterRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.reroute(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/action/admin/cluster/settings/ClusterUpdateSettingsRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/admin/cluster/settings/ClusterUpdateSettingsRequestBuilder.java index a6bb92368be..d34b59c7334 100644 --- a/src/main/java/org/elasticsearch/client/action/admin/cluster/settings/ClusterUpdateSettingsRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/admin/cluster/settings/ClusterUpdateSettingsRequestBuilder.java @@ -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 @@ -93,7 +93,8 @@ public class ClusterUpdateSettingsRequestBuilder extends BaseClusterRequestBuild return this; } - @Override protected void doExecute(ActionListener listener) { + @Override + protected void doExecute(ActionListener listener) { client.updateSettings(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/action/admin/cluster/state/ClusterStateRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/admin/cluster/state/ClusterStateRequestBuilder.java index 9df38da0ab6..c8cb3c0ffd8 100644 --- a/src/main/java/org/elasticsearch/client/action/admin/cluster/state/ClusterStateRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/admin/cluster/state/ClusterStateRequestBuilder.java @@ -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.client.action.admin.cluster.support.BaseClusterRequestB import org.elasticsearch.common.unit.TimeValue; /** - * @author kimchy (shay.banon) + * */ public class ClusterStateRequestBuilder extends BaseClusterRequestBuilder { @@ -95,7 +95,8 @@ public class ClusterStateRequestBuilder extends BaseClusterRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.state(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/action/admin/cluster/support/BaseClusterRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/admin/cluster/support/BaseClusterRequestBuilder.java index 8c378ed04af..44c7a3954f0 100644 --- a/src/main/java/org/elasticsearch/client/action/admin/cluster/support/BaseClusterRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/admin/cluster/support/BaseClusterRequestBuilder.java @@ -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.client.action.RequestBuilder; import org.elasticsearch.client.internal.InternalClusterAdminClient; /** - * @author kimchy (shay.banon) + * */ public abstract class BaseClusterRequestBuilder implements RequestBuilder { @@ -42,13 +42,15 @@ public abstract class BaseClusterRequestBuilder execute() { + @Override + public ListenableActionFuture execute() { PlainListenableActionFuture future = new PlainListenableActionFuture(request.listenerThreaded(), client.threadPool()); execute(future); return future; } - @Override public void execute(ActionListener listener) { + @Override + public void execute(ActionListener listener) { doExecute(listener); } diff --git a/src/main/java/org/elasticsearch/client/action/admin/indices/alias/IndicesAliasesRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/admin/indices/alias/IndicesAliasesRequestBuilder.java index e2a8fc3f6af..96d82314681 100644 --- a/src/main/java/org/elasticsearch/client/action/admin/indices/alias/IndicesAliasesRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/admin/indices/alias/IndicesAliasesRequestBuilder.java @@ -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,7 +31,7 @@ import org.elasticsearch.index.query.FilterBuilder; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class IndicesAliasesRequestBuilder extends BaseIndicesRequestBuilder { @@ -125,7 +125,8 @@ public class IndicesAliasesRequestBuilder extends BaseIndicesRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.aliases(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/action/admin/indices/analyze/AnalyzeRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/admin/indices/analyze/AnalyzeRequestBuilder.java index 1eccafb1971..f05d3cc9e90 100644 --- a/src/main/java/org/elasticsearch/client/action/admin/indices/analyze/AnalyzeRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/admin/indices/analyze/AnalyzeRequestBuilder.java @@ -26,7 +26,7 @@ import org.elasticsearch.client.IndicesAdminClient; import org.elasticsearch.client.action.admin.indices.support.BaseIndicesRequestBuilder; /** - * @author kimchy (shay.banon) + * */ public class AnalyzeRequestBuilder extends BaseIndicesRequestBuilder { @@ -53,7 +53,8 @@ public class AnalyzeRequestBuilder extends BaseIndicesRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.analyze(request, listener); } diff --git a/src/main/java/org/elasticsearch/client/action/admin/indices/cache/clear/ClearIndicesCacheRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/admin/indices/cache/clear/ClearIndicesCacheRequestBuilder.java index c232c4cdaee..448ed2b38a6 100644 --- a/src/main/java/org/elasticsearch/client/action/admin/indices/cache/clear/ClearIndicesCacheRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/admin/indices/cache/clear/ClearIndicesCacheRequestBuilder.java @@ -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.client.IndicesAdminClient; import org.elasticsearch.client.action.admin.indices.support.BaseIndicesRequestBuilder; /** - * @author kimchy (shay.banon) + * */ public class ClearIndicesCacheRequestBuilder extends BaseIndicesRequestBuilder { @@ -81,7 +81,8 @@ public class ClearIndicesCacheRequestBuilder extends BaseIndicesRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.clearCache(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/action/admin/indices/close/CloseIndexRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/admin/indices/close/CloseIndexRequestBuilder.java index d8517053380..15a7863442a 100644 --- a/src/main/java/org/elasticsearch/client/action/admin/indices/close/CloseIndexRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/admin/indices/close/CloseIndexRequestBuilder.java @@ -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.client.action.admin.indices.support.BaseIndicesRequestB import org.elasticsearch.common.unit.TimeValue; /** - * @author kimchy (shay.banon) + * */ public class CloseIndexRequestBuilder extends BaseIndicesRequestBuilder { @@ -69,7 +69,8 @@ public class CloseIndexRequestBuilder extends BaseIndicesRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.close(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/action/admin/indices/create/CreateIndexRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/admin/indices/create/CreateIndexRequestBuilder.java index 0f4c7a9cec0..75a14c30c4b 100644 --- a/src/main/java/org/elasticsearch/client/action/admin/indices/create/CreateIndexRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/admin/indices/create/CreateIndexRequestBuilder.java @@ -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,7 +31,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class CreateIndexRequestBuilder extends BaseIndicesRequestBuilder { @@ -154,7 +154,8 @@ public class CreateIndexRequestBuilder extends BaseIndicesRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.create(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/action/admin/indices/delete/DeleteIndexRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/admin/indices/delete/DeleteIndexRequestBuilder.java index 1eca8e3c52e..432132e4633 100644 --- a/src/main/java/org/elasticsearch/client/action/admin/indices/delete/DeleteIndexRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/admin/indices/delete/DeleteIndexRequestBuilder.java @@ -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.client.action.admin.indices.support.BaseIndicesRequestB import org.elasticsearch.common.unit.TimeValue; /** - * @author kimchy (shay.banon) + * */ public class DeleteIndexRequestBuilder extends BaseIndicesRequestBuilder { @@ -69,7 +69,8 @@ public class DeleteIndexRequestBuilder extends BaseIndicesRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.delete(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/action/admin/indices/exists/IndicesExistsRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/admin/indices/exists/IndicesExistsRequestBuilder.java index d0733cbc3e7..494c36e2228 100644 --- a/src/main/java/org/elasticsearch/client/action/admin/indices/exists/IndicesExistsRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/admin/indices/exists/IndicesExistsRequestBuilder.java @@ -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.client.IndicesAdminClient; import org.elasticsearch.client.action.admin.indices.support.BaseIndicesRequestBuilder; /** - * @author kimchy (shay.banon) + * */ public class IndicesExistsRequestBuilder extends BaseIndicesRequestBuilder { @@ -39,7 +39,8 @@ public class IndicesExistsRequestBuilder extends BaseIndicesRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.exists(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/action/admin/indices/flush/FlushRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/admin/indices/flush/FlushRequestBuilder.java index 249acfc9ffd..5de79176965 100644 --- a/src/main/java/org/elasticsearch/client/action/admin/indices/flush/FlushRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/admin/indices/flush/FlushRequestBuilder.java @@ -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.client.IndicesAdminClient; import org.elasticsearch.client.action.admin.indices.support.BaseIndicesRequestBuilder; /** - * @author kimchy (shay.banon) + * */ public class FlushRequestBuilder extends BaseIndicesRequestBuilder { @@ -49,7 +49,8 @@ public class FlushRequestBuilder extends BaseIndicesRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.flush(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/action/admin/indices/gateway/snapshot/GatewaySnapshotRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/admin/indices/gateway/snapshot/GatewaySnapshotRequestBuilder.java index a03a22935fc..0302333ea8c 100644 --- a/src/main/java/org/elasticsearch/client/action/admin/indices/gateway/snapshot/GatewaySnapshotRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/admin/indices/gateway/snapshot/GatewaySnapshotRequestBuilder.java @@ -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.client.IndicesAdminClient; import org.elasticsearch.client.action.admin.indices.support.BaseIndicesRequestBuilder; /** - * @author kimchy (shay.banon) + * */ public class GatewaySnapshotRequestBuilder extends BaseIndicesRequestBuilder { @@ -39,7 +39,8 @@ public class GatewaySnapshotRequestBuilder extends BaseIndicesRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.gatewaySnapshot(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/action/admin/indices/mapping/delete/DeleteMappingRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/admin/indices/mapping/delete/DeleteMappingRequestBuilder.java index 7f1ba36ed8b..05bc9818be1 100644 --- a/src/main/java/org/elasticsearch/client/action/admin/indices/mapping/delete/DeleteMappingRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/admin/indices/mapping/delete/DeleteMappingRequestBuilder.java @@ -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.client.action.admin.indices.support.BaseIndicesRequestB import org.elasticsearch.common.unit.TimeValue; /** - * @author kimchy (shay.banon) + * */ public class DeleteMappingRequestBuilder extends BaseIndicesRequestBuilder { @@ -56,7 +56,8 @@ public class DeleteMappingRequestBuilder extends BaseIndicesRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.deleteMapping(request, listener); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/action/admin/indices/mapping/put/PutMappingRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/admin/indices/mapping/put/PutMappingRequestBuilder.java index 4fc9cf79e49..c4cac43cb8f 100644 --- a/src/main/java/org/elasticsearch/client/action/admin/indices/mapping/put/PutMappingRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/admin/indices/mapping/put/PutMappingRequestBuilder.java @@ -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,7 +31,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class PutMappingRequestBuilder extends BaseIndicesRequestBuilder { @@ -47,7 +47,8 @@ public class PutMappingRequestBuilder extends BaseIndicesRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.putMapping(request, listener); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/action/admin/indices/open/OpenIndexRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/admin/indices/open/OpenIndexRequestBuilder.java index aeea8fbfe87..0a4299b7b6f 100644 --- a/src/main/java/org/elasticsearch/client/action/admin/indices/open/OpenIndexRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/admin/indices/open/OpenIndexRequestBuilder.java @@ -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.client.action.admin.indices.support.BaseIndicesRequestB import org.elasticsearch.common.unit.TimeValue; /** - * @author kimchy (shay.banon) + * */ public class OpenIndexRequestBuilder extends BaseIndicesRequestBuilder { @@ -69,7 +69,8 @@ public class OpenIndexRequestBuilder extends BaseIndicesRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.open(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/action/admin/indices/optimize/OptimizeRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/admin/indices/optimize/OptimizeRequestBuilder.java index ae4cfae9a5a..5ded31f388d 100644 --- a/src/main/java/org/elasticsearch/client/action/admin/indices/optimize/OptimizeRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/admin/indices/optimize/OptimizeRequestBuilder.java @@ -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,14 +29,14 @@ import org.elasticsearch.client.action.admin.indices.support.BaseIndicesRequestB /** * A request to optimize one or more indices. In order to optimize on all the indices, pass an empty array or * null for the indices. - * + *

*

{@link #setWaitForMerge(boolean)} allows to control if the call will block until the optimize completes and * defaults to true. - * + *

*

{@link #setMaxNumSegments(int)} allows to control the number of segments to optimize down to. By default, will * cause the optimize process to optimize down to half the configured number of segments. * - * @author kimchy (shay.banon) + * */ public class OptimizeRequestBuilder extends BaseIndicesRequestBuilder { @@ -107,7 +107,8 @@ public class OptimizeRequestBuilder extends BaseIndicesRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.optimize(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/action/admin/indices/refresh/RefreshRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/admin/indices/refresh/RefreshRequestBuilder.java index 4a20f989048..b0e33065bb0 100644 --- a/src/main/java/org/elasticsearch/client/action/admin/indices/refresh/RefreshRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/admin/indices/refresh/RefreshRequestBuilder.java @@ -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,7 +31,7 @@ import org.elasticsearch.client.action.admin.indices.support.BaseIndicesRequestB * capabilities depends on the index engine used. For example, the robin one requires refresh to be called, but by * default a refresh is scheduled periodically. * - * @author kimchy (shay.banon) + * */ public class RefreshRequestBuilder extends BaseIndicesRequestBuilder { @@ -65,7 +65,8 @@ public class RefreshRequestBuilder extends BaseIndicesRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.refresh(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/action/admin/indices/segments/IndicesSegmentsRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/admin/indices/segments/IndicesSegmentsRequestBuilder.java index 47295d3cf5a..8c8214e30eb 100644 --- a/src/main/java/org/elasticsearch/client/action/admin/indices/segments/IndicesSegmentsRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/admin/indices/segments/IndicesSegmentsRequestBuilder.java @@ -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.client.IndicesAdminClient; import org.elasticsearch.client.action.admin.indices.support.BaseIndicesRequestBuilder; /** - * @author kimchy (shay.banon) + * */ public class IndicesSegmentsRequestBuilder extends BaseIndicesRequestBuilder { @@ -39,7 +39,8 @@ public class IndicesSegmentsRequestBuilder extends BaseIndicesRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.segments(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/action/admin/indices/settings/UpdateSettingsRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/admin/indices/settings/UpdateSettingsRequestBuilder.java index 678a46a212f..c420cfac3b4 100644 --- a/src/main/java/org/elasticsearch/client/action/admin/indices/settings/UpdateSettingsRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/admin/indices/settings/UpdateSettingsRequestBuilder.java @@ -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.settings.Settings; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class UpdateSettingsRequestBuilder extends BaseIndicesRequestBuilder { @@ -74,7 +74,8 @@ public class UpdateSettingsRequestBuilder extends BaseIndicesRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.updateSettings(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/action/admin/indices/stats/IndicesStatsRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/admin/indices/stats/IndicesStatsRequestBuilder.java index 40316963085..5a894b4fc28 100644 --- a/src/main/java/org/elasticsearch/client/action/admin/indices/stats/IndicesStatsRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/admin/indices/stats/IndicesStatsRequestBuilder.java @@ -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,10 +27,10 @@ import org.elasticsearch.client.action.admin.indices.support.BaseIndicesRequestB /** * A request to get indices level stats. Allow to enable different stats to be returned. - * + *

*

By default, the {@link #setDocs(boolean)}, {@link #setStore(boolean)}, {@link #setIndexing(boolean)} * are enabled. Other stats can be enabled as well. - * + *

*

All the stats to be returned can be cleared using {@link #clear()}, at which point, specific * stats can be enabled. */ @@ -107,7 +107,8 @@ public class IndicesStatsRequestBuilder extends BaseIndicesRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.stats(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/action/admin/indices/status/IndicesStatusRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/admin/indices/status/IndicesStatusRequestBuilder.java index ec2fda62ed7..9b01f8fc75d 100644 --- a/src/main/java/org/elasticsearch/client/action/admin/indices/status/IndicesStatusRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/admin/indices/status/IndicesStatusRequestBuilder.java @@ -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.client.IndicesAdminClient; import org.elasticsearch.client.action.admin.indices.support.BaseIndicesRequestBuilder; /** - * @author kimchy (shay.banon) + * */ public class IndicesStatusRequestBuilder extends BaseIndicesRequestBuilder { @@ -58,7 +58,8 @@ public class IndicesStatusRequestBuilder extends BaseIndicesRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.status(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/action/admin/indices/support/BaseIndicesRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/admin/indices/support/BaseIndicesRequestBuilder.java index c5f4dc30183..d5c47bfb0cd 100644 --- a/src/main/java/org/elasticsearch/client/action/admin/indices/support/BaseIndicesRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/admin/indices/support/BaseIndicesRequestBuilder.java @@ -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.client.action.RequestBuilder; import org.elasticsearch.client.internal.InternalIndicesAdminClient; /** - * @author kimchy (shay.banon) + * */ public abstract class BaseIndicesRequestBuilder implements RequestBuilder { @@ -42,13 +42,15 @@ public abstract class BaseIndicesRequestBuilder execute() { + @Override + public ListenableActionFuture execute() { PlainListenableActionFuture future = new PlainListenableActionFuture(request.listenerThreaded(), client.threadPool()); execute(future); return future; } - @Override public void execute(ActionListener listener) { + @Override + public void execute(ActionListener listener) { doExecute(listener); } diff --git a/src/main/java/org/elasticsearch/client/action/admin/indices/template/delete/DeleteIndexTemplateRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/admin/indices/template/delete/DeleteIndexTemplateRequestBuilder.java index 183d417dc7a..92a34a23599 100644 --- a/src/main/java/org/elasticsearch/client/action/admin/indices/template/delete/DeleteIndexTemplateRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/admin/indices/template/delete/DeleteIndexTemplateRequestBuilder.java @@ -27,7 +27,7 @@ import org.elasticsearch.client.action.admin.indices.support.BaseIndicesRequestB import org.elasticsearch.common.unit.TimeValue; /** - * @author kimchy (shay.banon) + * */ public class DeleteIndexTemplateRequestBuilder extends BaseIndicesRequestBuilder { @@ -69,7 +69,8 @@ public class DeleteIndexTemplateRequestBuilder extends BaseIndicesRequestBuilder return this; } - @Override protected void doExecute(ActionListener listener) { + @Override + protected void doExecute(ActionListener listener) { client.deleteTemplate(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/action/admin/indices/template/put/PutIndexTemplateRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/admin/indices/template/put/PutIndexTemplateRequestBuilder.java index e0b5beb8d9c..16c71e86687 100644 --- a/src/main/java/org/elasticsearch/client/action/admin/indices/template/put/PutIndexTemplateRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/admin/indices/template/put/PutIndexTemplateRequestBuilder.java @@ -31,7 +31,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class PutIndexTemplateRequestBuilder extends BaseIndicesRequestBuilder { @@ -171,7 +171,8 @@ public class PutIndexTemplateRequestBuilder extends BaseIndicesRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.putTemplate(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/action/bulk/BulkRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/bulk/BulkRequestBuilder.java index b4b051f9dbd..ac7ec8ef1b9 100644 --- a/src/main/java/org/elasticsearch/client/action/bulk/BulkRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/bulk/BulkRequestBuilder.java @@ -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,7 +36,7 @@ import org.elasticsearch.common.Nullable; * A bulk request holds an ordered {@link IndexRequest}s and {@link DeleteRequest}s and allows to executes * it in a single batch. * - * @author kimchy (shay.banon) + * */ public class BulkRequestBuilder extends BaseRequestBuilder { @@ -127,7 +127,8 @@ public class BulkRequestBuilder extends BaseRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.bulk(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/action/count/CountRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/count/CountRequestBuilder.java index cec6f2057a9..d3d041a286b 100644 --- a/src/main/java/org/elasticsearch/client/action/count/CountRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/count/CountRequestBuilder.java @@ -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 org.elasticsearch.index.query.QueryBuilder; /** * A count action request builder. * - * @author kimchy (shay.banon) + * */ public class CountRequestBuilder extends BaseRequestBuilder { @@ -123,7 +123,8 @@ public class CountRequestBuilder extends BaseRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.count(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/action/delete/DeleteRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/delete/DeleteRequestBuilder.java index 5f5c8cb8ac9..647267c2a00 100644 --- a/src/main/java/org/elasticsearch/client/action/delete/DeleteRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/delete/DeleteRequestBuilder.java @@ -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,7 +32,7 @@ import org.elasticsearch.index.VersionType; /** * A delete document action request builder. * - * @author kimchy (shay.banon) + * */ public class DeleteRequestBuilder extends BaseRequestBuilder { @@ -133,7 +133,8 @@ public class DeleteRequestBuilder extends BaseRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.delete(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/action/deletebyquery/DeleteByQueryRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/deletebyquery/DeleteByQueryRequestBuilder.java index aef0486edcd..3cc32a8510b 100644 --- a/src/main/java/org/elasticsearch/client/action/deletebyquery/DeleteByQueryRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/deletebyquery/DeleteByQueryRequestBuilder.java @@ -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,7 +33,7 @@ import org.elasticsearch.index.query.QueryBuilder; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class DeleteByQueryRequestBuilder extends BaseRequestBuilder { @@ -170,7 +170,8 @@ public class DeleteByQueryRequestBuilder extends BaseRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.deleteByQuery(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/action/get/GetRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/get/GetRequestBuilder.java index eaa2d1359c8..983de0780bb 100644 --- a/src/main/java/org/elasticsearch/client/action/get/GetRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/get/GetRequestBuilder.java @@ -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.Nullable; /** * A get document action request builder. * - * @author kimchy (shay.banon) + * */ public class GetRequestBuilder extends BaseRequestBuilder { @@ -121,7 +121,8 @@ public class GetRequestBuilder extends BaseRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.get(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/action/get/MultiGetRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/get/MultiGetRequestBuilder.java index 275b5897356..6e73f5e316c 100644 --- a/src/main/java/org/elasticsearch/client/action/get/MultiGetRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/get/MultiGetRequestBuilder.java @@ -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.Nullable; /** * A multi get document action request builder. * - * @author kimchy (shay.banon) + * */ public class MultiGetRequestBuilder extends BaseRequestBuilder { @@ -94,7 +94,8 @@ public class MultiGetRequestBuilder extends BaseRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.multiGet(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/action/index/IndexRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/index/IndexRequestBuilder.java index 4369820b069..98f134c024a 100644 --- a/src/main/java/org/elasticsearch/client/action/index/IndexRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/index/IndexRequestBuilder.java @@ -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.util.Map; /** * An index document action request builder. * - * @author kimchy (shay.banon) + * */ public class IndexRequestBuilder extends BaseRequestBuilder { @@ -110,7 +110,7 @@ public class IndexRequestBuilder extends BaseRequestBuilder *

Note, its preferable to either set it using {@link #setSource(org.elasticsearch.common.xcontent.XContentBuilder)} * or using the {@link #setSource(byte[])}. */ @@ -334,7 +334,8 @@ public class IndexRequestBuilder extends BaseRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.index(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/action/mlt/MoreLikeThisRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/mlt/MoreLikeThisRequestBuilder.java index 4ddadf8a721..5b24cc2c687 100644 --- a/src/main/java/org/elasticsearch/client/action/mlt/MoreLikeThisRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/mlt/MoreLikeThisRequestBuilder.java @@ -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 @@ -75,10 +75,10 @@ public class MoreLikeThisRequestBuilder extends BaseRequestBuilder *

Even if your Analyzer allows stopwords, you might want to tell the MoreLikeThis code to ignore them, as * for the purposes of document similarity it seems reasonable to assume that "a stop word is never interesting". - * + *

*

Defaults to no stop words. */ public MoreLikeThisRequestBuilder setStopWords(String... stopWords) { @@ -233,7 +233,8 @@ public class MoreLikeThisRequestBuilder extends BaseRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.moreLikeThis(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/action/percolate/PercolateRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/percolate/PercolateRequestBuilder.java index 9d446ecde29..9770ceecaf9 100644 --- a/src/main/java/org/elasticsearch/client/action/percolate/PercolateRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/percolate/PercolateRequestBuilder.java @@ -30,7 +30,7 @@ import org.elasticsearch.common.xcontent.XContentType; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class PercolateRequestBuilder extends BaseRequestBuilder { @@ -76,7 +76,7 @@ public class PercolateRequestBuilder extends BaseRequestBuilder *

Note, its preferable to either set it using {@link #setSource(org.elasticsearch.common.xcontent.XContentBuilder)} * or using the {@link #setSource(byte[])}. */ @@ -153,7 +153,8 @@ public class PercolateRequestBuilder extends BaseRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.percolate(request, listener); } diff --git a/src/main/java/org/elasticsearch/client/action/search/SearchRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/search/SearchRequestBuilder.java index aafc1e95c7c..a7d0a59d476 100644 --- a/src/main/java/org/elasticsearch/client/action/search/SearchRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/search/SearchRequestBuilder.java @@ -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 @@ -43,7 +43,7 @@ import java.util.Map; /** * A search action request builder. * - * @author kimchy (shay.banon) + * */ public class SearchRequestBuilder extends BaseRequestBuilder { @@ -688,11 +688,13 @@ public class SearchRequestBuilder extends BaseRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { request.source(sourceBuilder()); client.search(request, listener); } diff --git a/src/main/java/org/elasticsearch/client/action/search/SearchScrollRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/search/SearchScrollRequestBuilder.java index 6652bf87706..743d3dc4892 100644 --- a/src/main/java/org/elasticsearch/client/action/search/SearchScrollRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/search/SearchScrollRequestBuilder.java @@ -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,7 +31,7 @@ import org.elasticsearch.search.Scroll; /** * A search scroll action request builder. * - * @author kimchy (shay.banon) + * */ public class SearchScrollRequestBuilder extends BaseRequestBuilder { @@ -79,7 +79,8 @@ public class SearchScrollRequestBuilder extends BaseRequestBuilder listener) { + @Override + protected void doExecute(ActionListener listener) { client.searchScroll(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/action/support/BaseRequestBuilder.java b/src/main/java/org/elasticsearch/client/action/support/BaseRequestBuilder.java index 39ceba569f1..2066d9ea0cb 100644 --- a/src/main/java/org/elasticsearch/client/action/support/BaseRequestBuilder.java +++ b/src/main/java/org/elasticsearch/client/action/support/BaseRequestBuilder.java @@ -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.client.action.RequestBuilder; import org.elasticsearch.client.internal.InternalClient; /** - * @author kimchy (shay.banon) + * */ public abstract class BaseRequestBuilder implements RequestBuilder { @@ -46,13 +46,15 @@ public abstract class BaseRequestBuilder execute() { + @Override + public ListenableActionFuture execute() { PlainListenableActionFuture future = new PlainListenableActionFuture(request.listenerThreaded(), client.threadPool()); execute(future); return future; } - @Override public void execute(ActionListener listener) { + @Override + public void execute(ActionListener listener) { doExecute(listener); } diff --git a/src/main/java/org/elasticsearch/client/internal/InternalClient.java b/src/main/java/org/elasticsearch/client/internal/InternalClient.java index 5506a048f20..da0223760ae 100644 --- a/src/main/java/org/elasticsearch/client/internal/InternalClient.java +++ b/src/main/java/org/elasticsearch/client/internal/InternalClient.java @@ -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.client.Client; import org.elasticsearch.threadpool.ThreadPool; /** - * @author kimchy (shay.banon) + * */ public interface InternalClient extends Client { diff --git a/src/main/java/org/elasticsearch/client/internal/InternalClusterAdminClient.java b/src/main/java/org/elasticsearch/client/internal/InternalClusterAdminClient.java index 30328d63dff..71bf96c451f 100644 --- a/src/main/java/org/elasticsearch/client/internal/InternalClusterAdminClient.java +++ b/src/main/java/org/elasticsearch/client/internal/InternalClusterAdminClient.java @@ -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.client.ClusterAdminClient; import org.elasticsearch.threadpool.ThreadPool; /** - * @author kimchy (shay.banon) + * */ public interface InternalClusterAdminClient extends ClusterAdminClient { diff --git a/src/main/java/org/elasticsearch/client/internal/InternalIndicesAdminClient.java b/src/main/java/org/elasticsearch/client/internal/InternalIndicesAdminClient.java index 8e76e5221a5..c6f31108e6f 100644 --- a/src/main/java/org/elasticsearch/client/internal/InternalIndicesAdminClient.java +++ b/src/main/java/org/elasticsearch/client/internal/InternalIndicesAdminClient.java @@ -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.client.IndicesAdminClient; import org.elasticsearch.threadpool.ThreadPool; /** - * @author kimchy (shay.banon) + * */ public interface InternalIndicesAdminClient extends IndicesAdminClient { diff --git a/src/main/java/org/elasticsearch/client/node/NodeAdminClient.java b/src/main/java/org/elasticsearch/client/node/NodeAdminClient.java index a14316c3ca5..2e403e7eae7 100644 --- a/src/main/java/org/elasticsearch/client/node/NodeAdminClient.java +++ b/src/main/java/org/elasticsearch/client/node/NodeAdminClient.java @@ -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.inject.Inject; import org.elasticsearch.common.settings.Settings; /** - * @author kimchy (shay.banon) + * */ public class NodeAdminClient extends AbstractComponent implements AdminClient { @@ -35,17 +35,20 @@ public class NodeAdminClient extends AbstractComponent implements AdminClient { private final NodeClusterAdminClient clusterAdminClient; - @Inject public NodeAdminClient(Settings settings, NodeClusterAdminClient clusterAdminClient, NodeIndicesAdminClient indicesAdminClient) { + @Inject + public NodeAdminClient(Settings settings, NodeClusterAdminClient clusterAdminClient, NodeIndicesAdminClient indicesAdminClient) { super(settings); this.indicesAdminClient = indicesAdminClient; this.clusterAdminClient = clusterAdminClient; } - @Override public IndicesAdminClient indices() { + @Override + public IndicesAdminClient indices() { return indicesAdminClient; } - @Override public ClusterAdminClient cluster() { + @Override + public ClusterAdminClient cluster() { return this.clusterAdminClient; } } diff --git a/src/main/java/org/elasticsearch/client/node/NodeClient.java b/src/main/java/org/elasticsearch/client/node/NodeClient.java index 99bc442d278..74812963a95 100644 --- a/src/main/java/org/elasticsearch/client/node/NodeClient.java +++ b/src/main/java/org/elasticsearch/client/node/NodeClient.java @@ -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,12 +33,7 @@ import org.elasticsearch.action.delete.TransportDeleteAction; import org.elasticsearch.action.deletebyquery.DeleteByQueryRequest; import org.elasticsearch.action.deletebyquery.DeleteByQueryResponse; import org.elasticsearch.action.deletebyquery.TransportDeleteByQueryAction; -import org.elasticsearch.action.get.GetRequest; -import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.action.get.MultiGetRequest; -import org.elasticsearch.action.get.MultiGetResponse; -import org.elasticsearch.action.get.TransportGetAction; -import org.elasticsearch.action.get.TransportMultiGetAction; +import org.elasticsearch.action.get.*; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.action.index.TransportIndexAction; @@ -47,11 +42,7 @@ import org.elasticsearch.action.mlt.TransportMoreLikeThisAction; import org.elasticsearch.action.percolate.PercolateRequest; import org.elasticsearch.action.percolate.PercolateResponse; import org.elasticsearch.action.percolate.TransportPercolateAction; -import org.elasticsearch.action.search.SearchRequest; -import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.action.search.SearchScrollRequest; -import org.elasticsearch.action.search.TransportSearchAction; -import org.elasticsearch.action.search.TransportSearchScrollAction; +import org.elasticsearch.action.search.*; import org.elasticsearch.client.AdminClient; import org.elasticsearch.client.internal.InternalClient; import org.elasticsearch.client.support.AbstractClient; @@ -60,7 +51,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; /** - * @author kimchy (shay.banon) + * */ public class NodeClient extends AbstractClient implements InternalClient { @@ -90,11 +81,12 @@ public class NodeClient extends AbstractClient implements InternalClient { private final TransportPercolateAction percolateAction; - @Inject public NodeClient(Settings settings, ThreadPool threadPool, NodeAdminClient admin, - TransportIndexAction indexAction, TransportDeleteAction deleteAction, TransportBulkAction bulkAction, - TransportDeleteByQueryAction deleteByQueryAction, TransportGetAction getAction, TransportMultiGetAction multiGetAction, TransportCountAction countAction, - TransportSearchAction searchAction, TransportSearchScrollAction searchScrollAction, - TransportMoreLikeThisAction moreLikeThisAction, TransportPercolateAction percolateAction) { + @Inject + public NodeClient(Settings settings, ThreadPool threadPool, NodeAdminClient admin, + TransportIndexAction indexAction, TransportDeleteAction deleteAction, TransportBulkAction bulkAction, + TransportDeleteByQueryAction deleteByQueryAction, TransportGetAction getAction, TransportMultiGetAction multiGetAction, TransportCountAction countAction, + TransportSearchAction searchAction, TransportSearchScrollAction searchScrollAction, + TransportMoreLikeThisAction moreLikeThisAction, TransportPercolateAction percolateAction) { this.threadPool = threadPool; this.admin = admin; this.indexAction = indexAction; @@ -110,103 +102,128 @@ public class NodeClient extends AbstractClient implements InternalClient { this.percolateAction = percolateAction; } - @Override public ThreadPool threadPool() { + @Override + public ThreadPool threadPool() { return this.threadPool; } - @Override public void close() { + @Override + public void close() { // nothing really to do } - @Override public AdminClient admin() { + @Override + public AdminClient admin() { return this.admin; } - @Override public ActionFuture index(IndexRequest request) { + @Override + public ActionFuture index(IndexRequest request) { return indexAction.execute(request); } - @Override public void index(IndexRequest request, ActionListener listener) { + @Override + public void index(IndexRequest request, ActionListener listener) { indexAction.execute(request, listener); } - @Override public ActionFuture delete(DeleteRequest request) { + @Override + public ActionFuture delete(DeleteRequest request) { return deleteAction.execute(request); } - @Override public void delete(DeleteRequest request, ActionListener listener) { + @Override + public void delete(DeleteRequest request, ActionListener listener) { deleteAction.execute(request, listener); } - @Override public ActionFuture bulk(BulkRequest request) { + @Override + public ActionFuture bulk(BulkRequest request) { return bulkAction.execute(request); } - @Override public void bulk(BulkRequest request, ActionListener listener) { + @Override + public void bulk(BulkRequest request, ActionListener listener) { bulkAction.execute(request, listener); } - @Override public ActionFuture deleteByQuery(DeleteByQueryRequest request) { + @Override + public ActionFuture deleteByQuery(DeleteByQueryRequest request) { return deleteByQueryAction.execute(request); } - @Override public void deleteByQuery(DeleteByQueryRequest request, ActionListener listener) { + @Override + public void deleteByQuery(DeleteByQueryRequest request, ActionListener listener) { deleteByQueryAction.execute(request, listener); } - @Override public ActionFuture get(GetRequest request) { + @Override + public ActionFuture get(GetRequest request) { return getAction.execute(request); } - @Override public void get(GetRequest request, ActionListener listener) { + @Override + public void get(GetRequest request, ActionListener listener) { getAction.execute(request, listener); } - @Override public ActionFuture multiGet(MultiGetRequest request) { + @Override + public ActionFuture multiGet(MultiGetRequest request) { return multiGetAction.execute(request); } - @Override public void multiGet(MultiGetRequest request, ActionListener listener) { + @Override + public void multiGet(MultiGetRequest request, ActionListener listener) { multiGetAction.execute(request, listener); } - @Override public ActionFuture count(CountRequest request) { + @Override + public ActionFuture count(CountRequest request) { return countAction.execute(request); } - @Override public void count(CountRequest request, ActionListener listener) { + @Override + public void count(CountRequest request, ActionListener listener) { countAction.execute(request, listener); } - @Override public ActionFuture search(SearchRequest request) { + @Override + public ActionFuture search(SearchRequest request) { return searchAction.execute(request); } - @Override public void search(SearchRequest request, ActionListener listener) { + @Override + public void search(SearchRequest request, ActionListener listener) { searchAction.execute(request, listener); } - @Override public ActionFuture searchScroll(SearchScrollRequest request) { + @Override + public ActionFuture searchScroll(SearchScrollRequest request) { return searchScrollAction.execute(request); } - @Override public void searchScroll(SearchScrollRequest request, ActionListener listener) { + @Override + public void searchScroll(SearchScrollRequest request, ActionListener listener) { searchScrollAction.execute(request, listener); } - @Override public ActionFuture moreLikeThis(MoreLikeThisRequest request) { + @Override + public ActionFuture moreLikeThis(MoreLikeThisRequest request) { return moreLikeThisAction.execute(request); } - @Override public void moreLikeThis(MoreLikeThisRequest request, ActionListener listener) { + @Override + public void moreLikeThis(MoreLikeThisRequest request, ActionListener listener) { moreLikeThisAction.execute(request, listener); } - @Override public ActionFuture percolate(PercolateRequest request) { + @Override + public ActionFuture percolate(PercolateRequest request) { return percolateAction.execute(request); } - @Override public void percolate(PercolateRequest request, ActionListener listener) { + @Override + public void percolate(PercolateRequest request, ActionListener listener) { percolateAction.execute(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/node/NodeClientModule.java b/src/main/java/org/elasticsearch/client/node/NodeClientModule.java index d794bbb0680..dfa3459d8bc 100644 --- a/src/main/java/org/elasticsearch/client/node/NodeClientModule.java +++ b/src/main/java/org/elasticsearch/client/node/NodeClientModule.java @@ -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,11 +26,12 @@ import org.elasticsearch.client.IndicesAdminClient; import org.elasticsearch.common.inject.AbstractModule; /** - * @author kimchy (shay.banon) + * */ public class NodeClientModule extends AbstractModule { - @Override protected void configure() { + @Override + protected void configure() { bind(ClusterAdminClient.class).to(NodeClusterAdminClient.class).asEagerSingleton(); bind(IndicesAdminClient.class).to(NodeIndicesAdminClient.class).asEagerSingleton(); bind(AdminClient.class).to(NodeAdminClient.class).asEagerSingleton(); diff --git a/src/main/java/org/elasticsearch/client/node/NodeClusterAdminClient.java b/src/main/java/org/elasticsearch/client/node/NodeClusterAdminClient.java index cd5f4549166..81a2b14207b 100644 --- a/src/main/java/org/elasticsearch/client/node/NodeClusterAdminClient.java +++ b/src/main/java/org/elasticsearch/client/node/NodeClusterAdminClient.java @@ -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 @@ -61,7 +61,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; /** - * @author kimchy (shay.banon) + * */ public class NodeClusterAdminClient extends AbstractClusterAdminClient implements InternalClusterAdminClient { @@ -89,10 +89,11 @@ public class NodeClusterAdminClient extends AbstractClusterAdminClient implement private final TransportNodesRestartAction nodesRestart; - @Inject public NodeClusterAdminClient(Settings settings, ThreadPool threadPool, - TransportClusterHealthAction clusterHealthAction, TransportClusterStateAction clusterStateAction, TransportClusterRerouteAction clusterRerouteAction, TransportClusterUpdateSettingsAction clusterUpdateSettingsAction, - TransportSinglePingAction singlePingAction, TransportBroadcastPingAction broadcastPingAction, TransportReplicationPingAction replicationPingAction, - TransportNodesInfoAction nodesInfoAction, TransportNodesShutdownAction nodesShutdown, TransportNodesRestartAction nodesRestart, TransportNodesStatsAction nodesStatsAction) { + @Inject + public NodeClusterAdminClient(Settings settings, ThreadPool threadPool, + TransportClusterHealthAction clusterHealthAction, TransportClusterStateAction clusterStateAction, TransportClusterRerouteAction clusterRerouteAction, TransportClusterUpdateSettingsAction clusterUpdateSettingsAction, + TransportSinglePingAction singlePingAction, TransportBroadcastPingAction broadcastPingAction, TransportReplicationPingAction replicationPingAction, + TransportNodesInfoAction nodesInfoAction, TransportNodesShutdownAction nodesShutdown, TransportNodesRestartAction nodesRestart, TransportNodesStatsAction nodesStatsAction) { this.threadPool = threadPool; this.clusterRerouteAction = clusterRerouteAction; this.clusterHealthAction = clusterHealthAction; @@ -107,95 +108,118 @@ public class NodeClusterAdminClient extends AbstractClusterAdminClient implement this.nodesStatsAction = nodesStatsAction; } - @Override public ThreadPool threadPool() { + @Override + public ThreadPool threadPool() { return this.threadPool; } - @Override public ActionFuture health(ClusterHealthRequest request) { + @Override + public ActionFuture health(ClusterHealthRequest request) { return clusterHealthAction.execute(request); } - @Override public void health(ClusterHealthRequest request, ActionListener listener) { + @Override + public void health(ClusterHealthRequest request, ActionListener listener) { clusterHealthAction.execute(request, listener); } - @Override public ActionFuture state(ClusterStateRequest request) { + @Override + public ActionFuture state(ClusterStateRequest request) { return clusterStateAction.execute(request); } - @Override public void state(ClusterStateRequest request, ActionListener listener) { + @Override + public void state(ClusterStateRequest request, ActionListener listener) { clusterStateAction.execute(request, listener); } - @Override public ActionFuture reroute(ClusterRerouteRequest request) { + @Override + public ActionFuture reroute(ClusterRerouteRequest request) { return clusterRerouteAction.execute(request); } - @Override public void reroute(ClusterRerouteRequest request, ActionListener listener) { + @Override + public void reroute(ClusterRerouteRequest request, ActionListener listener) { clusterRerouteAction.execute(request, listener); } - @Override public ActionFuture updateSettings(ClusterUpdateSettingsRequest request) { + @Override + public ActionFuture updateSettings(ClusterUpdateSettingsRequest request) { return clusterUpdateSettingsAction.execute(request); } - @Override public void updateSettings(ClusterUpdateSettingsRequest request, ActionListener listener) { + @Override + public void updateSettings(ClusterUpdateSettingsRequest request, ActionListener listener) { clusterUpdateSettingsAction.execute(request, listener); } - @Override public ActionFuture ping(SinglePingRequest request) { + @Override + public ActionFuture ping(SinglePingRequest request) { return singlePingAction.execute(request); } - @Override public void ping(SinglePingRequest request, ActionListener listener) { + @Override + public void ping(SinglePingRequest request, ActionListener listener) { singlePingAction.execute(request, listener); } - @Override public ActionFuture ping(BroadcastPingRequest request) { + @Override + public ActionFuture ping(BroadcastPingRequest request) { return broadcastPingAction.execute(request); } - @Override public void ping(BroadcastPingRequest request, ActionListener listener) { + @Override + public void ping(BroadcastPingRequest request, ActionListener listener) { broadcastPingAction.execute(request, listener); } - @Override public ActionFuture ping(ReplicationPingRequest request) { + @Override + public ActionFuture ping(ReplicationPingRequest request) { return replicationPingAction.execute(request); } - @Override public void ping(ReplicationPingRequest request, ActionListener listener) { + @Override + public void ping(ReplicationPingRequest request, ActionListener listener) { replicationPingAction.execute(request, listener); } - @Override public ActionFuture nodesInfo(NodesInfoRequest request) { + @Override + public ActionFuture nodesInfo(NodesInfoRequest request) { return nodesInfoAction.execute(request); } - @Override public void nodesInfo(NodesInfoRequest request, ActionListener listener) { + @Override + public void nodesInfo(NodesInfoRequest request, ActionListener listener) { nodesInfoAction.execute(request, listener); } - @Override public ActionFuture nodesStats(NodesStatsRequest request) { + @Override + public ActionFuture nodesStats(NodesStatsRequest request) { return nodesStatsAction.execute(request); } - @Override public void nodesStats(NodesStatsRequest request, ActionListener listener) { + @Override + public void nodesStats(NodesStatsRequest request, ActionListener listener) { nodesStatsAction.execute(request, listener); } - @Override public ActionFuture nodesShutdown(NodesShutdownRequest request) { + @Override + public ActionFuture nodesShutdown(NodesShutdownRequest request) { return nodesShutdown.execute(request); } - @Override public void nodesShutdown(NodesShutdownRequest request, ActionListener listener) { + @Override + public void nodesShutdown(NodesShutdownRequest request, ActionListener listener) { nodesShutdown.execute(request, listener); } - @Override public ActionFuture nodesRestart(NodesRestartRequest request) { + @Override + public ActionFuture nodesRestart(NodesRestartRequest request) { return nodesRestart.execute(request); } - @Override public void nodesRestart(NodesRestartRequest request, ActionListener listener) { + @Override + public void nodesRestart(NodesRestartRequest request, ActionListener listener) { nodesRestart.execute(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/node/NodeIndicesAdminClient.java b/src/main/java/org/elasticsearch/client/node/NodeIndicesAdminClient.java index cddcece6555..8326fdc518f 100644 --- a/src/main/java/org/elasticsearch/client/node/NodeIndicesAdminClient.java +++ b/src/main/java/org/elasticsearch/client/node/NodeIndicesAdminClient.java @@ -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 @@ -88,7 +88,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; /** - * @author kimchy (shay.banon) + * */ public class NodeIndicesAdminClient extends AbstractIndicesAdminClient implements IndicesAdminClient { @@ -134,14 +134,15 @@ public class NodeIndicesAdminClient extends AbstractIndicesAdminClient implement private final TransportDeleteIndexTemplateAction deleteIndexTemplateAction; - @Inject public NodeIndicesAdminClient(Settings settings, ThreadPool threadPool, TransportIndicesExistsAction indicesExistsAction, TransportIndicesStatsAction indicesStatsAction, TransportIndicesStatusAction indicesStatusAction, TransportIndicesSegmentsAction indicesSegmentsAction, - TransportCreateIndexAction createIndexAction, TransportDeleteIndexAction deleteIndexAction, - TransportCloseIndexAction closeIndexAction, TransportOpenIndexAction openIndexAction, - TransportRefreshAction refreshAction, TransportFlushAction flushAction, TransportOptimizeAction optimizeAction, - TransportPutMappingAction putMappingAction, TransportDeleteMappingAction deleteMappingAction, TransportGatewaySnapshotAction gatewaySnapshotAction, - TransportIndicesAliasesAction indicesAliasesAction, TransportClearIndicesCacheAction clearIndicesCacheAction, - TransportUpdateSettingsAction updateSettingsAction, TransportAnalyzeAction analyzeAction, - TransportPutIndexTemplateAction putIndexTemplateAction, TransportDeleteIndexTemplateAction deleteIndexTemplateAction) { + @Inject + public NodeIndicesAdminClient(Settings settings, ThreadPool threadPool, TransportIndicesExistsAction indicesExistsAction, TransportIndicesStatsAction indicesStatsAction, TransportIndicesStatusAction indicesStatusAction, TransportIndicesSegmentsAction indicesSegmentsAction, + TransportCreateIndexAction createIndexAction, TransportDeleteIndexAction deleteIndexAction, + TransportCloseIndexAction closeIndexAction, TransportOpenIndexAction openIndexAction, + TransportRefreshAction refreshAction, TransportFlushAction flushAction, TransportOptimizeAction optimizeAction, + TransportPutMappingAction putMappingAction, TransportDeleteMappingAction deleteMappingAction, TransportGatewaySnapshotAction gatewaySnapshotAction, + TransportIndicesAliasesAction indicesAliasesAction, TransportClearIndicesCacheAction clearIndicesCacheAction, + TransportUpdateSettingsAction updateSettingsAction, TransportAnalyzeAction analyzeAction, + TransportPutIndexTemplateAction putIndexTemplateAction, TransportDeleteIndexTemplateAction deleteIndexTemplateAction) { this.threadPool = threadPool; this.indicesExistsAction = indicesExistsAction; this.indicesStatsAction = indicesStatsAction; @@ -165,167 +166,208 @@ public class NodeIndicesAdminClient extends AbstractIndicesAdminClient implement this.deleteIndexTemplateAction = deleteIndexTemplateAction; } - @Override public ThreadPool threadPool() { + @Override + public ThreadPool threadPool() { return this.threadPool; } - @Override public ActionFuture exists(IndicesExistsRequest request) { + @Override + public ActionFuture exists(IndicesExistsRequest request) { return indicesExistsAction.execute(request); } - @Override public void exists(IndicesExistsRequest request, ActionListener listener) { + @Override + public void exists(IndicesExistsRequest request, ActionListener listener) { indicesExistsAction.execute(request, listener); } - @Override public ActionFuture stats(IndicesStatsRequest request) { + @Override + public ActionFuture stats(IndicesStatsRequest request) { return indicesStatsAction.execute(request); } - @Override public void stats(IndicesStatsRequest request, ActionListener lister) { + @Override + public void stats(IndicesStatsRequest request, ActionListener lister) { indicesStatsAction.execute(request, lister); } - @Override public ActionFuture status(IndicesStatusRequest request) { + @Override + public ActionFuture status(IndicesStatusRequest request) { return indicesStatusAction.execute(request); } - @Override public void status(IndicesStatusRequest request, ActionListener listener) { + @Override + public void status(IndicesStatusRequest request, ActionListener listener) { indicesStatusAction.execute(request, listener); } - @Override public ActionFuture segments(IndicesSegmentsRequest request) { + @Override + public ActionFuture segments(IndicesSegmentsRequest request) { return indicesSegmentsAction.execute(request); } - @Override public void segments(IndicesSegmentsRequest request, ActionListener listener) { + @Override + public void segments(IndicesSegmentsRequest request, ActionListener listener) { indicesSegmentsAction.execute(request, listener); } - @Override public ActionFuture create(CreateIndexRequest request) { + @Override + public ActionFuture create(CreateIndexRequest request) { return createIndexAction.execute(request); } - @Override public void create(CreateIndexRequest request, ActionListener listener) { + @Override + public void create(CreateIndexRequest request, ActionListener listener) { createIndexAction.execute(request, listener); } - @Override public ActionFuture delete(DeleteIndexRequest request) { + @Override + public ActionFuture delete(DeleteIndexRequest request) { return deleteIndexAction.execute(request); } - @Override public void delete(DeleteIndexRequest request, ActionListener listener) { + @Override + public void delete(DeleteIndexRequest request, ActionListener listener) { deleteIndexAction.execute(request, listener); } - @Override public ActionFuture close(CloseIndexRequest request) { + @Override + public ActionFuture close(CloseIndexRequest request) { return closeIndexAction.execute(request); } - @Override public void close(CloseIndexRequest request, ActionListener listener) { + @Override + public void close(CloseIndexRequest request, ActionListener listener) { closeIndexAction.execute(request, listener); } - @Override public ActionFuture open(OpenIndexRequest request) { + @Override + public ActionFuture open(OpenIndexRequest request) { return openIndexAction.execute(request); } - @Override public void open(OpenIndexRequest request, ActionListener listener) { + @Override + public void open(OpenIndexRequest request, ActionListener listener) { openIndexAction.execute(request, listener); } - @Override public ActionFuture refresh(RefreshRequest request) { + @Override + public ActionFuture refresh(RefreshRequest request) { return refreshAction.execute(request); } - @Override public void refresh(RefreshRequest request, ActionListener listener) { + @Override + public void refresh(RefreshRequest request, ActionListener listener) { refreshAction.execute(request, listener); } - @Override public ActionFuture flush(FlushRequest request) { + @Override + public ActionFuture flush(FlushRequest request) { return flushAction.execute(request); } - @Override public void flush(FlushRequest request, ActionListener listener) { + @Override + public void flush(FlushRequest request, ActionListener listener) { flushAction.execute(request, listener); } - @Override public ActionFuture optimize(OptimizeRequest request) { + @Override + public ActionFuture optimize(OptimizeRequest request) { return optimizeAction.execute(request); } - @Override public void optimize(OptimizeRequest request, ActionListener listener) { + @Override + public void optimize(OptimizeRequest request, ActionListener listener) { optimizeAction.execute(request, listener); } - @Override public ActionFuture putMapping(PutMappingRequest request) { + @Override + public ActionFuture putMapping(PutMappingRequest request) { return putMappingAction.execute(request); } - @Override public void putMapping(PutMappingRequest request, ActionListener listener) { + @Override + public void putMapping(PutMappingRequest request, ActionListener listener) { putMappingAction.execute(request, listener); } - @Override public ActionFuture deleteMapping(DeleteMappingRequest request) { + @Override + public ActionFuture deleteMapping(DeleteMappingRequest request) { return deleteMappingAction.execute(request); } - @Override public void deleteMapping(DeleteMappingRequest request, ActionListener listener) { + @Override + public void deleteMapping(DeleteMappingRequest request, ActionListener listener) { deleteMappingAction.execute(request, listener); } - @Override public ActionFuture gatewaySnapshot(GatewaySnapshotRequest request) { + @Override + public ActionFuture gatewaySnapshot(GatewaySnapshotRequest request) { return gatewaySnapshotAction.execute(request); } - @Override public void gatewaySnapshot(GatewaySnapshotRequest request, ActionListener listener) { + @Override + public void gatewaySnapshot(GatewaySnapshotRequest request, ActionListener listener) { gatewaySnapshotAction.execute(request, listener); } - @Override public ActionFuture aliases(IndicesAliasesRequest request) { + @Override + public ActionFuture aliases(IndicesAliasesRequest request) { return indicesAliasesAction.execute(request); } - @Override public void aliases(IndicesAliasesRequest request, ActionListener listener) { + @Override + public void aliases(IndicesAliasesRequest request, ActionListener listener) { indicesAliasesAction.execute(request, listener); } - @Override public ActionFuture clearCache(ClearIndicesCacheRequest request) { + @Override + public ActionFuture clearCache(ClearIndicesCacheRequest request) { return clearIndicesCacheAction.execute(request); } - @Override public void clearCache(ClearIndicesCacheRequest request, ActionListener listener) { + @Override + public void clearCache(ClearIndicesCacheRequest request, ActionListener listener) { clearIndicesCacheAction.execute(request, listener); } - @Override public ActionFuture updateSettings(UpdateSettingsRequest request) { + @Override + public ActionFuture updateSettings(UpdateSettingsRequest request) { return updateSettingsAction.execute(request); } - @Override public void updateSettings(UpdateSettingsRequest request, ActionListener listener) { + @Override + public void updateSettings(UpdateSettingsRequest request, ActionListener listener) { updateSettingsAction.execute(request, listener); } - @Override public ActionFuture analyze(AnalyzeRequest request) { + @Override + public ActionFuture analyze(AnalyzeRequest request) { return analyzeAction.execute(request); } - @Override public void analyze(AnalyzeRequest request, ActionListener listener) { + @Override + public void analyze(AnalyzeRequest request, ActionListener listener) { analyzeAction.execute(request, listener); } - @Override public ActionFuture putTemplate(PutIndexTemplateRequest request) { + @Override + public ActionFuture putTemplate(PutIndexTemplateRequest request) { return putIndexTemplateAction.execute(request); } - @Override public void putTemplate(PutIndexTemplateRequest request, ActionListener listener) { + @Override + public void putTemplate(PutIndexTemplateRequest request, ActionListener listener) { putIndexTemplateAction.execute(request, listener); } - @Override public ActionFuture deleteTemplate(DeleteIndexTemplateRequest request) { + @Override + public ActionFuture deleteTemplate(DeleteIndexTemplateRequest request) { return deleteIndexTemplateAction.execute(request); } - @Override public void deleteTemplate(DeleteIndexTemplateRequest request, ActionListener listener) { + @Override + public void deleteTemplate(DeleteIndexTemplateRequest request, ActionListener listener) { deleteIndexTemplateAction.execute(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/package-info.java b/src/main/java/org/elasticsearch/client/package-info.java index eb1a0ebd326..085358f9698 100644 --- a/src/main/java/org/elasticsearch/client/package-info.java +++ b/src/main/java/org/elasticsearch/client/package-info.java @@ -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 diff --git a/src/main/java/org/elasticsearch/client/support/AbstractClient.java b/src/main/java/org/elasticsearch/client/support/AbstractClient.java index e64b4715791..38340d8f36d 100644 --- a/src/main/java/org/elasticsearch/client/support/AbstractClient.java +++ b/src/main/java/org/elasticsearch/client/support/AbstractClient.java @@ -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,67 +34,82 @@ import org.elasticsearch.client.internal.InternalClient; import org.elasticsearch.common.Nullable; /** - * @author kimchy (shay.banon) + * */ public abstract class AbstractClient implements InternalClient { - @Override public IndexRequestBuilder prepareIndex() { + @Override + public IndexRequestBuilder prepareIndex() { return new IndexRequestBuilder(this, null); } - @Override public IndexRequestBuilder prepareIndex(String index, String type) { + @Override + public IndexRequestBuilder prepareIndex(String index, String type) { return prepareIndex(index, type, null); } - @Override public IndexRequestBuilder prepareIndex(String index, String type, @Nullable String id) { + @Override + public IndexRequestBuilder prepareIndex(String index, String type, @Nullable String id) { return prepareIndex().setIndex(index).setType(type).setId(id); } - @Override public DeleteRequestBuilder prepareDelete() { + @Override + public DeleteRequestBuilder prepareDelete() { return new DeleteRequestBuilder(this, null); } - @Override public DeleteRequestBuilder prepareDelete(String index, String type, String id) { + @Override + public DeleteRequestBuilder prepareDelete(String index, String type, String id) { return prepareDelete().setIndex(index).setType(type).setId(id); } - @Override public BulkRequestBuilder prepareBulk() { + @Override + public BulkRequestBuilder prepareBulk() { return new BulkRequestBuilder(this); } - @Override public DeleteByQueryRequestBuilder prepareDeleteByQuery(String... indices) { + @Override + public DeleteByQueryRequestBuilder prepareDeleteByQuery(String... indices) { return new DeleteByQueryRequestBuilder(this).setIndices(indices); } - @Override public GetRequestBuilder prepareGet() { + @Override + public GetRequestBuilder prepareGet() { return new GetRequestBuilder(this, null); } - @Override public GetRequestBuilder prepareGet(String index, String type, String id) { + @Override + public GetRequestBuilder prepareGet(String index, String type, String id) { return prepareGet().setIndex(index).setType(type).setId(id); } - @Override public MultiGetRequestBuilder prepareMultiGet() { + @Override + public MultiGetRequestBuilder prepareMultiGet() { return new MultiGetRequestBuilder(this); } - @Override public SearchRequestBuilder prepareSearch(String... indices) { + @Override + public SearchRequestBuilder prepareSearch(String... indices) { return new SearchRequestBuilder(this).setIndices(indices); } - @Override public SearchScrollRequestBuilder prepareSearchScroll(String scrollId) { + @Override + public SearchScrollRequestBuilder prepareSearchScroll(String scrollId) { return new SearchScrollRequestBuilder(this, scrollId); } - @Override public CountRequestBuilder prepareCount(String... indices) { + @Override + public CountRequestBuilder prepareCount(String... indices) { return new CountRequestBuilder(this).setIndices(indices); } - @Override public MoreLikeThisRequestBuilder prepareMoreLikeThis(String index, String type, String id) { + @Override + public MoreLikeThisRequestBuilder prepareMoreLikeThis(String index, String type, String id) { return new MoreLikeThisRequestBuilder(this, index, type, id); } - @Override public PercolateRequestBuilder preparePercolate(String index, String type) { + @Override + public PercolateRequestBuilder preparePercolate(String index, String type) { return new PercolateRequestBuilder(this, index, type); } } diff --git a/src/main/java/org/elasticsearch/client/support/AbstractClusterAdminClient.java b/src/main/java/org/elasticsearch/client/support/AbstractClusterAdminClient.java index da133613950..2475b63c6e9 100644 --- a/src/main/java/org/elasticsearch/client/support/AbstractClusterAdminClient.java +++ b/src/main/java/org/elasticsearch/client/support/AbstractClusterAdminClient.java @@ -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,55 +33,67 @@ import org.elasticsearch.client.action.admin.cluster.state.ClusterStateRequestBu import org.elasticsearch.client.internal.InternalClusterAdminClient; /** - * @author kimchy (shay.banon) + * */ public abstract class AbstractClusterAdminClient implements InternalClusterAdminClient { - @Override public ClusterHealthRequestBuilder prepareHealth(String... indices) { + @Override + public ClusterHealthRequestBuilder prepareHealth(String... indices) { return new ClusterHealthRequestBuilder(this).setIndices(indices); } - @Override public ClusterStateRequestBuilder prepareState() { + @Override + public ClusterStateRequestBuilder prepareState() { return new ClusterStateRequestBuilder(this); } - @Override public ClusterRerouteRequestBuilder prepareReroute() { + @Override + public ClusterRerouteRequestBuilder prepareReroute() { return new ClusterRerouteRequestBuilder(this); } - @Override public ClusterUpdateSettingsRequestBuilder prepareUpdateSettings() { + @Override + public ClusterUpdateSettingsRequestBuilder prepareUpdateSettings() { return new ClusterUpdateSettingsRequestBuilder(this); } - @Override public NodesInfoRequestBuilder prepareNodesInfo(String... nodesIds) { + @Override + public NodesInfoRequestBuilder prepareNodesInfo(String... nodesIds) { return new NodesInfoRequestBuilder(this).setNodesIds(nodesIds); } - @Override public NodesStatsRequestBuilder prepareNodesStats(String... nodesIds) { + @Override + public NodesStatsRequestBuilder prepareNodesStats(String... nodesIds) { return new NodesStatsRequestBuilder(this).setNodesIds(nodesIds); } - @Override public NodesRestartRequestBuilder prepareNodesRestart(String... nodesIds) { + @Override + public NodesRestartRequestBuilder prepareNodesRestart(String... nodesIds) { return new NodesRestartRequestBuilder(this).setNodesIds(nodesIds); } - @Override public NodesShutdownRequestBuilder prepareNodesShutdown(String... nodesIds) { + @Override + public NodesShutdownRequestBuilder prepareNodesShutdown(String... nodesIds) { return new NodesShutdownRequestBuilder(this).setNodesIds(nodesIds); } - @Override public SinglePingRequestBuilder preparePingSingle() { + @Override + public SinglePingRequestBuilder preparePingSingle() { return new SinglePingRequestBuilder(this); } - @Override public SinglePingRequestBuilder preparePingSingle(String index, String type, String id) { + @Override + public SinglePingRequestBuilder preparePingSingle(String index, String type, String id) { return preparePingSingle().setIndex(index).setType(type).setId(id); } - @Override public BroadcastPingRequestBuilder preparePingBroadcast(String... indices) { + @Override + public BroadcastPingRequestBuilder preparePingBroadcast(String... indices) { return new BroadcastPingRequestBuilder(this).setIndices(indices); } - @Override public ReplicationPingRequestBuilder preparePingReplication(String... indices) { + @Override + public ReplicationPingRequestBuilder preparePingReplication(String... indices) { return new ReplicationPingRequestBuilder(this).setIndices(indices); } } diff --git a/src/main/java/org/elasticsearch/client/support/AbstractIndicesAdminClient.java b/src/main/java/org/elasticsearch/client/support/AbstractIndicesAdminClient.java index 7487f633ba1..c5b4f3c2329 100644 --- a/src/main/java/org/elasticsearch/client/support/AbstractIndicesAdminClient.java +++ b/src/main/java/org/elasticsearch/client/support/AbstractIndicesAdminClient.java @@ -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 @@ -42,87 +42,107 @@ import org.elasticsearch.client.action.admin.indices.template.put.PutIndexTempla import org.elasticsearch.client.internal.InternalIndicesAdminClient; /** - * @author kimchy (shay.banon) + * */ public abstract class AbstractIndicesAdminClient implements InternalIndicesAdminClient { - @Override public IndicesExistsRequestBuilder prepareExists(String... indices) { + @Override + public IndicesExistsRequestBuilder prepareExists(String... indices) { return new IndicesExistsRequestBuilder(this, indices); } - @Override public IndicesAliasesRequestBuilder prepareAliases() { + @Override + public IndicesAliasesRequestBuilder prepareAliases() { return new IndicesAliasesRequestBuilder(this); } - @Override public ClearIndicesCacheRequestBuilder prepareClearCache(String... indices) { + @Override + public ClearIndicesCacheRequestBuilder prepareClearCache(String... indices) { return new ClearIndicesCacheRequestBuilder(this).setIndices(indices); } - @Override public CreateIndexRequestBuilder prepareCreate(String index) { + @Override + public CreateIndexRequestBuilder prepareCreate(String index) { return new CreateIndexRequestBuilder(this, index); } - @Override public DeleteIndexRequestBuilder prepareDelete(String... indices) { + @Override + public DeleteIndexRequestBuilder prepareDelete(String... indices) { return new DeleteIndexRequestBuilder(this, indices); } - @Override public CloseIndexRequestBuilder prepareClose(String index) { + @Override + public CloseIndexRequestBuilder prepareClose(String index) { return new CloseIndexRequestBuilder(this, index); } - @Override public OpenIndexRequestBuilder prepareOpen(String index) { + @Override + public OpenIndexRequestBuilder prepareOpen(String index) { return new OpenIndexRequestBuilder(this, index); } - @Override public FlushRequestBuilder prepareFlush(String... indices) { + @Override + public FlushRequestBuilder prepareFlush(String... indices) { return new FlushRequestBuilder(this).setIndices(indices); } - @Override public GatewaySnapshotRequestBuilder prepareGatewaySnapshot(String... indices) { + @Override + public GatewaySnapshotRequestBuilder prepareGatewaySnapshot(String... indices) { return new GatewaySnapshotRequestBuilder(this).setIndices(indices); } - @Override public PutMappingRequestBuilder preparePutMapping(String... indices) { + @Override + public PutMappingRequestBuilder preparePutMapping(String... indices) { return new PutMappingRequestBuilder(this).setIndices(indices); } - @Override public DeleteMappingRequestBuilder prepareDeleteMapping(String... indices) { + @Override + public DeleteMappingRequestBuilder prepareDeleteMapping(String... indices) { return new DeleteMappingRequestBuilder(this).setIndices(indices); } - @Override public OptimizeRequestBuilder prepareOptimize(String... indices) { + @Override + public OptimizeRequestBuilder prepareOptimize(String... indices) { return new OptimizeRequestBuilder(this).setIndices(indices); } - @Override public RefreshRequestBuilder prepareRefresh(String... indices) { + @Override + public RefreshRequestBuilder prepareRefresh(String... indices) { return new RefreshRequestBuilder(this).setIndices(indices); } - @Override public IndicesStatsRequestBuilder prepareStats(String... indices) { + @Override + public IndicesStatsRequestBuilder prepareStats(String... indices) { return new IndicesStatsRequestBuilder(this).setIndices(indices); } - @Override public IndicesStatusRequestBuilder prepareStatus(String... indices) { + @Override + public IndicesStatusRequestBuilder prepareStatus(String... indices) { return new IndicesStatusRequestBuilder(this).setIndices(indices); } - @Override public IndicesSegmentsRequestBuilder prepareSegments(String... indices) { + @Override + public IndicesSegmentsRequestBuilder prepareSegments(String... indices) { return new IndicesSegmentsRequestBuilder(this).setIndices(indices); } - @Override public UpdateSettingsRequestBuilder prepareUpdateSettings(String... indices) { + @Override + public UpdateSettingsRequestBuilder prepareUpdateSettings(String... indices) { return new UpdateSettingsRequestBuilder(this).setIndices(indices); } - @Override public AnalyzeRequestBuilder prepareAnalyze(String index, String text) { + @Override + public AnalyzeRequestBuilder prepareAnalyze(String index, String text) { return new AnalyzeRequestBuilder(this, index, text); } - @Override public PutIndexTemplateRequestBuilder preparePutTemplate(String name) { + @Override + public PutIndexTemplateRequestBuilder preparePutTemplate(String name) { return new PutIndexTemplateRequestBuilder(this, name); } - @Override public DeleteIndexTemplateRequestBuilder prepareDeleteTemplate(String name) { + @Override + public DeleteIndexTemplateRequestBuilder prepareDeleteTemplate(String name) { return new DeleteIndexTemplateRequestBuilder(this, name); } } diff --git a/src/main/java/org/elasticsearch/client/transport/ClientTransportModule.java b/src/main/java/org/elasticsearch/client/transport/ClientTransportModule.java index 1cbd994322a..0d8eee9bfc2 100644 --- a/src/main/java/org/elasticsearch/client/transport/ClientTransportModule.java +++ b/src/main/java/org/elasticsearch/client/transport/ClientTransportModule.java @@ -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,11 +26,12 @@ import org.elasticsearch.client.transport.support.InternalTransportIndicesAdminC import org.elasticsearch.common.inject.AbstractModule; /** - * @author kimchy (Shay Banon) + * */ public class ClientTransportModule extends AbstractModule { - @Override protected void configure() { + @Override + protected void configure() { bind(InternalTransportClient.class).asEagerSingleton(); bind(InternalTransportAdminClient.class).asEagerSingleton(); bind(InternalTransportIndicesAdminClient.class).asEagerSingleton(); diff --git a/src/main/java/org/elasticsearch/client/transport/NoNodeAvailableException.java b/src/main/java/org/elasticsearch/client/transport/NoNodeAvailableException.java index 7c1a2b26cf7..34c49d097a6 100644 --- a/src/main/java/org/elasticsearch/client/transport/NoNodeAvailableException.java +++ b/src/main/java/org/elasticsearch/client/transport/NoNodeAvailableException.java @@ -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.ElasticSearchException; /** * An exception indicating no node is available to perform the operation. * - * @author kimchy (Shay Banon) + * */ public class NoNodeAvailableException extends ElasticSearchException { diff --git a/src/main/java/org/elasticsearch/client/transport/TransportClient.java b/src/main/java/org/elasticsearch/client/transport/TransportClient.java index 35edfe2ce9c..890ad1f3b38 100644 --- a/src/main/java/org/elasticsearch/client/transport/TransportClient.java +++ b/src/main/java/org/elasticsearch/client/transport/TransportClient.java @@ -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.client.transport; +import com.google.common.collect.ImmutableList; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.action.ActionFuture; import org.elasticsearch.action.ActionListener; @@ -49,7 +50,6 @@ import org.elasticsearch.client.transport.support.InternalTransportClient; import org.elasticsearch.cluster.ClusterNameModule; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.CacheRecycler; -import org.elasticsearch.common.collect.ImmutableList; import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.inject.Injector; import org.elasticsearch.common.inject.ModulesBuilder; @@ -72,16 +72,16 @@ import org.elasticsearch.transport.TransportService; import java.util.concurrent.TimeUnit; -import static org.elasticsearch.common.settings.ImmutableSettings.*; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; /** * The transport client allows to create a client that is not part of the cluster, but simply connects to one * or more nodes directly by adding their respective addresses using {@link #addTransportAddress(org.elasticsearch.common.transport.TransportAddress)}. - * + *

*

The transport client important modules used is the {@link org.elasticsearch.transport.TransportModule} which is * started in client mode (only connects, no bind). * - * @author kimchy (shay.banon) + * */ public class TransportClient extends AbstractClient { @@ -180,7 +180,7 @@ public class TransportClient extends AbstractClient { /** * Returns the current connected transport nodes that this client will use. - * + *

*

The nodes include all the nodes that are currently alive based on the transport * addresses provided. */ @@ -190,10 +190,10 @@ public class TransportClient extends AbstractClient { /** * Adds a transport address that will be used to connect to. - * + *

*

The Node this transport address represents will be used if its possible to connect to it. * If it is unavailable, it will be automatically connected to once it is up. - * + *

*

In order to get the list of all the current connected nodes, please see {@link #connectedNodes()}. */ public TransportClient addTransportAddress(TransportAddress transportAddress) { @@ -212,7 +212,8 @@ public class TransportClient extends AbstractClient { /** * Closes the client. */ - @Override public void close() { + @Override + public void close() { injector.getInstance(TransportClientNodesService.class).close(); injector.getInstance(TransportService.class).close(); try { @@ -238,99 +239,123 @@ public class TransportClient extends AbstractClient { ThreadLocals.clearReferencesThreadLocals(); } - @Override public ThreadPool threadPool() { + @Override + public ThreadPool threadPool() { return internalClient.threadPool(); } - @Override public AdminClient admin() { + @Override + public AdminClient admin() { return internalClient.admin(); } - @Override public ActionFuture index(IndexRequest request) { + @Override + public ActionFuture index(IndexRequest request) { return internalClient.index(request); } - @Override public void index(IndexRequest request, ActionListener listener) { + @Override + public void index(IndexRequest request, ActionListener listener) { internalClient.index(request, listener); } - @Override public ActionFuture delete(DeleteRequest request) { + @Override + public ActionFuture delete(DeleteRequest request) { return internalClient.delete(request); } - @Override public void delete(DeleteRequest request, ActionListener listener) { + @Override + public void delete(DeleteRequest request, ActionListener listener) { internalClient.delete(request, listener); } - @Override public ActionFuture bulk(BulkRequest request) { + @Override + public ActionFuture bulk(BulkRequest request) { return internalClient.bulk(request); } - @Override public void bulk(BulkRequest request, ActionListener listener) { + @Override + public void bulk(BulkRequest request, ActionListener listener) { internalClient.bulk(request, listener); } - @Override public ActionFuture deleteByQuery(DeleteByQueryRequest request) { + @Override + public ActionFuture deleteByQuery(DeleteByQueryRequest request) { return internalClient.deleteByQuery(request); } - @Override public void deleteByQuery(DeleteByQueryRequest request, ActionListener listener) { + @Override + public void deleteByQuery(DeleteByQueryRequest request, ActionListener listener) { internalClient.deleteByQuery(request, listener); } - @Override public ActionFuture get(GetRequest request) { + @Override + public ActionFuture get(GetRequest request) { return internalClient.get(request); } - @Override public void get(GetRequest request, ActionListener listener) { + @Override + public void get(GetRequest request, ActionListener listener) { internalClient.get(request, listener); } - @Override public ActionFuture multiGet(MultiGetRequest request) { + @Override + public ActionFuture multiGet(MultiGetRequest request) { return internalClient.multiGet(request); } - @Override public void multiGet(MultiGetRequest request, ActionListener listener) { + @Override + public void multiGet(MultiGetRequest request, ActionListener listener) { internalClient.multiGet(request, listener); } - @Override public ActionFuture count(CountRequest request) { + @Override + public ActionFuture count(CountRequest request) { return internalClient.count(request); } - @Override public void count(CountRequest request, ActionListener listener) { + @Override + public void count(CountRequest request, ActionListener listener) { internalClient.count(request, listener); } - @Override public ActionFuture search(SearchRequest request) { + @Override + public ActionFuture search(SearchRequest request) { return internalClient.search(request); } - @Override public void search(SearchRequest request, ActionListener listener) { + @Override + public void search(SearchRequest request, ActionListener listener) { internalClient.search(request, listener); } - @Override public ActionFuture searchScroll(SearchScrollRequest request) { + @Override + public ActionFuture searchScroll(SearchScrollRequest request) { return internalClient.searchScroll(request); } - @Override public void searchScroll(SearchScrollRequest request, ActionListener listener) { + @Override + public void searchScroll(SearchScrollRequest request, ActionListener listener) { internalClient.searchScroll(request, listener); } - @Override public ActionFuture moreLikeThis(MoreLikeThisRequest request) { + @Override + public ActionFuture moreLikeThis(MoreLikeThisRequest request) { return internalClient.moreLikeThis(request); } - @Override public void moreLikeThis(MoreLikeThisRequest request, ActionListener listener) { + @Override + public void moreLikeThis(MoreLikeThisRequest request, ActionListener listener) { internalClient.moreLikeThis(request, listener); } - @Override public ActionFuture percolate(PercolateRequest request) { + @Override + public ActionFuture percolate(PercolateRequest request) { return internalClient.percolate(request); } - @Override public void percolate(PercolateRequest request, ActionListener listener) { + @Override + public void percolate(PercolateRequest request, ActionListener listener) { internalClient.percolate(request, listener); } } diff --git a/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java b/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java index 7cdfc2d7810..bb1ba08a9e6 100644 --- a/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java +++ b/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java @@ -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,8 @@ package org.elasticsearch.client.transport; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Maps; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.action.ActionListener; @@ -28,19 +30,13 @@ import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; import org.elasticsearch.client.Requests; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.node.DiscoveryNode; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.Maps; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.transport.BaseTransportResponseHandler; -import org.elasticsearch.transport.ConnectTransportException; -import org.elasticsearch.transport.FutureTransportResponseHandler; -import org.elasticsearch.transport.TransportException; -import org.elasticsearch.transport.TransportService; +import org.elasticsearch.transport.*; import java.util.HashSet; import java.util.Iterator; @@ -50,10 +46,10 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.atomic.AtomicInteger; -import static org.elasticsearch.common.unit.TimeValue.*; +import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; /** - * @author kimchy (shay.banon) + * */ public class TransportClientNodesService extends AbstractComponent { @@ -82,8 +78,9 @@ public class TransportClientNodesService extends AbstractComponent { private volatile boolean closed; - @Inject public TransportClientNodesService(Settings settings, ClusterName clusterName, - TransportService transportService, ThreadPool threadPool) { + @Inject + public TransportClientNodesService(Settings settings, ClusterName clusterName, + TransportService transportService, ThreadPool threadPool) { super(settings); this.clusterName = clusterName; this.transportService = transportService; @@ -201,11 +198,13 @@ public class TransportClientNodesService extends AbstractComponent { this.index = index; } - @Override public void onResponse(Response response) { + @Override + public void onResponse(Response response) { listener.onResponse(response); } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { if (ExceptionsHelper.unwrapCause(e) instanceof ConnectTransportException) { int i = ++this.i; if (i == nodes.size()) { @@ -241,7 +240,8 @@ public class TransportClientNodesService extends AbstractComponent { } class ScheduledNodeSampler implements Runnable { - @Override public void run() { + @Override + public void run() { nodesSampler.sample(); if (!closed) { nodesSamplerFuture = threadPool.schedule(nodesSamplerInterval, ThreadPool.Names.CACHED, this); @@ -251,7 +251,8 @@ public class TransportClientNodesService extends AbstractComponent { class SimpleNodeSampler implements NodeSampler { - @Override public synchronized void sample() { + @Override + public synchronized void sample() { if (closed) { return; } @@ -267,7 +268,8 @@ public class TransportClientNodesService extends AbstractComponent { } try { NodesInfoResponse nodeInfo = transportService.submitRequest(node, TransportActions.Admin.Cluster.Node.INFO, Requests.nodesInfoRequest("_local"), new FutureTransportResponseHandler() { - @Override public NodesInfoResponse newInstance() { + @Override + public NodesInfoResponse newInstance() { return new NodesInfoResponse(); } }).txGet(); @@ -286,7 +288,8 @@ public class TransportClientNodesService extends AbstractComponent { class SniffNodesSampler implements NodeSampler { - @Override public synchronized void sample() { + @Override + public synchronized void sample() { if (closed) { return; } @@ -305,25 +308,30 @@ public class TransportClientNodesService extends AbstractComponent { final CopyOnWriteArrayList nodesInfoResponses = new CopyOnWriteArrayList(); for (final DiscoveryNode listedNode : nodesToPing.values()) { threadPool.executor(ThreadPool.Names.MANAGEMENT).execute(new Runnable() { - @Override public void run() { + @Override + public void run() { try { transportService.connectToNode(listedNode); // make sure we are connected to it transportService.sendRequest(listedNode, TransportActions.Admin.Cluster.Node.INFO, Requests.nodesInfoRequest("_all"), new BaseTransportResponseHandler() { - @Override public NodesInfoResponse newInstance() { + @Override + public NodesInfoResponse newInstance() { return new NodesInfoResponse(); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } - @Override public void handleResponse(NodesInfoResponse response) { + @Override + public void handleResponse(NodesInfoResponse response) { nodesInfoResponses.add(response); latch.countDown(); } - @Override public void handleException(TransportException exp) { + @Override + public void handleException(TransportException exp) { logger.debug("Failed to get node info from " + listedNode + ", removed from nodes list", exp); latch.countDown(); } diff --git a/src/main/java/org/elasticsearch/client/transport/action/ClientTransportAction.java b/src/main/java/org/elasticsearch/client/transport/action/ClientTransportAction.java index cb227b4ffce..0e7576be353 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/ClientTransportAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/ClientTransportAction.java @@ -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.action.ActionResponse; import org.elasticsearch.cluster.node.DiscoveryNode; /** - * @author kimchy (Shay Banon) + * */ public interface ClientTransportAction { diff --git a/src/main/java/org/elasticsearch/client/transport/action/ClientTransportActionModule.java b/src/main/java/org/elasticsearch/client/transport/action/ClientTransportActionModule.java index caabf58dc7a..6bd0d45ad6d 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/ClientTransportActionModule.java +++ b/src/main/java/org/elasticsearch/client/transport/action/ClientTransportActionModule.java @@ -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 @@ -63,11 +63,12 @@ import org.elasticsearch.client.transport.action.search.ClientTransportSearchScr import org.elasticsearch.common.inject.AbstractModule; /** - * @author kimchy (shay.banon) + * */ public class ClientTransportActionModule extends AbstractModule { - @Override protected void configure() { + @Override + protected void configure() { bind(ClientTransportIndexAction.class).asEagerSingleton(); bind(ClientTransportDeleteAction.class).asEagerSingleton(); bind(ClientTransportDeleteByQueryAction.class).asEagerSingleton(); diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/health/ClientTransportClusterHealthAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/health/ClientTransportClusterHealthAction.java index 24ba1fd32c1..003d42294d1 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/health/ClientTransportClusterHealthAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/health/ClientTransportClusterHealthAction.java @@ -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,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (Shay Banon) + * */ public class ClientTransportClusterHealthAction extends BaseClientTransportAction { - @Inject public ClientTransportClusterHealthAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportClusterHealthAction(Settings settings, TransportService transportService) { super(settings, transportService, ClusterHealthResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.Admin.Cluster.HEALTH; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/node/info/ClientTransportNodesInfoAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/node/info/ClientTransportNodesInfoAction.java index 550e96da187..48a9bde1642 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/node/info/ClientTransportNodesInfoAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/node/info/ClientTransportNodesInfoAction.java @@ -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,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (shay.banon) + * */ public class ClientTransportNodesInfoAction extends BaseClientTransportAction { - @Inject public ClientTransportNodesInfoAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportNodesInfoAction(Settings settings, TransportService transportService) { super(settings, transportService, NodesInfoResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.Admin.Cluster.Node.INFO; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/node/restart/ClientTransportNodesRestartAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/node/restart/ClientTransportNodesRestartAction.java index fd156d2e519..307e5a6777d 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/node/restart/ClientTransportNodesRestartAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/node/restart/ClientTransportNodesRestartAction.java @@ -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,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (shay.banon) + * */ public class ClientTransportNodesRestartAction extends BaseClientTransportAction { - @Inject public ClientTransportNodesRestartAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportNodesRestartAction(Settings settings, TransportService transportService) { super(settings, transportService, NodesRestartResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.Admin.Cluster.Node.RESTART; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/node/shutdown/ClientTransportNodesShutdownAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/node/shutdown/ClientTransportNodesShutdownAction.java index f238f7c0790..ee2b4b71863 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/node/shutdown/ClientTransportNodesShutdownAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/node/shutdown/ClientTransportNodesShutdownAction.java @@ -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,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (shay.banon) + * */ public class ClientTransportNodesShutdownAction extends BaseClientTransportAction { - @Inject public ClientTransportNodesShutdownAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportNodesShutdownAction(Settings settings, TransportService transportService) { super(settings, transportService, NodesShutdownResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.Admin.Cluster.Node.SHUTDOWN; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/node/stats/ClientTransportNodesStatsAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/node/stats/ClientTransportNodesStatsAction.java index fafdef3f8b5..bc404dadd49 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/node/stats/ClientTransportNodesStatsAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/node/stats/ClientTransportNodesStatsAction.java @@ -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,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (shay.banon) + * */ public class ClientTransportNodesStatsAction extends BaseClientTransportAction { - @Inject public ClientTransportNodesStatsAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportNodesStatsAction(Settings settings, TransportService transportService) { super(settings, transportService, NodesStatsResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.Admin.Cluster.Node.STATS; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/ping/broadcast/ClientTransportBroadcastPingAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/ping/broadcast/ClientTransportBroadcastPingAction.java index f823b537fc0..ca91db202bb 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/ping/broadcast/ClientTransportBroadcastPingAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/ping/broadcast/ClientTransportBroadcastPingAction.java @@ -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,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (Shay Banon) + * */ public class ClientTransportBroadcastPingAction extends BaseClientTransportAction { - @Inject public ClientTransportBroadcastPingAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportBroadcastPingAction(Settings settings, TransportService transportService) { super(settings, transportService, BroadcastPingResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.Admin.Cluster.Ping.BROADCAST; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/ping/replication/ClientTransportReplicationPingAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/ping/replication/ClientTransportReplicationPingAction.java index 92f7e7e1b29..7c1744c10f2 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/ping/replication/ClientTransportReplicationPingAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/ping/replication/ClientTransportReplicationPingAction.java @@ -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,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (Shay Banon) + * */ public class ClientTransportReplicationPingAction extends BaseClientTransportAction { - @Inject public ClientTransportReplicationPingAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportReplicationPingAction(Settings settings, TransportService transportService) { super(settings, transportService, ReplicationPingResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.Admin.Cluster.Ping.REPLICATION; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/ping/single/ClientTransportSinglePingAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/ping/single/ClientTransportSinglePingAction.java index ad515332e7e..2d6043bac00 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/ping/single/ClientTransportSinglePingAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/ping/single/ClientTransportSinglePingAction.java @@ -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,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (Shay Banon) + * */ public class ClientTransportSinglePingAction extends BaseClientTransportAction { - @Inject public ClientTransportSinglePingAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportSinglePingAction(Settings settings, TransportService transportService) { super(settings, transportService, SinglePingResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.Admin.Cluster.Ping.SINGLE; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/reroute/ClientTransportClusterRerouteAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/reroute/ClientTransportClusterRerouteAction.java index 21ff3e43c8f..320ac108ded 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/reroute/ClientTransportClusterRerouteAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/reroute/ClientTransportClusterRerouteAction.java @@ -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,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (Shay Banon) + * */ public class ClientTransportClusterRerouteAction extends BaseClientTransportAction { - @Inject public ClientTransportClusterRerouteAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportClusterRerouteAction(Settings settings, TransportService transportService) { super(settings, transportService, ClusterRerouteResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.Admin.Cluster.REROUTE; } } diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/settings/ClientTransportClusterUpdateSettingsAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/settings/ClientTransportClusterUpdateSettingsAction.java index d34ece63232..9e5af794204 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/settings/ClientTransportClusterUpdateSettingsAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/settings/ClientTransportClusterUpdateSettingsAction.java @@ -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,11 +31,13 @@ import org.elasticsearch.transport.TransportService; */ public class ClientTransportClusterUpdateSettingsAction extends BaseClientTransportAction { - @Inject public ClientTransportClusterUpdateSettingsAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportClusterUpdateSettingsAction(Settings settings, TransportService transportService) { super(settings, transportService, ClusterUpdateSettingsResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.Admin.Cluster.UPDATE_SETTINGS; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/state/ClientTransportClusterStateAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/state/ClientTransportClusterStateAction.java index 1b338201e54..f05a4d0e543 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/state/ClientTransportClusterStateAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/cluster/state/ClientTransportClusterStateAction.java @@ -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,11 +31,13 @@ import org.elasticsearch.transport.TransportService; */ public class ClientTransportClusterStateAction extends BaseClientTransportAction { - @Inject public ClientTransportClusterStateAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportClusterStateAction(Settings settings, TransportService transportService) { super(settings, transportService, ClusterStateResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.Admin.Cluster.STATE; } } diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/alias/ClientTransportIndicesAliasesAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/alias/ClientTransportIndicesAliasesAction.java index a7c20de919f..31431747052 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/alias/ClientTransportIndicesAliasesAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/alias/ClientTransportIndicesAliasesAction.java @@ -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,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (shay.banon) + * */ public class ClientTransportIndicesAliasesAction extends BaseClientTransportAction { - @Inject public ClientTransportIndicesAliasesAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportIndicesAliasesAction(Settings settings, TransportService transportService) { super(settings, transportService, IndicesAliasesResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.Admin.Indices.ALIASES; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/analyze/ClientTransportAnalyzeAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/analyze/ClientTransportAnalyzeAction.java index ce6a51dfeb7..64f8dd89dd9 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/analyze/ClientTransportAnalyzeAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/analyze/ClientTransportAnalyzeAction.java @@ -28,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (shay.banon) + * */ public class ClientTransportAnalyzeAction extends BaseClientTransportAction { - @Inject public ClientTransportAnalyzeAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportAnalyzeAction(Settings settings, TransportService transportService) { super(settings, transportService, AnalyzeResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.Admin.Indices.ANALYZE; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/cache/clear/ClientTransportClearIndicesCacheAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/cache/clear/ClientTransportClearIndicesCacheAction.java index bab0a026078..944736b3db1 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/cache/clear/ClientTransportClearIndicesCacheAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/cache/clear/ClientTransportClearIndicesCacheAction.java @@ -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,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (shay.banon) + * */ public class ClientTransportClearIndicesCacheAction extends BaseClientTransportAction { - @Inject public ClientTransportClearIndicesCacheAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportClearIndicesCacheAction(Settings settings, TransportService transportService) { super(settings, transportService, ClearIndicesCacheResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.Admin.Indices.Cache.CLEAR; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/close/ClientTransportCloseIndexAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/close/ClientTransportCloseIndexAction.java index 467bc3d7d0f..4644c105fed 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/close/ClientTransportCloseIndexAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/close/ClientTransportCloseIndexAction.java @@ -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,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (Shay Banon) + * */ public class ClientTransportCloseIndexAction extends BaseClientTransportAction { - @Inject public ClientTransportCloseIndexAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportCloseIndexAction(Settings settings, TransportService transportService) { super(settings, transportService, CloseIndexResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.Admin.Indices.CLOSE; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/create/ClientTransportCreateIndexAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/create/ClientTransportCreateIndexAction.java index 61c106826c9..e6fde7cdbb2 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/create/ClientTransportCreateIndexAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/create/ClientTransportCreateIndexAction.java @@ -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,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (shay.banon) + * */ public class ClientTransportCreateIndexAction extends BaseClientTransportAction { - @Inject public ClientTransportCreateIndexAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportCreateIndexAction(Settings settings, TransportService transportService) { super(settings, transportService, CreateIndexResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.Admin.Indices.CREATE; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/delete/ClientTransportDeleteIndexAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/delete/ClientTransportDeleteIndexAction.java index d044f88ca06..5e3287316a4 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/delete/ClientTransportDeleteIndexAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/delete/ClientTransportDeleteIndexAction.java @@ -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,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (Shay Banon) + * */ public class ClientTransportDeleteIndexAction extends BaseClientTransportAction { - @Inject public ClientTransportDeleteIndexAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportDeleteIndexAction(Settings settings, TransportService transportService) { super(settings, transportService, DeleteIndexResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.Admin.Indices.DELETE; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/exists/ClientTransportIndicesExistsAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/exists/ClientTransportIndicesExistsAction.java index f60e71d5494..bbfa60fd74b 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/exists/ClientTransportIndicesExistsAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/exists/ClientTransportIndicesExistsAction.java @@ -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,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (Shay Banon) + * */ public class ClientTransportIndicesExistsAction extends BaseClientTransportAction { - @Inject public ClientTransportIndicesExistsAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportIndicesExistsAction(Settings settings, TransportService transportService) { super(settings, transportService, IndicesExistsResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.Admin.Indices.EXISTS; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/flush/ClientTransportFlushAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/flush/ClientTransportFlushAction.java index ce911455d0c..b302f6cf519 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/flush/ClientTransportFlushAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/flush/ClientTransportFlushAction.java @@ -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,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (Shay Banon) + * */ public class ClientTransportFlushAction extends BaseClientTransportAction { - @Inject public ClientTransportFlushAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportFlushAction(Settings settings, TransportService transportService) { super(settings, transportService, FlushResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.Admin.Indices.FLUSH; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/gateway/snapshot/ClientTransportGatewaySnapshotAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/gateway/snapshot/ClientTransportGatewaySnapshotAction.java index e265036d291..1941c46eb61 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/gateway/snapshot/ClientTransportGatewaySnapshotAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/gateway/snapshot/ClientTransportGatewaySnapshotAction.java @@ -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,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (Shay Banon) + * */ public class ClientTransportGatewaySnapshotAction extends BaseClientTransportAction { - @Inject public ClientTransportGatewaySnapshotAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportGatewaySnapshotAction(Settings settings, TransportService transportService) { super(settings, transportService, GatewaySnapshotResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.Admin.Indices.Gateway.SNAPSHOT; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/mapping/delete/ClientTransportDeleteMappingAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/mapping/delete/ClientTransportDeleteMappingAction.java index d47ba9906dd..6044ced3039 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/mapping/delete/ClientTransportDeleteMappingAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/mapping/delete/ClientTransportDeleteMappingAction.java @@ -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,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (shay.banon) + * */ public class ClientTransportDeleteMappingAction extends BaseClientTransportAction { - @Inject public ClientTransportDeleteMappingAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportDeleteMappingAction(Settings settings, TransportService transportService) { super(settings, transportService, DeleteMappingResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.Admin.Indices.Mapping.DELETE; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/mapping/put/ClientTransportPutMappingAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/mapping/put/ClientTransportPutMappingAction.java index af768fa5e92..e2a1402ff3f 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/mapping/put/ClientTransportPutMappingAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/mapping/put/ClientTransportPutMappingAction.java @@ -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,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (shay.banon) + * */ public class ClientTransportPutMappingAction extends BaseClientTransportAction { - @Inject public ClientTransportPutMappingAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportPutMappingAction(Settings settings, TransportService transportService) { super(settings, transportService, PutMappingResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.Admin.Indices.Mapping.PUT; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/open/ClientTransportOpenIndexAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/open/ClientTransportOpenIndexAction.java index 4fd7eab1356..5f99701dc7e 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/open/ClientTransportOpenIndexAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/open/ClientTransportOpenIndexAction.java @@ -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,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (Shay Banon) + * */ public class ClientTransportOpenIndexAction extends BaseClientTransportAction { - @Inject public ClientTransportOpenIndexAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportOpenIndexAction(Settings settings, TransportService transportService) { super(settings, transportService, OpenIndexResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.Admin.Indices.OPEN; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/optimize/ClientTransportOptimizeAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/optimize/ClientTransportOptimizeAction.java index 38e003f022a..6b3c9bcfa6d 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/optimize/ClientTransportOptimizeAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/optimize/ClientTransportOptimizeAction.java @@ -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,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (Shay Banon) + * */ public class ClientTransportOptimizeAction extends BaseClientTransportAction { - @Inject public ClientTransportOptimizeAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportOptimizeAction(Settings settings, TransportService transportService) { super(settings, transportService, OptimizeResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.Admin.Indices.OPTIMIZE; } } diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/refresh/ClientTransportRefreshAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/refresh/ClientTransportRefreshAction.java index d2cd0dd7cd7..dace2ddac3d 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/refresh/ClientTransportRefreshAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/refresh/ClientTransportRefreshAction.java @@ -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,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (Shay Banon) + * */ public class ClientTransportRefreshAction extends BaseClientTransportAction { - @Inject public ClientTransportRefreshAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportRefreshAction(Settings settings, TransportService transportService) { super(settings, transportService, RefreshResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.Admin.Indices.REFRESH; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/segments/ClientTransportIndicesSegmentsAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/segments/ClientTransportIndicesSegmentsAction.java index ad4389a6439..85d0b69eea0 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/segments/ClientTransportIndicesSegmentsAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/segments/ClientTransportIndicesSegmentsAction.java @@ -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,11 +31,13 @@ import org.elasticsearch.transport.TransportService; */ public class ClientTransportIndicesSegmentsAction extends BaseClientTransportAction { - @Inject public ClientTransportIndicesSegmentsAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportIndicesSegmentsAction(Settings settings, TransportService transportService) { super(settings, transportService, IndicesSegmentResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.Admin.Indices.SEGMENTS; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/settings/ClientTransportUpdateSettingsAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/settings/ClientTransportUpdateSettingsAction.java index 0a34f4dcc08..7a0acb500a8 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/settings/ClientTransportUpdateSettingsAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/settings/ClientTransportUpdateSettingsAction.java @@ -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,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (shay.banon) + * */ public class ClientTransportUpdateSettingsAction extends BaseClientTransportAction { - @Inject public ClientTransportUpdateSettingsAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportUpdateSettingsAction(Settings settings, TransportService transportService) { super(settings, transportService, UpdateSettingsResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.Admin.Indices.UPDATE_SETTINGS; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/stats/ClientTransportIndicesStatsAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/stats/ClientTransportIndicesStatsAction.java index 62056c7462e..0e65a43e1eb 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/stats/ClientTransportIndicesStatsAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/stats/ClientTransportIndicesStatsAction.java @@ -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,11 +31,13 @@ import org.elasticsearch.transport.TransportService; */ public class ClientTransportIndicesStatsAction extends BaseClientTransportAction { - @Inject public ClientTransportIndicesStatsAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportIndicesStatsAction(Settings settings, TransportService transportService) { super(settings, transportService, IndicesStats.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.Admin.Indices.STATS; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/status/ClientTransportIndicesStatusAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/status/ClientTransportIndicesStatusAction.java index 0342ea1563a..53f213efcb8 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/status/ClientTransportIndicesStatusAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/status/ClientTransportIndicesStatusAction.java @@ -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,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (Shay Banon) + * */ public class ClientTransportIndicesStatusAction extends BaseClientTransportAction { - @Inject public ClientTransportIndicesStatusAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportIndicesStatusAction(Settings settings, TransportService transportService) { super(settings, transportService, IndicesStatusResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.Admin.Indices.STATUS; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/template/delete/ClientTransportDeleteIndexTemplateAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/template/delete/ClientTransportDeleteIndexTemplateAction.java index 343564e2d6a..fe6d7d193b3 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/template/delete/ClientTransportDeleteIndexTemplateAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/template/delete/ClientTransportDeleteIndexTemplateAction.java @@ -28,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (shay.banon) + * */ public class ClientTransportDeleteIndexTemplateAction extends BaseClientTransportAction { - @Inject public ClientTransportDeleteIndexTemplateAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportDeleteIndexTemplateAction(Settings settings, TransportService transportService) { super(settings, transportService, DeleteIndexTemplateResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.Admin.Indices.DELETE_INDEX_TEMPLATE; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/template/put/ClientTransportPutIndexTemplateAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/template/put/ClientTransportPutIndexTemplateAction.java index 287003ebcce..b8e7331cce6 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/template/put/ClientTransportPutIndexTemplateAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/template/put/ClientTransportPutIndexTemplateAction.java @@ -28,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (shay.banon) + * */ public class ClientTransportPutIndexTemplateAction extends BaseClientTransportAction { - @Inject public ClientTransportPutIndexTemplateAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportPutIndexTemplateAction(Settings settings, TransportService transportService) { super(settings, transportService, PutIndexTemplateResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.Admin.Indices.PUT_INDEX_TEMPLATE; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/bulk/ClientTransportBulkAction.java b/src/main/java/org/elasticsearch/client/transport/action/bulk/ClientTransportBulkAction.java index 0b7b40774f7..e72a0fc3a7d 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/bulk/ClientTransportBulkAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/bulk/ClientTransportBulkAction.java @@ -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,19 +29,22 @@ import org.elasticsearch.transport.TransportRequestOptions; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (shay.banon) + * */ public class ClientTransportBulkAction extends BaseClientTransportAction { - @Inject public ClientTransportBulkAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportBulkAction(Settings settings, TransportService transportService) { super(settings, transportService, BulkResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.BULK; } - @Override protected TransportRequestOptions options() { + @Override + protected TransportRequestOptions options() { return TransportRequestOptions.options().withLowType().withCompress(true); } } diff --git a/src/main/java/org/elasticsearch/client/transport/action/count/ClientTransportCountAction.java b/src/main/java/org/elasticsearch/client/transport/action/count/ClientTransportCountAction.java index 5c1f8b8dba1..06e8cf1f4a4 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/count/ClientTransportCountAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/count/ClientTransportCountAction.java @@ -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,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (Shay Banon) + * */ public class ClientTransportCountAction extends BaseClientTransportAction { - @Inject public ClientTransportCountAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportCountAction(Settings settings, TransportService transportService) { super(settings, transportService, CountResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.COUNT; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/delete/ClientTransportDeleteAction.java b/src/main/java/org/elasticsearch/client/transport/action/delete/ClientTransportDeleteAction.java index 71f9f69f5c9..064b1c3a3e9 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/delete/ClientTransportDeleteAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/delete/ClientTransportDeleteAction.java @@ -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,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (Shay Banon) + * */ public class ClientTransportDeleteAction extends BaseClientTransportAction { - @Inject public ClientTransportDeleteAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportDeleteAction(Settings settings, TransportService transportService) { super(settings, transportService, DeleteResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.DELETE; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/deletebyquery/ClientTransportDeleteByQueryAction.java b/src/main/java/org/elasticsearch/client/transport/action/deletebyquery/ClientTransportDeleteByQueryAction.java index 1ccbafacf5e..9e32bceb57c 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/deletebyquery/ClientTransportDeleteByQueryAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/deletebyquery/ClientTransportDeleteByQueryAction.java @@ -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,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (Shay Banon) + * */ public class ClientTransportDeleteByQueryAction extends BaseClientTransportAction { - @Inject public ClientTransportDeleteByQueryAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportDeleteByQueryAction(Settings settings, TransportService transportService) { super(settings, transportService, DeleteByQueryResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.DELETE_BY_QUERY; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/get/ClientTransportGetAction.java b/src/main/java/org/elasticsearch/client/transport/action/get/ClientTransportGetAction.java index 557bfd012d6..bfbcbae854c 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/get/ClientTransportGetAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/get/ClientTransportGetAction.java @@ -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,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (Shay Banon) + * */ public class ClientTransportGetAction extends BaseClientTransportAction { - @Inject public ClientTransportGetAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportGetAction(Settings settings, TransportService transportService) { super(settings, transportService, GetResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.GET; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/get/ClientTransportMultiGetAction.java b/src/main/java/org/elasticsearch/client/transport/action/get/ClientTransportMultiGetAction.java index d4f5464a9ba..b0777b677b3 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/get/ClientTransportMultiGetAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/get/ClientTransportMultiGetAction.java @@ -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,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (Shay Banon) + * */ public class ClientTransportMultiGetAction extends BaseClientTransportAction { - @Inject public ClientTransportMultiGetAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportMultiGetAction(Settings settings, TransportService transportService) { super(settings, transportService, MultiGetResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.MULTI_GET; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/index/ClientTransportIndexAction.java b/src/main/java/org/elasticsearch/client/transport/action/index/ClientTransportIndexAction.java index 2d7280e3ac5..6ac0d67ec50 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/index/ClientTransportIndexAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/index/ClientTransportIndexAction.java @@ -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,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (Shay Banon) + * */ public class ClientTransportIndexAction extends BaseClientTransportAction { - @Inject public ClientTransportIndexAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportIndexAction(Settings settings, TransportService transportService) { super(settings, transportService, IndexResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.INDEX; } } diff --git a/src/main/java/org/elasticsearch/client/transport/action/mlt/ClientTransportMoreLikeThisAction.java b/src/main/java/org/elasticsearch/client/transport/action/mlt/ClientTransportMoreLikeThisAction.java index 86e6c080100..10d13c86598 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/mlt/ClientTransportMoreLikeThisAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/mlt/ClientTransportMoreLikeThisAction.java @@ -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,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (shay.banon) + * */ public class ClientTransportMoreLikeThisAction extends BaseClientTransportAction { - @Inject public ClientTransportMoreLikeThisAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportMoreLikeThisAction(Settings settings, TransportService transportService) { super(settings, transportService, SearchResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.MORE_LIKE_THIS; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/percolate/ClientTransportPercolateAction.java b/src/main/java/org/elasticsearch/client/transport/action/percolate/ClientTransportPercolateAction.java index f80990f0881..12876f888c2 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/percolate/ClientTransportPercolateAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/percolate/ClientTransportPercolateAction.java @@ -28,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (Shay Banon) + * */ public class ClientTransportPercolateAction extends BaseClientTransportAction { - @Inject public ClientTransportPercolateAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportPercolateAction(Settings settings, TransportService transportService) { super(settings, transportService, PercolateResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.PERCOLATE; } } diff --git a/src/main/java/org/elasticsearch/client/transport/action/search/ClientTransportSearchAction.java b/src/main/java/org/elasticsearch/client/transport/action/search/ClientTransportSearchAction.java index b688b0523cf..66488f83c18 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/search/ClientTransportSearchAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/search/ClientTransportSearchAction.java @@ -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,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (Shay Banon) + * */ public class ClientTransportSearchAction extends BaseClientTransportAction { - @Inject public ClientTransportSearchAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportSearchAction(Settings settings, TransportService transportService) { super(settings, transportService, SearchResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.SEARCH; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/search/ClientTransportSearchScrollAction.java b/src/main/java/org/elasticsearch/client/transport/action/search/ClientTransportSearchScrollAction.java index a314c2c40f5..628ce9710cb 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/search/ClientTransportSearchScrollAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/search/ClientTransportSearchScrollAction.java @@ -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,15 +28,17 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (Shay Banon) + * */ public class ClientTransportSearchScrollAction extends BaseClientTransportAction { - @Inject public ClientTransportSearchScrollAction(Settings settings, TransportService transportService) { + @Inject + public ClientTransportSearchScrollAction(Settings settings, TransportService transportService) { super(settings, transportService, SearchResponse.class); } - @Override protected String action() { + @Override + protected String action() { return TransportActions.SEARCH_SCROLL; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/support/BaseClientTransportAction.java b/src/main/java/org/elasticsearch/client/transport/action/support/BaseClientTransportAction.java index e20f1146486..d81315d41e6 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/support/BaseClientTransportAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/support/BaseClientTransportAction.java @@ -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,10 +39,10 @@ import org.elasticsearch.transport.TransportService; import java.lang.reflect.Constructor; -import static org.elasticsearch.action.support.PlainActionFuture.*; +import static org.elasticsearch.action.support.PlainActionFuture.newFuture; /** - * @author kimchy (shay.banon) + * */ public abstract class BaseClientTransportAction extends AbstractComponent implements ClientTransportAction { @@ -61,31 +61,37 @@ public abstract class BaseClientTransportAction execute(DiscoveryNode node, Request request) throws ElasticSearchException { + @Override + public ActionFuture execute(DiscoveryNode node, Request request) throws ElasticSearchException { PlainActionFuture future = newFuture(); request.listenerThreaded(false); execute(node, request, future); return future; } - @Override public void execute(DiscoveryNode node, final Request request, final ActionListener listener) { + @Override + public void execute(DiscoveryNode node, final Request request, final ActionListener listener) { transportService.sendRequest(node, action(), request, options(), new BaseTransportResponseHandler() { - @Override public Response newInstance() { + @Override + public Response newInstance() { return BaseClientTransportAction.this.newInstance(); } - @Override public String executor() { + @Override + public String executor() { if (request.listenerThreaded()) { return ThreadPool.Names.CACHED; } return ThreadPool.Names.SAME; } - @Override public void handleResponse(Response response) { + @Override + public void handleResponse(Response response) { listener.onResponse(response); } - @Override public void handleException(TransportException exp) { + @Override + public void handleException(TransportException exp) { listener.onFailure(exp); } }); diff --git a/src/main/java/org/elasticsearch/client/transport/support/InternalTransportAdminClient.java b/src/main/java/org/elasticsearch/client/transport/support/InternalTransportAdminClient.java index 7dccd9ca868..3b2923c21a5 100644 --- a/src/main/java/org/elasticsearch/client/transport/support/InternalTransportAdminClient.java +++ b/src/main/java/org/elasticsearch/client/transport/support/InternalTransportAdminClient.java @@ -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.inject.Inject; import org.elasticsearch.common.settings.Settings; /** - * @author kimchy (Shay Banon) + * */ public class InternalTransportAdminClient extends AbstractComponent implements AdminClient { @@ -38,19 +38,22 @@ public class InternalTransportAdminClient extends AbstractComponent implements A private final InternalTransportClusterAdminClient clusterAdminClient; - @Inject public InternalTransportAdminClient(Settings settings, TransportClientNodesService nodesService, - InternalTransportIndicesAdminClient indicesAdminClient, InternalTransportClusterAdminClient clusterAdminClient) { + @Inject + public InternalTransportAdminClient(Settings settings, TransportClientNodesService nodesService, + InternalTransportIndicesAdminClient indicesAdminClient, InternalTransportClusterAdminClient clusterAdminClient) { super(settings); this.nodesService = nodesService; this.indicesAdminClient = indicesAdminClient; this.clusterAdminClient = clusterAdminClient; } - @Override public IndicesAdminClient indices() { + @Override + public IndicesAdminClient indices() { return indicesAdminClient; } - @Override public ClusterAdminClient cluster() { + @Override + public ClusterAdminClient cluster() { return clusterAdminClient; } } diff --git a/src/main/java/org/elasticsearch/client/transport/support/InternalTransportClient.java b/src/main/java/org/elasticsearch/client/transport/support/InternalTransportClient.java index d13d801b889..6f9370c4c61 100644 --- a/src/main/java/org/elasticsearch/client/transport/support/InternalTransportClient.java +++ b/src/main/java/org/elasticsearch/client/transport/support/InternalTransportClient.java @@ -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 @@ -63,7 +63,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; /** - * @author kimchy (Shay Banon) + * */ public class InternalTransportClient extends AbstractClient implements InternalClient { @@ -95,12 +95,13 @@ public class InternalTransportClient extends AbstractClient implements InternalC private final ClientTransportPercolateAction percolateAction; - @Inject public InternalTransportClient(Settings settings, ThreadPool threadPool, - TransportClientNodesService nodesService, InternalTransportAdminClient adminClient, - ClientTransportIndexAction indexAction, ClientTransportDeleteAction deleteAction, ClientTransportBulkAction bulkAction, ClientTransportGetAction getAction, ClientTransportMultiGetAction multiGetAction, - ClientTransportDeleteByQueryAction deleteByQueryAction, ClientTransportCountAction countAction, - ClientTransportSearchAction searchAction, ClientTransportSearchScrollAction searchScrollAction, - ClientTransportMoreLikeThisAction moreLikeThisAction, ClientTransportPercolateAction percolateAction) { + @Inject + public InternalTransportClient(Settings settings, ThreadPool threadPool, + TransportClientNodesService nodesService, InternalTransportAdminClient adminClient, + ClientTransportIndexAction indexAction, ClientTransportDeleteAction deleteAction, ClientTransportBulkAction bulkAction, ClientTransportGetAction getAction, ClientTransportMultiGetAction multiGetAction, + ClientTransportDeleteByQueryAction deleteByQueryAction, ClientTransportCountAction countAction, + ClientTransportSearchAction searchAction, ClientTransportSearchScrollAction searchScrollAction, + ClientTransportMoreLikeThisAction moreLikeThisAction, ClientTransportPercolateAction percolateAction) { this.threadPool = threadPool; this.nodesService = nodesService; this.adminClient = adminClient; @@ -118,189 +119,236 @@ public class InternalTransportClient extends AbstractClient implements InternalC this.percolateAction = percolateAction; } - @Override public void close() { + @Override + public void close() { // nothing to do here } - @Override public ThreadPool threadPool() { + @Override + public ThreadPool threadPool() { return this.threadPool; } - @Override public AdminClient admin() { + @Override + public AdminClient admin() { return adminClient; } - @Override public ActionFuture index(final IndexRequest request) { + @Override + public ActionFuture index(final IndexRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return indexAction.execute(node, request); } }); } - @Override public void index(final IndexRequest request, final ActionListener listener) { + @Override + public void index(final IndexRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { indexAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture delete(final DeleteRequest request) { + @Override + public ActionFuture delete(final DeleteRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return deleteAction.execute(node, request); } }); } - @Override public void delete(final DeleteRequest request, final ActionListener listener) { + @Override + public void delete(final DeleteRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { deleteAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture bulk(final BulkRequest request) { + @Override + public ActionFuture bulk(final BulkRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return bulkAction.execute(node, request); } }); } - @Override public void bulk(final BulkRequest request, final ActionListener listener) { + @Override + public void bulk(final BulkRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { bulkAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture deleteByQuery(final DeleteByQueryRequest request) { + @Override + public ActionFuture deleteByQuery(final DeleteByQueryRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return deleteByQueryAction.execute(node, request); } }); } - @Override public void deleteByQuery(final DeleteByQueryRequest request, final ActionListener listener) { + @Override + public void deleteByQuery(final DeleteByQueryRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { deleteByQueryAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture get(final GetRequest request) { + @Override + public ActionFuture get(final GetRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return getAction.execute(node, request); } }); } - @Override public void get(final GetRequest request, final ActionListener listener) { + @Override + public void get(final GetRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { getAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture multiGet(final MultiGetRequest request) { + @Override + public ActionFuture multiGet(final MultiGetRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return multiGetAction.execute(node, request); } }); } - @Override public void multiGet(final MultiGetRequest request, final ActionListener listener) { + @Override + public void multiGet(final MultiGetRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { multiGetAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture count(final CountRequest request) { + @Override + public ActionFuture count(final CountRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return countAction.execute(node, request); } }); } - @Override public void count(final CountRequest request, final ActionListener listener) { + @Override + public void count(final CountRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { countAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture search(final SearchRequest request) { + @Override + public ActionFuture search(final SearchRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return searchAction.execute(node, request); } }); } - @Override public void search(final SearchRequest request, final ActionListener listener) { + @Override + public void search(final SearchRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { searchAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture searchScroll(final SearchScrollRequest request) { + @Override + public ActionFuture searchScroll(final SearchScrollRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return searchScrollAction.execute(node, request); } }); } - @Override public void searchScroll(final SearchScrollRequest request, final ActionListener listener) { + @Override + public void searchScroll(final SearchScrollRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { searchScrollAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture moreLikeThis(final MoreLikeThisRequest request) { + @Override + public ActionFuture moreLikeThis(final MoreLikeThisRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return moreLikeThisAction.execute(node, request); } }); } - @Override public void moreLikeThis(final MoreLikeThisRequest request, final ActionListener listener) { + @Override + public void moreLikeThis(final MoreLikeThisRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { moreLikeThisAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture percolate(final PercolateRequest request) { + @Override + public ActionFuture percolate(final PercolateRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return percolateAction.execute(node, request); } }); } - @Override public void percolate(final PercolateRequest request, final ActionListener listener) { + @Override + public void percolate(final PercolateRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { percolateAction.execute(node, request, listener); } }, listener); diff --git a/src/main/java/org/elasticsearch/client/transport/support/InternalTransportClusterAdminClient.java b/src/main/java/org/elasticsearch/client/transport/support/InternalTransportClusterAdminClient.java index cbd581ad21c..6b242ff99a0 100644 --- a/src/main/java/org/elasticsearch/client/transport/support/InternalTransportClusterAdminClient.java +++ b/src/main/java/org/elasticsearch/client/transport/support/InternalTransportClusterAdminClient.java @@ -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 @@ -64,7 +64,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; /** - * @author kimchy (Shay Banon) + * */ public class InternalTransportClusterAdminClient extends AbstractClusterAdminClient implements InternalClusterAdminClient { @@ -94,10 +94,11 @@ public class InternalTransportClusterAdminClient extends AbstractClusterAdminCli private final ClientTransportNodesRestartAction nodesRestartAction; - @Inject public InternalTransportClusterAdminClient(Settings settings, TransportClientNodesService nodesService, ThreadPool threadPool, - ClientTransportClusterHealthAction clusterHealthAction, ClientTransportClusterStateAction clusterStateAction, ClientTransportClusterRerouteAction clusterRerouteAction, ClientTransportClusterUpdateSettingsAction clusterUpdateSettingsAction, - ClientTransportSinglePingAction singlePingAction, ClientTransportReplicationPingAction replicationPingAction, ClientTransportBroadcastPingAction broadcastPingAction, - ClientTransportNodesInfoAction nodesInfoAction, ClientTransportNodesShutdownAction nodesShutdownAction, ClientTransportNodesRestartAction nodesRestartAction, ClientTransportNodesStatsAction nodesStatsAction) { + @Inject + public InternalTransportClusterAdminClient(Settings settings, TransportClientNodesService nodesService, ThreadPool threadPool, + ClientTransportClusterHealthAction clusterHealthAction, ClientTransportClusterStateAction clusterStateAction, ClientTransportClusterRerouteAction clusterRerouteAction, ClientTransportClusterUpdateSettingsAction clusterUpdateSettingsAction, + ClientTransportSinglePingAction singlePingAction, ClientTransportReplicationPingAction replicationPingAction, ClientTransportBroadcastPingAction broadcastPingAction, + ClientTransportNodesInfoAction nodesInfoAction, ClientTransportNodesShutdownAction nodesShutdownAction, ClientTransportNodesRestartAction nodesRestartAction, ClientTransportNodesStatsAction nodesStatsAction) { this.nodesService = nodesService; this.threadPool = threadPool; this.clusterHealthAction = clusterHealthAction; @@ -113,181 +114,226 @@ public class InternalTransportClusterAdminClient extends AbstractClusterAdminCli this.nodesStatsAction = nodesStatsAction; } - @Override public ThreadPool threadPool() { + @Override + public ThreadPool threadPool() { return this.threadPool; } - @Override public ActionFuture health(final ClusterHealthRequest request) { + @Override + public ActionFuture health(final ClusterHealthRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return clusterHealthAction.execute(node, request); } }); } - @Override public void health(final ClusterHealthRequest request, final ActionListener listener) { + @Override + public void health(final ClusterHealthRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { clusterHealthAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture state(final ClusterStateRequest request) { + @Override + public ActionFuture state(final ClusterStateRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return clusterStateAction.execute(node, request); } }); } - @Override public void state(final ClusterStateRequest request, final ActionListener listener) { + @Override + public void state(final ClusterStateRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { clusterStateAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture reroute(final ClusterRerouteRequest request) { + @Override + public ActionFuture reroute(final ClusterRerouteRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return clusterRerouteAction.execute(node, request); } }); } - @Override public void reroute(final ClusterRerouteRequest request, final ActionListener listener) { + @Override + public void reroute(final ClusterRerouteRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { clusterRerouteAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture updateSettings(final ClusterUpdateSettingsRequest request) { + @Override + public ActionFuture updateSettings(final ClusterUpdateSettingsRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return clusterUpdateSettingsAction.execute(node, request); } }); } - @Override public void updateSettings(final ClusterUpdateSettingsRequest request, final ActionListener listener) { + @Override + public void updateSettings(final ClusterUpdateSettingsRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { clusterUpdateSettingsAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture ping(final SinglePingRequest request) { + @Override + public ActionFuture ping(final SinglePingRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return singlePingAction.execute(node, request); } }); } - @Override public void ping(final SinglePingRequest request, final ActionListener listener) { + @Override + public void ping(final SinglePingRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { singlePingAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture ping(final BroadcastPingRequest request) { + @Override + public ActionFuture ping(final BroadcastPingRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return broadcastPingAction.execute(node, request); } }); } - @Override public void ping(final BroadcastPingRequest request, final ActionListener listener) { + @Override + public void ping(final BroadcastPingRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { broadcastPingAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture ping(final ReplicationPingRequest request) { + @Override + public ActionFuture ping(final ReplicationPingRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return replicationPingAction.execute(node, request); } }); } - @Override public void ping(final ReplicationPingRequest request, final ActionListener listener) { + @Override + public void ping(final ReplicationPingRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { replicationPingAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture nodesInfo(final NodesInfoRequest request) { + @Override + public ActionFuture nodesInfo(final NodesInfoRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return nodesInfoAction.execute(node, request); } }); } - @Override public void nodesInfo(final NodesInfoRequest request, final ActionListener listener) { + @Override + public void nodesInfo(final NodesInfoRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { nodesInfoAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture nodesStats(final NodesStatsRequest request) { + @Override + public ActionFuture nodesStats(final NodesStatsRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return nodesStatsAction.execute(node, request); } }); } - @Override public void nodesStats(final NodesStatsRequest request, final ActionListener listener) { + @Override + public void nodesStats(final NodesStatsRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { nodesStatsAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture nodesShutdown(final NodesShutdownRequest request) { + @Override + public ActionFuture nodesShutdown(final NodesShutdownRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return nodesShutdownAction.execute(node, request); } }); } - @Override public void nodesShutdown(final NodesShutdownRequest request, final ActionListener listener) { + @Override + public void nodesShutdown(final NodesShutdownRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { nodesShutdownAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture nodesRestart(final NodesRestartRequest request) { + @Override + public ActionFuture nodesRestart(final NodesRestartRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return nodesRestartAction.execute(node, request); } }); } - @Override public void nodesRestart(final NodesRestartRequest request, final ActionListener listener) { + @Override + public void nodesRestart(final NodesRestartRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { nodesRestartAction.execute(node, request, listener); } }, listener); diff --git a/src/main/java/org/elasticsearch/client/transport/support/InternalTransportIndicesAdminClient.java b/src/main/java/org/elasticsearch/client/transport/support/InternalTransportIndicesAdminClient.java index a4bf910b1ff..8daf3ea5aa6 100644 --- a/src/main/java/org/elasticsearch/client/transport/support/InternalTransportIndicesAdminClient.java +++ b/src/main/java/org/elasticsearch/client/transport/support/InternalTransportIndicesAdminClient.java @@ -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 @@ -91,7 +91,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; /** - * @author kimchy (shay.banon) + * */ public class InternalTransportIndicesAdminClient extends AbstractIndicesAdminClient implements IndicesAdminClient { @@ -139,15 +139,16 @@ public class InternalTransportIndicesAdminClient extends AbstractIndicesAdminCli private final ClientTransportDeleteIndexTemplateAction deleteIndexTemplateAction; - @Inject public InternalTransportIndicesAdminClient(Settings settings, TransportClientNodesService nodesService, ThreadPool threadPool, - ClientTransportIndicesExistsAction indicesExistsAction, ClientTransportIndicesStatusAction indicesStatusAction, ClientTransportIndicesStatsAction indicesStatsAction, ClientTransportIndicesSegmentsAction indicesSegmentsAction, - ClientTransportCreateIndexAction createIndexAction, ClientTransportDeleteIndexAction deleteIndexAction, - ClientTransportCloseIndexAction closeIndexAction, ClientTransportOpenIndexAction openIndexAction, - ClientTransportRefreshAction refreshAction, ClientTransportFlushAction flushAction, ClientTransportOptimizeAction optimizeAction, - ClientTransportPutMappingAction putMappingAction, ClientTransportDeleteMappingAction deleteMappingAction, ClientTransportGatewaySnapshotAction gatewaySnapshotAction, - ClientTransportIndicesAliasesAction indicesAliasesAction, ClientTransportClearIndicesCacheAction clearIndicesCacheAction, - ClientTransportUpdateSettingsAction updateSettingsAction, ClientTransportAnalyzeAction analyzeAction, - ClientTransportPutIndexTemplateAction putIndexTemplateAction, ClientTransportDeleteIndexTemplateAction deleteIndexTemplateAction) { + @Inject + public InternalTransportIndicesAdminClient(Settings settings, TransportClientNodesService nodesService, ThreadPool threadPool, + ClientTransportIndicesExistsAction indicesExistsAction, ClientTransportIndicesStatusAction indicesStatusAction, ClientTransportIndicesStatsAction indicesStatsAction, ClientTransportIndicesSegmentsAction indicesSegmentsAction, + ClientTransportCreateIndexAction createIndexAction, ClientTransportDeleteIndexAction deleteIndexAction, + ClientTransportCloseIndexAction closeIndexAction, ClientTransportOpenIndexAction openIndexAction, + ClientTransportRefreshAction refreshAction, ClientTransportFlushAction flushAction, ClientTransportOptimizeAction optimizeAction, + ClientTransportPutMappingAction putMappingAction, ClientTransportDeleteMappingAction deleteMappingAction, ClientTransportGatewaySnapshotAction gatewaySnapshotAction, + ClientTransportIndicesAliasesAction indicesAliasesAction, ClientTransportClearIndicesCacheAction clearIndicesCacheAction, + ClientTransportUpdateSettingsAction updateSettingsAction, ClientTransportAnalyzeAction analyzeAction, + ClientTransportPutIndexTemplateAction putIndexTemplateAction, ClientTransportDeleteIndexTemplateAction deleteIndexTemplateAction) { this.nodesService = nodesService; this.threadPool = threadPool; this.indicesExistsAction = indicesExistsAction; @@ -172,325 +173,406 @@ public class InternalTransportIndicesAdminClient extends AbstractIndicesAdminCli this.deleteIndexTemplateAction = deleteIndexTemplateAction; } - @Override public ThreadPool threadPool() { + @Override + public ThreadPool threadPool() { return this.threadPool; } - @Override public ActionFuture exists(final IndicesExistsRequest request) { + @Override + public ActionFuture exists(final IndicesExistsRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return indicesExistsAction.execute(node, request); } }); } - @Override public void exists(final IndicesExistsRequest request, final ActionListener listener) { + @Override + public void exists(final IndicesExistsRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { indicesExistsAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture stats(final IndicesStatsRequest request) { + @Override + public ActionFuture stats(final IndicesStatsRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return indicesStatsAction.execute(node, request); } }); } - @Override public void stats(final IndicesStatsRequest request, final ActionListener listener) { + @Override + public void stats(final IndicesStatsRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { indicesStatsAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture status(final IndicesStatusRequest request) { + @Override + public ActionFuture status(final IndicesStatusRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return indicesStatusAction.execute(node, request); } }); } - @Override public void status(final IndicesStatusRequest request, final ActionListener listener) { + @Override + public void status(final IndicesStatusRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { indicesStatusAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture segments(final IndicesSegmentsRequest request) { + @Override + public ActionFuture segments(final IndicesSegmentsRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return indicesSegmentsAction.execute(node, request); } }); } - @Override public void segments(final IndicesSegmentsRequest request, final ActionListener listener) { + @Override + public void segments(final IndicesSegmentsRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { indicesSegmentsAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture create(final CreateIndexRequest request) { + @Override + public ActionFuture create(final CreateIndexRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return createIndexAction.execute(node, request); } }); } - @Override public void create(final CreateIndexRequest request, final ActionListener listener) { + @Override + public void create(final CreateIndexRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { createIndexAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture delete(final DeleteIndexRequest request) { + @Override + public ActionFuture delete(final DeleteIndexRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return deleteIndexAction.execute(node, request); } }); } - @Override public void delete(final DeleteIndexRequest request, final ActionListener listener) { + @Override + public void delete(final DeleteIndexRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { deleteIndexAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture close(final CloseIndexRequest request) { + @Override + public ActionFuture close(final CloseIndexRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return closeIndexAction.execute(node, request); } }); } - @Override public void close(final CloseIndexRequest request, final ActionListener listener) { + @Override + public void close(final CloseIndexRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { closeIndexAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture open(final OpenIndexRequest request) { + @Override + public ActionFuture open(final OpenIndexRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return openIndexAction.execute(node, request); } }); } - @Override public void open(final OpenIndexRequest request, final ActionListener listener) { + @Override + public void open(final OpenIndexRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { openIndexAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture refresh(final RefreshRequest request) { + @Override + public ActionFuture refresh(final RefreshRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return refreshAction.execute(node, request); } }); } - @Override public void refresh(final RefreshRequest request, final ActionListener listener) { + @Override + public void refresh(final RefreshRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { refreshAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture flush(final FlushRequest request) { + @Override + public ActionFuture flush(final FlushRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return flushAction.execute(node, request); } }); } - @Override public void flush(final FlushRequest request, final ActionListener listener) { + @Override + public void flush(final FlushRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { flushAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture optimize(final OptimizeRequest request) { + @Override + public ActionFuture optimize(final OptimizeRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return optimizeAction.execute(node, request); } }); } - @Override public void optimize(final OptimizeRequest request, final ActionListener listener) { + @Override + public void optimize(final OptimizeRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { optimizeAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture putMapping(final PutMappingRequest request) { + @Override + public ActionFuture putMapping(final PutMappingRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return putMappingAction.execute(node, request); } }); } - @Override public void putMapping(final PutMappingRequest request, final ActionListener listener) { + @Override + public void putMapping(final PutMappingRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { putMappingAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture deleteMapping(final DeleteMappingRequest request) { + @Override + public ActionFuture deleteMapping(final DeleteMappingRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return deleteMappingAction.execute(node, request); } }); } - @Override public void deleteMapping(final DeleteMappingRequest request, final ActionListener listener) { + @Override + public void deleteMapping(final DeleteMappingRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { deleteMappingAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture gatewaySnapshot(final GatewaySnapshotRequest request) { + @Override + public ActionFuture gatewaySnapshot(final GatewaySnapshotRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return gatewaySnapshotAction.execute(node, request); } }); } - @Override public void gatewaySnapshot(final GatewaySnapshotRequest request, final ActionListener listener) { + @Override + public void gatewaySnapshot(final GatewaySnapshotRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { gatewaySnapshotAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture aliases(final IndicesAliasesRequest request) { + @Override + public ActionFuture aliases(final IndicesAliasesRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return indicesAliasesAction.execute(node, request); } }); } - @Override public void aliases(final IndicesAliasesRequest request, final ActionListener listener) { + @Override + public void aliases(final IndicesAliasesRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { indicesAliasesAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture clearCache(final ClearIndicesCacheRequest request) { + @Override + public ActionFuture clearCache(final ClearIndicesCacheRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return clearIndicesCacheAction.execute(node, request); } }); } - @Override public void clearCache(final ClearIndicesCacheRequest request, final ActionListener listener) { + @Override + public void clearCache(final ClearIndicesCacheRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { clearIndicesCacheAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture updateSettings(final UpdateSettingsRequest request) { + @Override + public ActionFuture updateSettings(final UpdateSettingsRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return updateSettingsAction.execute(node, request); } }); } - @Override public void updateSettings(final UpdateSettingsRequest request, final ActionListener listener) { + @Override + public void updateSettings(final UpdateSettingsRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { updateSettingsAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture analyze(final AnalyzeRequest request) { + @Override + public ActionFuture analyze(final AnalyzeRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return analyzeAction.execute(node, request); } }); } - @Override public void analyze(final AnalyzeRequest request, final ActionListener listener) { + @Override + public void analyze(final AnalyzeRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { analyzeAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture putTemplate(final PutIndexTemplateRequest request) { + @Override + public ActionFuture putTemplate(final PutIndexTemplateRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return putIndexTemplateAction.execute(node, request); } }); } - @Override public void putTemplate(final PutIndexTemplateRequest request, final ActionListener listener) { + @Override + public void putTemplate(final PutIndexTemplateRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { putIndexTemplateAction.execute(node, request, listener); } }, listener); } - @Override public ActionFuture deleteTemplate(final DeleteIndexTemplateRequest request) { + @Override + public ActionFuture deleteTemplate(final DeleteIndexTemplateRequest request) { return nodesService.execute(new TransportClientNodesService.NodeCallback>() { - @Override public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { + @Override + public ActionFuture doWithNode(DiscoveryNode node) throws ElasticSearchException { return deleteIndexTemplateAction.execute(node, request); } }); } - @Override public void deleteTemplate(final DeleteIndexTemplateRequest request, final ActionListener listener) { + @Override + public void deleteTemplate(final DeleteIndexTemplateRequest request, final ActionListener listener) { nodesService.execute(new TransportClientNodesService.NodeListenerCallback() { - @Override public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { + @Override + public void doWithNode(DiscoveryNode node, ActionListener listener) throws ElasticSearchException { deleteIndexTemplateAction.execute(node, request, listener); } }, listener); diff --git a/src/main/java/org/elasticsearch/cluster/ClusterChangedEvent.java b/src/main/java/org/elasticsearch/cluster/ClusterChangedEvent.java index 2062436ef2c..6fb0c84d6f6 100644 --- a/src/main/java/org/elasticsearch/cluster/ClusterChangedEvent.java +++ b/src/main/java/org/elasticsearch/cluster/ClusterChangedEvent.java @@ -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,14 +19,14 @@ package org.elasticsearch.cluster; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; import org.elasticsearch.cluster.node.DiscoveryNodes; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.Lists; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class ClusterChangedEvent { diff --git a/src/main/java/org/elasticsearch/cluster/ClusterModule.java b/src/main/java/org/elasticsearch/cluster/ClusterModule.java index 30c924f0b86..ac20ca2c33f 100644 --- a/src/main/java/org/elasticsearch/cluster/ClusterModule.java +++ b/src/main/java/org/elasticsearch/cluster/ClusterModule.java @@ -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,34 +19,22 @@ package org.elasticsearch.cluster; -import org.elasticsearch.cluster.action.index.MappingUpdatedAction; -import org.elasticsearch.cluster.action.index.NodeAliasesUpdatedAction; -import org.elasticsearch.cluster.action.index.NodeIndexCreatedAction; -import org.elasticsearch.cluster.action.index.NodeIndexDeletedAction; -import org.elasticsearch.cluster.action.index.NodeMappingCreatedAction; -import org.elasticsearch.cluster.action.index.NodeMappingRefreshAction; +import com.google.common.collect.ImmutableList; +import org.elasticsearch.cluster.action.index.*; import org.elasticsearch.cluster.action.shard.ShardStateAction; -import org.elasticsearch.cluster.metadata.MetaDataCreateIndexService; -import org.elasticsearch.cluster.metadata.MetaDataDeleteIndexService; -import org.elasticsearch.cluster.metadata.MetaDataIndexAliasesService; -import org.elasticsearch.cluster.metadata.MetaDataIndexTemplateService; -import org.elasticsearch.cluster.metadata.MetaDataMappingService; -import org.elasticsearch.cluster.metadata.MetaDataService; -import org.elasticsearch.cluster.metadata.MetaDataStateIndexService; -import org.elasticsearch.cluster.metadata.MetaDataUpdateSettingsService; +import org.elasticsearch.cluster.metadata.*; import org.elasticsearch.cluster.node.DiscoveryNodeService; import org.elasticsearch.cluster.routing.RoutingService; import org.elasticsearch.cluster.routing.allocation.AllocationModule; import org.elasticsearch.cluster.routing.operation.OperationRoutingModule; import org.elasticsearch.cluster.service.InternalClusterService; -import org.elasticsearch.common.collect.ImmutableList; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.inject.SpawnModules; import org.elasticsearch.common.settings.Settings; /** - * @author kimchy (shay.banon) + * */ public class ClusterModule extends AbstractModule implements SpawnModules { @@ -56,7 +44,8 @@ public class ClusterModule extends AbstractModule implements SpawnModules { this.settings = settings; } - @Override public Iterable spawnModules() { + @Override + public Iterable spawnModules() { return ImmutableList.of(new AllocationModule(settings), new OperationRoutingModule(settings)); } diff --git a/src/main/java/org/elasticsearch/cluster/ClusterName.java b/src/main/java/org/elasticsearch/cluster/ClusterName.java index 1cdd45a4c98..75074273167 100644 --- a/src/main/java/org/elasticsearch/cluster/ClusterName.java +++ b/src/main/java/org/elasticsearch/cluster/ClusterName.java @@ -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.settings.Settings; import java.io.IOException; /** - * @author kimchy (Shay Banon) + * */ public class ClusterName implements Streamable { @@ -59,15 +59,18 @@ public class ClusterName implements Streamable { return clusterName; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { value = in.readUTF().intern(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(value); } - @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; @@ -78,11 +81,13 @@ public class ClusterName implements Streamable { return true; } - @Override public int hashCode() { + @Override + public int hashCode() { return value != null ? value.hashCode() : 0; } - @Override public String toString() { + @Override + public String toString() { return "Cluster [" + value + "]"; } } diff --git a/src/main/java/org/elasticsearch/cluster/ClusterNameModule.java b/src/main/java/org/elasticsearch/cluster/ClusterNameModule.java index e8cc6956263..d42e77956bb 100644 --- a/src/main/java/org/elasticsearch/cluster/ClusterNameModule.java +++ b/src/main/java/org/elasticsearch/cluster/ClusterNameModule.java @@ -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.inject.AbstractModule; import org.elasticsearch.common.settings.Settings; /** - * @author kimchy (Shay Banon) + * */ public class ClusterNameModule extends AbstractModule { @@ -33,7 +33,8 @@ public class ClusterNameModule extends AbstractModule { this.settings = settings; } - @Override protected void configure() { + @Override + protected void configure() { bind(ClusterName.class).toInstance(ClusterName.clusterNameFromSettings(settings)); } } diff --git a/src/main/java/org/elasticsearch/cluster/ClusterService.java b/src/main/java/org/elasticsearch/cluster/ClusterService.java index ea15ff2112e..da47f108662 100644 --- a/src/main/java/org/elasticsearch/cluster/ClusterService.java +++ b/src/main/java/org/elasticsearch/cluster/ClusterService.java @@ -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 org.elasticsearch.common.unit.TimeValue; * The cluster service allowing to both register for cluster state events ({@link ClusterStateListener}) * and submit state update tasks ({@link ClusterStateUpdateTask}. * - * @author kimchy (shay.banon) + * */ public interface ClusterService extends LifecycleComponent { diff --git a/src/main/java/org/elasticsearch/cluster/ClusterState.java b/src/main/java/org/elasticsearch/cluster/ClusterState.java index ed5ee031159..fb17bc55fff 100644 --- a/src/main/java/org/elasticsearch/cluster/ClusterState.java +++ b/src/main/java/org/elasticsearch/cluster/ClusterState.java @@ -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,16 +28,12 @@ import org.elasticsearch.cluster.routing.RoutingTable; import org.elasticsearch.cluster.routing.allocation.AllocationExplanation; import org.elasticsearch.cluster.routing.allocation.RoutingAllocation; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.io.stream.BytesStreamInput; -import org.elasticsearch.common.io.stream.BytesStreamOutput; -import org.elasticsearch.common.io.stream.CachedStreamOutput; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.io.stream.*; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class ClusterState { diff --git a/src/main/java/org/elasticsearch/cluster/ClusterStateListener.java b/src/main/java/org/elasticsearch/cluster/ClusterStateListener.java index 873bd87482d..4d632ef2bf1 100644 --- a/src/main/java/org/elasticsearch/cluster/ClusterStateListener.java +++ b/src/main/java/org/elasticsearch/cluster/ClusterStateListener.java @@ -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.cluster; /** * A listener to be notified when a cluster state changes. * - * @author kimchy (shay.banon) + * */ public interface ClusterStateListener { diff --git a/src/main/java/org/elasticsearch/cluster/ClusterStateUpdateTask.java b/src/main/java/org/elasticsearch/cluster/ClusterStateUpdateTask.java index 3a50220fb87..b503c02c57b 100644 --- a/src/main/java/org/elasticsearch/cluster/ClusterStateUpdateTask.java +++ b/src/main/java/org/elasticsearch/cluster/ClusterStateUpdateTask.java @@ -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.cluster; /** * A task that can update the cluster state. * - * @author kimchy (shay.banon) + * */ public interface ClusterStateUpdateTask { diff --git a/src/main/java/org/elasticsearch/cluster/ProcessedClusterStateUpdateTask.java b/src/main/java/org/elasticsearch/cluster/ProcessedClusterStateUpdateTask.java index 761ebdc457e..898cfe50ec9 100644 --- a/src/main/java/org/elasticsearch/cluster/ProcessedClusterStateUpdateTask.java +++ b/src/main/java/org/elasticsearch/cluster/ProcessedClusterStateUpdateTask.java @@ -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 @@ package org.elasticsearch.cluster; * An extension interface to {@link ClusterStateUpdateTask} that allows to be notified when * the cluster state update has been processed. * - * @author kimchy (Shay Banon) + * */ public interface ProcessedClusterStateUpdateTask extends ClusterStateUpdateTask { diff --git a/src/main/java/org/elasticsearch/cluster/TimeoutClusterStateListener.java b/src/main/java/org/elasticsearch/cluster/TimeoutClusterStateListener.java index 7e4e8291ba2..81480ed5a12 100644 --- a/src/main/java/org/elasticsearch/cluster/TimeoutClusterStateListener.java +++ b/src/main/java/org/elasticsearch/cluster/TimeoutClusterStateListener.java @@ -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.common.unit.TimeValue; /** * An exception to cluster state listener that allows for timeouts and for post added notifications. * - * @author kimchy (shay.banon) + * */ public interface TimeoutClusterStateListener extends ClusterStateListener { diff --git a/src/main/java/org/elasticsearch/cluster/action/index/MappingUpdatedAction.java b/src/main/java/org/elasticsearch/cluster/action/index/MappingUpdatedAction.java index 90b244dd7c3..82060fcf04a 100644 --- a/src/main/java/org/elasticsearch/cluster/action/index/MappingUpdatedAction.java +++ b/src/main/java/org/elasticsearch/cluster/action/index/MappingUpdatedAction.java @@ -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 @@ -43,44 +43,52 @@ import java.util.concurrent.atomic.AtomicReference; * Called by shards in the cluster when their mapping was dynamically updated and it needs to be updated * in the cluster state meta data (and broadcast to all members). * - * @author kimchy (shay.banon) + * */ public class MappingUpdatedAction extends TransportMasterNodeOperationAction { private final MetaDataMappingService metaDataMappingService; - @Inject public MappingUpdatedAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, - MetaDataMappingService metaDataMappingService) { + @Inject + public MappingUpdatedAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, + MetaDataMappingService metaDataMappingService) { super(settings, transportService, clusterService, threadPool); this.metaDataMappingService = metaDataMappingService; } - @Override protected String transportAction() { + @Override + protected String transportAction() { return "cluster/mappingUpdated"; } - @Override protected String executor() { + @Override + protected String executor() { return ThreadPool.Names.CACHED; } - @Override protected MappingUpdatedRequest newRequest() { + @Override + protected MappingUpdatedRequest newRequest() { return new MappingUpdatedRequest(); } - @Override protected MappingUpdatedResponse newResponse() { + @Override + protected MappingUpdatedResponse newResponse() { return new MappingUpdatedResponse(); } - @Override protected MappingUpdatedResponse masterOperation(MappingUpdatedRequest request, ClusterState state) throws ElasticSearchException { + @Override + protected MappingUpdatedResponse masterOperation(MappingUpdatedRequest request, ClusterState state) throws ElasticSearchException { final CountDownLatch latch = new CountDownLatch(1); final AtomicReference failure = new AtomicReference(); try { metaDataMappingService.updateMapping(request.index(), request.type(), request.mappingSource(), new MetaDataMappingService.Listener() { - @Override public void onResponse(MetaDataMappingService.Response response) { + @Override + public void onResponse(MetaDataMappingService.Response response) { latch.countDown(); } - @Override public void onFailure(Throwable t) { + @Override + public void onFailure(Throwable t) { failure.set(t); latch.countDown(); } @@ -99,10 +107,12 @@ public class MappingUpdatedAction extends TransportMasterNodeOperationAction listeners = new CopyOnWriteArrayList(); - @Inject public NodeAliasesUpdatedAction(Settings settings, ThreadPool threadPool, TransportService transportService, ClusterService clusterService) { + @Inject + public NodeAliasesUpdatedAction(Settings settings, ThreadPool threadPool, TransportService transportService, ClusterService clusterService) { super(settings); this.threadPool = threadPool; this.transportService = transportService; @@ -64,7 +65,8 @@ public class NodeAliasesUpdatedAction extends AbstractComponent { public void add(final Listener listener, TimeValue timeout) { listeners.add(listener); threadPool.schedule(timeout, ThreadPool.Names.CACHED, new Runnable() { - @Override public void run() { + @Override + public void run() { boolean removed = listeners.remove(listener); if (removed) { listener.onTimeout(); @@ -81,7 +83,8 @@ public class NodeAliasesUpdatedAction extends AbstractComponent { DiscoveryNodes nodes = clusterService.state().nodes(); if (nodes.localNodeMaster()) { threadPool.cached().execute(new Runnable() { - @Override public void run() { + @Override + public void run() { innerNodeAliasesUpdated(response); } }); @@ -108,16 +111,19 @@ public class NodeAliasesUpdatedAction extends AbstractComponent { static final String ACTION = "cluster/nodeAliasesUpdated"; - @Override public NodeAliasesUpdatedResponse newInstance() { + @Override + public NodeAliasesUpdatedResponse newInstance() { return new NodeAliasesUpdatedResponse(); } - @Override public void messageReceived(NodeAliasesUpdatedResponse response, TransportChannel channel) throws Exception { + @Override + public void messageReceived(NodeAliasesUpdatedResponse response, TransportChannel channel) throws Exception { innerNodeAliasesUpdated(response); channel.sendResponse(VoidStreamable.INSTANCE); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } } @@ -144,12 +150,14 @@ public class NodeAliasesUpdatedAction extends AbstractComponent { return version; } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(nodeId); out.writeLong(version); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { nodeId = in.readUTF(); version = in.readLong(); } diff --git a/src/main/java/org/elasticsearch/cluster/action/index/NodeIndexCreatedAction.java b/src/main/java/org/elasticsearch/cluster/action/index/NodeIndexCreatedAction.java index 378203abb66..d1690f99d2b 100644 --- a/src/main/java/org/elasticsearch/cluster/action/index/NodeIndexCreatedAction.java +++ b/src/main/java/org/elasticsearch/cluster/action/index/NodeIndexCreatedAction.java @@ -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 @@ -40,7 +40,7 @@ import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; /** - * @author kimchy (Shay Banon) + * */ public class NodeIndexCreatedAction extends AbstractComponent { @@ -52,7 +52,8 @@ public class NodeIndexCreatedAction extends AbstractComponent { private final List listeners = new CopyOnWriteArrayList(); - @Inject public NodeIndexCreatedAction(Settings settings, ThreadPool threadPool, TransportService transportService, ClusterService clusterService) { + @Inject + public NodeIndexCreatedAction(Settings settings, ThreadPool threadPool, TransportService transportService, ClusterService clusterService) { super(settings); this.threadPool = threadPool; this.transportService = transportService; @@ -72,7 +73,8 @@ public class NodeIndexCreatedAction extends AbstractComponent { DiscoveryNodes nodes = clusterService.state().nodes(); if (nodes.localNodeMaster()) { threadPool.cached().execute(new Runnable() { - @Override public void run() { + @Override + public void run() { innerNodeIndexCreated(index, nodeId); } }); @@ -96,16 +98,19 @@ public class NodeIndexCreatedAction extends AbstractComponent { static final String ACTION = "cluster/nodeIndexCreated"; - @Override public NodeIndexCreatedMessage newInstance() { + @Override + public NodeIndexCreatedMessage newInstance() { return new NodeIndexCreatedMessage(); } - @Override public void messageReceived(NodeIndexCreatedMessage message, TransportChannel channel) throws Exception { + @Override + public void messageReceived(NodeIndexCreatedMessage message, TransportChannel channel) throws Exception { innerNodeIndexCreated(message.index, message.nodeId); channel.sendResponse(VoidStreamable.INSTANCE); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } } @@ -124,12 +129,14 @@ public class NodeIndexCreatedAction extends AbstractComponent { this.nodeId = nodeId; } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(index); out.writeUTF(nodeId); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { index = in.readUTF(); nodeId = in.readUTF(); } diff --git a/src/main/java/org/elasticsearch/cluster/action/index/NodeIndexDeletedAction.java b/src/main/java/org/elasticsearch/cluster/action/index/NodeIndexDeletedAction.java index e782a70784e..7595ee9aea6 100644 --- a/src/main/java/org/elasticsearch/cluster/action/index/NodeIndexDeletedAction.java +++ b/src/main/java/org/elasticsearch/cluster/action/index/NodeIndexDeletedAction.java @@ -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 @@ -40,7 +40,7 @@ import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; /** - * @author kimchy (Shay Banon) + * */ public class NodeIndexDeletedAction extends AbstractComponent { @@ -52,7 +52,8 @@ public class NodeIndexDeletedAction extends AbstractComponent { private final List listeners = new CopyOnWriteArrayList(); - @Inject public NodeIndexDeletedAction(Settings settings, ThreadPool threadPool, TransportService transportService, ClusterService clusterService) { + @Inject + public NodeIndexDeletedAction(Settings settings, ThreadPool threadPool, TransportService transportService, ClusterService clusterService) { super(settings); this.threadPool = threadPool; this.transportService = transportService; @@ -72,7 +73,8 @@ public class NodeIndexDeletedAction extends AbstractComponent { DiscoveryNodes nodes = clusterService.state().nodes(); if (nodes.localNodeMaster()) { threadPool.cached().execute(new Runnable() { - @Override public void run() { + @Override + public void run() { innerNodeIndexDeleted(index, nodeId); } }); @@ -96,16 +98,19 @@ public class NodeIndexDeletedAction extends AbstractComponent { static final String ACTION = "cluster/nodeIndexDeleted"; - @Override public NodeIndexDeletedMessage newInstance() { + @Override + public NodeIndexDeletedMessage newInstance() { return new NodeIndexDeletedMessage(); } - @Override public void messageReceived(NodeIndexDeletedMessage message, TransportChannel channel) throws Exception { + @Override + public void messageReceived(NodeIndexDeletedMessage message, TransportChannel channel) throws Exception { innerNodeIndexDeleted(message.index, message.nodeId); channel.sendResponse(VoidStreamable.INSTANCE); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } } @@ -124,12 +129,14 @@ public class NodeIndexDeletedAction extends AbstractComponent { this.nodeId = nodeId; } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(index); out.writeUTF(nodeId); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { index = in.readUTF(); nodeId = in.readUTF(); } diff --git a/src/main/java/org/elasticsearch/cluster/action/index/NodeMappingCreatedAction.java b/src/main/java/org/elasticsearch/cluster/action/index/NodeMappingCreatedAction.java index 8c601b3e096..f1f57ada64b 100644 --- a/src/main/java/org/elasticsearch/cluster/action/index/NodeMappingCreatedAction.java +++ b/src/main/java/org/elasticsearch/cluster/action/index/NodeMappingCreatedAction.java @@ -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,7 +41,7 @@ import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; /** - * @author kimchy (Shay Banon) + * */ public class NodeMappingCreatedAction extends AbstractComponent { @@ -53,7 +53,8 @@ public class NodeMappingCreatedAction extends AbstractComponent { private final List listeners = new CopyOnWriteArrayList(); - @Inject public NodeMappingCreatedAction(Settings settings, ThreadPool threadPool, TransportService transportService, ClusterService clusterService) { + @Inject + public NodeMappingCreatedAction(Settings settings, ThreadPool threadPool, TransportService transportService, ClusterService clusterService) { super(settings); this.threadPool = threadPool; this.transportService = transportService; @@ -64,7 +65,8 @@ public class NodeMappingCreatedAction extends AbstractComponent { public void add(final Listener listener, TimeValue timeout) { listeners.add(listener); threadPool.schedule(timeout, ThreadPool.Names.CACHED, new Runnable() { - @Override public void run() { + @Override + public void run() { boolean removed = listeners.remove(listener); if (removed) { listener.onTimeout(); @@ -81,7 +83,8 @@ public class NodeMappingCreatedAction extends AbstractComponent { DiscoveryNodes nodes = clusterService.state().nodes(); if (nodes.localNodeMaster()) { threadPool.cached().execute(new Runnable() { - @Override public void run() { + @Override + public void run() { innerNodeIndexCreated(response); } }); @@ -108,16 +111,19 @@ public class NodeMappingCreatedAction extends AbstractComponent { static final String ACTION = "cluster/nodeMappingCreated"; - @Override public NodeMappingCreatedResponse newInstance() { + @Override + public NodeMappingCreatedResponse newInstance() { return new NodeMappingCreatedResponse(); } - @Override public void messageReceived(NodeMappingCreatedResponse response, TransportChannel channel) throws Exception { + @Override + public void messageReceived(NodeMappingCreatedResponse response, TransportChannel channel) throws Exception { innerNodeIndexCreated(response); channel.sendResponse(VoidStreamable.INSTANCE); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } } @@ -151,13 +157,15 @@ public class NodeMappingCreatedAction extends AbstractComponent { return nodeId; } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(index); out.writeUTF(type); out.writeUTF(nodeId); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { index = in.readUTF(); type = in.readUTF(); nodeId = in.readUTF(); diff --git a/src/main/java/org/elasticsearch/cluster/action/index/NodeMappingRefreshAction.java b/src/main/java/org/elasticsearch/cluster/action/index/NodeMappingRefreshAction.java index aaa591d5838..15c42853528 100644 --- a/src/main/java/org/elasticsearch/cluster/action/index/NodeMappingRefreshAction.java +++ b/src/main/java/org/elasticsearch/cluster/action/index/NodeMappingRefreshAction.java @@ -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,7 @@ import org.elasticsearch.transport.VoidTransportResponseHandler; import java.io.IOException; /** - * @author kimchy (Shay Banon) + * */ public class NodeMappingRefreshAction extends AbstractComponent { @@ -51,8 +51,9 @@ public class NodeMappingRefreshAction extends AbstractComponent { private final MetaDataMappingService metaDataMappingService; - @Inject public NodeMappingRefreshAction(Settings settings, ThreadPool threadPool, TransportService transportService, ClusterService clusterService, - MetaDataMappingService metaDataMappingService) { + @Inject + public NodeMappingRefreshAction(Settings settings, ThreadPool threadPool, TransportService transportService, ClusterService clusterService, + MetaDataMappingService metaDataMappingService) { super(settings); this.threadPool = threadPool; this.transportService = transportService; @@ -65,7 +66,8 @@ public class NodeMappingRefreshAction extends AbstractComponent { DiscoveryNodes nodes = clusterService.state().nodes(); if (nodes.localNodeMaster()) { threadPool.cached().execute(new Runnable() { - @Override public void run() { + @Override + public void run() { innerMappingRefresh(request); } }); @@ -83,16 +85,19 @@ public class NodeMappingRefreshAction extends AbstractComponent { static final String ACTION = "cluster/nodeMappingRefresh"; - @Override public NodeMappingRefreshRequest newInstance() { + @Override + public NodeMappingRefreshRequest newInstance() { return new NodeMappingRefreshRequest(); } - @Override public void messageReceived(NodeMappingRefreshRequest request, TransportChannel channel) throws Exception { + @Override + public void messageReceived(NodeMappingRefreshRequest request, TransportChannel channel) throws Exception { innerMappingRefresh(request); channel.sendResponse(VoidStreamable.INSTANCE); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } } @@ -126,7 +131,8 @@ public class NodeMappingRefreshAction extends AbstractComponent { return nodeId; } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(index); out.writeVInt(types.length); for (String type : types) { @@ -135,7 +141,8 @@ public class NodeMappingRefreshAction extends AbstractComponent { out.writeUTF(nodeId); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { index = in.readUTF(); types = new String[in.readVInt()]; for (int i = 0; i < types.length; i++) { diff --git a/src/main/java/org/elasticsearch/cluster/action/shard/ShardStateAction.java b/src/main/java/org/elasticsearch/cluster/action/shard/ShardStateAction.java index f6bb94765b5..bcd0d233b9c 100644 --- a/src/main/java/org/elasticsearch/cluster/action/shard/ShardStateAction.java +++ b/src/main/java/org/elasticsearch/cluster/action/shard/ShardStateAction.java @@ -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.cluster.action.shard; +import jsr166y.LinkedTransferQueue; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.ClusterState; @@ -37,24 +38,19 @@ import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Streamable; import org.elasticsearch.common.io.stream.VoidStreamable; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.util.concurrent.jsr166y.LinkedTransferQueue; 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.ArrayList; import java.util.List; import java.util.concurrent.BlockingQueue; -import static org.elasticsearch.cluster.ClusterState.*; -import static org.elasticsearch.cluster.routing.ImmutableShardRouting.*; +import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; +import static org.elasticsearch.cluster.routing.ImmutableShardRouting.readShardRoutingEntry; /** - * @author kimchy (Shay Banon) + * */ public class ShardStateAction extends AbstractComponent { @@ -68,8 +64,9 @@ public class ShardStateAction extends AbstractComponent { private final BlockingQueue startedShardsQueue = new LinkedTransferQueue(); - @Inject public ShardStateAction(Settings settings, ClusterService clusterService, TransportService transportService, - AllocationService allocationService, ThreadPool threadPool) { + @Inject + public ShardStateAction(Settings settings, ClusterService clusterService, TransportService transportService, + AllocationService allocationService, ThreadPool threadPool) { super(settings); this.clusterService = clusterService; this.transportService = transportService; @@ -88,7 +85,8 @@ public class ShardStateAction extends AbstractComponent { } else { transportService.sendRequest(clusterService.state().nodes().masterNode(), ShardFailedTransportHandler.ACTION, new ShardRoutingEntry(shardRouting, reason), new VoidTransportResponseHandler(ThreadPool.Names.SAME) { - @Override public void handleException(TransportException exp) { + @Override + public void handleException(TransportException exp) { logger.warn("failed to send failed shard to [{}]", exp, clusterService.state().nodes().masterNode()); } }); @@ -105,7 +103,8 @@ public class ShardStateAction extends AbstractComponent { } else { transportService.sendRequest(clusterService.state().nodes().masterNode(), ShardStartedTransportHandler.ACTION, new ShardRoutingEntry(shardRouting, reason), new VoidTransportResponseHandler(ThreadPool.Names.SAME) { - @Override public void handleException(TransportException exp) { + @Override + public void handleException(TransportException exp) { logger.warn("failed to send shard started to [{}]", exp, clusterService.state().nodes().masterNode()); } }); @@ -115,7 +114,8 @@ public class ShardStateAction extends AbstractComponent { private void innerShardFailed(final ShardRouting shardRouting, final String reason) { logger.warn("received shard failed for {}, reason [{}]", shardRouting, reason); clusterService.submitStateUpdateTask("shard-failed (" + shardRouting + "), reason [" + reason + "]", new ClusterStateUpdateTask() { - @Override public ClusterState execute(ClusterState currentState) { + @Override + public ClusterState execute(ClusterState currentState) { if (logger.isDebugEnabled()) { logger.debug("Received failed shard {}, reason [{}]", shardRouting, reason); } @@ -142,7 +142,8 @@ public class ShardStateAction extends AbstractComponent { startedShardsQueue.add(shardRouting); clusterService.submitStateUpdateTask("shard-started (" + shardRouting + "), reason [" + reason + "]", new ClusterStateUpdateTask() { - @Override public ClusterState execute(ClusterState currentState) { + @Override + public ClusterState execute(ClusterState currentState) { List shards = new ArrayList(); startedShardsQueue.drainTo(shards); @@ -198,16 +199,19 @@ public class ShardStateAction extends AbstractComponent { static final String ACTION = "cluster/shardFailure"; - @Override public ShardRoutingEntry newInstance() { + @Override + public ShardRoutingEntry newInstance() { return new ShardRoutingEntry(); } - @Override public void messageReceived(ShardRoutingEntry request, TransportChannel channel) throws Exception { + @Override + public void messageReceived(ShardRoutingEntry request, TransportChannel channel) throws Exception { innerShardFailed(request.shardRouting, request.reason); channel.sendResponse(VoidStreamable.INSTANCE); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } } @@ -216,16 +220,19 @@ public class ShardStateAction extends AbstractComponent { static final String ACTION = "cluster/shardStarted"; - @Override public ShardRoutingEntry newInstance() { + @Override + public ShardRoutingEntry newInstance() { return new ShardRoutingEntry(); } - @Override public void messageReceived(ShardRoutingEntry request, TransportChannel channel) throws Exception { + @Override + public void messageReceived(ShardRoutingEntry request, TransportChannel channel) throws Exception { innerShardStarted(request.shardRouting, request.reason); channel.sendResponse(VoidStreamable.INSTANCE); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } } @@ -244,12 +251,14 @@ public class ShardStateAction extends AbstractComponent { this.reason = reason; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { shardRouting = readShardRoutingEntry(in); reason = in.readUTF(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { shardRouting.writeTo(out); out.writeUTF(reason); } diff --git a/src/main/java/org/elasticsearch/cluster/block/ClusterBlock.java b/src/main/java/org/elasticsearch/cluster/block/ClusterBlock.java index 12dde059c7c..ef4eb4ecfb0 100644 --- a/src/main/java/org/elasticsearch/cluster/block/ClusterBlock.java +++ b/src/main/java/org/elasticsearch/cluster/block/ClusterBlock.java @@ -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.io.IOException; import java.io.Serializable; /** - * @author kimchy (shay.banon) + * */ public class ClusterBlock implements Serializable, Streamable, ToXContent { @@ -90,7 +90,8 @@ public class ClusterBlock implements Serializable, Streamable, ToXContent { return this.disableStatePersistence; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(Integer.toString(id)); builder.field("description", description); builder.field("retryable", retryable); @@ -112,7 +113,8 @@ public class ClusterBlock implements Serializable, Streamable, ToXContent { return block; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { id = in.readVInt(); description = in.readUTF(); levels = new ClusterBlockLevel[in.readVInt()]; @@ -123,7 +125,8 @@ public class ClusterBlock implements Serializable, Streamable, ToXContent { disableStatePersistence = in.readBoolean(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeVInt(id); out.writeUTF(description); out.writeVInt(levels.length); @@ -143,7 +146,8 @@ public class ClusterBlock implements Serializable, Streamable, ToXContent { return sb.toString(); } - @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; @@ -154,7 +158,8 @@ public class ClusterBlock implements Serializable, Streamable, ToXContent { return true; } - @Override public int hashCode() { + @Override + public int hashCode() { return id; } } diff --git a/src/main/java/org/elasticsearch/cluster/block/ClusterBlockException.java b/src/main/java/org/elasticsearch/cluster/block/ClusterBlockException.java index 9e130fd420c..1ee48055254 100644 --- a/src/main/java/org/elasticsearch/cluster/block/ClusterBlockException.java +++ b/src/main/java/org/elasticsearch/cluster/block/ClusterBlockException.java @@ -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,11 +19,11 @@ package org.elasticsearch.cluster.block; +import com.google.common.collect.ImmutableSet; import org.elasticsearch.ElasticSearchException; -import org.elasticsearch.common.collect.ImmutableSet; /** - * @author kimchy (shay.banon) + * */ public class ClusterBlockException extends ElasticSearchException { diff --git a/src/main/java/org/elasticsearch/cluster/block/ClusterBlockLevel.java b/src/main/java/org/elasticsearch/cluster/block/ClusterBlockLevel.java index a72df988fa9..9d839a524c3 100644 --- a/src/main/java/org/elasticsearch/cluster/block/ClusterBlockLevel.java +++ b/src/main/java/org/elasticsearch/cluster/block/ClusterBlockLevel.java @@ -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.cluster.block; import org.elasticsearch.ElasticSearchIllegalArgumentException; /** - * @author kimchy (shay.banon) + * */ public enum ClusterBlockLevel { READ(0), diff --git a/src/main/java/org/elasticsearch/cluster/block/ClusterBlocks.java b/src/main/java/org/elasticsearch/cluster/block/ClusterBlocks.java index 0dff3bb5871..2189ff28d64 100644 --- a/src/main/java/org/elasticsearch/cluster/block/ClusterBlocks.java +++ b/src/main/java/org/elasticsearch/cluster/block/ClusterBlocks.java @@ -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.cluster.block; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.collect.Maps; -import org.elasticsearch.common.collect.Sets; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -33,7 +33,7 @@ import java.util.Set; /** * Represents current cluster level blocks to block dirty operations done against the cluster. * - * @author kimchy (shay.banon) + * */ public class ClusterBlocks { diff --git a/src/main/java/org/elasticsearch/cluster/metadata/AliasAction.java b/src/main/java/org/elasticsearch/cluster/metadata/AliasAction.java index 4bf74c67756..eadd6f0457a 100644 --- a/src/main/java/org/elasticsearch/cluster/metadata/AliasAction.java +++ b/src/main/java/org/elasticsearch/cluster/metadata/AliasAction.java @@ -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 java.io.IOException; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class AliasAction implements Streamable { @@ -70,11 +70,14 @@ public class AliasAction implements Streamable { private String alias; - @Nullable private String filter; + @Nullable + private String filter; - @Nullable private String indexRouting; + @Nullable + private String indexRouting; - @Nullable private String searchRouting; + @Nullable + private String searchRouting; private AliasAction() { @@ -175,7 +178,8 @@ public class AliasAction implements Streamable { return aliasAction; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { actionType = Type.fromValue(in.readByte()); index = in.readUTF(); alias = in.readUTF(); @@ -190,7 +194,8 @@ public class AliasAction implements Streamable { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeByte(actionType.value()); out.writeUTF(index); out.writeUTF(alias); diff --git a/src/main/java/org/elasticsearch/cluster/metadata/AliasMetaData.java b/src/main/java/org/elasticsearch/cluster/metadata/AliasMetaData.java index f304d346a9d..9bd1b7a9840 100644 --- a/src/main/java/org/elasticsearch/cluster/metadata/AliasMetaData.java +++ b/src/main/java/org/elasticsearch/cluster/metadata/AliasMetaData.java @@ -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,13 +25,16 @@ import org.elasticsearch.common.compress.CompressedString; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.util.concurrent.Immutable; -import org.elasticsearch.common.xcontent.*; +import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.common.xcontent.XContentFactory; +import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; import java.util.Map; /** - * @author imotov + * */ @Immutable public class AliasMetaData { diff --git a/src/main/java/org/elasticsearch/cluster/metadata/IndexMetaData.java b/src/main/java/org/elasticsearch/cluster/metadata/IndexMetaData.java index 14164d0d4f5..0f7702e8fee 100644 --- a/src/main/java/org/elasticsearch/cluster/metadata/IndexMetaData.java +++ b/src/main/java/org/elasticsearch/cluster/metadata/IndexMetaData.java @@ -19,12 +19,12 @@ package org.elasticsearch.cluster.metadata; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import org.elasticsearch.ElasticSearchIllegalStateException; import org.elasticsearch.cluster.node.DiscoveryNodeFilters; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Preconditions; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.ImmutableSet; import org.elasticsearch.common.collect.MapBuilder; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -45,7 +45,7 @@ import java.util.Map; import static org.elasticsearch.common.settings.ImmutableSettings.*; /** - * @author kimchy (shay.banon) + * */ @Immutable public class IndexMetaData { @@ -221,15 +221,18 @@ public class IndexMetaData { return mappings.get(mappingType); } - @Nullable public DiscoveryNodeFilters includeFilters() { + @Nullable + public DiscoveryNodeFilters includeFilters() { return includeFilters; } - @Nullable public DiscoveryNodeFilters excludeFilters() { + @Nullable + public DiscoveryNodeFilters excludeFilters() { return excludeFilters; } - @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; @@ -244,7 +247,8 @@ public class IndexMetaData { return true; } - @Override public int hashCode() { + @Override + public int hashCode() { int result = index.hashCode(); result = 31 * result + state.hashCode(); result = 31 * result + aliases.hashCode(); diff --git a/src/main/java/org/elasticsearch/cluster/metadata/IndexTemplateMetaData.java b/src/main/java/org/elasticsearch/cluster/metadata/IndexTemplateMetaData.java index 987e4f94838..f79e8ad623a 100644 --- a/src/main/java/org/elasticsearch/cluster/metadata/IndexTemplateMetaData.java +++ b/src/main/java/org/elasticsearch/cluster/metadata/IndexTemplateMetaData.java @@ -19,7 +19,7 @@ package org.elasticsearch.cluster.metadata; -import org.elasticsearch.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMap; import org.elasticsearch.common.collect.MapBuilder; import org.elasticsearch.common.compress.CompressedString; import org.elasticsearch.common.io.stream.StreamInput; @@ -35,7 +35,7 @@ import java.io.IOException; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class IndexTemplateMetaData { diff --git a/src/main/java/org/elasticsearch/cluster/metadata/MappingMetaData.java b/src/main/java/org/elasticsearch/cluster/metadata/MappingMetaData.java index 2439b4313eb..d0babc944b7 100644 --- a/src/main/java/org/elasticsearch/cluster/metadata/MappingMetaData.java +++ b/src/main/java/org/elasticsearch/cluster/metadata/MappingMetaData.java @@ -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,10 +37,10 @@ import java.io.IOException; import java.util.Arrays; import java.util.Map; -import static org.elasticsearch.common.xcontent.support.XContentMapValues.*; +import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeBooleanValue; /** - * @author kimchy (shay.banon) + * */ public class MappingMetaData { @@ -73,7 +73,8 @@ public class MappingMetaData { return this.pathElements; } - @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 MappingMetaData { return true; } - @Override public int hashCode() { + @Override + public int hashCode() { int result = path != null ? path.hashCode() : 0; result = 31 * result + (pathElements != null ? Arrays.hashCode(pathElements) : 0); return result; @@ -128,7 +130,8 @@ public class MappingMetaData { return this.pathElements; } - @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; @@ -141,7 +144,8 @@ public class MappingMetaData { return true; } - @Override public int hashCode() { + @Override + public int hashCode() { int result = (required ? 1 : 0); result = 31 * result + (path != null ? path.hashCode() : 0); result = 31 * result + (pathElements != null ? Arrays.hashCode(pathElements) : 0); @@ -214,7 +218,8 @@ public class MappingMetaData { return this.dateTimeFormatter; } - @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; @@ -230,7 +235,8 @@ public class MappingMetaData { return true; } - @Override public int hashCode() { + @Override + public int hashCode() { int result = (enabled ? 1 : 0); result = 31 * result + (path != null ? path.hashCode() : 0); result = 31 * result + (format != null ? format.hashCode() : 0); @@ -316,7 +322,7 @@ public class MappingMetaData { } } - MappingMetaData(String type, CompressedString source, Id id, Routing routing, Timestamp timestamp) { + public MappingMetaData(String type, CompressedString source, Id id, Routing routing, Timestamp timestamp) { this.type = type; this.source = source; this.id = id; @@ -473,7 +479,8 @@ public class MappingMetaData { out.writeUTF(mappingMd.timestamp().format()); } - @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; @@ -488,7 +495,8 @@ public class MappingMetaData { return true; } - @Override public int hashCode() { + @Override + public int hashCode() { int result = type.hashCode(); result = 31 * result + source.hashCode(); result = 31 * result + id.hashCode(); diff --git a/src/main/java/org/elasticsearch/cluster/metadata/MetaData.java b/src/main/java/org/elasticsearch/cluster/metadata/MetaData.java index b0dfbe12fa3..8c9f8c911ba 100644 --- a/src/main/java/org/elasticsearch/cluster/metadata/MetaData.java +++ b/src/main/java/org/elasticsearch/cluster/metadata/MetaData.java @@ -19,45 +19,33 @@ package org.elasticsearch.cluster.metadata; +import com.google.common.collect.*; +import gnu.trove.set.hash.THashSet; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.collect.MapBuilder; -import org.elasticsearch.common.collect.Sets; -import org.elasticsearch.common.collect.UnmodifiableIterator; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.trove.set.hash.THashSet; import org.elasticsearch.common.util.concurrent.Immutable; -import org.elasticsearch.common.xcontent.ToXContent; -import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.common.xcontent.XContentFactory; -import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.common.xcontent.XContentType; +import org.elasticsearch.common.xcontent.*; import org.elasticsearch.index.Index; import org.elasticsearch.indices.IndexMissingException; import java.io.IOException; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; -import static org.elasticsearch.common.collect.Lists.*; -import static org.elasticsearch.common.collect.MapBuilder.*; -import static org.elasticsearch.common.collect.Maps.*; -import static org.elasticsearch.common.collect.Sets.*; +import static com.google.common.collect.Lists.newArrayList; +import static com.google.common.collect.Maps.newHashMap; +import static com.google.common.collect.Sets.newHashSet; +import static org.elasticsearch.common.collect.MapBuilder.newMapBuilder; import static org.elasticsearch.common.settings.ImmutableSettings.*; /** - * @author kimchy (shay.banon) + * */ @Immutable public class MetaData implements Iterable { @@ -574,7 +562,7 @@ public class MetaData implements Iterable { /** * Iterates through the list of indices and selects the effective list of filtering aliases for the * given index. - * + *

*

Only aliases with filters are returned. If the indices list contains a non-filtering reference to * the index itself - null is returned. Returns null if no filtering is required.

*/ @@ -630,7 +618,8 @@ public class MetaData implements Iterable { } - @Override public UnmodifiableIterator iterator() { + @Override + public UnmodifiableIterator iterator() { return indices.values().iterator(); } diff --git a/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java b/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java index 013f4ed949e..7fd7c6fab47 100644 --- a/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java +++ b/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java @@ -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,10 @@ package org.elasticsearch.cluster.metadata; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.ClusterState; @@ -31,10 +35,6 @@ import org.elasticsearch.cluster.routing.RoutingTable; import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.cluster.routing.allocation.RoutingAllocation; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.collect.Maps; -import org.elasticsearch.common.collect.Sets; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.compress.CompressedString; import org.elasticsearch.common.inject.Inject; @@ -61,22 +61,18 @@ import org.elasticsearch.threadpool.ThreadPool; import java.io.File; import java.io.FileReader; import java.io.IOException; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; -import static org.elasticsearch.cluster.ClusterState.*; +import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; import static org.elasticsearch.cluster.metadata.IndexMetaData.*; -import static org.elasticsearch.cluster.metadata.MetaData.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; +import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; /** - * @author kimchy (shay.banon) + * */ public class MetaDataCreateIndexService extends AbstractComponent { @@ -96,8 +92,9 @@ public class MetaDataCreateIndexService extends AbstractComponent { private final String riverIndexName; - @Inject public MetaDataCreateIndexService(Settings settings, Environment environment, ThreadPool threadPool, ClusterService clusterService, IndicesService indicesService, - AllocationService allocationService, NodeIndexCreatedAction nodeIndexCreatedAction, MetaDataService metaDataService, @RiverIndexName String riverIndexName) { + @Inject + public MetaDataCreateIndexService(Settings settings, Environment environment, ThreadPool threadPool, ClusterService clusterService, IndicesService indicesService, + AllocationService allocationService, NodeIndexCreatedAction nodeIndexCreatedAction, MetaDataService metaDataService, @RiverIndexName String riverIndexName) { super(settings); this.environment = environment; this.threadPool = threadPool; @@ -133,7 +130,8 @@ public class MetaDataCreateIndexService extends AbstractComponent { final CreateIndexListener listener = new CreateIndexListener(mdLock, request, userListener); clusterService.submitStateUpdateTask("create-index [" + request.index + "], cause [" + request.cause + "]", new ProcessedClusterStateUpdateTask() { - @Override public ClusterState execute(ClusterState currentState) { + @Override + public ClusterState execute(ClusterState currentState) { try { try { validate(request, currentState); @@ -288,7 +286,8 @@ public class MetaDataCreateIndexService extends AbstractComponent { final AtomicInteger counter = new AtomicInteger(currentState.nodes().size()); final NodeIndexCreatedAction.Listener nodeIndexCreatedListener = new NodeIndexCreatedAction.Listener() { - @Override public void onNodeIndexCreated(String index, String nodeId) { + @Override + public void onNodeIndexCreated(String index, String nodeId) { if (index.equals(request.index)) { if (counter.decrementAndGet() == 0) { listener.onResponse(new Response(true, indexMetaData)); @@ -301,7 +300,8 @@ public class MetaDataCreateIndexService extends AbstractComponent { nodeIndexCreatedAction.add(nodeIndexCreatedListener); listener.future = threadPool.schedule(request.timeout, ThreadPool.Names.SAME, new Runnable() { - @Override public void run() { + @Override + public void run() { listener.onResponse(new Response(false, indexMetaData)); nodeIndexCreatedAction.remove(nodeIndexCreatedListener); } @@ -315,7 +315,8 @@ public class MetaDataCreateIndexService extends AbstractComponent { } } - @Override public void clusterStateProcessed(ClusterState clusterState) { + @Override + public void clusterStateProcessed(ClusterState clusterState) { } }); } @@ -338,7 +339,8 @@ public class MetaDataCreateIndexService extends AbstractComponent { this.listener = listener; } - @Override public void onResponse(final Response response) { + @Override + public void onResponse(final Response response) { if (notified.compareAndSet(false, true)) { mdLock.unlock(); if (future != null) { @@ -348,7 +350,8 @@ public class MetaDataCreateIndexService extends AbstractComponent { } } - @Override public void onFailure(Throwable t) { + @Override + public void onFailure(Throwable t) { if (notified.compareAndSet(false, true)) { mdLock.unlock(); if (future != null) { @@ -392,7 +395,8 @@ public class MetaDataCreateIndexService extends AbstractComponent { } } Collections.sort(templates, new Comparator() { - @Override public int compare(IndexTemplateMetaData o1, IndexTemplateMetaData o2) { + @Override + public int compare(IndexTemplateMetaData o1, IndexTemplateMetaData o2) { return o2.order() - o1.order(); } }); diff --git a/src/main/java/org/elasticsearch/cluster/metadata/MetaDataDeleteIndexService.java b/src/main/java/org/elasticsearch/cluster/metadata/MetaDataDeleteIndexService.java index 7cf4fbf2099..22d3ca8aedc 100644 --- a/src/main/java/org/elasticsearch/cluster/metadata/MetaDataDeleteIndexService.java +++ b/src/main/java/org/elasticsearch/cluster/metadata/MetaDataDeleteIndexService.java @@ -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,11 +39,11 @@ import java.util.concurrent.ScheduledFuture; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; -import static org.elasticsearch.cluster.ClusterState.*; -import static org.elasticsearch.cluster.metadata.MetaData.*; +import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; +import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; /** - * @author kimchy (shay.banon) + * */ public class MetaDataDeleteIndexService extends AbstractComponent { @@ -57,8 +57,9 @@ public class MetaDataDeleteIndexService extends AbstractComponent { private final MetaDataService metaDataService; - @Inject public MetaDataDeleteIndexService(Settings settings, ThreadPool threadPool, ClusterService clusterService, AllocationService allocationService, - NodeIndexDeletedAction nodeIndexDeletedAction, MetaDataService metaDataService) { + @Inject + public MetaDataDeleteIndexService(Settings settings, ThreadPool threadPool, ClusterService clusterService, AllocationService allocationService, + NodeIndexDeletedAction nodeIndexDeletedAction, MetaDataService metaDataService) { super(settings); this.threadPool = threadPool; this.clusterService = clusterService; @@ -80,7 +81,8 @@ public class MetaDataDeleteIndexService extends AbstractComponent { final DeleteIndexListener listener = new DeleteIndexListener(mdLock, request, userListener); clusterService.submitStateUpdateTask("delete-index [" + request.index + "]", new ClusterStateUpdateTask() { - @Override public ClusterState execute(ClusterState currentState) { + @Override + public ClusterState execute(ClusterState currentState) { try { if (!currentState.metaData().hasConcreteIndex(request.index)) { listener.onFailure(new IndexMissingException(new Index(request.index))); @@ -105,7 +107,8 @@ public class MetaDataDeleteIndexService extends AbstractComponent { final AtomicInteger counter = new AtomicInteger(currentState.nodes().size()); final NodeIndexDeletedAction.Listener nodeIndexDeleteListener = new NodeIndexDeletedAction.Listener() { - @Override public void onNodeIndexDeleted(String index, String nodeId) { + @Override + public void onNodeIndexDeleted(String index, String nodeId) { if (index.equals(request.index)) { if (counter.decrementAndGet() == 0) { listener.onResponse(new Response(true)); @@ -117,7 +120,8 @@ public class MetaDataDeleteIndexService extends AbstractComponent { nodeIndexDeletedAction.add(nodeIndexDeleteListener); listener.future = threadPool.schedule(request.timeout, ThreadPool.Names.SAME, new Runnable() { - @Override public void run() { + @Override + public void run() { listener.onResponse(new Response(false)); nodeIndexDeletedAction.remove(nodeIndexDeleteListener); } @@ -150,7 +154,8 @@ public class MetaDataDeleteIndexService extends AbstractComponent { this.listener = listener; } - @Override public void onResponse(final Response response) { + @Override + public void onResponse(final Response response) { if (notified.compareAndSet(false, true)) { mdLock.unlock(); if (future != null) { @@ -160,7 +165,8 @@ public class MetaDataDeleteIndexService extends AbstractComponent { } } - @Override public void onFailure(Throwable t) { + @Override + public void onFailure(Throwable t) { if (notified.compareAndSet(false, true)) { mdLock.unlock(); if (future != null) { diff --git a/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexAliasesService.java b/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexAliasesService.java index 5f224ea9e7c..62ab74a5ab7 100644 --- a/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexAliasesService.java +++ b/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexAliasesService.java @@ -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,14 +19,14 @@ package org.elasticsearch.cluster.metadata; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ProcessedClusterStateUpdateTask; import org.elasticsearch.cluster.action.index.NodeAliasesUpdatedAction; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.collect.Maps; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -45,12 +45,12 @@ import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; -import static org.elasticsearch.cluster.ClusterState.*; -import static org.elasticsearch.cluster.metadata.IndexMetaData.*; -import static org.elasticsearch.cluster.metadata.MetaData.*; +import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; +import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder; +import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; /** - * @author kimchy (shay.banon) + * */ public class MetaDataIndexAliasesService extends AbstractComponent { @@ -60,7 +60,8 @@ public class MetaDataIndexAliasesService extends AbstractComponent { private final NodeAliasesUpdatedAction aliasOperationPerformedAction; - @Inject public MetaDataIndexAliasesService(Settings settings, ClusterService clusterService, IndicesService indicesService, NodeAliasesUpdatedAction aliasOperationPerformedAction) { + @Inject + public MetaDataIndexAliasesService(Settings settings, ClusterService clusterService, IndicesService indicesService, NodeAliasesUpdatedAction aliasOperationPerformedAction) { super(settings); this.clusterService = clusterService; this.indicesService = indicesService; @@ -69,7 +70,8 @@ public class MetaDataIndexAliasesService extends AbstractComponent { public void indicesAliases(final Request request, final Listener listener) { clusterService.submitStateUpdateTask("index-aliases", new ProcessedClusterStateUpdateTask() { - @Override public ClusterState execute(ClusterState currentState) { + @Override + public ClusterState execute(ClusterState currentState) { for (AliasAction aliasAction : request.actions) { if (!currentState.metaData().hasIndex(aliasAction.index())) { @@ -176,7 +178,8 @@ public class MetaDataIndexAliasesService extends AbstractComponent { } } - @Override public void clusterStateProcessed(ClusterState clusterState) { + @Override + public void clusterStateProcessed(ClusterState clusterState) { } }); } @@ -225,7 +228,8 @@ public class MetaDataIndexAliasesService extends AbstractComponent { this.version = version; } - @Override public void onAliasesUpdated(NodeAliasesUpdatedAction.NodeAliasesUpdatedResponse response) { + @Override + public void onAliasesUpdated(NodeAliasesUpdatedAction.NodeAliasesUpdatedResponse response) { if (version <= response.version()) { logger.trace("Received NodeAliasesUpdatedResponse with version [{}] from [{}]", response.version(), response.nodeId()); if (countDown.decrementAndGet() == 0) { @@ -237,7 +241,8 @@ public class MetaDataIndexAliasesService extends AbstractComponent { } } - @Override public void onTimeout() { + @Override + public void onTimeout() { aliasOperationPerformedAction.remove(this); if (notified.compareAndSet(false, true)) { listener.onResponse(new Response(false)); diff --git a/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexTemplateService.java b/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexTemplateService.java index a1a4a5035e8..d83d2a54160 100644 --- a/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexTemplateService.java +++ b/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexTemplateService.java @@ -19,13 +19,13 @@ package org.elasticsearch.cluster.metadata; +import com.google.common.collect.Maps; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ProcessedClusterStateUpdateTask; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.collect.Maps; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.ImmutableSettings; @@ -37,20 +37,22 @@ import org.elasticsearch.indices.InvalidIndexTemplateException; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class MetaDataIndexTemplateService extends AbstractComponent { private final ClusterService clusterService; - @Inject public MetaDataIndexTemplateService(Settings settings, ClusterService clusterService) { + @Inject + public MetaDataIndexTemplateService(Settings settings, ClusterService clusterService) { super(settings); this.clusterService = clusterService; } public void removeTemplate(final RemoveRequest request, final RemoveListener listener) { clusterService.submitStateUpdateTask("remove-index-template [" + request.name + "]", new ProcessedClusterStateUpdateTask() { - @Override public ClusterState execute(ClusterState currentState) { + @Override + public ClusterState execute(ClusterState currentState) { if (!currentState.metaData().templates().containsKey(request.name)) { listener.onFailure(new IndexTemplateMissingException(request.name)); return currentState; @@ -61,7 +63,8 @@ public class MetaDataIndexTemplateService extends AbstractComponent { return ClusterState.builder().state(currentState).metaData(metaData).build(); } - @Override public void clusterStateProcessed(ClusterState clusterState) { + @Override + public void clusterStateProcessed(ClusterState clusterState) { listener.onResponse(new RemoveResponse(true)); } }); @@ -110,7 +113,8 @@ public class MetaDataIndexTemplateService extends AbstractComponent { final IndexTemplateMetaData template = templateBuilder.build(); clusterService.submitStateUpdateTask("create-index-template [" + request.name + "], cause [" + request.cause + "]", new ProcessedClusterStateUpdateTask() { - @Override public ClusterState execute(ClusterState currentState) { + @Override + public ClusterState execute(ClusterState currentState) { if (request.create && currentState.metaData().templates().containsKey(request.name)) { listener.onFailure(new IndexTemplateAlreadyExistsException(request.name)); return currentState; @@ -121,7 +125,8 @@ public class MetaDataIndexTemplateService extends AbstractComponent { return ClusterState.builder().state(currentState).metaData(builder).build(); } - @Override public void clusterStateProcessed(ClusterState clusterState) { + @Override + public void clusterStateProcessed(ClusterState clusterState) { listener.onResponse(new PutResponse(true, template)); } }); diff --git a/src/main/java/org/elasticsearch/cluster/metadata/MetaDataMappingService.java b/src/main/java/org/elasticsearch/cluster/metadata/MetaDataMappingService.java index 5a47fbf632e..f2d72137ae3 100644 --- a/src/main/java/org/elasticsearch/cluster/metadata/MetaDataMappingService.java +++ b/src/main/java/org/elasticsearch/cluster/metadata/MetaDataMappingService.java @@ -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,15 +19,15 @@ package org.elasticsearch.cluster.metadata; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterStateUpdateTask; import org.elasticsearch.cluster.ProcessedClusterStateUpdateTask; import org.elasticsearch.cluster.action.index.NodeMappingCreatedAction; import org.elasticsearch.cluster.routing.IndexRoutingTable; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.collect.Maps; -import org.elasticsearch.common.collect.Sets; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.compress.CompressedString; import org.elasticsearch.common.inject.Inject; @@ -50,14 +50,14 @@ import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; -import static org.elasticsearch.cluster.ClusterState.*; -import static org.elasticsearch.cluster.metadata.IndexMetaData.*; -import static org.elasticsearch.cluster.metadata.MetaData.*; -import static org.elasticsearch.common.collect.Maps.*; -import static org.elasticsearch.index.mapper.DocumentMapper.MergeFlags.*; +import static com.google.common.collect.Maps.newHashMap; +import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; +import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder; +import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; +import static org.elasticsearch.index.mapper.DocumentMapper.MergeFlags.mergeFlags; /** - * @author kimchy (shay.banon) + * */ public class MetaDataMappingService extends AbstractComponent { @@ -69,7 +69,8 @@ public class MetaDataMappingService extends AbstractComponent { private final Map> indicesAndTypesToRefresh = Maps.newHashMap(); - @Inject public MetaDataMappingService(Settings settings, ClusterService clusterService, IndicesService indicesService, NodeMappingCreatedAction mappingCreatedAction) { + @Inject + public MetaDataMappingService(Settings settings, ClusterService clusterService, IndicesService indicesService, NodeMappingCreatedAction mappingCreatedAction) { super(settings); this.clusterService = clusterService; this.indicesService = indicesService; @@ -89,7 +90,8 @@ public class MetaDataMappingService extends AbstractComponent { sTypes.addAll(Arrays.asList(types)); } clusterService.submitStateUpdateTask("refresh-mapping [" + index + "][" + Arrays.toString(types) + "]", new ClusterStateUpdateTask() { - @Override public ClusterState execute(ClusterState currentState) { + @Override + public ClusterState execute(ClusterState currentState) { boolean createdIndex = false; try { Set sTypes; @@ -152,7 +154,8 @@ public class MetaDataMappingService extends AbstractComponent { public void updateMapping(final String index, final String type, final CompressedString mappingSource, final Listener listener) { clusterService.submitStateUpdateTask("update-mapping [" + index + "][" + type + "]", new ProcessedClusterStateUpdateTask() { - @Override public ClusterState execute(ClusterState currentState) { + @Override + public ClusterState execute(ClusterState currentState) { boolean createdIndex = false; try { // first, check if it really needs to be updated @@ -217,7 +220,8 @@ public class MetaDataMappingService extends AbstractComponent { } } - @Override public void clusterStateProcessed(ClusterState clusterState) { + @Override + public void clusterStateProcessed(ClusterState clusterState) { listener.onResponse(new Response(true)); } }); @@ -225,7 +229,8 @@ public class MetaDataMappingService extends AbstractComponent { public void removeMapping(final RemoveRequest request) { clusterService.submitStateUpdateTask("remove-mapping [" + request.mappingType + "]", new ProcessedClusterStateUpdateTask() { - @Override public ClusterState execute(ClusterState currentState) { + @Override + public ClusterState execute(ClusterState currentState) { if (request.indices.length == 0) { throw new IndexMissingException(new Index("_all")); } @@ -241,7 +246,8 @@ public class MetaDataMappingService extends AbstractComponent { return ClusterState.builder().state(currentState).metaData(builder).build(); } - @Override public void clusterStateProcessed(ClusterState clusterState) { + @Override + public void clusterStateProcessed(ClusterState clusterState) { // TODO add a listener here! } }); @@ -249,7 +255,8 @@ public class MetaDataMappingService extends AbstractComponent { public void putMapping(final PutRequest request, final Listener listener) { clusterService.submitStateUpdateTask("put-mapping [" + request.mappingType + "]", new ProcessedClusterStateUpdateTask() { - @Override public ClusterState execute(ClusterState currentState) { + @Override + public ClusterState execute(ClusterState currentState) { List indicesToClose = Lists.newArrayList(); try { if (request.indices.length == 0) { @@ -392,7 +399,8 @@ public class MetaDataMappingService extends AbstractComponent { } } - @Override public void clusterStateProcessed(ClusterState clusterState) { + @Override + public void clusterStateProcessed(ClusterState clusterState) { } }); } @@ -468,7 +476,8 @@ public class MetaDataMappingService extends AbstractComponent { this.listener = listener; } - @Override public void onNodeMappingCreated(NodeMappingCreatedAction.NodeMappingCreatedResponse response) { + @Override + public void onNodeMappingCreated(NodeMappingCreatedAction.NodeMappingCreatedResponse response) { if (countDown.decrementAndGet() == 0) { mappingCreatedAction.remove(this); if (notified.compareAndSet(false, true)) { @@ -477,7 +486,8 @@ public class MetaDataMappingService extends AbstractComponent { } } - @Override public void onTimeout() { + @Override + public void onTimeout() { mappingCreatedAction.remove(this); if (notified.compareAndSet(false, true)) { listener.onResponse(new Response(false)); diff --git a/src/main/java/org/elasticsearch/cluster/metadata/MetaDataService.java b/src/main/java/org/elasticsearch/cluster/metadata/MetaDataService.java index f582fc46273..d0a895a1bdd 100644 --- a/src/main/java/org/elasticsearch/cluster/metadata/MetaDataService.java +++ b/src/main/java/org/elasticsearch/cluster/metadata/MetaDataService.java @@ -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,8 @@ public class MetaDataService extends AbstractComponent { private final MdLock[] indexMdLocks; - @Inject public MetaDataService(Settings settings) { + @Inject + public MetaDataService(Settings settings) { super(settings); indexMdLocks = new MdLock[500]; for (int i = 0; i < indexMdLocks.length; i++) { diff --git a/src/main/java/org/elasticsearch/cluster/metadata/MetaDataStateIndexService.java b/src/main/java/org/elasticsearch/cluster/metadata/MetaDataStateIndexService.java index 333195011c2..5a30e233768 100644 --- a/src/main/java/org/elasticsearch/cluster/metadata/MetaDataStateIndexService.java +++ b/src/main/java/org/elasticsearch/cluster/metadata/MetaDataStateIndexService.java @@ -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,10 +36,10 @@ import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.index.Index; import org.elasticsearch.indices.IndexMissingException; -import static org.elasticsearch.cluster.ClusterState.*; +import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; /** - * @author kimchy (shay.banon) + * */ public class MetaDataStateIndexService extends AbstractComponent { @@ -49,7 +49,8 @@ public class MetaDataStateIndexService extends AbstractComponent { private final AllocationService allocationService; - @Inject public MetaDataStateIndexService(Settings settings, ClusterService clusterService, AllocationService allocationService) { + @Inject + public MetaDataStateIndexService(Settings settings, ClusterService clusterService, AllocationService allocationService) { super(settings); this.clusterService = clusterService; this.allocationService = allocationService; @@ -57,7 +58,8 @@ public class MetaDataStateIndexService extends AbstractComponent { public void closeIndex(final Request request, final Listener listener) { clusterService.submitStateUpdateTask("close-index [" + request.index + "]", new ProcessedClusterStateUpdateTask() { - @Override public ClusterState execute(ClusterState currentState) { + @Override + public ClusterState execute(ClusterState currentState) { IndexMetaData indexMetaData = currentState.metaData().index(request.index); if (indexMetaData == null) { @@ -90,7 +92,8 @@ public class MetaDataStateIndexService extends AbstractComponent { return ClusterState.builder().state(updatedState).routingResult(routingResult).build(); } - @Override public void clusterStateProcessed(ClusterState clusterState) { + @Override + public void clusterStateProcessed(ClusterState clusterState) { listener.onResponse(new Response(true)); } }); @@ -98,7 +101,8 @@ public class MetaDataStateIndexService extends AbstractComponent { public void openIndex(final Request request, final Listener listener) { clusterService.submitStateUpdateTask("open-index [" + request.index + "]", new ProcessedClusterStateUpdateTask() { - @Override public ClusterState execute(ClusterState currentState) { + @Override + public ClusterState execute(ClusterState currentState) { IndexMetaData indexMetaData = currentState.metaData().index(request.index); if (indexMetaData == null) { @@ -132,7 +136,8 @@ public class MetaDataStateIndexService extends AbstractComponent { return ClusterState.builder().state(updatedState).routingResult(routingResult).build(); } - @Override public void clusterStateProcessed(ClusterState clusterState) { + @Override + public void clusterStateProcessed(ClusterState clusterState) { listener.onResponse(new Response(true)); } }); diff --git a/src/main/java/org/elasticsearch/cluster/metadata/MetaDataUpdateSettingsService.java b/src/main/java/org/elasticsearch/cluster/metadata/MetaDataUpdateSettingsService.java index 2a2aa627794..50b039f23a7 100644 --- a/src/main/java/org/elasticsearch/cluster/metadata/MetaDataUpdateSettingsService.java +++ b/src/main/java/org/elasticsearch/cluster/metadata/MetaDataUpdateSettingsService.java @@ -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,17 +19,13 @@ package org.elasticsearch.cluster.metadata; +import com.google.common.collect.Sets; import org.elasticsearch.ElasticSearchIllegalArgumentException; -import org.elasticsearch.cluster.ClusterChangedEvent; -import org.elasticsearch.cluster.ClusterService; -import org.elasticsearch.cluster.ClusterState; -import org.elasticsearch.cluster.ClusterStateListener; -import org.elasticsearch.cluster.ProcessedClusterStateUpdateTask; +import org.elasticsearch.cluster.*; import org.elasticsearch.cluster.routing.RoutingTable; import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.cluster.routing.allocation.RoutingAllocation; import org.elasticsearch.common.Booleans; -import org.elasticsearch.common.collect.Sets; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.ImmutableSettings; @@ -38,10 +34,10 @@ import org.elasticsearch.common.settings.Settings; import java.util.Map; import java.util.Set; -import static org.elasticsearch.cluster.ClusterState.*; +import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; /** - * @author kimchy (shay.banon) + * */ public class MetaDataUpdateSettingsService extends AbstractComponent implements ClusterStateListener { @@ -49,14 +45,16 @@ public class MetaDataUpdateSettingsService extends AbstractComponent implements private final AllocationService allocationService; - @Inject public MetaDataUpdateSettingsService(Settings settings, ClusterService clusterService, AllocationService allocationService) { + @Inject + public MetaDataUpdateSettingsService(Settings settings, ClusterService clusterService, AllocationService allocationService) { super(settings); this.clusterService = clusterService; this.clusterService.add(this); this.allocationService = allocationService; } - @Override public void clusterChanged(ClusterChangedEvent event) { + @Override + public void clusterChanged(ClusterChangedEvent event) { // update an index with number of replicas based on data nodes if possible if (!event.state().nodes().localNodeMaster()) { return; @@ -97,11 +95,13 @@ public class MetaDataUpdateSettingsService extends AbstractComponent implements final int fNumberOfReplicas = numberOfReplicas; Settings settings = ImmutableSettings.settingsBuilder().put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, fNumberOfReplicas).build(); updateSettings(settings, new String[]{indexMetaData.index()}, new Listener() { - @Override public void onSuccess() { + @Override + public void onSuccess() { logger.info("[{}] auto expanded replicas to [{}]", indexMetaData.index(), fNumberOfReplicas); } - @Override public void onFailure(Throwable t) { + @Override + public void onFailure(Throwable t) { logger.warn("[{}] fail to auto expand replicas to [{}]", indexMetaData.index(), fNumberOfReplicas); } }); @@ -149,7 +149,8 @@ public class MetaDataUpdateSettingsService extends AbstractComponent implements final Settings openSettings = updatedSettingsBuilder.build(); clusterService.submitStateUpdateTask("update-settings", new ProcessedClusterStateUpdateTask() { - @Override public ClusterState execute(ClusterState currentState) { + @Override + public ClusterState execute(ClusterState currentState) { try { String[] actualIndices = currentState.metaData().concreteIndices(indices); RoutingTable.Builder routingTableBuilder = RoutingTable.builder().routingTable(currentState.routingTable()); @@ -201,7 +202,8 @@ public class MetaDataUpdateSettingsService extends AbstractComponent implements } } - @Override public void clusterStateProcessed(ClusterState clusterState) { + @Override + public void clusterStateProcessed(ClusterState clusterState) { listener.onSuccess(); } }); diff --git a/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java b/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java index 7f457bde079..6338fc03a4f 100644 --- a/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java +++ b/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java @@ -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.cluster.node; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import org.elasticsearch.Version; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Streamable; @@ -33,12 +33,12 @@ import java.io.IOException; import java.io.Serializable; import java.util.Map; -import static org.elasticsearch.common.transport.TransportAddressSerializers.*; +import static org.elasticsearch.common.transport.TransportAddressSerializers.addressToStream; /** * A discovery node represents a node that is part of the cluster. * - * @author kimchy (shay.banon) + * */ public class DiscoveryNode implements Streamable, Serializable { @@ -208,7 +208,8 @@ public class DiscoveryNode implements Streamable, Serializable { return node; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { nodeName = in.readUTF().intern(); nodeId = in.readUTF().intern(); address = TransportAddressSerializers.addressFromStream(in); @@ -221,7 +222,8 @@ public class DiscoveryNode implements Streamable, Serializable { version = Version.readVersion(in); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(nodeName); out.writeUTF(nodeId); addressToStream(out, address); @@ -233,7 +235,8 @@ public class DiscoveryNode implements Streamable, Serializable { Version.writeVersion(version, out); } - @Override public boolean equals(Object obj) { + @Override + public boolean equals(Object obj) { if (!(obj instanceof DiscoveryNode)) return false; @@ -241,11 +244,13 @@ public class DiscoveryNode implements Streamable, Serializable { return this.nodeId.equals(other.nodeId); } - @Override public int hashCode() { + @Override + public int hashCode() { return nodeId.hashCode(); } - @Override public String toString() { + @Override + public String toString() { StringBuilder sb = new StringBuilder(); if (nodeName.length() > 0) { sb.append('[').append(nodeName).append(']'); diff --git a/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodeFilters.java b/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodeFilters.java index f1e11d0f71e..f9e8441f146 100644 --- a/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodeFilters.java +++ b/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodeFilters.java @@ -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.cluster.node; +import com.google.common.collect.ImmutableMap; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.InetSocketTransportAddress; diff --git a/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodeService.java b/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodeService.java index 630b9e65482..636c11fda69 100644 --- a/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodeService.java +++ b/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodeService.java @@ -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,7 +19,7 @@ package org.elasticsearch.cluster.node; -import org.elasticsearch.common.collect.Maps; +import com.google.common.collect.Maps; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -34,7 +34,8 @@ public class DiscoveryNodeService extends AbstractComponent { private final List customAttributesProviders = new CopyOnWriteArrayList(); - @Inject public DiscoveryNodeService(Settings settings) { + @Inject + public DiscoveryNodeService(Settings settings) { super(settings); } diff --git a/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java b/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java index c2051d00cce..ef8638463c0 100644 --- a/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java +++ b/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodes.java @@ -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,11 +19,11 @@ package org.elasticsearch.cluster.node; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.UnmodifiableIterator; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.collect.MapBuilder; -import org.elasticsearch.common.collect.UnmodifiableIterator; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.regex.Regex; @@ -35,11 +35,11 @@ import java.util.List; import java.util.Map; import java.util.Set; -import static org.elasticsearch.common.collect.Lists.*; -import static org.elasticsearch.common.collect.Maps.*; +import static com.google.common.collect.Lists.newArrayList; +import static com.google.common.collect.Maps.newHashMap; /** - * @author kimchy (Shay Banon) + * */ public class DiscoveryNodes implements Iterable { @@ -63,7 +63,8 @@ public class DiscoveryNodes implements Iterable { this.localNodeId = localNodeId; } - @Override public UnmodifiableIterator iterator() { + @Override + public UnmodifiableIterator iterator() { return nodes.values().iterator(); } @@ -271,7 +272,8 @@ public class DiscoveryNodes implements Iterable { return new Delta(previousMasterNode, newMasterNode, localNodeId, ImmutableList.copyOf(removed), ImmutableList.copyOf(added)); } - @Override public String toString() { + @Override + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); for (DiscoveryNode node : this) { diff --git a/src/main/java/org/elasticsearch/cluster/routing/GroupShardsIterator.java b/src/main/java/org/elasticsearch/cluster/routing/GroupShardsIterator.java index 4fdf9df6fe5..3568853721d 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/GroupShardsIterator.java +++ b/src/main/java/org/elasticsearch/cluster/routing/GroupShardsIterator.java @@ -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 java.util.Collection; import java.util.Iterator; /** - * @author kimchy (shay.banon) + * */ public class GroupShardsIterator implements Iterable { @@ -62,7 +62,8 @@ public class GroupShardsIterator implements Iterable { return iterators; } - @Override public Iterator iterator() { + @Override + public Iterator iterator() { return iterators.iterator(); } } diff --git a/src/main/java/org/elasticsearch/cluster/routing/IllegalShardRoutingStateException.java b/src/main/java/org/elasticsearch/cluster/routing/IllegalShardRoutingStateException.java index 99d94698700..906c59a2ed9 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/IllegalShardRoutingStateException.java +++ b/src/main/java/org/elasticsearch/cluster/routing/IllegalShardRoutingStateException.java @@ -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.cluster.routing; /** - * @author kimchy (Shay Banon) + * */ public class IllegalShardRoutingStateException extends RoutingException { diff --git a/src/main/java/org/elasticsearch/cluster/routing/ImmutableShardRouting.java b/src/main/java/org/elasticsearch/cluster/routing/ImmutableShardRouting.java index aab39c43f63..f3db4f58de3 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/ImmutableShardRouting.java +++ b/src/main/java/org/elasticsearch/cluster/routing/ImmutableShardRouting.java @@ -19,7 +19,7 @@ package org.elasticsearch.cluster.routing; -import org.elasticsearch.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Streamable; @@ -29,7 +29,7 @@ import java.io.IOException; import java.io.Serializable; /** - * @author kimchy (shay.banon) + * */ public class ImmutableShardRouting implements Streamable, Serializable, ShardRouting { @@ -82,67 +82,83 @@ public class ImmutableShardRouting implements Streamable, Serializable, ShardRou this.version = version; } - @Override public String index() { + @Override + public String index() { return this.index; } - @Override public String getIndex() { + @Override + public String getIndex() { return index(); } - @Override public int id() { + @Override + public int id() { return this.shardId; } - @Override public int getId() { + @Override + public int getId() { return id(); } - @Override public long version() { + @Override + public long version() { return this.version; } - @Override public boolean unassigned() { + @Override + public boolean unassigned() { return state == ShardRoutingState.UNASSIGNED; } - @Override public boolean initializing() { + @Override + public boolean initializing() { return state == ShardRoutingState.INITIALIZING; } - @Override public boolean active() { + @Override + public boolean active() { return started() || relocating(); } - @Override public boolean started() { + @Override + public boolean started() { return state == ShardRoutingState.STARTED; } - @Override public boolean relocating() { + @Override + public boolean relocating() { return state == ShardRoutingState.RELOCATING; } - @Override public boolean assignedToNode() { + @Override + public boolean assignedToNode() { return currentNodeId != null; } - @Override public String currentNodeId() { + @Override + public String currentNodeId() { return this.currentNodeId; } - @Override public String relocatingNodeId() { + @Override + public String relocatingNodeId() { return this.relocatingNodeId; } - @Override public boolean primary() { + @Override + public boolean primary() { return this.primary; } - @Override public ShardRoutingState state() { + @Override + public ShardRoutingState state() { return this.state; } - @Override public ShardId shardId() { + @Override + public ShardId shardId() { if (shardIdentifier != null) { return shardIdentifier; } @@ -150,7 +166,8 @@ public class ImmutableShardRouting implements Streamable, Serializable, ShardRou return shardIdentifier; } - @Override public ShardIterator shardsIt() { + @Override + public ShardIterator shardsIt() { return new PlainShardIterator(shardId(), asList); } @@ -172,7 +189,8 @@ public class ImmutableShardRouting implements Streamable, Serializable, ShardRou readFromThin(in); } - @Override public void readFromThin(StreamInput in) throws IOException { + @Override + public void readFromThin(StreamInput in) throws IOException { version = in.readLong(); if (in.readBoolean()) { currentNodeId = in.readUTF(); @@ -186,7 +204,8 @@ public class ImmutableShardRouting implements Streamable, Serializable, ShardRou state = ShardRoutingState.fromValue(in.readByte()); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { readFrom(in, in.readUTF(), in.readVInt()); } @@ -213,7 +232,8 @@ public class ImmutableShardRouting implements Streamable, Serializable, ShardRou out.writeByte(state.value()); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(index); out.writeVInt(shardId); writeToThin(out); @@ -249,11 +269,13 @@ public class ImmutableShardRouting implements Streamable, Serializable, ShardRou return result; } - @Override public String toString() { + @Override + public String toString() { return shortSummary(); } - @Override public String shortSummary() { + @Override + public String shortSummary() { StringBuilder sb = new StringBuilder(); sb.append('[').append(index).append(']').append('[').append(shardId).append(']'); sb.append(", node[").append(currentNodeId).append("], "); diff --git a/src/main/java/org/elasticsearch/cluster/routing/IndexRoutingTable.java b/src/main/java/org/elasticsearch/cluster/routing/IndexRoutingTable.java index 42e41fd7b0d..8f7f0bb1cba 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/IndexRoutingTable.java +++ b/src/main/java/org/elasticsearch/cluster/routing/IndexRoutingTable.java @@ -19,28 +19,24 @@ package org.elasticsearch.cluster.routing; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Sets; +import com.google.common.collect.UnmodifiableIterator; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.MetaData; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.Sets; -import org.elasticsearch.common.collect.UnmodifiableIterator; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.util.concurrent.Immutable; import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.concurrent.atomic.AtomicInteger; -import static org.elasticsearch.common.collect.Lists.*; +import static com.google.common.collect.Lists.newArrayList; /** - * @author kimchy (Shay Banon) + * */ @Immutable public class IndexRoutingTable implements Iterable { @@ -121,7 +117,8 @@ public class IndexRoutingTable implements Iterable { } } - @Override public UnmodifiableIterator iterator() { + @Override + public UnmodifiableIterator iterator() { return shards.values().iterator(); } @@ -224,7 +221,7 @@ public class IndexRoutingTable implements Iterable { /** * A groups shards iterator where each groups is a single {@link ShardRouting} and a group * is created for each shard routing. - * + *

*

This basically means that components that use the {@link GroupShardsIterator} will iterate * over *all* the shards (all the replicas) within the index. */ diff --git a/src/main/java/org/elasticsearch/cluster/routing/IndexShardRoutingTable.java b/src/main/java/org/elasticsearch/cluster/routing/IndexShardRoutingTable.java index 0cf05281305..ca470349264 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/IndexShardRoutingTable.java +++ b/src/main/java/org/elasticsearch/cluster/routing/IndexShardRoutingTable.java @@ -19,28 +19,24 @@ package org.elasticsearch.cluster.routing; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.UnmodifiableIterator; +import jsr166y.ThreadLocalRandom; import org.elasticsearch.cluster.node.DiscoveryNodes; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.collect.MapBuilder; -import org.elasticsearch.common.collect.UnmodifiableIterator; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom; import org.elasticsearch.index.shard.ShardId; import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.atomic.AtomicInteger; -import static org.elasticsearch.common.collect.Lists.*; +import static com.google.common.collect.Lists.newArrayList; /** - * @author kimchy (shay.banon) + * */ public class IndexShardRoutingTable implements Iterable { @@ -143,7 +139,8 @@ public class IndexShardRoutingTable implements Iterable { return shardId(); } - @Override public UnmodifiableIterator iterator() { + @Override + public UnmodifiableIterator iterator() { return shards.iterator(); } @@ -290,11 +287,13 @@ public class IndexShardRoutingTable implements Iterable { this.attributes = attributes; } - @Override public int hashCode() { + @Override + public int hashCode() { return Arrays.hashCode(attributes); } - @Override public boolean equals(Object obj) { + @Override + public boolean equals(Object obj) { return Arrays.equals(attributes, ((AttributesKey) obj).attributes); } } diff --git a/src/main/java/org/elasticsearch/cluster/routing/MutableShardRouting.java b/src/main/java/org/elasticsearch/cluster/routing/MutableShardRouting.java index da1ba08fbaa..ad70cbaae70 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/MutableShardRouting.java +++ b/src/main/java/org/elasticsearch/cluster/routing/MutableShardRouting.java @@ -20,7 +20,7 @@ package org.elasticsearch.cluster.routing; /** - * @author kimchy (Shay Banon) + * */ public class MutableShardRouting extends ImmutableShardRouting { diff --git a/src/main/java/org/elasticsearch/cluster/routing/PlainShardIterator.java b/src/main/java/org/elasticsearch/cluster/routing/PlainShardIterator.java index e4f9f7fa6a5..844580122a3 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/PlainShardIterator.java +++ b/src/main/java/org/elasticsearch/cluster/routing/PlainShardIterator.java @@ -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.index.shard.ShardId; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class PlainShardIterator extends PlainShardsIterator implements ShardIterator { @@ -40,22 +40,26 @@ public class PlainShardIterator extends PlainShardsIterator implements ShardIter this.shardId = shardId; } - @Override public ShardIterator reset() { + @Override + public ShardIterator reset() { super.reset(); return this; } - @Override public ShardId shardId() { + @Override + public ShardId shardId() { return this.shardId; } - @Override public boolean equals(Object o) { + @Override + public boolean equals(Object o) { if (this == o) return true; ShardIterator that = (ShardIterator) o; return shardId.equals(that.shardId()); } - @Override public int hashCode() { + @Override + public int hashCode() { return shardId.hashCode(); } } diff --git a/src/main/java/org/elasticsearch/cluster/routing/PlainShardsIterator.java b/src/main/java/org/elasticsearch/cluster/routing/PlainShardsIterator.java index 4feba1912cf..b4b682cd971 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/PlainShardsIterator.java +++ b/src/main/java/org/elasticsearch/cluster/routing/PlainShardsIterator.java @@ -22,7 +22,7 @@ package org.elasticsearch.cluster.routing; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class PlainShardsIterator implements ShardsIterator { @@ -52,23 +52,27 @@ public class PlainShardsIterator implements ShardsIterator { this.limit = this.index + size; } - @Override public ShardsIterator reset() { + @Override + public ShardsIterator reset() { this.counter = this.index; return this; } - @Override public int remaining() { + @Override + public int remaining() { return limit - counter; } - @Override public ShardRouting firstOrNull() { + @Override + public ShardRouting firstOrNull() { if (size == 0) { return null; } return shards.get(index); } - @Override public ShardRouting nextOrNull() { + @Override + public ShardRouting nextOrNull() { if (size == 0) { return null; } @@ -85,11 +89,13 @@ public class PlainShardsIterator implements ShardsIterator { } } - @Override public int size() { + @Override + public int size() { return size; } - @Override public int sizeActive() { + @Override + public int sizeActive() { int count = 0; for (int i = 0; i < size; i++) { if (shards.get(i).active()) { @@ -99,7 +105,8 @@ public class PlainShardsIterator implements ShardsIterator { return count; } - @Override public int assignedReplicasIncludingRelocating() { + @Override + public int assignedReplicasIncludingRelocating() { int count = 0; for (int i = 0; i < size; i++) { ShardRouting shard = shards.get(i); @@ -125,7 +132,8 @@ public class PlainShardsIterator implements ShardsIterator { return count; } - @Override public Iterable asUnordered() { + @Override + public Iterable asUnordered() { return shards; } } diff --git a/src/main/java/org/elasticsearch/cluster/routing/RoutingBuilders.java b/src/main/java/org/elasticsearch/cluster/routing/RoutingBuilders.java index 4e2f02a3c2e..bcdb9a57a0a 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/RoutingBuilders.java +++ b/src/main/java/org/elasticsearch/cluster/routing/RoutingBuilders.java @@ -20,7 +20,7 @@ package org.elasticsearch.cluster.routing; /** - * @author kimchy (Shay Banon) + * */ public final class RoutingBuilders { diff --git a/src/main/java/org/elasticsearch/cluster/routing/RoutingException.java b/src/main/java/org/elasticsearch/cluster/routing/RoutingException.java index 69c7c7d3016..8b7cade9056 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/RoutingException.java +++ b/src/main/java/org/elasticsearch/cluster/routing/RoutingException.java @@ -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.cluster.routing; import org.elasticsearch.ElasticSearchException; /** - * @author kimchy (Shay Banon) + * */ public class RoutingException extends ElasticSearchException { diff --git a/src/main/java/org/elasticsearch/cluster/routing/RoutingNode.java b/src/main/java/org/elasticsearch/cluster/routing/RoutingNode.java index fbf0294c91c..4728169fb71 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/RoutingNode.java +++ b/src/main/java/org/elasticsearch/cluster/routing/RoutingNode.java @@ -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.Iterator; import java.util.List; -import static org.elasticsearch.common.collect.Lists.*; +import static com.google.common.collect.Lists.newArrayList; /** */ @@ -44,7 +44,8 @@ public class RoutingNode implements Iterable { this.shards = shards; } - @Override public Iterator iterator() { + @Override + public Iterator iterator() { return shards.iterator(); } diff --git a/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java b/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java index 4cc338c789f..ad9b57f235e 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java +++ b/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java @@ -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,11 +19,11 @@ package org.elasticsearch.cluster.routing; +import gnu.trove.map.hash.TObjectIntHashMap; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.block.ClusterBlocks; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.MetaData; -import org.elasticsearch.common.trove.map.hash.TObjectIntHashMap; import org.elasticsearch.common.util.concurrent.NotThreadSafe; import java.util.HashMap; @@ -31,11 +31,11 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import static org.elasticsearch.common.collect.Lists.*; -import static org.elasticsearch.common.collect.Maps.*; +import static com.google.common.collect.Lists.newArrayList; +import static com.google.common.collect.Maps.newHashMap; /** - * @author kimchy (shay.banon) + * */ @NotThreadSafe public class RoutingNodes implements Iterable { @@ -92,7 +92,8 @@ public class RoutingNodes implements Iterable { } } - @Override public Iterator iterator() { + @Override + public Iterator iterator() { return nodesToShards.values().iterator(); } diff --git a/src/main/java/org/elasticsearch/cluster/routing/RoutingService.java b/src/main/java/org/elasticsearch/cluster/routing/RoutingService.java index 951c6ffde22..337b54d415f 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/RoutingService.java +++ b/src/main/java/org/elasticsearch/cluster/routing/RoutingService.java @@ -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,11 +20,7 @@ package org.elasticsearch.cluster.routing; import org.elasticsearch.ElasticSearchException; -import org.elasticsearch.cluster.ClusterChangedEvent; -import org.elasticsearch.cluster.ClusterService; -import org.elasticsearch.cluster.ClusterState; -import org.elasticsearch.cluster.ClusterStateListener; -import org.elasticsearch.cluster.ClusterStateUpdateTask; +import org.elasticsearch.cluster.*; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.cluster.routing.allocation.RoutingAllocation; @@ -36,11 +32,11 @@ import org.elasticsearch.threadpool.ThreadPool; import java.util.concurrent.Future; -import static org.elasticsearch.cluster.ClusterState.*; -import static org.elasticsearch.common.unit.TimeValue.*; +import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; +import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; /** - * @author kimchy (shay.banon) + * */ public class RoutingService extends AbstractLifecycleComponent implements ClusterStateListener { @@ -58,7 +54,8 @@ public class RoutingService extends AbstractLifecycleComponent i private volatile Future scheduledRoutingTableFuture; - @Inject public RoutingService(Settings settings, ThreadPool threadPool, ClusterService clusterService, AllocationService allocationService) { + @Inject + public RoutingService(Settings settings, ThreadPool threadPool, ClusterService clusterService, AllocationService allocationService) { super(settings); this.threadPool = threadPool; this.clusterService = clusterService; @@ -66,11 +63,13 @@ public class RoutingService extends AbstractLifecycleComponent i this.schedule = componentSettings.getAsTime("schedule", timeValueSeconds(10)); } - @Override protected void doStart() throws ElasticSearchException { + @Override + protected void doStart() throws ElasticSearchException { clusterService.addPriority(this); } - @Override protected void doStop() throws ElasticSearchException { + @Override + protected void doStop() throws ElasticSearchException { if (scheduledRoutingTableFuture != null) { scheduledRoutingTableFuture.cancel(true); scheduledRoutingTableFuture = null; @@ -78,10 +77,12 @@ public class RoutingService extends AbstractLifecycleComponent i clusterService.remove(this); } - @Override protected void doClose() throws ElasticSearchException { + @Override + protected void doClose() throws ElasticSearchException { } - @Override public void clusterChanged(ClusterChangedEvent event) { + @Override + public void clusterChanged(ClusterChangedEvent event) { if (event.source().equals(CLUSTER_UPDATE_TASK_SOURCE)) { // that's us, ignore this event return; @@ -129,7 +130,8 @@ public class RoutingService extends AbstractLifecycleComponent i return; } clusterService.submitStateUpdateTask(CLUSTER_UPDATE_TASK_SOURCE, new ClusterStateUpdateTask() { - @Override public ClusterState execute(ClusterState currentState) { + @Override + public ClusterState execute(ClusterState currentState) { RoutingAllocation.Result routingResult = allocationService.reroute(currentState); if (!routingResult.changed()) { // no state changed @@ -146,7 +148,8 @@ public class RoutingService extends AbstractLifecycleComponent i private class RoutingTableUpdater implements Runnable { - @Override public void run() { + @Override + public void run() { reroute(); } } diff --git a/src/main/java/org/elasticsearch/cluster/routing/RoutingTable.java b/src/main/java/org/elasticsearch/cluster/routing/RoutingTable.java index 8bfe146b921..c5d7015414f 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/RoutingTable.java +++ b/src/main/java/org/elasticsearch/cluster/routing/RoutingTable.java @@ -19,13 +19,9 @@ package org.elasticsearch.cluster.routing; +import com.google.common.collect.*; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.MetaData; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.Iterables; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.collect.UnmodifiableIterator; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.util.concurrent.Immutable; @@ -37,11 +33,11 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import static org.elasticsearch.common.collect.Lists.*; -import static org.elasticsearch.common.collect.Maps.*; +import static com.google.common.collect.Lists.newArrayList; +import static com.google.common.collect.Maps.newHashMap; /** - * @author kimchy (shay.banon) + * */ @Immutable public class RoutingTable implements Iterable { @@ -62,7 +58,8 @@ public class RoutingTable implements Iterable { return this.version; } - @Override public UnmodifiableIterator iterator() { + @Override + public UnmodifiableIterator iterator() { return indicesRouting.values().iterator(); } diff --git a/src/main/java/org/elasticsearch/cluster/routing/RoutingTableValidation.java b/src/main/java/org/elasticsearch/cluster/routing/RoutingTableValidation.java index 9dec5f35b32..ec8d3b84b06 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/RoutingTableValidation.java +++ b/src/main/java/org/elasticsearch/cluster/routing/RoutingTableValidation.java @@ -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.cluster.routing; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.Lists; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Lists; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Streamable; @@ -31,11 +31,12 @@ import java.io.Serializable; import java.util.List; import java.util.Map; -import static org.elasticsearch.common.collect.Lists.*; -import static org.elasticsearch.common.collect.Maps.*; +import static com.google.common.collect.Lists.newArrayList; +import static com.google.common.collect.Lists.newArrayListWithCapacity; +import static com.google.common.collect.Maps.newHashMap; /** - * @author kimchy (shay.banon) + * */ public class RoutingTableValidation implements Serializable, Streamable { @@ -111,11 +112,13 @@ public class RoutingTableValidation implements Serializable, Streamable { indexFailures.add(failure); } - @Override public String toString() { + @Override + public String toString() { return allFailures().toString(); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { valid = in.readBoolean(); int size = in.readVInt(); if (size == 0) { @@ -143,7 +146,8 @@ public class RoutingTableValidation implements Serializable, Streamable { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(valid); if (failures == null) { out.writeVInt(0); diff --git a/src/main/java/org/elasticsearch/cluster/routing/RoutingValidationException.java b/src/main/java/org/elasticsearch/cluster/routing/RoutingValidationException.java index 5f9c57c2970..a3a7bc14631 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/RoutingValidationException.java +++ b/src/main/java/org/elasticsearch/cluster/routing/RoutingValidationException.java @@ -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.cluster.routing; /** - * @author kimchy (Shay Banon) + * */ public class RoutingValidationException extends RoutingException { diff --git a/src/main/java/org/elasticsearch/cluster/routing/ShardIterator.java b/src/main/java/org/elasticsearch/cluster/routing/ShardIterator.java index 0961ada43a7..64feece1af8 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/ShardIterator.java +++ b/src/main/java/org/elasticsearch/cluster/routing/ShardIterator.java @@ -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.index.shard.ShardId; /** * Allows to iterate over a set of shard instances (routing) within a shard id group. * - * @author kimchy (shay.banon) + * */ public interface ShardIterator extends ShardsIterator { diff --git a/src/main/java/org/elasticsearch/cluster/routing/ShardRouting.java b/src/main/java/org/elasticsearch/cluster/routing/ShardRouting.java index 2ba47e46d43..bd8e6886b4a 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/ShardRouting.java +++ b/src/main/java/org/elasticsearch/cluster/routing/ShardRouting.java @@ -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.io.Serializable; /** * Shard routing represents the state of a shard instance allocated in the cluster. * - * @author kimchy (shay.banon) + * */ public interface ShardRouting extends Streamable, Serializable { diff --git a/src/main/java/org/elasticsearch/cluster/routing/ShardRoutingState.java b/src/main/java/org/elasticsearch/cluster/routing/ShardRoutingState.java index 93e433bb9e2..6f25d2b7bee 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/ShardRoutingState.java +++ b/src/main/java/org/elasticsearch/cluster/routing/ShardRoutingState.java @@ -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.ElasticSearchIllegalStateException; /** * The state of the shard as defined by the cluster. * - * @author kimchy (shay.banon) + * */ public enum ShardRoutingState { /** diff --git a/src/main/java/org/elasticsearch/cluster/routing/ShardsIterator.java b/src/main/java/org/elasticsearch/cluster/routing/ShardsIterator.java index d20ee13e8ac..29968ae0466 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/ShardsIterator.java +++ b/src/main/java/org/elasticsearch/cluster/routing/ShardsIterator.java @@ -22,7 +22,7 @@ package org.elasticsearch.cluster.routing; /** * Allows to iterate over unrelated shards. * - * @author kimchy (shay.banon) + * */ public interface ShardsIterator { diff --git a/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationExplanation.java b/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationExplanation.java index c297f16e949..60d52e543a9 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationExplanation.java +++ b/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationExplanation.java @@ -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.cluster.routing.allocation; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import org.elasticsearch.cluster.node.DiscoveryNode; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.collect.Maps; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Streamable; @@ -32,7 +32,7 @@ import java.util.List; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class AllocationExplanation implements Streamable { @@ -79,7 +79,8 @@ public class AllocationExplanation implements Streamable { return e; } - @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++) { ShardId shardId = ShardId.readShardId(in); @@ -96,7 +97,8 @@ public class AllocationExplanation implements Streamable { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeVInt(explanations.size()); for (Map.Entry> entry : explanations.entrySet()) { entry.getKey().writeTo(out); diff --git a/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationModule.java b/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationModule.java index fbec8881186..2d81c915c77 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationModule.java +++ b/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationModule.java @@ -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,11 +19,11 @@ package org.elasticsearch.cluster.routing.allocation; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; import org.elasticsearch.cluster.routing.allocation.allocator.ShardsAllocatorModule; import org.elasticsearch.cluster.routing.allocation.decider.AllocationDecider; import org.elasticsearch.cluster.routing.allocation.decider.AllocationDecidersModule; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.inject.SpawnModules; @@ -32,7 +32,7 @@ import org.elasticsearch.common.settings.Settings; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class AllocationModule extends AbstractModule implements SpawnModules { @@ -44,11 +44,13 @@ public class AllocationModule extends AbstractModule implements SpawnModules { this.settings = settings; } - @Override public Iterable spawnModules() { + @Override + public Iterable spawnModules() { return ImmutableList.of(new ShardsAllocatorModule(settings), new AllocationDecidersModule(settings)); } - @Override protected void configure() { + @Override + protected void configure() { bind(AllocationService.class).asEagerSingleton(); } } diff --git a/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java b/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java index 5b9c21d35fd..c9301ff90f9 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java +++ b/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java @@ -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,13 +21,7 @@ package org.elasticsearch.cluster.routing.allocation; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.node.DiscoveryNode; -import org.elasticsearch.cluster.routing.IndexRoutingTable; -import org.elasticsearch.cluster.routing.MutableShardRouting; -import org.elasticsearch.cluster.routing.RoutingNode; -import org.elasticsearch.cluster.routing.RoutingNodes; -import org.elasticsearch.cluster.routing.RoutingTable; -import org.elasticsearch.cluster.routing.ShardRouting; -import org.elasticsearch.cluster.routing.ShardRoutingState; +import org.elasticsearch.cluster.routing.*; import org.elasticsearch.cluster.routing.allocation.allocator.ShardsAllocators; import org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders; import org.elasticsearch.common.component.AbstractComponent; @@ -41,11 +35,11 @@ import java.util.Iterator; import java.util.List; import java.util.Set; -import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.common.collect.Sets.*; +import static com.google.common.collect.Sets.newHashSet; +import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; /** - * @author kimchy (shay.banon) + * */ public class AllocationService extends AbstractComponent { @@ -64,7 +58,8 @@ public class AllocationService extends AbstractComponent { ); } - @Inject public AllocationService(Settings settings, AllocationDeciders allocationDeciders, ShardsAllocators shardsAllocators) { + @Inject + public AllocationService(Settings settings, AllocationDeciders allocationDeciders, ShardsAllocators shardsAllocators) { super(settings); this.allocationDeciders = allocationDeciders; this.shardsAllocators = shardsAllocators; @@ -72,7 +67,7 @@ public class AllocationService extends AbstractComponent { /** * Applies the started shards. Note, shards can be called several times within this method. - * + *

*

If the same instance of the routing table is returned, then no change has been made. */ public RoutingAllocation.Result applyStartedShards(ClusterState clusterState, List startedShards) { @@ -89,7 +84,7 @@ public class AllocationService extends AbstractComponent { /** * Applies the failed shards. Note, shards can be called several times within this method. - * + *

*

If the same instance of the routing table is returned, then no change has been made. */ public RoutingAllocation.Result applyFailedShard(ClusterState clusterState, ShardRouting failedShard) { @@ -106,7 +101,7 @@ public class AllocationService extends AbstractComponent { /** * Reroutes the routing table based on the live nodes. - * + *

*

If the same instance of the routing table is returned, then no change has been made. */ public RoutingAllocation.Result reroute(ClusterState clusterState) { diff --git a/src/main/java/org/elasticsearch/cluster/routing/allocation/FailedRerouteAllocation.java b/src/main/java/org/elasticsearch/cluster/routing/allocation/FailedRerouteAllocation.java index ef1b7fc0f82..54adc36ba63 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/allocation/FailedRerouteAllocation.java +++ b/src/main/java/org/elasticsearch/cluster/routing/allocation/FailedRerouteAllocation.java @@ -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.cluster.routing.ShardRouting; import org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders; /** - * @author kimchy (shay.banon) + * */ public class FailedRerouteAllocation extends RoutingAllocation { diff --git a/src/main/java/org/elasticsearch/cluster/routing/allocation/RoutingAllocation.java b/src/main/java/org/elasticsearch/cluster/routing/allocation/RoutingAllocation.java index 01a08d655de..0a624d6c7e9 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/allocation/RoutingAllocation.java +++ b/src/main/java/org/elasticsearch/cluster/routing/allocation/RoutingAllocation.java @@ -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.HashMap; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class RoutingAllocation { diff --git a/src/main/java/org/elasticsearch/cluster/routing/allocation/StartedRerouteAllocation.java b/src/main/java/org/elasticsearch/cluster/routing/allocation/StartedRerouteAllocation.java index d4385e502a9..4b2393f9f80 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/allocation/StartedRerouteAllocation.java +++ b/src/main/java/org/elasticsearch/cluster/routing/allocation/StartedRerouteAllocation.java @@ -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.cluster.routing.allocation.decider.AllocationDeciders; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class StartedRerouteAllocation extends RoutingAllocation { diff --git a/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/EvenShardsCountAllocator.java b/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/EvenShardsCountAllocator.java index e5bd4fb7829..18f1dd7992d 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/EvenShardsCountAllocator.java +++ b/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/EvenShardsCountAllocator.java @@ -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.cluster.routing.allocation.allocator; +import gnu.trove.map.hash.TObjectIntHashMap; import org.elasticsearch.cluster.routing.MutableShardRouting; import org.elasticsearch.cluster.routing.RoutingNode; import org.elasticsearch.cluster.routing.RoutingNodes; @@ -29,30 +30,34 @@ import org.elasticsearch.cluster.routing.allocation.StartedRerouteAllocation; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.trove.map.hash.TObjectIntHashMap; import java.util.Arrays; import java.util.Comparator; import java.util.Iterator; import java.util.List; -import static org.elasticsearch.cluster.routing.ShardRoutingState.*; +import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; +import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; /** */ public class EvenShardsCountAllocator extends AbstractComponent implements ShardsAllocator { - @Inject public EvenShardsCountAllocator(Settings settings) { + @Inject + public EvenShardsCountAllocator(Settings settings) { super(settings); } - @Override public void applyStartedShards(StartedRerouteAllocation allocation) { + @Override + public void applyStartedShards(StartedRerouteAllocation allocation) { } - @Override public void applyFailedShards(FailedRerouteAllocation allocation) { + @Override + public void applyFailedShards(FailedRerouteAllocation allocation) { } - @Override public boolean allocateUnassigned(RoutingAllocation allocation) { + @Override + public boolean allocateUnassigned(RoutingAllocation allocation) { boolean changed = false; RoutingNodes routingNodes = allocation.routingNodes(); @@ -102,7 +107,8 @@ public class EvenShardsCountAllocator extends AbstractComponent implements Shard return changed; } - @Override public boolean rebalance(RoutingAllocation allocation) { + @Override + public boolean rebalance(RoutingAllocation allocation) { boolean changed = false; RoutingNode[] sortedNodesLeastToHigh = sortedNodesLeastToHigh(allocation); if (sortedNodesLeastToHigh.length == 0) { @@ -157,7 +163,8 @@ public class EvenShardsCountAllocator extends AbstractComponent implements Shard return changed; } - @Override public boolean move(MutableShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) { + @Override + public boolean move(MutableShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) { assert shardRouting.started(); boolean changed = false; RoutingNode[] sortedNodesLeastToHigh = sortedNodesLeastToHigh(allocation); @@ -196,7 +203,8 @@ public class EvenShardsCountAllocator extends AbstractComponent implements Shard } RoutingNode[] nodes = allocation.routingNodes().nodesToShards().values().toArray(new RoutingNode[allocation.routingNodes().nodesToShards().values().size()]); Arrays.sort(nodes, new Comparator() { - @Override public int compare(RoutingNode o1, RoutingNode o2) { + @Override + public int compare(RoutingNode o1, RoutingNode o2) { return nodeCounts.get(o1.nodeId()) - nodeCounts.get(o2.nodeId()); } }); diff --git a/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/GatewayAllocator.java b/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/GatewayAllocator.java index f80beceb685..cffd1d98215 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/GatewayAllocator.java +++ b/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/GatewayAllocator.java @@ -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 diff --git a/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/ShardsAllocator.java b/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/ShardsAllocator.java index bd72d42fe5f..b9261ab9f37 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/ShardsAllocator.java +++ b/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/ShardsAllocator.java @@ -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 diff --git a/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/ShardsAllocatorModule.java b/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/ShardsAllocatorModule.java index 3d401e2441f..ad40076cfeb 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/ShardsAllocatorModule.java +++ b/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/ShardsAllocatorModule.java @@ -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 ShardsAllocatorModule extends AbstractModule { this.gatewayAllocator = gatewayAllocator; } - @Override protected void configure() { + @Override + protected void configure() { bind(GatewayAllocator.class).to(gatewayAllocator).asEagerSingleton(); bind(ShardsAllocator.class).to(EvenShardsCountAllocator.class).asEagerSingleton(); } diff --git a/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/ShardsAllocators.java b/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/ShardsAllocators.java index b160838e1bb..b9fa03741f3 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/ShardsAllocators.java +++ b/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/ShardsAllocators.java @@ -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,34 +45,40 @@ public class ShardsAllocators extends AbstractComponent implements ShardsAllocat this(settings, new NoneGatewayAllocator(), new EvenShardsCountAllocator(settings)); } - @Inject public ShardsAllocators(Settings settings, GatewayAllocator gatewayAllocator, ShardsAllocator allocator) { + @Inject + public ShardsAllocators(Settings settings, GatewayAllocator gatewayAllocator, ShardsAllocator allocator) { super(settings); this.gatewayAllocator = gatewayAllocator; this.allocator = allocator; } - @Override public void applyStartedShards(StartedRerouteAllocation allocation) { + @Override + public void applyStartedShards(StartedRerouteAllocation allocation) { gatewayAllocator.applyStartedShards(allocation); allocator.applyStartedShards(allocation); } - @Override public void applyFailedShards(FailedRerouteAllocation allocation) { + @Override + public void applyFailedShards(FailedRerouteAllocation allocation) { gatewayAllocator.applyFailedShards(allocation); allocator.applyFailedShards(allocation); } - @Override public boolean allocateUnassigned(RoutingAllocation allocation) { + @Override + public boolean allocateUnassigned(RoutingAllocation allocation) { boolean changed = false; changed |= gatewayAllocator.allocateUnassigned(allocation); changed |= allocator.allocateUnassigned(allocation); return changed; } - @Override public boolean rebalance(RoutingAllocation allocation) { + @Override + public boolean rebalance(RoutingAllocation allocation) { return allocator.rebalance(allocation); } - @Override public boolean move(MutableShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) { + @Override + public boolean move(MutableShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) { return allocator.move(shardRouting, node, allocation); } } diff --git a/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/AllocationDecider.java b/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/AllocationDecider.java index 22c3abdb1e7..e01a80d7b7b 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/AllocationDecider.java +++ b/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/AllocationDecider.java @@ -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,23 +28,26 @@ import org.elasticsearch.common.settings.Settings; /** * A pluggable logic allowing to control if allocation of a shard is allowed on a specific node. * - * @author kimchy (shay.banon) + * */ public abstract class AllocationDecider extends AbstractComponent { public static enum Decision { YES { - @Override public boolean allocate() { + @Override + public boolean allocate() { return true; } }, NO { - @Override public boolean allocate() { + @Override + public boolean allocate() { return false; } }, THROTTLE { - @Override public boolean allocate() { + @Override + public boolean allocate() { return false; } }; diff --git a/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/AllocationDeciders.java b/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/AllocationDeciders.java index ccb6d8314e4..c1a8e561241 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/AllocationDeciders.java +++ b/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/AllocationDeciders.java @@ -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.cluster.routing.allocation.decider; +import com.google.common.collect.ImmutableSet; import org.elasticsearch.cluster.routing.RoutingNode; import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.cluster.routing.allocation.RoutingAllocation; -import org.elasticsearch.common.collect.ImmutableSet; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.node.settings.NodeSettingsService; @@ -51,12 +51,14 @@ public class AllocationDeciders extends AllocationDecider { ); } - @Inject public AllocationDeciders(Settings settings, Set allocations) { + @Inject + public AllocationDeciders(Settings settings, Set allocations) { super(settings); this.allocations = allocations.toArray(new AllocationDecider[allocations.size()]); } - @Override public boolean canRebalance(ShardRouting shardRouting, RoutingAllocation allocation) { + @Override + public boolean canRebalance(ShardRouting shardRouting, RoutingAllocation allocation) { for (AllocationDecider allocation1 : allocations) { if (!allocation1.canRebalance(shardRouting, allocation)) { return false; @@ -65,7 +67,8 @@ public class AllocationDeciders extends AllocationDecider { return true; } - @Override public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) { + @Override + public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) { Decision ret = Decision.YES; // first, check if its in the ignored, if so, return NO if (allocation.shouldIgnoreShardForNode(shardRouting.shardId(), node.nodeId())) { @@ -83,7 +86,8 @@ public class AllocationDeciders extends AllocationDecider { return ret; } - @Override public boolean canRemain(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) { + @Override + public boolean canRemain(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) { if (allocation.shouldIgnoreShardForNode(shardRouting.shardId(), node.nodeId())) { return false; } diff --git a/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/AllocationDecidersModule.java b/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/AllocationDecidersModule.java index 2bece7079e8..9abc94410dc 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/AllocationDecidersModule.java +++ b/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/AllocationDecidersModule.java @@ -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,7 +19,7 @@ package org.elasticsearch.cluster.routing.allocation.decider; -import org.elasticsearch.common.collect.Lists; +import com.google.common.collect.Lists; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.multibindings.Multibinder; import org.elasticsearch.common.settings.Settings; @@ -38,7 +38,8 @@ public class AllocationDecidersModule extends AbstractModule { this.settings = settings; } - @Override protected void configure() { + @Override + protected void configure() { Multibinder allocationMultibinder = Multibinder.newSetBinder(binder(), AllocationDecider.class); allocationMultibinder.addBinding().to(SameShardAllocationDecider.class); allocationMultibinder.addBinding().to(FilterAllocationDecider.class); diff --git a/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/AwarenessAllocationDecider.java b/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/AwarenessAllocationDecider.java index 85ad4248ac8..97c23cb8797 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/AwarenessAllocationDecider.java +++ b/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/AwarenessAllocationDecider.java @@ -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,16 +19,16 @@ package org.elasticsearch.cluster.routing.allocation.decider; +import com.google.common.collect.Maps; +import gnu.trove.map.hash.TObjectIntHashMap; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.routing.MutableShardRouting; import org.elasticsearch.cluster.routing.RoutingNode; import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.cluster.routing.allocation.RoutingAllocation; -import org.elasticsearch.common.collect.Maps; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.trove.map.hash.TObjectIntHashMap; import org.elasticsearch.node.settings.NodeSettingsService; import java.util.HashMap; @@ -46,7 +46,8 @@ public class AwarenessAllocationDecider extends AllocationDecider { } class ApplySettings implements NodeSettingsService.Listener { - @Override public void onRefreshSettings(Settings settings) { + @Override + public void onRefreshSettings(Settings settings) { String[] awarenessAttributes = settings.getAsArray("cluster.routing.allocation.awareness.attributes", null); if (awarenessAttributes != null) { logger.info("updating [cluster.routing.allocation.awareness.attributes] from [{}] to [{}]", AwarenessAllocationDecider.this.awarenessAttributes, awarenessAttributes); @@ -70,7 +71,8 @@ public class AwarenessAllocationDecider extends AllocationDecider { private Map forcedAwarenessAttributes; - @Inject public AwarenessAllocationDecider(Settings settings, NodeSettingsService nodeSettingsService) { + @Inject + public AwarenessAllocationDecider(Settings settings, NodeSettingsService nodeSettingsService) { super(settings); this.awarenessAttributes = settings.getAsArray("cluster.routing.allocation.awareness.attributes"); @@ -90,11 +92,13 @@ public class AwarenessAllocationDecider extends AllocationDecider { return this.awarenessAttributes; } - @Override public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) { + @Override + public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) { return underCapacity(shardRouting, node, allocation, true) ? Decision.YES : Decision.NO; } - @Override public boolean canRemain(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) { + @Override + public boolean canRemain(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) { return underCapacity(shardRouting, node, allocation, false); } diff --git a/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/ClusterRebalanceAllocationDecider.java b/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/ClusterRebalanceAllocationDecider.java index b4dcac950a8..c6ae0530911 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/ClusterRebalanceAllocationDecider.java +++ b/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/ClusterRebalanceAllocationDecider.java @@ -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,7 +38,8 @@ public class ClusterRebalanceAllocationDecider extends AllocationDecider { private final ClusterRebalanceType type; - @Inject public ClusterRebalanceAllocationDecider(Settings settings) { + @Inject + public ClusterRebalanceAllocationDecider(Settings settings) { super(settings); String allowRebalance = settings.get("cluster.routing.allocation.allow_rebalance", "indices_all_active"); if ("always".equalsIgnoreCase(allowRebalance)) { @@ -54,7 +55,8 @@ public class ClusterRebalanceAllocationDecider extends AllocationDecider { logger.debug("using [cluster.routing.allocation.allow_rebalance] with [{}]", type.toString().toLowerCase()); } - @Override public boolean canRebalance(ShardRouting shardRouting, RoutingAllocation allocation) { + @Override + public boolean canRebalance(ShardRouting shardRouting, RoutingAllocation allocation) { if (type == ClusterRebalanceType.INDICES_PRIMARIES_ACTIVE) { for (MutableShardRouting shard : allocation.routingNodes().unassigned()) { if (shard.primary()) { diff --git a/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/ConcurrentRebalanceAllocationDecider.java b/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/ConcurrentRebalanceAllocationDecider.java index 39b29817451..c5ea5728a72 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/ConcurrentRebalanceAllocationDecider.java +++ b/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/ConcurrentRebalanceAllocationDecider.java @@ -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 @@ -40,7 +40,8 @@ public class ConcurrentRebalanceAllocationDecider extends AllocationDecider { } class ApplySettings implements NodeSettingsService.Listener { - @Override public void onRefreshSettings(Settings settings) { + @Override + public void onRefreshSettings(Settings settings) { int clusterConcurrentRebalance = settings.getAsInt("cluster.routing.allocation.cluster_concurrent_rebalance", ConcurrentRebalanceAllocationDecider.this.clusterConcurrentRebalance); if (clusterConcurrentRebalance != ConcurrentRebalanceAllocationDecider.this.clusterConcurrentRebalance) { logger.info("updating [cluster.routing.allocation.cluster_concurrent_rebalance] from [{}], to [{}]", ConcurrentRebalanceAllocationDecider.this.clusterConcurrentRebalance, clusterConcurrentRebalance); @@ -51,14 +52,16 @@ public class ConcurrentRebalanceAllocationDecider extends AllocationDecider { private volatile int clusterConcurrentRebalance; - @Inject public ConcurrentRebalanceAllocationDecider(Settings settings, NodeSettingsService nodeSettingsService) { + @Inject + public ConcurrentRebalanceAllocationDecider(Settings settings, NodeSettingsService nodeSettingsService) { super(settings); this.clusterConcurrentRebalance = settings.getAsInt("cluster.routing.allocation.cluster_concurrent_rebalance", 2); logger.debug("using [cluster_concurrent_rebalance] with [{}]", clusterConcurrentRebalance); nodeSettingsService.addListener(new ApplySettings()); } - @Override public boolean canRebalance(ShardRouting shardRouting, RoutingAllocation allocation) { + @Override + public boolean canRebalance(ShardRouting shardRouting, RoutingAllocation allocation) { if (clusterConcurrentRebalance == -1) { return true; } diff --git a/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/DisableAllocationDecider.java b/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/DisableAllocationDecider.java index 5e6acf73d70..bab249bbf7c 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/DisableAllocationDecider.java +++ b/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/DisableAllocationDecider.java @@ -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 DisableAllocationDecider extends AllocationDecider { } class ApplySettings implements NodeSettingsService.Listener { - @Override public void onRefreshSettings(Settings settings) { + @Override + public void onRefreshSettings(Settings settings) { boolean disableAllocation = settings.getAsBoolean("cluster.routing.allocation.disable_allocation", DisableAllocationDecider.this.disableAllocation); if (disableAllocation != DisableAllocationDecider.this.disableAllocation) { logger.info("updating [cluster.routing.allocation.disable_allocation] from [{}] to [{}]", DisableAllocationDecider.this.disableAllocation, disableAllocation); @@ -57,7 +58,8 @@ public class DisableAllocationDecider extends AllocationDecider { private volatile boolean disableAllocation; private volatile boolean disableReplicaAllocation; - @Inject public DisableAllocationDecider(Settings settings, NodeSettingsService nodeSettingsService) { + @Inject + public DisableAllocationDecider(Settings settings, NodeSettingsService nodeSettingsService) { super(settings); this.disableAllocation = settings.getAsBoolean("cluster.routing.allocation.disable_allocation", false); this.disableReplicaAllocation = settings.getAsBoolean("cluster.routing.allocation.disable_replica_allocation", false); @@ -65,7 +67,8 @@ public class DisableAllocationDecider extends AllocationDecider { nodeSettingsService.addListener(new ApplySettings()); } - @Override public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) { + @Override + public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) { if (disableAllocation) { return Decision.NO; } diff --git a/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/FilterAllocationDecider.java b/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/FilterAllocationDecider.java index 58fd548ece8..487d9829590 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/FilterAllocationDecider.java +++ b/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/FilterAllocationDecider.java @@ -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.cluster.routing.allocation.decider; +import com.google.common.collect.ImmutableMap; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.node.DiscoveryNodeFilters; import org.elasticsearch.cluster.routing.RoutingNode; import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.cluster.routing.allocation.RoutingAllocation; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.node.settings.NodeSettingsService; @@ -48,7 +48,8 @@ public class FilterAllocationDecider extends AllocationDecider { private volatile DiscoveryNodeFilters clusterIncludeFilters; private volatile DiscoveryNodeFilters clusterExcludeFilters; - @Inject public FilterAllocationDecider(Settings settings, NodeSettingsService nodeSettingsService) { + @Inject + public FilterAllocationDecider(Settings settings, NodeSettingsService nodeSettingsService) { super(settings); ImmutableMap includeMap = settings.getByPrefix("cluster.routing.allocation.include.").getAsMap(); if (includeMap.isEmpty()) { @@ -65,11 +66,13 @@ public class FilterAllocationDecider extends AllocationDecider { nodeSettingsService.addListener(new ApplySettings()); } - @Override public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) { + @Override + public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) { return shouldFilter(shardRouting, node, allocation) ? Decision.NO : Decision.YES; } - @Override public boolean canRemain(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) { + @Override + public boolean canRemain(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) { return !shouldFilter(shardRouting, node, allocation); } @@ -101,7 +104,8 @@ public class FilterAllocationDecider extends AllocationDecider { } class ApplySettings implements NodeSettingsService.Listener { - @Override public void onRefreshSettings(Settings settings) { + @Override + public void onRefreshSettings(Settings settings) { ImmutableMap includeMap = settings.getByPrefix("cluster.routing.allocation.include.").getAsMap(); if (!includeMap.isEmpty()) { clusterIncludeFilters = DiscoveryNodeFilters.buildFromKeyValue(includeMap); diff --git a/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/RebalanceOnlyWhenActiveAllocationDecider.java b/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/RebalanceOnlyWhenActiveAllocationDecider.java index 23dc2cd4a32..b581d37b16d 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/RebalanceOnlyWhenActiveAllocationDecider.java +++ b/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/RebalanceOnlyWhenActiveAllocationDecider.java @@ -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,11 +32,13 @@ import java.util.List; */ public class RebalanceOnlyWhenActiveAllocationDecider extends AllocationDecider { - @Inject public RebalanceOnlyWhenActiveAllocationDecider(Settings settings) { + @Inject + public RebalanceOnlyWhenActiveAllocationDecider(Settings settings) { super(settings); } - @Override public boolean canRebalance(ShardRouting shardRouting, RoutingAllocation allocation) { + @Override + public boolean canRebalance(ShardRouting shardRouting, RoutingAllocation allocation) { List shards = allocation.routingNodes().shardsRoutingFor(shardRouting); // its ok to check for active here, since in relocation, a shard is split into two in routing // nodes, once relocating, and one initializing diff --git a/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/ReplicaAfterPrimaryActiveAllocationDecider.java b/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/ReplicaAfterPrimaryActiveAllocationDecider.java index ffdc8ea420b..3914e198be4 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/ReplicaAfterPrimaryActiveAllocationDecider.java +++ b/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/ReplicaAfterPrimaryActiveAllocationDecider.java @@ -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,11 +31,13 @@ import org.elasticsearch.common.settings.Settings; */ public class ReplicaAfterPrimaryActiveAllocationDecider extends AllocationDecider { - @Inject public ReplicaAfterPrimaryActiveAllocationDecider(Settings settings) { + @Inject + public ReplicaAfterPrimaryActiveAllocationDecider(Settings settings) { super(settings); } - @Override public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) { + @Override + public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) { if (shardRouting.primary()) { return Decision.YES; } diff --git a/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/SameShardAllocationDecider.java b/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/SameShardAllocationDecider.java index b8c259c4a6d..1599f9f3100 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/SameShardAllocationDecider.java +++ b/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/SameShardAllocationDecider.java @@ -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,11 +33,13 @@ import java.util.List; */ public class SameShardAllocationDecider extends AllocationDecider { - @Inject public SameShardAllocationDecider(Settings settings) { + @Inject + public SameShardAllocationDecider(Settings settings) { super(settings); } - @Override public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) { + @Override + public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) { List shards = node.shards(); for (int i = 0; i < shards.size(); i++) { // we do not allow for two shards of the same shard id to exists on the same node diff --git a/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/ThrottlingAllocationDecider.java b/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/ThrottlingAllocationDecider.java index ff9b0fa1dad..8f5ee2f567a 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/ThrottlingAllocationDecider.java +++ b/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/ThrottlingAllocationDecider.java @@ -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,8 @@ public class ThrottlingAllocationDecider extends AllocationDecider { private volatile int primariesInitialRecoveries; private volatile int concurrentRecoveries; - @Inject public ThrottlingAllocationDecider(Settings settings, NodeSettingsService nodeSettingsService) { + @Inject + public ThrottlingAllocationDecider(Settings settings, NodeSettingsService nodeSettingsService) { super(settings); this.primariesInitialRecoveries = settings.getAsInt("cluster.routing.allocation.node_initial_primaries_recoveries", settings.getAsInt("cluster.routing.allocation.node_initial_primaries_recoveries", 4)); @@ -55,7 +56,8 @@ public class ThrottlingAllocationDecider extends AllocationDecider { nodeSettingsService.addListener(new ApplySettings()); } - @Override public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) { + @Override + public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) { if (shardRouting.primary()) { boolean primaryUnassigned = false; for (MutableShardRouting shard : allocation.routingNodes().unassigned()) { @@ -102,7 +104,8 @@ public class ThrottlingAllocationDecider extends AllocationDecider { } class ApplySettings implements NodeSettingsService.Listener { - @Override public void onRefreshSettings(Settings settings) { + @Override + public void onRefreshSettings(Settings settings) { int primariesInitialRecoveries = settings.getAsInt("cluster.routing.allocation.node_initial_primaries_recoveries", ThrottlingAllocationDecider.this.primariesInitialRecoveries); if (primariesInitialRecoveries != ThrottlingAllocationDecider.this.primariesInitialRecoveries) { logger.info("updating [cluster.routing.allocation.node_initial_primaries_recoveries] from [{}] to [{}]", ThrottlingAllocationDecider.this.primariesInitialRecoveries, primariesInitialRecoveries); diff --git a/src/main/java/org/elasticsearch/cluster/routing/operation/OperationRouting.java b/src/main/java/org/elasticsearch/cluster/routing/operation/OperationRouting.java index 20602a9699d..1c7d375fdbd 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/operation/OperationRouting.java +++ b/src/main/java/org/elasticsearch/cluster/routing/operation/OperationRouting.java @@ -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.Map; import java.util.Set; /** - * @author kimchy (shay.banon) + * */ public interface OperationRouting { diff --git a/src/main/java/org/elasticsearch/cluster/routing/operation/OperationRoutingModule.java b/src/main/java/org/elasticsearch/cluster/routing/operation/OperationRoutingModule.java index 95eeb106bb4..56dd4e767d0 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/operation/OperationRoutingModule.java +++ b/src/main/java/org/elasticsearch/cluster/routing/operation/OperationRoutingModule.java @@ -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,19 +19,19 @@ package org.elasticsearch.cluster.routing.operation; +import com.google.common.collect.ImmutableList; import org.elasticsearch.cluster.routing.operation.hash.HashFunction; import org.elasticsearch.cluster.routing.operation.hash.djb.DjbHashFunction; import org.elasticsearch.cluster.routing.operation.plain.PlainOperationRoutingModule; -import org.elasticsearch.common.collect.ImmutableList; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.inject.SpawnModules; import org.elasticsearch.common.settings.Settings; -import static org.elasticsearch.common.inject.Modules.*; +import static org.elasticsearch.common.inject.Modules.createModule; /** - * @author kimchy (shay.banon) + * */ public class OperationRoutingModule extends AbstractModule implements SpawnModules { @@ -41,11 +41,13 @@ public class OperationRoutingModule extends AbstractModule implements SpawnModul this.settings = settings; } - @Override public Iterable spawnModules() { + @Override + public Iterable spawnModules() { return ImmutableList.of(createModule(settings.getAsClass("cluster.routing.operation.type", PlainOperationRoutingModule.class, "org.elasticsearch.cluster.routing.operation.", "OperationRoutingModule"), settings)); } - @Override protected void configure() { + @Override + protected void configure() { bind(HashFunction.class).to(settings.getAsClass("cluster.routing.operation.hash.type", DjbHashFunction.class, "org.elasticsearch.cluster.routing.operation.hash.", "HashFunction")).asEagerSingleton(); } } diff --git a/src/main/java/org/elasticsearch/cluster/routing/operation/hash/HashFunction.java b/src/main/java/org/elasticsearch/cluster/routing/operation/hash/HashFunction.java index 13c0b2b34f5..7ce764c1de0 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/operation/hash/HashFunction.java +++ b/src/main/java/org/elasticsearch/cluster/routing/operation/hash/HashFunction.java @@ -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.cluster.routing.operation.hash; /** - * @author kimchy (shay.banon) + * */ public interface HashFunction { diff --git a/src/main/java/org/elasticsearch/cluster/routing/operation/hash/djb/DjbHashFunction.java b/src/main/java/org/elasticsearch/cluster/routing/operation/hash/djb/DjbHashFunction.java index f5a5594383b..11448cb7816 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/operation/hash/djb/DjbHashFunction.java +++ b/src/main/java/org/elasticsearch/cluster/routing/operation/hash/djb/DjbHashFunction.java @@ -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.cluster.routing.operation.hash.djb; import org.elasticsearch.cluster.routing.operation.hash.HashFunction; /** - * @author kimchy (shay.banon) + * */ public class DjbHashFunction implements HashFunction { @@ -36,11 +36,13 @@ public class DjbHashFunction implements HashFunction { return (int) hash; } - @Override public int hash(String routing) { + @Override + public int hash(String routing) { return DJB_HASH(routing); } - @Override public int hash(String type, String id) { + @Override + public int hash(String type, String id) { long hash = 5381; for (int i = 0; i < type.length(); i++) { diff --git a/src/main/java/org/elasticsearch/cluster/routing/operation/hash/simple/SimpleHashFunction.java b/src/main/java/org/elasticsearch/cluster/routing/operation/hash/simple/SimpleHashFunction.java index 00521b829c1..f5fc592659e 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/operation/hash/simple/SimpleHashFunction.java +++ b/src/main/java/org/elasticsearch/cluster/routing/operation/hash/simple/SimpleHashFunction.java @@ -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,15 +22,17 @@ package org.elasticsearch.cluster.routing.operation.hash.simple; import org.elasticsearch.cluster.routing.operation.hash.HashFunction; /** - * @author kimchy (shay.banon) + * */ public class SimpleHashFunction implements HashFunction { - @Override public int hash(String routing) { + @Override + public int hash(String routing) { return routing.hashCode(); } - @Override public int hash(String type, String id) { + @Override + public int hash(String type, String id) { return type.hashCode() + 31 * id.hashCode(); } } diff --git a/src/main/java/org/elasticsearch/cluster/routing/operation/plain/PlainOperationRouting.java b/src/main/java/org/elasticsearch/cluster/routing/operation/plain/PlainOperationRouting.java index 27c62892090..5885c686410 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/operation/plain/PlainOperationRouting.java +++ b/src/main/java/org/elasticsearch/cluster/routing/operation/plain/PlainOperationRouting.java @@ -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 @@ -46,7 +46,7 @@ import java.util.Map; import java.util.Set; /** - * @author kimchy (shay.banon) + * */ public class PlainOperationRouting extends AbstractComponent implements OperationRouting { @@ -56,34 +56,41 @@ public class PlainOperationRouting extends AbstractComponent implements Operatio private final AwarenessAllocationDecider awarenessAllocationDecider; - @Inject public PlainOperationRouting(Settings indexSettings, HashFunction hashFunction, AwarenessAllocationDecider awarenessAllocationDecider) { + @Inject + public PlainOperationRouting(Settings indexSettings, HashFunction hashFunction, AwarenessAllocationDecider awarenessAllocationDecider) { super(indexSettings); this.hashFunction = hashFunction; this.useType = indexSettings.getAsBoolean("cluster.routing.operation.use_type", false); this.awarenessAllocationDecider = awarenessAllocationDecider; } - @Override public ShardIterator indexShards(ClusterState clusterState, String index, String type, String id, @Nullable String routing) throws IndexMissingException, IndexShardMissingException { + @Override + public ShardIterator indexShards(ClusterState clusterState, String index, String type, String id, @Nullable String routing) throws IndexMissingException, IndexShardMissingException { return shards(clusterState, index, type, id, routing).shardsIt(); } - @Override public ShardIterator deleteShards(ClusterState clusterState, String index, String type, String id, @Nullable String routing) throws IndexMissingException, IndexShardMissingException { + @Override + public ShardIterator deleteShards(ClusterState clusterState, String index, String type, String id, @Nullable String routing) throws IndexMissingException, IndexShardMissingException { return shards(clusterState, index, type, id, routing).shardsIt(); } - @Override public ShardIterator getShards(ClusterState clusterState, String index, String type, String id, @Nullable String routing, @Nullable String preference) throws IndexMissingException, IndexShardMissingException { + @Override + public ShardIterator getShards(ClusterState clusterState, String index, String type, String id, @Nullable String routing, @Nullable String preference) throws IndexMissingException, IndexShardMissingException { return preferenceActiveShardIterator(shards(clusterState, index, type, id, routing), clusterState.nodes().localNodeId(), clusterState.nodes(), preference); } - @Override public ShardIterator getShards(ClusterState clusterState, String index, int shardId, @Nullable String preference) throws IndexMissingException, IndexShardMissingException { + @Override + public ShardIterator getShards(ClusterState clusterState, String index, int shardId, @Nullable String preference) throws IndexMissingException, IndexShardMissingException { return preferenceActiveShardIterator(shards(clusterState, index, shardId), clusterState.nodes().localNodeId(), clusterState.nodes(), preference); } - @Override public GroupShardsIterator broadcastDeleteShards(ClusterState clusterState, String index) throws IndexMissingException { + @Override + public GroupShardsIterator broadcastDeleteShards(ClusterState clusterState, String index) throws IndexMissingException { return indexRoutingTable(clusterState, index).groupByShardsIt(); } - @Override public GroupShardsIterator deleteByQueryShards(ClusterState clusterState, String index, @Nullable Set routing) throws IndexMissingException { + @Override + public GroupShardsIterator deleteByQueryShards(ClusterState clusterState, String index, @Nullable Set routing) throws IndexMissingException { if (routing == null || routing.isEmpty()) { return indexRoutingTable(clusterState, index).groupByShardsIt(); } @@ -102,7 +109,8 @@ public class PlainOperationRouting extends AbstractComponent implements Operatio return new GroupShardsIterator(set); } - @Override public int searchShardsCount(ClusterState clusterState, String[] indices, String[] concreteIndices, @Nullable String queryHint, @Nullable Map> routing, @Nullable String preference) throws IndexMissingException { + @Override + public int searchShardsCount(ClusterState clusterState, String[] indices, String[] concreteIndices, @Nullable String queryHint, @Nullable Map> routing, @Nullable String preference) throws IndexMissingException { if (concreteIndices == null || concreteIndices.length == 0) { concreteIndices = clusterState.metaData().concreteAllOpenIndices(); } @@ -135,7 +143,8 @@ public class PlainOperationRouting extends AbstractComponent implements Operatio } } - @Override public GroupShardsIterator searchShards(ClusterState clusterState, String[] indices, String[] concreteIndices, @Nullable String queryHint, @Nullable Map> routing, @Nullable String preference) throws IndexMissingException { + @Override + public GroupShardsIterator searchShards(ClusterState clusterState, String[] indices, String[] concreteIndices, @Nullable String queryHint, @Nullable Map> routing, @Nullable String preference) throws IndexMissingException { if (concreteIndices == null || concreteIndices.length == 0) { concreteIndices = clusterState.metaData().concreteAllOpenIndices(); } diff --git a/src/main/java/org/elasticsearch/cluster/routing/operation/plain/PlainOperationRoutingModule.java b/src/main/java/org/elasticsearch/cluster/routing/operation/plain/PlainOperationRoutingModule.java index dde4129061f..3c377954c8b 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/operation/plain/PlainOperationRoutingModule.java +++ b/src/main/java/org/elasticsearch/cluster/routing/operation/plain/PlainOperationRoutingModule.java @@ -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,11 +23,12 @@ import org.elasticsearch.cluster.routing.operation.OperationRouting; import org.elasticsearch.common.inject.AbstractModule; /** - * @author kimchy (Shay Banon) + * */ public class PlainOperationRoutingModule extends AbstractModule { - @Override protected void configure() { + @Override + protected void configure() { bind(OperationRouting.class).to(PlainOperationRouting.class).asEagerSingleton(); } } diff --git a/src/main/java/org/elasticsearch/cluster/service/InternalClusterService.java b/src/main/java/org/elasticsearch/cluster/service/InternalClusterService.java index 8938d42757c..cfc53b4afd1 100644 --- a/src/main/java/org/elasticsearch/cluster/service/InternalClusterService.java +++ b/src/main/java/org/elasticsearch/cluster/service/InternalClusterService.java @@ -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,15 +19,10 @@ package org.elasticsearch.cluster.service; +import jsr166y.LinkedTransferQueue; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.ElasticSearchIllegalStateException; -import org.elasticsearch.cluster.ClusterChangedEvent; -import org.elasticsearch.cluster.ClusterService; -import org.elasticsearch.cluster.ClusterState; -import org.elasticsearch.cluster.ClusterStateListener; -import org.elasticsearch.cluster.ClusterStateUpdateTask; -import org.elasticsearch.cluster.ProcessedClusterStateUpdateTask; -import org.elasticsearch.cluster.TimeoutClusterStateListener; +import org.elasticsearch.cluster.*; import org.elasticsearch.cluster.block.ClusterBlock; import org.elasticsearch.cluster.block.ClusterBlocks; import org.elasticsearch.cluster.metadata.MetaData; @@ -39,7 +34,6 @@ import org.elasticsearch.common.component.AbstractLifecycleComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; -import org.elasticsearch.common.util.concurrent.jsr166y.LinkedTransferQueue; import org.elasticsearch.discovery.Discovery; import org.elasticsearch.discovery.DiscoveryService; import org.elasticsearch.node.settings.NodeSettingsService; @@ -54,12 +48,13 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; -import static java.util.concurrent.Executors.*; -import static org.elasticsearch.cluster.ClusterState.*; -import static org.elasticsearch.common.util.concurrent.EsExecutors.*; +import static java.util.concurrent.Executors.newSingleThreadExecutor; +import static org.elasticsearch.cluster.ClusterState.Builder; +import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; +import static org.elasticsearch.common.util.concurrent.EsExecutors.daemonThreadFactory; /** - * @author kimchy (shay.banon) + * */ public class InternalClusterService extends AbstractLifecycleComponent implements ClusterService { @@ -89,8 +84,9 @@ public class InternalClusterService extends AbstractLifecycleComponentEncodes and decodes to and from Base64 notation.

*

Homepage: http://iharder.net/base64.

- * + *

*

Example:

- * + *

* String encoded = Base64.encode( myByteArray ); *
* byte[] myByteArray = Base64.decode( encoded ); - * + *

*

The options parameter, which appears in a few places, is used to pass * several pieces of information to the encoder. In the "higher level" methods such as * encodeBytes( bytes, options ) the options parameter can be used to indicate such * things as first gzipping the bytes before encoding them, not inserting linefeeds, * and encoding using the URL-safe and Ordered dialects.

- * + *

*

Note, according to RFC3548, * Section 2.1, implementations should not add line feeds unless explicitly told * to do so. I've got Base64 set to this behavior now, although earlier versions * broke lines by default.

- * + *

*

The constants defined in Base64 can be OR-ed together to combine options, so you * might make a call like this:

- * + *

* String encoded = Base64.encodeBytes( mybytes, Base64.GZIP | Base64.DO_BREAK_LINES ); *

to compress the data before encoding it and then making the output have newline characters.

*

Also...

* String encoded = Base64.encodeBytes( crazyString.getBytes() ); - * - * - * + *

+ *

+ *

*

* Change Log: *

@@ -108,7 +108,7 @@ import java.nio.charset.Charset; * Special thanks to Jim Kellerman at http://www.powerset.com/ * for contributing the new Base64 dialects. * - * + *

*

  • v2.1 - Cleaned up javadoc comments and unused variables and methods. Added * some convenience methods for reading and writing to and from files.
  • *
  • v2.0.2 - Now specifies UTF-8 encoding in places where the code fails on systems @@ -136,7 +136,7 @@ import java.nio.charset.Charset; *
  • v1.3.4 - Fixed when "improperly padded stream" error was thrown at the wrong time.
  • *
  • v1.3.3 - Fixed I/O streams which were totally messed up.
  • * - * + *

    *

    * I am placing this code in the Public Domain. Do with it as you will. * This software comes with no guarantees or warranties but with @@ -616,13 +616,13 @@ public class Base64 { /** * Serializes an object and returns the Base64-encoded * version of that serialized object. - * + *

    *

    As of v 2.3, if the object * cannot be serialized or there is another error, * the method will throw an java.io.IOException. This is new to v2.3! * In earlier versions, it just returned a null value, but * in retrospect that's a pretty poor way to handle it.

    - * + *

    * The object is not GZip-compressed before being encoded. * * @param serializableObject The object to encode @@ -640,22 +640,22 @@ public class Base64 { /** * Serializes an object and returns the Base64-encoded * version of that serialized object. - * + *

    *

    As of v 2.3, if the object * cannot be serialized or there is another error, * the method will throw an java.io.IOException. This is new to v2.3! * In earlier versions, it just returned a null value, but * in retrospect that's a pretty poor way to handle it.

    - * + *

    * The object is not GZip-compressed before being encoded. - *

    + *

    * Example options:

          *   GZIP: gzip-compresses object before encoding it.
          *   DO_BREAK_LINES: break lines at 76 characters
          * 
    - *

    + *

    * Example: encodeObject( myObj, Base64.GZIP ) or - *

    + *

    * Example: encodeObject( myObj, Base64.GZIP | Base64.DO_BREAK_LINES ) * * @param serializableObject The object to encode @@ -760,8 +760,8 @@ public class Base64 { * Example: encodeBytes( myData, Base64.GZIP ) or *

    * Example: encodeBytes( myData, Base64.GZIP | Base64.DO_BREAK_LINES ) - * - * + *

    + *

    *

    As of v 2.3, if there is an error with the GZIP stream, * the method will throw an java.io.IOException. This is new to v2.3! * In earlier versions, it just returned a null value, but @@ -784,7 +784,7 @@ public class Base64 { /** * Encodes a byte array into Base64 notation. * Does not GZip-compress data. - * + *

    *

    As of v 2.3, if there is an error, * the method will throw an java.io.IOException. This is new to v2.3! * In earlier versions, it just returned a null value, but @@ -825,8 +825,8 @@ public class Base64 { * Example: encodeBytes( myData, Base64.GZIP ) or *

    * Example: encodeBytes( myData, Base64.GZIP | Base64.DO_BREAK_LINES ) - * - * + *

    + *

    *

    As of v 2.3, if there is an error with the GZIP stream, * the method will throw an java.io.IOException. This is new to v2.3! * In earlier versions, it just returned a null value, but @@ -1400,7 +1400,7 @@ public class Base64 { /** * Convenience method for encoding data to a file. - * + *

    *

    As of v 2.3, if there is a error, * the method will throw an java.io.IOException. This is new to v2.3! * In earlier versions, it just returned false, but @@ -1440,7 +1440,7 @@ public class Base64 { /** * Convenience method for decoding data to a file. - * + *

    *

    As of v 2.3, if there is a error, * the method will throw an java.io.IOException. This is new to v2.3! * In earlier versions, it just returned false, but @@ -1476,7 +1476,7 @@ public class Base64 { /** * Convenience method for reading a base64-encoded * file and decoding it. - * + *

    *

    As of v 2.3, if there is a error, * the method will throw an java.io.IOException. This is new to v2.3! * In earlier versions, it just returned false, but @@ -1537,7 +1537,7 @@ public class Base64 { /** * Convenience method for reading a binary file * and base64-encoding it. - * + *

    *

    As of v 2.3, if there is a error, * the method will throw an java.io.IOException. This is new to v2.3! * In earlier versions, it just returned false, but @@ -1611,8 +1611,7 @@ public class Base64 { finally { try { out.close(); - } - catch (Exception ex) { + } catch (Exception ex) { } } // end finally } // end encodeFileToFile @@ -1642,8 +1641,7 @@ public class Base64 { finally { try { out.close(); - } - catch (Exception ex) { + } catch (Exception ex) { } } // end finally } // end decodeFileToFile @@ -1687,13 +1685,13 @@ public class Base64 { /** * Constructs a {@link Base64.InputStream} in * either ENCODE or DECODE mode. - *

    + *

    * Valid options:

              *   ENCODE or DECODE: Encode or Decode as data is read.
              *   DO_BREAK_LINES: break lines at 76 characters
              *     (only meaningful when encoding)
              * 
    - *

    + *

    * Example: new Base64.InputStream( in, Base64.DECODE ) * * @param in the java.io.InputStream from which to read data. @@ -1894,13 +1892,13 @@ public class Base64 { /** * Constructs a {@link Base64.OutputStream} in * either ENCODE or DECODE mode. - *

    + *

    * Valid options:

              *   ENCODE or DECODE: Encode or Decode as data is read.
              *   DO_BREAK_LINES: don't break lines at 76 characters
              *     (only meaningful when encoding)
              * 
    - *

    + *

    * Example: new Base64.OutputStream( out, Base64.ENCODE ) * * @param out the java.io.OutputStream to which data will be written. diff --git a/src/main/java/org/elasticsearch/common/Booleans.java b/src/main/java/org/elasticsearch/common/Booleans.java index dfa319a3fed..a2f87bc0d0d 100644 --- a/src/main/java/org/elasticsearch/common/Booleans.java +++ b/src/main/java/org/elasticsearch/common/Booleans.java @@ -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.common; /** - * @author kimchy (shay.banon) + * */ public class Booleans { diff --git a/src/main/java/org/elasticsearch/common/Bytes.java b/src/main/java/org/elasticsearch/common/Bytes.java index 932d6386af0..3324dcc8d59 100644 --- a/src/main/java/org/elasticsearch/common/Bytes.java +++ b/src/main/java/org/elasticsearch/common/Bytes.java @@ -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.common; /** - * @author kimchy (shay.banon) + * */ public class Bytes { @@ -110,7 +110,7 @@ public class Bytes { // Fall thru to fast mode for smaller numbers // assert(i <= 65536, i); - for (; ;) { + for (; ; ) { q = (i * 52429) >>> (16 + 3); r = i - ((q << 3) + (q << 1)); // r = i-(q*10) ... buf[--charPos] = digits[r]; @@ -181,7 +181,7 @@ public class Bytes { * the buffer backwards starting with the least significant * digit at the specified index (exclusive), and working * backwards from there. - * + *

    * Will fail if i == Long.MIN_VALUE */ static void getChars(long i, int index, byte[] buf) { @@ -219,7 +219,7 @@ public class Bytes { // Fall thru to fast mode for smaller numbers // assert(i2 <= 65536, i2); - for (; ;) { + for (; ; ) { q2 = (i2 * 52429) >>> (16 + 3); r = i2 - ((q2 << 3) + (q2 << 1)); // r = i2-(q2*10) ... buf[--charPos] = digits[r]; diff --git a/src/main/java/org/elasticsearch/common/BytesHolder.java b/src/main/java/org/elasticsearch/common/BytesHolder.java index 84299f545bd..ef646392bb6 100644 --- a/src/main/java/org/elasticsearch/common/BytesHolder.java +++ b/src/main/java/org/elasticsearch/common/BytesHolder.java @@ -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 @@ -70,19 +70,22 @@ public class BytesHolder implements Streamable { return holder; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { offset = 0; length = in.readVInt(); bytes = new byte[length]; in.readFully(bytes); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeVInt(length); out.writeBytes(bytes, offset, length); } - @Override public boolean equals(Object obj) { + @Override + public boolean equals(Object obj) { return bytesEquals((BytesHolder) obj); } diff --git a/src/main/java/org/elasticsearch/common/BytesWrap.java b/src/main/java/org/elasticsearch/common/BytesWrap.java index 7ffb9ed42da..1423d23a725 100644 --- a/src/main/java/org/elasticsearch/common/BytesWrap.java +++ b/src/main/java/org/elasticsearch/common/BytesWrap.java @@ -22,7 +22,7 @@ package org.elasticsearch.common; import java.util.Arrays; /** - * @author kimchy (shay.banon) + * */ public class BytesWrap { @@ -48,13 +48,15 @@ public class BytesWrap { return Unicode.fromBytes(bytes); } - @Override public boolean equals(Object o) { + @Override + public boolean equals(Object o) { if (this == o) return true; BytesWrap bytesWrap = (BytesWrap) o; return Arrays.equals(bytes, bytesWrap.bytes); } - @Override public int hashCode() { + @Override + public int hashCode() { return hashCode; } } diff --git a/src/main/java/org/elasticsearch/common/CacheRecycler.java b/src/main/java/org/elasticsearch/common/CacheRecycler.java index 1326d794ff5..ef65615b634 100644 --- a/src/main/java/org/elasticsearch/common/CacheRecycler.java +++ b/src/main/java/org/elasticsearch/common/CacheRecycler.java @@ -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.elasticsearch.common; +import gnu.trove.ExtTDoubleObjectHashMap; +import gnu.trove.ExtTHashMap; +import gnu.trove.ExtTLongObjectHashMap; +import gnu.trove.map.hash.*; +import jsr166y.LinkedTransferQueue; import org.elasticsearch.common.compress.lzf.BufferRecycler; -import org.elasticsearch.common.trove.ExtTDoubleObjectHashMap; -import org.elasticsearch.common.trove.ExtTHashMap; -import org.elasticsearch.common.trove.ExtTLongObjectHashMap; -import org.elasticsearch.common.trove.map.hash.*; -import org.elasticsearch.common.util.concurrent.jsr166y.LinkedTransferQueue; import java.lang.ref.SoftReference; import java.util.Arrays; diff --git a/src/main/java/org/elasticsearch/common/Classes.java b/src/main/java/org/elasticsearch/common/Classes.java index c4a6c4a6705..6004ffcfb66 100644 --- a/src/main/java/org/elasticsearch/common/Classes.java +++ b/src/main/java/org/elasticsearch/common/Classes.java @@ -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.common; import java.lang.reflect.Modifier; /** - * @author kimchy (Shay Banon) + * */ public class Classes { @@ -49,8 +49,7 @@ public class Classes { ClassLoader cl = null; try { cl = Thread.currentThread().getContextClassLoader(); - } - catch (Throwable ex) { + } catch (Throwable ex) { // Cannot access thread context ClassLoader - falling back to system class loader... } if (cl == null) { diff --git a/src/main/java/org/elasticsearch/common/Digest.java b/src/main/java/org/elasticsearch/common/Digest.java index 19f847207e7..b5a0d937849 100644 --- a/src/main/java/org/elasticsearch/common/Digest.java +++ b/src/main/java/org/elasticsearch/common/Digest.java @@ -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.security.MessageDigest; import java.security.NoSuchAlgorithmException; /** - * @author kimchy (shay.banon) + * */ public class Digest { @@ -540,17 +540,21 @@ public class Digest { super(algorithm); } - @Override protected void engineUpdate(byte input) { + @Override + protected void engineUpdate(byte input) { } - @Override protected void engineUpdate(byte[] input, int offset, int len) { + @Override + protected void engineUpdate(byte[] input, int offset, int len) { } - @Override protected byte[] engineDigest() { + @Override + protected byte[] engineDigest() { return null; } - @Override protected void engineReset() { + @Override + protected void engineReset() { } } } diff --git a/src/main/java/org/elasticsearch/common/Hex.java b/src/main/java/org/elasticsearch/common/Hex.java index cdbf2b695f0..7c737ac5966 100644 --- a/src/main/java/org/elasticsearch/common/Hex.java +++ b/src/main/java/org/elasticsearch/common/Hex.java @@ -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.common; import org.elasticsearch.ElasticSearchIllegalStateException; /** - * @author kimchy (shay.banon) + * */ public class Hex { diff --git a/src/main/java/org/elasticsearch/common/Names.java b/src/main/java/org/elasticsearch/common/Names.java index e601b6acc5a..7753424cda8 100644 --- a/src/main/java/org/elasticsearch/common/Names.java +++ b/src/main/java/org/elasticsearch/common/Names.java @@ -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,7 +19,7 @@ package org.elasticsearch.common; -import org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom; +import jsr166y.ThreadLocalRandom; import java.io.BufferedReader; import java.io.IOException; @@ -29,7 +29,7 @@ import java.net.URL; import java.util.Random; /** - * @author kimchy (Shay Banon) + * */ public abstract class Names { diff --git a/src/main/java/org/elasticsearch/common/Nullable.java b/src/main/java/org/elasticsearch/common/Nullable.java index 19a899f1e17..6a83d0175f7 100644 --- a/src/main/java/org/elasticsearch/common/Nullable.java +++ b/src/main/java/org/elasticsearch/common/Nullable.java @@ -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.lang.annotation.*; * {@code null} is an acceptable value for that parameter. It should not be * used for parameters of primitive types. * - * @author kimchy (Shay Banon) + * */ @Documented @Retention(RetentionPolicy.RUNTIME) diff --git a/src/main/java/org/elasticsearch/common/Numbers.java b/src/main/java/org/elasticsearch/common/Numbers.java index 832fbede18d..8a8b7ee03b6 100644 --- a/src/main/java/org/elasticsearch/common/Numbers.java +++ b/src/main/java/org/elasticsearch/common/Numbers.java @@ -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.common; /** * A set of utlities around numbers. * - * @author kimchy (Shay Banon) + * */ public final class Numbers { diff --git a/src/main/java/org/elasticsearch/common/Preconditions.java b/src/main/java/org/elasticsearch/common/Preconditions.java index b6438f5131d..1af4b4bf4d9 100644 --- a/src/main/java/org/elasticsearch/common/Preconditions.java +++ b/src/main/java/org/elasticsearch/common/Preconditions.java @@ -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,16 +33,16 @@ import java.util.NoSuchElementException; * if (count <= 0) { * throw new ElasticSearchIllegalArgumentException("must be positive: " + count); * } - *

    + * * to be replaced with the more compact *

      *     checkArgument(count > 0, "must be positive: %s", count);
    - *

    + * * Note that the sense of the expression is inverted; with {@code Preconditions} * you declare what you expect to be true, just as you do with an * * {@code assert} or a JUnit {@code assertTrue()} call. - *

    + * *

    Take care not to confuse precondition checking with other similar types * of checks! Precondition exceptions -- including those provided here, but also * {@link IndexOutOfBoundsException}, {@link NoSuchElementException}, {@link @@ -51,7 +51,7 @@ import java.util.NoSuchElementException; * not have invoked the method when it did, with the arguments it did, or * perhaps ever. Postcondition or other invariant failures should not * throw these types of exceptions. - *

    + * *

    Note: The methods of the {@code Preconditions} class are highly * unusual in one way: they are supposed to throw exceptions, and promise * in their specifications to do so even when given perfectly valid input. That @@ -60,7 +60,7 @@ import java.util.NoSuchElementException; * as Nullable -- yet the method will still throw an exception anyway, * because that's what its contract says to do. * - * @author kimchy (Shay Banon) + * */ public final class Preconditions { private Preconditions() { diff --git a/src/main/java/org/elasticsearch/common/RamUsage.java b/src/main/java/org/elasticsearch/common/RamUsage.java index a2c618b66e1..97bafa4afe5 100644 --- a/src/main/java/org/elasticsearch/common/RamUsage.java +++ b/src/main/java/org/elasticsearch/common/RamUsage.java @@ -20,7 +20,7 @@ package org.elasticsearch.common; /** - * @author kimchy (shay.banon) + * */ public class RamUsage { diff --git a/src/main/java/org/elasticsearch/common/RandomStringGenerator.java b/src/main/java/org/elasticsearch/common/RandomStringGenerator.java index 317f765d87d..4834ccba360 100644 --- a/src/main/java/org/elasticsearch/common/RandomStringGenerator.java +++ b/src/main/java/org/elasticsearch/common/RandomStringGenerator.java @@ -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,7 +19,7 @@ package org.elasticsearch.common; -import org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom; +import jsr166y.ThreadLocalRandom; import java.util.Random; @@ -29,7 +29,7 @@ public class RandomStringGenerator { *

    RandomStringUtils instances should NOT be constructed in * standard programming. Instead, the class should be used as * RandomStringUtils.random(5);.

    - * + *

    *

    This constructor is public to permit tools that require a JavaBean instance * to operate.

    */ @@ -43,7 +43,7 @@ public class RandomStringGenerator { /** *

    Creates a random string whose length is the number of characters * specified.

    - * + *

    *

    Characters will be chosen from the set of all characters.

    * * @param count the length of random string to create @@ -56,7 +56,7 @@ public class RandomStringGenerator { /** *

    Creates a random string whose length is the number of characters * specified.

    - * + *

    *

    Characters will be chosen from the set of characters whose * ASCII value is between 32 and 126 (inclusive).

    * @@ -70,7 +70,7 @@ public class RandomStringGenerator { /** *

    Creates a random string whose length is the number of characters * specified.

    - * + *

    *

    Characters will be chosen from the set of alphabetic * characters.

    * @@ -84,7 +84,7 @@ public class RandomStringGenerator { /** *

    Creates a random string whose length is the number of characters * specified.

    - * + *

    *

    Characters will be chosen from the set of alpha-numeric * characters.

    * @@ -98,7 +98,7 @@ public class RandomStringGenerator { /** *

    Creates a random string whose length is the number of characters * specified.

    - * + *

    *

    Characters will be chosen from the set of numeric * characters.

    * @@ -112,7 +112,7 @@ public class RandomStringGenerator { /** *

    Creates a random string whose length is the number of characters * specified.

    - * + *

    *

    Characters will be chosen from the set of alpha-numeric * characters as indicated by the arguments.

    * @@ -130,7 +130,7 @@ public class RandomStringGenerator { /** *

    Creates a random string whose length is the number of characters * specified.

    - * + *

    *

    Characters will be chosen from the set of alpha-numeric * characters as indicated by the arguments.

    * @@ -150,7 +150,7 @@ public class RandomStringGenerator { /** *

    Creates a random string based on a variety of options, using * default source of randomness.

    - * + *

    *

    This method has exactly the same semantics as * {@link #random(int, int, int, boolean, boolean, char[], Random)}, but * instead of using an externally supplied source of randomness, it uses @@ -174,16 +174,16 @@ public class RandomStringGenerator { /** *

    Creates a random string based on a variety of options, using * supplied source of randomness.

    - * + *

    *

    If start and end are both 0, start and end are set * to ' ' and 'z', the ASCII printable * characters, will be used, unless letters and numbers are both * false, in which case, start and end are set to * 0 and Integer.MAX_VALUE. - * + *

    *

    If set is not null, characters between start and * end are chosen.

    - * + *

    *

    This method accepts a user-supplied {@link Random} * instance to use as a source of randomness. By seeding a single * {@link Random} instance with a fixed seed and using it for each call, @@ -267,7 +267,7 @@ public class RandomStringGenerator { /** *

    Creates a random string whose length is the number of characters * specified.

    - * + *

    *

    Characters will be chosen from the set of characters * specified.

    * @@ -287,7 +287,7 @@ public class RandomStringGenerator { /** *

    Creates a random string whose length is the number of characters * specified.

    - * + *

    *

    Characters will be chosen from the set of characters specified.

    * * @param count the length of random string to create diff --git a/src/main/java/org/elasticsearch/common/RateLimiter.java b/src/main/java/org/elasticsearch/common/RateLimiter.java index 64b2d31421d..b6f3fde6d85 100644 --- a/src/main/java/org/elasticsearch/common/RateLimiter.java +++ b/src/main/java/org/elasticsearch/common/RateLimiter.java @@ -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 diff --git a/src/main/java/org/elasticsearch/common/Required.java b/src/main/java/org/elasticsearch/common/Required.java index 39ca9d6be94..c28807c8933 100644 --- a/src/main/java/org/elasticsearch/common/Required.java +++ b/src/main/java/org/elasticsearch/common/Required.java @@ -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.lang.annotation.*; * {@code null} is an acceptable value for that parameter. It should not be * used for parameters of primitive types. * - * @author kimchy (Shay Banon) + * */ @Documented @Retention(RetentionPolicy.RUNTIME) diff --git a/src/main/java/org/elasticsearch/common/StopWatch.java b/src/main/java/org/elasticsearch/common/StopWatch.java index 3b4e61e6293..4592ae278c8 100644 --- a/src/main/java/org/elasticsearch/common/StopWatch.java +++ b/src/main/java/org/elasticsearch/common/StopWatch.java @@ -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,7 @@ import java.util.concurrent.TimeUnit; *

    This class is normally used to verify performance during proof-of-concepts * and in development, rather than as part of production applications. * - * @author kimchy (Shay Banon) + * */ public class StopWatch { @@ -247,7 +247,8 @@ public class StopWatch { * Return an informative string describing all tasks performed * For custom reporting, call getTaskInfo() and use the task info directly. */ - @Override public String toString() { + @Override + public String toString() { StringBuilder sb = new StringBuilder(shortSummary()); if (this.keepTaskList) { for (TaskInfo task : taskInfo()) { diff --git a/src/main/java/org/elasticsearch/common/Strings.java b/src/main/java/org/elasticsearch/common/Strings.java index 85dd0988325..c1a2e70708b 100644 --- a/src/main/java/org/elasticsearch/common/Strings.java +++ b/src/main/java/org/elasticsearch/common/Strings.java @@ -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,14 +19,14 @@ package org.elasticsearch.common; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.collect.Iterables; -import org.elasticsearch.common.trove.set.hash.THashSet; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; +import gnu.trove.set.hash.THashSet; import java.util.*; /** - * @author kimchy (Shay Banon) + * */ public class Strings { @@ -45,7 +45,7 @@ public class Strings { /** * Splits a backslash escaped string on the separator. - *

    + *

    * Current backslash escaping supported: *
    \n \t \r \b \f are escaped the same as a Java String *
    Other characters following a backslash are produced verbatim (\c => c) diff --git a/src/main/java/org/elasticsearch/common/UUID.java b/src/main/java/org/elasticsearch/common/UUID.java index 4c955e7edee..8be5ec78975 100644 --- a/src/main/java/org/elasticsearch/common/UUID.java +++ b/src/main/java/org/elasticsearch/common/UUID.java @@ -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.security.SecureRandom; /** * A UUID taken from java UUID that simply holds less data. * - * @author kimchy (Shay Banon) + * */ public class UUID implements Comparable { @@ -87,7 +87,7 @@ public class UUID implements Comparable { /** * Static factory to retrieve a type 4 (pseudo randomly generated) UUID. - * + *

    * The UUID is generated using a cryptographically strong * pseudo random number generator. * @@ -210,7 +210,7 @@ public class UUID implements Comparable { /** * Returns a String object representing this * UUID. - * + *

    *

    The UUID string representation is as described by this BNF : *

          * {@code
    @@ -282,7 +282,7 @@ public class UUID implements Comparable {
     
         /**
          * Compares this UUID with the specified UUID.
    -     *
    +     * 

    *

    The first of two UUIDs follows the second if the most significant * field in which the UUIDs differ is greater for the first UUID. * diff --git a/src/main/java/org/elasticsearch/common/Unicode.java b/src/main/java/org/elasticsearch/common/Unicode.java index 79317370b99..800149d20fa 100644 --- a/src/main/java/org/elasticsearch/common/Unicode.java +++ b/src/main/java/org/elasticsearch/common/Unicode.java @@ -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,18 +25,20 @@ import org.elasticsearch.common.thread.ThreadLocals; import java.util.Arrays; /** - * @author kimchy (shay.banon) + * */ public class Unicode { private static ThreadLocal> cachedUtf8Result = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { return new ThreadLocals.CleanableValue(new UnicodeUtil.UTF8Result()); } }; private static ThreadLocal> cachedUtf16Result = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { return new ThreadLocals.CleanableValue(new UTF16Result()); } }; @@ -112,7 +114,7 @@ public class Unicode { public static final class UTF16Result { public char[] result = new char[10]; -// public int[] offsets = new int[10]; + // public int[] offsets = new int[10]; public int length; public void setLength(int newLength) { diff --git a/src/main/java/org/elasticsearch/common/blobstore/BlobContainer.java b/src/main/java/org/elasticsearch/common/blobstore/BlobContainer.java index 4b2acc8bc64..10ca78b44c1 100644 --- a/src/main/java/org/elasticsearch/common/blobstore/BlobContainer.java +++ b/src/main/java/org/elasticsearch/common/blobstore/BlobContainer.java @@ -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.elasticsearch.common.blobstore; -import org.elasticsearch.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMap; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public interface BlobContainer { diff --git a/src/main/java/org/elasticsearch/common/blobstore/BlobMetaData.java b/src/main/java/org/elasticsearch/common/blobstore/BlobMetaData.java index 4d6e41379ef..2180f5515df 100644 --- a/src/main/java/org/elasticsearch/common/blobstore/BlobMetaData.java +++ b/src/main/java/org/elasticsearch/common/blobstore/BlobMetaData.java @@ -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.common.blobstore; /** - * @author kimchy (shay.banon) + * */ public interface BlobMetaData { diff --git a/src/main/java/org/elasticsearch/common/blobstore/BlobPath.java b/src/main/java/org/elasticsearch/common/blobstore/BlobPath.java index c31cacd4226..deeddfdaec2 100644 --- a/src/main/java/org/elasticsearch/common/blobstore/BlobPath.java +++ b/src/main/java/org/elasticsearch/common/blobstore/BlobPath.java @@ -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.elasticsearch.common.blobstore; -import org.elasticsearch.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList; import java.util.Iterator; /** - * @author kimchy (shay.banon) + * */ public class BlobPath implements Iterable { @@ -42,7 +42,8 @@ public class BlobPath implements Iterable { this.paths = paths; } - @Override public Iterator iterator() { + @Override + public Iterator iterator() { return paths.iterator(); } @@ -66,7 +67,8 @@ public class BlobPath implements Iterable { return sb.toString(); } - @Override public String toString() { + @Override + public String toString() { StringBuilder sb = new StringBuilder(); for (String path : paths) { sb.append('[').append(path).append(']'); diff --git a/src/main/java/org/elasticsearch/common/blobstore/BlobStore.java b/src/main/java/org/elasticsearch/common/blobstore/BlobStore.java index 4ac7927e4f8..6599b667694 100644 --- a/src/main/java/org/elasticsearch/common/blobstore/BlobStore.java +++ b/src/main/java/org/elasticsearch/common/blobstore/BlobStore.java @@ -1,7 +1,7 @@ package org.elasticsearch.common.blobstore; /** - * @author kimchy (shay.banon) + * */ public interface BlobStore { diff --git a/src/main/java/org/elasticsearch/common/blobstore/BlobStoreException.java b/src/main/java/org/elasticsearch/common/blobstore/BlobStoreException.java index f100f356f66..380076a8446 100644 --- a/src/main/java/org/elasticsearch/common/blobstore/BlobStoreException.java +++ b/src/main/java/org/elasticsearch/common/blobstore/BlobStoreException.java @@ -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.common.blobstore; import org.elasticsearch.ElasticSearchException; /** - * @author kimchy (shay.banon) + * */ public class BlobStoreException extends ElasticSearchException { diff --git a/src/main/java/org/elasticsearch/common/blobstore/ImmutableBlobContainer.java b/src/main/java/org/elasticsearch/common/blobstore/ImmutableBlobContainer.java index 63b0fa70cec..406cae08122 100644 --- a/src/main/java/org/elasticsearch/common/blobstore/ImmutableBlobContainer.java +++ b/src/main/java/org/elasticsearch/common/blobstore/ImmutableBlobContainer.java @@ -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 java.io.IOException; import java.io.InputStream; /** - * @author kimchy (shay.banon) + * */ public interface ImmutableBlobContainer extends BlobContainer { diff --git a/src/main/java/org/elasticsearch/common/blobstore/fs/AbstractFsBlobContainer.java b/src/main/java/org/elasticsearch/common/blobstore/fs/AbstractFsBlobContainer.java index c5c7df10ece..bf42a297a8f 100644 --- a/src/main/java/org/elasticsearch/common/blobstore/fs/AbstractFsBlobContainer.java +++ b/src/main/java/org/elasticsearch/common/blobstore/fs/AbstractFsBlobContainer.java @@ -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.common.blobstore.fs; +import com.google.common.collect.ImmutableMap; +import com.google.common.io.Closeables; import org.elasticsearch.common.blobstore.BlobMetaData; import org.elasticsearch.common.blobstore.BlobPath; import org.elasticsearch.common.blobstore.support.AbstractBlobContainer; import org.elasticsearch.common.blobstore.support.PlainBlobMetaData; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.collect.MapBuilder; -import org.elasticsearch.common.io.Closeables; import java.io.File; import java.io.FileInputStream; @@ -33,7 +33,7 @@ import java.io.FileNotFoundException; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public abstract class AbstractFsBlobContainer extends AbstractBlobContainer { @@ -70,13 +70,16 @@ public abstract class AbstractFsBlobContainer extends AbstractBlobContainer { return new File(path, blobName).delete(); } - @Override public boolean blobExists(String blobName) { + @Override + public boolean blobExists(String blobName) { return new File(path, blobName).exists(); } - @Override public void readBlob(final String blobName, final ReadBlobListener listener) { + @Override + public void readBlob(final String blobName, final ReadBlobListener listener) { blobStore.executor().execute(new Runnable() { - @Override public void run() { + @Override + public void run() { byte[] buffer = new byte[blobStore.bufferSizeInBytes()]; FileInputStream is = null; try { diff --git a/src/main/java/org/elasticsearch/common/blobstore/fs/FsBlobStore.java b/src/main/java/org/elasticsearch/common/blobstore/fs/FsBlobStore.java index 951d5e132d8..c75ce0ff321 100644 --- a/src/main/java/org/elasticsearch/common/blobstore/fs/FsBlobStore.java +++ b/src/main/java/org/elasticsearch/common/blobstore/fs/FsBlobStore.java @@ -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,7 +33,7 @@ import java.io.File; import java.util.concurrent.Executor; /** - * @author kimchy (shay.banon) + * */ public class FsBlobStore extends AbstractComponent implements BlobStore { @@ -59,7 +59,8 @@ public class FsBlobStore extends AbstractComponent implements BlobStore { this.executor = executor; } - @Override public String toString() { + @Override + public String toString() { return path.toString(); } @@ -75,15 +76,18 @@ public class FsBlobStore extends AbstractComponent implements BlobStore { return executor; } - @Override public ImmutableBlobContainer immutableBlobContainer(BlobPath path) { + @Override + public ImmutableBlobContainer immutableBlobContainer(BlobPath path) { return new FsImmutableBlobContainer(this, path, buildAndCreate(path)); } - @Override public void delete(BlobPath path) { + @Override + public void delete(BlobPath path) { FileSystemUtils.deleteRecursively(buildPath(path)); } - @Override public void close() { + @Override + public void close() { // nothing to do here... } diff --git a/src/main/java/org/elasticsearch/common/blobstore/fs/FsImmutableBlobContainer.java b/src/main/java/org/elasticsearch/common/blobstore/fs/FsImmutableBlobContainer.java index 99c5df8de84..a2d9bda8880 100644 --- a/src/main/java/org/elasticsearch/common/blobstore/fs/FsImmutableBlobContainer.java +++ b/src/main/java/org/elasticsearch/common/blobstore/fs/FsImmutableBlobContainer.java @@ -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,7 +31,7 @@ import java.io.InputStream; import java.io.RandomAccessFile; /** - * @author kimchy (shay.banon) + * */ public class FsImmutableBlobContainer extends AbstractFsBlobContainer implements ImmutableBlobContainer { @@ -39,9 +39,11 @@ public class FsImmutableBlobContainer extends AbstractFsBlobContainer implements super(blobStore, blobPath, path); } - @Override public void writeBlob(final String blobName, final InputStream is, final long sizeInBytes, final WriterListener listener) { + @Override + public void writeBlob(final String blobName, final InputStream is, final long sizeInBytes, final WriterListener listener) { blobStore.executor().execute(new Runnable() { - @Override public void run() { + @Override + public void run() { File file = new File(path, blobName); RandomAccessFile raf; try { @@ -94,7 +96,8 @@ public class FsImmutableBlobContainer extends AbstractFsBlobContainer implements }); } - @Override public void writeBlob(String blobName, InputStream is, long sizeInBytes) throws IOException { + @Override + public void writeBlob(String blobName, InputStream is, long sizeInBytes) throws IOException { BlobStores.syncWriteBlob(this, blobName, is, sizeInBytes); } } diff --git a/src/main/java/org/elasticsearch/common/blobstore/support/AbstractBlobContainer.java b/src/main/java/org/elasticsearch/common/blobstore/support/AbstractBlobContainer.java index 9cfebd58949..2599a27961e 100644 --- a/src/main/java/org/elasticsearch/common/blobstore/support/AbstractBlobContainer.java +++ b/src/main/java/org/elasticsearch/common/blobstore/support/AbstractBlobContainer.java @@ -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.common.blobstore.support; +import com.google.common.collect.ImmutableMap; import org.elasticsearch.common.blobstore.BlobContainer; import org.elasticsearch.common.blobstore.BlobMetaData; import org.elasticsearch.common.blobstore.BlobPath; -import org.elasticsearch.common.collect.ImmutableMap; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -31,7 +31,7 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicReference; /** - * @author kimchy (shay.banon) + * */ public abstract class AbstractBlobContainer implements BlobContainer { @@ -41,25 +41,30 @@ public abstract class AbstractBlobContainer implements BlobContainer { this.path = path; } - @Override public BlobPath path() { + @Override + public BlobPath path() { return this.path; } - @Override public byte[] readBlobFully(String blobName) throws IOException { + @Override + public byte[] readBlobFully(String blobName) throws IOException { final CountDownLatch latch = new CountDownLatch(1); final AtomicReference failure = new AtomicReference(); final ByteArrayOutputStream bos = new ByteArrayOutputStream(); readBlob(blobName, new ReadBlobListener() { - @Override public void onPartial(byte[] data, int offset, int size) { + @Override + public void onPartial(byte[] data, int offset, int size) { bos.write(data, offset, size); } - @Override public void onCompleted() { + @Override + public void onCompleted() { latch.countDown(); } - @Override public void onFailure(Throwable t) { + @Override + public void onFailure(Throwable t) { failure.set(t); latch.countDown(); } @@ -81,7 +86,8 @@ public abstract class AbstractBlobContainer implements BlobContainer { return bos.toByteArray(); } - @Override public ImmutableMap listBlobsByPrefix(String blobNamePrefix) throws IOException { + @Override + public ImmutableMap listBlobsByPrefix(String blobNamePrefix) throws IOException { ImmutableMap allBlobs = listBlobs(); ImmutableMap.Builder blobs = ImmutableMap.builder(); for (BlobMetaData blob : allBlobs.values()) { @@ -92,15 +98,18 @@ public abstract class AbstractBlobContainer implements BlobContainer { return blobs.build(); } - @Override public void deleteBlobsByPrefix(final String blobNamePrefix) throws IOException { + @Override + public void deleteBlobsByPrefix(final String blobNamePrefix) throws IOException { deleteBlobsByFilter(new BlobNameFilter() { - @Override public boolean accept(String blobName) { + @Override + public boolean accept(String blobName) { return blobName.startsWith(blobNamePrefix); } }); } - @Override public void deleteBlobsByFilter(BlobNameFilter filter) throws IOException { + @Override + public void deleteBlobsByFilter(BlobNameFilter filter) throws IOException { ImmutableMap blobs = listBlobs(); for (BlobMetaData blob : blobs.values()) { if (filter.accept(blob.name())) { diff --git a/src/main/java/org/elasticsearch/common/blobstore/support/BlobStores.java b/src/main/java/org/elasticsearch/common/blobstore/support/BlobStores.java index d8ba888fe7e..ce770fbc539 100644 --- a/src/main/java/org/elasticsearch/common/blobstore/support/BlobStores.java +++ b/src/main/java/org/elasticsearch/common/blobstore/support/BlobStores.java @@ -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.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicReference; /** - * @author kimchy (shay.banon) + * */ public class BlobStores { @@ -36,11 +36,13 @@ public class BlobStores { final CountDownLatch latch = new CountDownLatch(1); final AtomicReference failure = new AtomicReference(); blobContainer.writeBlob(blobName, is, sizeInBytes, new ImmutableBlobContainer.WriterListener() { - @Override public void onCompleted() { + @Override + public void onCompleted() { latch.countDown(); } - @Override public void onFailure(Throwable t) { + @Override + public void onFailure(Throwable t) { failure.set(t); latch.countDown(); } diff --git a/src/main/java/org/elasticsearch/common/blobstore/support/PlainBlobMetaData.java b/src/main/java/org/elasticsearch/common/blobstore/support/PlainBlobMetaData.java index 65e59c2b5b1..8b8864a45bd 100644 --- a/src/main/java/org/elasticsearch/common/blobstore/support/PlainBlobMetaData.java +++ b/src/main/java/org/elasticsearch/common/blobstore/support/PlainBlobMetaData.java @@ -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.common.blobstore.support; import org.elasticsearch.common.blobstore.BlobMetaData; /** - * @author kimchy (shay.banon) + * */ public class PlainBlobMetaData implements BlobMetaData { @@ -35,15 +35,18 @@ public class PlainBlobMetaData implements BlobMetaData { this.length = length; } - @Override public String name() { + @Override + public String name() { return this.name; } - @Override public long length() { + @Override + public long length() { return this.length; } - @Override public String toString() { + @Override + public String toString() { return "name [" + name + "], length [" + length + "]"; } } diff --git a/src/main/java/org/elasticsearch/common/bloom/BloomCalculations.java b/src/main/java/org/elasticsearch/common/bloom/BloomCalculations.java index 02f21ff3fcc..1cde133deaf 100644 --- a/src/main/java/org/elasticsearch/common/bloom/BloomCalculations.java +++ b/src/main/java/org/elasticsearch/common/bloom/BloomCalculations.java @@ -23,7 +23,7 @@ package org.elasticsearch.common.bloom; * The following calculations are taken from: * http://www.cs.wisc.edu/~cao/papers/summary-cache/node8.html * "Bloom Filters - the math" - * + *

    * This class's static methods are meant to facilitate the use of the Bloom * Filter class by helping to choose correct values of 'bits per element' and * 'number of hash functions, k'. diff --git a/src/main/java/org/elasticsearch/common/bloom/BloomFilter.java b/src/main/java/org/elasticsearch/common/bloom/BloomFilter.java index d07fe9347f3..0827ca49cb8 100644 --- a/src/main/java/org/elasticsearch/common/bloom/BloomFilter.java +++ b/src/main/java/org/elasticsearch/common/bloom/BloomFilter.java @@ -27,41 +27,51 @@ import java.nio.ByteBuffer; public interface BloomFilter { public static final BloomFilter NONE = new BloomFilter() { - @Override public void add(byte[] key, int offset, int length) { + @Override + public void add(byte[] key, int offset, int length) { } - @Override public void add(ByteBuffer key) { + @Override + public void add(ByteBuffer key) { } - @Override public boolean isPresent(byte[] key, int offset, int length) { + @Override + public boolean isPresent(byte[] key, int offset, int length) { return true; } - @Override public boolean isPresent(ByteBuffer key) { + @Override + public boolean isPresent(ByteBuffer key) { return true; } - @Override public long sizeInBytes() { + @Override + public long sizeInBytes() { return 0; } }; public static final BloomFilter EMPTY = new BloomFilter() { - @Override public void add(byte[] key, int offset, int length) { + @Override + public void add(byte[] key, int offset, int length) { } - @Override public void add(ByteBuffer key) { + @Override + public void add(ByteBuffer key) { } - @Override public boolean isPresent(byte[] key, int offset, int length) { + @Override + public boolean isPresent(byte[] key, int offset, int length) { return false; } - @Override public boolean isPresent(ByteBuffer key) { + @Override + public boolean isPresent(ByteBuffer key) { return false; } - @Override public long sizeInBytes() { + @Override + public long sizeInBytes() { return 0; } }; diff --git a/src/main/java/org/elasticsearch/common/bloom/BloomFilterFactory.java b/src/main/java/org/elasticsearch/common/bloom/BloomFilterFactory.java index b3a49a8233d..264d7b65e4a 100644 --- a/src/main/java/org/elasticsearch/common/bloom/BloomFilterFactory.java +++ b/src/main/java/org/elasticsearch/common/bloom/BloomFilterFactory.java @@ -55,7 +55,7 @@ public class BloomFilterFactory { /** * @return The smallest BloomFilter that can provide the given false positive * probability rate for the given number of elements. - * + *

    * Asserts that the given probability can be satisfied using this filter. */ public static BloomFilter getFilter(long numElements, double maxFalsePosProbability) { diff --git a/src/main/java/org/elasticsearch/common/bloom/MurmurHash.java b/src/main/java/org/elasticsearch/common/bloom/MurmurHash.java index 9530e5f2a8e..ec9fea462e1 100644 --- a/src/main/java/org/elasticsearch/common/bloom/MurmurHash.java +++ b/src/main/java/org/elasticsearch/common/bloom/MurmurHash.java @@ -24,7 +24,7 @@ import java.nio.ByteBuffer; /** * This is a very fast, non-cryptographic hash suitable for general hash-based * lookup. See http://murmurhash.googlepages.com/ for more details. - * + *

    *

    * The C version of MurmurHash 2.0 found at that site was ported to Java by * Andrzej Bialecki (ab at getopt org). diff --git a/src/main/java/org/elasticsearch/common/bloom/ObsBloomFilter.java b/src/main/java/org/elasticsearch/common/bloom/ObsBloomFilter.java index 6fce1389d9d..bd235c57a16 100644 --- a/src/main/java/org/elasticsearch/common/bloom/ObsBloomFilter.java +++ b/src/main/java/org/elasticsearch/common/bloom/ObsBloomFilter.java @@ -89,7 +89,8 @@ public class ObsBloomFilter implements BloomFilter { return result; } - @Override public void add(byte[] key, int offset, int length) { + @Override + public void add(byte[] key, int offset, int length) { for (long bucketIndex : getHashBuckets(key, offset, length)) { bitset.fastSet(bucketIndex); } @@ -101,7 +102,8 @@ public class ObsBloomFilter implements BloomFilter { } } - @Override public boolean isPresent(byte[] key, int offset, int length) { + @Override + public boolean isPresent(byte[] key, int offset, int length) { for (long bucketIndex : getHashBuckets(key, offset, length)) { if (!bitset.fastGet(bucketIndex)) { return false; @@ -123,7 +125,8 @@ public class ObsBloomFilter implements BloomFilter { bitset.clear(0, bitset.size()); } - @Override public long sizeInBytes() { + @Override + public long sizeInBytes() { return bitset.getBits().length * RamUsage.NUM_BYTES_LONG + RamUsage.NUM_BYTES_ARRAY_HEADER + RamUsage.NUM_BYTES_INT /* wlen */; } } diff --git a/src/main/java/org/elasticsearch/common/collect/BoundedArrayList.java b/src/main/java/org/elasticsearch/common/collect/BoundedArrayList.java deleted file mode 100644 index 11926ce08fa..00000000000 --- a/src/main/java/org/elasticsearch/common/collect/BoundedArrayList.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to Elastic Search 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 - * file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.common.collect; - -import java.util.AbstractList; -import java.util.RandomAccess; - -/** - * An array list that is based on an array and a size, only using the first size elements in the array. - */ -public class BoundedArrayList extends AbstractList implements RandomAccess { - - private final E[] a; - private final int size; - - public BoundedArrayList(E[] array, int size) { - if (array == null) - throw new NullPointerException(); - a = array; - this.size = size; - } - - public int size() { - return size; - } - - public Object[] toArray() { - throw new UnsupportedOperationException(); - } - - public T[] toArray(T[] a) { - throw new UnsupportedOperationException(); - } - - public E get(int index) { - return a[index]; - } - - public E set(int index, E element) { - E oldValue = a[index]; - a[index] = element; - return oldValue; - } - - public int indexOf(Object o) { - if (o == null) { - for (int i = 0; i < a.length; i++) - if (a[i] == null) - return i; - } else { - for (int i = 0; i < a.length; i++) - if (o.equals(a[i])) - return i; - } - return -1; - } - - public boolean contains(Object o) { - return indexOf(o) != -1; - } -} diff --git a/src/main/java/org/elasticsearch/common/collect/BoundedTreeSet.java b/src/main/java/org/elasticsearch/common/collect/BoundedTreeSet.java index 4c5a292956c..a159e15df1e 100644 --- a/src/main/java/org/elasticsearch/common/collect/BoundedTreeSet.java +++ b/src/main/java/org/elasticsearch/common/collect/BoundedTreeSet.java @@ -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.util.TreeSet; /** * A {@link TreeSet} that is bounded by size. * - * @author kimchy (shay.banon) + * */ public class BoundedTreeSet extends TreeSet { @@ -41,13 +41,15 @@ public class BoundedTreeSet extends TreeSet { this.size = size; } - @Override public boolean add(E e) { + @Override + public boolean add(E e) { boolean result = super.add(e); rebound(); return result; } - @Override public boolean addAll(Collection c) { + @Override + public boolean addAll(Collection c) { boolean result = super.addAll(c); rebound(); return result; diff --git a/src/main/java/org/elasticsearch/common/collect/IdentityHashSet.java b/src/main/java/org/elasticsearch/common/collect/IdentityHashSet.java index c6fbce44df1..f19eef490a7 100644 --- a/src/main/java/org/elasticsearch/common/collect/IdentityHashSet.java +++ b/src/main/java/org/elasticsearch/common/collect/IdentityHashSet.java @@ -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.common.collect; import java.util.*; /** - * @author kimchy (Shay Banon) + * */ public class IdentityHashSet extends AbstractSet @@ -165,7 +165,7 @@ public class IdentityHashSet s.writeInt(map.size()); // Write out all elements in the proper order. - for (Iterator i = map.keySet().iterator(); i.hasNext();) + for (Iterator i = map.keySet().iterator(); i.hasNext(); ) s.writeObject(i.next()); } diff --git a/src/main/java/org/elasticsearch/common/collect/MapBackedSet.java b/src/main/java/org/elasticsearch/common/collect/MapBackedSet.java index becca926693..0e2550938a3 100644 --- a/src/main/java/org/elasticsearch/common/collect/MapBackedSet.java +++ b/src/main/java/org/elasticsearch/common/collect/MapBackedSet.java @@ -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.Iterator; import java.util.Map; /** - * @author kimchy (Shay Banon) + * */ public class MapBackedSet extends AbstractSet implements Serializable { diff --git a/src/main/java/org/elasticsearch/common/collect/MapBuilder.java b/src/main/java/org/elasticsearch/common/collect/MapBuilder.java index d5b4a93bb8d..82176aa5362 100644 --- a/src/main/java/org/elasticsearch/common/collect/MapBuilder.java +++ b/src/main/java/org/elasticsearch/common/collect/MapBuilder.java @@ -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,14 @@ package org.elasticsearch.common.collect; +import com.google.common.collect.ImmutableMap; + import java.util.Map; -import static org.elasticsearch.common.collect.Maps.*; +import static com.google.common.collect.Maps.newHashMap; /** - * @author kimchy (Shay Banon) + * */ public class MapBuilder { diff --git a/src/main/java/org/elasticsearch/common/collect/ReusableIterator.java b/src/main/java/org/elasticsearch/common/collect/ReusableIterator.java deleted file mode 100644 index 1340fdeb1b0..00000000000 --- a/src/main/java/org/elasticsearch/common/collect/ReusableIterator.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to Elastic Search 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 - * file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.common.collect; - -import java.util.Iterator; - -/** - * @author kimchy (Shay Banon) - */ -public interface ReusableIterator extends Iterator { - void rewind(); -} diff --git a/src/main/java/org/elasticsearch/common/collect/SafeArray.java b/src/main/java/org/elasticsearch/common/collect/SafeArray.java deleted file mode 100644 index 929fd312dc8..00000000000 --- a/src/main/java/org/elasticsearch/common/collect/SafeArray.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to Elastic Search 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 - * file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.common.collect; - -/** - * An array that is safe in terms of size. - * - * @author kimchy (Shay Banon) - */ -public interface SafeArray { - - T get(int index); - - int size(); - - void add(T value); - - void add(int index, T value); - - void clear(); - - /** - * Applies the procedure to each value in the list in ascending - * (front to back) order. - * - * @param procedure a Procedure value - * @return true if the procedure did not terminate prematurely. - */ - boolean forEach(Procedure procedure); - - static interface Procedure { - /** - * Executes this procedure. A false return value indicates that - * the application executing this procedure should not invoke this - * procedure again. - * - * @param value a value - * @return true if additional invocations of the procedure are - * allowed. - */ - boolean execute(T value); - } -} diff --git a/src/main/java/org/elasticsearch/common/collect/Tuple.java b/src/main/java/org/elasticsearch/common/collect/Tuple.java index 435476ce165..aa762fad542 100644 --- a/src/main/java/org/elasticsearch/common/collect/Tuple.java +++ b/src/main/java/org/elasticsearch/common/collect/Tuple.java @@ -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.common.collect; /** - * @author kimchy (Shay Banon) + * */ public class Tuple { @@ -44,7 +44,8 @@ public class Tuple { return v2; } - @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; @@ -56,21 +57,21 @@ public class Tuple { return true; } - @Override public int hashCode() { + @Override + public int hashCode() { int result = v1 != null ? v1.hashCode() : 0; result = 31 * result + (v2 != null ? v2.hashCode() : 0); return result; } - /** - * Helper function to create a tuple. - * - * @param v1 the first element for the resulting tuple - * @param v2 the second element for the resulting tuple - * @return the tuple (v1,v2) - */ - public static Tuple create(V1 v1, V2 v2) - { - return new Tuple(v1, v2); - } + /** + * Helper function to create a tuple. + * + * @param v1 the first element for the resulting tuple + * @param v2 the second element for the resulting tuple + * @return the tuple (v1,v2) + */ + public static Tuple create(V1 v1, V2 v2) { + return new Tuple(v1, v2); + } } diff --git a/src/main/java/org/elasticsearch/common/component/AbstractComponent.java b/src/main/java/org/elasticsearch/common/component/AbstractComponent.java index 4fd21e72014..a66fa02180c 100644 --- a/src/main/java/org/elasticsearch/common/component/AbstractComponent.java +++ b/src/main/java/org/elasticsearch/common/component/AbstractComponent.java @@ -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.common.logging.Loggers; import org.elasticsearch.common.settings.Settings; /** - * @author kimchy (shay.banon) + * */ public class AbstractComponent { diff --git a/src/main/java/org/elasticsearch/common/component/AbstractLifecycleComponent.java b/src/main/java/org/elasticsearch/common/component/AbstractLifecycleComponent.java index 2e679b0b1a3..1ff2f1076b2 100644 --- a/src/main/java/org/elasticsearch/common/component/AbstractLifecycleComponent.java +++ b/src/main/java/org/elasticsearch/common/component/AbstractLifecycleComponent.java @@ -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.util.List; import java.util.concurrent.CopyOnWriteArrayList; /** - * @author kimchy (shay.banon) + * */ public abstract class AbstractLifecycleComponent extends AbstractComponent implements LifecycleComponent { @@ -58,19 +58,24 @@ public abstract class AbstractLifecycleComponent extends AbstractComponent im super(settings, prefixSettings, loggerClass, componentClass); } - @Override public Lifecycle.State lifecycleState() { + @Override + public Lifecycle.State lifecycleState() { return this.lifecycle.state(); } - @Override public void addLifecycleListener(LifecycleListener listener) { + @Override + public void addLifecycleListener(LifecycleListener listener) { listeners.add(listener); } - @Override public void removeLifecycleListener(LifecycleListener listener) { + @Override + public void removeLifecycleListener(LifecycleListener listener) { listeners.remove(listener); } - @SuppressWarnings({"unchecked"}) @Override public T start() throws ElasticSearchException { + @SuppressWarnings({"unchecked"}) + @Override + public T start() throws ElasticSearchException { if (!lifecycle.canMoveToStarted()) { return (T) this; } @@ -87,7 +92,9 @@ public abstract class AbstractLifecycleComponent extends AbstractComponent im protected abstract void doStart() throws ElasticSearchException; - @SuppressWarnings({"unchecked"}) @Override public T stop() throws ElasticSearchException { + @SuppressWarnings({"unchecked"}) + @Override + public T stop() throws ElasticSearchException { if (!lifecycle.canMoveToStopped()) { return (T) this; } @@ -104,7 +111,8 @@ public abstract class AbstractLifecycleComponent extends AbstractComponent im protected abstract void doStop() throws ElasticSearchException; - @Override public void close() throws ElasticSearchException { + @Override + public void close() throws ElasticSearchException { if (lifecycle.started()) { stop(); } diff --git a/src/main/java/org/elasticsearch/common/component/CloseableComponent.java b/src/main/java/org/elasticsearch/common/component/CloseableComponent.java index 8aa18303e4a..7c230dbb2ff 100644 --- a/src/main/java/org/elasticsearch/common/component/CloseableComponent.java +++ b/src/main/java/org/elasticsearch/common/component/CloseableComponent.java @@ -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.common.component; import org.elasticsearch.ElasticSearchException; /** - * @author kimchy (shay.banon) + * */ public interface CloseableComponent { diff --git a/src/main/java/org/elasticsearch/common/component/Lifecycle.java b/src/main/java/org/elasticsearch/common/component/Lifecycle.java index ae29733c6ac..7e0a01877a1 100644 --- a/src/main/java/org/elasticsearch/common/component/Lifecycle.java +++ b/src/main/java/org/elasticsearch/common/component/Lifecycle.java @@ -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,10 +30,10 @@ import org.elasticsearch.common.util.concurrent.ThreadSafe; *

  • STOPPED -> STARTED, CLOSED
  • *
  • CLOSED ->
  • * - * + *

    *

    Also allows to stay in the same state. For example, when calling stop on a component, the * following logic can be applied: - * + *

    *

      * public void stop() {
      *  if (!lifeccycleState.moveToStopped()) {
    @@ -42,10 +42,10 @@ import org.elasticsearch.common.util.concurrent.ThreadSafe;
      * // continue with stop logic
      * }
      * 
    - * + *

    *

    Note, closed is only allowed to be called when stopped, so make sure to stop the component first. * Here is how the logic can be applied: - * + *

    *

      * public void close() {
      *  if (lifecycleState.started()) {
    @@ -58,7 +58,7 @@ import org.elasticsearch.common.util.concurrent.ThreadSafe;
      * }
      * 
    * - * @author kimchy (Shay Banon) + * */ @ThreadSafe public class Lifecycle { @@ -192,7 +192,8 @@ public class Lifecycle { return true; } - @Override public String toString() { + @Override + public String toString() { return state.toString(); } } diff --git a/src/main/java/org/elasticsearch/common/component/LifecycleComponent.java b/src/main/java/org/elasticsearch/common/component/LifecycleComponent.java index e3a75dddc5d..d67882084a5 100644 --- a/src/main/java/org/elasticsearch/common/component/LifecycleComponent.java +++ b/src/main/java/org/elasticsearch/common/component/LifecycleComponent.java @@ -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.common.component; import org.elasticsearch.ElasticSearchException; /** - * @author kimchy (shay.banon) + * */ public interface LifecycleComponent extends CloseableComponent { diff --git a/src/main/java/org/elasticsearch/common/component/LifecycleListener.java b/src/main/java/org/elasticsearch/common/component/LifecycleListener.java index 64acc453bb9..143779f079e 100644 --- a/src/main/java/org/elasticsearch/common/component/LifecycleListener.java +++ b/src/main/java/org/elasticsearch/common/component/LifecycleListener.java @@ -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.common.component; /** - * @author kimchy (shay.banon) + * */ public interface LifecycleListener { diff --git a/src/main/java/org/elasticsearch/common/compress/CompressedString.java b/src/main/java/org/elasticsearch/common/compress/CompressedString.java index f5084006b2b..c06dba82569 100644 --- a/src/main/java/org/elasticsearch/common/compress/CompressedString.java +++ b/src/main/java/org/elasticsearch/common/compress/CompressedString.java @@ -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,7 +31,7 @@ import java.io.IOException; import java.util.Arrays; /** - * @author kimchy (shay.banon) + * */ public class CompressedString implements Streamable { @@ -63,17 +63,20 @@ public class CompressedString implements Streamable { return compressedString; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { bytes = new byte[in.readVInt()]; in.readBytes(bytes, 0, bytes.length); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeVInt(bytes.length); out.writeBytes(bytes); } - @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; @@ -84,11 +87,13 @@ public class CompressedString implements Streamable { return true; } - @Override public int hashCode() { + @Override + public int hashCode() { return bytes != null ? Arrays.hashCode(bytes) : 0; } - @Override public String toString() { + @Override + public String toString() { try { return string(); } catch (IOException e) { diff --git a/src/main/java/org/elasticsearch/common/compress/bzip2/BZip2Constants.java b/src/main/java/org/elasticsearch/common/compress/bzip2/BZip2Constants.java index 254bd2ffaf1..3cdb0100f51 100644 --- a/src/main/java/org/elasticsearch/common/compress/bzip2/BZip2Constants.java +++ b/src/main/java/org/elasticsearch/common/compress/bzip2/BZip2Constants.java @@ -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 @@ -49,7 +49,7 @@ public interface BZip2Constants { /** * This array really shouldn't be here. * Again, for historical purposes it is. - * + *

    *

    FIXME: This array should be in a private or package private * location, since it could be modified by malicious code.

    */ diff --git a/src/main/java/org/elasticsearch/common/compress/bzip2/CBZip2InputStream.java b/src/main/java/org/elasticsearch/common/compress/bzip2/CBZip2InputStream.java index fbceee2d7a8..f1826039c28 100644 --- a/src/main/java/org/elasticsearch/common/compress/bzip2/CBZip2InputStream.java +++ b/src/main/java/org/elasticsearch/common/compress/bzip2/CBZip2InputStream.java @@ -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,18 +30,18 @@ import java.io.InputStream; /** * An input stream that decompresses from the BZip2 format (without the file * header chars) to be read as any other stream. - * + *

    *

    The decompression requires large amounts of memory. Thus you * should call the {@link #close() close()} method as soon as * possible, to force CBZip2InputStream to release the * allocated memory. See {@link CBZip2OutputStream * CBZip2OutputStream} for information about memory usage.

    - * + *

    *

    CBZip2InputStream reads bytes from the compressed * source stream via the single byte {@link java.io.InputStream#read() * read()} method exclusively. Thus you should consider to use a * buffered source stream.

    - * + *

    *

    Instances of this class are not threadsafe.

    */ public class CBZip2InputStream extends InputStream implements BZip2Constants { @@ -131,7 +131,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { /** * Constructs a new CBZip2InputStream which decompresses bytes read from * the specified stream. - * + *

    *

    Although BZip2 headers are marked with the magic * "Bz" this constructor expects the next byte in the * stream to be the first one after the magic. Thus callers have @@ -175,7 +175,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { final int hi = offs + len; int destOffs = offs; - for (int b; (destOffs < hi) && ((b = read0()) >= 0);) { + for (int b; (destOffs < hi) && ((b = read0()) >= 0); ) { dest[destOffs++] = (byte) b; } @@ -406,7 +406,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { } } - for (int i = MAX_CODE_LEN; --i > 0;) { + for (int i = MAX_CODE_LEN; --i > 0; ) { base[i] = 0; limit[i] = 0; } @@ -449,7 +449,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { } } - for (int i = 256; --i >= 0;) { + for (int i = 256; --i >= 0; ) { inUse[i] = false; } @@ -480,7 +480,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { } /* Undo the MTF values for the selectors. */ - for (int v = nGroups; --v >= 0;) { + for (int v = nGroups; --v >= 0; ) { pos[v] = (byte) v; } @@ -530,7 +530,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { int minLen = 32; int maxLen = 0; final char[] len_t = len[t]; - for (int i = alphaSize; --i >= 0;) { + for (int i = alphaSize; --i >= 0; ) { final char lent = len_t[i]; if (lent > maxLen) { maxLen = lent; @@ -568,7 +568,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { in a separate pass, and so saves a block's worth of cache misses. */ - for (int i = 256; --i >= 0;) { + for (int i = 256; --i >= 0; ) { yy[i] = (char) i; unzftab[i] = 0; } @@ -670,7 +670,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { System.arraycopy for very small ranges to copy. */ if (nextSym <= 16) { - for (int j = nextSym - 1; j > 0;) { + for (int j = nextSym - 1; j > 0; ) { yy[j] = yy[--j]; } } else { @@ -956,7 +956,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { /** * Initializes the {@link #tt} array. - * + *

    * This method is called when the required length of the array * is known. I don't initialize it at construction time to * avoid unneccessary memory allocation when compressing small diff --git a/src/main/java/org/elasticsearch/common/compress/bzip2/CBZip2OutputStream.java b/src/main/java/org/elasticsearch/common/compress/bzip2/CBZip2OutputStream.java index aa6e5584f8f..29e2ec97604 100644 --- a/src/main/java/org/elasticsearch/common/compress/bzip2/CBZip2OutputStream.java +++ b/src/main/java/org/elasticsearch/common/compress/bzip2/CBZip2OutputStream.java @@ -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,33 +31,33 @@ import java.io.OutputStream; /** * An output stream that compresses into the BZip2 format (without the file * header chars) into another stream. - * + *

    *

    * The compression requires large amounts of memory. Thus you should call the * {@link #close() close()} method as soon as possible, to force * CBZip2OutputStream to release the allocated memory. *

    - * + *

    *

    You can shrink the amount of allocated memory and maybe raise * the compression speed by choosing a lower blocksize, which in turn * may cause a lower compression ratio. You can avoid unnecessary * memory allocation by avoiding using a blocksize which is bigger * than the size of the input.

    - * + *

    *

    You can compute the memory usage for compressing by the * following formula:

    - * + *

    *

      * <code>400k + (9 * blocksize)</code>.
      * 
    - * + *

    *

    To get the memory required for decompression by {@link * CBZip2InputStream CBZip2InputStream} use

    - * + *

    *

      * <code>65k + (5 * blocksize)</code>.
      * 
    - * + *

    * * * @@ -115,16 +115,16 @@ import java.io.OutputStream; * * *
    4565k
    - * + *

    *

    * For decompression CBZip2InputStream allocates less memory if the * bzipped input is smaller than one block. *

    - * + *

    *

    * Instances of this class are not threadsafe. *

    - * + *

    *

    * TODO: Update to BZip2 1.0.1 *

    @@ -226,11 +226,11 @@ public class CBZip2OutputStream extends OutputStream final int[] weight = new int[MAX_ALPHA_SIZE * 2]; final int[] parent = new int[MAX_ALPHA_SIZE * 2]; - for (int i = alphaSize; --i >= 0;) { + for (int i = alphaSize; --i >= 0; ) { weight[i + 1] = (freq[i] == 0 ? 1 : freq[i]) << 8; } - for (boolean tooLong = true; tooLong;) { + for (boolean tooLong = true; tooLong; ) { tooLong = false; int nNodes = alphaSize; @@ -351,7 +351,7 @@ public class CBZip2OutputStream extends OutputStream int j = 0; int k = i; - for (int parent_k; (parent_k = parent[k]) >= 0;) { + for (int parent_k; (parent_k = parent[k]) >= 0; ) { k = parent_k; j++; } @@ -383,11 +383,11 @@ public class CBZip2OutputStream extends OutputStream final int[] weight = dat.weight; final int[] parent = dat.parent; - for (int i = alphaSize; --i >= 0;) { + for (int i = alphaSize; --i >= 0; ) { weight[i + 1] = (freq[i] == 0 ? 1 : freq[i]) << 8; } - for (boolean tooLong = true; tooLong;) { + for (boolean tooLong = true; tooLong; ) { tooLong = false; int nNodes = alphaSize; @@ -502,7 +502,7 @@ public class CBZip2OutputStream extends OutputStream int j = 0; int k = i; - for (int parent_k; (parent_k = parent[k]) >= 0;) { + for (int parent_k; (parent_k = parent[k]) >= 0; ) { k = parent_k; j++; } @@ -588,7 +588,7 @@ public class CBZip2OutputStream extends OutputStream /** * Constructs a new CBZip2OutputStream with a blocksize of 900k. - * + *

    *

    * Attention: The caller is resonsible to write the two BZip2 magic * bytes "BZ" to the specified stream prior to calling this @@ -606,7 +606,7 @@ public class CBZip2OutputStream extends OutputStream /** * Constructs a new CBZip2OutputStream with specified blocksize. - * + *

    *

    * Attention: The caller is resonsible to write the two BZip2 magic * bytes "BZ" to the specified stream prior to calling this @@ -766,7 +766,7 @@ public class CBZip2OutputStream extends OutputStream // ch = 0; boolean[] inUse = this.data.inUse; - for (int i = 256; --i >= 0;) { + for (int i = 256; --i >= 0; ) { inUse[i] = false; } @@ -861,7 +861,7 @@ public class CBZip2OutputStream extends OutputStream throw new IOException("stream closed"); } - for (int hi = offs + len; offs < hi;) { + for (int hi = offs + len; offs < hi; ) { write0(buf[offs++]); } } @@ -941,9 +941,9 @@ public class CBZip2OutputStream extends OutputStream final byte[][] len = this.data.sendMTFValues_len; final int alphaSize = this.nInUse + 2; - for (int t = N_GROUPS; --t >= 0;) { + for (int t = N_GROUPS; --t >= 0; ) { byte[] len_t = len[t]; - for (int v = alphaSize; --v >= 0;) { + for (int v = alphaSize; --v >= 0; ) { len_t[v] = GREATER_ICOST; } } @@ -992,7 +992,7 @@ public class CBZip2OutputStream extends OutputStream int ge = gs - 1; int aFreq = 0; - for (final int a = alphaSize - 1; (aFreq < tFreq) && (ge < a);) { + for (final int a = alphaSize - 1; (aFreq < tFreq) && (ge < a); ) { aFreq += mtfFreq[++ge]; } @@ -1002,7 +1002,7 @@ public class CBZip2OutputStream extends OutputStream } final byte[] len_np = len[nPart - 1]; - for (int v = alphaSize; --v >= 0;) { + for (int v = alphaSize; --v >= 0; ) { if ((v >= gs) && (v <= ge)) { len_np[v] = LESSER_ICOST; } else { @@ -1034,17 +1034,17 @@ public class CBZip2OutputStream extends OutputStream int nSelectors = 0; for (int iter = 0; iter < N_ITERS; iter++) { - for (int t = nGroups; --t >= 0;) { + for (int t = nGroups; --t >= 0; ) { fave[t] = 0; int[] rfreqt = rfreq[t]; - for (int i = alphaSize; --i >= 0;) { + for (int i = alphaSize; --i >= 0; ) { rfreqt[i] = 0; } } nSelectors = 0; - for (int gs = 0; gs < this.nMTF;) { + for (int gs = 0; gs < this.nMTF; ) { /* Set group start & end marks. */ /* @@ -1082,13 +1082,13 @@ public class CBZip2OutputStream extends OutputStream cost[5] = cost5; } else { - for (int t = nGroups; --t >= 0;) { + for (int t = nGroups; --t >= 0; ) { cost[t] = 0; } for (int i = gs; i <= ge; i++) { final int icv = sfmap[i]; - for (int t = nGroups; --t >= 0;) { + for (int t = nGroups; --t >= 0; ) { cost[t] += len[t][icv] & 0xff; } } @@ -1099,7 +1099,7 @@ public class CBZip2OutputStream extends OutputStream * record its identity in the selector table. */ int bt = -1; - for (int t = nGroups, bc = 999999999; --t >= 0;) { + for (int t = nGroups, bc = 999999999; --t >= 0; ) { final int cost_t = cost[t]; if (cost_t < bc) { bc = cost_t; @@ -1139,7 +1139,7 @@ public class CBZip2OutputStream extends OutputStream final Data dataShadow = this.data; byte[] pos = dataShadow.sendMTFValues2_pos; - for (int i = nGroups; --i >= 0;) { + for (int i = nGroups; --i >= 0; ) { pos[i] = (byte) i; } @@ -1168,7 +1168,7 @@ public class CBZip2OutputStream extends OutputStream int minLen = 32; int maxLen = 0; final byte[] len_t = len[t]; - for (int i = alphaSize; --i >= 0;) { + for (int i = alphaSize; --i >= 0; ) { final int l = len_t[i] & 0xff; if (l > maxLen) { maxLen = l; @@ -1189,10 +1189,10 @@ public class CBZip2OutputStream extends OutputStream final boolean[] inUse = this.data.inUse; final boolean[] inUse16 = this.data.sentMTFValues4_inUse16; - for (int i = 16; --i >= 0;) { + for (int i = 16; --i >= 0; ) { inUse16[i] = false; final int i16 = i * 16; - for (int j = 16; --j >= 0;) { + for (int j = 16; --j >= 0; ) { if (inUse[i16 + j]) { inUse16[i] = true; } @@ -1344,7 +1344,7 @@ public class CBZip2OutputStream extends OutputStream int bsLiveShadow = this.bsLive; int bsBuffShadow = this.bsBuff; - for (int gs = 0; gs < nMTFShadow;) { + for (int gs = 0; gs < nMTFShadow; ) { final int ge = Math.min(gs + G_SIZE - 1, nMTFShadow - 1); final int selector_selCtr = selector[selCtr] & 0xff; final int[] code_selCtr = code[selector_selCtr]; @@ -1385,7 +1385,7 @@ public class CBZip2OutputStream extends OutputStream /** * This is the most hammered method of this class. - * + *

    *

    * This is the version using unrolled loops. Normally I never use such ones * in Java code. The unrolling has shown a noticable performance improvement @@ -1422,7 +1422,7 @@ public class CBZip2OutputStream extends OutputStream final int h = INCS[hp]; final int mj = lo + h - 1; - for (int i = lo + h; i <= hi;) { + for (int i = lo + h; i <= hi; ) { // copy for (int k = 3; (i <= hi) && (--k >= 0); i++) { final int v = fmap[i]; @@ -1636,7 +1636,7 @@ public class CBZip2OutputStream extends OutputStream stack_hh[0] = hiSt; stack_dd[0] = dSt; - for (int sp = 1; --sp >= 0;) { + for (int sp = 1; --sp >= 0; ) { final int lo = stack_ll[sp]; final int hi = stack_hh[sp]; final int d = stack_dd[sp]; @@ -1742,7 +1742,7 @@ public class CBZip2OutputStream extends OutputStream final boolean firstAttemptShadow = this.firstAttempt; // Set up the 2-byte frequency table - for (int i = 65537; --i >= 0;) { + for (int i = 65537; --i >= 0; ) { ftab[i] = 0; } @@ -1754,7 +1754,7 @@ public class CBZip2OutputStream extends OutputStream for (int i = 0; i < NUM_OVERSHOOT_BYTES; i++) { block[lastShadow + i + 2] = block[(i % (lastShadow + 1)) + 1]; } - for (int i = lastShadow + NUM_OVERSHOOT_BYTES + 1; --i >= 0;) { + for (int i = lastShadow + NUM_OVERSHOOT_BYTES + 1; --i >= 0; ) { quadrant[i] = 0; } block[0] = block[lastShadow + 1]; @@ -1784,12 +1784,12 @@ public class CBZip2OutputStream extends OutputStream * Now ftab contains the first loc of every small bucket. Calculate the * running order, from smallest to largest big bucket. */ - for (int i = 256; --i >= 0;) { + for (int i = 256; --i >= 0; ) { bigDone[i] = false; runningOrder[i] = i; } - for (int h = 364; h != 1;) { + for (int h = 364; h != 1; ) { h /= 3; for (int i = h; i <= 255; i++) { final int vv = runningOrder[i]; @@ -1858,7 +1858,7 @@ public class CBZip2OutputStream extends OutputStream } } - for (int j = 256; --j >= 0;) + for (int j = 256; --j >= 0; ) ftab[(j << 8) + ss] |= SETMASK; // Step 3: @@ -1898,7 +1898,7 @@ public class CBZip2OutputStream extends OutputStream final byte[] block = this.data.block; final int lastShadow = this.last; - for (int i = 256; --i >= 0;) + for (int i = 256; --i >= 0; ) inUse[i] = false; int rNToGo = 0; @@ -1948,7 +1948,7 @@ public class CBZip2OutputStream extends OutputStream mtfFreq[i] = 0; } - for (int i = nInUseShadow; --i >= 0;) { + for (int i = nInUseShadow; --i >= 0; ) { yy[i] = (byte) i; } diff --git a/src/main/java/org/elasticsearch/common/compress/bzip2/CRC.java b/src/main/java/org/elasticsearch/common/compress/bzip2/CRC.java index 87007b1f157..fab2304236d 100644 --- a/src/main/java/org/elasticsearch/common/compress/bzip2/CRC.java +++ b/src/main/java/org/elasticsearch/common/compress/bzip2/CRC.java @@ -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 diff --git a/src/main/java/org/elasticsearch/common/compress/lzf/BufferRecycler.java b/src/main/java/org/elasticsearch/common/compress/lzf/BufferRecycler.java index cce9fe17b79..23c42ad4940 100644 --- a/src/main/java/org/elasticsearch/common/compress/lzf/BufferRecycler.java +++ b/src/main/java/org/elasticsearch/common/compress/lzf/BufferRecycler.java @@ -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 diff --git a/src/main/java/org/elasticsearch/common/compress/lzf/impl/UnsafeChunkDecoder.java b/src/main/java/org/elasticsearch/common/compress/lzf/impl/UnsafeChunkDecoder.java index 64596e4c6eb..14738bf4674 100755 --- a/src/main/java/org/elasticsearch/common/compress/lzf/impl/UnsafeChunkDecoder.java +++ b/src/main/java/org/elasticsearch/common/compress/lzf/impl/UnsafeChunkDecoder.java @@ -12,7 +12,7 @@ import java.lang.reflect.Field; * Highly optimized {@link ChunkDecoder} implementation that uses * Sun JDK's Unsafe class (which may be included by other JDK's as well; * IBM's apparently does). - *

    + *

    * Credits for the idea go to Dain Sundstrom, who kindly suggested this use, * and is all-around great source for optimization tips and tricks. */ diff --git a/src/main/java/org/elasticsearch/common/compress/lzf/package-info.java b/src/main/java/org/elasticsearch/common/compress/lzf/package-info.java index af8d3face67..f1904f2acf6 100644 --- a/src/main/java/org/elasticsearch/common/compress/lzf/package-info.java +++ b/src/main/java/org/elasticsearch/common/compress/lzf/package-info.java @@ -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 diff --git a/src/main/java/org/elasticsearch/common/compress/lzf/util/ChunkDecoderFactory.java b/src/main/java/org/elasticsearch/common/compress/lzf/util/ChunkDecoderFactory.java index 3626d6a5664..09140e81682 100755 --- a/src/main/java/org/elasticsearch/common/compress/lzf/util/ChunkDecoderFactory.java +++ b/src/main/java/org/elasticsearch/common/compress/lzf/util/ChunkDecoderFactory.java @@ -9,7 +9,7 @@ import org.elasticsearch.common.compress.lzf.impl.VanillaChunkDecoder; * Simple helper class used for loading * {@link ChunkDecoder} implementations, based on criteria * such as "fastest available". - *

    + *

    * Yes, it looks butt-ugly, but does the job. Nonetheless, if anyone * has lipstick for this pig, let me know. * diff --git a/src/main/java/org/elasticsearch/common/http/client/HttpDownloadHelper.java b/src/main/java/org/elasticsearch/common/http/client/HttpDownloadHelper.java index a451a5fb12c..7b1bf093642 100644 --- a/src/main/java/org/elasticsearch/common/http/client/HttpDownloadHelper.java +++ b/src/main/java/org/elasticsearch/common/http/client/HttpDownloadHelper.java @@ -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,19 +21,13 @@ package org.elasticsearch.common.http.client; import org.elasticsearch.common.Nullable; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.PrintStream; +import java.io.*; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; /** - * @author kimchy (shay.banon) + * */ public class HttpDownloadHelper { @@ -366,7 +360,7 @@ public class HttpDownloadHelper { /** * Has the download completed successfully? - * + *

    *

    Re-throws any exception caught during executaion.

    */ boolean wasSuccessful() throws IOException { diff --git a/src/main/java/org/elasticsearch/common/inject/AbstractModule.java b/src/main/java/org/elasticsearch/common/inject/AbstractModule.java index 71387664b15..4b15f4bf4d8 100644 --- a/src/main/java/org/elasticsearch/common/inject/AbstractModule.java +++ b/src/main/java/org/elasticsearch/common/inject/AbstractModule.java @@ -26,14 +26,15 @@ import org.elasticsearch.common.inject.spi.TypeListener; import java.lang.annotation.Annotation; -import static org.elasticsearch.common.base.Preconditions.*; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; /** * A support class for {@link Module}s which reduces repetition and results in * a more readable configuration. Simply extend this class, implement {@link * #configure()}, and call the inherited methods which mirror those found in * {@link Binder}. For example: - * + *

    *

      * public class MyModule extends AbstractModule {
      *   protected void configure() {
    diff --git a/src/main/java/org/elasticsearch/common/inject/AbstractProcessor.java b/src/main/java/org/elasticsearch/common/inject/AbstractProcessor.java
    index bd2c11c0ee8..fad6926c5e1 100644
    --- a/src/main/java/org/elasticsearch/common/inject/AbstractProcessor.java
    +++ b/src/main/java/org/elasticsearch/common/inject/AbstractProcessor.java
    @@ -24,7 +24,7 @@ import java.util.List;
     
     /**
      * Abstract base class for creating an injector from module elements.
    - *
    + * 

    *

    Extending classes must return {@code true} from any overridden * {@code visit*()} methods, in order for the element processor to remove the * handled element. diff --git a/src/main/java/org/elasticsearch/common/inject/Binder.java b/src/main/java/org/elasticsearch/common/inject/Binder.java index 1c78ee2c777..93155131e9f 100644 --- a/src/main/java/org/elasticsearch/common/inject/Binder.java +++ b/src/main/java/org/elasticsearch/common/inject/Binder.java @@ -31,9 +31,9 @@ import java.lang.annotation.Annotation; * used to create an {@link Injector}. Guice provides this object to your * application's {@link Module} implementors so they may each contribute * their own bindings and other registrations. - * + *

    *

    The Guice Binding EDSL

    - * + *

    * Guice uses an embedded domain-specific language, or EDSL, to help you * create bindings simply and readably. This approach is great for overall * usability, but it does come with a small cost: it is difficult to @@ -42,7 +42,7 @@ import java.lang.annotation.Annotation; * examples below. To save space, these examples omit the opening * {@code binder}, just as you will if your module extends * {@link AbstractModule}. - * + *

    *

      *     bind(ServiceImpl.class);
    * diff --git a/src/main/java/org/elasticsearch/common/inject/Binding.java b/src/main/java/org/elasticsearch/common/inject/Binding.java index 8515e1b5b42..b854d1df316 100644 --- a/src/main/java/org/elasticsearch/common/inject/Binding.java +++ b/src/main/java/org/elasticsearch/common/inject/Binding.java @@ -24,7 +24,7 @@ import org.elasticsearch.common.inject.spi.Element; * A mapping from a key (type and optional annotation) to the strategy for getting instances of the * type. This interface is part of the introspection API and is intended primarily for use by * tools. - * + *

    *

    Bindings are created in several ways: *

      *
    • Explicitly in a module, via {@code bind()} and {@code bindConstant()} diff --git a/src/main/java/org/elasticsearch/common/inject/BindingAnnotation.java b/src/main/java/org/elasticsearch/common/inject/BindingAnnotation.java index 13021b71446..816c306b230 100644 --- a/src/main/java/org/elasticsearch/common/inject/BindingAnnotation.java +++ b/src/main/java/org/elasticsearch/common/inject/BindingAnnotation.java @@ -19,14 +19,14 @@ package org.elasticsearch.common.inject; import java.lang.annotation.Retention; import java.lang.annotation.Target; -import static java.lang.annotation.ElementType.*; -import static java.lang.annotation.RetentionPolicy.*; +import static java.lang.annotation.ElementType.ANNOTATION_TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; /** * Annotates annotations which are used for binding. Only one such annotation * may apply to a single injection point. You must also annotate binder * annotations with {@code @Retention(RUNTIME)}. For example: - * + *

      *

        *   {@code @}Retention(RUNTIME)
        *   {@code @}Target({ FIELD, PARAMETER, METHOD })
      diff --git a/src/main/java/org/elasticsearch/common/inject/BindingProcessor.java b/src/main/java/org/elasticsearch/common/inject/BindingProcessor.java
      index 70ef8d6b317..db3cb6bb257 100644
      --- a/src/main/java/org/elasticsearch/common/inject/BindingProcessor.java
      +++ b/src/main/java/org/elasticsearch/common/inject/BindingProcessor.java
      @@ -16,8 +16,8 @@
       
       package org.elasticsearch.common.inject;
       
      -import org.elasticsearch.common.collect.ImmutableSet;
      -import org.elasticsearch.common.collect.Lists;
      +import com.google.common.collect.ImmutableSet;
      +import com.google.common.collect.Lists;
       import org.elasticsearch.common.inject.internal.*;
       import org.elasticsearch.common.inject.spi.*;
       
      @@ -41,7 +41,8 @@ class BindingProcessor extends AbstractProcessor {
               this.initializer = initializer;
           }
       
      -    @Override public  Boolean visit(Binding command) {
      +    @Override
      +    public  Boolean visit(Binding command) {
               final Object source = command.getSource();
       
               if (Void.class.equals(command.getKey().getRawType())) {
      @@ -175,7 +176,8 @@ class BindingProcessor extends AbstractProcessor {
               return true;
           }
       
      -    @Override public Boolean visit(PrivateElements privateElements) {
      +    @Override
      +    public Boolean visit(PrivateElements privateElements) {
               for (Key key : privateElements.getExposedKeys()) {
                   bindExposed(privateElements, key);
               }
      diff --git a/src/main/java/org/elasticsearch/common/inject/BoundProviderFactory.java b/src/main/java/org/elasticsearch/common/inject/BoundProviderFactory.java
      index 5bcda607ac4..39f2932742f 100644
      --- a/src/main/java/org/elasticsearch/common/inject/BoundProviderFactory.java
      +++ b/src/main/java/org/elasticsearch/common/inject/BoundProviderFactory.java
      @@ -61,7 +61,8 @@ class BoundProviderFactory implements InternalFactory, CreationListener {
               }
           }
       
      -    @Override public String toString() {
      +    @Override
      +    public String toString() {
               return providerKey.toString();
           }
       }
      diff --git a/src/main/java/org/elasticsearch/common/inject/ConfigurationException.java b/src/main/java/org/elasticsearch/common/inject/ConfigurationException.java
      index 23c9993d3e3..db7f2507332 100644
      --- a/src/main/java/org/elasticsearch/common/inject/ConfigurationException.java
      +++ b/src/main/java/org/elasticsearch/common/inject/ConfigurationException.java
      @@ -16,13 +16,13 @@
       
       package org.elasticsearch.common.inject;
       
      -import org.elasticsearch.common.collect.ImmutableSet;
      +import com.google.common.collect.ImmutableSet;
       import org.elasticsearch.common.inject.internal.Errors;
       import org.elasticsearch.common.inject.spi.Message;
       
       import java.util.Collection;
       
      -import static org.elasticsearch.common.base.Preconditions.*;
      +import static com.google.common.base.Preconditions.checkState;
       
       /**
        * Thrown when a programming error such as a misplaced annotation, illegal binding, or unsupported
      @@ -74,7 +74,8 @@ public final class ConfigurationException extends RuntimeException {
               return (E) partialValue;
           }
       
      -    @Override public String getMessage() {
      +    @Override
      +    public String getMessage() {
               return Errors.format("Guice configuration errors", messages);
           }
       
      diff --git a/src/main/java/org/elasticsearch/common/inject/ConstantFactory.java b/src/main/java/org/elasticsearch/common/inject/ConstantFactory.java
      index 2d9acd1d992..db34eecef55 100644
      --- a/src/main/java/org/elasticsearch/common/inject/ConstantFactory.java
      +++ b/src/main/java/org/elasticsearch/common/inject/ConstantFactory.java
      @@ -16,11 +16,7 @@
       
       package org.elasticsearch.common.inject;
       
      -import org.elasticsearch.common.inject.internal.Errors;
      -import org.elasticsearch.common.inject.internal.ErrorsException;
      -import org.elasticsearch.common.inject.internal.InternalContext;
      -import org.elasticsearch.common.inject.internal.InternalFactory;
      -import org.elasticsearch.common.inject.internal.ToStringBuilder;
      +import org.elasticsearch.common.inject.internal.*;
       import org.elasticsearch.common.inject.spi.Dependency;
       
       /**
      diff --git a/src/main/java/org/elasticsearch/common/inject/ConstructorBindingImpl.java b/src/main/java/org/elasticsearch/common/inject/ConstructorBindingImpl.java
      index dc3d69294f9..44723a43fd6 100644
      --- a/src/main/java/org/elasticsearch/common/inject/ConstructorBindingImpl.java
      +++ b/src/main/java/org/elasticsearch/common/inject/ConstructorBindingImpl.java
      @@ -16,14 +16,8 @@
       
       package org.elasticsearch.common.inject;
       
      -import org.elasticsearch.common.collect.ImmutableSet;
      -import org.elasticsearch.common.inject.internal.BindingImpl;
      -import org.elasticsearch.common.inject.internal.Errors;
      -import org.elasticsearch.common.inject.internal.ErrorsException;
      -import org.elasticsearch.common.inject.internal.InternalContext;
      -import org.elasticsearch.common.inject.internal.InternalFactory;
      -import org.elasticsearch.common.inject.internal.Scoping;
      -import org.elasticsearch.common.inject.internal.ToStringBuilder;
      +import com.google.common.collect.ImmutableSet;
      +import org.elasticsearch.common.inject.internal.*;
       import org.elasticsearch.common.inject.spi.BindingTargetVisitor;
       import org.elasticsearch.common.inject.spi.ConstructorBinding;
       import org.elasticsearch.common.inject.spi.Dependency;
      @@ -31,7 +25,7 @@ import org.elasticsearch.common.inject.spi.InjectionPoint;
       
       import java.util.Set;
       
      -import static org.elasticsearch.common.base.Preconditions.*;
      +import static com.google.common.base.Preconditions.checkState;
       
       class ConstructorBindingImpl extends BindingImpl implements ConstructorBinding {
       
      @@ -82,7 +76,8 @@ class ConstructorBindingImpl extends BindingImpl implements ConstructorBin
               throw new UnsupportedOperationException("This element represents a synthetic binding.");
           }
       
      -    @Override public String toString() {
      +    @Override
      +    public String toString() {
               return new ToStringBuilder(ConstructorBinding.class)
                       .add("key", getKey())
                       .add("source", getSource())
      diff --git a/src/main/java/org/elasticsearch/common/inject/ConstructorInjector.java b/src/main/java/org/elasticsearch/common/inject/ConstructorInjector.java
      index 49575739b34..f732a0d36b4 100644
      --- a/src/main/java/org/elasticsearch/common/inject/ConstructorInjector.java
      +++ b/src/main/java/org/elasticsearch/common/inject/ConstructorInjector.java
      @@ -16,7 +16,7 @@
       
       package org.elasticsearch.common.inject;
       
      -import org.elasticsearch.common.collect.ImmutableSet;
      +import com.google.common.collect.ImmutableSet;
       import org.elasticsearch.common.inject.internal.ConstructionContext;
       import org.elasticsearch.common.inject.internal.Errors;
       import org.elasticsearch.common.inject.internal.ErrorsException;
      diff --git a/src/main/java/org/elasticsearch/common/inject/CreationException.java b/src/main/java/org/elasticsearch/common/inject/CreationException.java
      index 60ef2517e71..4553bc2785f 100644
      --- a/src/main/java/org/elasticsearch/common/inject/CreationException.java
      +++ b/src/main/java/org/elasticsearch/common/inject/CreationException.java
      @@ -16,13 +16,13 @@
       
       package org.elasticsearch.common.inject;
       
      -import org.elasticsearch.common.collect.ImmutableSet;
      +import com.google.common.collect.ImmutableSet;
       import org.elasticsearch.common.inject.internal.Errors;
       import org.elasticsearch.common.inject.spi.Message;
       
       import java.util.Collection;
       
      -import static org.elasticsearch.common.base.Preconditions.*;
      +import static com.google.common.base.Preconditions.checkArgument;
       
       /**
        * Thrown when errors occur while creating a {@link Injector}. Includes a list of encountered
      @@ -50,7 +50,8 @@ public class CreationException extends RuntimeException {
               return messages;
           }
       
      -    @Override public String getMessage() {
      +    @Override
      +    public String getMessage() {
               return Errors.format("Guice creation errors", messages);
           }
       
      diff --git a/src/main/java/org/elasticsearch/common/inject/DeferredLookups.java b/src/main/java/org/elasticsearch/common/inject/DeferredLookups.java
      index 82c25ffe85a..5f0dcd460e5 100644
      --- a/src/main/java/org/elasticsearch/common/inject/DeferredLookups.java
      +++ b/src/main/java/org/elasticsearch/common/inject/DeferredLookups.java
      @@ -16,7 +16,7 @@
       
       package org.elasticsearch.common.inject;
       
      -import org.elasticsearch.common.collect.Lists;
      +import com.google.common.collect.Lists;
       import org.elasticsearch.common.inject.internal.Errors;
       import org.elasticsearch.common.inject.spi.Element;
       import org.elasticsearch.common.inject.spi.MembersInjectorLookup;
      diff --git a/src/main/java/org/elasticsearch/common/inject/EncounterImpl.java b/src/main/java/org/elasticsearch/common/inject/EncounterImpl.java
      index 14ee41ad9d0..ccd5f9afdaf 100644
      --- a/src/main/java/org/elasticsearch/common/inject/EncounterImpl.java
      +++ b/src/main/java/org/elasticsearch/common/inject/EncounterImpl.java
      @@ -16,8 +16,8 @@
       
       package org.elasticsearch.common.inject;
       
      -import org.elasticsearch.common.collect.ImmutableList;
      -import org.elasticsearch.common.collect.Lists;
      +import com.google.common.collect.ImmutableList;
      +import com.google.common.collect.Lists;
       import org.elasticsearch.common.inject.internal.Errors;
       import org.elasticsearch.common.inject.spi.InjectionListener;
       import org.elasticsearch.common.inject.spi.Message;
      @@ -25,7 +25,7 @@ import org.elasticsearch.common.inject.spi.TypeEncounter;
       
       import java.util.List;
       
      -import static org.elasticsearch.common.base.Preconditions.*;
      +import static com.google.common.base.Preconditions.checkState;
       
       /**
        * @author jessewilson@google.com (Jesse Wilson)
      diff --git a/src/main/java/org/elasticsearch/common/inject/Exposed.java b/src/main/java/org/elasticsearch/common/inject/Exposed.java
      index 21851cfb117..992da18d7cb 100644
      --- a/src/main/java/org/elasticsearch/common/inject/Exposed.java
      +++ b/src/main/java/org/elasticsearch/common/inject/Exposed.java
      @@ -21,7 +21,7 @@ import java.lang.annotation.ElementType;
       import java.lang.annotation.Retention;
       import java.lang.annotation.Target;
       
      -import static java.lang.annotation.RetentionPolicy.*;
      +import static java.lang.annotation.RetentionPolicy.RUNTIME;
       
       /**
        * Acccompanies a {@literal @}{@link org.elasticsearch.common.inject.Provides Provides} method annotation in a
      diff --git a/src/main/java/org/elasticsearch/common/inject/ExposedKeyFactory.java b/src/main/java/org/elasticsearch/common/inject/ExposedKeyFactory.java
      index 851e5757c1d..0cdb8a5b539 100644
      --- a/src/main/java/org/elasticsearch/common/inject/ExposedKeyFactory.java
      +++ b/src/main/java/org/elasticsearch/common/inject/ExposedKeyFactory.java
      @@ -16,11 +16,7 @@
       
       package org.elasticsearch.common.inject;
       
      -import org.elasticsearch.common.inject.internal.BindingImpl;
      -import org.elasticsearch.common.inject.internal.Errors;
      -import org.elasticsearch.common.inject.internal.ErrorsException;
      -import org.elasticsearch.common.inject.internal.InternalContext;
      -import org.elasticsearch.common.inject.internal.InternalFactory;
      +import org.elasticsearch.common.inject.internal.*;
       import org.elasticsearch.common.inject.spi.Dependency;
       import org.elasticsearch.common.inject.spi.PrivateElements;
       
      diff --git a/src/main/java/org/elasticsearch/common/inject/FactoryProxy.java b/src/main/java/org/elasticsearch/common/inject/FactoryProxy.java
      index 1278e15653f..0c40fe5638f 100644
      --- a/src/main/java/org/elasticsearch/common/inject/FactoryProxy.java
      +++ b/src/main/java/org/elasticsearch/common/inject/FactoryProxy.java
      @@ -17,11 +17,7 @@
       
       package org.elasticsearch.common.inject;
       
      -import org.elasticsearch.common.inject.internal.Errors;
      -import org.elasticsearch.common.inject.internal.ErrorsException;
      -import org.elasticsearch.common.inject.internal.InternalContext;
      -import org.elasticsearch.common.inject.internal.InternalFactory;
      -import org.elasticsearch.common.inject.internal.ToStringBuilder;
      +import org.elasticsearch.common.inject.internal.*;
       import org.elasticsearch.common.inject.spi.Dependency;
       
       /**
      @@ -56,7 +52,8 @@ class FactoryProxy implements InternalFactory, BindingProcessor.CreationLi
               return targetFactory.get(errors.withSource(targetKey), context, dependency);
           }
       
      -    @Override public String toString() {
      +    @Override
      +    public String toString() {
               return new ToStringBuilder(FactoryProxy.class)
                       .add("key", key)
                       .add("provider", targetFactory)
      diff --git a/src/main/java/org/elasticsearch/common/inject/Guice.java b/src/main/java/org/elasticsearch/common/inject/Guice.java
      index d6f627f36d5..7b303e5d684 100644
      --- a/src/main/java/org/elasticsearch/common/inject/Guice.java
      +++ b/src/main/java/org/elasticsearch/common/inject/Guice.java
      @@ -21,7 +21,7 @@ import java.util.Arrays;
       /**
        * The entry point to the Guice framework. Creates {@link Injector}s from
        * {@link Module}s.
      - *
      + * 

      *

      Guice supports a model of development that draws clear boundaries between * APIs, Implementations of these APIs, Modules which configure these * implementations, and finally Applications which consist of a collection of diff --git a/src/main/java/org/elasticsearch/common/inject/ImplementedBy.java b/src/main/java/org/elasticsearch/common/inject/ImplementedBy.java index 06de1fe00d9..52e3509a287 100644 --- a/src/main/java/org/elasticsearch/common/inject/ImplementedBy.java +++ b/src/main/java/org/elasticsearch/common/inject/ImplementedBy.java @@ -19,8 +19,8 @@ package org.elasticsearch.common.inject; import java.lang.annotation.Retention; import java.lang.annotation.Target; -import static java.lang.annotation.ElementType.*; -import static java.lang.annotation.RetentionPolicy.*; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; /** * A pointer to the default implementation of a type. diff --git a/src/main/java/org/elasticsearch/common/inject/InheritingState.java b/src/main/java/org/elasticsearch/common/inject/InheritingState.java index 0467e6ddac3..5747e537e04 100644 --- a/src/main/java/org/elasticsearch/common/inject/InheritingState.java +++ b/src/main/java/org/elasticsearch/common/inject/InheritingState.java @@ -16,8 +16,8 @@ package org.elasticsearch.common.inject; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.collect.Maps; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import org.elasticsearch.common.inject.internal.BindingImpl; import org.elasticsearch.common.inject.internal.Errors; import org.elasticsearch.common.inject.internal.MatcherAndConverter; @@ -29,7 +29,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; -import static org.elasticsearch.common.base.Preconditions.*; +import static com.google.common.base.Preconditions.checkNotNull; /** * @author jessewilson@google.com (Jesse Wilson) @@ -126,7 +126,8 @@ class InheritingState implements State { return blacklistedKeys.contains(key); } - @Override public void clearBlacklisted() { + @Override + public void clearBlacklisted() { blacklistedKeys = new WeakKeySet(); } diff --git a/src/main/java/org/elasticsearch/common/inject/Initializables.java b/src/main/java/org/elasticsearch/common/inject/Initializables.java index 94d821374cc..b2c017e6ddf 100644 --- a/src/main/java/org/elasticsearch/common/inject/Initializables.java +++ b/src/main/java/org/elasticsearch/common/inject/Initializables.java @@ -33,7 +33,8 @@ class Initializables { return instance; } - @Override public String toString() { + @Override + public String toString() { return String.valueOf(instance); } }; diff --git a/src/main/java/org/elasticsearch/common/inject/Initializer.java b/src/main/java/org/elasticsearch/common/inject/Initializer.java index 8f63f221cc0..259e09e224f 100644 --- a/src/main/java/org/elasticsearch/common/inject/Initializer.java +++ b/src/main/java/org/elasticsearch/common/inject/Initializer.java @@ -16,8 +16,8 @@ package org.elasticsearch.common.inject; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.collect.Maps; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import org.elasticsearch.common.inject.internal.Errors; import org.elasticsearch.common.inject.internal.ErrorsException; import org.elasticsearch.common.inject.spi.InjectionPoint; @@ -26,7 +26,7 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.CountDownLatch; -import static org.elasticsearch.common.base.Preconditions.*; +import static com.google.common.base.Preconditions.checkNotNull; /** * Manages and injects instances at injector-creation time. This is made more complicated by @@ -156,7 +156,8 @@ class Initializer { return instance; } - @Override public String toString() { + @Override + public String toString() { return instance.toString(); } } diff --git a/src/main/java/org/elasticsearch/common/inject/Inject.java b/src/main/java/org/elasticsearch/common/inject/Inject.java index 37207b9677c..c118c4db945 100644 --- a/src/main/java/org/elasticsearch/common/inject/Inject.java +++ b/src/main/java/org/elasticsearch/common/inject/Inject.java @@ -21,29 +21,29 @@ import java.lang.annotation.Retention; import java.lang.annotation.Target; import static java.lang.annotation.ElementType.*; -import static java.lang.annotation.RetentionPolicy.*; +import static java.lang.annotation.RetentionPolicy.RUNTIME; /** * Annotates members of your implementation class (constructors, methods * and fields) into which the {@link Injector} should inject values. * The Injector fulfills injection requests for: - * + *

      *

        *
      • Every instance it constructs. The class being constructed must have * exactly one of its constructors marked with {@code @Inject} or must have a * constructor taking no parameters. The Injector then proceeds to perform * method and field injections. - * + *

        *

      • Pre-constructed instances passed to {@link Injector#injectMembers}, * {@link org.elasticsearch.common.inject.binder.LinkedBindingBuilder#toInstance(Object)} and * {@link org.elasticsearch.common.inject.binder.LinkedBindingBuilder#toProvider(Provider)}. * In this case all constructors are, of course, ignored. - * + *

        *

      • Static fields and methods of classes which any {@link Module} has * specifically requested static injection for, using * {@link Binder#requestStaticInjection}. *
      - * + *

      * In all cases, a member can be injected regardless of its Java access * specifier (private, default, protected, public). * diff --git a/src/main/java/org/elasticsearch/common/inject/InjectionRequestProcessor.java b/src/main/java/org/elasticsearch/common/inject/InjectionRequestProcessor.java index 8c81dd70faa..09308f77d4d 100644 --- a/src/main/java/org/elasticsearch/common/inject/InjectionRequestProcessor.java +++ b/src/main/java/org/elasticsearch/common/inject/InjectionRequestProcessor.java @@ -16,8 +16,8 @@ package org.elasticsearch.common.inject; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.Lists; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; import org.elasticsearch.common.inject.internal.Errors; import org.elasticsearch.common.inject.internal.ErrorsException; import org.elasticsearch.common.inject.internal.InternalContext; @@ -45,12 +45,14 @@ class InjectionRequestProcessor extends AbstractProcessor { this.initializer = initializer; } - @Override public Boolean visit(StaticInjectionRequest request) { + @Override + public Boolean visit(StaticInjectionRequest request) { staticInjections.add(new StaticInjection(injector, request)); return true; } - @Override public Boolean visit(InjectionRequest request) { + @Override + public Boolean visit(InjectionRequest request) { Set injectionPoints; try { injectionPoints = request.getInjectionPoints(); diff --git a/src/main/java/org/elasticsearch/common/inject/Injector.java b/src/main/java/org/elasticsearch/common/inject/Injector.java index 7ef2ab4766a..d7ee0e832e8 100644 --- a/src/main/java/org/elasticsearch/common/inject/Injector.java +++ b/src/main/java/org/elasticsearch/common/inject/Injector.java @@ -24,25 +24,25 @@ import java.util.Map; * for each type and uses bindings to inject them. This is the core of Guice, although you rarely * interact with it directly. This "behind-the-scenes" operation is what distinguishes dependency * injection from its cousin, the service locator pattern. - * + *

      *

      Contains several default bindings: - * + *

      *

        *
      • This {@link Injector} instance itself *
      • A {@code Provider} for each binding of type {@code T} *
      • The {@link java.util.logging.Logger} for the class being injected *
      • The {@link Stage} in which the Injector was created *
      - * + *

      * Injectors are created using the facade class {@link Guice}. - * + *

      *

      An injector can also {@link #injectMembers(Object) inject the dependencies} of * already-constructed instances. This can be used to interoperate with objects created by other * frameworks or services. - * + *

      *

      Injectors can be {@link #createChildInjector(Iterable) hierarchical}. Child injectors inherit * the configuration of their parent injectors, but the converse does not hold. - * + *

      *

      The injector's {@link #getBindings() internal bindings} are available for introspection. This * enables tools and extensions to operate on an injector reflectively. * @@ -54,7 +54,7 @@ public interface Injector { /** * Injects dependencies into the fields and methods of {@code instance}. Ignores the presence or * absence of an injectable constructor. - * + *

      *

      Whenever Guice creates an instance, it performs this injection automatically (after first * performing constructor injection), so if you're able to let Guice create all your objects for * you, you'll never need to use this method. @@ -90,12 +90,12 @@ public interface Injector { /** * Returns all explicit bindings. - * + *

      *

      The returned map does not include bindings inherited from a {@link #getParent() parent * injector}, should one exist. The returned map is guaranteed to iterate (for example, with * its {@link java.util.Map#entrySet()} iterator) in the order of insertion. In other words, * the order in which bindings appear in user Modules. - * + *

      *

      This method is part of the Guice SPI and is intended for use by tools and extensions. */ Map, Binding> getBindings(); @@ -104,7 +104,7 @@ public interface Injector { * Returns the binding for the given injection key. This will be an explicit bindings if the key * was bound explicitly by a module, or an implicit binding otherwise. The implicit binding will * be created if necessary. - * + *

      *

      This method is part of the Guice SPI and is intended for use by tools and extensions. * * @throws ConfigurationException if this injector cannot find or create the binding. @@ -115,7 +115,7 @@ public interface Injector { * Returns the binding for the given type. This will be an explicit bindings if the injection key * was bound explicitly by a module, or an implicit binding otherwise. The implicit binding will * be created if necessary. - * + *

      *

      This method is part of the Guice SPI and is intended for use by tools and extensions. * * @throws ConfigurationException if this injector cannot find or create the binding. @@ -125,7 +125,7 @@ public interface Injector { /** * Returns all explicit bindings for {@code type}. - * + *

      *

      This method is part of the Guice SPI and is intended for use by tools and extensions. */ List> findBindingsByType(TypeLiteral type); @@ -179,11 +179,11 @@ public interface Injector { * Returns a new injector that inherits all state from this injector. All bindings, scopes, * interceptors and type converters are inherited -- they are visible to the child injector. * Elements of the child injector are not visible to its parent. - * + *

      *

      Just-in-time bindings created for child injectors will be created in an ancestor injector * whenever possible. This allows for scoped instances to be shared between injectors. Use * explicit bindings to prevent bindings from being shared with the parent injector. - * + *

      *

      No key may be bound by both an injector and one of its ancestors. This includes just-in-time * bindings. The lone exception is the key for {@code Injector.class}, which is bound by each * injector to itself. @@ -196,11 +196,11 @@ public interface Injector { * Returns a new injector that inherits all state from this injector. All bindings, scopes, * interceptors and type converters are inherited -- they are visible to the child injector. * Elements of the child injector are not visible to its parent. - * + *

      *

      Just-in-time bindings created for child injectors will be created in an ancestor injector * whenever possible. This allows for scoped instances to be shared between injectors. Use * explicit bindings to prevent bindings from being shared with the parent injector. - * + *

      *

      No key may be bound by both an injector and one of its ancestors. This includes just-in-time * bindings. The lone exception is the key for {@code Injector.class}, which is bound by each * injector to itself. diff --git a/src/main/java/org/elasticsearch/common/inject/InjectorBuilder.java b/src/main/java/org/elasticsearch/common/inject/InjectorBuilder.java index 2214b385957..8568ec97a31 100644 --- a/src/main/java/org/elasticsearch/common/inject/InjectorBuilder.java +++ b/src/main/java/org/elasticsearch/common/inject/InjectorBuilder.java @@ -16,13 +16,9 @@ package org.elasticsearch.common.inject; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.collect.Iterables; -import org.elasticsearch.common.inject.internal.BindingImpl; -import org.elasticsearch.common.inject.internal.Errors; -import org.elasticsearch.common.inject.internal.ErrorsException; -import org.elasticsearch.common.inject.internal.InternalContext; -import org.elasticsearch.common.inject.internal.Stopwatch; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; +import org.elasticsearch.common.inject.internal.*; import org.elasticsearch.common.inject.spi.Dependency; import java.util.Collection; @@ -34,7 +30,7 @@ import java.util.Set; * Builds a tree of injectors. This is a primary injector, plus child injectors needed for each * {@link Binder#newPrivateBinder() private environment}. The primary injector is not necessarily a * top-level injector. - * + *

      *

      Injector construction happens in two phases. *

        *
      1. Static building. In this phase, we interpret commands, create bindings, and inspect diff --git a/src/main/java/org/elasticsearch/common/inject/InjectorImpl.java b/src/main/java/org/elasticsearch/common/inject/InjectorImpl.java index 3a4f01de886..79aed0bb416 100644 --- a/src/main/java/org/elasticsearch/common/inject/InjectorImpl.java +++ b/src/main/java/org/elasticsearch/common/inject/InjectorImpl.java @@ -16,31 +16,22 @@ package org.elasticsearch.common.inject; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.collect.Maps; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import org.elasticsearch.common.inject.internal.*; -import org.elasticsearch.common.inject.spi.BindingTargetVisitor; -import org.elasticsearch.common.inject.spi.ConvertedConstantBinding; -import org.elasticsearch.common.inject.spi.Dependency; -import org.elasticsearch.common.inject.spi.InjectionPoint; -import org.elasticsearch.common.inject.spi.ProviderBinding; -import org.elasticsearch.common.inject.spi.ProviderKeyBinding; +import org.elasticsearch.common.inject.spi.*; import org.elasticsearch.common.inject.util.Providers; import java.lang.annotation.Annotation; -import java.lang.reflect.GenericArrayType; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Modifier; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; +import java.lang.reflect.*; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; -import static org.elasticsearch.common.inject.internal.Annotations.*; +import static org.elasticsearch.common.inject.internal.Annotations.findScopeAnnotation; /** * Default {@link Injector} implementation. @@ -142,7 +133,7 @@ class InjectorImpl implements Injector, Lookups { } public Injector createChildInjector(Module... modules) { - return createChildInjector(ImmutableList.of(modules)); + return createChildInjector(ImmutableList.copyOf(modules)); } /** @@ -255,7 +246,8 @@ class InjectorImpl implements Injector, Lookups { throw new UnsupportedOperationException("This element represents a synthetic binding."); } - @Override public String toString() { + @Override + public String toString() { return new ToStringBuilder(ProviderKeyBinding.class) .add("key", getKey()) .add("providedKey", getProvidedKey()) @@ -330,7 +322,8 @@ class InjectorImpl implements Injector, Lookups { this.originalBinding = originalBinding; } - @Override public Provider getProvider() { + @Override + public Provider getProvider() { return provider; } @@ -354,7 +347,8 @@ class InjectorImpl implements Injector, Lookups { throw new UnsupportedOperationException("This element represents a synthetic binding."); } - @Override public String toString() { + @Override + public String toString() { return new ToStringBuilder(ConvertedConstantBinding.class) .add("key", getKey()) .add("sourceKey", getSourceKey()) @@ -673,7 +667,8 @@ class InjectorImpl implements Injector, Lookups { } - @SuppressWarnings("unchecked") // safe because we only put matching entries into the map + @SuppressWarnings("unchecked") + // safe because we only put matching entries into the map List> getAll(TypeLiteral type) { List> bindings = multimap.get(type); return bindings != null @@ -778,7 +773,8 @@ class InjectorImpl implements Injector, Lookups { } } - @Override public String toString() { + @Override + public String toString() { return factory.toString(); } }; diff --git a/src/main/java/org/elasticsearch/common/inject/InjectorShell.java b/src/main/java/org/elasticsearch/common/inject/InjectorShell.java index 3a440dd6330..3babb713565 100644 --- a/src/main/java/org/elasticsearch/common/inject/InjectorShell.java +++ b/src/main/java/org/elasticsearch/common/inject/InjectorShell.java @@ -16,29 +16,17 @@ package org.elasticsearch.common.inject; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.inject.internal.Errors; -import org.elasticsearch.common.inject.internal.ErrorsException; -import org.elasticsearch.common.inject.internal.InternalContext; -import org.elasticsearch.common.inject.internal.InternalFactory; -import org.elasticsearch.common.inject.internal.PrivateElementsImpl; -import org.elasticsearch.common.inject.internal.ProviderInstanceBindingImpl; -import org.elasticsearch.common.inject.internal.Scoping; -import org.elasticsearch.common.inject.internal.SourceProvider; -import org.elasticsearch.common.inject.internal.Stopwatch; -import org.elasticsearch.common.inject.spi.Dependency; -import org.elasticsearch.common.inject.spi.Element; -import org.elasticsearch.common.inject.spi.Elements; -import org.elasticsearch.common.inject.spi.InjectionPoint; -import org.elasticsearch.common.inject.spi.PrivateElements; -import org.elasticsearch.common.inject.spi.TypeListenerBinding; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import org.elasticsearch.common.inject.internal.*; +import org.elasticsearch.common.inject.spi.*; import java.util.List; import java.util.logging.Logger; -import static org.elasticsearch.common.base.Preconditions.*; -import static org.elasticsearch.common.inject.Scopes.*; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; +import static org.elasticsearch.common.inject.Scopes.SINGLETON; /** * A partially-initialized injector. See {@link InjectorBuilder}, which uses this to build a tree diff --git a/src/main/java/org/elasticsearch/common/inject/Injectors.java b/src/main/java/org/elasticsearch/common/inject/Injectors.java index 74d6e3f41d8..7c4459e9455 100644 --- a/src/main/java/org/elasticsearch/common/inject/Injectors.java +++ b/src/main/java/org/elasticsearch/common/inject/Injectors.java @@ -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,7 +19,7 @@ package org.elasticsearch.common.inject; -import org.elasticsearch.common.collect.Sets; +import com.google.common.collect.Sets; import org.elasticsearch.common.inject.matcher.Matcher; import org.elasticsearch.common.inject.name.Names; import org.elasticsearch.common.inject.spi.Message; @@ -30,7 +30,7 @@ import java.util.Map.Entry; import java.util.Set; /** - * @author kimchy (Shay Banon) + * */ public class Injectors { diff --git a/src/main/java/org/elasticsearch/common/inject/InternalFactoryToProviderAdapter.java b/src/main/java/org/elasticsearch/common/inject/InternalFactoryToProviderAdapter.java index 68ac07e22fd..f492bd155a7 100644 --- a/src/main/java/org/elasticsearch/common/inject/InternalFactoryToProviderAdapter.java +++ b/src/main/java/org/elasticsearch/common/inject/InternalFactoryToProviderAdapter.java @@ -16,14 +16,10 @@ package org.elasticsearch.common.inject; -import org.elasticsearch.common.inject.internal.Errors; -import org.elasticsearch.common.inject.internal.ErrorsException; -import org.elasticsearch.common.inject.internal.InternalContext; -import org.elasticsearch.common.inject.internal.InternalFactory; -import org.elasticsearch.common.inject.internal.SourceProvider; +import org.elasticsearch.common.inject.internal.*; import org.elasticsearch.common.inject.spi.Dependency; -import static org.elasticsearch.common.base.Preconditions.*; +import static com.google.common.base.Preconditions.checkNotNull; /** * @author crazybob@google.com (Bob Lee) @@ -52,7 +48,8 @@ class InternalFactoryToProviderAdapter implements InternalFactory { } } - @Override public String toString() { + @Override + public String toString() { return initializable.toString(); } } diff --git a/src/main/java/org/elasticsearch/common/inject/Key.java b/src/main/java/org/elasticsearch/common/inject/Key.java index 66b6dbf1a2d..e8ee244fbc4 100644 --- a/src/main/java/org/elasticsearch/common/inject/Key.java +++ b/src/main/java/org/elasticsearch/common/inject/Key.java @@ -23,25 +23,26 @@ import org.elasticsearch.common.inject.internal.ToStringBuilder; import java.lang.annotation.Annotation; import java.lang.reflect.Type; -import static org.elasticsearch.common.base.Preconditions.*; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; /** * Binding key consisting of an injection type and an optional annotation. * Matches the type and annotation at a point of injection. - * + *

        *

        For example, {@code Key.get(Service.class, Transactional.class)} will * match: - * + *

        *

          *   {@literal @}Inject
          *   public void setService({@literal @}Transactional Service service) {
          *     ...
          *   }
          * 
        - * + *

        *

        {@code Key} supports generic types via subclassing just like {@link * TypeLiteral}. - * + *

        *

        Keys do not differentiate between primitive types (int, char, etc.) and * their correpsonding wrapper types (Integer, Character, etc.). Primitive * types will be replaced with their wrapper types when keys are created. @@ -57,14 +58,14 @@ public class Key { /** * Constructs a new key. Derives the type from this class's type parameter. - * + *

        *

        Clients create an empty anonymous subclass. Doing so embeds the type * parameter in the anonymous class's type hierarchy so we can reconstitute it * at runtime despite erasure. - * + *

        *

        Example usage for a binding of type {@code Foo} annotated with * {@code @Bar}: - * + *

        *

        {@code new Key(Bar.class) {}}. */ @SuppressWarnings("unchecked") @@ -76,14 +77,14 @@ public class Key { /** * Constructs a new key. Derives the type from this class's type parameter. - * + *

        *

        Clients create an empty anonymous subclass. Doing so embeds the type * parameter in the anonymous class's type hierarchy so we can reconstitute it * at runtime despite erasure. - * + *

        *

        Example usage for a binding of type {@code Foo} annotated with * {@code @Bar}: - * + *

        *

        {@code new Key(new Bar()) {}}. */ @SuppressWarnings("unchecked") @@ -96,13 +97,13 @@ public class Key { /** * Constructs a new key. Derives the type from this class's type parameter. - * + *

        *

        Clients create an empty anonymous subclass. Doing so embeds the type * parameter in the anonymous class's type hierarchy so we can reconstitute it * at runtime despite erasure. - * + *

        *

        Example usage for a binding of type {@code Foo}: - * + *

        *

        {@code new Key() {}}. */ @SuppressWarnings("unchecked") @@ -181,7 +182,8 @@ public class Key { return ofType(typeLiteral.providerType()); } - @Override public final boolean equals(Object o) { + @Override + public final boolean equals(Object o) { if (o == this) { return true; } @@ -193,11 +195,13 @@ public class Key { && typeLiteral.equals(other.typeLiteral); } - @Override public final int hashCode() { + @Override + public final int hashCode() { return this.hashCode; } - @Override public final String toString() { + @Override + public final String toString() { return new ToStringBuilder(Key.class) .add("type", typeLiteral) .add("annotation", annotationStrategy) @@ -394,7 +398,8 @@ public class Key { return null; } - @Override public String toString() { + @Override + public String toString() { return "[none]"; } } @@ -424,7 +429,8 @@ public class Key { return annotation.annotationType(); } - @Override public boolean equals(Object o) { + @Override + public boolean equals(Object o) { if (!(o instanceof AnnotationInstanceStrategy)) { return false; } @@ -433,11 +439,13 @@ public class Key { return annotation.equals(other.annotation); } - @Override public int hashCode() { + @Override + public int hashCode() { return annotation.hashCode(); } - @Override public String toString() { + @Override + public String toString() { return annotation.toString(); } } @@ -471,7 +479,8 @@ public class Key { return annotationType; } - @Override public boolean equals(Object o) { + @Override + public boolean equals(Object o) { if (!(o instanceof AnnotationTypeStrategy)) { return false; } @@ -480,11 +489,13 @@ public class Key { return annotationType.equals(other.annotationType); } - @Override public int hashCode() { + @Override + public int hashCode() { return annotationType.hashCode(); } - @Override public String toString() { + @Override + public String toString() { return "@" + annotationType.getName(); } } diff --git a/src/main/java/org/elasticsearch/common/inject/LookupProcessor.java b/src/main/java/org/elasticsearch/common/inject/LookupProcessor.java index 4e20708fe8a..0bcfaa27c5d 100644 --- a/src/main/java/org/elasticsearch/common/inject/LookupProcessor.java +++ b/src/main/java/org/elasticsearch/common/inject/LookupProcessor.java @@ -33,7 +33,8 @@ class LookupProcessor extends AbstractProcessor { super(errors); } - @Override public Boolean visit(MembersInjectorLookup lookup) { + @Override + public Boolean visit(MembersInjectorLookup lookup) { try { MembersInjector membersInjector = injector.membersInjectorStore.get(lookup.getType(), errors); @@ -45,7 +46,8 @@ class LookupProcessor extends AbstractProcessor { return true; } - @Override public Boolean visit(ProviderLookup lookup) { + @Override + public Boolean visit(ProviderLookup lookup) { // ensure the provider can be created try { Provider provider = injector.getProviderOrThrow(lookup.getKey(), errors); diff --git a/src/main/java/org/elasticsearch/common/inject/MembersInjector.java b/src/main/java/org/elasticsearch/common/inject/MembersInjector.java index 1b915e5337d..3893bf197c0 100644 --- a/src/main/java/org/elasticsearch/common/inject/MembersInjector.java +++ b/src/main/java/org/elasticsearch/common/inject/MembersInjector.java @@ -30,7 +30,7 @@ public interface MembersInjector { /** * Injects dependencies into the fields and methods of {@code instance}. Ignores the presence or * absence of an injectable constructor. - * + *

        *

        Whenever Guice creates an instance, it performs this injection automatically (after first * performing constructor injection), so if you're able to let Guice create all your objects for * you, you'll never need to use this method. diff --git a/src/main/java/org/elasticsearch/common/inject/MembersInjectorImpl.java b/src/main/java/org/elasticsearch/common/inject/MembersInjectorImpl.java index ed13219ac66..6ae6ffc8722 100644 --- a/src/main/java/org/elasticsearch/common/inject/MembersInjectorImpl.java +++ b/src/main/java/org/elasticsearch/common/inject/MembersInjectorImpl.java @@ -16,8 +16,8 @@ package org.elasticsearch.common.inject; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; import org.elasticsearch.common.inject.internal.Errors; import org.elasticsearch.common.inject.internal.ErrorsException; import org.elasticsearch.common.inject.internal.InternalContext; @@ -104,7 +104,8 @@ class MembersInjectorImpl implements MembersInjector { } } - @Override public String toString() { + @Override + public String toString() { return "MembersInjector<" + typeLiteral + ">"; } diff --git a/src/main/java/org/elasticsearch/common/inject/MembersInjectorStore.java b/src/main/java/org/elasticsearch/common/inject/MembersInjectorStore.java index bbb52a215e1..2904ccd8dfc 100644 --- a/src/main/java/org/elasticsearch/common/inject/MembersInjectorStore.java +++ b/src/main/java/org/elasticsearch/common/inject/MembersInjectorStore.java @@ -16,8 +16,8 @@ package org.elasticsearch.common.inject; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.Lists; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; import org.elasticsearch.common.inject.internal.Errors; import org.elasticsearch.common.inject.internal.ErrorsException; import org.elasticsearch.common.inject.internal.FailableCache; @@ -39,7 +39,8 @@ class MembersInjectorStore { private final FailableCache, MembersInjectorImpl> cache = new FailableCache, MembersInjectorImpl>() { - @Override protected MembersInjectorImpl create(TypeLiteral type, Errors errors) + @Override + protected MembersInjectorImpl create(TypeLiteral type, Errors errors) throws ErrorsException { return createWithListeners(type, errors); } diff --git a/src/main/java/org/elasticsearch/common/inject/MessageProcessor.java b/src/main/java/org/elasticsearch/common/inject/MessageProcessor.java index ef8336d976a..2acba6865ca 100644 --- a/src/main/java/org/elasticsearch/common/inject/MessageProcessor.java +++ b/src/main/java/org/elasticsearch/common/inject/MessageProcessor.java @@ -33,7 +33,8 @@ class MessageProcessor extends AbstractProcessor { super(errors); } - @Override public Boolean visit(Message message) { + @Override + public Boolean visit(Message message) { // ES_GUICE: don't log failures using jdk logging // if (message.getCause() != null) { // String rootMessage = getRootMessage(message.getCause()); diff --git a/src/main/java/org/elasticsearch/common/inject/Module.java b/src/main/java/org/elasticsearch/common/inject/Module.java index 70d88d8b758..9af716d9282 100644 --- a/src/main/java/org/elasticsearch/common/inject/Module.java +++ b/src/main/java/org/elasticsearch/common/inject/Module.java @@ -21,10 +21,10 @@ package org.elasticsearch.common.inject; * bindings, which will be used to create an {@link Injector}. A Guice-based * application is ultimately composed of little more than a set of * {@code Module}s and some bootstrapping code. - * + *

        *

        Your Module classes can use a more streamlined syntax by extending * {@link AbstractModule} rather than implementing this interface directly. - * + *

        *

        In addition to the bindings configured via {@link #configure}, bindings * will be created for all methods annotated with {@literal @}{@link Provides}. * Use scope and binding annotations on these methods to configure the @@ -34,7 +34,7 @@ public interface Module { /** * Contributes bindings and other configurations for this module to {@code binder}. - * + *

        *

        Do not invoke this method directly to install submodules. Instead use * {@link Binder#install(Module)}, which ensures that {@link Provides provider methods} are * discovered. diff --git a/src/main/java/org/elasticsearch/common/inject/Modules.java b/src/main/java/org/elasticsearch/common/inject/Modules.java index 9b4ffe0056c..a492f6b117e 100644 --- a/src/main/java/org/elasticsearch/common/inject/Modules.java +++ b/src/main/java/org/elasticsearch/common/inject/Modules.java @@ -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.settings.Settings; import java.lang.reflect.Constructor; /** - * @author kimchy (shay.banon) + * */ public class Modules { diff --git a/src/main/java/org/elasticsearch/common/inject/ModulesBuilder.java b/src/main/java/org/elasticsearch/common/inject/ModulesBuilder.java index 40a983d57ed..1a9212ac4a1 100644 --- a/src/main/java/org/elasticsearch/common/inject/ModulesBuilder.java +++ b/src/main/java/org/elasticsearch/common/inject/ModulesBuilder.java @@ -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.common.inject; -import org.elasticsearch.common.collect.Lists; +import com.google.common.collect.Lists; import java.util.Iterator; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class ModulesBuilder implements Iterable { @@ -49,7 +49,8 @@ public class ModulesBuilder implements Iterable { return this; } - @Override public Iterator iterator() { + @Override + public Iterator iterator() { return modules.iterator(); } diff --git a/src/main/java/org/elasticsearch/common/inject/PreProcessModule.java b/src/main/java/org/elasticsearch/common/inject/PreProcessModule.java index 009ff0e335b..d4b409c9a5b 100644 --- a/src/main/java/org/elasticsearch/common/inject/PreProcessModule.java +++ b/src/main/java/org/elasticsearch/common/inject/PreProcessModule.java @@ -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 @@ package org.elasticsearch.common.inject; * A module can implement this interface to allow to pre process other modules * before an injector is created. * - * @author kimchy (shay.banon) + * */ public interface PreProcessModule { diff --git a/src/main/java/org/elasticsearch/common/inject/PrivateElementProcessor.java b/src/main/java/org/elasticsearch/common/inject/PrivateElementProcessor.java index 45bb406f042..9b0fd3d7e07 100644 --- a/src/main/java/org/elasticsearch/common/inject/PrivateElementProcessor.java +++ b/src/main/java/org/elasticsearch/common/inject/PrivateElementProcessor.java @@ -16,7 +16,7 @@ package org.elasticsearch.common.inject; -import org.elasticsearch.common.collect.Lists; +import com.google.common.collect.Lists; import org.elasticsearch.common.inject.internal.Errors; import org.elasticsearch.common.inject.spi.PrivateElements; @@ -37,7 +37,8 @@ class PrivateElementProcessor extends AbstractProcessor { this.stage = stage; } - @Override public Boolean visit(PrivateElements privateElements) { + @Override + public Boolean visit(PrivateElements privateElements) { InjectorShell.Builder builder = new InjectorShell.Builder() .parent(injector) .stage(stage) diff --git a/src/main/java/org/elasticsearch/common/inject/PrivateModule.java b/src/main/java/org/elasticsearch/common/inject/PrivateModule.java index e1df6665401..81472ff9720 100644 --- a/src/main/java/org/elasticsearch/common/inject/PrivateModule.java +++ b/src/main/java/org/elasticsearch/common/inject/PrivateModule.java @@ -27,23 +27,23 @@ import org.elasticsearch.common.inject.spi.TypeListener; import java.lang.annotation.Annotation; -import static org.elasticsearch.common.base.Preconditions.*; +import static com.google.common.base.Preconditions.checkState; /** * A module whose configuration information is hidden from its environment by default. Only bindings * that are explicitly exposed will be available to other modules and to the users of the injector. * This module may expose the bindings it creates and the bindings of the modules it installs. - * + *

        *

        A private module can be nested within a regular module or within another private module using * {@link Binder#install install()}. Its bindings live in a new environment that inherits bindings, * type converters, scopes, and interceptors from the surrounding ("parent") environment. When you * nest multiple private modules, the result is a tree of environments where the injector's * environment is the root. - * + *

        *

        Guice EDSL bindings can be exposed with {@link #expose(Class) expose()}. {@literal @}{@link * org.elasticsearch.common.inject.Provides Provides} bindings can be exposed with the {@literal @}{@link * Exposed} annotation: - * + *

        *

          * public class FooBarBazModule extends PrivateModule {
          *   protected void configure() {
        @@ -63,19 +63,19 @@ import static org.elasticsearch.common.base.Preconditions.*;
          *   }
          * }
          * 
        - * + *

        *

        Private modules are implemented using {@link Injector#createChildInjector(Module[]) parent * injectors}. When it can satisfy their dependencies, just-in-time bindings will be created in the * root environment. Such bindings are shared among all environments in the tree. - * + *

        *

        The scope of a binding is constrained to its environment. A singleton bound in a private * module will be unique to its environment. But a binding for the same type in a different private * module will yield a different instance. - * + *

        *

        A shared binding that injects the {@code Injector} gets the root injector, which only has * access to bindings in the root environment. An explicit binding that injects the {@code Injector} * gets access to all bindings in the child environment. - * + *

        *

        To promote a just-in-time binding to an explicit binding, bind it: *

          *   bind(FooImpl.class);
        diff --git a/src/main/java/org/elasticsearch/common/inject/ProvidedBy.java b/src/main/java/org/elasticsearch/common/inject/ProvidedBy.java
        index c6ffcdfef70..6232dd70559 100644
        --- a/src/main/java/org/elasticsearch/common/inject/ProvidedBy.java
        +++ b/src/main/java/org/elasticsearch/common/inject/ProvidedBy.java
        @@ -19,8 +19,8 @@ package org.elasticsearch.common.inject;
         import java.lang.annotation.Retention;
         import java.lang.annotation.Target;
         
        -import static java.lang.annotation.ElementType.*;
        -import static java.lang.annotation.RetentionPolicy.*;
        +import static java.lang.annotation.ElementType.TYPE;
        +import static java.lang.annotation.RetentionPolicy.RUNTIME;
         
         /**
          * A pointer to the default provider type for a type.
        diff --git a/src/main/java/org/elasticsearch/common/inject/Provider.java b/src/main/java/org/elasticsearch/common/inject/Provider.java
        index 4fd983526d1..f9f446670d0 100644
        --- a/src/main/java/org/elasticsearch/common/inject/Provider.java
        +++ b/src/main/java/org/elasticsearch/common/inject/Provider.java
        @@ -19,21 +19,21 @@ package org.elasticsearch.common.inject;
         /**
          * An object capable of providing instances of type {@code T}. Providers are used in numerous ways
          * by Guice:
        - *
        + * 

        *

          *
        • When the default means for obtaining instances (an injectable or parameterless constructor) * is insufficient for a particular binding, the module can specify a custom {@code Provider} * instead, to control exactly how Guice creates or obtains instances for the binding. - * + *

          *

        • An implementation class may always choose to have a {@code Provider} instance injected, * rather than having a {@code T} injected directly. This may give you access to multiple * instances, instances you wish to safely mutate and discard, instances which are out of scope * (e.g. using a {@code @RequestScoped} object from within a {@code @SessionScoped} object), or * instances that will be initialized lazily. - * + *

          *

        • A custom {@link Scope} is implemented as a decorator of {@code Provider}, which decides * when to delegate to the backing provider and when to provide the instance some other way. - * + *

          *

        • The {@link Injector} offers access to the {@code Provider} it uses to fulfill requests * for a given key, via the {@link Injector#getProvider} methods. *
        diff --git a/src/main/java/org/elasticsearch/common/inject/ProviderToInternalFactoryAdapter.java b/src/main/java/org/elasticsearch/common/inject/ProviderToInternalFactoryAdapter.java index b4f6373d964..4a7931c4e11 100644 --- a/src/main/java/org/elasticsearch/common/inject/ProviderToInternalFactoryAdapter.java +++ b/src/main/java/org/elasticsearch/common/inject/ProviderToInternalFactoryAdapter.java @@ -52,7 +52,8 @@ class ProviderToInternalFactoryAdapter implements Provider { } } - @Override public String toString() { + @Override + public String toString() { return internalFactory.toString(); } } diff --git a/src/main/java/org/elasticsearch/common/inject/Provides.java b/src/main/java/org/elasticsearch/common/inject/Provides.java index 123916c7cb6..8fc7bbb9113 100644 --- a/src/main/java/org/elasticsearch/common/inject/Provides.java +++ b/src/main/java/org/elasticsearch/common/inject/Provides.java @@ -20,8 +20,8 @@ import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.Target; -import static java.lang.annotation.ElementType.*; -import static java.lang.annotation.RetentionPolicy.*; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; /** * Annotates methods of a {@link Module} to create a provider method binding. The method's return diff --git a/src/main/java/org/elasticsearch/common/inject/ProvisionException.java b/src/main/java/org/elasticsearch/common/inject/ProvisionException.java index 08141759e13..4c0c3652128 100644 --- a/src/main/java/org/elasticsearch/common/inject/ProvisionException.java +++ b/src/main/java/org/elasticsearch/common/inject/ProvisionException.java @@ -16,14 +16,14 @@ package org.elasticsearch.common.inject; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; import org.elasticsearch.common.inject.internal.Errors; import org.elasticsearch.common.inject.spi.Message; import java.util.Collection; -import static org.elasticsearch.common.base.Preconditions.*; +import static com.google.common.base.Preconditions.checkArgument; /** * Indicates that there was a runtime failure while providing an instance. @@ -61,7 +61,8 @@ public final class ProvisionException extends RuntimeException { return messages; } - @Override public String getMessage() { + @Override + public String getMessage() { return Errors.format("Guice provision errors", messages); } diff --git a/src/main/java/org/elasticsearch/common/inject/Scope.java b/src/main/java/org/elasticsearch/common/inject/Scope.java index f523e2bc57d..c817800c14a 100644 --- a/src/main/java/org/elasticsearch/common/inject/Scope.java +++ b/src/main/java/org/elasticsearch/common/inject/Scope.java @@ -24,7 +24,7 @@ package org.elasticsearch.common.inject; * and then immediately forgets it. Associating a scope with a particular * binding allows the created instance to be "remembered" and possibly used * again for other injections. - * + *

        *

        An example of a scope is {@link Scopes#SINGLETON}. * * @author crazybob@google.com (Bob Lee) @@ -35,7 +35,7 @@ public interface Scope { * Scopes a provider. The returned provider returns objects from this scope. * If an object does not exist in this scope, the provider can use the given * unscoped provider to retrieve one. - * + *

        *

        Scope implementations are strongly encouraged to override * {@link Object#toString} in the returned provider and include the backing * provider's {@code toString()} output. diff --git a/src/main/java/org/elasticsearch/common/inject/ScopeAnnotation.java b/src/main/java/org/elasticsearch/common/inject/ScopeAnnotation.java index 304e6ac0dff..7c6ab299c88 100644 --- a/src/main/java/org/elasticsearch/common/inject/ScopeAnnotation.java +++ b/src/main/java/org/elasticsearch/common/inject/ScopeAnnotation.java @@ -19,14 +19,14 @@ package org.elasticsearch.common.inject; import java.lang.annotation.Retention; import java.lang.annotation.Target; -import static java.lang.annotation.ElementType.*; -import static java.lang.annotation.RetentionPolicy.*; +import static java.lang.annotation.ElementType.ANNOTATION_TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; /** * Annotates annotations which are used for scoping. Only one such annotation * may apply to a single implementation class. You must also annotate scope * annotations with {@code @Retention(RUNTIME)}. For example: - * + *

        *

          *   {@code @}Retention(RUNTIME)
          *   {@code @}Target(TYPE)
        diff --git a/src/main/java/org/elasticsearch/common/inject/ScopeBindingProcessor.java b/src/main/java/org/elasticsearch/common/inject/ScopeBindingProcessor.java
        index 9941477b825..019d04ce0c7 100644
        --- a/src/main/java/org/elasticsearch/common/inject/ScopeBindingProcessor.java
        +++ b/src/main/java/org/elasticsearch/common/inject/ScopeBindingProcessor.java
        @@ -22,7 +22,7 @@ import org.elasticsearch.common.inject.spi.ScopeBinding;
         
         import java.lang.annotation.Annotation;
         
        -import static org.elasticsearch.common.base.Preconditions.*;
        +import static com.google.common.base.Preconditions.checkNotNull;
         
         /**
          * Handles {@link Binder#bindScope} commands.
        @@ -36,7 +36,8 @@ class ScopeBindingProcessor extends AbstractProcessor {
                 super(errors);
             }
         
        -    @Override public Boolean visit(ScopeBinding command) {
        +    @Override
        +    public Boolean visit(ScopeBinding command) {
                 Scope scope = command.getScope();
                 Class annotationType = command.getAnnotationType();
         
        diff --git a/src/main/java/org/elasticsearch/common/inject/Scopes.java b/src/main/java/org/elasticsearch/common/inject/Scopes.java
        index 8ce30d88508..7aedc52714a 100644
        --- a/src/main/java/org/elasticsearch/common/inject/Scopes.java
        +++ b/src/main/java/org/elasticsearch/common/inject/Scopes.java
        @@ -66,7 +66,8 @@ public class Scopes {
                     };
                 }
         
        -        @Override public String toString() {
        +        @Override
        +        public String toString() {
                     return "Scopes.SINGLETON";
                 }
             };
        @@ -76,7 +77,7 @@ public class Scopes {
              * Injector obtains an instance of an object with "no scope", it injects this
              * instance then immediately forgets it.  When the next request for the same
              * binding arrives it will need to obtain the instance over again.
        -     *
        +     * 

        *

        This exists only in case a class has been annotated with a scope * annotation such as {@link Singleton @Singleton}, and you need to override * this to "no scope" in your binding. @@ -88,7 +89,8 @@ public class Scopes { return unscoped; } - @Override public String toString() { + @Override + public String toString() { return "Scopes.NO_SCOPE"; } }; diff --git a/src/main/java/org/elasticsearch/common/inject/Singleton.java b/src/main/java/org/elasticsearch/common/inject/Singleton.java index 37ff1476229..eeca5e01852 100644 --- a/src/main/java/org/elasticsearch/common/inject/Singleton.java +++ b/src/main/java/org/elasticsearch/common/inject/Singleton.java @@ -20,7 +20,7 @@ import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.Target; -import static java.lang.annotation.RetentionPolicy.*; +import static java.lang.annotation.RetentionPolicy.RUNTIME; /** * Apply this to implementation classes when you want only one instance diff --git a/src/main/java/org/elasticsearch/common/inject/SpawnModules.java b/src/main/java/org/elasticsearch/common/inject/SpawnModules.java index 573c04e07a6..56c4b0c46d3 100644 --- a/src/main/java/org/elasticsearch/common/inject/SpawnModules.java +++ b/src/main/java/org/elasticsearch/common/inject/SpawnModules.java @@ -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.common.inject; /** - * @author kimchy (shay.banon) + * */ public interface SpawnModules { diff --git a/src/main/java/org/elasticsearch/common/inject/State.java b/src/main/java/org/elasticsearch/common/inject/State.java index 7e443d3f384..208d4f3104b 100644 --- a/src/main/java/org/elasticsearch/common/inject/State.java +++ b/src/main/java/org/elasticsearch/common/inject/State.java @@ -16,8 +16,8 @@ package org.elasticsearch.common.inject; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; import org.elasticsearch.common.inject.internal.BindingImpl; import org.elasticsearch.common.inject.internal.Errors; import org.elasticsearch.common.inject.internal.MatcherAndConverter; @@ -88,7 +88,8 @@ interface State { return true; } - @Override public void clearBlacklisted() { + @Override + public void clearBlacklisted() { } public Object lock() { diff --git a/src/main/java/org/elasticsearch/common/inject/TypeConverterBindingProcessor.java b/src/main/java/org/elasticsearch/common/inject/TypeConverterBindingProcessor.java index 76c6248549f..040ef4098a1 100644 --- a/src/main/java/org/elasticsearch/common/inject/TypeConverterBindingProcessor.java +++ b/src/main/java/org/elasticsearch/common/inject/TypeConverterBindingProcessor.java @@ -67,7 +67,8 @@ class TypeConverterBindingProcessor extends AbstractProcessor { return value.charAt(0); } - @Override public String toString() { + @Override + public String toString() { return "TypeConverter"; } }); @@ -78,7 +79,8 @@ class TypeConverterBindingProcessor extends AbstractProcessor { return Enum.valueOf((Class) toType.getRawType(), value); } - @Override public String toString() { + @Override + public String toString() { return "TypeConverter>"; } }); @@ -89,7 +91,8 @@ class TypeConverterBindingProcessor extends AbstractProcessor { return typeLiteral.getRawType() == Class.class; } - @Override public String toString() { + @Override + public String toString() { return "Class"; } }, @@ -103,7 +106,8 @@ class TypeConverterBindingProcessor extends AbstractProcessor { } } - @Override public String toString() { + @Override + public String toString() { return "TypeConverter>"; } } @@ -130,7 +134,8 @@ class TypeConverterBindingProcessor extends AbstractProcessor { } } - @Override public String toString() { + @Override + public String toString() { return "TypeConverter<" + wrapperType.getSimpleName() + ">"; } }; @@ -148,19 +153,20 @@ class TypeConverterBindingProcessor extends AbstractProcessor { private void convertToClasses(final Matcher> typeMatcher, TypeConverter converter) { internalConvertToTypes(new AbstractMatcher>() { - public boolean matches(TypeLiteral typeLiteral) { - Type type = typeLiteral.getType(); - if (!(type instanceof Class)) { - return false; - } - Class clazz = (Class) type; - return typeMatcher.matches(clazz); - } + public boolean matches(TypeLiteral typeLiteral) { + Type type = typeLiteral.getType(); + if (!(type instanceof Class)) { + return false; + } + Class clazz = (Class) type; + return typeMatcher.matches(clazz); + } - @Override public String toString() { - return typeMatcher.toString(); - } - }, converter); + @Override + public String toString() { + return typeMatcher.toString(); + } + }, converter); } private void internalConvertToTypes(Matcher> typeMatcher, @@ -169,7 +175,8 @@ class TypeConverterBindingProcessor extends AbstractProcessor { new MatcherAndConverter(typeMatcher, converter, SourceProvider.UNKNOWN_SOURCE)); } - @Override public Boolean visit(TypeConverterBinding command) { + @Override + public Boolean visit(TypeConverterBinding command) { injector.state.addConverter(new MatcherAndConverter( command.getTypeMatcher(), command.getTypeConverter(), command.getSource())); return true; diff --git a/src/main/java/org/elasticsearch/common/inject/TypeListenerBindingProcessor.java b/src/main/java/org/elasticsearch/common/inject/TypeListenerBindingProcessor.java index f6eaa9b57b4..4139fc04f2d 100644 --- a/src/main/java/org/elasticsearch/common/inject/TypeListenerBindingProcessor.java +++ b/src/main/java/org/elasticsearch/common/inject/TypeListenerBindingProcessor.java @@ -30,7 +30,8 @@ class TypeListenerBindingProcessor extends AbstractProcessor { super(errors); } - @Override public Boolean visit(TypeListenerBinding binding) { + @Override + public Boolean visit(TypeListenerBinding binding) { injector.state.addTypeListener(binding); return true; } diff --git a/src/main/java/org/elasticsearch/common/inject/TypeLiteral.java b/src/main/java/org/elasticsearch/common/inject/TypeLiteral.java index feef3b0afe1..0a31c207a75 100644 --- a/src/main/java/org/elasticsearch/common/inject/TypeLiteral.java +++ b/src/main/java/org/elasticsearch/common/inject/TypeLiteral.java @@ -16,46 +16,39 @@ package org.elasticsearch.common.inject; -import org.elasticsearch.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList; import org.elasticsearch.common.inject.internal.MoreTypes; import org.elasticsearch.common.inject.util.Types; -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.GenericArrayType; -import java.lang.reflect.Member; -import java.lang.reflect.Method; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.lang.reflect.TypeVariable; -import java.lang.reflect.WildcardType; +import java.lang.reflect.*; import java.util.List; -import static org.elasticsearch.common.base.Preconditions.*; -import static org.elasticsearch.common.inject.internal.MoreTypes.*; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; +import static org.elasticsearch.common.inject.internal.MoreTypes.canonicalize; /** * Represents a generic type {@code T}. Java doesn't yet provide a way to * represent generic types, so this class does. Forces clients to create a * subclass of this class which enables retrieval the type information even at * runtime. - * + *

        *

        For example, to create a type literal for {@code List}, you can * create an empty anonymous inner class: - * - *

        + *

        + *

        * {@code TypeLiteral> list = new TypeLiteral>() {};} - * + *

        *

        This syntax cannot be used to create type literals that have wildcard * parameters, such as {@code Class} or {@code List}. * Such type literals must be constructed programatically, either by {@link * Method#getGenericReturnType extracting types from members} or by using the * {@link Types} factory class. - * + *

        *

        Along with modeling generic types, this class can resolve type parameters. * For example, to figure out what type {@code keySet()} returns on a {@code * Map}, use this code:

           {@code
        - *
        + * 

        * TypeLiteral> mapType * = new TypeLiteral>() {}; * TypeLiteral keySetType @@ -74,7 +67,7 @@ public class TypeLiteral { /** * Constructs a new type literal. Derives represented class from type * parameter. - * + *

        *

        Clients create an empty anonymous subclass. Doing so embeds the type * parameter in the anonymous class's type hierarchy so we can reconstitute it * at runtime despite erasure. @@ -89,7 +82,8 @@ public class TypeLiteral { /** * Unsafe. Constructs a type literal manually. */ - @SuppressWarnings("unchecked") TypeLiteral(Type type) { + @SuppressWarnings("unchecked") + TypeLiteral(Type type) { this.type = canonicalize(checkNotNull(type, "type")); this.rawType = (Class) MoreTypes.getRawType(this.type); this.hashCode = MoreTypes.hashCode(this.type); @@ -141,16 +135,19 @@ public class TypeLiteral { return (TypeLiteral>) get(Types.providerOf(getType())); } - @Override public final int hashCode() { + @Override + public final int hashCode() { return this.hashCode; } - @Override public final boolean equals(Object o) { + @Override + public final boolean equals(Object o) { return o instanceof TypeLiteral && MoreTypes.equals(type, ((TypeLiteral) o).type); } - @Override public final String toString() { + @Override + public final String toString() { return MoreTypes.toString(type); } diff --git a/src/main/java/org/elasticsearch/common/inject/WeakKeySet.java b/src/main/java/org/elasticsearch/common/inject/WeakKeySet.java index 3553a0cfa8d..bff939dd139 100644 --- a/src/main/java/org/elasticsearch/common/inject/WeakKeySet.java +++ b/src/main/java/org/elasticsearch/common/inject/WeakKeySet.java @@ -16,7 +16,7 @@ package org.elasticsearch.common.inject; -import org.elasticsearch.common.collect.Sets; +import com.google.common.collect.Sets; import java.util.Set; @@ -29,7 +29,7 @@ final class WeakKeySet { /** * We store strings rather than keys so we don't hold strong references. - * + *

        *

        One potential problem with this approach is that parent and child injectors cannot define * keys whose class names are equal but class loaders are different. This shouldn't be an issue * in practice. diff --git a/src/main/java/org/elasticsearch/common/inject/assistedinject/Assisted.java b/src/main/java/org/elasticsearch/common/inject/assistedinject/Assisted.java index 43e46d4b4fd..7dba708ef01 100644 --- a/src/main/java/org/elasticsearch/common/inject/assistedinject/Assisted.java +++ b/src/main/java/org/elasticsearch/common/inject/assistedinject/Assisted.java @@ -22,7 +22,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.Target; import static java.lang.annotation.ElementType.*; -import static java.lang.annotation.RetentionPolicy.*; +import static java.lang.annotation.RetentionPolicy.RUNTIME; /** * Annotates an injected parameter or field whose value comes from an argument to a factory method. diff --git a/src/main/java/org/elasticsearch/common/inject/assistedinject/AssistedConstructor.java b/src/main/java/org/elasticsearch/common/inject/assistedinject/AssistedConstructor.java index 0cc2b8e04ac..29bbd6b91ec 100644 --- a/src/main/java/org/elasticsearch/common/inject/assistedinject/AssistedConstructor.java +++ b/src/main/java/org/elasticsearch/common/inject/assistedinject/AssistedConstructor.java @@ -16,7 +16,7 @@ package org.elasticsearch.common.inject.assistedinject; -import org.elasticsearch.common.collect.Lists; +import com.google.common.collect.Lists; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.TypeLiteral; @@ -24,11 +24,7 @@ import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; /** * Internal respresentation of a constructor annotated with diff --git a/src/main/java/org/elasticsearch/common/inject/assistedinject/AssistedInject.java b/src/main/java/org/elasticsearch/common/inject/assistedinject/AssistedInject.java index 62f56f991f4..cbba8be2373 100644 --- a/src/main/java/org/elasticsearch/common/inject/assistedinject/AssistedInject.java +++ b/src/main/java/org/elasticsearch/common/inject/assistedinject/AssistedInject.java @@ -19,14 +19,14 @@ package org.elasticsearch.common.inject.assistedinject; import java.lang.annotation.Retention; import java.lang.annotation.Target; -import static java.lang.annotation.ElementType.*; -import static java.lang.annotation.RetentionPolicy.*; +import static java.lang.annotation.ElementType.CONSTRUCTOR; +import static java.lang.annotation.RetentionPolicy.RUNTIME; /** *

        Constructors annotated with {@code @AssistedInject} indicate that they can be instantiated by * the {@link FactoryProvider}. Each constructor must exactly match one corresponding factory method * within the factory interface. - * + *

        *

        Constructor parameters must be either supplied by the factory interface and marked with * @Assisted, or they must be injectable. * diff --git a/src/main/java/org/elasticsearch/common/inject/assistedinject/FactoryProvider.java b/src/main/java/org/elasticsearch/common/inject/assistedinject/FactoryProvider.java index e72f08ec757..5b29ce44e08 100644 --- a/src/main/java/org/elasticsearch/common/inject/assistedinject/FactoryProvider.java +++ b/src/main/java/org/elasticsearch/common/inject/assistedinject/FactoryProvider.java @@ -16,27 +16,18 @@ package org.elasticsearch.common.inject.assistedinject; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.collect.Maps; -import org.elasticsearch.common.inject.ConfigurationException; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.inject.Injector; -import org.elasticsearch.common.inject.Key; -import org.elasticsearch.common.inject.Provider; -import org.elasticsearch.common.inject.TypeLiteral; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import org.elasticsearch.common.inject.*; import org.elasticsearch.common.inject.internal.Errors; import org.elasticsearch.common.inject.spi.Dependency; import org.elasticsearch.common.inject.spi.HasDependencies; import org.elasticsearch.common.inject.spi.Message; import java.lang.annotation.Annotation; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; -import java.lang.reflect.Type; +import java.lang.reflect.*; import java.util.List; import java.util.Map; import java.util.Set; @@ -44,7 +35,7 @@ import java.util.Set; /** * Provides a factory that combines the caller's arguments with injector-supplied values to * construct objects. - * + *

        *

        Defining a factory

        * Create an interface whose methods return the constructed type, or any of its supertypes. The * method's parameters are the arguments required to build the constructed type. @@ -53,7 +44,7 @@ import java.util.Set; * }
        * You can name your factory methods whatever you like, such as create, createPayment * or newPayment. - * + *

        *

        Creating a type that accepts factory parameters

        * {@code constructedType} is a concrete class with an {@literal @}{@link Inject}-annotated * constructor. In addition to injector-supplied parameters, the constructor should have @@ -71,7 +62,7 @@ import java.util.Set; * } * }
        * Any parameter that permits a null value should also be annotated {@code @Nullable}. - * + *

        *

        Configuring factories

        * In your {@link org.elasticsearch.common.inject.Module module}, bind the factory interface to the returned * factory: @@ -79,24 +70,24 @@ import java.util.Set; * FactoryProvider.newFactory(PaymentFactory.class, RealPayment.class));
        * As a side-effect of this binding, Guice will inject the factory to initialize it for use. The * factory cannot be used until the injector has been initialized. - * + *

        *

        Using the factory

        * Inject your factory into your application classes. When you use the factory, your arguments * will be combined with values from the injector to construct an instance. *
        public class PaymentAction {
          *   {@literal @}Inject private PaymentFactory paymentFactory;
        - *
        + * 

        * public void doPayment(Money amount) { * Payment payment = paymentFactory.create(new Date(), amount); * payment.apply(); * } * }

        - * + *

        *

        Making parameter types distinct

        * The types of the factory method's parameters must be distinct. To use multiple parameters of * the same type, use a named {@literal @}{@link Assisted} annotation to disambiguate the * parameters. The names must be applied to the factory method's parameters: - * + *

        *

        public interface PaymentFactory {
          *   Payment create(
          *       {@literal @}Assisted("startDate") Date startDate,
        @@ -115,21 +106,21 @@ import java.util.Set;
          *     ...
          *   }
          * }
        - * + *

        *

        Values are created by Guice

        * Returned factories use child injectors to create values. The values are eligible for method * interception. In addition, {@literal @}{@literal Inject} members will be injected before they are * returned. - * + *

        *

        Backwards compatibility using {@literal @}AssistedInject

        * Instead of the {@literal @}Inject annotation, you may annotate the constructed classes with * {@literal @}{@link AssistedInject}. This triggers a limited backwards-compatability mode. - * + *

        *

        Instead of matching factory method arguments to constructor parameters using their names, the * parameters are matched by their order. The first factory method argument is * used for the first {@literal @}Assisted constructor parameter, etc.. Annotation names have no * effect. - * + *

        *

        Returned values are not created by Guice. These types are not eligible for * method interception. They do receive post-construction member injection. * @@ -174,7 +165,8 @@ public class FactoryProvider implements Provider, HasDependencies { checkDeclaredExceptionsMatch(); } - @Inject void setInjectorAndCheckUnboundParametersAreInjectable(Injector injector) { + @Inject + void setInjectorAndCheckUnboundParametersAreInjectable(Injector injector) { this.injector = injector; for (AssistedConstructor c : factoryMethodToConstructor.values()) { for (Parameter p : c.getAllParameters()) { diff --git a/src/main/java/org/elasticsearch/common/inject/assistedinject/FactoryProvider2.java b/src/main/java/org/elasticsearch/common/inject/assistedinject/FactoryProvider2.java index 30e82da0f97..32ae6c665f2 100644 --- a/src/main/java/org/elasticsearch/common/inject/assistedinject/FactoryProvider2.java +++ b/src/main/java/org/elasticsearch/common/inject/assistedinject/FactoryProvider2.java @@ -16,10 +16,10 @@ package org.elasticsearch.common.inject.assistedinject; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.Iterables; -import org.elasticsearch.common.collect.Lists; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; import org.elasticsearch.common.inject.*; import org.elasticsearch.common.inject.internal.Errors; import org.elasticsearch.common.inject.internal.ErrorsException; @@ -33,8 +33,8 @@ import java.lang.reflect.Proxy; import java.util.Arrays; import java.util.List; -import static org.elasticsearch.common.base.Preconditions.*; -import static org.elasticsearch.common.inject.internal.Annotations.*; +import static com.google.common.base.Preconditions.checkState; +import static org.elasticsearch.common.inject.internal.Annotations.getKey; /** * The newer implementation of factory provider. This implementation uses a child injector to @@ -57,16 +57,19 @@ final class FactoryProvider2 implements InvocationHandler, Provider { return Assisted.class; } - @Override public boolean equals(Object o) { + @Override + public boolean equals(Object o) { return o instanceof Assisted && ((Assisted) o).value().equals(""); } - @Override public int hashCode() { + @Override + public int hashCode() { return 127 * "value".hashCode() ^ "".hashCode(); } - @Override public String toString() { + @Override + public String toString() { return "@" + Assisted.class.getName() + "(value=)"; } }; @@ -156,7 +159,8 @@ final class FactoryProvider2 implements InvocationHandler, Provider { * At injector-creation time, we initialize the invocation handler. At this time we make sure * all factory methods will be able to build the target types. */ - @Inject void initialize(Injector injector) { + @Inject + void initialize(Injector injector) { if (this.injector != null) { throw new ConfigurationException(ImmutableList.of(new Message(FactoryProvider2.class, "Factories.create() factories may only be used in one Injector!"))); @@ -228,12 +232,14 @@ final class FactoryProvider2 implements InvocationHandler, Provider { } } - @Override public String toString() { + @Override + public String toString() { return factory.getClass().getInterfaces()[0].getName() + " for " + producedType.getTypeLiteral(); } - @Override public boolean equals(Object o) { + @Override + public boolean equals(Object o) { return o == this || o == factory; } diff --git a/src/main/java/org/elasticsearch/common/inject/assistedinject/Parameter.java b/src/main/java/org/elasticsearch/common/inject/assistedinject/Parameter.java index f13d4f2825a..a882b9fb280 100644 --- a/src/main/java/org/elasticsearch/common/inject/assistedinject/Parameter.java +++ b/src/main/java/org/elasticsearch/common/inject/assistedinject/Parameter.java @@ -16,17 +16,13 @@ package org.elasticsearch.common.inject.assistedinject; -import org.elasticsearch.common.inject.BindingAnnotation; -import org.elasticsearch.common.inject.ConfigurationException; -import org.elasticsearch.common.inject.Injector; -import org.elasticsearch.common.inject.Key; -import org.elasticsearch.common.inject.Provider; +import org.elasticsearch.common.inject.*; import java.lang.annotation.Annotation; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; -import static org.elasticsearch.common.base.Preconditions.*; +import static com.google.common.base.Preconditions.checkArgument; /** * Models a method or constructor parameter. @@ -107,7 +103,7 @@ class Parameter { /** * Replace annotation instances with annotation types, this is only * appropriate for testing if a key is bound and not for injecting. - * + *

        * See Guice bug 125, * http://code.google.com/p/google-guice/issues/detail?id=125 */ diff --git a/src/main/java/org/elasticsearch/common/inject/internal/AbstractBindingBuilder.java b/src/main/java/org/elasticsearch/common/inject/internal/AbstractBindingBuilder.java index 9cf7b63a74e..b1057a16587 100644 --- a/src/main/java/org/elasticsearch/common/inject/internal/AbstractBindingBuilder.java +++ b/src/main/java/org/elasticsearch/common/inject/internal/AbstractBindingBuilder.java @@ -25,7 +25,7 @@ import org.elasticsearch.common.inject.spi.InstanceBinding; import java.lang.annotation.Annotation; import java.util.List; -import static org.elasticsearch.common.base.Preconditions.*; +import static com.google.common.base.Preconditions.checkNotNull; /** * Bind a value or constant. diff --git a/src/main/java/org/elasticsearch/common/inject/internal/BindingBuilder.java b/src/main/java/org/elasticsearch/common/inject/internal/BindingBuilder.java index f1fe38dd569..98243820448 100644 --- a/src/main/java/org/elasticsearch/common/inject/internal/BindingBuilder.java +++ b/src/main/java/org/elasticsearch/common/inject/internal/BindingBuilder.java @@ -16,12 +16,8 @@ package org.elasticsearch.common.inject.internal; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.inject.Binder; -import org.elasticsearch.common.inject.ConfigurationException; -import org.elasticsearch.common.inject.Key; -import org.elasticsearch.common.inject.Provider; -import org.elasticsearch.common.inject.TypeLiteral; +import com.google.common.collect.ImmutableSet; +import org.elasticsearch.common.inject.*; import org.elasticsearch.common.inject.binder.AnnotatedBindingBuilder; import org.elasticsearch.common.inject.spi.Element; import org.elasticsearch.common.inject.spi.InjectionPoint; @@ -31,7 +27,7 @@ import java.lang.annotation.Annotation; import java.util.List; import java.util.Set; -import static org.elasticsearch.common.base.Preconditions.*; +import static com.google.common.base.Preconditions.checkNotNull; /** * Bind a non-constant key. @@ -131,7 +127,8 @@ public class BindingBuilder extends AbstractBindingBuilder return this; } - @Override public String toString() { + @Override + public String toString() { return "BindingBuilder<" + getBinding().getKey().getTypeLiteral() + ">"; } } diff --git a/src/main/java/org/elasticsearch/common/inject/internal/BindingImpl.java b/src/main/java/org/elasticsearch/common/inject/internal/BindingImpl.java index 23d03e45e81..2bca257cf90 100644 --- a/src/main/java/org/elasticsearch/common/inject/internal/BindingImpl.java +++ b/src/main/java/org/elasticsearch/common/inject/internal/BindingImpl.java @@ -105,7 +105,8 @@ public abstract class BindingImpl implements Binding { throw new AssertionError(); } - @Override public String toString() { + @Override + public String toString() { return new ToStringBuilder(Binding.class) .add("key", key) .add("scope", scoping) diff --git a/src/main/java/org/elasticsearch/common/inject/internal/BytecodeGen.java b/src/main/java/org/elasticsearch/common/inject/internal/BytecodeGen.java index edd8790b9ff..113a9ed7991 100644 --- a/src/main/java/org/elasticsearch/common/inject/internal/BytecodeGen.java +++ b/src/main/java/org/elasticsearch/common/inject/internal/BytecodeGen.java @@ -16,8 +16,8 @@ package org.elasticsearch.common.inject.internal; -import org.elasticsearch.common.base.Function; -import org.elasticsearch.common.collect.MapMaker; +import com.google.common.base.Function; +import com.google.common.collect.MapMaker; import java.lang.reflect.Constructor; import java.lang.reflect.Member; @@ -28,13 +28,13 @@ import java.security.PrivilegedAction; import java.util.Map; import java.util.logging.Logger; -import static org.elasticsearch.common.base.Preconditions.*; +import static com.google.common.base.Preconditions.checkNotNull; /** * Utility methods for runtime code generation and class loading. We use this stuff for {@link * net.sf.cglib.reflect.FastClass faster reflection}, {@link net.sf.cglib.proxy.Enhancer method * interceptors} and to proxy circular dependencies. - * + *

        *

        When loading classes, we need to be careful of: *

          *
        • Memory leaks. Generated classes need to be garbage collected in long-lived @@ -43,7 +43,7 @@ import static org.elasticsearch.common.base.Preconditions.*; *
        • Visibility. Containers like OSGi use class loader boundaries * to enforce modularity at runtime. *
        - * + *

        *

        For each generated class, there's multiple class loaders involved: *

          *
        • The related class's class loader. Every generated class services exactly @@ -213,7 +213,8 @@ public final class BytecodeGen { super(usersClassLoader); } - @Override protected Class loadClass(String name, boolean resolve) + @Override + protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException { // delegate internal requests to Guice class space diff --git a/src/main/java/org/elasticsearch/common/inject/internal/ConstantBindingBuilderImpl.java b/src/main/java/org/elasticsearch/common/inject/internal/ConstantBindingBuilderImpl.java index c9f91bd5372..7d9e91f5fd2 100644 --- a/src/main/java/org/elasticsearch/common/inject/internal/ConstantBindingBuilderImpl.java +++ b/src/main/java/org/elasticsearch/common/inject/internal/ConstantBindingBuilderImpl.java @@ -16,7 +16,7 @@ package org.elasticsearch.common.inject.internal; -import org.elasticsearch.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSet; import org.elasticsearch.common.inject.Binder; import org.elasticsearch.common.inject.Key; import org.elasticsearch.common.inject.binder.AnnotatedConstantBindingBuilder; @@ -121,7 +121,8 @@ public final class ConstantBindingBuilderImpl base.getSource(), key, base.getScoping(), ImmutableSet.of(), instanceAsT)); } - @Override public String toString() { + @Override + public String toString() { return "ConstantBindingBuilder"; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/common/inject/internal/Errors.java b/src/main/java/org/elasticsearch/common/inject/internal/Errors.java index 2774fe8a625..c764fdb4251 100644 --- a/src/main/java/org/elasticsearch/common/inject/internal/Errors.java +++ b/src/main/java/org/elasticsearch/common/inject/internal/Errors.java @@ -16,22 +16,11 @@ package org.elasticsearch.common.inject.internal; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.inject.ConfigurationException; -import org.elasticsearch.common.inject.CreationException; -import org.elasticsearch.common.inject.Key; -import org.elasticsearch.common.inject.MembersInjector; -import org.elasticsearch.common.inject.Provider; -import org.elasticsearch.common.inject.ProvisionException; -import org.elasticsearch.common.inject.Scope; -import org.elasticsearch.common.inject.TypeLiteral; -import org.elasticsearch.common.inject.spi.Dependency; -import org.elasticsearch.common.inject.spi.InjectionListener; -import org.elasticsearch.common.inject.spi.InjectionPoint; -import org.elasticsearch.common.inject.spi.Message; -import org.elasticsearch.common.inject.spi.TypeListenerBinding; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import org.elasticsearch.common.inject.*; +import org.elasticsearch.common.inject.spi.*; import java.io.PrintWriter; import java.io.Serializable; @@ -41,20 +30,16 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Member; import java.lang.reflect.Type; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.Formatter; -import java.util.List; +import java.util.*; /** * A collection of error messages. If this type is passed as a method parameter, the method is * considered to have executed succesfully only if new errors were not added to this collection. - * + *

          *

          Errors can be chained to provide additional context. To add context, call {@link #withSource} * to create a new Errors instance that contains additional context. All messages added to the * returned instance will contain full context. - * + *

          *

          To avoid messages with redundant context, {@link #withSource} should be added sparingly. A * good rule of thumb is to assume a ethod's caller has already specified enough context to * identify that method. When calling a method that's defined in a different context, call that diff --git a/src/main/java/org/elasticsearch/common/inject/internal/ExposedBindingImpl.java b/src/main/java/org/elasticsearch/common/inject/internal/ExposedBindingImpl.java index 13a249fae51..c89952c6de7 100644 --- a/src/main/java/org/elasticsearch/common/inject/internal/ExposedBindingImpl.java +++ b/src/main/java/org/elasticsearch/common/inject/internal/ExposedBindingImpl.java @@ -16,7 +16,7 @@ package org.elasticsearch.common.inject.internal; -import org.elasticsearch.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSet; import org.elasticsearch.common.inject.Binder; import org.elasticsearch.common.inject.Injector; import org.elasticsearch.common.inject.Key; @@ -63,7 +63,8 @@ public class ExposedBindingImpl extends BindingImpl implements ExposedBind return new ExposedBindingImpl(getSource(), key, getScoping(), privateElements); } - @Override public String toString() { + @Override + public String toString() { return new ToStringBuilder(ExposedBinding.class) .add("key", getKey()) .add("source", getSource()) diff --git a/src/main/java/org/elasticsearch/common/inject/internal/ExposureBuilder.java b/src/main/java/org/elasticsearch/common/inject/internal/ExposureBuilder.java index 646f10bed26..d9aef08e478 100644 --- a/src/main/java/org/elasticsearch/common/inject/internal/ExposureBuilder.java +++ b/src/main/java/org/elasticsearch/common/inject/internal/ExposureBuilder.java @@ -43,13 +43,13 @@ public class ExposureBuilder implements AnnotatedElementBuilder { } public void annotatedWith(Class annotationType) { - org.elasticsearch.common.base.Preconditions.checkNotNull(annotationType, "annotationType"); + com.google.common.base.Preconditions.checkNotNull(annotationType, "annotationType"); checkNotAnnotated(); key = Key.get(key.getTypeLiteral(), annotationType); } public void annotatedWith(Annotation annotation) { - org.elasticsearch.common.base.Preconditions.checkNotNull(annotation, "annotation"); + com.google.common.base.Preconditions.checkNotNull(annotation, "annotation"); checkNotAnnotated(); key = Key.get(key.getTypeLiteral(), annotation); } @@ -62,7 +62,8 @@ public class ExposureBuilder implements AnnotatedElementBuilder { return source; } - @Override public String toString() { + @Override + public String toString() { return "AnnotatedElementBuilder"; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/common/inject/internal/FailableCache.java b/src/main/java/org/elasticsearch/common/inject/internal/FailableCache.java index 6e5b9c81fb6..afcae7a997e 100644 --- a/src/main/java/org/elasticsearch/common/inject/internal/FailableCache.java +++ b/src/main/java/org/elasticsearch/common/inject/internal/FailableCache.java @@ -16,8 +16,8 @@ package org.elasticsearch.common.inject.internal; -import org.elasticsearch.common.base.Function; -import org.elasticsearch.common.collect.MapMaker; +import com.google.common.base.Function; +import com.google.common.collect.MapMaker; import java.util.Map; diff --git a/src/main/java/org/elasticsearch/common/inject/internal/InstanceBindingImpl.java b/src/main/java/org/elasticsearch/common/inject/internal/InstanceBindingImpl.java index e83b6396764..4710c588fb4 100644 --- a/src/main/java/org/elasticsearch/common/inject/internal/InstanceBindingImpl.java +++ b/src/main/java/org/elasticsearch/common/inject/internal/InstanceBindingImpl.java @@ -16,16 +16,12 @@ package org.elasticsearch.common.inject.internal; -import org.elasticsearch.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSet; import org.elasticsearch.common.inject.Binder; import org.elasticsearch.common.inject.Injector; import org.elasticsearch.common.inject.Key; import org.elasticsearch.common.inject.Provider; -import org.elasticsearch.common.inject.spi.BindingTargetVisitor; -import org.elasticsearch.common.inject.spi.Dependency; -import org.elasticsearch.common.inject.spi.HasDependencies; -import org.elasticsearch.common.inject.spi.InjectionPoint; -import org.elasticsearch.common.inject.spi.InstanceBinding; +import org.elasticsearch.common.inject.spi.*; import org.elasticsearch.common.inject.util.Providers; import java.util.Set; @@ -53,7 +49,8 @@ public class InstanceBindingImpl extends BindingImpl implements InstanceBi this.provider = Providers.of(instance); } - @Override public Provider getProvider() { + @Override + public Provider getProvider() { return this.provider; } @@ -88,7 +85,8 @@ public class InstanceBindingImpl extends BindingImpl implements InstanceBi binder.withSource(getSource()).bind(getKey()).toInstance(instance); } - @Override public String toString() { + @Override + public String toString() { return new ToStringBuilder(InstanceBinding.class) .add("key", getKey()) .add("source", getSource()) diff --git a/src/main/java/org/elasticsearch/common/inject/internal/InternalContext.java b/src/main/java/org/elasticsearch/common/inject/internal/InternalContext.java index a2e577c96f9..b16342cd696 100644 --- a/src/main/java/org/elasticsearch/common/inject/internal/InternalContext.java +++ b/src/main/java/org/elasticsearch/common/inject/internal/InternalContext.java @@ -16,7 +16,7 @@ package org.elasticsearch.common.inject.internal; -import org.elasticsearch.common.collect.Maps; +import com.google.common.collect.Maps; import org.elasticsearch.common.inject.spi.Dependency; import java.util.Map; diff --git a/src/main/java/org/elasticsearch/common/inject/internal/Join.java b/src/main/java/org/elasticsearch/common/inject/internal/Join.java index cf30f102bec..fd8348d8f34 100644 --- a/src/main/java/org/elasticsearch/common/inject/internal/Join.java +++ b/src/main/java/org/elasticsearch/common/inject/internal/Join.java @@ -16,21 +16,21 @@ package org.elasticsearch.common.inject.internal; -import org.elasticsearch.common.collect.Lists; +import com.google.common.collect.Lists; import java.io.IOException; import java.util.Arrays; import java.util.Iterator; import java.util.Map; -import static org.elasticsearch.common.base.Preconditions.*; +import static com.google.common.base.Preconditions.checkNotNull; /** * Utility for joining pieces of text separated by a delimiter. It can handle * iterators, collections, arrays, and varargs, and can append to any * {@link Appendable} or just return a {@link String}. For example, * {@code join(":", "a", "b", "c")} returns {@code "a:b:c"}. - * + *

          *

          All methods of this class throw {@link NullPointerException} when a value * of {@code null} is supplied for any parameter. The elements within the * collection, iterator, array, or varargs parameter list may be null -- @@ -46,7 +46,7 @@ public final class Join { * Returns a string containing the {@code tokens}, converted to strings if * necessary, separated by {@code delimiter}. If {@code tokens} is empty, it * returns an empty string. - * + *

          *

          Each token will be converted to a {@link CharSequence} using * {@link String#valueOf(Object)}, if it isn't a {@link CharSequence} already. * Note that this implies that null tokens will be appended as the @@ -65,7 +65,7 @@ public final class Join { * Returns a string containing the {@code tokens}, converted to strings if * necessary, separated by {@code delimiter}. If {@code tokens} is empty, it * returns an empty string. - * + *

          *

          Each token will be converted to a {@link CharSequence} using * {@link String#valueOf(Object)}, if it isn't a {@link CharSequence} already. * Note that this implies that null tokens will be appended as the @@ -83,7 +83,7 @@ public final class Join { /** * Returns a string containing the {@code tokens}, converted to strings if * necessary, separated by {@code delimiter}. - * + *

          *

          Each token will be converted to a {@link CharSequence} using * {@link String#valueOf(Object)}, if it isn't a {@link CharSequence} already. * Note that this implies that null tokens will be appended as the @@ -105,7 +105,7 @@ public final class Join { * Returns a string containing the {@code tokens}, converted to strings if * necessary, separated by {@code delimiter}. If {@code tokens} is empty, it * returns an empty string. - * + *

          *

          Each token will be converted to a {@link CharSequence} using * {@link String#valueOf(Object)}, if it isn't a {@link CharSequence} already. * Note that this implies that null tokens will be appended as the @@ -126,7 +126,7 @@ public final class Join { * Returns a string containing the contents of {@code map}, with entries * separated by {@code entryDelimiter}, and keys and values separated with * {@code keyValueSeparator}. - * + *

          *

          Each key and value will be converted to a {@link CharSequence} using * {@link String#valueOf(Object)}, if it isn't a {@link CharSequence} already. * Note that this implies that null tokens will be appended as the @@ -149,7 +149,7 @@ public final class Join { /** * Appends each of the {@code tokens} to {@code appendable}, separated by * {@code delimiter}. - * + *

          *

          Each token will be converted to a {@link CharSequence} using * {@link String#valueOf(Object)}, if it isn't a {@link CharSequence} already. * Note that this implies that null tokens will be appended as the @@ -170,7 +170,7 @@ public final class Join { /** * Appends each of the {@code tokens} to {@code appendable}, separated by * {@code delimiter}. - * + *

          *

          Each token will be converted to a {@link CharSequence} using * {@link String#valueOf(Object)}, if it isn't a {@link CharSequence} already. * Note that this implies that null tokens will be appended as the @@ -191,7 +191,7 @@ public final class Join { /** * Appends each of the {@code tokens} to {@code appendable}, separated by * {@code delimiter}. - * + *

          *

          Each token will be converted to a {@link CharSequence} using * {@link String#valueOf(Object)}, if it isn't a {@link CharSequence} already. * Note that this implies that null tokens will be appended as the @@ -214,7 +214,7 @@ public final class Join { /** * Appends each of the {@code tokens} to {@code appendable}, separated by * {@code delimiter}. - * + *

          *

          Each token will be converted to a {@link CharSequence} using * {@link String#valueOf(Object)}, if it isn't a {@link CharSequence} already. * Note that this implies that null tokens will be appended as the @@ -252,7 +252,7 @@ public final class Join { * Appends the contents of {@code map} to {@code appendable}, with entries * separated by {@code entryDelimiter}, and keys and values separated with * {@code keyValueSeparator}. - * + *

          *

          Each key and value will be converted to a {@link CharSequence} using * {@link String#valueOf(Object)}, if it isn't a {@link CharSequence} already. * Note that this implies that null tokens will be appended as the diff --git a/src/main/java/org/elasticsearch/common/inject/internal/LinkedBindingImpl.java b/src/main/java/org/elasticsearch/common/inject/internal/LinkedBindingImpl.java index 77ea2975c46..c4b8e49fbeb 100644 --- a/src/main/java/org/elasticsearch/common/inject/internal/LinkedBindingImpl.java +++ b/src/main/java/org/elasticsearch/common/inject/internal/LinkedBindingImpl.java @@ -58,7 +58,8 @@ public final class LinkedBindingImpl extends BindingImpl implements Linked getScoping().applyTo(binder.withSource(getSource()).bind(getKey()).to(getLinkedKey())); } - @Override public String toString() { + @Override + public String toString() { return new ToStringBuilder(LinkedKeyBinding.class) .add("key", getKey()) .add("source", getSource()) diff --git a/src/main/java/org/elasticsearch/common/inject/internal/LinkedProviderBindingImpl.java b/src/main/java/org/elasticsearch/common/inject/internal/LinkedProviderBindingImpl.java index ab3b6c4e0d8..416dab2aad2 100644 --- a/src/main/java/org/elasticsearch/common/inject/internal/LinkedProviderBindingImpl.java +++ b/src/main/java/org/elasticsearch/common/inject/internal/LinkedProviderBindingImpl.java @@ -62,7 +62,8 @@ public final class LinkedProviderBindingImpl .bind(getKey()).toProvider(getProviderKey())); } - @Override public String toString() { + @Override + public String toString() { return new ToStringBuilder(ProviderKeyBinding.class) .add("key", getKey()) .add("source", getSource()) diff --git a/src/main/java/org/elasticsearch/common/inject/internal/MatcherAndConverter.java b/src/main/java/org/elasticsearch/common/inject/internal/MatcherAndConverter.java index e05672d56c8..7ee9313041f 100644 --- a/src/main/java/org/elasticsearch/common/inject/internal/MatcherAndConverter.java +++ b/src/main/java/org/elasticsearch/common/inject/internal/MatcherAndConverter.java @@ -20,7 +20,7 @@ import org.elasticsearch.common.inject.TypeLiteral; import org.elasticsearch.common.inject.matcher.Matcher; import org.elasticsearch.common.inject.spi.TypeConverter; -import static org.elasticsearch.common.base.Preconditions.*; +import static com.google.common.base.Preconditions.checkNotNull; /** * @author crazybob@google.com (Bob Lee) @@ -50,7 +50,8 @@ public final class MatcherAndConverter { return source; } - @Override public String toString() { + @Override + public String toString() { return typeConverter + " which matches " + typeMatcher + " (bound at " + source + ")"; } diff --git a/src/main/java/org/elasticsearch/common/inject/internal/MoreTypes.java b/src/main/java/org/elasticsearch/common/inject/internal/MoreTypes.java index f41a92a6b7f..7843c283c3a 100644 --- a/src/main/java/org/elasticsearch/common/inject/internal/MoreTypes.java +++ b/src/main/java/org/elasticsearch/common/inject/internal/MoreTypes.java @@ -17,8 +17,8 @@ package org.elasticsearch.common.inject.internal; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import org.elasticsearch.common.inject.ConfigurationException; import org.elasticsearch.common.inject.TypeLiteral; import org.elasticsearch.common.inject.spi.Message; @@ -29,7 +29,8 @@ import java.util.Arrays; import java.util.Map; import java.util.NoSuchElementException; -import static org.elasticsearch.common.base.Preconditions.*; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; /** * Static methods for working with types that we aren't publishing in the @@ -490,16 +491,19 @@ public class MoreTypes { return true; } - @Override public boolean equals(Object other) { + @Override + public boolean equals(Object other) { return other instanceof ParameterizedType && MoreTypes.equals(this, (ParameterizedType) other); } - @Override public int hashCode() { + @Override + public int hashCode() { return MoreTypes.hashCode(this); } - @Override public String toString() { + @Override + public String toString() { return MoreTypes.toString(this); } @@ -522,16 +526,19 @@ public class MoreTypes { return MoreTypes.isFullySpecified(componentType); } - @Override public boolean equals(Object o) { + @Override + public boolean equals(Object o) { return o instanceof GenericArrayType && MoreTypes.equals(this, (GenericArrayType) o); } - @Override public int hashCode() { + @Override + public int hashCode() { return MoreTypes.hashCode(this); } - @Override public String toString() { + @Override + public String toString() { return MoreTypes.toString(this); } @@ -579,16 +586,19 @@ public class MoreTypes { && (lowerBound == null || MoreTypes.isFullySpecified(lowerBound)); } - @Override public boolean equals(Object other) { + @Override + public boolean equals(Object other) { return other instanceof WildcardType && MoreTypes.equals(this, (WildcardType) other); } - @Override public int hashCode() { + @Override + public int hashCode() { return MoreTypes.hashCode(this); } - @Override public String toString() { + @Override + public String toString() { return MoreTypes.toString(this); } @@ -638,7 +648,8 @@ public class MoreTypes { return synthetic; } - @Override public String toString() { + @Override + public String toString() { return MoreTypes.toString(this); } } diff --git a/src/main/java/org/elasticsearch/common/inject/internal/Nullability.java b/src/main/java/org/elasticsearch/common/inject/internal/Nullability.java index 51ed18ffe08..621ff4d7562 100644 --- a/src/main/java/org/elasticsearch/common/inject/internal/Nullability.java +++ b/src/main/java/org/elasticsearch/common/inject/internal/Nullability.java @@ -4,11 +4,11 @@ import java.lang.annotation.Annotation; /** * Whether a member supports null values injected. - * + *

          *

          Support for {@code Nullable} annotations in Guice is loose. * Any annotation type whose simplename is "Nullable" is sufficient to indicate * support for null values injected. - * + *

          *

          This allows support for JSR-305's * * javax.annotation.meta.Nullable annotation and IntelliJ IDEA's diff --git a/src/main/java/org/elasticsearch/common/inject/internal/Nullable.java b/src/main/java/org/elasticsearch/common/inject/internal/Nullable.java index 266d8e37daa..ec48aedb6eb 100644 --- a/src/main/java/org/elasticsearch/common/inject/internal/Nullable.java +++ b/src/main/java/org/elasticsearch/common/inject/internal/Nullable.java @@ -16,17 +16,13 @@ package org.elasticsearch.common.inject.internal; -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; +import java.lang.annotation.*; /** * The presence of this annotation on a method parameter indicates that * {@code null} is an acceptable value for that parameter. It should not be * used for parameters of primitive types. - * + *

          *

          This annotation may be used with the Google Web Toolkit (GWT). * * @author Kevin Bourrillion diff --git a/src/main/java/org/elasticsearch/common/inject/internal/Objects.java b/src/main/java/org/elasticsearch/common/inject/internal/Objects.java index fb679ec44c4..60a9899f1ad 100644 --- a/src/main/java/org/elasticsearch/common/inject/internal/Objects.java +++ b/src/main/java/org/elasticsearch/common/inject/internal/Objects.java @@ -29,14 +29,14 @@ public final class Objects { /** * Determines whether two possibly-null objects are equal. Returns: - * + *

          *

            *
          • {@code true} if {@code a} and {@code b} are both null. *
          • {@code true} if {@code a} and {@code b} are both non-null and they are * equal according to {@link Object#equals(Object)}. *
          • {@code false} in all other situations. *
          - * + *

          *

          This assumes that any non-null objects passed to this function conform * to the {@code equals()} contract. */ @@ -47,7 +47,7 @@ public final class Objects { /** * Generates a hash code for multiple values. The hash code is generated by * calling {@link Arrays#hashCode(Object[])}. - * + *

          *

          This is useful for implementing {@link Object#hashCode()}. For example, * in an object that has three properties, {@code x}, {@code y}, and * {@code z}, one could write: diff --git a/src/main/java/org/elasticsearch/common/inject/internal/PrivateElementsImpl.java b/src/main/java/org/elasticsearch/common/inject/internal/PrivateElementsImpl.java index 96b91bb4129..39bdff130ed 100644 --- a/src/main/java/org/elasticsearch/common/inject/internal/PrivateElementsImpl.java +++ b/src/main/java/org/elasticsearch/common/inject/internal/PrivateElementsImpl.java @@ -16,10 +16,10 @@ package org.elasticsearch.common.inject.internal; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.collect.Maps; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import org.elasticsearch.common.inject.Binder; import org.elasticsearch.common.inject.Injector; import org.elasticsearch.common.inject.Key; @@ -32,7 +32,7 @@ import java.util.List; import java.util.Map; import java.util.Set; -import static org.elasticsearch.common.base.Preconditions.*; +import static com.google.common.base.Preconditions.*; /** * @author jessewilson@google.com (Jesse Wilson) @@ -132,7 +132,8 @@ public final class PrivateElementsImpl implements PrivateElements { return source; } - @Override public String toString() { + @Override + public String toString() { return new ToStringBuilder(PrivateElements.class) .add("exposedKeys", getExposedKeys()) .add("source", getSource()) diff --git a/src/main/java/org/elasticsearch/common/inject/internal/ProviderInstanceBindingImpl.java b/src/main/java/org/elasticsearch/common/inject/internal/ProviderInstanceBindingImpl.java index e91b53fe5da..b384b7931d1 100644 --- a/src/main/java/org/elasticsearch/common/inject/internal/ProviderInstanceBindingImpl.java +++ b/src/main/java/org/elasticsearch/common/inject/internal/ProviderInstanceBindingImpl.java @@ -16,16 +16,12 @@ limitations under the License. package org.elasticsearch.common.inject.internal; -import org.elasticsearch.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSet; import org.elasticsearch.common.inject.Binder; import org.elasticsearch.common.inject.Injector; import org.elasticsearch.common.inject.Key; import org.elasticsearch.common.inject.Provider; -import org.elasticsearch.common.inject.spi.BindingTargetVisitor; -import org.elasticsearch.common.inject.spi.Dependency; -import org.elasticsearch.common.inject.spi.HasDependencies; -import org.elasticsearch.common.inject.spi.InjectionPoint; -import org.elasticsearch.common.inject.spi.ProviderInstanceBinding; +import org.elasticsearch.common.inject.spi.*; import java.util.Set; diff --git a/src/main/java/org/elasticsearch/common/inject/internal/ProviderMethod.java b/src/main/java/org/elasticsearch/common/inject/internal/ProviderMethod.java index 4bde7f85796..603a42aa2da 100644 --- a/src/main/java/org/elasticsearch/common/inject/internal/ProviderMethod.java +++ b/src/main/java/org/elasticsearch/common/inject/internal/ProviderMethod.java @@ -16,12 +16,8 @@ package org.elasticsearch.common.inject.internal; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.inject.Binder; -import org.elasticsearch.common.inject.Exposed; -import org.elasticsearch.common.inject.Key; -import org.elasticsearch.common.inject.PrivateBinder; -import org.elasticsearch.common.inject.Provider; +import com.google.common.collect.ImmutableSet; +import org.elasticsearch.common.inject.*; import org.elasticsearch.common.inject.spi.Dependency; import org.elasticsearch.common.inject.spi.ProviderWithDependencies; diff --git a/src/main/java/org/elasticsearch/common/inject/internal/ProviderMethodsModule.java b/src/main/java/org/elasticsearch/common/inject/internal/ProviderMethodsModule.java index b3507708018..9192e577a72 100644 --- a/src/main/java/org/elasticsearch/common/inject/internal/ProviderMethodsModule.java +++ b/src/main/java/org/elasticsearch/common/inject/internal/ProviderMethodsModule.java @@ -16,14 +16,9 @@ package org.elasticsearch.common.inject.internal; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.inject.Binder; -import org.elasticsearch.common.inject.Key; -import org.elasticsearch.common.inject.Module; -import org.elasticsearch.common.inject.Provider; -import org.elasticsearch.common.inject.Provides; -import org.elasticsearch.common.inject.TypeLiteral; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import org.elasticsearch.common.inject.*; import org.elasticsearch.common.inject.spi.Dependency; import org.elasticsearch.common.inject.spi.Message; import org.elasticsearch.common.inject.util.Modules; @@ -33,7 +28,7 @@ import java.lang.reflect.Member; import java.lang.reflect.Method; import java.util.List; -import static org.elasticsearch.common.base.Preconditions.*; +import static com.google.common.base.Preconditions.checkNotNull; /** * Creates bindings to methods annotated with {@literal @}{@link Provides}. Use the scope and @@ -124,12 +119,14 @@ public final class ProviderMethodsModule implements Module { return bindingAnnotation == null ? Key.get(type) : Key.get(type, bindingAnnotation); } - @Override public boolean equals(Object o) { + @Override + public boolean equals(Object o) { return o instanceof ProviderMethodsModule && ((ProviderMethodsModule) o).delegate == delegate; } - @Override public int hashCode() { + @Override + public int hashCode() { return delegate.hashCode(); } } diff --git a/src/main/java/org/elasticsearch/common/inject/internal/Scoping.java b/src/main/java/org/elasticsearch/common/inject/internal/Scoping.java index e9728a37839..a06918705db 100644 --- a/src/main/java/org/elasticsearch/common/inject/internal/Scoping.java +++ b/src/main/java/org/elasticsearch/common/inject/internal/Scoping.java @@ -42,11 +42,13 @@ public abstract class Scoping { return visitor.visitNoScoping(); } - @Override public Scope getScopeInstance() { + @Override + public Scope getScopeInstance() { return Scopes.NO_SCOPE; } - @Override public String toString() { + @Override + public String toString() { return Scopes.NO_SCOPE.toString(); } @@ -60,11 +62,13 @@ public abstract class Scoping { return visitor.visitScopeAnnotation(Singleton.class); } - @Override public Class getScopeAnnotation() { + @Override + public Class getScopeAnnotation() { return Singleton.class; } - @Override public String toString() { + @Override + public String toString() { return Singleton.class.getName(); } @@ -78,11 +82,13 @@ public abstract class Scoping { return visitor.visitScope(Scopes.SINGLETON); } - @Override public Scope getScopeInstance() { + @Override + public Scope getScopeInstance() { return Scopes.SINGLETON; } - @Override public String toString() { + @Override + public String toString() { return Scopes.SINGLETON.toString(); } @@ -96,11 +102,13 @@ public abstract class Scoping { return visitor.visitEagerSingleton(); } - @Override public Scope getScopeInstance() { + @Override + public Scope getScopeInstance() { return Scopes.SINGLETON; } - @Override public String toString() { + @Override + public String toString() { return "eager singleton"; } @@ -119,11 +127,13 @@ public abstract class Scoping { return visitor.visitScopeAnnotation(scopingAnnotation); } - @Override public Class getScopeAnnotation() { + @Override + public Class getScopeAnnotation() { return scopingAnnotation; } - @Override public String toString() { + @Override + public String toString() { return scopingAnnotation.getName(); } @@ -143,11 +153,13 @@ public abstract class Scoping { return visitor.visitScope(scope); } - @Override public Scope getScopeInstance() { + @Override + public Scope getScopeInstance() { return scope; } - @Override public String toString() { + @Override + public String toString() { return scope.toString(); } diff --git a/src/main/java/org/elasticsearch/common/inject/internal/SourceProvider.java b/src/main/java/org/elasticsearch/common/inject/internal/SourceProvider.java index bfdb65d2c69..4c34be0d415 100644 --- a/src/main/java/org/elasticsearch/common/inject/internal/SourceProvider.java +++ b/src/main/java/org/elasticsearch/common/inject/internal/SourceProvider.java @@ -16,9 +16,9 @@ package org.elasticsearch.common.inject.internal; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.collect.Iterables; -import org.elasticsearch.common.collect.Lists; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; import java.util.List; diff --git a/src/main/java/org/elasticsearch/common/inject/internal/Strings.java b/src/main/java/org/elasticsearch/common/inject/internal/Strings.java index fd7bed93821..7c2e703d7f4 100644 --- a/src/main/java/org/elasticsearch/common/inject/internal/Strings.java +++ b/src/main/java/org/elasticsearch/common/inject/internal/Strings.java @@ -31,7 +31,7 @@ public class Strings { * The returned string will have the same value as the specified string if * its first character is non-alphabetic, if its first character is already * uppercase, or if the specified string is of length 0. - * + *

          *

          For example: *

                *    capitalize("foo bar").equals("Foo bar");
          diff --git a/src/main/java/org/elasticsearch/common/inject/internal/ToStringBuilder.java b/src/main/java/org/elasticsearch/common/inject/internal/ToStringBuilder.java
          index c6b699c22fe..1e6f42309cf 100644
          --- a/src/main/java/org/elasticsearch/common/inject/internal/ToStringBuilder.java
          +++ b/src/main/java/org/elasticsearch/common/inject/internal/ToStringBuilder.java
          @@ -46,7 +46,8 @@ public class ToStringBuilder {
                   return this;
               }
           
          -    @Override public String toString() {
          +    @Override
          +    public String toString() {
                   return name + map.toString().replace('{', '[').replace('}', ']');
               }
           }
          diff --git a/src/main/java/org/elasticsearch/common/inject/internal/UniqueAnnotations.java b/src/main/java/org/elasticsearch/common/inject/internal/UniqueAnnotations.java
          index 7f0847dfdbc..eee45350040 100644
          --- a/src/main/java/org/elasticsearch/common/inject/internal/UniqueAnnotations.java
          +++ b/src/main/java/org/elasticsearch/common/inject/internal/UniqueAnnotations.java
          @@ -22,7 +22,7 @@ import java.lang.annotation.Annotation;
           import java.lang.annotation.Retention;
           import java.util.concurrent.atomic.AtomicInteger;
           
          -import static java.lang.annotation.RetentionPolicy.*;
          +import static java.lang.annotation.RetentionPolicy.RUNTIME;
           
           /**
            * @author jessewilson@google.com (Jesse Wilson)
          @@ -51,16 +51,19 @@ public class UniqueAnnotations {
                           return Internal.class;
                       }
           
          -            @Override public String toString() {
          +            @Override
          +            public String toString() {
                           return "@" + Internal.class.getName() + "(value=" + value + ")";
                       }
           
          -            @Override public boolean equals(Object o) {
          +            @Override
          +            public boolean equals(Object o) {
                           return o instanceof Internal
                                   && ((Internal) o).value() == value();
                       }
           
          -            @Override public int hashCode() {
          +            @Override
          +            public int hashCode() {
                           return (127 * "value".hashCode()) ^ value;
                       }
                   };
          diff --git a/src/main/java/org/elasticsearch/common/inject/internal/UntargettedBindingImpl.java b/src/main/java/org/elasticsearch/common/inject/internal/UntargettedBindingImpl.java
          index 9c046f6433c..cf3b5ecf4bc 100644
          --- a/src/main/java/org/elasticsearch/common/inject/internal/UntargettedBindingImpl.java
          +++ b/src/main/java/org/elasticsearch/common/inject/internal/UntargettedBindingImpl.java
          @@ -27,10 +27,10 @@ public class UntargettedBindingImpl extends BindingImpl implements Untarge
           
               public UntargettedBindingImpl(Injector injector, Key key, Object source) {
                   super(injector, key, source, new InternalFactory() {
          -                    public T get(Errors errors, InternalContext context, Dependency dependency) {
          -                        throw new AssertionError();
          -                    }
          -                }, Scoping.UNSCOPED);
          +            public T get(Errors errors, InternalContext context, Dependency dependency) {
          +                throw new AssertionError();
          +            }
          +        }, Scoping.UNSCOPED);
               }
           
               public UntargettedBindingImpl(Object source, Key key, Scoping scoping) {
          @@ -53,7 +53,8 @@ public class UntargettedBindingImpl extends BindingImpl implements Untarge
                   getScoping().applyTo(binder.withSource(getSource()).bind(getKey()));
               }
           
          -    @Override public String toString() {
          +    @Override
          +    public String toString() {
                   return new ToStringBuilder(UntargettedBinding.class)
                           .add("key", getKey())
                           .add("source", getSource())
          diff --git a/src/main/java/org/elasticsearch/common/inject/matcher/AbstractMatcher.java b/src/main/java/org/elasticsearch/common/inject/matcher/AbstractMatcher.java
          index 9e256670b64..7144e3db85d 100644
          --- a/src/main/java/org/elasticsearch/common/inject/matcher/AbstractMatcher.java
          +++ b/src/main/java/org/elasticsearch/common/inject/matcher/AbstractMatcher.java
          @@ -45,17 +45,20 @@ public abstract class AbstractMatcher implements Matcher {
                       return a.matches(t) && b.matches(t);
                   }
           
          -        @Override public boolean equals(Object other) {
          +        @Override
          +        public boolean equals(Object other) {
                       return other instanceof AndMatcher
                               && ((AndMatcher) other).a.equals(a)
                               && ((AndMatcher) other).b.equals(b);
                   }
           
          -        @Override public int hashCode() {
          +        @Override
          +        public int hashCode() {
                       return 41 * (a.hashCode() ^ b.hashCode());
                   }
           
          -        @Override public String toString() {
          +        @Override
          +        public String toString() {
                       return "and(" + a + ", " + b + ")";
                   }
           
          @@ -74,17 +77,20 @@ public abstract class AbstractMatcher implements Matcher {
                       return a.matches(t) || b.matches(t);
                   }
           
          -        @Override public boolean equals(Object other) {
          +        @Override
          +        public boolean equals(Object other) {
                       return other instanceof OrMatcher
                               && ((OrMatcher) other).a.equals(a)
                               && ((OrMatcher) other).b.equals(b);
                   }
           
          -        @Override public int hashCode() {
          +        @Override
          +        public int hashCode() {
                       return 37 * (a.hashCode() ^ b.hashCode());
                   }
           
          -        @Override public String toString() {
          +        @Override
          +        public String toString() {
                       return "or(" + a + ", " + b + ")";
                   }
           
          diff --git a/src/main/java/org/elasticsearch/common/inject/matcher/Matchers.java b/src/main/java/org/elasticsearch/common/inject/matcher/Matchers.java
          index 4aa2f194b5d..1b5d2ba82f9 100644
          --- a/src/main/java/org/elasticsearch/common/inject/matcher/Matchers.java
          +++ b/src/main/java/org/elasticsearch/common/inject/matcher/Matchers.java
          @@ -23,7 +23,8 @@ import java.lang.annotation.RetentionPolicy;
           import java.lang.reflect.AnnotatedElement;
           import java.lang.reflect.Method;
           
          -import static org.elasticsearch.common.base.Preconditions.*;
          +import static com.google.common.base.Preconditions.checkArgument;
          +import static com.google.common.base.Preconditions.checkNotNull;
           
           /**
            * Matcher implementations. Supports matching classes and methods.
          @@ -48,7 +49,8 @@ public class Matchers {
                       return true;
                   }
           
          -        @Override public String toString() {
          +        @Override
          +        public String toString() {
                       return "any()";
                   }
           
          @@ -77,16 +79,19 @@ public class Matchers {
                       return !delegate.matches(t);
                   }
           
          -        @Override public boolean equals(Object other) {
          +        @Override
          +        public boolean equals(Object other) {
                       return other instanceof Not
                               && ((Not) other).delegate.equals(delegate);
                   }
           
          -        @Override public int hashCode() {
          +        @Override
          +        public int hashCode() {
                       return -delegate.hashCode();
                   }
           
          -        @Override public String toString() {
          +        @Override
          +        public String toString() {
                       return "not(" + delegate + ")";
                   }
           
          @@ -122,16 +127,19 @@ public class Matchers {
                       return element.getAnnotation(annotationType) != null;
                   }
           
          -        @Override public boolean equals(Object other) {
          +        @Override
          +        public boolean equals(Object other) {
                       return other instanceof AnnotatedWithType
                               && ((AnnotatedWithType) other).annotationType.equals(annotationType);
                   }
           
          -        @Override public int hashCode() {
          +        @Override
          +        public int hashCode() {
                       return 37 * annotationType.hashCode();
                   }
           
          -        @Override public String toString() {
          +        @Override
          +        public String toString() {
                       return "annotatedWith(" + annotationType.getSimpleName() + ".class)";
                   }
           
          @@ -161,16 +169,19 @@ public class Matchers {
                       return fromElement != null && annotation.equals(fromElement);
                   }
           
          -        @Override public boolean equals(Object other) {
          +        @Override
          +        public boolean equals(Object other) {
                       return other instanceof AnnotatedWith
                               && ((AnnotatedWith) other).annotation.equals(annotation);
                   }
           
          -        @Override public int hashCode() {
          +        @Override
          +        public int hashCode() {
                       return 37 * annotation.hashCode();
                   }
           
          -        @Override public String toString() {
          +        @Override
          +        public String toString() {
                       return "annotatedWith(" + annotation + ")";
                   }
           
          @@ -197,16 +208,19 @@ public class Matchers {
                       return superclass.isAssignableFrom(subclass);
                   }
           
          -        @Override public boolean equals(Object other) {
          +        @Override
          +        public boolean equals(Object other) {
                       return other instanceof SubclassesOf
                               && ((SubclassesOf) other).superclass.equals(superclass);
                   }
           
          -        @Override public int hashCode() {
          +        @Override
          +        public int hashCode() {
                       return 37 * superclass.hashCode();
                   }
           
          -        @Override public String toString() {
          +        @Override
          +        public String toString() {
                       return "subclassesOf(" + superclass.getSimpleName() + ".class)";
                   }
           
          @@ -232,16 +246,19 @@ public class Matchers {
                       return value.equals(other);
                   }
           
          -        @Override public boolean equals(Object other) {
          +        @Override
          +        public boolean equals(Object other) {
                       return other instanceof Only
                               && ((Only) other).value.equals(value);
                   }
           
          -        @Override public int hashCode() {
          +        @Override
          +        public int hashCode() {
                       return 37 * value.hashCode();
                   }
           
          -        @Override public String toString() {
          +        @Override
          +        public String toString() {
                       return "only(" + value + ")";
                   }
           
          @@ -267,16 +284,19 @@ public class Matchers {
                       return value == other;
                   }
           
          -        @Override public boolean equals(Object other) {
          +        @Override
          +        public boolean equals(Object other) {
                       return other instanceof IdenticalTo
                               && ((IdenticalTo) other).value == value;
                   }
           
          -        @Override public int hashCode() {
          +        @Override
          +        public int hashCode() {
                       return 37 * System.identityHashCode(value);
                   }
           
          -        @Override public String toString() {
          +        @Override
          +        public String toString() {
                       return "identicalTo(" + value + ")";
                   }
           
          @@ -304,16 +324,19 @@ public class Matchers {
                       return c.getPackage().equals(targetPackage);
                   }
           
          -        @Override public boolean equals(Object other) {
          +        @Override
          +        public boolean equals(Object other) {
                       return other instanceof InPackage
                               && ((InPackage) other).targetPackage.equals(targetPackage);
                   }
           
          -        @Override public int hashCode() {
          +        @Override
          +        public int hashCode() {
                       return 37 * targetPackage.hashCode();
                   }
           
          -        @Override public String toString() {
          +        @Override
          +        public String toString() {
                       return "inPackage(" + targetPackage.getName() + ")";
                   }
           
          @@ -347,16 +370,19 @@ public class Matchers {
                               || classPackageName.startsWith(targetPackageName + ".");
                   }
           
          -        @Override public boolean equals(Object other) {
          +        @Override
          +        public boolean equals(Object other) {
                       return other instanceof InSubpackage
                               && ((InSubpackage) other).targetPackageName.equals(targetPackageName);
                   }
           
          -        @Override public int hashCode() {
          +        @Override
          +        public int hashCode() {
                       return 37 * targetPackageName.hashCode();
                   }
           
          -        @Override public String toString() {
          +        @Override
          +        public String toString() {
                       return "inSubpackage(" + targetPackageName + ")";
                   }
           
          @@ -382,16 +408,19 @@ public class Matchers {
                       return returnType.matches(m.getReturnType());
                   }
           
          -        @Override public boolean equals(Object other) {
          +        @Override
          +        public boolean equals(Object other) {
                       return other instanceof Returns
                               && ((Returns) other).returnType.equals(returnType);
                   }
           
          -        @Override public int hashCode() {
          +        @Override
          +        public int hashCode() {
                       return 37 * returnType.hashCode();
                   }
           
          -        @Override public String toString() {
          +        @Override
          +        public String toString() {
                       return "returns(" + returnType + ")";
                   }
           
          diff --git a/src/main/java/org/elasticsearch/common/inject/multibindings/Element.java b/src/main/java/org/elasticsearch/common/inject/multibindings/Element.java
          index b8ab63b9288..02323dc5681 100644
          --- a/src/main/java/org/elasticsearch/common/inject/multibindings/Element.java
          +++ b/src/main/java/org/elasticsearch/common/inject/multibindings/Element.java
          @@ -21,7 +21,7 @@ import org.elasticsearch.common.inject.BindingAnnotation;
           
           import java.lang.annotation.Retention;
           
          -import static java.lang.annotation.RetentionPolicy.*;
          +import static java.lang.annotation.RetentionPolicy.RUNTIME;
           
           /**
            * An internal binding annotation applied to each element in a multibinding.
          diff --git a/src/main/java/org/elasticsearch/common/inject/multibindings/MapBinder.java b/src/main/java/org/elasticsearch/common/inject/multibindings/MapBinder.java
          index 479e4064699..fe3aa1de246 100644
          --- a/src/main/java/org/elasticsearch/common/inject/multibindings/MapBinder.java
          +++ b/src/main/java/org/elasticsearch/common/inject/multibindings/MapBinder.java
          @@ -16,13 +16,8 @@
           
           package org.elasticsearch.common.inject.multibindings;
           
          -import org.elasticsearch.common.collect.ImmutableSet;
          -import org.elasticsearch.common.inject.Binder;
          -import org.elasticsearch.common.inject.Inject;
          -import org.elasticsearch.common.inject.Key;
          -import org.elasticsearch.common.inject.Module;
          -import org.elasticsearch.common.inject.Provider;
          -import org.elasticsearch.common.inject.TypeLiteral;
          +import com.google.common.collect.ImmutableSet;
          +import org.elasticsearch.common.inject.*;
           import org.elasticsearch.common.inject.binder.LinkedBindingBuilder;
           import org.elasticsearch.common.inject.multibindings.Multibinder.RealMultibinder;
           import org.elasticsearch.common.inject.spi.Dependency;
          @@ -36,7 +31,8 @@ import java.util.Map;
           import java.util.Map.Entry;
           import java.util.Set;
           
          -import static org.elasticsearch.common.inject.util.Types.*;
          +import static org.elasticsearch.common.inject.util.Types.newParameterizedType;
          +import static org.elasticsearch.common.inject.util.Types.newParameterizedTypeWithOwner;
           
           /**
            * An API to bind multiple map entries separately, only to later inject them as
          @@ -51,7 +47,7 @@ import static org.elasticsearch.common.inject.util.Types.*;
            *     mapbinder.addBinding("skittles").to(Skittles.class);
            *   }
            * }
          - * + *

          *

          With this binding, a {@link Map}{@code } can now be * injected: *

          
          @@ -59,7 +55,7 @@ import static org.elasticsearch.common.inject.util.Types.*;
            *   {@literal @}Inject
            *   public SnackMachine(Map<String, Snack> snacks) { ... }
            * }
          - * + *

          *

          In addition to binding {@code Map}, a mapbinder will also bind * {@code Map>} for lazy value provision: *

          
          @@ -67,26 +63,26 @@ import static org.elasticsearch.common.inject.util.Types.*;
            *   {@literal @}Inject
            *   public SnackMachine(Map<String, Provider<Snack>> snackProviders) { ... }
            * }
          - * + *

          *

          Creating mapbindings from different modules is supported. For example, it * is okay to have both {@code CandyModule} and {@code ChipsModule} both * create their own {@code MapBinder}, and to each contribute * bindings to the snacks map. When that map is injected, it will contain * entries from both modules. - * + *

          *

          Values are resolved at map injection time. If a value is bound to a * provider, that provider's get method will be called each time the map is * injected (unless the binding is also scoped, or a map of providers is injected). - * + *

          *

          Annotations are used to create different maps of the same key/value * type. Each distinct annotation gets its own independent map. - * + *

          *

          Keys must be distinct. If the same key is bound more than * once, map injection will fail. - * + *

          *

          Keys must be non-null. {@code addBinding(null)} will * throw an unchecked exception. - * + *

          *

          Values must be non-null to use map injection. If any * value is null, map injection will fail (although injecting a map of providers * will not). @@ -198,10 +194,10 @@ public abstract class MapBinder { * Returns a binding builder used to add a new entry in the map. Each * key must be distinct (and non-null). Bound providers will be evaluated each * time the map is injected. - * + *

          *

          It is an error to call this method without also calling one of the * {@code to} methods on the returned binding builder. - * + *

          *

          Scoping elements independently is supported. Use the {@code in} method * to specify a binding scope. */ @@ -209,26 +205,26 @@ public abstract class MapBinder { /** * The actual mapbinder plays several roles: - * + *

          *

          As a MapBinder, it acts as a factory for LinkedBindingBuilders for * each of the map's values. It delegates to a {@link Multibinder} of * entries (keys to value providers). - * + *

          *

          As a Module, it installs the binding to the map itself, as well as to * a corresponding map whose values are providers. It uses the entry set * multibinder to construct the map and the provider map. - * + *

          *

          As a module, this implements equals() and hashcode() in order to trick * Guice into executing its configure() method only once. That makes it so * that multiple mapbinders can be created for the same target map, but * only one is bound. Since the list of bindings is retrieved from the * injector itself (and not the mapbinder), each mapbinder has access to * all contributions from all equivalent mapbinders. - * + *

          *

          Rather than binding a single Map.Entry<K, V>, the map binder * binds keys and values independently. This allows the values to be properly * scoped. - * + *

          *

          We use a subclass to hide 'implements Module' from the public API. */ private static final class RealMapBinder extends MapBinder implements Module { @@ -254,7 +250,8 @@ public abstract class MapBinder { * This creates two bindings. One for the {@code Map.Entry>} * and another for {@code V}. */ - @Override public LinkedBindingBuilder addBinding(K key) { + @Override + public LinkedBindingBuilder addBinding(K key) { Multibinder.checkNotNull(key, "key"); Multibinder.checkConfiguration(!isInitialized(), "MapBinder was already initialized"); @@ -277,7 +274,8 @@ public abstract class MapBinder { private Map> providerMap; @SuppressWarnings("unused") - @Inject void initialize() { + @Inject + void initialize() { RealMapBinder.this.binder = null; Map> providerMapMutable = new LinkedHashMap>(); @@ -322,12 +320,14 @@ public abstract class MapBinder { return binder == null; } - @Override public boolean equals(Object o) { + @Override + public boolean equals(Object o) { return o instanceof RealMapBinder && ((RealMapBinder) o).mapKey.equals(mapKey); } - @Override public int hashCode() { + @Override + public int hashCode() { return mapKey.hashCode(); } @@ -352,18 +352,21 @@ public abstract class MapBinder { throw new UnsupportedOperationException(); } - @Override public boolean equals(Object obj) { + @Override + public boolean equals(Object obj) { return obj instanceof Map.Entry && key.equals(((Map.Entry) obj).getKey()) && value.equals(((Map.Entry) obj).getValue()); } - @Override public int hashCode() { + @Override + public int hashCode() { return 127 * ("key".hashCode() ^ key.hashCode()) + 127 * ("value".hashCode() ^ value.hashCode()); } - @Override public String toString() { + @Override + public String toString() { return "MapEntry(" + key + ", " + value + ")"; } } diff --git a/src/main/java/org/elasticsearch/common/inject/multibindings/Multibinder.java b/src/main/java/org/elasticsearch/common/inject/multibindings/Multibinder.java index 3fa424111e9..3dfd108c639 100644 --- a/src/main/java/org/elasticsearch/common/inject/multibindings/Multibinder.java +++ b/src/main/java/org/elasticsearch/common/inject/multibindings/Multibinder.java @@ -16,18 +16,10 @@ package org.elasticsearch.common.inject.multibindings; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.inject.Binder; -import org.elasticsearch.common.inject.Binding; -import org.elasticsearch.common.inject.ConfigurationException; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.inject.Injector; -import org.elasticsearch.common.inject.Key; -import org.elasticsearch.common.inject.Module; -import org.elasticsearch.common.inject.Provider; -import org.elasticsearch.common.inject.TypeLiteral; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import org.elasticsearch.common.inject.*; import org.elasticsearch.common.inject.binder.LinkedBindingBuilder; import org.elasticsearch.common.inject.internal.Errors; import org.elasticsearch.common.inject.spi.Dependency; @@ -56,31 +48,31 @@ import java.util.Set; * multibinder.addBinding().to(Skittles.class); * } * }

      - * + *

      *

      With this binding, a {@link Set}{@code } can now be injected: *

      
        * class SnackMachine {
        *   {@literal @}Inject
        *   public SnackMachine(Set<Snack> snacks) { ... }
        * }
      - * + *

      *

      Create multibindings from different modules is supported. For example, it * is okay to have both {@code CandyModule} and {@code ChipsModule} to both * create their own {@code Multibinder}, and to each contribute bindings * to the set of snacks. When that set is injected, it will contain elements * from both modules. - * + *

      *

      Elements are resolved at set injection time. If an element is bound to a * provider, that provider's get method will be called each time the set is * injected (unless the binding is also scoped). - * + *

      *

      Annotations are be used to create different sets of the same element * type. Each distinct annotation gets its own independent collection of * elements. - * + *

      *

      Elements must be distinct. If multiple bound elements * have the same value, set injection will fail. - * + *

      *

      Elements must be non-null. If any set element is null, * set injection will fail. * @@ -164,10 +156,10 @@ public abstract class Multibinder { * Returns a binding builder used to add a new element in the set. Each * bound element must have a distinct value. Bound providers will be * evaluated each time the set is injected. - * + *

      *

      It is an error to call this method without also calling one of the * {@code to} methods on the returned binding builder. - * + *

      *

      Scoping elements independently is supported. Use the {@code in} method * to specify a binding scope. */ @@ -175,11 +167,11 @@ public abstract class Multibinder { /** * The actual multibinder plays several roles: - * + *

      *

      As a Multibinder, it acts as a factory for LinkedBindingBuilders for * each of the set's elements. Each binding is given an annotation that * identifies it as a part of this set. - * + *

      *

      As a Module, it installs the binding to the set itself. As a module, * this implements equals() and hashcode() in order to trick Guice into * executing its configure() method only once. That makes it so that @@ -187,9 +179,9 @@ public abstract class Multibinder { * only one is bound. Since the list of bindings is retrieved from the * injector itself (and not the multibinder), each multibinder has access to * all contributions from all multibinders. - * + *

      *

      As a Provider, this constructs the set instances. - * + *

      *

      We use a subclass to hide 'implements Module, Provider' from the public * API. */ @@ -222,7 +214,8 @@ public abstract class Multibinder { binder.bind(setKey).toProvider(this); } - @Override public LinkedBindingBuilder addBinding() { + @Override + public LinkedBindingBuilder addBinding() { checkConfiguration(!isInitialized(), "Multibinder was already initialized"); return binder.bind(Key.get(elementType, new RealElement(setName))); @@ -233,7 +226,8 @@ public abstract class Multibinder { * element in this set. At this time the set's size is known, but its * contents are only evaluated when get() is invoked. */ - @Inject void initialize(Injector injector) { + @Inject + void initialize(Injector injector) { providers = Lists.newArrayList(); List> dependencies = Lists.newArrayList(); for (Binding entry : injector.findBindingsByType(elementType)) { @@ -285,16 +279,19 @@ public abstract class Multibinder { return dependencies; } - @Override public boolean equals(Object o) { + @Override + public boolean equals(Object o) { return o instanceof RealMultibinder && ((RealMultibinder) o).setKey.equals(setKey); } - @Override public int hashCode() { + @Override + public int hashCode() { return setKey.hashCode(); } - @Override public String toString() { + @Override + public String toString() { return new StringBuilder() .append(setName) .append(setName.length() > 0 ? " " : "") diff --git a/src/main/java/org/elasticsearch/common/inject/multibindings/RealElement.java b/src/main/java/org/elasticsearch/common/inject/multibindings/RealElement.java index 463aa729f76..eb6fdf56fcd 100644 --- a/src/main/java/org/elasticsearch/common/inject/multibindings/RealElement.java +++ b/src/main/java/org/elasticsearch/common/inject/multibindings/RealElement.java @@ -45,18 +45,21 @@ class RealElement implements Element { return Element.class; } - @Override public String toString() { + @Override + public String toString() { return "@" + Element.class.getName() + "(setName=" + setName + ",uniqueId=" + uniqueId + ")"; } - @Override public boolean equals(Object o) { + @Override + public boolean equals(Object o) { return o instanceof Element && ((Element) o).setName().equals(setName()) && ((Element) o).uniqueId() == uniqueId(); } - @Override public int hashCode() { + @Override + public int hashCode() { return 127 * ("setName".hashCode() ^ setName.hashCode()) + 127 * ("uniqueId".hashCode() ^ uniqueId); } diff --git a/src/main/java/org/elasticsearch/common/inject/name/Named.java b/src/main/java/org/elasticsearch/common/inject/name/Named.java index 24da40e4df6..0d914be6f51 100644 --- a/src/main/java/org/elasticsearch/common/inject/name/Named.java +++ b/src/main/java/org/elasticsearch/common/inject/name/Named.java @@ -22,7 +22,7 @@ import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.Target; -import static java.lang.annotation.RetentionPolicy.*; +import static java.lang.annotation.RetentionPolicy.RUNTIME; /** * Annotates named things. diff --git a/src/main/java/org/elasticsearch/common/inject/name/NamedImpl.java b/src/main/java/org/elasticsearch/common/inject/name/NamedImpl.java index a804a5efd59..4961fe328ba 100644 --- a/src/main/java/org/elasticsearch/common/inject/name/NamedImpl.java +++ b/src/main/java/org/elasticsearch/common/inject/name/NamedImpl.java @@ -19,7 +19,7 @@ package org.elasticsearch.common.inject.name; import java.io.Serializable; import java.lang.annotation.Annotation; -import static org.elasticsearch.common.base.Preconditions.*; +import static com.google.common.base.Preconditions.checkNotNull; class NamedImpl implements Named, Serializable { diff --git a/src/main/java/org/elasticsearch/common/inject/spi/Dependency.java b/src/main/java/org/elasticsearch/common/inject/spi/Dependency.java index db96194d146..df3a52ddcf5 100644 --- a/src/main/java/org/elasticsearch/common/inject/spi/Dependency.java +++ b/src/main/java/org/elasticsearch/common/inject/spi/Dependency.java @@ -16,8 +16,8 @@ package org.elasticsearch.common.inject.spi; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.collect.Lists; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; import org.elasticsearch.common.inject.Key; import org.elasticsearch.common.inject.internal.Objects; @@ -26,7 +26,7 @@ import java.util.Set; /** * A variable that can be resolved by an injector. - * + *

      *

      Use {@link #get} to build a freestanding dependency, or {@link InjectionPoint} to build one * that's attached to a constructor, method or field. * @@ -98,11 +98,13 @@ public final class Dependency { return parameterIndex; } - @Override public int hashCode() { + @Override + public int hashCode() { return Objects.hashCode(injectionPoint, parameterIndex, key); } - @Override public boolean equals(Object o) { + @Override + public boolean equals(Object o) { if (o instanceof Dependency) { Dependency dependency = (Dependency) o; return Objects.equal(injectionPoint, dependency.injectionPoint) @@ -113,7 +115,8 @@ public final class Dependency { } } - @Override public String toString() { + @Override + public String toString() { StringBuilder builder = new StringBuilder(); builder.append(key); if (injectionPoint != null) { diff --git a/src/main/java/org/elasticsearch/common/inject/spi/Element.java b/src/main/java/org/elasticsearch/common/inject/spi/Element.java index b5b5c910590..a222c37bba5 100644 --- a/src/main/java/org/elasticsearch/common/inject/spi/Element.java +++ b/src/main/java/org/elasticsearch/common/inject/spi/Element.java @@ -20,12 +20,12 @@ import org.elasticsearch.common.inject.Binder; /** * A core component of a module or injector. - * + *

      *

      The elements of a module can be inspected, validated and rewritten. Use {@link * Elements#getElements(org.elasticsearch.common.inject.Module[]) Elements.getElements()} to read the elements * from a module, and {@link Elements#getModule(Iterable) Elements.getModule()} to rewrite them. * This can be used for static analysis and generation of Guice modules. - * + *

      *

      The elements of an injector can be inspected and exercised. Use {@link * org.elasticsearch.common.inject.Injector#getBindings Injector.getBindings()} to reflect on Guice injectors. * @@ -38,7 +38,7 @@ public interface Element { /** * Returns an arbitrary object containing information about the "place" where this element was * configured. Used by Guice in the production of descriptive error messages. - * + *

      *

      Tools might specially handle types they know about; {@code StackTraceElement} is a good * example. Tools should simply call {@code toString()} on the source object if the type is * unfamiliar. diff --git a/src/main/java/org/elasticsearch/common/inject/spi/Elements.java b/src/main/java/org/elasticsearch/common/inject/spi/Elements.java index f31bb5d6cf3..9d4eed47b38 100644 --- a/src/main/java/org/elasticsearch/common/inject/spi/Elements.java +++ b/src/main/java/org/elasticsearch/common/inject/spi/Elements.java @@ -16,31 +16,20 @@ package org.elasticsearch.common.inject.spi; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.collect.Sets; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; import org.elasticsearch.common.inject.*; import org.elasticsearch.common.inject.binder.AnnotatedBindingBuilder; import org.elasticsearch.common.inject.binder.AnnotatedConstantBindingBuilder; import org.elasticsearch.common.inject.binder.AnnotatedElementBuilder; -import org.elasticsearch.common.inject.internal.AbstractBindingBuilder; -import org.elasticsearch.common.inject.internal.BindingBuilder; -import org.elasticsearch.common.inject.internal.ConstantBindingBuilderImpl; -import org.elasticsearch.common.inject.internal.Errors; -import org.elasticsearch.common.inject.internal.ExposureBuilder; -import org.elasticsearch.common.inject.internal.PrivateElementsImpl; -import org.elasticsearch.common.inject.internal.ProviderMethodsModule; -import org.elasticsearch.common.inject.internal.SourceProvider; +import org.elasticsearch.common.inject.internal.*; import org.elasticsearch.common.inject.matcher.Matcher; import java.lang.annotation.Annotation; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Set; +import java.util.*; -import static org.elasticsearch.common.base.Preconditions.*; +import static com.google.common.base.Preconditions.checkArgument; /** * Exposes elements of a module so they can be inspected, validated or {@link @@ -52,11 +41,13 @@ import static org.elasticsearch.common.base.Preconditions.*; public final class Elements { private static final BindingTargetVisitor GET_INSTANCE_VISITOR = new DefaultBindingTargetVisitor() { - @Override public Object visit(InstanceBinding binding) { + @Override + public Object visit(InstanceBinding binding) { return binding.getInstance(); } - @Override protected Object visitOther(Binding binding) { + @Override + protected Object visitOther(Binding binding) { throw new IllegalArgumentException(); } }; @@ -324,7 +315,8 @@ public final class Elements { : source; } - @Override public String toString() { + @Override + public String toString() { return "Binder"; } } diff --git a/src/main/java/org/elasticsearch/common/inject/spi/InjectionPoint.java b/src/main/java/org/elasticsearch/common/inject/spi/InjectionPoint.java index 7f2d26fac4b..ceb629dd516 100644 --- a/src/main/java/org/elasticsearch/common/inject/spi/InjectionPoint.java +++ b/src/main/java/org/elasticsearch/common/inject/spi/InjectionPoint.java @@ -16,33 +16,20 @@ package org.elasticsearch.common.inject.spi; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.collect.Lists; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; import org.elasticsearch.common.inject.ConfigurationException; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.Key; import org.elasticsearch.common.inject.TypeLiteral; -import org.elasticsearch.common.inject.internal.Annotations; -import org.elasticsearch.common.inject.internal.Errors; -import org.elasticsearch.common.inject.internal.ErrorsException; -import org.elasticsearch.common.inject.internal.MoreTypes; -import org.elasticsearch.common.inject.internal.Nullability; +import org.elasticsearch.common.inject.internal.*; import java.lang.annotation.Annotation; -import java.lang.reflect.AnnotatedElement; -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Member; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.Arrays; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Set; +import java.lang.reflect.*; +import java.util.*; -import static org.elasticsearch.common.inject.internal.MoreTypes.*; +import static org.elasticsearch.common.inject.internal.MoreTypes.getRawType; /** * A constructor, field or method that can receive injections. Typically this is a member with the @@ -157,16 +144,19 @@ public final class InjectionPoint { return optional; } - @Override public boolean equals(Object o) { + @Override + public boolean equals(Object o) { return o instanceof InjectionPoint && member.equals(((InjectionPoint) o).member); } - @Override public int hashCode() { + @Override + public int hashCode() { return member.hashCode(); } - @Override public String toString() { + @Override + public String toString() { return MoreTypes.toString(member); } diff --git a/src/main/java/org/elasticsearch/common/inject/spi/InjectionRequest.java b/src/main/java/org/elasticsearch/common/inject/spi/InjectionRequest.java index 89a0ef520ac..26b62956c3e 100644 --- a/src/main/java/org/elasticsearch/common/inject/spi/InjectionRequest.java +++ b/src/main/java/org/elasticsearch/common/inject/spi/InjectionRequest.java @@ -22,7 +22,7 @@ import org.elasticsearch.common.inject.TypeLiteral; import java.util.Set; -import static org.elasticsearch.common.base.Preconditions.*; +import static com.google.common.base.Preconditions.checkNotNull; /** * A request to inject the instance fields and methods of an instance. Requests are created diff --git a/src/main/java/org/elasticsearch/common/inject/spi/MembersInjectorLookup.java b/src/main/java/org/elasticsearch/common/inject/spi/MembersInjectorLookup.java index 4c9a1419fbb..873ffc3db9b 100644 --- a/src/main/java/org/elasticsearch/common/inject/spi/MembersInjectorLookup.java +++ b/src/main/java/org/elasticsearch/common/inject/spi/MembersInjectorLookup.java @@ -20,7 +20,8 @@ import org.elasticsearch.common.inject.Binder; import org.elasticsearch.common.inject.MembersInjector; import org.elasticsearch.common.inject.TypeLiteral; -import static org.elasticsearch.common.base.Preconditions.*; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; /** * A lookup of the members injector for a type. Lookups are created explicitly in a module using @@ -94,7 +95,8 @@ public final class MembersInjectorLookup implements Element { delegate.injectMembers(instance); } - @Override public String toString() { + @Override + public String toString() { return "MembersInjector<" + type + ">"; } }; diff --git a/src/main/java/org/elasticsearch/common/inject/spi/Message.java b/src/main/java/org/elasticsearch/common/inject/spi/Message.java index 32f3cfcd2b6..16aebcc9b5e 100644 --- a/src/main/java/org/elasticsearch/common/inject/spi/Message.java +++ b/src/main/java/org/elasticsearch/common/inject/spi/Message.java @@ -16,7 +16,7 @@ package org.elasticsearch.common.inject.spi; -import org.elasticsearch.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList; import org.elasticsearch.common.inject.Binder; import org.elasticsearch.common.inject.internal.Errors; import org.elasticsearch.common.inject.internal.Objects; @@ -26,7 +26,7 @@ import java.io.ObjectStreamException; import java.io.Serializable; import java.util.List; -import static org.elasticsearch.common.base.Preconditions.*; +import static com.google.common.base.Preconditions.checkNotNull; /** * An error message and the context in which it occured. Messages are usually created internally by @@ -100,15 +100,18 @@ public final class Message implements Serializable, Element { return cause; } - @Override public String toString() { + @Override + public String toString() { return message; } - @Override public int hashCode() { + @Override + public int hashCode() { return message.hashCode(); } - @Override public boolean equals(Object o) { + @Override + public boolean equals(Object o) { if (!(o instanceof Message)) { return false; } diff --git a/src/main/java/org/elasticsearch/common/inject/spi/PrivateElements.java b/src/main/java/org/elasticsearch/common/inject/spi/PrivateElements.java index d7a803e0f1b..64ead9c0b02 100644 --- a/src/main/java/org/elasticsearch/common/inject/spi/PrivateElements.java +++ b/src/main/java/org/elasticsearch/common/inject/spi/PrivateElements.java @@ -50,7 +50,7 @@ public interface PrivateElements extends Element { /** * Returns an arbitrary object containing information about the "place" where this key was * exposed. Used by Guice in the production of descriptive error messages. - * + *

      *

      Tools might specially handle types they know about; {@code StackTraceElement} is a good * example. Tools should simply call {@code toString()} on the source object if the type is * unfamiliar. diff --git a/src/main/java/org/elasticsearch/common/inject/spi/ProviderLookup.java b/src/main/java/org/elasticsearch/common/inject/spi/ProviderLookup.java index 9ea3a13ce21..fc9bbd176cd 100644 --- a/src/main/java/org/elasticsearch/common/inject/spi/ProviderLookup.java +++ b/src/main/java/org/elasticsearch/common/inject/spi/ProviderLookup.java @@ -20,7 +20,8 @@ import org.elasticsearch.common.inject.Binder; import org.elasticsearch.common.inject.Key; import org.elasticsearch.common.inject.Provider; -import static org.elasticsearch.common.base.Preconditions.*; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; /** * A lookup of the provider for a type. Lookups are created explicitly in a module using @@ -89,7 +90,8 @@ public final class ProviderLookup implements Element { return delegate.get(); } - @Override public String toString() { + @Override + public String toString() { return "Provider<" + key.getTypeLiteral() + ">"; } }; diff --git a/src/main/java/org/elasticsearch/common/inject/spi/ScopeBinding.java b/src/main/java/org/elasticsearch/common/inject/spi/ScopeBinding.java index 301597c41ef..cefd060c039 100644 --- a/src/main/java/org/elasticsearch/common/inject/spi/ScopeBinding.java +++ b/src/main/java/org/elasticsearch/common/inject/spi/ScopeBinding.java @@ -21,7 +21,7 @@ import org.elasticsearch.common.inject.Scope; import java.lang.annotation.Annotation; -import static org.elasticsearch.common.base.Preconditions.*; +import static com.google.common.base.Preconditions.checkNotNull; /** * Registration of a scope annotation with the scope that implements it. Instances are created diff --git a/src/main/java/org/elasticsearch/common/inject/spi/StaticInjectionRequest.java b/src/main/java/org/elasticsearch/common/inject/spi/StaticInjectionRequest.java index 53313fc9fa2..dc233f2c099 100644 --- a/src/main/java/org/elasticsearch/common/inject/spi/StaticInjectionRequest.java +++ b/src/main/java/org/elasticsearch/common/inject/spi/StaticInjectionRequest.java @@ -21,7 +21,7 @@ import org.elasticsearch.common.inject.ConfigurationException; import java.util.Set; -import static org.elasticsearch.common.base.Preconditions.*; +import static com.google.common.base.Preconditions.checkNotNull; /** * A request to inject the static fields and methods of a type. Requests are created diff --git a/src/main/java/org/elasticsearch/common/inject/spi/TypeConverterBinding.java b/src/main/java/org/elasticsearch/common/inject/spi/TypeConverterBinding.java index b5f85274daa..d0522aa9c6c 100644 --- a/src/main/java/org/elasticsearch/common/inject/spi/TypeConverterBinding.java +++ b/src/main/java/org/elasticsearch/common/inject/spi/TypeConverterBinding.java @@ -20,7 +20,7 @@ import org.elasticsearch.common.inject.Binder; import org.elasticsearch.common.inject.TypeLiteral; import org.elasticsearch.common.inject.matcher.Matcher; -import static org.elasticsearch.common.base.Preconditions.*; +import static com.google.common.base.Preconditions.checkNotNull; /** * Registration of type converters for matching target types. Instances are created diff --git a/src/main/java/org/elasticsearch/common/inject/spi/TypeListener.java b/src/main/java/org/elasticsearch/common/inject/spi/TypeListener.java index 737a362e641..f066683fec5 100644 --- a/src/main/java/org/elasticsearch/common/inject/spi/TypeListener.java +++ b/src/main/java/org/elasticsearch/common/inject/spi/TypeListener.java @@ -22,7 +22,7 @@ import org.elasticsearch.common.inject.TypeLiteral; * Listens for Guice to encounter injectable types. If a given type has its constructor injected in * one situation but only its methods and fields injected in another, Guice will notify this * listener once. - * + *

      *

      Useful for extra type checking, {@linkplain TypeEncounter#register(InjectionListener) * registering injection listeners}, and {@linkplain TypeEncounter#bindInterceptor( *org.elasticsearch.common.inject.matcher.Matcher, org.aopalliance.intercept.MethodInterceptor[]) diff --git a/src/main/java/org/elasticsearch/common/inject/spi/TypeListenerBinding.java b/src/main/java/org/elasticsearch/common/inject/spi/TypeListenerBinding.java index 2493da3a8fd..9df91569a4d 100644 --- a/src/main/java/org/elasticsearch/common/inject/spi/TypeListenerBinding.java +++ b/src/main/java/org/elasticsearch/common/inject/spi/TypeListenerBinding.java @@ -23,7 +23,7 @@ import org.elasticsearch.common.inject.matcher.Matcher; /** * Binds types (picked using a Matcher) to an type listener. Registrations are created explicitly in * a module using {@link org.elasticsearch.common.inject.Binder#bindListener(Matcher, TypeListener)} statements: - * + *

      *

        *     register(only(new TypeLiteral<PaymentService<CreditCard>>() {}), listener);
      * diff --git a/src/main/java/org/elasticsearch/common/inject/util/Modules.java b/src/main/java/org/elasticsearch/common/inject/util/Modules.java index 02941eedb69..f842c6a7155 100644 --- a/src/main/java/org/elasticsearch/common/inject/util/Modules.java +++ b/src/main/java/org/elasticsearch/common/inject/util/Modules.java @@ -16,23 +16,12 @@ package org.elasticsearch.common.inject.util; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.collect.Maps; -import org.elasticsearch.common.collect.Sets; -import org.elasticsearch.common.inject.AbstractModule; -import org.elasticsearch.common.inject.Binder; -import org.elasticsearch.common.inject.Binding; -import org.elasticsearch.common.inject.Key; -import org.elasticsearch.common.inject.Module; -import org.elasticsearch.common.inject.PrivateBinder; -import org.elasticsearch.common.inject.Scope; -import org.elasticsearch.common.inject.spi.DefaultBindingScopingVisitor; -import org.elasticsearch.common.inject.spi.DefaultElementVisitor; -import org.elasticsearch.common.inject.spi.Element; -import org.elasticsearch.common.inject.spi.Elements; -import org.elasticsearch.common.inject.spi.PrivateElements; -import org.elasticsearch.common.inject.spi.ScopeBinding; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import org.elasticsearch.common.inject.*; +import org.elasticsearch.common.inject.spi.*; import java.lang.annotation.Annotation; import java.util.Arrays; @@ -63,7 +52,7 @@ public final class Modules { * Module functionalTestModule * = Modules.override(new ProductionModule()).with(new TestModule()); *
    - * + *

    *

    Prefer to write smaller modules that can be reused and tested without overrides. * * @param modules the modules whose bindings are open to be overridden @@ -80,7 +69,7 @@ public final class Modules { * Module functionalTestModule * = Modules.override(getProductionModules()).with(getTestModules()); *

    - * + *

    *

    Prefer to write smaller modules that can be reused and tested without overrides. * * @param modules the modules whose bindings are open to be overridden @@ -150,17 +139,20 @@ public final class Modules { // execute the overrides module, keeping track of which keys and scopes are bound new ModuleWriter(binder()) { - @Override public Void visit(Binding binding) { + @Override + public Void visit(Binding binding) { overriddenKeys.add(binding.getKey()); return super.visit(binding); } - @Override public Void visit(ScopeBinding scopeBinding) { + @Override + public Void visit(ScopeBinding scopeBinding) { overridesScopeAnnotations.add(scopeBinding.getAnnotationType()); return super.visit(scopeBinding); } - @Override public Void visit(PrivateElements privateElements) { + @Override + public Void visit(PrivateElements privateElements) { overriddenKeys.addAll(privateElements.getExposedKeys()); return super.visit(privateElements); } @@ -172,7 +164,8 @@ public final class Modules { final Map scopeInstancesInUse = Maps.newHashMap(); final List scopeBindings = Lists.newArrayList(); new ModuleWriter(binder()) { - @Override public Void visit(Binding binding) { + @Override + public Void visit(Binding binding) { if (!overriddenKeys.remove(binding.getKey())) { super.visit(binding); @@ -186,7 +179,8 @@ public final class Modules { return null; } - @Override public Void visit(PrivateElements privateElements) { + @Override + public Void visit(PrivateElements privateElements) { PrivateBinder privateBinder = binder.withSource(privateElements.getSource()) .newPrivateBinder(); @@ -213,7 +207,8 @@ public final class Modules { return null; } - @Override public Void visit(ScopeBinding scopeBinding) { + @Override + public Void visit(ScopeBinding scopeBinding) { scopeBindings.add(scopeBinding); return null; } @@ -222,7 +217,8 @@ public final class Modules { // execute the scope bindings, skipping scopes that have been overridden. Any scope that // is overridden and in active use will prompt an error new ModuleWriter(binder()) { - @Override public Void visit(ScopeBinding scopeBinding) { + @Override + public Void visit(ScopeBinding scopeBinding) { if (!overridesScopeAnnotations.remove(scopeBinding.getAnnotationType())) { super.visit(scopeBinding); } else { @@ -258,7 +254,8 @@ public final class Modules { this.binder = binder; } - @Override protected Void visitOther(Element element) { + @Override + protected Void visitOther(Element element) { element.applyTo(binder); return null; } diff --git a/src/main/java/org/elasticsearch/common/inject/util/Providers.java b/src/main/java/org/elasticsearch/common/inject/util/Providers.java index f9e8aa044ef..c62c1436433 100644 --- a/src/main/java/org/elasticsearch/common/inject/util/Providers.java +++ b/src/main/java/org/elasticsearch/common/inject/util/Providers.java @@ -45,7 +45,8 @@ public final class Providers { return instance; } - @Override public String toString() { + @Override + public String toString() { return "of(" + instance + ")"; } }; diff --git a/src/main/java/org/elasticsearch/common/io/BooleanStreamable.java b/src/main/java/org/elasticsearch/common/io/BooleanStreamable.java index eddea7305be..dd19428d54c 100644 --- a/src/main/java/org/elasticsearch/common/io/BooleanStreamable.java +++ b/src/main/java/org/elasticsearch/common/io/BooleanStreamable.java @@ -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 BooleanStreamable implements Streamable { @@ -47,11 +47,13 @@ public class BooleanStreamable implements Streamable { return this.value; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { value = in.readBoolean(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(value); } } diff --git a/src/main/java/org/elasticsearch/common/io/BytesStream.java b/src/main/java/org/elasticsearch/common/io/BytesStream.java index d5f4060584a..b6ea8d26a6e 100644 --- a/src/main/java/org/elasticsearch/common/io/BytesStream.java +++ b/src/main/java/org/elasticsearch/common/io/BytesStream.java @@ -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 diff --git a/src/main/java/org/elasticsearch/common/io/CachedStreams.java b/src/main/java/org/elasticsearch/common/io/CachedStreams.java index 48917cb9d4f..1a210da4f1e 100644 --- a/src/main/java/org/elasticsearch/common/io/CachedStreams.java +++ b/src/main/java/org/elasticsearch/common/io/CachedStreams.java @@ -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 diff --git a/src/main/java/org/elasticsearch/common/io/CharSequenceReader.java b/src/main/java/org/elasticsearch/common/io/CharSequenceReader.java index c8646a12bbd..001618fe7ba 100644 --- a/src/main/java/org/elasticsearch/common/io/CharSequenceReader.java +++ b/src/main/java/org/elasticsearch/common/io/CharSequenceReader.java @@ -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.common.io; import java.io.Reader; /** - * @author kimchy (shay.banon) + * */ public abstract class CharSequenceReader extends Reader implements CharSequence { } diff --git a/src/main/java/org/elasticsearch/common/io/CompactObjectInputStream.java b/src/main/java/org/elasticsearch/common/io/CompactObjectInputStream.java index a3f94297bf4..91defe17b58 100644 --- a/src/main/java/org/elasticsearch/common/io/CompactObjectInputStream.java +++ b/src/main/java/org/elasticsearch/common/io/CompactObjectInputStream.java @@ -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.common.Classes; import java.io.*; /** - * @author kimchy (Shay Banon) + * */ class CompactObjectInputStream extends ObjectInputStream { @@ -39,7 +39,8 @@ class CompactObjectInputStream extends ObjectInputStream { this.classLoader = classLoader; } - @Override protected void readStreamHeader() throws IOException, + @Override + protected void readStreamHeader() throws IOException, StreamCorruptedException { int version = readByte() & 0xFF; if (version != STREAM_VERSION) { @@ -48,7 +49,8 @@ class CompactObjectInputStream extends ObjectInputStream { } } - @Override protected ObjectStreamClass readClassDescriptor() + @Override + protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException { int type = read(); if (type < 0) { @@ -67,7 +69,8 @@ class CompactObjectInputStream extends ObjectInputStream { } } - @Override protected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { + @Override + protected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { String className = desc.getName(); try { return loadClass(className); diff --git a/src/main/java/org/elasticsearch/common/io/CompactObjectOutputStream.java b/src/main/java/org/elasticsearch/common/io/CompactObjectOutputStream.java index c44711d3072..a2653413449 100644 --- a/src/main/java/org/elasticsearch/common/io/CompactObjectOutputStream.java +++ b/src/main/java/org/elasticsearch/common/io/CompactObjectOutputStream.java @@ -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.io.ObjectStreamClass; import java.io.OutputStream; /** - * @author kimchy (Shay Banon) + * */ class CompactObjectOutputStream extends ObjectOutputStream { @@ -36,11 +36,13 @@ class CompactObjectOutputStream extends ObjectOutputStream { super(out); } - @Override protected void writeStreamHeader() throws IOException { + @Override + protected void writeStreamHeader() throws IOException { writeByte(STREAM_VERSION); } - @Override protected void writeClassDescriptor(ObjectStreamClass desc) throws IOException { + @Override + protected void writeClassDescriptor(ObjectStreamClass desc) throws IOException { Class clazz = desc.forClass(); if (clazz.isPrimitive() || clazz.isArray()) { write(TYPE_FAT_DESCRIPTOR); diff --git a/src/main/java/org/elasticsearch/common/io/FastByteArrayInputStream.java b/src/main/java/org/elasticsearch/common/io/FastByteArrayInputStream.java index 25bd077cb8c..fbe7e922488 100644 --- a/src/main/java/org/elasticsearch/common/io/FastByteArrayInputStream.java +++ b/src/main/java/org/elasticsearch/common/io/FastByteArrayInputStream.java @@ -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 java.io.IOException; import java.io.InputStream; /** - * @author kimchy (Shay Banon) + * */ public class FastByteArrayInputStream extends InputStream { diff --git a/src/main/java/org/elasticsearch/common/io/FastByteArrayOutputStream.java b/src/main/java/org/elasticsearch/common/io/FastByteArrayOutputStream.java index a36f7b8150b..2ee1a95e10e 100644 --- a/src/main/java/org/elasticsearch/common/io/FastByteArrayOutputStream.java +++ b/src/main/java/org/elasticsearch/common/io/FastByteArrayOutputStream.java @@ -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 java.util.Arrays; /** * Similar to {@link java.io.ByteArrayOutputStream} just not synced. * - * @author kimchy (Shay Banon) + * */ public class FastByteArrayOutputStream extends OutputStream implements BytesStream { @@ -44,7 +44,7 @@ public class FastByteArrayOutputStream extends OutputStream implements BytesStre /** * Creates a new byte array output stream. The buffer capacity is * initially 1024 bytes, though its size increases if necessary. - * + *

    * ES: We use 1024 bytes since we mainly use this to build json/smile * content in memory, and rarely does the 32 byte default in ByteArrayOutputStream fits... */ @@ -84,7 +84,7 @@ public class FastByteArrayOutputStream extends OutputStream implements BytesStre /** * Writes len bytes from the specified byte array * starting at offset off to this byte array output stream. - * + *

    * NO checks for bounds, parameters must be ok! * * @param b the data. diff --git a/src/main/java/org/elasticsearch/common/io/FastCharArrayReader.java b/src/main/java/org/elasticsearch/common/io/FastCharArrayReader.java index 7d5506bbdfb..ab64ff619b9 100644 --- a/src/main/java/org/elasticsearch/common/io/FastCharArrayReader.java +++ b/src/main/java/org/elasticsearch/common/io/FastCharArrayReader.java @@ -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 java.io.IOException; import java.io.Reader; /** - * @author kimchy (shay.banon) + * */ public class FastCharArrayReader extends Reader { @@ -61,7 +61,7 @@ public class FastCharArrayReader extends Reader { /** * Creates a CharArrayReader from the specified array of chars. - * + *

    *

    The resulting reader will start reading at the given * offset. The total number of char values that can be * read from this reader will be either length or @@ -141,7 +141,7 @@ public class FastCharArrayReader extends Reader { /** * Skips characters. Returns the number of characters that were skipped. - * + *

    *

    The n parameter may be negative, even though the * skip method of the {@link Reader} superclass throws * an exception in this case. If n is negative, then diff --git a/src/main/java/org/elasticsearch/common/io/FastCharArrayWriter.java b/src/main/java/org/elasticsearch/common/io/FastCharArrayWriter.java index 8099ac147c1..aa7e1a0ff44 100644 --- a/src/main/java/org/elasticsearch/common/io/FastCharArrayWriter.java +++ b/src/main/java/org/elasticsearch/common/io/FastCharArrayWriter.java @@ -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.util.Arrays; /** * A similar class to {@link java.io.CharArrayWriter} allowing to get the underlying char[] buffer. * - * @author kimchy (shay.banon) + * */ @NotThreadSafe public class FastCharArrayWriter extends Writer { @@ -132,7 +132,7 @@ public class FastCharArrayWriter extends Writer { *

    *

          *     out.write(csq.toString()) 
    - *

    + * *

    Depending on the specification of toString for the * character sequence csq, the entire sequence may not be * appended. For instance, invoking the toString method of a diff --git a/src/main/java/org/elasticsearch/common/io/FastStringReader.java b/src/main/java/org/elasticsearch/common/io/FastStringReader.java index c5c786528cd..6dbb87c083d 100644 --- a/src/main/java/org/elasticsearch/common/io/FastStringReader.java +++ b/src/main/java/org/elasticsearch/common/io/FastStringReader.java @@ -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 java.io.Reader; /** * A character stream whose source is a string that is not thread safe * - * @author kimchy (shay.banon + * (shay.banon * ) */ @NotThreadSafe @@ -56,15 +56,18 @@ public class FastStringReader extends CharSequenceReader { throw new IOException("Stream closed"); } - @Override public int length() { + @Override + public int length() { return length; } - @Override public char charAt(int index) { + @Override + public char charAt(int index) { return str.charAt(index); } - @Override public CharSequence subSequence(int start, int end) { + @Override + public CharSequence subSequence(int start, int end) { return str.subSequence(start, end); } @@ -75,7 +78,8 @@ public class FastStringReader extends CharSequenceReader { * reached * @throws IOException If an I/O error occurs */ - @Override public int read() throws IOException { + @Override + public int read() throws IOException { ensureOpen(); if (next >= length) return -1; @@ -92,7 +96,8 @@ public class FastStringReader extends CharSequenceReader { * stream has been reached * @throws IOException If an I/O error occurs */ - @Override public int read(char cbuf[], int off, int len) throws IOException { + @Override + public int read(char cbuf[], int off, int len) throws IOException { ensureOpen(); if (len == 0) { return 0; @@ -121,7 +126,8 @@ public class FastStringReader extends CharSequenceReader { * * @throws IOException If an I/O error occurs */ - @Override public long skip(long ns) throws IOException { + @Override + public long skip(long ns) throws IOException { ensureOpen(); if (next >= length) return 0; @@ -138,7 +144,8 @@ public class FastStringReader extends CharSequenceReader { * @return True if the next read() is guaranteed not to block for input * @throws IOException If the stream is closed */ - @Override public boolean ready() throws IOException { + @Override + public boolean ready() throws IOException { ensureOpen(); return true; } @@ -146,7 +153,8 @@ public class FastStringReader extends CharSequenceReader { /** * Tells whether this stream supports the mark() operation, which it does. */ - @Override public boolean markSupported() { + @Override + public boolean markSupported() { return true; } @@ -162,7 +170,8 @@ public class FastStringReader extends CharSequenceReader { * @throws IllegalArgumentException If readAheadLimit is < 0 * @throws IOException If an I/O error occurs */ - @Override public void mark(int readAheadLimit) throws IOException { + @Override + public void mark(int readAheadLimit) throws IOException { if (readAheadLimit < 0) { throw new IllegalArgumentException("Read-ahead limit < 0"); } @@ -176,7 +185,8 @@ public class FastStringReader extends CharSequenceReader { * * @throws IOException If an I/O error occurs */ - @Override public void reset() throws IOException { + @Override + public void reset() throws IOException { ensureOpen(); next = mark; } @@ -191,7 +201,8 @@ public class FastStringReader extends CharSequenceReader { length = -1; } - @Override public String toString() { + @Override + public String toString() { return str; } } diff --git a/src/main/java/org/elasticsearch/common/io/FileChannelInputStream.java b/src/main/java/org/elasticsearch/common/io/FileChannelInputStream.java index 32a7063e768..e075c00f60a 100644 --- a/src/main/java/org/elasticsearch/common/io/FileChannelInputStream.java +++ b/src/main/java/org/elasticsearch/common/io/FileChannelInputStream.java @@ -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.nio.ByteBuffer; import java.nio.channels.FileChannel; /** - * @author kimchy (shay.banon) + * */ public class FileChannelInputStream extends InputStream { @@ -50,7 +50,8 @@ public class FileChannelInputStream extends InputStream { this.length = position + length; // easier to work with total length } - @Override public int read() throws IOException { + @Override + public int read() throws IOException { if (b1 == null) { b1 = new byte[1]; } @@ -61,7 +62,8 @@ public class FileChannelInputStream extends InputStream { return -1; } - @Override public int read(byte[] bs, int off, int len) throws IOException { + @Override + public int read(byte[] bs, int off, int len) throws IOException { if (len == 0) { return 0; } diff --git a/src/main/java/org/elasticsearch/common/io/FileSystemUtils.java b/src/main/java/org/elasticsearch/common/io/FileSystemUtils.java index d8cad05f09d..e3d96cd7918 100644 --- a/src/main/java/org/elasticsearch/common/io/FileSystemUtils.java +++ b/src/main/java/org/elasticsearch/common/io/FileSystemUtils.java @@ -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,18 +23,13 @@ import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.ESLoggerFactory; import org.elasticsearch.common.unit.TimeValue; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InterruptedIOException; -import java.io.RandomAccessFile; +import java.io.*; import java.nio.channels.FileChannel; import java.util.ArrayList; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class FileSystemUtils { diff --git a/src/main/java/org/elasticsearch/common/io/Serializers.java b/src/main/java/org/elasticsearch/common/io/Serializers.java index 667f8e45c33..08dc23365d2 100644 --- a/src/main/java/org/elasticsearch/common/io/Serializers.java +++ b/src/main/java/org/elasticsearch/common/io/Serializers.java @@ -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.io.IOException; import java.io.Serializable; /** - * @author kimchy (Shay Banon) + * */ public final class Serializers { diff --git a/src/main/java/org/elasticsearch/common/io/Streams.java b/src/main/java/org/elasticsearch/common/io/Streams.java index 95fe08d4f89..ef142068154 100644 --- a/src/main/java/org/elasticsearch/common/io/Streams.java +++ b/src/main/java/org/elasticsearch/common/io/Streams.java @@ -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,7 +33,7 @@ import java.io.*; *

    Mainly for use within the framework, * but also useful for application code. * - * @author kimchy (Shay Banon) + * */ public abstract class Streams { diff --git a/src/main/java/org/elasticsearch/common/io/ThrowableObjectInputStream.java b/src/main/java/org/elasticsearch/common/io/ThrowableObjectInputStream.java index 432f62cc1b4..61d6f8c4bb9 100644 --- a/src/main/java/org/elasticsearch/common/io/ThrowableObjectInputStream.java +++ b/src/main/java/org/elasticsearch/common/io/ThrowableObjectInputStream.java @@ -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.common.io; import java.io.*; /** - * @author kimchy (Shay Banon) + * */ public class ThrowableObjectInputStream extends ObjectInputStream { diff --git a/src/main/java/org/elasticsearch/common/io/ThrowableObjectOutputStream.java b/src/main/java/org/elasticsearch/common/io/ThrowableObjectOutputStream.java index 83c465a82f8..793639ce2a5 100644 --- a/src/main/java/org/elasticsearch/common/io/ThrowableObjectOutputStream.java +++ b/src/main/java/org/elasticsearch/common/io/ThrowableObjectOutputStream.java @@ -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.io.ObjectStreamClass; import java.io.OutputStream; /** - * @author kimchy (Shay Banon) + * */ public class ThrowableObjectOutputStream extends ObjectOutputStream { @@ -43,11 +43,13 @@ public class ThrowableObjectOutputStream extends ObjectOutputStream { super(out); } - @Override protected void writeStreamHeader() throws IOException { + @Override + protected void writeStreamHeader() throws IOException { writeByte(STREAM_VERSION); } - @Override protected void writeClassDescriptor(ObjectStreamClass desc) throws IOException { + @Override + protected void writeClassDescriptor(ObjectStreamClass desc) throws IOException { if (desc.getName().equals(EXCEPTION_CLASSNAME)) { write(TYPE_EXCEPTION); } else if (desc.getName().equals(STACKTRACEELEMENT_CLASSNAME)) { diff --git a/src/main/java/org/elasticsearch/common/io/stream/BytesStreamInput.java b/src/main/java/org/elasticsearch/common/io/stream/BytesStreamInput.java index e92dc305b5c..9ecc3a21343 100644 --- a/src/main/java/org/elasticsearch/common/io/stream/BytesStreamInput.java +++ b/src/main/java/org/elasticsearch/common/io/stream/BytesStreamInput.java @@ -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 java.io.IOException; import java.io.UTFDataFormatException; /** - * @author kimchy (shay.banon) + * */ public class BytesStreamInput extends StreamInput { @@ -44,7 +44,8 @@ public class BytesStreamInput extends StreamInput { this.count = Math.min(offset + length, buf.length); } - @Override public long skip(long n) throws IOException { + @Override + public long skip(long n) throws IOException { if (pos + n > count) { n = count - pos; } @@ -59,11 +60,13 @@ public class BytesStreamInput extends StreamInput { return this.pos; } - @Override public int read() throws IOException { + @Override + public int read() throws IOException { return (pos < count) ? (buf[pos++] & 0xff) : -1; } - @Override public int read(byte[] b, int off, int len) throws IOException { + @Override + public int read(byte[] b, int off, int len) throws IOException { if (b == null) { throw new NullPointerException(); } else if (off < 0 || len < 0 || len > b.length - off) { @@ -87,14 +90,16 @@ public class BytesStreamInput extends StreamInput { return buf; } - @Override public byte readByte() throws IOException { + @Override + public byte readByte() throws IOException { if (pos >= count) { throw new EOFException(); } return buf[pos++]; } - @Override public void readBytes(byte[] b, int offset, int len) throws IOException { + @Override + public void readBytes(byte[] b, int offset, int len) throws IOException { if (len == 0) { return; } @@ -111,11 +116,13 @@ public class BytesStreamInput extends StreamInput { pos += len; } - @Override public void reset() throws IOException { + @Override + public void reset() throws IOException { pos = 0; } - @Override public void close() throws IOException { + @Override + public void close() throws IOException { // nothing to do here... } diff --git a/src/main/java/org/elasticsearch/common/io/stream/BytesStreamOutput.java b/src/main/java/org/elasticsearch/common/io/stream/BytesStreamOutput.java index 385d971fa02..074e0769662 100644 --- a/src/main/java/org/elasticsearch/common/io/stream/BytesStreamOutput.java +++ b/src/main/java/org/elasticsearch/common/io/stream/BytesStreamOutput.java @@ -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.io.IOException; import java.util.Arrays; /** - * @author kimchy (shay.banon) + * */ public class BytesStreamOutput extends StreamOutput implements BytesStream { @@ -47,7 +47,8 @@ public class BytesStreamOutput extends StreamOutput implements BytesStream { this.buf = new byte[size]; } - @Override public void writeByte(byte b) throws IOException { + @Override + public void writeByte(byte b) throws IOException { int newcount = count + 1; if (newcount > buf.length) { buf = Arrays.copyOf(buf, Math.max(buf.length << 1, newcount)); @@ -56,7 +57,8 @@ public class BytesStreamOutput extends StreamOutput implements BytesStream { count = newcount; } - @Override public void writeBytes(byte[] b, int offset, int length) throws IOException { + @Override + public void writeBytes(byte[] b, int offset, int length) throws IOException { if (length == 0) { return; } @@ -76,11 +78,13 @@ public class BytesStreamOutput extends StreamOutput implements BytesStream { count = 0; } - @Override public void flush() throws IOException { + @Override + public void flush() throws IOException { // nothing to do there } - @Override public void close() throws IOException { + @Override + public void close() throws IOException { // nothing to do here } diff --git a/src/main/java/org/elasticsearch/common/io/stream/CachedStreamInput.java b/src/main/java/org/elasticsearch/common/io/stream/CachedStreamInput.java index b5825a84ec0..9f4dfbeb338 100644 --- a/src/main/java/org/elasticsearch/common/io/stream/CachedStreamInput.java +++ b/src/main/java/org/elasticsearch/common/io/stream/CachedStreamInput.java @@ -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 java.io.IOException; import java.lang.ref.SoftReference; /** - * @author kimchy (shay.banon) + * */ public class CachedStreamInput { diff --git a/src/main/java/org/elasticsearch/common/io/stream/CachedStreamOutput.java b/src/main/java/org/elasticsearch/common/io/stream/CachedStreamOutput.java index f94fae3a52d..28dfaed4feb 100644 --- a/src/main/java/org/elasticsearch/common/io/stream/CachedStreamOutput.java +++ b/src/main/java/org/elasticsearch/common/io/stream/CachedStreamOutput.java @@ -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,7 +19,7 @@ package org.elasticsearch.common.io.stream; -import org.elasticsearch.common.util.concurrent.jsr166y.LinkedTransferQueue; +import jsr166y.LinkedTransferQueue; import java.io.IOException; import java.lang.ref.SoftReference; @@ -27,7 +27,7 @@ import java.util.Queue; import java.util.concurrent.atomic.AtomicInteger; /** - * @author kimchy (shay.banon) + * */ public class CachedStreamOutput { diff --git a/src/main/java/org/elasticsearch/common/io/stream/DataOutputStreamOutput.java b/src/main/java/org/elasticsearch/common/io/stream/DataOutputStreamOutput.java index 6f48528628e..1d0a5cf7527 100644 --- a/src/main/java/org/elasticsearch/common/io/stream/DataOutputStreamOutput.java +++ b/src/main/java/org/elasticsearch/common/io/stream/DataOutputStreamOutput.java @@ -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 java.io.DataOutput; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class DataOutputStreamOutput extends StreamOutput { @@ -34,23 +34,28 @@ public class DataOutputStreamOutput extends StreamOutput { this.out = out; } - @Override public void writeByte(byte b) throws IOException { + @Override + public void writeByte(byte b) throws IOException { out.writeByte(b); } - @Override public void writeBytes(byte[] b, int offset, int length) throws IOException { + @Override + public void writeBytes(byte[] b, int offset, int length) throws IOException { out.write(b, offset, length); } - @Override public void flush() throws IOException { + @Override + public void flush() throws IOException { // nothing to do there... } - @Override public void reset() throws IOException { + @Override + public void reset() throws IOException { // nothing to do there... } - @Override public void close() throws IOException { + @Override + public void close() throws IOException { if (out instanceof Closeable) { ((Closeable) out).close(); } diff --git a/src/main/java/org/elasticsearch/common/io/stream/HandlesStreamInput.java b/src/main/java/org/elasticsearch/common/io/stream/HandlesStreamInput.java index 38b768fe663..35f63ec72e8 100644 --- a/src/main/java/org/elasticsearch/common/io/stream/HandlesStreamInput.java +++ b/src/main/java/org/elasticsearch/common/io/stream/HandlesStreamInput.java @@ -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.elasticsearch.common.io.stream; -import org.elasticsearch.common.trove.map.hash.TIntObjectHashMap; +import gnu.trove.map.hash.TIntObjectHashMap; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class HandlesStreamInput extends StreamInput { @@ -41,7 +41,8 @@ public class HandlesStreamInput extends StreamInput { this.in = in; } - @Override public String readUTF() throws IOException { + @Override + public String readUTF() throws IOException { byte b = in.readByte(); if (b == 0) { // full string with handle @@ -64,23 +65,28 @@ public class HandlesStreamInput extends StreamInput { } } - @Override public int read() throws IOException { + @Override + public int read() throws IOException { return in.read(); } - @Override public int read(byte[] b) throws IOException { + @Override + public int read(byte[] b) throws IOException { return in.read(b); } - @Override public int read(byte[] b, int off, int len) throws IOException { + @Override + public int read(byte[] b, int off, int len) throws IOException { return in.read(b, off, len); } - @Override public byte readByte() throws IOException { + @Override + public byte readByte() throws IOException { return in.readByte(); } - @Override public void readBytes(byte[] b, int offset, int len) throws IOException { + @Override + public void readBytes(byte[] b, int offset, int len) throws IOException { in.readBytes(b, offset, len); } @@ -88,7 +94,8 @@ public class HandlesStreamInput extends StreamInput { handles.clear(); } - @Override public void reset() throws IOException { + @Override + public void reset() throws IOException { in.reset(); handles.clear(); } @@ -99,7 +106,8 @@ public class HandlesStreamInput extends StreamInput { identityHandles.clear(); } - @Override public void close() throws IOException { + @Override + public void close() throws IOException { in.close(); } } diff --git a/src/main/java/org/elasticsearch/common/io/stream/HandlesStreamOutput.java b/src/main/java/org/elasticsearch/common/io/stream/HandlesStreamOutput.java index 75ad78db087..fa1be3eac93 100644 --- a/src/main/java/org/elasticsearch/common/io/stream/HandlesStreamOutput.java +++ b/src/main/java/org/elasticsearch/common/io/stream/HandlesStreamOutput.java @@ -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,14 +19,14 @@ package org.elasticsearch.common.io.stream; -import org.elasticsearch.common.trove.impl.Constants; -import org.elasticsearch.common.trove.map.hash.TObjectIntHashMap; +import gnu.trove.impl.Constants; +import gnu.trove.map.hash.TObjectIntHashMap; import java.io.IOException; import java.util.Arrays; /** - * @author kimchy (shay.banon) + * */ public class HandlesStreamOutput extends StreamOutput { @@ -50,7 +50,8 @@ public class HandlesStreamOutput extends StreamOutput { this.identityThreshold = identityThreshold; } - @Override public void writeUTF(String s) throws IOException { + @Override + public void writeUTF(String s) throws IOException { if (s.length() < identityThreshold) { int handle = handles.get(s); if (handle == -1) { @@ -77,11 +78,13 @@ public class HandlesStreamOutput extends StreamOutput { } } - @Override public void writeByte(byte b) throws IOException { + @Override + public void writeByte(byte b) throws IOException { out.writeByte(b); } - @Override public void writeBytes(byte[] b, int offset, int length) throws IOException { + @Override + public void writeBytes(byte[] b, int offset, int length) throws IOException { out.writeBytes(b, offset, length); } @@ -90,7 +93,8 @@ public class HandlesStreamOutput extends StreamOutput { identityHandles.clear(); } - @Override public void reset() throws IOException { + @Override + public void reset() throws IOException { handles.clear(); identityHandles.clear(); out.reset(); @@ -101,11 +105,13 @@ public class HandlesStreamOutput extends StreamOutput { reset(); } - @Override public void flush() throws IOException { + @Override + public void flush() throws IOException { out.flush(); } - @Override public void close() throws IOException { + @Override + public void close() throws IOException { out.close(); } diff --git a/src/main/java/org/elasticsearch/common/io/stream/InputStreamStreamInput.java b/src/main/java/org/elasticsearch/common/io/stream/InputStreamStreamInput.java index 056bad1af15..d5052b24d70 100644 --- a/src/main/java/org/elasticsearch/common/io/stream/InputStreamStreamInput.java +++ b/src/main/java/org/elasticsearch/common/io/stream/InputStreamStreamInput.java @@ -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 java.io.IOException; import java.io.InputStream; /** - * @author kimchy (shay.banon) + * */ public class InputStreamStreamInput extends StreamInput { @@ -34,14 +34,16 @@ public class InputStreamStreamInput extends StreamInput { this.is = is; } - @Override public byte readByte() throws IOException { + @Override + public byte readByte() throws IOException { int ch = is.read(); if (ch < 0) throw new EOFException(); return (byte) (ch); } - @Override public void readBytes(byte[] b, int offset, int len) throws IOException { + @Override + public void readBytes(byte[] b, int offset, int len) throws IOException { if (len < 0) throw new IndexOutOfBoundsException(); int n = 0; @@ -53,27 +55,33 @@ public class InputStreamStreamInput extends StreamInput { } } - @Override public void reset() throws IOException { + @Override + public void reset() throws IOException { is.reset(); } - @Override public void close() throws IOException { + @Override + public void close() throws IOException { is.close(); } - @Override public int read() throws IOException { + @Override + public int read() throws IOException { return is.read(); } - @Override public int read(byte[] b) throws IOException { + @Override + public int read(byte[] b) throws IOException { return is.read(b); } - @Override public int read(byte[] b, int off, int len) throws IOException { + @Override + public int read(byte[] b, int off, int len) throws IOException { return is.read(b, off, len); } - @Override public long skip(long n) throws IOException { + @Override + public long skip(long n) throws IOException { return is.skip(n); } } diff --git a/src/main/java/org/elasticsearch/common/io/stream/LZFStreamInput.java b/src/main/java/org/elasticsearch/common/io/stream/LZFStreamInput.java index 6ff0de91a11..be80df1a5e5 100644 --- a/src/main/java/org/elasticsearch/common/io/stream/LZFStreamInput.java +++ b/src/main/java/org/elasticsearch/common/io/stream/LZFStreamInput.java @@ -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.EOFException; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class LZFStreamInput extends StreamInput { /** @@ -149,21 +149,24 @@ public class LZFStreamInput extends StreamInput { return totalRead; } - @Override public byte readByte() throws IOException { + @Override + public byte readByte() throws IOException { if (!readyBuffer()) { throw new EOFException(); } return _decodedBytes[bufferPosition++]; } - @Override public void readBytes(byte[] b, int offset, int len) throws IOException { + @Override + public void readBytes(byte[] b, int offset, int len) throws IOException { int result = read(b, offset, len); if (result < len) { throw new EOFException(); } } - @Override public void reset() throws IOException { + @Override + public void reset() throws IOException { this.bufferPosition = 0; this.bufferLength = 0; inputStream.reset(); @@ -182,7 +185,8 @@ public class LZFStreamInput extends StreamInput { this.bufferPosition = 0; } - @Override public void close() throws IOException { + @Override + public void close() throws IOException { if (cached) { reset(); return; diff --git a/src/main/java/org/elasticsearch/common/io/stream/LZFStreamOutput.java b/src/main/java/org/elasticsearch/common/io/stream/LZFStreamOutput.java index 30278520a3c..62de85ee63e 100644 --- a/src/main/java/org/elasticsearch/common/io/stream/LZFStreamOutput.java +++ b/src/main/java/org/elasticsearch/common/io/stream/LZFStreamOutput.java @@ -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.compress.lzf.LZFChunk; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class LZFStreamOutput extends StreamOutput { @@ -43,7 +43,7 @@ public class LZFStreamOutput extends StreamOutput { /** * Configuration setting that governs whether basic 'flush()' should * first complete a block or not. - *

    + *

    * Default value is 'true' * * @since 0.8 @@ -60,21 +60,24 @@ public class LZFStreamOutput extends StreamOutput { _outputBuffer = _recycler.allocOutputBuffer(OUTPUT_BUFFER_SIZE); } - @Override public void write(final int singleByte) throws IOException { + @Override + public void write(final int singleByte) throws IOException { if (_position >= _outputBuffer.length) { writeCompressedBlock(); } _outputBuffer[_position++] = (byte) singleByte; } - @Override public void writeByte(byte b) throws IOException { + @Override + public void writeByte(byte b) throws IOException { if (_position >= _outputBuffer.length) { writeCompressedBlock(); } _outputBuffer[_position++] = b; } - @Override public void writeBytes(byte[] buffer, int offset, int length) throws IOException { + @Override + public void writeBytes(byte[] buffer, int offset, int length) throws IOException { // ES, check if length is 0, and don't write in this case if (length == 0) { return; @@ -137,7 +140,8 @@ public class LZFStreamOutput extends StreamOutput { _outputStream.close(); } - @Override public void reset() throws IOException { + @Override + public void reset() throws IOException { _position = 0; _outputStream.reset(); } diff --git a/src/main/java/org/elasticsearch/common/io/stream/LongStreamable.java b/src/main/java/org/elasticsearch/common/io/stream/LongStreamable.java index c447720b5db..27c4d7dc0c2 100644 --- a/src/main/java/org/elasticsearch/common/io/stream/LongStreamable.java +++ b/src/main/java/org/elasticsearch/common/io/stream/LongStreamable.java @@ -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.common.io.stream; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class LongStreamable implements Streamable { @@ -43,11 +43,13 @@ public class LongStreamable implements Streamable { return this.value; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { value = in.readLong(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeLong(value); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java b/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java index 955f3db48dd..19fddae5392 100644 --- a/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java +++ b/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java @@ -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.io.InputStream; import java.io.UTFDataFormatException; /** - * @author kimchy (shay.banon) + * */ public abstract class StreamInput extends InputStream { diff --git a/src/main/java/org/elasticsearch/common/io/stream/StreamOutput.java b/src/main/java/org/elasticsearch/common/io/stream/StreamOutput.java index d5ddd9043ed..31705e08478 100644 --- a/src/main/java/org/elasticsearch/common/io/stream/StreamOutput.java +++ b/src/main/java/org/elasticsearch/common/io/stream/StreamOutput.java @@ -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 java.io.IOException; import java.io.OutputStream; /** - * @author kimchy (shay.banon) + * */ public abstract class StreamOutput extends OutputStream { @@ -200,11 +200,13 @@ public abstract class StreamOutput extends OutputStream { public abstract void reset() throws IOException; - @Override public void write(int b) throws IOException { + @Override + public void write(int b) throws IOException { writeByte((byte) b); } - @Override public void write(byte[] b, int off, int len) throws IOException { + @Override + public void write(byte[] b, int off, int len) throws IOException { writeBytes(b, off, len); } } diff --git a/src/main/java/org/elasticsearch/common/io/stream/Streamable.java b/src/main/java/org/elasticsearch/common/io/stream/Streamable.java index d4736df1903..d41d16f7377 100644 --- a/src/main/java/org/elasticsearch/common/io/stream/Streamable.java +++ b/src/main/java/org/elasticsearch/common/io/stream/Streamable.java @@ -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.common.io.stream; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public interface Streamable { diff --git a/src/main/java/org/elasticsearch/common/io/stream/Streamables.java b/src/main/java/org/elasticsearch/common/io/stream/Streamables.java index 096b205f3aa..e9ac61afd84 100644 --- a/src/main/java/org/elasticsearch/common/io/stream/Streamables.java +++ b/src/main/java/org/elasticsearch/common/io/stream/Streamables.java @@ -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.util.List; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class Streamables { diff --git a/src/main/java/org/elasticsearch/common/io/stream/StringStreamable.java b/src/main/java/org/elasticsearch/common/io/stream/StringStreamable.java index d17a42b2f5f..08bdb8e051a 100644 --- a/src/main/java/org/elasticsearch/common/io/stream/StringStreamable.java +++ b/src/main/java/org/elasticsearch/common/io/stream/StringStreamable.java @@ -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.common.io.stream; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class StringStreamable implements Streamable { @@ -43,11 +43,13 @@ public class StringStreamable implements Streamable { return this.value; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { value = in.readUTF(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(value); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/common/io/stream/VoidStreamable.java b/src/main/java/org/elasticsearch/common/io/stream/VoidStreamable.java index 21d024479ff..f6841d9444c 100644 --- a/src/main/java/org/elasticsearch/common/io/stream/VoidStreamable.java +++ b/src/main/java/org/elasticsearch/common/io/stream/VoidStreamable.java @@ -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,15 +22,17 @@ package org.elasticsearch.common.io.stream; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class VoidStreamable implements Streamable { public static final VoidStreamable INSTANCE = new VoidStreamable(); - @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 { } } diff --git a/src/main/java/org/elasticsearch/common/jline/ANSI.java b/src/main/java/org/elasticsearch/common/jline/ANSI.java index 604c0631c51..87b5db286fd 100644 --- a/src/main/java/org/elasticsearch/common/jline/ANSI.java +++ b/src/main/java/org/elasticsearch/common/jline/ANSI.java @@ -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,7 +31,7 @@ import java.util.HashMap; import java.util.Map; /** - * @author kimchy (Shay Banon) + * */ public class ANSI { // @@ -145,8 +145,7 @@ public class ANSI { names.put(name, code); codes.put(code, name); } - } - catch (IllegalAccessException e) { + } catch (IllegalAccessException e) { // This should never happen throw new Error(e); } @@ -199,8 +198,7 @@ public class ANSI { public String toString() { try { return buff.toString(); - } - finally { + } finally { if (autoClear) clear(); } } diff --git a/src/main/java/org/elasticsearch/common/jna/CLibrary.java b/src/main/java/org/elasticsearch/common/jna/CLibrary.java index 23e3fb543d7..cfed3f0779e 100644 --- a/src/main/java/org/elasticsearch/common/jna/CLibrary.java +++ b/src/main/java/org/elasticsearch/common/jna/CLibrary.java @@ -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.common.logging.Loggers; /** - * @author kimchy (shay.banon) + * */ public class CLibrary { diff --git a/src/main/java/org/elasticsearch/common/jna/Natives.java b/src/main/java/org/elasticsearch/common/jna/Natives.java index fdc2c1e2ebd..3581fd7fcf0 100644 --- a/src/main/java/org/elasticsearch/common/jna/Natives.java +++ b/src/main/java/org/elasticsearch/common/jna/Natives.java @@ -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.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; /** - * @author kimchy (shay.banon) + * */ public class Natives { diff --git a/src/main/java/org/elasticsearch/common/joda/FormatDateTimeFormatter.java b/src/main/java/org/elasticsearch/common/joda/FormatDateTimeFormatter.java index f1130bb2843..b5bf535a0e2 100644 --- a/src/main/java/org/elasticsearch/common/joda/FormatDateTimeFormatter.java +++ b/src/main/java/org/elasticsearch/common/joda/FormatDateTimeFormatter.java @@ -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,14 +19,14 @@ package org.elasticsearch.common.joda; -import org.elasticsearch.common.joda.time.format.DateTimeFormatter; import org.elasticsearch.common.util.concurrent.Immutable; +import org.joda.time.format.DateTimeFormatter; /** * A simple wrapper around {@link DateTimeFormatter} that retains the * format that was used to create it. * - * @author kimchy (shay.banon) + * */ @Immutable public class FormatDateTimeFormatter { diff --git a/src/main/java/org/elasticsearch/common/joda/Joda.java b/src/main/java/org/elasticsearch/common/joda/Joda.java index 891ac36d414..2ec46f5be37 100644 --- a/src/main/java/org/elasticsearch/common/joda/Joda.java +++ b/src/main/java/org/elasticsearch/common/joda/Joda.java @@ -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,15 +20,11 @@ package org.elasticsearch.common.joda; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.joda.time.DateTimeZone; -import org.elasticsearch.common.joda.time.format.DateTimeFormat; -import org.elasticsearch.common.joda.time.format.DateTimeFormatter; -import org.elasticsearch.common.joda.time.format.DateTimeFormatterBuilder; -import org.elasticsearch.common.joda.time.format.DateTimeParser; -import org.elasticsearch.common.joda.time.format.ISODateTimeFormat; +import org.joda.time.DateTimeZone; +import org.joda.time.format.*; /** - * @author kimchy (shay.banon) + * */ public class Joda { diff --git a/src/main/java/org/elasticsearch/common/lab/LongsLAB.java b/src/main/java/org/elasticsearch/common/lab/LongsLAB.java index 639350c862e..12cc49901c2 100644 --- a/src/main/java/org/elasticsearch/common/lab/LongsLAB.java +++ b/src/main/java/org/elasticsearch/common/lab/LongsLAB.java @@ -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 @@ -40,7 +40,7 @@ public class LongsLAB { /** * Allocate a slice of the given length. - * + *

    * If the size is larger than the maximum size specified for this * allocator, returns null. */ diff --git a/src/main/java/org/elasticsearch/common/lease/Releasable.java b/src/main/java/org/elasticsearch/common/lease/Releasable.java index 9b487c64bff..7e44f4d7182 100644 --- a/src/main/java/org/elasticsearch/common/lease/Releasable.java +++ b/src/main/java/org/elasticsearch/common/lease/Releasable.java @@ -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.common.lease; import org.elasticsearch.ElasticSearchException; /** - * @author kimchy (Shay Banon) + * */ public interface Releasable { diff --git a/src/main/java/org/elasticsearch/common/logging/ESLogger.java b/src/main/java/org/elasticsearch/common/logging/ESLogger.java index d270d31c292..76b309d431d 100644 --- a/src/main/java/org/elasticsearch/common/logging/ESLogger.java +++ b/src/main/java/org/elasticsearch/common/logging/ESLogger.java @@ -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.common.logging; /** - * @author kimchy (shay.banon) + * */ public interface ESLogger { diff --git a/src/main/java/org/elasticsearch/common/logging/ESLoggerFactory.java b/src/main/java/org/elasticsearch/common/logging/ESLoggerFactory.java index f647c2d61a1..869ef673827 100644 --- a/src/main/java/org/elasticsearch/common/logging/ESLoggerFactory.java +++ b/src/main/java/org/elasticsearch/common/logging/ESLoggerFactory.java @@ -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.common.logging.log4j.Log4jESLoggerFactory; import org.elasticsearch.common.logging.slf4j.Slf4jESLoggerFactory; /** - * @author kimchy (shay.banon) + * */ public abstract class ESLoggerFactory { diff --git a/src/main/java/org/elasticsearch/common/logging/Loggers.java b/src/main/java/org/elasticsearch/common/logging/Loggers.java index 6c8b61b9096..7d1899031d9 100644 --- a/src/main/java/org/elasticsearch/common/logging/Loggers.java +++ b/src/main/java/org/elasticsearch/common/logging/Loggers.java @@ -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.common.logging; +import com.google.common.collect.Lists; import org.elasticsearch.common.Classes; -import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.Index; import org.elasticsearch.index.shard.ShardId; @@ -30,13 +30,13 @@ import java.net.InetAddress; import java.net.UnknownHostException; import java.util.List; +import static com.google.common.collect.Lists.newArrayList; import static java.util.Arrays.asList; -import static org.elasticsearch.common.collect.Lists.*; /** * A set of utilities around Logging. * - * @author kimchy (shay.banon) + * */ public class Loggers { diff --git a/src/main/java/org/elasticsearch/common/logging/jdk/JdkESLogger.java b/src/main/java/org/elasticsearch/common/logging/jdk/JdkESLogger.java index 10f161f1bff..04b6c9c94bf 100644 --- a/src/main/java/org/elasticsearch/common/logging/jdk/JdkESLogger.java +++ b/src/main/java/org/elasticsearch/common/logging/jdk/JdkESLogger.java @@ -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.logging.Level; import java.util.logging.Logger; /** - * @author kimchy (shay.banon) + * */ public class JdkESLogger extends AbstractESLogger { @@ -39,7 +39,8 @@ public class JdkESLogger extends AbstractESLogger { this.name = name; } - @Override public void setLevel(String level) { + @Override + public void setLevel(String level) { if ("error".equalsIgnoreCase(level)) { logger.setLevel(Level.SEVERE); } else if ("warn".equalsIgnoreCase(level)) { @@ -53,67 +54,83 @@ public class JdkESLogger extends AbstractESLogger { } } - @Override public String getName() { + @Override + public String getName() { return logger.getName(); } - @Override public boolean isTraceEnabled() { + @Override + public boolean isTraceEnabled() { return logger.isLoggable(Level.FINEST); } - @Override public boolean isDebugEnabled() { + @Override + public boolean isDebugEnabled() { return logger.isLoggable(Level.FINE); } - @Override public boolean isInfoEnabled() { + @Override + public boolean isInfoEnabled() { return logger.isLoggable(Level.INFO); } - @Override public boolean isWarnEnabled() { + @Override + public boolean isWarnEnabled() { return logger.isLoggable(Level.WARNING); } - @Override public boolean isErrorEnabled() { + @Override + public boolean isErrorEnabled() { return logger.isLoggable(Level.SEVERE); } - @Override protected void internalTrace(String msg) { + @Override + protected void internalTrace(String msg) { logger.logp(Level.FINEST, name, null, msg); } - @Override protected void internalTrace(String msg, Throwable cause) { + @Override + protected void internalTrace(String msg, Throwable cause) { logger.logp(Level.FINEST, name, null, msg, cause); } - @Override protected void internalDebug(String msg) { + @Override + protected void internalDebug(String msg) { logger.logp(Level.FINE, name, null, msg); } - @Override protected void internalDebug(String msg, Throwable cause) { + @Override + protected void internalDebug(String msg, Throwable cause) { logger.logp(Level.FINE, name, null, msg, cause); } - @Override protected void internalInfo(String msg) { + @Override + protected void internalInfo(String msg) { logger.logp(Level.INFO, name, null, msg); } - @Override protected void internalInfo(String msg, Throwable cause) { + @Override + protected void internalInfo(String msg, Throwable cause) { logger.logp(Level.INFO, name, null, msg, cause); } - @Override protected void internalWarn(String msg) { + @Override + protected void internalWarn(String msg) { logger.logp(Level.WARNING, name, null, msg); } - @Override protected void internalWarn(String msg, Throwable cause) { + @Override + protected void internalWarn(String msg, Throwable cause) { logger.logp(Level.WARNING, name, null, msg, cause); } - @Override protected void internalError(String msg) { + @Override + protected void internalError(String msg) { logger.logp(Level.SEVERE, name, null, msg); } - @Override protected void internalError(String msg, Throwable cause) { + @Override + protected void internalError(String msg, Throwable cause) { logger.logp(Level.SEVERE, name, null, msg, cause); } } diff --git a/src/main/java/org/elasticsearch/common/logging/jdk/JdkESLoggerFactory.java b/src/main/java/org/elasticsearch/common/logging/jdk/JdkESLoggerFactory.java index b7adc1a9c45..e299121419d 100644 --- a/src/main/java/org/elasticsearch/common/logging/jdk/JdkESLoggerFactory.java +++ b/src/main/java/org/elasticsearch/common/logging/jdk/JdkESLoggerFactory.java @@ -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,11 +23,12 @@ import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.ESLoggerFactory; /** - * @author kimchy (shay.banon) + * */ public class JdkESLoggerFactory extends ESLoggerFactory { - @Override protected ESLogger newInstance(String prefix, String name) { + @Override + protected ESLogger newInstance(String prefix, String name) { final java.util.logging.Logger logger = java.util.logging.Logger.getLogger(name); return new JdkESLogger(prefix, name, logger); } diff --git a/src/main/java/org/elasticsearch/common/logging/log4j/ConsoleAppender.java b/src/main/java/org/elasticsearch/common/logging/log4j/ConsoleAppender.java index 02c82af43cb..feba3a3bd5f 100644 --- a/src/main/java/org/elasticsearch/common/logging/log4j/ConsoleAppender.java +++ b/src/main/java/org/elasticsearch/common/logging/log4j/ConsoleAppender.java @@ -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 diff --git a/src/main/java/org/elasticsearch/common/logging/log4j/JLinePatternLayout.java b/src/main/java/org/elasticsearch/common/logging/log4j/JLinePatternLayout.java index 14ef03f3c6f..606f36738d5 100644 --- a/src/main/java/org/elasticsearch/common/logging/log4j/JLinePatternLayout.java +++ b/src/main/java/org/elasticsearch/common/logging/log4j/JLinePatternLayout.java @@ -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,20 +29,16 @@ import org.elasticsearch.common.jline.ANSI; import java.lang.reflect.Field; -import static jline.ANSIBuffer.ANSICodes.*; -import static org.elasticsearch.common.jline.ANSI.Code.FG_BLUE; -import static org.elasticsearch.common.jline.ANSI.Code.FG_CYAN; -import static org.elasticsearch.common.jline.ANSI.Code.FG_GREEN; -import static org.elasticsearch.common.jline.ANSI.Code.FG_RED; -import static org.elasticsearch.common.jline.ANSI.Code.FG_YELLOW; -import static org.elasticsearch.common.jline.ANSI.Code.OFF; +import static jline.ANSIBuffer.ANSICodes.attrib; +import static org.elasticsearch.common.jline.ANSI.Code.*; /** - * @author kimchy (Shay Banon) + * */ public class JLinePatternLayout extends PatternLayout { - @Override protected PatternParser createPatternParser(String pattern) { + @Override + protected PatternParser createPatternParser(String pattern) { try { return new JLinePatternParser(pattern); } catch (Throwable t) { @@ -56,7 +52,8 @@ public class JLinePatternLayout extends PatternLayout { super(pattern); } - @Override protected void addConverter(PatternConverter pc) { + @Override + protected void addConverter(PatternConverter pc) { try { if (ANSI.isEnabled()) { if (pc.getClass().getName().endsWith("BasicPatternConverter")) { diff --git a/src/main/java/org/elasticsearch/common/logging/log4j/Log4jESLogger.java b/src/main/java/org/elasticsearch/common/logging/log4j/Log4jESLogger.java index 2f24436ae0d..349b897cf83 100644 --- a/src/main/java/org/elasticsearch/common/logging/log4j/Log4jESLogger.java +++ b/src/main/java/org/elasticsearch/common/logging/log4j/Log4jESLogger.java @@ -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.log4j.Logger; import org.elasticsearch.common.logging.support.AbstractESLogger; /** - * @author kimchy (shay.banon) + * */ public class Log4jESLogger extends AbstractESLogger { @@ -49,67 +49,83 @@ public class Log4jESLogger extends AbstractESLogger { } } - @Override public String getName() { + @Override + public String getName() { return logger.getName(); } - @Override public boolean isTraceEnabled() { + @Override + public boolean isTraceEnabled() { return logger.isTraceEnabled(); } - @Override public boolean isDebugEnabled() { + @Override + public boolean isDebugEnabled() { return logger.isDebugEnabled(); } - @Override public boolean isInfoEnabled() { + @Override + public boolean isInfoEnabled() { return logger.isInfoEnabled(); } - @Override public boolean isWarnEnabled() { + @Override + public boolean isWarnEnabled() { return logger.isEnabledFor(Level.WARN); } - @Override public boolean isErrorEnabled() { + @Override + public boolean isErrorEnabled() { return logger.isEnabledFor(Level.ERROR); } - @Override protected void internalTrace(String msg) { + @Override + protected void internalTrace(String msg) { logger.trace(msg); } - @Override protected void internalTrace(String msg, Throwable cause) { + @Override + protected void internalTrace(String msg, Throwable cause) { logger.trace(msg, cause); } - @Override protected void internalDebug(String msg) { + @Override + protected void internalDebug(String msg) { logger.debug(msg); } - @Override protected void internalDebug(String msg, Throwable cause) { + @Override + protected void internalDebug(String msg, Throwable cause) { logger.debug(msg, cause); } - @Override protected void internalInfo(String msg) { + @Override + protected void internalInfo(String msg) { logger.info(msg); } - @Override protected void internalInfo(String msg, Throwable cause) { + @Override + protected void internalInfo(String msg, Throwable cause) { logger.info(msg, cause); } - @Override protected void internalWarn(String msg) { + @Override + protected void internalWarn(String msg) { logger.warn(msg); } - @Override protected void internalWarn(String msg, Throwable cause) { + @Override + protected void internalWarn(String msg, Throwable cause) { logger.warn(msg, cause); } - @Override protected void internalError(String msg) { + @Override + protected void internalError(String msg) { logger.error(msg); } - @Override protected void internalError(String msg, Throwable cause) { + @Override + protected void internalError(String msg, Throwable cause) { logger.error(msg, cause); } } diff --git a/src/main/java/org/elasticsearch/common/logging/log4j/Log4jESLoggerFactory.java b/src/main/java/org/elasticsearch/common/logging/log4j/Log4jESLoggerFactory.java index b83fc7f0f61..d89821c7837 100644 --- a/src/main/java/org/elasticsearch/common/logging/log4j/Log4jESLoggerFactory.java +++ b/src/main/java/org/elasticsearch/common/logging/log4j/Log4jESLoggerFactory.java @@ -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,11 +23,12 @@ import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.ESLoggerFactory; /** - * @author kimchy (shay.banon) + * */ public class Log4jESLoggerFactory extends ESLoggerFactory { - @Override protected ESLogger newInstance(String prefix, String name) { + @Override + protected ESLogger newInstance(String prefix, String name) { final org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(name); return new Log4jESLogger(prefix, logger); } diff --git a/src/main/java/org/elasticsearch/common/logging/log4j/LogConfigurator.java b/src/main/java/org/elasticsearch/common/logging/log4j/LogConfigurator.java index e84be3dd01c..9d6eccb1156 100644 --- a/src/main/java/org/elasticsearch/common/logging/log4j/LogConfigurator.java +++ b/src/main/java/org/elasticsearch/common/logging/log4j/LogConfigurator.java @@ -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.common.logging.log4j; +import com.google.common.collect.ImmutableMap; import org.apache.log4j.PropertyConfigurator; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.collect.MapBuilder; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; @@ -30,10 +30,10 @@ import org.elasticsearch.env.FailedToResolveConfigException; import java.util.Map; import java.util.Properties; -import static org.elasticsearch.common.settings.ImmutableSettings.*; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; /** - * @author kimchy (Shay Banon) + * */ public class LogConfigurator { diff --git a/src/main/java/org/elasticsearch/common/logging/slf4j/Slf4jESLogger.java b/src/main/java/org/elasticsearch/common/logging/slf4j/Slf4jESLogger.java index 94f5eba84a7..21c046d41f9 100644 --- a/src/main/java/org/elasticsearch/common/logging/slf4j/Slf4jESLogger.java +++ b/src/main/java/org/elasticsearch/common/logging/slf4j/Slf4jESLogger.java @@ -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.support.AbstractESLogger; import org.slf4j.Logger; /** - * @author kimchy (shay.banon) + * */ public class Slf4jESLogger extends AbstractESLogger { @@ -34,71 +34,88 @@ public class Slf4jESLogger extends AbstractESLogger { this.logger = logger; } - @Override public void setLevel(String level) { + @Override + public void setLevel(String level) { // can't set it in slf4j... } - @Override public String getName() { + @Override + public String getName() { return logger.getName(); } - @Override public boolean isTraceEnabled() { + @Override + public boolean isTraceEnabled() { return logger.isTraceEnabled(); } - @Override public boolean isDebugEnabled() { + @Override + public boolean isDebugEnabled() { return logger.isDebugEnabled(); } - @Override public boolean isInfoEnabled() { + @Override + public boolean isInfoEnabled() { return logger.isInfoEnabled(); } - @Override public boolean isWarnEnabled() { + @Override + public boolean isWarnEnabled() { return logger.isWarnEnabled(); } - @Override public boolean isErrorEnabled() { + @Override + public boolean isErrorEnabled() { return logger.isErrorEnabled(); } - @Override protected void internalTrace(String msg) { + @Override + protected void internalTrace(String msg) { logger.trace(msg); } - @Override protected void internalTrace(String msg, Throwable cause) { + @Override + protected void internalTrace(String msg, Throwable cause) { logger.trace(msg, cause); } - @Override protected void internalDebug(String msg) { + @Override + protected void internalDebug(String msg) { logger.debug(msg); } - @Override protected void internalDebug(String msg, Throwable cause) { + @Override + protected void internalDebug(String msg, Throwable cause) { logger.debug(msg, cause); } - @Override protected void internalInfo(String msg) { + @Override + protected void internalInfo(String msg) { logger.info(msg); } - @Override protected void internalInfo(String msg, Throwable cause) { + @Override + protected void internalInfo(String msg, Throwable cause) { logger.info(msg, cause); } - @Override protected void internalWarn(String msg) { + @Override + protected void internalWarn(String msg) { logger.warn(msg); } - @Override protected void internalWarn(String msg, Throwable cause) { + @Override + protected void internalWarn(String msg, Throwable cause) { logger.warn(msg, cause); } - @Override protected void internalError(String msg) { + @Override + protected void internalError(String msg) { logger.error(msg); } - @Override protected void internalError(String msg, Throwable cause) { + @Override + protected void internalError(String msg, Throwable cause) { logger.error(msg, cause); } } diff --git a/src/main/java/org/elasticsearch/common/logging/slf4j/Slf4jESLoggerFactory.java b/src/main/java/org/elasticsearch/common/logging/slf4j/Slf4jESLoggerFactory.java index ca4c49c079a..4e4dad752be 100644 --- a/src/main/java/org/elasticsearch/common/logging/slf4j/Slf4jESLoggerFactory.java +++ b/src/main/java/org/elasticsearch/common/logging/slf4j/Slf4jESLoggerFactory.java @@ -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,11 +24,12 @@ import org.elasticsearch.common.logging.ESLoggerFactory; import org.slf4j.LoggerFactory; /** - * @author kimchy (shay.banon) + * */ public class Slf4jESLoggerFactory extends ESLoggerFactory { - @Override protected ESLogger newInstance(String prefix, String name) { + @Override + protected ESLogger newInstance(String prefix, String name) { return new Slf4jESLogger(prefix, LoggerFactory.getLogger(name)); } } diff --git a/src/main/java/org/elasticsearch/common/logging/support/AbstractESLogger.java b/src/main/java/org/elasticsearch/common/logging/support/AbstractESLogger.java index a4f5965d2bc..f220444b735 100644 --- a/src/main/java/org/elasticsearch/common/logging/support/AbstractESLogger.java +++ b/src/main/java/org/elasticsearch/common/logging/support/AbstractESLogger.java @@ -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.common.logging.support; import org.elasticsearch.common.logging.ESLogger; /** - * @author kimchy (shay.banon) + * */ public abstract class AbstractESLogger implements ESLogger { @@ -32,11 +32,13 @@ public abstract class AbstractESLogger implements ESLogger { this.prefix = prefix; } - @Override public String getPrefix() { + @Override + public String getPrefix() { return this.prefix; } - @Override public void trace(String msg, Object... params) { + @Override + public void trace(String msg, Object... params) { if (isTraceEnabled()) { internalTrace(LoggerMessageFormat.format(prefix, msg, params)); } @@ -44,7 +46,8 @@ public abstract class AbstractESLogger implements ESLogger { protected abstract void internalTrace(String msg); - @Override public void trace(String msg, Throwable cause, Object... params) { + @Override + public void trace(String msg, Throwable cause, Object... params) { if (isTraceEnabled()) { internalTrace(LoggerMessageFormat.format(prefix, msg, params), cause); } @@ -53,7 +56,8 @@ public abstract class AbstractESLogger implements ESLogger { protected abstract void internalTrace(String msg, Throwable cause); - @Override public void debug(String msg, Object... params) { + @Override + public void debug(String msg, Object... params) { if (isDebugEnabled()) { internalDebug(LoggerMessageFormat.format(prefix, msg, params)); } @@ -61,7 +65,8 @@ public abstract class AbstractESLogger implements ESLogger { protected abstract void internalDebug(String msg); - @Override public void debug(String msg, Throwable cause, Object... params) { + @Override + public void debug(String msg, Throwable cause, Object... params) { if (isDebugEnabled()) { internalDebug(LoggerMessageFormat.format(prefix, msg, params), cause); } @@ -70,7 +75,8 @@ public abstract class AbstractESLogger implements ESLogger { protected abstract void internalDebug(String msg, Throwable cause); - @Override public void info(String msg, Object... params) { + @Override + public void info(String msg, Object... params) { if (isInfoEnabled()) { internalInfo(LoggerMessageFormat.format(prefix, msg, params)); } @@ -78,7 +84,8 @@ public abstract class AbstractESLogger implements ESLogger { protected abstract void internalInfo(String msg); - @Override public void info(String msg, Throwable cause, Object... params) { + @Override + public void info(String msg, Throwable cause, Object... params) { if (isInfoEnabled()) { internalInfo(LoggerMessageFormat.format(prefix, msg, params), cause); } @@ -87,7 +94,8 @@ public abstract class AbstractESLogger implements ESLogger { protected abstract void internalInfo(String msg, Throwable cause); - @Override public void warn(String msg, Object... params) { + @Override + public void warn(String msg, Object... params) { if (isWarnEnabled()) { internalWarn(LoggerMessageFormat.format(prefix, msg, params)); } @@ -95,7 +103,8 @@ public abstract class AbstractESLogger implements ESLogger { protected abstract void internalWarn(String msg); - @Override public void warn(String msg, Throwable cause, Object... params) { + @Override + public void warn(String msg, Throwable cause, Object... params) { if (isWarnEnabled()) { internalWarn(LoggerMessageFormat.format(prefix, msg, params), cause); } @@ -104,7 +113,8 @@ public abstract class AbstractESLogger implements ESLogger { protected abstract void internalWarn(String msg, Throwable cause); - @Override public void error(String msg, Object... params) { + @Override + public void error(String msg, Object... params) { if (isErrorEnabled()) { internalError(LoggerMessageFormat.format(prefix, msg, params)); } @@ -112,7 +122,8 @@ public abstract class AbstractESLogger implements ESLogger { protected abstract void internalError(String msg); - @Override public void error(String msg, Throwable cause, Object... params) { + @Override + public void error(String msg, Throwable cause, Object... params) { if (isErrorEnabled()) { internalError(LoggerMessageFormat.format(prefix, msg, params), cause); } diff --git a/src/main/java/org/elasticsearch/common/logging/support/LoggerMessageFormat.java b/src/main/java/org/elasticsearch/common/logging/support/LoggerMessageFormat.java index d4e383dd6b8..3f1b8064638 100644 --- a/src/main/java/org/elasticsearch/common/logging/support/LoggerMessageFormat.java +++ b/src/main/java/org/elasticsearch/common/logging/support/LoggerMessageFormat.java @@ -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 java.util.HashMap; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class LoggerMessageFormat { diff --git a/src/main/java/org/elasticsearch/common/lucene/Directories.java b/src/main/java/org/elasticsearch/common/lucene/Directories.java index 93094cb1503..86ad435471a 100644 --- a/src/main/java/org/elasticsearch/common/lucene/Directories.java +++ b/src/main/java/org/elasticsearch/common/lucene/Directories.java @@ -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 java.io.IOException; /** * A set of utilities for Lucene {@link Directory}. * - * @author kimchy (shay.banon) + * */ public class Directories { diff --git a/src/main/java/org/elasticsearch/common/lucene/DocumentBuilder.java b/src/main/java/org/elasticsearch/common/lucene/DocumentBuilder.java index fee1f4dd859..a2902de6c8d 100644 --- a/src/main/java/org/elasticsearch/common/lucene/DocumentBuilder.java +++ b/src/main/java/org/elasticsearch/common/lucene/DocumentBuilder.java @@ -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.apache.lucene.document.Fieldable; import org.elasticsearch.common.lucene.uid.UidField; /** - * @author kimchy (Shay Banon) + * */ public class DocumentBuilder { diff --git a/src/main/java/org/elasticsearch/common/lucene/FieldBuilder.java b/src/main/java/org/elasticsearch/common/lucene/FieldBuilder.java index ceb70402c9c..cce9bbcd364 100644 --- a/src/main/java/org/elasticsearch/common/lucene/FieldBuilder.java +++ b/src/main/java/org/elasticsearch/common/lucene/FieldBuilder.java @@ -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.common.lucene; import org.apache.lucene.document.Field; /** - * @author kimchy (Shay Banon) + * */ public class FieldBuilder { diff --git a/src/main/java/org/elasticsearch/common/lucene/IndexCommitDelegate.java b/src/main/java/org/elasticsearch/common/lucene/IndexCommitDelegate.java index 002f7caae09..c0b5b2098d4 100644 --- a/src/main/java/org/elasticsearch/common/lucene/IndexCommitDelegate.java +++ b/src/main/java/org/elasticsearch/common/lucene/IndexCommitDelegate.java @@ -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.Map; * A simple delegate that delegates all {@link IndexCommit} calls to a delegated * {@link IndexCommit}. * - * @author kimchy (Shay Banon) + * */ public abstract class IndexCommitDelegate extends IndexCommit { @@ -46,51 +46,63 @@ public abstract class IndexCommitDelegate extends IndexCommit { this.delegate = delegate; } - @Override public String getSegmentsFileName() { + @Override + public String getSegmentsFileName() { return delegate.getSegmentsFileName(); } - @Override public Collection getFileNames() throws IOException { + @Override + public Collection getFileNames() throws IOException { return delegate.getFileNames(); } - @Override public Directory getDirectory() { + @Override + public Directory getDirectory() { return delegate.getDirectory(); } - @Override public void delete() { + @Override + public void delete() { delegate.delete(); } - @Override public boolean isDeleted() { + @Override + public boolean isDeleted() { return delegate.isDeleted(); } - @Override public int getSegmentCount() { + @Override + public int getSegmentCount() { return delegate.getSegmentCount(); } - @Override public boolean equals(Object other) { + @Override + public boolean equals(Object other) { return delegate.equals(other); } - @Override public int hashCode() { + @Override + public int hashCode() { return delegate.hashCode(); } - @Override public long getVersion() { + @Override + public long getVersion() { return delegate.getVersion(); } - @Override public long getGeneration() { + @Override + public long getGeneration() { return delegate.getGeneration(); } - @Override public long getTimestamp() throws IOException { + @Override + public long getTimestamp() throws IOException { return delegate.getTimestamp(); } - @Override public Map getUserData() throws IOException { + @Override + public Map getUserData() throws IOException { return delegate.getUserData(); } } diff --git a/src/main/java/org/elasticsearch/common/lucene/IndexWriters.java b/src/main/java/org/elasticsearch/common/lucene/IndexWriters.java index 37197bc7683..02f5b9b8325 100644 --- a/src/main/java/org/elasticsearch/common/lucene/IndexWriters.java +++ b/src/main/java/org/elasticsearch/common/lucene/IndexWriters.java @@ -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.logging.Loggers; import java.lang.reflect.Field; /** - * @author kimchy (shay.banon) + * */ public abstract class IndexWriters { diff --git a/src/main/java/org/elasticsearch/common/lucene/LoggerInfoStream.java b/src/main/java/org/elasticsearch/common/lucene/LoggerInfoStream.java index b131755e127..27217784e8e 100644 --- a/src/main/java/org/elasticsearch/common/lucene/LoggerInfoStream.java +++ b/src/main/java/org/elasticsearch/common/lucene/LoggerInfoStream.java @@ -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,7 +32,7 @@ import java.io.PrintStream; *

    Provides also factory methods that basically append to the logger name provide the * {@link #SUFFIX}. * - * @author kimchy (Shay Banon) + * */ public class LoggerInfoStream extends PrintStream { @@ -68,7 +68,8 @@ public class LoggerInfoStream extends PrintStream { /** * Override only the method Lucene actually uses. */ - @Override public void println(String x) { + @Override + public void println(String x) { logger.trace(x); } } diff --git a/src/main/java/org/elasticsearch/common/lucene/Lucene.java b/src/main/java/org/elasticsearch/common/lucene/Lucene.java index bee40a036b7..22321e3647a 100644 --- a/src/main/java/org/elasticsearch/common/lucene/Lucene.java +++ b/src/main/java/org/elasticsearch/common/lucene/Lucene.java @@ -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,12 +21,7 @@ package org.elasticsearch.common.lucene; import org.apache.lucene.analysis.KeywordAnalyzer; import org.apache.lucene.analysis.standard.StandardAnalyzer; -import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.IndexWriter; -import org.apache.lucene.index.SegmentInfo; -import org.apache.lucene.index.SegmentReader; -import org.apache.lucene.index.Term; -import org.apache.lucene.index.TermDocs; +import org.apache.lucene.index.*; import org.apache.lucene.search.*; import org.apache.lucene.util.Version; import org.elasticsearch.common.Nullable; @@ -45,7 +40,7 @@ import java.util.List; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class Lucene { @@ -437,20 +432,24 @@ public class Lucene { return this.count; } - @Override public void setScorer(Scorer scorer) throws IOException { + @Override + public void setScorer(Scorer scorer) throws IOException { this.scorer = scorer; } - @Override public void collect(int doc) throws IOException { + @Override + public void collect(int doc) throws IOException { if (scorer.score() > minScore) { count++; } } - @Override public void setNextReader(IndexReader reader, int docBase) throws IOException { + @Override + public void setNextReader(IndexReader reader, int docBase) throws IOException { } - @Override public boolean acceptsDocsOutOfOrder() { + @Override + public boolean acceptsDocsOutOfOrder() { return true; } } @@ -467,18 +466,22 @@ public class Lucene { return exists; } - @Override public void setScorer(Scorer scorer) throws IOException { + @Override + public void setScorer(Scorer scorer) throws IOException { this.exists = false; } - @Override public void collect(int doc) throws IOException { + @Override + public void collect(int doc) throws IOException { exists = true; } - @Override public void setNextReader(IndexReader reader, int docBase) throws IOException { + @Override + public void setNextReader(IndexReader reader, int docBase) throws IOException { } - @Override public boolean acceptsDocsOutOfOrder() { + @Override + public boolean acceptsDocsOutOfOrder() { return true; } } diff --git a/src/main/java/org/elasticsearch/common/lucene/MinimumScoreCollector.java b/src/main/java/org/elasticsearch/common/lucene/MinimumScoreCollector.java index 4adea9fa3d5..e97d4bd7f19 100644 --- a/src/main/java/org/elasticsearch/common/lucene/MinimumScoreCollector.java +++ b/src/main/java/org/elasticsearch/common/lucene/MinimumScoreCollector.java @@ -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 @@ -42,7 +42,8 @@ public class MinimumScoreCollector extends Collector { this.minimumScore = minimumScore; } - @Override public void setScorer(Scorer scorer) throws IOException { + @Override + public void setScorer(Scorer scorer) throws IOException { if (!(scorer instanceof ScoreCachingWrappingScorer)) { scorer = new ScoreCachingWrappingScorer(scorer); } @@ -50,17 +51,20 @@ public class MinimumScoreCollector extends Collector { collector.setScorer(scorer); } - @Override public void collect(int doc) throws IOException { + @Override + public void collect(int doc) throws IOException { if (scorer.score() > minimumScore) { collector.collect(doc); } } - @Override public void setNextReader(IndexReader reader, int docBase) throws IOException { + @Override + public void setNextReader(IndexReader reader, int docBase) throws IOException { collector.setNextReader(reader, docBase); } - @Override public boolean acceptsDocsOutOfOrder() { + @Override + public boolean acceptsDocsOutOfOrder() { return collector.acceptsDocsOutOfOrder(); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/common/lucene/MultiCollector.java b/src/main/java/org/elasticsearch/common/lucene/MultiCollector.java index 94b403a9ed4..ab44e50627e 100644 --- a/src/main/java/org/elasticsearch/common/lucene/MultiCollector.java +++ b/src/main/java/org/elasticsearch/common/lucene/MultiCollector.java @@ -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.apache.lucene.search.Scorer; import java.io.IOException; /** - * @author kimchy (Shay Banon) + * */ public class MultiCollector extends Collector { @@ -40,7 +40,8 @@ public class MultiCollector extends Collector { this.collectors = collectors; } - @Override public void setScorer(Scorer scorer) throws IOException { + @Override + public void setScorer(Scorer scorer) throws IOException { // always wrap it in a scorer wrapper if (!(scorer instanceof ScoreCachingWrappingScorer)) { scorer = new ScoreCachingWrappingScorer(scorer); @@ -51,21 +52,24 @@ public class MultiCollector extends Collector { } } - @Override public void collect(int doc) throws IOException { + @Override + public void collect(int doc) throws IOException { collector.collect(doc); for (Collector collector : collectors) { collector.collect(doc); } } - @Override public void setNextReader(IndexReader reader, int docBase) throws IOException { + @Override + public void setNextReader(IndexReader reader, int docBase) throws IOException { collector.setNextReader(reader, docBase); for (Collector collector : collectors) { collector.setNextReader(reader, docBase); } } - @Override public boolean acceptsDocsOutOfOrder() { + @Override + public boolean acceptsDocsOutOfOrder() { if (!collector.acceptsDocsOutOfOrder()) { return false; } diff --git a/src/main/java/org/elasticsearch/common/lucene/ReaderSearcherHolder.java b/src/main/java/org/elasticsearch/common/lucene/ReaderSearcherHolder.java index eee38a76efd..8d0756d856c 100644 --- a/src/main/java/org/elasticsearch/common/lucene/ReaderSearcherHolder.java +++ b/src/main/java/org/elasticsearch/common/lucene/ReaderSearcherHolder.java @@ -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.lease.Releasable; /** * A very simple holder for a tuple of reader and searcher. * - * @author kimchy (Shay Banon) + * */ public class ReaderSearcherHolder implements Releasable { @@ -49,7 +49,8 @@ public class ReaderSearcherHolder implements Releasable { return indexSearcher; } - @Override public boolean release() throws ElasticSearchException { + @Override + public boolean release() throws ElasticSearchException { try { indexSearcher.close(); } catch (Exception e) { diff --git a/src/main/java/org/elasticsearch/common/lucene/all/AllEntries.java b/src/main/java/org/elasticsearch/common/lucene/all/AllEntries.java index 377d2efd315..5b5066be983 100644 --- a/src/main/java/org/elasticsearch/common/lucene/all/AllEntries.java +++ b/src/main/java/org/elasticsearch/common/lucene/all/AllEntries.java @@ -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.common.lucene.all; +import com.google.common.collect.Lists; import org.elasticsearch.ElasticSearchIllegalStateException; -import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.io.FastCharArrayWriter; import org.elasticsearch.common.io.FastStringReader; @@ -30,10 +30,10 @@ import java.util.Iterator; import java.util.List; import java.util.Set; -import static org.elasticsearch.common.collect.Sets.*; +import static com.google.common.collect.Sets.newHashSet; /** - * @author kimchy (shay.banon) + * */ public class AllEntries extends Reader { @@ -129,7 +129,8 @@ public class AllEntries extends Reader { return this.current; } - @Override public int read(char[] cbuf, int off, int len) throws IOException { + @Override + public int read(char[] cbuf, int off, int len) throws IOException { if (current == null) { return -1; } @@ -178,7 +179,8 @@ public class AllEntries extends Reader { } } - @Override public void close() { + @Override + public void close() { if (current != null) { current.reader().close(); current = null; @@ -186,11 +188,13 @@ public class AllEntries extends Reader { } - @Override public boolean ready() throws IOException { + @Override + public boolean ready() throws IOException { return (current != null) && current.reader().ready(); } - @Override public String toString() { + @Override + public String toString() { StringBuilder sb = new StringBuilder(); for (Entry entry : entries) { sb.append(entry.name()).append(','); diff --git a/src/main/java/org/elasticsearch/common/lucene/all/AllField.java b/src/main/java/org/elasticsearch/common/lucene/all/AllField.java index bd2311b84d2..8e31243dcae 100644 --- a/src/main/java/org/elasticsearch/common/lucene/all/AllField.java +++ b/src/main/java/org/elasticsearch/common/lucene/all/AllField.java @@ -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.io.IOException; import java.io.Reader; /** - * @author kimchy (shay.banon) + * */ public class AllField extends AbstractField { @@ -44,18 +44,21 @@ public class AllField extends AbstractField { this.analyzer = analyzer; } - @Override public String stringValue() { + @Override + public String stringValue() { if (isStored()) { return allEntries.buildText(); } return null; } - @Override public Reader readerValue() { + @Override + public Reader readerValue() { return null; } - @Override public TokenStream tokenStreamValue() { + @Override + public TokenStream tokenStreamValue() { try { allEntries.reset(); // reset the all entries, just in case it was read already return AllTokenStream.allTokenStream(name, allEntries, analyzer); diff --git a/src/main/java/org/elasticsearch/common/lucene/all/AllTermQuery.java b/src/main/java/org/elasticsearch/common/lucene/all/AllTermQuery.java index 192b2799ee1..791b655d903 100644 --- a/src/main/java/org/elasticsearch/common/lucene/all/AllTermQuery.java +++ b/src/main/java/org/elasticsearch/common/lucene/all/AllTermQuery.java @@ -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,12 +30,12 @@ import org.apache.lucene.search.spans.TermSpans; import java.io.IOException; -import static org.apache.lucene.analysis.payloads.PayloadHelper.*; +import static org.apache.lucene.analysis.payloads.PayloadHelper.decodeFloat; /** * A term query that takes all payload boost values into account. * - * @author kimchy (shay.banon) + * */ public class AllTermQuery extends SpanTermQuery { diff --git a/src/main/java/org/elasticsearch/common/lucene/all/AllTokenStream.java b/src/main/java/org/elasticsearch/common/lucene/all/AllTokenStream.java index 04731bea4db..34bb8925c0d 100644 --- a/src/main/java/org/elasticsearch/common/lucene/all/AllTokenStream.java +++ b/src/main/java/org/elasticsearch/common/lucene/all/AllTokenStream.java @@ -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,10 +27,10 @@ import org.apache.lucene.index.Payload; import java.io.IOException; -import static org.apache.lucene.analysis.payloads.PayloadHelper.*; +import static org.apache.lucene.analysis.payloads.PayloadHelper.encodeFloat; /** - * @author kimchy (shay.banon) + * */ public final class AllTokenStream extends TokenFilter { @@ -52,7 +52,8 @@ public final class AllTokenStream extends TokenFilter { return allEntries; } - @Override public final boolean incrementToken() throws IOException { + @Override + public final boolean incrementToken() throws IOException { if (!input.incrementToken()) { return false; } @@ -67,7 +68,8 @@ public final class AllTokenStream extends TokenFilter { return true; } - @Override public String toString() { + @Override + public String toString() { return allEntries.toString(); } } diff --git a/src/main/java/org/elasticsearch/common/lucene/analysis/HTMLStripCharFilter.java b/src/main/java/org/elasticsearch/common/lucene/analysis/HTMLStripCharFilter.java index 95a0245faf5..d6ab8e359cb 100644 --- a/src/main/java/org/elasticsearch/common/lucene/analysis/HTMLStripCharFilter.java +++ b/src/main/java/org/elasticsearch/common/lucene/analysis/HTMLStripCharFilter.java @@ -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,7 +31,7 @@ import java.util.HashMap; import java.util.Set; /** - * @author kimchy (shay.banon) + * */ // LUCENE MONITOR: Once the next Lucene version is out, use the built in HTML filter public class HTMLStripCharFilter extends BaseCharFilter { @@ -287,19 +287,19 @@ public class HTMLStripCharFilter extends BaseCharFilter { * * * Hello --> - * + *

    * #comments inside of an entity decl: * - * + *

    * Turns out, IE & mozilla don't parse comments correctly. * Since this is meant to be a practical stripper, I'll just * try and duplicate what the browsers do. - * + *

    * * * - * - * + *

    + *

    * * */ @@ -571,10 +571,10 @@ public class HTMLStripCharFilter extends BaseCharFilter { /** * [10] AttValue ::= '"' ([^<&"] | Reference)* '"' * | "'" ([^<&'] | Reference)* "'" - * + *

    * need to also handle unquoted attributes, and attributes w/o values: * - * + *

    * * */ diff --git a/src/main/java/org/elasticsearch/common/lucene/docset/AllDocSet.java b/src/main/java/org/elasticsearch/common/lucene/docset/AllDocSet.java index b0b325b31ba..cf7956e3220 100644 --- a/src/main/java/org/elasticsearch/common/lucene/docset/AllDocSet.java +++ b/src/main/java/org/elasticsearch/common/lucene/docset/AllDocSet.java @@ -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 java.io.IOException; /** * An always positive * - * @author kimchy (shay.banon) + * */ public class AllDocSet extends DocSet { @@ -37,23 +37,28 @@ public class AllDocSet extends DocSet { this.maxDoc = maxDoc; } - @Override public boolean isCacheable() { + @Override + public boolean isCacheable() { return true; } - @Override public int length() { + @Override + public int length() { return maxDoc; } - @Override public boolean get(int doc) { + @Override + public boolean get(int doc) { return doc < maxDoc; } - @Override public long sizeInBytes() { + @Override + public long sizeInBytes() { return RamUsage.NUM_BYTES_INT; } - @Override public DocIdSetIterator iterator() throws IOException { + @Override + public DocIdSetIterator iterator() throws IOException { return new AllDocIdSetIterator(maxDoc); } @@ -67,18 +72,21 @@ public class AllDocSet extends DocSet { this.maxDoc = maxDoc; } - @Override public int docID() { + @Override + public int docID() { return doc; } - @Override public int nextDoc() throws IOException { + @Override + public int nextDoc() throws IOException { if (++doc < maxDoc) { return doc; } return doc = NO_MORE_DOCS; } - @Override public int advance(int target) throws IOException { + @Override + public int advance(int target) throws IOException { doc = target; if (doc < maxDoc) { return doc; diff --git a/src/main/java/org/elasticsearch/common/lucene/docset/AndDocIdSet.java b/src/main/java/org/elasticsearch/common/lucene/docset/AndDocIdSet.java index 145a17760ed..251ee67860c 100644 --- a/src/main/java/org/elasticsearch/common/lucene/docset/AndDocIdSet.java +++ b/src/main/java/org/elasticsearch/common/lucene/docset/AndDocIdSet.java @@ -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.IOException; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class AndDocIdSet extends DocIdSet { @@ -36,7 +36,8 @@ public class AndDocIdSet extends DocIdSet { this.sets = sets; } - @Override public boolean isCacheable() { + @Override + public boolean isCacheable() { // not cacheable, the reason is that by default, when constructing the filter, it is not cacheable, // so if someone wants it to be cacheable, we might as well construct a cached version of the result return false; @@ -48,7 +49,8 @@ public class AndDocIdSet extends DocIdSet { // return true; } - @Override public DocIdSetIterator iterator() throws IOException { + @Override + public DocIdSetIterator iterator() throws IOException { return new AndDocIdSetIterator(); } diff --git a/src/main/java/org/elasticsearch/common/lucene/docset/AndDocSet.java b/src/main/java/org/elasticsearch/common/lucene/docset/AndDocSet.java index c252e5457f0..1935d52e55c 100644 --- a/src/main/java/org/elasticsearch/common/lucene/docset/AndDocSet.java +++ b/src/main/java/org/elasticsearch/common/lucene/docset/AndDocSet.java @@ -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.IOException; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class AndDocSet extends DocSet { @@ -36,21 +36,24 @@ public class AndDocSet extends DocSet { this.sets = sets; } - @Override public boolean get(int doc) { + @Override + public boolean get(int doc) { for (DocSet s : sets) { if (!s.get(doc)) return false; } return true; } - @Override public int length() { + @Override + public int length() { if (sets.isEmpty()) { return 0; } return sets.get(0).length(); } - @Override public boolean isCacheable() { + @Override + public boolean isCacheable() { // not cacheable, the reason is that by default, when constructing the filter, it is not cacheable, // so if someone wants it to be cacheable, we might as well construct a cached version of the result return false; @@ -62,7 +65,8 @@ public class AndDocSet extends DocSet { // return true; } - @Override public long sizeInBytes() { + @Override + public long sizeInBytes() { long sizeInBytes = 0; for (DocSet set : sets) { sizeInBytes += set.sizeInBytes(); @@ -70,7 +74,8 @@ public class AndDocSet extends DocSet { return sizeInBytes; } - @Override public DocIdSetIterator iterator() throws IOException { + @Override + public DocIdSetIterator iterator() throws IOException { return new AndDocIdSetIterator(); } diff --git a/src/main/java/org/elasticsearch/common/lucene/docset/DocIdSetCollector.java b/src/main/java/org/elasticsearch/common/lucene/docset/DocIdSetCollector.java index 89d4df0ebe2..dbe5c77490b 100644 --- a/src/main/java/org/elasticsearch/common/lucene/docset/DocIdSetCollector.java +++ b/src/main/java/org/elasticsearch/common/lucene/docset/DocIdSetCollector.java @@ -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.apache.lucene.util.OpenBitSetDISI; import java.io.IOException; /** - * @author kimchy (Shay Banon) + * */ public class DocIdSetCollector extends Collector { @@ -46,21 +46,25 @@ public class DocIdSetCollector extends Collector { return docIdSet; } - @Override public void setScorer(Scorer scorer) throws IOException { + @Override + public void setScorer(Scorer scorer) throws IOException { collector.setScorer(scorer); } - @Override public void collect(int doc) throws IOException { + @Override + public void collect(int doc) throws IOException { collector.collect(doc); docIdSet.fastSet(base + doc); } - @Override public void setNextReader(IndexReader reader, int docBase) throws IOException { + @Override + public void setNextReader(IndexReader reader, int docBase) throws IOException { base = docBase; collector.setNextReader(reader, docBase); } - @Override public boolean acceptsDocsOutOfOrder() { + @Override + public boolean acceptsDocsOutOfOrder() { return collector.acceptsDocsOutOfOrder(); } } diff --git a/src/main/java/org/elasticsearch/common/lucene/docset/DocSet.java b/src/main/java/org/elasticsearch/common/lucene/docset/DocSet.java index 066bbb7ebed..892e222d349 100644 --- a/src/main/java/org/elasticsearch/common/lucene/docset/DocSet.java +++ b/src/main/java/org/elasticsearch/common/lucene/docset/DocSet.java @@ -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,28 +26,33 @@ import org.apache.lucene.util.Bits; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public abstract class DocSet extends DocIdSet implements Bits { public static final DocSet EMPTY_DOC_SET = new DocSet() { - @Override public boolean get(int doc) { + @Override + public boolean get(int doc) { return false; } - @Override public DocIdSetIterator iterator() throws IOException { + @Override + public DocIdSetIterator iterator() throws IOException { return DocIdSet.EMPTY_DOCIDSET.iterator(); } - @Override public boolean isCacheable() { + @Override + public boolean isCacheable() { return true; } - @Override public long sizeInBytes() { + @Override + public long sizeInBytes() { return 0; } - @Override public int length() { + @Override + public int length() { return 0; } }; diff --git a/src/main/java/org/elasticsearch/common/lucene/docset/DocSets.java b/src/main/java/org/elasticsearch/common/lucene/docset/DocSets.java index 2b142202b9c..3bb3edb94e3 100644 --- a/src/main/java/org/elasticsearch/common/lucene/docset/DocSets.java +++ b/src/main/java/org/elasticsearch/common/lucene/docset/DocSets.java @@ -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 diff --git a/src/main/java/org/elasticsearch/common/lucene/docset/FixedBitDocSet.java b/src/main/java/org/elasticsearch/common/lucene/docset/FixedBitDocSet.java index 1e05b28756d..4d36c97eff7 100644 --- a/src/main/java/org/elasticsearch/common/lucene/docset/FixedBitDocSet.java +++ b/src/main/java/org/elasticsearch/common/lucene/docset/FixedBitDocSet.java @@ -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.RamUsage; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class FixedBitDocSet extends DocSet { @@ -40,11 +40,13 @@ public class FixedBitDocSet extends DocSet { this.set = new FixedBitSet(numBits); } - @Override public boolean isCacheable() { + @Override + public boolean isCacheable() { return true; } - @Override public int length() { + @Override + public int length() { return set.length(); } @@ -52,15 +54,18 @@ public class FixedBitDocSet extends DocSet { return set; } - @Override public boolean get(int doc) { + @Override + public boolean get(int doc) { return set.get(doc); } - @Override public DocIdSetIterator iterator() throws IOException { + @Override + public DocIdSetIterator iterator() throws IOException { return set.iterator(); } - @Override public long sizeInBytes() { + @Override + public long sizeInBytes() { return set.getBits().length * RamUsage.NUM_BYTES_LONG + RamUsage.NUM_BYTES_ARRAY_HEADER + RamUsage.NUM_BYTES_INT /* wlen */; } } diff --git a/src/main/java/org/elasticsearch/common/lucene/docset/GetDocSet.java b/src/main/java/org/elasticsearch/common/lucene/docset/GetDocSet.java index d76e6a6a55c..4bfa5cda610 100644 --- a/src/main/java/org/elasticsearch/common/lucene/docset/GetDocSet.java +++ b/src/main/java/org/elasticsearch/common/lucene/docset/GetDocSet.java @@ -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.DocIdSetIterator; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public abstract class GetDocSet extends DocSet { @@ -34,23 +34,28 @@ public abstract class GetDocSet extends DocSet { this.maxDoc = maxDoc; } - @Override public long sizeInBytes() { + @Override + public long sizeInBytes() { return 0; } - @Override public int length() { + @Override + public int length() { return maxDoc; } - @Override public DocIdSetIterator iterator() throws IOException { + @Override + public DocIdSetIterator iterator() throws IOException { return new DocIdSetIterator() { private int doc = -1; - @Override public int docID() { + @Override + public int docID() { return doc; } - @Override public int nextDoc() throws IOException { + @Override + public int nextDoc() throws IOException { do { doc++; if (doc >= maxDoc) { @@ -60,7 +65,8 @@ public abstract class GetDocSet extends DocSet { return doc; } - @Override public int advance(int target) throws IOException { + @Override + public int advance(int target) throws IOException { if (target >= maxDoc) { return doc = NO_MORE_DOCS; } diff --git a/src/main/java/org/elasticsearch/common/lucene/docset/NotDocIdSet.java b/src/main/java/org/elasticsearch/common/lucene/docset/NotDocIdSet.java index d3ae76a4732..f298c76039e 100644 --- a/src/main/java/org/elasticsearch/common/lucene/docset/NotDocIdSet.java +++ b/src/main/java/org/elasticsearch/common/lucene/docset/NotDocIdSet.java @@ -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.apache.lucene.search.DocIdSetIterator; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class NotDocIdSet extends DocIdSet { @@ -38,14 +38,16 @@ public class NotDocIdSet extends DocIdSet { this.set = set; } - @Override public boolean isCacheable() { + @Override + public boolean isCacheable() { // not cacheable, the reason is that by default, when constructing the filter, it is not cacheable, // so if someone wants it to be cacheable, we might as well construct a cached version of the result return false; // return set.isCacheable(); } - @Override public DocIdSetIterator iterator() throws IOException { + @Override + public DocIdSetIterator iterator() throws IOException { DocIdSetIterator it = set.iterator(); if (it == null) { return new AllDocSet.AllDocIdSetIterator(max); diff --git a/src/main/java/org/elasticsearch/common/lucene/docset/NotDocSet.java b/src/main/java/org/elasticsearch/common/lucene/docset/NotDocSet.java index 87b556cbb7e..f16e49c5730 100644 --- a/src/main/java/org/elasticsearch/common/lucene/docset/NotDocSet.java +++ b/src/main/java/org/elasticsearch/common/lucene/docset/NotDocSet.java @@ -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.common.lucene.docset; /** - * @author kimchy (shay.banon) + * */ public class NotDocSet extends GetDocSet { @@ -31,18 +31,21 @@ public class NotDocSet extends GetDocSet { this.set = set; } - @Override public boolean isCacheable() { + @Override + public boolean isCacheable() { // not cacheable, the reason is that by default, when constructing the filter, it is not cacheable, // so if someone wants it to be cacheable, we might as well construct a cached version of the result return false; // return set.isCacheable(); } - @Override public boolean get(int doc) { + @Override + public boolean get(int doc) { return !set.get(doc); } - @Override public long sizeInBytes() { + @Override + public long sizeInBytes() { return set.sizeInBytes(); } diff --git a/src/main/java/org/elasticsearch/common/lucene/docset/OpenBitDocSet.java b/src/main/java/org/elasticsearch/common/lucene/docset/OpenBitDocSet.java index 08a883cb7ca..50cd8532f38 100644 --- a/src/main/java/org/elasticsearch/common/lucene/docset/OpenBitDocSet.java +++ b/src/main/java/org/elasticsearch/common/lucene/docset/OpenBitDocSet.java @@ -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.RamUsage; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class OpenBitDocSet extends DocSet { @@ -45,11 +45,13 @@ public class OpenBitDocSet extends DocSet { this.set = new OpenBitSetDISI(disi, numBits); } - @Override public int length() { + @Override + public int length() { return set.length(); } - @Override public boolean isCacheable() { + @Override + public boolean isCacheable() { return true; } @@ -57,15 +59,18 @@ public class OpenBitDocSet extends DocSet { return set; } - @Override public boolean get(int doc) { + @Override + public boolean get(int doc) { return set.fastGet(doc); } - @Override public DocIdSetIterator iterator() throws IOException { + @Override + public DocIdSetIterator iterator() throws IOException { return set.iterator(); } - @Override public long sizeInBytes() { + @Override + public long sizeInBytes() { return set.getBits().length * RamUsage.NUM_BYTES_LONG + RamUsage.NUM_BYTES_ARRAY_HEADER + RamUsage.NUM_BYTES_INT /* wlen */; } } diff --git a/src/main/java/org/elasticsearch/common/lucene/docset/OrDocIdSet.java b/src/main/java/org/elasticsearch/common/lucene/docset/OrDocIdSet.java index 9f3580e9cfc..e817c69fa22 100644 --- a/src/main/java/org/elasticsearch/common/lucene/docset/OrDocIdSet.java +++ b/src/main/java/org/elasticsearch/common/lucene/docset/OrDocIdSet.java @@ -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.IOException; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class OrDocIdSet extends DocIdSet { @@ -36,7 +36,8 @@ public class OrDocIdSet extends DocIdSet { this.sets = sets; } - @Override public boolean isCacheable() { + @Override + public boolean isCacheable() { // not cacheable, the reason is that by default, when constructing the filter, it is not cacheable, // so if someone wants it to be cacheable, we might as well construct a cached version of the result return false; @@ -48,7 +49,8 @@ public class OrDocIdSet extends DocIdSet { // return true; } - @Override public DocIdSetIterator iterator() throws IOException { + @Override + public DocIdSetIterator iterator() throws IOException { return new OrDocIdSetIterator(); } diff --git a/src/main/java/org/elasticsearch/common/lucene/docset/OrDocSet.java b/src/main/java/org/elasticsearch/common/lucene/docset/OrDocSet.java index e17abe30ec8..2bbcce9a969 100644 --- a/src/main/java/org/elasticsearch/common/lucene/docset/OrDocSet.java +++ b/src/main/java/org/elasticsearch/common/lucene/docset/OrDocSet.java @@ -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.IOException; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class OrDocSet extends DocSet { @@ -36,21 +36,24 @@ public class OrDocSet extends DocSet { this.sets = sets; } - @Override public boolean get(int doc) { + @Override + public boolean get(int doc) { for (DocSet s : sets) { if (s.get(doc)) return true; } return false; } - @Override public int length() { + @Override + public int length() { if (sets.isEmpty()) { return 0; } return sets.get(0).length(); } - @Override public boolean isCacheable() { + @Override + public boolean isCacheable() { // not cacheable, the reason is that by default, when constructing the filter, it is not cacheable, // so if someone wants it to be cacheable, we might as well construct a cached version of the result return false; @@ -62,7 +65,8 @@ public class OrDocSet extends DocSet { // return true; } - @Override public long sizeInBytes() { + @Override + public long sizeInBytes() { long sizeInBytes = 0; for (DocSet set : sets) { sizeInBytes += set.sizeInBytes(); @@ -70,7 +74,8 @@ public class OrDocSet extends DocSet { return sizeInBytes; } - @Override public DocIdSetIterator iterator() throws IOException { + @Override + public DocIdSetIterator iterator() throws IOException { return new OrDocIdSetIterator(); } diff --git a/src/main/java/org/elasticsearch/common/lucene/document/ResetFieldSelector.java b/src/main/java/org/elasticsearch/common/lucene/document/ResetFieldSelector.java index 128fe2c21b2..f447107ce8d 100644 --- a/src/main/java/org/elasticsearch/common/lucene/document/ResetFieldSelector.java +++ b/src/main/java/org/elasticsearch/common/lucene/document/ResetFieldSelector.java @@ -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 diff --git a/src/main/java/org/elasticsearch/common/lucene/document/SingleFieldSelector.java b/src/main/java/org/elasticsearch/common/lucene/document/SingleFieldSelector.java index 7bdc930d1b3..cbc9d7a2313 100644 --- a/src/main/java/org/elasticsearch/common/lucene/document/SingleFieldSelector.java +++ b/src/main/java/org/elasticsearch/common/lucene/document/SingleFieldSelector.java @@ -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.common.lucene.document; import org.apache.lucene.document.FieldSelectorResult; /** - * @author kimchy (shay.banon) + * */ public class SingleFieldSelector implements ResetFieldSelector { @@ -39,13 +39,15 @@ public class SingleFieldSelector implements ResetFieldSelector { this.name = name; } - @Override public FieldSelectorResult accept(String fieldName) { + @Override + public FieldSelectorResult accept(String fieldName) { if (name.equals(fieldName)) { return FieldSelectorResult.LOAD; } return FieldSelectorResult.NO_LOAD; } - @Override public void reset() { + @Override + public void reset() { } } diff --git a/src/main/java/org/elasticsearch/common/lucene/search/AndFilter.java b/src/main/java/org/elasticsearch/common/lucene/search/AndFilter.java index 29d902b79d2..ae11d1bbee8 100644 --- a/src/main/java/org/elasticsearch/common/lucene/search/AndFilter.java +++ b/src/main/java/org/elasticsearch/common/lucene/search/AndFilter.java @@ -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.common.lucene.search; +import com.google.common.collect.Lists; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.DocIdSet; import org.apache.lucene.search.Filter; -import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.lucene.docset.AndDocIdSet; import org.elasticsearch.common.lucene.docset.AndDocSet; import org.elasticsearch.common.lucene.docset.DocSet; @@ -31,7 +31,7 @@ import java.io.IOException; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class AndFilter extends Filter { @@ -45,7 +45,8 @@ public class AndFilter extends Filter { return filters; } - @Override public DocIdSet getDocIdSet(IndexReader reader) throws IOException { + @Override + public DocIdSet getDocIdSet(IndexReader reader) throws IOException { if (filters.size() == 1) { return filters.get(0).getDocIdSet(reader); } @@ -67,13 +68,15 @@ public class AndFilter extends Filter { return new AndDocIdSet(sets); } - @Override public int hashCode() { + @Override + public int hashCode() { int hash = 7; hash = 31 * hash + (null == filters ? 0 : filters.hashCode()); return hash; } - @Override public boolean equals(Object obj) { + @Override + public boolean equals(Object obj) { if (this == obj) return true; diff --git a/src/main/java/org/elasticsearch/common/lucene/search/EmptyScorer.java b/src/main/java/org/elasticsearch/common/lucene/search/EmptyScorer.java index 9f354368bba..8834c49ce17 100644 --- a/src/main/java/org/elasticsearch/common/lucene/search/EmptyScorer.java +++ b/src/main/java/org/elasticsearch/common/lucene/search/EmptyScorer.java @@ -25,7 +25,7 @@ import org.apache.lucene.search.Similarity; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class EmptyScorer extends Scorer { @@ -33,19 +33,23 @@ public class EmptyScorer extends Scorer { super(similarity); } - @Override public float score() throws IOException { + @Override + public float score() throws IOException { return 0; } - @Override public int docID() { + @Override + public int docID() { return NO_MORE_DOCS; } - @Override public int nextDoc() throws IOException { + @Override + public int nextDoc() throws IOException { return NO_MORE_DOCS; } - @Override public int advance(int target) throws IOException { + @Override + public int advance(int target) throws IOException { return NO_MORE_DOCS; } } diff --git a/src/main/java/org/elasticsearch/common/lucene/search/FilteredCollector.java b/src/main/java/org/elasticsearch/common/lucene/search/FilteredCollector.java index 2981a937151..37a7fdf8563 100644 --- a/src/main/java/org/elasticsearch/common/lucene/search/FilteredCollector.java +++ b/src/main/java/org/elasticsearch/common/lucene/search/FilteredCollector.java @@ -29,7 +29,7 @@ import org.elasticsearch.common.lucene.docset.DocSets; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class FilteredCollector extends Collector { @@ -44,22 +44,26 @@ public class FilteredCollector extends Collector { this.filter = filter; } - @Override public void setScorer(Scorer scorer) throws IOException { + @Override + public void setScorer(Scorer scorer) throws IOException { collector.setScorer(scorer); } - @Override public void collect(int doc) throws IOException { + @Override + public void collect(int doc) throws IOException { if (docSet.get(doc)) { collector.collect(doc); } } - @Override public void setNextReader(IndexReader reader, int docBase) throws IOException { + @Override + public void setNextReader(IndexReader reader, int docBase) throws IOException { collector.setNextReader(reader, docBase); docSet = DocSets.convert(reader, filter.getDocIdSet(reader)); } - @Override public boolean acceptsDocsOutOfOrder() { + @Override + public boolean acceptsDocsOutOfOrder() { return collector.acceptsDocsOutOfOrder(); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/common/lucene/search/LimitFilter.java b/src/main/java/org/elasticsearch/common/lucene/search/LimitFilter.java index 1b002f713c4..ece97578047 100644 --- a/src/main/java/org/elasticsearch/common/lucene/search/LimitFilter.java +++ b/src/main/java/org/elasticsearch/common/lucene/search/LimitFilter.java @@ -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,7 +38,8 @@ public class LimitFilter extends NoCacheFilter { return limit; } - @Override public DocIdSet getDocIdSet(IndexReader reader) throws IOException { + @Override + public DocIdSet getDocIdSet(IndexReader reader) throws IOException { if (counter > limit) { return null; } @@ -54,7 +55,8 @@ public class LimitFilter extends NoCacheFilter { this.limit = limit; } - @Override public boolean get(int doc) { + @Override + public boolean get(int doc) { if (++counter > limit) { return false; } diff --git a/src/main/java/org/elasticsearch/common/lucene/search/MatchAllDocsFilter.java b/src/main/java/org/elasticsearch/common/lucene/search/MatchAllDocsFilter.java index 7ab401c78b2..fd382a83380 100644 --- a/src/main/java/org/elasticsearch/common/lucene/search/MatchAllDocsFilter.java +++ b/src/main/java/org/elasticsearch/common/lucene/search/MatchAllDocsFilter.java @@ -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,19 +29,22 @@ import java.io.IOException; /** * A filter that matches on all docs. * - * @author kimchy (shay.banon) + * */ public class MatchAllDocsFilter extends Filter { - @Override public DocIdSet getDocIdSet(IndexReader reader) throws IOException { + @Override + public DocIdSet getDocIdSet(IndexReader reader) throws IOException { return new AllDocSet(reader.maxDoc()); } - @Override public int hashCode() { + @Override + public int hashCode() { return this.getClass().hashCode(); } - @Override public boolean equals(Object obj) { + @Override + public boolean equals(Object obj) { if (this == obj) return true; @@ -56,7 +59,8 @@ public class MatchAllDocsFilter extends Filter { return false; } - @Override public String toString() { + @Override + public String toString() { return "*:*"; } } diff --git a/src/main/java/org/elasticsearch/common/lucene/search/MatchNoDocsQuery.java b/src/main/java/org/elasticsearch/common/lucene/search/MatchNoDocsQuery.java index e29d5ee01c2..f2b8d6c66b6 100644 --- a/src/main/java/org/elasticsearch/common/lucene/search/MatchNoDocsQuery.java +++ b/src/main/java/org/elasticsearch/common/lucene/search/MatchNoDocsQuery.java @@ -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 diff --git a/src/main/java/org/elasticsearch/common/lucene/search/MoreLikeThisQuery.java b/src/main/java/org/elasticsearch/common/lucene/search/MoreLikeThisQuery.java index 9150722d3b7..8356f62af58 100644 --- a/src/main/java/org/elasticsearch/common/lucene/search/MoreLikeThisQuery.java +++ b/src/main/java/org/elasticsearch/common/lucene/search/MoreLikeThisQuery.java @@ -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.io.IOException; import java.util.Set; /** - * @author kimchy (shay.banon) + * */ public class MoreLikeThisQuery extends Query { @@ -62,7 +62,8 @@ public class MoreLikeThisQuery extends Query { this.analyzer = analyzer; } - @Override public Query rewrite(IndexReader reader) throws IOException { + @Override + public Query rewrite(IndexReader reader) throws IOException { MoreLikeThis mlt = new MoreLikeThis(reader, similarity == null ? new DefaultSimilarity() : similarity); mlt.setFieldNames(moreLikeFields); @@ -83,7 +84,8 @@ public class MoreLikeThisQuery extends Query { return bq; } - @Override public String toString(String field) { + @Override + public String toString(String field) { return "like:" + likeText; } diff --git a/src/main/java/org/elasticsearch/common/lucene/search/MultiPhrasePrefixQuery.java b/src/main/java/org/elasticsearch/common/lucene/search/MultiPhrasePrefixQuery.java index fed5b8e6b21..315b47afdc4 100644 --- a/src/main/java/org/elasticsearch/common/lucene/search/MultiPhrasePrefixQuery.java +++ b/src/main/java/org/elasticsearch/common/lucene/search/MultiPhrasePrefixQuery.java @@ -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 @@ -124,7 +124,8 @@ public class MultiPhrasePrefixQuery extends Query { return result; } - @Override public Query rewrite(IndexReader reader) throws IOException { + @Override + public Query rewrite(IndexReader reader) throws IOException { if (termArrays.isEmpty()) { return MatchNoDocsQuery.INSTANCE; } diff --git a/src/main/java/org/elasticsearch/common/lucene/search/NoCacheFilter.java b/src/main/java/org/elasticsearch/common/lucene/search/NoCacheFilter.java index aa87b1f17ee..ab638df2577 100644 --- a/src/main/java/org/elasticsearch/common/lucene/search/NoCacheFilter.java +++ b/src/main/java/org/elasticsearch/common/lucene/search/NoCacheFilter.java @@ -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 diff --git a/src/main/java/org/elasticsearch/common/lucene/search/NoopCollector.java b/src/main/java/org/elasticsearch/common/lucene/search/NoopCollector.java index f6924812d8c..15a4f5efcb1 100644 --- a/src/main/java/org/elasticsearch/common/lucene/search/NoopCollector.java +++ b/src/main/java/org/elasticsearch/common/lucene/search/NoopCollector.java @@ -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,22 +26,26 @@ import org.apache.lucene.search.Scorer; import java.io.IOException; /** - * @author kimchy (Shay Banon) + * */ public class NoopCollector extends Collector { public static final NoopCollector NOOP_COLLECTOR = new NoopCollector(); - @Override public void setScorer(Scorer scorer) throws IOException { + @Override + public void setScorer(Scorer scorer) throws IOException { } - @Override public void collect(int doc) throws IOException { + @Override + public void collect(int doc) throws IOException { } - @Override public void setNextReader(IndexReader reader, int docBase) throws IOException { + @Override + public void setNextReader(IndexReader reader, int docBase) throws IOException { } - @Override public boolean acceptsDocsOutOfOrder() { + @Override + public boolean acceptsDocsOutOfOrder() { return true; } } diff --git a/src/main/java/org/elasticsearch/common/lucene/search/NotFilter.java b/src/main/java/org/elasticsearch/common/lucene/search/NotFilter.java index 3e5ade23c86..c1e6b39a510 100644 --- a/src/main/java/org/elasticsearch/common/lucene/search/NotFilter.java +++ b/src/main/java/org/elasticsearch/common/lucene/search/NotFilter.java @@ -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 org.elasticsearch.common.lucene.docset.NotDocSet; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class NotFilter extends Filter { @@ -44,7 +44,8 @@ public class NotFilter extends Filter { return filter; } - @Override public DocIdSet getDocIdSet(IndexReader reader) throws IOException { + @Override + public DocIdSet getDocIdSet(IndexReader reader) throws IOException { DocIdSet set = filter.getDocIdSet(reader); if (set == null) { return new AllDocSet(reader.maxDoc()); diff --git a/src/main/java/org/elasticsearch/common/lucene/search/OrFilter.java b/src/main/java/org/elasticsearch/common/lucene/search/OrFilter.java index 286d992cb43..6933b37bcec 100644 --- a/src/main/java/org/elasticsearch/common/lucene/search/OrFilter.java +++ b/src/main/java/org/elasticsearch/common/lucene/search/OrFilter.java @@ -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.common.lucene.search; +import com.google.common.collect.Lists; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.DocIdSet; import org.apache.lucene.search.Filter; -import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.lucene.docset.DocSet; import org.elasticsearch.common.lucene.docset.OrDocIdSet; import org.elasticsearch.common.lucene.docset.OrDocSet; @@ -31,7 +31,7 @@ import java.io.IOException; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class OrFilter extends Filter { @@ -45,7 +45,8 @@ public class OrFilter extends Filter { return filters; } - @Override public DocIdSet getDocIdSet(IndexReader reader) throws IOException { + @Override + public DocIdSet getDocIdSet(IndexReader reader) throws IOException { if (filters.size() == 1) { return filters.get(0).getDocIdSet(reader); } @@ -73,13 +74,15 @@ public class OrFilter extends Filter { return new OrDocIdSet(sets); } - @Override public int hashCode() { + @Override + public int hashCode() { int hash = 7; hash = 31 * hash + (null == filters ? 0 : filters.hashCode()); return hash; } - @Override public boolean equals(Object obj) { + @Override + public boolean equals(Object obj) { if (this == obj) return true; diff --git a/src/main/java/org/elasticsearch/common/lucene/search/Queries.java b/src/main/java/org/elasticsearch/common/lucene/search/Queries.java index b5166892c59..2272cab8cde 100644 --- a/src/main/java/org/elasticsearch/common/lucene/search/Queries.java +++ b/src/main/java/org/elasticsearch/common/lucene/search/Queries.java @@ -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,7 @@ package org.elasticsearch.common.lucene.search; -import org.apache.lucene.search.BooleanClause; -import org.apache.lucene.search.BooleanQuery; -import org.apache.lucene.search.DeletionAwareConstantScoreQuery; -import org.apache.lucene.search.DisjunctionMaxQuery; -import org.apache.lucene.search.Filter; -import org.apache.lucene.search.MatchAllDocsQuery; -import org.apache.lucene.search.Query; +import org.apache.lucene.search.*; import org.elasticsearch.common.Nullable; import java.lang.reflect.Field; @@ -33,7 +27,7 @@ import java.util.List; import java.util.regex.Pattern; /** - * @author kimchy (shay.banon) + * */ public class Queries { diff --git a/src/main/java/org/elasticsearch/common/lucene/search/TermFilter.java b/src/main/java/org/elasticsearch/common/lucene/search/TermFilter.java index 79ca710d557..d28cdd2ca3b 100644 --- a/src/main/java/org/elasticsearch/common/lucene/search/TermFilter.java +++ b/src/main/java/org/elasticsearch/common/lucene/search/TermFilter.java @@ -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,7 +31,7 @@ import java.io.IOException; /** * A simple filter for a specific term. * - * @author kimchy (shay.banon) + * */ public class TermFilter extends Filter { @@ -45,7 +45,8 @@ public class TermFilter extends Filter { return term; } - @Override public DocIdSet getDocIdSet(IndexReader reader) throws IOException { + @Override + public DocIdSet getDocIdSet(IndexReader reader) throws IOException { FixedBitSet result = null; TermDocs td = reader.termDocs(); try { @@ -80,7 +81,8 @@ public class TermFilter extends Filter { return term != null ? term.hashCode() : 0; } - @Override public String toString() { + @Override + public String toString() { return term.field() + ":" + term.text(); } } diff --git a/src/main/java/org/elasticsearch/common/lucene/search/XBooleanFilter.java b/src/main/java/org/elasticsearch/common/lucene/search/XBooleanFilter.java index 79a81faf101..25c7654ffa6 100644 --- a/src/main/java/org/elasticsearch/common/lucene/search/XBooleanFilter.java +++ b/src/main/java/org/elasticsearch/common/lucene/search/XBooleanFilter.java @@ -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,7 +33,7 @@ import java.util.ArrayList; import java.util.List; /** - * @author kimchy (shay.banon) + * */ // LUCENE MONITOR: added to take into account DocSet that wraps OpenBitSet when optimizing or/and/... public class XBooleanFilter extends Filter { diff --git a/src/main/java/org/elasticsearch/common/lucene/search/function/BoostScoreFunction.java b/src/main/java/org/elasticsearch/common/lucene/search/function/BoostScoreFunction.java index 9590e65d439..d4fd30c3cf4 100644 --- a/src/main/java/org/elasticsearch/common/lucene/search/function/BoostScoreFunction.java +++ b/src/main/java/org/elasticsearch/common/lucene/search/function/BoostScoreFunction.java @@ -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.index.IndexReader; import org.apache.lucene.search.Explanation; /** - * @author kimchy (shay.banon) + * */ public class BoostScoreFunction implements ScoreFunction { @@ -38,22 +38,26 @@ public class BoostScoreFunction implements ScoreFunction { return boost; } - @Override public void setNextReader(IndexReader reader) { + @Override + public void setNextReader(IndexReader reader) { // nothing to do here... } - @Override public float score(int docId, float subQueryScore) { + @Override + public float score(int docId, float subQueryScore) { return subQueryScore * boost; } - @Override public Explanation explain(int docId, Explanation subQueryExpl) { + @Override + public Explanation explain(int docId, Explanation subQueryExpl) { Explanation exp = new Explanation(boost * subQueryExpl.getValue(), "static boost function: product of:"); exp.addDetail(subQueryExpl); exp.addDetail(new Explanation(boost, "boostFactor")); return exp; } - @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; @@ -64,7 +68,8 @@ public class BoostScoreFunction implements ScoreFunction { return true; } - @Override public int hashCode() { + @Override + public int hashCode() { return (boost != +0.0f ? Float.floatToIntBits(boost) : 0); } } diff --git a/src/main/java/org/elasticsearch/common/lucene/search/function/FiltersFunctionScoreQuery.java b/src/main/java/org/elasticsearch/common/lucene/search/function/FiltersFunctionScoreQuery.java index 61adb6a8e22..a54a2711d9b 100644 --- a/src/main/java/org/elasticsearch/common/lucene/search/function/FiltersFunctionScoreQuery.java +++ b/src/main/java/org/elasticsearch/common/lucene/search/function/FiltersFunctionScoreQuery.java @@ -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.elasticsearch.common.lucene.search.function; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.Term; -import org.apache.lucene.search.ComplexExplanation; -import org.apache.lucene.search.Explanation; -import org.apache.lucene.search.Filter; -import org.apache.lucene.search.Query; -import org.apache.lucene.search.Scorer; -import org.apache.lucene.search.Searcher; -import org.apache.lucene.search.Similarity; -import org.apache.lucene.search.Weight; +import org.apache.lucene.search.*; import org.apache.lucene.util.ToStringUtils; import org.elasticsearch.common.lucene.docset.DocSet; import org.elasticsearch.common.lucene.docset.DocSets; @@ -42,7 +35,7 @@ import java.util.Set; * A query that allows for a pluggable boost function / filter. If it matches the filter, it will * be boosted by the formula. * - * @author kimchy (shay.banon) + * */ public class FiltersFunctionScoreQuery extends Query { @@ -55,7 +48,8 @@ public class FiltersFunctionScoreQuery extends Query { this.function = function; } - @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; @@ -67,7 +61,8 @@ public class FiltersFunctionScoreQuery extends Query { return true; } - @Override public int hashCode() { + @Override + public int hashCode() { int result = filter != null ? filter.hashCode() : 0; result = 31 * result + (function != null ? function.hashCode() : 0); return result; diff --git a/src/main/java/org/elasticsearch/common/lucene/search/function/FunctionScoreQuery.java b/src/main/java/org/elasticsearch/common/lucene/search/function/FunctionScoreQuery.java index 20ac862e935..11e2e055ef4 100644 --- a/src/main/java/org/elasticsearch/common/lucene/search/function/FunctionScoreQuery.java +++ b/src/main/java/org/elasticsearch/common/lucene/search/function/FunctionScoreQuery.java @@ -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,13 +21,7 @@ package org.elasticsearch.common.lucene.search.function; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.Term; -import org.apache.lucene.search.ComplexExplanation; -import org.apache.lucene.search.Explanation; -import org.apache.lucene.search.Query; -import org.apache.lucene.search.Scorer; -import org.apache.lucene.search.Searcher; -import org.apache.lucene.search.Similarity; -import org.apache.lucene.search.Weight; +import org.apache.lucene.search.*; import org.apache.lucene.util.ToStringUtils; import java.io.IOException; @@ -36,7 +30,7 @@ import java.util.Set; /** * A query that allows for a pluggable boost function to be applied to it. * - * @author kimchy (shay.banon) + * */ public class FunctionScoreQuery extends Query { diff --git a/src/main/java/org/elasticsearch/common/lucene/search/function/ScoreFunction.java b/src/main/java/org/elasticsearch/common/lucene/search/function/ScoreFunction.java index 8b40febe01a..f5dd7437766 100644 --- a/src/main/java/org/elasticsearch/common/lucene/search/function/ScoreFunction.java +++ b/src/main/java/org/elasticsearch/common/lucene/search/function/ScoreFunction.java @@ -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.index.IndexReader; import org.apache.lucene.search.Explanation; /** - * @author kimchy (shay.banon) + * */ public interface ScoreFunction { diff --git a/src/main/java/org/elasticsearch/common/lucene/store/InputStreamIndexInput.java b/src/main/java/org/elasticsearch/common/lucene/store/InputStreamIndexInput.java index 4b3798cad30..09c09d75211 100644 --- a/src/main/java/org/elasticsearch/common/lucene/store/InputStreamIndexInput.java +++ b/src/main/java/org/elasticsearch/common/lucene/store/InputStreamIndexInput.java @@ -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.io.IOException; import java.io.InputStream; /** - * @author kimchy (shay.banon) + * */ public class InputStreamIndexInput extends InputStream { @@ -51,7 +51,8 @@ public class InputStreamIndexInput extends InputStream { return actualSizeToRead; } - @Override public int read(byte[] b, int off, int len) throws IOException { + @Override + public int read(byte[] b, int off, int len) throws IOException { if (b == null) { throw new NullPointerException(); } else if (off < 0 || len < 0 || len > b.length - off) { @@ -74,7 +75,8 @@ public class InputStreamIndexInput extends InputStream { return len; } - @Override public int read() throws IOException { + @Override + public int read() throws IOException { if (counter++ >= limit) { return -1; } diff --git a/src/main/java/org/elasticsearch/common/lucene/store/NullIndexOutput.java b/src/main/java/org/elasticsearch/common/lucene/store/NullIndexOutput.java index c3c91a0f10a..0d6c2700196 100644 --- a/src/main/java/org/elasticsearch/common/lucene/store/NullIndexOutput.java +++ b/src/main/java/org/elasticsearch/common/lucene/store/NullIndexOutput.java @@ -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.store.IndexOutput; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class NullIndexOutput extends IndexOutput { @@ -32,35 +32,42 @@ public class NullIndexOutput extends IndexOutput { private long position = 0; - @Override public void writeByte(byte b) throws IOException { + @Override + public void writeByte(byte b) throws IOException { position++; if (position > length) { length = position; } } - @Override public void writeBytes(byte[] b, int offset, int length) throws IOException { + @Override + public void writeBytes(byte[] b, int offset, int length) throws IOException { position += length; if (position > this.length) { this.length = position; } } - @Override public void flush() throws IOException { + @Override + public void flush() throws IOException { } - @Override public void close() throws IOException { + @Override + public void close() throws IOException { } - @Override public long getFilePointer() { + @Override + public long getFilePointer() { return position; } - @Override public void seek(long pos) throws IOException { + @Override + public void seek(long pos) throws IOException { position = pos; } - @Override public long length() throws IOException { + @Override + public long length() throws IOException { return length; } } diff --git a/src/main/java/org/elasticsearch/common/lucene/store/SwitchDirectory.java b/src/main/java/org/elasticsearch/common/lucene/store/SwitchDirectory.java index efe6804624f..8252ba13200 100644 --- a/src/main/java/org/elasticsearch/common/lucene/store/SwitchDirectory.java +++ b/src/main/java/org/elasticsearch/common/lucene/store/SwitchDirectory.java @@ -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.common.lucene.store; +import com.google.common.collect.ImmutableSet; import org.apache.lucene.store.Directory; import org.apache.lucene.store.IndexInput; import org.apache.lucene.store.IndexOutput; -import org.elasticsearch.common.collect.ImmutableSet; import org.elasticsearch.index.store.support.ForceSyncDirectory; import java.io.IOException; @@ -31,12 +31,12 @@ import java.util.*; /** * A Directory instance that switches files between * two other Directory instances. - * + *

    *

    Files with the specified extensions are placed in the * primary directory; others are placed in the secondary * directory. * - * @author kimchy (shay.banon) + * */ public class SwitchDirectory extends Directory implements ForceSyncDirectory { @@ -74,7 +74,8 @@ public class SwitchDirectory extends Directory implements ForceSyncDirectory { return secondaryDir; } - @Override public void close() throws IOException { + @Override + public void close() throws IOException { if (doClose) { try { secondaryDir.close(); @@ -85,7 +86,8 @@ public class SwitchDirectory extends Directory implements ForceSyncDirectory { } } - @Override public String[] listAll() throws IOException { + @Override + public String[] listAll() throws IOException { Set files = new HashSet(); for (String f : primaryDir.listAll()) { files.add(f); @@ -116,31 +118,38 @@ public class SwitchDirectory extends Directory implements ForceSyncDirectory { } } - @Override public boolean fileExists(String name) throws IOException { + @Override + public boolean fileExists(String name) throws IOException { return getDirectory(name).fileExists(name); } - @Override public long fileModified(String name) throws IOException { + @Override + public long fileModified(String name) throws IOException { return getDirectory(name).fileModified(name); } - @Override public void touchFile(String name) throws IOException { + @Override + public void touchFile(String name) throws IOException { getDirectory(name).touchFile(name); } - @Override public void deleteFile(String name) throws IOException { + @Override + public void deleteFile(String name) throws IOException { getDirectory(name).deleteFile(name); } - @Override public long fileLength(String name) throws IOException { + @Override + public long fileLength(String name) throws IOException { return getDirectory(name).fileLength(name); } - @Override public IndexOutput createOutput(String name) throws IOException { + @Override + public IndexOutput createOutput(String name) throws IOException { return getDirectory(name).createOutput(name); } - @Override public void sync(Collection names) throws IOException { + @Override + public void sync(Collection names) throws IOException { List primaryNames = new ArrayList(); List secondaryNames = new ArrayList(); @@ -154,11 +163,13 @@ public class SwitchDirectory extends Directory implements ForceSyncDirectory { secondaryDir.sync(secondaryNames); } - @Override public void sync(String name) throws IOException { + @Override + public void sync(String name) throws IOException { getDirectory(name).sync(name); } - @Override public void forceSync(String name) throws IOException { + @Override + public void forceSync(String name) throws IOException { Directory dir = getDirectory(name); if (dir instanceof ForceSyncDirectory) { ((ForceSyncDirectory) dir).forceSync(name); @@ -167,7 +178,8 @@ public class SwitchDirectory extends Directory implements ForceSyncDirectory { } } - @Override public IndexInput openInput(String name) throws IOException { + @Override + public IndexInput openInput(String name) throws IOException { return getDirectory(name).openInput(name); } } diff --git a/src/main/java/org/elasticsearch/common/lucene/store/ThreadSafeInputStreamIndexInput.java b/src/main/java/org/elasticsearch/common/lucene/store/ThreadSafeInputStreamIndexInput.java index 88f6fb95ca5..69c722ec03e 100644 --- a/src/main/java/org/elasticsearch/common/lucene/store/ThreadSafeInputStreamIndexInput.java +++ b/src/main/java/org/elasticsearch/common/lucene/store/ThreadSafeInputStreamIndexInput.java @@ -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.store.IndexInput; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class ThreadSafeInputStreamIndexInput extends InputStreamIndexInput { @@ -32,7 +32,8 @@ public class ThreadSafeInputStreamIndexInput extends InputStreamIndexInput { super(indexInput, limit); } - @Override public synchronized int read(byte[] b, int off, int len) throws IOException { + @Override + public synchronized int read(byte[] b, int off, int len) throws IOException { return super.read(b, off, len); } } diff --git a/src/main/java/org/elasticsearch/common/lucene/uid/UidField.java b/src/main/java/org/elasticsearch/common/lucene/uid/UidField.java index f143c92956e..0e027fbd282 100644 --- a/src/main/java/org/elasticsearch/common/lucene/uid/UidField.java +++ b/src/main/java/org/elasticsearch/common/lucene/uid/UidField.java @@ -24,11 +24,7 @@ import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; import org.apache.lucene.analysis.tokenattributes.PayloadAttribute; import org.apache.lucene.document.AbstractField; import org.apache.lucene.document.Field; -import org.apache.lucene.index.FieldInfo; -import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.Payload; -import org.apache.lucene.index.Term; -import org.apache.lucene.index.TermPositions; +import org.apache.lucene.index.*; import org.elasticsearch.common.Numbers; import org.elasticsearch.common.lucene.Lucene; @@ -36,7 +32,7 @@ import java.io.IOException; import java.io.Reader; /** - * @author kimchy (shay.banon) + * */ public class UidField extends AbstractField { @@ -140,11 +136,13 @@ public class UidField extends AbstractField { this.tokenStream = new UidPayloadTokenStream(this); } - @Override public void setIndexOptions(FieldInfo.IndexOptions indexOptions) { + @Override + public void setIndexOptions(FieldInfo.IndexOptions indexOptions) { // never allow to set this, since we want payload! } - @Override public void setOmitTermFreqAndPositions(boolean omitTermFreqAndPositions) { + @Override + public void setOmitTermFreqAndPositions(boolean omitTermFreqAndPositions) { // never allow to set this, since we want payload! } @@ -156,11 +154,13 @@ public class UidField extends AbstractField { this.uid = uid; } - @Override public String stringValue() { + @Override + public String stringValue() { return uid; } - @Override public Reader readerValue() { + @Override + public Reader readerValue() { return null; } @@ -172,7 +172,8 @@ public class UidField extends AbstractField { this.version = version; } - @Override public TokenStream tokenStreamValue() { + @Override + public TokenStream tokenStreamValue() { return tokenStream; } @@ -189,11 +190,13 @@ public class UidField extends AbstractField { this.field = field; } - @Override public void reset() throws IOException { + @Override + public void reset() throws IOException { added = false; } - @Override public final boolean incrementToken() throws IOException { + @Override + public final boolean incrementToken() throws IOException { if (added) { return false; } diff --git a/src/main/java/org/elasticsearch/common/lucene/versioned/ConcurrentVersionedMap.java b/src/main/java/org/elasticsearch/common/lucene/versioned/ConcurrentVersionedMap.java index 22059c5b4ad..966989bfcf0 100644 --- a/src/main/java/org/elasticsearch/common/lucene/versioned/ConcurrentVersionedMap.java +++ b/src/main/java/org/elasticsearch/common/lucene/versioned/ConcurrentVersionedMap.java @@ -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,27 +26,31 @@ import java.util.concurrent.ConcurrentHashMap; /** * An implementation of {@link VersionedMap} based on {@link ConcurrentHashMap}. * - * @author kimchy (Shay Banon) + * */ @ThreadSafe public class ConcurrentVersionedMap implements VersionedMap { private final ConcurrentHashMap map = new ConcurrentHashMap(); - @Override public boolean beforeVersion(int key, int versionToCheck) { + @Override + public boolean beforeVersion(int key, int versionToCheck) { Integer result = map.get(key); return result == null || versionToCheck < result; } - @Override public void putVersion(int key, int version) { + @Override + public void putVersion(int key, int version) { map.put(key, version); } - @Override public void putVersionIfAbsent(int key, int version) { + @Override + public void putVersionIfAbsent(int key, int version) { map.putIfAbsent(key, version); } - @Override public void clear() { + @Override + public void clear() { map.clear(); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/common/lucene/versioned/ConcurrentVersionedMapLong.java b/src/main/java/org/elasticsearch/common/lucene/versioned/ConcurrentVersionedMapLong.java index bef126d3eb3..4f9a8875b98 100644 --- a/src/main/java/org/elasticsearch/common/lucene/versioned/ConcurrentVersionedMapLong.java +++ b/src/main/java/org/elasticsearch/common/lucene/versioned/ConcurrentVersionedMapLong.java @@ -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,27 +26,31 @@ import org.elasticsearch.common.util.concurrent.ThreadSafe; /** * An implementation of {@link VersionedMap} based on {@link org.elasticsearch.common.util.concurrent.ConcurrentMapLong}. * - * @author kimchy (Shay Banon) + * */ @ThreadSafe public class ConcurrentVersionedMapLong implements VersionedMap { private final ConcurrentMapLong map = ConcurrentCollections.newConcurrentMapLong(); - @Override public boolean beforeVersion(int key, int versionToCheck) { + @Override + public boolean beforeVersion(int key, int versionToCheck) { Integer result = map.get(key); return result == null || versionToCheck < result; } - @Override public void putVersion(int key, int version) { + @Override + public void putVersion(int key, int version) { map.put(key, version); } - @Override public void putVersionIfAbsent(int key, int version) { + @Override + public void putVersionIfAbsent(int key, int version) { map.putIfAbsent(key, version); } - @Override public void clear() { + @Override + public void clear() { map.clear(); } } diff --git a/src/main/java/org/elasticsearch/common/lucene/versioned/NativeVersionedMap.java b/src/main/java/org/elasticsearch/common/lucene/versioned/NativeVersionedMap.java index ba82b6e7c55..33899b3b5f5 100644 --- a/src/main/java/org/elasticsearch/common/lucene/versioned/NativeVersionedMap.java +++ b/src/main/java/org/elasticsearch/common/lucene/versioned/NativeVersionedMap.java @@ -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.common.lucene.versioned; -import org.elasticsearch.common.trove.impl.Constants; -import org.elasticsearch.common.trove.map.hash.TIntIntHashMap; +import gnu.trove.impl.Constants; +import gnu.trove.map.hash.TIntIntHashMap; import org.elasticsearch.common.util.concurrent.ThreadSafe; import java.util.concurrent.locks.ReadWriteLock; @@ -29,7 +29,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock; /** * An implementation of {@link VersionedMap} based on trove. * - * @author kimchy (Shay Banon) + * */ @ThreadSafe public class NativeVersionedMap implements VersionedMap { @@ -67,7 +67,8 @@ public class NativeVersionedMap implements VersionedMap { } } - @Override public boolean beforeVersion(int key, int versionToCheck) { + @Override + public boolean beforeVersion(int key, int versionToCheck) { Segment segment = segmentFor(hash(key)); segment.rwl.readLock().lock(); try { @@ -78,7 +79,8 @@ public class NativeVersionedMap implements VersionedMap { } } - @Override public void putVersion(int key, int version) { + @Override + public void putVersion(int key, int version) { Segment segment = segmentFor(hash(key)); segment.rwl.writeLock().lock(); try { @@ -88,7 +90,8 @@ public class NativeVersionedMap implements VersionedMap { } } - @Override public void putVersionIfAbsent(int key, int version) { + @Override + public void putVersionIfAbsent(int key, int version) { Segment segment = segmentFor(hash(key)); segment.rwl.writeLock().lock(); try { @@ -100,7 +103,8 @@ public class NativeVersionedMap implements VersionedMap { } } - @Override public void clear() { + @Override + public void clear() { for (Segment segment : segments) { segment.rwl.writeLock().lock(); try { diff --git a/src/main/java/org/elasticsearch/common/lucene/versioned/VersionedIndexReader.java b/src/main/java/org/elasticsearch/common/lucene/versioned/VersionedIndexReader.java index 7892328f36f..92a6b09fcdd 100644 --- a/src/main/java/org/elasticsearch/common/lucene/versioned/VersionedIndexReader.java +++ b/src/main/java/org/elasticsearch/common/lucene/versioned/VersionedIndexReader.java @@ -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.common.util.concurrent.ThreadSafe; import java.io.IOException; /** - * @author kimchy (Shay Banon) + * */ @ThreadSafe public class VersionedIndexReader extends FilterIndexReader { @@ -40,19 +40,23 @@ public class VersionedIndexReader extends FilterIndexReader { this.versionedMap = versionedMap; } - @Override public TermDocs termDocs() throws IOException { + @Override + public TermDocs termDocs() throws IOException { return new VersionedTermDocs(in.termDocs()); } - @Override public TermDocs termDocs(Term term) throws IOException { + @Override + public TermDocs termDocs(Term term) throws IOException { return new VersionedTermDocs(in.termDocs(term)); } - @Override public TermPositions termPositions() throws IOException { + @Override + public TermPositions termPositions() throws IOException { return new VersionedTermPositions(in.termPositions()); } - @Override public TermPositions termPositions(Term term) throws IOException { + @Override + public TermPositions termPositions(Term term) throws IOException { return new VersionedTermPositions(in.termPositions(term)); } diff --git a/src/main/java/org/elasticsearch/common/lucene/versioned/VersionedMap.java b/src/main/java/org/elasticsearch/common/lucene/versioned/VersionedMap.java index cbe94710d54..9f59e3d4dfb 100644 --- a/src/main/java/org/elasticsearch/common/lucene/versioned/VersionedMap.java +++ b/src/main/java/org/elasticsearch/common/lucene/versioned/VersionedMap.java @@ -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.util.concurrent.ThreadSafe; *

    *

    Note. versions can be assumed to be >= 0. * - * @author kimchy (Shay Banon) + * */ @ThreadSafe public interface VersionedMap { diff --git a/src/main/java/org/elasticsearch/common/math/MathRuntimeException.java b/src/main/java/org/elasticsearch/common/math/MathRuntimeException.java index ec85d0d1638..7adfe85c220 100644 --- a/src/main/java/org/elasticsearch/common/math/MathRuntimeException.java +++ b/src/main/java/org/elasticsearch/common/math/MathRuntimeException.java @@ -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 diff --git a/src/main/java/org/elasticsearch/common/math/MathUtils.java b/src/main/java/org/elasticsearch/common/math/MathUtils.java index 57fb29ebf04..88e51d56169 100644 --- a/src/main/java/org/elasticsearch/common/math/MathUtils.java +++ b/src/main/java/org/elasticsearch/common/math/MathUtils.java @@ -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 @@ -490,7 +490,7 @@ public final class MathUtils { /** * Returns true iff both arguments are null or have same dimensions - * and all their elements are {@link #equals(double,double) equals} + * and all their elements are {@link #equals(double, double) equals} * * @param x first array * @param y second array @@ -1157,11 +1157,11 @@ public final class MathUtils { * * applied to each non-NaN element x of the input array, where sum is the * sum of the non-NaN entries in the input array.

    - * + *

    *

    Throws IllegalArgumentException if normalizedSum is infinite * or NaN and ArithmeticException if the input array contains any infinite elements * or sums to 0

    - * + *

    *

    Ignores (i.e., copies unchanged to the output array) NaNs in the input array.

    * * @param values input array to be normalized diff --git a/src/main/java/org/elasticsearch/common/math/UnboxedMathUtils.java b/src/main/java/org/elasticsearch/common/math/UnboxedMathUtils.java index cafd2b59c90..50962601b07 100644 --- a/src/main/java/org/elasticsearch/common/math/UnboxedMathUtils.java +++ b/src/main/java/org/elasticsearch/common/math/UnboxedMathUtils.java @@ -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.common.math; -import org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom; +import jsr166y.ThreadLocalRandom; /** - * @author kimchy (shay.banon) + * */ public class UnboxedMathUtils { diff --git a/src/main/java/org/elasticsearch/common/metrics/CounterMetric.java b/src/main/java/org/elasticsearch/common/metrics/CounterMetric.java index a711fe1c8fa..184046bf549 100644 --- a/src/main/java/org/elasticsearch/common/metrics/CounterMetric.java +++ b/src/main/java/org/elasticsearch/common/metrics/CounterMetric.java @@ -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,7 +19,7 @@ package org.elasticsearch.common.metrics; -import org.elasticsearch.common.util.concurrent.jsr166e.LongAdder; +import jsr166e.LongAdder; /** */ diff --git a/src/main/java/org/elasticsearch/common/metrics/EWMA.java b/src/main/java/org/elasticsearch/common/metrics/EWMA.java index d16275fcb85..3126cb9f24f 100644 --- a/src/main/java/org/elasticsearch/common/metrics/EWMA.java +++ b/src/main/java/org/elasticsearch/common/metrics/EWMA.java @@ -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,7 +19,7 @@ package org.elasticsearch.common.metrics; -import org.elasticsearch.common.util.concurrent.jsr166e.LongAdder; +import jsr166e.LongAdder; import java.util.concurrent.TimeUnit; @@ -28,7 +28,7 @@ import java.util.concurrent.TimeUnit; * * @see UNIX Load Average Part 1: How It Works * @see UNIX Load Average Part 2: Not Your Average Average - * + *

    * Taken from codahale metric module, changed to use LongAdder */ public class EWMA { diff --git a/src/main/java/org/elasticsearch/common/metrics/MeanMetric.java b/src/main/java/org/elasticsearch/common/metrics/MeanMetric.java index 02f197ad945..302dbc0bd3b 100644 --- a/src/main/java/org/elasticsearch/common/metrics/MeanMetric.java +++ b/src/main/java/org/elasticsearch/common/metrics/MeanMetric.java @@ -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,7 +19,7 @@ package org.elasticsearch.common.metrics; -import org.elasticsearch.common.util.concurrent.jsr166e.LongAdder; +import jsr166e.LongAdder; /** */ diff --git a/src/main/java/org/elasticsearch/common/metrics/MeterMetric.java b/src/main/java/org/elasticsearch/common/metrics/MeterMetric.java index 52b47207704..eef7e3f8301 100644 --- a/src/main/java/org/elasticsearch/common/metrics/MeterMetric.java +++ b/src/main/java/org/elasticsearch/common/metrics/MeterMetric.java @@ -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,7 +19,7 @@ package org.elasticsearch.common.metrics; -import org.elasticsearch.common.util.concurrent.jsr166e.LongAdder; +import jsr166e.LongAdder; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; @@ -30,7 +30,7 @@ import java.util.concurrent.TimeUnit; * fifteen-minute exponentially-weighted moving average throughputs. * * @see EMA - * + *

    * taken from codahale metric module, replaced with LongAdder */ public class MeterMetric implements Metric { diff --git a/src/main/java/org/elasticsearch/common/metrics/Metric.java b/src/main/java/org/elasticsearch/common/metrics/Metric.java index 298e9db68ff..cc4a6112da7 100644 --- a/src/main/java/org/elasticsearch/common/metrics/Metric.java +++ b/src/main/java/org/elasticsearch/common/metrics/Metric.java @@ -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 diff --git a/src/main/java/org/elasticsearch/common/netty/OpenChannelsHandler.java b/src/main/java/org/elasticsearch/common/netty/OpenChannelsHandler.java index 65385e64172..493fbd41d28 100644 --- a/src/main/java/org/elasticsearch/common/netty/OpenChannelsHandler.java +++ b/src/main/java/org/elasticsearch/common/netty/OpenChannelsHandler.java @@ -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,21 +21,13 @@ package org.elasticsearch.common.netty; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.metrics.CounterMetric; -import org.elasticsearch.common.netty.channel.Channel; -import org.elasticsearch.common.netty.channel.ChannelEvent; -import org.elasticsearch.common.netty.channel.ChannelFuture; -import org.elasticsearch.common.netty.channel.ChannelFutureListener; -import org.elasticsearch.common.netty.channel.ChannelHandler; -import org.elasticsearch.common.netty.channel.ChannelHandlerContext; -import org.elasticsearch.common.netty.channel.ChannelState; -import org.elasticsearch.common.netty.channel.ChannelStateEvent; -import org.elasticsearch.common.netty.channel.ChannelUpstreamHandler; import org.elasticsearch.common.util.concurrent.ConcurrentCollections; +import org.jboss.netty.channel.*; import java.util.Set; /** - * @author kimchy (shay.banon) + * */ @ChannelHandler.Sharable public class OpenChannelsHandler implements ChannelUpstreamHandler { @@ -62,7 +54,8 @@ public class OpenChannelsHandler implements ChannelUpstreamHandler { } }; - @Override public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception { + @Override + public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception { if (e instanceof ChannelStateEvent) { ChannelStateEvent evt = (ChannelStateEvent) e; // OPEN is also sent to when closing channel, but with FALSE on it to indicate it closes diff --git a/src/main/java/org/elasticsearch/common/network/NetworkModule.java b/src/main/java/org/elasticsearch/common/network/NetworkModule.java index 2f5787c0f5f..a4f9d70527e 100644 --- a/src/main/java/org/elasticsearch/common/network/NetworkModule.java +++ b/src/main/java/org/elasticsearch/common/network/NetworkModule.java @@ -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,11 +22,12 @@ package org.elasticsearch.common.network; import org.elasticsearch.common.inject.AbstractModule; /** - * @author kimchy (shay.banon) + * */ public class NetworkModule extends AbstractModule { - @Override protected void configure() { + @Override + protected void configure() { bind(NetworkService.class).asEagerSingleton(); } } diff --git a/src/main/java/org/elasticsearch/common/network/NetworkService.java b/src/main/java/org/elasticsearch/common/network/NetworkService.java index b85d37df7d5..f8b2617e41a 100644 --- a/src/main/java/org/elasticsearch/common/network/NetworkService.java +++ b/src/main/java/org/elasticsearch/common/network/NetworkService.java @@ -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,7 +36,7 @@ import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.TimeUnit; /** - * @author kimchy (shay.banon) + * */ public class NetworkService extends AbstractComponent { @@ -80,7 +80,8 @@ public class NetworkService extends AbstractComponent { private final List customNameResolvers = new CopyOnWriteArrayList(); - @Inject public NetworkService(Settings settings) { + @Inject + public NetworkService(Settings settings) { super(settings); } diff --git a/src/main/java/org/elasticsearch/common/network/NetworkUtils.java b/src/main/java/org/elasticsearch/common/network/NetworkUtils.java index f48636530b9..aa2ff6e49ea 100644 --- a/src/main/java/org/elasticsearch/common/network/NetworkUtils.java +++ b/src/main/java/org/elasticsearch/common/network/NetworkUtils.java @@ -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,30 +19,18 @@ package org.elasticsearch.common.network; +import com.google.common.collect.Lists; import org.elasticsearch.ElasticSearchIllegalStateException; -import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.os.OsUtils; import java.lang.reflect.Method; -import java.net.Inet4Address; -import java.net.Inet6Address; -import java.net.InetAddress; -import java.net.NetworkInterface; -import java.net.SocketException; -import java.net.UnknownHostException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.Enumeration; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.net.*; +import java.util.*; /** - * @author kimchy (shay.banon) + * */ public abstract class NetworkUtils { @@ -122,7 +110,8 @@ public abstract class NetworkUtils { getIndexMethod.setAccessible(true); Collections.sort(intfsList, new Comparator() { - @Override public int compare(NetworkInterface o1, NetworkInterface o2) { + @Override + public int compare(NetworkInterface o1, NetworkInterface o2) { try { return ((Integer) getIndexMethod.invoke(o1)).intValue() - ((Integer) getIndexMethod.invoke(o2)).intValue(); } catch (Exception e) { diff --git a/src/main/java/org/elasticsearch/common/os/OsUtils.java b/src/main/java/org/elasticsearch/common/os/OsUtils.java index 258217abd2b..d037e87a476 100644 --- a/src/main/java/org/elasticsearch/common/os/OsUtils.java +++ b/src/main/java/org/elasticsearch/common/os/OsUtils.java @@ -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.common.os; /** - * @author kimchy (Shay Banon) + * */ public class OsUtils { diff --git a/src/main/java/org/elasticsearch/common/path/PathTrie.java b/src/main/java/org/elasticsearch/common/path/PathTrie.java index 0a8e2a04e5e..b1b345add06 100644 --- a/src/main/java/org/elasticsearch/common/path/PathTrie.java +++ b/src/main/java/org/elasticsearch/common/path/PathTrie.java @@ -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,15 +19,15 @@ package org.elasticsearch.common.path; +import com.google.common.collect.ImmutableMap; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.collect.ImmutableMap; import java.util.Map; -import static org.elasticsearch.common.collect.MapBuilder.*; +import static org.elasticsearch.common.collect.MapBuilder.newMapBuilder; /** - * @author kimchy (Shay Banon) + * */ public class PathTrie { @@ -36,7 +36,8 @@ public class PathTrie { } public static final Decoder NO_DECODER = new Decoder() { - @Override public String decode(String value) { + @Override + public String decode(String value) { return value; } }; diff --git a/src/main/java/org/elasticsearch/common/property/PropertyPlaceholder.java b/src/main/java/org/elasticsearch/common/property/PropertyPlaceholder.java index e69c040b44f..4f94c702db5 100644 --- a/src/main/java/org/elasticsearch/common/property/PropertyPlaceholder.java +++ b/src/main/java/org/elasticsearch/common/property/PropertyPlaceholder.java @@ -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,7 +34,7 @@ import java.util.Set; *

    Values for substitution can be supplied using a {@link Properties} instance or using a * {@link PlaceholderResolver}. * - * @author kimchy (Shay Banon) + * */ public class PropertyPlaceholder { diff --git a/src/main/java/org/elasticsearch/common/regex/Regex.java b/src/main/java/org/elasticsearch/common/regex/Regex.java index acc365745ac..4a9a7727371 100644 --- a/src/main/java/org/elasticsearch/common/regex/Regex.java +++ b/src/main/java/org/elasticsearch/common/regex/Regex.java @@ -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.common.Strings; import java.util.regex.Pattern; /** - * @author kimchy (shay.banon) + * */ public class Regex { diff --git a/src/main/java/org/elasticsearch/common/settings/ImmutableSettings.java b/src/main/java/org/elasticsearch/common/settings/ImmutableSettings.java index 20c4f62d81e..50ff49e3001 100644 --- a/src/main/java/org/elasticsearch/common/settings/ImmutableSettings.java +++ b/src/main/java/org/elasticsearch/common/settings/ImmutableSettings.java @@ -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,11 +19,11 @@ package org.elasticsearch.common.settings; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Lists; import org.elasticsearch.common.Booleans; import org.elasticsearch.common.Classes; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.io.Streams; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -41,22 +41,18 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; +import java.util.*; import java.util.concurrent.TimeUnit; -import static org.elasticsearch.common.Strings.*; -import static org.elasticsearch.common.unit.ByteSizeValue.*; -import static org.elasticsearch.common.unit.SizeValue.*; -import static org.elasticsearch.common.unit.TimeValue.*; +import static org.elasticsearch.common.Strings.toCamelCase; +import static org.elasticsearch.common.unit.ByteSizeValue.parseBytesSizeValue; +import static org.elasticsearch.common.unit.SizeValue.parseSizeValue; +import static org.elasticsearch.common.unit.TimeValue.parseTimeValue; /** * An immutable implementation of {@link Settings}. * - * @author kimchy (shay.banon) + * */ @ThreadSafe @Immutable @@ -71,15 +67,18 @@ public class ImmutableSettings implements Settings { this.classLoader = classLoader == null ? buildClassLoader() : classLoader; } - @Override public ClassLoader getClassLoader() { + @Override + public ClassLoader getClassLoader() { return this.classLoader; } - @Override public ImmutableMap getAsMap() { + @Override + public ImmutableMap getAsMap() { return this.settings; } - @Override public Settings getComponentSettings(Class component) { + @Override + public Settings getComponentSettings(Class component) { if (component.getName().startsWith("org.elasticsearch")) { return getComponentSettings("org.elasticsearch", component); } @@ -87,7 +86,8 @@ public class ImmutableSettings implements Settings { return getComponentSettings(component.getName().substring(0, component.getName().indexOf('.')), component); } - @Override public Settings getComponentSettings(String prefix, Class component) { + @Override + public Settings getComponentSettings(String prefix, Class component) { String type = component.getName(); if (!type.startsWith(prefix)) { throw new SettingsException("Component [" + type + "] does not start with prefix [" + prefix + "]"); @@ -97,7 +97,8 @@ public class ImmutableSettings implements Settings { return getByPrefix(settingPrefix); } - @Override public Settings getByPrefix(String prefix) { + @Override + public Settings getByPrefix(String prefix) { Builder builder = new Builder(); for (Map.Entry entry : getAsMap().entrySet()) { if (entry.getKey().startsWith(prefix)) { @@ -112,7 +113,8 @@ public class ImmutableSettings implements Settings { return builder.build(); } - @Override public String get(String setting) { + @Override + public String get(String setting) { String retVal = settings.get(setting); if (retVal != null) { return retVal; @@ -121,12 +123,14 @@ public class ImmutableSettings implements Settings { return settings.get(toCamelCase(setting)); } - @Override public String get(String setting, String defaultValue) { + @Override + public String get(String setting, String defaultValue) { String retVal = settings.get(setting); return retVal == null ? defaultValue : retVal; } - @Override public Float getAsFloat(String setting, Float defaultValue) { + @Override + public Float getAsFloat(String setting, Float defaultValue) { String sValue = get(setting); if (sValue == null) { return defaultValue; @@ -138,7 +142,8 @@ public class ImmutableSettings implements Settings { } } - @Override public Double getAsDouble(String setting, Double defaultValue) { + @Override + public Double getAsDouble(String setting, Double defaultValue) { String sValue = get(setting); if (sValue == null) { return defaultValue; @@ -150,7 +155,8 @@ public class ImmutableSettings implements Settings { } } - @Override public Integer getAsInt(String setting, Integer defaultValue) { + @Override + public Integer getAsInt(String setting, Integer defaultValue) { String sValue = get(setting); if (sValue == null) { return defaultValue; @@ -162,7 +168,8 @@ public class ImmutableSettings implements Settings { } } - @Override public Long getAsLong(String setting, Long defaultValue) { + @Override + public Long getAsLong(String setting, Long defaultValue) { String sValue = get(setting); if (sValue == null) { return defaultValue; @@ -174,24 +181,29 @@ public class ImmutableSettings implements Settings { } } - @Override public Boolean getAsBoolean(String setting, Boolean defaultValue) { + @Override + public Boolean getAsBoolean(String setting, Boolean defaultValue) { return Booleans.parseBoolean(get(setting), defaultValue); } - @Override public TimeValue getAsTime(String setting, TimeValue defaultValue) { + @Override + public TimeValue getAsTime(String setting, TimeValue defaultValue) { return parseTimeValue(get(setting), defaultValue); } - @Override public ByteSizeValue getAsBytesSize(String setting, ByteSizeValue defaultValue) throws SettingsException { + @Override + public ByteSizeValue getAsBytesSize(String setting, ByteSizeValue defaultValue) throws SettingsException { return parseBytesSizeValue(get(setting), defaultValue); } - @Override public SizeValue getAsSize(String setting, SizeValue defaultValue) throws SettingsException { + @Override + public SizeValue getAsSize(String setting, SizeValue defaultValue) throws SettingsException { return parseSizeValue(get(setting), defaultValue); } @SuppressWarnings({"unchecked"}) - @Override public Class getAsClass(String setting, Class defaultClazz) throws NoClassSettingsException { + @Override + public Class getAsClass(String setting, Class defaultClazz) throws NoClassSettingsException { String sValue = get(setting); if (sValue == null) { return defaultClazz; @@ -204,7 +216,8 @@ public class ImmutableSettings implements Settings { } @SuppressWarnings({"unchecked"}) - @Override public Class getAsClass(String setting, Class defaultClazz, String prefixPackage, String suffixClassName) throws NoClassSettingsException { + @Override + public Class getAsClass(String setting, Class defaultClazz, String prefixPackage, String suffixClassName) throws NoClassSettingsException { String sValue = get(setting); if (sValue == null) { return defaultClazz; @@ -233,11 +246,13 @@ public class ImmutableSettings implements Settings { } } - @Override public String[] getAsArray(String settingPrefix) throws SettingsException { + @Override + public String[] getAsArray(String settingPrefix) throws SettingsException { return getAsArray(settingPrefix, Strings.EMPTY_ARRAY); } - @Override public String[] getAsArray(String settingPrefix, String[] defaultArray) throws SettingsException { + @Override + public String[] getAsArray(String settingPrefix, String[] defaultArray) throws SettingsException { List result = Lists.newArrayList(); if (get(settingPrefix) != null) { @@ -263,7 +278,8 @@ public class ImmutableSettings implements Settings { return result.toArray(new String[result.size()]); } - @Override public Map getGroups(String settingPrefix) throws SettingsException { + @Override + public Map getGroups(String settingPrefix) throws SettingsException { if (settingPrefix.charAt(settingPrefix.length() - 1) != '.') { settingPrefix = settingPrefix + "."; } @@ -642,7 +658,7 @@ public class ImmutableSettings implements Settings { /** * Runs across all the settings set on this builder and replaces ${...} elements in the * each setting value according to the following logic: - * + *

    *

    First, tries to resolve it against a System property ({@link System#getProperty(String)}), next, * tries and resolve it against an environment variable ({@link System#getenv(String)}), and last, tries * and replace it with another setting already set on this builder. @@ -650,7 +666,8 @@ public class ImmutableSettings implements Settings { public Builder replacePropertyPlaceholders() { PropertyPlaceholder propertyPlaceholder = new PropertyPlaceholder("${", "}", false); PropertyPlaceholder.PlaceholderResolver placeholderResolver = new PropertyPlaceholder.PlaceholderResolver() { - @Override public String resolvePlaceholder(String placeholderName) { + @Override + public String resolvePlaceholder(String placeholderName) { String value = System.getProperty(placeholderName); if (value != null) { return value; diff --git a/src/main/java/org/elasticsearch/common/settings/NoClassSettingsException.java b/src/main/java/org/elasticsearch/common/settings/NoClassSettingsException.java index 6d543fddb38..1468ed859db 100644 --- a/src/main/java/org/elasticsearch/common/settings/NoClassSettingsException.java +++ b/src/main/java/org/elasticsearch/common/settings/NoClassSettingsException.java @@ -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 @@ package org.elasticsearch.common.settings; * A specific type of {@link SettingsException} indicating failure to load a class * based on a settings value. * - * @author kimchy (Shay Banon) + * */ public class NoClassSettingsException extends SettingsException { diff --git a/src/main/java/org/elasticsearch/common/settings/Settings.java b/src/main/java/org/elasticsearch/common/settings/Settings.java index 939320cc2f5..144cc43938f 100644 --- a/src/main/java/org/elasticsearch/common/settings/Settings.java +++ b/src/main/java/org/elasticsearch/common/settings/Settings.java @@ -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,7 +19,7 @@ package org.elasticsearch.common.settings; -import org.elasticsearch.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMap; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.unit.SizeValue; import org.elasticsearch.common.unit.TimeValue; @@ -29,11 +29,11 @@ import java.util.Map; /** * Immutable settings allowing to control the configuration. - * + *

    *

    Using {@link ImmutableSettings#settingsBuilder()} in order to create a builder * which in turn can create an immutable implementation of settings. * - * @author kimchy (shay.banon) + * * @see ImmutableSettings */ @ThreadSafe @@ -211,7 +211,7 @@ public interface Settings { /** * The values associated with a setting prefix as an array. The settings array is in the format of: * settingPrefix.[index]. - * + *

    *

    It will also automatically load a comma separated list under the settingPrefix and merge with * the numbered format. * @@ -224,7 +224,7 @@ public interface Settings { /** * The values associated with a setting prefix as an array. The settings array is in the format of: * settingPrefix.[index]. - * + *

    *

    It will also automatically load a comma separated list under the settingPrefix and merge with * the numbered format. * diff --git a/src/main/java/org/elasticsearch/common/settings/SettingsException.java b/src/main/java/org/elasticsearch/common/settings/SettingsException.java index 100c0f15176..29b87568ffd 100644 --- a/src/main/java/org/elasticsearch/common/settings/SettingsException.java +++ b/src/main/java/org/elasticsearch/common/settings/SettingsException.java @@ -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.ElasticSearchException; /** * A generic failure to handle settings. * - * @author kimchy (Shay Banon) + * */ public class SettingsException extends ElasticSearchException { diff --git a/src/main/java/org/elasticsearch/common/settings/SettingsFilter.java b/src/main/java/org/elasticsearch/common/settings/SettingsFilter.java index 8b442c66a87..347e03db81f 100644 --- a/src/main/java/org/elasticsearch/common/settings/SettingsFilter.java +++ b/src/main/java/org/elasticsearch/common/settings/SettingsFilter.java @@ -6,7 +6,7 @@ import org.elasticsearch.common.inject.Inject; import java.util.concurrent.CopyOnWriteArrayList; /** - * @author kimchy (shay.banon) + * */ public class SettingsFilter extends AbstractComponent { @@ -17,7 +17,8 @@ public class SettingsFilter extends AbstractComponent { private final CopyOnWriteArrayList filters = new CopyOnWriteArrayList(); - @Inject public SettingsFilter(Settings settings) { + @Inject + public SettingsFilter(Settings settings) { super(settings); } diff --git a/src/main/java/org/elasticsearch/common/settings/SettingsModule.java b/src/main/java/org/elasticsearch/common/settings/SettingsModule.java index 95d7e6a97ae..ac80cf27a1d 100644 --- a/src/main/java/org/elasticsearch/common/settings/SettingsModule.java +++ b/src/main/java/org/elasticsearch/common/settings/SettingsModule.java @@ -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.common.inject.AbstractModule; /** * A module that binds the provided settings to the {@link Settings} interface. * - * @author kimchy (Shay Banon) + * */ public class SettingsModule extends AbstractModule { @@ -34,7 +34,8 @@ public class SettingsModule extends AbstractModule { this.settings = settings; } - @Override protected void configure() { + @Override + protected void configure() { bind(Settings.class).toInstance(settings); bind(SettingsFilter.class).asEagerSingleton(); } diff --git a/src/main/java/org/elasticsearch/common/settings/loader/JsonSettingsLoader.java b/src/main/java/org/elasticsearch/common/settings/loader/JsonSettingsLoader.java index 69d8b4652ab..7bb09a01422 100644 --- a/src/main/java/org/elasticsearch/common/settings/loader/JsonSettingsLoader.java +++ b/src/main/java/org/elasticsearch/common/settings/loader/JsonSettingsLoader.java @@ -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,18 +27,19 @@ import java.io.IOException; import java.util.List; import java.util.Map; -import static org.elasticsearch.common.collect.Lists.*; -import static org.elasticsearch.common.collect.Maps.*; +import static com.google.common.collect.Lists.newArrayList; +import static com.google.common.collect.Maps.newHashMap; /** * Settings loader that loads (parses) the settings in a json format by flattening them * into a map. * - * @author kimchy (shay.banon) + * */ public class JsonSettingsLoader implements SettingsLoader { - @Override public Map load(String source) throws IOException { + @Override + public Map load(String source) throws IOException { XContentParser parser = XContentFactory.xContent(XContentType.JSON).createParser(source); try { return load(parser); @@ -47,7 +48,8 @@ public class JsonSettingsLoader implements SettingsLoader { } } - @Override public Map load(byte[] source) throws IOException { + @Override + public Map load(byte[] source) throws IOException { XContentParser parser = XContentFactory.xContent(XContentType.JSON).createParser(source); try { return load(parser); diff --git a/src/main/java/org/elasticsearch/common/settings/loader/PropertiesSettingsLoader.java b/src/main/java/org/elasticsearch/common/settings/loader/PropertiesSettingsLoader.java index 42c1ced65ed..ceab8639355 100644 --- a/src/main/java/org/elasticsearch/common/settings/loader/PropertiesSettingsLoader.java +++ b/src/main/java/org/elasticsearch/common/settings/loader/PropertiesSettingsLoader.java @@ -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,7 +19,7 @@ package org.elasticsearch.common.settings.loader; -import org.elasticsearch.common.io.Closeables; +import com.google.common.io.Closeables; import org.elasticsearch.common.io.FastByteArrayInputStream; import org.elasticsearch.common.io.FastStringReader; @@ -27,16 +27,17 @@ import java.io.IOException; import java.util.Map; import java.util.Properties; -import static org.elasticsearch.common.collect.Maps.*; +import static com.google.common.collect.Maps.newHashMap; /** * Settings loader that loads (parses) the settings in a properties format. * - * @author kimchy (shay.banon) + * */ public class PropertiesSettingsLoader implements SettingsLoader { - @Override public Map load(String source) throws IOException { + @Override + public Map load(String source) throws IOException { Properties props = new Properties(); FastStringReader reader = new FastStringReader(source); try { @@ -51,7 +52,8 @@ public class PropertiesSettingsLoader implements SettingsLoader { } } - @Override public Map load(byte[] source) throws IOException { + @Override + public Map load(byte[] source) throws IOException { Properties props = new Properties(); FastByteArrayInputStream stream = new FastByteArrayInputStream(source); try { diff --git a/src/main/java/org/elasticsearch/common/settings/loader/SettingsLoader.java b/src/main/java/org/elasticsearch/common/settings/loader/SettingsLoader.java index 97aaf240d37..7e764062473 100644 --- a/src/main/java/org/elasticsearch/common/settings/loader/SettingsLoader.java +++ b/src/main/java/org/elasticsearch/common/settings/loader/SettingsLoader.java @@ -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.util.Map; * Provides the ability to load settings (in the form of a simple Map) from * the actual source content that represents them. * - * @author kimchy (shay.banon) + * */ public interface SettingsLoader { diff --git a/src/main/java/org/elasticsearch/common/settings/loader/SettingsLoaderFactory.java b/src/main/java/org/elasticsearch/common/settings/loader/SettingsLoaderFactory.java index 061dc5abaf6..76fdaeac8fd 100644 --- a/src/main/java/org/elasticsearch/common/settings/loader/SettingsLoaderFactory.java +++ b/src/main/java/org/elasticsearch/common/settings/loader/SettingsLoaderFactory.java @@ -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 @@ package org.elasticsearch.common.settings.loader; * A settings loader factory automatically trying to identify what type of * {@link SettingsLoader} to use. * - * @author kimchy (Shay Banon) + * */ public final class SettingsLoaderFactory { diff --git a/src/main/java/org/elasticsearch/common/settings/loader/YamlSettingsLoader.java b/src/main/java/org/elasticsearch/common/settings/loader/YamlSettingsLoader.java index a7d9796aa2d..113063208fd 100644 --- a/src/main/java/org/elasticsearch/common/settings/loader/YamlSettingsLoader.java +++ b/src/main/java/org/elasticsearch/common/settings/loader/YamlSettingsLoader.java @@ -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,24 +20,25 @@ package org.elasticsearch.common.settings.loader; import org.elasticsearch.common.io.FastByteArrayInputStream; -import org.elasticsearch.common.yaml.snakeyaml.Yaml; +import org.yaml.snakeyaml.Yaml; import java.io.IOException; import java.util.List; import java.util.Map; -import static org.elasticsearch.common.collect.Lists.*; -import static org.elasticsearch.common.collect.Maps.*; +import static com.google.common.collect.Lists.newArrayList; +import static com.google.common.collect.Maps.newHashMap; /** * Settings loader that loads (parses) the settings in a yaml format by flattening them * into a map. * - * @author kimchy (shay.banon) + * */ public class YamlSettingsLoader implements SettingsLoader { - @Override public Map load(String source) throws IOException { + @Override + public Map load(String source) throws IOException { // replace tabs with whitespace (yaml does not accept tabs, but many users might use it still...) source = source.replace("\t", " "); Yaml yaml = new Yaml(); @@ -52,7 +53,8 @@ public class YamlSettingsLoader implements SettingsLoader { return settings; } - @Override public Map load(byte[] source) throws IOException { + @Override + public Map load(byte[] source) throws IOException { Yaml yaml = new Yaml(); Map yamlMap = (Map) yaml.load(new FastByteArrayInputStream(source)); StringBuilder sb = new StringBuilder(); diff --git a/src/main/java/org/elasticsearch/common/settings/loader/package-info.java b/src/main/java/org/elasticsearch/common/settings/loader/package-info.java index 1ca121b25c0..be8ef19e8ba 100644 --- a/src/main/java/org/elasticsearch/common/settings/loader/package-info.java +++ b/src/main/java/org/elasticsearch/common/settings/loader/package-info.java @@ -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 diff --git a/src/main/java/org/elasticsearch/common/settings/package-info.java b/src/main/java/org/elasticsearch/common/settings/package-info.java index f4a6201d9b6..7a00c9d8668 100644 --- a/src/main/java/org/elasticsearch/common/settings/package-info.java +++ b/src/main/java/org/elasticsearch/common/settings/package-info.java @@ -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 diff --git a/src/main/java/org/elasticsearch/common/thread/LoggingRunnable.java b/src/main/java/org/elasticsearch/common/thread/LoggingRunnable.java index 043c58c0fc4..3b30391862b 100644 --- a/src/main/java/org/elasticsearch/common/thread/LoggingRunnable.java +++ b/src/main/java/org/elasticsearch/common/thread/LoggingRunnable.java @@ -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,7 +34,8 @@ public class LoggingRunnable implements Runnable { this.logger = logger; } - @Override public void run() { + @Override + public void run() { try { runnable.run(); } catch (Exception e) { diff --git a/src/main/java/org/elasticsearch/common/thread/ThreadLocals.java b/src/main/java/org/elasticsearch/common/thread/ThreadLocals.java index 0d61aed8b88..73f79297f89 100644 --- a/src/main/java/org/elasticsearch/common/thread/ThreadLocals.java +++ b/src/main/java/org/elasticsearch/common/thread/ThreadLocals.java @@ -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.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; /** - * @author kimchy (shay.banon) + * */ public class ThreadLocals { diff --git a/src/main/java/org/elasticsearch/common/thread/ThreadNameDeterminer.java b/src/main/java/org/elasticsearch/common/thread/ThreadNameDeterminer.java index 02d0b528492..a5a2668e621 100644 --- a/src/main/java/org/elasticsearch/common/thread/ThreadNameDeterminer.java +++ b/src/main/java/org/elasticsearch/common/thread/ThreadNameDeterminer.java @@ -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.common.thread; /** * Overrides the thread name proposed by {@link ThreadRenamingRunnable}. * - * @author kimchy (shay.banon) + * */ public interface ThreadNameDeterminer { diff --git a/src/main/java/org/elasticsearch/common/thread/ThreadRenamingRunnable.java b/src/main/java/org/elasticsearch/common/thread/ThreadRenamingRunnable.java index 6f43d7e5395..11b8014d748 100644 --- a/src/main/java/org/elasticsearch/common/thread/ThreadRenamingRunnable.java +++ b/src/main/java/org/elasticsearch/common/thread/ThreadRenamingRunnable.java @@ -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.logging.Loggers; * when its execution ends. To change the default thread names set by Netty, * use {@link #setThreadNameDeterminer(ThreadNameDeterminer)}. * - * @author kimchy (shay.banon) + * */ public class ThreadRenamingRunnable implements Runnable { diff --git a/src/main/java/org/elasticsearch/common/timer/HashedWheelTimer.java b/src/main/java/org/elasticsearch/common/timer/HashedWheelTimer.java deleted file mode 100644 index 4927b31afe4..00000000000 --- a/src/main/java/org/elasticsearch/common/timer/HashedWheelTimer.java +++ /dev/null @@ -1,489 +0,0 @@ -/* - * Licensed to Elastic Search 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 - * file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.common.timer; - -import org.elasticsearch.common.collect.MapBackedSet; -import org.elasticsearch.common.collect.ReusableIterator; -import org.elasticsearch.common.logging.ESLogger; -import org.elasticsearch.common.thread.ThreadRenamingRunnable; -import org.elasticsearch.common.util.concurrent.ConcurrentIdentityHashMap; - -import java.util.*; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.locks.ReadWriteLock; -import java.util.concurrent.locks.ReentrantReadWriteLock; - -/** - * A {@link Timer} optimized for approximated I/O timeout scheduling. - * - *

    Tick Duration

    - * - * As described with 'approximated', this timer does not execute the scheduled - * {@link TimerTask} on time. {@link HashedWheelTimer}, on every tick, will - * check if there are any {@link TimerTask}s behind the schedule and execute - * them. - *

    - * You can increase or decrease the accuracy of the execution timing by - * specifying smaller or larger tick duration in the constructor. In most - * network applications, I/O timeout does not need to be accurate. Therefore, - * the default tick duration is 100 milliseconds and you will not need to try - * different configurations in most cases. - * - *

    Ticks per Wheel (Wheel Size)

    - * - * {@link HashedWheelTimer} maintains a data structure called 'wheel'. - * To put simply, a wheel is a hash table of {@link TimerTask}s whose hash - * function is 'dead line of the task'. The default number of ticks per wheel - * (i.e. the size of the wheel) is 512. You could specify a larger value - * if you are going to schedule a lot of timeouts. - * - *

    Implementation Details

    - * - * {@link HashedWheelTimer} is based on - * 'Hashed - * and Hierarchical Timing Wheels: data structures to efficiently implement a - * timer facility'. More comprehensive slides are located - * here. - * - * @author kimchy (shay.banon) - */ -public class HashedWheelTimer implements Timer { - - private final ESLogger logger; - - private static final AtomicInteger id = new AtomicInteger(); - - private final Worker worker = new Worker(); - final Thread workerThread; - final AtomicBoolean shutdown = new AtomicBoolean(); - - private final long roundDuration; - final long tickDuration; - final Set[] wheel; - final ReusableIterator[] iterators; - final int mask; - final ReadWriteLock lock = new ReentrantReadWriteLock(); - volatile int wheelCursor; - - /** - * Creates a new timer with the default number of ticks per wheel. - * - * @param threadFactory a {@link ThreadFactory} that creates a - * background {@link Thread} which is dedicated to - * {@link TimerTask} execution. - * @param tickDuration the duration between tick - * @param unit the time unit of the {@code tickDuration} - */ - public HashedWheelTimer(ESLogger logger, ThreadFactory threadFactory, long tickDuration, TimeUnit unit) { - this(logger, threadFactory, tickDuration, unit, 512); - } - - /** - * Creates a new timer. - * - * @param threadFactory a {@link ThreadFactory} that creates a - * background {@link Thread} which is dedicated to - * {@link TimerTask} execution. - * @param tickDuration the duration between tick - * @param unit the time unit of the {@code tickDuration} - * @param ticksPerWheel the size of the wheel - */ - public HashedWheelTimer(ESLogger logger, ThreadFactory threadFactory, long tickDuration, TimeUnit unit, int ticksPerWheel) { - this.logger = logger; - - if (threadFactory == null) { - throw new NullPointerException("threadFactory"); - } - if (unit == null) { - throw new NullPointerException("unit"); - } - if (tickDuration <= 0) { - throw new IllegalArgumentException( - "tickDuration must be greater than 0: " + tickDuration); - } - if (ticksPerWheel <= 0) { - throw new IllegalArgumentException( - "ticksPerWheel must be greater than 0: " + ticksPerWheel); - } - - // Normalize ticksPerWheel to power of two and initialize the wheel. - wheel = createWheel(ticksPerWheel); - iterators = createIterators(wheel); - mask = wheel.length - 1; - - // Convert tickDuration to milliseconds. - this.tickDuration = tickDuration = unit.toMillis(tickDuration); - - // Prevent overflow. - if (tickDuration == Long.MAX_VALUE || - tickDuration >= Long.MAX_VALUE / wheel.length) { - throw new IllegalArgumentException( - "tickDuration is too long: " + - tickDuration + ' ' + unit); - } - - roundDuration = tickDuration * wheel.length; - - workerThread = threadFactory.newThread(new ThreadRenamingRunnable( - worker, "Hashed wheel timer #" + id.incrementAndGet())); - } - - @SuppressWarnings("unchecked") - private static Set[] createWheel(int ticksPerWheel) { - if (ticksPerWheel <= 0) { - throw new IllegalArgumentException( - "ticksPerWheel must be greater than 0: " + ticksPerWheel); - } - if (ticksPerWheel > 1073741824) { - throw new IllegalArgumentException( - "ticksPerWheel may not be greater than 2^30: " + ticksPerWheel); - } - - ticksPerWheel = normalizeTicksPerWheel(ticksPerWheel); - Set[] wheel = new Set[ticksPerWheel]; - for (int i = 0; i < wheel.length; i++) { - wheel[i] = new MapBackedSet( - new ConcurrentIdentityHashMap(16, 0.95f, 4)); - } - return wheel; - } - - @SuppressWarnings("unchecked") - private static ReusableIterator[] createIterators(Set[] wheel) { - ReusableIterator[] iterators = new ReusableIterator[wheel.length]; - for (int i = 0; i < wheel.length; i++) { - iterators[i] = (ReusableIterator) wheel[i].iterator(); - } - return iterators; - } - - private static int normalizeTicksPerWheel(int ticksPerWheel) { - int normalizedTicksPerWheel = 1; - while (normalizedTicksPerWheel < ticksPerWheel) { - normalizedTicksPerWheel <<= 1; - } - return normalizedTicksPerWheel; - } - - /** - * Starts the background thread explicitly. The background thread will - * start automatically on demand even if you did not call this method. - * - * @throws IllegalStateException if this timer has been - * {@linkplain #stop() stopped} already - */ - public synchronized void start() { - if (shutdown.get()) { - throw new IllegalStateException("cannot be started once stopped"); - } - - if (!workerThread.isAlive()) { - workerThread.start(); - } - } - - public synchronized Set stop() { - if (!shutdown.compareAndSet(false, true)) { - return Collections.emptySet(); - } - - boolean interrupted = false; - while (workerThread.isAlive()) { - workerThread.interrupt(); - try { - workerThread.join(100); - } catch (InterruptedException e) { - interrupted = true; - } - } - - if (interrupted) { - Thread.currentThread().interrupt(); - } - - Set unprocessedTimeouts = new HashSet(); - for (Set bucket : wheel) { - unprocessedTimeouts.addAll(bucket); - bucket.clear(); - } - - return Collections.unmodifiableSet(unprocessedTimeouts); - } - - public Timeout newTimeout(TimerTask task, long delay, TimeUnit unit) { - final long currentTime = System.currentTimeMillis(); - - if (task == null) { - throw new NullPointerException("task"); - } - if (unit == null) { - throw new NullPointerException("unit"); - } - - delay = unit.toMillis(delay); - if (delay < tickDuration) { - delay = tickDuration; - } - - if (!workerThread.isAlive()) { - start(); - } - - HashedWheelTimeout timeout = new HashedWheelTimeout(task, currentTime + delay); - scheduleTimeout(timeout, delay); - return timeout; - } - - void scheduleTimeout(HashedWheelTimeout timeout, long delay) { - // delay must be equal to or greater than tickDuration so that the - // worker thread never misses the timeout. - if (delay < tickDuration) { - delay = tickDuration; - } - - // Prepare the required parameters to schedule the timeout object. - final long lastRoundDelay = delay % roundDuration; - final long lastTickDelay = delay % tickDuration; - final long relativeIndex = - lastRoundDelay / tickDuration + (lastTickDelay != 0 ? 1 : 0); - - final long remainingRounds = - delay / roundDuration - (delay % roundDuration == 0 ? 1 : 0); - - // Add the timeout to the wheel. - lock.readLock().lock(); - try { - int stopIndex = (int) (wheelCursor + relativeIndex & mask); - timeout.stopIndex = stopIndex; - timeout.remainingRounds = remainingRounds; - - wheel[stopIndex].add(timeout); - } finally { - lock.readLock().unlock(); - } - } - - private final class Worker implements Runnable { - - private long startTime; - private long tick; - - Worker() { - super(); - } - - @Override - public void run() { - List expiredTimeouts = - new ArrayList(); - - startTime = System.currentTimeMillis(); - tick = 1; - - while (!shutdown.get()) { - final long deadline = waitForNextTick(); - if (deadline > 0) { - fetchExpiredTimeouts(expiredTimeouts, deadline); - notifyExpiredTimeouts(expiredTimeouts); - } - } - } - - private void fetchExpiredTimeouts( - List expiredTimeouts, long deadline) { - - // Find the expired timeouts and decrease the round counter - // if necessary. Note that we don't send the notification - // immediately to make sure the listeners are called without - // an exclusive lock. - lock.writeLock().lock(); - try { - int newWheelCursor = wheelCursor = wheelCursor + 1 & mask; - ReusableIterator i = iterators[newWheelCursor]; - fetchExpiredTimeouts(expiredTimeouts, i, deadline); - } finally { - lock.writeLock().unlock(); - } - } - - private void fetchExpiredTimeouts( - List expiredTimeouts, - ReusableIterator i, long deadline) { - - List slipped = null; - i.rewind(); - while (i.hasNext()) { - HashedWheelTimeout timeout = i.next(); - if (timeout.remainingRounds <= 0) { - i.remove(); - if (timeout.deadline <= deadline) { - expiredTimeouts.add(timeout); - } else { - // Handle the case where the timeout is put into a wrong - // place, usually one tick earlier. For now, just add - // it to a temporary list - we will reschedule it in a - // separate loop. - if (slipped == null) { - slipped = new ArrayList(); - } - slipped.add(timeout); - } - } else { - timeout.remainingRounds--; - } - } - - // Reschedule the slipped timeouts. - if (slipped != null) { - for (HashedWheelTimeout timeout : slipped) { - scheduleTimeout(timeout, timeout.deadline - deadline); - } - } - } - - private void notifyExpiredTimeouts( - List expiredTimeouts) { - // Notify the expired timeouts. - for (int i = expiredTimeouts.size() - 1; i >= 0; i--) { - expiredTimeouts.get(i).expire(); - } - - // Clean up the temporary list. - expiredTimeouts.clear(); - } - - private long waitForNextTick() { - long deadline = startTime + tickDuration * tick; - - for (; ;) { - final long currentTime = System.currentTimeMillis(); - final long sleepTime = tickDuration * tick - (currentTime - startTime); - - if (sleepTime <= 0) { - break; - } - - try { - Thread.sleep(sleepTime); - } catch (InterruptedException e) { - if (shutdown.get()) { - return -1; - } - } - } - - // Increase the tick. - tick++; - return deadline; - } - } - - private final class HashedWheelTimeout implements Timeout { - - private final TimerTask task; - final long deadline; - volatile int stopIndex; - volatile long remainingRounds; - private volatile boolean cancelled; - - HashedWheelTimeout(TimerTask task, long deadline) { - this.task = task; - this.deadline = deadline; - } - - @Override - public Timer getTimer() { - return HashedWheelTimer.this; - } - - @Override - public TimerTask getTask() { - return task; - } - - @Override - public void cancel() { - if (isExpired()) { - return; - } - - cancelled = true; - - // Might be called more than once, but doesn't matter. - wheel[stopIndex].remove(this); - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @Override - public boolean isExpired() { - return cancelled || System.currentTimeMillis() > deadline; - } - - public void expire() { - if (cancelled) { - return; - } - - try { - task.run(this); - } catch (Throwable t) { - logger.warn( - "An exception was thrown by " + - TimerTask.class.getSimpleName() + ".", t); - } - } - - @Override - public String toString() { - long currentTime = System.currentTimeMillis(); - long remaining = deadline - currentTime; - - StringBuilder buf = new StringBuilder(192); - buf.append(getClass().getSimpleName()); - buf.append('('); - - buf.append("deadline: "); - if (remaining > 0) { - buf.append(remaining); - buf.append(" ms later, "); - } else if (remaining < 0) { - buf.append(-remaining); - buf.append(" ms ago, "); - } else { - buf.append("now, "); - } - - if (isCancelled()) { - buf.append(", cancelled"); - } - - return buf.append(')').toString(); - } - } -} diff --git a/src/main/java/org/elasticsearch/common/timer/Timeout.java b/src/main/java/org/elasticsearch/common/timer/Timeout.java deleted file mode 100644 index 7157cbd207d..00000000000 --- a/src/main/java/org/elasticsearch/common/timer/Timeout.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to Elastic Search 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 - * file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.common.timer; - -/** - * A handle associated with a {@link TimerTask} that is returned by a - * {@link Timer}. - * - * @author kimchy (Shay Banon) - */ -public interface Timeout { - - /** - * Returns the {@link Timer} that created this handle. - */ - Timer getTimer(); - - /** - * Returns the {@link TimerTask} which is associated with this handle. - */ - TimerTask getTask(); - - /** - * Returns {@code true} if and only if the {@link TimerTask} associated - * with this handle has been expired. - */ - boolean isExpired(); - - /** - * Returns {@code true} if and only if the {@link TimerTask} associated - * with this handle has been cancelled. - */ - boolean isCancelled(); - - /** - * Cancels the {@link TimerTask} associated with this handle. It the - * task has been executed or cancelled already, it will return with no - * side effect. - */ - void cancel(); -} diff --git a/src/main/java/org/elasticsearch/common/timer/Timer.java b/src/main/java/org/elasticsearch/common/timer/Timer.java deleted file mode 100644 index 300c084d9c2..00000000000 --- a/src/main/java/org/elasticsearch/common/timer/Timer.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to Elastic Search 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 - * file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.common.timer; - -import java.util.Set; -import java.util.concurrent.TimeUnit; - -/** - * Schedules {@link TimerTask}s for one-time future execution in a background - * thread. - * - * @author kimchy (Shay Banon) - */ -public interface Timer { - - /** - * Schedules the specified {@link TimerTask} for one-time execution after - * the specified delay. - * - * @return a handle which is associated with the specified task - * @throws IllegalStateException if this timer has been - * {@linkplain #stop() stopped} already - */ - Timeout newTimeout(TimerTask task, long delay, TimeUnit unit); - - /** - * Releases all resources acquired by this {@link Timer} and cancels all - * tasks which were scheduled but not executed yet. - * - * @return the handles associated with the tasks which were canceled by - * this method - */ - Set stop(); -} diff --git a/src/main/java/org/elasticsearch/common/timer/TimerTask.java b/src/main/java/org/elasticsearch/common/timer/TimerTask.java deleted file mode 100644 index 6baaf5944fe..00000000000 --- a/src/main/java/org/elasticsearch/common/timer/TimerTask.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to Elastic Search 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 - * file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.common.timer; - -/** - * A task which is executed after the delay specified with - * {@link Timer#newTimeout(TimerTask, long, java.util.concurrent.TimeUnit)}. - * - * @author kimchy (shay.banon) - */ -public interface TimerTask { - - /** - * Executed after the delay specified with - * {@link Timer#newTimeout(TimerTask, long, java.util.concurrent.TimeUnit)}. - * - * @param timeout a handle which is associated with this task - */ - void run(Timeout timeout) throws Exception; -} diff --git a/src/main/java/org/elasticsearch/common/transport/BoundTransportAddress.java b/src/main/java/org/elasticsearch/common/transport/BoundTransportAddress.java index 5ae75ca3509..7f5be765bca 100644 --- a/src/main/java/org/elasticsearch/common/transport/BoundTransportAddress.java +++ b/src/main/java/org/elasticsearch/common/transport/BoundTransportAddress.java @@ -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.io.IOException; * the address the transport is bounded on, the the published one represents the one clients should * communicate on. * - * @author kimchy (shay.banon) + * */ public class BoundTransportAddress implements Streamable { @@ -60,17 +60,20 @@ public class BoundTransportAddress implements Streamable { return addr; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { boundAddress = TransportAddressSerializers.addressFromStream(in); publishAddress = TransportAddressSerializers.addressFromStream(in); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { TransportAddressSerializers.addressToStream(out, boundAddress); TransportAddressSerializers.addressToStream(out, publishAddress); } - @Override public String toString() { + @Override + public String toString() { return "bound_address {" + boundAddress + "}, publish_address {" + publishAddress + "}"; } } diff --git a/src/main/java/org/elasticsearch/common/transport/DummyTransportAddress.java b/src/main/java/org/elasticsearch/common/transport/DummyTransportAddress.java index c5e78b55d6d..906168a3391 100644 --- a/src/main/java/org/elasticsearch/common/transport/DummyTransportAddress.java +++ b/src/main/java/org/elasticsearch/common/transport/DummyTransportAddress.java @@ -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.common.io.stream.StreamOutput; import java.io.IOException; /** - * @author kimchy (Shay Banon) + * */ public class DummyTransportAddress implements TransportAddress { @@ -34,17 +34,21 @@ public class DummyTransportAddress implements TransportAddress { DummyTransportAddress() { } - @Override public short uniqueAddressTypeId() { + @Override + public short uniqueAddressTypeId() { return 0; } - @Override public boolean match(String otherAddress) { + @Override + public boolean match(String otherAddress) { return false; } - @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 { } } diff --git a/src/main/java/org/elasticsearch/common/transport/InetSocketTransportAddress.java b/src/main/java/org/elasticsearch/common/transport/InetSocketTransportAddress.java index 0f65c0b38df..0e39b61e397 100644 --- a/src/main/java/org/elasticsearch/common/transport/InetSocketTransportAddress.java +++ b/src/main/java/org/elasticsearch/common/transport/InetSocketTransportAddress.java @@ -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,7 +31,7 @@ import java.net.InetSocketAddress; /** * A transport address used for IP socket address (wraps {@link java.net.InetSocketAddress}). * - * @author kimchy (shay.banon) + * */ public class InetSocketTransportAddress implements TransportAddress { @@ -59,11 +59,13 @@ public class InetSocketTransportAddress implements TransportAddress { return address; } - @Override public short uniqueAddressTypeId() { + @Override + public short uniqueAddressTypeId() { return 1; } - @Override public boolean match(String otherAddress) { + @Override + public boolean match(String otherAddress) { if (address.getHostName() != null && Regex.simpleMatch(otherAddress, address.getHostName())) { return true; } @@ -82,7 +84,8 @@ public class InetSocketTransportAddress implements TransportAddress { return this.address; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { if (in.readByte() == 0) { int len = in.readByte(); byte[] a = new byte[len]; // 4 bytes (IPv4) or 16 bytes (IPv6) @@ -101,7 +104,8 @@ public class InetSocketTransportAddress implements TransportAddress { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { if (address.getAddress() != null) { out.writeByte((byte) 0); byte[] bytes = address().getAddress().getAddress(); // 4 bytes (IPv4) or 16 bytes (IPv6) @@ -129,7 +133,8 @@ public class InetSocketTransportAddress implements TransportAddress { return address != null ? address.hashCode() : 0; } - @Override public String toString() { + @Override + public String toString() { return "inet[" + address + "]"; } } diff --git a/src/main/java/org/elasticsearch/common/transport/LocalTransportAddress.java b/src/main/java/org/elasticsearch/common/transport/LocalTransportAddress.java index 16107a6d0fd..421f7db42d4 100644 --- a/src/main/java/org/elasticsearch/common/transport/LocalTransportAddress.java +++ b/src/main/java/org/elasticsearch/common/transport/LocalTransportAddress.java @@ -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.common.io.stream.StreamOutput; import java.io.IOException; /** - * @author kimchy (Shay Banon) + * */ public class LocalTransportAddress implements TransportAddress { @@ -42,23 +42,28 @@ public class LocalTransportAddress implements TransportAddress { return this.id; } - @Override public short uniqueAddressTypeId() { + @Override + public short uniqueAddressTypeId() { return 2; } - @Override public boolean match(String otherAddress) { + @Override + public boolean match(String otherAddress) { return id.equals(otherAddress); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { id = in.readUTF(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(id); } - @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; @@ -69,11 +74,13 @@ public class LocalTransportAddress implements TransportAddress { return true; } - @Override public int hashCode() { + @Override + public int hashCode() { return id != null ? id.hashCode() : 0; } - @Override public String toString() { + @Override + public String toString() { return "local[" + id + "]"; } } diff --git a/src/main/java/org/elasticsearch/common/transport/NetworkExceptionHelper.java b/src/main/java/org/elasticsearch/common/transport/NetworkExceptionHelper.java index 283df64487a..d86d7b3b299 100644 --- a/src/main/java/org/elasticsearch/common/transport/NetworkExceptionHelper.java +++ b/src/main/java/org/elasticsearch/common/transport/NetworkExceptionHelper.java @@ -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 java.net.ConnectException; import java.nio.channels.ClosedChannelException; /** - * @author kimchy (Shay Banon) + * */ public class NetworkExceptionHelper { diff --git a/src/main/java/org/elasticsearch/common/transport/PortsRange.java b/src/main/java/org/elasticsearch/common/transport/PortsRange.java index 24d02901891..13e9670f4aa 100644 --- a/src/main/java/org/elasticsearch/common/transport/PortsRange.java +++ b/src/main/java/org/elasticsearch/common/transport/PortsRange.java @@ -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.elasticsearch.common.transport; -import org.elasticsearch.common.trove.list.array.TIntArrayList; +import gnu.trove.list.array.TIntArrayList; import java.util.StringTokenizer; /** - * @author kimchy (Shay Banon) + * */ public class PortsRange { @@ -37,7 +37,8 @@ public class PortsRange { public int[] ports() throws NumberFormatException { final TIntArrayList ports = new TIntArrayList(); iterate(new PortCallback() { - @Override public boolean onPortNumber(int portNumber) { + @Override + public boolean onPortNumber(int portNumber) { ports.add(portNumber); return false; } diff --git a/src/main/java/org/elasticsearch/common/transport/TransportAddress.java b/src/main/java/org/elasticsearch/common/transport/TransportAddress.java index b5249563dff..0e78fe2903c 100644 --- a/src/main/java/org/elasticsearch/common/transport/TransportAddress.java +++ b/src/main/java/org/elasticsearch/common/transport/TransportAddress.java @@ -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.common.io.stream.Streamable; import java.io.Serializable; /** - * @author kimchy (shay.banon) + * */ public interface TransportAddress extends Streamable, Serializable { diff --git a/src/main/java/org/elasticsearch/common/transport/TransportAddressSerializers.java b/src/main/java/org/elasticsearch/common/transport/TransportAddressSerializers.java index 38d24288151..b1ff34d34db 100644 --- a/src/main/java/org/elasticsearch/common/transport/TransportAddressSerializers.java +++ b/src/main/java/org/elasticsearch/common/transport/TransportAddressSerializers.java @@ -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.common.transport; +import com.google.common.collect.ImmutableMap; import org.elasticsearch.ElasticSearchIllegalStateException; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.logging.ESLogger; @@ -29,15 +29,15 @@ import org.elasticsearch.common.logging.Loggers; import java.io.IOException; import java.lang.reflect.Constructor; -import static org.elasticsearch.common.collect.MapBuilder.*; +import static org.elasticsearch.common.collect.MapBuilder.newMapBuilder; /** * A global registry of all different types of {@link org.elasticsearch.common.transport.TransportAddress} allowing * to perform serialization of them. - * + *

    *

    By default, adds {@link org.elasticsearch.common.transport.InetSocketTransportAddress}. * - * @author kimchy (Shay Banon) + * */ public abstract class TransportAddressSerializers { diff --git a/src/main/java/org/elasticsearch/common/trove/ExtTDoubleObjectHashMap.java b/src/main/java/org/elasticsearch/common/trove/ExtTDoubleObjectHashMap.java index 9607021e950..bbf13f3881e 100644 --- a/src/main/java/org/elasticsearch/common/trove/ExtTDoubleObjectHashMap.java +++ b/src/main/java/org/elasticsearch/common/trove/ExtTDoubleObjectHashMap.java @@ -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 @@ -17,10 +17,10 @@ * under the License. */ -package org.elasticsearch.common.trove; +package gnu.trove; -import org.elasticsearch.common.trove.map.TDoubleObjectMap; -import org.elasticsearch.common.trove.map.hash.TDoubleObjectHashMap; +import gnu.trove.map.TDoubleObjectMap; +import gnu.trove.map.hash.TDoubleObjectHashMap; public class ExtTDoubleObjectHashMap extends TDoubleObjectHashMap { diff --git a/src/main/java/org/elasticsearch/common/trove/ExtTHashMap.java b/src/main/java/org/elasticsearch/common/trove/ExtTHashMap.java index 370e3a11c89..55a2746eba5 100644 --- a/src/main/java/org/elasticsearch/common/trove/ExtTHashMap.java +++ b/src/main/java/org/elasticsearch/common/trove/ExtTHashMap.java @@ -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 @@ -17,9 +17,9 @@ * under the License. */ -package org.elasticsearch.common.trove; +package gnu.trove; -import org.elasticsearch.common.trove.map.hash.THashMap; +import gnu.trove.map.hash.THashMap; import java.util.Map; diff --git a/src/main/java/org/elasticsearch/common/trove/ExtTIntArrayList.java b/src/main/java/org/elasticsearch/common/trove/ExtTIntArrayList.java index 60be49a07c9..6e3a6061b2c 100644 --- a/src/main/java/org/elasticsearch/common/trove/ExtTIntArrayList.java +++ b/src/main/java/org/elasticsearch/common/trove/ExtTIntArrayList.java @@ -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 @@ -17,12 +17,12 @@ * under the License. */ -package org.elasticsearch.common.trove; +package gnu.trove; -import org.elasticsearch.common.trove.list.array.TIntArrayList; +import gnu.trove.list.array.TIntArrayList; /** - * @author kimchy (Shay Banon) + * */ public class ExtTIntArrayList extends TIntArrayList { diff --git a/src/main/java/org/elasticsearch/common/trove/ExtTLongObjectHashMap.java b/src/main/java/org/elasticsearch/common/trove/ExtTLongObjectHashMap.java index 160ee1a9d17..d95954ea19d 100644 --- a/src/main/java/org/elasticsearch/common/trove/ExtTLongObjectHashMap.java +++ b/src/main/java/org/elasticsearch/common/trove/ExtTLongObjectHashMap.java @@ -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 @@ -17,10 +17,10 @@ * under the License. */ -package org.elasticsearch.common.trove; +package gnu.trove; -import org.elasticsearch.common.trove.map.TLongObjectMap; -import org.elasticsearch.common.trove.map.hash.TLongObjectHashMap; +import gnu.trove.map.TLongObjectMap; +import gnu.trove.map.hash.TLongObjectHashMap; public class ExtTLongObjectHashMap extends TLongObjectHashMap { diff --git a/src/main/java/org/elasticsearch/common/trove/ExtTObjectIntHasMap.java b/src/main/java/org/elasticsearch/common/trove/ExtTObjectIntHasMap.java index 911c347939f..7b00aff7d31 100644 --- a/src/main/java/org/elasticsearch/common/trove/ExtTObjectIntHasMap.java +++ b/src/main/java/org/elasticsearch/common/trove/ExtTObjectIntHasMap.java @@ -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 @@ -17,12 +17,12 @@ * under the License. */ -package org.elasticsearch.common.trove; +package gnu.trove; -import org.elasticsearch.common.trove.map.hash.TObjectIntHashMap; +import gnu.trove.map.hash.TObjectIntHashMap; /** - * @author kimchy (Shay Banon) + * */ public class ExtTObjectIntHasMap extends TObjectIntHashMap { diff --git a/src/main/java/org/elasticsearch/common/trove/StringIdentityHashingStrategy.java b/src/main/java/org/elasticsearch/common/trove/StringIdentityHashingStrategy.java index bb52e4a9465..da6e57bf71f 100644 --- a/src/main/java/org/elasticsearch/common/trove/StringIdentityHashingStrategy.java +++ b/src/main/java/org/elasticsearch/common/trove/StringIdentityHashingStrategy.java @@ -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 @@ -17,9 +17,9 @@ * under the License. */ -package org.elasticsearch.common.trove; +package gnu.trove; -import org.elasticsearch.common.trove.strategy.HashingStrategy; +import gnu.trove.strategy.HashingStrategy; /** * A string based hash code with identity equality. @@ -32,7 +32,8 @@ public class StringIdentityHashingStrategy implements HashingStrategy { return object.hashCode(); } - @SuppressWarnings({"StringEquality"}) public boolean equals(String o1, String o2) { + @SuppressWarnings({"StringEquality"}) + public boolean equals(String o1, String o2) { return o1 == o2; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/common/unit/ByteSizeUnit.java b/src/main/java/org/elasticsearch/common/unit/ByteSizeUnit.java index 185ac85b803..e0254a5e3d5 100644 --- a/src/main/java/org/elasticsearch/common/unit/ByteSizeUnit.java +++ b/src/main/java/org/elasticsearch/common/unit/ByteSizeUnit.java @@ -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,49 +26,93 @@ package org.elasticsearch.common.unit; * helps organize and use size representations that may be maintained * separately across various contexts. * - * @author kimchy (Shay Banon) + * */ public enum ByteSizeUnit { BYTES { - @Override public long toBytes(long size) { + @Override + public long toBytes(long size) { return size; - }@Override public long toKB(long size) { + } + + @Override + public long toKB(long size) { return size / (C1 / C0); - }@Override public long toMB(long size) { + } + + @Override + public long toMB(long size) { return size / (C2 / C0); - }@Override public long toGB(long size) { + } + + @Override + public long toGB(long size) { return size / (C3 / C0); - }}, + } + }, KB { - @Override public long toBytes(long size) { + @Override + public long toBytes(long size) { return x(size, C1 / C0, MAX / (C1 / C0)); - }@Override public long toKB(long size) { + } + + @Override + public long toKB(long size) { return size; - }@Override public long toMB(long size) { + } + + @Override + public long toMB(long size) { return size / (C2 / C1); - }@Override public long toGB(long size) { + } + + @Override + public long toGB(long size) { return size / (C3 / C1); - }}, + } + }, MB { - @Override public long toBytes(long size) { + @Override + public long toBytes(long size) { return x(size, C2 / C0, MAX / (C2 / C0)); - }@Override public long toKB(long size) { + } + + @Override + public long toKB(long size) { return x(size, C2 / C1, MAX / (C2 / C1)); - }@Override public long toMB(long size) { + } + + @Override + public long toMB(long size) { return size; - }@Override public long toGB(long size) { + } + + @Override + public long toGB(long size) { return size / (C3 / C2); - }}, + } + }, GB { - @Override public long toBytes(long size) { + @Override + public long toBytes(long size) { return x(size, C3 / C0, MAX / (C3 / C0)); - }@Override public long toKB(long size) { + } + + @Override + public long toKB(long size) { return x(size, C3 / C1, MAX / (C3 / C1)); - }@Override public long toMB(long size) { + } + + @Override + public long toMB(long size) { return x(size, C3 / C2, MAX / (C3 / C2)); - }@Override public long toGB(long size) { + } + + @Override + public long toGB(long size) { return size; - }}; + } + }; static final long C0 = 1L; static final long C1 = C0 * 1024L; diff --git a/src/main/java/org/elasticsearch/common/unit/ByteSizeValue.java b/src/main/java/org/elasticsearch/common/unit/ByteSizeValue.java index 842adfb3f9d..1876482e2d9 100644 --- a/src/main/java/org/elasticsearch/common/unit/ByteSizeValue.java +++ b/src/main/java/org/elasticsearch/common/unit/ByteSizeValue.java @@ -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.io.IOException; import java.io.Serializable; /** - * @author kimchy (shay.banon) + * */ public class ByteSizeValue implements Serializable, Streamable { @@ -106,7 +106,8 @@ public class ByteSizeValue implements Serializable, Streamable { return gbFrac(); } - @Override public String toString() { + @Override + public String toString() { long bytes = bytes(); double value = bytes; String suffix = "b"; @@ -162,16 +163,19 @@ public class ByteSizeValue implements Serializable, Streamable { return sizeValue; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { size = in.readVLong(); sizeUnit = ByteSizeUnit.BYTES; } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeVLong(bytes()); } - @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; @@ -183,7 +187,8 @@ public class ByteSizeValue implements Serializable, Streamable { return true; } - @Override public int hashCode() { + @Override + public int hashCode() { int result = (int) (size ^ (size >>> 32)); result = 31 * result + (sizeUnit != null ? sizeUnit.hashCode() : 0); return result; diff --git a/src/main/java/org/elasticsearch/common/unit/DistanceUnit.java b/src/main/java/org/elasticsearch/common/unit/DistanceUnit.java index 818a5be639a..e9558c70ca7 100644 --- a/src/main/java/org/elasticsearch/common/unit/DistanceUnit.java +++ b/src/main/java/org/elasticsearch/common/unit/DistanceUnit.java @@ -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,40 +26,48 @@ import org.elasticsearch.common.io.stream.StreamOutput; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public enum DistanceUnit { MILES(3959, 24902) { - @Override public String toString() { + @Override + public String toString() { return "miles"; } - @Override public double toMiles(double distance) { + @Override + public double toMiles(double distance) { return distance; } - @Override public double toKilometers(double distance) { + @Override + public double toKilometers(double distance) { return distance * MILES_KILOMETRES_RATIO; } - @Override public String toString(double distance) { + @Override + public String toString(double distance) { return distance + "mi"; } }, KILOMETERS(6371, 40076) { - @Override public String toString() { + @Override + public String toString() { return "km"; } - @Override public double toMiles(double distance) { + @Override + public double toMiles(double distance) { return distance / MILES_KILOMETRES_RATIO; } - @Override public double toKilometers(double distance) { + @Override + public double toKilometers(double distance) { return distance; } - @Override public String toString(double distance) { + @Override + public String toString(double distance) { return distance + "km"; } }; diff --git a/src/main/java/org/elasticsearch/common/unit/Percent.java b/src/main/java/org/elasticsearch/common/unit/Percent.java index d3a3487b1e1..9425ba38fd6 100644 --- a/src/main/java/org/elasticsearch/common/unit/Percent.java +++ b/src/main/java/org/elasticsearch/common/unit/Percent.java @@ -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 java.io.IOException; import java.io.Serializable; /** - * @author kimchy (shay.banon) + * */ public class Percent implements Streamable, Serializable { @@ -51,11 +51,13 @@ public class Percent implements Streamable, Serializable { return p.substring(0, ix) + p.substring(ix, ix + 1) + "%"; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { value = in.readDouble(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeDouble(value); } } diff --git a/src/main/java/org/elasticsearch/common/unit/SizeUnit.java b/src/main/java/org/elasticsearch/common/unit/SizeUnit.java index 7a5071407bb..48221fbc55e 100644 --- a/src/main/java/org/elasticsearch/common/unit/SizeUnit.java +++ b/src/main/java/org/elasticsearch/common/unit/SizeUnit.java @@ -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,49 +20,93 @@ package org.elasticsearch.common.unit; /** - * @author kimchy (shay.banon) + * */ public enum SizeUnit { SINGLE { - @Override public long toSingles(long size) { + @Override + public long toSingles(long size) { return size; - }@Override public long toKilo(long size) { + } + + @Override + public long toKilo(long size) { return size / (C1 / C0); - }@Override public long toMega(long size) { + } + + @Override + public long toMega(long size) { return size / (C2 / C0); - }@Override public long toGiga(long size) { + } + + @Override + public long toGiga(long size) { return size / (C3 / C0); - }}, + } + }, KILO { - @Override public long toSingles(long size) { + @Override + public long toSingles(long size) { return x(size, C1 / C0, MAX / (C1 / C0)); - }@Override public long toKilo(long size) { + } + + @Override + public long toKilo(long size) { return size; - }@Override public long toMega(long size) { + } + + @Override + public long toMega(long size) { return size / (C2 / C1); - }@Override public long toGiga(long size) { + } + + @Override + public long toGiga(long size) { return size / (C3 / C1); - }}, + } + }, MEGA { - @Override public long toSingles(long size) { + @Override + public long toSingles(long size) { return x(size, C2 / C0, MAX / (C2 / C0)); - }@Override public long toKilo(long size) { + } + + @Override + public long toKilo(long size) { return x(size, C2 / C1, MAX / (C2 / C1)); - }@Override public long toMega(long size) { + } + + @Override + public long toMega(long size) { return size; - }@Override public long toGiga(long size) { + } + + @Override + public long toGiga(long size) { return size / (C3 / C2); - }}, + } + }, GIGA { - @Override public long toSingles(long size) { + @Override + public long toSingles(long size) { return x(size, C3 / C0, MAX / (C3 / C0)); - }@Override public long toKilo(long size) { + } + + @Override + public long toKilo(long size) { return x(size, C3 / C1, MAX / (C3 / C1)); - }@Override public long toMega(long size) { + } + + @Override + public long toMega(long size) { return x(size, C3 / C2, MAX / (C3 / C2)); - }@Override public long toGiga(long size) { + } + + @Override + public long toGiga(long size) { return size; - }}; + } + }; static final long C0 = 1L; static final long C1 = C0 * 1000L; diff --git a/src/main/java/org/elasticsearch/common/unit/SizeValue.java b/src/main/java/org/elasticsearch/common/unit/SizeValue.java index 6b133fca448..4430dc53250 100644 --- a/src/main/java/org/elasticsearch/common/unit/SizeValue.java +++ b/src/main/java/org/elasticsearch/common/unit/SizeValue.java @@ -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.io.IOException; import java.io.Serializable; /** - * @author kimchy (shay.banon) + * */ public class SizeValue implements Serializable, Streamable { @@ -106,7 +106,8 @@ public class SizeValue implements Serializable, Streamable { return gigaFrac(); } - @Override public String toString() { + @Override + public String toString() { long singles = singles(); double value = singles; String suffix = ""; @@ -156,16 +157,19 @@ public class SizeValue implements Serializable, Streamable { return sizeValue; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { size = in.readVLong(); sizeUnit = SizeUnit.SINGLE; } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeVLong(singles()); } - @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; @@ -177,7 +181,8 @@ public class SizeValue implements Serializable, Streamable { return true; } - @Override public int hashCode() { + @Override + public int hashCode() { int result = (int) (size ^ (size >>> 32)); result = 31 * result + (sizeUnit != null ? sizeUnit.hashCode() : 0); return result; diff --git a/src/main/java/org/elasticsearch/common/unit/TimeValue.java b/src/main/java/org/elasticsearch/common/unit/TimeValue.java index d1867dd878e..ab6745e1372 100644 --- a/src/main/java/org/elasticsearch/common/unit/TimeValue.java +++ b/src/main/java/org/elasticsearch/common/unit/TimeValue.java @@ -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,17 +24,17 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Streamable; -import org.elasticsearch.common.joda.time.Period; -import org.elasticsearch.common.joda.time.PeriodType; -import org.elasticsearch.common.joda.time.format.PeriodFormat; -import org.elasticsearch.common.joda.time.format.PeriodFormatter; +import org.joda.time.Period; +import org.joda.time.PeriodType; +import org.joda.time.format.PeriodFormat; +import org.joda.time.format.PeriodFormatter; import java.io.IOException; import java.io.Serializable; import java.util.concurrent.TimeUnit; /** - * @author kimchy (shay.banon) + * */ public class TimeValue implements Serializable, Streamable { @@ -192,7 +192,8 @@ public class TimeValue implements Serializable, Streamable { return PeriodFormat.getDefault().withParseType(type).print(period); } - @Override public String toString() { + @Override + public String toString() { if (duration < 0) { return Long.toString(duration); } @@ -267,16 +268,19 @@ public class TimeValue implements Serializable, Streamable { return timeValue; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { duration = in.readLong(); timeUnit = TimeUnit.NANOSECONDS; } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeLong(nanos()); } - @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; @@ -288,7 +292,8 @@ public class TimeValue implements Serializable, Streamable { return true; } - @Override public int hashCode() { + @Override + public int hashCode() { int result = (int) (duration ^ (duration >>> 32)); result = 31 * result + (timeUnit != null ? timeUnit.hashCode() : 0); return result; diff --git a/src/main/java/org/elasticsearch/common/util/concurrent/ConcurrentCollections.java b/src/main/java/org/elasticsearch/common/util/concurrent/ConcurrentCollections.java index 6a19067b313..31021421376 100644 --- a/src/main/java/org/elasticsearch/common/util/concurrent/ConcurrentCollections.java +++ b/src/main/java/org/elasticsearch/common/util/concurrent/ConcurrentCollections.java @@ -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.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; /** - * @author kimchy (shay.banon) + * */ public abstract class ConcurrentCollections { diff --git a/src/main/java/org/elasticsearch/common/util/concurrent/ConcurrentHashMapLong.java b/src/main/java/org/elasticsearch/common/util/concurrent/ConcurrentHashMapLong.java index a81f6c8ecc1..81cf4c57fe6 100644 --- a/src/main/java/org/elasticsearch/common/util/concurrent/ConcurrentHashMapLong.java +++ b/src/main/java/org/elasticsearch/common/util/concurrent/ConcurrentHashMapLong.java @@ -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.util.Set; import java.util.concurrent.ConcurrentHashMap; /** - * @author kimchy (shay.banon) + * */ public class ConcurrentHashMapLong implements ConcurrentMapLong { @@ -36,41 +36,50 @@ public class ConcurrentHashMapLong implements ConcurrentMapLong { this.map = new ConcurrentHashMap(); } - @Override public T get(long key) { + @Override + public T get(long key) { return map.get(key); } - @Override public T remove(long key) { + @Override + public T remove(long key) { return map.remove(key); } - @Override public T put(long key, T value) { + @Override + public T put(long key, T value) { return map.put(key, value); } - @Override public T putIfAbsent(long key, T value) { + @Override + public T putIfAbsent(long key, T value) { return map.putIfAbsent(key, value); } // MAP DELEGATION - @Override public boolean isEmpty() { + @Override + public boolean isEmpty() { return map.isEmpty(); } - @Override public int size() { + @Override + public int size() { return map.size(); } - @Override public T get(Object key) { + @Override + public T get(Object key) { return map.get(key); } - @Override public boolean containsKey(Object key) { + @Override + public boolean containsKey(Object key) { return map.containsKey(key); } - @Override public boolean containsValue(Object value) { + @Override + public boolean containsValue(Object value) { return map.containsValue(value); } @@ -90,11 +99,13 @@ public class ConcurrentHashMapLong implements ConcurrentMapLong { map.putAll(m); } - @Override public T remove(Object key) { + @Override + public T remove(Object key) { return map.remove(key); } - @Override public boolean remove(Object key, Object value) { + @Override + public boolean remove(Object key, Object value) { return map.remove(key, value); } @@ -106,19 +117,23 @@ public class ConcurrentHashMapLong implements ConcurrentMapLong { return map.replace(key, value); } - @Override public void clear() { + @Override + public void clear() { map.clear(); } - @Override public Set keySet() { + @Override + public Set keySet() { return map.keySet(); } - @Override public Collection values() { + @Override + public Collection values() { return map.values(); } - @Override public Set> entrySet() { + @Override + public Set> entrySet() { return map.entrySet(); } @@ -130,15 +145,18 @@ public class ConcurrentHashMapLong implements ConcurrentMapLong { return map.elements(); } - @Override public boolean equals(Object o) { + @Override + public boolean equals(Object o) { return map.equals(o); } - @Override public int hashCode() { + @Override + public int hashCode() { return map.hashCode(); } - @Override public String toString() { + @Override + public String toString() { return map.toString(); } } diff --git a/src/main/java/org/elasticsearch/common/util/concurrent/ConcurrentIdentityHashMap.java b/src/main/java/org/elasticsearch/common/util/concurrent/ConcurrentIdentityHashMap.java deleted file mode 100644 index d551669d8cd..00000000000 --- a/src/main/java/org/elasticsearch/common/util/concurrent/ConcurrentIdentityHashMap.java +++ /dev/null @@ -1,1405 +0,0 @@ -/* - * Licensed to Elastic Search 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 - * file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.common.util.concurrent; - -import org.elasticsearch.common.collect.ReusableIterator; - -import java.util.*; -import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.locks.ReentrantLock; - -/** - * An alternative identity-comparing {@link ConcurrentMap} which is similar to - * {@link java.util.concurrent.ConcurrentHashMap}. - * - * @author Doug Lea - * @author kimchy (shay.banon) - */ -public final class ConcurrentIdentityHashMap extends AbstractMap - implements ConcurrentMap { - - /** - * The default initial capacity for this table, used when not otherwise - * specified in a constructor. - */ - static final int DEFAULT_INITIAL_CAPACITY = 16; - - /** - * The default load factor for this table, used when not otherwise specified - * in a constructor. - */ - static final float DEFAULT_LOAD_FACTOR = 0.75f; - - /** - * The default concurrency level for this table, used when not otherwise - * specified in a constructor. - */ - static final int DEFAULT_CONCURRENCY_LEVEL = 16; - - /** - * The maximum capacity, used if a higher value is implicitly specified by - * either of the constructors with arguments. MUST be a power of two - * <= 1<<30 to ensure that entries are indexable using integers. - */ - static final int MAXIMUM_CAPACITY = 1 << 30; - - /** - * The maximum number of segments to allow; used to bound constructor - * arguments. - */ - static final int MAX_SEGMENTS = 1 << 16; // slightly conservative - - /** - * Number of unsynchronized retries in size and containsValue methods before - * resorting to locking. This is used to avoid unbounded retries if tables - * undergo continuous modification which would make it impossible to obtain - * an accurate result. - */ - static final int RETRIES_BEFORE_LOCK = 2; - - /* ---------------- Fields -------------- */ - - /** - * Mask value for indexing into segments. The upper bits of a key's hash - * code are used to choose the segment. - */ - final int segmentMask; - - /** - * Shift value for indexing within segments. - */ - final int segmentShift; - - /** - * The segments, each of which is a specialized hash table - */ - final Segment[] segments; - - Set keySet; - Set> entrySet; - Collection values; - - /* ---------------- Small Utilities -------------- */ - - /** - * Applies a supplemental hash function to a given hashCode, which defends - * against poor quality hash functions. This is critical because - * ConcurrentReferenceHashMap uses power-of-two length hash tables, that - * otherwise encounter collisions for hashCodes that do not differ in lower - * or upper bits. - */ - private static int hash(int h) { - // Spread bits to regularize both segment and index locations, - // using variant of single-word Wang/Jenkins hash. - h += h << 15 ^ 0xffffcd7d; - h ^= h >>> 10; - h += h << 3; - h ^= h >>> 6; - h += (h << 2) + (h << 14); - return h ^ h >>> 16; - } - - /** - * Returns the segment that should be used for key with given hash. - * - * @param hash the hash code for the key - * @return the segment - */ - final Segment segmentFor(int hash) { - return segments[hash >>> segmentShift & segmentMask]; - } - - private int hashOf(Object key) { - return hash(System.identityHashCode(key)); - } - - /** - * ConcurrentReferenceHashMap list entry. Note that this is never exported - * out as a user-visible Map.Entry. - * - * Because the value field is volatile, not final, it is legal wrt - * the Java Memory Model for an unsynchronized reader to see null - * instead of initial value when read via a data race. Although a - * reordering leading to this is not likely to ever actually - * occur, the Segment.readValueUnderLock method is used as a - * backup in case a null (pre-initialized) value is ever seen in - * an unsynchronized access method. - */ - static final class HashEntry { - final Object key; - final int hash; - volatile Object value; - final HashEntry next; - - HashEntry( - K key, int hash, HashEntry next, V value) { - this.hash = hash; - this.next = next; - this.key = key; - this.value = value; - } - - @SuppressWarnings("unchecked") - final K key() { - return (K) key; - } - - @SuppressWarnings("unchecked") - final V value() { - return (V) value; - } - - final void setValue(V value) { - this.value = value; - } - - @SuppressWarnings("unchecked") - static final HashEntry[] newArray(int i) { - return new HashEntry[i]; - } - } - - /** - * Segments are specialized versions of hash tables. This subclasses from - * ReentrantLock opportunistically, just to simplify some locking and avoid - * separate construction. - */ - static final class Segment extends ReentrantLock { - /* - * Segments maintain a table of entry lists that are ALWAYS kept in a - * consistent state, so can be read without locking. Next fields of - * nodes are immutable (final). All list additions are performed at the - * front of each bin. This makes it easy to check changes, and also fast - * to traverse. When nodes would otherwise be changed, new nodes are - * created to replace them. This works well for hash tables since the - * bin lists tend to be short. (The average length is less than two for - * the default load factor threshold.) - * - * Read operations can thus proceed without locking, but rely on - * selected uses of volatiles to ensure that completed write operations - * performed by other threads are noticed. For most purposes, the - * "count" field, tracking the number of elements, serves as that - * volatile variable ensuring visibility. This is convenient because - * this field needs to be read in many read operations anyway: - * - * - All (unsynchronized) read operations must first read the - * "count" field, and should not look at table entries if - * it is 0. - * - * - All (synchronized) write operations should write to - * the "count" field after structurally changing any bin. - * The operations must not take any action that could even - * momentarily cause a concurrent read operation to see - * inconsistent data. This is made easier by the nature of - * the read operations in Map. For example, no operation - * can reveal that the table has grown but the threshold - * has not yet been updated, so there are no atomicity - * requirements for this with respect to reads. - * - * As a guide, all critical volatile reads and writes to the count field - * are marked in code comments. - */ - - private static final long serialVersionUID = 5207829234977119743L; - - /** - * The number of elements in this segment's region. - */ - transient volatile int count; - - /** - * Number of updates that alter the size of the table. This is used - * during bulk-read methods to make sure they see a consistent snapshot: - * If modCounts change during a traversal of segments computing size or - * checking containsValue, then we might have an inconsistent view of - * state so (usually) must retry. - */ - int modCount; - - /** - * The table is rehashed when its size exceeds this threshold. - * (The value of this field is always (capacity * loadFactor).) - */ - int threshold; - - /** - * The per-segment table. - */ - transient volatile HashEntry[] table; - - /** - * The load factor for the hash table. Even though this value is same - * for all segments, it is replicated to avoid needing links to outer - * object. - * - * @serial - */ - final float loadFactor; - - Segment(int initialCapacity, float lf) { - loadFactor = lf; - setTable(HashEntry.newArray(initialCapacity)); - } - - @SuppressWarnings("unchecked") - static final Segment[] newArray(int i) { - return new Segment[i]; - } - - private boolean keyEq(Object src, Object dest) { - return src == dest; - } - - /** - * Sets table to new HashEntry array. Call only while holding lock or in - * constructor. - */ - void setTable(HashEntry[] newTable) { - threshold = (int) (newTable.length * loadFactor); - table = newTable; - } - - /** - * Returns properly casted first entry of bin for given hash. - */ - HashEntry getFirst(int hash) { - HashEntry[] tab = table; - return tab[hash & tab.length - 1]; - } - - HashEntry newHashEntry( - K key, int hash, HashEntry next, V value) { - return new HashEntry(key, hash, next, value); - } - - /** - * Reads value field of an entry under lock. Called if value field ever - * appears to be null. This is possible only if a compiler happens to - * reorder a HashEntry initialization with its table assignment, which - * is legal under memory model but is not known to ever occur. - */ - V readValueUnderLock(HashEntry e) { - lock(); - try { - return e.value(); - } finally { - unlock(); - } - } - - /* Specialized implementations of map methods */ - - V get(Object key, int hash) { - if (count != 0) { // read-volatile - HashEntry e = getFirst(hash); - while (e != null) { - if (e.hash == hash && keyEq(key, e.key())) { - V opaque = e.value(); - if (opaque != null) { - return opaque; - } - - return readValueUnderLock(e); // recheck - } - e = e.next; - } - } - return null; - } - - boolean containsKey(Object key, int hash) { - if (count != 0) { // read-volatile - HashEntry e = getFirst(hash); - while (e != null) { - if (e.hash == hash && keyEq(key, e.key())) { - return true; - } - e = e.next; - } - } - return false; - } - - boolean containsValue(Object value) { - if (count != 0) { // read-volatile - HashEntry[] tab = table; - int len = tab.length; - for (int i = 0; i < len; i++) { - for (HashEntry e = tab[i]; e != null; e = e.next) { - V opaque = e.value(); - V v; - - if (opaque == null) { - v = readValueUnderLock(e); // recheck - } else { - v = opaque; - } - - if (value.equals(v)) { - return true; - } - } - } - } - return false; - } - - boolean replace(K key, int hash, V oldValue, V newValue) { - lock(); - try { - HashEntry e = getFirst(hash); - while (e != null && (e.hash != hash || !keyEq(key, e.key()))) { - e = e.next; - } - - boolean replaced = false; - if (e != null && oldValue.equals(e.value())) { - replaced = true; - e.setValue(newValue); - } - return replaced; - } finally { - unlock(); - } - } - - V replace(K key, int hash, V newValue) { - lock(); - try { - HashEntry e = getFirst(hash); - while (e != null && (e.hash != hash || !keyEq(key, e.key()))) { - e = e.next; - } - - V oldValue = null; - if (e != null) { - oldValue = e.value(); - e.setValue(newValue); - } - return oldValue; - } finally { - unlock(); - } - } - - V put(K key, int hash, V value, boolean onlyIfAbsent) { - lock(); - try { - int c = count; - if (c++ > threshold) { // ensure capacity - int reduced = rehash(); - if (reduced > 0) { - count = (c -= reduced) - 1; // write-volatile - } - } - - HashEntry[] tab = table; - int index = hash & tab.length - 1; - HashEntry first = tab[index]; - HashEntry e = first; - while (e != null && (e.hash != hash || !keyEq(key, e.key()))) { - e = e.next; - } - - V oldValue; - if (e != null) { - oldValue = e.value(); - if (!onlyIfAbsent) { - e.setValue(value); - } - } else { - oldValue = null; - ++modCount; - tab[index] = newHashEntry(key, hash, first, value); - count = c; // write-volatile - } - return oldValue; - } finally { - unlock(); - } - } - - int rehash() { - HashEntry[] oldTable = table; - int oldCapacity = oldTable.length; - if (oldCapacity >= MAXIMUM_CAPACITY) { - return 0; - } - - /* - * Reclassify nodes in each list to new Map. Because we are using - * power-of-two expansion, the elements from each bin must either - * stay at same index, or move with a power of two offset. We - * eliminate unnecessary node creation by catching cases where old - * nodes can be reused because their next fields won't change. - * Statistically, at the default threshold, only about one-sixth of - * them need cloning when a table doubles. The nodes they replace - * will be garbage collectable as soon as they are no longer - * referenced by any reader thread that may be in the midst of - * traversing table right now. - */ - - HashEntry[] newTable = HashEntry.newArray(oldCapacity << 1); - threshold = (int) (newTable.length * loadFactor); - int sizeMask = newTable.length - 1; - int reduce = 0; - for (int i = 0; i < oldCapacity; i++) { - // We need to guarantee that any existing reads of old Map can - // proceed. So we cannot yet null out each bin. - HashEntry e = oldTable[i]; - - if (e != null) { - HashEntry next = e.next; - int idx = e.hash & sizeMask; - - // Single node on list - if (next == null) { - newTable[idx] = e; - } else { - // Reuse trailing consecutive sequence at same slot - HashEntry lastRun = e; - int lastIdx = idx; - for (HashEntry last = next; last != null; last = last.next) { - int k = last.hash & sizeMask; - if (k != lastIdx) { - lastIdx = k; - lastRun = last; - } - } - newTable[lastIdx] = lastRun; - // Clone all remaining nodes - for (HashEntry p = e; p != lastRun; p = p.next) { - // Skip GC'd weak references - K key = p.key(); - if (key == null) { - reduce++; - continue; - } - int k = p.hash & sizeMask; - HashEntry n = newTable[k]; - newTable[k] = newHashEntry(key, p.hash, n, p.value()); - } - } - } - } - table = newTable; - return reduce; - } - - /** - * Remove; match on key only if value null, else match both. - */ - V remove(Object key, int hash, Object value, boolean refRemove) { - lock(); - try { - int c = count - 1; - HashEntry[] tab = table; - int index = hash & tab.length - 1; - HashEntry first = tab[index]; - HashEntry e = first; - // a reference remove operation compares the Reference instance - while (e != null && key != e.key && - (refRemove || hash != e.hash || !keyEq(key, e.key()))) { - e = e.next; - } - - V oldValue = null; - if (e != null) { - V v = e.value(); - if (value == null || value.equals(v)) { - oldValue = v; - // All entries following removed node can stay in list, - // but all preceding ones need to be cloned. - ++modCount; - HashEntry newFirst = e.next; - for (HashEntry p = first; p != e; p = p.next) { - K pKey = p.key(); - if (pKey == null) { // Skip GC'd keys - c--; - continue; - } - - newFirst = newHashEntry( - pKey, p.hash, newFirst, p.value()); - } - tab[index] = newFirst; - count = c; // write-volatile - } - } - return oldValue; - } finally { - unlock(); - } - } - - void clear() { - if (count != 0) { - lock(); - try { - HashEntry[] tab = table; - for (int i = 0; i < tab.length; i++) { - tab[i] = null; - } - ++modCount; - count = 0; // write-volatile - } finally { - unlock(); - } - } - } - } - - /* ---------------- Public operations -------------- */ - - /** - * Creates a new, empty map with the specified initial capacity, load factor - * and concurrency level. - * - * @param initialCapacity the initial capacity. The implementation performs - * internal sizing to accommodate this many elements. - * @param loadFactor the load factor threshold, used to control resizing. - * Resizing may be performed when the average number of - * elements per bin exceeds this threshold. - * @param concurrencyLevel the estimated number of concurrently updating - * threads. The implementation performs internal - * sizing to try to accommodate this many threads. - * @throws IllegalArgumentException if the initial capacity is negative or - * the load factor or concurrencyLevel are - * nonpositive. - */ - public ConcurrentIdentityHashMap( - int initialCapacity, float loadFactor, - int concurrencyLevel) { - if (!(loadFactor > 0) || initialCapacity < 0 || concurrencyLevel <= 0) { - throw new IllegalArgumentException(); - } - - if (concurrencyLevel > MAX_SEGMENTS) { - concurrencyLevel = MAX_SEGMENTS; - } - - // Find power-of-two sizes best matching arguments - int sshift = 0; - int ssize = 1; - while (ssize < concurrencyLevel) { - ++sshift; - ssize <<= 1; - } - segmentShift = 32 - sshift; - segmentMask = ssize - 1; - this.segments = Segment.newArray(ssize); - - if (initialCapacity > MAXIMUM_CAPACITY) { - initialCapacity = MAXIMUM_CAPACITY; - } - int c = initialCapacity / ssize; - if (c * ssize < initialCapacity) { - ++c; - } - int cap = 1; - while (cap < c) { - cap <<= 1; - } - - for (int i = 0; i < this.segments.length; ++i) { - this.segments[i] = new Segment(cap, loadFactor); - } - } - - - /** - * Creates a new, empty map with the specified initial capacity and load - * factor and with the default reference types (weak keys, strong values), - * and concurrencyLevel (16). - * - * @param initialCapacity The implementation performs internal sizing to - * accommodate this many elements. - * @param loadFactor the load factor threshold, used to control resizing. - * Resizing may be performed when the average number of - * elements per bin exceeds this threshold. - * @throws IllegalArgumentException if the initial capacity of elements is - * negative or the load factor is - * nonpositive - */ - public ConcurrentIdentityHashMap(int initialCapacity, float loadFactor) { - this(initialCapacity, loadFactor, DEFAULT_CONCURRENCY_LEVEL); - } - - /** - * Creates a new, empty map with the specified initial capacity, and with - * default reference types (weak keys, strong values), load factor (0.75) - * and concurrencyLevel (16). - * - * @param initialCapacity the initial capacity. The implementation performs - * internal sizing to accommodate this many elements. - * @throws IllegalArgumentException if the initial capacity of elements is - * negative. - */ - public ConcurrentIdentityHashMap(int initialCapacity) { - this(initialCapacity, DEFAULT_LOAD_FACTOR, DEFAULT_CONCURRENCY_LEVEL); - } - - /** - * Creates a new, empty map with a default initial capacity (16), reference - * types (weak keys, strong values), default load factor (0.75) and - * concurrencyLevel (16). - */ - public ConcurrentIdentityHashMap() { - this(DEFAULT_INITIAL_CAPACITY, DEFAULT_LOAD_FACTOR, DEFAULT_CONCURRENCY_LEVEL); - } - - /** - * Creates a new map with the same mappings as the given map. The map is - * created with a capacity of 1.5 times the number of mappings in the given - * map or 16 (whichever is greater), and a default load factor (0.75) and - * concurrencyLevel (16). - * - * @param m the map - */ - public ConcurrentIdentityHashMap(Map m) { - this(Math.max((int) (m.size() / DEFAULT_LOAD_FACTOR) + 1, - DEFAULT_INITIAL_CAPACITY), DEFAULT_LOAD_FACTOR, - DEFAULT_CONCURRENCY_LEVEL); - putAll(m); - } - - /** - * Returns true if this map contains no key-value mappings. - * - * @return true if this map contains no key-value mappings - */ - @Override - public boolean isEmpty() { - final Segment[] segments = this.segments; - /* - * We keep track of per-segment modCounts to avoid ABA problems in which - * an element in one segment was added and in another removed during - * traversal, in which case the table was never actually empty at any - * point. Note the similar use of modCounts in the size() and - * containsValue() methods, which are the only other methods also - * susceptible to ABA problems. - */ - int[] mc = new int[segments.length]; - int mcsum = 0; - for (int i = 0; i < segments.length; ++i) { - if (segments[i].count != 0) { - return false; - } else { - mcsum += mc[i] = segments[i].modCount; - } - } - // If mcsum happens to be zero, then we know we got a snapshot before - // any modifications at all were made. This is probably common enough - // to bother tracking. - if (mcsum != 0) { - for (int i = 0; i < segments.length; ++i) { - if (segments[i].count != 0 || mc[i] != segments[i].modCount) { - return false; - } - } - } - return true; - } - - /** - * Returns the number of key-value mappings in this map. If the map contains - * more than Integer.MAX_VALUE elements, returns - * Integer.MAX_VALUE. - * - * @return the number of key-value mappings in this map - */ - @Override - public int size() { - final Segment[] segments = this.segments; - long sum = 0; - long check = 0; - int[] mc = new int[segments.length]; - // Try a few times to get accurate count. On failure due to continuous - // async changes in table, resort to locking. - for (int k = 0; k < RETRIES_BEFORE_LOCK; ++k) { - check = 0; - sum = 0; - int mcsum = 0; - for (int i = 0; i < segments.length; ++i) { - sum += segments[i].count; - mcsum += mc[i] = segments[i].modCount; - } - if (mcsum != 0) { - for (int i = 0; i < segments.length; ++i) { - check += segments[i].count; - if (mc[i] != segments[i].modCount) { - check = -1; // force retry - break; - } - } - } - if (check == sum) { - break; - } - } - if (check != sum) { // Resort to locking all segments - sum = 0; - for (int i = 0; i < segments.length; ++i) { - segments[i].lock(); - } - for (int i = 0; i < segments.length; ++i) { - sum += segments[i].count; - } - for (int i = 0; i < segments.length; ++i) { - segments[i].unlock(); - } - } - if (sum > Integer.MAX_VALUE) { - return Integer.MAX_VALUE; - } else { - return (int) sum; - } - } - - /** - * Returns the value to which the specified key is mapped, or {@code null} - * if this map contains no mapping for the key. - * - *

    More formally, if this map contains a mapping from a key {@code k} to - * a value {@code v} such that {@code key.equals(k)}, then this method - * returns {@code v}; otherwise it returns {@code null}. (There can be at - * most one such mapping.) - * - * @throws NullPointerException if the specified key is null - */ - @Override - public V get(Object key) { - int hash = hashOf(key); - return segmentFor(hash).get(key, hash); - } - - /** - * Tests if the specified object is a key in this table. - * - * @param key possible key - * @return true if and only if the specified object is a key in - * this table, as determined by the equals method; - * false otherwise. - * @throws NullPointerException if the specified key is null - */ - @Override - public boolean containsKey(Object key) { - int hash = hashOf(key); - return segmentFor(hash).containsKey(key, hash); - } - - /** - * Returns true if this map maps one or more keys to the specified - * value. Note: This method requires a full internal traversal of the hash - * table, and so is much slower than method containsKey. - * - * @param value value whose presence in this map is to be tested - * @return true if this map maps one or more keys to the specified - * value - * @throws NullPointerException if the specified value is null - */ - - @Override - public boolean containsValue(Object value) { - if (value == null) { - throw new NullPointerException(); - } - - // See explanation of modCount use above - - final Segment[] segments = this.segments; - int[] mc = new int[segments.length]; - - // Try a few times without locking - for (int k = 0; k < RETRIES_BEFORE_LOCK; ++k) { - int mcsum = 0; - for (int i = 0; i < segments.length; ++i) { - mcsum += mc[i] = segments[i].modCount; - if (segments[i].containsValue(value)) { - return true; - } - } - boolean cleanSweep = true; - if (mcsum != 0) { - for (int i = 0; i < segments.length; ++i) { - if (mc[i] != segments[i].modCount) { - cleanSweep = false; - break; - } - } - } - if (cleanSweep) { - return false; - } - } - // Resort to locking all segments - for (int i = 0; i < segments.length; ++i) { - segments[i].lock(); - } - boolean found = false; - try { - for (int i = 0; i < segments.length; ++i) { - if (segments[i].containsValue(value)) { - found = true; - break; - } - } - } finally { - for (int i = 0; i < segments.length; ++i) { - segments[i].unlock(); - } - } - return found; - } - - /** - * Legacy method testing if some key maps into the specified value in this - * table. This method is identical in functionality to - * {@link #containsValue}, and exists solely to ensure full compatibility - * with class {@link Hashtable}, which supported this method prior to - * introduction of the Java Collections framework. - * - * @param value a value to search for - * @return true if and only if some key maps to the value - * argument in this table as determined by the equals - * method; false otherwise - * @throws NullPointerException if the specified value is null - */ - public boolean contains(Object value) { - return containsValue(value); - } - - /** - * Maps the specified key to the specified value in this table. Neither the - * key nor the value can be null. - * - *

    The value can be retrieved by calling the get method with a - * key that is equal to the original key. - * - * @param key key with which the specified value is to be associated - * @param value value to be associated with the specified key - * @return the previous value associated with key, or null - * if there was no mapping for key - * @throws NullPointerException if the specified key or value is null - */ - @Override - public V put(K key, V value) { - if (value == null) { - throw new NullPointerException(); - } - int hash = hashOf(key); - return segmentFor(hash).put(key, hash, value, false); - } - - /** - * {@inheritDoc} - * - * @return the previous value associated with the specified key, or - * null if there was no mapping for the key - * @throws NullPointerException if the specified key or value is null - */ - public V putIfAbsent(K key, V value) { - if (value == null) { - throw new NullPointerException(); - } - int hash = hashOf(key); - return segmentFor(hash).put(key, hash, value, true); - } - - /** - * Copies all of the mappings from the specified map to this one. These - * mappings replace any mappings that this map had for any of the keys - * currently in the specified map. - * - * @param m mappings to be stored in this map - */ - @Override - public void putAll(Map m) { - for (Map.Entry e : m.entrySet()) { - put(e.getKey(), e.getValue()); - } - } - - /** - * Removes the key (and its corresponding value) from this map. This method - * does nothing if the key is not in the map. - * - * @param key the key that needs to be removed - * @return the previous value associated with key, or null - * if there was no mapping for key - * @throws NullPointerException if the specified key is null - */ - @Override - public V remove(Object key) { - int hash = hashOf(key); - return segmentFor(hash).remove(key, hash, null, false); - } - - /** - * {@inheritDoc} - * - * @throws NullPointerException if the specified key is null - */ - public boolean remove(Object key, Object value) { - int hash = hashOf(key); - if (value == null) { - return false; - } - return segmentFor(hash).remove(key, hash, value, false) != null; - } - - /** - * {@inheritDoc} - * - * @throws NullPointerException if any of the arguments are null - */ - public boolean replace(K key, V oldValue, V newValue) { - if (oldValue == null || newValue == null) { - throw new NullPointerException(); - } - int hash = hashOf(key); - return segmentFor(hash).replace(key, hash, oldValue, newValue); - } - - /** - * {@inheritDoc} - * - * @return the previous value associated with the specified key, or - * null if there was no mapping for the key - * @throws NullPointerException if the specified key or value is null - */ - public V replace(K key, V value) { - if (value == null) { - throw new NullPointerException(); - } - int hash = hashOf(key); - return segmentFor(hash).replace(key, hash, value); - } - - /** - * Removes all of the mappings from this map. - */ - @Override - public void clear() { - for (int i = 0; i < segments.length; ++i) { - segments[i].clear(); - } - } - - /** - * Returns a {@link Set} view of the keys contained in this map. The set is - * backed by the map, so changes to the map are reflected in the set, and - * vice-versa. The set supports element removal, which removes the - * corresponding mapping from this map, via the Iterator.remove, - * Set.remove, removeAll, retainAll, and - * clear operations. It does not support the add or - * addAll operations. - * - *

    The view's iterator is a "weakly consistent" iterator that - * will never throw {@link ConcurrentModificationException}, and guarantees - * to traverse elements as they existed upon construction of the iterator, - * and may (but is not guaranteed to) reflect any modifications subsequent - * to construction. - */ - @Override - public Set keySet() { - Set ks = keySet; - return ks != null ? ks : (keySet = new KeySet()); - } - - /** - * Returns a {@link Collection} view of the values contained in this map. - * The collection is backed by the map, so changes to the map are reflected - * in the collection, and vice-versa. The collection supports element - * removal, which removes the corresponding mapping from this map, via the - * Iterator.remove, Collection.remove, removeAll, - * retainAll, and clear operations. It does not support - * the add or addAll operations. - * - *

    The view's iterator is a "weakly consistent" iterator that - * will never throw {@link ConcurrentModificationException}, and guarantees - * to traverse elements as they existed upon construction of the iterator, - * and may (but is not guaranteed to) reflect any modifications subsequent - * to construction. - */ - @Override - public Collection values() { - Collection vs = values; - return vs != null ? vs : (values = new Values()); - } - - /** - * Returns a {@link Set} view of the mappings contained in this map. - * The set is backed by the map, so changes to the map are reflected in the - * set, and vice-versa. The set supports element removal, which removes the - * corresponding mapping from the map, via the Iterator.remove, - * Set.remove, removeAll, retainAll, and - * clear operations. It does not support the add or - * addAll operations. - * - *

    The view's iterator is a "weakly consistent" iterator that - * will never throw {@link ConcurrentModificationException}, and guarantees - * to traverse elements as they existed upon construction of the iterator, - * and may (but is not guaranteed to) reflect any modifications subsequent - * to construction. - */ - @Override - public Set> entrySet() { - Set> es = entrySet; - return es != null ? es : (entrySet = new EntrySet()); - } - - /** - * Returns an enumeration of the keys in this table. - * - * @return an enumeration of the keys in this table - * @see #keySet() - */ - public Enumeration keys() { - return new KeyIterator(); - } - - /** - * Returns an enumeration of the values in this table. - * - * @return an enumeration of the values in this table - * @see #values() - */ - public Enumeration elements() { - return new ValueIterator(); - } - - /* ---------------- Iterator Support -------------- */ - - abstract class HashIterator { - int nextSegmentIndex; - int nextTableIndex; - HashEntry[] currentTable; - HashEntry nextEntry; - HashEntry lastReturned; - K currentKey; // Strong reference to weak key (prevents gc) - - HashIterator() { - nextSegmentIndex = segments.length - 1; - nextTableIndex = -1; - advance(); - } - - public void rewind() { - nextSegmentIndex = segments.length - 1; - nextTableIndex = -1; - currentTable = null; - nextEntry = null; - lastReturned = null; - currentKey = null; - advance(); - } - - public boolean hasMoreElements() { - return hasNext(); - } - - final void advance() { - if (nextEntry != null && (nextEntry = nextEntry.next) != null) { - return; - } - - while (nextTableIndex >= 0) { - if ((nextEntry = currentTable[nextTableIndex--]) != null) { - return; - } - } - - while (nextSegmentIndex >= 0) { - Segment seg = segments[nextSegmentIndex--]; - if (seg.count != 0) { - currentTable = seg.table; - for (int j = currentTable.length - 1; j >= 0; --j) { - if ((nextEntry = currentTable[j]) != null) { - nextTableIndex = j - 1; - return; - } - } - } - } - } - - public boolean hasNext() { - while (nextEntry != null) { - if (nextEntry.key() != null) { - return true; - } - advance(); - } - - return false; - } - - HashEntry nextEntry() { - do { - if (nextEntry == null) { - throw new NoSuchElementException(); - } - - lastReturned = nextEntry; - currentKey = lastReturned.key(); - advance(); - } while (currentKey == null); // Skip GC'd keys - - return lastReturned; - } - - public void remove() { - if (lastReturned == null) { - throw new IllegalStateException(); - } - ConcurrentIdentityHashMap.this.remove(currentKey); - lastReturned = null; - } - } - - final class KeyIterator - extends HashIterator implements ReusableIterator, Enumeration { - - public K next() { - return super.nextEntry().key(); - } - - public K nextElement() { - return super.nextEntry().key(); - } - } - - final class ValueIterator - extends HashIterator implements ReusableIterator, Enumeration { - - public V next() { - return super.nextEntry().value(); - } - - public V nextElement() { - return super.nextEntry().value(); - } - } - - /* - * This class is needed for JDK5 compatibility. - */ - - static class SimpleEntry implements Entry { - - private static final long serialVersionUID = -8144765946475398746L; - - private final K key; - - private V value; - - public SimpleEntry(K key, V value) { - this.key = key; - this.value = value; - - } - - public SimpleEntry(Entry entry) { - this.key = entry.getKey(); - this.value = entry.getValue(); - - } - - public K getKey() { - return key; - } - - public V getValue() { - return value; - } - - public V setValue(V value) { - V oldValue = this.value; - this.value = value; - return oldValue; - } - - @Override - public boolean equals(Object o) { - if (!(o instanceof Map.Entry)) { - return false; - } - @SuppressWarnings("unchecked") - Map.Entry e = (Map.Entry) o; - return eq(key, e.getKey()) && eq(value, e.getValue()); - } - - @Override - public int hashCode() { - return (key == null ? 0 : key.hashCode()) ^ (value == null ? 0 : value.hashCode()); - } - - @Override - public String toString() { - return key + "=" + value; - } - - private static boolean eq(Object o1, Object o2) { - return o1 == null ? o2 == null : o1.equals(o2); - } - } - - /** - * Custom Entry class used by EntryIterator.next(), that relays setValue - * changes to the underlying map. - */ - final class WriteThroughEntry extends SimpleEntry { - - WriteThroughEntry(K k, V v) { - super(k, v); - } - - /** - * Set our entry's value and write through to the map. The value to - * return is somewhat arbitrary here. Since a WriteThroughEntry does not - * necessarily track asynchronous changes, the most recent "previous" - * value could be different from what we return (or could even have been - * removed in which case the put will re-establish). We do not and can - * not guarantee more. - */ - @Override - public V setValue(V value) { - - if (value == null) { - throw new NullPointerException(); - } - V v = super.setValue(value); - ConcurrentIdentityHashMap.this.put(getKey(), value); - return v; - } - - } - - final class EntryIterator extends HashIterator implements - ReusableIterator> { - public Map.Entry next() { - HashEntry e = super.nextEntry(); - return new WriteThroughEntry(e.key(), e.value()); - } - } - - final class KeySet extends AbstractSet { - @Override - public Iterator iterator() { - - return new KeyIterator(); - } - - @Override - public int size() { - return ConcurrentIdentityHashMap.this.size(); - } - - @Override - public boolean isEmpty() { - return ConcurrentIdentityHashMap.this.isEmpty(); - } - - @Override - public boolean contains(Object o) { - return ConcurrentIdentityHashMap.this.containsKey(o); - } - - @Override - public boolean remove(Object o) { - return ConcurrentIdentityHashMap.this.remove(o) != null; - - } - - @Override - public void clear() { - ConcurrentIdentityHashMap.this.clear(); - } - } - - final class Values extends AbstractCollection { - @Override - public Iterator iterator() { - return new ValueIterator(); - } - - @Override - public int size() { - return ConcurrentIdentityHashMap.this.size(); - } - - @Override - public boolean isEmpty() { - return ConcurrentIdentityHashMap.this.isEmpty(); - } - - @Override - public boolean contains(Object o) { - return ConcurrentIdentityHashMap.this.containsValue(o); - } - - @Override - public void clear() { - ConcurrentIdentityHashMap.this.clear(); - } - } - - final class EntrySet extends AbstractSet> { - @Override - public Iterator> iterator() { - return new EntryIterator(); - } - - @Override - public boolean contains(Object o) { - if (!(o instanceof Map.Entry)) { - return false; - } - Map.Entry e = (Map.Entry) o; - V v = ConcurrentIdentityHashMap.this.get(e.getKey()); - return v != null && v.equals(e.getValue()); - } - - @Override - public boolean remove(Object o) { - if (!(o instanceof Map.Entry)) { - return false; - } - Map.Entry e = (Map.Entry) o; - return ConcurrentIdentityHashMap.this.remove(e.getKey(), e.getValue()); - } - - @Override - public int size() { - return ConcurrentIdentityHashMap.this.size(); - } - - @Override - public boolean isEmpty() { - return ConcurrentIdentityHashMap.this.isEmpty(); - } - - @Override - public void clear() { - ConcurrentIdentityHashMap.this.clear(); - } - } -} diff --git a/src/main/java/org/elasticsearch/common/util/concurrent/ConcurrentMapLong.java b/src/main/java/org/elasticsearch/common/util/concurrent/ConcurrentMapLong.java index f1d9de8c30e..9c0c023cfd4 100644 --- a/src/main/java/org/elasticsearch/common/util/concurrent/ConcurrentMapLong.java +++ b/src/main/java/org/elasticsearch/common/util/concurrent/ConcurrentMapLong.java @@ -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.common.util.concurrent; import java.util.concurrent.ConcurrentMap; /** - * @author kimchy (shay.banon) + * */ public interface ConcurrentMapLong extends ConcurrentMap { diff --git a/src/main/java/org/elasticsearch/common/util/concurrent/ConcurrentSafeArray.java b/src/main/java/org/elasticsearch/common/util/concurrent/ConcurrentSafeArray.java deleted file mode 100644 index bdf10edebda..00000000000 --- a/src/main/java/org/elasticsearch/common/util/concurrent/ConcurrentSafeArray.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Licensed to Elastic Search 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 - * file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.common.util.concurrent; - -import org.elasticsearch.common.collect.SafeArray; - -import java.util.ArrayList; -import java.util.concurrent.locks.ReadWriteLock; -import java.util.concurrent.locks.ReentrantReadWriteLock; - -/** - * A concurrent version of {@link SafeArray}. - * - * @author kimchy (Shay Banon) - */ -@ThreadSafe -public class ConcurrentSafeArray implements SafeArray { - - private final ArrayList list = new ArrayList(); - - private final ReadWriteLock rwl = new ReentrantReadWriteLock(); - - @Override public T get(int index) { - rwl.readLock().lock(); - try { - return list.get(index); - } finally { - rwl.readLock().unlock(); - } - } - - @Override public int size() { - rwl.readLock().lock(); - try { - return list.size(); - } finally { - rwl.readLock().unlock(); - } - } - - @Override public void add(T value) { - rwl.writeLock().lock(); - try { - list.add(value); - } finally { - rwl.writeLock().unlock(); - } - } - - @Override public void add(int index, T value) { - rwl.writeLock().lock(); - try { - list.add(index, value); - } finally { - rwl.writeLock().unlock(); - } - } - - @Override public void clear() { - rwl.writeLock().lock(); - try { - list.clear(); - } finally { - rwl.writeLock().unlock(); - } - } - - @Override public boolean forEach(Procedure procedure) { - rwl.readLock().lock(); - try { - for (int i = 0; i < list.size(); i++) { - if (!procedure.execute(list.get(i))) { - return false; - } - } - return true; - } finally { - rwl.readLock().unlock(); - } - } -} diff --git a/src/main/java/org/elasticsearch/common/util/concurrent/CopyOnWriteMap.java b/src/main/java/org/elasticsearch/common/util/concurrent/CopyOnWriteMap.java index 30d44b12a54..2086d90b792 100644 --- a/src/main/java/org/elasticsearch/common/util/concurrent/CopyOnWriteMap.java +++ b/src/main/java/org/elasticsearch/common/util/concurrent/CopyOnWriteMap.java @@ -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.util.concurrent.ConcurrentMap; /** * Provides the semantics of a thread safe copy on write map. * - * @author kimchy (Shay Banon) + * */ @ThreadSafe public class CopyOnWriteMap implements ConcurrentMap { diff --git a/src/main/java/org/elasticsearch/common/util/concurrent/DynamicExecutors.java b/src/main/java/org/elasticsearch/common/util/concurrent/DynamicExecutors.java index 5ea7fd7f09a..017d0252685 100644 --- a/src/main/java/org/elasticsearch/common/util/concurrent/DynamicExecutors.java +++ b/src/main/java/org/elasticsearch/common/util/concurrent/DynamicExecutors.java @@ -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.common.util.concurrent; import java.util.concurrent.*; /** - * @author kimchy (shay.banon) + * */ public class DynamicExecutors { diff --git a/src/main/java/org/elasticsearch/common/util/concurrent/DynamicThreadPoolExecutor.java b/src/main/java/org/elasticsearch/common/util/concurrent/DynamicThreadPoolExecutor.java index b92428b1073..69f4728a68f 100644 --- a/src/main/java/org/elasticsearch/common/util/concurrent/DynamicThreadPoolExecutor.java +++ b/src/main/java/org/elasticsearch/common/util/concurrent/DynamicThreadPoolExecutor.java @@ -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 java.util.concurrent.atomic.AtomicInteger; * possibly several pooled threads, normally configured using * {@link DynamicExecutors} factory methods. * - * @author kimchy (shay.banon) + * */ public class DynamicThreadPoolExecutor extends ThreadPoolExecutor { /** @@ -41,15 +41,18 @@ public class DynamicThreadPoolExecutor extends ThreadPoolExecutor { super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory); } - @Override public int getActiveCount() { + @Override + public int getActiveCount() { return activeCount.get(); } - @Override protected void beforeExecute(Thread t, Runnable r) { + @Override + protected void beforeExecute(Thread t, Runnable r) { activeCount.incrementAndGet(); } - @Override protected void afterExecute(Runnable r, Throwable t) { + @Override + protected void afterExecute(Runnable r, Throwable t) { activeCount.decrementAndGet(); } @@ -68,7 +71,7 @@ public class DynamicThreadPoolExecutor extends ThreadPoolExecutor { * executed. * * - * @author kimchy (Shay Banon) + * */ public static class DynamicQueue extends LinkedBlockingQueue { private static final long serialVersionUID = 1L; diff --git a/src/main/java/org/elasticsearch/common/util/concurrent/EsExecutors.java b/src/main/java/org/elasticsearch/common/util/concurrent/EsExecutors.java index 449ea21b95a..91399716063 100644 --- a/src/main/java/org/elasticsearch/common/util/concurrent/EsExecutors.java +++ b/src/main/java/org/elasticsearch/common/util/concurrent/EsExecutors.java @@ -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.common.unit.TimeValue; import java.util.concurrent.*; /** - * @author kimchy (shay.banon) + * */ public class EsExecutors { diff --git a/src/main/java/org/elasticsearch/common/util/concurrent/Immutable.java b/src/main/java/org/elasticsearch/common/util/concurrent/Immutable.java index d49e11d5186..5bd6be661f9 100644 --- a/src/main/java/org/elasticsearch/common/util/concurrent/Immutable.java +++ b/src/main/java/org/elasticsearch/common/util/concurrent/Immutable.java @@ -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.lang.annotation.*; * Immutable objects are inherently thread-safe; they may be passed between * threads or published without synchronization. * - * @author kimchy (Shay Banon) + * */ @Documented @Target(ElementType.TYPE) diff --git a/src/main/java/org/elasticsearch/common/util/concurrent/NotThreadSafe.java b/src/main/java/org/elasticsearch/common/util/concurrent/NotThreadSafe.java index 46bb0b6fdf3..d3a4116723d 100644 --- a/src/main/java/org/elasticsearch/common/util/concurrent/NotThreadSafe.java +++ b/src/main/java/org/elasticsearch/common/util/concurrent/NotThreadSafe.java @@ -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.lang.annotation.*; * that might otherwise be assumed to be thread-safe, despite the fact that it * is a bad idea to assume a class is thread-safe without good reason. * - * @author kimchy (Shay Banon) + * * @see ThreadSafe */ @Documented diff --git a/src/main/java/org/elasticsearch/common/util/concurrent/ThreadBarrier.java b/src/main/java/org/elasticsearch/common/util/concurrent/ThreadBarrier.java index 1926d06e728..c7796f6e32c 100644 --- a/src/main/java/org/elasticsearch/common/util/concurrent/ThreadBarrier.java +++ b/src/main/java/org/elasticsearch/common/util/concurrent/ThreadBarrier.java @@ -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 @@ -42,7 +42,7 @@ import java.util.concurrent.TimeoutException; * class MyTestClass implements RemoteEventListener * { * final ThreadBarrier barrier; - *

    + * * class Worker implements Runnable * { * public void run() @@ -61,12 +61,12 @@ import java.util.concurrent.TimeoutException; * } * } * } - *

    + * * public void testThreads() { * barrier = new ThreadBarrier(N_THREADS + 1); * for (int i = 0; i < N; ++i) * new Thread(new Worker()).start(); - *

    + * * try{ * barrier.await(); //wait for all threads to reach run * barrier.await(); //wait for all threads to prepare @@ -76,14 +76,14 @@ import java.util.concurrent.TimeoutException; * Assert.fail(bbe); * } * } - *

    + * * int actualNotificationCount = 0; * public synchronized void notify (RemoteEvent event) { * try{ * actualNotificationCount++; * if (actualNotificationCount == EXPECTED_COUNT) * barrier.await(); //signal when all notifications arrive - *

    + * * // too many notifications? * Assert.assertFalse("Exceeded notification count", * actualNotificationCount > EXPECTED_COUNT); @@ -93,27 +93,27 @@ import java.util.concurrent.TimeoutException; * barrier.reset(t); * } * } - *

    + * * public void testNotify() { * barrier = new ThreadBarrier(N_LISTENERS + 1); * registerNotification(); * triggerNotifications(); - *

    + * * //wait until either all notifications arrive, or * //until a MAX_TIMEOUT is reached. * barrier.await(MAX_TIMEOUT); - *

    + * * //check if all notifications were accounted for or timed-out * Assert.assertEquals("Notification count", * EXPECTED_COUNT, actualNotificationCount); - *

    + * * //inspect that the barrier isn't broken * barrier.inspect(); //throws BrokenBarrierException if broken * } * } * * - * @author kimchy (shay.banon) + * */ public class ThreadBarrier extends CyclicBarrier { /** @@ -141,7 +141,8 @@ public class ThreadBarrier extends CyclicBarrier { } } - @Override public int await(long timeout, TimeUnit unit) throws InterruptedException, BrokenBarrierException, TimeoutException { + @Override + public int await(long timeout, TimeUnit unit) throws InterruptedException, BrokenBarrierException, TimeoutException { try { breakIfBroken(); return super.await(timeout, unit); @@ -246,18 +247,18 @@ public class ThreadBarrier extends CyclicBarrier { *

    * Usage example:
    *

    
    -     *                                                                                   BarrierTimer timer = new BarrierTimer();
    -     *                                                                                   ThreadBarrier barrier = new ThreadBarrier( nTHREADS + 1, timer );
    -     *                                                                                   ..
    -     *                                                                                   barrier.await(); // starts timer when all threads trip on await
    -     *                                                                                   barrier.await(); // stops  timer when all threads trip on await
    -     *                                                                                   ..
    -     *                                                                                   long time = timer.getTimeInNanos();
    -     *                                                                                   long tpi = time / ((long)nREPEATS * nTHREADS); //throughput per thread iteration
    -     *                                                                                   long secs = timer.getTimeInSeconds();	//total runtime in seconds
    -     *                                                                                   ..
    -     *                                                                                   timer.reset();  // reuse timer
    -     *                                                                                 
    + * BarrierTimer timer = new BarrierTimer(); + * ThreadBarrier barrier = new ThreadBarrier( nTHREADS + 1, timer ); + * .. + * barrier.await(); // starts timer when all threads trip on await + * barrier.await(); // stops timer when all threads trip on await + * .. + * long time = timer.getTimeInNanos(); + * long tpi = time / ((long)nREPEATS * nTHREADS); //throughput per thread iteration + * long secs = timer.getTimeInSeconds(); //total runtime in seconds + * .. + * timer.reset(); // reuse timer + * */ public static class BarrierTimer implements Runnable { volatile boolean started; diff --git a/src/main/java/org/elasticsearch/common/util/concurrent/ThreadSafe.java b/src/main/java/org/elasticsearch/common/util/concurrent/ThreadSafe.java index 8d2b69d20f6..9197b3f7178 100644 --- a/src/main/java/org/elasticsearch/common/util/concurrent/ThreadSafe.java +++ b/src/main/java/org/elasticsearch/common/util/concurrent/ThreadSafe.java @@ -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.lang.annotation.*; * interleaving of those actions by the runtime, and without requiring any * additional synchronization or coordination on the part of the caller. * - * @author kimchy (Shay Banon) + * */ @Documented @Target(ElementType.TYPE) diff --git a/src/main/java/org/elasticsearch/common/util/concurrent/TransferThreadPoolExecutor.java b/src/main/java/org/elasticsearch/common/util/concurrent/TransferThreadPoolExecutor.java index 16d6f0b97b8..a415588e71b 100644 --- a/src/main/java/org/elasticsearch/common/util/concurrent/TransferThreadPoolExecutor.java +++ b/src/main/java/org/elasticsearch/common/util/concurrent/TransferThreadPoolExecutor.java @@ -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.common.util.concurrent; -import org.elasticsearch.common.util.concurrent.jsr166y.LinkedTransferQueue; -import org.elasticsearch.common.util.concurrent.jsr166y.TransferQueue; +import jsr166y.LinkedTransferQueue; +import jsr166y.TransferQueue; import java.util.*; import java.util.concurrent.AbstractExecutorService; @@ -32,11 +32,11 @@ import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.ReentrantLock; /** - * A thread pool based on {@link org.elasticsearch.common.util.concurrent.jsr166y.TransferQueue}. - * + * A thread pool based on {@link jsr166y.TransferQueue}. + *

    *

    Limited compared to ExecutorServer in what it does, but focused on speed. * - * @author kimchy (shay.banon) + * */ public class TransferThreadPoolExecutor extends AbstractExecutorService { @@ -78,17 +78,17 @@ public class TransferThreadPoolExecutor extends AbstractExecutorService { /** * runState provides the main lifecyle control, taking on values: - * + *

    * RUNNING: Accept new tasks and process queued tasks * SHUTDOWN: Don't accept new tasks, but process queued tasks * STOP: Don't accept new tasks, don't process queued tasks, * and interrupt in-progress tasks * TERMINATED: Same as STOP, plus all threads have terminated - * + *

    * The numerical order among these values matters, to allow * ordered comparisons. The runState monotonically increases over * time, but need not hit each state. The transitions are: - * + *

    * RUNNING -> SHUTDOWN * On invocation of shutdown(), perhaps implicitly in finalize() * (RUNNING or SHUTDOWN) -> STOP @@ -168,7 +168,8 @@ public class TransferThreadPoolExecutor extends AbstractExecutorService { } - @Override public void execute(Runnable command) { + @Override + public void execute(Runnable command) { if (blocking) { executeBlocking(command); } else { @@ -259,7 +260,8 @@ public class TransferThreadPoolExecutor extends AbstractExecutorService { } } - @Override public void shutdown() { + @Override + public void shutdown() { final ReentrantLock mainLock = this.mainLock; mainLock.lock(); try { @@ -283,7 +285,8 @@ public class TransferThreadPoolExecutor extends AbstractExecutorService { } } - @Override public List shutdownNow() { + @Override + public List shutdownNow() { final ReentrantLock mainLock = this.mainLock; mainLock.lock(); try { @@ -309,20 +312,23 @@ public class TransferThreadPoolExecutor extends AbstractExecutorService { } } - @Override public boolean isShutdown() { + @Override + public boolean isShutdown() { return runState != RUNNING; } - @Override public boolean isTerminated() { + @Override + public boolean isTerminated() { return runState == TERMINATED; } - @Override public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { + @Override + public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { long nanos = unit.toNanos(timeout); final ReentrantLock mainLock = this.mainLock; mainLock.lock(); try { - for (; ;) { + for (; ; ) { if (runState == TERMINATED) return true; if (nanos <= 0) @@ -460,7 +466,7 @@ public class TransferThreadPoolExecutor extends AbstractExecutorService { Runnable getTask() { - for (; ;) { + for (; ; ) { try { int state = runState; if (state > SHUTDOWN) @@ -545,7 +551,7 @@ public class TransferThreadPoolExecutor extends AbstractExecutorService { * and queue empty) or (STOP and pool empty), otherwise unless * stopped, ensuring that there is at least one live thread to * handle queued tasks. - * + *

    * This method is called from the three places in which * termination can occur: in workerDone on exit of the last thread * after pool has been shut down, or directly within calls to diff --git a/src/main/java/org/elasticsearch/common/util/concurrent/UncategorizedExecutionException.java b/src/main/java/org/elasticsearch/common/util/concurrent/UncategorizedExecutionException.java index 7818c8cc617..e7fa5298291 100644 --- a/src/main/java/org/elasticsearch/common/util/concurrent/UncategorizedExecutionException.java +++ b/src/main/java/org/elasticsearch/common/util/concurrent/UncategorizedExecutionException.java @@ -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.common.util.concurrent; import org.elasticsearch.ElasticSearchException; /** - * @author kimchy (Shay Banon) + * */ public class UncategorizedExecutionException extends ElasticSearchException { diff --git a/src/main/java/org/elasticsearch/common/util/concurrent/resource/AcquirableResource.java b/src/main/java/org/elasticsearch/common/util/concurrent/resource/AcquirableResource.java index d8edf3bcbf2..5121d591564 100644 --- a/src/main/java/org/elasticsearch/common/util/concurrent/resource/AcquirableResource.java +++ b/src/main/java/org/elasticsearch/common/util/concurrent/resource/AcquirableResource.java @@ -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.lease.Releasable; *

    Yea, I now, the fact that the resouce itself is releasable basically means that * users of this class should take care... . * - * @author kimchy (Shay Banon) + * */ public interface AcquirableResource { diff --git a/src/main/java/org/elasticsearch/common/util/concurrent/resource/AcquirableResourceFactory.java b/src/main/java/org/elasticsearch/common/util/concurrent/resource/AcquirableResourceFactory.java index 569a8267b02..6fcc2935316 100644 --- a/src/main/java/org/elasticsearch/common/util/concurrent/resource/AcquirableResourceFactory.java +++ b/src/main/java/org/elasticsearch/common/util/concurrent/resource/AcquirableResourceFactory.java @@ -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.common.util.concurrent.resource; import org.elasticsearch.common.lease.Releasable; /** - * @author kimchy (Shay Banon) + * */ public final class AcquirableResourceFactory { diff --git a/src/main/java/org/elasticsearch/common/util/concurrent/resource/BlockingAcquirableResource.java b/src/main/java/org/elasticsearch/common/util/concurrent/resource/BlockingAcquirableResource.java index e9a0d52a1a1..e4ed7a459b2 100644 --- a/src/main/java/org/elasticsearch/common/util/concurrent/resource/BlockingAcquirableResource.java +++ b/src/main/java/org/elasticsearch/common/util/concurrent/resource/BlockingAcquirableResource.java @@ -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,11 +24,11 @@ import org.elasticsearch.common.lease.Releasable; /** * A wrapper around a resource that can be released. Note, release should not be * called directly on the resource itself. - * + *

    *

    Yea, I now, the fact that the resource itself is releasable basically means that * users of this class should take care... . * - * @author kimchy (shay.banon) + * */ public class BlockingAcquirableResource implements AcquirableResource { @@ -44,14 +44,16 @@ public class BlockingAcquirableResource implements Acquira this.resource = resource; } - @Override public T resource() { + @Override + public T resource() { return resource; } /** * Acquires the resource, returning true if it was acquired. */ - @Override public synchronized boolean acquire() { + @Override + public synchronized boolean acquire() { if (markForClose) { return false; } @@ -62,7 +64,8 @@ public class BlockingAcquirableResource implements Acquira /** * Releases the resource, will close it if there are no more acquirers. */ - @Override public synchronized void release() { + @Override + public synchronized void release() { count--; checkIfCanClose(); } @@ -71,12 +74,14 @@ public class BlockingAcquirableResource implements Acquira * Marks the resource to be closed. Will close it if there are no current * acquires. */ - @Override public synchronized void markForClose() { + @Override + public synchronized void markForClose() { markForClose = true; checkIfCanClose(); } - @Override public void forceClose() { + @Override + public void forceClose() { count = 0; markForClose(); } diff --git a/src/main/java/org/elasticsearch/common/util/concurrent/resource/NonBlockingAcquirableResource.java b/src/main/java/org/elasticsearch/common/util/concurrent/resource/NonBlockingAcquirableResource.java index c6e933d89f7..033b67533fc 100644 --- a/src/main/java/org/elasticsearch/common/util/concurrent/resource/NonBlockingAcquirableResource.java +++ b/src/main/java/org/elasticsearch/common/util/concurrent/resource/NonBlockingAcquirableResource.java @@ -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,11 +27,11 @@ import java.util.concurrent.atomic.AtomicStampedReference; /** * A wrapper around a resource that can be released. Note, release should not be * called directly on the resource itself. - * + *

    *

    Yea, I now, the fact that the resource itself is releasable basically means that * users of this class should take care... . * - * @author kimchy (shay.banon) + * */ public class NonBlockingAcquirableResource implements AcquirableResource { @@ -45,11 +45,13 @@ public class NonBlockingAcquirableResource implements Acqu this.resource = resource; } - @Override public T resource() { + @Override + public T resource() { return resource; } - @Override public boolean acquire() { + @Override + public boolean acquire() { while (true) { int stamp = counter.getStamp(); boolean result = counter.compareAndSet(false, false, stamp, stamp + 1); @@ -62,7 +64,8 @@ public class NonBlockingAcquirableResource implements Acqu } } - @Override public void release() { + @Override + public void release() { while (true) { boolean currentReference = counter.getReference(); int stamp = counter.getStamp(); @@ -76,7 +79,8 @@ public class NonBlockingAcquirableResource implements Acqu } } - @Override public void markForClose() { + @Override + public void markForClose() { while (true) { int stamp = counter.getStamp(); boolean result = counter.compareAndSet(false, true, stamp, stamp); @@ -91,7 +95,8 @@ public class NonBlockingAcquirableResource implements Acqu } } - @Override public void forceClose() { + @Override + public void forceClose() { close(); } diff --git a/src/main/java/org/elasticsearch/common/xcontent/ToXContent.java b/src/main/java/org/elasticsearch/common/xcontent/ToXContent.java index 5a6041d4417..3424d4cdd8a 100644 --- a/src/main/java/org/elasticsearch/common/xcontent/ToXContent.java +++ b/src/main/java/org/elasticsearch/common/xcontent/ToXContent.java @@ -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 java.util.Map; /** * An interface allowing to transfer an object to "XContent" using an {@link XContentBuilder}. * - * @author kimchy (shay.banon) + * */ public interface ToXContent { @@ -42,19 +42,23 @@ public interface ToXContent { } public static final Params EMPTY_PARAMS = new Params() { - @Override public String param(String key) { + @Override + public String param(String key) { return null; } - @Override public String param(String key, String defaultValue) { + @Override + public String param(String key, String defaultValue) { return defaultValue; } - @Override public boolean paramAsBoolean(String key, boolean defaultValue) { + @Override + public boolean paramAsBoolean(String key, boolean defaultValue) { return defaultValue; } - @Override public Boolean paramAsBooleanOptional(String key, Boolean defaultValue) { + @Override + public Boolean paramAsBooleanOptional(String key, Boolean defaultValue) { return defaultValue; } }; @@ -67,11 +71,13 @@ public interface ToXContent { this.params = params; } - @Override public String param(String key) { + @Override + public String param(String key) { return params.get(key); } - @Override public String param(String key, String defaultValue) { + @Override + public String param(String key, String defaultValue) { String value = params.get(key); if (value == null) { return defaultValue; @@ -79,11 +85,13 @@ public interface ToXContent { return value; } - @Override public boolean paramAsBoolean(String key, boolean defaultValue) { + @Override + public boolean paramAsBoolean(String key, boolean defaultValue) { return Booleans.parseBoolean(param(key), defaultValue); } - @Override public Boolean paramAsBooleanOptional(String key, Boolean defaultValue) { + @Override + public Boolean paramAsBooleanOptional(String key, Boolean defaultValue) { String sValue = param(key); if (sValue == null) { return defaultValue; diff --git a/src/main/java/org/elasticsearch/common/xcontent/XContent.java b/src/main/java/org/elasticsearch/common/xcontent/XContent.java index 305b55d6f75..a92b0fbb3f2 100644 --- a/src/main/java/org/elasticsearch/common/xcontent/XContent.java +++ b/src/main/java/org/elasticsearch/common/xcontent/XContent.java @@ -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 java.io.*; /** * A generic abstraction on top of handling content, inspired by JSON and pull parsing. * - * @author kimchy (shay.banon) + * */ public interface XContent { diff --git a/src/main/java/org/elasticsearch/common/xcontent/XContentBuilder.java b/src/main/java/org/elasticsearch/common/xcontent/XContentBuilder.java index b83c84deefe..1ad802fc77d 100644 --- a/src/main/java/org/elasticsearch/common/xcontent/XContentBuilder.java +++ b/src/main/java/org/elasticsearch/common/xcontent/XContentBuilder.java @@ -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,11 +24,11 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.Unicode; import org.elasticsearch.common.io.BytesStream; import org.elasticsearch.common.io.FastByteArrayOutputStream; -import org.elasticsearch.common.joda.time.DateTimeZone; -import org.elasticsearch.common.joda.time.ReadableInstant; -import org.elasticsearch.common.joda.time.format.DateTimeFormatter; -import org.elasticsearch.common.joda.time.format.ISODateTimeFormat; import org.elasticsearch.common.xcontent.support.XContentMapConverter; +import org.joda.time.DateTimeZone; +import org.joda.time.ReadableInstant; +import org.joda.time.format.DateTimeFormatter; +import org.joda.time.format.ISODateTimeFormat; import java.io.IOException; import java.io.InputStream; @@ -38,7 +38,7 @@ import java.util.List; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public final class XContentBuilder { @@ -984,7 +984,8 @@ public final class XContentBuilder { } } - @Nullable public Object payload() { + @Nullable + public Object payload() { return this.payload; } @@ -995,7 +996,7 @@ public final class XContentBuilder { /** * Returns the unsafe bytes (thread local bound). Make sure to use it with * {@link #underlyingBytesLength()}. - * + *

    *

    Only applicable when the builder is constructed with {@link FastByteArrayOutputStream}. */ public byte[] underlyingBytes() throws IOException { @@ -1006,7 +1007,7 @@ public final class XContentBuilder { /** * Returns the unsafe bytes length (thread local bound). Make sure to use it with * {@link #underlyingBytes()}. - * + *

    *

    Only applicable when the builder is constructed with {@link FastByteArrayOutputStream}. */ public int underlyingBytesLength() throws IOException { @@ -1024,7 +1025,7 @@ public final class XContentBuilder { /** * Returns a copy of the bytes this builder generated. - * + *

    *

    Only applicable when the builder is constructed with {@link FastByteArrayOutputStream}. */ public byte[] copiedBytes() throws IOException { @@ -1034,7 +1035,7 @@ public final class XContentBuilder { /** * Returns a string representation of the builder (only applicable for text based xcontent). - * + *

    *

    Only applicable when the builder is constructed with {@link FastByteArrayOutputStream}. */ public String string() throws IOException { diff --git a/src/main/java/org/elasticsearch/common/xcontent/XContentBuilderString.java b/src/main/java/org/elasticsearch/common/xcontent/XContentBuilderString.java index 4cd514e351b..9ccfdd75ad1 100644 --- a/src/main/java/org/elasticsearch/common/xcontent/XContentBuilderString.java +++ b/src/main/java/org/elasticsearch/common/xcontent/XContentBuilderString.java @@ -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.common.xcontent; import org.elasticsearch.common.Strings; /** - * @author kimchy (shay.banon) + * */ public class XContentBuilderString { diff --git a/src/main/java/org/elasticsearch/common/xcontent/XContentFactory.java b/src/main/java/org/elasticsearch/common/xcontent/XContentFactory.java index 1fcb5258fa0..4e44d03ea82 100644 --- a/src/main/java/org/elasticsearch/common/xcontent/XContentFactory.java +++ b/src/main/java/org/elasticsearch/common/xcontent/XContentFactory.java @@ -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.common.xcontent; +import org.codehaus.jackson.smile.SmileConstants; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.ElasticSearchParseException; -import org.elasticsearch.common.jackson.smile.SmileConstants; import org.elasticsearch.common.xcontent.json.JsonXContent; import org.elasticsearch.common.xcontent.smile.SmileXContent; @@ -33,7 +33,7 @@ import java.util.Arrays; /** * A one stop to use {@link org.elasticsearch.common.xcontent.XContent} and {@link XContentBuilder}. * - * @author kimchy (shay.banon) + * */ public class XContentFactory { diff --git a/src/main/java/org/elasticsearch/common/xcontent/XContentGenerator.java b/src/main/java/org/elasticsearch/common/xcontent/XContentGenerator.java index b53d41bed13..32ff2cba663 100644 --- a/src/main/java/org/elasticsearch/common/xcontent/XContentGenerator.java +++ b/src/main/java/org/elasticsearch/common/xcontent/XContentGenerator.java @@ -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 java.io.InputStream; import java.io.OutputStream; /** - * @author kimchy (shay.banon) + * */ public interface XContentGenerator { diff --git a/src/main/java/org/elasticsearch/common/xcontent/XContentHelper.java b/src/main/java/org/elasticsearch/common/xcontent/XContentHelper.java index d6d1ee80747..966d966c98a 100644 --- a/src/main/java/org/elasticsearch/common/xcontent/XContentHelper.java +++ b/src/main/java/org/elasticsearch/common/xcontent/XContentHelper.java @@ -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.common.xcontent; +import com.google.common.base.Charsets; import org.elasticsearch.ElasticSearchParseException; -import org.elasticsearch.common.base.Charsets; import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.compress.lzf.LZF; import org.elasticsearch.common.io.stream.BytesStreamInput; @@ -34,7 +34,7 @@ import java.util.List; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class XContentHelper { @@ -90,7 +90,8 @@ public class XContentHelper { * Merges the defaults provided as the second parameter into the content of the first. Only does recursive merge * for inner maps. */ - @SuppressWarnings({"unchecked"}) public static void mergeDefaults(Map content, Map defaults) { + @SuppressWarnings({"unchecked"}) + public static void mergeDefaults(Map content, Map defaults) { for (Map.Entry defaultEntry : defaults.entrySet()) { if (!content.containsKey(defaultEntry.getKey())) { // copy it over, it does not exists in the content diff --git a/src/main/java/org/elasticsearch/common/xcontent/XContentParser.java b/src/main/java/org/elasticsearch/common/xcontent/XContentParser.java index ba31b2795d0..227855f4ca0 100644 --- a/src/main/java/org/elasticsearch/common/xcontent/XContentParser.java +++ b/src/main/java/org/elasticsearch/common/xcontent/XContentParser.java @@ -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,68 +23,78 @@ import java.io.IOException; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public interface XContentParser { enum Token { START_OBJECT { - @Override public boolean isValue() { + @Override + public boolean isValue() { return false; } }, END_OBJECT { - @Override public boolean isValue() { + @Override + public boolean isValue() { return false; } }, START_ARRAY { - @Override public boolean isValue() { + @Override + public boolean isValue() { return false; } }, END_ARRAY { - @Override public boolean isValue() { + @Override + public boolean isValue() { return false; } }, FIELD_NAME { - @Override public boolean isValue() { + @Override + public boolean isValue() { return false; } }, VALUE_STRING { - @Override public boolean isValue() { + @Override + public boolean isValue() { return true; } }, VALUE_NUMBER { - @Override public boolean isValue() { + @Override + public boolean isValue() { return true; } }, VALUE_BOOLEAN { - @Override public boolean isValue() { + @Override + public boolean isValue() { return true; } }, // usually a binary value VALUE_EMBEDDED_OBJECT { - @Override public boolean isValue() { + @Override + public boolean isValue() { return true; } }, VALUE_NULL { - @Override public boolean isValue() { + @Override + public boolean isValue() { return false; } }; diff --git a/src/main/java/org/elasticsearch/common/xcontent/XContentString.java b/src/main/java/org/elasticsearch/common/xcontent/XContentString.java index 279b71b9cf0..c94b17bebf3 100644 --- a/src/main/java/org/elasticsearch/common/xcontent/XContentString.java +++ b/src/main/java/org/elasticsearch/common/xcontent/XContentString.java @@ -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.common.xcontent; -import org.elasticsearch.common.jackson.io.SerializedString; +import org.codehaus.jackson.io.SerializedString; /** - * @author kimchy (shay.banon) + * */ public class XContentString extends SerializedString { diff --git a/src/main/java/org/elasticsearch/common/xcontent/XContentType.java b/src/main/java/org/elasticsearch/common/xcontent/XContentType.java index 205f488f971..e656c74474e 100644 --- a/src/main/java/org/elasticsearch/common/xcontent/XContentType.java +++ b/src/main/java/org/elasticsearch/common/xcontent/XContentType.java @@ -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.common.xcontent; /** * The content type of {@link org.elasticsearch.common.xcontent.XContent}. * - * @author kimchy (shay.banon) + * */ public enum XContentType { @@ -30,16 +30,20 @@ public enum XContentType { * A JSON based content type. */ JSON(0) { - @Override public String restContentType() { + @Override + public String restContentType() { return "application/json; charset=UTF-8"; - }}, + } + }, /** * The jackson based smile binary format. Fast and compact binary format. */ SMILE(1) { - @Override public String restContentType() { + @Override + public String restContentType() { return "application/smile"; - }}; + } + }; public static XContentType fromRestContentType(String contentType) { if (contentType == null) { diff --git a/src/main/java/org/elasticsearch/common/xcontent/json/JsonXContent.java b/src/main/java/org/elasticsearch/common/xcontent/json/JsonXContent.java index 16722274f33..35498c38eb8 100644 --- a/src/main/java/org/elasticsearch/common/xcontent/json/JsonXContent.java +++ b/src/main/java/org/elasticsearch/common/xcontent/json/JsonXContent.java @@ -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,27 +19,19 @@ package org.elasticsearch.common.xcontent.json; +import org.codehaus.jackson.JsonEncoding; +import org.codehaus.jackson.JsonFactory; +import org.codehaus.jackson.JsonGenerator; +import org.codehaus.jackson.JsonParser; import org.elasticsearch.common.io.FastStringReader; -import org.elasticsearch.common.jackson.JsonEncoding; -import org.elasticsearch.common.jackson.JsonFactory; -import org.elasticsearch.common.jackson.JsonGenerator; -import org.elasticsearch.common.jackson.JsonParser; -import org.elasticsearch.common.xcontent.XContent; -import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.common.xcontent.XContentGenerator; -import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.common.xcontent.XContentType; +import org.elasticsearch.common.xcontent.*; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.Reader; -import java.io.Writer; +import java.io.*; /** * A JSON based content implementation using Jackson. * - * @author kimchy (shay.banon) + * */ public class JsonXContent implements XContent { @@ -60,39 +52,48 @@ public class JsonXContent implements XContent { private JsonXContent() { } - @Override public XContentType type() { + @Override + public XContentType type() { return XContentType.JSON; } - @Override public byte streamSeparator() { + @Override + public byte streamSeparator() { return '\n'; } - @Override public XContentGenerator createGenerator(OutputStream os) throws IOException { + @Override + public XContentGenerator createGenerator(OutputStream os) throws IOException { return new JsonXContentGenerator(jsonFactory.createJsonGenerator(os, JsonEncoding.UTF8)); } - @Override public XContentGenerator createGenerator(Writer writer) throws IOException { + @Override + public XContentGenerator createGenerator(Writer writer) throws IOException { return new JsonXContentGenerator(jsonFactory.createJsonGenerator(writer)); } - @Override public XContentParser createParser(String content) throws IOException { + @Override + public XContentParser createParser(String content) throws IOException { return new JsonXContentParser(jsonFactory.createJsonParser(new FastStringReader(content))); } - @Override public XContentParser createParser(InputStream is) throws IOException { + @Override + public XContentParser createParser(InputStream is) throws IOException { return new JsonXContentParser(jsonFactory.createJsonParser(is)); } - @Override public XContentParser createParser(byte[] data) throws IOException { + @Override + public XContentParser createParser(byte[] data) throws IOException { return new JsonXContentParser(jsonFactory.createJsonParser(data)); } - @Override public XContentParser createParser(byte[] data, int offset, int length) throws IOException { + @Override + public XContentParser createParser(byte[] data, int offset, int length) throws IOException { return new JsonXContentParser(jsonFactory.createJsonParser(data, offset, length)); } - @Override public XContentParser createParser(Reader reader) throws IOException { + @Override + public XContentParser createParser(Reader reader) throws IOException { return new JsonXContentParser(jsonFactory.createJsonParser(reader)); } } diff --git a/src/main/java/org/elasticsearch/common/xcontent/json/JsonXContentGenerator.java b/src/main/java/org/elasticsearch/common/xcontent/json/JsonXContentGenerator.java index 574b285884e..2b7c6757aec 100644 --- a/src/main/java/org/elasticsearch/common/xcontent/json/JsonXContentGenerator.java +++ b/src/main/java/org/elasticsearch/common/xcontent/json/JsonXContentGenerator.java @@ -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,20 +19,16 @@ package org.elasticsearch.common.xcontent.json; +import org.codehaus.jackson.JsonGenerator; import org.elasticsearch.common.io.Streams; -import org.elasticsearch.common.jackson.JsonGenerator; -import org.elasticsearch.common.xcontent.XContentGenerator; -import org.elasticsearch.common.xcontent.XContentHelper; -import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.common.xcontent.XContentString; -import org.elasticsearch.common.xcontent.XContentType; +import org.elasticsearch.common.xcontent.*; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; /** - * @author kimchy (shay.banon) + * */ public class JsonXContentGenerator implements XContentGenerator { @@ -42,169 +38,208 @@ public class JsonXContentGenerator implements XContentGenerator { this.generator = generator; } - @Override public XContentType contentType() { + @Override + public XContentType contentType() { return XContentType.JSON; } - @Override public void usePrettyPrint() { + @Override + public void usePrettyPrint() { generator.useDefaultPrettyPrinter(); } - @Override public void writeStartArray() throws IOException { + @Override + public void writeStartArray() throws IOException { generator.writeStartArray(); } - @Override public void writeEndArray() throws IOException { + @Override + public void writeEndArray() throws IOException { generator.writeEndArray(); } - @Override public void writeStartObject() throws IOException { + @Override + public void writeStartObject() throws IOException { generator.writeStartObject(); } - @Override public void writeEndObject() throws IOException { + @Override + public void writeEndObject() throws IOException { generator.writeEndObject(); } - @Override public void writeFieldName(String name) throws IOException { + @Override + public void writeFieldName(String name) throws IOException { generator.writeFieldName(name); } - @Override public void writeFieldName(XContentString name) throws IOException { + @Override + public void writeFieldName(XContentString name) throws IOException { generator.writeFieldName(name); } - @Override public void writeString(String text) throws IOException { + @Override + public void writeString(String text) throws IOException { generator.writeString(text); } - @Override public void writeString(char[] text, int offset, int len) throws IOException { + @Override + public void writeString(char[] text, int offset, int len) throws IOException { generator.writeString(text, offset, len); } - @Override public void writeBinary(byte[] data, int offset, int len) throws IOException { + @Override + public void writeBinary(byte[] data, int offset, int len) throws IOException { generator.writeBinary(data, offset, len); } - @Override public void writeBinary(byte[] data) throws IOException { + @Override + public void writeBinary(byte[] data) throws IOException { generator.writeBinary(data); } - @Override public void writeNumber(int v) throws IOException { + @Override + public void writeNumber(int v) throws IOException { generator.writeNumber(v); } - @Override public void writeNumber(long v) throws IOException { + @Override + public void writeNumber(long v) throws IOException { generator.writeNumber(v); } - @Override public void writeNumber(double d) throws IOException { + @Override + public void writeNumber(double d) throws IOException { generator.writeNumber(d); } - @Override public void writeNumber(float f) throws IOException { + @Override + public void writeNumber(float f) throws IOException { generator.writeNumber(f); } - @Override public void writeBoolean(boolean state) throws IOException { + @Override + public void writeBoolean(boolean state) throws IOException { generator.writeBoolean(state); } - @Override public void writeNull() throws IOException { + @Override + public void writeNull() throws IOException { generator.writeNull(); } - @Override public void writeStringField(String fieldName, String value) throws IOException { + @Override + public void writeStringField(String fieldName, String value) throws IOException { generator.writeStringField(fieldName, value); } - @Override public void writeStringField(XContentString fieldName, String value) throws IOException { + @Override + public void writeStringField(XContentString fieldName, String value) throws IOException { generator.writeFieldName(fieldName); generator.writeString(value); } - @Override public void writeBooleanField(String fieldName, boolean value) throws IOException { + @Override + public void writeBooleanField(String fieldName, boolean value) throws IOException { generator.writeBooleanField(fieldName, value); } - @Override public void writeBooleanField(XContentString fieldName, boolean value) throws IOException { + @Override + public void writeBooleanField(XContentString fieldName, boolean value) throws IOException { generator.writeFieldName(fieldName); generator.writeBoolean(value); } - @Override public void writeNullField(String fieldName) throws IOException { + @Override + public void writeNullField(String fieldName) throws IOException { generator.writeNullField(fieldName); } - @Override public void writeNullField(XContentString fieldName) throws IOException { + @Override + public void writeNullField(XContentString fieldName) throws IOException { generator.writeFieldName(fieldName); generator.writeNull(); } - @Override public void writeNumberField(String fieldName, int value) throws IOException { + @Override + public void writeNumberField(String fieldName, int value) throws IOException { generator.writeNumberField(fieldName, value); } - @Override public void writeNumberField(XContentString fieldName, int value) throws IOException { + @Override + public void writeNumberField(XContentString fieldName, int value) throws IOException { generator.writeFieldName(fieldName); generator.writeNumber(value); } - @Override public void writeNumberField(String fieldName, long value) throws IOException { + @Override + public void writeNumberField(String fieldName, long value) throws IOException { generator.writeNumberField(fieldName, value); } - @Override public void writeNumberField(XContentString fieldName, long value) throws IOException { + @Override + public void writeNumberField(XContentString fieldName, long value) throws IOException { generator.writeFieldName(fieldName); generator.writeNumber(value); } - @Override public void writeNumberField(String fieldName, double value) throws IOException { + @Override + public void writeNumberField(String fieldName, double value) throws IOException { generator.writeNumberField(fieldName, value); } - @Override public void writeNumberField(XContentString fieldName, double value) throws IOException { + @Override + public void writeNumberField(XContentString fieldName, double value) throws IOException { generator.writeFieldName(fieldName); generator.writeNumber(value); } - @Override public void writeNumberField(String fieldName, float value) throws IOException { + @Override + public void writeNumberField(String fieldName, float value) throws IOException { generator.writeNumberField(fieldName, value); } - @Override public void writeNumberField(XContentString fieldName, float value) throws IOException { + @Override + public void writeNumberField(XContentString fieldName, float value) throws IOException { generator.writeFieldName(fieldName); generator.writeNumber(value); } - @Override public void writeBinaryField(String fieldName, byte[] data) throws IOException { + @Override + public void writeBinaryField(String fieldName, byte[] data) throws IOException { generator.writeBinaryField(fieldName, data); } - @Override public void writeBinaryField(XContentString fieldName, byte[] value) throws IOException { + @Override + public void writeBinaryField(XContentString fieldName, byte[] value) throws IOException { generator.writeFieldName(fieldName); generator.writeBinary(value); } - @Override public void writeArrayFieldStart(String fieldName) throws IOException { + @Override + public void writeArrayFieldStart(String fieldName) throws IOException { generator.writeArrayFieldStart(fieldName); } - @Override public void writeArrayFieldStart(XContentString fieldName) throws IOException { + @Override + public void writeArrayFieldStart(XContentString fieldName) throws IOException { generator.writeFieldName(fieldName); generator.writeStartArray(); } - @Override public void writeObjectFieldStart(String fieldName) throws IOException { + @Override + public void writeObjectFieldStart(String fieldName) throws IOException { generator.writeObjectFieldStart(fieldName); } - @Override public void writeObjectFieldStart(XContentString fieldName) throws IOException { + @Override + public void writeObjectFieldStart(XContentString fieldName) throws IOException { generator.writeFieldName(fieldName); generator.writeStartObject(); } - @Override public void writeRawField(String fieldName, byte[] content, OutputStream bos) throws IOException { + @Override + public void writeRawField(String fieldName, byte[] content, OutputStream bos) throws IOException { generator.writeRaw(", \""); generator.writeRaw(fieldName); generator.writeRaw("\" : "); @@ -212,7 +247,8 @@ public class JsonXContentGenerator implements XContentGenerator { bos.write(content); } - @Override public void writeRawField(String fieldName, byte[] content, int offset, int length, OutputStream bos) throws IOException { + @Override + public void writeRawField(String fieldName, byte[] content, int offset, int length, OutputStream bos) throws IOException { generator.writeRaw(", \""); generator.writeRaw(fieldName); generator.writeRaw("\" : "); @@ -220,7 +256,8 @@ public class JsonXContentGenerator implements XContentGenerator { bos.write(content, offset, length); } - @Override public void writeRawField(String fieldName, InputStream content, OutputStream bos) throws IOException { + @Override + public void writeRawField(String fieldName, InputStream content, OutputStream bos) throws IOException { generator.writeRaw(", \""); generator.writeRaw(fieldName); generator.writeRaw("\" : "); @@ -228,7 +265,8 @@ public class JsonXContentGenerator implements XContentGenerator { Streams.copy(content, bos); } - @Override public void copyCurrentStructure(XContentParser parser) throws IOException { + @Override + public void copyCurrentStructure(XContentParser parser) throws IOException { if (parser instanceof JsonXContentParser) { generator.copyCurrentStructure(((JsonXContentParser) parser).parser); } else { @@ -236,11 +274,13 @@ public class JsonXContentGenerator implements XContentGenerator { } } - @Override public void flush() throws IOException { + @Override + public void flush() throws IOException { generator.flush(); } - @Override public void close() throws IOException { + @Override + public void close() throws IOException { generator.close(); } } diff --git a/src/main/java/org/elasticsearch/common/xcontent/json/JsonXContentParser.java b/src/main/java/org/elasticsearch/common/xcontent/json/JsonXContentParser.java index c023a0ee415..1f5ae1343e2 100644 --- a/src/main/java/org/elasticsearch/common/xcontent/json/JsonXContentParser.java +++ b/src/main/java/org/elasticsearch/common/xcontent/json/JsonXContentParser.java @@ -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,16 +19,16 @@ package org.elasticsearch.common.xcontent.json; +import org.codehaus.jackson.JsonParser; +import org.codehaus.jackson.JsonToken; import org.elasticsearch.ElasticSearchIllegalStateException; -import org.elasticsearch.common.jackson.JsonParser; -import org.elasticsearch.common.jackson.JsonToken; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.common.xcontent.support.AbstractXContentParser; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class JsonXContentParser extends AbstractXContentParser { @@ -38,87 +38,108 @@ public class JsonXContentParser extends AbstractXContentParser { this.parser = parser; } - @Override public XContentType contentType() { + @Override + public XContentType contentType() { return XContentType.JSON; } - @Override public Token nextToken() throws IOException { + @Override + public Token nextToken() throws IOException { return convertToken(parser.nextToken()); } - @Override public void skipChildren() throws IOException { + @Override + public void skipChildren() throws IOException { parser.skipChildren(); } - @Override public Token currentToken() { + @Override + public Token currentToken() { return convertToken(parser.getCurrentToken()); } - @Override public NumberType numberType() throws IOException { + @Override + public NumberType numberType() throws IOException { return convertNumberType(parser.getNumberType()); } - @Override public boolean estimatedNumberType() { + @Override + public boolean estimatedNumberType() { return true; } - @Override public String currentName() throws IOException { + @Override + public String currentName() throws IOException { return parser.getCurrentName(); } - @Override protected boolean doBooleanValue() throws IOException { + @Override + protected boolean doBooleanValue() throws IOException { return parser.getBooleanValue(); } - @Override public String text() throws IOException { + @Override + public String text() throws IOException { return parser.getText(); } - @Override public boolean hasTextCharacters() { + @Override + public boolean hasTextCharacters() { return parser.hasTextCharacters(); } - @Override public char[] textCharacters() throws IOException { + @Override + public char[] textCharacters() throws IOException { return parser.getTextCharacters(); } - @Override public int textLength() throws IOException { + @Override + public int textLength() throws IOException { return parser.getTextLength(); } - @Override public int textOffset() throws IOException { + @Override + public int textOffset() throws IOException { return parser.getTextOffset(); } - @Override public Number numberValue() throws IOException { + @Override + public Number numberValue() throws IOException { return parser.getNumberValue(); } - @Override public short doShortValue() throws IOException { + @Override + public short doShortValue() throws IOException { return parser.getShortValue(); } - @Override public int doIntValue() throws IOException { + @Override + public int doIntValue() throws IOException { return parser.getIntValue(); } - @Override public long doLongValue() throws IOException { + @Override + public long doLongValue() throws IOException { return parser.getLongValue(); } - @Override public float doFloatValue() throws IOException { + @Override + public float doFloatValue() throws IOException { return parser.getFloatValue(); } - @Override public double doDoubleValue() throws IOException { + @Override + public double doDoubleValue() throws IOException { return parser.getDoubleValue(); } - @Override public byte[] binaryValue() throws IOException { + @Override + public byte[] binaryValue() throws IOException { return parser.getBinaryValue(); } - @Override public void close() { + @Override + public void close() { try { parser.close(); } catch (IOException e) { diff --git a/src/main/java/org/elasticsearch/common/xcontent/smile/SmileXContent.java b/src/main/java/org/elasticsearch/common/xcontent/smile/SmileXContent.java index 26f3c1f352a..91a67a33ad7 100644 --- a/src/main/java/org/elasticsearch/common/xcontent/smile/SmileXContent.java +++ b/src/main/java/org/elasticsearch/common/xcontent/smile/SmileXContent.java @@ -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,27 +19,19 @@ package org.elasticsearch.common.xcontent.smile; +import org.codehaus.jackson.JsonEncoding; +import org.codehaus.jackson.smile.SmileFactory; +import org.codehaus.jackson.smile.SmileGenerator; import org.elasticsearch.common.io.FastStringReader; -import org.elasticsearch.common.jackson.JsonEncoding; -import org.elasticsearch.common.jackson.smile.SmileFactory; -import org.elasticsearch.common.jackson.smile.SmileGenerator; -import org.elasticsearch.common.xcontent.XContent; -import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.common.xcontent.XContentGenerator; -import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.common.xcontent.XContentType; +import org.elasticsearch.common.xcontent.*; import org.elasticsearch.common.xcontent.json.JsonXContentParser; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.Reader; -import java.io.Writer; +import java.io.*; /** * A JSON based content implementation using Jackson. * - * @author kimchy (shay.banon) + * */ public class SmileXContent implements XContent { @@ -59,39 +51,48 @@ public class SmileXContent implements XContent { private SmileXContent() { } - @Override public XContentType type() { + @Override + public XContentType type() { return XContentType.SMILE; } - @Override public byte streamSeparator() { + @Override + public byte streamSeparator() { return (byte) 0xFF; } - @Override public XContentGenerator createGenerator(OutputStream os) throws IOException { + @Override + public XContentGenerator createGenerator(OutputStream os) throws IOException { return new SmileXContentGenerator(smileFactory.createJsonGenerator(os, JsonEncoding.UTF8)); } - @Override public XContentGenerator createGenerator(Writer writer) throws IOException { + @Override + public XContentGenerator createGenerator(Writer writer) throws IOException { return new SmileXContentGenerator(smileFactory.createJsonGenerator(writer)); } - @Override public XContentParser createParser(String content) throws IOException { + @Override + public XContentParser createParser(String content) throws IOException { return new SmileXContentParser(smileFactory.createJsonParser(new FastStringReader(content))); } - @Override public XContentParser createParser(InputStream is) throws IOException { + @Override + public XContentParser createParser(InputStream is) throws IOException { return new SmileXContentParser(smileFactory.createJsonParser(is)); } - @Override public XContentParser createParser(byte[] data) throws IOException { + @Override + public XContentParser createParser(byte[] data) throws IOException { return new SmileXContentParser(smileFactory.createJsonParser(data)); } - @Override public XContentParser createParser(byte[] data, int offset, int length) throws IOException { + @Override + public XContentParser createParser(byte[] data, int offset, int length) throws IOException { return new SmileXContentParser(smileFactory.createJsonParser(data, offset, length)); } - @Override public XContentParser createParser(Reader reader) throws IOException { + @Override + public XContentParser createParser(Reader reader) throws IOException { return new JsonXContentParser(smileFactory.createJsonParser(reader)); } } diff --git a/src/main/java/org/elasticsearch/common/xcontent/smile/SmileXContentGenerator.java b/src/main/java/org/elasticsearch/common/xcontent/smile/SmileXContentGenerator.java index 3cd9e331d27..40c713c4e0e 100644 --- a/src/main/java/org/elasticsearch/common/xcontent/smile/SmileXContentGenerator.java +++ b/src/main/java/org/elasticsearch/common/xcontent/smile/SmileXContentGenerator.java @@ -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.common.xcontent.smile; -import org.elasticsearch.common.jackson.JsonGenerator; -import org.elasticsearch.common.jackson.smile.SmileParser; +import org.codehaus.jackson.JsonGenerator; +import org.codehaus.jackson.smile.SmileParser; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.common.xcontent.json.JsonXContentGenerator; @@ -29,7 +29,7 @@ import java.io.InputStream; import java.io.OutputStream; /** - * @author kimchy (shay.banon) + * */ public class SmileXContentGenerator extends JsonXContentGenerator { @@ -37,11 +37,13 @@ public class SmileXContentGenerator extends JsonXContentGenerator { super(generator); } - @Override public XContentType contentType() { + @Override + public XContentType contentType() { return XContentType.SMILE; } - @Override public void writeRawField(String fieldName, InputStream content, OutputStream bos) throws IOException { + @Override + public void writeRawField(String fieldName, InputStream content, OutputStream bos) throws IOException { writeFieldName(fieldName); SmileParser parser = SmileXContent.smileFactory.createJsonParser(content); try { @@ -52,7 +54,8 @@ public class SmileXContentGenerator extends JsonXContentGenerator { } } - @Override public void writeRawField(String fieldName, byte[] content, OutputStream bos) throws IOException { + @Override + public void writeRawField(String fieldName, byte[] content, OutputStream bos) throws IOException { writeFieldName(fieldName); SmileParser parser = SmileXContent.smileFactory.createJsonParser(content); try { @@ -63,7 +66,8 @@ public class SmileXContentGenerator extends JsonXContentGenerator { } } - @Override public void writeRawField(String fieldName, byte[] content, int offset, int length, OutputStream bos) throws IOException { + @Override + public void writeRawField(String fieldName, byte[] content, int offset, int length, OutputStream bos) throws IOException { writeFieldName(fieldName); SmileParser parser = SmileXContent.smileFactory.createJsonParser(content, offset, length); try { diff --git a/src/main/java/org/elasticsearch/common/xcontent/smile/SmileXContentParser.java b/src/main/java/org/elasticsearch/common/xcontent/smile/SmileXContentParser.java index 6a894d65c39..3269c1e72f8 100644 --- a/src/main/java/org/elasticsearch/common/xcontent/smile/SmileXContentParser.java +++ b/src/main/java/org/elasticsearch/common/xcontent/smile/SmileXContentParser.java @@ -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.elasticsearch.common.xcontent.smile; -import org.elasticsearch.common.jackson.JsonParser; +import org.codehaus.jackson.JsonParser; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.common.xcontent.json.JsonXContentParser; /** - * @author kimchy (shay.banon) + * */ public class SmileXContentParser extends JsonXContentParser { @@ -32,7 +32,8 @@ public class SmileXContentParser extends JsonXContentParser { super(parser); } - @Override public XContentType contentType() { + @Override + public XContentType contentType() { return XContentType.SMILE; } } diff --git a/src/main/java/org/elasticsearch/common/xcontent/support/AbstractXContentGenerator.java b/src/main/java/org/elasticsearch/common/xcontent/support/AbstractXContentGenerator.java index 3e83c21e5f7..22f734ec6e9 100644 --- a/src/main/java/org/elasticsearch/common/xcontent/support/AbstractXContentGenerator.java +++ b/src/main/java/org/elasticsearch/common/xcontent/support/AbstractXContentGenerator.java @@ -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,56 +24,66 @@ import org.elasticsearch.common.xcontent.XContentGenerator; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public abstract class AbstractXContentGenerator implements XContentGenerator { - @Override public void writeStringField(String fieldName, String value) throws IOException { + @Override + public void writeStringField(String fieldName, String value) throws IOException { writeFieldName(fieldName); writeString(value); } - @Override public void writeBooleanField(String fieldName, boolean value) throws IOException { + @Override + public void writeBooleanField(String fieldName, boolean value) throws IOException { writeFieldName(fieldName); writeBoolean(value); } - @Override public void writeNullField(String fieldName) throws IOException { + @Override + public void writeNullField(String fieldName) throws IOException { writeFieldName(fieldName); writeNull(); } - @Override public void writeNumberField(String fieldName, int value) throws IOException { + @Override + public void writeNumberField(String fieldName, int value) throws IOException { writeFieldName(fieldName); writeNumber(value); } - @Override public void writeNumberField(String fieldName, long value) throws IOException { + @Override + public void writeNumberField(String fieldName, long value) throws IOException { writeFieldName(fieldName); writeNumber(value); } - @Override public void writeNumberField(String fieldName, double value) throws IOException { + @Override + public void writeNumberField(String fieldName, double value) throws IOException { writeFieldName(fieldName); writeNumber(value); } - @Override public void writeNumberField(String fieldName, float value) throws IOException { + @Override + public void writeNumberField(String fieldName, float value) throws IOException { writeFieldName(fieldName); writeNumber(value); } - @Override public void writeBinaryField(String fieldName, byte[] data) throws IOException { + @Override + public void writeBinaryField(String fieldName, byte[] data) throws IOException { writeFieldName(fieldName); writeBinary(data); } - @Override public void writeArrayFieldStart(String fieldName) throws IOException { + @Override + public void writeArrayFieldStart(String fieldName) throws IOException { writeFieldName(fieldName); writeStartArray(); } - @Override public void writeObjectFieldStart(String fieldName) throws IOException { + @Override + public void writeObjectFieldStart(String fieldName) throws IOException { writeFieldName(fieldName); writeStartObject(); } diff --git a/src/main/java/org/elasticsearch/common/xcontent/support/AbstractXContentParser.java b/src/main/java/org/elasticsearch/common/xcontent/support/AbstractXContentParser.java index 43cdf040040..300fbf20f78 100644 --- a/src/main/java/org/elasticsearch/common/xcontent/support/AbstractXContentParser.java +++ b/src/main/java/org/elasticsearch/common/xcontent/support/AbstractXContentParser.java @@ -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,11 +26,12 @@ import java.io.IOException; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public abstract class AbstractXContentParser implements XContentParser { - @Override public boolean booleanValue() throws IOException { + @Override + public boolean booleanValue() throws IOException { Token token = currentToken(); if (token == Token.VALUE_NUMBER) { return intValue() != 0; @@ -42,7 +43,8 @@ public abstract class AbstractXContentParser implements XContentParser { protected abstract boolean doBooleanValue() throws IOException; - @Override public short shortValue() throws IOException { + @Override + public short shortValue() throws IOException { Token token = currentToken(); if (token == Token.VALUE_STRING) { return Short.parseShort(text()); @@ -52,7 +54,8 @@ public abstract class AbstractXContentParser implements XContentParser { protected abstract short doShortValue() throws IOException; - @Override public int intValue() throws IOException { + @Override + public int intValue() throws IOException { Token token = currentToken(); if (token == Token.VALUE_STRING) { return Integer.parseInt(text()); @@ -62,7 +65,8 @@ public abstract class AbstractXContentParser implements XContentParser { protected abstract int doIntValue() throws IOException; - @Override public long longValue() throws IOException { + @Override + public long longValue() throws IOException { Token token = currentToken(); if (token == Token.VALUE_STRING) { return Long.parseLong(text()); @@ -72,7 +76,8 @@ public abstract class AbstractXContentParser implements XContentParser { protected abstract long doLongValue() throws IOException; - @Override public float floatValue() throws IOException { + @Override + public float floatValue() throws IOException { Token token = currentToken(); if (token == Token.VALUE_STRING) { return Float.parseFloat(text()); @@ -82,7 +87,8 @@ public abstract class AbstractXContentParser implements XContentParser { protected abstract float doFloatValue() throws IOException; - @Override public double doubleValue() throws IOException { + @Override + public double doubleValue() throws IOException { Token token = currentToken(); if (token == Token.VALUE_STRING) { return Double.parseDouble(text()); @@ -92,22 +98,26 @@ public abstract class AbstractXContentParser implements XContentParser { protected abstract double doDoubleValue() throws IOException; - @Override public String textOrNull() throws IOException { + @Override + public String textOrNull() throws IOException { if (currentToken() == Token.VALUE_NULL) { return null; } return text(); } - @Override public Map map() throws IOException { + @Override + public Map map() throws IOException { return XContentMapConverter.readMap(this); } - @Override public Map mapOrdered() throws IOException { + @Override + public Map mapOrdered() throws IOException { return XContentMapConverter.readOrderedMap(this); } - @Override public Map mapAndClose() throws IOException { + @Override + public Map mapAndClose() throws IOException { try { return map(); } finally { diff --git a/src/main/java/org/elasticsearch/common/xcontent/support/XContentMapConverter.java b/src/main/java/org/elasticsearch/common/xcontent/support/XContentMapConverter.java index 561c1610523..af2787d6a57 100644 --- a/src/main/java/org/elasticsearch/common/xcontent/support/XContentMapConverter.java +++ b/src/main/java/org/elasticsearch/common/xcontent/support/XContentMapConverter.java @@ -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,15 +24,10 @@ import org.elasticsearch.common.xcontent.XContentGenerator; import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** - * @author kimchy (shay.banon) + * */ public class XContentMapConverter { @@ -41,13 +36,15 @@ public class XContentMapConverter { } public static final MapFactory SIMPLE_MAP_FACTORY = new MapFactory() { - @Override public Map newMap() { + @Override + public Map newMap() { return new HashMap(); } }; public static final MapFactory ORDERED_MAP_FACTORY = new MapFactory() { - @Override public Map newMap() { + @Override + public Map newMap() { return new LinkedHashMap(); } }; diff --git a/src/main/java/org/elasticsearch/common/xcontent/support/XContentMapValues.java b/src/main/java/org/elasticsearch/common/xcontent/support/XContentMapValues.java index 626cca0daec..08d5486ec1f 100644 --- a/src/main/java/org/elasticsearch/common/xcontent/support/XContentMapValues.java +++ b/src/main/java/org/elasticsearch/common/xcontent/support/XContentMapValues.java @@ -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.common.xcontent.support; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.collect.Maps; import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.unit.TimeValue; @@ -30,7 +30,7 @@ import java.util.List; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class XContentMapValues { @@ -91,7 +91,8 @@ public class XContentMapValues { return extractValue(pathElements, 0, map); } - @SuppressWarnings({"unchecked"}) private static Object extractValue(String[] pathElements, int index, Object currentValue) { + @SuppressWarnings({"unchecked"}) + private static Object extractValue(String[] pathElements, int index, Object currentValue) { if (index == pathElements.length) { return currentValue; } diff --git a/src/main/java/org/elasticsearch/discovery/Discovery.java b/src/main/java/org/elasticsearch/discovery/Discovery.java index 877ad4559a5..5adce51c7c4 100644 --- a/src/main/java/org/elasticsearch/discovery/Discovery.java +++ b/src/main/java/org/elasticsearch/discovery/Discovery.java @@ -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 org.elasticsearch.common.component.LifecycleComponent; * state to all nodes, electing a master of the cluster that raises cluster state change * events. * - * @author kimchy (shay.banon) + * */ public interface Discovery extends LifecycleComponent { diff --git a/src/main/java/org/elasticsearch/discovery/DiscoveryException.java b/src/main/java/org/elasticsearch/discovery/DiscoveryException.java index 90b7ef5a820..c6e7add9ad3 100644 --- a/src/main/java/org/elasticsearch/discovery/DiscoveryException.java +++ b/src/main/java/org/elasticsearch/discovery/DiscoveryException.java @@ -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.discovery; import org.elasticsearch.ElasticSearchException; /** - * @author kimchy (Shay Banon) + * */ public class DiscoveryException extends ElasticSearchException { diff --git a/src/main/java/org/elasticsearch/discovery/DiscoveryModule.java b/src/main/java/org/elasticsearch/discovery/DiscoveryModule.java index ae2778c480c..da6a729f5ac 100644 --- a/src/main/java/org/elasticsearch/discovery/DiscoveryModule.java +++ b/src/main/java/org/elasticsearch/discovery/DiscoveryModule.java @@ -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,7 +19,7 @@ package org.elasticsearch.discovery; -import org.elasticsearch.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.inject.Modules; @@ -29,7 +29,7 @@ import org.elasticsearch.discovery.local.LocalDiscoveryModule; import org.elasticsearch.discovery.zen.ZenDiscoveryModule; /** - * @author kimchy (shay.banon) + * */ public class DiscoveryModule extends AbstractModule implements SpawnModules { @@ -39,7 +39,8 @@ public class DiscoveryModule extends AbstractModule implements SpawnModules { this.settings = settings; } - @Override public Iterable spawnModules() { + @Override + public Iterable spawnModules() { Class defaultDiscoveryModule; if (settings.getAsBoolean("node.local", false)) { defaultDiscoveryModule = LocalDiscoveryModule.class; @@ -49,7 +50,8 @@ public class DiscoveryModule extends AbstractModule implements SpawnModules { return ImmutableList.of(Modules.createModule(settings.getAsClass("discovery.type", defaultDiscoveryModule, "org.elasticsearch.discovery.", "DiscoveryModule"), settings)); } - @Override protected void configure() { + @Override + protected void configure() { bind(DiscoveryService.class).asEagerSingleton(); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/discovery/DiscoveryService.java b/src/main/java/org/elasticsearch/discovery/DiscoveryService.java index 90c8fc58cf8..206120c1b3b 100644 --- a/src/main/java/org/elasticsearch/discovery/DiscoveryService.java +++ b/src/main/java/org/elasticsearch/discovery/DiscoveryService.java @@ -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,7 +31,7 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; /** - * @author kimchy (shay.banon) + * */ public class DiscoveryService extends AbstractLifecycleComponent { @@ -41,16 +41,19 @@ public class DiscoveryService extends AbstractLifecycleComponent *

    Note, this listener should be registered with the discovery service before it has started. * - * @author kimchy (Shay Banon) + * */ public interface InitialStateDiscoveryListener { diff --git a/src/main/java/org/elasticsearch/discovery/MasterNotDiscoveredException.java b/src/main/java/org/elasticsearch/discovery/MasterNotDiscoveredException.java index a392fa0a939..a40944cd3f2 100644 --- a/src/main/java/org/elasticsearch/discovery/MasterNotDiscoveredException.java +++ b/src/main/java/org/elasticsearch/discovery/MasterNotDiscoveredException.java @@ -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.discovery; import org.elasticsearch.ElasticSearchException; /** - * @author kimchy (shay.banon) + * */ public class MasterNotDiscoveredException extends ElasticSearchException { diff --git a/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java b/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java index a98cd7e929d..97bd6d9d46b 100644 --- a/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java +++ b/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java @@ -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,10 @@ package org.elasticsearch.discovery.local; +import jsr166y.LinkedTransferQueue; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.ElasticSearchIllegalStateException; -import org.elasticsearch.cluster.ClusterName; -import org.elasticsearch.cluster.ClusterService; -import org.elasticsearch.cluster.ClusterState; -import org.elasticsearch.cluster.ClusterStateUpdateTask; -import org.elasticsearch.cluster.ProcessedClusterStateUpdateTask; +import org.elasticsearch.cluster.*; import org.elasticsearch.cluster.block.ClusterBlocks; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodeService; @@ -33,7 +30,6 @@ import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.common.component.AbstractLifecycleComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.util.concurrent.jsr166y.LinkedTransferQueue; import org.elasticsearch.discovery.Discovery; import org.elasticsearch.discovery.InitialStateDiscoveryListener; import org.elasticsearch.transport.TransportService; @@ -46,11 +42,12 @@ import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; -import static org.elasticsearch.cluster.ClusterState.*; -import static org.elasticsearch.common.collect.Sets.*; +import static com.google.common.collect.Sets.newHashSet; +import static org.elasticsearch.cluster.ClusterState.Builder; +import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; /** - * @author kimchy (Shay Banon) + * */ public class LocalDiscovery extends AbstractLifecycleComponent implements Discovery { @@ -75,8 +72,9 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem private static final AtomicLong nodeIdGenerator = new AtomicLong(); - @Inject public LocalDiscovery(Settings settings, ClusterName clusterName, TransportService transportService, ClusterService clusterService, - DiscoveryNodeService discoveryNodeService) { + @Inject + public LocalDiscovery(Settings settings, ClusterName clusterName, TransportService transportService, ClusterService clusterService, + DiscoveryNodeService discoveryNodeService) { super(settings); this.clusterName = clusterName; this.clusterService = clusterService; @@ -84,7 +82,8 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem this.discoveryNodeService = discoveryNodeService; } - @Override protected void doStart() throws ElasticSearchException { + @Override + protected void doStart() throws ElasticSearchException { synchronized (clusterGroups) { ClusterGroup clusterGroup = clusterGroups.get(clusterName); if (clusterGroup == null) { @@ -110,7 +109,8 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem master = true; final LocalDiscovery master = firstMaster; clusterService.submitStateUpdateTask("local-disco-initial_connect(master)", new ProcessedClusterStateUpdateTask() { - @Override public ClusterState execute(ClusterState currentState) { + @Override + public ClusterState execute(ClusterState currentState) { DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.newNodesBuilder(); for (LocalDiscovery discovery : clusterGroups.get(clusterName).members()) { nodesBuilder.put(discovery.localNode); @@ -121,7 +121,8 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem return newClusterStateBuilder().state(currentState).nodes(nodesBuilder).blocks(blocks).build(); } - @Override public void clusterStateProcessed(ClusterState clusterState) { + @Override + public void clusterStateProcessed(ClusterState clusterState) { sendInitialStateEventIfNeeded(); } }); @@ -129,7 +130,8 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem // update as fast as we can the local node state with the new metadata (so we create indices for example) final ClusterState masterState = firstMaster.clusterService.state(); clusterService.submitStateUpdateTask("local-disco(detected_master)", new ClusterStateUpdateTask() { - @Override public ClusterState execute(ClusterState currentState) { + @Override + public ClusterState execute(ClusterState currentState) { // make sure we have the local node id set, we might need it as a result of the new metadata DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.newNodesBuilder().putAll(currentState.nodes()).put(localNode).localNodeId(localNode.id()); return ClusterState.builder().state(currentState).metaData(masterState.metaData()).nodes(nodesBuilder).build(); @@ -139,7 +141,8 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem // tell the master to send the fact that we are here final LocalDiscovery master = firstMaster; firstMaster.clusterService.submitStateUpdateTask("local-disco-receive(from node[" + localNode + "])", new ProcessedClusterStateUpdateTask() { - @Override public ClusterState execute(ClusterState currentState) { + @Override + public ClusterState execute(ClusterState currentState) { DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.newNodesBuilder(); for (LocalDiscovery discovery : clusterGroups.get(clusterName).members()) { nodesBuilder.put(discovery.localNode); @@ -148,7 +151,8 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem return newClusterStateBuilder().state(currentState).nodes(nodesBuilder).build(); } - @Override public void clusterStateProcessed(ClusterState clusterState) { + @Override + public void clusterStateProcessed(ClusterState clusterState) { sendInitialStateEventIfNeeded(); } }); @@ -156,7 +160,8 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem } // else, no master node, the next node that will start will fill things in... } - @Override protected void doStop() throws ElasticSearchException { + @Override + protected void doStop() throws ElasticSearchException { synchronized (clusterGroups) { ClusterGroup clusterGroup = clusterGroups.get(clusterName); if (clusterGroup == null) { @@ -191,7 +196,8 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem final LocalDiscovery master = firstMaster; master.clusterService.submitStateUpdateTask("local-disco-update", new ClusterStateUpdateTask() { - @Override public ClusterState execute(ClusterState currentState) { + @Override + public ClusterState execute(ClusterState currentState) { DiscoveryNodes newNodes = currentState.nodes().removeDeadMembers(newMembers, master.localNode.id()); DiscoveryNodes.Delta delta = newNodes.delta(currentState.nodes()); if (delta.added()) { @@ -204,26 +210,32 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem } } - @Override protected void doClose() throws ElasticSearchException { + @Override + protected void doClose() throws ElasticSearchException { } - @Override public DiscoveryNode localNode() { + @Override + public DiscoveryNode localNode() { return localNode; } - @Override public void addListener(InitialStateDiscoveryListener listener) { + @Override + public void addListener(InitialStateDiscoveryListener listener) { this.initialStateListeners.add(listener); } - @Override public void removeListener(InitialStateDiscoveryListener listener) { + @Override + public void removeListener(InitialStateDiscoveryListener listener) { this.initialStateListeners.remove(listener); } - @Override public String nodeDescription() { + @Override + public String nodeDescription() { return clusterName.value() + "/" + localNode.id(); } - @Override public void publish(ClusterState clusterState) { + @Override + public void publish(ClusterState clusterState) { if (!master) { throw new ElasticSearchIllegalStateException("Shouldn't publish state when not master"); } @@ -243,7 +255,8 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem // ignore cluster state messages that do not include "me", not in the game yet... if (nodeSpecificClusterState.nodes().localNode() != null) { discovery.clusterService.submitStateUpdateTask("local-disco-receive(from master)", new ProcessedClusterStateUpdateTask() { - @Override public ClusterState execute(ClusterState currentState) { + @Override + public ClusterState execute(ClusterState currentState) { ClusterState.Builder builder = ClusterState.builder().state(nodeSpecificClusterState); // if the routing table did not change, use the original one if (nodeSpecificClusterState.routingTable().version() == currentState.routingTable().version()) { @@ -256,7 +269,8 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem return builder.build(); } - @Override public void clusterStateProcessed(ClusterState clusterState) { + @Override + public void clusterStateProcessed(ClusterState clusterState) { sendInitialStateEventIfNeeded(); } }); diff --git a/src/main/java/org/elasticsearch/discovery/local/LocalDiscoveryModule.java b/src/main/java/org/elasticsearch/discovery/local/LocalDiscoveryModule.java index d78bccfd548..a270dd3c97f 100644 --- a/src/main/java/org/elasticsearch/discovery/local/LocalDiscoveryModule.java +++ b/src/main/java/org/elasticsearch/discovery/local/LocalDiscoveryModule.java @@ -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,11 +23,12 @@ import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.discovery.Discovery; /** - * @author kimchy (shay.banon) + * */ public class LocalDiscoveryModule extends AbstractModule { - @Override protected void configure() { + @Override + protected void configure() { bind(Discovery.class).to(LocalDiscovery.class).asEagerSingleton(); } } diff --git a/src/main/java/org/elasticsearch/discovery/zen/DiscoveryNodesProvider.java b/src/main/java/org/elasticsearch/discovery/zen/DiscoveryNodesProvider.java index eb3f2b0a2c5..d2487b65f6d 100644 --- a/src/main/java/org/elasticsearch/discovery/zen/DiscoveryNodesProvider.java +++ b/src/main/java/org/elasticsearch/discovery/zen/DiscoveryNodesProvider.java @@ -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.discovery.zen; import org.elasticsearch.cluster.node.DiscoveryNodes; /** - * @author kimchy (shay.banon) + * */ public interface DiscoveryNodesProvider { diff --git a/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java b/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java index 2d26b8f0c35..a85b14f282b 100644 --- a/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java +++ b/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java @@ -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,10 @@ package org.elasticsearch.discovery.zen; +import com.google.common.collect.Sets; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.ElasticSearchIllegalStateException; -import org.elasticsearch.cluster.ClusterName; -import org.elasticsearch.cluster.ClusterService; -import org.elasticsearch.cluster.ClusterState; -import org.elasticsearch.cluster.ClusterStateUpdateTask; -import org.elasticsearch.cluster.ProcessedClusterStateUpdateTask; +import org.elasticsearch.cluster.*; import org.elasticsearch.cluster.block.ClusterBlocks; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.node.DiscoveryNode; @@ -33,7 +30,6 @@ import org.elasticsearch.cluster.node.DiscoveryNodeService; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.cluster.routing.RoutingTable; import org.elasticsearch.common.UUID; -import org.elasticsearch.common.collect.Sets; import org.elasticsearch.common.component.AbstractLifecycleComponent; import org.elasticsearch.common.component.Lifecycle; import org.elasticsearch.common.inject.Inject; @@ -59,13 +55,13 @@ import java.util.Set; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.atomic.AtomicBoolean; -import static org.elasticsearch.cluster.ClusterState.*; -import static org.elasticsearch.cluster.node.DiscoveryNodes.*; -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.cluster.ClusterState.newClusterStateBuilder; +import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; +import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; /** - * @author kimchy (shay.banon) + * */ public class ZenDiscovery extends AbstractLifecycleComponent implements Discovery, DiscoveryNodesProvider { @@ -110,9 +106,10 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen private final AtomicBoolean initialStateSent = new AtomicBoolean(); - @Inject public ZenDiscovery(Settings settings, ClusterName clusterName, ThreadPool threadPool, - TransportService transportService, ClusterService clusterService, NodeSettingsService nodeSettingsService, - DiscoveryNodeService discoveryNodeService, ZenPingService pingService) { + @Inject + public ZenDiscovery(Settings settings, ClusterName clusterName, ThreadPool threadPool, + TransportService transportService, ClusterService clusterService, NodeSettingsService nodeSettingsService, + DiscoveryNodeService discoveryNodeService, ZenPingService pingService) { super(settings); this.clusterName = clusterName; this.threadPool = threadPool; @@ -140,7 +137,8 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen this.membership = new MembershipAction(settings, transportService, this, new MembershipListener()); } - @Override protected void doStart() throws ElasticSearchException { + @Override + protected void doStart() throws ElasticSearchException { Map nodeAttributes = discoveryNodeService.buildAttributes(); // note, we rely on the fact that its a new id each time we start, see FD and "kill -9" handling String nodeId = UUID.randomBase64UUID(); @@ -153,7 +151,8 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen asyncJoinCluster(); } - @Override protected void doStop() throws ElasticSearchException { + @Override + protected void doStop() throws ElasticSearchException { pingService.stop(); masterFD.stop("zen disco stop"); nodesFD.stop(); @@ -189,7 +188,8 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen } } - @Override protected void doClose() throws ElasticSearchException { + @Override + protected void doClose() throws ElasticSearchException { masterFD.close(); nodesFD.close(); publishClusterState.close(); @@ -197,23 +197,28 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen pingService.close(); } - @Override public DiscoveryNode localNode() { + @Override + public DiscoveryNode localNode() { return localNode; } - @Override public void addListener(InitialStateDiscoveryListener listener) { + @Override + public void addListener(InitialStateDiscoveryListener listener) { this.initialStateListeners.add(listener); } - @Override public void removeListener(InitialStateDiscoveryListener listener) { + @Override + public void removeListener(InitialStateDiscoveryListener listener) { this.initialStateListeners.remove(listener); } - @Override public String nodeDescription() { + @Override + public String nodeDescription() { return clusterName.value() + "/" + localNode.id(); } - @Override public DiscoveryNodes nodes() { + @Override + public DiscoveryNodes nodes() { DiscoveryNodes latestNodes = this.latestDiscoNodes; if (latestNodes != null) { return latestNodes; @@ -222,7 +227,8 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen return newNodesBuilder().put(localNode).localNodeId(localNode.id()).build(); } - @Override public void publish(ClusterState clusterState) { + @Override + public void publish(ClusterState clusterState) { if (!master) { throw new ElasticSearchIllegalStateException("Shouldn't publish state when not master"); } @@ -237,7 +243,8 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen return; } threadPool.cached().execute(new Runnable() { - @Override public void run() { + @Override + public void run() { currentJoinThread = Thread.currentThread(); try { innterJoinCluster(); @@ -264,7 +271,8 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen this.master = true; nodesFD.start(); // start the nodes FD clusterService.submitStateUpdateTask("zen-disco-join (elected_as_master)", new ProcessedClusterStateUpdateTask() { - @Override public ClusterState execute(ClusterState currentState) { + @Override + public ClusterState execute(ClusterState currentState) { DiscoveryNodes.Builder builder = new DiscoveryNodes.Builder() .localNodeId(localNode.id()) .masterNodeId(localNode.id()) @@ -276,7 +284,8 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen return newClusterStateBuilder().state(currentState).nodes(builder).blocks(clusterBlocks).build(); } - @Override public void clusterStateProcessed(ClusterState clusterState) { + @Override + public void clusterStateProcessed(ClusterState clusterState) { sendInitialStateEventIfNeeded(); } }); @@ -314,14 +323,16 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen // sync also the version with the version the master currently has, so the next update will be applied final long version = clusterState.version(); clusterService.submitStateUpdateTask("zen-disco-join (detected master)", new ProcessedClusterStateUpdateTask() { - @Override public ClusterState execute(ClusterState currentState) { + @Override + public ClusterState execute(ClusterState currentState) { ClusterBlocks clusterBlocks = ClusterBlocks.builder().blocks(currentState.blocks()).removeGlobalBlock(NO_MASTER_BLOCK).build(); // make sure we have the local node id set, we might need it as a result of the new metadata DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.newNodesBuilder().putAll(currentState.nodes()).put(localNode).localNodeId(localNode.id()); return newClusterStateBuilder().state(currentState).nodes(nodesBuilder).blocks(clusterBlocks).metaData(metaData).version(version).build(); } - @Override public void clusterStateProcessed(ClusterState clusterState) { + @Override + public void clusterStateProcessed(ClusterState clusterState) { // don't send initial state event, since we want to get the cluster state from the master that includes us first // sendInitialStateEventIfNeeded(); } @@ -337,7 +348,8 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen } if (master) { clusterService.submitStateUpdateTask("zen-disco-node_left(" + node + ")", new ClusterStateUpdateTask() { - @Override public ClusterState execute(ClusterState currentState) { + @Override + public ClusterState execute(ClusterState currentState) { DiscoveryNodes.Builder builder = new DiscoveryNodes.Builder() .putAll(currentState.nodes()) .remove(node.id()); @@ -365,7 +377,8 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen return; } clusterService.submitStateUpdateTask("zen-disco-node_failed(" + node + "), reason " + reason, new ProcessedClusterStateUpdateTask() { - @Override public ClusterState execute(ClusterState currentState) { + @Override + public ClusterState execute(ClusterState currentState) { DiscoveryNodes.Builder builder = new DiscoveryNodes.Builder() .putAll(currentState.nodes()) .remove(node.id()); @@ -378,7 +391,8 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen return currentState; } - @Override public void clusterStateProcessed(ClusterState clusterState) { + @Override + public void clusterStateProcessed(ClusterState clusterState) { sendInitialStateEventIfNeeded(); } }); @@ -397,7 +411,8 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen logger.info("master_left [{}], reason [{}]", masterNode, reason); clusterService.submitStateUpdateTask("zen-disco-master_failed (" + masterNode + ")", new ProcessedClusterStateUpdateTask() { - @Override public ClusterState execute(ClusterState currentState) { + @Override + public ClusterState execute(ClusterState currentState) { if (!masterNode.id().equals(currentState.nodes().masterNodeId())) { // master got switched on us, no need to send anything return currentState; @@ -436,7 +451,8 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen } } - @Override public void clusterStateProcessed(ClusterState clusterState) { + @Override + public void clusterStateProcessed(ClusterState clusterState) { sendInitialStateEventIfNeeded(); } @@ -455,7 +471,8 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen } clusterService.submitStateUpdateTask("zen-disco-receive(from master [" + newState.nodes().masterNode() + "])", new ProcessedClusterStateUpdateTask() { - @Override public ClusterState execute(ClusterState currentState) { + @Override + public ClusterState execute(ClusterState currentState) { // we don't need to do this, since we ping the master, and get notified when it has moved from being a master // because it doesn't have enough master nodes... @@ -483,7 +500,8 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen return builder.build(); } - @Override public void clusterStateProcessed(ClusterState clusterState) { + @Override + public void clusterStateProcessed(ClusterState clusterState) { sendInitialStateEventIfNeeded(); } }); @@ -506,7 +524,8 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen state = clusterService.state(); clusterService.submitStateUpdateTask("zen-disco-receive(join from node[" + node + "])", new ClusterStateUpdateTask() { - @Override public ClusterState execute(ClusterState currentState) { + @Override + public ClusterState execute(ClusterState currentState) { if (currentState.nodes().nodeExists(node.id())) { // the node already exists in the cluster logger.warn("received a join request for an existing node [{}]", node); @@ -607,35 +626,41 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen } private class NewClusterStateListener implements PublishClusterStateAction.NewClusterStateListener { - @Override public void onNewClusterState(ClusterState clusterState) { + @Override + public void onNewClusterState(ClusterState clusterState) { handleNewClusterStateFromMaster(clusterState); } } private class MembershipListener implements MembershipAction.MembershipListener { - @Override public ClusterState onJoin(DiscoveryNode node) { + @Override + public ClusterState onJoin(DiscoveryNode node) { return handleJoinRequest(node); } - @Override public void onLeave(DiscoveryNode node) { + @Override + public void onLeave(DiscoveryNode node) { handleLeaveRequest(node); } } private class NodeFailureListener implements NodesFaultDetection.Listener { - @Override public void onNodeFailure(DiscoveryNode node, String reason) { + @Override + public void onNodeFailure(DiscoveryNode node, String reason) { handleNodeFailure(node, reason); } } private class MasterNodeFailureListener implements MasterFaultDetection.Listener { - @Override public void onMasterFailure(DiscoveryNode masterNode, String reason) { + @Override + public void onMasterFailure(DiscoveryNode masterNode, String reason) { handleMasterGone(masterNode, reason); } - @Override public void onDisconnectedFromMaster() { + @Override + public void onDisconnectedFromMaster() { // got disconnected from the master, send a join request DiscoveryNode masterNode = latestDiscoNodes.masterNode(); try { diff --git a/src/main/java/org/elasticsearch/discovery/zen/ZenDiscoveryModule.java b/src/main/java/org/elasticsearch/discovery/zen/ZenDiscoveryModule.java index 3f5cca3838b..202084d586b 100644 --- a/src/main/java/org/elasticsearch/discovery/zen/ZenDiscoveryModule.java +++ b/src/main/java/org/elasticsearch/discovery/zen/ZenDiscoveryModule.java @@ -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,11 +24,12 @@ import org.elasticsearch.discovery.Discovery; import org.elasticsearch.discovery.zen.ping.ZenPingService; /** - * @author kimchy (shay.banon) + * */ public class ZenDiscoveryModule extends AbstractModule { - @Override protected void configure() { + @Override + protected void configure() { bind(ZenPingService.class).asEagerSingleton(); bindDiscovery(); } diff --git a/src/main/java/org/elasticsearch/discovery/zen/elect/ElectMasterService.java b/src/main/java/org/elasticsearch/discovery/zen/elect/ElectMasterService.java index 643763864e3..22a71168bbc 100644 --- a/src/main/java/org/elasticsearch/discovery/zen/elect/ElectMasterService.java +++ b/src/main/java/org/elasticsearch/discovery/zen/elect/ElectMasterService.java @@ -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.discovery.zen.elect; +import com.google.common.collect.Lists; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.node.DiscoveryNode; -import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.node.settings.NodeSettingsService; @@ -32,7 +32,7 @@ import java.util.Iterator; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class ElectMasterService extends AbstractComponent { @@ -112,7 +112,8 @@ public class ElectMasterService extends AbstractComponent { } class ApplySettings implements NodeSettingsService.Listener { - @Override public void onRefreshSettings(Settings settings) { + @Override + public void onRefreshSettings(Settings settings) { int minimumMasterNodes = settings.getAsInt("discovery.zen.minimum_master_nodes", ElectMasterService.this.minimumMasterNodes); if (minimumMasterNodes != ElectMasterService.this.minimumMasterNodes) { logger.info("updating [discovery.zen.minimum_master_nodes] from [{}] to [{}]", ElectMasterService.this.minimumMasterNodes, minimumMasterNodes); @@ -123,7 +124,8 @@ public class ElectMasterService extends AbstractComponent { private static class NodeComparator implements Comparator { - @Override public int compare(DiscoveryNode o1, DiscoveryNode o2) { + @Override + public int compare(DiscoveryNode o1, DiscoveryNode o2) { return o1.id().compareTo(o2.id()); } } diff --git a/src/main/java/org/elasticsearch/discovery/zen/fd/MasterFaultDetection.java b/src/main/java/org/elasticsearch/discovery/zen/fd/MasterFaultDetection.java index 9270e4a08f9..b598d196e41 100644 --- a/src/main/java/org/elasticsearch/discovery/zen/fd/MasterFaultDetection.java +++ b/src/main/java/org/elasticsearch/discovery/zen/fd/MasterFaultDetection.java @@ -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,25 +30,19 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.discovery.zen.DiscoveryNodesProvider; import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.transport.BaseTransportRequestHandler; -import org.elasticsearch.transport.BaseTransportResponseHandler; -import org.elasticsearch.transport.ConnectTransportException; -import org.elasticsearch.transport.TransportChannel; -import org.elasticsearch.transport.TransportConnectionListener; -import org.elasticsearch.transport.TransportException; -import org.elasticsearch.transport.TransportService; +import org.elasticsearch.transport.*; import java.io.IOException; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.atomic.AtomicBoolean; -import static org.elasticsearch.common.unit.TimeValue.*; -import static org.elasticsearch.transport.TransportRequestOptions.*; +import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; +import static org.elasticsearch.transport.TransportRequestOptions.options; /** * A fault detection that pings the master periodically to see if its alive. * - * @author kimchy (shay.banon) + * */ public class MasterFaultDetection extends AbstractComponent { @@ -221,7 +215,8 @@ public class MasterFaultDetection extends AbstractComponent { private void notifyDisconnectedFromMaster() { threadPool.cached().execute(new Runnable() { - @Override public void run() { + @Override + public void run() { for (Listener listener : listeners) { listener.onDisconnectedFromMaster(); } @@ -232,7 +227,8 @@ public class MasterFaultDetection extends AbstractComponent { private void notifyMasterFailure(final DiscoveryNode masterNode, final String reason) { if (notifiedMasterFailure.compareAndSet(false, true)) { threadPool.cached().execute(new Runnable() { - @Override public void run() { + @Override + public void run() { for (Listener listener : listeners) { listener.onMasterFailure(masterNode, reason); } @@ -243,10 +239,12 @@ public class MasterFaultDetection extends AbstractComponent { } private class FDConnectionListener implements TransportConnectionListener { - @Override public void onNodeConnected(DiscoveryNode node) { + @Override + public void onNodeConnected(DiscoveryNode node) { } - @Override public void onNodeDisconnected(DiscoveryNode node) { + @Override + public void onNodeDisconnected(DiscoveryNode node) { handleTransportDisconnect(node); } } @@ -259,7 +257,8 @@ public class MasterFaultDetection extends AbstractComponent { this.running = false; } - @Override public void run() { + @Override + public void run() { if (!running) { // return and don't spawn... return; @@ -272,11 +271,13 @@ public class MasterFaultDetection extends AbstractComponent { } transportService.sendRequest(masterToPing, MasterPingRequestHandler.ACTION, new MasterPingRequest(nodesProvider.nodes().localNode().id(), masterToPing.id()), options().withHighType().withTimeout(pingRetryTimeout), new BaseTransportResponseHandler() { - @Override public MasterPingResponseResponse newInstance() { + @Override + public MasterPingResponseResponse newInstance() { return new MasterPingResponseResponse(); } - @Override public void handleResponse(MasterPingResponseResponse response) { + @Override + public void handleResponse(MasterPingResponseResponse response) { if (!running) { return; } @@ -293,7 +294,8 @@ public class MasterFaultDetection extends AbstractComponent { } } - @Override public void handleException(TransportException exp) { + @Override + public void handleException(TransportException exp) { if (!running) { return; } @@ -322,7 +324,8 @@ public class MasterFaultDetection extends AbstractComponent { } } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } }); @@ -330,7 +333,8 @@ public class MasterFaultDetection extends AbstractComponent { } private static class NoLongerMasterException extends ElasticSearchIllegalStateException { - @Override public Throwable fillInStackTrace() { + @Override + public Throwable fillInStackTrace() { return null; } } @@ -339,11 +343,13 @@ public class MasterFaultDetection extends AbstractComponent { public static final String ACTION = "discovery/zen/fd/masterPing"; - @Override public MasterPingRequest newInstance() { + @Override + public MasterPingRequest newInstance() { return new MasterPingRequest(); } - @Override public void messageReceived(MasterPingRequest request, TransportChannel channel) throws Exception { + @Override + public void messageReceived(MasterPingRequest request, TransportChannel channel) throws Exception { DiscoveryNodes nodes = nodesProvider.nodes(); // check if we are really the same master as the one we seemed to be think we are // this can happen if the master got "kill -9" and then another node started using the same port @@ -358,7 +364,8 @@ public class MasterFaultDetection extends AbstractComponent { channel.sendResponse(new MasterPingResponseResponse(nodes.nodeExists(request.nodeId))); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } } @@ -378,12 +385,14 @@ public class MasterFaultDetection extends AbstractComponent { this.masterNodeId = masterNodeId; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { nodeId = in.readUTF(); masterNodeId = in.readUTF(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(nodeId); out.writeUTF(masterNodeId); } @@ -400,11 +409,13 @@ public class MasterFaultDetection extends AbstractComponent { this.connectedToMaster = connectedToMaster; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { connectedToMaster = in.readBoolean(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(connectedToMaster); } } diff --git a/src/main/java/org/elasticsearch/discovery/zen/fd/NodesFaultDetection.java b/src/main/java/org/elasticsearch/discovery/zen/fd/NodesFaultDetection.java index b4952bdf75c..58f68d9da88 100644 --- a/src/main/java/org/elasticsearch/discovery/zen/fd/NodesFaultDetection.java +++ b/src/main/java/org/elasticsearch/discovery/zen/fd/NodesFaultDetection.java @@ -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,15 +35,15 @@ import java.io.IOException; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.CopyOnWriteArrayList; -import static org.elasticsearch.cluster.node.DiscoveryNodes.*; -import static org.elasticsearch.common.unit.TimeValue.*; -import static org.elasticsearch.common.util.concurrent.ConcurrentCollections.*; -import static org.elasticsearch.transport.TransportRequestOptions.*; +import static org.elasticsearch.cluster.node.DiscoveryNodes.EMPTY_NODES; +import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; +import static org.elasticsearch.common.util.concurrent.ConcurrentCollections.newConcurrentMap; +import static org.elasticsearch.transport.TransportRequestOptions.options; /** * A fault detection of multiple nodes. * - * @author kimchy (shay.banon) + * */ public class NodesFaultDetection extends AbstractComponent { @@ -181,7 +181,8 @@ public class NodesFaultDetection extends AbstractComponent { private void notifyNodeFailure(final DiscoveryNode node, final String reason) { threadPool.cached().execute(new Runnable() { - @Override public void run() { + @Override + public void run() { for (Listener listener : listeners) { listener.onNodeFailure(node, reason); } @@ -197,17 +198,20 @@ public class NodesFaultDetection extends AbstractComponent { this.node = node; } - @Override public void run() { + @Override + public void run() { if (!running) { return; } transportService.sendRequest(node, PingRequestHandler.ACTION, new PingRequest(node.id()), options().withHighType().withTimeout(pingRetryTimeout), new BaseTransportResponseHandler() { - @Override public PingResponse newInstance() { + @Override + public PingResponse newInstance() { return new PingResponse(); } - @Override public void handleResponse(PingResponse response) { + @Override + public void handleResponse(PingResponse response) { if (!running) { return; } @@ -221,7 +225,8 @@ public class NodesFaultDetection extends AbstractComponent { } } - @Override public void handleException(TransportException exp) { + @Override + public void handleException(TransportException exp) { // check if the master node did not get switched on us... if (!running) { return; @@ -251,7 +256,8 @@ public class NodesFaultDetection extends AbstractComponent { } } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } }); @@ -264,10 +270,12 @@ public class NodesFaultDetection extends AbstractComponent { } private class FDConnectionListener implements TransportConnectionListener { - @Override public void onNodeConnected(DiscoveryNode node) { + @Override + public void onNodeConnected(DiscoveryNode node) { } - @Override public void onNodeDisconnected(DiscoveryNode node) { + @Override + public void onNodeDisconnected(DiscoveryNode node) { handleTransportDisconnect(node); } } @@ -277,11 +285,13 @@ public class NodesFaultDetection extends AbstractComponent { public static final String ACTION = "discovery/zen/fd/ping"; - @Override public PingRequest newInstance() { + @Override + public PingRequest newInstance() { return new PingRequest(); } - @Override public void messageReceived(PingRequest request, TransportChannel channel) throws Exception { + @Override + public void messageReceived(PingRequest request, TransportChannel channel) throws Exception { // if we are not the node we are supposed to be pinged, send an exception // this can happen when a kill -9 is sent, and another node is started using the same port if (!latestNodes.localNodeId().equals(request.nodeId)) { @@ -290,7 +300,8 @@ public class NodesFaultDetection extends AbstractComponent { channel.sendResponse(new PingResponse()); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } } @@ -308,11 +319,13 @@ public class NodesFaultDetection extends AbstractComponent { this.nodeId = nodeId; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { nodeId = in.readUTF(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(nodeId); } } @@ -322,10 +335,12 @@ public class NodesFaultDetection extends AbstractComponent { private PingResponse() { } - @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 { } } } diff --git a/src/main/java/org/elasticsearch/discovery/zen/membership/MembershipAction.java b/src/main/java/org/elasticsearch/discovery/zen/membership/MembershipAction.java index dd4547c5c78..1666c88c0e7 100644 --- a/src/main/java/org/elasticsearch/discovery/zen/membership/MembershipAction.java +++ b/src/main/java/org/elasticsearch/discovery/zen/membership/MembershipAction.java @@ -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; import java.util.concurrent.TimeUnit; /** - * @author kimchy (shay.banon) + * */ public class MembershipAction extends AbstractComponent { @@ -82,7 +82,8 @@ public class MembershipAction extends AbstractComponent { public ClusterState sendJoinRequestBlocking(DiscoveryNode masterNode, DiscoveryNode node, TimeValue timeout) throws ElasticSearchException { return transportService.submitRequest(masterNode, JoinRequestRequestHandler.ACTION, new JoinRequest(node, true), new FutureTransportResponseHandler() { - @Override public JoinResponse newInstance() { + @Override + public JoinResponse newInstance() { return new JoinResponse(); } }).txGet(timeout.millis(), TimeUnit.MILLISECONDS).clusterState; @@ -102,12 +103,14 @@ public class MembershipAction extends AbstractComponent { this.withClusterState = withClusterState; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { node = DiscoveryNode.readNode(in); withClusterState = in.readBoolean(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { node.writeTo(out); out.writeBoolean(withClusterState); } @@ -124,11 +127,13 @@ public class MembershipAction extends AbstractComponent { this.clusterState = clusterState; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { clusterState = ClusterState.Builder.readFrom(in, nodesProvider.nodes().localNode()); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { ClusterState.Builder.writeTo(clusterState, out); } } @@ -137,11 +142,13 @@ public class MembershipAction extends AbstractComponent { static final String ACTION = "discovery/zen/join"; - @Override public JoinRequest newInstance() { + @Override + public JoinRequest newInstance() { return new JoinRequest(); } - @Override public void messageReceived(JoinRequest request, TransportChannel channel) throws Exception { + @Override + public void messageReceived(JoinRequest request, TransportChannel channel) throws Exception { ClusterState clusterState = listener.onJoin(request.node); if (request.withClusterState) { channel.sendResponse(new JoinResponse(clusterState)); @@ -150,7 +157,8 @@ public class MembershipAction extends AbstractComponent { } } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.CACHED; } } @@ -166,11 +174,13 @@ public class MembershipAction extends AbstractComponent { this.node = node; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { node = DiscoveryNode.readNode(in); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { node.writeTo(out); } } @@ -179,16 +189,19 @@ public class MembershipAction extends AbstractComponent { static final String ACTION = "discovery/zen/leave"; - @Override public LeaveRequest newInstance() { + @Override + public LeaveRequest newInstance() { return new LeaveRequest(); } - @Override public void messageReceived(LeaveRequest request, TransportChannel channel) throws Exception { + @Override + public void messageReceived(LeaveRequest request, TransportChannel channel) throws Exception { listener.onLeave(request.node); channel.sendResponse(VoidStreamable.INSTANCE); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } } diff --git a/src/main/java/org/elasticsearch/discovery/zen/ping/ZenPing.java b/src/main/java/org/elasticsearch/discovery/zen/ping/ZenPing.java index 121bcaa82be..1172dbb3f37 100644 --- a/src/main/java/org/elasticsearch/discovery/zen/ping/ZenPing.java +++ b/src/main/java/org/elasticsearch/discovery/zen/ping/ZenPing.java @@ -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,11 +31,11 @@ import org.elasticsearch.discovery.zen.DiscoveryNodesProvider; import java.io.IOException; -import static org.elasticsearch.cluster.ClusterName.*; -import static org.elasticsearch.cluster.node.DiscoveryNode.*; +import static org.elasticsearch.cluster.ClusterName.readClusterName; +import static org.elasticsearch.cluster.node.DiscoveryNode.readNode; /** - * @author kimchy (shay.banon) + * */ public interface ZenPing extends LifecycleComponent { @@ -83,7 +83,8 @@ public interface ZenPing extends LifecycleComponent { return response; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { clusterName = readClusterName(in); target = readNode(in); if (in.readBoolean()) { @@ -91,7 +92,8 @@ public interface ZenPing extends LifecycleComponent { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { clusterName.writeTo(out); target.writeTo(out); if (master == null) { @@ -102,7 +104,8 @@ public interface ZenPing extends LifecycleComponent { } } - @Override public String toString() { + @Override + public String toString() { return "ping_response{target [" + target + "], master [" + master + "], cluster_name[" + clusterName.value() + "]}"; } } diff --git a/src/main/java/org/elasticsearch/discovery/zen/ping/ZenPingException.java b/src/main/java/org/elasticsearch/discovery/zen/ping/ZenPingException.java index 6d598e1ffcb..cf9c26bd3f6 100644 --- a/src/main/java/org/elasticsearch/discovery/zen/ping/ZenPingException.java +++ b/src/main/java/org/elasticsearch/discovery/zen/ping/ZenPingException.java @@ -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.discovery.zen.ping; import org.elasticsearch.discovery.DiscoveryException; /** - * @author kimchy (shay.banon) + * */ public class ZenPingException extends DiscoveryException { diff --git a/src/main/java/org/elasticsearch/discovery/zen/ping/ZenPingService.java b/src/main/java/org/elasticsearch/discovery/zen/ping/ZenPingService.java index 9efd4504ade..91689cc7cb2 100644 --- a/src/main/java/org/elasticsearch/discovery/zen/ping/ZenPingService.java +++ b/src/main/java/org/elasticsearch/discovery/zen/ping/ZenPingService.java @@ -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,11 +19,11 @@ package org.elasticsearch.discovery.zen.ping; +import com.google.common.collect.ImmutableList; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.ElasticSearchIllegalStateException; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.node.DiscoveryNode; -import org.elasticsearch.common.collect.ImmutableList; import org.elasticsearch.common.component.AbstractLifecycleComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.network.NetworkService; @@ -42,13 +42,14 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; /** - * @author kimchy (shay.banon) + * */ public class ZenPingService extends AbstractLifecycleComponent implements ZenPing { private volatile ImmutableList zenPings = ImmutableList.of(); - @Inject public ZenPingService(Settings settings, ThreadPool threadPool, TransportService transportService, ClusterName clusterName, NetworkService networkService) { + @Inject + public ZenPingService(Settings settings, ThreadPool threadPool, TransportService transportService, ClusterName clusterName, NetworkService networkService) { super(settings); ImmutableList.Builder zenPingsBuilder = ImmutableList.builder(); @@ -78,7 +79,8 @@ public class ZenPingService extends AbstractLifecycleComponent implemen } } - @Override public void setNodesProvider(DiscoveryNodesProvider nodesProvider) { + @Override + public void setNodesProvider(DiscoveryNodesProvider nodesProvider) { if (lifecycle.started()) { throw new ElasticSearchIllegalStateException("Can't set nodes provider when started"); } @@ -87,19 +89,22 @@ public class ZenPingService extends AbstractLifecycleComponent implemen } } - @Override protected void doStart() throws ElasticSearchException { + @Override + protected void doStart() throws ElasticSearchException { for (ZenPing zenPing : zenPings) { zenPing.start(); } } - @Override protected void doStop() throws ElasticSearchException { + @Override + protected void doStop() throws ElasticSearchException { for (ZenPing zenPing : zenPings) { zenPing.stop(); } } - @Override protected void doClose() throws ElasticSearchException { + @Override + protected void doClose() throws ElasticSearchException { for (ZenPing zenPing : zenPings) { zenPing.close(); } @@ -109,7 +114,8 @@ public class ZenPingService extends AbstractLifecycleComponent implemen final AtomicReference response = new AtomicReference(); final CountDownLatch latch = new CountDownLatch(1); ping(new PingListener() { - @Override public void onPing(PingResponse[] pings) { + @Override + public void onPing(PingResponse[] pings) { response.set(pings); latch.countDown(); } @@ -122,7 +128,8 @@ public class ZenPingService extends AbstractLifecycleComponent implemen } } - @Override public void ping(PingListener listener, TimeValue timeout) throws ElasticSearchException { + @Override + public void ping(PingListener listener, TimeValue timeout) throws ElasticSearchException { ImmutableList zenPings = this.zenPings; CompoundPingListener compoundPingListener = new CompoundPingListener(listener, zenPings); for (ZenPing zenPing : zenPings) { @@ -146,7 +153,8 @@ public class ZenPingService extends AbstractLifecycleComponent implemen this.counter = new AtomicInteger(zenPings.size()); } - @Override public void onPing(PingResponse[] pings) { + @Override + public void onPing(PingResponse[] pings) { if (pings != null) { for (PingResponse pingResponse : pings) { responses.put(pingResponse.target(), pingResponse); diff --git a/src/main/java/org/elasticsearch/discovery/zen/ping/multicast/MulticastZenPing.java b/src/main/java/org/elasticsearch/discovery/zen/ping/multicast/MulticastZenPing.java index 5421922bcfc..eaf99c34d5e 100644 --- a/src/main/java/org/elasticsearch/discovery/zen/ping/multicast/MulticastZenPing.java +++ b/src/main/java/org/elasticsearch/discovery/zen/ping/multicast/MulticastZenPing.java @@ -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,14 +25,7 @@ import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.common.component.AbstractLifecycleComponent; -import org.elasticsearch.common.io.stream.BytesStreamInput; -import org.elasticsearch.common.io.stream.CachedStreamInput; -import org.elasticsearch.common.io.stream.CachedStreamOutput; -import org.elasticsearch.common.io.stream.HandlesStreamOutput; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.io.stream.Streamable; -import org.elasticsearch.common.io.stream.VoidStreamable; +import org.elasticsearch.common.io.stream.*; import org.elasticsearch.common.network.NetworkService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; @@ -40,11 +33,7 @@ import org.elasticsearch.discovery.zen.DiscoveryNodesProvider; import org.elasticsearch.discovery.zen.ping.ZenPing; import org.elasticsearch.discovery.zen.ping.ZenPingException; 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.net.DatagramPacket; @@ -58,13 +47,13 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; -import static org.elasticsearch.cluster.node.DiscoveryNode.*; -import static org.elasticsearch.common.settings.ImmutableSettings.Builder.*; -import static org.elasticsearch.common.util.concurrent.ConcurrentCollections.*; -import static org.elasticsearch.common.util.concurrent.EsExecutors.*; +import static org.elasticsearch.cluster.node.DiscoveryNode.readNode; +import static org.elasticsearch.common.settings.ImmutableSettings.Builder.EMPTY_SETTINGS; +import static org.elasticsearch.common.util.concurrent.ConcurrentCollections.newConcurrentMap; +import static org.elasticsearch.common.util.concurrent.EsExecutors.daemonThreadFactory; /** - * @author kimchy (shay.banon) + * */ public class MulticastZenPing extends AbstractLifecycleComponent implements ZenPing { @@ -129,14 +118,16 @@ public class MulticastZenPing extends AbstractLifecycleComponent implem this.transportService.registerHandler(MulticastPingResponseRequestHandler.ACTION, new MulticastPingResponseRequestHandler()); } - @Override public void setNodesProvider(DiscoveryNodesProvider nodesProvider) { + @Override + public void setNodesProvider(DiscoveryNodesProvider nodesProvider) { if (lifecycle.started()) { throw new ElasticSearchIllegalStateException("Can't set nodes provider when started"); } this.nodesProvider = nodesProvider; } - @Override protected void doStart() throws ElasticSearchException { + @Override + protected void doStart() throws ElasticSearchException { try { this.datagramPacketReceive = new DatagramPacket(new byte[bufferSize], bufferSize); this.datagramPacketSend = new DatagramPacket(new byte[bufferSize], bufferSize, InetAddress.getByName(group), port); @@ -192,7 +183,8 @@ public class MulticastZenPing extends AbstractLifecycleComponent implem } } - @Override protected void doStop() throws ElasticSearchException { + @Override + protected void doStop() throws ElasticSearchException { if (receiver != null) { receiver.stop(); } @@ -205,14 +197,16 @@ public class MulticastZenPing extends AbstractLifecycleComponent implem } } - @Override protected void doClose() throws ElasticSearchException { + @Override + protected void doClose() throws ElasticSearchException { } public PingResponse[] pingAndWait(TimeValue timeout) { final AtomicReference response = new AtomicReference(); final CountDownLatch latch = new CountDownLatch(1); ping(new PingListener() { - @Override public void onPing(PingResponse[] pings) { + @Override + public void onPing(PingResponse[] pings) { response.set(pings); latch.countDown(); } @@ -225,14 +219,16 @@ public class MulticastZenPing extends AbstractLifecycleComponent implem } } - @Override public void ping(final PingListener listener, final TimeValue timeout) { + @Override + public void ping(final PingListener listener, final TimeValue timeout) { final int id = pingIdGenerator.incrementAndGet(); receivedResponses.put(id, new ConcurrentHashMap()); sendPingRequest(id, true); // try and send another ping request halfway through (just in case someone woke up during it...) // this can be a good trade-off to nailing the initial lookup or un-delivered messages threadPool.schedule(TimeValue.timeValueMillis(timeout.millis() / 2), ThreadPool.Names.CACHED, new Runnable() { - @Override public void run() { + @Override + public void run() { try { sendPingRequest(id, false); } catch (Exception e) { @@ -241,7 +237,8 @@ public class MulticastZenPing extends AbstractLifecycleComponent implem } }); threadPool.schedule(timeout, ThreadPool.Names.CACHED, new Runnable() { - @Override public void run() { + @Override + public void run() { ConcurrentMap responses = receivedResponses.remove(id); listener.onPing(responses.values().toArray(new PingResponse[responses.size()])); } @@ -289,11 +286,13 @@ public class MulticastZenPing extends AbstractLifecycleComponent implem static final String ACTION = "discovery/zen/multicast"; - @Override public MulticastPingResponse newInstance() { + @Override + public MulticastPingResponse newInstance() { return new MulticastPingResponse(); } - @Override public void messageReceived(MulticastPingResponse request, TransportChannel channel) throws Exception { + @Override + public void messageReceived(MulticastPingResponse request, TransportChannel channel) throws Exception { if (logger.isTraceEnabled()) { logger.trace("[{}] received {}", request.id, request.pingResponse); } @@ -306,7 +305,8 @@ public class MulticastZenPing extends AbstractLifecycleComponent implem channel.sendResponse(VoidStreamable.INSTANCE); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } } @@ -320,12 +320,14 @@ public class MulticastZenPing extends AbstractLifecycleComponent implem MulticastPingResponse() { } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { id = in.readInt(); pingResponse = PingResponse.readPingResponse(in); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeInt(id); pingResponse.writeTo(out); } @@ -340,7 +342,8 @@ public class MulticastZenPing extends AbstractLifecycleComponent implem running = false; } - @Override public void run() { + @Override + public void run() { while (running) { try { int id; @@ -397,12 +400,14 @@ public class MulticastZenPing extends AbstractLifecycleComponent implem if (!transportService.nodeConnected(requestingNode)) { // do the connect and send on a thread pool threadPool.cached().execute(new Runnable() { - @Override public void run() { + @Override + public void run() { // connect to the node if possible try { transportService.connectToNode(requestingNode); transportService.sendRequest(requestingNode, MulticastPingResponseRequestHandler.ACTION, multicastPingResponse, new VoidTransportResponseHandler(ThreadPool.Names.SAME) { - @Override public void handleException(TransportException exp) { + @Override + public void handleException(TransportException exp) { logger.warn("failed to receive confirmation on sent ping response to [{}]", exp, requestingNode); } }); @@ -413,7 +418,8 @@ public class MulticastZenPing extends AbstractLifecycleComponent implem }); } else { transportService.sendRequest(requestingNode, MulticastPingResponseRequestHandler.ACTION, multicastPingResponse, new VoidTransportResponseHandler(ThreadPool.Names.SAME) { - @Override public void handleException(TransportException exp) { + @Override + public void handleException(TransportException exp) { logger.warn("failed to receive confirmation on sent ping response to [{}]", exp, requestingNode); } }); diff --git a/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastHostsProvider.java b/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastHostsProvider.java index 92f95df312a..1b5f8365737 100644 --- a/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastHostsProvider.java +++ b/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastHostsProvider.java @@ -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.cluster.node.DiscoveryNode; import java.util.List; /** - * @author kimchy (Shay Banon) + * */ public interface UnicastHostsProvider { diff --git a/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java b/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java index 0c9a7751e0c..e1acde6b15a 100644 --- a/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java +++ b/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java @@ -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,14 @@ package org.elasticsearch.discovery.zen.ping.unicast; +import com.google.common.collect.Lists; +import jsr166y.LinkedTransferQueue; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.component.AbstractLifecycleComponent; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -36,43 +37,25 @@ import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.concurrent.ConcurrentCollections; import org.elasticsearch.common.util.concurrent.DynamicExecutors; import org.elasticsearch.common.util.concurrent.EsExecutors; -import org.elasticsearch.common.util.concurrent.jsr166y.LinkedTransferQueue; import org.elasticsearch.discovery.zen.DiscoveryNodesProvider; import org.elasticsearch.discovery.zen.ping.ZenPing; import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.transport.BaseTransportRequestHandler; -import org.elasticsearch.transport.BaseTransportResponseHandler; -import org.elasticsearch.transport.ConnectTransportException; -import org.elasticsearch.transport.TransportChannel; -import org.elasticsearch.transport.TransportException; -import org.elasticsearch.transport.TransportRequestOptions; -import org.elasticsearch.transport.TransportService; +import org.elasticsearch.transport.*; import java.io.IOException; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.Queue; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.Executor; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.TimeUnit; +import java.util.*; +import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; -import static org.elasticsearch.common.collect.Lists.*; -import static org.elasticsearch.common.settings.ImmutableSettings.Builder.*; -import static org.elasticsearch.common.unit.TimeValue.*; -import static org.elasticsearch.common.util.concurrent.ConcurrentCollections.*; -import static org.elasticsearch.discovery.zen.ping.ZenPing.PingResponse.*; +import static com.google.common.collect.Lists.newArrayList; +import static org.elasticsearch.common.settings.ImmutableSettings.Builder.EMPTY_SETTINGS; +import static org.elasticsearch.common.unit.TimeValue.readTimeValue; +import static org.elasticsearch.common.util.concurrent.ConcurrentCollections.newConcurrentMap; +import static org.elasticsearch.discovery.zen.ping.ZenPing.PingResponse.readPingResponse; /** - * @author kimchy (shay.banon) + * */ public class UnicastZenPing extends AbstractLifecycleComponent implements ZenPing { @@ -136,13 +119,16 @@ public class UnicastZenPing extends AbstractLifecycleComponent implemen transportService.registerHandler(UnicastPingRequestHandler.ACTION, new UnicastPingRequestHandler()); } - @Override protected void doStart() throws ElasticSearchException { + @Override + protected void doStart() throws ElasticSearchException { } - @Override protected void doStop() throws ElasticSearchException { + @Override + protected void doStop() throws ElasticSearchException { } - @Override protected void doClose() throws ElasticSearchException { + @Override + protected void doClose() throws ElasticSearchException { transportService.removeHandler(UnicastPingRequestHandler.ACTION); } @@ -154,7 +140,8 @@ public class UnicastZenPing extends AbstractLifecycleComponent implemen hostsProviders.remove(provider); } - @Override public void setNodesProvider(DiscoveryNodesProvider nodesProvider) { + @Override + public void setNodesProvider(DiscoveryNodesProvider nodesProvider) { this.nodesProvider = nodesProvider; } @@ -162,7 +149,8 @@ public class UnicastZenPing extends AbstractLifecycleComponent implemen final AtomicReference response = new AtomicReference(); final CountDownLatch latch = new CountDownLatch(1); ping(new PingListener() { - @Override public void onPing(PingResponse[] pings) { + @Override + public void onPing(PingResponse[] pings) { response.set(pings); latch.countDown(); } @@ -175,15 +163,18 @@ public class UnicastZenPing extends AbstractLifecycleComponent implemen } } - @Override public void ping(final PingListener listener, final TimeValue timeout) throws ElasticSearchException { + @Override + public void ping(final PingListener listener, final TimeValue timeout) throws ElasticSearchException { final SendPingsHandler sendPingsHandler = new SendPingsHandler(pingIdGenerator.incrementAndGet()); receivedResponses.put(sendPingsHandler.id(), new ConcurrentHashMap()); sendPings(timeout, null, sendPingsHandler); threadPool.schedule(TimeValue.timeValueMillis(timeout.millis() / 2), ThreadPool.Names.CACHED, new Runnable() { - @Override public void run() { + @Override + public void run() { sendPings(timeout, null, sendPingsHandler); threadPool.schedule(TimeValue.timeValueMillis(timeout.millis() / 2), ThreadPool.Names.CACHED, new Runnable() { - @Override public void run() { + @Override + public void run() { sendPings(timeout, TimeValue.timeValueMillis(timeout.millis() / 2), sendPingsHandler); ConcurrentMap responses = receivedResponses.remove(sendPingsHandler.id()); listener.onPing(responses.values().toArray(new PingResponse[responses.size()])); @@ -266,7 +257,8 @@ public class UnicastZenPing extends AbstractLifecycleComponent implemen sendPingsHandler.nodeToDisconnect.add(nodeToSend); // fork the connection to another thread sendPingsHandler.executor().execute(new Runnable() { - @Override public void run() { + @Override + public void run() { try { // connect to the node, see if we manage to do it, if not, bail if (!nodeFoundByAddress) { @@ -300,15 +292,18 @@ public class UnicastZenPing extends AbstractLifecycleComponent implemen logger.trace("[{}] connecting to {}", id, nodeToSend); transportService.sendRequest(nodeToSend, UnicastPingRequestHandler.ACTION, pingRequest, TransportRequestOptions.options().withTimeout((long) (timeout.millis() * 1.25)), new BaseTransportResponseHandler() { - @Override public UnicastPingResponse newInstance() { + @Override + public UnicastPingResponse newInstance() { return new UnicastPingResponse(); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } - @Override public void handleResponse(UnicastPingResponse response) { + @Override + public void handleResponse(UnicastPingResponse response) { logger.trace("[{}] received response from {}: {}", id, nodeToSend, Arrays.toString(response.pingResponses)); try { DiscoveryNodes discoveryNodes = nodesProvider.nodes(); @@ -334,7 +329,8 @@ public class UnicastZenPing extends AbstractLifecycleComponent implemen } } - @Override public void handleException(TransportException exp) { + @Override + public void handleException(TransportException exp) { latch.countDown(); if (exp instanceof ConnectTransportException) { // ok, not connected... @@ -349,7 +345,8 @@ public class UnicastZenPing extends AbstractLifecycleComponent implemen private UnicastPingResponse handlePingRequest(final UnicastPingRequest request) { temporalResponses.add(request.pingResponse); threadPool.schedule(TimeValue.timeValueMillis(request.timeout.millis() * 2), ThreadPool.Names.SAME, new Runnable() { - @Override public void run() { + @Override + public void run() { temporalResponses.remove(request.pingResponse); } }); @@ -370,15 +367,18 @@ public class UnicastZenPing extends AbstractLifecycleComponent implemen static final String ACTION = "discovery/zen/unicast"; - @Override public UnicastPingRequest newInstance() { + @Override + public UnicastPingRequest newInstance() { return new UnicastPingRequest(); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } - @Override public void messageReceived(UnicastPingRequest request, TransportChannel channel) throws Exception { + @Override + public void messageReceived(UnicastPingRequest request, TransportChannel channel) throws Exception { channel.sendResponse(handlePingRequest(request)); } } @@ -394,13 +394,15 @@ public class UnicastZenPing extends AbstractLifecycleComponent implemen UnicastPingRequest() { } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { id = in.readInt(); timeout = readTimeValue(in); pingResponse = readPingResponse(in); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeInt(id); timeout.writeTo(out); pingResponse.writeTo(out); @@ -416,7 +418,8 @@ public class UnicastZenPing extends AbstractLifecycleComponent implemen UnicastPingResponse() { } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { id = in.readInt(); pingResponses = new PingResponse[in.readVInt()]; for (int i = 0; i < pingResponses.length; i++) { @@ -424,7 +427,8 @@ public class UnicastZenPing extends AbstractLifecycleComponent implemen } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeInt(id); out.writeVInt(pingResponses.length); for (PingResponse pingResponse : pingResponses) { diff --git a/src/main/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateAction.java b/src/main/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateAction.java index 32794dce593..db1ef3f1dd3 100644 --- a/src/main/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateAction.java +++ b/src/main/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateAction.java @@ -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,7 +31,7 @@ import org.elasticsearch.transport.*; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class PublishClusterStateAction extends AbstractComponent { @@ -87,7 +87,8 @@ public class PublishClusterStateAction extends AbstractComponent { TransportRequestOptions.options().withHighType().withCompress(false), // no need to compress, we already compressed the bytes new VoidTransportResponseHandler(ThreadPool.Names.SAME) { - @Override public void handleException(TransportException exp) { + @Override + public void handleException(TransportException exp) { logger.debug("failed to send cluster state to [{}], should be detected as failed soon...", exp, node); } }); @@ -105,12 +106,14 @@ public class PublishClusterStateAction extends AbstractComponent { this.clusterStateInBytes = clusterStateInBytes; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { clusterStateInBytes = new byte[in.readVInt()]; in.readFully(clusterStateInBytes); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeVInt(clusterStateInBytes.length); out.writeBytes(clusterStateInBytes); } @@ -120,18 +123,21 @@ public class PublishClusterStateAction extends AbstractComponent { static final String ACTION = "discovery/zen/publish"; - @Override public PublishClusterStateRequest newInstance() { + @Override + public PublishClusterStateRequest newInstance() { return new PublishClusterStateRequest(); } - @Override public void messageReceived(PublishClusterStateRequest request, TransportChannel channel) throws Exception { + @Override + public void messageReceived(PublishClusterStateRequest request, TransportChannel channel) throws Exception { StreamInput in = CachedStreamInput.cachedHandlesLzf(new BytesStreamInput(request.clusterStateInBytes)); ClusterState clusterState = ClusterState.Builder.readFrom(in, nodesProvider.nodes().localNode()); listener.onNewClusterState(clusterState); channel.sendResponse(VoidStreamable.INSTANCE); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } } diff --git a/src/main/java/org/elasticsearch/env/Environment.java b/src/main/java/org/elasticsearch/env/Environment.java index ae1826bc12c..68a98900ddf 100644 --- a/src/main/java/org/elasticsearch/env/Environment.java +++ b/src/main/java/org/elasticsearch/env/Environment.java @@ -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,13 +30,13 @@ import java.io.InputStreamReader; import java.net.MalformedURLException; import java.net.URL; -import static org.elasticsearch.common.Strings.*; -import static org.elasticsearch.common.settings.ImmutableSettings.Builder.*; +import static org.elasticsearch.common.Strings.cleanPath; +import static org.elasticsearch.common.settings.ImmutableSettings.Builder.EMPTY_SETTINGS; /** * The environment of where things exists. * - * @author kimchy (shay.banon) + * */ public class Environment { diff --git a/src/main/java/org/elasticsearch/env/EnvironmentModule.java b/src/main/java/org/elasticsearch/env/EnvironmentModule.java index bc04fe442a5..bbe81541491 100644 --- a/src/main/java/org/elasticsearch/env/EnvironmentModule.java +++ b/src/main/java/org/elasticsearch/env/EnvironmentModule.java @@ -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.env; import org.elasticsearch.common.inject.AbstractModule; /** - * @author kimchy (shay.banon) + * */ public class EnvironmentModule extends AbstractModule { @@ -32,7 +32,8 @@ public class EnvironmentModule extends AbstractModule { this.environment = environment; } - @Override protected void configure() { + @Override + protected void configure() { bind(Environment.class).toInstance(environment); } } diff --git a/src/main/java/org/elasticsearch/env/FailedToResolveConfigException.java b/src/main/java/org/elasticsearch/env/FailedToResolveConfigException.java index 898bf1b476a..0f4ba41f3fa 100644 --- a/src/main/java/org/elasticsearch/env/FailedToResolveConfigException.java +++ b/src/main/java/org/elasticsearch/env/FailedToResolveConfigException.java @@ -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.env; import org.elasticsearch.ElasticSearchException; /** - * @author kimchy (Shay Banon) + * */ public class FailedToResolveConfigException extends ElasticSearchException { diff --git a/src/main/java/org/elasticsearch/env/NodeEnvironment.java b/src/main/java/org/elasticsearch/env/NodeEnvironment.java index 4e52093d7a8..cf29afa36c9 100644 --- a/src/main/java/org/elasticsearch/env/NodeEnvironment.java +++ b/src/main/java/org/elasticsearch/env/NodeEnvironment.java @@ -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 java.io.File; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class NodeEnvironment extends AbstractComponent { @@ -46,7 +46,8 @@ public class NodeEnvironment extends AbstractComponent { private final int localNodeId; - @Inject public NodeEnvironment(Settings settings, Environment environment) throws IOException { + @Inject + public NodeEnvironment(Settings settings, Environment environment) throws IOException { super(settings); if (!DiscoveryNode.nodeRequiresLocalStorage(settings)) { diff --git a/src/main/java/org/elasticsearch/env/NodeEnvironmentModule.java b/src/main/java/org/elasticsearch/env/NodeEnvironmentModule.java index 3a5bdd9cfdf..c86d9367e82 100644 --- a/src/main/java/org/elasticsearch/env/NodeEnvironmentModule.java +++ b/src/main/java/org/elasticsearch/env/NodeEnvironmentModule.java @@ -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,14 +22,15 @@ package org.elasticsearch.env; import org.elasticsearch.common.inject.AbstractModule; /** - * @author kimchy (shay.banon) + * */ public class NodeEnvironmentModule extends AbstractModule { public NodeEnvironmentModule() { } - @Override protected void configure() { + @Override + protected void configure() { bind(NodeEnvironment.class).asEagerSingleton(); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/gateway/Gateway.java b/src/main/java/org/elasticsearch/gateway/Gateway.java index 76f26143297..8fdd5a84190 100644 --- a/src/main/java/org/elasticsearch/gateway/Gateway.java +++ b/src/main/java/org/elasticsearch/gateway/Gateway.java @@ -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.common.component.LifecycleComponent; import org.elasticsearch.common.inject.Module; /** - * @author kimchy (shay.banon) + * */ public interface Gateway extends LifecycleComponent { diff --git a/src/main/java/org/elasticsearch/gateway/GatewayException.java b/src/main/java/org/elasticsearch/gateway/GatewayException.java index 8a7a35ce255..b7176c0d96c 100644 --- a/src/main/java/org/elasticsearch/gateway/GatewayException.java +++ b/src/main/java/org/elasticsearch/gateway/GatewayException.java @@ -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.gateway; import org.elasticsearch.ElasticSearchException; /** - * @author kimchy (Shay Banon) + * */ public class GatewayException extends ElasticSearchException { diff --git a/src/main/java/org/elasticsearch/gateway/GatewayModule.java b/src/main/java/org/elasticsearch/gateway/GatewayModule.java index 14b10d4d85e..ee03f2fa48d 100644 --- a/src/main/java/org/elasticsearch/gateway/GatewayModule.java +++ b/src/main/java/org/elasticsearch/gateway/GatewayModule.java @@ -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,7 +19,7 @@ package org.elasticsearch.gateway; -import org.elasticsearch.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.inject.Modules; @@ -28,7 +28,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.gateway.local.LocalGatewayModule; /** - * @author kimchy (shay.banon) + * */ public class GatewayModule extends AbstractModule implements SpawnModules { @@ -38,11 +38,13 @@ public class GatewayModule extends AbstractModule implements SpawnModules { this.settings = settings; } - @Override public Iterable spawnModules() { + @Override + public Iterable spawnModules() { return ImmutableList.of(Modules.createModule(settings.getAsClass("gateway.type", LocalGatewayModule.class, "org.elasticsearch.gateway.", "GatewayModule"), settings)); } - @Override protected void configure() { + @Override + protected void configure() { bind(GatewayService.class).asEagerSingleton(); } } diff --git a/src/main/java/org/elasticsearch/gateway/GatewayService.java b/src/main/java/org/elasticsearch/gateway/GatewayService.java index 94bf0a37fa7..13e1a4722ca 100644 --- a/src/main/java/org/elasticsearch/gateway/GatewayService.java +++ b/src/main/java/org/elasticsearch/gateway/GatewayService.java @@ -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,19 +20,11 @@ package org.elasticsearch.gateway; import org.elasticsearch.ElasticSearchException; -import org.elasticsearch.cluster.ClusterChangedEvent; -import org.elasticsearch.cluster.ClusterService; -import org.elasticsearch.cluster.ClusterState; -import org.elasticsearch.cluster.ClusterStateListener; -import org.elasticsearch.cluster.ProcessedClusterStateUpdateTask; +import org.elasticsearch.cluster.*; import org.elasticsearch.cluster.block.ClusterBlock; import org.elasticsearch.cluster.block.ClusterBlockLevel; import org.elasticsearch.cluster.block.ClusterBlocks; -import org.elasticsearch.cluster.metadata.IndexMetaData; -import org.elasticsearch.cluster.metadata.IndexTemplateMetaData; -import org.elasticsearch.cluster.metadata.MetaData; -import org.elasticsearch.cluster.metadata.MetaDataCreateIndexService; -import org.elasticsearch.cluster.metadata.MetaDataStateIndexService; +import org.elasticsearch.cluster.metadata.*; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.cluster.routing.IndexRoutingTable; import org.elasticsearch.cluster.routing.RoutingTable; @@ -50,11 +42,11 @@ import java.util.Map; import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicBoolean; -import static org.elasticsearch.cluster.ClusterState.*; -import static org.elasticsearch.cluster.metadata.MetaData.*; +import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; +import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; /** - * @author kimchy (shay.banon) + * */ public class GatewayService extends AbstractLifecycleComponent implements ClusterStateListener { @@ -84,7 +76,8 @@ public class GatewayService extends AbstractLifecycleComponent i private final AtomicBoolean recovered = new AtomicBoolean(); private final AtomicBoolean scheduledRecovery = new AtomicBoolean(); - @Inject public GatewayService(Settings settings, Gateway gateway, AllocationService allocationService, ClusterService clusterService, DiscoveryService discoveryService, MetaDataCreateIndexService createIndexService, ThreadPool threadPool) { + @Inject + public GatewayService(Settings settings, Gateway gateway, AllocationService allocationService, ClusterService clusterService, DiscoveryService discoveryService, MetaDataCreateIndexService createIndexService, ThreadPool threadPool) { super(settings); this.gateway = gateway; this.allocationService = allocationService; @@ -105,7 +98,8 @@ public class GatewayService extends AbstractLifecycleComponent i this.clusterService.addInitialStateBlock(STATE_NOT_RECOVERED_BLOCK); } - @Override protected void doStart() throws ElasticSearchException { + @Override + protected void doStart() throws ElasticSearchException { gateway.start(); // if we received initial state, see if we can recover within the start phase, so we hold the // node from starting until we recovered properly @@ -148,16 +142,19 @@ public class GatewayService extends AbstractLifecycleComponent i clusterService.add(this); } - @Override protected void doStop() throws ElasticSearchException { + @Override + protected void doStop() throws ElasticSearchException { clusterService.remove(this); gateway.stop(); } - @Override protected void doClose() throws ElasticSearchException { + @Override + protected void doClose() throws ElasticSearchException { gateway.close(); } - @Override public void clusterChanged(final ClusterChangedEvent event) { + @Override + public void clusterChanged(final ClusterChangedEvent event) { if (lifecycle.stoppedOrClosed()) { return; } @@ -198,7 +195,8 @@ public class GatewayService extends AbstractLifecycleComponent i } final boolean fIgnoreRecoverAfterTime = ignoreRecoverAfterTime; threadPool.cached().execute(new Runnable() { - @Override public void run() { + @Override + public void run() { performStateRecovery(fIgnoreRecoverAfterTime); } }); @@ -213,7 +211,8 @@ public class GatewayService extends AbstractLifecycleComponent i if (scheduledRecovery.compareAndSet(false, true)) { logger.debug("delaying initial state recovery for [{}]", recoverAfterTime); threadPool.schedule(recoverAfterTime, ThreadPool.Names.CACHED, new Runnable() { - @Override public void run() { + @Override + public void run() { if (recovered.compareAndSet(false, true)) { gateway.performStateRecovery(recoveryListener); } @@ -235,9 +234,11 @@ public class GatewayService extends AbstractLifecycleComponent i this.latch = latch; } - @Override public void onSuccess(final ClusterState recoveredState) { + @Override + public void onSuccess(final ClusterState recoveredState) { clusterService.submitStateUpdateTask("local-gateway-elected-state", new ProcessedClusterStateUpdateTask() { - @Override public ClusterState execute(ClusterState currentState) { + @Override + public ClusterState execute(ClusterState currentState) { assert currentState.metaData().indices().isEmpty(); // remove the block, since we recovered from gateway @@ -288,14 +289,16 @@ public class GatewayService extends AbstractLifecycleComponent i return newClusterStateBuilder().state(updatedState).routingResult(routingResult).build(); } - @Override public void clusterStateProcessed(ClusterState clusterState) { + @Override + public void clusterStateProcessed(ClusterState clusterState) { logger.info("recovered [{}] indices into cluster_state", clusterState.metaData().indices().size()); latch.countDown(); } }); } - @Override public void onFailure(Throwable t) { + @Override + public void onFailure(Throwable t) { // don't remove the block here, we don't want to allow anything in such a case logger.error("failed recover state, blocking...", t); } diff --git a/src/main/java/org/elasticsearch/gateway/blobstore/BlobReuseExistingGatewayAllocator.java b/src/main/java/org/elasticsearch/gateway/blobstore/BlobReuseExistingGatewayAllocator.java index cfc35ed5709..2b3f79cfe91 100644 --- a/src/main/java/org/elasticsearch/gateway/blobstore/BlobReuseExistingGatewayAllocator.java +++ b/src/main/java/org/elasticsearch/gateway/blobstore/BlobReuseExistingGatewayAllocator.java @@ -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,8 @@ package org.elasticsearch.gateway.blobstore; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodes; @@ -31,8 +33,6 @@ import org.elasticsearch.cluster.routing.allocation.RoutingAllocation; import org.elasticsearch.cluster.routing.allocation.StartedRerouteAllocation; import org.elasticsearch.cluster.routing.allocation.allocator.GatewayAllocator; import org.elasticsearch.cluster.routing.allocation.decider.AllocationDecider; -import org.elasticsearch.common.collect.Maps; -import org.elasticsearch.common.collect.Sets; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -54,7 +54,7 @@ import java.util.Set; import java.util.concurrent.ConcurrentMap; /** - * @author kimchy (shay.banon) + * */ public class BlobReuseExistingGatewayAllocator extends AbstractComponent implements GatewayAllocator { @@ -68,8 +68,9 @@ public class BlobReuseExistingGatewayAllocator extends AbstractComponent impleme private final ConcurrentMap> cachedStores = ConcurrentCollections.newConcurrentMap(); - @Inject public BlobReuseExistingGatewayAllocator(Settings settings, Node node, - TransportNodesListShardStoreMetaData transportNodesListShardStoreMetaData) { + @Inject + public BlobReuseExistingGatewayAllocator(Settings settings, Node node, + TransportNodesListShardStoreMetaData transportNodesListShardStoreMetaData) { super(settings); this.node = node; // YACK!, we need the Gateway, but it creates crazy circular dependency this.listShardStoreMetaData = transportNodesListShardStoreMetaData; @@ -77,19 +78,22 @@ public class BlobReuseExistingGatewayAllocator extends AbstractComponent impleme this.listTimeout = componentSettings.getAsTime("list_timeout", TimeValue.timeValueSeconds(30)); } - @Override public void applyStartedShards(StartedRerouteAllocation allocation) { + @Override + public void applyStartedShards(StartedRerouteAllocation allocation) { for (ShardRouting shardRouting : allocation.startedShards()) { cachedCommitPoints.remove(shardRouting.shardId()); cachedStores.remove(shardRouting.shardId()); } } - @Override public void applyFailedShards(FailedRerouteAllocation allocation) { + @Override + public void applyFailedShards(FailedRerouteAllocation allocation) { cachedCommitPoints.remove(allocation.failedShard().shardId()); cachedStores.remove(allocation.failedShard().shardId()); } - @Override public boolean allocateUnassigned(RoutingAllocation allocation) { + @Override + public boolean allocateUnassigned(RoutingAllocation allocation) { boolean changed = false; DiscoveryNodes nodes = allocation.nodes(); diff --git a/src/main/java/org/elasticsearch/gateway/blobstore/BlobStoreGateway.java b/src/main/java/org/elasticsearch/gateway/blobstore/BlobStoreGateway.java index 21fdbdad2ec..23463e7ccf6 100644 --- a/src/main/java/org/elasticsearch/gateway/blobstore/BlobStoreGateway.java +++ b/src/main/java/org/elasticsearch/gateway/blobstore/BlobStoreGateway.java @@ -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,30 +19,18 @@ package org.elasticsearch.gateway.blobstore; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Lists; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.blobstore.BlobContainer; -import org.elasticsearch.common.blobstore.BlobMetaData; -import org.elasticsearch.common.blobstore.BlobPath; -import org.elasticsearch.common.blobstore.BlobStore; -import org.elasticsearch.common.blobstore.ImmutableBlobContainer; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.Lists; +import org.elasticsearch.common.blobstore.*; import org.elasticsearch.common.compress.lzf.LZF; -import org.elasticsearch.common.io.stream.BytesStreamInput; -import org.elasticsearch.common.io.stream.CachedStreamInput; -import org.elasticsearch.common.io.stream.CachedStreamOutput; -import org.elasticsearch.common.io.stream.LZFStreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.io.stream.*; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.ByteSizeValue; -import org.elasticsearch.common.xcontent.ToXContent; -import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.common.xcontent.XContentFactory; -import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.common.xcontent.XContentType; +import org.elasticsearch.common.xcontent.*; import org.elasticsearch.gateway.GatewayException; import org.elasticsearch.gateway.shared.SharedStorageGateway; import org.elasticsearch.index.gateway.CommitPoint; @@ -55,7 +43,7 @@ import java.io.IOException; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public abstract class BlobStoreGateway extends SharedStorageGateway { @@ -85,7 +73,8 @@ public abstract class BlobStoreGateway extends SharedStorageGateway { logger.debug("Latest metadata found at index [" + currentIndex + "]"); } - @Override public String toString() { + @Override + public String toString() { return type() + "://" + blobStore + "/" + basePath; } @@ -101,11 +90,13 @@ public abstract class BlobStoreGateway extends SharedStorageGateway { return this.chunkSize; } - @Override public void reset() throws Exception { + @Override + public void reset() throws Exception { blobStore.delete(BlobPath.cleanPath()); } - @Override public MetaData read() throws GatewayException { + @Override + public MetaData read() throws GatewayException { try { this.currentIndex = findLatestIndex(); } catch (IOException e) { @@ -149,7 +140,8 @@ public abstract class BlobStoreGateway extends SharedStorageGateway { } - @Override public void write(MetaData metaData) throws GatewayException { + @Override + public void write(MetaData metaData) throws GatewayException { final String newMetaData = "metadata-" + (currentIndex + 1); CachedStreamOutput.Entry cachedEntry = CachedStreamOutput.popEntry(); try { @@ -175,7 +167,8 @@ public abstract class BlobStoreGateway extends SharedStorageGateway { try { metaDataBlobContainer.deleteBlobsByFilter(new BlobContainer.BlobNameFilter() { - @Override public boolean accept(String blobName) { + @Override + public boolean accept(String blobName) { return blobName.startsWith("metadata-") && !newMetaData.equals(blobName); } }); diff --git a/src/main/java/org/elasticsearch/gateway/blobstore/BlobStoreGatewayModule.java b/src/main/java/org/elasticsearch/gateway/blobstore/BlobStoreGatewayModule.java index 20f192fda33..1c7019f0228 100644 --- a/src/main/java/org/elasticsearch/gateway/blobstore/BlobStoreGatewayModule.java +++ b/src/main/java/org/elasticsearch/gateway/blobstore/BlobStoreGatewayModule.java @@ -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,11 +25,12 @@ import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.inject.PreProcessModule; /** - * @author kimchy (shay.banon) + * */ public abstract class BlobStoreGatewayModule extends AbstractModule implements PreProcessModule { - @Override public void processModule(Module module) { + @Override + public void processModule(Module module) { if (module instanceof ShardsAllocatorModule) { ((ShardsAllocatorModule) module).setGatewayAllocator(BlobReuseExistingGatewayAllocator.class); } diff --git a/src/main/java/org/elasticsearch/gateway/fs/FsGateway.java b/src/main/java/org/elasticsearch/gateway/fs/FsGateway.java index 102b0888bce..c8210c215fc 100644 --- a/src/main/java/org/elasticsearch/gateway/fs/FsGateway.java +++ b/src/main/java/org/elasticsearch/gateway/fs/FsGateway.java @@ -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,14 +39,15 @@ import java.io.IOException; import java.util.concurrent.ExecutorService; /** - * @author kimchy (shay.banon) + * */ public class FsGateway extends BlobStoreGateway { private final ExecutorService concurrentStreamPool; - @Inject public FsGateway(Settings settings, ThreadPool threadPool, ClusterService clusterService, - Environment environment, ClusterName clusterName) throws IOException { + @Inject + public FsGateway(Settings settings, ThreadPool threadPool, ClusterService clusterService, + Environment environment, ClusterName clusterName) throws IOException { super(settings, threadPool, clusterService); File gatewayFile; @@ -64,15 +65,18 @@ public class FsGateway extends BlobStoreGateway { initialize(new FsBlobStore(componentSettings, concurrentStreamPool, gatewayFile), clusterName, null); } - @Override public String type() { + @Override + public String type() { return "fs"; } - @Override public Class suggestIndexGateway() { + @Override + public Class suggestIndexGateway() { return FsIndexGatewayModule.class; } - @Override protected void doClose() throws ElasticSearchException { + @Override + protected void doClose() throws ElasticSearchException { super.doClose(); concurrentStreamPool.shutdown(); } diff --git a/src/main/java/org/elasticsearch/gateway/fs/FsGatewayModule.java b/src/main/java/org/elasticsearch/gateway/fs/FsGatewayModule.java index 5cfd7c65a1a..aaf2568e11b 100644 --- a/src/main/java/org/elasticsearch/gateway/fs/FsGatewayModule.java +++ b/src/main/java/org/elasticsearch/gateway/fs/FsGatewayModule.java @@ -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,11 +23,12 @@ import org.elasticsearch.gateway.Gateway; import org.elasticsearch.gateway.blobstore.BlobStoreGatewayModule; /** - * @author kimchy (shay.banon) + * */ public class FsGatewayModule extends BlobStoreGatewayModule { - @Override protected void configure() { + @Override + protected void configure() { bind(Gateway.class).to(FsGateway.class).asEagerSingleton(); } } diff --git a/src/main/java/org/elasticsearch/gateway/local/LocalGateway.java b/src/main/java/org/elasticsearch/gateway/local/LocalGateway.java index 888270428e9..f7fc9cf2d73 100644 --- a/src/main/java/org/elasticsearch/gateway/local/LocalGateway.java +++ b/src/main/java/org/elasticsearch/gateway/local/LocalGateway.java @@ -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,8 @@ package org.elasticsearch.gateway.local; +import com.google.common.collect.Sets; +import com.google.common.io.Closeables; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.action.FailedNodeException; import org.elasticsearch.cluster.ClusterChangedEvent; @@ -26,51 +28,33 @@ import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterStateListener; import org.elasticsearch.cluster.metadata.MetaData; -import org.elasticsearch.cluster.routing.IndexRoutingTable; -import org.elasticsearch.cluster.routing.IndexShardRoutingTable; -import org.elasticsearch.cluster.routing.MutableShardRouting; -import org.elasticsearch.cluster.routing.RoutingNode; -import org.elasticsearch.cluster.routing.ShardRoutingState; -import org.elasticsearch.common.collect.Sets; +import org.elasticsearch.cluster.routing.*; import org.elasticsearch.common.component.AbstractLifecycleComponent; import org.elasticsearch.common.compress.lzf.LZF; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.Module; -import org.elasticsearch.common.io.Closeables; import org.elasticsearch.common.io.FileSystemUtils; import org.elasticsearch.common.io.Streams; -import org.elasticsearch.common.io.stream.BytesStreamInput; -import org.elasticsearch.common.io.stream.CachedStreamInput; -import org.elasticsearch.common.io.stream.CachedStreamOutput; -import org.elasticsearch.common.io.stream.LZFStreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.io.stream.*; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.thread.LoggingRunnable; -import org.elasticsearch.common.xcontent.ToXContent; -import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.common.xcontent.XContentFactory; -import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.common.xcontent.XContentType; +import org.elasticsearch.common.xcontent.*; import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.gateway.Gateway; import org.elasticsearch.gateway.GatewayException; import org.elasticsearch.index.gateway.local.LocalIndexGatewayModule; import org.elasticsearch.index.shard.ShardId; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.FilenameFilter; -import java.io.IOException; +import java.io.*; import java.util.Set; import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; -import static java.util.concurrent.Executors.*; -import static org.elasticsearch.common.util.concurrent.EsExecutors.*; +import static java.util.concurrent.Executors.newSingleThreadExecutor; +import static org.elasticsearch.common.util.concurrent.EsExecutors.daemonThreadFactory; /** - * @author kimchy (shay.banon) + * */ public class LocalGateway extends AbstractLifecycleComponent implements Gateway, ClusterStateListener { @@ -98,8 +82,9 @@ public class LocalGateway extends AbstractLifecycleComponent implements private volatile boolean metaDataPersistedAtLeastOnce = false; - @Inject public LocalGateway(Settings settings, ClusterService clusterService, NodeEnvironment nodeEnv, - TransportNodesListGatewayMetaState listGatewayMetaState, TransportNodesListGatewayStartedShards listGatewayStartedShards) { + @Inject + public LocalGateway(Settings settings, ClusterService clusterService, NodeEnvironment nodeEnv, + TransportNodesListGatewayMetaState listGatewayMetaState, TransportNodesListGatewayStartedShards listGatewayStartedShards) { super(settings); this.clusterService = clusterService; this.nodeEnv = nodeEnv; @@ -110,7 +95,8 @@ public class LocalGateway extends AbstractLifecycleComponent implements this.prettyPrint = componentSettings.getAsBoolean("pretty", false); } - @Override public String type() { + @Override + public String type() { return "local"; } @@ -124,13 +110,15 @@ public class LocalGateway extends AbstractLifecycleComponent implements return this.currentStartedShards; } - @Override protected void doStart() throws ElasticSearchException { + @Override + protected void doStart() throws ElasticSearchException { this.executor = newSingleThreadExecutor(daemonThreadFactory(settings, "gateway")); lazyInitialize(); clusterService.add(this); } - @Override protected void doStop() throws ElasticSearchException { + @Override + protected void doStop() throws ElasticSearchException { clusterService.remove(this); executor.shutdown(); try { @@ -140,10 +128,12 @@ public class LocalGateway extends AbstractLifecycleComponent implements } } - @Override protected void doClose() throws ElasticSearchException { + @Override + protected void doClose() throws ElasticSearchException { } - @Override public void performStateRecovery(final GatewayStateRecoveredListener listener) throws GatewayException { + @Override + public void performStateRecovery(final GatewayStateRecoveredListener listener) throws GatewayException { Set nodesIds = Sets.newHashSet(); nodesIds.addAll(clusterService.state().nodes().masterNodes().keySet()); TransportNodesListGatewayMetaState.NodesLocalGatewayMetaState nodesState = listGatewayMetaState.list(nodesIds, null).actionGet(); @@ -176,15 +166,18 @@ public class LocalGateway extends AbstractLifecycleComponent implements } } - @Override public Class suggestIndexGateway() { + @Override + public Class suggestIndexGateway() { return LocalIndexGatewayModule.class; } - @Override public void reset() throws Exception { + @Override + public void reset() throws Exception { FileSystemUtils.deleteRecursively(nodeEnv.nodeDataLocations()); } - @Override public void clusterChanged(final ClusterChangedEvent event) { + @Override + public void clusterChanged(final ClusterChangedEvent event) { if (!requiresStatePersistence) { return; } @@ -248,7 +241,7 @@ public class LocalGateway extends AbstractLifecycleComponent implements /** * We do here lazy initialization on not only on start(), since we might be called before start by another node (really will * happen in term of timing in testing, but still), and we want to return the cluster state when we can. - * + *

    * It is synchronized since we want to wait for it to be loaded if called concurrently. There should really be a nicer * solution here, but for now, its good enough. */ @@ -420,7 +413,8 @@ public class LocalGateway extends AbstractLifecycleComponent implements this.event = event; } - @Override public void run() { + @Override + public void run() { LocalGatewayMetaState.Builder builder = LocalGatewayMetaState.builder(); if (currentMetaState != null) { builder.state(currentMetaState); @@ -482,7 +476,8 @@ public class LocalGateway extends AbstractLifecycleComponent implements continue; } File[] files = stateLocation.listFiles(new FilenameFilter() { - @Override public boolean accept(File dir, String name) { + @Override + public boolean accept(File dir, String name) { return name.startsWith("metadata-") && !name.equals("metadata-" + version); } }); @@ -508,7 +503,8 @@ public class LocalGateway extends AbstractLifecycleComponent implements this.stateToWrite = stateToWrite; } - @Override public void run() { + @Override + public void run() { CachedStreamOutput.Entry cachedEntry = CachedStreamOutput.popEntry(); try { @@ -562,7 +558,8 @@ public class LocalGateway extends AbstractLifecycleComponent implements continue; } File[] files = stateLocation.listFiles(new FilenameFilter() { - @Override public boolean accept(File dir, String name) { + @Override + public boolean accept(File dir, String name) { return name.startsWith("shards-") && !name.equals("shards-" + event.state().version()); } }); diff --git a/src/main/java/org/elasticsearch/gateway/local/LocalGatewayAllocator.java b/src/main/java/org/elasticsearch/gateway/local/LocalGatewayAllocator.java index 6eecf040f73..ba17f3f96e4 100644 --- a/src/main/java/org/elasticsearch/gateway/local/LocalGatewayAllocator.java +++ b/src/main/java/org/elasticsearch/gateway/local/LocalGatewayAllocator.java @@ -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,10 @@ package org.elasticsearch.gateway.local; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import gnu.trove.iterator.TObjectLongIterator; +import gnu.trove.map.hash.TObjectLongHashMap; import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.node.DiscoveryNode; @@ -32,13 +36,9 @@ import org.elasticsearch.cluster.routing.allocation.RoutingAllocation; import org.elasticsearch.cluster.routing.allocation.StartedRerouteAllocation; import org.elasticsearch.cluster.routing.allocation.allocator.GatewayAllocator; import org.elasticsearch.cluster.routing.allocation.decider.AllocationDecider; -import org.elasticsearch.common.collect.Maps; -import org.elasticsearch.common.collect.Sets; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.trove.iterator.TObjectLongIterator; -import org.elasticsearch.common.trove.map.hash.TObjectLongHashMap; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.concurrent.ConcurrentCollections; @@ -53,7 +53,7 @@ import java.util.Set; import java.util.concurrent.ConcurrentMap; /** - * @author kimchy (shay.banon) + * */ public class LocalGatewayAllocator extends AbstractComponent implements GatewayAllocator { @@ -73,8 +73,9 @@ public class LocalGatewayAllocator extends AbstractComponent implements GatewayA private final String initialShards; - @Inject public LocalGatewayAllocator(Settings settings, - TransportNodesListGatewayStartedShards listGatewayStartedShards, TransportNodesListShardStoreMetaData listShardStoreMetaData) { + @Inject + public LocalGatewayAllocator(Settings settings, + TransportNodesListGatewayStartedShards listGatewayStartedShards, TransportNodesListShardStoreMetaData listShardStoreMetaData) { super(settings); this.listGatewayStartedShards = listGatewayStartedShards; this.listShardStoreMetaData = listShardStoreMetaData; @@ -85,20 +86,23 @@ public class LocalGatewayAllocator extends AbstractComponent implements GatewayA logger.debug("using initial_shards [{}], list_timeout [{}]", initialShards, listTimeout); } - @Override public void applyStartedShards(StartedRerouteAllocation allocation) { + @Override + public void applyStartedShards(StartedRerouteAllocation allocation) { for (ShardRouting shardRouting : allocation.startedShards()) { cachedStores.remove(shardRouting.shardId()); cachedShardsState.remove(shardRouting.shardId()); } } - @Override public void applyFailedShards(FailedRerouteAllocation allocation) { + @Override + public void applyFailedShards(FailedRerouteAllocation allocation) { ShardRouting failedShard = allocation.failedShard(); cachedStores.remove(failedShard.shardId()); cachedShardsState.remove(failedShard.shardId()); } - @Override public boolean allocateUnassigned(RoutingAllocation allocation) { + @Override + public boolean allocateUnassigned(RoutingAllocation allocation) { boolean changed = false; DiscoveryNodes nodes = allocation.nodes(); RoutingNodes routingNodes = allocation.routingNodes(); diff --git a/src/main/java/org/elasticsearch/gateway/local/LocalGatewayMetaState.java b/src/main/java/org/elasticsearch/gateway/local/LocalGatewayMetaState.java index 9314ba81b06..92a26d15303 100644 --- a/src/main/java/org/elasticsearch/gateway/local/LocalGatewayMetaState.java +++ b/src/main/java/org/elasticsearch/gateway/local/LocalGatewayMetaState.java @@ -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.xcontent.XContentParser; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class LocalGatewayMetaState { diff --git a/src/main/java/org/elasticsearch/gateway/local/LocalGatewayModule.java b/src/main/java/org/elasticsearch/gateway/local/LocalGatewayModule.java index bd199ffebf8..f3ae64bc2f9 100644 --- a/src/main/java/org/elasticsearch/gateway/local/LocalGatewayModule.java +++ b/src/main/java/org/elasticsearch/gateway/local/LocalGatewayModule.java @@ -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,17 +26,19 @@ import org.elasticsearch.common.inject.PreProcessModule; import org.elasticsearch.gateway.Gateway; /** - * @author kimchy (shay.banon) + * */ public class LocalGatewayModule extends AbstractModule implements PreProcessModule { - @Override protected void configure() { + @Override + protected void configure() { bind(Gateway.class).to(LocalGateway.class).asEagerSingleton(); bind(TransportNodesListGatewayMetaState.class).asEagerSingleton(); bind(TransportNodesListGatewayStartedShards.class).asEagerSingleton(); } - @Override public void processModule(Module module) { + @Override + public void processModule(Module module) { if (module instanceof ShardsAllocatorModule) { ((ShardsAllocatorModule) module).setGatewayAllocator(LocalGatewayAllocator.class); } diff --git a/src/main/java/org/elasticsearch/gateway/local/LocalGatewayStartedShards.java b/src/main/java/org/elasticsearch/gateway/local/LocalGatewayStartedShards.java index cf70269b5aa..33afc114ad3 100644 --- a/src/main/java/org/elasticsearch/gateway/local/LocalGatewayStartedShards.java +++ b/src/main/java/org/elasticsearch/gateway/local/LocalGatewayStartedShards.java @@ -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.gateway.local; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.Maps; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.xcontent.ToXContent; @@ -32,7 +32,7 @@ import java.io.IOException; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class LocalGatewayStartedShards { diff --git a/src/main/java/org/elasticsearch/gateway/local/TransportNodesListGatewayMetaState.java b/src/main/java/org/elasticsearch/gateway/local/TransportNodesListGatewayMetaState.java index ee6399b8b2a..93583207625 100644 --- a/src/main/java/org/elasticsearch/gateway/local/TransportNodesListGatewayMetaState.java +++ b/src/main/java/org/elasticsearch/gateway/local/TransportNodesListGatewayMetaState.java @@ -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.gateway.local; +import com.google.common.collect.Lists; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.action.ActionFuture; import org.elasticsearch.action.FailedNodeException; @@ -27,7 +28,6 @@ import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -42,13 +42,14 @@ import java.util.Set; import java.util.concurrent.atomic.AtomicReferenceArray; /** - * @author kimchy (shay.banon) + * */ public class TransportNodesListGatewayMetaState extends TransportNodesOperationAction { private LocalGateway gateway; - @Inject public TransportNodesListGatewayMetaState(Settings settings, ClusterName clusterName, ThreadPool threadPool, ClusterService clusterService, TransportService transportService) { + @Inject + public TransportNodesListGatewayMetaState(Settings settings, ClusterName clusterName, ThreadPool threadPool, ClusterService clusterService, TransportService transportService) { super(settings, clusterName, threadPool, clusterService, transportService); } @@ -61,39 +62,48 @@ public class TransportNodesListGatewayMetaState extends TransportNodesOperationA return execute(new Request(nodesIds).timeout(timeout)); } - @Override protected String executor() { + @Override + protected String executor() { return ThreadPool.Names.CACHED; } - @Override protected String transportAction() { + @Override + protected String transportAction() { return "/gateway/local/meta-state"; } - @Override protected String transportNodeAction() { + @Override + protected String transportNodeAction() { return "/gateway/local/meta-state/node"; } - @Override protected boolean transportCompress() { + @Override + protected boolean transportCompress() { return true; // compress since the metadata can become large } - @Override protected Request newRequest() { + @Override + protected Request newRequest() { return new Request(); } - @Override protected NodeRequest newNodeRequest() { + @Override + protected NodeRequest newNodeRequest() { return new NodeRequest(); } - @Override protected NodeRequest newNodeRequest(String nodeId, Request request) { + @Override + protected NodeRequest newNodeRequest(String nodeId, Request request) { return new NodeRequest(nodeId); } - @Override protected NodeLocalGatewayMetaState newNodeResponse() { + @Override + protected NodeLocalGatewayMetaState newNodeResponse() { return new NodeLocalGatewayMetaState(); } - @Override protected NodesLocalGatewayMetaState newResponse(Request request, AtomicReferenceArray responses) { + @Override + protected NodesLocalGatewayMetaState newResponse(Request request, AtomicReferenceArray responses) { final List nodesList = Lists.newArrayList(); final List failures = Lists.newArrayList(); for (int i = 0; i < responses.length(); i++) { @@ -108,11 +118,13 @@ public class TransportNodesListGatewayMetaState extends TransportNodesOperationA failures.toArray(new FailedNodeException[failures.size()])); } - @Override protected NodeLocalGatewayMetaState nodeOperation(NodeRequest request) throws ElasticSearchException { + @Override + protected NodeLocalGatewayMetaState nodeOperation(NodeRequest request) throws ElasticSearchException { return new NodeLocalGatewayMetaState(clusterService.localNode(), gateway.currentMetaState()); } - @Override protected boolean accumulateExceptions() { + @Override + protected boolean accumulateExceptions() { return true; } @@ -125,16 +137,19 @@ public class TransportNodesListGatewayMetaState extends TransportNodesOperationA super(nodesIds.toArray(new String[nodesIds.size()])); } - @Override public Request timeout(TimeValue timeout) { + @Override + public Request timeout(TimeValue timeout) { super.timeout(timeout); return this; } - @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); } } @@ -155,7 +170,8 @@ public class TransportNodesListGatewayMetaState extends TransportNodesOperationA return failures; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); nodes = new NodeLocalGatewayMetaState[in.readVInt()]; for (int i = 0; i < nodes.length; i++) { @@ -164,7 +180,8 @@ public class TransportNodesListGatewayMetaState extends TransportNodesOperationA } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeVInt(nodes.length); for (NodeLocalGatewayMetaState response : nodes) { @@ -183,11 +200,13 @@ public class TransportNodesListGatewayMetaState extends TransportNodesOperationA super(nodeId); } - @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); } } @@ -208,14 +227,16 @@ public class TransportNodesListGatewayMetaState extends TransportNodesOperationA return state; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); if (in.readBoolean()) { state = LocalGatewayMetaState.Builder.readFrom(in); } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); if (state == null) { out.writeBoolean(false); diff --git a/src/main/java/org/elasticsearch/gateway/local/TransportNodesListGatewayStartedShards.java b/src/main/java/org/elasticsearch/gateway/local/TransportNodesListGatewayStartedShards.java index 2ecf224fd57..7ecceffed5a 100644 --- a/src/main/java/org/elasticsearch/gateway/local/TransportNodesListGatewayStartedShards.java +++ b/src/main/java/org/elasticsearch/gateway/local/TransportNodesListGatewayStartedShards.java @@ -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.gateway.local; +import com.google.common.collect.Lists; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.action.ActionFuture; import org.elasticsearch.action.FailedNodeException; @@ -27,7 +28,6 @@ import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -44,13 +44,14 @@ import java.util.Set; import java.util.concurrent.atomic.AtomicReferenceArray; /** - * @author kimchy (shay.banon) + * */ public class TransportNodesListGatewayStartedShards extends TransportNodesOperationAction { private LocalGateway gateway; - @Inject public TransportNodesListGatewayStartedShards(Settings settings, ClusterName clusterName, ThreadPool threadPool, ClusterService clusterService, TransportService transportService) { + @Inject + public TransportNodesListGatewayStartedShards(Settings settings, ClusterName clusterName, ThreadPool threadPool, ClusterService clusterService, TransportService transportService) { super(settings, clusterName, threadPool, clusterService, transportService); } @@ -63,39 +64,48 @@ public class TransportNodesListGatewayStartedShards extends TransportNodesOperat return execute(new Request(shardId, nodesIds).timeout(timeout)); } - @Override protected String executor() { + @Override + protected String executor() { return ThreadPool.Names.CACHED; } - @Override protected String transportAction() { + @Override + protected String transportAction() { return "/gateway/local/started-shards"; } - @Override protected String transportNodeAction() { + @Override + protected String transportNodeAction() { return "/gateway/local/started-shards/node"; } - @Override protected boolean transportCompress() { + @Override + protected boolean transportCompress() { return true; // this can become big... } - @Override protected Request newRequest() { + @Override + protected Request newRequest() { return new Request(); } - @Override protected NodeRequest newNodeRequest() { + @Override + protected NodeRequest newNodeRequest() { return new NodeRequest(); } - @Override protected NodeRequest newNodeRequest(String nodeId, Request request) { + @Override + protected NodeRequest newNodeRequest(String nodeId, Request request) { return new NodeRequest(request.shardId(), nodeId); } - @Override protected NodeLocalGatewayStartedShards newNodeResponse() { + @Override + protected NodeLocalGatewayStartedShards newNodeResponse() { return new NodeLocalGatewayStartedShards(); } - @Override protected NodesLocalGatewayStartedShards newResponse(Request request, AtomicReferenceArray responses) { + @Override + protected NodesLocalGatewayStartedShards newResponse(Request request, AtomicReferenceArray responses) { final List nodesList = Lists.newArrayList(); final List failures = Lists.newArrayList(); for (int i = 0; i < responses.length(); i++) { @@ -110,7 +120,8 @@ public class TransportNodesListGatewayStartedShards extends TransportNodesOperat failures.toArray(new FailedNodeException[failures.size()])); } - @Override protected NodeLocalGatewayStartedShards nodeOperation(NodeRequest request) throws ElasticSearchException { + @Override + protected NodeLocalGatewayStartedShards nodeOperation(NodeRequest request) throws ElasticSearchException { LocalGatewayStartedShards startedShards = gateway.currentStartedShards(); if (startedShards != null) { for (Map.Entry entry : startedShards.shards().entrySet()) { @@ -123,7 +134,8 @@ public class TransportNodesListGatewayStartedShards extends TransportNodesOperat return new NodeLocalGatewayStartedShards(clusterService.localNode(), -1); } - @Override protected boolean accumulateExceptions() { + @Override + protected boolean accumulateExceptions() { return true; } @@ -143,17 +155,20 @@ public class TransportNodesListGatewayStartedShards extends TransportNodesOperat return this.shardId; } - @Override public Request timeout(TimeValue timeout) { + @Override + public Request timeout(TimeValue timeout) { super.timeout(timeout); return this; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); shardId = ShardId.readShardId(in); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); shardId.writeTo(out); } @@ -175,7 +190,8 @@ public class TransportNodesListGatewayStartedShards extends TransportNodesOperat return failures; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); nodes = new NodeLocalGatewayStartedShards[in.readVInt()]; for (int i = 0; i < nodes.length; i++) { @@ -184,7 +200,8 @@ public class TransportNodesListGatewayStartedShards extends TransportNodesOperat } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeVInt(nodes.length); for (NodeLocalGatewayStartedShards response : nodes) { @@ -206,12 +223,14 @@ public class TransportNodesListGatewayStartedShards extends TransportNodesOperat this.shardId = shardId; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); shardId = ShardId.readShardId(in); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); shardId.writeTo(out); } @@ -237,12 +256,14 @@ public class TransportNodesListGatewayStartedShards extends TransportNodesOperat return this.version; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); version = in.readLong(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeLong(version); } diff --git a/src/main/java/org/elasticsearch/gateway/none/NoneGateway.java b/src/main/java/org/elasticsearch/gateway/none/NoneGateway.java index 4d17e137f91..6ac06e82f44 100644 --- a/src/main/java/org/elasticsearch/gateway/none/NoneGateway.java +++ b/src/main/java/org/elasticsearch/gateway/none/NoneGateway.java @@ -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,42 +30,51 @@ import org.elasticsearch.gateway.GatewayException; import org.elasticsearch.index.gateway.none.NoneIndexGatewayModule; /** - * @author kimchy (shay.banon) + * */ public class NoneGateway extends AbstractLifecycleComponent implements Gateway { public static final String TYPE = "none"; - @Inject public NoneGateway(Settings settings) { + @Inject + public NoneGateway(Settings settings) { super(settings); } - @Override public String type() { + @Override + public String type() { return TYPE; } - @Override public String toString() { + @Override + public String toString() { return "_none_"; } - @Override protected void doStart() throws ElasticSearchException { + @Override + protected void doStart() throws ElasticSearchException { } - @Override protected void doStop() throws ElasticSearchException { + @Override + protected void doStop() throws ElasticSearchException { } - @Override protected void doClose() throws ElasticSearchException { + @Override + protected void doClose() throws ElasticSearchException { } - @Override public void performStateRecovery(GatewayStateRecoveredListener listener) throws GatewayException { + @Override + public void performStateRecovery(GatewayStateRecoveredListener listener) throws GatewayException { logger.debug("performing state recovery"); listener.onSuccess(ClusterState.builder().build()); } - @Override public Class suggestIndexGateway() { + @Override + public Class suggestIndexGateway() { return NoneIndexGatewayModule.class; } - @Override public void reset() { + @Override + public void reset() { } } diff --git a/src/main/java/org/elasticsearch/gateway/none/NoneGatewayAllocator.java b/src/main/java/org/elasticsearch/gateway/none/NoneGatewayAllocator.java index 81c9739abc0..0a043ad401a 100644 --- a/src/main/java/org/elasticsearch/gateway/none/NoneGatewayAllocator.java +++ b/src/main/java/org/elasticsearch/gateway/none/NoneGatewayAllocator.java @@ -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,13 +28,16 @@ import org.elasticsearch.cluster.routing.allocation.allocator.GatewayAllocator; */ public class NoneGatewayAllocator implements GatewayAllocator { - @Override public void applyStartedShards(StartedRerouteAllocation allocation) { + @Override + public void applyStartedShards(StartedRerouteAllocation allocation) { } - @Override public void applyFailedShards(FailedRerouteAllocation allocation) { + @Override + public void applyFailedShards(FailedRerouteAllocation allocation) { } - @Override public boolean allocateUnassigned(RoutingAllocation allocation) { + @Override + public boolean allocateUnassigned(RoutingAllocation allocation) { return false; } } diff --git a/src/main/java/org/elasticsearch/gateway/none/NoneGatewayModule.java b/src/main/java/org/elasticsearch/gateway/none/NoneGatewayModule.java index 510cad6bee8..503f567c2a7 100644 --- a/src/main/java/org/elasticsearch/gateway/none/NoneGatewayModule.java +++ b/src/main/java/org/elasticsearch/gateway/none/NoneGatewayModule.java @@ -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,13 +29,15 @@ import org.elasticsearch.gateway.Gateway; */ public class NoneGatewayModule extends AbstractModule implements PreProcessModule { - @Override public void processModule(Module module) { + @Override + public void processModule(Module module) { if (module instanceof ShardsAllocatorModule) { ((ShardsAllocatorModule) module).setGatewayAllocator(NoneGatewayAllocator.class); } } - @Override protected void configure() { + @Override + protected void configure() { bind(Gateway.class).to(NoneGateway.class).asEagerSingleton(); } } diff --git a/src/main/java/org/elasticsearch/gateway/shared/SharedStorageGateway.java b/src/main/java/org/elasticsearch/gateway/shared/SharedStorageGateway.java index 352551a0cff..8d3ce981cde 100644 --- a/src/main/java/org/elasticsearch/gateway/shared/SharedStorageGateway.java +++ b/src/main/java/org/elasticsearch/gateway/shared/SharedStorageGateway.java @@ -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,7 +33,7 @@ import org.elasticsearch.gateway.GatewayException; import org.elasticsearch.threadpool.ThreadPool; /** - * @author kimchy (shay.banon) + * */ public abstract class SharedStorageGateway extends AbstractLifecycleComponent implements Gateway, ClusterStateListener { @@ -47,20 +47,25 @@ public abstract class SharedStorageGateway extends AbstractLifecycleComponent { @@ -54,9 +54,10 @@ public class HttpServer extends AbstractLifecycleComponent { private final boolean disableSites; - @Inject public HttpServer(Settings settings, Environment environment, HttpServerTransport transport, - RestController restController, - NodeService nodeService) { + @Inject + public HttpServer(Settings settings, Environment environment, HttpServerTransport transport, + RestController restController, + NodeService nodeService) { super(settings); this.environment = environment; this.transport = transport; @@ -77,12 +78,14 @@ public class HttpServer extends AbstractLifecycleComponent { this.server = server; } - @Override public void dispatchRequest(HttpRequest request, HttpChannel channel) { + @Override + public void dispatchRequest(HttpRequest request, HttpChannel channel) { server.internalDispatchRequest(request, channel); } } - @Override protected void doStart() throws ElasticSearchException { + @Override + protected void doStart() throws ElasticSearchException { transport.start(); if (logger.isInfoEnabled()) { logger.info("{}", transport.boundAddress()); @@ -90,12 +93,14 @@ public class HttpServer extends AbstractLifecycleComponent { nodeService.putNodeAttribute("http_address", transport.boundAddress().publishAddress().toString()); } - @Override protected void doStop() throws ElasticSearchException { + @Override + protected void doStop() throws ElasticSearchException { nodeService.removeNodeAttribute("http_address"); transport.stop(); } - @Override protected void doClose() throws ElasticSearchException { + @Override + protected void doClose() throws ElasticSearchException { transport.close(); } diff --git a/src/main/java/org/elasticsearch/http/HttpServerAdapter.java b/src/main/java/org/elasticsearch/http/HttpServerAdapter.java index 59fd54d931f..bec726c3bd0 100644 --- a/src/main/java/org/elasticsearch/http/HttpServerAdapter.java +++ b/src/main/java/org/elasticsearch/http/HttpServerAdapter.java @@ -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.http; /** - * @author kimchy (Shay Banon) + * */ public interface HttpServerAdapter { diff --git a/src/main/java/org/elasticsearch/http/HttpServerModule.java b/src/main/java/org/elasticsearch/http/HttpServerModule.java index 04ecaa4a579..833fd026d8e 100644 --- a/src/main/java/org/elasticsearch/http/HttpServerModule.java +++ b/src/main/java/org/elasticsearch/http/HttpServerModule.java @@ -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,7 +19,7 @@ package org.elasticsearch.http; -import org.elasticsearch.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.inject.Modules; @@ -28,7 +28,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.http.netty.NettyHttpServerTransportModule; /** - * @author kimchy (shay.banon) + * */ public class HttpServerModule extends AbstractModule implements SpawnModules { @@ -38,11 +38,14 @@ public class HttpServerModule extends AbstractModule implements SpawnModules { this.settings = settings; } - @Override public Iterable spawnModules() { + @Override + public Iterable spawnModules() { return ImmutableList.of(Modules.createModule(settings.getAsClass("http.type", NettyHttpServerTransportModule.class, "org.elasticsearch.http.", "HttpServerTransportModule"), settings)); } - @SuppressWarnings({"unchecked"}) @Override protected void configure() { + @SuppressWarnings({"unchecked"}) + @Override + protected void configure() { bind(HttpServer.class).asEagerSingleton(); } } diff --git a/src/main/java/org/elasticsearch/http/HttpServerTransport.java b/src/main/java/org/elasticsearch/http/HttpServerTransport.java index c57f5a43af4..5c7576a1025 100644 --- a/src/main/java/org/elasticsearch/http/HttpServerTransport.java +++ b/src/main/java/org/elasticsearch/http/HttpServerTransport.java @@ -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.component.LifecycleComponent; import org.elasticsearch.common.transport.BoundTransportAddress; /** - * @author kimchy (Shay Banon) + * */ public interface HttpServerTransport extends LifecycleComponent { diff --git a/src/main/java/org/elasticsearch/http/HttpStats.java b/src/main/java/org/elasticsearch/http/HttpStats.java index cf41e76ea79..6a67e552c85 100644 --- a/src/main/java/org/elasticsearch/http/HttpStats.java +++ b/src/main/java/org/elasticsearch/http/HttpStats.java @@ -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 @@ -63,17 +63,20 @@ public class HttpStats implements Streamable, ToXContent { return stats; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { serverOpen = in.readVLong(); totalOpen = in.readVLong(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeVLong(serverOpen); out.writeVLong(totalOpen); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject("http"); builder.field("current_open", serverOpen); builder.field("total_opened", totalOpen); diff --git a/src/main/java/org/elasticsearch/http/netty/HttpRequestHandler.java b/src/main/java/org/elasticsearch/http/netty/HttpRequestHandler.java index c36a967a976..0f49a2f841a 100644 --- a/src/main/java/org/elasticsearch/http/netty/HttpRequestHandler.java +++ b/src/main/java/org/elasticsearch/http/netty/HttpRequestHandler.java @@ -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,16 +19,12 @@ package org.elasticsearch.http.netty; -import org.elasticsearch.common.netty.channel.ChannelHandler; -import org.elasticsearch.common.netty.channel.ChannelHandlerContext; -import org.elasticsearch.common.netty.channel.ExceptionEvent; -import org.elasticsearch.common.netty.channel.MessageEvent; -import org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler; -import org.elasticsearch.common.netty.handler.codec.http.HttpRequest; +import org.jboss.netty.channel.*; +import org.jboss.netty.handler.codec.http.HttpRequest; /** - * @author kimchy (shay.banon) + * */ @ChannelHandler.Sharable public class HttpRequestHandler extends SimpleChannelUpstreamHandler { @@ -39,13 +35,15 @@ public class HttpRequestHandler extends SimpleChannelUpstreamHandler { this.serverTransport = serverTransport; } - @Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { + @Override + public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { HttpRequest request = (HttpRequest) e.getMessage(); serverTransport.dispatchRequest(new NettyHttpRequest(request), new NettyHttpChannel(serverTransport, e.getChannel(), request)); super.messageReceived(ctx, e); } - @Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { + @Override + public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { serverTransport.exceptionCaught(ctx, e); } } diff --git a/src/main/java/org/elasticsearch/http/netty/NettyHttpChannel.java b/src/main/java/org/elasticsearch/http/netty/NettyHttpChannel.java index 89625902a44..937f2a6835c 100644 --- a/src/main/java/org/elasticsearch/http/netty/NettyHttpChannel.java +++ b/src/main/java/org/elasticsearch/http/netty/NettyHttpChannel.java @@ -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,19 +20,6 @@ package org.elasticsearch.http.netty; import org.elasticsearch.common.io.stream.CachedStreamOutput; -import org.elasticsearch.common.netty.buffer.ChannelBuffer; -import org.elasticsearch.common.netty.buffer.ChannelBuffers; -import org.elasticsearch.common.netty.channel.Channel; -import org.elasticsearch.common.netty.channel.ChannelFuture; -import org.elasticsearch.common.netty.channel.ChannelFutureListener; -import org.elasticsearch.common.netty.handler.codec.http.Cookie; -import org.elasticsearch.common.netty.handler.codec.http.CookieDecoder; -import org.elasticsearch.common.netty.handler.codec.http.CookieEncoder; -import org.elasticsearch.common.netty.handler.codec.http.DefaultHttpResponse; -import org.elasticsearch.common.netty.handler.codec.http.HttpHeaders; -import org.elasticsearch.common.netty.handler.codec.http.HttpMethod; -import org.elasticsearch.common.netty.handler.codec.http.HttpResponseStatus; -import org.elasticsearch.common.netty.handler.codec.http.HttpVersion; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.http.HttpChannel; import org.elasticsearch.http.HttpException; @@ -41,25 +28,32 @@ import org.elasticsearch.rest.RestStatus; import org.elasticsearch.rest.XContentRestResponse; import org.elasticsearch.rest.support.RestUtils; import org.elasticsearch.transport.netty.NettyTransport; +import org.jboss.netty.buffer.ChannelBuffer; +import org.jboss.netty.buffer.ChannelBuffers; +import org.jboss.netty.channel.Channel; +import org.jboss.netty.channel.ChannelFuture; +import org.jboss.netty.channel.ChannelFutureListener; +import org.jboss.netty.handler.codec.http.*; import java.io.IOException; import java.util.Set; /** - * @author kimchy (shay.banon) + * */ public class NettyHttpChannel implements HttpChannel { private final NettyHttpServerTransport transport; private final Channel channel; - private final org.elasticsearch.common.netty.handler.codec.http.HttpRequest request; + private final org.jboss.netty.handler.codec.http.HttpRequest request; - public NettyHttpChannel(NettyHttpServerTransport transport, Channel channel, org.elasticsearch.common.netty.handler.codec.http.HttpRequest request) { + public NettyHttpChannel(NettyHttpServerTransport transport, Channel channel, org.jboss.netty.handler.codec.http.HttpRequest request) { this.transport = transport; this.channel = channel; this.request = request; } - @Override public void sendResponse(RestResponse response) { + @Override + public void sendResponse(RestResponse response) { // Decide whether to close the connection or not. boolean http10 = request.getProtocolVersion().equals(HttpVersion.HTTP_1_0); @@ -69,7 +63,7 @@ public class NettyHttpChannel implements HttpChannel { // Build the response object. HttpResponseStatus status = getStatus(response.status()); - org.elasticsearch.common.netty.handler.codec.http.HttpResponse resp; + org.jboss.netty.handler.codec.http.HttpResponse resp; if (http10) { resp = new DefaultHttpResponse(HttpVersion.HTTP_1_0, status); if (!close) { diff --git a/src/main/java/org/elasticsearch/http/netty/NettyHttpRequest.java b/src/main/java/org/elasticsearch/http/netty/NettyHttpRequest.java index 5794ef97298..3951f502467 100644 --- a/src/main/java/org/elasticsearch/http/netty/NettyHttpRequest.java +++ b/src/main/java/org/elasticsearch/http/netty/NettyHttpRequest.java @@ -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,21 +19,21 @@ package org.elasticsearch.http.netty; -import org.elasticsearch.common.netty.handler.codec.http.HttpMethod; import org.elasticsearch.http.HttpRequest; import org.elasticsearch.rest.support.AbstractRestRequest; import org.elasticsearch.rest.support.RestUtils; +import org.jboss.netty.handler.codec.http.HttpMethod; import java.nio.charset.Charset; import java.util.HashMap; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class NettyHttpRequest extends AbstractRestRequest implements HttpRequest { - private final org.elasticsearch.common.netty.handler.codec.http.HttpRequest request; + private final org.jboss.netty.handler.codec.http.HttpRequest request; private final Map params; @@ -41,7 +41,7 @@ public class NettyHttpRequest extends AbstractRestRequest implements HttpRequest private byte[] cachedData; - public NettyHttpRequest(org.elasticsearch.common.netty.handler.codec.http.HttpRequest request) { + public NettyHttpRequest(org.jboss.netty.handler.codec.http.HttpRequest request) { this.request = request; this.params = new HashMap(); @@ -55,7 +55,8 @@ public class NettyHttpRequest extends AbstractRestRequest implements HttpRequest } } - @Override public Method method() { + @Override + public Method method() { HttpMethod httpMethod = request.getMethod(); if (httpMethod == HttpMethod.GET) return Method.GET; @@ -80,31 +81,38 @@ public class NettyHttpRequest extends AbstractRestRequest implements HttpRequest return Method.GET; } - @Override public String uri() { + @Override + public String uri() { return request.getUri(); } - @Override public String rawPath() { + @Override + public String rawPath() { return rawPath; } - @Override public Map params() { + @Override + public Map params() { return params; } - @Override public boolean hasContent() { + @Override + public boolean hasContent() { return request.getContent().readableBytes() > 0; } - @Override public int contentLength() { + @Override + public int contentLength() { return request.getContent().readableBytes(); } - @Override public boolean contentUnsafe() { + @Override + public boolean contentUnsafe() { return request.getContent().hasArray(); } - @Override public byte[] contentByteArray() { + @Override + public byte[] contentByteArray() { if (request.getContent().hasArray()) { return request.getContent().array(); } @@ -116,7 +124,8 @@ public class NettyHttpRequest extends AbstractRestRequest implements HttpRequest return cachedData; } - @Override public int contentByteArrayOffset() { + @Override + public int contentByteArrayOffset() { if (request.getContent().hasArray()) { // get the array offset, and the reader index offset within it return request.getContent().arrayOffset() + request.getContent().readerIndex(); @@ -126,23 +135,28 @@ public class NettyHttpRequest extends AbstractRestRequest implements HttpRequest private static Charset UTF8 = Charset.forName("UTF-8"); - @Override public String contentAsString() { + @Override + public String contentAsString() { return request.getContent().toString(UTF8); } - @Override public String header(String name) { + @Override + public String header(String name) { return request.getHeader(name); } - @Override public boolean hasParam(String key) { + @Override + public boolean hasParam(String key) { return params.containsKey(key); } - @Override public String param(String key) { + @Override + public String param(String key) { return params.get(key); } - @Override public String param(String key, String defaultValue) { + @Override + public String param(String key, String defaultValue) { String value = params.get(key); if (value == null) { return defaultValue; diff --git a/src/main/java/org/elasticsearch/http/netty/NettyHttpServerTransport.java b/src/main/java/org/elasticsearch/http/netty/NettyHttpServerTransport.java index d64dde174e6..6808676644b 100644 --- a/src/main/java/org/elasticsearch/http/netty/NettyHttpServerTransport.java +++ b/src/main/java/org/elasticsearch/http/netty/NettyHttpServerTransport.java @@ -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,23 +23,6 @@ import org.elasticsearch.ElasticSearchException; import org.elasticsearch.common.component.AbstractLifecycleComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.netty.OpenChannelsHandler; -import org.elasticsearch.common.netty.bootstrap.ServerBootstrap; -import org.elasticsearch.common.netty.channel.Channel; -import org.elasticsearch.common.netty.channel.ChannelHandlerContext; -import org.elasticsearch.common.netty.channel.ChannelPipeline; -import org.elasticsearch.common.netty.channel.ChannelPipelineFactory; -import org.elasticsearch.common.netty.channel.Channels; -import org.elasticsearch.common.netty.channel.ExceptionEvent; -import org.elasticsearch.common.netty.channel.socket.nio.NioServerSocketChannelFactory; -import org.elasticsearch.common.netty.channel.socket.oio.OioServerSocketChannelFactory; -import org.elasticsearch.common.netty.handler.codec.http.HttpChunkAggregator; -import org.elasticsearch.common.netty.handler.codec.http.HttpContentCompressor; -import org.elasticsearch.common.netty.handler.codec.http.HttpContentDecompressor; -import org.elasticsearch.common.netty.handler.codec.http.HttpRequestDecoder; -import org.elasticsearch.common.netty.handler.codec.http.HttpResponseEncoder; -import org.elasticsearch.common.netty.handler.timeout.ReadTimeoutException; -import org.elasticsearch.common.netty.logging.InternalLogger; -import org.elasticsearch.common.netty.logging.InternalLoggerFactory; import org.elasticsearch.common.network.NetworkService; import org.elasticsearch.common.network.NetworkUtils; import org.elasticsearch.common.settings.Settings; @@ -49,14 +32,18 @@ import org.elasticsearch.common.transport.NetworkExceptionHelper; import org.elasticsearch.common.transport.PortsRange; import org.elasticsearch.common.unit.ByteSizeUnit; import org.elasticsearch.common.unit.ByteSizeValue; -import org.elasticsearch.http.BindHttpException; -import org.elasticsearch.http.HttpChannel; +import org.elasticsearch.http.*; import org.elasticsearch.http.HttpRequest; -import org.elasticsearch.http.HttpServerAdapter; -import org.elasticsearch.http.HttpServerTransport; -import org.elasticsearch.http.HttpStats; import org.elasticsearch.transport.BindTransportException; import org.elasticsearch.transport.netty.NettyInternalESLoggerFactory; +import org.jboss.netty.bootstrap.ServerBootstrap; +import org.jboss.netty.channel.*; +import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory; +import org.jboss.netty.channel.socket.oio.OioServerSocketChannelFactory; +import org.jboss.netty.handler.codec.http.*; +import org.jboss.netty.handler.timeout.ReadTimeoutException; +import org.jboss.netty.logging.InternalLogger; +import org.jboss.netty.logging.InternalLoggerFactory; import java.io.IOException; import java.net.InetAddress; @@ -65,17 +52,18 @@ import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicReference; import static org.elasticsearch.common.network.NetworkService.TcpSettings.*; -import static org.elasticsearch.common.util.concurrent.EsExecutors.*; +import static org.elasticsearch.common.util.concurrent.EsExecutors.daemonThreadFactory; /** - * @author kimchy (shay.banon) + * */ public class NettyHttpServerTransport extends AbstractLifecycleComponent implements HttpServerTransport { static { InternalLoggerFactory.setDefaultFactory(new NettyInternalESLoggerFactory() { - @Override public InternalLogger newInstance(String name) { - return super.newInstance(name.replace("org.elasticsearch.common.netty.", "netty.").replace("org.jboss.netty.", "netty.")); + @Override + public InternalLogger newInstance(String name) { + return super.newInstance(name.replace("org.jboss.netty.", "netty.").replace("org.jboss.netty.", "netty.")); } }); } @@ -123,7 +111,8 @@ public class NettyHttpServerTransport extends AbstractLifecycleComponent lastException = new AtomicReference(); boolean success = portsRange.iterate(new PortsRange.PortCallback() { - @Override public boolean onPortNumber(int portNumber) { + @Override + public boolean onPortNumber(int portNumber) { try { serverChannel = serverBootstrap.bind(new InetSocketAddress(hostAddress, portNumber)); } catch (Exception e) { @@ -232,7 +223,8 @@ public class NettyHttpServerTransport extends AbstractLifecycleComponent { @@ -53,7 +53,8 @@ public class IndexAliasesService extends AbstractIndexComponent implements Itera private final Object mutex = new Object(); - @Inject public IndexAliasesService(Index index, @IndexSettings Settings indexSettings, IndexQueryParserService indexQueryParser) { + @Inject + public IndexAliasesService(Index index, @IndexSettings Settings indexSettings, IndexQueryParserService indexQueryParser) { super(index, indexSettings); this.indexQueryParser = indexQueryParser; } @@ -72,7 +73,7 @@ public class IndexAliasesService extends AbstractIndexComponent implements Itera /** * Returns the filter associated with listed filtering aliases. - * + *

    *

    The list of filtering aliases should be obtained by calling MetaData.filteringAliases. * Returns null if no filtering is required.

    */ @@ -142,7 +143,8 @@ public class IndexAliasesService extends AbstractIndexComponent implements Itera } } - @Override public UnmodifiableIterator iterator() { + @Override + public UnmodifiableIterator iterator() { return aliases.values().iterator(); } } diff --git a/src/main/java/org/elasticsearch/index/aliases/IndexAliasesServiceModule.java b/src/main/java/org/elasticsearch/index/aliases/IndexAliasesServiceModule.java index b4cffaddd30..0b5eb260ef6 100644 --- a/src/main/java/org/elasticsearch/index/aliases/IndexAliasesServiceModule.java +++ b/src/main/java/org/elasticsearch/index/aliases/IndexAliasesServiceModule.java @@ -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,11 +22,12 @@ package org.elasticsearch.index.aliases; import org.elasticsearch.common.inject.AbstractModule; /** - * @author imotov + * */ public class IndexAliasesServiceModule extends AbstractModule { - @Override protected void configure() { + @Override + protected void configure() { bind(IndexAliasesService.class).asEagerSingleton(); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/ASCIIFoldingTokenFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/ASCIIFoldingTokenFilterFactory.java index 9594442a49c..3278a339837 100644 --- a/src/main/java/org/elasticsearch/index/analysis/ASCIIFoldingTokenFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/ASCIIFoldingTokenFilterFactory.java @@ -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,15 +28,17 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (Shay Banon) + * */ public class ASCIIFoldingTokenFilterFactory extends AbstractTokenFilterFactory { - @Inject public ASCIIFoldingTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public ASCIIFoldingTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); } - @Override public TokenStream create(TokenStream tokenStream) { + @Override + public TokenStream create(TokenStream tokenStream) { return new ASCIIFoldingFilter(tokenStream); } } diff --git a/src/main/java/org/elasticsearch/index/analysis/AbstractCharFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/AbstractCharFilterFactory.java index 8c5a98bfdc1..a8e50be4d4e 100644 --- a/src/main/java/org/elasticsearch/index/analysis/AbstractCharFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/AbstractCharFilterFactory.java @@ -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.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public abstract class AbstractCharFilterFactory extends AbstractIndexComponent implements CharFilterFactory { @@ -36,7 +36,8 @@ public abstract class AbstractCharFilterFactory extends AbstractIndexComponent i this.name = name; } - @Override public String name() { + @Override + public String name() { return this.name; } } diff --git a/src/main/java/org/elasticsearch/index/analysis/AbstractIndexAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/AbstractIndexAnalyzerProvider.java index a47951a0606..ec2ca648b36 100644 --- a/src/main/java/org/elasticsearch/index/analysis/AbstractIndexAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/AbstractIndexAnalyzerProvider.java @@ -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.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public abstract class AbstractIndexAnalyzerProvider extends AbstractIndexComponent implements AnalyzerProvider { @@ -63,11 +63,13 @@ public abstract class AbstractIndexAnalyzerProvider extends this.version = Lucene.parseVersion(settings.get("version"), Lucene.ANALYZER_VERSION, logger); } - @Override public String name() { + @Override + public String name() { return this.name; } - @Override public AnalyzerScope scope() { + @Override + public AnalyzerScope scope() { return AnalyzerScope.INDEX; } } diff --git a/src/main/java/org/elasticsearch/index/analysis/AbstractTokenFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/AbstractTokenFilterFactory.java index ec5193a1bd4..2894de8202e 100644 --- a/src/main/java/org/elasticsearch/index/analysis/AbstractTokenFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/AbstractTokenFilterFactory.java @@ -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.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (Shay Banon) + * */ public abstract class AbstractTokenFilterFactory extends AbstractIndexComponent implements TokenFilterFactory { @@ -41,7 +41,8 @@ public abstract class AbstractTokenFilterFactory extends AbstractIndexComponent this.version = Lucene.parseVersion(settings.get("version"), Lucene.ANALYZER_VERSION, logger); } - @Override public String name() { + @Override + public String name() { return this.name; } } diff --git a/src/main/java/org/elasticsearch/index/analysis/AbstractTokenizerFactory.java b/src/main/java/org/elasticsearch/index/analysis/AbstractTokenizerFactory.java index fdce73a973e..9591c7c319f 100644 --- a/src/main/java/org/elasticsearch/index/analysis/AbstractTokenizerFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/AbstractTokenizerFactory.java @@ -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.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public abstract class AbstractTokenizerFactory extends AbstractIndexComponent implements TokenizerFactory { @@ -41,7 +41,8 @@ public abstract class AbstractTokenizerFactory extends AbstractIndexComponent im this.version = Lucene.parseVersion(settings.get("version"), Lucene.ANALYZER_VERSION, logger); } - @Override public String name() { + @Override + public String name() { return this.name; } } diff --git a/src/main/java/org/elasticsearch/index/analysis/Analysis.java b/src/main/java/org/elasticsearch/index/analysis/Analysis.java index 5ed5c4d7da1..4ccedab918f 100644 --- a/src/main/java/org/elasticsearch/index/analysis/Analysis.java +++ b/src/main/java/org/elasticsearch/index/analysis/Analysis.java @@ -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,10 @@ package org.elasticsearch.index.analysis; +import com.google.common.base.Charsets; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterators; import org.apache.lucene.analysis.CharArraySet; import org.apache.lucene.analysis.ar.ArabicAnalyzer; import org.apache.lucene.analysis.bg.BulgarianAnalyzer; @@ -50,10 +54,6 @@ import org.apache.lucene.analysis.tr.TurkishAnalyzer; import org.apache.lucene.util.Version; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.base.Charsets; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.collect.Iterators; import org.elasticsearch.common.collect.MapBuilder; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; @@ -69,7 +69,7 @@ import java.util.List; import java.util.Set; /** - * @author kimchy (shay.banon) + * */ public class Analysis { diff --git a/src/main/java/org/elasticsearch/index/analysis/AnalysisModule.java b/src/main/java/org/elasticsearch/index/analysis/AnalysisModule.java index d7fdb08dc16..4f1009844b5 100644 --- a/src/main/java/org/elasticsearch/index/analysis/AnalysisModule.java +++ b/src/main/java/org/elasticsearch/index/analysis/AnalysisModule.java @@ -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.index.analysis; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import org.elasticsearch.ElasticSearchIllegalArgumentException; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.collect.Maps; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.Scopes; import org.elasticsearch.common.inject.assistedinject.FactoryProvider; @@ -37,7 +37,7 @@ import java.util.LinkedList; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class AnalysisModule extends AbstractModule { @@ -154,7 +154,8 @@ public class AnalysisModule extends AbstractModule { return this; } - @Override protected void configure() { + @Override + protected void configure() { MapBinder charFilterBinder = MapBinder.newMapBinder(binder(), String.class, CharFilterFactoryFactory.class); @@ -330,11 +331,13 @@ public class AnalysisModule extends AbstractModule { private static class DefaultProcessor extends AnalysisBinderProcessor { - @Override public void processCharFilters(CharFiltersBindings charFiltersBindings) { + @Override + public void processCharFilters(CharFiltersBindings charFiltersBindings) { charFiltersBindings.processCharFilter("html_strip", HtmlStripCharFilterFactory.class); } - @Override public void processTokenFilters(TokenFiltersBindings tokenFiltersBindings) { + @Override + public void processTokenFilters(TokenFiltersBindings tokenFiltersBindings) { tokenFiltersBindings.processTokenFilter("stop", StopTokenFilterFactory.class); tokenFiltersBindings.processTokenFilter("reverse", ReverseTokenFilterFactory.class); tokenFiltersBindings.processTokenFilter("asciifolding", ASCIIFoldingTokenFilterFactory.class); @@ -352,7 +355,8 @@ public class AnalysisModule extends AbstractModule { tokenFiltersBindings.processTokenFilter("truncate", TruncateTokenFilterFactory.class); } - @Override public void processTokenizers(TokenizersBindings tokenizersBindings) { + @Override + public void processTokenizers(TokenizersBindings tokenizersBindings) { tokenizersBindings.processTokenizer("standard", StandardTokenizerFactory.class); tokenizersBindings.processTokenizer("uax_url_email", UAX29URLEmailTokenizerFactory.class); tokenizersBindings.processTokenizer("path_hierarchy", PathHierarchyTokenizerFactory.class); @@ -367,7 +371,8 @@ public class AnalysisModule extends AbstractModule { tokenizersBindings.processTokenizer("edge_ngram", EdgeNGramTokenizerFactory.class); } - @Override public void processAnalyzers(AnalyzersBindings analyzersBindings) { + @Override + public void processAnalyzers(AnalyzersBindings analyzersBindings) { analyzersBindings.processAnalyzer("default", StandardAnalyzerProvider.class); analyzersBindings.processAnalyzer("standard", StandardAnalyzerProvider.class); analyzersBindings.processAnalyzer("standard_html_strip", StandardHtmlStripAnalyzerProvider.class); @@ -379,11 +384,13 @@ public class AnalysisModule extends AbstractModule { } private static class ExtendedProcessor extends AnalysisBinderProcessor { - @Override public void processCharFilters(CharFiltersBindings charFiltersBindings) { + @Override + public void processCharFilters(CharFiltersBindings charFiltersBindings) { charFiltersBindings.processCharFilter("mapping", MappingCharFilterFactory.class); } - @Override public void processTokenFilters(TokenFiltersBindings tokenFiltersBindings) { + @Override + public void processTokenFilters(TokenFiltersBindings tokenFiltersBindings) { tokenFiltersBindings.processTokenFilter("snowball", SnowballTokenFilterFactory.class); tokenFiltersBindings.processTokenFilter("stemmer", StemmerTokenFilterFactory.class); tokenFiltersBindings.processTokenFilter("word_delimiter", WordDelimiterTokenFilterFactory.class); @@ -407,11 +414,13 @@ public class AnalysisModule extends AbstractModule { tokenFiltersBindings.processTokenFilter("stemmer_override", StemmerOverrideTokenFilterFactory.class); } - @Override public void processTokenizers(TokenizersBindings tokenizersBindings) { + @Override + public void processTokenizers(TokenizersBindings tokenizersBindings) { tokenizersBindings.processTokenizer("pattern", PatternTokenizerFactory.class); } - @Override public void processAnalyzers(AnalyzersBindings analyzersBindings) { + @Override + public void processAnalyzers(AnalyzersBindings analyzersBindings) { analyzersBindings.processAnalyzer("pattern", PatternAnalyzerProvider.class); analyzersBindings.processAnalyzer("snowball", SnowballAnalyzerProvider.class); diff --git a/src/main/java/org/elasticsearch/index/analysis/AnalysisService.java b/src/main/java/org/elasticsearch/index/analysis/AnalysisService.java index 44e5828cf6f..d7285edb0af 100644 --- a/src/main/java/org/elasticsearch/index/analysis/AnalysisService.java +++ b/src/main/java/org/elasticsearch/index/analysis/AnalysisService.java @@ -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.index.analysis; +import com.google.common.collect.ImmutableMap; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.component.CloseableComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.ImmutableSettings; @@ -33,10 +33,10 @@ import org.elasticsearch.indices.analysis.IndicesAnalysisService; import java.util.Map; -import static org.elasticsearch.common.collect.Maps.*; +import static com.google.common.collect.Maps.newHashMap; /** - * @author kimchy (Shay Banon) + * */ public class AnalysisService extends AbstractIndexComponent implements CloseableComponent { @@ -56,11 +56,12 @@ public class AnalysisService extends AbstractIndexComponent implements Closeable this(index, ImmutableSettings.Builder.EMPTY_SETTINGS, null, null, null, null, null); } - @Inject public AnalysisService(Index index, @IndexSettings Settings indexSettings, @Nullable IndicesAnalysisService indicesAnalysisService, - @Nullable Map analyzerFactoryFactories, - @Nullable Map tokenizerFactoryFactories, - @Nullable Map charFilterFactoryFactories, - @Nullable Map tokenFilterFactoryFactories) { + @Inject + public AnalysisService(Index index, @IndexSettings Settings indexSettings, @Nullable IndicesAnalysisService indicesAnalysisService, + @Nullable Map analyzerFactoryFactories, + @Nullable Map tokenizerFactoryFactories, + @Nullable Map charFilterFactoryFactories, + @Nullable Map tokenFilterFactoryFactories) { super(index, indexSettings); Map tokenizers = newHashMap(); diff --git a/src/main/java/org/elasticsearch/index/analysis/AnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/AnalyzerProvider.java index 8cde8d6c8af..ee79468a575 100644 --- a/src/main/java/org/elasticsearch/index/analysis/AnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/AnalyzerProvider.java @@ -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.analysis.Analyzer; import org.elasticsearch.common.inject.Provider; /** - * @author kimchy (shay.banon) + * */ public interface AnalyzerProvider extends Provider { diff --git a/src/main/java/org/elasticsearch/index/analysis/AnalyzerProviderFactory.java b/src/main/java/org/elasticsearch/index/analysis/AnalyzerProviderFactory.java index df9227b05c3..bd37696dcdc 100644 --- a/src/main/java/org/elasticsearch/index/analysis/AnalyzerProviderFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/AnalyzerProviderFactory.java @@ -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.index.analysis; import org.elasticsearch.common.settings.Settings; /** - * @author kimchy (shay.banon) + * */ public interface AnalyzerProviderFactory { diff --git a/src/main/java/org/elasticsearch/index/analysis/AnalyzerScope.java b/src/main/java/org/elasticsearch/index/analysis/AnalyzerScope.java index 08ea93e01fe..fbbd1bdf41f 100644 --- a/src/main/java/org/elasticsearch/index/analysis/AnalyzerScope.java +++ b/src/main/java/org/elasticsearch/index/analysis/AnalyzerScope.java @@ -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.index.analysis; /** - * @author kimchy (shay.banon) + * */ public enum AnalyzerScope { INDEX, diff --git a/src/main/java/org/elasticsearch/index/analysis/ArabicAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/ArabicAnalyzerProvider.java index 63602c7da5f..94e4767c094 100644 --- a/src/main/java/org/elasticsearch/index/analysis/ArabicAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/ArabicAnalyzerProvider.java @@ -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,20 +29,22 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class ArabicAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final ArabicAnalyzer arabicAnalyzer; - @Inject public ArabicAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public ArabicAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); arabicAnalyzer = new ArabicAnalyzer(version, Analysis.parseStopWords(env, settings, ArabicAnalyzer.getDefaultStopSet(), version), Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET)); } - @Override public ArabicAnalyzer get() { + @Override + public ArabicAnalyzer get() { return this.arabicAnalyzer; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/ArabicStemTokenFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/ArabicStemTokenFilterFactory.java index 895b371b654..c8097c2997c 100644 --- a/src/main/java/org/elasticsearch/index/analysis/ArabicStemTokenFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/ArabicStemTokenFilterFactory.java @@ -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,15 +28,17 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class ArabicStemTokenFilterFactory extends AbstractTokenFilterFactory { - @Inject public ArabicStemTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public ArabicStemTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); } - @Override public TokenStream create(TokenStream tokenStream) { + @Override + public TokenStream create(TokenStream tokenStream) { return new ArabicStemFilter(tokenStream); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/ArmenianAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/ArmenianAnalyzerProvider.java index 65366b047c7..7f97b5d90f9 100644 --- a/src/main/java/org/elasticsearch/index/analysis/ArmenianAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/ArmenianAnalyzerProvider.java @@ -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,20 +29,22 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class ArmenianAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final ArmenianAnalyzer analyzer; - @Inject public ArmenianAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public ArmenianAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); analyzer = new ArmenianAnalyzer(version, Analysis.parseStopWords(env, settings, ArmenianAnalyzer.getDefaultStopSet(), version), Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET)); } - @Override public ArmenianAnalyzer get() { + @Override + public ArmenianAnalyzer get() { return this.analyzer; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/BasqueAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/BasqueAnalyzerProvider.java index c2192b9d7cb..868b5d8f1ce 100644 --- a/src/main/java/org/elasticsearch/index/analysis/BasqueAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/BasqueAnalyzerProvider.java @@ -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,20 +29,22 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class BasqueAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final BasqueAnalyzer analyzer; - @Inject public BasqueAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public BasqueAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); analyzer = new BasqueAnalyzer(version, Analysis.parseStopWords(env, settings, BasqueAnalyzer.getDefaultStopSet(), version), Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET)); } - @Override public BasqueAnalyzer get() { + @Override + public BasqueAnalyzer get() { return this.analyzer; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/BrazilianAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/BrazilianAnalyzerProvider.java index 818511f7877..42017cf6694 100644 --- a/src/main/java/org/elasticsearch/index/analysis/BrazilianAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/BrazilianAnalyzerProvider.java @@ -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,20 +29,22 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class BrazilianAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final BrazilianAnalyzer analyzer; - @Inject public BrazilianAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public BrazilianAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); analyzer = new BrazilianAnalyzer(version, Analysis.parseStopWords(env, settings, BrazilianAnalyzer.getDefaultStopSet(), version), Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET)); } - @Override public BrazilianAnalyzer get() { + @Override + public BrazilianAnalyzer get() { return this.analyzer; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/BrazilianStemTokenFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/BrazilianStemTokenFilterFactory.java index 84376c1609f..66db090c0c5 100644 --- a/src/main/java/org/elasticsearch/index/analysis/BrazilianStemTokenFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/BrazilianStemTokenFilterFactory.java @@ -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.index.analysis; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterators; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.br.BrazilianStemFilter; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.collect.Iterators; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; @@ -32,13 +32,14 @@ import org.elasticsearch.index.settings.IndexSettings; import java.util.Set; /** - * @author kimchy (shay.banon) + * */ public class BrazilianStemTokenFilterFactory extends AbstractTokenFilterFactory { private final Set exclusions; - @Inject public BrazilianStemTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public BrazilianStemTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); String[] stemExclusion = settings.getAsArray("stem_exclusion"); if (stemExclusion.length > 0) { @@ -48,7 +49,8 @@ public class BrazilianStemTokenFilterFactory extends AbstractTokenFilterFactory } } - @Override public TokenStream create(TokenStream tokenStream) { + @Override + public TokenStream create(TokenStream tokenStream) { return new BrazilianStemFilter(tokenStream, exclusions); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/BulgarianAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/BulgarianAnalyzerProvider.java index 6cbd86259b5..2acfc857c7d 100644 --- a/src/main/java/org/elasticsearch/index/analysis/BulgarianAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/BulgarianAnalyzerProvider.java @@ -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,20 +29,22 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class BulgarianAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final BulgarianAnalyzer analyzer; - @Inject public BulgarianAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public BulgarianAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); analyzer = new BulgarianAnalyzer(version, Analysis.parseStopWords(env, settings, BulgarianAnalyzer.getDefaultStopSet(), version), Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET)); } - @Override public BulgarianAnalyzer get() { + @Override + public BulgarianAnalyzer get() { return this.analyzer; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/CatalanAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/CatalanAnalyzerProvider.java index 51120512325..0deef9d3293 100644 --- a/src/main/java/org/elasticsearch/index/analysis/CatalanAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/CatalanAnalyzerProvider.java @@ -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,20 +29,22 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class CatalanAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final CatalanAnalyzer analyzer; - @Inject public CatalanAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public CatalanAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); analyzer = new CatalanAnalyzer(version, Analysis.parseStopWords(env, settings, CatalanAnalyzer.getDefaultStopSet(), version), Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET)); } - @Override public CatalanAnalyzer get() { + @Override + public CatalanAnalyzer get() { return this.analyzer; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/CharFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/CharFilterFactory.java index 1189b0f72a3..4df5a3c08f2 100644 --- a/src/main/java/org/elasticsearch/index/analysis/CharFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/CharFilterFactory.java @@ -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.index.analysis; import org.apache.lucene.analysis.CharStream; /** - * @author kimchy (shay.banon) + * */ public interface CharFilterFactory { diff --git a/src/main/java/org/elasticsearch/index/analysis/CharFilterFactoryFactory.java b/src/main/java/org/elasticsearch/index/analysis/CharFilterFactoryFactory.java index d86dc267e60..026fc505026 100644 --- a/src/main/java/org/elasticsearch/index/analysis/CharFilterFactoryFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/CharFilterFactoryFactory.java @@ -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.index.analysis; import org.elasticsearch.common.settings.Settings; /** - * @author kimchy (shay.banon) + * */ public interface CharFilterFactoryFactory { diff --git a/src/main/java/org/elasticsearch/index/analysis/ChineseAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/ChineseAnalyzerProvider.java index e2db9bc4cf6..03715e7468c 100644 --- a/src/main/java/org/elasticsearch/index/analysis/ChineseAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/ChineseAnalyzerProvider.java @@ -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,18 +27,20 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class ChineseAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final ChineseAnalyzer analyzer; - @Inject public ChineseAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public ChineseAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); analyzer = new ChineseAnalyzer(); } - @Override public ChineseAnalyzer get() { + @Override + public ChineseAnalyzer get() { return this.analyzer; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/CjkAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/CjkAnalyzerProvider.java index 90e815bf191..84428d6ae2c 100644 --- a/src/main/java/org/elasticsearch/index/analysis/CjkAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/CjkAnalyzerProvider.java @@ -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,20 +30,22 @@ import org.elasticsearch.index.settings.IndexSettings; import java.util.Set; /** - * @author kimchy (shay.banon) + * */ public class CjkAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final CJKAnalyzer analyzer; - @Inject public CjkAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public CjkAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); Set stopWords = Analysis.parseStopWords(env, settings, CJKAnalyzer.getDefaultStopSet(), version); analyzer = new CJKAnalyzer(version, stopWords); } - @Override public CJKAnalyzer get() { + @Override + public CJKAnalyzer get() { return this.analyzer; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/CustomAnalyzer.java b/src/main/java/org/elasticsearch/index/analysis/CustomAnalyzer.java index 54747a84f54..f047a2e0fb3 100644 --- a/src/main/java/org/elasticsearch/index/analysis/CustomAnalyzer.java +++ b/src/main/java/org/elasticsearch/index/analysis/CustomAnalyzer.java @@ -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.io.IOException; import java.io.Reader; /** - * @author kimchy (Shay Banon) + * */ public final class CustomAnalyzer extends Analyzer implements PositionIncrementGapAnalyzer { @@ -43,7 +43,8 @@ public final class CustomAnalyzer extends Analyzer implements PositionIncrementG this.tokenFilters = tokenFilters; } - @Override public void setPositionIncrementGap(int positionIncrementGap) { + @Override + public void setPositionIncrementGap(int positionIncrementGap) { this.positionIncrementGap = positionIncrementGap; } @@ -59,15 +60,18 @@ public final class CustomAnalyzer extends Analyzer implements PositionIncrementG return charFilters; } - @Override public int getPositionIncrementGap(String fieldName) { + @Override + public int getPositionIncrementGap(String fieldName) { return this.positionIncrementGap; } - @Override public final TokenStream tokenStream(String fieldName, Reader reader) { + @Override + public final TokenStream tokenStream(String fieldName, Reader reader) { return buildHolder(reader).tokenStream; } - @Override public final TokenStream reusableTokenStream(String fieldName, Reader reader) throws IOException { + @Override + public final TokenStream reusableTokenStream(String fieldName, Reader reader) throws IOException { Holder holder = (Holder) getPreviousTokenStream(); if (holder == null) { holder = buildHolder(charFilterIfNeeded(reader)); diff --git a/src/main/java/org/elasticsearch/index/analysis/CustomAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/CustomAnalyzerProvider.java index 3668d484b1b..d803f46fa3e 100644 --- a/src/main/java/org/elasticsearch/index/analysis/CustomAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/CustomAnalyzerProvider.java @@ -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,13 +27,13 @@ import org.elasticsearch.index.settings.IndexSettings; import java.util.List; -import static org.elasticsearch.common.collect.Lists.*; +import static com.google.common.collect.Lists.newArrayList; /** * A custom analyzer that is built out of a single {@link org.apache.lucene.analysis.Tokenizer} and a list * of {@link org.apache.lucene.analysis.TokenFilter}s. * - * @author kimchy (shay.banon) + * */ public class CustomAnalyzerProvider extends AbstractIndexAnalyzerProvider { @@ -41,8 +41,9 @@ public class CustomAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final CzechAnalyzer analyzer; - @Inject public CzechAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public CzechAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); analyzer = new CzechAnalyzer(version, Analysis.parseStopWords(env, settings, CzechAnalyzer.getDefaultStopSet(), version), Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET)); } - @Override public CzechAnalyzer get() { + @Override + public CzechAnalyzer get() { return this.analyzer; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/CzechStemTokenFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/CzechStemTokenFilterFactory.java index 6fb72994b29..c200f43025e 100644 --- a/src/main/java/org/elasticsearch/index/analysis/CzechStemTokenFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/CzechStemTokenFilterFactory.java @@ -10,11 +10,13 @@ import org.elasticsearch.index.settings.IndexSettings; public class CzechStemTokenFilterFactory extends AbstractTokenFilterFactory { - @Inject public CzechStemTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public CzechStemTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); } - @Override public TokenStream create(TokenStream tokenStream) { + @Override + public TokenStream create(TokenStream tokenStream) { return new CzechStemFilter(tokenStream); } } diff --git a/src/main/java/org/elasticsearch/index/analysis/DanishAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/DanishAnalyzerProvider.java index f8d476cee49..bcd39e21668 100644 --- a/src/main/java/org/elasticsearch/index/analysis/DanishAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/DanishAnalyzerProvider.java @@ -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,20 +29,22 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class DanishAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final DanishAnalyzer analyzer; - @Inject public DanishAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public DanishAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); analyzer = new DanishAnalyzer(version, Analysis.parseStopWords(env, settings, DanishAnalyzer.getDefaultStopSet(), version), Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET)); } - @Override public DanishAnalyzer get() { + @Override + public DanishAnalyzer get() { return this.analyzer; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/DutchAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/DutchAnalyzerProvider.java index 66a1390a2b5..74a9d514173 100644 --- a/src/main/java/org/elasticsearch/index/analysis/DutchAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/DutchAnalyzerProvider.java @@ -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,20 +29,22 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class DutchAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final DutchAnalyzer analyzer; - @Inject public DutchAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public DutchAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); analyzer = new DutchAnalyzer(version, Analysis.parseStopWords(env, settings, DutchAnalyzer.getDefaultStopSet(), version), Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET)); } - @Override public DutchAnalyzer get() { + @Override + public DutchAnalyzer get() { return this.analyzer; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/DutchStemTokenFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/DutchStemTokenFilterFactory.java index 8601312f0b5..e66d41ab1bf 100644 --- a/src/main/java/org/elasticsearch/index/analysis/DutchStemTokenFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/DutchStemTokenFilterFactory.java @@ -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.index.analysis; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterators; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.nl.DutchStemFilter; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.collect.Iterators; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; @@ -32,13 +32,14 @@ import org.elasticsearch.index.settings.IndexSettings; import java.util.Set; /** - * @author kimchy (shay.banon) + * */ public class DutchStemTokenFilterFactory extends AbstractTokenFilterFactory { private final Set exclusions; - @Inject public DutchStemTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public DutchStemTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); String[] stemExclusion = settings.getAsArray("stem_exclusion"); if (stemExclusion.length > 0) { @@ -48,7 +49,8 @@ public class DutchStemTokenFilterFactory extends AbstractTokenFilterFactory { } } - @Override public TokenStream create(TokenStream tokenStream) { + @Override + public TokenStream create(TokenStream tokenStream) { return new DutchStemFilter(tokenStream, exclusions); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/EdgeNGramTokenFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/EdgeNGramTokenFilterFactory.java index 5e0b3e85e67..44addf1321b 100644 --- a/src/main/java/org/elasticsearch/index/analysis/EdgeNGramTokenFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/EdgeNGramTokenFilterFactory.java @@ -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,7 +31,7 @@ import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (Shay Banon) + * */ public class EdgeNGramTokenFilterFactory extends AbstractTokenFilterFactory { @@ -41,14 +41,16 @@ public class EdgeNGramTokenFilterFactory extends AbstractTokenFilterFactory { private final EdgeNGramTokenFilter.Side side; - @Inject public EdgeNGramTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public EdgeNGramTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); this.minGram = settings.getAsInt("min_gram", NGramTokenFilter.DEFAULT_MIN_NGRAM_SIZE); this.maxGram = settings.getAsInt("max_gram", NGramTokenFilter.DEFAULT_MAX_NGRAM_SIZE); this.side = EdgeNGramTokenFilter.Side.getSide(settings.get("side", EdgeNGramTokenizer.DEFAULT_SIDE.getLabel())); } - @Override public TokenStream create(TokenStream tokenStream) { + @Override + public TokenStream create(TokenStream tokenStream) { return new EdgeNGramTokenFilter(tokenStream, side, minGram, maxGram); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/EdgeNGramTokenizerFactory.java b/src/main/java/org/elasticsearch/index/analysis/EdgeNGramTokenizerFactory.java index f21973f24ed..6e45cb440dc 100644 --- a/src/main/java/org/elasticsearch/index/analysis/EdgeNGramTokenizerFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/EdgeNGramTokenizerFactory.java @@ -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,7 +31,7 @@ import org.elasticsearch.index.settings.IndexSettings; import java.io.Reader; /** - * @author kimchy (Shay Banon) + * */ public class EdgeNGramTokenizerFactory extends AbstractTokenizerFactory { @@ -41,14 +41,16 @@ public class EdgeNGramTokenizerFactory extends AbstractTokenizerFactory { private final EdgeNGramTokenizer.Side side; - @Inject public EdgeNGramTokenizerFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public EdgeNGramTokenizerFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); this.minGram = settings.getAsInt("min_gram", NGramTokenizer.DEFAULT_MIN_NGRAM_SIZE); this.maxGram = settings.getAsInt("max_gram", NGramTokenizer.DEFAULT_MAX_NGRAM_SIZE); this.side = EdgeNGramTokenizer.Side.getSide(settings.get("side", EdgeNGramTokenizer.DEFAULT_SIDE.getLabel())); } - @Override public Tokenizer create(Reader reader) { + @Override + public Tokenizer create(Reader reader) { return new EdgeNGramTokenizer(reader, side, minGram, maxGram); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/ElisionTokenFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/ElisionTokenFilterFactory.java index 31366d6dab6..1bed5963046 100644 --- a/src/main/java/org/elasticsearch/index/analysis/ElisionTokenFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/ElisionTokenFilterFactory.java @@ -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,18 +31,20 @@ import org.elasticsearch.index.settings.IndexSettings; import java.util.Set; /** - * @author kimchy (Shay Banon) + * */ public class ElisionTokenFilterFactory extends AbstractTokenFilterFactory { private final Set articles; - @Inject public ElisionTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public ElisionTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); this.articles = Analysis.parseArticles(env, settings, version); } - @Override public TokenStream create(TokenStream tokenStream) { + @Override + public TokenStream create(TokenStream tokenStream) { if (articles == null) { return new ElisionFilter(version, tokenStream); } else { diff --git a/src/main/java/org/elasticsearch/index/analysis/EnglishAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/EnglishAnalyzerProvider.java index 230cd2e3c6a..82996d0f666 100644 --- a/src/main/java/org/elasticsearch/index/analysis/EnglishAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/EnglishAnalyzerProvider.java @@ -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,20 +29,22 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class EnglishAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final EnglishAnalyzer analyzer; - @Inject public EnglishAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public EnglishAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); analyzer = new EnglishAnalyzer(version, Analysis.parseStopWords(env, settings, EnglishAnalyzer.getDefaultStopSet(), version), Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET)); } - @Override public EnglishAnalyzer get() { + @Override + public EnglishAnalyzer get() { return this.analyzer; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/FieldNameAnalyzer.java b/src/main/java/org/elasticsearch/index/analysis/FieldNameAnalyzer.java index 9080abd52ee..1bc0d66019d 100644 --- a/src/main/java/org/elasticsearch/index/analysis/FieldNameAnalyzer.java +++ b/src/main/java/org/elasticsearch/index/analysis/FieldNameAnalyzer.java @@ -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,17 +19,17 @@ package org.elasticsearch.index.analysis; +import com.google.common.collect.ImmutableMap; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.document.Fieldable; -import org.elasticsearch.common.collect.ImmutableMap; import java.io.IOException; import java.io.Reader; import java.util.Map; /** - * @author kimchy (Shay Banon) + * */ public final class FieldNameAnalyzer extends Analyzer { @@ -50,19 +50,23 @@ public final class FieldNameAnalyzer extends Analyzer { return defaultAnalyzer; } - @Override public final TokenStream tokenStream(String fieldName, Reader reader) { + @Override + public final TokenStream tokenStream(String fieldName, Reader reader) { return getAnalyzer(fieldName).tokenStream(fieldName, reader); } - @Override public final TokenStream reusableTokenStream(String fieldName, Reader reader) throws IOException { + @Override + public final TokenStream reusableTokenStream(String fieldName, Reader reader) throws IOException { return getAnalyzer(fieldName).reusableTokenStream(fieldName, reader); } - @Override public int getPositionIncrementGap(String fieldName) { + @Override + public int getPositionIncrementGap(String fieldName) { return getAnalyzer(fieldName).getPositionIncrementGap(fieldName); } - @Override public int getOffsetGap(Fieldable field) { + @Override + public int getOffsetGap(Fieldable field) { return getAnalyzer(field.name()).getOffsetGap(field); } diff --git a/src/main/java/org/elasticsearch/index/analysis/FinnishAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/FinnishAnalyzerProvider.java index 1159b193789..d2d8029e969 100644 --- a/src/main/java/org/elasticsearch/index/analysis/FinnishAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/FinnishAnalyzerProvider.java @@ -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,20 +29,22 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class FinnishAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final FinnishAnalyzer analyzer; - @Inject public FinnishAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public FinnishAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); analyzer = new FinnishAnalyzer(version, Analysis.parseStopWords(env, settings, FinnishAnalyzer.getDefaultStopSet(), version), Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET)); } - @Override public FinnishAnalyzer get() { + @Override + public FinnishAnalyzer get() { return this.analyzer; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/FrenchAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/FrenchAnalyzerProvider.java index 6b6a389edaa..036b51b9bcb 100644 --- a/src/main/java/org/elasticsearch/index/analysis/FrenchAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/FrenchAnalyzerProvider.java @@ -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,20 +29,22 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class FrenchAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final FrenchAnalyzer analyzer; - @Inject public FrenchAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public FrenchAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); analyzer = new FrenchAnalyzer(version, Analysis.parseStopWords(env, settings, FrenchAnalyzer.getDefaultStopSet(), version), Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET)); } - @Override public FrenchAnalyzer get() { + @Override + public FrenchAnalyzer get() { return this.analyzer; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/FrenchStemTokenFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/FrenchStemTokenFilterFactory.java index d87310158bc..3462cf687d7 100644 --- a/src/main/java/org/elasticsearch/index/analysis/FrenchStemTokenFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/FrenchStemTokenFilterFactory.java @@ -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.index.analysis; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterators; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.fr.FrenchStemFilter; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.collect.Iterators; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; @@ -32,13 +32,14 @@ import org.elasticsearch.index.settings.IndexSettings; import java.util.Set; /** - * @author kimchy (shay.banon) + * */ public class FrenchStemTokenFilterFactory extends AbstractTokenFilterFactory { private final Set exclusions; - @Inject public FrenchStemTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public FrenchStemTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); String[] stemExclusion = settings.getAsArray("stem_exclusion"); if (stemExclusion.length > 0) { @@ -48,7 +49,8 @@ public class FrenchStemTokenFilterFactory extends AbstractTokenFilterFactory { } } - @Override public TokenStream create(TokenStream tokenStream) { + @Override + public TokenStream create(TokenStream tokenStream) { return new FrenchStemFilter(tokenStream, exclusions); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/GalicianAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/GalicianAnalyzerProvider.java index 4c4637468d2..c1c8ab46afa 100644 --- a/src/main/java/org/elasticsearch/index/analysis/GalicianAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/GalicianAnalyzerProvider.java @@ -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,20 +29,22 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class GalicianAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final GalicianAnalyzer analyzer; - @Inject public GalicianAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public GalicianAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); analyzer = new GalicianAnalyzer(version, Analysis.parseStopWords(env, settings, GalicianAnalyzer.getDefaultStopSet(), version), Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET)); } - @Override public GalicianAnalyzer get() { + @Override + public GalicianAnalyzer get() { return this.analyzer; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/GermanAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/GermanAnalyzerProvider.java index 62bda905446..121111defb9 100644 --- a/src/main/java/org/elasticsearch/index/analysis/GermanAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/GermanAnalyzerProvider.java @@ -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,20 +29,22 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class GermanAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final GermanAnalyzer analyzer; - @Inject public GermanAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public GermanAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); analyzer = new GermanAnalyzer(version, Analysis.parseStopWords(env, settings, GermanAnalyzer.getDefaultStopSet(), version), Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET)); } - @Override public GermanAnalyzer get() { + @Override + public GermanAnalyzer get() { return this.analyzer; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/GermanStemTokenFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/GermanStemTokenFilterFactory.java index 44fe37fe702..d9c34142c4b 100644 --- a/src/main/java/org/elasticsearch/index/analysis/GermanStemTokenFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/GermanStemTokenFilterFactory.java @@ -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.index.analysis; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterators; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.de.GermanStemFilter; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.collect.Iterators; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; @@ -32,13 +32,14 @@ import org.elasticsearch.index.settings.IndexSettings; import java.util.Set; /** - * @author kimchy (shay.banon) + * */ public class GermanStemTokenFilterFactory extends AbstractTokenFilterFactory { private final Set exclusions; - @Inject public GermanStemTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public GermanStemTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); String[] stemExclusion = settings.getAsArray("stem_exclusion"); if (stemExclusion.length > 0) { @@ -48,7 +49,8 @@ public class GermanStemTokenFilterFactory extends AbstractTokenFilterFactory { } } - @Override public TokenStream create(TokenStream tokenStream) { + @Override + public TokenStream create(TokenStream tokenStream) { return new GermanStemFilter(tokenStream, exclusions); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/GreekAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/GreekAnalyzerProvider.java index a90e92fff40..e94f4d21a42 100644 --- a/src/main/java/org/elasticsearch/index/analysis/GreekAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/GreekAnalyzerProvider.java @@ -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,19 +28,21 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class GreekAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final GreekAnalyzer analyzer; - @Inject public GreekAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public GreekAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); analyzer = new GreekAnalyzer(version, Analysis.parseStopWords(env, settings, GreekAnalyzer.getDefaultStopSet(), version)); } - @Override public GreekAnalyzer get() { + @Override + public GreekAnalyzer get() { return this.analyzer; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/HindiAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/HindiAnalyzerProvider.java index 439e6f0f7e5..8185947f986 100644 --- a/src/main/java/org/elasticsearch/index/analysis/HindiAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/HindiAnalyzerProvider.java @@ -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,20 +29,22 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class HindiAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final HindiAnalyzer analyzer; - @Inject public HindiAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public HindiAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); analyzer = new HindiAnalyzer(version, Analysis.parseStopWords(env, settings, HindiAnalyzer.getDefaultStopSet(), version), Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET)); } - @Override public HindiAnalyzer get() { + @Override + public HindiAnalyzer get() { return this.analyzer; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/HtmlStripCharFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/HtmlStripCharFilterFactory.java index e532118105d..75ae6c4567d 100644 --- a/src/main/java/org/elasticsearch/index/analysis/HtmlStripCharFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/HtmlStripCharFilterFactory.java @@ -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.index.analysis; +import com.google.common.collect.ImmutableSet; import org.apache.lucene.analysis.CharStream; -import org.elasticsearch.common.collect.ImmutableSet; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.lucene.analysis.HTMLStripCharFilter; @@ -29,7 +29,7 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class HtmlStripCharFilterFactory extends AbstractCharFilterFactory { @@ -37,7 +37,8 @@ public class HtmlStripCharFilterFactory extends AbstractCharFilterFactory { private final int readAheadLimit; - @Inject public HtmlStripCharFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public HtmlStripCharFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name); this.readAheadLimit = settings.getAsInt("read_ahead", HTMLStripCharFilter.DEFAULT_READ_AHEAD); String[] escapedTags = settings.getAsArray("escaped_tags"); @@ -56,7 +57,8 @@ public class HtmlStripCharFilterFactory extends AbstractCharFilterFactory { return readAheadLimit; } - @Override public CharStream create(CharStream tokenStream) { + @Override + public CharStream create(CharStream tokenStream) { return new HTMLStripCharFilter(tokenStream, escapedTags, readAheadLimit); } } diff --git a/src/main/java/org/elasticsearch/index/analysis/HungarianAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/HungarianAnalyzerProvider.java index dfca9a57ef6..019d6a8194d 100644 --- a/src/main/java/org/elasticsearch/index/analysis/HungarianAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/HungarianAnalyzerProvider.java @@ -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,20 +29,22 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class HungarianAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final HungarianAnalyzer analyzer; - @Inject public HungarianAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public HungarianAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); analyzer = new HungarianAnalyzer(version, Analysis.parseStopWords(env, settings, HungarianAnalyzer.getDefaultStopSet(), version), Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET)); } - @Override public HungarianAnalyzer get() { + @Override + public HungarianAnalyzer get() { return this.analyzer; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/IndonesianAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/IndonesianAnalyzerProvider.java index a03e17e4e28..1cdd495521b 100644 --- a/src/main/java/org/elasticsearch/index/analysis/IndonesianAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/IndonesianAnalyzerProvider.java @@ -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,20 +29,22 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class IndonesianAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final IndonesianAnalyzer analyzer; - @Inject public IndonesianAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public IndonesianAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); analyzer = new IndonesianAnalyzer(version, Analysis.parseStopWords(env, settings, IndonesianAnalyzer.getDefaultStopSet(), version), Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET)); } - @Override public IndonesianAnalyzer get() { + @Override + public IndonesianAnalyzer get() { return this.analyzer; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/ItalianAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/ItalianAnalyzerProvider.java index 5531e4883de..ff3065027a1 100644 --- a/src/main/java/org/elasticsearch/index/analysis/ItalianAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/ItalianAnalyzerProvider.java @@ -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,20 +29,22 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class ItalianAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final ItalianAnalyzer analyzer; - @Inject public ItalianAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public ItalianAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); analyzer = new ItalianAnalyzer(version, Analysis.parseStopWords(env, settings, ItalianAnalyzer.getDefaultStopSet(), version), Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET)); } - @Override public ItalianAnalyzer get() { + @Override + public ItalianAnalyzer get() { return this.analyzer; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/KStemTokenFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/KStemTokenFilterFactory.java index 6d559e3cdf9..f2036577df2 100644 --- a/src/main/java/org/elasticsearch/index/analysis/KStemTokenFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/KStemTokenFilterFactory.java @@ -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,11 +29,13 @@ import org.elasticsearch.index.settings.IndexSettings; public class KStemTokenFilterFactory extends AbstractTokenFilterFactory { - @Inject public KStemTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public KStemTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); } - @Override public TokenStream create(TokenStream tokenStream) { + @Override + public TokenStream create(TokenStream tokenStream) { return new KStemFilter(tokenStream); } } diff --git a/src/main/java/org/elasticsearch/index/analysis/KeywordAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/KeywordAnalyzerProvider.java index 6d4ef475ba2..ffd0a8d783b 100644 --- a/src/main/java/org/elasticsearch/index/analysis/KeywordAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/KeywordAnalyzerProvider.java @@ -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,18 +27,20 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (Shay Banon) + * */ public class KeywordAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final KeywordAnalyzer keywordAnalyzer; - @Inject public KeywordAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public KeywordAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); this.keywordAnalyzer = new KeywordAnalyzer(); } - @Override public KeywordAnalyzer get() { + @Override + public KeywordAnalyzer get() { return this.keywordAnalyzer; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/KeywordMarkerTokenFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/KeywordMarkerTokenFilterFactory.java index 3bd27c555b5..618f089c61e 100644 --- a/src/main/java/org/elasticsearch/index/analysis/KeywordMarkerTokenFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/KeywordMarkerTokenFilterFactory.java @@ -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,8 @@ public class KeywordMarkerTokenFilterFactory extends AbstractTokenFilterFactory private final CharArraySet keywordLookup; - @Inject public KeywordMarkerTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public KeywordMarkerTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); boolean ignoreCase = settings.getAsBoolean("ignore_case", false); @@ -48,7 +49,8 @@ public class KeywordMarkerTokenFilterFactory extends AbstractTokenFilterFactory keywordLookup = new CharArraySet(version, rules, ignoreCase); } - @Override public TokenStream create(TokenStream tokenStream) { + @Override + public TokenStream create(TokenStream tokenStream) { return new KeywordMarkerFilter(tokenStream, keywordLookup); } } diff --git a/src/main/java/org/elasticsearch/index/analysis/KeywordTokenizerFactory.java b/src/main/java/org/elasticsearch/index/analysis/KeywordTokenizerFactory.java index 3a8e92e6123..09bc3335651 100644 --- a/src/main/java/org/elasticsearch/index/analysis/KeywordTokenizerFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/KeywordTokenizerFactory.java @@ -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,18 +30,20 @@ import org.elasticsearch.index.settings.IndexSettings; import java.io.Reader; /** - * @author kimchy (Shay Banon) + * */ public class KeywordTokenizerFactory extends AbstractTokenizerFactory { private final int bufferSize; - @Inject public KeywordTokenizerFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public KeywordTokenizerFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); bufferSize = settings.getAsInt("buffer_size", 256); } - @Override public Tokenizer create(Reader reader) { + @Override + public Tokenizer create(Reader reader) { return new KeywordTokenizer(reader, bufferSize); } } diff --git a/src/main/java/org/elasticsearch/index/analysis/LengthTokenFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/LengthTokenFilterFactory.java index fe38eaf0b8a..2e98fb3b63f 100644 --- a/src/main/java/org/elasticsearch/index/analysis/LengthTokenFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/LengthTokenFilterFactory.java @@ -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.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (Shay Banon) + * */ public class LengthTokenFilterFactory extends AbstractTokenFilterFactory { @@ -36,14 +36,16 @@ public class LengthTokenFilterFactory extends AbstractTokenFilterFactory { private final int max; private final boolean enablePositionIncrements; - @Inject public LengthTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public LengthTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); min = settings.getAsInt("min", 0); max = settings.getAsInt("max", Integer.MAX_VALUE); enablePositionIncrements = settings.getAsBoolean("enabled_position_increments", true); } - @Override public TokenStream create(TokenStream tokenStream) { + @Override + public TokenStream create(TokenStream tokenStream) { return new LengthFilter(enablePositionIncrements, tokenStream, min, max); } } diff --git a/src/main/java/org/elasticsearch/index/analysis/LetterTokenizerFactory.java b/src/main/java/org/elasticsearch/index/analysis/LetterTokenizerFactory.java index e45018fa58d..e058aa8d9ad 100644 --- a/src/main/java/org/elasticsearch/index/analysis/LetterTokenizerFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/LetterTokenizerFactory.java @@ -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,15 +30,17 @@ import org.elasticsearch.index.settings.IndexSettings; import java.io.Reader; /** - * @author kimchy (Shay Banon) + * */ public class LetterTokenizerFactory extends AbstractTokenizerFactory { - @Inject public LetterTokenizerFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public LetterTokenizerFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); } - @Override public Tokenizer create(Reader reader) { + @Override + public Tokenizer create(Reader reader) { return new LetterTokenizer(version, reader); } } diff --git a/src/main/java/org/elasticsearch/index/analysis/LowerCaseTokenFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/LowerCaseTokenFilterFactory.java index d5ce5cb1b7d..2baaafc358a 100644 --- a/src/main/java/org/elasticsearch/index/analysis/LowerCaseTokenFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/LowerCaseTokenFilterFactory.java @@ -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,18 +31,20 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (Shay Banon) + * */ public class LowerCaseTokenFilterFactory extends AbstractTokenFilterFactory { private final String lang; - @Inject public LowerCaseTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public LowerCaseTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); this.lang = settings.get("language", null); } - @Override public TokenStream create(TokenStream tokenStream) { + @Override + public TokenStream create(TokenStream tokenStream) { if (lang == null) { return new LowerCaseFilter(version, tokenStream); } else if (lang.equalsIgnoreCase("greek")) { diff --git a/src/main/java/org/elasticsearch/index/analysis/LowerCaseTokenizerFactory.java b/src/main/java/org/elasticsearch/index/analysis/LowerCaseTokenizerFactory.java index 24a9c80139f..a6e501591e5 100644 --- a/src/main/java/org/elasticsearch/index/analysis/LowerCaseTokenizerFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/LowerCaseTokenizerFactory.java @@ -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,15 +30,17 @@ import org.elasticsearch.index.settings.IndexSettings; import java.io.Reader; /** - * @author kimchy (Shay Banon) + * */ public class LowerCaseTokenizerFactory extends AbstractTokenizerFactory { - @Inject public LowerCaseTokenizerFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public LowerCaseTokenizerFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); } - @Override public Tokenizer create(Reader reader) { + @Override + public Tokenizer create(Reader reader) { return new LowerCaseTokenizer(version, reader); } } diff --git a/src/main/java/org/elasticsearch/index/analysis/MappingCharFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/MappingCharFilterFactory.java index 72ed913683b..848cbd25a55 100644 --- a/src/main/java/org/elasticsearch/index/analysis/MappingCharFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/MappingCharFilterFactory.java @@ -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.index.analysis; import org.apache.lucene.analysis.CharStream; import org.apache.lucene.analysis.MappingCharFilter; import org.apache.lucene.analysis.NormalizeCharMap; - import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.assistedinject.Assisted; @@ -31,34 +30,36 @@ import org.elasticsearch.env.Environment; import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; -import java.util.*; +import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @AnalysisSettingsRequired public class MappingCharFilterFactory extends AbstractCharFilterFactory { - + private final NormalizeCharMap normMap; - - @Inject public MappingCharFilterFactory(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + + @Inject + public MappingCharFilterFactory(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name); - + List rules = Analysis.getWordList(env, settings, "mappings"); if (rules == null) { throw new ElasticSearchIllegalArgumentException("mapping requires either `mappings` or `mappings_path` to be configured"); } - + normMap = new NormalizeCharMap(); parseRules(rules, normMap); } - - @Override public CharStream create(CharStream tokenStream) { + + @Override + public CharStream create(CharStream tokenStream) { return new MappingCharFilter(normMap, tokenStream); } - + // source => target private static Pattern rulePattern = Pattern.compile("(.*)\\s*=>\\s*(.*)\\s*$"); - + /** * parses a list of MappingCharFilter style rules into a normalize char map */ @@ -74,9 +75,9 @@ public class MappingCharFilterFactory extends AbstractCharFilterFactory { map.add(lhs, rhs); } } - + char[] out = new char[256]; - + private String parseString(String s) { int readPos = 0; int len = s.length(); @@ -88,30 +89,30 @@ public class MappingCharFilterFactory extends AbstractCharFilterFactory { throw new RuntimeException("Invalid escaped char in [" + s + "]"); c = s.charAt(readPos++); switch (c) { - case '\\': - c = '\\'; - break; - case 'n': - c = '\n'; - break; - case 't': - c = '\t'; - break; - case 'r': - c = '\r'; - break; - case 'b': - c = '\b'; - break; - case 'f': - c = '\f'; - break; - case 'u': - if (readPos + 3 >= len) - throw new RuntimeException("Invalid escaped char in [" + s + "]"); - c = (char) Integer.parseInt(s.substring(readPos, readPos + 4), 16); - readPos += 4; - break; + case '\\': + c = '\\'; + break; + case 'n': + c = '\n'; + break; + case 't': + c = '\t'; + break; + case 'r': + c = '\r'; + break; + case 'b': + c = '\b'; + break; + case 'f': + c = '\f'; + break; + case 'u': + if (readPos + 3 >= len) + throw new RuntimeException("Invalid escaped char in [" + s + "]"); + c = (char) Integer.parseInt(s.substring(readPos, readPos + 4), 16); + readPos += 4; + break; } } out[writePos++] = c; diff --git a/src/main/java/org/elasticsearch/index/analysis/NGramTokenFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/NGramTokenFilterFactory.java index 260d7df9286..8b9964804cf 100644 --- a/src/main/java/org/elasticsearch/index/analysis/NGramTokenFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/NGramTokenFilterFactory.java @@ -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.index.settings.IndexSettings; /** - * @author kimchy (Shay Banon) + * */ public class NGramTokenFilterFactory extends AbstractTokenFilterFactory { @@ -38,13 +38,15 @@ public class NGramTokenFilterFactory extends AbstractTokenFilterFactory { private final int maxGram; - @Inject public NGramTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public NGramTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); this.minGram = settings.getAsInt("min_gram", NGramTokenFilter.DEFAULT_MIN_NGRAM_SIZE); this.maxGram = settings.getAsInt("max_gram", NGramTokenFilter.DEFAULT_MAX_NGRAM_SIZE); } - @Override public TokenStream create(TokenStream tokenStream) { + @Override + public TokenStream create(TokenStream tokenStream) { return new NGramTokenFilter(tokenStream, minGram, maxGram); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/NGramTokenizerFactory.java b/src/main/java/org/elasticsearch/index/analysis/NGramTokenizerFactory.java index 41990690785..f7084cf0bd2 100644 --- a/src/main/java/org/elasticsearch/index/analysis/NGramTokenizerFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/NGramTokenizerFactory.java @@ -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 org.elasticsearch.index.settings.IndexSettings; import java.io.Reader; /** - * @author kimchy (Shay Banon) + * */ public class NGramTokenizerFactory extends AbstractTokenizerFactory { @@ -38,13 +38,15 @@ public class NGramTokenizerFactory extends AbstractTokenizerFactory { private final int maxGram; - @Inject public NGramTokenizerFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public NGramTokenizerFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); this.minGram = settings.getAsInt("min_gram", NGramTokenizer.DEFAULT_MIN_NGRAM_SIZE); this.maxGram = settings.getAsInt("max_gram", NGramTokenizer.DEFAULT_MAX_NGRAM_SIZE); } - @Override public Tokenizer create(Reader reader) { + @Override + public Tokenizer create(Reader reader) { return new NGramTokenizer(reader, minGram, maxGram); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/NamedAnalyzer.java b/src/main/java/org/elasticsearch/index/analysis/NamedAnalyzer.java index effa878aad0..b742d47eb40 100644 --- a/src/main/java/org/elasticsearch/index/analysis/NamedAnalyzer.java +++ b/src/main/java/org/elasticsearch/index/analysis/NamedAnalyzer.java @@ -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,7 +31,7 @@ import java.io.Reader; * Named analyzer is an analyzer wrapper around an actual analyzer ({@link #analyzer} that is associated * with a name ({@link #name()}. * - * @author kimchy (shay.banon) + * */ @Immutable public final class NamedAnalyzer extends Analyzer { @@ -73,27 +73,33 @@ public final class NamedAnalyzer extends Analyzer { return this.analyzer; } - @Override public final TokenStream tokenStream(String fieldName, Reader reader) { + @Override + public final TokenStream tokenStream(String fieldName, Reader reader) { return analyzer.tokenStream(fieldName, reader); } - @Override public final TokenStream reusableTokenStream(String fieldName, Reader reader) throws IOException { + @Override + public final TokenStream reusableTokenStream(String fieldName, Reader reader) throws IOException { return analyzer.reusableTokenStream(fieldName, reader); } - @Override public int getPositionIncrementGap(String fieldName) { + @Override + public int getPositionIncrementGap(String fieldName) { return analyzer.getPositionIncrementGap(fieldName); } - @Override public int getOffsetGap(Fieldable field) { + @Override + public int getOffsetGap(Fieldable field) { return analyzer.getOffsetGap(field); } - @Override public void close() { + @Override + public void close() { analyzer.close(); } - @Override public String toString() { + @Override + public String toString() { return "analyzer name[" + name + "], analyzer [" + analyzer + "]"; } } diff --git a/src/main/java/org/elasticsearch/index/analysis/NorwegianAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/NorwegianAnalyzerProvider.java index 9d14dc9b577..79e96683643 100644 --- a/src/main/java/org/elasticsearch/index/analysis/NorwegianAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/NorwegianAnalyzerProvider.java @@ -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,20 +29,22 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class NorwegianAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final NorwegianAnalyzer analyzer; - @Inject public NorwegianAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public NorwegianAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); analyzer = new NorwegianAnalyzer(version, Analysis.parseStopWords(env, settings, NorwegianAnalyzer.getDefaultStopSet(), version), Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET)); } - @Override public NorwegianAnalyzer get() { + @Override + public NorwegianAnalyzer get() { return this.analyzer; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/NumericAnalyzer.java b/src/main/java/org/elasticsearch/index/analysis/NumericAnalyzer.java index d4290a04583..24db00cfe3f 100644 --- a/src/main/java/org/elasticsearch/index/analysis/NumericAnalyzer.java +++ b/src/main/java/org/elasticsearch/index/analysis/NumericAnalyzer.java @@ -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,11 +26,12 @@ import java.io.IOException; import java.io.Reader; /** - * @author kimchy (Shay Banon) + * */ public abstract class NumericAnalyzer extends Analyzer { - @Override public final TokenStream tokenStream(String fieldName, Reader reader) { + @Override + public final TokenStream tokenStream(String fieldName, Reader reader) { try { return createNumericTokenizer(reader, new char[32]); } catch (IOException e) { @@ -38,7 +39,8 @@ public abstract class NumericAnalyzer extends Analyz } } - @Override public final TokenStream reusableTokenStream(String fieldName, Reader reader) throws IOException { + @Override + public final TokenStream reusableTokenStream(String fieldName, Reader reader) throws IOException { Holder holder = (Holder) getPreviousTokenStream(); if (holder == null) { char[] buffer = new char[120]; diff --git a/src/main/java/org/elasticsearch/index/analysis/NumericDateAnalyzer.java b/src/main/java/org/elasticsearch/index/analysis/NumericDateAnalyzer.java index a808c729c07..303c226ab83 100644 --- a/src/main/java/org/elasticsearch/index/analysis/NumericDateAnalyzer.java +++ b/src/main/java/org/elasticsearch/index/analysis/NumericDateAnalyzer.java @@ -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,13 +20,13 @@ package org.elasticsearch.index.analysis; import org.apache.lucene.util.NumericUtils; -import org.elasticsearch.common.joda.time.format.DateTimeFormatter; +import org.joda.time.format.DateTimeFormatter; import java.io.IOException; import java.io.Reader; /** - * @author kimchy (Shay Banon) + * */ public class NumericDateAnalyzer extends NumericAnalyzer { @@ -43,7 +43,8 @@ public class NumericDateAnalyzer extends NumericAnalyzer { this.dateTimeFormatter = dateTimeFormatter; } - @Override protected NumericDateTokenizer createNumericTokenizer(Reader reader, char[] buffer) throws IOException { + @Override + protected NumericDateTokenizer createNumericTokenizer(Reader reader, char[] buffer) throws IOException { return new NumericDateTokenizer(reader, precisionStep, buffer, dateTimeFormatter); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/NumericDateTokenizer.java b/src/main/java/org/elasticsearch/index/analysis/NumericDateTokenizer.java index 274d422e0e8..ce74a55a059 100644 --- a/src/main/java/org/elasticsearch/index/analysis/NumericDateTokenizer.java +++ b/src/main/java/org/elasticsearch/index/analysis/NumericDateTokenizer.java @@ -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,13 +20,13 @@ package org.elasticsearch.index.analysis; import org.apache.lucene.analysis.NumericTokenStream; -import org.elasticsearch.common.joda.time.format.DateTimeFormatter; +import org.joda.time.format.DateTimeFormatter; import java.io.IOException; import java.io.Reader; /** - * @author kimchy (shay.banon) + * */ public class NumericDateTokenizer extends NumericTokenizer { @@ -38,7 +38,8 @@ public class NumericDateTokenizer extends NumericTokenizer { super(reader, new NumericTokenStream(precisionStep), buffer, dateTimeFormatter); } - @Override protected void setValue(NumericTokenStream tokenStream, String value) { + @Override + protected void setValue(NumericTokenStream tokenStream, String value) { tokenStream.setLongValue(((DateTimeFormatter) extra).parseMillis(value)); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/NumericDoubleAnalyzer.java b/src/main/java/org/elasticsearch/index/analysis/NumericDoubleAnalyzer.java index 537dd1f7d95..2c8465d3643 100644 --- a/src/main/java/org/elasticsearch/index/analysis/NumericDoubleAnalyzer.java +++ b/src/main/java/org/elasticsearch/index/analysis/NumericDoubleAnalyzer.java @@ -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.io.IOException; import java.io.Reader; /** - * @author kimchy (Shay Banon) + * */ public class NumericDoubleAnalyzer extends NumericAnalyzer { @@ -39,7 +39,8 @@ public class NumericDoubleAnalyzer extends NumericAnalyzer { @@ -39,7 +39,8 @@ public class NumericFloatAnalyzer extends NumericAnalyzer this.precisionStep = precisionStep; } - @Override protected NumericFloatTokenizer createNumericTokenizer(Reader reader, char[] buffer) throws IOException { + @Override + protected NumericFloatTokenizer createNumericTokenizer(Reader reader, char[] buffer) throws IOException { return new NumericFloatTokenizer(reader, precisionStep, buffer); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/NumericFloatTokenizer.java b/src/main/java/org/elasticsearch/index/analysis/NumericFloatTokenizer.java index 0e86ea0816f..b6d66b1e108 100644 --- a/src/main/java/org/elasticsearch/index/analysis/NumericFloatTokenizer.java +++ b/src/main/java/org/elasticsearch/index/analysis/NumericFloatTokenizer.java @@ -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.io.IOException; import java.io.Reader; /** - * @author kimchy (shay.banon) + * */ public class NumericFloatTokenizer extends NumericTokenizer { @@ -37,7 +37,8 @@ public class NumericFloatTokenizer extends NumericTokenizer { super(reader, new NumericTokenStream(precisionStep), buffer, null); } - @Override protected void setValue(NumericTokenStream tokenStream, String value) { + @Override + protected void setValue(NumericTokenStream tokenStream, String value) { tokenStream.setFloatValue(Float.parseFloat(value)); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/NumericIntegerAnalyzer.java b/src/main/java/org/elasticsearch/index/analysis/NumericIntegerAnalyzer.java index 3fe6b7157ba..c969de7e23d 100644 --- a/src/main/java/org/elasticsearch/index/analysis/NumericIntegerAnalyzer.java +++ b/src/main/java/org/elasticsearch/index/analysis/NumericIntegerAnalyzer.java @@ -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.io.IOException; import java.io.Reader; /** - * @author kimchy (Shay Banon) + * */ public class NumericIntegerAnalyzer extends NumericAnalyzer { @@ -39,7 +39,8 @@ public class NumericIntegerAnalyzer extends NumericAnalyzer { @@ -39,7 +39,8 @@ public class NumericLongAnalyzer extends NumericAnalyzer { this.precisionStep = precisionStep; } - @Override protected NumericLongTokenizer createNumericTokenizer(Reader reader, char[] buffer) throws IOException { + @Override + protected NumericLongTokenizer createNumericTokenizer(Reader reader, char[] buffer) throws IOException { return new NumericLongTokenizer(reader, precisionStep, buffer); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/NumericLongTokenizer.java b/src/main/java/org/elasticsearch/index/analysis/NumericLongTokenizer.java index 4a1e2421b97..93b5e94324c 100644 --- a/src/main/java/org/elasticsearch/index/analysis/NumericLongTokenizer.java +++ b/src/main/java/org/elasticsearch/index/analysis/NumericLongTokenizer.java @@ -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.io.IOException; import java.io.Reader; /** - * @author kimchy (shay.banon) + * */ public class NumericLongTokenizer extends NumericTokenizer { @@ -37,7 +37,8 @@ public class NumericLongTokenizer extends NumericTokenizer { super(reader, new NumericTokenStream(precisionStep), buffer, null); } - @Override protected void setValue(NumericTokenStream tokenStream, String value) { + @Override + protected void setValue(NumericTokenStream tokenStream, String value) { tokenStream.setLongValue(Long.parseLong(value)); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/NumericTokenizer.java b/src/main/java/org/elasticsearch/index/analysis/NumericTokenizer.java index 8a76eb9d3d3..a3f11037eef 100644 --- a/src/main/java/org/elasticsearch/index/analysis/NumericTokenizer.java +++ b/src/main/java/org/elasticsearch/index/analysis/NumericTokenizer.java @@ -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.IOException; import java.io.Reader; /** - * @author kimchy (shay.banon) + * */ public abstract class NumericTokenizer extends Tokenizer { @@ -48,7 +48,8 @@ public abstract class NumericTokenizer extends Tokenizer { reset(reader, buffer); } - @Override public void reset(Reader input) throws IOException { + @Override + public void reset(Reader input) throws IOException { char[] buffer = new char[32]; reset(input, buffer); } @@ -61,7 +62,8 @@ public abstract class NumericTokenizer extends Tokenizer { numericTokenStream.reset(); } - @Override public final boolean incrementToken() throws IOException { + @Override + public final boolean incrementToken() throws IOException { return numericTokenStream.incrementToken(); } diff --git a/src/main/java/org/elasticsearch/index/analysis/PathHierarchyTokenizerFactory.java b/src/main/java/org/elasticsearch/index/analysis/PathHierarchyTokenizerFactory.java index 4fae5681457..a310ec5f415 100644 --- a/src/main/java/org/elasticsearch/index/analysis/PathHierarchyTokenizerFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/PathHierarchyTokenizerFactory.java @@ -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 @@ -40,7 +40,8 @@ public class PathHierarchyTokenizerFactory extends AbstractTokenizerFactory { private final int skip; private final boolean reverse; - @Inject public PathHierarchyTokenizerFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public PathHierarchyTokenizerFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); bufferSize = settings.getAsInt("buffer_size", 1024); String delimiter = settings.get("delimiter"); @@ -64,7 +65,8 @@ public class PathHierarchyTokenizerFactory extends AbstractTokenizerFactory { this.reverse = settings.getAsBoolean("reverse", false); } - @Override public Tokenizer create(Reader reader) { + @Override + public Tokenizer create(Reader reader) { if (reverse) { return new ReversePathHierarchyTokenizer(reader, bufferSize, delimiter, replacement, skip); } diff --git a/src/main/java/org/elasticsearch/index/analysis/PatternAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/PatternAnalyzerProvider.java index 2c907528772..7e1ebdab5e1 100644 --- a/src/main/java/org/elasticsearch/index/analysis/PatternAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/PatternAnalyzerProvider.java @@ -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,13 +34,14 @@ import java.util.Set; import java.util.regex.Pattern; /** - * @author kimchy (shay.banon) + * */ public class PatternAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final PatternAnalyzer analyzer; - @Inject public PatternAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public PatternAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); boolean lowercase = settings.getAsBoolean("lowercase", true); @@ -56,7 +57,8 @@ public class PatternAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final PersianAnalyzer analyzer; - @Inject public PersianAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public PersianAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); analyzer = new PersianAnalyzer(version, Analysis.parseStopWords(env, settings, PersianAnalyzer.getDefaultStopSet(), version)); } - @Override public PersianAnalyzer get() { + @Override + public PersianAnalyzer get() { return this.analyzer; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/PorterStemTokenFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/PorterStemTokenFilterFactory.java index f0b9e428f1d..7e96ce349af 100644 --- a/src/main/java/org/elasticsearch/index/analysis/PorterStemTokenFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/PorterStemTokenFilterFactory.java @@ -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,15 +28,17 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (Shay Banon) + * */ public class PorterStemTokenFilterFactory extends AbstractTokenFilterFactory { - @Inject public PorterStemTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public PorterStemTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); } - @Override public TokenStream create(TokenStream tokenStream) { + @Override + public TokenStream create(TokenStream tokenStream) { return new PorterStemFilter(tokenStream); } } diff --git a/src/main/java/org/elasticsearch/index/analysis/PortugueseAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/PortugueseAnalyzerProvider.java index 02000fcfd60..372d034f7eb 100644 --- a/src/main/java/org/elasticsearch/index/analysis/PortugueseAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/PortugueseAnalyzerProvider.java @@ -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,20 +29,22 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class PortugueseAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final PortugueseAnalyzer analyzer; - @Inject public PortugueseAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public PortugueseAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); analyzer = new PortugueseAnalyzer(version, Analysis.parseStopWords(env, settings, PortugueseAnalyzer.getDefaultStopSet(), version), Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET)); } - @Override public PortugueseAnalyzer get() { + @Override + public PortugueseAnalyzer get() { return this.analyzer; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/PositionIncrementGapAnalyzer.java b/src/main/java/org/elasticsearch/index/analysis/PositionIncrementGapAnalyzer.java index d5f8c9221a4..4514263baa2 100644 --- a/src/main/java/org/elasticsearch/index/analysis/PositionIncrementGapAnalyzer.java +++ b/src/main/java/org/elasticsearch/index/analysis/PositionIncrementGapAnalyzer.java @@ -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.index.analysis; /** - * @author kimchy (Shay Banon) + * */ public interface PositionIncrementGapAnalyzer { diff --git a/src/main/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerProvider.java index 5002c91850d..012460efdb1 100644 --- a/src/main/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerProvider.java @@ -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.index.analysis; import org.apache.lucene.analysis.Analyzer; /** - * @author kimchy (shay.banon) + * */ public class PreBuiltAnalyzerProvider implements AnalyzerProvider { @@ -38,15 +38,18 @@ public class PreBuiltAnalyzerProvider implements AnalyzerPro this.analyzer = analyzer; } - @Override public String name() { + @Override + public String name() { return name; } - @Override public AnalyzerScope scope() { + @Override + public AnalyzerScope scope() { return scope; } - @Override public T get() { + @Override + public T get() { return analyzer; } } diff --git a/src/main/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerProviderFactory.java b/src/main/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerProviderFactory.java index 4221acc6226..51299a79626 100644 --- a/src/main/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerProviderFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerProviderFactory.java @@ -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.analysis.Analyzer; import org.elasticsearch.common.settings.Settings; /** - * @author kimchy (shay.banon) + * */ public class PreBuiltAnalyzerProviderFactory implements AnalyzerProviderFactory { @@ -37,7 +37,8 @@ public class PreBuiltAnalyzerProviderFactory implements AnalyzerProviderFactory this.analyzerProvider = analyzerProvider; } - @Override public AnalyzerProvider create(String name, Settings settings) { + @Override + public AnalyzerProvider create(String name, Settings settings) { return analyzerProvider; } diff --git a/src/main/java/org/elasticsearch/index/analysis/PreBuiltCharFilterFactoryFactory.java b/src/main/java/org/elasticsearch/index/analysis/PreBuiltCharFilterFactoryFactory.java index 318f40a15ce..091dc1c76df 100644 --- a/src/main/java/org/elasticsearch/index/analysis/PreBuiltCharFilterFactoryFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/PreBuiltCharFilterFactoryFactory.java @@ -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,8 @@ public class PreBuiltCharFilterFactoryFactory implements CharFilterFactoryFactor this.charFilterFactory = charFilterFactory; } - @Override public CharFilterFactory create(String name, Settings settings) { + @Override + public CharFilterFactory create(String name, Settings settings) { return charFilterFactory; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/PreBuiltTokenFilterFactoryFactory.java b/src/main/java/org/elasticsearch/index/analysis/PreBuiltTokenFilterFactoryFactory.java index cd095f9cf50..8677a449c63 100644 --- a/src/main/java/org/elasticsearch/index/analysis/PreBuiltTokenFilterFactoryFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/PreBuiltTokenFilterFactoryFactory.java @@ -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,8 @@ public class PreBuiltTokenFilterFactoryFactory implements TokenFilterFactoryFact this.tokenFilterFactory = tokenFilterFactory; } - @Override public TokenFilterFactory create(String name, Settings settings) { + @Override + public TokenFilterFactory create(String name, Settings settings) { return tokenFilterFactory; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/PreBuiltTokenizerFactoryFactory.java b/src/main/java/org/elasticsearch/index/analysis/PreBuiltTokenizerFactoryFactory.java index c9581096d1d..1d70411d147 100644 --- a/src/main/java/org/elasticsearch/index/analysis/PreBuiltTokenizerFactoryFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/PreBuiltTokenizerFactoryFactory.java @@ -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,8 @@ public class PreBuiltTokenizerFactoryFactory implements TokenizerFactoryFactory this.tokenizerFactory = tokenizerFactory; } - @Override public TokenizerFactory create(String name, Settings settings) { + @Override + public TokenizerFactory create(String name, Settings settings) { return tokenizerFactory; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/ReverseTokenFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/ReverseTokenFilterFactory.java index e4878fe3b54..547b85c4a35 100644 --- a/src/main/java/org/elasticsearch/index/analysis/ReverseTokenFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/ReverseTokenFilterFactory.java @@ -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,15 +28,17 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (Shay Banon) + * */ public class ReverseTokenFilterFactory extends AbstractTokenFilterFactory { - @Inject public ReverseTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public ReverseTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); } - @Override public TokenStream create(TokenStream tokenStream) { + @Override + public TokenStream create(TokenStream tokenStream) { return new ReverseStringFilter(version, tokenStream); } } diff --git a/src/main/java/org/elasticsearch/index/analysis/RomanianAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/RomanianAnalyzerProvider.java index e23e6ab3a4b..d5346216e64 100644 --- a/src/main/java/org/elasticsearch/index/analysis/RomanianAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/RomanianAnalyzerProvider.java @@ -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,20 +29,22 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class RomanianAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final RomanianAnalyzer analyzer; - @Inject public RomanianAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public RomanianAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); analyzer = new RomanianAnalyzer(version, Analysis.parseStopWords(env, settings, RomanianAnalyzer.getDefaultStopSet(), version), Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET)); } - @Override public RomanianAnalyzer get() { + @Override + public RomanianAnalyzer get() { return this.analyzer; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/RussianAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/RussianAnalyzerProvider.java index 3176ede9869..45847b393f5 100644 --- a/src/main/java/org/elasticsearch/index/analysis/RussianAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/RussianAnalyzerProvider.java @@ -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,20 +29,22 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class RussianAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final RussianAnalyzer analyzer; - @Inject public RussianAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public RussianAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); analyzer = new RussianAnalyzer(version, Analysis.parseStopWords(env, settings, RussianAnalyzer.getDefaultStopSet(), version), Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET)); } - @Override public RussianAnalyzer get() { + @Override + public RussianAnalyzer get() { return this.analyzer; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/RussianStemTokenFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/RussianStemTokenFilterFactory.java index 9d2ec5b430b..1e735389522 100644 --- a/src/main/java/org/elasticsearch/index/analysis/RussianStemTokenFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/RussianStemTokenFilterFactory.java @@ -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,15 +28,17 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class RussianStemTokenFilterFactory extends AbstractTokenFilterFactory { - @Inject public RussianStemTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public RussianStemTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); } - @Override public TokenStream create(TokenStream tokenStream) { + @Override + public TokenStream create(TokenStream tokenStream) { return new RussianStemFilter(tokenStream); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/ShingleTokenFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/ShingleTokenFilterFactory.java index 64c54b16140..58ce9f7af44 100644 --- a/src/main/java/org/elasticsearch/index/analysis/ShingleTokenFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/ShingleTokenFilterFactory.java @@ -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.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (Shay Banon) + * */ public class ShingleTokenFilterFactory extends AbstractTokenFilterFactory { @@ -36,13 +36,15 @@ public class ShingleTokenFilterFactory extends AbstractTokenFilterFactory { private final boolean outputUnigrams; - @Inject public ShingleTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public ShingleTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); maxShingleSize = settings.getAsInt("max_shingle_size", ShingleFilter.DEFAULT_MAX_SHINGLE_SIZE); outputUnigrams = settings.getAsBoolean("output_unigrams", true); } - @Override public TokenStream create(TokenStream tokenStream) { + @Override + public TokenStream create(TokenStream tokenStream) { ShingleFilter filter = new ShingleFilter(tokenStream, maxShingleSize); filter.setOutputUnigrams(outputUnigrams); return filter; diff --git a/src/main/java/org/elasticsearch/index/analysis/SimpleAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/SimpleAnalyzerProvider.java index d19ce378b89..cf37194e38a 100644 --- a/src/main/java/org/elasticsearch/index/analysis/SimpleAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/SimpleAnalyzerProvider.java @@ -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,18 +27,20 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (Shay Banon) + * */ public class SimpleAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final SimpleAnalyzer simpleAnalyzer; - @Inject public SimpleAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public SimpleAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); this.simpleAnalyzer = new SimpleAnalyzer(version); } - @Override public SimpleAnalyzer get() { + @Override + public SimpleAnalyzer get() { return this.simpleAnalyzer; } } diff --git a/src/main/java/org/elasticsearch/index/analysis/SnowballAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/SnowballAnalyzerProvider.java index e5d094387d1..c40afad8573 100644 --- a/src/main/java/org/elasticsearch/index/analysis/SnowballAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/SnowballAnalyzerProvider.java @@ -19,13 +19,13 @@ package org.elasticsearch.index.analysis; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import org.apache.lucene.analysis.StopAnalyzer; import org.apache.lucene.analysis.de.GermanAnalyzer; import org.apache.lucene.analysis.fr.FrenchAnalyzer; import org.apache.lucene.analysis.nl.DutchAnalyzer; import org.apache.lucene.analysis.snowball.SnowballAnalyzer; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.ImmutableSet; import org.elasticsearch.common.collect.MapBuilder; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.assistedinject.Assisted; @@ -43,12 +43,11 @@ import java.util.Set; * Stemmer, use them directly with the SnowballFilter and a CustomAnalyzer. * Configuration of language is done with the "language" attribute or the analyzer. * Also supports additional stopwords via "stopwords" attribute - * + *

    * The SnowballAnalyzer comes with a StandardFilter, LowerCaseFilter, StopFilter * and the SnowballFilter. * - * @author kimchy (Shay Banon) - * @author harryf (Harry Fuecks) + * */ public class SnowballAnalyzerProvider extends AbstractIndexAnalyzerProvider { @@ -62,7 +61,8 @@ public class SnowballAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final SpanishAnalyzer analyzer; - @Inject public SpanishAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public SpanishAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); analyzer = new SpanishAnalyzer(version, Analysis.parseStopWords(env, settings, SpanishAnalyzer.getDefaultStopSet(), version), Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET)); } - @Override public SpanishAnalyzer get() { + @Override + public SpanishAnalyzer get() { return this.analyzer; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/StandardAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/StandardAnalyzerProvider.java index 7d24f7fd19d..ee70282ddc8 100644 --- a/src/main/java/org/elasticsearch/index/analysis/StandardAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/StandardAnalyzerProvider.java @@ -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,13 +31,14 @@ import org.elasticsearch.index.settings.IndexSettings; import java.util.Set; /** - * @author kimchy (shay.banon) + * */ public class StandardAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final StandardAnalyzer standardAnalyzer; - @Inject public StandardAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public StandardAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); Set stopWords = Analysis.parseStopWords(env, settings, StopAnalyzer.ENGLISH_STOP_WORDS_SET, version); int maxTokenLength = settings.getAsInt("max_token_length", StandardAnalyzer.DEFAULT_MAX_TOKEN_LENGTH); @@ -45,7 +46,8 @@ public class StandardAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final StandardHtmlStripAnalyzer analyzer; - @Inject public StandardHtmlStripAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public StandardHtmlStripAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); analyzer = new StandardHtmlStripAnalyzer(version); } - @Override public StandardHtmlStripAnalyzer get() { + @Override + public StandardHtmlStripAnalyzer get() { return this.analyzer; } } diff --git a/src/main/java/org/elasticsearch/index/analysis/StandardTokenFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/StandardTokenFilterFactory.java index 5bd5713cb5e..8676f22214a 100644 --- a/src/main/java/org/elasticsearch/index/analysis/StandardTokenFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/StandardTokenFilterFactory.java @@ -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,15 +29,17 @@ import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (Shay Banon) + * */ public class StandardTokenFilterFactory extends AbstractTokenFilterFactory { - @Inject public StandardTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public StandardTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); } - @Override public TokenStream create(TokenStream tokenStream) { + @Override + public TokenStream create(TokenStream tokenStream) { return new StandardFilter(version, tokenStream); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/StandardTokenizerFactory.java b/src/main/java/org/elasticsearch/index/analysis/StandardTokenizerFactory.java index c5330946767..a1c0aa05af2 100644 --- a/src/main/java/org/elasticsearch/index/analysis/StandardTokenizerFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/StandardTokenizerFactory.java @@ -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,12 +36,14 @@ public class StandardTokenizerFactory extends AbstractTokenizerFactory { private final int maxTokenLength; - @Inject public StandardTokenizerFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public StandardTokenizerFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); maxTokenLength = settings.getAsInt("max_token_length", StandardAnalyzer.DEFAULT_MAX_TOKEN_LENGTH); } - @Override public Tokenizer create(Reader reader) { + @Override + public Tokenizer create(Reader reader) { StandardTokenizer tokenizer = new StandardTokenizer(version, reader); tokenizer.setMaxTokenLength(maxTokenLength); return tokenizer; diff --git a/src/main/java/org/elasticsearch/index/analysis/StemmerOverrideTokenFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/StemmerOverrideTokenFilterFactory.java index 1a2f98e0195..70ba9e142e1 100644 --- a/src/main/java/org/elasticsearch/index/analysis/StemmerOverrideTokenFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/StemmerOverrideTokenFilterFactory.java @@ -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,6 +21,7 @@ package org.elasticsearch.index.analysis; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.miscellaneous.StemmerOverrideFilter; +import org.apache.lucene.util.Version; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; @@ -29,7 +30,6 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; -import org.apache.lucene.util.Version; import java.util.HashMap; import java.util.List; @@ -38,9 +38,10 @@ import java.util.Map; @AnalysisSettingsRequired public class StemmerOverrideTokenFilterFactory extends AbstractTokenFilterFactory { - private final Map dictionary; + private final Map dictionary; - @Inject public StemmerOverrideTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public StemmerOverrideTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); List rules = Analysis.getWordList(env, settings, "rules"); @@ -51,7 +52,8 @@ public class StemmerOverrideTokenFilterFactory extends AbstractTokenFilterFactor parseRules(rules, dictionary, "=>"); } - @Override public TokenStream create(TokenStream tokenStream) { + @Override + public TokenStream create(TokenStream tokenStream) { return new StemmerOverrideFilter(Version.LUCENE_32, tokenStream, dictionary); } diff --git a/src/main/java/org/elasticsearch/index/analysis/StemmerTokenFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/StemmerTokenFilterFactory.java index 8408c19e911..ff75c80f827 100644 --- a/src/main/java/org/elasticsearch/index/analysis/StemmerTokenFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/StemmerTokenFilterFactory.java @@ -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 @@ -57,12 +57,14 @@ public class StemmerTokenFilterFactory extends AbstractTokenFilterFactory { private String language; - @Inject public StemmerTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public StemmerTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); this.language = Strings.capitalize(settings.get("language", settings.get("name", "porter"))); } - @Override public TokenStream create(TokenStream tokenStream) { + @Override + public TokenStream create(TokenStream tokenStream) { if ("arabic".equalsIgnoreCase(language)) { return new ArabicStemFilter(tokenStream); } else if ("armenian".equalsIgnoreCase(language)) { diff --git a/src/main/java/org/elasticsearch/index/analysis/StopAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/StopAnalyzerProvider.java index aa255a09b10..0780301768d 100644 --- a/src/main/java/org/elasticsearch/index/analysis/StopAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/StopAnalyzerProvider.java @@ -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,19 +30,21 @@ import org.elasticsearch.index.settings.IndexSettings; import java.util.Set; /** - * @author kimchy (Shay Banon) + * */ public class StopAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final StopAnalyzer stopAnalyzer; - @Inject public StopAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public StopAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); Set stopWords = Analysis.parseStopWords(env, settings, StopAnalyzer.ENGLISH_STOP_WORDS_SET, version); this.stopAnalyzer = new StopAnalyzer(version, stopWords); } - @Override public StopAnalyzer get() { + @Override + public StopAnalyzer get() { return this.stopAnalyzer; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/StopTokenFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/StopTokenFilterFactory.java index 39c7c867fb9..15c361568f6 100644 --- a/src/main/java/org/elasticsearch/index/analysis/StopTokenFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/StopTokenFilterFactory.java @@ -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,7 +33,7 @@ import org.elasticsearch.index.settings.IndexSettings; import java.util.Set; /** - * @author kimchy (Shay Banon) + * */ public class StopTokenFilterFactory extends AbstractTokenFilterFactory { @@ -43,14 +43,16 @@ public class StopTokenFilterFactory extends AbstractTokenFilterFactory { private final boolean enablePositionIncrements; - @Inject public StopTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public StopTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); this.stopWords = Analysis.parseStopWords(env, settings, StopAnalyzer.ENGLISH_STOP_WORDS_SET, version); this.ignoreCase = settings.getAsBoolean("ignore_case", false); this.enablePositionIncrements = settings.getAsBoolean("enable_position_increments", version.onOrAfter(Version.LUCENE_29)); } - @Override public TokenStream create(TokenStream tokenStream) { + @Override + public TokenStream create(TokenStream tokenStream) { StopFilter filter = new StopFilter(version, tokenStream, stopWords, ignoreCase); filter.setEnablePositionIncrements(enablePositionIncrements); return filter; diff --git a/src/main/java/org/elasticsearch/index/analysis/SwedishAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/SwedishAnalyzerProvider.java index 738c6c668ca..5bdb1462379 100644 --- a/src/main/java/org/elasticsearch/index/analysis/SwedishAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/SwedishAnalyzerProvider.java @@ -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,20 +29,22 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class SwedishAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final SwedishAnalyzer analyzer; - @Inject public SwedishAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public SwedishAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); analyzer = new SwedishAnalyzer(version, Analysis.parseStopWords(env, settings, SwedishAnalyzer.getDefaultStopSet(), version), Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET)); } - @Override public SwedishAnalyzer get() { + @Override + public SwedishAnalyzer get() { return this.analyzer; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/SynonymTokenFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/SynonymTokenFilterFactory.java index 3f89fc6df3d..ebe906529ee 100644 --- a/src/main/java/org/elasticsearch/index/analysis/SynonymTokenFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/SynonymTokenFilterFactory.java @@ -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,7 @@ package org.elasticsearch.index.analysis; -import org.apache.lucene.analysis.Analyzer; -import org.apache.lucene.analysis.LowerCaseFilter; -import org.apache.lucene.analysis.ReusableAnalyzerBase; -import org.apache.lucene.analysis.TokenStream; -import org.apache.lucene.analysis.Tokenizer; -import org.apache.lucene.analysis.WhitespaceTokenizer; +import org.apache.lucene.analysis.*; import org.apache.lucene.analysis.synonym.SolrSynonymParser; import org.apache.lucene.analysis.synonym.SynonymFilter; import org.apache.lucene.analysis.synonym.SynonymMap; @@ -50,8 +45,9 @@ public class SynonymTokenFilterFactory extends AbstractTokenFilterFactory { private final SynonymMap synonymMap; private final boolean ignoreCase; - @Inject public SynonymTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, Environment env, IndicesAnalysisService indicesAnalysisService, Map tokenizerFactories, - @Assisted String name, @Assisted Settings settings) { + @Inject + public SynonymTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, Environment env, IndicesAnalysisService indicesAnalysisService, Map tokenizerFactories, + @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); Reader rulesReader = null; @@ -96,10 +92,10 @@ public class SynonymTokenFilterFactory extends AbstractTokenFilterFactory { if ("wordnet".equalsIgnoreCase(settings.get("format"))) { parser = new WordnetSynonymParser(true, expand, analyzer); - ((WordnetSynonymParser)parser).add(rulesReader); + ((WordnetSynonymParser) parser).add(rulesReader); } else { parser = new SolrSynonymParser(true, expand, analyzer); - ((SolrSynonymParser)parser).add(rulesReader); + ((SolrSynonymParser) parser).add(rulesReader); } synonymMap = parser.build(); @@ -108,7 +104,8 @@ public class SynonymTokenFilterFactory extends AbstractTokenFilterFactory { } } - @Override public TokenStream create(TokenStream tokenStream) { + @Override + public TokenStream create(TokenStream tokenStream) { // fst is null means no synonyms return synonymMap.fst == null ? tokenStream : new SynonymFilter(tokenStream, synonymMap, ignoreCase); } diff --git a/src/main/java/org/elasticsearch/index/analysis/ThaiAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/ThaiAnalyzerProvider.java index a726781eaff..72a4f17114c 100644 --- a/src/main/java/org/elasticsearch/index/analysis/ThaiAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/ThaiAnalyzerProvider.java @@ -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,18 +27,20 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class ThaiAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final ThaiAnalyzer analyzer; - @Inject public ThaiAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public ThaiAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); analyzer = new ThaiAnalyzer(version); } - @Override public ThaiAnalyzer get() { + @Override + public ThaiAnalyzer get() { return this.analyzer; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/TokenFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/TokenFilterFactory.java index 0ec6a6ddbcd..efed6e4a028 100644 --- a/src/main/java/org/elasticsearch/index/analysis/TokenFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/TokenFilterFactory.java @@ -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.index.analysis; import org.apache.lucene.analysis.TokenStream; /** - * @author kimchy (Shay Banon) + * */ public interface TokenFilterFactory { diff --git a/src/main/java/org/elasticsearch/index/analysis/TokenFilterFactoryFactory.java b/src/main/java/org/elasticsearch/index/analysis/TokenFilterFactoryFactory.java index 57946db7561..8adc31f77aa 100644 --- a/src/main/java/org/elasticsearch/index/analysis/TokenFilterFactoryFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/TokenFilterFactoryFactory.java @@ -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.index.analysis; import org.elasticsearch.common.settings.Settings; /** - * @author kimchy (Shay Banon) + * */ public interface TokenFilterFactoryFactory { diff --git a/src/main/java/org/elasticsearch/index/analysis/TokenizerFactory.java b/src/main/java/org/elasticsearch/index/analysis/TokenizerFactory.java index f018d785b90..f38c04b8d85 100644 --- a/src/main/java/org/elasticsearch/index/analysis/TokenizerFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/TokenizerFactory.java @@ -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.analysis.Tokenizer; import java.io.Reader; /** - * @author kimchy (Shay Banon) + * */ public interface TokenizerFactory { diff --git a/src/main/java/org/elasticsearch/index/analysis/TokenizerFactoryFactory.java b/src/main/java/org/elasticsearch/index/analysis/TokenizerFactoryFactory.java index 88c822b83a2..201a367a72f 100644 --- a/src/main/java/org/elasticsearch/index/analysis/TokenizerFactoryFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/TokenizerFactoryFactory.java @@ -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.index.analysis; import org.elasticsearch.common.settings.Settings; /** - * @author kimchy (Shay Banon) + * */ public interface TokenizerFactoryFactory { diff --git a/src/main/java/org/elasticsearch/index/analysis/TruncateTokenFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/TruncateTokenFilterFactory.java index 32f47a51906..8be423a22e4 100644 --- a/src/main/java/org/elasticsearch/index/analysis/TruncateTokenFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/TruncateTokenFilterFactory.java @@ -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,8 +36,9 @@ public class TruncateTokenFilterFactory extends AbstractTokenFilterFactory { private final int length; - @Inject public TruncateTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, - @Assisted String name, @Assisted Settings settings) { + @Inject + public TruncateTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, + @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); this.length = settings.getAsInt("length", -1); if (length <= 0) { @@ -45,7 +46,8 @@ public class TruncateTokenFilterFactory extends AbstractTokenFilterFactory { } } - @Override public TokenStream create(TokenStream tokenStream) { + @Override + public TokenStream create(TokenStream tokenStream) { return new TruncateTokenFilter(tokenStream, length); } } diff --git a/src/main/java/org/elasticsearch/index/analysis/TurkishAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/TurkishAnalyzerProvider.java index 9a301e113c6..9cbaa35b999 100644 --- a/src/main/java/org/elasticsearch/index/analysis/TurkishAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/TurkishAnalyzerProvider.java @@ -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,20 +29,22 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class TurkishAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final TurkishAnalyzer analyzer; - @Inject public TurkishAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public TurkishAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); analyzer = new TurkishAnalyzer(version, Analysis.parseStopWords(env, settings, TurkishAnalyzer.getDefaultStopSet(), version), Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET)); } - @Override public TurkishAnalyzer get() { + @Override + public TurkishAnalyzer get() { return this.analyzer; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/analysis/UAX29URLEmailTokenizerFactory.java b/src/main/java/org/elasticsearch/index/analysis/UAX29URLEmailTokenizerFactory.java index 60b2cacd715..07137f86cf9 100644 --- a/src/main/java/org/elasticsearch/index/analysis/UAX29URLEmailTokenizerFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/UAX29URLEmailTokenizerFactory.java @@ -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,12 +37,14 @@ public class UAX29URLEmailTokenizerFactory extends AbstractTokenizerFactory { private final int maxTokenLength; - @Inject public UAX29URLEmailTokenizerFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public UAX29URLEmailTokenizerFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); maxTokenLength = settings.getAsInt("max_token_length", StandardAnalyzer.DEFAULT_MAX_TOKEN_LENGTH); } - @Override public Tokenizer create(Reader reader) { + @Override + public Tokenizer create(Reader reader) { UAX29URLEmailTokenizer tokenizer = new UAX29URLEmailTokenizer(reader); tokenizer.setMaxTokenLength(maxTokenLength); return tokenizer; diff --git a/src/main/java/org/elasticsearch/index/analysis/UniqueTokenFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/UniqueTokenFilterFactory.java index 86590df2781..b3b0c6d27a2 100644 --- a/src/main/java/org/elasticsearch/index/analysis/UniqueTokenFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/UniqueTokenFilterFactory.java @@ -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,13 +34,15 @@ public class UniqueTokenFilterFactory extends AbstractTokenFilterFactory { private final boolean onlyOnSamePosition; - @Inject public UniqueTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, - @Assisted String name, @Assisted Settings settings) { + @Inject + public UniqueTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, + @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); this.onlyOnSamePosition = settings.getAsBoolean("only_on_same_position", false); } - @Override public TokenStream create(TokenStream tokenStream) { + @Override + public TokenStream create(TokenStream tokenStream) { return new UniqueTokenFilter(tokenStream, onlyOnSamePosition); } } diff --git a/src/main/java/org/elasticsearch/index/analysis/WhitespaceAnalyzerProvider.java b/src/main/java/org/elasticsearch/index/analysis/WhitespaceAnalyzerProvider.java index 5695117dcd0..c22a3ed1a17 100644 --- a/src/main/java/org/elasticsearch/index/analysis/WhitespaceAnalyzerProvider.java +++ b/src/main/java/org/elasticsearch/index/analysis/WhitespaceAnalyzerProvider.java @@ -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,18 +27,20 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (Shay Banon) + * */ public class WhitespaceAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final WhitespaceAnalyzer analyzer; - @Inject public WhitespaceAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public WhitespaceAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); this.analyzer = new WhitespaceAnalyzer(version); } - @Override public WhitespaceAnalyzer get() { + @Override + public WhitespaceAnalyzer get() { return this.analyzer; } } diff --git a/src/main/java/org/elasticsearch/index/analysis/WhitespaceTokenizerFactory.java b/src/main/java/org/elasticsearch/index/analysis/WhitespaceTokenizerFactory.java index aef1a06b695..791adeb4539 100644 --- a/src/main/java/org/elasticsearch/index/analysis/WhitespaceTokenizerFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/WhitespaceTokenizerFactory.java @@ -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,15 +30,17 @@ import org.elasticsearch.index.settings.IndexSettings; import java.io.Reader; /** - * @author kimchy (Shay Banon) + * */ public class WhitespaceTokenizerFactory extends AbstractTokenizerFactory { - @Inject public WhitespaceTokenizerFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public WhitespaceTokenizerFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); } - @Override public Tokenizer create(Reader reader) { + @Override + public Tokenizer create(Reader reader) { return new WhitespaceTokenizer(version, reader); } } diff --git a/src/main/java/org/elasticsearch/index/analysis/WordDelimiterTokenFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/WordDelimiterTokenFilterFactory.java index 43ed618ee14..a2545f5e0e9 100644 --- a/src/main/java/org/elasticsearch/index/analysis/WordDelimiterTokenFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/WordDelimiterTokenFilterFactory.java @@ -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,12 +31,7 @@ import org.elasticsearch.env.Environment; import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.SortedMap; -import java.util.TreeMap; +import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -54,7 +49,8 @@ public class WordDelimiterTokenFilterFactory extends AbstractTokenFilterFactory private final boolean stemEnglishPossessive; private final CharArraySet protoWords; - @Inject public WordDelimiterTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public WordDelimiterTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); // Sample Format for the type table: @@ -93,7 +89,8 @@ public class WordDelimiterTokenFilterFactory extends AbstractTokenFilterFactory this.protoWords = protectedWords == null ? null : CharArraySet.copy(Lucene.VERSION, protectedWords); } - @Override public TokenStream create(TokenStream tokenStream) { + @Override + public TokenStream create(TokenStream tokenStream) { return new WordDelimiterFilter(tokenStream, WordDelimiterIterator.DEFAULT_WORD_DELIM_TABLE, generateWordParts ? 1 : 0, diff --git a/src/main/java/org/elasticsearch/index/analysis/compound/AbstractCompoundWordTokenFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/compound/AbstractCompoundWordTokenFilterFactory.java index b112cc14b7b..c77982110a8 100644 --- a/src/main/java/org/elasticsearch/index/analysis/compound/AbstractCompoundWordTokenFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/compound/AbstractCompoundWordTokenFilterFactory.java @@ -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,6 @@ import java.util.Set; /** * Contains the common configuration settings between subclasses of this class. - * - * @author Edward Dale (scompt@scompt.com) - * @author kimchy (shay.banon) */ public abstract class AbstractCompoundWordTokenFilterFactory extends AbstractTokenFilterFactory { @@ -46,7 +43,8 @@ public abstract class AbstractCompoundWordTokenFilterFactory extends AbstractTok protected final boolean onlyLongestMatch; protected final Set wordList; - @Inject public AbstractCompoundWordTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public AbstractCompoundWordTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); minWordSize = settings.getAsInt("min_word_size", CompoundWordTokenFilterBase.DEFAULT_MIN_WORD_SIZE); diff --git a/src/main/java/org/elasticsearch/index/analysis/compound/DictionaryCompoundWordTokenFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/compound/DictionaryCompoundWordTokenFilterFactory.java index 977d50d1bcb..2488f2b1ed2 100644 --- a/src/main/java/org/elasticsearch/index/analysis/compound/DictionaryCompoundWordTokenFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/compound/DictionaryCompoundWordTokenFilterFactory.java @@ -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,18 +33,18 @@ import org.elasticsearch.index.settings.IndexSettings; /** * Uses the {@link org.apache.lucene.analysis.compound.DictionaryCompoundWordTokenFilter} to decompound tokens using a dictionary. * - * @author Edward Dale (scompt@scompt.com) - * @author kimchy (shay.banon) * @see org.apache.lucene.analysis.compound.DictionaryCompoundWordTokenFilter */ @AnalysisSettingsRequired public class DictionaryCompoundWordTokenFilterFactory extends AbstractCompoundWordTokenFilterFactory { - @Inject public DictionaryCompoundWordTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public DictionaryCompoundWordTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, env, name, settings); } - @Override public TokenStream create(TokenStream tokenStream) { + @Override + public TokenStream create(TokenStream tokenStream) { return new DictionaryCompoundWordTokenFilter(version, tokenStream, wordList, minWordSize, minSubwordSize, maxSubwordSize, onlyLongestMatch); } diff --git a/src/main/java/org/elasticsearch/index/analysis/compound/HyphenationCompoundWordTokenFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/compound/HyphenationCompoundWordTokenFilterFactory.java index 9dd599265dd..53ea2707f3d 100644 --- a/src/main/java/org/elasticsearch/index/analysis/compound/HyphenationCompoundWordTokenFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/compound/HyphenationCompoundWordTokenFilterFactory.java @@ -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,8 +37,6 @@ import java.net.URL; /** * Uses the {@link org.apache.lucene.analysis.compound.HyphenationCompoundWordTokenFilter} to decompound tokens based on hyphenation rules. * - * @author Edward Dale (scompt@scompt.com) - * @author kimchy (shay.banon) * @see org.apache.lucene.analysis.compound.HyphenationCompoundWordTokenFilter */ @AnalysisSettingsRequired @@ -46,7 +44,8 @@ public class HyphenationCompoundWordTokenFilterFactory extends AbstractCompoundW private final HyphenationTree hyphenationTree; - @Inject public HyphenationCompoundWordTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + @Inject + public HyphenationCompoundWordTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, env, name, settings); String hyphenationPatternsPath = settings.get("hyphenation_patterns_path", null); @@ -63,7 +62,8 @@ public class HyphenationCompoundWordTokenFilterFactory extends AbstractCompoundW } } - @Override public TokenStream create(TokenStream tokenStream) { + @Override + public TokenStream create(TokenStream tokenStream) { return new HyphenationCompoundWordTokenFilter(version, tokenStream, hyphenationTree, wordList, minWordSize, minSubwordSize, maxSubwordSize, onlyLongestMatch); diff --git a/src/main/java/org/elasticsearch/index/analysis/phonetic/DoubleMetaphoneFilter.java b/src/main/java/org/elasticsearch/index/analysis/phonetic/DoubleMetaphoneFilter.java index f54bfd47b16..bd73e509ef9 100644 --- a/src/main/java/org/elasticsearch/index/analysis/phonetic/DoubleMetaphoneFilter.java +++ b/src/main/java/org/elasticsearch/index/analysis/phonetic/DoubleMetaphoneFilter.java @@ -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,11 +19,11 @@ package org.elasticsearch.index.analysis.phonetic; +import org.apache.commons.codec.language.DoubleMetaphone; import org.apache.lucene.analysis.TokenFilter; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute; -import org.elasticsearch.common.codec.language.DoubleMetaphone; import java.io.IOException; import java.util.LinkedList; @@ -46,7 +46,7 @@ public final class DoubleMetaphoneFilter extends TokenFilter { @Override public boolean incrementToken() throws IOException { - for (; ;) { + for (; ; ) { if (!remainingTokens.isEmpty()) { // clearAttributes(); // not currently necessary diff --git a/src/main/java/org/elasticsearch/index/analysis/phonetic/PhoneticFilter.java b/src/main/java/org/elasticsearch/index/analysis/phonetic/PhoneticFilter.java index b0a64371190..d98c66cd11b 100644 --- a/src/main/java/org/elasticsearch/index/analysis/phonetic/PhoneticFilter.java +++ b/src/main/java/org/elasticsearch/index/analysis/phonetic/PhoneticFilter.java @@ -19,11 +19,11 @@ package org.elasticsearch.index.analysis.phonetic; +import org.apache.commons.codec.Encoder; import org.apache.lucene.analysis.TokenFilter; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute; -import org.elasticsearch.common.codec.Encoder; import java.io.IOException; diff --git a/src/main/java/org/elasticsearch/index/analysis/phonetic/PhoneticTokenFilterFactory.java b/src/main/java/org/elasticsearch/index/analysis/phonetic/PhoneticTokenFilterFactory.java index d44f66be03c..e8c4657dfe0 100644 --- a/src/main/java/org/elasticsearch/index/analysis/phonetic/PhoneticTokenFilterFactory.java +++ b/src/main/java/org/elasticsearch/index/analysis/phonetic/PhoneticTokenFilterFactory.java @@ -19,16 +19,10 @@ package org.elasticsearch.index.analysis.phonetic; +import org.apache.commons.codec.Encoder; +import org.apache.commons.codec.language.*; import org.apache.lucene.analysis.TokenStream; import org.elasticsearch.ElasticSearchIllegalArgumentException; -import org.elasticsearch.common.codec.Encoder; -import org.elasticsearch.common.codec.language.Caverphone1; -import org.elasticsearch.common.codec.language.Caverphone2; -import org.elasticsearch.common.codec.language.ColognePhonetic; -import org.elasticsearch.common.codec.language.DoubleMetaphone; -import org.elasticsearch.common.codec.language.Metaphone; -import org.elasticsearch.common.codec.language.RefinedSoundex; -import org.elasticsearch.common.codec.language.Soundex; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; @@ -38,7 +32,7 @@ import org.elasticsearch.index.analysis.AnalysisSettingsRequired; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ @AnalysisSettingsRequired public class PhoneticTokenFilterFactory extends AbstractTokenFilterFactory { @@ -47,7 +41,8 @@ public class PhoneticTokenFilterFactory extends AbstractTokenFilterFactory { private final boolean replace; - @Inject public PhoneticTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public PhoneticTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); this.replace = settings.getAsBoolean("replace", true); String encoder = settings.get("encoder"); @@ -77,7 +72,8 @@ public class PhoneticTokenFilterFactory extends AbstractTokenFilterFactory { } } - @Override public TokenStream create(TokenStream tokenStream) { + @Override + public TokenStream create(TokenStream tokenStream) { if (encoder instanceof DoubleMetaphone) { return new DoubleMetaphoneFilter(tokenStream, (DoubleMetaphone) encoder, !replace); } diff --git a/src/main/java/org/elasticsearch/index/cache/CacheStats.java b/src/main/java/org/elasticsearch/index/cache/CacheStats.java index baa7150f4ed..e5c7e7eda10 100644 --- a/src/main/java/org/elasticsearch/index/cache/CacheStats.java +++ b/src/main/java/org/elasticsearch/index/cache/CacheStats.java @@ -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 @@ -142,7 +142,8 @@ public class CacheStats implements Streamable, ToXContent { return bloomSize(); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(Fields.CACHE); builder.field(Fields.FIELD_EVICTIONS, fieldEvictions); builder.field(Fields.FIELD_SIZE, fieldSize().toString()); @@ -172,7 +173,8 @@ public class CacheStats implements Streamable, ToXContent { return stats; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { fieldEvictions = in.readVLong(); filterEvictions = in.readVLong(); fieldSize = in.readVLong(); @@ -181,7 +183,8 @@ public class CacheStats implements Streamable, ToXContent { bloomSize = in.readVLong(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeVLong(fieldEvictions); out.writeVLong(filterEvictions); out.writeVLong(fieldSize); diff --git a/src/main/java/org/elasticsearch/index/cache/IndexCache.java b/src/main/java/org/elasticsearch/index/cache/IndexCache.java index 3251bce7daf..4fb3d8e028a 100644 --- a/src/main/java/org/elasticsearch/index/cache/IndexCache.java +++ b/src/main/java/org/elasticsearch/index/cache/IndexCache.java @@ -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,7 @@ import org.elasticsearch.index.cache.query.parser.QueryParserCache; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class IndexCache extends AbstractIndexComponent implements CloseableComponent, ClusterStateListener { @@ -60,8 +60,9 @@ public class IndexCache extends AbstractIndexComponent implements CloseableCompo private long latestCacheStatsTimestamp = -1; private CacheStats latestCacheStats; - @Inject public IndexCache(Index index, @IndexSettings Settings indexSettings, FilterCache filterCache, FieldDataCache fieldDataCache, - QueryParserCache queryParserCache, IdCache idCache, BloomCache bloomCache) { + @Inject + public IndexCache(Index index, @IndexSettings Settings indexSettings, FilterCache filterCache, FieldDataCache fieldDataCache, + QueryParserCache queryParserCache, IdCache idCache, BloomCache bloomCache) { super(index, indexSettings); this.filterCache = filterCache; this.fieldDataCache = fieldDataCache; @@ -118,7 +119,8 @@ public class IndexCache extends AbstractIndexComponent implements CloseableCompo return this.queryParserCache; } - @Override public void close() throws ElasticSearchException { + @Override + public void close() throws ElasticSearchException { filterCache.close(); fieldDataCache.close(); idCache.close(); @@ -144,7 +146,8 @@ public class IndexCache extends AbstractIndexComponent implements CloseableCompo bloomCache.clear(); } - @Override public void clusterChanged(ClusterChangedEvent event) { + @Override + public void clusterChanged(ClusterChangedEvent event) { // clear the query parser cache if the metadata (mappings) changed... if (event.metaDataChanged()) { queryParserCache.clear(); diff --git a/src/main/java/org/elasticsearch/index/cache/IndexCacheModule.java b/src/main/java/org/elasticsearch/index/cache/IndexCacheModule.java index 8031258985b..e89b1aba6e9 100644 --- a/src/main/java/org/elasticsearch/index/cache/IndexCacheModule.java +++ b/src/main/java/org/elasticsearch/index/cache/IndexCacheModule.java @@ -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.index.cache.id.IdCacheModule; import org.elasticsearch.index.cache.query.parser.QueryParserCacheModule; /** - * @author kimchy (shay.banon) + * */ public class IndexCacheModule extends AbstractModule { @@ -38,7 +38,8 @@ public class IndexCacheModule extends AbstractModule { this.settings = settings; } - @Override protected void configure() { + @Override + protected void configure() { new FilterCacheModule(settings).configure(binder()); new FieldDataCacheModule(settings).configure(binder()); new IdCacheModule(settings).configure(binder()); diff --git a/src/main/java/org/elasticsearch/index/cache/bloom/BloomCache.java b/src/main/java/org/elasticsearch/index/cache/bloom/BloomCache.java index 07b4f5a237a..a50c1ca419a 100644 --- a/src/main/java/org/elasticsearch/index/cache/bloom/BloomCache.java +++ b/src/main/java/org/elasticsearch/index/cache/bloom/BloomCache.java @@ -25,7 +25,7 @@ import org.elasticsearch.common.component.CloseableComponent; import org.elasticsearch.index.IndexComponent; /** - * @author kimchy (shay.banon) + * */ public interface BloomCache extends IndexComponent, CloseableComponent { diff --git a/src/main/java/org/elasticsearch/index/cache/bloom/BloomCacheModule.java b/src/main/java/org/elasticsearch/index/cache/bloom/BloomCacheModule.java index 504f62c5945..55d7182b498 100644 --- a/src/main/java/org/elasticsearch/index/cache/bloom/BloomCacheModule.java +++ b/src/main/java/org/elasticsearch/index/cache/bloom/BloomCacheModule.java @@ -25,7 +25,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.cache.bloom.simple.SimpleBloomCache; /** - * @author kimchy (shay.banon) + * */ public class BloomCacheModule extends AbstractModule { @@ -39,7 +39,8 @@ public class BloomCacheModule extends AbstractModule { this.settings = settings; } - @Override protected void configure() { + @Override + protected void configure() { bind(BloomCache.class) .to(settings.getAsClass(BloomCacheSettings.TYPE, SimpleBloomCache.class, "org.elasticsearch.index.cache.bloom.", "BloomCache")) .in(Scopes.SINGLETON); diff --git a/src/main/java/org/elasticsearch/index/cache/bloom/none/NoneBloomCache.java b/src/main/java/org/elasticsearch/index/cache/bloom/none/NoneBloomCache.java index 2a39829eabc..1255d84260b 100644 --- a/src/main/java/org/elasticsearch/index/cache/bloom/none/NoneBloomCache.java +++ b/src/main/java/org/elasticsearch/index/cache/bloom/none/NoneBloomCache.java @@ -31,7 +31,7 @@ import org.elasticsearch.index.cache.bloom.BloomCache; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class NoneBloomCache extends AbstractIndexComponent implements BloomCache { @@ -39,28 +39,35 @@ public class NoneBloomCache extends AbstractIndexComponent implements BloomCache super(index, ImmutableSettings.Builder.EMPTY_SETTINGS); } - @Inject public NoneBloomCache(Index index, @IndexSettings Settings indexSettings) { + @Inject + public NoneBloomCache(Index index, @IndexSettings Settings indexSettings) { super(index, indexSettings); } - @Override public BloomFilter filter(IndexReader reader, String fieldName, boolean asyncLoad) { + @Override + public BloomFilter filter(IndexReader reader, String fieldName, boolean asyncLoad) { return BloomFilter.NONE; } - @Override public void clear() { + @Override + public void clear() { } - @Override public void clear(IndexReader reader) { + @Override + public void clear(IndexReader reader) { } - @Override public long sizeInBytes() { + @Override + public long sizeInBytes() { return 0; } - @Override public long sizeInBytes(String fieldName) { + @Override + public long sizeInBytes(String fieldName) { return 0; } - @Override public void close() throws ElasticSearchException { + @Override + public void close() throws ElasticSearchException { } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/cache/bloom/simple/SimpleBloomCache.java b/src/main/java/org/elasticsearch/index/cache/bloom/simple/SimpleBloomCache.java index 4ae7dd45596..437d4e5a6b5 100644 --- a/src/main/java/org/elasticsearch/index/cache/bloom/simple/SimpleBloomCache.java +++ b/src/main/java/org/elasticsearch/index/cache/bloom/simple/SimpleBloomCache.java @@ -46,7 +46,7 @@ import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicBoolean; /** - * @author kimchy (shay.banon) + * */ public class SimpleBloomCache extends AbstractIndexComponent implements BloomCache, IndexReader.ReaderFinishedListener { @@ -58,7 +58,8 @@ public class SimpleBloomCache extends AbstractIndexComponent implements BloomCac private final Object creationMutex = new Object(); - @Inject public SimpleBloomCache(Index index, @IndexSettings Settings indexSettings, ThreadPool threadPool) { + @Inject + public SimpleBloomCache(Index index, @IndexSettings Settings indexSettings, ThreadPool threadPool) { super(index, indexSettings); this.threadPool = threadPool; @@ -66,19 +67,23 @@ public class SimpleBloomCache extends AbstractIndexComponent implements BloomCac this.cache = ConcurrentCollections.newConcurrentMap(); } - @Override public void close() throws ElasticSearchException { + @Override + public void close() throws ElasticSearchException { clear(); } - @Override public void clear() { + @Override + public void clear() { cache.clear(); } - @Override public void finished(IndexReader reader) { + @Override + public void finished(IndexReader reader) { clear(reader); } - @Override public void clear(IndexReader reader) { + @Override + public void clear(IndexReader reader) { ConcurrentMap map = cache.remove(reader.getCoreCacheKey()); // help soft/weak handling GC if (map != null) { @@ -86,7 +91,8 @@ public class SimpleBloomCache extends AbstractIndexComponent implements BloomCac } } - @Override public long sizeInBytes() { + @Override + public long sizeInBytes() { // the overhead of the map is not really relevant... long sizeInBytes = 0; for (ConcurrentMap map : cache.values()) { @@ -97,7 +103,8 @@ public class SimpleBloomCache extends AbstractIndexComponent implements BloomCac return sizeInBytes; } - @Override public long sizeInBytes(String fieldName) { + @Override + public long sizeInBytes(String fieldName) { long sizeInBytes = 0; for (ConcurrentMap map : cache.values()) { BloomFilterEntry filter = map.get(fieldName); @@ -108,7 +115,8 @@ public class SimpleBloomCache extends AbstractIndexComponent implements BloomCac return sizeInBytes; } - @Override public BloomFilter filter(IndexReader reader, String fieldName, boolean asyncLoad) { + @Override + public BloomFilter filter(IndexReader reader, String fieldName, boolean asyncLoad) { int currentNumDocs = reader.numDocs(); if (currentNumDocs == 0) { return BloomFilter.EMPTY; @@ -171,7 +179,8 @@ public class SimpleBloomCache extends AbstractIndexComponent implements BloomCac } @SuppressWarnings({"StringEquality"}) - @Override public void run() { + @Override + public void run() { TermDocs termDocs = null; TermEnum termEnum = null; try { diff --git a/src/main/java/org/elasticsearch/index/cache/field/data/FieldDataCache.java b/src/main/java/org/elasticsearch/index/cache/field/data/FieldDataCache.java index 835b24dc3fd..dd2088b4f6f 100644 --- a/src/main/java/org/elasticsearch/index/cache/field/data/FieldDataCache.java +++ b/src/main/java/org/elasticsearch/index/cache/field/data/FieldDataCache.java @@ -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.index.field.data.FieldDataType; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public interface FieldDataCache extends IndexComponent, CloseableComponent { diff --git a/src/main/java/org/elasticsearch/index/cache/field/data/FieldDataCacheModule.java b/src/main/java/org/elasticsearch/index/cache/field/data/FieldDataCacheModule.java index 8300ce5a269..6abca05d508 100644 --- a/src/main/java/org/elasticsearch/index/cache/field/data/FieldDataCacheModule.java +++ b/src/main/java/org/elasticsearch/index/cache/field/data/FieldDataCacheModule.java @@ -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.common.settings.Settings; import org.elasticsearch.index.cache.field.data.resident.ResidentFieldDataCache; /** - * @author kimchy (shay.banon) + * */ public class FieldDataCacheModule extends AbstractModule { @@ -39,7 +39,8 @@ public class FieldDataCacheModule extends AbstractModule { this.settings = settings; } - @Override protected void configure() { + @Override + protected void configure() { bind(FieldDataCache.class) .to(settings.getAsClass(FieldDataCacheSettings.FIELD_DATA_CACHE_TYPE, ResidentFieldDataCache.class, "org.elasticsearch.index.cache.field.data.", "FieldDataCache")) .in(Scopes.SINGLETON); diff --git a/src/main/java/org/elasticsearch/index/cache/field/data/none/NoneFieldDataCache.java b/src/main/java/org/elasticsearch/index/cache/field/data/none/NoneFieldDataCache.java index a0393edda29..e723786db51 100644 --- a/src/main/java/org/elasticsearch/index/cache/field/data/none/NoneFieldDataCache.java +++ b/src/main/java/org/elasticsearch/index/cache/field/data/none/NoneFieldDataCache.java @@ -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,45 +33,55 @@ import org.elasticsearch.index.settings.IndexSettings; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class NoneFieldDataCache extends AbstractIndexComponent implements FieldDataCache { - @Inject public NoneFieldDataCache(Index index, @IndexSettings Settings indexSettings) { + @Inject + public NoneFieldDataCache(Index index, @IndexSettings Settings indexSettings) { super(index, indexSettings); logger.debug("Using no field cache"); } - @Override public FieldData cache(FieldDataType type, IndexReader reader, String fieldName) throws IOException { + @Override + public FieldData cache(FieldDataType type, IndexReader reader, String fieldName) throws IOException { return FieldData.load(type, reader, fieldName); } - @Override public String type() { + @Override + public String type() { return "none"; } - @Override public void clear(String fieldName) { + @Override + public void clear(String fieldName) { } - @Override public void clear() { + @Override + public void clear() { } - @Override public void clear(IndexReader reader) { + @Override + public void clear(IndexReader reader) { } - @Override public void close() throws ElasticSearchException { + @Override + public void close() throws ElasticSearchException { } - @Override public long sizeInBytes() { + @Override + public long sizeInBytes() { return 0; } - @Override public long sizeInBytes(String fieldName) { + @Override + public long sizeInBytes(String fieldName) { return 0; } - @Override public long evictions() { + @Override + public long evictions() { return 0; } } diff --git a/src/main/java/org/elasticsearch/index/cache/field/data/resident/ResidentFieldDataCache.java b/src/main/java/org/elasticsearch/index/cache/field/data/resident/ResidentFieldDataCache.java index 8455102cd73..202abfd530d 100644 --- a/src/main/java/org/elasticsearch/index/cache/field/data/resident/ResidentFieldDataCache.java +++ b/src/main/java/org/elasticsearch/index/cache/field/data/resident/ResidentFieldDataCache.java @@ -19,12 +19,12 @@ package org.elasticsearch.index.cache.field.data.resident; +import com.google.common.base.Objects; +import com.google.common.collect.MapEvictionListener; +import com.google.common.collect.MapMaker; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.base.Objects; -import org.elasticsearch.common.collect.MapEvictionListener; -import org.elasticsearch.common.collect.MapMaker; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.metrics.CounterMetric; import org.elasticsearch.common.settings.Settings; @@ -39,7 +39,7 @@ import java.util.concurrent.ConcurrentMap; import java.util.concurrent.TimeUnit; /** - * @author kimchy (shay.banon) + * */ public class ResidentFieldDataCache extends AbstractConcurrentMapFieldDataCache implements MapEvictionListener { @@ -52,7 +52,8 @@ public class ResidentFieldDataCache extends AbstractConcurrentMapFieldDataCache private final ApplySettings applySettings = new ApplySettings(); - @Inject public ResidentFieldDataCache(Index index, @IndexSettings Settings indexSettings, IndexSettingsService indexSettingsService) { + @Inject + public ResidentFieldDataCache(Index index, @IndexSettings Settings indexSettings, IndexSettingsService indexSettingsService) { super(index, indexSettings); this.indexSettingsService = indexSettingsService; @@ -63,12 +64,14 @@ public class ResidentFieldDataCache extends AbstractConcurrentMapFieldDataCache indexSettingsService.addListener(applySettings); } - @Override public void close() throws ElasticSearchException { + @Override + public void close() throws ElasticSearchException { indexSettingsService.removeListener(applySettings); super.close(); } - @Override protected ConcurrentMap buildFieldDataMap() { + @Override + protected ConcurrentMap buildFieldDataMap() { MapMaker mapMaker = new MapMaker(); if (maxSize != -1) { mapMaker.maximumSize(maxSize); @@ -80,15 +83,18 @@ public class ResidentFieldDataCache extends AbstractConcurrentMapFieldDataCache return mapMaker.makeMap(); } - @Override public String type() { + @Override + public String type() { return "resident"; } - @Override public long evictions() { + @Override + public long evictions() { return evictions.count(); } - @Override public void onEviction(@Nullable String s, @Nullable FieldData fieldData) { + @Override + public void onEviction(@Nullable String s, @Nullable FieldData fieldData) { evictions.inc(); } @@ -100,7 +106,8 @@ public class ResidentFieldDataCache extends AbstractConcurrentMapFieldDataCache } class ApplySettings implements IndexSettingsService.Listener { - @Override public void onRefreshSettings(Settings settings) { + @Override + public void onRefreshSettings(Settings settings) { int maxSize = settings.getAsInt("index.cache.field.max_size", ResidentFieldDataCache.this.maxSize); TimeValue expire = settings.getAsTime("index.cache.field.expire", ResidentFieldDataCache.this.expire); boolean changed = false; diff --git a/src/main/java/org/elasticsearch/index/cache/field/data/soft/SoftFieldDataCache.java b/src/main/java/org/elasticsearch/index/cache/field/data/soft/SoftFieldDataCache.java index 9cc2a9baab0..c49f84e5008 100644 --- a/src/main/java/org/elasticsearch/index/cache/field/data/soft/SoftFieldDataCache.java +++ b/src/main/java/org/elasticsearch/index/cache/field/data/soft/SoftFieldDataCache.java @@ -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.index.cache.field.data.soft; +import com.google.common.collect.MapEvictionListener; +import com.google.common.collect.MapMaker; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.collect.MapEvictionListener; -import org.elasticsearch.common.collect.MapMaker; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.metrics.CounterMetric; import org.elasticsearch.common.settings.Settings; @@ -33,29 +33,34 @@ import org.elasticsearch.index.settings.IndexSettings; import java.util.concurrent.ConcurrentMap; /** - * @author kimchy (shay.banon) + * */ public class SoftFieldDataCache extends AbstractConcurrentMapFieldDataCache implements MapEvictionListener { private final CounterMetric evictions = new CounterMetric(); - @Inject public SoftFieldDataCache(Index index, @IndexSettings Settings indexSettings) { + @Inject + public SoftFieldDataCache(Index index, @IndexSettings Settings indexSettings) { super(index, indexSettings); } - @Override protected ConcurrentMap buildFieldDataMap() { + @Override + protected ConcurrentMap buildFieldDataMap() { return new MapMaker().softValues().evictionListener(this).makeMap(); } - @Override public long evictions() { + @Override + public long evictions() { return evictions.count(); } - @Override public String type() { + @Override + public String type() { return "soft"; } - @Override public void onEviction(@Nullable String s, @Nullable FieldData fieldData) { + @Override + public void onEviction(@Nullable String s, @Nullable FieldData fieldData) { evictions.inc(); } } diff --git a/src/main/java/org/elasticsearch/index/cache/field/data/support/AbstractConcurrentMapFieldDataCache.java b/src/main/java/org/elasticsearch/index/cache/field/data/support/AbstractConcurrentMapFieldDataCache.java index bd17cf2847f..7db2a88cf25 100644 --- a/src/main/java/org/elasticsearch/index/cache/field/data/support/AbstractConcurrentMapFieldDataCache.java +++ b/src/main/java/org/elasticsearch/index/cache/field/data/support/AbstractConcurrentMapFieldDataCache.java @@ -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,7 +36,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; /** - * @author kimchy (shay.banon) + * */ public abstract class AbstractConcurrentMapFieldDataCache extends AbstractIndexComponent implements FieldDataCache, IndexReader.ReaderFinishedListener { @@ -51,25 +51,30 @@ public abstract class AbstractConcurrentMapFieldDataCache extends AbstractIndexC this.cache = new ConcurrentHashMap>(); } - @Override public void close() throws ElasticSearchException { + @Override + public void close() throws ElasticSearchException { clear(); } - @Override public void clear(String fieldName) { + @Override + public void clear(String fieldName) { for (Map.Entry> entry : cache.entrySet()) { entry.getValue().remove(fieldName); } } - @Override public void clear() { + @Override + public void clear() { cache.clear(); } - @Override public void finished(IndexReader reader) { + @Override + public void finished(IndexReader reader) { clear(reader); } - @Override public void clear(IndexReader reader) { + @Override + public void clear(IndexReader reader) { ConcurrentMap map = cache.remove(reader.getCoreCacheKey()); // help soft/weak handling GC if (map != null) { @@ -77,7 +82,8 @@ public abstract class AbstractConcurrentMapFieldDataCache extends AbstractIndexC } } - @Override public long sizeInBytes() { + @Override + public long sizeInBytes() { // the overhead of the map is not really relevant... long sizeInBytes = 0; for (ConcurrentMap map : cache.values()) { @@ -88,7 +94,8 @@ public abstract class AbstractConcurrentMapFieldDataCache extends AbstractIndexC return sizeInBytes; } - @Override public long sizeInBytes(String fieldName) { + @Override + public long sizeInBytes(String fieldName) { long sizeInBytes = 0; for (ConcurrentMap map : cache.values()) { FieldData fieldData = map.get(fieldName); @@ -99,7 +106,8 @@ public abstract class AbstractConcurrentMapFieldDataCache extends AbstractIndexC return sizeInBytes; } - @Override public FieldData cache(FieldDataType type, IndexReader reader, String fieldName) throws IOException { + @Override + public FieldData cache(FieldDataType type, IndexReader reader, String fieldName) throws IOException { ConcurrentMap fieldDataCache = cache.get(reader.getCoreCacheKey()); if (fieldDataCache == null) { synchronized (creationMutex) { diff --git a/src/main/java/org/elasticsearch/index/cache/field/data/weak/WeakFieldDataCache.java b/src/main/java/org/elasticsearch/index/cache/field/data/weak/WeakFieldDataCache.java index 1669df66956..a63cd313a85 100644 --- a/src/main/java/org/elasticsearch/index/cache/field/data/weak/WeakFieldDataCache.java +++ b/src/main/java/org/elasticsearch/index/cache/field/data/weak/WeakFieldDataCache.java @@ -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.index.cache.field.data.weak; +import com.google.common.collect.MapEvictionListener; +import com.google.common.collect.MapMaker; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.collect.MapEvictionListener; -import org.elasticsearch.common.collect.MapMaker; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.metrics.CounterMetric; import org.elasticsearch.common.settings.Settings; @@ -33,29 +33,34 @@ import org.elasticsearch.index.settings.IndexSettings; import java.util.concurrent.ConcurrentMap; /** - * @author kimchy (shay.banon) + * */ public class WeakFieldDataCache extends AbstractConcurrentMapFieldDataCache implements MapEvictionListener { private final CounterMetric evictions = new CounterMetric(); - @Inject public WeakFieldDataCache(Index index, @IndexSettings Settings indexSettings) { + @Inject + public WeakFieldDataCache(Index index, @IndexSettings Settings indexSettings) { super(index, indexSettings); } - @Override protected ConcurrentMap buildFieldDataMap() { + @Override + protected ConcurrentMap buildFieldDataMap() { return new MapMaker().weakValues().evictionListener(this).makeMap(); } - @Override public String type() { + @Override + public String type() { return "weak"; } - @Override public long evictions() { + @Override + public long evictions() { return evictions.count(); } - @Override public void onEviction(@Nullable String s, @Nullable FieldData fieldData) { + @Override + public void onEviction(@Nullable String s, @Nullable FieldData fieldData) { evictions.inc(); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/cache/filter/FilterCache.java b/src/main/java/org/elasticsearch/index/cache/filter/FilterCache.java index 8a1ba5297ce..e5b86bdb909 100644 --- a/src/main/java/org/elasticsearch/index/cache/filter/FilterCache.java +++ b/src/main/java/org/elasticsearch/index/cache/filter/FilterCache.java @@ -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.common.component.CloseableComponent; import org.elasticsearch.index.IndexComponent; /** - * @author kimchy (shay.banon) + * */ public interface FilterCache extends IndexComponent, CloseableComponent { diff --git a/src/main/java/org/elasticsearch/index/cache/filter/FilterCacheModule.java b/src/main/java/org/elasticsearch/index/cache/filter/FilterCacheModule.java index 32dc3d92fb6..c4144922e2d 100644 --- a/src/main/java/org/elasticsearch/index/cache/filter/FilterCacheModule.java +++ b/src/main/java/org/elasticsearch/index/cache/filter/FilterCacheModule.java @@ -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.common.settings.Settings; import org.elasticsearch.index.cache.filter.node.NodeFilterCache; /** - * @author kimchy (Shay Banon) + * */ public class FilterCacheModule extends AbstractModule { @@ -39,7 +39,8 @@ public class FilterCacheModule extends AbstractModule { this.settings = settings; } - @Override protected void configure() { + @Override + protected void configure() { bind(FilterCache.class) .to(settings.getAsClass(FilterCacheSettings.FILTER_CACHE_TYPE, NodeFilterCache.class, "org.elasticsearch.index.cache.filter.", "FilterCache")) .in(Scopes.SINGLETON); diff --git a/src/main/java/org/elasticsearch/index/cache/filter/node/NodeFilterCache.java b/src/main/java/org/elasticsearch/index/cache/filter/node/NodeFilterCache.java index d703a772265..3af2a54ae63 100644 --- a/src/main/java/org/elasticsearch/index/cache/filter/node/NodeFilterCache.java +++ b/src/main/java/org/elasticsearch/index/cache/filter/node/NodeFilterCache.java @@ -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,23 +35,27 @@ public class NodeFilterCache extends AbstractWeightedFilterCache { private final IndicesNodeFilterCache indicesNodeFilterCache; - @Inject public NodeFilterCache(Index index, @IndexSettings Settings indexSettings, IndicesNodeFilterCache indicesNodeFilterCache) { + @Inject + public NodeFilterCache(Index index, @IndexSettings Settings indexSettings, IndicesNodeFilterCache indicesNodeFilterCache) { super(index, indexSettings); this.indicesNodeFilterCache = indicesNodeFilterCache; indicesNodeFilterCache.addEvictionListener(this); } - @Override public void close() throws ElasticSearchException { + @Override + public void close() throws ElasticSearchException { indicesNodeFilterCache.removeEvictionListener(this); super.close(); } - @Override protected ConcurrentMap> cache() { + @Override + protected ConcurrentMap> cache() { return indicesNodeFilterCache.cache(); } - @Override public String type() { + @Override + public String type() { return "node"; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/cache/filter/none/NoneFilterCache.java b/src/main/java/org/elasticsearch/index/cache/filter/none/NoneFilterCache.java index 431e96216f6..9d9333e35d0 100644 --- a/src/main/java/org/elasticsearch/index/cache/filter/none/NoneFilterCache.java +++ b/src/main/java/org/elasticsearch/index/cache/filter/none/NoneFilterCache.java @@ -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,44 +29,53 @@ import org.elasticsearch.index.cache.filter.FilterCache; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (Shay Banon) + * */ public class NoneFilterCache extends AbstractIndexComponent implements FilterCache { - @Inject public NoneFilterCache(Index index, @IndexSettings Settings indexSettings) { + @Inject + public NoneFilterCache(Index index, @IndexSettings Settings indexSettings) { super(index, indexSettings); logger.debug("Using no filter cache"); } - @Override public String type() { + @Override + public String type() { return "none"; } - @Override public void close() { + @Override + public void close() { // nothing to do here } - @Override public Filter cache(Filter filterToCache) { + @Override + public Filter cache(Filter filterToCache) { return filterToCache; } - @Override public boolean isCached(Filter filter) { + @Override + public boolean isCached(Filter filter) { return false; } - @Override public void clear() { + @Override + public void clear() { // nothing to do here } - @Override public void clear(IndexReader reader) { + @Override + public void clear(IndexReader reader) { // nothing to do here } - @Override public EntriesStats entriesStats() { + @Override + public EntriesStats entriesStats() { return new EntriesStats(0, 0); } - @Override public long evictions() { + @Override + public long evictions() { return 0; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/cache/filter/resident/ResidentFilterCache.java b/src/main/java/org/elasticsearch/index/cache/filter/resident/ResidentFilterCache.java index 07786431533..c45930a16ad 100644 --- a/src/main/java/org/elasticsearch/index/cache/filter/resident/ResidentFilterCache.java +++ b/src/main/java/org/elasticsearch/index/cache/filter/resident/ResidentFilterCache.java @@ -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,11 +19,11 @@ package org.elasticsearch.index.cache.filter.resident; +import com.google.common.base.Objects; +import com.google.common.collect.MapEvictionListener; +import com.google.common.collect.MapMaker; import org.apache.lucene.search.Filter; import org.elasticsearch.cluster.metadata.IndexMetaData; -import org.elasticsearch.common.base.Objects; -import org.elasticsearch.common.collect.MapEvictionListener; -import org.elasticsearch.common.collect.MapMaker; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.lucene.docset.DocSet; import org.elasticsearch.common.metrics.CounterMetric; @@ -40,7 +40,7 @@ import java.util.concurrent.TimeUnit; /** * A resident reference based filter cache that has weak keys on the IndexReader. * - * @author kimchy (shay.banon) + * */ public class ResidentFilterCache extends AbstractConcurrentMapFilterCache implements MapEvictionListener { @@ -53,7 +53,8 @@ public class ResidentFilterCache extends AbstractConcurrentMapFilterCache implem private final ApplySettings applySettings = new ApplySettings(); - @Inject public ResidentFilterCache(Index index, @IndexSettings Settings indexSettings, IndexSettingsService indexSettingsService) { + @Inject + public ResidentFilterCache(Index index, @IndexSettings Settings indexSettings, IndexSettingsService indexSettingsService) { super(index, indexSettings); this.indexSettingsService = indexSettingsService; this.maxSize = indexSettings.getAsInt("index.cache.filter.max_size", componentSettings.getAsInt("max_size", 1000)); @@ -63,12 +64,14 @@ public class ResidentFilterCache extends AbstractConcurrentMapFilterCache implem indexSettingsService.addListener(applySettings); } - @Override public void close() { + @Override + public void close() { indexSettingsService.removeListener(applySettings); super.close(); } - @Override protected ConcurrentMap buildFilterMap() { + @Override + protected ConcurrentMap buildFilterMap() { MapMaker mapMaker = new MapMaker(); if (maxSize != -1) { mapMaker.maximumSize(maxSize); @@ -80,15 +83,18 @@ public class ResidentFilterCache extends AbstractConcurrentMapFilterCache implem return mapMaker.makeMap(); } - @Override public String type() { + @Override + public String type() { return "resident"; } - @Override public long evictions() { + @Override + public long evictions() { return evictions.count(); } - @Override public void onEviction(Filter filter, DocSet docSet) { + @Override + public void onEviction(Filter filter, DocSet docSet) { evictions.inc(); } @@ -100,7 +106,8 @@ public class ResidentFilterCache extends AbstractConcurrentMapFilterCache implem } class ApplySettings implements IndexSettingsService.Listener { - @Override public void onRefreshSettings(Settings settings) { + @Override + public void onRefreshSettings(Settings settings) { int maxSize = settings.getAsInt("index.cache.filter.max_size", ResidentFilterCache.this.maxSize); TimeValue expire = settings.getAsTime("index.cache.filter.expire", ResidentFilterCache.this.expire); boolean changed = false; diff --git a/src/main/java/org/elasticsearch/index/cache/filter/soft/SoftFilterCache.java b/src/main/java/org/elasticsearch/index/cache/filter/soft/SoftFilterCache.java index 3194e83fdc1..b132101ec2a 100644 --- a/src/main/java/org/elasticsearch/index/cache/filter/soft/SoftFilterCache.java +++ b/src/main/java/org/elasticsearch/index/cache/filter/soft/SoftFilterCache.java @@ -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,11 +19,11 @@ package org.elasticsearch.index.cache.filter.soft; +import com.google.common.base.Objects; +import com.google.common.collect.MapEvictionListener; +import com.google.common.collect.MapMaker; import org.apache.lucene.search.Filter; import org.elasticsearch.cluster.metadata.IndexMetaData; -import org.elasticsearch.common.base.Objects; -import org.elasticsearch.common.collect.MapEvictionListener; -import org.elasticsearch.common.collect.MapMaker; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.lucene.docset.DocSet; import org.elasticsearch.common.metrics.CounterMetric; @@ -40,7 +40,7 @@ import java.util.concurrent.TimeUnit; /** * A soft reference based filter cache that has soft keys on the IndexReader. * - * @author kimchy (shay.banon) + * */ public class SoftFilterCache extends AbstractConcurrentMapFilterCache implements MapEvictionListener { @@ -53,7 +53,8 @@ public class SoftFilterCache extends AbstractConcurrentMapFilterCache implements private final ApplySettings applySettings = new ApplySettings(); - @Inject public SoftFilterCache(Index index, @IndexSettings Settings indexSettings, IndexSettingsService indexSettingsService) { + @Inject + public SoftFilterCache(Index index, @IndexSettings Settings indexSettings, IndexSettingsService indexSettingsService) { super(index, indexSettings); this.indexSettingsService = indexSettingsService; this.maxSize = indexSettings.getAsInt("index.cache.filter.max_size", componentSettings.getAsInt("max_size", -1)); @@ -63,12 +64,14 @@ public class SoftFilterCache extends AbstractConcurrentMapFilterCache implements indexSettingsService.addListener(applySettings); } - @Override public void close() { + @Override + public void close() { indexSettingsService.removeListener(applySettings); super.close(); } - @Override protected ConcurrentMap buildFilterMap() { + @Override + protected ConcurrentMap buildFilterMap() { // DocSet are not really stored with strong reference only when searching on them... // Filter might be stored in query cache MapMaker mapMaker = new MapMaker().softValues(); @@ -82,15 +85,18 @@ public class SoftFilterCache extends AbstractConcurrentMapFilterCache implements return mapMaker.makeMap(); } - @Override public String type() { + @Override + public String type() { return "soft"; } - @Override public long evictions() { + @Override + public long evictions() { return evictions.count(); } - @Override public void onEviction(Filter filter, DocSet docSet) { + @Override + public void onEviction(Filter filter, DocSet docSet) { evictions.inc(); } @@ -102,7 +108,8 @@ public class SoftFilterCache extends AbstractConcurrentMapFilterCache implements } class ApplySettings implements IndexSettingsService.Listener { - @Override public void onRefreshSettings(Settings settings) { + @Override + public void onRefreshSettings(Settings settings) { int maxSize = settings.getAsInt("index.cache.filter.max_size", SoftFilterCache.this.maxSize); TimeValue expire = settings.getAsTime("index.cache.filter.expire", SoftFilterCache.this.expire); boolean changed = false; diff --git a/src/main/java/org/elasticsearch/index/cache/filter/support/AbstractConcurrentMapFilterCache.java b/src/main/java/org/elasticsearch/index/cache/filter/support/AbstractConcurrentMapFilterCache.java index 01087a0ba5b..4826b9269ed 100644 --- a/src/main/java/org/elasticsearch/index/cache/filter/support/AbstractConcurrentMapFilterCache.java +++ b/src/main/java/org/elasticsearch/index/cache/filter/support/AbstractConcurrentMapFilterCache.java @@ -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,12 +34,12 @@ import java.io.IOException; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -import static org.elasticsearch.common.util.concurrent.ConcurrentCollections.*; +import static org.elasticsearch.common.util.concurrent.ConcurrentCollections.newConcurrentMap; /** * A base concurrent filter cache that accepts the actual cache to use. * - * @author kimchy (shay.banon) + * */ public abstract class AbstractConcurrentMapFilterCache extends AbstractIndexComponent implements FilterCache, IndexReader.ReaderFinishedListener { @@ -58,15 +58,18 @@ public abstract class AbstractConcurrentMapFilterCache extends AbstractIndexComp return newConcurrentMap(); } - @Override public void close() { + @Override + public void close() { cache.clear(); } - @Override public void clear() { + @Override + public void clear() { cache.clear(); } - @Override public void finished(IndexReader reader) { + @Override + public void finished(IndexReader reader) { FilterCacheValue> readerValue = cache.remove(reader.getCoreCacheKey()); // help soft/weak handling GC if (readerValue != null) { @@ -74,7 +77,8 @@ public abstract class AbstractConcurrentMapFilterCache extends AbstractIndexComp } } - @Override public void clear(IndexReader reader) { + @Override + public void clear(IndexReader reader) { FilterCacheValue> readerValue = cache.remove(reader.getCoreCacheKey()); // help soft/weak handling GC if (readerValue != null) { @@ -82,7 +86,8 @@ public abstract class AbstractConcurrentMapFilterCache extends AbstractIndexComp } } - @Override public EntriesStats entriesStats() { + @Override + public EntriesStats entriesStats() { long sizeInBytes = 0; long totalCount = 0; int segmentsCount = 0; @@ -96,7 +101,8 @@ public abstract class AbstractConcurrentMapFilterCache extends AbstractIndexComp return new EntriesStats(sizeInBytes, segmentsCount == 0 ? 0 : totalCount / segmentsCount); } - @Override public Filter cache(Filter filterToCache) { + @Override + public Filter cache(Filter filterToCache) { if (filterToCache instanceof NoCacheFilter) { return filterToCache; } @@ -106,7 +112,8 @@ public abstract class AbstractConcurrentMapFilterCache extends AbstractIndexComp return new FilterCacheFilterWrapper(filterToCache, this); } - @Override public boolean isCached(Filter filter) { + @Override + public boolean isCached(Filter filter) { return filter instanceof FilterCacheFilterWrapper; } @@ -125,7 +132,8 @@ public abstract class AbstractConcurrentMapFilterCache extends AbstractIndexComp this.cache = cache; } - @Override public DocIdSet getDocIdSet(IndexReader reader) throws IOException { + @Override + public DocIdSet getDocIdSet(IndexReader reader) throws IOException { FilterCacheValue> cacheValue = cache.cache.get(reader.getCoreCacheKey()); if (cacheValue == null) { cacheValue = new FilterCacheValue>(cache.buildFilterMap()); diff --git a/src/main/java/org/elasticsearch/index/cache/filter/support/AbstractWeightedFilterCache.java b/src/main/java/org/elasticsearch/index/cache/filter/support/AbstractWeightedFilterCache.java index 793241b2054..1389e12c33b 100644 --- a/src/main/java/org/elasticsearch/index/cache/filter/support/AbstractWeightedFilterCache.java +++ b/src/main/java/org/elasticsearch/index/cache/filter/support/AbstractWeightedFilterCache.java @@ -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.elasticsearch.index.cache.filter.support; +import com.googlecode.concurrentlinkedhashmap.EvictionListener; +import com.googlecode.concurrentlinkedhashmap.Weigher; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.DocIdSet; import org.apache.lucene.search.Filter; import org.elasticsearch.ElasticSearchException; -import org.elasticsearch.common.concurrentlinkedhashmap.EvictionListener; -import org.elasticsearch.common.concurrentlinkedhashmap.Weigher; import org.elasticsearch.common.lucene.docset.DocSet; import org.elasticsearch.common.lucene.search.NoCacheFilter; import org.elasticsearch.common.metrics.CounterMetric; @@ -53,11 +53,13 @@ public abstract class AbstractWeightedFilterCache extends AbstractIndexComponent protected abstract ConcurrentMap> cache(); - @Override public void close() throws ElasticSearchException { + @Override + public void close() throws ElasticSearchException { clear(); } - @Override public void clear() { + @Override + public void clear() { for (Object readerKey : seenReaders.keySet()) { Boolean removed = seenReaders.remove(readerKey); if (removed == null) { @@ -76,11 +78,13 @@ public abstract class AbstractWeightedFilterCache extends AbstractIndexComponent } } - @Override public void finished(IndexReader reader) { + @Override + public void finished(IndexReader reader) { clear(reader); } - @Override public void clear(IndexReader reader) { + @Override + public void clear(IndexReader reader) { // we add the seen reader before we add the first cache entry for this reader // so, if we don't see it here, its won't be in the cache Boolean removed = seenReaders.remove(reader.getCoreCacheKey()); @@ -99,16 +103,19 @@ public abstract class AbstractWeightedFilterCache extends AbstractIndexComponent } } - @Override public EntriesStats entriesStats() { + @Override + public EntriesStats entriesStats() { long seenReadersCount = this.seenReadersCount.count(); return new EntriesStats(totalMetric.sum(), seenReadersCount == 0 ? 0 : totalMetric.count() / seenReadersCount); } - @Override public long evictions() { + @Override + public long evictions() { return evictionsMetric.count(); } - @Override public Filter cache(Filter filterToCache) { + @Override + public Filter cache(Filter filterToCache) { if (filterToCache instanceof NoCacheFilter) { return filterToCache; } @@ -118,7 +125,8 @@ public abstract class AbstractWeightedFilterCache extends AbstractIndexComponent return new FilterCacheFilterWrapper(filterToCache, this); } - @Override public boolean isCached(Filter filter) { + @Override + public boolean isCached(Filter filter) { return filter instanceof FilterCacheFilterWrapper; } @@ -133,7 +141,8 @@ public abstract class AbstractWeightedFilterCache extends AbstractIndexComponent this.cache = cache; } - @Override public DocIdSet getDocIdSet(IndexReader reader) throws IOException { + @Override + public DocIdSet getDocIdSet(IndexReader reader) throws IOException { Object filterKey = filter; if (filter instanceof CacheKeyFilter) { filterKey = ((CacheKeyFilter) filter).cacheKey(); @@ -183,13 +192,15 @@ public abstract class AbstractWeightedFilterCache extends AbstractIndexComponent public static final long FACTOR = 10l; - @Override public int weightOf(FilterCacheValue value) { + @Override + public int weightOf(FilterCacheValue value) { int weight = (int) Math.min(value.value().sizeInBytes() / 10, Integer.MAX_VALUE); return weight == 0 ? 1 : weight; } } - @Override public void onEviction(FilterCacheKey filterCacheKey, FilterCacheValue docSetFilterCacheValue) { + @Override + public void onEviction(FilterCacheKey filterCacheKey, FilterCacheValue docSetFilterCacheValue) { if (filterCacheKey != null) { if (seenReaders.containsKey(filterCacheKey.readerKey())) { evictionsMetric.inc(); @@ -217,14 +228,16 @@ public abstract class AbstractWeightedFilterCache extends AbstractIndexComponent return filterKey; } - @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; FilterCacheKey that = (FilterCacheKey) o; return (readerKey == that.readerKey && filterKey.equals(that.filterKey)); } - @Override public int hashCode() { + @Override + public int hashCode() { return readerKey.hashCode() + 31 * filterKey.hashCode(); } } diff --git a/src/main/java/org/elasticsearch/index/cache/filter/support/CacheKeyFilter.java b/src/main/java/org/elasticsearch/index/cache/filter/support/CacheKeyFilter.java index d12a494d9de..6786128b65f 100644 --- a/src/main/java/org/elasticsearch/index/cache/filter/support/CacheKeyFilter.java +++ b/src/main/java/org/elasticsearch/index/cache/filter/support/CacheKeyFilter.java @@ -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 @@ -53,7 +53,8 @@ public interface CacheKeyFilter { return Unicode.fromBytes(bytes); } - @Override public boolean equals(Object o) { + @Override + public boolean equals(Object o) { if (this == o) return true; if (o.getClass() != this.getClass()) { return false; @@ -62,7 +63,8 @@ public interface CacheKeyFilter { return Arrays.equals(bytes, bytesWrap.bytes); } - @Override public int hashCode() { + @Override + public int hashCode() { return hashCode; } } @@ -78,23 +80,28 @@ public interface CacheKeyFilter { this.key = key; } - @Override public Key cacheKey() { + @Override + public Key cacheKey() { return key; } - @Override public DocIdSet getDocIdSet(IndexReader reader) throws IOException { + @Override + public DocIdSet getDocIdSet(IndexReader reader) throws IOException { return filter.getDocIdSet(reader); } - @Override public int hashCode() { + @Override + public int hashCode() { return filter.hashCode(); } - @Override public boolean equals(Object obj) { + @Override + public boolean equals(Object obj) { return filter.equals(obj); } - @Override public String toString() { + @Override + public String toString() { return filter.toString(); } } diff --git a/src/main/java/org/elasticsearch/index/cache/filter/support/FilterCacheValue.java b/src/main/java/org/elasticsearch/index/cache/filter/support/FilterCacheValue.java index bb8f6875cb0..5593b2b2d06 100644 --- a/src/main/java/org/elasticsearch/index/cache/filter/support/FilterCacheValue.java +++ b/src/main/java/org/elasticsearch/index/cache/filter/support/FilterCacheValue.java @@ -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 diff --git a/src/main/java/org/elasticsearch/index/cache/filter/weak/WeakFilterCache.java b/src/main/java/org/elasticsearch/index/cache/filter/weak/WeakFilterCache.java index b2dbbe4cd14..a3b603e51af 100644 --- a/src/main/java/org/elasticsearch/index/cache/filter/weak/WeakFilterCache.java +++ b/src/main/java/org/elasticsearch/index/cache/filter/weak/WeakFilterCache.java @@ -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,11 +19,11 @@ package org.elasticsearch.index.cache.filter.weak; +import com.google.common.base.Objects; +import com.google.common.collect.MapEvictionListener; +import com.google.common.collect.MapMaker; import org.apache.lucene.search.Filter; import org.elasticsearch.cluster.metadata.IndexMetaData; -import org.elasticsearch.common.base.Objects; -import org.elasticsearch.common.collect.MapEvictionListener; -import org.elasticsearch.common.collect.MapMaker; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.lucene.docset.DocSet; import org.elasticsearch.common.metrics.CounterMetric; @@ -40,7 +40,7 @@ import java.util.concurrent.TimeUnit; /** * A weak reference based filter cache that has weak keys on the IndexReader. * - * @author kimchy (shay.banon) + * */ public class WeakFilterCache extends AbstractConcurrentMapFilterCache implements MapEvictionListener { @@ -53,7 +53,8 @@ public class WeakFilterCache extends AbstractConcurrentMapFilterCache implements private final ApplySettings applySettings = new ApplySettings(); - @Inject public WeakFilterCache(Index index, @IndexSettings Settings indexSettings, IndexSettingsService indexSettingsService) { + @Inject + public WeakFilterCache(Index index, @IndexSettings Settings indexSettings, IndexSettingsService indexSettingsService) { super(index, indexSettings); this.indexSettingsService = indexSettingsService; this.maxSize = indexSettings.getAsInt("index.cache.filter.max_size", componentSettings.getAsInt("max_size", -1)); @@ -63,12 +64,14 @@ public class WeakFilterCache extends AbstractConcurrentMapFilterCache implements indexSettingsService.addListener(applySettings); } - @Override public void close() { + @Override + public void close() { indexSettingsService.removeListener(applySettings); super.close(); } - @Override protected ConcurrentMap buildFilterMap() { + @Override + protected ConcurrentMap buildFilterMap() { MapMaker mapMaker = new MapMaker().weakValues(); if (maxSize != -1) { mapMaker.maximumSize(maxSize); @@ -80,15 +83,18 @@ public class WeakFilterCache extends AbstractConcurrentMapFilterCache implements return mapMaker.makeMap(); } - @Override public String type() { + @Override + public String type() { return "weak"; } - @Override public long evictions() { + @Override + public long evictions() { return evictions.count(); } - @Override public void onEviction(Filter filter, DocSet docSet) { + @Override + public void onEviction(Filter filter, DocSet docSet) { evictions.inc(); } @@ -100,7 +106,8 @@ public class WeakFilterCache extends AbstractConcurrentMapFilterCache implements } class ApplySettings implements IndexSettingsService.Listener { - @Override public void onRefreshSettings(Settings settings) { + @Override + public void onRefreshSettings(Settings settings) { int maxSize = settings.getAsInt("index.cache.filter.max_size", WeakFilterCache.this.maxSize); TimeValue expire = settings.getAsTime("index.cache.filter.expire", WeakFilterCache.this.expire); boolean changed = false; diff --git a/src/main/java/org/elasticsearch/index/cache/id/IdCache.java b/src/main/java/org/elasticsearch/index/cache/id/IdCache.java index 25499a1a837..ec659b042a3 100644 --- a/src/main/java/org/elasticsearch/index/cache/id/IdCache.java +++ b/src/main/java/org/elasticsearch/index/cache/id/IdCache.java @@ -24,7 +24,7 @@ import org.elasticsearch.common.component.CloseableComponent; import org.elasticsearch.index.IndexComponent; /** - * @author kimchy (shay.banon) + * */ public interface IdCache extends IndexComponent, CloseableComponent, Iterable { diff --git a/src/main/java/org/elasticsearch/index/cache/id/IdCacheModule.java b/src/main/java/org/elasticsearch/index/cache/id/IdCacheModule.java index 2aaaaa6f0bf..ddb940883cf 100644 --- a/src/main/java/org/elasticsearch/index/cache/id/IdCacheModule.java +++ b/src/main/java/org/elasticsearch/index/cache/id/IdCacheModule.java @@ -25,7 +25,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.cache.id.simple.SimpleIdCache; /** - * @author kimchy (shay.banon) + * */ public class IdCacheModule extends AbstractModule { @@ -39,7 +39,8 @@ public class IdCacheModule extends AbstractModule { this.settings = settings; } - @Override protected void configure() { + @Override + protected void configure() { bind(IdCache.class) .to(settings.getAsClass(IdCacheSettings.ID_CACHE_TYPE, SimpleIdCache.class, "org.elasticsearch.index.cache.id.", "IdCache")) .in(Scopes.SINGLETON); diff --git a/src/main/java/org/elasticsearch/index/cache/id/IdReaderCache.java b/src/main/java/org/elasticsearch/index/cache/id/IdReaderCache.java index 8d835f8f512..ff0e4978a6e 100644 --- a/src/main/java/org/elasticsearch/index/cache/id/IdReaderCache.java +++ b/src/main/java/org/elasticsearch/index/cache/id/IdReaderCache.java @@ -22,7 +22,7 @@ package org.elasticsearch.index.cache.id; import org.elasticsearch.common.BytesWrap; /** - * @author kimchy (shay.banon) + * */ public interface IdReaderCache { diff --git a/src/main/java/org/elasticsearch/index/cache/id/IdReaderTypeCache.java b/src/main/java/org/elasticsearch/index/cache/id/IdReaderTypeCache.java index 5c15792a883..1173bb8e268 100644 --- a/src/main/java/org/elasticsearch/index/cache/id/IdReaderTypeCache.java +++ b/src/main/java/org/elasticsearch/index/cache/id/IdReaderTypeCache.java @@ -22,7 +22,7 @@ package org.elasticsearch.index.cache.id; import org.elasticsearch.common.BytesWrap; /** - * @author kimchy (shay.banon) + * */ public interface IdReaderTypeCache { diff --git a/src/main/java/org/elasticsearch/index/cache/id/simple/SimpleIdCache.java b/src/main/java/org/elasticsearch/index/cache/id/simple/SimpleIdCache.java index e08a777544a..26a6d98c908 100644 --- a/src/main/java/org/elasticsearch/index/cache/id/simple/SimpleIdCache.java +++ b/src/main/java/org/elasticsearch/index/cache/id/simple/SimpleIdCache.java @@ -19,6 +19,8 @@ package org.elasticsearch.index.cache.id.simple; +import gnu.trove.ExtTObjectIntHasMap; +import gnu.trove.impl.Constants; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.Term; import org.apache.lucene.index.TermDocs; @@ -29,8 +31,6 @@ import org.elasticsearch.common.BytesWrap; import org.elasticsearch.common.collect.MapBuilder; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.trove.ExtTObjectIntHasMap; -import org.elasticsearch.common.trove.impl.Constants; import org.elasticsearch.common.util.concurrent.ConcurrentCollections; import org.elasticsearch.index.AbstractIndexComponent; import org.elasticsearch.index.Index; @@ -48,43 +48,52 @@ import java.util.Map; import java.util.concurrent.ConcurrentMap; /** - * @author kimchy (shay.banon) + * */ public class SimpleIdCache extends AbstractIndexComponent implements IdCache, IndexReader.ReaderFinishedListener { private final ConcurrentMap idReaders; - @Inject public SimpleIdCache(Index index, @IndexSettings Settings indexSettings) { + @Inject + public SimpleIdCache(Index index, @IndexSettings Settings indexSettings) { super(index, indexSettings); idReaders = ConcurrentCollections.newConcurrentMap(); } - @Override public void close() throws ElasticSearchException { + @Override + public void close() throws ElasticSearchException { clear(); } - @Override public void clear() { + @Override + public void clear() { idReaders.clear(); } - @Override public void finished(IndexReader reader) { + @Override + public void finished(IndexReader reader) { clear(reader); } - @Override public void clear(IndexReader reader) { + @Override + public void clear(IndexReader reader) { idReaders.remove(reader.getCoreCacheKey()); } - @Override public IdReaderCache reader(IndexReader reader) { + @Override + public IdReaderCache reader(IndexReader reader) { return idReaders.get(reader.getCoreCacheKey()); } - @SuppressWarnings({"unchecked"}) @Override public Iterator iterator() { + @SuppressWarnings({"unchecked"}) + @Override + public Iterator iterator() { return (Iterator) idReaders.values(); } @SuppressWarnings({"StringEquality"}) - @Override public void refresh(IndexReader[] readers) throws Exception { + @Override + public void refresh(IndexReader[] readers) throws Exception { // do a quick check for the common case, that all are there if (refreshNeeded(readers)) { synchronized (idReaders) { diff --git a/src/main/java/org/elasticsearch/index/cache/id/simple/SimpleIdReaderCache.java b/src/main/java/org/elasticsearch/index/cache/id/simple/SimpleIdReaderCache.java index 3c570e62ecf..db311a7e5ff 100644 --- a/src/main/java/org/elasticsearch/index/cache/id/simple/SimpleIdReaderCache.java +++ b/src/main/java/org/elasticsearch/index/cache/id/simple/SimpleIdReaderCache.java @@ -19,13 +19,13 @@ package org.elasticsearch.index.cache.id.simple; +import com.google.common.collect.ImmutableMap; import org.elasticsearch.common.BytesWrap; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.index.cache.id.IdReaderCache; import org.elasticsearch.index.cache.id.IdReaderTypeCache; /** - * @author kimchy (shay.banon) + * */ public class SimpleIdReaderCache implements IdReaderCache { @@ -38,15 +38,18 @@ public class SimpleIdReaderCache implements IdReaderCache { this.types = types; } - @Override public Object readerCacheKey() { + @Override + public Object readerCacheKey() { return this.readerCacheKey; } - @Override public IdReaderTypeCache type(String type) { + @Override + public IdReaderTypeCache type(String type) { return types.get(type); } - @Override public BytesWrap parentIdByDoc(String type, int docId) { + @Override + public BytesWrap parentIdByDoc(String type, int docId) { SimpleIdReaderTypeCache typeCache = types.get(type); if (typeCache != null) { return typeCache.parentIdByDoc(docId); @@ -54,7 +57,8 @@ public class SimpleIdReaderCache implements IdReaderCache { return null; } - @Override public int docById(String type, BytesWrap id) { + @Override + public int docById(String type, BytesWrap id) { SimpleIdReaderTypeCache typeCache = types.get(type); if (typeCache != null) { return typeCache.docById(id); diff --git a/src/main/java/org/elasticsearch/index/cache/id/simple/SimpleIdReaderTypeCache.java b/src/main/java/org/elasticsearch/index/cache/id/simple/SimpleIdReaderTypeCache.java index 941436b7f17..90121bf0773 100644 --- a/src/main/java/org/elasticsearch/index/cache/id/simple/SimpleIdReaderTypeCache.java +++ b/src/main/java/org/elasticsearch/index/cache/id/simple/SimpleIdReaderTypeCache.java @@ -19,12 +19,12 @@ package org.elasticsearch.index.cache.id.simple; +import gnu.trove.ExtTObjectIntHasMap; import org.elasticsearch.common.BytesWrap; -import org.elasticsearch.common.trove.ExtTObjectIntHasMap; import org.elasticsearch.index.cache.id.IdReaderTypeCache; /** - * @author kimchy (shay.banon) + * */ public class SimpleIdReaderTypeCache implements IdReaderTypeCache { diff --git a/src/main/java/org/elasticsearch/index/cache/query/parser/QueryParserCache.java b/src/main/java/org/elasticsearch/index/cache/query/parser/QueryParserCache.java index 7f8e60e71ec..7c11eed3c40 100644 --- a/src/main/java/org/elasticsearch/index/cache/query/parser/QueryParserCache.java +++ b/src/main/java/org/elasticsearch/index/cache/query/parser/QueryParserCache.java @@ -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.common.component.CloseableComponent; import org.elasticsearch.index.IndexComponent; /** - * @author kimchy (shay.banon) + * */ public interface QueryParserCache extends IndexComponent, CloseableComponent { diff --git a/src/main/java/org/elasticsearch/index/cache/query/parser/QueryParserCacheModule.java b/src/main/java/org/elasticsearch/index/cache/query/parser/QueryParserCacheModule.java index d96c5cfb716..4747d5e7455 100644 --- a/src/main/java/org/elasticsearch/index/cache/query/parser/QueryParserCacheModule.java +++ b/src/main/java/org/elasticsearch/index/cache/query/parser/QueryParserCacheModule.java @@ -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.common.settings.Settings; import org.elasticsearch.index.cache.query.parser.weak.WeakQueryParserCache; /** - * @author kimchy (shay.banon) + * */ public class QueryParserCacheModule extends AbstractModule { @@ -35,7 +35,8 @@ public class QueryParserCacheModule extends AbstractModule { this.settings = settings; } - @Override protected void configure() { + @Override + protected void configure() { bind(QueryParserCache.class) .to(settings.getAsClass("index.cache.query.parser.type", WeakQueryParserCache.class, "org.elasticsearch.index.cache.query.parser.", "QueryParserCache")) .in(Scopes.SINGLETON); diff --git a/src/main/java/org/elasticsearch/index/cache/query/parser/none/NoneQueryParserCache.java b/src/main/java/org/elasticsearch/index/cache/query/parser/none/NoneQueryParserCache.java index fed5c3230f3..805b5473d8b 100644 --- a/src/main/java/org/elasticsearch/index/cache/query/parser/none/NoneQueryParserCache.java +++ b/src/main/java/org/elasticsearch/index/cache/query/parser/none/NoneQueryParserCache.java @@ -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,24 +30,29 @@ import org.elasticsearch.index.cache.query.parser.QueryParserCache; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class NoneQueryParserCache extends AbstractIndexComponent implements QueryParserCache { - @Inject public NoneQueryParserCache(Index index, @IndexSettings Settings indexSettings) { + @Inject + public NoneQueryParserCache(Index index, @IndexSettings Settings indexSettings) { super(index, indexSettings); } - @Override public Query get(QueryParserSettings queryString) { + @Override + public Query get(QueryParserSettings queryString) { return null; } - @Override public void put(QueryParserSettings queryString, Query query) { + @Override + public void put(QueryParserSettings queryString, Query query) { } - @Override public void clear() { + @Override + public void clear() { } - @Override public void close() throws ElasticSearchException { + @Override + public void close() throws ElasticSearchException { } } diff --git a/src/main/java/org/elasticsearch/index/cache/query/parser/soft/SoftQueryParserCache.java b/src/main/java/org/elasticsearch/index/cache/query/parser/soft/SoftQueryParserCache.java index 2a10317e8a6..fa746fdff52 100644 --- a/src/main/java/org/elasticsearch/index/cache/query/parser/soft/SoftQueryParserCache.java +++ b/src/main/java/org/elasticsearch/index/cache/query/parser/soft/SoftQueryParserCache.java @@ -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.index.cache.query.parser.soft; +import com.google.common.collect.MapMaker; import org.apache.lucene.queryParser.QueryParserSettings; import org.apache.lucene.search.Query; -import org.elasticsearch.common.collect.MapMaker; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.Index; @@ -29,11 +29,12 @@ import org.elasticsearch.index.cache.query.parser.support.AbstractJvmQueryParser import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class SoftQueryParserCache extends AbstractJvmQueryParserCache { - @Inject public SoftQueryParserCache(Index index, @IndexSettings Settings indexSettings) { + @Inject + public SoftQueryParserCache(Index index, @IndexSettings Settings indexSettings) { super(index, indexSettings, new MapMaker().softValues().makeMap()); } } diff --git a/src/main/java/org/elasticsearch/index/cache/query/parser/support/AbstractJvmQueryParserCache.java b/src/main/java/org/elasticsearch/index/cache/query/parser/support/AbstractJvmQueryParserCache.java index 4c24bf6b282..5f555f308ac 100644 --- a/src/main/java/org/elasticsearch/index/cache/query/parser/support/AbstractJvmQueryParserCache.java +++ b/src/main/java/org/elasticsearch/index/cache/query/parser/support/AbstractJvmQueryParserCache.java @@ -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,7 +31,7 @@ import org.elasticsearch.index.settings.IndexSettings; import java.util.concurrent.ConcurrentMap; /** - * @author kimchy (shay.banon) + * */ public class AbstractJvmQueryParserCache extends AbstractIndexComponent implements QueryParserCache { @@ -42,19 +42,23 @@ public class AbstractJvmQueryParserCache extends AbstractIndexComponent implemen this.cache = cache; } - @Override public void close() throws ElasticSearchException { + @Override + public void close() throws ElasticSearchException { clear(); } - @Override public void clear() { + @Override + public void clear() { cache.clear(); } - @Override public Query get(QueryParserSettings queryString) { + @Override + public Query get(QueryParserSettings queryString) { return cache.get(queryString); } - @Override public void put(QueryParserSettings queryString, Query query) { + @Override + public void put(QueryParserSettings queryString, Query query) { cache.put(queryString, query); } } diff --git a/src/main/java/org/elasticsearch/index/cache/query/parser/weak/WeakQueryParserCache.java b/src/main/java/org/elasticsearch/index/cache/query/parser/weak/WeakQueryParserCache.java index ade6ac5767f..f819beada72 100644 --- a/src/main/java/org/elasticsearch/index/cache/query/parser/weak/WeakQueryParserCache.java +++ b/src/main/java/org/elasticsearch/index/cache/query/parser/weak/WeakQueryParserCache.java @@ -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.index.cache.query.parser.weak; +import com.google.common.collect.MapMaker; import org.apache.lucene.queryParser.QueryParserSettings; import org.apache.lucene.search.Query; -import org.elasticsearch.common.collect.MapMaker; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.Index; @@ -29,11 +29,12 @@ import org.elasticsearch.index.cache.query.parser.support.AbstractJvmQueryParser import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class WeakQueryParserCache extends AbstractJvmQueryParserCache { - @Inject public WeakQueryParserCache(Index index, @IndexSettings Settings indexSettings) { + @Inject + public WeakQueryParserCache(Index index, @IndexSettings Settings indexSettings) { super(index, indexSettings, new MapMaker().weakValues().makeMap()); } } diff --git a/src/main/java/org/elasticsearch/index/deletionpolicy/DeletionPolicyModule.java b/src/main/java/org/elasticsearch/index/deletionpolicy/DeletionPolicyModule.java index 455b3f3c7b9..c9b215835cc 100644 --- a/src/main/java/org/elasticsearch/index/deletionpolicy/DeletionPolicyModule.java +++ b/src/main/java/org/elasticsearch/index/deletionpolicy/DeletionPolicyModule.java @@ -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,10 +24,10 @@ import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.name.Names; import org.elasticsearch.common.settings.Settings; -import static org.elasticsearch.index.deletionpolicy.DeletionPolicyModule.DeletionPolicySettings.*; +import static org.elasticsearch.index.deletionpolicy.DeletionPolicyModule.DeletionPolicySettings.TYPE; /** - * @author kimchy (shay.banon) + * */ public class DeletionPolicyModule extends AbstractModule { @@ -41,7 +41,8 @@ public class DeletionPolicyModule extends AbstractModule { this.settings = settings; } - @Override protected void configure() { + @Override + protected void configure() { bind(IndexDeletionPolicy.class) .annotatedWith(Names.named("actual")) .to(settings.getAsClass(TYPE, KeepOnlyLastDeletionPolicy.class)) diff --git a/src/main/java/org/elasticsearch/index/deletionpolicy/KeepLastNDeletionPolicy.java b/src/main/java/org/elasticsearch/index/deletionpolicy/KeepLastNDeletionPolicy.java index 67b1773f3b7..3c1289d29af 100644 --- a/src/main/java/org/elasticsearch/index/deletionpolicy/KeepLastNDeletionPolicy.java +++ b/src/main/java/org/elasticsearch/index/deletionpolicy/KeepLastNDeletionPolicy.java @@ -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,13 +31,14 @@ import java.io.IOException; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class KeepLastNDeletionPolicy extends AbstractIndexShardComponent implements IndexDeletionPolicy { private final int numToKeep; - @Inject public KeepLastNDeletionPolicy(ShardId shardId, @IndexSettings Settings indexSettings) { + @Inject + public KeepLastNDeletionPolicy(ShardId shardId, @IndexSettings Settings indexSettings) { super(shardId, indexSettings); this.numToKeep = componentSettings.getAsInt("num_to_keep", 5); logger.debug("Using [keep_last_n] deletion policy with num_to_keep[{}]", numToKeep); diff --git a/src/main/java/org/elasticsearch/index/deletionpolicy/KeepOnlyLastDeletionPolicy.java b/src/main/java/org/elasticsearch/index/deletionpolicy/KeepOnlyLastDeletionPolicy.java index de4c56efc25..420cf4750d0 100644 --- a/src/main/java/org/elasticsearch/index/deletionpolicy/KeepOnlyLastDeletionPolicy.java +++ b/src/main/java/org/elasticsearch/index/deletionpolicy/KeepOnlyLastDeletionPolicy.java @@ -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,8 @@ import java.util.List; */ public class KeepOnlyLastDeletionPolicy extends AbstractIndexShardComponent implements IndexDeletionPolicy { - @Inject public KeepOnlyLastDeletionPolicy(ShardId shardId, @IndexSettings Settings indexSettings) { + @Inject + public KeepOnlyLastDeletionPolicy(ShardId shardId, @IndexSettings Settings indexSettings) { super(shardId, indexSettings); logger.debug("Using [keep_only_last] deletion policy"); } diff --git a/src/main/java/org/elasticsearch/index/deletionpolicy/SnapshotDeletionPolicy.java b/src/main/java/org/elasticsearch/index/deletionpolicy/SnapshotDeletionPolicy.java index 902432984c9..05d8e3a0285 100644 --- a/src/main/java/org/elasticsearch/index/deletionpolicy/SnapshotDeletionPolicy.java +++ b/src/main/java/org/elasticsearch/index/deletionpolicy/SnapshotDeletionPolicy.java @@ -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,7 +38,7 @@ import java.util.concurrent.ConcurrentMap; * and if the deletion policy is used with all open index writers (JVM level) then the snapshot * state will not be deleted until it will be released. * - * @author kimchy (shay.banon) + * */ public class SnapshotDeletionPolicy extends AbstractIndexShardComponent implements IndexDeletionPolicy { @@ -55,7 +55,8 @@ public class SnapshotDeletionPolicy extends AbstractIndexShardComponent implemen /** * Constructs a new snapshot deletion policy that wraps the provided deletion policy. */ - @Inject public SnapshotDeletionPolicy(@Named("actual") IndexDeletionPolicy primary) { + @Inject + public SnapshotDeletionPolicy(@Named("actual") IndexDeletionPolicy primary) { super(((IndexShardComponent) primary).shardId(), ((IndexShardComponent) primary).indexSettings()); this.primary = primary; } @@ -77,7 +78,7 @@ public class SnapshotDeletionPolicy extends AbstractIndexShardComponent implemen primary.onCommit(snapshotCommits); // clean snapshots that their respective counts are 0 (should not really happen) - for (Iterator it = snapshots.values().iterator(); it.hasNext();) { + for (Iterator it = snapshots.values().iterator(); it.hasNext(); ) { SnapshotHolder holder = it.next(); if (holder.counter <= 0) { it.remove(); @@ -178,7 +179,8 @@ public class SnapshotDeletionPolicy extends AbstractIndexShardComponent implemen super(deletionPolicy, cp); } - @Override public boolean release() { + @Override + public boolean release() { if (released) { return false; } diff --git a/src/main/java/org/elasticsearch/index/deletionpolicy/SnapshotIndexCommit.java b/src/main/java/org/elasticsearch/index/deletionpolicy/SnapshotIndexCommit.java index 9a286f102c9..6d03547f250 100644 --- a/src/main/java/org/elasticsearch/index/deletionpolicy/SnapshotIndexCommit.java +++ b/src/main/java/org/elasticsearch/index/deletionpolicy/SnapshotIndexCommit.java @@ -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,7 +31,7 @@ import java.util.ArrayList; * was not called, no files will be deleted that relates to this commit point * ({@link #getFileNames()}). * - * @author kimchy (Shay Banon) + * */ public class SnapshotIndexCommit extends IndexCommitDelegate implements Releasable { @@ -65,7 +65,8 @@ public class SnapshotIndexCommit extends IndexCommitDelegate implements Releasab * Override the delete operation, and only actually delete it if it * is not held by the {@link SnapshotDeletionPolicy}. */ - @Override public void delete() { + @Override + public void delete() { if (!deletionPolicy.isHeld(getVersion())) { delegate.delete(); } diff --git a/src/main/java/org/elasticsearch/index/deletionpolicy/SnapshotIndexCommits.java b/src/main/java/org/elasticsearch/index/deletionpolicy/SnapshotIndexCommits.java index e136cdf1671..3062ec47497 100644 --- a/src/main/java/org/elasticsearch/index/deletionpolicy/SnapshotIndexCommits.java +++ b/src/main/java/org/elasticsearch/index/deletionpolicy/SnapshotIndexCommits.java @@ -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.util.List; * Represents a snapshot view of several commits. Provides a way to iterate over * them as well as a simple method to release all of them. * - * @author kimchy (Shay Banon) + * */ public class SnapshotIndexCommits implements Iterable, Releasable { @@ -42,7 +42,8 @@ public class SnapshotIndexCommits implements Iterable, Rele return commits.size(); } - @Override public Iterator iterator() { + @Override + public Iterator iterator() { return commits.iterator(); } diff --git a/src/main/java/org/elasticsearch/index/engine/CloseEngineException.java b/src/main/java/org/elasticsearch/index/engine/CloseEngineException.java index 11b3602580b..d0613ae0db8 100644 --- a/src/main/java/org/elasticsearch/index/engine/CloseEngineException.java +++ b/src/main/java/org/elasticsearch/index/engine/CloseEngineException.java @@ -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.index.shard.ShardId; /** * An exception indicating that an {@link org.elasticsearch.index.engine.Engine} close failed. * - * @author kimchy (Shay Banon) + * */ public class CloseEngineException extends EngineException { diff --git a/src/main/java/org/elasticsearch/index/engine/CreateFailedEngineException.java b/src/main/java/org/elasticsearch/index/engine/CreateFailedEngineException.java index b79e693236e..ad2c3775940 100644 --- a/src/main/java/org/elasticsearch/index/engine/CreateFailedEngineException.java +++ b/src/main/java/org/elasticsearch/index/engine/CreateFailedEngineException.java @@ -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.index.engine; import org.elasticsearch.index.shard.ShardId; /** - * @author kimchy (Shay Banon) + * */ public class CreateFailedEngineException extends EngineException { diff --git a/src/main/java/org/elasticsearch/index/engine/DeleteByQueryFailedEngineException.java b/src/main/java/org/elasticsearch/index/engine/DeleteByQueryFailedEngineException.java index 57bab23873f..f073b9a8a0a 100644 --- a/src/main/java/org/elasticsearch/index/engine/DeleteByQueryFailedEngineException.java +++ b/src/main/java/org/elasticsearch/index/engine/DeleteByQueryFailedEngineException.java @@ -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.index.engine; import org.elasticsearch.index.shard.ShardId; /** - * @author kimchy (Shay Banon) + * */ public class DeleteByQueryFailedEngineException extends EngineException { diff --git a/src/main/java/org/elasticsearch/index/engine/DeleteFailedEngineException.java b/src/main/java/org/elasticsearch/index/engine/DeleteFailedEngineException.java index 9ce29ee3db5..43384c02df0 100644 --- a/src/main/java/org/elasticsearch/index/engine/DeleteFailedEngineException.java +++ b/src/main/java/org/elasticsearch/index/engine/DeleteFailedEngineException.java @@ -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.index.engine; import org.elasticsearch.index.shard.ShardId; /** - * @author kimchy (Shay Banon) + * */ public class DeleteFailedEngineException extends EngineException { diff --git a/src/main/java/org/elasticsearch/index/engine/DocumentAlreadyExistsEngineException.java b/src/main/java/org/elasticsearch/index/engine/DocumentAlreadyExistsEngineException.java index 3a5df80aa2e..db84ae92691 100644 --- a/src/main/java/org/elasticsearch/index/engine/DocumentAlreadyExistsEngineException.java +++ b/src/main/java/org/elasticsearch/index/engine/DocumentAlreadyExistsEngineException.java @@ -23,7 +23,7 @@ import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.rest.RestStatus; /** - * @author kimchy (shay.banon) + * */ public class DocumentAlreadyExistsEngineException extends EngineException { @@ -31,7 +31,8 @@ public class DocumentAlreadyExistsEngineException extends EngineException { super(shardId, "[" + type + "][" + id + "]: document already exists"); } - @Override public RestStatus status() { + @Override + public RestStatus status() { return RestStatus.CONFLICT; } } diff --git a/src/main/java/org/elasticsearch/index/engine/Engine.java b/src/main/java/org/elasticsearch/index/engine/Engine.java index 8cc9fb2843b..fe5c3be38d6 100644 --- a/src/main/java/org/elasticsearch/index/engine/Engine.java +++ b/src/main/java/org/elasticsearch/index/engine/Engine.java @@ -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 @@ -46,7 +46,7 @@ import org.elasticsearch.index.translog.Translog; import java.util.List; /** - * @author kimchy (shay.banon) + * */ @ThreadSafe public interface Engine extends IndexShardComponent, CloseableComponent { @@ -64,7 +64,7 @@ public interface Engine extends IndexShardComponent, CloseableComponent { /** * Starts the Engine. - * + *

    *

    Note, after the creation and before the call to start, the store might * be changed. */ @@ -120,13 +120,13 @@ public interface Engine extends IndexShardComponent, CloseableComponent { /** * Recovery allow to start the recovery process. It is built of three phases. - * + *

    *

    The first phase allows to take a snapshot of the master index. Once this * is taken, no commit operations are effectively allowed on the index until the recovery * phases are through. - * + *

    *

    The seconds phase takes a snapshot of the current transaction log. - * + *

    *

    The last phase returns the remaining transaction log. During this phase, no dirty * operations are allowed on the index. */ @@ -176,7 +176,8 @@ public interface Engine extends IndexShardComponent, CloseableComponent { return waitForOperations; } - @Override public String toString() { + @Override + public String toString() { return "waitForOperations[" + waitForOperations + "]"; } } @@ -226,7 +227,8 @@ public interface Engine extends IndexShardComponent, CloseableComponent { return this; } - @Override public String toString() { + @Override + public String toString() { return "full[" + full + "], refresh[" + refresh + "], force[" + force + "]"; } } @@ -286,7 +288,8 @@ public interface Engine extends IndexShardComponent, CloseableComponent { return this; } - @Override public String toString() { + @Override + public String toString() { return "waitForMerge[" + waitForMerge + "], maxNumSegments[" + maxNumSegments + "], onlyExpungeDeletes[" + onlyExpungeDeletes + "], flush[" + flush + "], refresh[" + refresh + "]"; } } @@ -339,7 +342,8 @@ public interface Engine extends IndexShardComponent, CloseableComponent { return this.docMapper; } - @Override public Type opType() { + @Override + public Type opType() { return Type.CREATE; } @@ -348,7 +352,8 @@ public interface Engine extends IndexShardComponent, CloseableComponent { return this; } - @Override public Origin origin() { + @Override + public Origin origin() { return this.origin; } @@ -473,7 +478,8 @@ public interface Engine extends IndexShardComponent, CloseableComponent { return this.docMapper; } - @Override public Type opType() { + @Override + public Type opType() { return Type.INDEX; } @@ -482,7 +488,8 @@ public interface Engine extends IndexShardComponent, CloseableComponent { return this; } - @Override public Origin origin() { + @Override + public Origin origin() { return this.origin; } @@ -603,7 +610,8 @@ public interface Engine extends IndexShardComponent, CloseableComponent { this.uid = uid; } - @Override public Type opType() { + @Override + public Type opType() { return Type.DELETE; } @@ -612,7 +620,8 @@ public interface Engine extends IndexShardComponent, CloseableComponent { return this; } - @Override public Origin origin() { + @Override + public Origin origin() { return this.origin; } @@ -806,7 +815,8 @@ public interface Engine extends IndexShardComponent, CloseableComponent { return this.version; } - @Nullable public Translog.Source source() { + @Nullable + public Translog.Source source() { return source; } diff --git a/src/main/java/org/elasticsearch/index/engine/EngineAlreadyStartedException.java b/src/main/java/org/elasticsearch/index/engine/EngineAlreadyStartedException.java index b094b56bd57..e0822b0c181 100644 --- a/src/main/java/org/elasticsearch/index/engine/EngineAlreadyStartedException.java +++ b/src/main/java/org/elasticsearch/index/engine/EngineAlreadyStartedException.java @@ -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.index.engine; import org.elasticsearch.index.shard.ShardId; /** - * @author kimchy (Shay Banon) + * */ public class EngineAlreadyStartedException extends EngineException { diff --git a/src/main/java/org/elasticsearch/index/engine/EngineClosedException.java b/src/main/java/org/elasticsearch/index/engine/EngineClosedException.java index 95c61770839..05e58cb7844 100644 --- a/src/main/java/org/elasticsearch/index/engine/EngineClosedException.java +++ b/src/main/java/org/elasticsearch/index/engine/EngineClosedException.java @@ -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,11 +24,11 @@ import org.elasticsearch.index.shard.ShardId; /** * An engine is already closed. - * + *

    *

    Note, the relationship between shard and engine indicates that engine closed is shard closed, and * we might get something slipping through the the shard and into the engine while the shard is closing. * - * @author kimchy (shay.banon) + * */ public class EngineClosedException extends IndexShardClosedException { diff --git a/src/main/java/org/elasticsearch/index/engine/EngineCreationFailureException.java b/src/main/java/org/elasticsearch/index/engine/EngineCreationFailureException.java index 147719e66c6..cb997e1490b 100644 --- a/src/main/java/org/elasticsearch/index/engine/EngineCreationFailureException.java +++ b/src/main/java/org/elasticsearch/index/engine/EngineCreationFailureException.java @@ -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.index.shard.ShardId; /** * An exception indicating that an {@link Engine} creation failed. * - * @author kimchy (Shay Banon) + * */ public class EngineCreationFailureException extends EngineException { diff --git a/src/main/java/org/elasticsearch/index/engine/EngineException.java b/src/main/java/org/elasticsearch/index/engine/EngineException.java index 5aba7371399..bcb12ea4690 100644 --- a/src/main/java/org/elasticsearch/index/engine/EngineException.java +++ b/src/main/java/org/elasticsearch/index/engine/EngineException.java @@ -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 EngineException extends IndexShardException { diff --git a/src/main/java/org/elasticsearch/index/engine/EngineModule.java b/src/main/java/org/elasticsearch/index/engine/EngineModule.java index 26214358ac0..eae81c0495f 100644 --- a/src/main/java/org/elasticsearch/index/engine/EngineModule.java +++ b/src/main/java/org/elasticsearch/index/engine/EngineModule.java @@ -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,7 +19,7 @@ package org.elasticsearch.index.engine; -import org.elasticsearch.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.inject.Modules; @@ -27,7 +27,7 @@ import org.elasticsearch.common.inject.SpawnModules; import org.elasticsearch.common.settings.Settings; /** - * @author kimchy (shay.banon) + * */ public class EngineModule extends AbstractModule implements SpawnModules { @@ -37,10 +37,12 @@ public class EngineModule extends AbstractModule implements SpawnModules { this.settings = settings; } - @Override public Iterable spawnModules() { + @Override + public Iterable spawnModules() { return ImmutableList.of(Modules.createModule(settings.getAsClass(IndexEngineModule.EngineSettings.ENGINE_TYPE, IndexEngineModule.EngineSettings.DEFAULT_ENGINE, "org.elasticsearch.index.engine.", "EngineModule"), settings)); } - @Override protected void configure() { + @Override + protected void configure() { } } diff --git a/src/main/java/org/elasticsearch/index/engine/FlushFailedEngineException.java b/src/main/java/org/elasticsearch/index/engine/FlushFailedEngineException.java index 7e785ca3b23..4f1aef14485 100644 --- a/src/main/java/org/elasticsearch/index/engine/FlushFailedEngineException.java +++ b/src/main/java/org/elasticsearch/index/engine/FlushFailedEngineException.java @@ -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.index.engine; import org.elasticsearch.index.shard.ShardId; /** - * @author kimchy (Shay Banon) + * */ public class FlushFailedEngineException extends EngineException { diff --git a/src/main/java/org/elasticsearch/index/engine/FlushNotAllowedEngineException.java b/src/main/java/org/elasticsearch/index/engine/FlushNotAllowedEngineException.java index 871be010f3a..63031e7beec 100644 --- a/src/main/java/org/elasticsearch/index/engine/FlushNotAllowedEngineException.java +++ b/src/main/java/org/elasticsearch/index/engine/FlushNotAllowedEngineException.java @@ -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.index.engine; import org.elasticsearch.index.shard.ShardId; /** - * @author kimchy (Shay Banon) + * */ public class FlushNotAllowedEngineException extends EngineException { diff --git a/src/main/java/org/elasticsearch/index/engine/IgnoreOnRecoveryEngineException.java b/src/main/java/org/elasticsearch/index/engine/IgnoreOnRecoveryEngineException.java index 724766b602a..22eacd2ae2d 100644 --- a/src/main/java/org/elasticsearch/index/engine/IgnoreOnRecoveryEngineException.java +++ b/src/main/java/org/elasticsearch/index/engine/IgnoreOnRecoveryEngineException.java @@ -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 diff --git a/src/main/java/org/elasticsearch/index/engine/IndexEngine.java b/src/main/java/org/elasticsearch/index/engine/IndexEngine.java index 25e98e81e4a..82b85a6c3d6 100644 --- a/src/main/java/org/elasticsearch/index/engine/IndexEngine.java +++ b/src/main/java/org/elasticsearch/index/engine/IndexEngine.java @@ -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.index.IndexComponent; * An "index" scoped engine that provides some meta engine for the engine, and can be used to store * index level data structures that an engine requires. * - * @author kimchy (shay.banon) + * */ public interface IndexEngine extends IndexComponent { diff --git a/src/main/java/org/elasticsearch/index/engine/IndexEngineModule.java b/src/main/java/org/elasticsearch/index/engine/IndexEngineModule.java index 9f41b2bd58f..8689c40c75d 100644 --- a/src/main/java/org/elasticsearch/index/engine/IndexEngineModule.java +++ b/src/main/java/org/elasticsearch/index/engine/IndexEngineModule.java @@ -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,7 +19,7 @@ package org.elasticsearch.index.engine; -import org.elasticsearch.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.inject.SpawnModules; @@ -27,10 +27,10 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.engine.robin.RobinEngineModule; import org.elasticsearch.index.engine.robin.RobinIndexEngineModule; -import static org.elasticsearch.common.inject.Modules.*; +import static org.elasticsearch.common.inject.Modules.createModule; /** - * @author kimchy (shay.banon) + * */ public class IndexEngineModule extends AbstractModule implements SpawnModules { @@ -46,10 +46,12 @@ public class IndexEngineModule extends AbstractModule implements SpawnModules { this.settings = settings; } - @Override public Iterable spawnModules() { + @Override + public Iterable spawnModules() { return ImmutableList.of(createModule(settings.getAsClass(EngineSettings.ENGINE_TYPE, EngineSettings.DEFAULT_INDEX_ENGINE, "org.elasticsearch.index.engine.", "IndexEngineModule"), settings)); } - @Override protected void configure() { + @Override + protected void configure() { } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/engine/IndexFailedEngineException.java b/src/main/java/org/elasticsearch/index/engine/IndexFailedEngineException.java index 7d8e731f754..436d6a0a333 100644 --- a/src/main/java/org/elasticsearch/index/engine/IndexFailedEngineException.java +++ b/src/main/java/org/elasticsearch/index/engine/IndexFailedEngineException.java @@ -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.index.engine; import org.elasticsearch.index.shard.ShardId; /** - * @author kimchy (Shay Banon) + * */ public class IndexFailedEngineException extends EngineException { diff --git a/src/main/java/org/elasticsearch/index/engine/OptimizeFailedEngineException.java b/src/main/java/org/elasticsearch/index/engine/OptimizeFailedEngineException.java index a9a52c455bd..ba1f6f277f4 100644 --- a/src/main/java/org/elasticsearch/index/engine/OptimizeFailedEngineException.java +++ b/src/main/java/org/elasticsearch/index/engine/OptimizeFailedEngineException.java @@ -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.index.engine; import org.elasticsearch.index.shard.ShardId; /** - * @author kimchy (Shay Banon) + * */ public class OptimizeFailedEngineException extends EngineException { diff --git a/src/main/java/org/elasticsearch/index/engine/RecoveryEngineException.java b/src/main/java/org/elasticsearch/index/engine/RecoveryEngineException.java index 24c2467d426..4054804f3e7 100644 --- a/src/main/java/org/elasticsearch/index/engine/RecoveryEngineException.java +++ b/src/main/java/org/elasticsearch/index/engine/RecoveryEngineException.java @@ -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.index.engine; import org.elasticsearch.index.shard.ShardId; /** - * @author kimchy (Shay Banon) + * */ public class RecoveryEngineException extends EngineException { diff --git a/src/main/java/org/elasticsearch/index/engine/RefreshFailedEngineException.java b/src/main/java/org/elasticsearch/index/engine/RefreshFailedEngineException.java index b4f8dd5dc40..3a909cbb77e 100644 --- a/src/main/java/org/elasticsearch/index/engine/RefreshFailedEngineException.java +++ b/src/main/java/org/elasticsearch/index/engine/RefreshFailedEngineException.java @@ -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.index.engine; import org.elasticsearch.index.shard.ShardId; /** - * @author kimchy (Shay Banon) + * */ public class RefreshFailedEngineException extends EngineException { diff --git a/src/main/java/org/elasticsearch/index/engine/RollbackFailedEngineException.java b/src/main/java/org/elasticsearch/index/engine/RollbackFailedEngineException.java index 525ad9d4a05..65dddc0905f 100644 --- a/src/main/java/org/elasticsearch/index/engine/RollbackFailedEngineException.java +++ b/src/main/java/org/elasticsearch/index/engine/RollbackFailedEngineException.java @@ -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.index.engine; import org.elasticsearch.index.shard.ShardId; /** - * @author kimchy (Shay Banon) + * */ public class RollbackFailedEngineException extends EngineException { diff --git a/src/main/java/org/elasticsearch/index/engine/RollbackNotAllowedEngineException.java b/src/main/java/org/elasticsearch/index/engine/RollbackNotAllowedEngineException.java index 910600f366d..5412bd8dd09 100644 --- a/src/main/java/org/elasticsearch/index/engine/RollbackNotAllowedEngineException.java +++ b/src/main/java/org/elasticsearch/index/engine/RollbackNotAllowedEngineException.java @@ -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.index.engine; import org.elasticsearch.index.shard.ShardId; /** - * @author kimchy (Shay Banon) + * */ public class RollbackNotAllowedEngineException extends EngineException { diff --git a/src/main/java/org/elasticsearch/index/engine/Segment.java b/src/main/java/org/elasticsearch/index/engine/Segment.java index b0bff468ee8..bd10611e866 100644 --- a/src/main/java/org/elasticsearch/index/engine/Segment.java +++ b/src/main/java/org/elasticsearch/index/engine/Segment.java @@ -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 @@ -108,7 +108,8 @@ public class Segment implements Streamable { return sizeInBytes(); } - @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; @@ -119,7 +120,8 @@ public class Segment implements Streamable { return true; } - @Override public int hashCode() { + @Override + public int hashCode() { return name != null ? name.hashCode() : 0; } @@ -129,7 +131,8 @@ public class Segment implements Streamable { return segment; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { name = in.readUTF(); generation = Long.parseLong(name.substring(1), Character.MAX_RADIX); committed = in.readBoolean(); @@ -139,7 +142,8 @@ public class Segment implements Streamable { sizeInBytes = in.readLong(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(name); out.writeBoolean(committed); out.writeBoolean(search); diff --git a/src/main/java/org/elasticsearch/index/engine/SnapshotFailedEngineException.java b/src/main/java/org/elasticsearch/index/engine/SnapshotFailedEngineException.java index b61b7e71202..5af1a11e47c 100644 --- a/src/main/java/org/elasticsearch/index/engine/SnapshotFailedEngineException.java +++ b/src/main/java/org/elasticsearch/index/engine/SnapshotFailedEngineException.java @@ -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.index.engine; import org.elasticsearch.index.shard.ShardId; /** - * @author kimchy (Shay Banon) + * */ public class SnapshotFailedEngineException extends EngineException { diff --git a/src/main/java/org/elasticsearch/index/engine/VersionConflictEngineException.java b/src/main/java/org/elasticsearch/index/engine/VersionConflictEngineException.java index 2a504b88549..286260e0d79 100644 --- a/src/main/java/org/elasticsearch/index/engine/VersionConflictEngineException.java +++ b/src/main/java/org/elasticsearch/index/engine/VersionConflictEngineException.java @@ -23,7 +23,7 @@ import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.rest.RestStatus; /** - * @author kimchy (shay.banon) + * */ public class VersionConflictEngineException extends EngineException { @@ -31,7 +31,8 @@ public class VersionConflictEngineException extends EngineException { super(shardId, "[" + type + "][" + id + "]: version conflict, current [" + current + "], required [" + required + "]"); } - @Override public RestStatus status() { + @Override + public RestStatus status() { return RestStatus.CONFLICT; } } diff --git a/src/main/java/org/elasticsearch/index/engine/robin/RobinEngine.java b/src/main/java/org/elasticsearch/index/engine/robin/RobinEngine.java index dabce72259c..334782e32cc 100644 --- a/src/main/java/org/elasticsearch/index/engine/robin/RobinEngine.java +++ b/src/main/java/org/elasticsearch/index/engine/robin/RobinEngine.java @@ -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,14 +19,7 @@ package org.elasticsearch.index.engine.robin; -import org.apache.lucene.index.ExtendedIndexSearcher; -import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.IndexWriter; -import org.apache.lucene.index.IndexWriterConfig; -import org.apache.lucene.index.SegmentInfo; -import org.apache.lucene.index.SegmentInfos; -import org.apache.lucene.index.SegmentReader; -import org.apache.lucene.index.Term; +import org.apache.lucene.index.*; import org.apache.lucene.search.FilteredQuery; import org.apache.lucene.search.Query; import org.apache.lucene.store.AlreadyClosedException; @@ -67,11 +60,7 @@ import org.elasticsearch.index.translog.TranslogStreams; import org.elasticsearch.threadpool.ThreadPool; import java.io.IOException; -import java.util.Arrays; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.CopyOnWriteArrayList; @@ -81,11 +70,11 @@ import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; -import static org.elasticsearch.common.lucene.Lucene.*; -import static org.elasticsearch.common.util.concurrent.resource.AcquirableResourceFactory.*; +import static org.elasticsearch.common.lucene.Lucene.safeClose; +import static org.elasticsearch.common.util.concurrent.resource.AcquirableResourceFactory.newAcquirableResource; /** - * @author kimchy (shay.banon) + * */ public class RobinEngine extends AbstractIndexShardComponent implements Engine { @@ -161,12 +150,13 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine { private SegmentInfos lastCommittedSegmentInfos; - @Inject public RobinEngine(ShardId shardId, @IndexSettings Settings indexSettings, ThreadPool threadPool, - IndexSettingsService indexSettingsService, - Store store, SnapshotDeletionPolicy deletionPolicy, Translog translog, - MergePolicyProvider mergePolicyProvider, MergeSchedulerProvider mergeScheduler, - AnalysisService analysisService, SimilarityService similarityService, - BloomCache bloomCache) throws EngineException { + @Inject + public RobinEngine(ShardId shardId, @IndexSettings Settings indexSettings, ThreadPool threadPool, + IndexSettingsService indexSettingsService, + Store store, SnapshotDeletionPolicy deletionPolicy, Translog translog, + MergePolicyProvider mergePolicyProvider, MergeSchedulerProvider mergeScheduler, + AnalysisService analysisService, SimilarityService similarityService, + BloomCache bloomCache) throws EngineException { super(shardId, indexSettings); Preconditions.checkNotNull(store, "Store must be provided to the engine"); Preconditions.checkNotNull(deletionPolicy, "Snapshot deletion policy must be provided to the engine"); @@ -199,7 +189,8 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine { this.indexSettingsService.addListener(applySettings); } - @Override public void updateIndexingBufferSize(ByteSizeValue indexingBufferSize) { + @Override + public void updateIndexingBufferSize(ByteSizeValue indexingBufferSize) { ByteSizeValue preValue = this.indexingBufferSize; rwl.readLock().lock(); try { @@ -227,11 +218,13 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine { } } - @Override public void addFailedEngineListener(FailedEngineListener listener) { + @Override + public void addFailedEngineListener(FailedEngineListener listener) { failedEngineListeners.add(listener); } - @Override public void start() throws EngineException { + @Override + public void start() throws EngineException { rwl.writeLock().lock(); try { if (indexWriter != null) { @@ -288,7 +281,8 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine { } } - @Override public TimeValue defaultRefreshInterval() { + @Override + public TimeValue defaultRefreshInterval() { return new TimeValue(1, TimeUnit.SECONDS); } @@ -343,7 +337,8 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine { } } - @Override public void create(Create create) throws EngineException { + @Override + public void create(Create create) throws EngineException { rwl.readLock().lock(); try { IndexWriter writer = this.indexWriter; @@ -466,7 +461,8 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine { } } - @Override public void index(Index index) throws EngineException { + @Override + public void index(Index index) throws EngineException { rwl.readLock().lock(); try { IndexWriter writer = this.indexWriter; @@ -587,7 +583,8 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine { } } - @Override public void delete(Delete delete) throws EngineException { + @Override + public void delete(Delete delete) throws EngineException { rwl.readLock().lock(); try { IndexWriter writer = this.indexWriter; @@ -693,7 +690,8 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine { } } - @Override public void delete(DeleteByQuery delete) throws EngineException { + @Override + public void delete(DeleteByQuery delete) throws EngineException { rwl.readLock().lock(); try { IndexWriter writer = this.indexWriter; @@ -720,7 +718,8 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine { refreshVersioningTable(System.currentTimeMillis()); } - @Override public Searcher searcher() throws EngineException { + @Override + public Searcher searcher() throws EngineException { AcquirableResource holder; for (; ; ) { holder = this.nrtResource; @@ -732,15 +731,18 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine { return new RobinSearchResult(holder); } - @Override public boolean refreshNeeded() { + @Override + public boolean refreshNeeded() { return dirty; } - @Override public boolean possibleMergeNeeded() { + @Override + public boolean possibleMergeNeeded() { return this.possibleMergeNeeded; } - @Override public void refresh(Refresh refresh) throws EngineException { + @Override + public void refresh(Refresh refresh) throws EngineException { if (indexWriter == null) { throw new EngineClosedException(shardId); } @@ -794,7 +796,8 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine { } } - @Override public void flush(Flush flush) throws EngineException { + @Override + public void flush(Flush flush) throws EngineException { if (indexWriter == null) { throw new EngineClosedException(shardId, failedEngine); } @@ -947,7 +950,8 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine { } } - @Override public void maybeMerge() throws EngineException { + @Override + public void maybeMerge() throws EngineException { if (!possibleMergeNeeded) { return; } @@ -979,7 +983,8 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine { } } - @Override public void optimize(Optimize optimize) throws EngineException { + @Override + public void optimize(Optimize optimize) throws EngineException { if (optimize.flush()) { flush(new Flush().force(true)); } @@ -1030,7 +1035,8 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine { } } - @Override public T snapshot(SnapshotHandler snapshotHandler) throws EngineException { + @Override + public T snapshot(SnapshotHandler snapshotHandler) throws EngineException { SnapshotIndexCommit snapshotIndexCommit = null; Translog.Snapshot traslogSnapshot = null; rwl.readLock().lock(); @@ -1052,7 +1058,8 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine { } } - @Override public void recover(RecoveryHandler recoveryHandler) throws EngineException { + @Override + public void recover(RecoveryHandler recoveryHandler) throws EngineException { // take a write lock here so it won't happen while a flush is in progress // this means that next commits will not be allowed once the lock is released rwl.writeLock().lock(); @@ -1123,7 +1130,8 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine { } } - @Override public List segments() { + @Override + public List segments() { rwl.readLock().lock(); try { IndexWriter indexWriter = this.indexWriter; @@ -1184,7 +1192,8 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine { Segment[] segmentsArr = segments.values().toArray(new Segment[segments.values().size()]); Arrays.sort(segmentsArr, new Comparator() { - @Override public int compare(Segment o1, Segment o2) { + @Override + public int compare(Segment o1, Segment o2) { return (int) (o1.generation() - o2.generation()); } }); @@ -1195,7 +1204,8 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine { } } - @Override public void close() throws ElasticSearchException { + @Override + public void close() throws ElasticSearchException { rwl.writeLock().lock(); try { innerClose(); @@ -1319,7 +1329,8 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine { class ApplySettings implements IndexSettingsService.Listener { - @Override public void onRefreshSettings(Settings settings) { + @Override + public void onRefreshSettings(Settings settings) { long gcDeletesInMillis = indexSettings.getAsTime("index.gc_deletes", TimeValue.timeValueMillis(RobinEngine.this.gcDeletesInMillis)).millis(); if (gcDeletesInMillis != RobinEngine.this.gcDeletesInMillis) { logger.info("updating index.gc_deletes from [{}] to [{}]", TimeValue.timeValueMillis(RobinEngine.this.gcDeletesInMillis), TimeValue.timeValueMillis(gcDeletesInMillis)); @@ -1376,15 +1387,18 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine { this.nrtHolder = nrtHolder; } - @Override public IndexReader reader() { + @Override + public IndexReader reader() { return nrtHolder.resource().reader(); } - @Override public ExtendedIndexSearcher searcher() { + @Override + public ExtendedIndexSearcher searcher() { return nrtHolder.resource().searcher(); } - @Override public boolean release() throws ElasticSearchException { + @Override + public boolean release() throws ElasticSearchException { nrtHolder.release(); return true; } diff --git a/src/main/java/org/elasticsearch/index/engine/robin/RobinEngineModule.java b/src/main/java/org/elasticsearch/index/engine/robin/RobinEngineModule.java index 272842fc827..987e2345b2a 100644 --- a/src/main/java/org/elasticsearch/index/engine/robin/RobinEngineModule.java +++ b/src/main/java/org/elasticsearch/index/engine/robin/RobinEngineModule.java @@ -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,11 +23,12 @@ import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.index.engine.Engine; /** - * @author kimchy (Shay Banon) + * */ public class RobinEngineModule extends AbstractModule { - @Override protected void configure() { + @Override + protected void configure() { bind(Engine.class).to(RobinEngine.class).asEagerSingleton(); } } diff --git a/src/main/java/org/elasticsearch/index/engine/robin/RobinIndexEngine.java b/src/main/java/org/elasticsearch/index/engine/robin/RobinIndexEngine.java index 8aff8ba501a..d64ed0f88e6 100644 --- a/src/main/java/org/elasticsearch/index/engine/robin/RobinIndexEngine.java +++ b/src/main/java/org/elasticsearch/index/engine/robin/RobinIndexEngine.java @@ -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,10 +26,10 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.engine.IndexEngine; import org.elasticsearch.index.settings.IndexSettings; -import static org.elasticsearch.common.settings.ImmutableSettings.Builder.*; +import static org.elasticsearch.common.settings.ImmutableSettings.Builder.EMPTY_SETTINGS; /** - * @author kimchy (shay.banon) + * */ public class RobinIndexEngine extends AbstractIndexComponent implements IndexEngine { @@ -37,10 +37,12 @@ public class RobinIndexEngine extends AbstractIndexComponent implements IndexEng this(index, EMPTY_SETTINGS); } - @Inject public RobinIndexEngine(Index index, @IndexSettings Settings indexSettings) { + @Inject + public RobinIndexEngine(Index index, @IndexSettings Settings indexSettings) { super(index, indexSettings); } - @Override public void close() { + @Override + public void close() { } } diff --git a/src/main/java/org/elasticsearch/index/engine/robin/RobinIndexEngineModule.java b/src/main/java/org/elasticsearch/index/engine/robin/RobinIndexEngineModule.java index c6ad9ece5e1..1f56e038d35 100644 --- a/src/main/java/org/elasticsearch/index/engine/robin/RobinIndexEngineModule.java +++ b/src/main/java/org/elasticsearch/index/engine/robin/RobinIndexEngineModule.java @@ -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,11 +23,12 @@ import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.index.engine.IndexEngine; /** - * @author kimchy (shay.banon) + * */ public class RobinIndexEngineModule extends AbstractModule { - @Override protected void configure() { + @Override + protected void configure() { bind(IndexEngine.class).to(RobinIndexEngine.class).asEagerSingleton(); } } diff --git a/src/main/java/org/elasticsearch/index/field/data/DocFieldData.java b/src/main/java/org/elasticsearch/index/field/data/DocFieldData.java index b09fb283d91..8c4f834ad63 100644 --- a/src/main/java/org/elasticsearch/index/field/data/DocFieldData.java +++ b/src/main/java/org/elasticsearch/index/field/data/DocFieldData.java @@ -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.index.field.data; /** - * @author kimchy (shay.banon) + * */ public abstract class DocFieldData { diff --git a/src/main/java/org/elasticsearch/index/field/data/FieldData.java b/src/main/java/org/elasticsearch/index/field/data/FieldData.java index 082f38d6c95..337e47c76a8 100644 --- a/src/main/java/org/elasticsearch/index/field/data/FieldData.java +++ b/src/main/java/org/elasticsearch/index/field/data/FieldData.java @@ -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,14 +25,15 @@ import org.elasticsearch.common.thread.ThreadLocals; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ // General TODOs on FieldData // TODO Optimize the order (both int[] and int[][] when they are sparse, create an Order abstraction) public abstract class FieldData { private final ThreadLocal> cachedDocFieldData = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { return new ThreadLocals.CleanableValue(createFieldData()); } }; diff --git a/src/main/java/org/elasticsearch/index/field/data/FieldDataType.java b/src/main/java/org/elasticsearch/index/field/data/FieldDataType.java index dfbbb5f3375..55e160b42f8 100644 --- a/src/main/java/org/elasticsearch/index/field/data/FieldDataType.java +++ b/src/main/java/org/elasticsearch/index/field/data/FieldDataType.java @@ -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,7 +34,7 @@ import org.elasticsearch.index.field.data.strings.StringFieldDataType; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public interface FieldDataType { diff --git a/src/main/java/org/elasticsearch/index/field/data/NumericDocFieldData.java b/src/main/java/org/elasticsearch/index/field/data/NumericDocFieldData.java index 9b92b35ee96..c1783c01e61 100644 --- a/src/main/java/org/elasticsearch/index/field/data/NumericDocFieldData.java +++ b/src/main/java/org/elasticsearch/index/field/data/NumericDocFieldData.java @@ -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.index.field.data; /** - * @author kimchy (shay.banon) + * */ public class NumericDocFieldData extends DocFieldData { diff --git a/src/main/java/org/elasticsearch/index/field/data/NumericFieldData.java b/src/main/java/org/elasticsearch/index/field/data/NumericFieldData.java index d69427e6af6..42acb4f82d5 100644 --- a/src/main/java/org/elasticsearch/index/field/data/NumericFieldData.java +++ b/src/main/java/org/elasticsearch/index/field/data/NumericFieldData.java @@ -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.index.field.data; /** - * @author kimchy (shay.banon) + * */ public abstract class NumericFieldData extends FieldData { @@ -86,7 +86,8 @@ public abstract class NumericFieldData extends return (short) intValue(docId); } - @Override public Doc docFieldData(int docId) { + @Override + public Doc docFieldData(int docId) { return super.docFieldData(docId); } diff --git a/src/main/java/org/elasticsearch/index/field/data/bytes/ByteDocFieldData.java b/src/main/java/org/elasticsearch/index/field/data/bytes/ByteDocFieldData.java index a6fa888167f..6a6fac8519a 100644 --- a/src/main/java/org/elasticsearch/index/field/data/bytes/ByteDocFieldData.java +++ b/src/main/java/org/elasticsearch/index/field/data/bytes/ByteDocFieldData.java @@ -22,7 +22,7 @@ package org.elasticsearch.index.field.data.bytes; import org.elasticsearch.index.field.data.NumericDocFieldData; /** - * @author kimchy (shay.banon) + * */ public class ByteDocFieldData extends NumericDocFieldData { diff --git a/src/main/java/org/elasticsearch/index/field/data/bytes/ByteFieldData.java b/src/main/java/org/elasticsearch/index/field/data/bytes/ByteFieldData.java index 123ac5cb808..c2069ea3992 100644 --- a/src/main/java/org/elasticsearch/index/field/data/bytes/ByteFieldData.java +++ b/src/main/java/org/elasticsearch/index/field/data/bytes/ByteFieldData.java @@ -19,10 +19,10 @@ package org.elasticsearch.index.field.data.bytes; +import gnu.trove.list.array.TByteArrayList; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.FieldCache; import org.elasticsearch.common.RamUsage; -import org.elasticsearch.common.trove.list.array.TByteArrayList; import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.NumericFieldData; import org.elasticsearch.index.field.data.support.FieldDataLoader; @@ -30,7 +30,7 @@ import org.elasticsearch.index.field.data.support.FieldDataLoader; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public abstract class ByteFieldData extends NumericFieldData { @@ -43,7 +43,8 @@ public abstract class ByteFieldData extends NumericFieldData { this.values = values; } - @Override protected long computeSizeInBytes() { + @Override + protected long computeSizeInBytes() { return 1 * values.length + RamUsage.NUM_BYTES_ARRAY_HEADER; } @@ -55,49 +56,60 @@ public abstract class ByteFieldData extends NumericFieldData { abstract public byte[] values(int docId); - @Override public ByteDocFieldData docFieldData(int docId) { + @Override + public ByteDocFieldData docFieldData(int docId) { return super.docFieldData(docId); } - @Override protected ByteDocFieldData createFieldData() { + @Override + protected ByteDocFieldData createFieldData() { return new ByteDocFieldData(this); } - @Override public void forEachValue(StringValueProc proc) { + @Override + public void forEachValue(StringValueProc proc) { for (int i = 1; i < values.length; i++) { proc.onValue(Byte.toString(values[i])); } } - @Override public String stringValue(int docId) { + @Override + public String stringValue(int docId) { return Byte.toString(value(docId)); } - @Override public byte byteValue(int docId) { + @Override + public byte byteValue(int docId) { return value(docId); } - @Override public short shortValue(int docId) { + @Override + public short shortValue(int docId) { return value(docId); } - @Override public int intValue(int docId) { + @Override + public int intValue(int docId) { return (int) value(docId); } - @Override public long longValue(int docId) { + @Override + public long longValue(int docId) { return (long) value(docId); } - @Override public float floatValue(int docId) { + @Override + public float floatValue(int docId) { return (float) value(docId); } - @Override public double doubleValue(int docId) { + @Override + public double doubleValue(int docId) { return (double) value(docId); } - @Override public FieldDataType type() { + @Override + public FieldDataType type() { return FieldDataType.DefaultTypes.BYTE; } @@ -133,15 +145,18 @@ public abstract class ByteFieldData extends NumericFieldData { terms.add((byte) 0); } - @Override public void collectTerm(String term) { + @Override + public void collectTerm(String term) { terms.add((byte) FieldCache.NUMERIC_UTILS_INT_PARSER.parseInt(term)); } - @Override public ByteFieldData buildSingleValue(String field, int[] ordinals) { + @Override + public ByteFieldData buildSingleValue(String field, int[] ordinals) { return new SingleValueByteFieldData(field, ordinals, terms.toArray()); } - @Override public ByteFieldData buildMultiValue(String field, int[][] ordinals) { + @Override + public ByteFieldData buildMultiValue(String field, int[][] ordinals) { return new MultiValueByteFieldData(field, ordinals, terms.toArray()); } } diff --git a/src/main/java/org/elasticsearch/index/field/data/bytes/ByteFieldDataComparator.java b/src/main/java/org/elasticsearch/index/field/data/bytes/ByteFieldDataComparator.java index 1123dd9a182..e192e2fc106 100644 --- a/src/main/java/org/elasticsearch/index/field/data/bytes/ByteFieldDataComparator.java +++ b/src/main/java/org/elasticsearch/index/field/data/bytes/ByteFieldDataComparator.java @@ -24,7 +24,7 @@ import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.support.NumericFieldDataComparator; /** - * @author kimchy (shay.banon) + * */ // LUCENE MONITOR: Monitor against FieldComparator.Short public class ByteFieldDataComparator extends NumericFieldDataComparator { @@ -37,27 +37,33 @@ public class ByteFieldDataComparator extends NumericFieldDataComparator { values = new byte[numHits]; } - @Override public FieldDataType fieldDataType() { + @Override + public FieldDataType fieldDataType() { return FieldDataType.DefaultTypes.BYTE; } - @Override public int compare(int slot1, int slot2) { + @Override + public int compare(int slot1, int slot2) { return values[slot1] - values[slot2]; } - @Override public int compareBottom(int doc) { + @Override + public int compareBottom(int doc) { return bottom - currentFieldData.byteValue(doc); } - @Override public void copy(int slot, int doc) { + @Override + public void copy(int slot, int doc) { values[slot] = currentFieldData.byteValue(doc); } - @Override public void setBottom(final int bottom) { + @Override + public void setBottom(final int bottom) { this.bottom = values[bottom]; } - @Override public Comparable value(int slot) { + @Override + public Comparable value(int slot) { return Byte.valueOf(values[slot]); } } diff --git a/src/main/java/org/elasticsearch/index/field/data/bytes/ByteFieldDataMissingComparator.java b/src/main/java/org/elasticsearch/index/field/data/bytes/ByteFieldDataMissingComparator.java index ee06dfb74db..491b2eeea46 100644 --- a/src/main/java/org/elasticsearch/index/field/data/bytes/ByteFieldDataMissingComparator.java +++ b/src/main/java/org/elasticsearch/index/field/data/bytes/ByteFieldDataMissingComparator.java @@ -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.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.support.NumericFieldDataComparator; /** - * @author kimchy (shay.banon) + * */ // LUCENE MONITOR: Monitor against FieldComparator.Short public class ByteFieldDataMissingComparator extends NumericFieldDataComparator { @@ -39,15 +39,18 @@ public class ByteFieldDataMissingComparator extends NumericFieldDataComparator { this.missingValue = missingValue; } - @Override public FieldDataType fieldDataType() { + @Override + public FieldDataType fieldDataType() { return FieldDataType.DefaultTypes.BYTE; } - @Override public int compare(int slot1, int slot2) { + @Override + public int compare(int slot1, int slot2) { return values[slot1] - values[slot2]; } - @Override public int compareBottom(int doc) { + @Override + public int compareBottom(int doc) { byte value = missingValue; if (currentFieldData.hasValue(doc)) { value = currentFieldData.byteValue(doc); @@ -55,7 +58,8 @@ public class ByteFieldDataMissingComparator extends NumericFieldDataComparator { return bottom - value; } - @Override public void copy(int slot, int doc) { + @Override + public void copy(int slot, int doc) { byte value = missingValue; if (currentFieldData.hasValue(doc)) { value = currentFieldData.byteValue(doc); @@ -63,11 +67,13 @@ public class ByteFieldDataMissingComparator extends NumericFieldDataComparator { values[slot] = value; } - @Override public void setBottom(final int bottom) { + @Override + public void setBottom(final int bottom) { this.bottom = values[bottom]; } - @Override public Comparable value(int slot) { + @Override + public Comparable value(int slot) { return Byte.valueOf(values[slot]); } } diff --git a/src/main/java/org/elasticsearch/index/field/data/bytes/ByteFieldDataType.java b/src/main/java/org/elasticsearch/index/field/data/bytes/ByteFieldDataType.java index e1c2bc5c9c2..5e9264873a5 100644 --- a/src/main/java/org/elasticsearch/index/field/data/bytes/ByteFieldDataType.java +++ b/src/main/java/org/elasticsearch/index/field/data/bytes/ByteFieldDataType.java @@ -28,56 +28,66 @@ import org.elasticsearch.index.field.data.FieldDataType; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class ByteFieldDataType implements FieldDataType { - @Override public ExtendedFieldComparatorSource newFieldComparatorSource(final FieldDataCache cache, final String missing) { + @Override + public ExtendedFieldComparatorSource newFieldComparatorSource(final FieldDataCache cache, final String missing) { if (missing == null) { return new ExtendedFieldComparatorSource() { - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + @Override + public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { return new ByteFieldDataComparator(numHits, fieldname, cache); } - @Override public int reducedType() { + @Override + public int reducedType() { return SortField.BYTE; } }; } if (missing.equals("_last")) { return new ExtendedFieldComparatorSource() { - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + @Override + public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { return new ByteFieldDataMissingComparator(numHits, fieldname, cache, reversed ? Byte.MIN_VALUE : Byte.MAX_VALUE); } - @Override public int reducedType() { + @Override + public int reducedType() { return SortField.BYTE; } }; } if (missing.equals("_first")) { return new ExtendedFieldComparatorSource() { - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + @Override + public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { return new ByteFieldDataMissingComparator(numHits, fieldname, cache, reversed ? Byte.MAX_VALUE : Byte.MIN_VALUE); } - @Override public int reducedType() { + @Override + public int reducedType() { return SortField.BYTE; } }; } return new ExtendedFieldComparatorSource() { - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + @Override + public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { return new ByteFieldDataMissingComparator(numHits, fieldname, cache, Byte.parseByte(missing)); } - @Override public int reducedType() { + @Override + public int reducedType() { return SortField.BYTE; } }; } - @Override public ByteFieldData load(IndexReader reader, String fieldName) throws IOException { + @Override + public ByteFieldData load(IndexReader reader, String fieldName) throws IOException { return ByteFieldData.load(reader, fieldName); } } diff --git a/src/main/java/org/elasticsearch/index/field/data/bytes/MultiValueByteFieldData.java b/src/main/java/org/elasticsearch/index/field/data/bytes/MultiValueByteFieldData.java index 553b82a238b..9e43ebe27e4 100644 --- a/src/main/java/org/elasticsearch/index/field/data/bytes/MultiValueByteFieldData.java +++ b/src/main/java/org/elasticsearch/index/field/data/bytes/MultiValueByteFieldData.java @@ -24,14 +24,15 @@ import org.elasticsearch.common.thread.ThreadLocals; import org.elasticsearch.index.field.data.doubles.DoubleFieldData; /** - * @author kimchy (shay.banon) + * */ public class MultiValueByteFieldData extends ByteFieldData { private static final int VALUE_CACHE_SIZE = 10; private ThreadLocal> doublesValuesCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { double[][] value = new double[VALUE_CACHE_SIZE][]; for (int i = 0; i < value.length; i++) { value[i] = new double[i]; @@ -41,7 +42,8 @@ public class MultiValueByteFieldData extends ByteFieldData { }; private ThreadLocal> valuesCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { byte[][] value = new byte[VALUE_CACHE_SIZE][]; for (int i = 0; i < value.length; i++) { value[i] = new byte[i]; @@ -58,7 +60,8 @@ public class MultiValueByteFieldData extends ByteFieldData { this.ordinals = ordinals; } - @Override protected long computeSizeInBytes() { + @Override + protected long computeSizeInBytes() { long size = super.computeSizeInBytes(); size += RamUsage.NUM_BYTES_ARRAY_HEADER; // for the top level array for (int[] ordinal : ordinals) { @@ -67,11 +70,13 @@ public class MultiValueByteFieldData extends ByteFieldData { return size; } - @Override public boolean multiValued() { + @Override + public boolean multiValued() { return true; } - @Override public boolean hasValue(int docId) { + @Override + public boolean hasValue(int docId) { for (int[] ordinal : ordinals) { if (ordinal[docId] != 0) { return true; @@ -80,7 +85,8 @@ public class MultiValueByteFieldData extends ByteFieldData { return false; } - @Override public void forEachValueInDoc(int docId, StringValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, StringValueInDocProc proc) { boolean found = false; for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -94,7 +100,8 @@ public class MultiValueByteFieldData extends ByteFieldData { } } - @Override public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) { for (int[] ordinal : ordinals) { int loc = ordinal[docId]; if (loc != 0) { @@ -103,7 +110,8 @@ public class MultiValueByteFieldData extends ByteFieldData { } } - @Override public void forEachValueInDoc(int docId, LongValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, LongValueInDocProc proc) { for (int[] ordinal : ordinals) { int loc = ordinal[docId]; if (loc != 0) { @@ -112,7 +120,8 @@ public class MultiValueByteFieldData extends ByteFieldData { } } - @Override public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) { boolean found = false; for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -126,7 +135,8 @@ public class MultiValueByteFieldData extends ByteFieldData { } } - @Override public void forEachValueInDoc(int docId, MissingLongValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, MissingLongValueInDocProc proc) { boolean found = false; for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -140,7 +150,8 @@ public class MultiValueByteFieldData extends ByteFieldData { } } - @Override public void forEachValueInDoc(int docId, ValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, ValueInDocProc proc) { boolean found = false; for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -154,7 +165,8 @@ public class MultiValueByteFieldData extends ByteFieldData { } } - @Override public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { + @Override + public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { boolean found = false; for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -168,7 +180,8 @@ public class MultiValueByteFieldData extends ByteFieldData { } } - @Override public double[] doubleValues(int docId) { + @Override + public double[] doubleValues(int docId) { int length = 0; for (int[] ordinal : ordinals) { if (ordinal[docId] != 0) { @@ -194,7 +207,8 @@ public class MultiValueByteFieldData extends ByteFieldData { return doubles; } - @Override public byte value(int docId) { + @Override + public byte value(int docId) { for (int[] ordinal : ordinals) { int loc = ordinal[docId]; if (loc != 0) { @@ -204,7 +218,8 @@ public class MultiValueByteFieldData extends ByteFieldData { return 0; } - @Override public byte[] values(int docId) { + @Override + public byte[] values(int docId) { int length = 0; for (int[] ordinal : ordinals) { if (ordinal[docId] != 0) { diff --git a/src/main/java/org/elasticsearch/index/field/data/bytes/SingleValueByteFieldData.java b/src/main/java/org/elasticsearch/index/field/data/bytes/SingleValueByteFieldData.java index 28f2aea34b3..85a7d2234df 100644 --- a/src/main/java/org/elasticsearch/index/field/data/bytes/SingleValueByteFieldData.java +++ b/src/main/java/org/elasticsearch/index/field/data/bytes/SingleValueByteFieldData.java @@ -24,18 +24,20 @@ import org.elasticsearch.common.thread.ThreadLocals; import org.elasticsearch.index.field.data.doubles.DoubleFieldData; /** - * @author kimchy (shay.banon) + * */ public class SingleValueByteFieldData extends ByteFieldData { private ThreadLocal> doublesValuesCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { return new ThreadLocals.CleanableValue(new double[1]); } }; private ThreadLocal> valuesCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { return new ThreadLocals.CleanableValue(new byte[1]); } }; @@ -48,20 +50,24 @@ public class SingleValueByteFieldData extends ByteFieldData { this.ordinals = ordinals; } - @Override protected long computeSizeInBytes() { + @Override + protected long computeSizeInBytes() { return super.computeSizeInBytes() + RamUsage.NUM_BYTES_INT * ordinals.length + RamUsage.NUM_BYTES_ARRAY_HEADER; } - @Override public boolean multiValued() { + @Override + public boolean multiValued() { return false; } - @Override public boolean hasValue(int docId) { + @Override + public boolean hasValue(int docId) { return ordinals[docId] != 0; } - @Override public void forEachValueInDoc(int docId, StringValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, StringValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { proc.onMissing(docId); @@ -70,7 +76,8 @@ public class SingleValueByteFieldData extends ByteFieldData { proc.onValue(docId, Byte.toString(values[loc])); } - @Override public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { return; @@ -78,7 +85,8 @@ public class SingleValueByteFieldData extends ByteFieldData { proc.onValue(docId, values[loc]); } - @Override public void forEachValueInDoc(int docId, LongValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, LongValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { return; @@ -86,7 +94,8 @@ public class SingleValueByteFieldData extends ByteFieldData { proc.onValue(docId, values[loc]); } - @Override public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { proc.onMissing(docId); @@ -95,7 +104,8 @@ public class SingleValueByteFieldData extends ByteFieldData { proc.onValue(docId, values[loc]); } - @Override public void forEachValueInDoc(int docId, MissingLongValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, MissingLongValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { proc.onMissing(docId); @@ -104,7 +114,8 @@ public class SingleValueByteFieldData extends ByteFieldData { proc.onValue(docId, values[loc]); } - @Override public void forEachValueInDoc(int docId, ValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, ValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { proc.onMissing(docId); @@ -113,15 +124,18 @@ public class SingleValueByteFieldData extends ByteFieldData { proc.onValue(docId, values[loc]); } - @Override public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { + @Override + public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { proc.onOrdinal(docId, ordinals[docId]); } - @Override public byte value(int docId) { + @Override + public byte value(int docId) { return values[ordinals[docId]]; } - @Override public double[] doubleValues(int docId) { + @Override + public double[] doubleValues(int docId) { int loc = ordinals[docId]; if (loc == 0) { return DoubleFieldData.EMPTY_DOUBLE_ARRAY; @@ -131,7 +145,8 @@ public class SingleValueByteFieldData extends ByteFieldData { return ret; } - @Override public byte[] values(int docId) { + @Override + public byte[] values(int docId) { int loc = ordinals[docId]; if (loc == 0) { return EMPTY_BYTE_ARRAY; diff --git a/src/main/java/org/elasticsearch/index/field/data/doubles/DoubleDocFieldData.java b/src/main/java/org/elasticsearch/index/field/data/doubles/DoubleDocFieldData.java index 2d6c49d065b..07eda570f0b 100644 --- a/src/main/java/org/elasticsearch/index/field/data/doubles/DoubleDocFieldData.java +++ b/src/main/java/org/elasticsearch/index/field/data/doubles/DoubleDocFieldData.java @@ -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.index.field.data.doubles; import org.elasticsearch.index.field.data.NumericDocFieldData; /** - * @author kimchy (shay.banon) + * */ public class DoubleDocFieldData extends NumericDocFieldData { diff --git a/src/main/java/org/elasticsearch/index/field/data/doubles/DoubleFieldData.java b/src/main/java/org/elasticsearch/index/field/data/doubles/DoubleFieldData.java index c253e0175f1..f6906de98b0 100644 --- a/src/main/java/org/elasticsearch/index/field/data/doubles/DoubleFieldData.java +++ b/src/main/java/org/elasticsearch/index/field/data/doubles/DoubleFieldData.java @@ -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.index.field.data.doubles; +import gnu.trove.list.array.TDoubleArrayList; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.FieldCache; import org.elasticsearch.common.RamUsage; -import org.elasticsearch.common.trove.list.array.TDoubleArrayList; import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.NumericFieldData; import org.elasticsearch.index.field.data.support.FieldDataLoader; @@ -30,7 +30,7 @@ import org.elasticsearch.index.field.data.support.FieldDataLoader; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public abstract class DoubleFieldData extends NumericFieldData { @@ -43,7 +43,8 @@ public abstract class DoubleFieldData extends NumericFieldData v2) { @@ -53,7 +55,8 @@ public class DoubleFieldDataComparator extends NumericFieldDataComparator { } } - @Override public int compareBottom(int doc) { + @Override + public int compareBottom(int doc) { final double v2 = currentFieldData.doubleValue(doc); if (bottom > v2) { return 1; @@ -64,15 +67,18 @@ public class DoubleFieldDataComparator extends NumericFieldDataComparator { } } - @Override public void copy(int slot, int doc) { + @Override + public void copy(int slot, int doc) { values[slot] = currentFieldData.doubleValue(doc); } - @Override public void setBottom(final int bottom) { + @Override + public void setBottom(final int bottom) { this.bottom = values[bottom]; } - @Override public Comparable value(int slot) { + @Override + public Comparable value(int slot) { return Double.valueOf(values[slot]); } } diff --git a/src/main/java/org/elasticsearch/index/field/data/doubles/DoubleFieldDataMissingComparator.java b/src/main/java/org/elasticsearch/index/field/data/doubles/DoubleFieldDataMissingComparator.java index e9b5485d435..4e36137b7d6 100644 --- a/src/main/java/org/elasticsearch/index/field/data/doubles/DoubleFieldDataMissingComparator.java +++ b/src/main/java/org/elasticsearch/index/field/data/doubles/DoubleFieldDataMissingComparator.java @@ -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.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.support.NumericFieldDataComparator; /** - * @author kimchy (shay.banon) + * */ // LUCENE MONITOR: Monitor against FieldComparator.Double public class DoubleFieldDataMissingComparator extends NumericFieldDataComparator { @@ -39,11 +39,13 @@ public class DoubleFieldDataMissingComparator extends NumericFieldDataComparator this.missingValue = missingValue; } - @Override public FieldDataType fieldDataType() { + @Override + public FieldDataType fieldDataType() { return FieldDataType.DefaultTypes.DOUBLE; } - @Override public int compare(int slot1, int slot2) { + @Override + public int compare(int slot1, int slot2) { final double v1 = values[slot1]; final double v2 = values[slot2]; if (v1 > v2) { @@ -55,7 +57,8 @@ public class DoubleFieldDataMissingComparator extends NumericFieldDataComparator } } - @Override public int compareBottom(int doc) { + @Override + public int compareBottom(int doc) { double v2 = missingValue; if (currentFieldData.hasValue(doc)) { v2 = currentFieldData.doubleValue(doc); @@ -69,7 +72,8 @@ public class DoubleFieldDataMissingComparator extends NumericFieldDataComparator } } - @Override public void copy(int slot, int doc) { + @Override + public void copy(int slot, int doc) { double value = missingValue; if (currentFieldData.hasValue(doc)) { value = currentFieldData.doubleValue(doc); @@ -77,11 +81,13 @@ public class DoubleFieldDataMissingComparator extends NumericFieldDataComparator values[slot] = value; } - @Override public void setBottom(final int bottom) { + @Override + public void setBottom(final int bottom) { this.bottom = values[bottom]; } - @Override public Comparable value(int slot) { + @Override + public Comparable value(int slot) { return Double.valueOf(values[slot]); } } diff --git a/src/main/java/org/elasticsearch/index/field/data/doubles/DoubleFieldDataType.java b/src/main/java/org/elasticsearch/index/field/data/doubles/DoubleFieldDataType.java index 2923f2226cb..7c3830316f6 100644 --- a/src/main/java/org/elasticsearch/index/field/data/doubles/DoubleFieldDataType.java +++ b/src/main/java/org/elasticsearch/index/field/data/doubles/DoubleFieldDataType.java @@ -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,56 +28,66 @@ import org.elasticsearch.index.field.data.FieldDataType; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class DoubleFieldDataType implements FieldDataType { - @Override public ExtendedFieldComparatorSource newFieldComparatorSource(final FieldDataCache cache, final String missing) { + @Override + public ExtendedFieldComparatorSource newFieldComparatorSource(final FieldDataCache cache, final String missing) { if (missing == null) { return new ExtendedFieldComparatorSource() { - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + @Override + public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { return new DoubleFieldDataComparator(numHits, fieldname, cache); } - @Override public int reducedType() { + @Override + public int reducedType() { return SortField.DOUBLE; } }; } if (missing.equals("_last")) { return new ExtendedFieldComparatorSource() { - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + @Override + public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { return new DoubleFieldDataMissingComparator(numHits, fieldname, cache, reversed ? Double.NEGATIVE_INFINITY : Double.POSITIVE_INFINITY); } - @Override public int reducedType() { + @Override + public int reducedType() { return SortField.DOUBLE; } }; } if (missing.equals("_first")) { return new ExtendedFieldComparatorSource() { - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + @Override + public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { return new DoubleFieldDataMissingComparator(numHits, fieldname, cache, reversed ? Double.POSITIVE_INFINITY : Double.NEGATIVE_INFINITY); } - @Override public int reducedType() { + @Override + public int reducedType() { return SortField.DOUBLE; } }; } return new ExtendedFieldComparatorSource() { - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + @Override + public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { return new DoubleFieldDataMissingComparator(numHits, fieldname, cache, Double.parseDouble(missing)); } - @Override public int reducedType() { + @Override + public int reducedType() { return SortField.DOUBLE; } }; } - @Override public DoubleFieldData load(IndexReader reader, String fieldName) throws IOException { + @Override + public DoubleFieldData load(IndexReader reader, String fieldName) throws IOException { return DoubleFieldData.load(reader, fieldName); } } diff --git a/src/main/java/org/elasticsearch/index/field/data/doubles/MultiValueDoubleFieldData.java b/src/main/java/org/elasticsearch/index/field/data/doubles/MultiValueDoubleFieldData.java index 2f6290d850c..bf36be1f6a8 100644 --- a/src/main/java/org/elasticsearch/index/field/data/doubles/MultiValueDoubleFieldData.java +++ b/src/main/java/org/elasticsearch/index/field/data/doubles/MultiValueDoubleFieldData.java @@ -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,14 +23,15 @@ import org.elasticsearch.common.RamUsage; import org.elasticsearch.common.thread.ThreadLocals; /** - * @author kimchy (shay.banon) + * */ public class MultiValueDoubleFieldData extends DoubleFieldData { private static final int VALUE_CACHE_SIZE = 10; private ThreadLocal> valuesCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { double[][] value = new double[VALUE_CACHE_SIZE][]; for (int i = 0; i < value.length; i++) { value[i] = new double[i]; @@ -47,7 +48,8 @@ public class MultiValueDoubleFieldData extends DoubleFieldData { this.ordinals = ordinals; } - @Override protected long computeSizeInBytes() { + @Override + protected long computeSizeInBytes() { long size = super.computeSizeInBytes(); size += RamUsage.NUM_BYTES_ARRAY_HEADER; // for the top level array for (int[] ordinal : ordinals) { @@ -56,11 +58,13 @@ public class MultiValueDoubleFieldData extends DoubleFieldData { return size; } - @Override public boolean multiValued() { + @Override + public boolean multiValued() { return true; } - @Override public boolean hasValue(int docId) { + @Override + public boolean hasValue(int docId) { for (int[] ordinal : ordinals) { if (ordinal[docId] != 0) { return true; @@ -69,7 +73,8 @@ public class MultiValueDoubleFieldData extends DoubleFieldData { return false; } - @Override public void forEachValueInDoc(int docId, StringValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, StringValueInDocProc proc) { boolean found = false; for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -83,7 +88,8 @@ public class MultiValueDoubleFieldData extends DoubleFieldData { } } - @Override public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) { for (int[] ordinal : ordinals) { int loc = ordinal[docId]; if (loc != 0) { @@ -92,7 +98,8 @@ public class MultiValueDoubleFieldData extends DoubleFieldData { } } - @Override public void forEachValueInDoc(int docId, LongValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, LongValueInDocProc proc) { for (int[] ordinal : ordinals) { int loc = ordinal[docId]; if (loc != 0) { @@ -101,7 +108,8 @@ public class MultiValueDoubleFieldData extends DoubleFieldData { } } - @Override public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) { boolean found = false; for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -115,7 +123,8 @@ public class MultiValueDoubleFieldData extends DoubleFieldData { } } - @Override public void forEachValueInDoc(int docId, MissingLongValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, MissingLongValueInDocProc proc) { boolean found = false; for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -129,7 +138,8 @@ public class MultiValueDoubleFieldData extends DoubleFieldData { } } - @Override public void forEachValueInDoc(int docId, ValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, ValueInDocProc proc) { boolean found = false; for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -143,7 +153,8 @@ public class MultiValueDoubleFieldData extends DoubleFieldData { } } - @Override public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { + @Override + public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { boolean found = false; for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -157,11 +168,13 @@ public class MultiValueDoubleFieldData extends DoubleFieldData { } } - @Override public double[] doubleValues(int docId) { + @Override + public double[] doubleValues(int docId) { return values(docId); } - @Override public double value(int docId) { + @Override + public double value(int docId) { for (int[] ordinal : ordinals) { int loc = ordinal[docId]; if (loc != 0) { @@ -171,7 +184,8 @@ public class MultiValueDoubleFieldData extends DoubleFieldData { return 0; } - @Override public double[] values(int docId) { + @Override + public double[] values(int docId) { int length = 0; for (int[] ordinal : ordinals) { if (ordinal[docId] != 0) { diff --git a/src/main/java/org/elasticsearch/index/field/data/doubles/SingleValueDoubleFieldData.java b/src/main/java/org/elasticsearch/index/field/data/doubles/SingleValueDoubleFieldData.java index 268ab88b513..5c4dcaf7f7a 100644 --- a/src/main/java/org/elasticsearch/index/field/data/doubles/SingleValueDoubleFieldData.java +++ b/src/main/java/org/elasticsearch/index/field/data/doubles/SingleValueDoubleFieldData.java @@ -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,12 +23,13 @@ import org.elasticsearch.common.RamUsage; import org.elasticsearch.common.thread.ThreadLocals; /** - * @author kimchy (shay.banon) + * */ public class SingleValueDoubleFieldData extends DoubleFieldData { private ThreadLocal> valuesCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { return new ThreadLocals.CleanableValue(new double[1]); } }; @@ -41,20 +42,24 @@ public class SingleValueDoubleFieldData extends DoubleFieldData { this.ordinals = ordinals; } - @Override protected long computeSizeInBytes() { + @Override + protected long computeSizeInBytes() { return super.computeSizeInBytes() + RamUsage.NUM_BYTES_INT * ordinals.length + RamUsage.NUM_BYTES_ARRAY_HEADER; } - @Override public boolean multiValued() { + @Override + public boolean multiValued() { return false; } - @Override public boolean hasValue(int docId) { + @Override + public boolean hasValue(int docId) { return ordinals[docId] != 0; } - @Override public void forEachValueInDoc(int docId, StringValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, StringValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { proc.onMissing(docId); @@ -63,7 +68,8 @@ public class SingleValueDoubleFieldData extends DoubleFieldData { proc.onValue(docId, Double.toString(values[loc])); } - @Override public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { return; @@ -71,7 +77,8 @@ public class SingleValueDoubleFieldData extends DoubleFieldData { proc.onValue(docId, values[loc]); } - @Override public void forEachValueInDoc(int docId, LongValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, LongValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { return; @@ -79,7 +86,8 @@ public class SingleValueDoubleFieldData extends DoubleFieldData { proc.onValue(docId, (long) values[loc]); } - @Override public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { proc.onMissing(docId); @@ -88,7 +96,8 @@ public class SingleValueDoubleFieldData extends DoubleFieldData { proc.onValue(docId, values[loc]); } - @Override public void forEachValueInDoc(int docId, MissingLongValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, MissingLongValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { proc.onMissing(docId); @@ -97,7 +106,8 @@ public class SingleValueDoubleFieldData extends DoubleFieldData { proc.onValue(docId, (long) values[loc]); } - @Override public void forEachValueInDoc(int docId, ValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, ValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { proc.onMissing(docId); @@ -106,19 +116,23 @@ public class SingleValueDoubleFieldData extends DoubleFieldData { proc.onValue(docId, values[loc]); } - @Override public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { + @Override + public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { proc.onOrdinal(docId, ordinals[docId]); } - @Override public double[] doubleValues(int docId) { + @Override + public double[] doubleValues(int docId) { return values(docId); } - @Override public double value(int docId) { + @Override + public double value(int docId) { return values[ordinals[docId]]; } - @Override public double[] values(int docId) { + @Override + public double[] values(int docId) { int loc = ordinals[docId]; if (loc == 0) { return EMPTY_DOUBLE_ARRAY; diff --git a/src/main/java/org/elasticsearch/index/field/data/floats/FloatDocFieldData.java b/src/main/java/org/elasticsearch/index/field/data/floats/FloatDocFieldData.java index 193186464cd..ceca0f0b3a3 100644 --- a/src/main/java/org/elasticsearch/index/field/data/floats/FloatDocFieldData.java +++ b/src/main/java/org/elasticsearch/index/field/data/floats/FloatDocFieldData.java @@ -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.index.field.data.floats; import org.elasticsearch.index.field.data.NumericDocFieldData; /** - * @author kimchy (shay.banon) + * */ public class FloatDocFieldData extends NumericDocFieldData { diff --git a/src/main/java/org/elasticsearch/index/field/data/floats/FloatFieldData.java b/src/main/java/org/elasticsearch/index/field/data/floats/FloatFieldData.java index d732a46d738..36f69229ccd 100644 --- a/src/main/java/org/elasticsearch/index/field/data/floats/FloatFieldData.java +++ b/src/main/java/org/elasticsearch/index/field/data/floats/FloatFieldData.java @@ -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.index.field.data.floats; +import gnu.trove.list.array.TFloatArrayList; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.FieldCache; import org.elasticsearch.common.RamUsage; -import org.elasticsearch.common.trove.list.array.TFloatArrayList; import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.NumericFieldData; import org.elasticsearch.index.field.data.support.FieldDataLoader; @@ -30,7 +30,7 @@ import org.elasticsearch.index.field.data.support.FieldDataLoader; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public abstract class FloatFieldData extends NumericFieldData { @@ -43,7 +43,8 @@ public abstract class FloatFieldData extends NumericFieldData this.values = values; } - @Override protected long computeSizeInBytes() { + @Override + protected long computeSizeInBytes() { return RamUsage.NUM_BYTES_FLOAT * values.length + RamUsage.NUM_BYTES_ARRAY_HEADER; } @@ -55,49 +56,60 @@ public abstract class FloatFieldData extends NumericFieldData abstract public float[] values(int docId); - @Override public FloatDocFieldData docFieldData(int docId) { + @Override + public FloatDocFieldData docFieldData(int docId) { return super.docFieldData(docId); } - @Override protected FloatDocFieldData createFieldData() { + @Override + protected FloatDocFieldData createFieldData() { return new FloatDocFieldData(this); } - @Override public String stringValue(int docId) { + @Override + public String stringValue(int docId) { return Float.toString(value(docId)); } - @Override public void forEachValue(StringValueProc proc) { + @Override + public void forEachValue(StringValueProc proc) { for (int i = 1; i < values.length; i++) { proc.onValue(Float.toString(values[i])); } } - @Override public byte byteValue(int docId) { + @Override + public byte byteValue(int docId) { return (byte) value(docId); } - @Override public short shortValue(int docId) { + @Override + public short shortValue(int docId) { return (short) value(docId); } - @Override public int intValue(int docId) { + @Override + public int intValue(int docId) { return (int) value(docId); } - @Override public long longValue(int docId) { + @Override + public long longValue(int docId) { return (long) value(docId); } - @Override public float floatValue(int docId) { + @Override + public float floatValue(int docId) { return value(docId); } - @Override public double doubleValue(int docId) { + @Override + public double doubleValue(int docId) { return (double) value(docId); } - @Override public FieldDataType type() { + @Override + public FieldDataType type() { return FieldDataType.DefaultTypes.FLOAT; } @@ -133,15 +145,18 @@ public abstract class FloatFieldData extends NumericFieldData terms.add(0); } - @Override public void collectTerm(String term) { + @Override + public void collectTerm(String term) { terms.add(FieldCache.NUMERIC_UTILS_FLOAT_PARSER.parseFloat(term)); } - @Override public FloatFieldData buildSingleValue(String field, int[] ordinals) { + @Override + public FloatFieldData buildSingleValue(String field, int[] ordinals) { return new SingleValueFloatFieldData(field, ordinals, terms.toArray()); } - @Override public FloatFieldData buildMultiValue(String field, int[][] ordinals) { + @Override + public FloatFieldData buildMultiValue(String field, int[][] ordinals) { return new MultiValueFloatFieldData(field, ordinals, terms.toArray()); } } diff --git a/src/main/java/org/elasticsearch/index/field/data/floats/FloatFieldDataComparator.java b/src/main/java/org/elasticsearch/index/field/data/floats/FloatFieldDataComparator.java index e8d3328c103..7c76685c867 100644 --- a/src/main/java/org/elasticsearch/index/field/data/floats/FloatFieldDataComparator.java +++ b/src/main/java/org/elasticsearch/index/field/data/floats/FloatFieldDataComparator.java @@ -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.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.support.NumericFieldDataComparator; /** - * @author kimchy (shay.banon) + * */ // LUCENE MONITOR - Monitor against FieldComparator.Float public class FloatFieldDataComparator extends NumericFieldDataComparator { @@ -37,11 +37,13 @@ public class FloatFieldDataComparator extends NumericFieldDataComparator { values = new float[numHits]; } - @Override public FieldDataType fieldDataType() { + @Override + public FieldDataType fieldDataType() { return FieldDataType.DefaultTypes.FLOAT; } - @Override public int compare(int slot1, int slot2) { + @Override + public int compare(int slot1, int slot2) { // TODO: are there sneaky non-branch ways to compute // sign of float? final float v1 = values[slot1]; @@ -55,7 +57,8 @@ public class FloatFieldDataComparator extends NumericFieldDataComparator { } } - @Override public int compareBottom(int doc) { + @Override + public int compareBottom(int doc) { // TODO: are there sneaky non-branch ways to compute // sign of float? final float v2 = currentFieldData.floatValue(doc); @@ -73,11 +76,13 @@ public class FloatFieldDataComparator extends NumericFieldDataComparator { values[slot] = currentFieldData.floatValue(doc); } - @Override public void setBottom(final int bottom) { + @Override + public void setBottom(final int bottom) { this.bottom = values[bottom]; } - @Override public Comparable value(int slot) { + @Override + public Comparable value(int slot) { return Float.valueOf(values[slot]); } } diff --git a/src/main/java/org/elasticsearch/index/field/data/floats/FloatFieldDataMissingComparator.java b/src/main/java/org/elasticsearch/index/field/data/floats/FloatFieldDataMissingComparator.java index f3644ad2f38..df2bd5f621d 100644 --- a/src/main/java/org/elasticsearch/index/field/data/floats/FloatFieldDataMissingComparator.java +++ b/src/main/java/org/elasticsearch/index/field/data/floats/FloatFieldDataMissingComparator.java @@ -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.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.support.NumericFieldDataComparator; /** - * @author kimchy (shay.banon) + * */ // LUCENE MONITOR - Monitor against FieldComparator.Float public class FloatFieldDataMissingComparator extends NumericFieldDataComparator { @@ -39,11 +39,13 @@ public class FloatFieldDataMissingComparator extends NumericFieldDataComparator this.missingValue = missingValue; } - @Override public FieldDataType fieldDataType() { + @Override + public FieldDataType fieldDataType() { return FieldDataType.DefaultTypes.FLOAT; } - @Override public int compare(int slot1, int slot2) { + @Override + public int compare(int slot1, int slot2) { // TODO: are there sneaky non-branch ways to compute // sign of float? final float v1 = values[slot1]; @@ -57,7 +59,8 @@ public class FloatFieldDataMissingComparator extends NumericFieldDataComparator } } - @Override public int compareBottom(int doc) { + @Override + public int compareBottom(int doc) { // TODO: are there sneaky non-branch ways to compute // sign of float? float v2 = missingValue; @@ -82,11 +85,13 @@ public class FloatFieldDataMissingComparator extends NumericFieldDataComparator values[slot] = value; } - @Override public void setBottom(final int bottom) { + @Override + public void setBottom(final int bottom) { this.bottom = values[bottom]; } - @Override public Comparable value(int slot) { + @Override + public Comparable value(int slot) { return Float.valueOf(values[slot]); } } diff --git a/src/main/java/org/elasticsearch/index/field/data/floats/FloatFieldDataType.java b/src/main/java/org/elasticsearch/index/field/data/floats/FloatFieldDataType.java index 41f1e2c186f..b2c830e39b6 100644 --- a/src/main/java/org/elasticsearch/index/field/data/floats/FloatFieldDataType.java +++ b/src/main/java/org/elasticsearch/index/field/data/floats/FloatFieldDataType.java @@ -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,56 +28,66 @@ import org.elasticsearch.index.field.data.FieldDataType; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class FloatFieldDataType implements FieldDataType { - @Override public ExtendedFieldComparatorSource newFieldComparatorSource(final FieldDataCache cache, final String missing) { + @Override + public ExtendedFieldComparatorSource newFieldComparatorSource(final FieldDataCache cache, final String missing) { if (missing == null) { return new ExtendedFieldComparatorSource() { - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + @Override + public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { return new FloatFieldDataComparator(numHits, fieldname, cache); } - @Override public int reducedType() { + @Override + public int reducedType() { return SortField.FLOAT; } }; } if (missing.equals("_last")) { return new ExtendedFieldComparatorSource() { - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + @Override + public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { return new FloatFieldDataMissingComparator(numHits, fieldname, cache, reversed ? Float.NEGATIVE_INFINITY : Float.POSITIVE_INFINITY); } - @Override public int reducedType() { + @Override + public int reducedType() { return SortField.FLOAT; } }; } if (missing.equals("_first")) { return new ExtendedFieldComparatorSource() { - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + @Override + public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { return new FloatFieldDataMissingComparator(numHits, fieldname, cache, reversed ? Float.POSITIVE_INFINITY : Float.NEGATIVE_INFINITY); } - @Override public int reducedType() { + @Override + public int reducedType() { return SortField.FLOAT; } }; } return new ExtendedFieldComparatorSource() { - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + @Override + public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { return new FloatFieldDataMissingComparator(numHits, fieldname, cache, Float.parseFloat(missing)); } - @Override public int reducedType() { + @Override + public int reducedType() { return SortField.FLOAT; } }; } - @Override public FloatFieldData load(IndexReader reader, String fieldName) throws IOException { + @Override + public FloatFieldData load(IndexReader reader, String fieldName) throws IOException { return FloatFieldData.load(reader, fieldName); } } diff --git a/src/main/java/org/elasticsearch/index/field/data/floats/MultiValueFloatFieldData.java b/src/main/java/org/elasticsearch/index/field/data/floats/MultiValueFloatFieldData.java index 6ca2cdf9719..e08204cd11d 100644 --- a/src/main/java/org/elasticsearch/index/field/data/floats/MultiValueFloatFieldData.java +++ b/src/main/java/org/elasticsearch/index/field/data/floats/MultiValueFloatFieldData.java @@ -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,14 +24,15 @@ import org.elasticsearch.common.thread.ThreadLocals; import org.elasticsearch.index.field.data.doubles.DoubleFieldData; /** - * @author kimchy (shay.banon) + * */ public class MultiValueFloatFieldData extends FloatFieldData { private static final int VALUE_CACHE_SIZE = 10; private ThreadLocal> doublesValuesCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { double[][] value = new double[VALUE_CACHE_SIZE][]; for (int i = 0; i < value.length; i++) { value[i] = new double[i]; @@ -41,7 +42,8 @@ public class MultiValueFloatFieldData extends FloatFieldData { }; private ThreadLocal> valuesCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { float[][] value = new float[VALUE_CACHE_SIZE][]; for (int i = 0; i < value.length; i++) { value[i] = new float[i]; @@ -58,7 +60,8 @@ public class MultiValueFloatFieldData extends FloatFieldData { this.ordinals = ordinals; } - @Override protected long computeSizeInBytes() { + @Override + protected long computeSizeInBytes() { long size = super.computeSizeInBytes(); size += RamUsage.NUM_BYTES_ARRAY_HEADER; // for the top level array for (int[] ordinal : ordinals) { @@ -67,11 +70,13 @@ public class MultiValueFloatFieldData extends FloatFieldData { return size; } - @Override public boolean multiValued() { + @Override + public boolean multiValued() { return true; } - @Override public boolean hasValue(int docId) { + @Override + public boolean hasValue(int docId) { for (int[] ordinal : ordinals) { if (ordinal[docId] != 0) { return true; @@ -80,7 +85,8 @@ public class MultiValueFloatFieldData extends FloatFieldData { return false; } - @Override public void forEachValueInDoc(int docId, StringValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, StringValueInDocProc proc) { boolean found = false; for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -94,7 +100,8 @@ public class MultiValueFloatFieldData extends FloatFieldData { } } - @Override public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) { for (int[] ordinal : ordinals) { int loc = ordinal[docId]; if (loc != 0) { @@ -103,7 +110,8 @@ public class MultiValueFloatFieldData extends FloatFieldData { } } - @Override public void forEachValueInDoc(int docId, LongValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, LongValueInDocProc proc) { for (int[] ordinal : ordinals) { int loc = ordinal[docId]; if (loc != 0) { @@ -112,7 +120,8 @@ public class MultiValueFloatFieldData extends FloatFieldData { } } - @Override public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) { boolean found = false; for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -126,7 +135,8 @@ public class MultiValueFloatFieldData extends FloatFieldData { } } - @Override public void forEachValueInDoc(int docId, MissingLongValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, MissingLongValueInDocProc proc) { boolean found = false; for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -140,7 +150,8 @@ public class MultiValueFloatFieldData extends FloatFieldData { } } - @Override public void forEachValueInDoc(int docId, ValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, ValueInDocProc proc) { boolean found = false; for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -154,7 +165,8 @@ public class MultiValueFloatFieldData extends FloatFieldData { } } - @Override public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { + @Override + public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { boolean found = false; for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -168,7 +180,8 @@ public class MultiValueFloatFieldData extends FloatFieldData { } } - @Override public double[] doubleValues(int docId) { + @Override + public double[] doubleValues(int docId) { int length = 0; for (int[] ordinal : ordinals) { if (ordinal[docId] != 0) { @@ -194,7 +207,8 @@ public class MultiValueFloatFieldData extends FloatFieldData { return doubles; } - @Override public float value(int docId) { + @Override + public float value(int docId) { for (int[] ordinal : ordinals) { int loc = ordinal[docId]; if (loc != 0) { @@ -204,7 +218,8 @@ public class MultiValueFloatFieldData extends FloatFieldData { return 0; } - @Override public float[] values(int docId) { + @Override + public float[] values(int docId) { int length = 0; for (int[] ordinal : ordinals) { if (ordinal[docId] != 0) { diff --git a/src/main/java/org/elasticsearch/index/field/data/floats/SingleValueFloatFieldData.java b/src/main/java/org/elasticsearch/index/field/data/floats/SingleValueFloatFieldData.java index ce3d289a555..80276769182 100644 --- a/src/main/java/org/elasticsearch/index/field/data/floats/SingleValueFloatFieldData.java +++ b/src/main/java/org/elasticsearch/index/field/data/floats/SingleValueFloatFieldData.java @@ -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,18 +24,20 @@ import org.elasticsearch.common.thread.ThreadLocals; import org.elasticsearch.index.field.data.doubles.DoubleFieldData; /** - * @author kimchy (shay.banon) + * */ public class SingleValueFloatFieldData extends FloatFieldData { private ThreadLocal> doublesValuesCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { return new ThreadLocals.CleanableValue(new double[1]); } }; private ThreadLocal> valuesCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { return new ThreadLocals.CleanableValue(new float[1]); } }; @@ -48,20 +50,24 @@ public class SingleValueFloatFieldData extends FloatFieldData { this.ordinals = ordinals; } - @Override protected long computeSizeInBytes() { + @Override + protected long computeSizeInBytes() { return super.computeSizeInBytes() + RamUsage.NUM_BYTES_INT * ordinals.length + RamUsage.NUM_BYTES_ARRAY_HEADER; } - @Override public boolean multiValued() { + @Override + public boolean multiValued() { return false; } - @Override public boolean hasValue(int docId) { + @Override + public boolean hasValue(int docId) { return ordinals[docId] != 0; } - @Override public void forEachValueInDoc(int docId, StringValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, StringValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { proc.onMissing(docId); @@ -70,7 +76,8 @@ public class SingleValueFloatFieldData extends FloatFieldData { proc.onValue(docId, Float.toString(values[loc])); } - @Override public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { return; @@ -78,7 +85,8 @@ public class SingleValueFloatFieldData extends FloatFieldData { proc.onValue(docId, values[loc]); } - @Override public void forEachValueInDoc(int docId, LongValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, LongValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { return; @@ -86,7 +94,8 @@ public class SingleValueFloatFieldData extends FloatFieldData { proc.onValue(docId, (long) values[loc]); } - @Override public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { proc.onMissing(docId); @@ -95,7 +104,8 @@ public class SingleValueFloatFieldData extends FloatFieldData { proc.onValue(docId, values[loc]); } - @Override public void forEachValueInDoc(int docId, MissingLongValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, MissingLongValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { proc.onMissing(docId); @@ -104,7 +114,8 @@ public class SingleValueFloatFieldData extends FloatFieldData { proc.onValue(docId, (long) values[loc]); } - @Override public void forEachValueInDoc(int docId, ValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, ValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { proc.onMissing(docId); @@ -113,11 +124,13 @@ public class SingleValueFloatFieldData extends FloatFieldData { proc.onValue(docId, values[loc]); } - @Override public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { + @Override + public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { proc.onOrdinal(docId, ordinals[docId]); } - @Override public double[] doubleValues(int docId) { + @Override + public double[] doubleValues(int docId) { int loc = ordinals[docId]; if (loc == 0) { return DoubleFieldData.EMPTY_DOUBLE_ARRAY; @@ -127,11 +140,13 @@ public class SingleValueFloatFieldData extends FloatFieldData { return ret; } - @Override public float value(int docId) { + @Override + public float value(int docId) { return values[ordinals[docId]]; } - @Override public float[] values(int docId) { + @Override + public float[] values(int docId) { int loc = ordinals[docId]; if (loc == 0) { return EMPTY_FLOAT_ARRAY; diff --git a/src/main/java/org/elasticsearch/index/field/data/ints/IntDocFieldData.java b/src/main/java/org/elasticsearch/index/field/data/ints/IntDocFieldData.java index c4b5bb4c96a..3ebdb4a6c90 100644 --- a/src/main/java/org/elasticsearch/index/field/data/ints/IntDocFieldData.java +++ b/src/main/java/org/elasticsearch/index/field/data/ints/IntDocFieldData.java @@ -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.index.field.data.ints; import org.elasticsearch.index.field.data.NumericDocFieldData; /** - * @author kimchy (shay.banon) + * */ public class IntDocFieldData extends NumericDocFieldData { diff --git a/src/main/java/org/elasticsearch/index/field/data/ints/IntFieldData.java b/src/main/java/org/elasticsearch/index/field/data/ints/IntFieldData.java index eab29451f23..0bed01060fb 100644 --- a/src/main/java/org/elasticsearch/index/field/data/ints/IntFieldData.java +++ b/src/main/java/org/elasticsearch/index/field/data/ints/IntFieldData.java @@ -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.index.field.data.ints; +import gnu.trove.list.array.TIntArrayList; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.FieldCache; import org.elasticsearch.common.RamUsage; -import org.elasticsearch.common.trove.list.array.TIntArrayList; import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.NumericFieldData; import org.elasticsearch.index.field.data.support.FieldDataLoader; @@ -30,7 +30,7 @@ import org.elasticsearch.index.field.data.support.FieldDataLoader; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public abstract class IntFieldData extends NumericFieldData { @@ -43,7 +43,8 @@ public abstract class IntFieldData extends NumericFieldData { this.values = values; } - @Override protected long computeSizeInBytes() { + @Override + protected long computeSizeInBytes() { return RamUsage.NUM_BYTES_INT * values.length + RamUsage.NUM_BYTES_ARRAY_HEADER; } @@ -55,49 +56,60 @@ public abstract class IntFieldData extends NumericFieldData { abstract public int[] values(int docId); - @Override public IntDocFieldData docFieldData(int docId) { + @Override + public IntDocFieldData docFieldData(int docId) { return super.docFieldData(docId); } - @Override protected IntDocFieldData createFieldData() { + @Override + protected IntDocFieldData createFieldData() { return new IntDocFieldData(this); } - @Override public String stringValue(int docId) { + @Override + public String stringValue(int docId) { return Integer.toString(value(docId)); } - @Override public void forEachValue(StringValueProc proc) { + @Override + public void forEachValue(StringValueProc proc) { for (int i = 1; i < values.length; i++) { proc.onValue(Integer.toString(values[i])); } } - @Override public byte byteValue(int docId) { + @Override + public byte byteValue(int docId) { return (byte) value(docId); } - @Override public short shortValue(int docId) { + @Override + public short shortValue(int docId) { return (short) value(docId); } - @Override public int intValue(int docId) { + @Override + public int intValue(int docId) { return value(docId); } - @Override public long longValue(int docId) { + @Override + public long longValue(int docId) { return (long) value(docId); } - @Override public float floatValue(int docId) { + @Override + public float floatValue(int docId) { return (float) value(docId); } - @Override public double doubleValue(int docId) { + @Override + public double doubleValue(int docId) { return (double) value(docId); } - @Override public FieldDataType type() { + @Override + public FieldDataType type() { return FieldDataType.DefaultTypes.INT; } @@ -133,15 +145,18 @@ public abstract class IntFieldData extends NumericFieldData { terms.add(0); } - @Override public void collectTerm(String term) { + @Override + public void collectTerm(String term) { terms.add(FieldCache.NUMERIC_UTILS_INT_PARSER.parseInt(term)); } - @Override public IntFieldData buildSingleValue(String field, int[] ordinals) { + @Override + public IntFieldData buildSingleValue(String field, int[] ordinals) { return new SingleValueIntFieldData(field, ordinals, terms.toArray()); } - @Override public IntFieldData buildMultiValue(String field, int[][] ordinals) { + @Override + public IntFieldData buildMultiValue(String field, int[][] ordinals) { return new MultiValueIntFieldData(field, ordinals, terms.toArray()); } } diff --git a/src/main/java/org/elasticsearch/index/field/data/ints/IntFieldDataComparator.java b/src/main/java/org/elasticsearch/index/field/data/ints/IntFieldDataComparator.java index 68007c133b0..548180687cd 100644 --- a/src/main/java/org/elasticsearch/index/field/data/ints/IntFieldDataComparator.java +++ b/src/main/java/org/elasticsearch/index/field/data/ints/IntFieldDataComparator.java @@ -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.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.support.NumericFieldDataComparator; /** - * @author kimchy (shay.banon) + * */ // LUCENE MONITOR - Monitor against FieldComparator.Int public class IntFieldDataComparator extends NumericFieldDataComparator { @@ -38,11 +38,13 @@ public class IntFieldDataComparator extends NumericFieldDataComparator { values = new int[numHits]; } - @Override public FieldDataType fieldDataType() { + @Override + public FieldDataType fieldDataType() { return FieldDataType.DefaultTypes.INT; } - @Override public int compare(int slot1, int slot2) { + @Override + public int compare(int slot1, int slot2) { // TODO: there are sneaky non-branch ways to compute // -1/+1/0 sign // Cannot return values[slot1] - values[slot2] because that @@ -58,7 +60,8 @@ public class IntFieldDataComparator extends NumericFieldDataComparator { } } - @Override public int compareBottom(int doc) { + @Override + public int compareBottom(int doc) { // TODO: there are sneaky non-branch ways to compute // -1/+1/0 sign // Cannot return bottom - values[slot2] because that @@ -74,15 +77,18 @@ public class IntFieldDataComparator extends NumericFieldDataComparator { } } - @Override public void copy(int slot, int doc) { + @Override + public void copy(int slot, int doc) { values[slot] = currentFieldData.intValue(doc); } - @Override public void setBottom(final int bottom) { + @Override + public void setBottom(final int bottom) { this.bottom = values[bottom]; } - @Override public Comparable value(int slot) { + @Override + public Comparable value(int slot) { return Integer.valueOf(values[slot]); } } diff --git a/src/main/java/org/elasticsearch/index/field/data/ints/IntFieldDataMissingComparator.java b/src/main/java/org/elasticsearch/index/field/data/ints/IntFieldDataMissingComparator.java index 1721b525f17..d5955ba00ec 100644 --- a/src/main/java/org/elasticsearch/index/field/data/ints/IntFieldDataMissingComparator.java +++ b/src/main/java/org/elasticsearch/index/field/data/ints/IntFieldDataMissingComparator.java @@ -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.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.support.NumericFieldDataComparator; /** - * @author kimchy (shay.banon) + * */ // LUCENE MONITOR - Monitor against FieldComparator.Int public class IntFieldDataMissingComparator extends NumericFieldDataComparator { @@ -40,11 +40,13 @@ public class IntFieldDataMissingComparator extends NumericFieldDataComparator { this.missingValue = missingValue; } - @Override public FieldDataType fieldDataType() { + @Override + public FieldDataType fieldDataType() { return FieldDataType.DefaultTypes.INT; } - @Override public int compare(int slot1, int slot2) { + @Override + public int compare(int slot1, int slot2) { // TODO: there are sneaky non-branch ways to compute // -1/+1/0 sign // Cannot return values[slot1] - values[slot2] because that @@ -60,7 +62,8 @@ public class IntFieldDataMissingComparator extends NumericFieldDataComparator { } } - @Override public int compareBottom(int doc) { + @Override + public int compareBottom(int doc) { // TODO: there are sneaky non-branch ways to compute // -1/+1/0 sign // Cannot return bottom - values[slot2] because that @@ -79,7 +82,8 @@ public class IntFieldDataMissingComparator extends NumericFieldDataComparator { } } - @Override public void copy(int slot, int doc) { + @Override + public void copy(int slot, int doc) { int value = missingValue; if (currentFieldData.hasValue(doc)) { value = currentFieldData.intValue(doc); @@ -87,11 +91,13 @@ public class IntFieldDataMissingComparator extends NumericFieldDataComparator { values[slot] = value; } - @Override public void setBottom(final int bottom) { + @Override + public void setBottom(final int bottom) { this.bottom = values[bottom]; } - @Override public Comparable value(int slot) { + @Override + public Comparable value(int slot) { return Integer.valueOf(values[slot]); } } diff --git a/src/main/java/org/elasticsearch/index/field/data/ints/IntFieldDataType.java b/src/main/java/org/elasticsearch/index/field/data/ints/IntFieldDataType.java index 1be489ff75f..bd3614a9f0f 100644 --- a/src/main/java/org/elasticsearch/index/field/data/ints/IntFieldDataType.java +++ b/src/main/java/org/elasticsearch/index/field/data/ints/IntFieldDataType.java @@ -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,56 +28,66 @@ import org.elasticsearch.index.field.data.FieldDataType; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class IntFieldDataType implements FieldDataType { - @Override public ExtendedFieldComparatorSource newFieldComparatorSource(final FieldDataCache cache, final String missing) { + @Override + public ExtendedFieldComparatorSource newFieldComparatorSource(final FieldDataCache cache, final String missing) { if (missing == null) { return new ExtendedFieldComparatorSource() { - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + @Override + public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { return new IntFieldDataComparator(numHits, fieldname, cache); } - @Override public int reducedType() { + @Override + public int reducedType() { return SortField.INT; } }; } if (missing.equals("_last")) { return new ExtendedFieldComparatorSource() { - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + @Override + public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { return new IntFieldDataMissingComparator(numHits, fieldname, cache, reversed ? Integer.MIN_VALUE : Integer.MAX_VALUE); } - @Override public int reducedType() { + @Override + public int reducedType() { return SortField.INT; } }; } if (missing.equals("_first")) { return new ExtendedFieldComparatorSource() { - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + @Override + public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { return new IntFieldDataMissingComparator(numHits, fieldname, cache, reversed ? Integer.MAX_VALUE : Integer.MIN_VALUE); } - @Override public int reducedType() { + @Override + public int reducedType() { return SortField.INT; } }; } return new ExtendedFieldComparatorSource() { - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + @Override + public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { return new IntFieldDataMissingComparator(numHits, fieldname, cache, Integer.parseInt(missing)); } - @Override public int reducedType() { + @Override + public int reducedType() { return SortField.INT; } }; } - @Override public IntFieldData load(IndexReader reader, String fieldName) throws IOException { + @Override + public IntFieldData load(IndexReader reader, String fieldName) throws IOException { return IntFieldData.load(reader, fieldName); } } diff --git a/src/main/java/org/elasticsearch/index/field/data/ints/MultiValueIntFieldData.java b/src/main/java/org/elasticsearch/index/field/data/ints/MultiValueIntFieldData.java index 38d89ad641d..5fd13dfcfc8 100644 --- a/src/main/java/org/elasticsearch/index/field/data/ints/MultiValueIntFieldData.java +++ b/src/main/java/org/elasticsearch/index/field/data/ints/MultiValueIntFieldData.java @@ -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,14 +24,15 @@ import org.elasticsearch.common.thread.ThreadLocals; import org.elasticsearch.index.field.data.doubles.DoubleFieldData; /** - * @author kimchy (shay.banon) + * */ public class MultiValueIntFieldData extends IntFieldData { private static final int VALUE_CACHE_SIZE = 10; private ThreadLocal> doublesValuesCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { double[][] value = new double[VALUE_CACHE_SIZE][]; for (int i = 0; i < value.length; i++) { value[i] = new double[i]; @@ -41,7 +42,8 @@ public class MultiValueIntFieldData extends IntFieldData { }; private ThreadLocal> valuesCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { int[][] value = new int[VALUE_CACHE_SIZE][]; for (int i = 0; i < value.length; i++) { value[i] = new int[i]; @@ -58,7 +60,8 @@ public class MultiValueIntFieldData extends IntFieldData { this.ordinals = ordinals; } - @Override protected long computeSizeInBytes() { + @Override + protected long computeSizeInBytes() { long size = super.computeSizeInBytes(); size += RamUsage.NUM_BYTES_ARRAY_HEADER; // for the top level array for (int[] ordinal : ordinals) { @@ -67,11 +70,13 @@ public class MultiValueIntFieldData extends IntFieldData { return size; } - @Override public boolean multiValued() { + @Override + public boolean multiValued() { return true; } - @Override public boolean hasValue(int docId) { + @Override + public boolean hasValue(int docId) { for (int[] ordinal : ordinals) { if (ordinal[docId] != 0) { return true; @@ -80,7 +85,8 @@ public class MultiValueIntFieldData extends IntFieldData { return false; } - @Override public void forEachValueInDoc(int docId, StringValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, StringValueInDocProc proc) { boolean found = false; for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -94,7 +100,8 @@ public class MultiValueIntFieldData extends IntFieldData { } } - @Override public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) { for (int[] ordinal : ordinals) { int loc = ordinal[docId]; if (loc != 0) { @@ -103,7 +110,8 @@ public class MultiValueIntFieldData extends IntFieldData { } } - @Override public void forEachValueInDoc(int docId, LongValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, LongValueInDocProc proc) { for (int[] ordinal : ordinals) { int loc = ordinal[docId]; if (loc != 0) { @@ -112,7 +120,8 @@ public class MultiValueIntFieldData extends IntFieldData { } } - @Override public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) { boolean found = false; for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -126,7 +135,8 @@ public class MultiValueIntFieldData extends IntFieldData { } } - @Override public void forEachValueInDoc(int docId, MissingLongValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, MissingLongValueInDocProc proc) { boolean found = false; for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -140,7 +150,8 @@ public class MultiValueIntFieldData extends IntFieldData { } } - @Override public void forEachValueInDoc(int docId, ValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, ValueInDocProc proc) { boolean found = false; for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -154,7 +165,8 @@ public class MultiValueIntFieldData extends IntFieldData { } } - @Override public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { + @Override + public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { boolean found = false; for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -168,7 +180,8 @@ public class MultiValueIntFieldData extends IntFieldData { } } - @Override public double[] doubleValues(int docId) { + @Override + public double[] doubleValues(int docId) { int length = 0; for (int[] ordinal : ordinals) { if (ordinal[docId] != 0) { @@ -194,7 +207,8 @@ public class MultiValueIntFieldData extends IntFieldData { return doubles; } - @Override public int value(int docId) { + @Override + public int value(int docId) { for (int[] ordinal : ordinals) { int loc = ordinal[docId]; if (loc != 0) { @@ -204,7 +218,8 @@ public class MultiValueIntFieldData extends IntFieldData { return 0; } - @Override public int[] values(int docId) { + @Override + public int[] values(int docId) { int length = 0; for (int[] ordinal : ordinals) { if (ordinal[docId] != 0) { diff --git a/src/main/java/org/elasticsearch/index/field/data/ints/SingleValueIntFieldData.java b/src/main/java/org/elasticsearch/index/field/data/ints/SingleValueIntFieldData.java index 901062aa06a..e23bd19bd50 100644 --- a/src/main/java/org/elasticsearch/index/field/data/ints/SingleValueIntFieldData.java +++ b/src/main/java/org/elasticsearch/index/field/data/ints/SingleValueIntFieldData.java @@ -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,18 +24,20 @@ import org.elasticsearch.common.thread.ThreadLocals; import org.elasticsearch.index.field.data.doubles.DoubleFieldData; /** - * @author kimchy (shay.banon) + * */ public class SingleValueIntFieldData extends IntFieldData { private ThreadLocal> doublesValuesCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { return new ThreadLocals.CleanableValue(new double[1]); } }; private ThreadLocal> valuesCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { return new ThreadLocals.CleanableValue(new int[1]); } }; @@ -48,20 +50,24 @@ public class SingleValueIntFieldData extends IntFieldData { this.ordinals = ordinals; } - @Override protected long computeSizeInBytes() { + @Override + protected long computeSizeInBytes() { return super.computeSizeInBytes() + RamUsage.NUM_BYTES_INT * ordinals.length + RamUsage.NUM_BYTES_ARRAY_HEADER; } - @Override public boolean multiValued() { + @Override + public boolean multiValued() { return false; } - @Override public boolean hasValue(int docId) { + @Override + public boolean hasValue(int docId) { return ordinals[docId] != 0; } - @Override public void forEachValueInDoc(int docId, StringValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, StringValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { proc.onMissing(docId); @@ -70,7 +76,8 @@ public class SingleValueIntFieldData extends IntFieldData { proc.onValue(docId, Integer.toString(values[loc])); } - @Override public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { return; @@ -78,7 +85,8 @@ public class SingleValueIntFieldData extends IntFieldData { proc.onValue(docId, values[loc]); } - @Override public void forEachValueInDoc(int docId, LongValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, LongValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { return; @@ -86,7 +94,8 @@ public class SingleValueIntFieldData extends IntFieldData { proc.onValue(docId, values[loc]); } - @Override public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { proc.onMissing(docId); @@ -95,7 +104,8 @@ public class SingleValueIntFieldData extends IntFieldData { proc.onValue(docId, values[loc]); } - @Override public void forEachValueInDoc(int docId, MissingLongValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, MissingLongValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { proc.onMissing(docId); @@ -104,7 +114,8 @@ public class SingleValueIntFieldData extends IntFieldData { proc.onValue(docId, values[loc]); } - @Override public void forEachValueInDoc(int docId, ValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, ValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { proc.onMissing(docId); @@ -113,11 +124,13 @@ public class SingleValueIntFieldData extends IntFieldData { proc.onValue(docId, values[loc]); } - @Override public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { + @Override + public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { proc.onOrdinal(docId, ordinals[docId]); } - @Override public double[] doubleValues(int docId) { + @Override + public double[] doubleValues(int docId) { int loc = ordinals[docId]; if (loc == 0) { return DoubleFieldData.EMPTY_DOUBLE_ARRAY; @@ -127,11 +140,13 @@ public class SingleValueIntFieldData extends IntFieldData { return ret; } - @Override public int value(int docId) { + @Override + public int value(int docId) { return values[ordinals[docId]]; } - @Override public int[] values(int docId) { + @Override + public int[] values(int docId) { int loc = ordinals[docId]; if (loc == 0) { return EMPTY_INT_ARRAY; diff --git a/src/main/java/org/elasticsearch/index/field/data/longs/LongDocFieldData.java b/src/main/java/org/elasticsearch/index/field/data/longs/LongDocFieldData.java index 580924328a4..b16788052f3 100644 --- a/src/main/java/org/elasticsearch/index/field/data/longs/LongDocFieldData.java +++ b/src/main/java/org/elasticsearch/index/field/data/longs/LongDocFieldData.java @@ -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,11 +19,11 @@ package org.elasticsearch.index.field.data.longs; -import org.elasticsearch.common.joda.time.MutableDateTime; import org.elasticsearch.index.field.data.NumericDocFieldData; +import org.joda.time.MutableDateTime; /** - * @author kimchy (shay.banon) + * */ public class LongDocFieldData extends NumericDocFieldData { diff --git a/src/main/java/org/elasticsearch/index/field/data/longs/LongFieldData.java b/src/main/java/org/elasticsearch/index/field/data/longs/LongFieldData.java index fe87d4fcf76..3d8e337df7d 100644 --- a/src/main/java/org/elasticsearch/index/field/data/longs/LongFieldData.java +++ b/src/main/java/org/elasticsearch/index/field/data/longs/LongFieldData.java @@ -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,21 +19,21 @@ package org.elasticsearch.index.field.data.longs; +import gnu.trove.list.array.TLongArrayList; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.FieldCache; import org.elasticsearch.common.RamUsage; -import org.elasticsearch.common.joda.time.DateTimeZone; -import org.elasticsearch.common.joda.time.MutableDateTime; import org.elasticsearch.common.thread.ThreadLocals; -import org.elasticsearch.common.trove.list.array.TLongArrayList; import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.NumericFieldData; import org.elasticsearch.index.field.data.support.FieldDataLoader; +import org.joda.time.DateTimeZone; +import org.joda.time.MutableDateTime; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public abstract class LongFieldData extends NumericFieldData { @@ -41,7 +41,8 @@ public abstract class LongFieldData extends NumericFieldData { static final MutableDateTime[] EMPTY_DATETIME_ARRAY = new MutableDateTime[0]; ThreadLocal> dateTimeCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { return new ThreadLocals.CleanableValue(new MutableDateTime(DateTimeZone.UTC)); } }; @@ -53,7 +54,8 @@ public abstract class LongFieldData extends NumericFieldData { this.values = values; } - @Override protected long computeSizeInBytes() { + @Override + protected long computeSizeInBytes() { return RamUsage.NUM_BYTES_LONG * values.length + RamUsage.NUM_BYTES_ARRAY_HEADER; } @@ -77,49 +79,60 @@ public abstract class LongFieldData extends NumericFieldData { public abstract MutableDateTime[] dates(int docId); - @Override public LongDocFieldData docFieldData(int docId) { + @Override + public LongDocFieldData docFieldData(int docId) { return super.docFieldData(docId); } - @Override protected LongDocFieldData createFieldData() { + @Override + protected LongDocFieldData createFieldData() { return new LongDocFieldData(this); } - @Override public void forEachValue(StringValueProc proc) { + @Override + public void forEachValue(StringValueProc proc) { for (int i = 1; i < values.length; i++) { proc.onValue(Long.toString(values[i])); } } - @Override public String stringValue(int docId) { + @Override + public String stringValue(int docId) { return Long.toString(docId); } - @Override public byte byteValue(int docId) { + @Override + public byte byteValue(int docId) { return (byte) value(docId); } - @Override public short shortValue(int docId) { + @Override + public short shortValue(int docId) { return (short) value(docId); } - @Override public int intValue(int docId) { + @Override + public int intValue(int docId) { return (int) value(docId); } - @Override public long longValue(int docId) { + @Override + public long longValue(int docId) { return value(docId); } - @Override public float floatValue(int docId) { + @Override + public float floatValue(int docId) { return (float) value(docId); } - @Override public double doubleValue(int docId) { + @Override + public double doubleValue(int docId) { return (double) value(docId); } - @Override public FieldDataType type() { + @Override + public FieldDataType type() { return FieldDataType.DefaultTypes.LONG; } @@ -163,15 +176,18 @@ public abstract class LongFieldData extends NumericFieldData { terms.add(0); } - @Override public void collectTerm(String term) { + @Override + public void collectTerm(String term) { terms.add(FieldCache.NUMERIC_UTILS_LONG_PARSER.parseLong(term)); } - @Override public LongFieldData buildSingleValue(String field, int[] ordinals) { + @Override + public LongFieldData buildSingleValue(String field, int[] ordinals) { return new SingleValueLongFieldData(field, ordinals, terms.toArray()); } - @Override public LongFieldData buildMultiValue(String field, int[][] ordinals) { + @Override + public LongFieldData buildMultiValue(String field, int[][] ordinals) { return new MultiValueLongFieldData(field, ordinals, terms.toArray()); } } diff --git a/src/main/java/org/elasticsearch/index/field/data/longs/LongFieldDataComparator.java b/src/main/java/org/elasticsearch/index/field/data/longs/LongFieldDataComparator.java index 47c964c0e4d..fd396bc51fd 100644 --- a/src/main/java/org/elasticsearch/index/field/data/longs/LongFieldDataComparator.java +++ b/src/main/java/org/elasticsearch/index/field/data/longs/LongFieldDataComparator.java @@ -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.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.support.NumericFieldDataComparator; /** - * @author kimchy (shay.banon) + * */ // LUCENE MONITOR - Monitor against FieldComparator.Long public class LongFieldDataComparator extends NumericFieldDataComparator { @@ -37,11 +37,13 @@ public class LongFieldDataComparator extends NumericFieldDataComparator { values = new long[numHits]; } - @Override public FieldDataType fieldDataType() { + @Override + public FieldDataType fieldDataType() { return FieldDataType.DefaultTypes.LONG; } - @Override public int compare(int slot1, int slot2) { + @Override + public int compare(int slot1, int slot2) { // TODO: there are sneaky non-branch ways to compute // -1/+1/0 sign final long v1 = values[slot1]; @@ -75,11 +77,13 @@ public class LongFieldDataComparator extends NumericFieldDataComparator { values[slot] = currentFieldData.longValue(doc); } - @Override public void setBottom(final int bottom) { + @Override + public void setBottom(final int bottom) { this.bottom = values[bottom]; } - @Override public Comparable value(int slot) { + @Override + public Comparable value(int slot) { return Long.valueOf(values[slot]); } diff --git a/src/main/java/org/elasticsearch/index/field/data/longs/LongFieldDataMissingComparator.java b/src/main/java/org/elasticsearch/index/field/data/longs/LongFieldDataMissingComparator.java index b5c2051ba66..2289729959a 100644 --- a/src/main/java/org/elasticsearch/index/field/data/longs/LongFieldDataMissingComparator.java +++ b/src/main/java/org/elasticsearch/index/field/data/longs/LongFieldDataMissingComparator.java @@ -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.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.support.NumericFieldDataComparator; /** - * @author kimchy (shay.banon) + * */ // LUCENE MONITOR - Monitor against FieldComparator.Long public class LongFieldDataMissingComparator extends NumericFieldDataComparator { @@ -39,11 +39,13 @@ public class LongFieldDataMissingComparator extends NumericFieldDataComparator { this.missingValue = missingValue; } - @Override public FieldDataType fieldDataType() { + @Override + public FieldDataType fieldDataType() { return FieldDataType.DefaultTypes.LONG; } - @Override public int compare(int slot1, int slot2) { + @Override + public int compare(int slot1, int slot2) { // TODO: there are sneaky non-branch ways to compute // -1/+1/0 sign final long v1 = values[slot1]; @@ -84,11 +86,13 @@ public class LongFieldDataMissingComparator extends NumericFieldDataComparator { values[slot] = value; } - @Override public void setBottom(final int bottom) { + @Override + public void setBottom(final int bottom) { this.bottom = values[bottom]; } - @Override public Comparable value(int slot) { + @Override + public Comparable value(int slot) { return Long.valueOf(values[slot]); } diff --git a/src/main/java/org/elasticsearch/index/field/data/longs/LongFieldDataType.java b/src/main/java/org/elasticsearch/index/field/data/longs/LongFieldDataType.java index 081e793e482..7fcff5d0457 100644 --- a/src/main/java/org/elasticsearch/index/field/data/longs/LongFieldDataType.java +++ b/src/main/java/org/elasticsearch/index/field/data/longs/LongFieldDataType.java @@ -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,56 +28,66 @@ import org.elasticsearch.index.field.data.FieldDataType; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class LongFieldDataType implements FieldDataType { - @Override public ExtendedFieldComparatorSource newFieldComparatorSource(final FieldDataCache cache, final String missing) { + @Override + public ExtendedFieldComparatorSource newFieldComparatorSource(final FieldDataCache cache, final String missing) { if (missing == null) { return new ExtendedFieldComparatorSource() { - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + @Override + public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { return new LongFieldDataComparator(numHits, fieldname, cache); } - @Override public int reducedType() { + @Override + public int reducedType() { return SortField.LONG; } }; } if (missing.equals("_last")) { return new ExtendedFieldComparatorSource() { - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + @Override + public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { return new LongFieldDataMissingComparator(numHits, fieldname, cache, reversed ? Long.MIN_VALUE : Long.MAX_VALUE); } - @Override public int reducedType() { + @Override + public int reducedType() { return SortField.LONG; } }; } if (missing.equals("_first")) { return new ExtendedFieldComparatorSource() { - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + @Override + public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { return new LongFieldDataMissingComparator(numHits, fieldname, cache, reversed ? Long.MAX_VALUE : Long.MIN_VALUE); } - @Override public int reducedType() { + @Override + public int reducedType() { return SortField.LONG; } }; } return new ExtendedFieldComparatorSource() { - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + @Override + public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { return new LongFieldDataMissingComparator(numHits, fieldname, cache, Long.parseLong(missing)); } - @Override public int reducedType() { + @Override + public int reducedType() { return SortField.LONG; } }; } - @Override public LongFieldData load(IndexReader reader, String fieldName) throws IOException { + @Override + public LongFieldData load(IndexReader reader, String fieldName) throws IOException { return LongFieldData.load(reader, fieldName); } } diff --git a/src/main/java/org/elasticsearch/index/field/data/longs/MultiValueLongFieldData.java b/src/main/java/org/elasticsearch/index/field/data/longs/MultiValueLongFieldData.java index e52adfcfb75..083476f3871 100644 --- a/src/main/java/org/elasticsearch/index/field/data/longs/MultiValueLongFieldData.java +++ b/src/main/java/org/elasticsearch/index/field/data/longs/MultiValueLongFieldData.java @@ -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,20 +20,21 @@ package org.elasticsearch.index.field.data.longs; import org.elasticsearch.common.RamUsage; -import org.elasticsearch.common.joda.time.DateTimeZone; -import org.elasticsearch.common.joda.time.MutableDateTime; import org.elasticsearch.common.thread.ThreadLocals; import org.elasticsearch.index.field.data.doubles.DoubleFieldData; +import org.joda.time.DateTimeZone; +import org.joda.time.MutableDateTime; /** - * @author kimchy (shay.banon) + * */ public class MultiValueLongFieldData extends LongFieldData { private static final int VALUE_CACHE_SIZE = 10; private ThreadLocal> doublesValuesCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { double[][] value = new double[VALUE_CACHE_SIZE][]; for (int i = 0; i < value.length; i++) { value[i] = new double[i]; @@ -43,7 +44,8 @@ public class MultiValueLongFieldData extends LongFieldData { }; private ThreadLocal> dateTimesCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { MutableDateTime[][] value = new MutableDateTime[VALUE_CACHE_SIZE][]; for (int i = 0; i < value.length; i++) { value[i] = new MutableDateTime[i]; @@ -57,7 +59,8 @@ public class MultiValueLongFieldData extends LongFieldData { private ThreadLocal> valuesCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { long[][] value = new long[VALUE_CACHE_SIZE][]; for (int i = 0; i < value.length; i++) { value[i] = new long[i]; @@ -74,7 +77,8 @@ public class MultiValueLongFieldData extends LongFieldData { this.ordinals = ordinals; } - @Override protected long computeSizeInBytes() { + @Override + protected long computeSizeInBytes() { long size = super.computeSizeInBytes(); size += RamUsage.NUM_BYTES_ARRAY_HEADER; // for the top level array for (int[] ordinal : ordinals) { @@ -83,11 +87,13 @@ public class MultiValueLongFieldData extends LongFieldData { return size; } - @Override public boolean multiValued() { + @Override + public boolean multiValued() { return true; } - @Override public boolean hasValue(int docId) { + @Override + public boolean hasValue(int docId) { for (int[] ordinal : ordinals) { if (ordinal[docId] != 0) { return true; @@ -96,7 +102,8 @@ public class MultiValueLongFieldData extends LongFieldData { return false; } - @Override public void forEachValueInDoc(int docId, StringValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, StringValueInDocProc proc) { boolean found = false; for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -110,7 +117,8 @@ public class MultiValueLongFieldData extends LongFieldData { } } - @Override public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) { for (int[] ordinal : ordinals) { int loc = ordinal[docId]; if (loc != 0) { @@ -119,7 +127,8 @@ public class MultiValueLongFieldData extends LongFieldData { } } - @Override public void forEachValueInDoc(int docId, LongValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, LongValueInDocProc proc) { for (int[] ordinal : ordinals) { int loc = ordinal[docId]; if (loc != 0) { @@ -128,7 +137,8 @@ public class MultiValueLongFieldData extends LongFieldData { } } - @Override public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) { boolean found = false; for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -142,7 +152,8 @@ public class MultiValueLongFieldData extends LongFieldData { } } - @Override public void forEachValueInDoc(int docId, MissingLongValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, MissingLongValueInDocProc proc) { boolean found = false; for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -156,7 +167,8 @@ public class MultiValueLongFieldData extends LongFieldData { } } - @Override public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { + @Override + public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { boolean found = false; for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -170,7 +182,8 @@ public class MultiValueLongFieldData extends LongFieldData { } } - @Override public void forEachValueInDoc(int docId, ValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, ValueInDocProc proc) { boolean found = false; for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -184,7 +197,8 @@ public class MultiValueLongFieldData extends LongFieldData { } } - @Override public void forEachValueInDoc(int docId, DateValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, DateValueInDocProc proc) { MutableDateTime dateTime = dateTimeCache.get().get(); for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -195,7 +209,8 @@ public class MultiValueLongFieldData extends LongFieldData { } } - @Override public void forEachValueInDoc(int docId, MutableDateTime dateTime, DateValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, MutableDateTime dateTime, DateValueInDocProc proc) { for (int[] ordinal : ordinals) { int loc = ordinal[docId]; if (loc != 0) { @@ -205,7 +220,8 @@ public class MultiValueLongFieldData extends LongFieldData { } } - @Override public MutableDateTime[] dates(int docId) { + @Override + public MutableDateTime[] dates(int docId) { int length = 0; for (int[] ordinal : ordinals) { if (ordinal[docId] != 0) { @@ -234,7 +250,8 @@ public class MultiValueLongFieldData extends LongFieldData { return dates; } - @Override public double[] doubleValues(int docId) { + @Override + public double[] doubleValues(int docId) { int length = 0; for (int[] ordinal : ordinals) { if (ordinal[docId] != 0) { @@ -260,7 +277,8 @@ public class MultiValueLongFieldData extends LongFieldData { return doubles; } - @Override public long value(int docId) { + @Override + public long value(int docId) { for (int[] ordinal : ordinals) { int loc = ordinal[docId]; if (loc != 0) { @@ -270,7 +288,8 @@ public class MultiValueLongFieldData extends LongFieldData { return 0; } - @Override public long[] values(int docId) { + @Override + public long[] values(int docId) { int length = 0; for (int[] ordinal : ordinals) { if (ordinal[docId] != 0) { diff --git a/src/main/java/org/elasticsearch/index/field/data/longs/SingleValueLongFieldData.java b/src/main/java/org/elasticsearch/index/field/data/longs/SingleValueLongFieldData.java index 33a862831c3..f29faa3aeee 100644 --- a/src/main/java/org/elasticsearch/index/field/data/longs/SingleValueLongFieldData.java +++ b/src/main/java/org/elasticsearch/index/field/data/longs/SingleValueLongFieldData.java @@ -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,24 +20,26 @@ package org.elasticsearch.index.field.data.longs; import org.elasticsearch.common.RamUsage; -import org.elasticsearch.common.joda.time.DateTimeZone; -import org.elasticsearch.common.joda.time.MutableDateTime; import org.elasticsearch.common.thread.ThreadLocals; import org.elasticsearch.index.field.data.doubles.DoubleFieldData; +import org.joda.time.DateTimeZone; +import org.joda.time.MutableDateTime; /** - * @author kimchy (shay.banon) + * */ public class SingleValueLongFieldData extends LongFieldData { private ThreadLocal> doublesValuesCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { return new ThreadLocals.CleanableValue(new double[1]); } }; private ThreadLocal> datesValuesCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { MutableDateTime[] date = new MutableDateTime[1]; date[0] = new MutableDateTime(DateTimeZone.UTC); return new ThreadLocals.CleanableValue(date); @@ -45,7 +47,8 @@ public class SingleValueLongFieldData extends LongFieldData { }; private ThreadLocal valuesCache = new ThreadLocal() { - @Override protected long[] initialValue() { + @Override + protected long[] initialValue() { return new long[1]; } }; @@ -58,20 +61,24 @@ public class SingleValueLongFieldData extends LongFieldData { this.ordinals = ordinals; } - @Override protected long computeSizeInBytes() { + @Override + protected long computeSizeInBytes() { return super.computeSizeInBytes() + RamUsage.NUM_BYTES_INT * ordinals.length + RamUsage.NUM_BYTES_ARRAY_HEADER; } - @Override public boolean multiValued() { + @Override + public boolean multiValued() { return false; } - @Override public boolean hasValue(int docId) { + @Override + public boolean hasValue(int docId) { return ordinals[docId] != 0; } - @Override public void forEachValueInDoc(int docId, StringValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, StringValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { proc.onMissing(docId); @@ -80,7 +87,8 @@ public class SingleValueLongFieldData extends LongFieldData { proc.onValue(docId, Long.toString(values[loc])); } - @Override public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { return; @@ -88,7 +96,8 @@ public class SingleValueLongFieldData extends LongFieldData { proc.onValue(docId, values[loc]); } - @Override public void forEachValueInDoc(int docId, LongValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, LongValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { return; @@ -96,7 +105,8 @@ public class SingleValueLongFieldData extends LongFieldData { proc.onValue(docId, values[loc]); } - @Override public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { proc.onMissing(docId); @@ -105,7 +115,8 @@ public class SingleValueLongFieldData extends LongFieldData { proc.onValue(docId, values[loc]); } - @Override public void forEachValueInDoc(int docId, MissingLongValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, MissingLongValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { proc.onMissing(docId); @@ -114,11 +125,13 @@ public class SingleValueLongFieldData extends LongFieldData { proc.onValue(docId, values[loc]); } - @Override public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { + @Override + public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { proc.onOrdinal(docId, ordinals[docId]); } - @Override public void forEachValueInDoc(int docId, ValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, ValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { proc.onMissing(docId); @@ -127,7 +140,8 @@ public class SingleValueLongFieldData extends LongFieldData { proc.onValue(docId, values[loc]); } - @Override public void forEachValueInDoc(int docId, DateValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, DateValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { return; @@ -137,7 +151,8 @@ public class SingleValueLongFieldData extends LongFieldData { proc.onValue(docId, dateTime); } - @Override public void forEachValueInDoc(int docId, MutableDateTime dateTime, DateValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, MutableDateTime dateTime, DateValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { return; @@ -146,7 +161,8 @@ public class SingleValueLongFieldData extends LongFieldData { proc.onValue(docId, dateTime); } - @Override public MutableDateTime[] dates(int docId) { + @Override + public MutableDateTime[] dates(int docId) { int loc = ordinals[docId]; if (loc == 0) { return EMPTY_DATETIME_ARRAY; @@ -156,7 +172,8 @@ public class SingleValueLongFieldData extends LongFieldData { return ret; } - @Override public double[] doubleValues(int docId) { + @Override + public double[] doubleValues(int docId) { int loc = ordinals[docId]; if (loc == 0) { return DoubleFieldData.EMPTY_DOUBLE_ARRAY; @@ -166,11 +183,13 @@ public class SingleValueLongFieldData extends LongFieldData { return ret; } - @Override public long value(int docId) { + @Override + public long value(int docId) { return values[ordinals[docId]]; } - @Override public long[] values(int docId) { + @Override + public long[] values(int docId) { int loc = ordinals[docId]; if (loc == 0) { return EMPTY_LONG_ARRAY; diff --git a/src/main/java/org/elasticsearch/index/field/data/shorts/MultiValueShortFieldData.java b/src/main/java/org/elasticsearch/index/field/data/shorts/MultiValueShortFieldData.java index 39907bf18f4..3bad20c9800 100644 --- a/src/main/java/org/elasticsearch/index/field/data/shorts/MultiValueShortFieldData.java +++ b/src/main/java/org/elasticsearch/index/field/data/shorts/MultiValueShortFieldData.java @@ -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,14 +24,15 @@ import org.elasticsearch.common.thread.ThreadLocals; import org.elasticsearch.index.field.data.doubles.DoubleFieldData; /** - * @author kimchy (shay.banon) + * */ public class MultiValueShortFieldData extends ShortFieldData { private static final int VALUE_CACHE_SIZE = 10; private ThreadLocal> doublesValuesCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { double[][] value = new double[VALUE_CACHE_SIZE][]; for (int i = 0; i < value.length; i++) { value[i] = new double[i]; @@ -41,7 +42,8 @@ public class MultiValueShortFieldData extends ShortFieldData { }; private ThreadLocal> valuesCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { short[][] value = new short[VALUE_CACHE_SIZE][]; for (int i = 0; i < value.length; i++) { value[i] = new short[i]; @@ -58,7 +60,8 @@ public class MultiValueShortFieldData extends ShortFieldData { this.ordinals = ordinals; } - @Override protected long computeSizeInBytes() { + @Override + protected long computeSizeInBytes() { long size = super.computeSizeInBytes(); size += RamUsage.NUM_BYTES_ARRAY_HEADER; // for the top level array for (int[] ordinal : ordinals) { @@ -67,11 +70,13 @@ public class MultiValueShortFieldData extends ShortFieldData { return size; } - @Override public boolean multiValued() { + @Override + public boolean multiValued() { return true; } - @Override public boolean hasValue(int docId) { + @Override + public boolean hasValue(int docId) { for (int[] ordinal : ordinals) { if (ordinal[docId] != 0) { return true; @@ -80,7 +85,8 @@ public class MultiValueShortFieldData extends ShortFieldData { return false; } - @Override public void forEachValueInDoc(int docId, StringValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, StringValueInDocProc proc) { boolean found = false; for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -94,7 +100,8 @@ public class MultiValueShortFieldData extends ShortFieldData { } } - @Override public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) { for (int[] ordinal : ordinals) { int loc = ordinal[docId]; if (loc != 0) { @@ -103,7 +110,8 @@ public class MultiValueShortFieldData extends ShortFieldData { } } - @Override public void forEachValueInDoc(int docId, LongValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, LongValueInDocProc proc) { for (int[] ordinal : ordinals) { int loc = ordinal[docId]; if (loc != 0) { @@ -112,7 +120,8 @@ public class MultiValueShortFieldData extends ShortFieldData { } } - @Override public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) { boolean found = false; for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -126,7 +135,8 @@ public class MultiValueShortFieldData extends ShortFieldData { } } - @Override public void forEachValueInDoc(int docId, MissingLongValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, MissingLongValueInDocProc proc) { boolean found = false; for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -140,7 +150,8 @@ public class MultiValueShortFieldData extends ShortFieldData { } } - @Override public void forEachValueInDoc(int docId, ValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, ValueInDocProc proc) { boolean found = false; for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -154,7 +165,8 @@ public class MultiValueShortFieldData extends ShortFieldData { } } - @Override public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { + @Override + public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { boolean found = false; for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -168,7 +180,8 @@ public class MultiValueShortFieldData extends ShortFieldData { } } - @Override public double[] doubleValues(int docId) { + @Override + public double[] doubleValues(int docId) { int length = 0; for (int[] ordinal : ordinals) { if (ordinal[docId] != 0) { @@ -194,7 +207,8 @@ public class MultiValueShortFieldData extends ShortFieldData { return doubles; } - @Override public short value(int docId) { + @Override + public short value(int docId) { for (int[] ordinal : ordinals) { int loc = ordinal[docId]; if (loc != 0) { @@ -204,7 +218,8 @@ public class MultiValueShortFieldData extends ShortFieldData { return 0; } - @Override public short[] values(int docId) { + @Override + public short[] values(int docId) { int length = 0; for (int[] ordinal : ordinals) { if (ordinal[docId] != 0) { diff --git a/src/main/java/org/elasticsearch/index/field/data/shorts/ShortDocFieldData.java b/src/main/java/org/elasticsearch/index/field/data/shorts/ShortDocFieldData.java index bcaf0a4323c..014dc7eb677 100644 --- a/src/main/java/org/elasticsearch/index/field/data/shorts/ShortDocFieldData.java +++ b/src/main/java/org/elasticsearch/index/field/data/shorts/ShortDocFieldData.java @@ -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.index.field.data.shorts; import org.elasticsearch.index.field.data.NumericDocFieldData; /** - * @author kimchy (shay.banon) + * */ public class ShortDocFieldData extends NumericDocFieldData { diff --git a/src/main/java/org/elasticsearch/index/field/data/shorts/ShortFieldData.java b/src/main/java/org/elasticsearch/index/field/data/shorts/ShortFieldData.java index 6c787308aa6..deec92dcb49 100644 --- a/src/main/java/org/elasticsearch/index/field/data/shorts/ShortFieldData.java +++ b/src/main/java/org/elasticsearch/index/field/data/shorts/ShortFieldData.java @@ -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.index.field.data.shorts; +import gnu.trove.list.array.TShortArrayList; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.FieldCache; import org.elasticsearch.common.RamUsage; -import org.elasticsearch.common.trove.list.array.TShortArrayList; import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.NumericFieldData; import org.elasticsearch.index.field.data.support.FieldDataLoader; @@ -30,7 +30,7 @@ import org.elasticsearch.index.field.data.support.FieldDataLoader; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public abstract class ShortFieldData extends NumericFieldData { @@ -43,7 +43,8 @@ public abstract class ShortFieldData extends NumericFieldData this.values = values; } - @Override protected long computeSizeInBytes() { + @Override + protected long computeSizeInBytes() { return RamUsage.NUM_BYTES_SHORT * values.length + RamUsage.NUM_BYTES_ARRAY_HEADER; } @@ -55,49 +56,60 @@ public abstract class ShortFieldData extends NumericFieldData abstract public short[] values(int docId); - @Override public ShortDocFieldData docFieldData(int docId) { + @Override + public ShortDocFieldData docFieldData(int docId) { return super.docFieldData(docId); } - @Override protected ShortDocFieldData createFieldData() { + @Override + protected ShortDocFieldData createFieldData() { return new ShortDocFieldData(this); } - @Override public void forEachValue(StringValueProc proc) { + @Override + public void forEachValue(StringValueProc proc) { for (int i = 1; i < values.length; i++) { proc.onValue(Short.toString(values[i])); } } - @Override public String stringValue(int docId) { + @Override + public String stringValue(int docId) { return Short.toString(value(docId)); } - @Override public byte byteValue(int docId) { + @Override + public byte byteValue(int docId) { return (byte) value(docId); } - @Override public short shortValue(int docId) { + @Override + public short shortValue(int docId) { return value(docId); } - @Override public int intValue(int docId) { + @Override + public int intValue(int docId) { return (int) value(docId); } - @Override public long longValue(int docId) { + @Override + public long longValue(int docId) { return (long) value(docId); } - @Override public float floatValue(int docId) { + @Override + public float floatValue(int docId) { return (float) value(docId); } - @Override public double doubleValue(int docId) { + @Override + public double doubleValue(int docId) { return (double) value(docId); } - @Override public FieldDataType type() { + @Override + public FieldDataType type() { return FieldDataType.DefaultTypes.SHORT; } @@ -133,15 +145,18 @@ public abstract class ShortFieldData extends NumericFieldData terms.add((short) 0); } - @Override public void collectTerm(String term) { + @Override + public void collectTerm(String term) { terms.add((short) FieldCache.NUMERIC_UTILS_INT_PARSER.parseInt(term)); } - @Override public ShortFieldData buildSingleValue(String field, int[] ordinals) { + @Override + public ShortFieldData buildSingleValue(String field, int[] ordinals) { return new SingleValueShortFieldData(field, ordinals, terms.toArray()); } - @Override public ShortFieldData buildMultiValue(String field, int[][] ordinals) { + @Override + public ShortFieldData buildMultiValue(String field, int[][] ordinals) { return new MultiValueShortFieldData(field, ordinals, terms.toArray()); } } diff --git a/src/main/java/org/elasticsearch/index/field/data/shorts/ShortFieldDataComparator.java b/src/main/java/org/elasticsearch/index/field/data/shorts/ShortFieldDataComparator.java index 0629d77ff30..bb7fd43da90 100644 --- a/src/main/java/org/elasticsearch/index/field/data/shorts/ShortFieldDataComparator.java +++ b/src/main/java/org/elasticsearch/index/field/data/shorts/ShortFieldDataComparator.java @@ -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.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.support.NumericFieldDataComparator; /** - * @author kimchy (shay.banon) + * */ // LUCENE MONITOR: Monitor against FieldComparator.Short public class ShortFieldDataComparator extends NumericFieldDataComparator { @@ -37,27 +37,33 @@ public class ShortFieldDataComparator extends NumericFieldDataComparator { values = new short[numHits]; } - @Override public FieldDataType fieldDataType() { + @Override + public FieldDataType fieldDataType() { return FieldDataType.DefaultTypes.SHORT; } - @Override public int compare(int slot1, int slot2) { + @Override + public int compare(int slot1, int slot2) { return values[slot1] - values[slot2]; } - @Override public int compareBottom(int doc) { + @Override + public int compareBottom(int doc) { return bottom - currentFieldData.shortValue(doc); } - @Override public void copy(int slot, int doc) { + @Override + public void copy(int slot, int doc) { values[slot] = currentFieldData.shortValue(doc); } - @Override public void setBottom(final int bottom) { + @Override + public void setBottom(final int bottom) { this.bottom = values[bottom]; } - @Override public Comparable value(int slot) { + @Override + public Comparable value(int slot) { return Short.valueOf(values[slot]); } } diff --git a/src/main/java/org/elasticsearch/index/field/data/shorts/ShortFieldDataMissingComparator.java b/src/main/java/org/elasticsearch/index/field/data/shorts/ShortFieldDataMissingComparator.java index ec77ce6b43c..0f03d35cc2c 100644 --- a/src/main/java/org/elasticsearch/index/field/data/shorts/ShortFieldDataMissingComparator.java +++ b/src/main/java/org/elasticsearch/index/field/data/shorts/ShortFieldDataMissingComparator.java @@ -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.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.support.NumericFieldDataComparator; /** - * @author kimchy (shay.banon) + * */ // LUCENE MONITOR: Monitor against FieldComparator.Short public class ShortFieldDataMissingComparator extends NumericFieldDataComparator { @@ -39,15 +39,18 @@ public class ShortFieldDataMissingComparator extends NumericFieldDataComparator this.missingValue = missingValue; } - @Override public FieldDataType fieldDataType() { + @Override + public FieldDataType fieldDataType() { return FieldDataType.DefaultTypes.SHORT; } - @Override public int compare(int slot1, int slot2) { + @Override + public int compare(int slot1, int slot2) { return values[slot1] - values[slot2]; } - @Override public int compareBottom(int doc) { + @Override + public int compareBottom(int doc) { short value = missingValue; if (currentFieldData.hasValue(doc)) { value = currentFieldData.shortValue(doc); @@ -55,7 +58,8 @@ public class ShortFieldDataMissingComparator extends NumericFieldDataComparator return bottom - value; } - @Override public void copy(int slot, int doc) { + @Override + public void copy(int slot, int doc) { short value = missingValue; if (currentFieldData.hasValue(doc)) { value = currentFieldData.shortValue(doc); @@ -63,11 +67,13 @@ public class ShortFieldDataMissingComparator extends NumericFieldDataComparator values[slot] = value; } - @Override public void setBottom(final int bottom) { + @Override + public void setBottom(final int bottom) { this.bottom = values[bottom]; } - @Override public Comparable value(int slot) { + @Override + public Comparable value(int slot) { return Short.valueOf(values[slot]); } } diff --git a/src/main/java/org/elasticsearch/index/field/data/shorts/ShortFieldDataType.java b/src/main/java/org/elasticsearch/index/field/data/shorts/ShortFieldDataType.java index 99cccb79889..c1d10a70226 100644 --- a/src/main/java/org/elasticsearch/index/field/data/shorts/ShortFieldDataType.java +++ b/src/main/java/org/elasticsearch/index/field/data/shorts/ShortFieldDataType.java @@ -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,56 +28,66 @@ import org.elasticsearch.index.field.data.FieldDataType; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class ShortFieldDataType implements FieldDataType { - @Override public ExtendedFieldComparatorSource newFieldComparatorSource(final FieldDataCache cache, final String missing) { + @Override + public ExtendedFieldComparatorSource newFieldComparatorSource(final FieldDataCache cache, final String missing) { if (missing == null) { return new ExtendedFieldComparatorSource() { - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + @Override + public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { return new ShortFieldDataComparator(numHits, fieldname, cache); } - @Override public int reducedType() { + @Override + public int reducedType() { return SortField.SHORT; } }; } if (missing.equals("_last")) { return new ExtendedFieldComparatorSource() { - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + @Override + public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { return new ShortFieldDataMissingComparator(numHits, fieldname, cache, reversed ? Short.MIN_VALUE : Short.MAX_VALUE); } - @Override public int reducedType() { + @Override + public int reducedType() { return SortField.SHORT; } }; } if (missing.equals("_first")) { return new ExtendedFieldComparatorSource() { - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + @Override + public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { return new ShortFieldDataMissingComparator(numHits, fieldname, cache, reversed ? Short.MAX_VALUE : Short.MIN_VALUE); } - @Override public int reducedType() { + @Override + public int reducedType() { return SortField.SHORT; } }; } return new ExtendedFieldComparatorSource() { - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + @Override + public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { return new ShortFieldDataMissingComparator(numHits, fieldname, cache, Short.parseShort(missing)); } - @Override public int reducedType() { + @Override + public int reducedType() { return SortField.SHORT; } }; } - @Override public ShortFieldData load(IndexReader reader, String fieldName) throws IOException { + @Override + public ShortFieldData load(IndexReader reader, String fieldName) throws IOException { return ShortFieldData.load(reader, fieldName); } } diff --git a/src/main/java/org/elasticsearch/index/field/data/shorts/SingleValueShortFieldData.java b/src/main/java/org/elasticsearch/index/field/data/shorts/SingleValueShortFieldData.java index 12ca91fade2..4e349a7d1e9 100644 --- a/src/main/java/org/elasticsearch/index/field/data/shorts/SingleValueShortFieldData.java +++ b/src/main/java/org/elasticsearch/index/field/data/shorts/SingleValueShortFieldData.java @@ -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,18 +24,20 @@ import org.elasticsearch.common.thread.ThreadLocals; import org.elasticsearch.index.field.data.doubles.DoubleFieldData; /** - * @author kimchy (shay.banon) + * */ public class SingleValueShortFieldData extends ShortFieldData { private ThreadLocal> doublesValuesCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { return new ThreadLocals.CleanableValue(new double[1]); } }; private ThreadLocal> valuesCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { return new ThreadLocals.CleanableValue(new short[1]); } }; @@ -48,20 +50,24 @@ public class SingleValueShortFieldData extends ShortFieldData { this.ordinals = ordinals; } - @Override protected long computeSizeInBytes() { + @Override + protected long computeSizeInBytes() { return super.computeSizeInBytes() + RamUsage.NUM_BYTES_INT * ordinals.length + RamUsage.NUM_BYTES_ARRAY_HEADER; } - @Override public boolean multiValued() { + @Override + public boolean multiValued() { return false; } - @Override public boolean hasValue(int docId) { + @Override + public boolean hasValue(int docId) { return ordinals[docId] != 0; } - @Override public void forEachValueInDoc(int docId, StringValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, StringValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { proc.onMissing(docId); @@ -70,7 +76,8 @@ public class SingleValueShortFieldData extends ShortFieldData { proc.onValue(docId, Short.toString(values[loc])); } - @Override public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { return; @@ -78,7 +85,8 @@ public class SingleValueShortFieldData extends ShortFieldData { proc.onValue(docId, values[loc]); } - @Override public void forEachValueInDoc(int docId, LongValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, LongValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { return; @@ -86,7 +94,8 @@ public class SingleValueShortFieldData extends ShortFieldData { proc.onValue(docId, values[loc]); } - @Override public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { proc.onMissing(docId); @@ -95,7 +104,8 @@ public class SingleValueShortFieldData extends ShortFieldData { proc.onValue(docId, values[loc]); } - @Override public void forEachValueInDoc(int docId, MissingLongValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, MissingLongValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { proc.onMissing(docId); @@ -104,7 +114,8 @@ public class SingleValueShortFieldData extends ShortFieldData { proc.onValue(docId, values[loc]); } - @Override public void forEachValueInDoc(int docId, ValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, ValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { proc.onMissing(docId); @@ -113,15 +124,18 @@ public class SingleValueShortFieldData extends ShortFieldData { proc.onValue(docId, values[loc]); } - @Override public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { + @Override + public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { proc.onOrdinal(docId, ordinals[docId]); } - @Override public short value(int docId) { + @Override + public short value(int docId) { return values[ordinals[docId]]; } - @Override public double[] doubleValues(int docId) { + @Override + public double[] doubleValues(int docId) { int loc = ordinals[docId]; if (loc == 0) { return DoubleFieldData.EMPTY_DOUBLE_ARRAY; @@ -131,7 +145,8 @@ public class SingleValueShortFieldData extends ShortFieldData { return ret; } - @Override public short[] values(int docId) { + @Override + public short[] values(int docId) { int loc = ordinals[docId]; if (loc == 0) { return EMPTY_SHORT_ARRAY; diff --git a/src/main/java/org/elasticsearch/index/field/data/strings/MultiValueStringFieldData.java b/src/main/java/org/elasticsearch/index/field/data/strings/MultiValueStringFieldData.java index d5c6f944c15..31e5df1dabf 100644 --- a/src/main/java/org/elasticsearch/index/field/data/strings/MultiValueStringFieldData.java +++ b/src/main/java/org/elasticsearch/index/field/data/strings/MultiValueStringFieldData.java @@ -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,14 +24,15 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.thread.ThreadLocals; /** - * @author kimchy (shay.banon) + * */ public class MultiValueStringFieldData extends StringFieldData { private static final int VALUE_CACHE_SIZE = 100; private static ThreadLocal> valuesCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { String[][] value = new String[VALUE_CACHE_SIZE][]; for (int i = 0; i < value.length; i++) { value[i] = new String[i]; @@ -48,7 +49,8 @@ public class MultiValueStringFieldData extends StringFieldData { this.ordinals = ordinals; } - @Override protected long computeSizeInBytes() { + @Override + protected long computeSizeInBytes() { long size = super.computeSizeInBytes(); size += RamUsage.NUM_BYTES_ARRAY_HEADER; // for the top level array for (int[] ordinal : ordinals) { @@ -57,11 +59,13 @@ public class MultiValueStringFieldData extends StringFieldData { return size; } - @Override public boolean multiValued() { + @Override + public boolean multiValued() { return true; } - @Override public boolean hasValue(int docId) { + @Override + public boolean hasValue(int docId) { for (int[] ordinal : ordinals) { if (ordinal[docId] != 0) { return true; @@ -70,7 +74,8 @@ public class MultiValueStringFieldData extends StringFieldData { return false; } - @Override public void forEachValueInDoc(int docId, StringValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, StringValueInDocProc proc) { boolean found = false; for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -84,7 +89,8 @@ public class MultiValueStringFieldData extends StringFieldData { } } - @Override public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { + @Override + public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { boolean found = false; for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -98,7 +104,8 @@ public class MultiValueStringFieldData extends StringFieldData { } } - @Override public String value(int docId) { + @Override + public String value(int docId) { for (int[] ordinal : ordinals) { int loc = ordinal[docId]; if (loc != 0) { @@ -108,7 +115,8 @@ public class MultiValueStringFieldData extends StringFieldData { return null; } - @Override public String[] values(int docId) { + @Override + public String[] values(int docId) { int length = 0; for (int[] ordinal : ordinals) { if (ordinal[docId] != 0) { diff --git a/src/main/java/org/elasticsearch/index/field/data/strings/SingleValueStringFieldData.java b/src/main/java/org/elasticsearch/index/field/data/strings/SingleValueStringFieldData.java index 719043a8569..fe17a1600cb 100644 --- a/src/main/java/org/elasticsearch/index/field/data/strings/SingleValueStringFieldData.java +++ b/src/main/java/org/elasticsearch/index/field/data/strings/SingleValueStringFieldData.java @@ -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,12 +24,13 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.thread.ThreadLocals; /** - * @author kimchy (shay.banon) + * */ public class SingleValueStringFieldData extends StringFieldData { private static ThreadLocal> valuesCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { return new ThreadLocals.CleanableValue(new String[1]); } }; @@ -42,7 +43,8 @@ public class SingleValueStringFieldData extends StringFieldData { this.ordinals = ordinals; } - @Override protected long computeSizeInBytes() { + @Override + protected long computeSizeInBytes() { return super.computeSizeInBytes() + RamUsage.NUM_BYTES_INT * ordinals.length + RamUsage.NUM_BYTES_ARRAY_HEADER; } @@ -51,19 +53,23 @@ public class SingleValueStringFieldData extends StringFieldData { return ordinals; } - @Override public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { + @Override + public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { proc.onOrdinal(docId, ordinals[docId]); } - @Override public boolean multiValued() { + @Override + public boolean multiValued() { return false; } - @Override public boolean hasValue(int docId) { + @Override + public boolean hasValue(int docId) { return ordinals[docId] != 0; } - @Override public void forEachValueInDoc(int docId, StringValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, StringValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { proc.onMissing(docId); @@ -72,11 +78,13 @@ public class SingleValueStringFieldData extends StringFieldData { proc.onValue(docId, values[loc]); } - @Override public String value(int docId) { + @Override + public String value(int docId) { return values[ordinals[docId]]; } - @Override public String[] values(int docId) { + @Override + public String[] values(int docId) { int loc = ordinals[docId]; if (loc == 0) { return Strings.EMPTY_ARRAY; diff --git a/src/main/java/org/elasticsearch/index/field/data/strings/StringDocFieldData.java b/src/main/java/org/elasticsearch/index/field/data/strings/StringDocFieldData.java index 8771b650a20..d135391c344 100644 --- a/src/main/java/org/elasticsearch/index/field/data/strings/StringDocFieldData.java +++ b/src/main/java/org/elasticsearch/index/field/data/strings/StringDocFieldData.java @@ -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.index.field.data.strings; import org.elasticsearch.index.field.data.DocFieldData; /** - * @author kimchy (shay.banon) + * */ public class StringDocFieldData extends DocFieldData { diff --git a/src/main/java/org/elasticsearch/index/field/data/strings/StringFieldData.java b/src/main/java/org/elasticsearch/index/field/data/strings/StringFieldData.java index a8312313bcf..a1684c88d3e 100644 --- a/src/main/java/org/elasticsearch/index/field/data/strings/StringFieldData.java +++ b/src/main/java/org/elasticsearch/index/field/data/strings/StringFieldData.java @@ -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.io.IOException; import java.util.ArrayList; /** - * @author kimchy (shay.banon) + * */ public abstract class StringFieldData extends FieldData { @@ -40,7 +40,8 @@ public abstract class StringFieldData extends FieldData { this.values = values; } - @Override protected long computeSizeInBytes() { + @Override + protected long computeSizeInBytes() { long size = RamUsage.NUM_BYTES_ARRAY_HEADER; for (String value : values) { if (value != null) { @@ -58,23 +59,28 @@ public abstract class StringFieldData extends FieldData { abstract public String[] values(int docId); - @Override public StringDocFieldData docFieldData(int docId) { + @Override + public StringDocFieldData docFieldData(int docId) { return super.docFieldData(docId); } - @Override public String stringValue(int docId) { + @Override + public String stringValue(int docId) { return value(docId); } - @Override protected StringDocFieldData createFieldData() { + @Override + protected StringDocFieldData createFieldData() { return new StringDocFieldData(this); } - @Override public FieldDataType type() { + @Override + public FieldDataType type() { return FieldDataType.DefaultTypes.STRING; } - @Override public void forEachValue(StringValueProc proc) { + @Override + public void forEachValue(StringValueProc proc) { for (int i = 1; i < values.length; i++) { proc.onValue(values[i]); } @@ -94,15 +100,18 @@ public abstract class StringFieldData extends FieldData { terms.add(null); } - @Override public void collectTerm(String term) { + @Override + public void collectTerm(String term) { terms.add(term); } - @Override public StringFieldData buildSingleValue(String field, int[] ordinals) { + @Override + public StringFieldData buildSingleValue(String field, int[] ordinals) { return new SingleValueStringFieldData(field, ordinals, terms.toArray(new String[terms.size()])); } - @Override public StringFieldData buildMultiValue(String field, int[][] ordinals) { + @Override + public StringFieldData buildMultiValue(String field, int[][] ordinals) { return new MultiValueStringFieldData(field, ordinals, terms.toArray(new String[terms.size()])); } } diff --git a/src/main/java/org/elasticsearch/index/field/data/strings/StringFieldDataType.java b/src/main/java/org/elasticsearch/index/field/data/strings/StringFieldDataType.java index f3cee491de5..1e46c46b1e2 100644 --- a/src/main/java/org/elasticsearch/index/field/data/strings/StringFieldDataType.java +++ b/src/main/java/org/elasticsearch/index/field/data/strings/StringFieldDataType.java @@ -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,26 +29,30 @@ import org.elasticsearch.index.field.data.FieldDataType; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class StringFieldDataType implements FieldDataType { - @Override public ExtendedFieldComparatorSource newFieldComparatorSource(final FieldDataCache cache, final String missing) { + @Override + public ExtendedFieldComparatorSource newFieldComparatorSource(final FieldDataCache cache, final String missing) { if (missing != null) { throw new ElasticSearchIllegalArgumentException("Sorting on string type field does not support missing parameter"); } return new ExtendedFieldComparatorSource() { - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + @Override + public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { return new StringOrdValFieldDataComparator(numHits, fieldname, sortPos, reversed, cache); } - @Override public int reducedType() { + @Override + public int reducedType() { return SortField.STRING; } }; } - @Override public StringFieldData load(IndexReader reader, String fieldName) throws IOException { + @Override + public StringFieldData load(IndexReader reader, String fieldName) throws IOException { return StringFieldData.load(reader, fieldName); } } diff --git a/src/main/java/org/elasticsearch/index/field/data/strings/StringOrdValFieldDataComparator.java b/src/main/java/org/elasticsearch/index/field/data/strings/StringOrdValFieldDataComparator.java index c5c3fce42bc..1aeb7ff7995 100644 --- a/src/main/java/org/elasticsearch/index/field/data/strings/StringOrdValFieldDataComparator.java +++ b/src/main/java/org/elasticsearch/index/field/data/strings/StringOrdValFieldDataComparator.java @@ -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.index.field.data.FieldDataType; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ // LUCENE MONITOR: Monitor against FieldComparator#String public class StringOrdValFieldDataComparator extends FieldComparator { @@ -57,7 +57,8 @@ public class StringOrdValFieldDataComparator extends FieldComparator { this.field = field; } - @Override public int compare(int slot1, int slot2) { + @Override + public int compare(int slot1, int slot2) { if (readerGen[slot1] == readerGen[slot2]) { return ords[slot1] - ords[slot2]; } @@ -75,7 +76,8 @@ public class StringOrdValFieldDataComparator extends FieldComparator { return val1.compareTo(val2); } - @Override public int compareBottom(int doc) { + @Override + public int compareBottom(int doc) { assert bottomSlot != -1; if (bottomSameReader) { // ord is precisely comparable, even in the equal case @@ -105,7 +107,8 @@ public class StringOrdValFieldDataComparator extends FieldComparator { } } - @Override public void copy(int slot, int doc) { + @Override + public void copy(int slot, int doc) { final int ord = order[doc]; ords[slot] = ord; assert ord >= 0; @@ -113,7 +116,8 @@ public class StringOrdValFieldDataComparator extends FieldComparator { readerGen[slot] = currentReaderGen; } - @Override public void setNextReader(IndexReader reader, int docBase) throws IOException { + @Override + public void setNextReader(IndexReader reader, int docBase) throws IOException { FieldData cleanFieldData = fieldDataCache.cache(FieldDataType.DefaultTypes.STRING, reader, field); if (cleanFieldData instanceof MultiValueStringFieldData) { throw new IOException("Can't sort on string types with more than one value per doc, or more than one token per field"); @@ -128,7 +132,8 @@ public class StringOrdValFieldDataComparator extends FieldComparator { } } - @Override public void setBottom(final int bottom) { + @Override + public void setBottom(final int bottom) { bottomSlot = bottom; bottomValue = values[bottomSlot]; @@ -157,7 +162,8 @@ public class StringOrdValFieldDataComparator extends FieldComparator { } } - @Override public Comparable value(int slot) { + @Override + public Comparable value(int slot) { return values[slot]; } diff --git a/src/main/java/org/elasticsearch/index/field/data/strings/StringValFieldDataComparator.java b/src/main/java/org/elasticsearch/index/field/data/strings/StringValFieldDataComparator.java index 06b702bf73d..1f13606949d 100644 --- a/src/main/java/org/elasticsearch/index/field/data/strings/StringValFieldDataComparator.java +++ b/src/main/java/org/elasticsearch/index/field/data/strings/StringValFieldDataComparator.java @@ -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.index.field.data.FieldDataType; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ // LUCENE MONITOR: Monitor against FieldComparator#String public class StringValFieldDataComparator extends FieldComparator { @@ -49,7 +49,8 @@ public class StringValFieldDataComparator extends FieldComparator { values = new String[numHits]; } - @Override public int compare(int slot1, int slot2) { + @Override + public int compare(int slot1, int slot2) { final String val1 = values[slot1]; final String val2 = values[slot2]; if (val1 == null) { @@ -64,7 +65,8 @@ public class StringValFieldDataComparator extends FieldComparator { return val1.compareTo(val2); } - @Override public int compareBottom(int doc) { + @Override + public int compareBottom(int doc) { final String val2 = currentFieldData.stringValue(doc); if (bottom == null) { if (val2 == null) { @@ -77,19 +79,23 @@ public class StringValFieldDataComparator extends FieldComparator { return bottom.compareTo(val2); } - @Override public void copy(int slot, int doc) { + @Override + public void copy(int slot, int doc) { values[slot] = currentFieldData.stringValue(doc); } - @Override public void setNextReader(IndexReader reader, int docBase) throws IOException { + @Override + public void setNextReader(IndexReader reader, int docBase) throws IOException { currentFieldData = fieldDataCache.cache(FieldDataType.DefaultTypes.STRING, reader, fieldName); } - @Override public void setBottom(final int bottom) { + @Override + public void setBottom(final int bottom) { this.bottom = values[bottom]; } - @Override public Comparable value(int slot) { + @Override + public Comparable value(int slot) { return values[slot]; } } diff --git a/src/main/java/org/elasticsearch/index/field/data/support/FieldDataLoader.java b/src/main/java/org/elasticsearch/index/field/data/support/FieldDataLoader.java index 74fcf85c02a..cb5ae291fb1 100644 --- a/src/main/java/org/elasticsearch/index/field/data/support/FieldDataLoader.java +++ b/src/main/java/org/elasticsearch/index/field/data/support/FieldDataLoader.java @@ -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.io.IOException; import java.util.ArrayList; /** - * @author kimchy (shay.banon) + * */ public class FieldDataLoader { @@ -106,7 +106,8 @@ public class FieldDataLoader { protected FreqsTypeLoader() { } - @Override public void init() { + @Override + public void init() { } } } diff --git a/src/main/java/org/elasticsearch/index/field/data/support/NumericFieldDataComparator.java b/src/main/java/org/elasticsearch/index/field/data/support/NumericFieldDataComparator.java index 38d9c26ee05..8857369ac45 100644 --- a/src/main/java/org/elasticsearch/index/field/data/support/NumericFieldDataComparator.java +++ b/src/main/java/org/elasticsearch/index/field/data/support/NumericFieldDataComparator.java @@ -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.index.field.data.NumericFieldData; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public abstract class NumericFieldDataComparator extends FieldComparator { @@ -45,7 +45,8 @@ public abstract class NumericFieldDataComparator extends FieldComparator { public abstract FieldDataType fieldDataType(); - @Override public void setNextReader(IndexReader reader, int docBase) throws IOException { + @Override + public void setNextReader(IndexReader reader, int docBase) throws IOException { currentFieldData = (NumericFieldData) fieldDataCache.cache(fieldDataType(), reader, fieldName); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/field/function/sort/DoubleFieldsFunctionDataComparator.java b/src/main/java/org/elasticsearch/index/field/function/sort/DoubleFieldsFunctionDataComparator.java index 62ae7466c89..ac7376cd371 100644 --- a/src/main/java/org/elasticsearch/index/field/function/sort/DoubleFieldsFunctionDataComparator.java +++ b/src/main/java/org/elasticsearch/index/field/function/sort/DoubleFieldsFunctionDataComparator.java @@ -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.script.SearchScript; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ // LUCENE MONITOR: Monitor against FieldComparator.Double public class DoubleFieldsFunctionDataComparator extends FieldComparator { @@ -46,11 +46,13 @@ public class DoubleFieldsFunctionDataComparator extends FieldComparator { this.script = script; } - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + @Override + public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { return new DoubleFieldsFunctionDataComparator(numHits, script); } - @Override public int reducedType() { + @Override + public int reducedType() { return SortField.DOUBLE; } } @@ -65,15 +67,18 @@ public class DoubleFieldsFunctionDataComparator extends FieldComparator { values = new double[numHits]; } - @Override public void setNextReader(IndexReader reader, int docBase) throws IOException { + @Override + public void setNextReader(IndexReader reader, int docBase) throws IOException { script.setNextReader(reader); } - @Override public void setScorer(Scorer scorer) { + @Override + public void setScorer(Scorer scorer) { script.setScorer(scorer); } - @Override public int compare(int slot1, int slot2) { + @Override + public int compare(int slot1, int slot2) { final double v1 = values[slot1]; final double v2 = values[slot2]; if (v1 > v2) { @@ -85,7 +90,8 @@ public class DoubleFieldsFunctionDataComparator extends FieldComparator { } } - @Override public int compareBottom(int doc) { + @Override + public int compareBottom(int doc) { script.setNextDocId(doc); final double v2 = script.runAsDouble(); if (bottom > v2) { @@ -97,16 +103,19 @@ public class DoubleFieldsFunctionDataComparator extends FieldComparator { } } - @Override public void copy(int slot, int doc) { + @Override + public void copy(int slot, int doc) { script.setNextDocId(doc); values[slot] = script.runAsDouble(); } - @Override public void setBottom(final int bottom) { + @Override + public void setBottom(final int bottom) { this.bottom = values[bottom]; } - @Override public Comparable value(int slot) { + @Override + public Comparable value(int slot) { return Double.valueOf(values[slot]); } } diff --git a/src/main/java/org/elasticsearch/index/field/function/sort/StringFieldsFunctionDataComparator.java b/src/main/java/org/elasticsearch/index/field/function/sort/StringFieldsFunctionDataComparator.java index a433aca0112..aaae60bcf55 100644 --- a/src/main/java/org/elasticsearch/index/field/function/sort/StringFieldsFunctionDataComparator.java +++ b/src/main/java/org/elasticsearch/index/field/function/sort/StringFieldsFunctionDataComparator.java @@ -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.script.SearchScript; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class StringFieldsFunctionDataComparator extends FieldComparator { @@ -45,11 +45,13 @@ public class StringFieldsFunctionDataComparator extends FieldComparator { this.script = script; } - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + @Override + public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { return new StringFieldsFunctionDataComparator(numHits, script); } - @Override public int reducedType() { + @Override + public int reducedType() { return SortField.STRING; } } @@ -65,15 +67,18 @@ public class StringFieldsFunctionDataComparator extends FieldComparator { values = new String[numHits]; } - @Override public void setNextReader(IndexReader reader, int docBase) throws IOException { + @Override + public void setNextReader(IndexReader reader, int docBase) throws IOException { script.setNextReader(reader); } - @Override public void setScorer(Scorer scorer) { + @Override + public void setScorer(Scorer scorer) { script.setScorer(scorer); } - @Override public int compare(int slot1, int slot2) { + @Override + public int compare(int slot1, int slot2) { final String val1 = values[slot1]; final String val2 = values[slot2]; if (val1 == null) { @@ -88,7 +93,8 @@ public class StringFieldsFunctionDataComparator extends FieldComparator { return val1.compareTo(val2); } - @Override public int compareBottom(int doc) { + @Override + public int compareBottom(int doc) { script.setNextDocId(doc); final String val2 = script.run().toString(); if (bottom == null) { @@ -102,16 +108,19 @@ public class StringFieldsFunctionDataComparator extends FieldComparator { return bottom.compareTo(val2); } - @Override public void copy(int slot, int doc) { + @Override + public void copy(int slot, int doc) { script.setNextDocId(doc); values[slot] = script.run().toString(); } - @Override public void setBottom(final int bottom) { + @Override + public void setBottom(final int bottom) { this.bottom = values[bottom]; } - @Override public Comparable value(int slot) { + @Override + public Comparable value(int slot) { return values[slot]; } } diff --git a/src/main/java/org/elasticsearch/index/flush/FlushStats.java b/src/main/java/org/elasticsearch/index/flush/FlushStats.java index 78ae390fbb9..83e6bdc2553 100644 --- a/src/main/java/org/elasticsearch/index/flush/FlushStats.java +++ b/src/main/java/org/elasticsearch/index/flush/FlushStats.java @@ -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 @@ -84,7 +84,8 @@ public class FlushStats implements Streamable, ToXContent { return flushStats; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(Fields.FLUSH); builder.field(Fields.TOTAL, total); builder.field(Fields.TOTAL_TIME, totalTime().toString()); @@ -100,12 +101,14 @@ public class FlushStats implements Streamable, ToXContent { static final XContentBuilderString TOTAL_TIME_IN_MILLIS = new XContentBuilderString("total_time_in_millis"); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { total = in.readVLong(); totalTimeInMillis = in.readVLong(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeVLong(total); out.writeVLong(totalTimeInMillis); } diff --git a/src/main/java/org/elasticsearch/index/gateway/CommitPoint.java b/src/main/java/org/elasticsearch/index/gateway/CommitPoint.java index 1791a50410c..b6f6abb2eea 100644 --- a/src/main/java/org/elasticsearch/index/gateway/CommitPoint.java +++ b/src/main/java/org/elasticsearch/index/gateway/CommitPoint.java @@ -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,14 +19,14 @@ package org.elasticsearch.index.gateway; +import com.google.common.collect.ImmutableList; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.collect.ImmutableList; import org.elasticsearch.index.store.StoreFileMetaData; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class CommitPoint { @@ -57,7 +57,8 @@ public class CommitPoint { return length; } - @Nullable public String checksum() { + @Nullable + public String checksum() { return checksum; } diff --git a/src/main/java/org/elasticsearch/index/gateway/CommitPoints.java b/src/main/java/org/elasticsearch/index/gateway/CommitPoints.java index cefb41176b7..d3253759197 100644 --- a/src/main/java/org/elasticsearch/index/gateway/CommitPoints.java +++ b/src/main/java/org/elasticsearch/index/gateway/CommitPoints.java @@ -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.index.gateway; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.Lists; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; @@ -33,7 +33,7 @@ import java.util.Iterator; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class CommitPoints implements Iterable { @@ -41,7 +41,8 @@ public class CommitPoints implements Iterable { public CommitPoints(List commitPoints) { Collections.sort(commitPoints, new Comparator() { - @Override public int compare(CommitPoint o1, CommitPoint o2) { + @Override + public int compare(CommitPoint o1, CommitPoint o2) { return (o2.version() < o1.version() ? -1 : (o2.version() == o1.version() ? 0 : 1)); } }); @@ -81,7 +82,8 @@ public class CommitPoints implements Iterable { return null; } - @Override public Iterator iterator() { + @Override + public Iterator iterator() { return commitPoints.iterator(); } diff --git a/src/main/java/org/elasticsearch/index/gateway/IgnoreGatewayRecoveryException.java b/src/main/java/org/elasticsearch/index/gateway/IgnoreGatewayRecoveryException.java index 446d350fefa..3bcc5ad065c 100644 --- a/src/main/java/org/elasticsearch/index/gateway/IgnoreGatewayRecoveryException.java +++ b/src/main/java/org/elasticsearch/index/gateway/IgnoreGatewayRecoveryException.java @@ -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.index.shard.ShardId; /** * An exception marking that this recovery attempt should be ignored (since probably, we already recovered). * - * @author kimchy (Shay Banon) + * */ public class IgnoreGatewayRecoveryException extends IndexShardException { diff --git a/src/main/java/org/elasticsearch/index/gateway/IndexGateway.java b/src/main/java/org/elasticsearch/index/gateway/IndexGateway.java index b9b3b65aa06..5721ab78a00 100644 --- a/src/main/java/org/elasticsearch/index/gateway/IndexGateway.java +++ b/src/main/java/org/elasticsearch/index/gateway/IndexGateway.java @@ -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.CloseableIndexComponent; import org.elasticsearch.index.IndexComponent; /** - * @author kimchy (shay.banon) + * */ public interface IndexGateway extends IndexComponent, CloseableIndexComponent { diff --git a/src/main/java/org/elasticsearch/index/gateway/IndexGatewayModule.java b/src/main/java/org/elasticsearch/index/gateway/IndexGatewayModule.java index 0cf5754b864..d1f33305ece 100644 --- a/src/main/java/org/elasticsearch/index/gateway/IndexGatewayModule.java +++ b/src/main/java/org/elasticsearch/index/gateway/IndexGatewayModule.java @@ -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,7 +19,7 @@ package org.elasticsearch.index.gateway; -import org.elasticsearch.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.inject.Modules; @@ -28,7 +28,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.gateway.Gateway; /** - * @author kimchy (shay.banon) + * */ public class IndexGatewayModule extends AbstractModule implements SpawnModules { @@ -41,10 +41,12 @@ public class IndexGatewayModule extends AbstractModule implements SpawnModules { this.gateway = gateway; } - @Override public Iterable spawnModules() { + @Override + public Iterable spawnModules() { return ImmutableList.of(Modules.createModule(settings.getAsClass("index.gateway.type", gateway.suggestIndexGateway(), "org.elasticsearch.index.gateway.", "IndexGatewayModule"), settings)); } - @Override protected void configure() { + @Override + protected void configure() { } } diff --git a/src/main/java/org/elasticsearch/index/gateway/IndexShardGateway.java b/src/main/java/org/elasticsearch/index/gateway/IndexShardGateway.java index 5fb919f42ca..ef6e312cca0 100644 --- a/src/main/java/org/elasticsearch/index/gateway/IndexShardGateway.java +++ b/src/main/java/org/elasticsearch/index/gateway/IndexShardGateway.java @@ -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.index.shard.IndexShardComponent; import org.elasticsearch.index.translog.Translog; /** - * @author kimchy (shay.banon) + * */ public interface IndexShardGateway extends IndexShardComponent, CloseableIndexComponent { @@ -76,7 +76,8 @@ public interface IndexShardGateway extends IndexShardComponent, CloseableIndexCo } public static final SnapshotLock NO_SNAPSHOT_LOCK = new SnapshotLock() { - @Override public void release() { + @Override + public void release() { } }; diff --git a/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewayException.java b/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewayException.java index d497755eb0e..74e9d1ac417 100644 --- a/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewayException.java +++ b/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewayException.java @@ -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 IndexShardGatewayException extends IndexShardException { diff --git a/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewayModule.java b/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewayModule.java index e931790a1bf..489ce87ff18 100644 --- a/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewayModule.java +++ b/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewayModule.java @@ -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.index.gateway; import org.elasticsearch.common.inject.AbstractModule; /** - * @author kimchy (Shay Banon) + * */ public class IndexShardGatewayModule extends AbstractModule { @@ -32,7 +32,8 @@ public class IndexShardGatewayModule extends AbstractModule { this.indexGateway = indexGateway; } - @Override protected void configure() { + @Override + protected void configure() { bind(IndexShardGateway.class) .to(indexGateway.shardGatewayClass()) .asEagerSingleton(); diff --git a/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewayRecoveryException.java b/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewayRecoveryException.java index 99c76975992..6c9f1ca045c 100644 --- a/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewayRecoveryException.java +++ b/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewayRecoveryException.java @@ -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.index.gateway; import org.elasticsearch.index.shard.ShardId; /** - * @author kimchy (Shay Banon) + * */ public class IndexShardGatewayRecoveryException extends IndexShardGatewayException { diff --git a/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewayService.java b/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewayService.java index c6db2f20c60..e4173afe0ea 100644 --- a/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewayService.java +++ b/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewayService.java @@ -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,12 +31,7 @@ import org.elasticsearch.index.engine.EngineException; import org.elasticsearch.index.engine.SnapshotFailedEngineException; import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.index.settings.IndexSettingsService; -import org.elasticsearch.index.shard.AbstractIndexShardComponent; -import org.elasticsearch.index.shard.IllegalIndexShardStateException; -import org.elasticsearch.index.shard.IndexShardClosedException; -import org.elasticsearch.index.shard.IndexShardNotStartedException; -import org.elasticsearch.index.shard.IndexShardState; -import org.elasticsearch.index.shard.ShardId; +import org.elasticsearch.index.shard.*; import org.elasticsearch.index.shard.service.IndexShard; import org.elasticsearch.index.shard.service.InternalIndexShard; import org.elasticsearch.index.translog.Translog; @@ -44,10 +39,10 @@ import org.elasticsearch.threadpool.ThreadPool; import java.util.concurrent.ScheduledFuture; -import static org.elasticsearch.common.unit.TimeValue.*; +import static org.elasticsearch.common.unit.TimeValue.timeValueMillis; /** - * @author kimchy (shay.banon) + * */ public class IndexShardGatewayService extends AbstractIndexShardComponent implements CloseableIndexComponent { @@ -82,8 +77,9 @@ public class IndexShardGatewayService extends AbstractIndexShardComponent implem private final ApplySettings applySettings = new ApplySettings(); - @Inject public IndexShardGatewayService(ShardId shardId, @IndexSettings Settings indexSettings, IndexSettingsService indexSettingsService, - ThreadPool threadPool, IndexShard indexShard, IndexShardGateway shardGateway) { + @Inject + public IndexShardGatewayService(ShardId shardId, @IndexSettings Settings indexSettings, IndexSettingsService indexSettingsService, + ThreadPool threadPool, IndexShard indexShard, IndexShardGateway shardGateway) { super(shardId, indexSettings); this.threadPool = threadPool; this.indexSettingsService = indexSettingsService; @@ -101,7 +97,8 @@ public class IndexShardGatewayService extends AbstractIndexShardComponent implem } class ApplySettings implements IndexSettingsService.Listener { - @Override public void onRefreshSettings(Settings settings) { + @Override + public void onRefreshSettings(Settings settings) { TimeValue snapshotInterval = settings.getAsTime("index.gateway.snapshot_interval", IndexShardGatewayService.this.snapshotInterval); if (!snapshotInterval.equals(IndexShardGatewayService.this.snapshotInterval)) { logger.info("updating snapshot_interval from [{}] to [{}]", IndexShardGatewayService.this.snapshotInterval, snapshotInterval); @@ -170,7 +167,8 @@ public class IndexShardGatewayService extends AbstractIndexShardComponent implem } threadPool.cached().execute(new Runnable() { - @Override public void run() { + @Override + public void run() { recoveryStatus = new RecoveryStatus(); recoveryStatus.updateStage(RecoveryStatus.Stage.INIT); @@ -264,7 +262,8 @@ public class IndexShardGatewayService extends AbstractIndexShardComponent implem try { SnapshotStatus snapshotStatus = indexShard.snapshot(new Engine.SnapshotHandler() { - @Override public SnapshotStatus snapshot(SnapshotIndexCommit snapshotIndexCommit, Translog.Snapshot translogSnapshot) throws EngineException { + @Override + public SnapshotStatus snapshot(SnapshotIndexCommit snapshotIndexCommit, Translog.Snapshot translogSnapshot) throws EngineException { if (lastIndexVersion != snapshotIndexCommit.getVersion() || lastTranslogId != translogSnapshot.translogId() || lastTranslogLength < translogSnapshot.length()) { logger.debug("snapshot ({}) to {} ...", reason, shardGateway); @@ -360,7 +359,8 @@ public class IndexShardGatewayService extends AbstractIndexShardComponent implem } private class SnapshotRunnable implements Runnable { - @Override public synchronized void run() { + @Override + public synchronized void run() { try { snapshot("scheduled"); } catch (Throwable e) { diff --git a/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewaySnapshotFailedException.java b/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewaySnapshotFailedException.java index 8a3ef8b3156..4650b81d383 100644 --- a/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewaySnapshotFailedException.java +++ b/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewaySnapshotFailedException.java @@ -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.index.gateway; import org.elasticsearch.index.shard.ShardId; /** - * @author kimchy (Shay Banon) + * */ public class IndexShardGatewaySnapshotFailedException extends IndexShardGatewayException { diff --git a/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewaySnapshotNotAllowedException.java b/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewaySnapshotNotAllowedException.java index 0e40989684b..55d4c4c594e 100644 --- a/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewaySnapshotNotAllowedException.java +++ b/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewaySnapshotNotAllowedException.java @@ -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.index.gateway; import org.elasticsearch.index.shard.ShardId; /** - * @author kimchy (Shay Banon) + * */ public class IndexShardGatewaySnapshotNotAllowedException extends IndexShardGatewayException { diff --git a/src/main/java/org/elasticsearch/index/gateway/RecoveryStatus.java b/src/main/java/org/elasticsearch/index/gateway/RecoveryStatus.java index 6a0bacc4ae6..0b761af9f65 100644 --- a/src/main/java/org/elasticsearch/index/gateway/RecoveryStatus.java +++ b/src/main/java/org/elasticsearch/index/gateway/RecoveryStatus.java @@ -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.index.gateway; import java.util.concurrent.atomic.AtomicLong; /** - * @author kimchy (shay.banon) + * */ public class RecoveryStatus { diff --git a/src/main/java/org/elasticsearch/index/gateway/SnapshotStatus.java b/src/main/java/org/elasticsearch/index/gateway/SnapshotStatus.java index 93bc8796c24..23c1cf987bf 100644 --- a/src/main/java/org/elasticsearch/index/gateway/SnapshotStatus.java +++ b/src/main/java/org/elasticsearch/index/gateway/SnapshotStatus.java @@ -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.index.gateway; /** - * @author kimchy (shay.banon) + * */ public class SnapshotStatus { diff --git a/src/main/java/org/elasticsearch/index/gateway/blobstore/BlobStoreIndexGateway.java b/src/main/java/org/elasticsearch/index/gateway/blobstore/BlobStoreIndexGateway.java index 1b976bdc628..ef5615884a8 100644 --- a/src/main/java/org/elasticsearch/index/gateway/blobstore/BlobStoreIndexGateway.java +++ b/src/main/java/org/elasticsearch/index/gateway/blobstore/BlobStoreIndexGateway.java @@ -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,7 +33,7 @@ import org.elasticsearch.index.gateway.IndexGateway; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public abstract class BlobStoreIndexGateway extends AbstractIndexComponent implements IndexGateway { @@ -60,7 +60,8 @@ public abstract class BlobStoreIndexGateway extends AbstractIndexComponent imple this.indexPath = this.gateway.basePath().add("indices").add(index.name()); } - @Override public String toString() { + @Override + public String toString() { return type() + "://" + blobStore + "/" + indexPath; } @@ -80,7 +81,8 @@ public abstract class BlobStoreIndexGateway extends AbstractIndexComponent imple return basePath.add("indices").add(index).add(Integer.toString(shardId)); } - @Override public void close(boolean delete) throws ElasticSearchException { + @Override + public void close(boolean delete) throws ElasticSearchException { if (delete) { blobStore.delete(indexPath); } diff --git a/src/main/java/org/elasticsearch/index/gateway/blobstore/BlobStoreIndexShardGateway.java b/src/main/java/org/elasticsearch/index/gateway/blobstore/BlobStoreIndexShardGateway.java index 98134909579..b6de2744636 100644 --- a/src/main/java/org/elasticsearch/index/gateway/blobstore/BlobStoreIndexShardGateway.java +++ b/src/main/java/org/elasticsearch/index/gateway/blobstore/BlobStoreIndexShardGateway.java @@ -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,19 +19,15 @@ package org.elasticsearch.index.gateway.blobstore; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; import org.apache.lucene.index.IndexReader; import org.apache.lucene.store.Directory; import org.apache.lucene.store.IndexInput; import org.apache.lucene.store.IndexOutput; import org.elasticsearch.ElasticSearchException; -import org.elasticsearch.common.blobstore.BlobContainer; -import org.elasticsearch.common.blobstore.BlobMetaData; -import org.elasticsearch.common.blobstore.BlobPath; -import org.elasticsearch.common.blobstore.BlobStore; -import org.elasticsearch.common.blobstore.ImmutableBlobContainer; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.Iterables; -import org.elasticsearch.common.collect.Lists; +import org.elasticsearch.common.blobstore.*; import org.elasticsearch.common.io.FastByteArrayInputStream; import org.elasticsearch.common.io.FastByteArrayOutputStream; import org.elasticsearch.common.io.stream.BytesStreamInput; @@ -40,14 +36,7 @@ import org.elasticsearch.common.lucene.store.ThreadSafeInputStreamIndexInput; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.index.deletionpolicy.SnapshotIndexCommit; -import org.elasticsearch.index.gateway.CommitPoint; -import org.elasticsearch.index.gateway.CommitPoints; -import org.elasticsearch.index.gateway.IndexGateway; -import org.elasticsearch.index.gateway.IndexShardGateway; -import org.elasticsearch.index.gateway.IndexShardGatewayRecoveryException; -import org.elasticsearch.index.gateway.IndexShardGatewaySnapshotFailedException; -import org.elasticsearch.index.gateway.RecoveryStatus; -import org.elasticsearch.index.gateway.SnapshotStatus; +import org.elasticsearch.index.gateway.*; import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.index.shard.AbstractIndexShardComponent; import org.elasticsearch.index.shard.ShardId; @@ -70,7 +59,7 @@ import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; /** - * @author kimchy (shay.banon) + * */ public abstract class BlobStoreIndexShardGateway extends AbstractIndexShardComponent implements IndexShardGateway { @@ -113,37 +102,45 @@ public abstract class BlobStoreIndexShardGateway extends AbstractIndexShardCompo this.recoveryStatus = new RecoveryStatus(); } - @Override public RecoveryStatus recoveryStatus() { + @Override + public RecoveryStatus recoveryStatus() { return this.recoveryStatus; } - @Override public String toString() { + @Override + public String toString() { return type() + "://" + blobStore + "/" + shardPath; } - @Override public boolean requiresSnapshot() { + @Override + public boolean requiresSnapshot() { return true; } - @Override public boolean requiresSnapshotScheduling() { + @Override + public boolean requiresSnapshotScheduling() { return true; } - @Override public SnapshotLock obtainSnapshotLock() throws Exception { + @Override + public SnapshotLock obtainSnapshotLock() throws Exception { return NO_SNAPSHOT_LOCK; } - @Override public void close(boolean delete) throws ElasticSearchException { + @Override + public void close(boolean delete) throws ElasticSearchException { if (delete) { blobStore.delete(shardPath); } } - @Override public SnapshotStatus lastSnapshotStatus() { + @Override + public SnapshotStatus lastSnapshotStatus() { return this.lastSnapshotStatus; } - @Override public SnapshotStatus currentSnapshotStatus() { + @Override + public SnapshotStatus currentSnapshotStatus() { SnapshotStatus snapshotStatus = this.currentSnapshotStatus; if (snapshotStatus == null) { return snapshotStatus; @@ -154,7 +151,8 @@ public abstract class BlobStoreIndexShardGateway extends AbstractIndexShardCompo return snapshotStatus; } - @Override public SnapshotStatus snapshot(final Snapshot snapshot) throws IndexShardGatewaySnapshotFailedException { + @Override + public SnapshotStatus snapshot(final Snapshot snapshot) throws IndexShardGatewaySnapshotFailedException { currentSnapshotStatus = new SnapshotStatus(); currentSnapshotStatus.startTime(System.currentTimeMillis()); @@ -369,7 +367,8 @@ public abstract class BlobStoreIndexShardGateway extends AbstractIndexShardCompo } } - @Override public void recover(boolean indexShouldExists, RecoveryStatus recoveryStatus) throws IndexShardGatewayRecoveryException { + @Override + public void recover(boolean indexShouldExists, RecoveryStatus recoveryStatus) throws IndexShardGatewayRecoveryException { this.recoveryStatus = recoveryStatus; final ImmutableMap blobs; @@ -453,7 +452,8 @@ public abstract class BlobStoreIndexShardGateway extends AbstractIndexShardCompo FastByteArrayOutputStream bos = new FastByteArrayOutputStream(); boolean ignore = false; - @Override public synchronized void onPartial(byte[] data, int offset, int size) throws IOException { + @Override + public synchronized void onPartial(byte[] data, int offset, int size) throws IOException { if (ignore) { return; } @@ -503,7 +503,8 @@ public abstract class BlobStoreIndexShardGateway extends AbstractIndexShardCompo bos = newBos; } - @Override public synchronized void onCompleted() { + @Override + public synchronized void onCompleted() { if (ignore) { return; } @@ -514,7 +515,8 @@ public abstract class BlobStoreIndexShardGateway extends AbstractIndexShardCompo blobContainer.readBlob(transIt.next().name(), this); } - @Override public void onFailure(Throwable t) { + @Override + public void onFailure(Throwable t) { failure.set(t); latch.countDown(); } @@ -649,12 +651,14 @@ public abstract class BlobStoreIndexShardGateway extends AbstractIndexShardCompo final AtomicInteger partIndex = new AtomicInteger(); blobContainer.readBlob(firstFileToRecover, new BlobContainer.ReadBlobListener() { - @Override public synchronized void onPartial(byte[] data, int offset, int size) throws IOException { + @Override + public synchronized void onPartial(byte[] data, int offset, int size) throws IOException { recoveryStatus.index().addCurrentFilesSize(size); indexOutput.writeBytes(data, offset, size); } - @Override public synchronized void onCompleted() { + @Override + public synchronized void onCompleted() { int part = partIndex.incrementAndGet(); String partName = fileInfo.name() + ".part" + part; if (blobs.containsKey(partName)) { @@ -678,7 +682,8 @@ public abstract class BlobStoreIndexShardGateway extends AbstractIndexShardCompo latch.countDown(); } - @Override public void onFailure(Throwable t) { + @Override + public void onFailure(Throwable t) { failures.add(t); latch.countDown(); } @@ -752,7 +757,8 @@ public abstract class BlobStoreIndexShardGateway extends AbstractIndexShardCompo final IndexInput fIndexInput = indexInput; blobContainer.writeBlob(blobName, is, is.actualSizeToRead(), new ImmutableBlobContainer.WriterListener() { - @Override public void onCompleted() { + @Override + public void onCompleted() { try { fIndexInput.close(); } catch (IOException e) { @@ -763,7 +769,8 @@ public abstract class BlobStoreIndexShardGateway extends AbstractIndexShardCompo } } - @Override public void onFailure(Throwable t) { + @Override + public void onFailure(Throwable t) { try { fIndexInput.close(); } catch (IOException e) { diff --git a/src/main/java/org/elasticsearch/index/gateway/fs/FsIndexGateway.java b/src/main/java/org/elasticsearch/index/gateway/fs/FsIndexGateway.java index 7f4b3474c50..9636cb9e2be 100644 --- a/src/main/java/org/elasticsearch/index/gateway/fs/FsIndexGateway.java +++ b/src/main/java/org/elasticsearch/index/gateway/fs/FsIndexGateway.java @@ -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,19 +28,22 @@ import org.elasticsearch.index.gateway.blobstore.BlobStoreIndexGateway; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class FsIndexGateway extends BlobStoreIndexGateway { - @Inject public FsIndexGateway(Index index, @IndexSettings Settings indexSettings, Gateway gateway) { + @Inject + public FsIndexGateway(Index index, @IndexSettings Settings indexSettings, Gateway gateway) { super(index, indexSettings, gateway); } - @Override public String type() { + @Override + public String type() { return "fs"; } - @Override public Class shardGatewayClass() { + @Override + public Class shardGatewayClass() { return FsIndexShardGateway.class; } } diff --git a/src/main/java/org/elasticsearch/index/gateway/fs/FsIndexGatewayModule.java b/src/main/java/org/elasticsearch/index/gateway/fs/FsIndexGatewayModule.java index 67e65d9575c..20753b83fd9 100644 --- a/src/main/java/org/elasticsearch/index/gateway/fs/FsIndexGatewayModule.java +++ b/src/main/java/org/elasticsearch/index/gateway/fs/FsIndexGatewayModule.java @@ -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,11 +23,12 @@ import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.index.gateway.IndexGateway; /** - * @author kimchy (Shay Banon) + * */ public class FsIndexGatewayModule extends AbstractModule { - @Override protected void configure() { + @Override + protected void configure() { bind(IndexGateway.class).to(FsIndexGateway.class).asEagerSingleton(); } } diff --git a/src/main/java/org/elasticsearch/index/gateway/fs/FsIndexShardGateway.java b/src/main/java/org/elasticsearch/index/gateway/fs/FsIndexShardGateway.java index f4113f9808d..703a47f257d 100644 --- a/src/main/java/org/elasticsearch/index/gateway/fs/FsIndexShardGateway.java +++ b/src/main/java/org/elasticsearch/index/gateway/fs/FsIndexShardGateway.java @@ -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,23 +36,26 @@ import org.elasticsearch.threadpool.ThreadPool; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class FsIndexShardGateway extends BlobStoreIndexShardGateway { private final boolean snapshotLock; - @Inject public FsIndexShardGateway(ShardId shardId, @IndexSettings Settings indexSettings, ThreadPool threadPool, IndexGateway fsIndexGateway, - IndexShard indexShard, Store store) { + @Inject + public FsIndexShardGateway(ShardId shardId, @IndexSettings Settings indexSettings, ThreadPool threadPool, IndexGateway fsIndexGateway, + IndexShard indexShard, Store store) { super(shardId, indexSettings, threadPool, fsIndexGateway, indexShard, store); this.snapshotLock = indexSettings.getAsBoolean("gateway.fs.snapshot_lock", true); } - @Override public String type() { + @Override + public String type() { return "fs"; } - @Override public SnapshotLock obtainSnapshotLock() throws Exception { + @Override + public SnapshotLock obtainSnapshotLock() throws Exception { if (!snapshotLock) { return NO_SNAPSHOT_LOCK; } @@ -74,7 +77,8 @@ public class FsIndexShardGateway extends BlobStoreIndexShardGateway { this.lock = lock; } - @Override public void release() { + @Override + public void release() { try { lock.release(); } catch (IOException e) { diff --git a/src/main/java/org/elasticsearch/index/gateway/local/LocalIndexGateway.java b/src/main/java/org/elasticsearch/index/gateway/local/LocalIndexGateway.java index e93ea309b63..f911c331683 100644 --- a/src/main/java/org/elasticsearch/index/gateway/local/LocalIndexGateway.java +++ b/src/main/java/org/elasticsearch/index/gateway/local/LocalIndexGateway.java @@ -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,26 +28,31 @@ import org.elasticsearch.index.gateway.IndexShardGateway; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class LocalIndexGateway extends AbstractIndexComponent implements IndexGateway { - @Inject public LocalIndexGateway(Index index, @IndexSettings Settings indexSettings) { + @Inject + public LocalIndexGateway(Index index, @IndexSettings Settings indexSettings) { super(index, indexSettings); } - @Override public String type() { + @Override + public String type() { return "local"; } - @Override public Class shardGatewayClass() { + @Override + public Class shardGatewayClass() { return LocalIndexShardGateway.class; } - @Override public String toString() { + @Override + public String toString() { return "local"; } - @Override public void close(boolean delete) { + @Override + public void close(boolean delete) { } } diff --git a/src/main/java/org/elasticsearch/index/gateway/local/LocalIndexGatewayModule.java b/src/main/java/org/elasticsearch/index/gateway/local/LocalIndexGatewayModule.java index b353aa94281..71d73af1e8e 100644 --- a/src/main/java/org/elasticsearch/index/gateway/local/LocalIndexGatewayModule.java +++ b/src/main/java/org/elasticsearch/index/gateway/local/LocalIndexGatewayModule.java @@ -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,11 +23,12 @@ import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.index.gateway.IndexGateway; /** - * @author kimchy (shay.banon) + * */ public class LocalIndexGatewayModule extends AbstractModule { - @Override protected void configure() { + @Override + protected void configure() { bind(IndexGateway.class).to(LocalIndexGateway.class).asEagerSingleton(); } } diff --git a/src/main/java/org/elasticsearch/index/gateway/local/LocalIndexShardGateway.java b/src/main/java/org/elasticsearch/index/gateway/local/LocalIndexShardGateway.java index 6e42255ff6e..6955e0289a1 100644 --- a/src/main/java/org/elasticsearch/index/gateway/local/LocalIndexShardGateway.java +++ b/src/main/java/org/elasticsearch/index/gateway/local/LocalIndexShardGateway.java @@ -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 @@ -47,7 +47,7 @@ import java.util.Map; import java.util.concurrent.ScheduledFuture; /** - * @author kimchy (shay.banon) + * */ public class LocalIndexShardGateway extends AbstractIndexShardComponent implements IndexShardGateway { @@ -57,7 +57,8 @@ public class LocalIndexShardGateway extends AbstractIndexShardComponent implemen private final ScheduledFuture flushScheduler; - @Inject public LocalIndexShardGateway(ShardId shardId, @IndexSettings Settings indexSettings, ThreadPool threadPool, IndexShard indexShard) { + @Inject + public LocalIndexShardGateway(ShardId shardId, @IndexSettings Settings indexSettings, ThreadPool threadPool, IndexShard indexShard) { super(shardId, indexSettings); this.indexShard = (InternalIndexShard) indexShard; @@ -74,15 +75,18 @@ public class LocalIndexShardGateway extends AbstractIndexShardComponent implemen } } - @Override public String toString() { + @Override + public String toString() { return "local"; } - @Override public RecoveryStatus recoveryStatus() { + @Override + public RecoveryStatus recoveryStatus() { return recoveryStatus; } - @Override public void recover(boolean indexShouldExists, RecoveryStatus recoveryStatus) throws IndexShardGatewayRecoveryException { + @Override + public void recover(boolean indexShouldExists, RecoveryStatus recoveryStatus) throws IndexShardGatewayRecoveryException { recoveryStatus.index().startTime(System.currentTimeMillis()); long version = -1; long translogId = -1; @@ -191,42 +195,51 @@ public class LocalIndexShardGateway extends AbstractIndexShardComponent implemen recoveryStatus.translog().time(System.currentTimeMillis() - recoveryStatus.index().startTime()); } - @Override public String type() { + @Override + public String type() { return "local"; } - @Override public SnapshotStatus snapshot(Snapshot snapshot) { + @Override + public SnapshotStatus snapshot(Snapshot snapshot) { return null; } - @Override public SnapshotStatus lastSnapshotStatus() { + @Override + public SnapshotStatus lastSnapshotStatus() { return null; } - @Override public SnapshotStatus currentSnapshotStatus() { + @Override + public SnapshotStatus currentSnapshotStatus() { return null; } - @Override public boolean requiresSnapshot() { + @Override + public boolean requiresSnapshot() { return false; } - @Override public boolean requiresSnapshotScheduling() { + @Override + public boolean requiresSnapshotScheduling() { return false; } - @Override public void close(boolean delete) { + @Override + public void close(boolean delete) { if (flushScheduler != null) { flushScheduler.cancel(false); } } - @Override public SnapshotLock obtainSnapshotLock() throws Exception { + @Override + public SnapshotLock obtainSnapshotLock() throws Exception { return NO_SNAPSHOT_LOCK; } private class Sync implements Runnable { - @Override public void run() { + @Override + public void run() { if (indexShard.state() == IndexShardState.STARTED) { indexShard.translog().sync(); } diff --git a/src/main/java/org/elasticsearch/index/gateway/none/NoneIndexGateway.java b/src/main/java/org/elasticsearch/index/gateway/none/NoneIndexGateway.java index 4ce2c859600..2aea4d54f2b 100644 --- a/src/main/java/org/elasticsearch/index/gateway/none/NoneIndexGateway.java +++ b/src/main/java/org/elasticsearch/index/gateway/none/NoneIndexGateway.java @@ -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,26 +28,31 @@ import org.elasticsearch.index.gateway.IndexShardGateway; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (shay.banon) + * */ public class NoneIndexGateway extends AbstractIndexComponent implements IndexGateway { - @Inject public NoneIndexGateway(Index index, @IndexSettings Settings indexSettings) { + @Inject + public NoneIndexGateway(Index index, @IndexSettings Settings indexSettings) { super(index, indexSettings); } - @Override public String type() { + @Override + public String type() { return "none"; } - @Override public Class shardGatewayClass() { + @Override + public Class shardGatewayClass() { return NoneIndexShardGateway.class; } - @Override public String toString() { + @Override + public String toString() { return "_none_"; } - @Override public void close(boolean delete) { + @Override + public void close(boolean delete) { } } diff --git a/src/main/java/org/elasticsearch/index/gateway/none/NoneIndexGatewayModule.java b/src/main/java/org/elasticsearch/index/gateway/none/NoneIndexGatewayModule.java index 4c5b7ba229b..cf400ccddd1 100644 --- a/src/main/java/org/elasticsearch/index/gateway/none/NoneIndexGatewayModule.java +++ b/src/main/java/org/elasticsearch/index/gateway/none/NoneIndexGatewayModule.java @@ -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,11 +23,12 @@ import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.index.gateway.IndexGateway; /** - * @author kimchy (shay.banon) + * */ public class NoneIndexGatewayModule extends AbstractModule { - @Override protected void configure() { + @Override + protected void configure() { bind(IndexGateway.class).to(NoneIndexGateway.class).asEagerSingleton(); } } diff --git a/src/main/java/org/elasticsearch/index/gateway/none/NoneIndexShardGateway.java b/src/main/java/org/elasticsearch/index/gateway/none/NoneIndexShardGateway.java index a8c32d9ed76..8af45314751 100644 --- a/src/main/java/org/elasticsearch/index/gateway/none/NoneIndexShardGateway.java +++ b/src/main/java/org/elasticsearch/index/gateway/none/NoneIndexShardGateway.java @@ -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.index.shard.service.InternalIndexShard; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class NoneIndexShardGateway extends AbstractIndexShardComponent implements IndexShardGateway { @@ -43,20 +43,24 @@ public class NoneIndexShardGateway extends AbstractIndexShardComponent implement private final RecoveryStatus recoveryStatus = new RecoveryStatus(); - @Inject public NoneIndexShardGateway(ShardId shardId, @IndexSettings Settings indexSettings, IndexShard indexShard) { + @Inject + public NoneIndexShardGateway(ShardId shardId, @IndexSettings Settings indexSettings, IndexShard indexShard) { super(shardId, indexSettings); this.indexShard = (InternalIndexShard) indexShard; } - @Override public String toString() { + @Override + public String toString() { return "_none_"; } - @Override public RecoveryStatus recoveryStatus() { + @Override + public RecoveryStatus recoveryStatus() { return recoveryStatus; } - @Override public void recover(boolean indexShouldExists, RecoveryStatus recoveryStatus) throws IndexShardGatewayRecoveryException { + @Override + public void recover(boolean indexShouldExists, RecoveryStatus recoveryStatus) throws IndexShardGatewayRecoveryException { recoveryStatus().index().startTime(System.currentTimeMillis()); // in the none case, we simply start the shard // clean the store, there should be nothing there... @@ -71,34 +75,42 @@ public class NoneIndexShardGateway extends AbstractIndexShardComponent implement recoveryStatus.translog().time(System.currentTimeMillis() - recoveryStatus.index().startTime()); } - @Override public String type() { + @Override + public String type() { return NoneGateway.TYPE; } - @Override public SnapshotStatus snapshot(Snapshot snapshot) { + @Override + public SnapshotStatus snapshot(Snapshot snapshot) { return null; } - @Override public SnapshotStatus lastSnapshotStatus() { + @Override + public SnapshotStatus lastSnapshotStatus() { return null; } - @Override public SnapshotStatus currentSnapshotStatus() { + @Override + public SnapshotStatus currentSnapshotStatus() { return null; } - @Override public boolean requiresSnapshot() { + @Override + public boolean requiresSnapshot() { return false; } - @Override public boolean requiresSnapshotScheduling() { + @Override + public boolean requiresSnapshotScheduling() { return false; } - @Override public void close(boolean delete) { + @Override + public void close(boolean delete) { } - @Override public SnapshotLock obtainSnapshotLock() throws Exception { + @Override + public SnapshotLock obtainSnapshotLock() throws Exception { return NO_SNAPSHOT_LOCK; } } diff --git a/src/main/java/org/elasticsearch/index/get/GetField.java b/src/main/java/org/elasticsearch/index/get/GetField.java index a2ab35e9e9d..a3ecdfc36f4 100644 --- a/src/main/java/org/elasticsearch/index/get/GetField.java +++ b/src/main/java/org/elasticsearch/index/get/GetField.java @@ -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.Iterator; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class GetField implements Streamable, Iterable { @@ -74,7 +74,8 @@ public class GetField implements Streamable, Iterable { return values; } - @Override public Iterator iterator() { + @Override + public Iterator iterator() { return values.iterator(); } @@ -84,7 +85,8 @@ public class GetField implements Streamable, Iterable { return result; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { name = in.readUTF(); int size = in.readVInt(); values = new ArrayList(size); @@ -93,7 +95,8 @@ public class GetField implements Streamable, Iterable { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(name); out.writeVInt(values.size()); for (Object obj : values) { diff --git a/src/main/java/org/elasticsearch/index/get/GetResult.java b/src/main/java/org/elasticsearch/index/get/GetResult.java index 816b910df44..028381d0f60 100644 --- a/src/main/java/org/elasticsearch/index/get/GetResult.java +++ b/src/main/java/org/elasticsearch/index/get/GetResult.java @@ -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.index.get; +import com.google.common.collect.ImmutableMap; import org.elasticsearch.ElasticSearchParseException; import org.elasticsearch.common.BytesHolder; import org.elasticsearch.common.Unicode; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.compress.lzf.LZF; import org.elasticsearch.common.compress.lzf.LZFDecoder; import org.elasticsearch.common.io.stream.StreamInput; @@ -38,9 +38,9 @@ import java.io.IOException; import java.util.Iterator; import java.util.Map; -import static org.elasticsearch.common.collect.Iterators.*; -import static org.elasticsearch.common.collect.Maps.*; -import static org.elasticsearch.index.get.GetField.*; +import static com.google.common.collect.Iterators.emptyIterator; +import static com.google.common.collect.Maps.newHashMapWithExpectedSize; +import static org.elasticsearch.index.get.GetField.readGetField; /** */ @@ -229,7 +229,8 @@ public class GetResult implements Streamable, Iterable, ToXContent { return fields.get(name); } - @Override public Iterator iterator() { + @Override + public Iterator iterator() { if (fields == null) { return emptyIterator(); } @@ -245,7 +246,8 @@ public class GetResult implements Streamable, Iterable, ToXContent { static final XContentBuilderString FIELDS = new XContentBuilderString("fields"); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { if (!exists()) { builder.startObject(); builder.field(Fields._INDEX, index); @@ -298,7 +300,8 @@ public class GetResult implements Streamable, Iterable, ToXContent { return result; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { index = in.readUTF(); type = in.readUTF(); id = in.readUTF(); @@ -321,7 +324,8 @@ public class GetResult implements Streamable, Iterable, ToXContent { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(index); out.writeUTF(type); out.writeUTF(id); diff --git a/src/main/java/org/elasticsearch/index/get/GetStats.java b/src/main/java/org/elasticsearch/index/get/GetStats.java index 49fdf90b549..eecb31cd7ac 100644 --- a/src/main/java/org/elasticsearch/index/get/GetStats.java +++ b/src/main/java/org/elasticsearch/index/get/GetStats.java @@ -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 @@ -141,7 +141,8 @@ public class GetStats implements Streamable, ToXContent { return this.current; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(Fields.GET); builder.field(Fields.TOTAL, count()); builder.field(Fields.TIME, time().toString()); @@ -177,7 +178,8 @@ public class GetStats implements Streamable, ToXContent { return stats; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { existsCount = in.readVLong(); existsTimeInMillis = in.readVLong(); missingCount = in.readVLong(); @@ -185,7 +187,8 @@ public class GetStats implements Streamable, ToXContent { current = in.readVLong(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeVLong(existsCount); out.writeVLong(existsTimeInMillis); out.writeVLong(missingCount); diff --git a/src/main/java/org/elasticsearch/index/get/ShardGetModule.java b/src/main/java/org/elasticsearch/index/get/ShardGetModule.java index 5356a095f76..275b09265af 100644 --- a/src/main/java/org/elasticsearch/index/get/ShardGetModule.java +++ b/src/main/java/org/elasticsearch/index/get/ShardGetModule.java @@ -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,8 @@ import org.elasticsearch.common.inject.AbstractModule; */ public class ShardGetModule extends AbstractModule { - @Override protected void configure() { + @Override + protected void configure() { bind(ShardGetService.class).asEagerSingleton(); } } diff --git a/src/main/java/org/elasticsearch/index/get/ShardGetService.java b/src/main/java/org/elasticsearch/index/get/ShardGetService.java index b7fec0987e8..8af217bf3ba 100644 --- a/src/main/java/org/elasticsearch/index/get/ShardGetService.java +++ b/src/main/java/org/elasticsearch/index/get/ShardGetService.java @@ -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,16 +31,8 @@ import org.elasticsearch.common.metrics.MeanMetric; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.cache.IndexCache; import org.elasticsearch.index.engine.Engine; -import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.mapper.FieldMapper; -import org.elasticsearch.index.mapper.FieldMappers; -import org.elasticsearch.index.mapper.MapperService; -import org.elasticsearch.index.mapper.Uid; -import org.elasticsearch.index.mapper.internal.ParentFieldMapper; -import org.elasticsearch.index.mapper.internal.RoutingFieldMapper; -import org.elasticsearch.index.mapper.internal.TTLFieldMapper; -import org.elasticsearch.index.mapper.internal.TimestampFieldMapper; -import org.elasticsearch.index.mapper.internal.UidFieldMapper; +import org.elasticsearch.index.mapper.*; +import org.elasticsearch.index.mapper.internal.*; import org.elasticsearch.index.mapper.selector.FieldMappersFieldSelector; import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.index.shard.AbstractIndexShardComponent; @@ -57,7 +49,7 @@ import java.util.ArrayList; import java.util.Map; import java.util.concurrent.TimeUnit; -import static org.elasticsearch.common.collect.Maps.*; +import static com.google.common.collect.Maps.newHashMapWithExpectedSize; /** */ @@ -75,8 +67,9 @@ public class ShardGetService extends AbstractIndexShardComponent { private final MeanMetric missingMetric = new MeanMetric(); private final CounterMetric currentMetric = new CounterMetric(); - @Inject public ShardGetService(ShardId shardId, @IndexSettings Settings indexSettings, ScriptService scriptService, - MapperService mapperService, IndexCache indexCache) { + @Inject + public ShardGetService(ShardId shardId, @IndexSettings Settings indexSettings, ScriptService scriptService, + MapperService mapperService, IndexCache indexCache) { super(shardId, indexSettings); this.scriptService = scriptService; this.mapperService = mapperService; diff --git a/src/main/java/org/elasticsearch/index/indexing/IndexingOperationListener.java b/src/main/java/org/elasticsearch/index/indexing/IndexingOperationListener.java index 9f52949aa29..790c79b717e 100644 --- a/src/main/java/org/elasticsearch/index/indexing/IndexingOperationListener.java +++ b/src/main/java/org/elasticsearch/index/indexing/IndexingOperationListener.java @@ -22,7 +22,7 @@ package org.elasticsearch.index.indexing; import org.elasticsearch.index.engine.Engine; /** - * @author kimchy (shay.banon) + * */ public abstract class IndexingOperationListener { diff --git a/src/main/java/org/elasticsearch/index/indexing/IndexingStats.java b/src/main/java/org/elasticsearch/index/indexing/IndexingStats.java index 6965df46ded..2e2f53cb801 100644 --- a/src/main/java/org/elasticsearch/index/indexing/IndexingStats.java +++ b/src/main/java/org/elasticsearch/index/indexing/IndexingStats.java @@ -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 @@ -132,7 +132,8 @@ public class IndexingStats implements Streamable, ToXContent { return stats; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { indexCount = in.readVLong(); indexTimeInMillis = in.readVLong(); indexCurrent = in.readVLong(); @@ -142,7 +143,8 @@ public class IndexingStats implements Streamable, ToXContent { deleteCurrent = in.readVLong(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeVLong(indexCount); out.writeVLong(indexTimeInMillis); out.writeVLong(indexCurrent); @@ -152,7 +154,8 @@ public class IndexingStats implements Streamable, ToXContent { out.writeVLong(deleteCurrent); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.field(Fields.INDEX_TOTAL, indexCount); builder.field(Fields.INDEX_TIME, indexTime().toString()); builder.field(Fields.INDEX_TIME_IN_MILLIS, indexTimeInMillis); @@ -169,7 +172,8 @@ public class IndexingStats implements Streamable, ToXContent { private Stats totalStats; - @Nullable private Map typeStats; + @Nullable + private Map typeStats; public IndexingStats() { totalStats = new Stats(); @@ -208,11 +212,13 @@ public class IndexingStats implements Streamable, ToXContent { return this.totalStats; } - @Nullable public Map typeStats() { + @Nullable + public Map typeStats() { return this.typeStats; } - @Override public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException { builder.startObject(Fields.INDEXING); totalStats.toXContent(builder, params); if (typeStats != null && !typeStats.isEmpty()) { @@ -247,7 +253,8 @@ public class IndexingStats implements Streamable, ToXContent { return indexingStats; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { totalStats = Stats.readStats(in); if (in.readBoolean()) { int size = in.readVInt(); @@ -258,7 +265,8 @@ public class IndexingStats implements Streamable, ToXContent { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { totalStats.writeTo(out); if (typeStats == null || typeStats.isEmpty()) { out.writeBoolean(false); diff --git a/src/main/java/org/elasticsearch/index/indexing/ShardIndexingModule.java b/src/main/java/org/elasticsearch/index/indexing/ShardIndexingModule.java index 4f603a4d8da..a85a4ade4b2 100644 --- a/src/main/java/org/elasticsearch/index/indexing/ShardIndexingModule.java +++ b/src/main/java/org/elasticsearch/index/indexing/ShardIndexingModule.java @@ -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,8 @@ import org.elasticsearch.common.inject.AbstractModule; */ public class ShardIndexingModule extends AbstractModule { - @Override protected void configure() { + @Override + protected void configure() { bind(ShardIndexingService.class).asEagerSingleton(); } } diff --git a/src/main/java/org/elasticsearch/index/indexing/ShardIndexingService.java b/src/main/java/org/elasticsearch/index/indexing/ShardIndexingService.java index e5d5229af31..12060c40c0c 100644 --- a/src/main/java/org/elasticsearch/index/indexing/ShardIndexingService.java +++ b/src/main/java/org/elasticsearch/index/indexing/ShardIndexingService.java @@ -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,7 +19,7 @@ package org.elasticsearch.index.indexing; -import org.elasticsearch.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMap; import org.elasticsearch.common.collect.MapBuilder; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.metrics.CounterMetric; @@ -45,7 +45,8 @@ public class ShardIndexingService extends AbstractIndexShardComponent { private CopyOnWriteArrayList listeners = null; - @Inject public ShardIndexingService(ShardId shardId, @IndexSettings Settings indexSettings) { + @Inject + public ShardIndexingService(ShardId shardId, @IndexSettings Settings indexSettings) { super(shardId, indexSettings); } diff --git a/src/main/java/org/elasticsearch/index/mapper/ContentPath.java b/src/main/java/org/elasticsearch/index/mapper/ContentPath.java index 7cf199815fd..d53b67d5e10 100644 --- a/src/main/java/org/elasticsearch/index/mapper/ContentPath.java +++ b/src/main/java/org/elasticsearch/index/mapper/ContentPath.java @@ -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.index.mapper; import org.elasticsearch.common.util.concurrent.NotThreadSafe; /** - * @author kimchy (Shay Banon) + * */ @NotThreadSafe public class ContentPath { diff --git a/src/main/java/org/elasticsearch/index/mapper/DocumentFieldMappers.java b/src/main/java/org/elasticsearch/index/mapper/DocumentFieldMappers.java index dca26edeb03..d2cbb813c18 100644 --- a/src/main/java/org/elasticsearch/index/mapper/DocumentFieldMappers.java +++ b/src/main/java/org/elasticsearch/index/mapper/DocumentFieldMappers.java @@ -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.index.mapper; +import com.google.common.collect.*; import org.apache.lucene.analysis.Analyzer; -import org.elasticsearch.common.collect.*; import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.util.concurrent.Immutable; import org.elasticsearch.index.analysis.FieldNameAnalyzer; @@ -28,11 +28,11 @@ import org.elasticsearch.index.analysis.FieldNameAnalyzer; import java.util.Map; import java.util.Set; -import static org.elasticsearch.common.collect.Lists.*; -import static org.elasticsearch.common.collect.Maps.*; +import static com.google.common.collect.Lists.newArrayList; +import static com.google.common.collect.Maps.newHashMap; /** - * @author kimchy (Shay Banon) + * */ @Immutable public class DocumentFieldMappers implements Iterable { @@ -94,7 +94,8 @@ public class DocumentFieldMappers implements Iterable { this.searchAnalyzer = new FieldNameAnalyzer(searchAnalyzers, docMapper.searchAnalyzer()); } - @Override public UnmodifiableIterator iterator() { + @Override + public UnmodifiableIterator iterator() { return fieldMappers.iterator(); } diff --git a/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java b/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java index a1b4625a18f..0b69d3ed5ea 100644 --- a/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java @@ -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,8 @@ package org.elasticsearch.index.mapper; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; @@ -27,17 +29,10 @@ import org.apache.lucene.search.Filter; import org.elasticsearch.common.Booleans; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Preconditions; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.collect.MapBuilder; -import org.elasticsearch.common.collect.Maps; import org.elasticsearch.common.compress.CompressedString; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.xcontent.ToXContent; -import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.common.xcontent.XContentFactory; -import org.elasticsearch.common.xcontent.XContentHelper; -import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.common.xcontent.XContentType; +import org.elasticsearch.common.xcontent.*; import org.elasticsearch.index.analysis.NamedAnalyzer; import org.elasticsearch.index.mapper.internal.*; import org.elasticsearch.index.mapper.object.ObjectMapper; @@ -50,10 +45,10 @@ import java.util.List; import java.util.Map; import java.util.concurrent.CopyOnWriteArrayList; -import static org.elasticsearch.common.collect.Lists.*; +import static com.google.common.collect.Lists.newArrayList; /** - * @author kimchy (shay.banon) + * */ public class DocumentMapper implements ToXContent { @@ -123,7 +118,8 @@ public class DocumentMapper implements ToXContent { public static class ParseListenerAdapter implements ParseListener { - @Override public boolean beforeFieldAdded(FieldMapper fieldMapper, Fieldable fieldable, Object parseContext) { + @Override + public boolean beforeFieldAdded(FieldMapper fieldMapper, Fieldable fieldable, Object parseContext) { return true; } } @@ -138,7 +134,8 @@ public class DocumentMapper implements ToXContent { private final String index; - @Nullable private final Settings indexSettings; + @Nullable + private final Settings indexSettings; private final RootObjectMapper rootObjectMapper; @@ -213,7 +210,8 @@ public class DocumentMapper implements ToXContent { private ThreadLocal cache = new ThreadLocal() { - @Override protected ParseContext initialValue() { + @Override + protected ParseContext initialValue() { return new ParseContext(index, indexSettings, docMapperParser, DocumentMapper.this, new ContentPath(0)); } }; @@ -299,7 +297,8 @@ public class DocumentMapper implements ToXContent { // now traverse and get all the statically defined ones rootObjectMapper.traverse(new FieldMapperListener() { - @Override public void fieldMapper(FieldMapper fieldMapper) { + @Override + public void fieldMapper(FieldMapper fieldMapper) { tempFieldMappers.add(fieldMapper); } }); @@ -308,7 +307,8 @@ public class DocumentMapper implements ToXContent { final Map objectMappers = Maps.newHashMap(); rootObjectMapper.traverse(new ObjectMapperListener() { - @Override public void objectMapper(ObjectMapper objectMapper) { + @Override + public void objectMapper(ObjectMapper objectMapper) { objectMappers.put(objectMapper.fullPath(), objectMapper); } }); @@ -342,7 +342,8 @@ public class DocumentMapper implements ToXContent { return rootMapper(UidFieldMapper.class); } - @SuppressWarnings({"unchecked"}) public T rootMapper(Class type) { + @SuppressWarnings({"unchecked"}) + public T rootMapper(Class type) { return (T) rootMappers.get(type); } @@ -579,9 +580,11 @@ public class DocumentMapper implements ToXContent { } } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { rootObjectMapper.toXContent(builder, params, new ToXContent() { - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { if (indexAnalyzer != null && searchAnalyzer != null && indexAnalyzer.name().equals(searchAnalyzer.name()) && !indexAnalyzer.name().startsWith("_")) { if (!indexAnalyzer.name().equals("default")) { // same analyzers, output it once diff --git a/src/main/java/org/elasticsearch/index/mapper/DocumentMapperParser.java b/src/main/java/org/elasticsearch/index/mapper/DocumentMapperParser.java index 42334f047c8..4991a155470 100644 --- a/src/main/java/org/elasticsearch/index/mapper/DocumentMapperParser.java +++ b/src/main/java/org/elasticsearch/index/mapper/DocumentMapperParser.java @@ -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,11 +19,11 @@ package org.elasticsearch.index.mapper; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.collect.MapBuilder; -import org.elasticsearch.common.collect.Maps; import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; @@ -46,10 +46,10 @@ import org.elasticsearch.index.settings.IndexSettings; import java.io.IOException; import java.util.Map; -import static org.elasticsearch.index.mapper.MapperBuilders.*; +import static org.elasticsearch.index.mapper.MapperBuilders.doc; /** - * @author kimchy (shay.banon) + * */ public class DocumentMapperParser extends AbstractIndexComponent { diff --git a/src/main/java/org/elasticsearch/index/mapper/FailedToGenerateSourceMapperException.java b/src/main/java/org/elasticsearch/index/mapper/FailedToGenerateSourceMapperException.java index 7689929b5fe..11521150757 100644 --- a/src/main/java/org/elasticsearch/index/mapper/FailedToGenerateSourceMapperException.java +++ b/src/main/java/org/elasticsearch/index/mapper/FailedToGenerateSourceMapperException.java @@ -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.index.mapper; /** - * @author kimchy (shay.banon) + * */ public class FailedToGenerateSourceMapperException extends MapperException { diff --git a/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java index 6de9a990997..9a65077d6ba 100644 --- a/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java @@ -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,7 +32,7 @@ import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.query.QueryParseContext; /** - * @author kimchy (shay.banon) + * */ @ThreadSafe public interface FieldMapper { diff --git a/src/main/java/org/elasticsearch/index/mapper/FieldMapperListener.java b/src/main/java/org/elasticsearch/index/mapper/FieldMapperListener.java index 134d40d528e..3f7fbc41ad1 100644 --- a/src/main/java/org/elasticsearch/index/mapper/FieldMapperListener.java +++ b/src/main/java/org/elasticsearch/index/mapper/FieldMapperListener.java @@ -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.index.mapper; /** - * @author kimchy (shay.banon) + * */ public interface FieldMapperListener { diff --git a/src/main/java/org/elasticsearch/index/mapper/FieldMappers.java b/src/main/java/org/elasticsearch/index/mapper/FieldMappers.java index aa4d8a4a970..a54e48a4c40 100644 --- a/src/main/java/org/elasticsearch/index/mapper/FieldMappers.java +++ b/src/main/java/org/elasticsearch/index/mapper/FieldMappers.java @@ -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.index.mapper; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.Iterators; -import org.elasticsearch.common.collect.UnmodifiableIterator; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Iterators; +import com.google.common.collect.UnmodifiableIterator; import org.elasticsearch.common.util.concurrent.Immutable; import java.util.List; @@ -29,7 +29,7 @@ import java.util.List; /** * A holder for several {@link FieldMapper}. * - * @author kimchy (Shay Banon) + * */ @Immutable public class FieldMappers implements Iterable { @@ -70,7 +70,8 @@ public class FieldMappers implements Iterable { return this.fieldMappers; } - @Override public UnmodifiableIterator iterator() { + @Override + public UnmodifiableIterator iterator() { return fieldMappers.iterator(); } diff --git a/src/main/java/org/elasticsearch/index/mapper/InternalMapper.java b/src/main/java/org/elasticsearch/index/mapper/InternalMapper.java index 1d09476f2cb..6db71e99d7b 100644 --- a/src/main/java/org/elasticsearch/index/mapper/InternalMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/InternalMapper.java @@ -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.index.mapper; /** * A marker interface for internal mappings. * - * @author kimchy (shay.banon) + * */ public interface InternalMapper { } diff --git a/src/main/java/org/elasticsearch/index/mapper/Mapper.java b/src/main/java/org/elasticsearch/index/mapper/Mapper.java index 5a6c5b5ad9e..74aea119868 100644 --- a/src/main/java/org/elasticsearch/index/mapper/Mapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/Mapper.java @@ -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.index.mapper; +import com.google.common.collect.ImmutableMap; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.NotThreadSafe; import org.elasticsearch.common.util.concurrent.ThreadSafe; @@ -32,7 +32,7 @@ import java.io.IOException; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ @ThreadSafe public interface Mapper extends ToXContent { @@ -53,7 +53,8 @@ public interface Mapper extends ToXContent { return this.contentPath; } - @Nullable public Settings indexSettings() { + @Nullable + public Settings indexSettings() { return this.indexSettings; } } diff --git a/src/main/java/org/elasticsearch/index/mapper/MapperBuilders.java b/src/main/java/org/elasticsearch/index/mapper/MapperBuilders.java index 383b809de2b..0fa8d1f2303 100644 --- a/src/main/java/org/elasticsearch/index/mapper/MapperBuilders.java +++ b/src/main/java/org/elasticsearch/index/mapper/MapperBuilders.java @@ -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.index.mapper.object.ObjectMapper; import org.elasticsearch.index.mapper.object.RootObjectMapper; /** - * @author kimchy (shay.banon) + * */ public final class MapperBuilders { diff --git a/src/main/java/org/elasticsearch/index/mapper/MapperCompressionException.java b/src/main/java/org/elasticsearch/index/mapper/MapperCompressionException.java index 38ca7538fd1..ddd7f49671e 100644 --- a/src/main/java/org/elasticsearch/index/mapper/MapperCompressionException.java +++ b/src/main/java/org/elasticsearch/index/mapper/MapperCompressionException.java @@ -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.index.mapper; /** - * @author kimchy (Shay Banon) + * */ public class MapperCompressionException extends MapperException { diff --git a/src/main/java/org/elasticsearch/index/mapper/MapperException.java b/src/main/java/org/elasticsearch/index/mapper/MapperException.java index d085d12a22f..b04ff2a22bc 100644 --- a/src/main/java/org/elasticsearch/index/mapper/MapperException.java +++ b/src/main/java/org/elasticsearch/index/mapper/MapperException.java @@ -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.index.mapper; import org.elasticsearch.ElasticSearchException; /** - * @author kimchy (Shay Banon) + * */ public class MapperException extends ElasticSearchException { diff --git a/src/main/java/org/elasticsearch/index/mapper/MapperParsingException.java b/src/main/java/org/elasticsearch/index/mapper/MapperParsingException.java index da72d91bb2c..d6a0e596013 100644 --- a/src/main/java/org/elasticsearch/index/mapper/MapperParsingException.java +++ b/src/main/java/org/elasticsearch/index/mapper/MapperParsingException.java @@ -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.index.mapper; import org.elasticsearch.rest.RestStatus; /** - * @author kimchy (Shay Banon) + * */ public class MapperParsingException extends MapperException { @@ -35,7 +35,8 @@ public class MapperParsingException extends MapperException { } - @Override public RestStatus status() { + @Override + public RestStatus status() { return RestStatus.BAD_REQUEST; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/mapper/MapperService.java b/src/main/java/org/elasticsearch/index/mapper/MapperService.java index 95df231b85f..4d58a7335b9 100644 --- a/src/main/java/org/elasticsearch/index/mapper/MapperService.java +++ b/src/main/java/org/elasticsearch/index/mapper/MapperService.java @@ -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,9 @@ package org.elasticsearch.index.mapper; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Sets; +import com.google.common.collect.UnmodifiableIterator; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.document.Fieldable; @@ -28,9 +31,6 @@ import org.apache.lucene.search.Filter; import org.apache.lucene.search.FilterClause; import org.apache.lucene.search.PublicTermsFilter; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.Sets; -import org.elasticsearch.common.collect.UnmodifiableIterator; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.io.Streams; import org.elasticsearch.common.lucene.search.TermFilter; @@ -60,10 +60,10 @@ import java.util.Collection; import java.util.Map; import java.util.Set; -import static org.elasticsearch.common.collect.MapBuilder.*; +import static org.elasticsearch.common.collect.MapBuilder.newMapBuilder; /** - * @author kimchy (shay.banon) + * */ @ThreadSafe public class MapperService extends AbstractIndexComponent implements Iterable { @@ -96,7 +96,8 @@ public class MapperService extends AbstractIndexComponent implements Iterable iterator() { + @Override + public UnmodifiableIterator iterator() { return mappers.values().iterator(); } @@ -613,12 +615,12 @@ public class MapperService extends AbstractIndexComponent implements Iterable *

    It also (without the optional type prefix) try and find the {@link FieldMappers} for the specific * name. It will first try to find it based on the full name (with the dots if its a compound name). If * it is not found, will try and find it based on the indexName (which can be controlled in the mapping), * and last, will try it based no the name itself. - * + *

    *

    If nothing is found, returns null. */ public SmartNameFieldMappers smartName(String smartName) { @@ -761,7 +763,8 @@ public class MapperService extends AbstractIndexComponent implements Iterable { @@ -69,7 +69,8 @@ public class ObjectMappers implements Iterable { return this.objectMappers; } - @Override public UnmodifiableIterator iterator() { + @Override + public UnmodifiableIterator iterator() { return objectMappers.iterator(); } diff --git a/src/main/java/org/elasticsearch/index/mapper/ParseContext.java b/src/main/java/org/elasticsearch/index/mapper/ParseContext.java index 4f75eefb229..8538d47529d 100644 --- a/src/main/java/org/elasticsearch/index/mapper/ParseContext.java +++ b/src/main/java/org/elasticsearch/index/mapper/ParseContext.java @@ -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,7 +36,7 @@ import java.util.List; import java.util.Map; /** - * @author kimchy (Shay Banon) + * */ @NotThreadSafe public class ParseContext { @@ -57,7 +57,8 @@ public class ParseContext { private final String index; - @Nullable private final Settings indexSettings; + @Nullable + private final Settings indexSettings; private SourceToParse sourceToParse; private byte[] source; @@ -133,7 +134,8 @@ public class ParseContext { return this.index; } - @Nullable public Settings indexSettings() { + @Nullable + public Settings indexSettings() { return this.indexSettings; } diff --git a/src/main/java/org/elasticsearch/index/mapper/ParsedDocument.java b/src/main/java/org/elasticsearch/index/mapper/ParsedDocument.java index 22ba2295f87..a7ff3ff106e 100644 --- a/src/main/java/org/elasticsearch/index/mapper/ParsedDocument.java +++ b/src/main/java/org/elasticsearch/index/mapper/ParsedDocument.java @@ -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.util.List; /** * The result of parsing a document. * - * @author kimchy (shay.banon) + * */ public class ParsedDocument { diff --git a/src/main/java/org/elasticsearch/index/mapper/RootMapper.java b/src/main/java/org/elasticsearch/index/mapper/RootMapper.java index 69ee7b0776e..a504ab8a109 100644 --- a/src/main/java/org/elasticsearch/index/mapper/RootMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/RootMapper.java @@ -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 diff --git a/src/main/java/org/elasticsearch/index/mapper/SourceToParse.java b/src/main/java/org/elasticsearch/index/mapper/SourceToParse.java index 4863fc84ac6..b8ef9c28b0d 100644 --- a/src/main/java/org/elasticsearch/index/mapper/SourceToParse.java +++ b/src/main/java/org/elasticsearch/index/mapper/SourceToParse.java @@ -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.index.mapper; import org.elasticsearch.common.xcontent.XContentParser; /** - * @author kimchy (shay.banon) + * */ public class SourceToParse { diff --git a/src/main/java/org/elasticsearch/index/mapper/StrictDynamicMappingException.java b/src/main/java/org/elasticsearch/index/mapper/StrictDynamicMappingException.java index 11736522b10..f3a808a2d11 100644 --- a/src/main/java/org/elasticsearch/index/mapper/StrictDynamicMappingException.java +++ b/src/main/java/org/elasticsearch/index/mapper/StrictDynamicMappingException.java @@ -29,7 +29,8 @@ public class StrictDynamicMappingException extends MapperException { super("mapping set to strict, dynamic introduction of [" + fieldName + "] within [" + path + "] is not allowed"); } - @Override public RestStatus status() { + @Override + public RestStatus status() { return RestStatus.BAD_REQUEST; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/mapper/Uid.java b/src/main/java/org/elasticsearch/index/mapper/Uid.java index 88e398fce0d..ced66f91256 100644 --- a/src/main/java/org/elasticsearch/index/mapper/Uid.java +++ b/src/main/java/org/elasticsearch/index/mapper/Uid.java @@ -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.index.mapper; /** - * @author kimchy (Shay Banon) + * */ public final class Uid { @@ -43,7 +43,8 @@ public final class Uid { return id; } - @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; @@ -55,13 +56,15 @@ public final class Uid { return true; } - @Override public int hashCode() { + @Override + public int hashCode() { int result = type != null ? type.hashCode() : 0; result = 31 * result + (id != null ? id.hashCode() : 0); return result; } - @Override public String toString() { + @Override + public String toString() { return type + DELIMITER + id; } diff --git a/src/main/java/org/elasticsearch/index/mapper/core/AbstractFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/AbstractFieldMapper.java index 9b8a92811d2..0b8e7ff7f69 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/AbstractFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/AbstractFieldMapper.java @@ -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,32 +24,20 @@ import org.apache.lucene.document.Field; import org.apache.lucene.document.Fieldable; import org.apache.lucene.index.FieldInfo; import org.apache.lucene.index.Term; -import org.apache.lucene.search.Filter; -import org.apache.lucene.search.FuzzyQuery; -import org.apache.lucene.search.Query; -import org.apache.lucene.search.TermQuery; -import org.apache.lucene.search.TermRangeFilter; -import org.apache.lucene.search.TermRangeQuery; +import org.apache.lucene.search.*; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.common.lucene.search.TermFilter; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.index.analysis.NamedAnalyzer; import org.elasticsearch.index.field.data.FieldDataType; -import org.elasticsearch.index.mapper.FieldMapper; -import org.elasticsearch.index.mapper.FieldMapperListener; -import org.elasticsearch.index.mapper.Mapper; -import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MergeContext; -import org.elasticsearch.index.mapper.MergeMappingException; -import org.elasticsearch.index.mapper.ObjectMapperListener; -import org.elasticsearch.index.mapper.ParseContext; +import org.elasticsearch.index.mapper.*; import org.elasticsearch.index.query.QueryParseContext; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public abstract class AbstractFieldMapper implements FieldMapper, Mapper { @@ -68,39 +56,48 @@ public abstract class AbstractFieldMapper implements FieldMapper, Mapper { super(name); } - @Override public T index(Field.Index index) { + @Override + public T index(Field.Index index) { return super.index(index); } - @Override public T store(Field.Store store) { + @Override + public T store(Field.Store store) { return super.store(store); } - @Override public T termVector(Field.TermVector termVector) { + @Override + public T termVector(Field.TermVector termVector) { return super.termVector(termVector); } - @Override public T boost(float boost) { + @Override + public T boost(float boost) { return super.boost(boost); } - @Override public T omitNorms(boolean omitNorms) { + @Override + public T omitNorms(boolean omitNorms) { return super.omitNorms(omitNorms); } - @Override public T omitTermFreqAndPositions(boolean omitTermFreqAndPositions) { + @Override + public T omitTermFreqAndPositions(boolean omitTermFreqAndPositions) { return super.omitTermFreqAndPositions(omitTermFreqAndPositions); } - @Override public T indexName(String indexName) { + @Override + public T indexName(String indexName) { return super.indexName(indexName); } - @Override public T indexAnalyzer(NamedAnalyzer indexAnalyzer) { + @Override + public T indexAnalyzer(NamedAnalyzer indexAnalyzer) { return super.indexAnalyzer(indexAnalyzer); } - @Override public T searchAnalyzer(NamedAnalyzer searchAnalyzer) { + @Override + public T searchAnalyzer(NamedAnalyzer searchAnalyzer) { return super.searchAnalyzer(searchAnalyzer); } } @@ -239,59 +236,73 @@ public abstract class AbstractFieldMapper implements FieldMapper, Mapper { } } - @Override public String name() { + @Override + public String name() { return names.name(); } - @Override public Names names() { + @Override + public Names names() { return this.names; } - @Override public Field.Index index() { + @Override + public Field.Index index() { return this.index; } - @Override public Field.Store store() { + @Override + public Field.Store store() { return this.store; } - @Override public boolean stored() { + @Override + public boolean stored() { return store == Field.Store.YES; } - @Override public boolean indexed() { + @Override + public boolean indexed() { return index != Field.Index.NO; } - @Override public boolean analyzed() { + @Override + public boolean analyzed() { return index == Field.Index.ANALYZED; } - @Override public Field.TermVector termVector() { + @Override + public Field.TermVector termVector() { return this.termVector; } - @Override public float boost() { + @Override + public float boost() { return this.boost; } - @Override public boolean omitNorms() { + @Override + public boolean omitNorms() { return this.omitNorms; } - @Override public boolean omitTermFreqAndPositions() { + @Override + public boolean omitTermFreqAndPositions() { return this.omitTermFreqAndPositions; } - @Override public Analyzer indexAnalyzer() { + @Override + public Analyzer indexAnalyzer() { return this.indexAnalyzer; } - @Override public Analyzer searchAnalyzer() { + @Override + public Analyzer searchAnalyzer() { return this.searchAnalyzer; } - @Override public void parse(ParseContext context) throws IOException { + @Override + public void parse(ParseContext context) throws IOException { try { Fieldable field = parseCreateField(context); if (field == null) { @@ -319,61 +330,74 @@ public abstract class AbstractFieldMapper implements FieldMapper, Mapper { return false; } - @Override public void traverse(FieldMapperListener fieldMapperListener) { + @Override + public void traverse(FieldMapperListener fieldMapperListener) { fieldMapperListener.fieldMapper(this); } - @Override public void traverse(ObjectMapperListener objectMapperListener) { + @Override + public void traverse(ObjectMapperListener objectMapperListener) { // nothing to do here... } - @Override public Object valueForSearch(Fieldable field) { + @Override + public Object valueForSearch(Fieldable field) { return valueAsString(field); } - @Override public String indexedValue(String value) { + @Override + public String indexedValue(String value) { return value; } - @Override public Query queryStringTermQuery(Term term) { + @Override + public Query queryStringTermQuery(Term term) { return null; } - @Override public boolean useFieldQueryWithQueryString() { + @Override + public boolean useFieldQueryWithQueryString() { return false; } - @Override public Query fieldQuery(String value, @Nullable QueryParseContext context) { + @Override + public Query fieldQuery(String value, @Nullable QueryParseContext context) { return new TermQuery(names().createIndexNameTerm(indexedValue(value))); } - @Override public Filter fieldFilter(String value, @Nullable QueryParseContext context) { + @Override + public Filter fieldFilter(String value, @Nullable QueryParseContext context) { return new TermFilter(names().createIndexNameTerm(indexedValue(value))); } - @Override public Query fuzzyQuery(String value, String minSim, int prefixLength, int maxExpansions) { + @Override + public Query fuzzyQuery(String value, String minSim, int prefixLength, int maxExpansions) { return new FuzzyQuery(names().createIndexNameTerm(indexedValue(value)), Float.parseFloat(minSim), prefixLength, maxExpansions); } - @Override public Query fuzzyQuery(String value, double minSim, int prefixLength, int maxExpansions) { + @Override + public Query fuzzyQuery(String value, double minSim, int prefixLength, int maxExpansions) { return new FuzzyQuery(names().createIndexNameTerm(value), (float) minSim, prefixLength, maxExpansions); } - @Override public Query rangeQuery(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { + @Override + public Query rangeQuery(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { return new TermRangeQuery(names.indexName(), lowerTerm == null ? null : indexedValue(lowerTerm), upperTerm == null ? null : indexedValue(upperTerm), includeLower, includeUpper); } - @Override public Filter rangeFilter(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { + @Override + public Filter rangeFilter(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { return new TermRangeFilter(names.indexName(), lowerTerm == null ? null : indexedValue(lowerTerm), upperTerm == null ? null : indexedValue(upperTerm), includeLower, includeUpper); } - @Override public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { + @Override + public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { if (!this.getClass().equals(mergeWith.getClass())) { String mergedType = mergeWith.getClass().getSimpleName(); if (mergeWith instanceof AbstractFieldMapper) { @@ -417,11 +441,13 @@ public abstract class AbstractFieldMapper implements FieldMapper, Mapper { } } - @Override public FieldDataType fieldDataType() { + @Override + public FieldDataType fieldDataType() { return FieldDataType.DefaultTypes.STRING; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(names.name()); doXContentBody(builder); builder.endObject(); @@ -451,7 +477,8 @@ public abstract class AbstractFieldMapper implements FieldMapper, Mapper { protected abstract String contentType(); - @Override public void close() { + @Override + public void close() { // nothing to do here, sub classes to override if needed } diff --git a/src/main/java/org/elasticsearch/index/mapper/core/BinaryFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/BinaryFieldMapper.java index 10e6b490661..ee61f11271e 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/BinaryFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/BinaryFieldMapper.java @@ -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,21 +31,17 @@ import org.elasticsearch.common.io.stream.LZFStreamOutput; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.index.mapper.Mapper; -import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MergeContext; -import org.elasticsearch.index.mapper.MergeMappingException; -import org.elasticsearch.index.mapper.ParseContext; +import org.elasticsearch.index.mapper.*; import java.io.IOException; import java.util.Map; -import static org.elasticsearch.common.xcontent.support.XContentMapValues.*; -import static org.elasticsearch.index.mapper.MapperBuilders.*; -import static org.elasticsearch.index.mapper.core.TypeParsers.*; +import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeBooleanValue; +import static org.elasticsearch.index.mapper.MapperBuilders.binaryField; +import static org.elasticsearch.index.mapper.core.TypeParsers.parseField; /** - * @author kimchy (shay.banon) + * */ public class BinaryFieldMapper extends AbstractFieldMapper { @@ -76,17 +72,20 @@ public class BinaryFieldMapper extends AbstractFieldMapper { return this; } - @Override public Builder indexName(String indexName) { + @Override + public Builder indexName(String indexName) { return super.indexName(indexName); } - @Override public BinaryFieldMapper build(BuilderContext context) { + @Override + public BinaryFieldMapper build(BuilderContext context) { return new BinaryFieldMapper(buildNames(context), compress, compressThreshold); } } public static class TypeParser implements Mapper.TypeParser { - @Override public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { + @Override + public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { BinaryFieldMapper.Builder builder = binaryField(name); parseField(builder, name, node, parserContext); for (Map.Entry entry : node.entrySet()) { @@ -123,7 +122,8 @@ public class BinaryFieldMapper extends AbstractFieldMapper { return value(field); } - @Override public byte[] value(Fieldable field) { + @Override + public byte[] value(Fieldable field) { byte[] value = field.getBinaryValue(); if (value != null && LZF.isCompressed(value)) { try { @@ -135,7 +135,8 @@ public class BinaryFieldMapper extends AbstractFieldMapper { return value; } - @Override public byte[] valueFromString(String value) { + @Override + public byte[] valueFromString(String value) { // assume its base64 (json) try { return Base64.decode(value); @@ -144,15 +145,18 @@ public class BinaryFieldMapper extends AbstractFieldMapper { } } - @Override public String valueAsString(Fieldable field) { + @Override + public String valueAsString(Fieldable field) { return null; } - @Override public String indexedValue(String value) { + @Override + public String indexedValue(String value) { return value; } - @Override protected Field parseCreateField(ParseContext context) throws IOException { + @Override + protected Field parseCreateField(ParseContext context) throws IOException { byte[] value; if (context.parser().currentToken() == XContentParser.Token.VALUE_NULL) { return null; @@ -177,11 +181,13 @@ public class BinaryFieldMapper extends AbstractFieldMapper { return new Field(names.indexName(), value); } - @Override protected String contentType() { + @Override + protected String contentType() { return CONTENT_TYPE; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(names.name()); builder.field("type", contentType()); if (!names.name().equals(names.indexNameClean())) { @@ -197,7 +203,8 @@ public class BinaryFieldMapper extends AbstractFieldMapper { return builder; } - @Override public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { + @Override + public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { BinaryFieldMapper sourceMergeWith = (BinaryFieldMapper) mergeWith; if (!mergeContext.mergeFlags().simulate()) { if (sourceMergeWith.compress != null) { diff --git a/src/main/java/org/elasticsearch/index/mapper/core/BooleanFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/BooleanFieldMapper.java index 7f84f435902..e206420c86e 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/BooleanFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/BooleanFieldMapper.java @@ -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,12 +33,12 @@ import org.elasticsearch.index.mapper.ParseContext; import java.io.IOException; import java.util.Map; -import static org.elasticsearch.common.xcontent.support.XContentMapValues.*; -import static org.elasticsearch.index.mapper.MapperBuilders.*; -import static org.elasticsearch.index.mapper.core.TypeParsers.*; +import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeBooleanValue; +import static org.elasticsearch.index.mapper.MapperBuilders.booleanField; +import static org.elasticsearch.index.mapper.core.TypeParsers.parseField; /** - * @author kimchy (shay.banon) + * */ // TODO this can be made better, maybe storing a byte for it? public class BooleanFieldMapper extends AbstractFieldMapper { @@ -65,38 +65,46 @@ public class BooleanFieldMapper extends AbstractFieldMapper { return this; } - @Override public Builder index(Field.Index index) { + @Override + public Builder index(Field.Index index) { return super.index(index); } - @Override public Builder store(Field.Store store) { + @Override + public Builder store(Field.Store store) { return super.store(store); } - @Override public Builder termVector(Field.TermVector termVector) { + @Override + public Builder termVector(Field.TermVector termVector) { return super.termVector(termVector); } - @Override public Builder boost(float boost) { + @Override + public Builder boost(float boost) { return super.boost(boost); } - @Override public Builder indexName(String indexName) { + @Override + public Builder indexName(String indexName) { return super.indexName(indexName); } - @Override public Builder omitTermFreqAndPositions(boolean omitTermFreqAndPositions) { + @Override + public Builder omitTermFreqAndPositions(boolean omitTermFreqAndPositions) { return super.omitTermFreqAndPositions(omitTermFreqAndPositions); } - @Override public BooleanFieldMapper build(BuilderContext context) { + @Override + public BooleanFieldMapper build(BuilderContext context) { return new BooleanFieldMapper(buildNames(context), index, store, termVector, boost, omitNorms, omitTermFreqAndPositions, nullValue); } } public static class TypeParser implements Mapper.TypeParser { - @Override public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { + @Override + public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { BooleanFieldMapper.Builder builder = booleanField(name); parseField(builder, name, node, parserContext); for (Map.Entry entry : node.entrySet()) { @@ -118,23 +126,28 @@ public class BooleanFieldMapper extends AbstractFieldMapper { this.nullValue = nullValue; } - @Override public boolean useFieldQueryWithQueryString() { + @Override + public boolean useFieldQueryWithQueryString() { return true; } - @Override public Boolean value(Fieldable field) { + @Override + public Boolean value(Fieldable field) { return field.stringValue().charAt(0) == 'T' ? Boolean.TRUE : Boolean.FALSE; } - @Override public Boolean valueFromString(String value) { + @Override + public Boolean valueFromString(String value) { return value.charAt(0) == 'T' ? Boolean.TRUE : Boolean.FALSE; } - @Override public String valueAsString(Fieldable field) { + @Override + public String valueAsString(Fieldable field) { return field.stringValue().charAt(0) == 'T' ? "true" : "false"; } - @Override public String indexedValue(String value) { + @Override + public String indexedValue(String value) { if (value == null || value.length() == 0) { return "F"; } @@ -144,7 +157,8 @@ public class BooleanFieldMapper extends AbstractFieldMapper { return "F"; } - @Override protected Field parseCreateField(ParseContext context) throws IOException { + @Override + protected Field parseCreateField(ParseContext context) throws IOException { if (!indexed() && !stored()) { return null; } @@ -163,11 +177,13 @@ public class BooleanFieldMapper extends AbstractFieldMapper { return new Field(names.indexName(), value, store, index, termVector); } - @Override protected String contentType() { + @Override + protected String contentType() { return CONTENT_TYPE; } - @Override protected void doXContentBody(XContentBuilder builder) throws IOException { + @Override + protected void doXContentBody(XContentBuilder builder) throws IOException { super.doXContentBody(builder); if (index != Defaults.INDEX) { builder.field("index", index.name().toLowerCase()); diff --git a/src/main/java/org/elasticsearch/index/mapper/core/ByteFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/ByteFieldMapper.java index cb90c341aa0..29eaea76cba 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/ByteFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/ByteFieldMapper.java @@ -34,22 +34,18 @@ import org.elasticsearch.index.analysis.NamedAnalyzer; import org.elasticsearch.index.analysis.NumericIntegerAnalyzer; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldDataType; -import org.elasticsearch.index.mapper.Mapper; -import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MergeContext; -import org.elasticsearch.index.mapper.MergeMappingException; -import org.elasticsearch.index.mapper.ParseContext; +import org.elasticsearch.index.mapper.*; import org.elasticsearch.index.search.NumericRangeFieldDataFilter; import java.io.IOException; import java.util.Map; -import static org.elasticsearch.common.xcontent.support.XContentMapValues.*; -import static org.elasticsearch.index.mapper.MapperBuilders.*; -import static org.elasticsearch.index.mapper.core.TypeParsers.*; +import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeByteValue; +import static org.elasticsearch.index.mapper.MapperBuilders.byteField; +import static org.elasticsearch.index.mapper.core.TypeParsers.parseNumberField; /** - * @author kimchy (shay.banon) + * */ public class ByteFieldMapper extends NumberFieldMapper { @@ -73,7 +69,8 @@ public class ByteFieldMapper extends NumberFieldMapper { return this; } - @Override public ByteFieldMapper build(BuilderContext context) { + @Override + public ByteFieldMapper build(BuilderContext context) { ByteFieldMapper fieldMapper = new ByteFieldMapper(buildNames(context), precisionStep, fuzzyFactor, index, store, boost, omitNorms, omitTermFreqAndPositions, nullValue); fieldMapper.includeInAll(includeInAll); @@ -82,7 +79,8 @@ public class ByteFieldMapper extends NumberFieldMapper { } public static class TypeParser implements Mapper.TypeParser { - @Override public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { + @Override + public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { ByteFieldMapper.Builder builder = byteField(name); parseNumberField(builder, name, node, parserContext); for (Map.Entry entry : node.entrySet()) { @@ -110,11 +108,13 @@ public class ByteFieldMapper extends NumberFieldMapper { this.nullValueAsString = nullValue == null ? null : nullValue.toString(); } - @Override protected int maxPrecisionStep() { + @Override + protected int maxPrecisionStep() { return 32; } - @Override public Byte value(Fieldable field) { + @Override + public Byte value(Fieldable field) { byte[] value = field.getBinaryValue(); if (value == null) { return null; @@ -122,15 +122,18 @@ public class ByteFieldMapper extends NumberFieldMapper { return value[0]; } - @Override public Byte valueFromString(String value) { + @Override + public Byte valueFromString(String value) { return Byte.valueOf(value); } - @Override public String indexedValue(String value) { + @Override + public String indexedValue(String value) { return NumericUtils.intToPrefixCoded(Byte.parseByte(value)); } - @Override public Query fuzzyQuery(String value, String minSim, int prefixLength, int maxExpansions) { + @Override + public Query fuzzyQuery(String value, String minSim, int prefixLength, int maxExpansions) { byte iValue = Byte.parseByte(value); byte iSim; try { @@ -144,7 +147,8 @@ public class ByteFieldMapper extends NumberFieldMapper { true, true); } - @Override public Query fuzzyQuery(String value, double minSim, int prefixLength, int maxExpansions) { + @Override + public Query fuzzyQuery(String value, double minSim, int prefixLength, int maxExpansions) { byte iValue = Byte.parseByte(value); byte iSim = (byte) (minSim * dFuzzyFactor); return NumericRangeQuery.newIntRange(names.indexName(), precisionStep, @@ -154,32 +158,37 @@ public class ByteFieldMapper extends NumberFieldMapper { } - @Override public Query rangeQuery(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { + @Override + public Query rangeQuery(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { return NumericRangeQuery.newIntRange(names.indexName(), precisionStep, lowerTerm == null ? null : Integer.parseInt(lowerTerm), upperTerm == null ? null : Integer.parseInt(upperTerm), includeLower, includeUpper); } - @Override public Filter rangeFilter(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { + @Override + public Filter rangeFilter(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { return NumericRangeFilter.newIntRange(names.indexName(), precisionStep, lowerTerm == null ? null : Integer.parseInt(lowerTerm), upperTerm == null ? null : Integer.parseInt(upperTerm), includeLower, includeUpper); } - @Override public Filter rangeFilter(FieldDataCache fieldDataCache, String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { + @Override + public Filter rangeFilter(FieldDataCache fieldDataCache, String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { return NumericRangeFieldDataFilter.newByteRange(fieldDataCache, names.indexName(), lowerTerm == null ? null : Byte.parseByte(lowerTerm), upperTerm == null ? null : Byte.parseByte(upperTerm), includeLower, includeUpper); } - @Override protected boolean customBoost() { + @Override + protected boolean customBoost() { return true; } - @Override protected Fieldable parseCreateField(ParseContext context) throws IOException { + @Override + protected Fieldable parseCreateField(ParseContext context) throws IOException { byte value; float boost = this.boost; if (context.externalValueSet()) { @@ -250,15 +259,18 @@ public class ByteFieldMapper extends NumberFieldMapper { return field; } - @Override public FieldDataType fieldDataType() { + @Override + public FieldDataType fieldDataType() { return FieldDataType.DefaultTypes.BYTE; } - @Override protected String contentType() { + @Override + protected String contentType() { return CONTENT_TYPE; } - @Override public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { + @Override + public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { super.merge(mergeWith, mergeContext); if (!this.getClass().equals(mergeWith.getClass())) { return; @@ -269,7 +281,8 @@ public class ByteFieldMapper extends NumberFieldMapper { } } - @Override protected void doXContentBody(XContentBuilder builder) throws IOException { + @Override + protected void doXContentBody(XContentBuilder builder) throws IOException { super.doXContentBody(builder); if (index != Defaults.INDEX) { builder.field("index", index.name().toLowerCase()); @@ -312,14 +325,16 @@ public class ByteFieldMapper extends NumberFieldMapper { this.number = number; } - @Override public TokenStream tokenStreamValue() { + @Override + public TokenStream tokenStreamValue() { if (isIndexed) { return mapper.popCachedStream().setIntValue(number); } return null; } - @Override public String numericAsString() { + @Override + public String numericAsString() { return Byte.toString(number); } } diff --git a/src/main/java/org/elasticsearch/index/mapper/core/DateFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/DateFieldMapper.java index 426b0fbbd66..25165f8ff2e 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/DateFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/DateFieldMapper.java @@ -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,8 +30,6 @@ import org.elasticsearch.common.Numbers; import org.elasticsearch.common.Strings; import org.elasticsearch.common.joda.FormatDateTimeFormatter; import org.elasticsearch.common.joda.Joda; -import org.elasticsearch.common.joda.time.DateTimeZone; -import org.elasticsearch.common.joda.time.MutableDateTime; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; @@ -39,22 +37,21 @@ import org.elasticsearch.index.analysis.NamedAnalyzer; import org.elasticsearch.index.analysis.NumericDateAnalyzer; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldDataType; -import org.elasticsearch.index.mapper.Mapper; -import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MergeContext; -import org.elasticsearch.index.mapper.MergeMappingException; -import org.elasticsearch.index.mapper.ParseContext; +import org.elasticsearch.index.mapper.*; import org.elasticsearch.index.search.NumericRangeFieldDataFilter; +import org.joda.time.DateTimeZone; +import org.joda.time.MutableDateTime; import java.io.IOException; import java.util.Map; import java.util.concurrent.TimeUnit; -import static org.elasticsearch.index.mapper.MapperBuilders.*; -import static org.elasticsearch.index.mapper.core.TypeParsers.*; +import static org.elasticsearch.index.mapper.MapperBuilders.dateField; +import static org.elasticsearch.index.mapper.core.TypeParsers.parseDateTimeFormatter; +import static org.elasticsearch.index.mapper.core.TypeParsers.parseNumberField; /** - * @author kimchy (shay.banon) + * */ public class DateFieldMapper extends NumberFieldMapper { @@ -97,7 +94,8 @@ public class DateFieldMapper extends NumberFieldMapper { return this; } - @Override public DateFieldMapper build(BuilderContext context) { + @Override + public DateFieldMapper build(BuilderContext context) { boolean parseUpperInclusive = Defaults.PARSE_UPPER_INCLUSIVE; if (context.indexSettings() != null) { parseUpperInclusive = context.indexSettings().getAsBoolean("index.mapping.date.parse_upper_inclusive", Defaults.PARSE_UPPER_INCLUSIVE); @@ -110,7 +108,8 @@ public class DateFieldMapper extends NumberFieldMapper { } public static class TypeParser implements Mapper.TypeParser { - @Override public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { + @Override + public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { DateFieldMapper.Builder builder = dateField(name); parseNumberField(builder, name, node, parserContext); for (Map.Entry entry : node.entrySet()) { @@ -149,7 +148,8 @@ public class DateFieldMapper extends NumberFieldMapper { this.parseUpperInclusive = parseUpperInclusive; } - @Override protected double parseFuzzyFactor(String fuzzyFactor) { + @Override + protected double parseFuzzyFactor(String fuzzyFactor) { if (fuzzyFactor == null) { return 1.0d; } @@ -160,11 +160,13 @@ public class DateFieldMapper extends NumberFieldMapper { } } - @Override protected int maxPrecisionStep() { + @Override + protected int maxPrecisionStep() { return 64; } - @Override public Long value(Fieldable field) { + @Override + public Long value(Fieldable field) { byte[] value = field.getBinaryValue(); if (value == null) { return null; @@ -172,18 +174,21 @@ public class DateFieldMapper extends NumberFieldMapper { return Numbers.bytesToLong(value); } - @Override public Long valueFromString(String value) { + @Override + public Long valueFromString(String value) { return parseStringValue(value); } /** * Dates should return as a string, delegates to {@link #valueAsString(org.apache.lucene.document.Fieldable)}. */ - @Override public Object valueForSearch(Fieldable field) { + @Override + public Object valueForSearch(Fieldable field) { return valueAsString(field); } - @Override public String valueAsString(Fieldable field) { + @Override + public String valueAsString(Fieldable field) { Long value = value(field); if (value == null) { return null; @@ -191,11 +196,13 @@ public class DateFieldMapper extends NumberFieldMapper { return dateTimeFormatter.printer().print(value); } - @Override public String indexedValue(String value) { + @Override + public String indexedValue(String value) { return NumericUtils.longToPrefixCoded(dateTimeFormatter.parser().parseMillis(value)); } - @Override public Query fuzzyQuery(String value, String minSim, int prefixLength, int maxExpansions) { + @Override + public Query fuzzyQuery(String value, String minSim, int prefixLength, int maxExpansions) { long iValue = parseStringValue(value); long iSim; try { @@ -210,7 +217,8 @@ public class DateFieldMapper extends NumberFieldMapper { true, true); } - @Override public Query fuzzyQuery(String value, double minSim, int prefixLength, int maxExpansions) { + @Override + public Query fuzzyQuery(String value, double minSim, int prefixLength, int maxExpansions) { long iValue = parseStringValue(value); long iSim = (long) (minSim * dFuzzyFactor); return NumericRangeQuery.newLongRange(names.indexName(), precisionStep, @@ -219,32 +227,37 @@ public class DateFieldMapper extends NumberFieldMapper { true, true); } - @Override public Query rangeQuery(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { + @Override + public Query rangeQuery(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { return NumericRangeQuery.newLongRange(names.indexName(), precisionStep, lowerTerm == null ? null : parseStringValue(lowerTerm), upperTerm == null ? null : includeUpper ? parseUpperInclusiveStringValue(upperTerm) : parseStringValue(upperTerm), includeLower, includeUpper); } - @Override public Filter rangeFilter(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { + @Override + public Filter rangeFilter(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { return NumericRangeFilter.newLongRange(names.indexName(), precisionStep, lowerTerm == null ? null : parseStringValue(lowerTerm), upperTerm == null ? null : includeUpper ? parseUpperInclusiveStringValue(upperTerm) : parseStringValue(upperTerm), includeLower, includeUpper); } - @Override public Filter rangeFilter(FieldDataCache fieldDataCache, String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { + @Override + public Filter rangeFilter(FieldDataCache fieldDataCache, String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { return NumericRangeFieldDataFilter.newLongRange(fieldDataCache, names.indexName(), lowerTerm == null ? null : parseStringValue(lowerTerm), upperTerm == null ? null : includeUpper ? parseUpperInclusiveStringValue(upperTerm) : parseStringValue(upperTerm), includeLower, includeUpper); } - @Override protected boolean customBoost() { + @Override + protected boolean customBoost() { return true; } - @Override protected Fieldable parseCreateField(ParseContext context) throws IOException { + @Override + protected Fieldable parseCreateField(ParseContext context) throws IOException { String dateAsString = null; Long value = null; float boost = this.boost; @@ -308,15 +321,18 @@ public class DateFieldMapper extends NumberFieldMapper { return field; } - @Override public FieldDataType fieldDataType() { + @Override + public FieldDataType fieldDataType() { return FieldDataType.DefaultTypes.LONG; } - @Override protected String contentType() { + @Override + protected String contentType() { return CONTENT_TYPE; } - @Override public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { + @Override + public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { super.merge(mergeWith, mergeContext); if (!this.getClass().equals(mergeWith.getClass())) { return; @@ -326,7 +342,8 @@ public class DateFieldMapper extends NumberFieldMapper { } } - @Override protected void doXContentBody(XContentBuilder builder) throws IOException { + @Override + protected void doXContentBody(XContentBuilder builder) throws IOException { super.doXContentBody(builder); if (index != Defaults.INDEX) { builder.field("index", index.name().toLowerCase()); diff --git a/src/main/java/org/elasticsearch/index/mapper/core/DoubleFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/DoubleFieldMapper.java index 419f275ee44..80103d406f3 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/DoubleFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/DoubleFieldMapper.java @@ -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,22 +34,18 @@ import org.elasticsearch.index.analysis.NamedAnalyzer; import org.elasticsearch.index.analysis.NumericDoubleAnalyzer; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldDataType; -import org.elasticsearch.index.mapper.Mapper; -import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MergeContext; -import org.elasticsearch.index.mapper.MergeMappingException; -import org.elasticsearch.index.mapper.ParseContext; +import org.elasticsearch.index.mapper.*; import org.elasticsearch.index.search.NumericRangeFieldDataFilter; import java.io.IOException; import java.util.Map; -import static org.elasticsearch.common.xcontent.support.XContentMapValues.*; -import static org.elasticsearch.index.mapper.MapperBuilders.*; -import static org.elasticsearch.index.mapper.core.TypeParsers.*; +import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeDoubleValue; +import static org.elasticsearch.index.mapper.MapperBuilders.doubleField; +import static org.elasticsearch.index.mapper.core.TypeParsers.parseNumberField; /** - * @author kimchy (shay.banon) + * */ public class DoubleFieldMapper extends NumberFieldMapper { @@ -73,7 +69,8 @@ public class DoubleFieldMapper extends NumberFieldMapper { return this; } - @Override public DoubleFieldMapper build(BuilderContext context) { + @Override + public DoubleFieldMapper build(BuilderContext context) { DoubleFieldMapper fieldMapper = new DoubleFieldMapper(buildNames(context), precisionStep, fuzzyFactor, index, store, boost, omitNorms, omitTermFreqAndPositions, nullValue); fieldMapper.includeInAll(includeInAll); @@ -82,7 +79,8 @@ public class DoubleFieldMapper extends NumberFieldMapper { } public static class TypeParser implements Mapper.TypeParser { - @Override public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { + @Override + public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { DoubleFieldMapper.Builder builder = doubleField(name); parseNumberField(builder, name, node, parserContext); for (Map.Entry entry : node.entrySet()) { @@ -112,11 +110,13 @@ public class DoubleFieldMapper extends NumberFieldMapper { this.nullValueAsString = nullValue == null ? null : nullValue.toString(); } - @Override protected int maxPrecisionStep() { + @Override + protected int maxPrecisionStep() { return 64; } - @Override public Double value(Fieldable field) { + @Override + public Double value(Fieldable field) { byte[] value = field.getBinaryValue(); if (value == null) { return null; @@ -124,15 +124,18 @@ public class DoubleFieldMapper extends NumberFieldMapper { return Numbers.bytesToDouble(value); } - @Override public Double valueFromString(String value) { + @Override + public Double valueFromString(String value) { return Double.valueOf(value); } - @Override public String indexedValue(String value) { + @Override + public String indexedValue(String value) { return NumericUtils.doubleToPrefixCoded(Double.parseDouble(value)); } - @Override public Query fuzzyQuery(String value, String minSim, int prefixLength, int maxExpansions) { + @Override + public Query fuzzyQuery(String value, String minSim, int prefixLength, int maxExpansions) { double iValue = Double.parseDouble(value); double iSim = Double.parseDouble(minSim); return NumericRangeQuery.newDoubleRange(names.indexName(), precisionStep, @@ -141,7 +144,8 @@ public class DoubleFieldMapper extends NumberFieldMapper { true, true); } - @Override public Query fuzzyQuery(String value, double minSim, int prefixLength, int maxExpansions) { + @Override + public Query fuzzyQuery(String value, double minSim, int prefixLength, int maxExpansions) { double iValue = Double.parseDouble(value); double iSim = minSim * dFuzzyFactor; return NumericRangeQuery.newDoubleRange(names.indexName(), precisionStep, @@ -150,14 +154,16 @@ public class DoubleFieldMapper extends NumberFieldMapper { true, true); } - @Override public Query rangeQuery(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { + @Override + public Query rangeQuery(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { return NumericRangeQuery.newDoubleRange(names.indexName(), precisionStep, lowerTerm == null ? null : Double.parseDouble(lowerTerm), upperTerm == null ? null : Double.parseDouble(upperTerm), includeLower, includeUpper); } - @Override public Filter rangeFilter(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { + @Override + public Filter rangeFilter(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { return NumericRangeFilter.newDoubleRange(names.indexName(), precisionStep, lowerTerm == null ? null : Double.parseDouble(lowerTerm), upperTerm == null ? null : Double.parseDouble(upperTerm), @@ -168,18 +174,21 @@ public class DoubleFieldMapper extends NumberFieldMapper { return NumericRangeFilter.newDoubleRange(names.indexName(), precisionStep, lowerTerm, upperTerm, includeLower, includeUpper); } - @Override public Filter rangeFilter(FieldDataCache fieldDataCache, String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { + @Override + public Filter rangeFilter(FieldDataCache fieldDataCache, String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { return NumericRangeFieldDataFilter.newDoubleRange(fieldDataCache, names.indexName(), lowerTerm == null ? null : Double.parseDouble(lowerTerm), upperTerm == null ? null : Double.parseDouble(upperTerm), includeLower, includeUpper); } - @Override protected boolean customBoost() { + @Override + protected boolean customBoost() { return true; } - @Override protected Fieldable parseCreateField(ParseContext context) throws IOException { + @Override + protected Fieldable parseCreateField(ParseContext context) throws IOException { double value; float boost = this.boost; if (context.externalValueSet()) { @@ -251,15 +260,18 @@ public class DoubleFieldMapper extends NumberFieldMapper { return field; } - @Override public FieldDataType fieldDataType() { + @Override + public FieldDataType fieldDataType() { return FieldDataType.DefaultTypes.DOUBLE; } - @Override protected String contentType() { + @Override + protected String contentType() { return CONTENT_TYPE; } - @Override public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { + @Override + public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { super.merge(mergeWith, mergeContext); if (!this.getClass().equals(mergeWith.getClass())) { return; @@ -270,7 +282,8 @@ public class DoubleFieldMapper extends NumberFieldMapper { } } - @Override protected void doXContentBody(XContentBuilder builder) throws IOException { + @Override + protected void doXContentBody(XContentBuilder builder) throws IOException { super.doXContentBody(builder); if (index != Defaults.INDEX) { builder.field("index", index.name().toLowerCase()); @@ -313,14 +326,16 @@ public class DoubleFieldMapper extends NumberFieldMapper { this.number = number; } - @Override public TokenStream tokenStreamValue() { + @Override + public TokenStream tokenStreamValue() { if (isIndexed) { return mapper.popCachedStream().setDoubleValue(number); } return null; } - @Override public String numericAsString() { + @Override + public String numericAsString() { return Double.toString(number); } } diff --git a/src/main/java/org/elasticsearch/index/mapper/core/FloatFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/FloatFieldMapper.java index f57c221f1c0..e665744299f 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/FloatFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/FloatFieldMapper.java @@ -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,22 +35,18 @@ import org.elasticsearch.index.analysis.NamedAnalyzer; import org.elasticsearch.index.analysis.NumericFloatAnalyzer; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldDataType; -import org.elasticsearch.index.mapper.Mapper; -import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MergeContext; -import org.elasticsearch.index.mapper.MergeMappingException; -import org.elasticsearch.index.mapper.ParseContext; +import org.elasticsearch.index.mapper.*; import org.elasticsearch.index.search.NumericRangeFieldDataFilter; import java.io.IOException; import java.util.Map; -import static org.elasticsearch.common.xcontent.support.XContentMapValues.*; -import static org.elasticsearch.index.mapper.MapperBuilders.*; -import static org.elasticsearch.index.mapper.core.TypeParsers.*; +import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeFloatValue; +import static org.elasticsearch.index.mapper.MapperBuilders.floatField; +import static org.elasticsearch.index.mapper.core.TypeParsers.parseNumberField; /** - * @author kimchy (shay.banon) + * */ public class FloatFieldMapper extends NumberFieldMapper { @@ -74,7 +70,8 @@ public class FloatFieldMapper extends NumberFieldMapper { return this; } - @Override public FloatFieldMapper build(BuilderContext context) { + @Override + public FloatFieldMapper build(BuilderContext context) { FloatFieldMapper fieldMapper = new FloatFieldMapper(buildNames(context), precisionStep, fuzzyFactor, index, store, boost, omitNorms, omitTermFreqAndPositions, nullValue); fieldMapper.includeInAll(includeInAll); @@ -83,7 +80,8 @@ public class FloatFieldMapper extends NumberFieldMapper { } public static class TypeParser implements Mapper.TypeParser { - @Override public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { + @Override + public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { FloatFieldMapper.Builder builder = floatField(name); parseNumberField(builder, name, node, parserContext); for (Map.Entry entry : node.entrySet()) { @@ -111,11 +109,13 @@ public class FloatFieldMapper extends NumberFieldMapper { this.nullValueAsString = nullValue == null ? null : nullValue.toString(); } - @Override protected int maxPrecisionStep() { + @Override + protected int maxPrecisionStep() { return 32; } - @Override public Float value(Fieldable field) { + @Override + public Float value(Fieldable field) { byte[] value = field.getBinaryValue(); if (value == null) { return null; @@ -123,15 +123,18 @@ public class FloatFieldMapper extends NumberFieldMapper { return Numbers.bytesToFloat(value); } - @Override public Float valueFromString(String value) { + @Override + public Float valueFromString(String value) { return Float.parseFloat(value); } - @Override public String indexedValue(String value) { + @Override + public String indexedValue(String value) { return NumericUtils.floatToPrefixCoded(Float.parseFloat(value)); } - @Override public Query fuzzyQuery(String value, String minSim, int prefixLength, int maxExpansions) { + @Override + public Query fuzzyQuery(String value, String minSim, int prefixLength, int maxExpansions) { float iValue = Float.parseFloat(value); float iSim = Float.parseFloat(minSim); return NumericRangeQuery.newFloatRange(names.indexName(), precisionStep, @@ -140,7 +143,8 @@ public class FloatFieldMapper extends NumberFieldMapper { true, true); } - @Override public Query fuzzyQuery(String value, double minSim, int prefixLength, int maxExpansions) { + @Override + public Query fuzzyQuery(String value, double minSim, int prefixLength, int maxExpansions) { float iValue = Float.parseFloat(value); float iSim = (float) (minSim * dFuzzyFactor); return NumericRangeQuery.newFloatRange(names.indexName(), precisionStep, @@ -149,32 +153,37 @@ public class FloatFieldMapper extends NumberFieldMapper { true, true); } - @Override public Query rangeQuery(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { + @Override + public Query rangeQuery(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { return NumericRangeQuery.newFloatRange(names.indexName(), precisionStep, lowerTerm == null ? null : Float.parseFloat(lowerTerm), upperTerm == null ? null : Float.parseFloat(upperTerm), includeLower, includeUpper); } - @Override public Filter rangeFilter(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { + @Override + public Filter rangeFilter(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { return NumericRangeFilter.newFloatRange(names.indexName(), precisionStep, lowerTerm == null ? null : Float.parseFloat(lowerTerm), upperTerm == null ? null : Float.parseFloat(upperTerm), includeLower, includeUpper); } - @Override public Filter rangeFilter(FieldDataCache fieldDataCache, String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { + @Override + public Filter rangeFilter(FieldDataCache fieldDataCache, String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { return NumericRangeFieldDataFilter.newFloatRange(fieldDataCache, names.indexName(), lowerTerm == null ? null : Float.parseFloat(lowerTerm), upperTerm == null ? null : Float.parseFloat(upperTerm), includeLower, includeUpper); } - @Override protected boolean customBoost() { + @Override + protected boolean customBoost() { return true; } - @Override protected Fieldable parseCreateField(ParseContext context) throws IOException { + @Override + protected Fieldable parseCreateField(ParseContext context) throws IOException { float value; float boost = this.boost; if (context.externalValueSet()) { @@ -246,15 +255,18 @@ public class FloatFieldMapper extends NumberFieldMapper { return field; } - @Override public FieldDataType fieldDataType() { + @Override + public FieldDataType fieldDataType() { return FieldDataType.DefaultTypes.FLOAT; } - @Override protected String contentType() { + @Override + protected String contentType() { return CONTENT_TYPE; } - @Override public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { + @Override + public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { super.merge(mergeWith, mergeContext); if (!this.getClass().equals(mergeWith.getClass())) { return; @@ -266,7 +278,8 @@ public class FloatFieldMapper extends NumberFieldMapper { } - @Override protected void doXContentBody(XContentBuilder builder) throws IOException { + @Override + protected void doXContentBody(XContentBuilder builder) throws IOException { super.doXContentBody(builder); if (index != Defaults.INDEX) { builder.field("index", index.name().toLowerCase()); @@ -309,14 +322,16 @@ public class FloatFieldMapper extends NumberFieldMapper { this.number = number; } - @Override public TokenStream tokenStreamValue() { + @Override + public TokenStream tokenStreamValue() { if (isIndexed) { return mapper.popCachedStream().setFloatValue(number); } return null; } - @Override public String numericAsString() { + @Override + public String numericAsString() { return Float.toString(number); } } diff --git a/src/main/java/org/elasticsearch/index/mapper/core/IntegerFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/IntegerFieldMapper.java index c87db76efc7..50b1d3edc63 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/IntegerFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/IntegerFieldMapper.java @@ -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,22 +35,18 @@ import org.elasticsearch.index.analysis.NamedAnalyzer; import org.elasticsearch.index.analysis.NumericIntegerAnalyzer; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldDataType; -import org.elasticsearch.index.mapper.Mapper; -import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MergeContext; -import org.elasticsearch.index.mapper.MergeMappingException; -import org.elasticsearch.index.mapper.ParseContext; +import org.elasticsearch.index.mapper.*; import org.elasticsearch.index.search.NumericRangeFieldDataFilter; import java.io.IOException; import java.util.Map; -import static org.elasticsearch.common.xcontent.support.XContentMapValues.*; -import static org.elasticsearch.index.mapper.MapperBuilders.*; -import static org.elasticsearch.index.mapper.core.TypeParsers.*; +import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeIntegerValue; +import static org.elasticsearch.index.mapper.MapperBuilders.integerField; +import static org.elasticsearch.index.mapper.core.TypeParsers.parseNumberField; /** - * @author kimchy (shay.banon) + * */ public class IntegerFieldMapper extends NumberFieldMapper { @@ -74,7 +70,8 @@ public class IntegerFieldMapper extends NumberFieldMapper { return this; } - @Override public IntegerFieldMapper build(BuilderContext context) { + @Override + public IntegerFieldMapper build(BuilderContext context) { IntegerFieldMapper fieldMapper = new IntegerFieldMapper(buildNames(context), precisionStep, fuzzyFactor, index, store, boost, omitNorms, omitTermFreqAndPositions, nullValue); fieldMapper.includeInAll(includeInAll); @@ -83,7 +80,8 @@ public class IntegerFieldMapper extends NumberFieldMapper { } public static class TypeParser implements Mapper.TypeParser { - @Override public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { + @Override + public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { IntegerFieldMapper.Builder builder = integerField(name); parseNumberField(builder, name, node, parserContext); for (Map.Entry entry : node.entrySet()) { @@ -111,11 +109,13 @@ public class IntegerFieldMapper extends NumberFieldMapper { this.nullValueAsString = nullValue == null ? null : nullValue.toString(); } - @Override protected int maxPrecisionStep() { + @Override + protected int maxPrecisionStep() { return 32; } - @Override public Integer value(Fieldable field) { + @Override + public Integer value(Fieldable field) { byte[] value = field.getBinaryValue(); if (value == null) { return null; @@ -123,15 +123,18 @@ public class IntegerFieldMapper extends NumberFieldMapper { return Numbers.bytesToInt(value); } - @Override public Integer valueFromString(String value) { + @Override + public Integer valueFromString(String value) { return Integer.parseInt(value); } - @Override public String indexedValue(String value) { + @Override + public String indexedValue(String value) { return NumericUtils.intToPrefixCoded(Integer.parseInt(value)); } - @Override public Query fuzzyQuery(String value, String minSim, int prefixLength, int maxExpansions) { + @Override + public Query fuzzyQuery(String value, String minSim, int prefixLength, int maxExpansions) { int iValue = Integer.parseInt(value); int iSim; try { @@ -145,7 +148,8 @@ public class IntegerFieldMapper extends NumberFieldMapper { true, true); } - @Override public Query fuzzyQuery(String value, double minSim, int prefixLength, int maxExpansions) { + @Override + public Query fuzzyQuery(String value, double minSim, int prefixLength, int maxExpansions) { int iValue = Integer.parseInt(value); int iSim = (int) (minSim * dFuzzyFactor); return NumericRangeQuery.newIntRange(names.indexName(), precisionStep, @@ -154,32 +158,37 @@ public class IntegerFieldMapper extends NumberFieldMapper { true, true); } - @Override public Query rangeQuery(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { + @Override + public Query rangeQuery(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { return NumericRangeQuery.newIntRange(names.indexName(), precisionStep, lowerTerm == null ? null : Integer.parseInt(lowerTerm), upperTerm == null ? null : Integer.parseInt(upperTerm), includeLower, includeUpper); } - @Override public Filter rangeFilter(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { + @Override + public Filter rangeFilter(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { return NumericRangeFilter.newIntRange(names.indexName(), precisionStep, lowerTerm == null ? null : Integer.parseInt(lowerTerm), upperTerm == null ? null : Integer.parseInt(upperTerm), includeLower, includeUpper); } - @Override public Filter rangeFilter(FieldDataCache fieldDataCache, String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { + @Override + public Filter rangeFilter(FieldDataCache fieldDataCache, String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { return NumericRangeFieldDataFilter.newIntRange(fieldDataCache, names.indexName(), lowerTerm == null ? null : Integer.parseInt(lowerTerm), upperTerm == null ? null : Integer.parseInt(upperTerm), includeLower, includeUpper); } - @Override protected boolean customBoost() { + @Override + protected boolean customBoost() { return true; } - @Override protected Fieldable parseCreateField(ParseContext context) throws IOException { + @Override + protected Fieldable parseCreateField(ParseContext context) throws IOException { int value; float boost = this.boost; if (context.externalValueSet()) { @@ -251,15 +260,18 @@ public class IntegerFieldMapper extends NumberFieldMapper { return field; } - @Override public FieldDataType fieldDataType() { + @Override + public FieldDataType fieldDataType() { return FieldDataType.DefaultTypes.INT; } - @Override protected String contentType() { + @Override + protected String contentType() { return CONTENT_TYPE; } - @Override public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { + @Override + public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { super.merge(mergeWith, mergeContext); if (!this.getClass().equals(mergeWith.getClass())) { return; @@ -270,7 +282,8 @@ public class IntegerFieldMapper extends NumberFieldMapper { } } - @Override protected void doXContentBody(XContentBuilder builder) throws IOException { + @Override + protected void doXContentBody(XContentBuilder builder) throws IOException { super.doXContentBody(builder); if (index != Defaults.INDEX) { builder.field("index", index.name().toLowerCase()); @@ -313,14 +326,16 @@ public class IntegerFieldMapper extends NumberFieldMapper { this.number = number; } - @Override public TokenStream tokenStreamValue() { + @Override + public TokenStream tokenStreamValue() { if (isIndexed) { return mapper.popCachedStream().setIntValue(number); } return null; } - @Override public String numericAsString() { + @Override + public String numericAsString() { return Integer.toString(number); } } diff --git a/src/main/java/org/elasticsearch/index/mapper/core/LongFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/LongFieldMapper.java index aac5b9d5568..b970500c030 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/LongFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/LongFieldMapper.java @@ -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,22 +35,18 @@ import org.elasticsearch.index.analysis.NamedAnalyzer; import org.elasticsearch.index.analysis.NumericLongAnalyzer; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldDataType; -import org.elasticsearch.index.mapper.Mapper; -import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MergeContext; -import org.elasticsearch.index.mapper.MergeMappingException; -import org.elasticsearch.index.mapper.ParseContext; +import org.elasticsearch.index.mapper.*; import org.elasticsearch.index.search.NumericRangeFieldDataFilter; import java.io.IOException; import java.util.Map; -import static org.elasticsearch.common.xcontent.support.XContentMapValues.*; -import static org.elasticsearch.index.mapper.MapperBuilders.*; -import static org.elasticsearch.index.mapper.core.TypeParsers.*; +import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeLongValue; +import static org.elasticsearch.index.mapper.MapperBuilders.longField; +import static org.elasticsearch.index.mapper.core.TypeParsers.parseNumberField; /** - * @author kimchy (shay.banon) + * */ public class LongFieldMapper extends NumberFieldMapper { @@ -74,7 +70,8 @@ public class LongFieldMapper extends NumberFieldMapper { return this; } - @Override public LongFieldMapper build(BuilderContext context) { + @Override + public LongFieldMapper build(BuilderContext context) { LongFieldMapper fieldMapper = new LongFieldMapper(buildNames(context), precisionStep, fuzzyFactor, index, store, boost, omitNorms, omitTermFreqAndPositions, nullValue); fieldMapper.includeInAll(includeInAll); @@ -83,7 +80,8 @@ public class LongFieldMapper extends NumberFieldMapper { } public static class TypeParser implements Mapper.TypeParser { - @Override public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { + @Override + public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { LongFieldMapper.Builder builder = longField(name); parseNumberField(builder, name, node, parserContext); for (Map.Entry entry : node.entrySet()) { @@ -111,11 +109,13 @@ public class LongFieldMapper extends NumberFieldMapper { this.nullValueAsString = nullValue == null ? null : nullValue.toString(); } - @Override protected int maxPrecisionStep() { + @Override + protected int maxPrecisionStep() { return 64; } - @Override public Long value(Fieldable field) { + @Override + public Long value(Fieldable field) { byte[] value = field.getBinaryValue(); if (value == null) { return null; @@ -123,15 +123,18 @@ public class LongFieldMapper extends NumberFieldMapper { return Numbers.bytesToLong(value); } - @Override public Long valueFromString(String value) { + @Override + public Long valueFromString(String value) { return Long.valueOf(value); } - @Override public String indexedValue(String value) { + @Override + public String indexedValue(String value) { return NumericUtils.longToPrefixCoded(Long.parseLong(value)); } - @Override public Query fuzzyQuery(String value, String minSim, int prefixLength, int maxExpansions) { + @Override + public Query fuzzyQuery(String value, String minSim, int prefixLength, int maxExpansions) { long iValue = Long.parseLong(value); long iSim; try { @@ -145,7 +148,8 @@ public class LongFieldMapper extends NumberFieldMapper { true, true); } - @Override public Query fuzzyQuery(String value, double minSim, int prefixLength, int maxExpansions) { + @Override + public Query fuzzyQuery(String value, double minSim, int prefixLength, int maxExpansions) { long iValue = Long.parseLong(value); long iSim = (long) (minSim * dFuzzyFactor); return NumericRangeQuery.newLongRange(names.indexName(), precisionStep, @@ -154,32 +158,37 @@ public class LongFieldMapper extends NumberFieldMapper { true, true); } - @Override public Query rangeQuery(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { + @Override + public Query rangeQuery(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { return NumericRangeQuery.newLongRange(names.indexName(), precisionStep, lowerTerm == null ? null : Long.parseLong(lowerTerm), upperTerm == null ? null : Long.parseLong(upperTerm), includeLower, includeUpper); } - @Override public Filter rangeFilter(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { + @Override + public Filter rangeFilter(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { return NumericRangeFilter.newLongRange(names.indexName(), precisionStep, lowerTerm == null ? null : Long.parseLong(lowerTerm), upperTerm == null ? null : Long.parseLong(upperTerm), includeLower, includeUpper); } - @Override public Filter rangeFilter(FieldDataCache fieldDataCache, String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { + @Override + public Filter rangeFilter(FieldDataCache fieldDataCache, String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { return NumericRangeFieldDataFilter.newLongRange(fieldDataCache, names.indexName(), lowerTerm == null ? null : Long.parseLong(lowerTerm), upperTerm == null ? null : Long.parseLong(upperTerm), includeLower, includeUpper); } - @Override protected boolean customBoost() { + @Override + protected boolean customBoost() { return true; } - @Override protected Fieldable parseCreateField(ParseContext context) throws IOException { + @Override + protected Fieldable parseCreateField(ParseContext context) throws IOException { long value; float boost = this.boost; if (context.externalValueSet()) { @@ -250,15 +259,18 @@ public class LongFieldMapper extends NumberFieldMapper { return field; } - @Override public FieldDataType fieldDataType() { + @Override + public FieldDataType fieldDataType() { return FieldDataType.DefaultTypes.LONG; } - @Override protected String contentType() { + @Override + protected String contentType() { return CONTENT_TYPE; } - @Override public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { + @Override + public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { super.merge(mergeWith, mergeContext); if (!this.getClass().equals(mergeWith.getClass())) { return; @@ -269,7 +281,8 @@ public class LongFieldMapper extends NumberFieldMapper { } } - @Override protected void doXContentBody(XContentBuilder builder) throws IOException { + @Override + protected void doXContentBody(XContentBuilder builder) throws IOException { super.doXContentBody(builder); if (index != Defaults.INDEX) { builder.field("index", index.name().toLowerCase()); @@ -312,14 +325,16 @@ public class LongFieldMapper extends NumberFieldMapper { this.number = number; } - @Override public TokenStream tokenStreamValue() { + @Override + public TokenStream tokenStreamValue() { if (isIndexed) { return mapper.popCachedStream().setLongValue(number); } return null; } - @Override public String numericAsString() { + @Override + public String numericAsString() { return Long.toString(number); } } diff --git a/src/main/java/org/elasticsearch/index/mapper/core/NumberFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/NumberFieldMapper.java index f488aaee250..d1b45b8e475 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/NumberFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/NumberFieldMapper.java @@ -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 @@ -40,7 +40,7 @@ import org.elasticsearch.index.query.QueryParseContext; import java.io.Reader; /** - * @author kimchy (shay.banon) + * */ public abstract class NumberFieldMapper extends AbstractFieldMapper implements AllFieldMapper.IncludeInAll { @@ -65,19 +65,23 @@ public abstract class NumberFieldMapper extends AbstractFieldM this.omitTermFreqAndPositions = Defaults.OMIT_TERM_FREQ_AND_POSITIONS; } - @Override public T store(Field.Store store) { + @Override + public T store(Field.Store store) { return super.store(store); } - @Override public T boost(float boost) { + @Override + public T boost(float boost) { return super.boost(boost); } - @Override public T indexName(String indexName) { + @Override + public T indexName(String indexName) { return super.indexName(indexName); } - @Override public T includeInAll(Boolean includeInAll) { + @Override + public T includeInAll(Boolean includeInAll) { return super.includeInAll(includeInAll); } @@ -101,7 +105,8 @@ public abstract class NumberFieldMapper extends AbstractFieldM protected Boolean includeInAll; private ThreadLocal tokenStream = new ThreadLocal() { - @Override protected NumericTokenStream initialValue() { + @Override + protected NumericTokenStream initialValue() { return new NumericTokenStream(precisionStep); } }; @@ -127,13 +132,15 @@ public abstract class NumberFieldMapper extends AbstractFieldM return Double.parseDouble(fuzzyFactor); } - @Override public void includeInAll(Boolean includeInAll) { + @Override + public void includeInAll(Boolean includeInAll) { if (includeInAll != null) { this.includeInAll = includeInAll; } } - @Override public void includeInAllIfNotSet(Boolean includeInAll) { + @Override + public void includeInAllIfNotSet(Boolean includeInAll) { if (includeInAll != null && this.includeInAll == null) { this.includeInAll = includeInAll; } @@ -148,7 +155,8 @@ public abstract class NumberFieldMapper extends AbstractFieldM /** * Use the field query created here when matching on numbers. */ - @Override public boolean useFieldQueryWithQueryString() { + @Override + public boolean useFieldQueryWithQueryString() { return true; } @@ -156,25 +164,31 @@ public abstract class NumberFieldMapper extends AbstractFieldM * Numeric field level query are basically range queries with same value and included. That's the recommended * way to execute it. */ - @Override public Query fieldQuery(String value, @Nullable QueryParseContext context) { + @Override + public Query fieldQuery(String value, @Nullable QueryParseContext context) { return rangeQuery(value, value, true, true); } - @Override public abstract Query fuzzyQuery(String value, String minSim, int prefixLength, int maxExpansions); + @Override + public abstract Query fuzzyQuery(String value, String minSim, int prefixLength, int maxExpansions); - @Override public abstract Query fuzzyQuery(String value, double minSim, int prefixLength, int maxExpansions); + @Override + public abstract Query fuzzyQuery(String value, double minSim, int prefixLength, int maxExpansions); /** * Numeric field level filter are basically range queries with same value and included. That's the recommended * way to execute it. */ - @Override public Filter fieldFilter(String value, @Nullable QueryParseContext context) { + @Override + public Filter fieldFilter(String value, @Nullable QueryParseContext context) { return rangeFilter(value, value, true, true); } - @Override public abstract Query rangeQuery(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper); + @Override + public abstract Query rangeQuery(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper); - @Override public abstract Filter rangeFilter(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper); + @Override + public abstract Filter rangeFilter(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper); /** * A range filter based on the field data cache. @@ -184,16 +198,19 @@ public abstract class NumberFieldMapper extends AbstractFieldM /** * Override the default behavior (to return the string, and return the actual Number instance). */ - @Override public Object valueForSearch(Fieldable field) { + @Override + public Object valueForSearch(Fieldable field) { return value(field); } - @Override public String valueAsString(Fieldable field) { + @Override + public String valueAsString(Fieldable field) { Number num = value(field); return num == null ? null : num.toString(); } - @Override public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { + @Override + public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { super.merge(mergeWith, mergeContext); if (!this.getClass().equals(mergeWith.getClass())) { return; @@ -206,11 +223,13 @@ public abstract class NumberFieldMapper extends AbstractFieldM } } - @Override public void close() { + @Override + public void close() { tokenStream.remove(); } - @Override public abstract FieldDataType fieldDataType(); + @Override + public abstract FieldDataType fieldDataType(); protected NumericTokenStream popCachedStream() { return tokenStream.get(); @@ -241,11 +260,13 @@ public abstract class NumberFieldMapper extends AbstractFieldM setStoreTermVector(Field.TermVector.NO); } - @Override public String stringValue() { + @Override + public String stringValue() { return null; } - @Override public Reader readerValue() { + @Override + public Reader readerValue() { return null; } diff --git a/src/main/java/org/elasticsearch/index/mapper/core/ShortFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/ShortFieldMapper.java index 59a81624c93..28b5a66d735 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/ShortFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/ShortFieldMapper.java @@ -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,22 +35,18 @@ import org.elasticsearch.index.analysis.NamedAnalyzer; import org.elasticsearch.index.analysis.NumericIntegerAnalyzer; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldDataType; -import org.elasticsearch.index.mapper.Mapper; -import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MergeContext; -import org.elasticsearch.index.mapper.MergeMappingException; -import org.elasticsearch.index.mapper.ParseContext; +import org.elasticsearch.index.mapper.*; import org.elasticsearch.index.search.NumericRangeFieldDataFilter; import java.io.IOException; import java.util.Map; -import static org.elasticsearch.common.xcontent.support.XContentMapValues.*; -import static org.elasticsearch.index.mapper.MapperBuilders.*; -import static org.elasticsearch.index.mapper.core.TypeParsers.*; +import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeShortValue; +import static org.elasticsearch.index.mapper.MapperBuilders.shortField; +import static org.elasticsearch.index.mapper.core.TypeParsers.parseNumberField; /** - * @author kimchy (shay.banon) + * */ public class ShortFieldMapper extends NumberFieldMapper { @@ -74,7 +70,8 @@ public class ShortFieldMapper extends NumberFieldMapper { return this; } - @Override public ShortFieldMapper build(BuilderContext context) { + @Override + public ShortFieldMapper build(BuilderContext context) { ShortFieldMapper fieldMapper = new ShortFieldMapper(buildNames(context), precisionStep, fuzzyFactor, index, store, boost, omitNorms, omitTermFreqAndPositions, nullValue); fieldMapper.includeInAll(includeInAll); @@ -83,7 +80,8 @@ public class ShortFieldMapper extends NumberFieldMapper { } public static class TypeParser implements Mapper.TypeParser { - @Override public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { + @Override + public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { ShortFieldMapper.Builder builder = shortField(name); parseNumberField(builder, name, node, parserContext); for (Map.Entry entry : node.entrySet()) { @@ -111,11 +109,13 @@ public class ShortFieldMapper extends NumberFieldMapper { this.nullValueAsString = nullValue == null ? null : nullValue.toString(); } - @Override protected int maxPrecisionStep() { + @Override + protected int maxPrecisionStep() { return 32; } - @Override public Short value(Fieldable field) { + @Override + public Short value(Fieldable field) { byte[] value = field.getBinaryValue(); if (value == null) { return null; @@ -123,15 +123,18 @@ public class ShortFieldMapper extends NumberFieldMapper { return Numbers.bytesToShort(value); } - @Override public Short valueFromString(String value) { + @Override + public Short valueFromString(String value) { return Short.valueOf(value); } - @Override public String indexedValue(String value) { + @Override + public String indexedValue(String value) { return NumericUtils.intToPrefixCoded(Short.parseShort(value)); } - @Override public Query fuzzyQuery(String value, String minSim, int prefixLength, int maxExpansions) { + @Override + public Query fuzzyQuery(String value, String minSim, int prefixLength, int maxExpansions) { short iValue = Short.parseShort(value); short iSim; try { @@ -145,7 +148,8 @@ public class ShortFieldMapper extends NumberFieldMapper { true, true); } - @Override public Query fuzzyQuery(String value, double minSim, int prefixLength, int maxExpansions) { + @Override + public Query fuzzyQuery(String value, double minSim, int prefixLength, int maxExpansions) { short iValue = Short.parseShort(value); short iSim = (short) (minSim * dFuzzyFactor); return NumericRangeQuery.newIntRange(names.indexName(), precisionStep, @@ -154,32 +158,37 @@ public class ShortFieldMapper extends NumberFieldMapper { true, true); } - @Override public Query rangeQuery(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { + @Override + public Query rangeQuery(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { return NumericRangeQuery.newIntRange(names.indexName(), precisionStep, lowerTerm == null ? null : Integer.parseInt(lowerTerm), upperTerm == null ? null : Integer.parseInt(upperTerm), includeLower, includeUpper); } - @Override public Filter rangeFilter(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { + @Override + public Filter rangeFilter(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { return NumericRangeFilter.newIntRange(names.indexName(), precisionStep, lowerTerm == null ? null : Integer.parseInt(lowerTerm), upperTerm == null ? null : Integer.parseInt(upperTerm), includeLower, includeUpper); } - @Override public Filter rangeFilter(FieldDataCache fieldDataCache, String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { + @Override + public Filter rangeFilter(FieldDataCache fieldDataCache, String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { return NumericRangeFieldDataFilter.newShortRange(fieldDataCache, names.indexName(), lowerTerm == null ? null : Short.parseShort(lowerTerm), upperTerm == null ? null : Short.parseShort(upperTerm), includeLower, includeUpper); } - @Override protected boolean customBoost() { + @Override + protected boolean customBoost() { return true; } - @Override protected Fieldable parseCreateField(ParseContext context) throws IOException { + @Override + protected Fieldable parseCreateField(ParseContext context) throws IOException { short value; float boost = this.boost; if (context.externalValueSet()) { @@ -250,15 +259,18 @@ public class ShortFieldMapper extends NumberFieldMapper { return field; } - @Override public FieldDataType fieldDataType() { + @Override + public FieldDataType fieldDataType() { return FieldDataType.DefaultTypes.SHORT; } - @Override protected String contentType() { + @Override + protected String contentType() { return CONTENT_TYPE; } - @Override public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { + @Override + public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { super.merge(mergeWith, mergeContext); if (!this.getClass().equals(mergeWith.getClass())) { return; @@ -269,7 +281,8 @@ public class ShortFieldMapper extends NumberFieldMapper { } } - @Override protected void doXContentBody(XContentBuilder builder) throws IOException { + @Override + protected void doXContentBody(XContentBuilder builder) throws IOException { super.doXContentBody(builder); if (index != Defaults.INDEX) { builder.field("index", index.name().toLowerCase()); @@ -312,14 +325,16 @@ public class ShortFieldMapper extends NumberFieldMapper { this.number = number; } - @Override public TokenStream tokenStreamValue() { + @Override + public TokenStream tokenStreamValue() { if (isIndexed) { return mapper.popCachedStream().setIntValue(number); } return null; } - @Override public String numericAsString() { + @Override + public String numericAsString() { return Short.toString(number); } } diff --git a/src/main/java/org/elasticsearch/index/mapper/core/StringFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/StringFieldMapper.java index 4fa3c985cae..0870857862d 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/StringFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/StringFieldMapper.java @@ -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,21 +25,17 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.analysis.NamedAnalyzer; -import org.elasticsearch.index.mapper.Mapper; -import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MergeContext; -import org.elasticsearch.index.mapper.MergeMappingException; -import org.elasticsearch.index.mapper.ParseContext; +import org.elasticsearch.index.mapper.*; import org.elasticsearch.index.mapper.internal.AllFieldMapper; import java.io.IOException; import java.util.Map; -import static org.elasticsearch.index.mapper.MapperBuilders.*; -import static org.elasticsearch.index.mapper.core.TypeParsers.*; +import static org.elasticsearch.index.mapper.MapperBuilders.stringField; +import static org.elasticsearch.index.mapper.core.TypeParsers.parseField; /** - * @author kimchy (shay.banon) + * */ public class StringFieldMapper extends AbstractFieldMapper implements AllFieldMapper.IncludeInAll { @@ -64,12 +60,14 @@ public class StringFieldMapper extends AbstractFieldMapper implements Al return this; } - @Override public Builder includeInAll(Boolean includeInAll) { + @Override + public Builder includeInAll(Boolean includeInAll) { this.includeInAll = includeInAll; return this; } - @Override public StringFieldMapper build(BuilderContext context) { + @Override + public StringFieldMapper build(BuilderContext context) { StringFieldMapper fieldMapper = new StringFieldMapper(buildNames(context), index, store, termVector, boost, omitNorms, omitTermFreqAndPositions, nullValue, indexAnalyzer, searchAnalyzer); @@ -79,7 +77,8 @@ public class StringFieldMapper extends AbstractFieldMapper implements Al } public static class TypeParser implements Mapper.TypeParser { - @Override public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { + @Override + public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { StringFieldMapper.Builder builder = stringField(name); parseField(builder, name, node, parserContext); for (Map.Entry entry : node.entrySet()) { @@ -104,39 +103,47 @@ public class StringFieldMapper extends AbstractFieldMapper implements Al this.nullValue = nullValue; } - @Override public void includeInAll(Boolean includeInAll) { + @Override + public void includeInAll(Boolean includeInAll) { if (includeInAll != null) { this.includeInAll = includeInAll; } } - @Override public void includeInAllIfNotSet(Boolean includeInAll) { + @Override + public void includeInAllIfNotSet(Boolean includeInAll) { if (includeInAll != null && this.includeInAll == null) { this.includeInAll = includeInAll; } } - @Override public String value(Fieldable field) { + @Override + public String value(Fieldable field) { return field.stringValue(); } - @Override public String valueFromString(String value) { + @Override + public String valueFromString(String value) { return value; } - @Override public String valueAsString(Fieldable field) { + @Override + public String valueAsString(Fieldable field) { return value(field); } - @Override public String indexedValue(String value) { + @Override + public String indexedValue(String value) { return value; } - @Override protected boolean customBoost() { + @Override + protected boolean customBoost() { return true; } - @Override protected Field parseCreateField(ParseContext context) throws IOException { + @Override + protected Field parseCreateField(ParseContext context) throws IOException { String value = nullValue; float boost = this.boost; if (context.externalValueSet()) { @@ -178,11 +185,13 @@ public class StringFieldMapper extends AbstractFieldMapper implements Al return field; } - @Override protected String contentType() { + @Override + protected String contentType() { return CONTENT_TYPE; } - @Override public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { + @Override + public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { super.merge(mergeWith, mergeContext); if (!this.getClass().equals(mergeWith.getClass())) { return; @@ -193,7 +202,8 @@ public class StringFieldMapper extends AbstractFieldMapper implements Al } } - @Override protected void doXContentBody(XContentBuilder builder) throws IOException { + @Override + protected void doXContentBody(XContentBuilder builder) throws IOException { super.doXContentBody(builder); if (index != Defaults.INDEX) { builder.field("index", index.name().toLowerCase()); diff --git a/src/main/java/org/elasticsearch/index/mapper/core/TypeParsers.java b/src/main/java/org/elasticsearch/index/mapper/core/TypeParsers.java index ac6c9794f5e..d6735dd9963 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/TypeParsers.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/TypeParsers.java @@ -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,7 +33,7 @@ import java.util.Map; import static org.elasticsearch.common.xcontent.support.XContentMapValues.*; /** - * @author kimchy (shay.banon) + * */ public class TypeParsers { diff --git a/src/main/java/org/elasticsearch/index/mapper/default-mapping.json b/src/main/java/org/elasticsearch/index/mapper/default-mapping.json index 05ad6188e38..7b035a36d4f 100644 --- a/src/main/java/org/elasticsearch/index/mapper/default-mapping.json +++ b/src/main/java/org/elasticsearch/index/mapper/default-mapping.json @@ -1,4 +1,4 @@ { - "_default_" : { + "_default_":{ } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/mapper/geo/GeoPoint.java b/src/main/java/org/elasticsearch/index/mapper/geo/GeoPoint.java index ab7dbc5db93..ae991d93374 100644 --- a/src/main/java/org/elasticsearch/index/mapper/geo/GeoPoint.java +++ b/src/main/java/org/elasticsearch/index/mapper/geo/GeoPoint.java @@ -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.index.mapper.geo; import org.elasticsearch.index.search.geo.GeoHashUtils; /** - * @author kimchy (shay.banon) + * */ public class GeoPoint { diff --git a/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointDocFieldData.java b/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointDocFieldData.java index db8c1e819e9..c56c1ddb8ef 100644 --- a/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointDocFieldData.java +++ b/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointDocFieldData.java @@ -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.unit.DistanceUnit; import org.elasticsearch.index.field.data.DocFieldData; /** - * @author kimchy (shay.banon) + * */ public class GeoPointDocFieldData extends DocFieldData { diff --git a/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldData.java b/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldData.java index 3e1d59003de..43e7c4e98d8 100644 --- a/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldData.java +++ b/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldData.java @@ -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.index.mapper.geo; +import gnu.trove.list.array.TDoubleArrayList; import org.apache.lucene.index.IndexReader; import org.elasticsearch.common.RamUsage; import org.elasticsearch.common.thread.ThreadLocals; -import org.elasticsearch.common.trove.list.array.TDoubleArrayList; import org.elasticsearch.common.unit.DistanceUnit; import org.elasticsearch.index.field.data.FieldData; import org.elasticsearch.index.field.data.FieldDataType; @@ -33,12 +33,13 @@ import org.elasticsearch.index.search.geo.GeoHashUtils; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public abstract class GeoPointFieldData extends FieldData { static ThreadLocal> valuesCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { return new ThreadLocals.CleanableValue(new GeoPoint()); } }; @@ -50,7 +51,8 @@ public abstract class GeoPointFieldData extends FieldData } static ThreadLocal> geoHashCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { return new ThreadLocals.CleanableValue(new GeoPointHash()); } }; @@ -101,28 +103,34 @@ public abstract class GeoPointFieldData extends FieldData return GeoDistance.PLANE.calculate(latValue(docId), lonValue(docId), geoPointHash.lat, geoPointHash.lon, unit); } - @Override public GeoPointDocFieldData docFieldData(int docId) { + @Override + public GeoPointDocFieldData docFieldData(int docId) { return super.docFieldData(docId); } - @Override protected long computeSizeInBytes() { + @Override + protected long computeSizeInBytes() { return (RamUsage.NUM_BYTES_DOUBLE * lat.length + RamUsage.NUM_BYTES_ARRAY_HEADER) + (RamUsage.NUM_BYTES_DOUBLE * lon.length + RamUsage.NUM_BYTES_ARRAY_HEADER); } - @Override public String stringValue(int docId) { + @Override + public String stringValue(int docId) { return value(docId).geohash(); } - @Override protected GeoPointDocFieldData createFieldData() { + @Override + protected GeoPointDocFieldData createFieldData() { return new GeoPointDocFieldData(this); } - @Override public FieldDataType type() { + @Override + public FieldDataType type() { return GeoPointFieldDataType.TYPE; } - @Override public void forEachValue(StringValueProc proc) { + @Override + public void forEachValue(StringValueProc proc) { for (int i = 1; i < lat.length; i++) { proc.onValue(GeoHashUtils.encode(lat[i], lon[i])); } @@ -172,18 +180,21 @@ public abstract class GeoPointFieldData extends FieldData lon.add(0); } - @Override public void collectTerm(String term) { + @Override + public void collectTerm(String term) { int comma = term.indexOf(','); lat.add(Double.parseDouble(term.substring(0, comma))); lon.add(Double.parseDouble(term.substring(comma + 1))); } - @Override public GeoPointFieldData buildSingleValue(String field, int[] ordinals) { + @Override + public GeoPointFieldData buildSingleValue(String field, int[] ordinals) { return new SingleValueGeoPointFieldData(field, ordinals, lat.toArray(), lon.toArray()); } - @Override public GeoPointFieldData buildMultiValue(String field, int[][] ordinals) { + @Override + public GeoPointFieldData buildMultiValue(String field, int[][] ordinals) { return new MultiValueGeoPointFieldData(field, ordinals, lat.toArray(), lon.toArray()); } } diff --git a/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldDataType.java b/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldDataType.java index dbc6f40c6fa..225017b3148 100644 --- a/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldDataType.java +++ b/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldDataType.java @@ -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,25 +29,29 @@ import org.elasticsearch.index.field.data.strings.StringOrdValFieldDataComparato import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class GeoPointFieldDataType implements FieldDataType { public static final GeoPointFieldDataType TYPE = new GeoPointFieldDataType(); - @Override public ExtendedFieldComparatorSource newFieldComparatorSource(final FieldDataCache cache, final String missing) { + @Override + public ExtendedFieldComparatorSource newFieldComparatorSource(final FieldDataCache cache, final String missing) { return new ExtendedFieldComparatorSource() { - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + @Override + public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { return new StringOrdValFieldDataComparator(numHits, fieldname, sortPos, reversed, cache); } - @Override public int reducedType() { + @Override + public int reducedType() { return SortField.STRING; } }; } - @Override public GeoPointFieldData load(IndexReader reader, String fieldName) throws IOException { + @Override + public GeoPointFieldData load(IndexReader reader, String fieldName) throws IOException { return GeoPointFieldData.load(reader, fieldName); } } diff --git a/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapper.java index 7a76dc94cb6..406efe63b28 100644 --- a/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapper.java @@ -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,14 +27,7 @@ import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.support.XContentMapValues; import org.elasticsearch.index.analysis.NamedAnalyzer; import org.elasticsearch.index.field.data.FieldDataType; -import org.elasticsearch.index.mapper.ContentPath; -import org.elasticsearch.index.mapper.FieldMapperListener; -import org.elasticsearch.index.mapper.Mapper; -import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MergeContext; -import org.elasticsearch.index.mapper.MergeMappingException; -import org.elasticsearch.index.mapper.ObjectMapperListener; -import org.elasticsearch.index.mapper.ParseContext; +import org.elasticsearch.index.mapper.*; import org.elasticsearch.index.mapper.core.AbstractFieldMapper; import org.elasticsearch.index.mapper.core.DoubleFieldMapper; import org.elasticsearch.index.mapper.core.NumberFieldMapper; @@ -46,12 +39,14 @@ import org.elasticsearch.index.search.geo.GeoUtils; import java.io.IOException; import java.util.Map; -import static org.elasticsearch.index.mapper.MapperBuilders.*; -import static org.elasticsearch.index.mapper.core.TypeParsers.*; +import static org.elasticsearch.index.mapper.MapperBuilders.doubleField; +import static org.elasticsearch.index.mapper.MapperBuilders.stringField; +import static org.elasticsearch.index.mapper.core.TypeParsers.parsePathType; +import static org.elasticsearch.index.mapper.core.TypeParsers.parseStore; /** * Parsing: We handle: - * + *

    * - "field" : "geo_hash" * - "field" : "lat,lon" * - "field" : { @@ -59,7 +54,7 @@ import static org.elasticsearch.index.mapper.core.TypeParsers.*; * "lon" : 2.1 * } * - * @author kimchy (shay.banon) + * */ public class GeoPointFieldMapper implements Mapper, ArrayValueMapperParser { @@ -140,7 +135,8 @@ public class GeoPointFieldMapper implements Mapper, ArrayValueMapperParser { return this; } - @Override public GeoPointFieldMapper build(BuilderContext context) { + @Override + public GeoPointFieldMapper build(BuilderContext context) { ContentPath.Type origPathType = context.path().pathType(); context.path().pathType(pathType); @@ -177,7 +173,8 @@ public class GeoPointFieldMapper implements Mapper, ArrayValueMapperParser { } public static class TypeParser implements Mapper.TypeParser { - @Override public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { + @Override + public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { Builder builder = new Builder(name); for (Map.Entry entry : node.entrySet()) { @@ -266,7 +263,8 @@ public class GeoPointFieldMapper implements Mapper, ArrayValueMapperParser { this.normalizeLon = normalizeLon; } - @Override public String name() { + @Override + public String name() { return this.name; } @@ -282,7 +280,8 @@ public class GeoPointFieldMapper implements Mapper, ArrayValueMapperParser { return enableLatLon; } - @Override public void parse(ParseContext context) throws IOException { + @Override + public void parse(ParseContext context) throws IOException { ContentPath.Type origPathType = context.path().pathType(); context.path().pathType(pathType); context.path().add(name); @@ -442,7 +441,8 @@ public class GeoPointFieldMapper implements Mapper, ArrayValueMapperParser { } } - @Override public void close() { + @Override + public void close() { if (latMapper != null) { latMapper.close(); } @@ -457,11 +457,13 @@ public class GeoPointFieldMapper implements Mapper, ArrayValueMapperParser { } } - @Override public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { + @Override + public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { // TODO } - @Override public void traverse(FieldMapperListener fieldMapperListener) { + @Override + public void traverse(FieldMapperListener fieldMapperListener) { geoStringMapper.traverse(fieldMapperListener); if (enableGeoHash) { geohashMapper.traverse(fieldMapperListener); @@ -472,10 +474,12 @@ public class GeoPointFieldMapper implements Mapper, ArrayValueMapperParser { } } - @Override public void traverse(ObjectMapperListener objectMapperListener) { + @Override + public void traverse(ObjectMapperListener objectMapperListener) { } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(name); builder.field("type", CONTENT_TYPE); if (pathType != Defaults.PATH_TYPE) { @@ -537,12 +541,14 @@ public class GeoPointFieldMapper implements Mapper, ArrayValueMapperParser { return this; } - @Override public Builder includeInAll(Boolean includeInAll) { + @Override + public Builder includeInAll(Boolean includeInAll) { this.includeInAll = includeInAll; return this; } - @Override public GeoStringFieldMapper build(BuilderContext context) { + @Override + public GeoStringFieldMapper build(BuilderContext context) { GeoStringFieldMapper fieldMapper = new GeoStringFieldMapper(buildNames(context), index, store, termVector, boost, omitNorms, omitTermFreqAndPositions, nullValue, indexAnalyzer, searchAnalyzer); @@ -557,7 +563,8 @@ public class GeoPointFieldMapper implements Mapper, ArrayValueMapperParser { super(names, index, store, termVector, boost, omitNorms, omitTermFreqAndPositions, nullValue, indexAnalyzer, searchAnalyzer); } - @Override public FieldDataType fieldDataType() { + @Override + public FieldDataType fieldDataType() { return GeoPointFieldDataType.TYPE; } diff --git a/src/main/java/org/elasticsearch/index/mapper/geo/MultiValueGeoPointFieldData.java b/src/main/java/org/elasticsearch/index/mapper/geo/MultiValueGeoPointFieldData.java index 9e02dedfee5..51428013142 100644 --- a/src/main/java/org/elasticsearch/index/mapper/geo/MultiValueGeoPointFieldData.java +++ b/src/main/java/org/elasticsearch/index/mapper/geo/MultiValueGeoPointFieldData.java @@ -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,14 +25,15 @@ import org.elasticsearch.index.field.data.doubles.DoubleFieldData; import org.elasticsearch.index.search.geo.GeoHashUtils; /** - * @author kimchy (shay.banon) + * */ public class MultiValueGeoPointFieldData extends GeoPointFieldData { private static final int VALUE_CACHE_SIZE = 100; private static ThreadLocal> valuesArrayCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { GeoPoint[][] value = new GeoPoint[VALUE_CACHE_SIZE][]; for (int i = 0; i < value.length; i++) { value[i] = new GeoPoint[i]; @@ -45,7 +46,8 @@ public class MultiValueGeoPointFieldData extends GeoPointFieldData { }; private ThreadLocal> valuesLatCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { double[][] value = new double[VALUE_CACHE_SIZE][]; for (int i = 0; i < value.length; i++) { value[i] = new double[i]; @@ -55,7 +57,8 @@ public class MultiValueGeoPointFieldData extends GeoPointFieldData { }; private ThreadLocal> valuesLonCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { double[][] value = new double[VALUE_CACHE_SIZE][]; for (int i = 0; i < value.length; i++) { value[i] = new double[i]; @@ -72,7 +75,8 @@ public class MultiValueGeoPointFieldData extends GeoPointFieldData { this.ordinals = ordinals; } - @Override protected long computeSizeInBytes() { + @Override + protected long computeSizeInBytes() { long size = super.computeSizeInBytes(); size += RamUsage.NUM_BYTES_ARRAY_HEADER; // for the top level array for (int[] ordinal : ordinals) { @@ -81,11 +85,13 @@ public class MultiValueGeoPointFieldData extends GeoPointFieldData { return size; } - @Override public boolean multiValued() { + @Override + public boolean multiValued() { return true; } - @Override public boolean hasValue(int docId) { + @Override + public boolean hasValue(int docId) { for (int[] ordinal : ordinals) { if (ordinal[docId] != 0) { return true; @@ -94,7 +100,8 @@ public class MultiValueGeoPointFieldData extends GeoPointFieldData { return false; } - @Override public void forEachValueInDoc(int docId, StringValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, StringValueInDocProc proc) { boolean found = false; for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -108,7 +115,8 @@ public class MultiValueGeoPointFieldData extends GeoPointFieldData { } } - @Override public void forEachValueInDoc(int docId, ValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, ValueInDocProc proc) { for (int[] ordinal : ordinals) { int loc = ordinal[docId]; if (loc != 0) { @@ -117,7 +125,8 @@ public class MultiValueGeoPointFieldData extends GeoPointFieldData { } } - @Override public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { + @Override + public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { boolean found = false; for (int[] ordinal : ordinals) { int loc = ordinal[docId]; @@ -131,7 +140,8 @@ public class MultiValueGeoPointFieldData extends GeoPointFieldData { } } - @Override public GeoPoint value(int docId) { + @Override + public GeoPoint value(int docId) { for (int[] ordinal : ordinals) { int loc = ordinal[docId]; if (loc != 0) { @@ -143,7 +153,8 @@ public class MultiValueGeoPointFieldData extends GeoPointFieldData { return null; } - @Override public GeoPoint[] values(int docId) { + @Override + public GeoPoint[] values(int docId) { int length = 0; for (int[] ordinal : ordinals) { if (ordinal[docId] != 0) { @@ -176,7 +187,8 @@ public class MultiValueGeoPointFieldData extends GeoPointFieldData { return points; } - @Override public double latValue(int docId) { + @Override + public double latValue(int docId) { for (int[] ordinal : ordinals) { int loc = ordinal[docId]; if (loc != 0) { @@ -186,7 +198,8 @@ public class MultiValueGeoPointFieldData extends GeoPointFieldData { return 0; } - @Override public double lonValue(int docId) { + @Override + public double lonValue(int docId) { for (int[] ordinal : ordinals) { int loc = ordinal[docId]; if (loc != 0) { @@ -196,7 +209,8 @@ public class MultiValueGeoPointFieldData extends GeoPointFieldData { return 0; } - @Override public double[] latValues(int docId) { + @Override + public double[] latValues(int docId) { int length = 0; for (int[] ordinal : ordinals) { if (ordinal[docId] != 0) { @@ -222,7 +236,8 @@ public class MultiValueGeoPointFieldData extends GeoPointFieldData { return doubles; } - @Override public double[] lonValues(int docId) { + @Override + public double[] lonValues(int docId) { int length = 0; for (int[] ordinal : ordinals) { if (ordinal[docId] != 0) { diff --git a/src/main/java/org/elasticsearch/index/mapper/geo/SingleValueGeoPointFieldData.java b/src/main/java/org/elasticsearch/index/mapper/geo/SingleValueGeoPointFieldData.java index 311ad4c4172..8a734399f57 100644 --- a/src/main/java/org/elasticsearch/index/mapper/geo/SingleValueGeoPointFieldData.java +++ b/src/main/java/org/elasticsearch/index/mapper/geo/SingleValueGeoPointFieldData.java @@ -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,12 +25,13 @@ import org.elasticsearch.index.field.data.doubles.DoubleFieldData; import org.elasticsearch.index.search.geo.GeoHashUtils; /** - * @author kimchy (shay.banon) + * */ public class SingleValueGeoPointFieldData extends GeoPointFieldData { private static ThreadLocal> valuesArrayCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { GeoPoint[] value = new GeoPoint[1]; value[0] = new GeoPoint(); return new ThreadLocals.CleanableValue(value); @@ -38,13 +39,15 @@ public class SingleValueGeoPointFieldData extends GeoPointFieldData { }; private ThreadLocal> valuesLatCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { return new ThreadLocals.CleanableValue(new double[1]); } }; private ThreadLocal> valuesLonCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { return new ThreadLocals.CleanableValue(new double[1]); } }; @@ -58,20 +61,24 @@ public class SingleValueGeoPointFieldData extends GeoPointFieldData { this.ordinals = ordinals; } - @Override protected long computeSizeInBytes() { + @Override + protected long computeSizeInBytes() { return super.computeSizeInBytes() + RamUsage.NUM_BYTES_INT * ordinals.length + RamUsage.NUM_BYTES_ARRAY_HEADER; } - @Override public boolean multiValued() { + @Override + public boolean multiValued() { return false; } - @Override public boolean hasValue(int docId) { + @Override + public boolean hasValue(int docId) { return ordinals[docId] != 0; } - @Override public void forEachValueInDoc(int docId, StringValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, StringValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { proc.onMissing(docId); @@ -80,11 +87,13 @@ public class SingleValueGeoPointFieldData extends GeoPointFieldData { proc.onValue(docId, GeoHashUtils.encode(lat[loc], lon[loc])); } - @Override public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { + @Override + public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) { proc.onOrdinal(docId, ordinals[docId]); } - @Override public void forEachValueInDoc(int docId, ValueInDocProc proc) { + @Override + public void forEachValueInDoc(int docId, ValueInDocProc proc) { int loc = ordinals[docId]; if (loc == 0) { return; @@ -92,7 +101,8 @@ public class SingleValueGeoPointFieldData extends GeoPointFieldData { proc.onValue(docId, lat[loc], lon[loc]); } - @Override public GeoPoint value(int docId) { + @Override + public GeoPoint value(int docId) { int loc = ordinals[docId]; if (loc == 0) { return null; @@ -102,7 +112,8 @@ public class SingleValueGeoPointFieldData extends GeoPointFieldData { return point; } - @Override public GeoPoint[] values(int docId) { + @Override + public GeoPoint[] values(int docId) { int loc = ordinals[docId]; if (loc == 0) { return EMPTY_ARRAY; @@ -112,15 +123,18 @@ public class SingleValueGeoPointFieldData extends GeoPointFieldData { return ret; } - @Override public double latValue(int docId) { + @Override + public double latValue(int docId) { return lat[ordinals[docId]]; } - @Override public double lonValue(int docId) { + @Override + public double lonValue(int docId) { return lon[ordinals[docId]]; } - @Override public double[] latValues(int docId) { + @Override + public double[] latValues(int docId) { int loc = ordinals[docId]; if (loc == 0) { return DoubleFieldData.EMPTY_DOUBLE_ARRAY; @@ -130,7 +144,8 @@ public class SingleValueGeoPointFieldData extends GeoPointFieldData { return ret; } - @Override public double[] lonValues(int docId) { + @Override + public double[] lonValues(int docId) { int loc = ordinals[docId]; if (loc == 0) { return DoubleFieldData.EMPTY_DOUBLE_ARRAY; diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/AllFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/internal/AllFieldMapper.java index 30b4c55a3d5..a44b3f4caae 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/AllFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/AllFieldMapper.java @@ -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,25 +30,19 @@ import org.elasticsearch.common.lucene.all.AllField; import org.elasticsearch.common.lucene.all.AllTermQuery; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.index.analysis.NamedAnalyzer; -import org.elasticsearch.index.mapper.InternalMapper; -import org.elasticsearch.index.mapper.Mapper; -import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MergeContext; -import org.elasticsearch.index.mapper.MergeMappingException; -import org.elasticsearch.index.mapper.ParseContext; -import org.elasticsearch.index.mapper.RootMapper; +import org.elasticsearch.index.mapper.*; import org.elasticsearch.index.mapper.core.AbstractFieldMapper; import org.elasticsearch.index.query.QueryParseContext; import java.io.IOException; import java.util.Map; -import static org.elasticsearch.common.xcontent.support.XContentMapValues.*; -import static org.elasticsearch.index.mapper.MapperBuilders.*; -import static org.elasticsearch.index.mapper.core.TypeParsers.*; +import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeBooleanValue; +import static org.elasticsearch.index.mapper.MapperBuilders.all; +import static org.elasticsearch.index.mapper.core.TypeParsers.parseField; /** - * @author kimchy (shay.banon) + * */ public class AllFieldMapper extends AbstractFieldMapper implements InternalMapper, RootMapper { @@ -84,30 +78,36 @@ public class AllFieldMapper extends AbstractFieldMapper implements Interna return this; } - @Override public Builder store(Field.Store store) { + @Override + public Builder store(Field.Store store) { return super.store(store); } - @Override public Builder termVector(Field.TermVector termVector) { + @Override + public Builder termVector(Field.TermVector termVector) { return super.termVector(termVector); } - @Override protected Builder indexAnalyzer(NamedAnalyzer indexAnalyzer) { + @Override + protected Builder indexAnalyzer(NamedAnalyzer indexAnalyzer) { return super.indexAnalyzer(indexAnalyzer); } - @Override protected Builder searchAnalyzer(NamedAnalyzer searchAnalyzer) { + @Override + protected Builder searchAnalyzer(NamedAnalyzer searchAnalyzer) { return super.searchAnalyzer(searchAnalyzer); } - @Override public AllFieldMapper build(BuilderContext context) { + @Override + public AllFieldMapper build(BuilderContext context) { return new AllFieldMapper(name, store, termVector, omitNorms, omitTermFreqAndPositions, indexAnalyzer, searchAnalyzer, enabled); } } public static class TypeParser implements Mapper.TypeParser { - @Override public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { + @Override + public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { AllFieldMapper.Builder builder = all(); parseField(builder, builder.name, node, parserContext); for (Map.Entry entry : node.entrySet()) { @@ -139,33 +139,41 @@ public class AllFieldMapper extends AbstractFieldMapper implements Interna return this.enabled; } - @Override public Query queryStringTermQuery(Term term) { + @Override + public Query queryStringTermQuery(Term term) { return new AllTermQuery(term); } - @Override public Query fieldQuery(String value, QueryParseContext context) { + @Override + public Query fieldQuery(String value, QueryParseContext context) { return new AllTermQuery(names().createIndexNameTerm(value)); } - @Override public void preParse(ParseContext context) throws IOException { + @Override + public void preParse(ParseContext context) throws IOException { } - @Override public void postParse(ParseContext context) throws IOException { + @Override + public void postParse(ParseContext context) throws IOException { super.parse(context); } - @Override public void parse(ParseContext context) throws IOException { + @Override + public void parse(ParseContext context) throws IOException { // we parse in post parse } - @Override public void validate(ParseContext context) throws MapperParsingException { + @Override + public void validate(ParseContext context) throws MapperParsingException { } - @Override public boolean includeInObject() { + @Override + public boolean includeInObject() { return true; } - @Override protected Fieldable parseCreateField(ParseContext context) throws IOException { + @Override + protected Fieldable parseCreateField(ParseContext context) throws IOException { if (!enabled) { return null; } @@ -191,27 +199,33 @@ public class AllFieldMapper extends AbstractFieldMapper implements Interna return analyzer; } - @Override public Void value(Fieldable field) { + @Override + public Void value(Fieldable field) { return null; } - @Override public Void valueFromString(String value) { + @Override + public Void valueFromString(String value) { return null; } - @Override public String valueAsString(Fieldable field) { + @Override + public String valueAsString(Fieldable field) { return null; } - @Override public Object valueForSearch(Fieldable field) { + @Override + public Object valueForSearch(Fieldable field) { return null; } - @Override protected String contentType() { + @Override + protected String contentType() { return CONTENT_TYPE; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { // if all are defaults, no need to write it at all if (enabled == Defaults.ENABLED && store == Defaults.STORE && termVector == Defaults.TERM_VECTOR && indexAnalyzer == null && searchAnalyzer == null) { return builder; @@ -241,7 +255,8 @@ public class AllFieldMapper extends AbstractFieldMapper implements Interna return builder; } - @Override public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { + @Override + public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { // do nothing here, no merging, but also no exception } } diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/AnalyzerMapper.java b/src/main/java/org/elasticsearch/index/mapper/internal/AnalyzerMapper.java index ee1426ea1a8..aeeca282791 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/AnalyzerMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/AnalyzerMapper.java @@ -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,23 +22,15 @@ package org.elasticsearch.index.mapper.internal; import org.apache.lucene.analysis.Analyzer; import org.elasticsearch.common.Strings; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.index.mapper.FieldMapperListener; -import org.elasticsearch.index.mapper.InternalMapper; -import org.elasticsearch.index.mapper.Mapper; -import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MergeContext; -import org.elasticsearch.index.mapper.MergeMappingException; -import org.elasticsearch.index.mapper.ObjectMapperListener; -import org.elasticsearch.index.mapper.ParseContext; -import org.elasticsearch.index.mapper.RootMapper; +import org.elasticsearch.index.mapper.*; import java.io.IOException; import java.util.Map; -import static org.elasticsearch.index.mapper.MapperBuilders.*; +import static org.elasticsearch.index.mapper.MapperBuilders.analyzer; /** - * @author kimchy (shay.banon) + * */ public class AnalyzerMapper implements Mapper, InternalMapper, RootMapper { @@ -63,13 +55,15 @@ public class AnalyzerMapper implements Mapper, InternalMapper, RootMapper { return this; } - @Override public AnalyzerMapper build(BuilderContext context) { + @Override + public AnalyzerMapper build(BuilderContext context) { return new AnalyzerMapper(field); } } public static class TypeParser implements Mapper.TypeParser { - @Override public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { + @Override + public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { AnalyzerMapper.Builder builder = analyzer(); for (Map.Entry entry : node.entrySet()) { String fieldName = Strings.toUnderscoreCase(entry.getKey()); @@ -92,14 +86,17 @@ public class AnalyzerMapper implements Mapper, InternalMapper, RootMapper { this.path = path; } - @Override public String name() { + @Override + public String name() { return CONTENT_TYPE; } - @Override public void preParse(ParseContext context) throws IOException { + @Override + public void preParse(ParseContext context) throws IOException { } - @Override public void postParse(ParseContext context) throws IOException { + @Override + public void postParse(ParseContext context) throws IOException { Analyzer analyzer = context.docMapper().mappers().indexAnalyzer(); if (path != null) { String value = context.doc().get(path); @@ -117,26 +114,33 @@ public class AnalyzerMapper implements Mapper, InternalMapper, RootMapper { context.analyzer(analyzer); } - @Override public void validate(ParseContext context) throws MapperParsingException { + @Override + public void validate(ParseContext context) throws MapperParsingException { } - @Override public boolean includeInObject() { + @Override + public boolean includeInObject() { return false; } - @Override public void parse(ParseContext context) throws IOException { + @Override + public void parse(ParseContext context) throws IOException { } - @Override public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { + @Override + public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { } - @Override public void traverse(FieldMapperListener fieldMapperListener) { + @Override + public void traverse(FieldMapperListener fieldMapperListener) { } - @Override public void traverse(ObjectMapperListener objectMapperListener) { + @Override + public void traverse(ObjectMapperListener objectMapperListener) { } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { if (path.equals(Defaults.PATH)) { return builder; } @@ -148,7 +152,8 @@ public class AnalyzerMapper implements Mapper, InternalMapper, RootMapper { return builder; } - @Override public void close() { + @Override + public void close() { } } diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/BoostFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/internal/BoostFieldMapper.java index 01934cf8681..2cbeea0c22d 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/BoostFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/BoostFieldMapper.java @@ -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,14 +34,7 @@ import org.elasticsearch.index.analysis.NamedAnalyzer; import org.elasticsearch.index.analysis.NumericFloatAnalyzer; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldDataType; -import org.elasticsearch.index.mapper.InternalMapper; -import org.elasticsearch.index.mapper.Mapper; -import org.elasticsearch.index.mapper.MapperBuilders; -import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MergeContext; -import org.elasticsearch.index.mapper.MergeMappingException; -import org.elasticsearch.index.mapper.ParseContext; -import org.elasticsearch.index.mapper.RootMapper; +import org.elasticsearch.index.mapper.*; import org.elasticsearch.index.mapper.core.FloatFieldMapper; import org.elasticsearch.index.mapper.core.NumberFieldMapper; import org.elasticsearch.index.search.NumericRangeFieldDataFilter; @@ -49,11 +42,11 @@ import org.elasticsearch.index.search.NumericRangeFieldDataFilter; import java.io.IOException; import java.util.Map; -import static org.elasticsearch.common.xcontent.support.XContentMapValues.*; -import static org.elasticsearch.index.mapper.core.TypeParsers.*; +import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeFloatValue; +import static org.elasticsearch.index.mapper.core.TypeParsers.parseNumberField; /** - * @author kimchy (shay.banon) + * */ public class BoostFieldMapper extends NumberFieldMapper implements InternalMapper, RootMapper { @@ -83,14 +76,16 @@ public class BoostFieldMapper extends NumberFieldMapper implements Intern return this; } - @Override public BoostFieldMapper build(BuilderContext context) { + @Override + public BoostFieldMapper build(BuilderContext context) { return new BoostFieldMapper(name, buildIndexName(context), precisionStep, index, store, boost, omitNorms, omitTermFreqAndPositions, nullValue); } } public static class TypeParser implements Mapper.TypeParser { - @Override public Mapper.Builder parse(String fieldName, Map node, ParserContext parserContext) throws MapperParsingException { + @Override + public Mapper.Builder parse(String fieldName, Map node, ParserContext parserContext) throws MapperParsingException { String name = node.get("name") == null ? BoostFieldMapper.Defaults.NAME : node.get("name").toString(); BoostFieldMapper.Builder builder = MapperBuilders.boost(name); parseNumberField(builder, name, node, parserContext); @@ -125,11 +120,13 @@ public class BoostFieldMapper extends NumberFieldMapper implements Intern this.nullValue = nullValue; } - @Override protected int maxPrecisionStep() { + @Override + protected int maxPrecisionStep() { return 32; } - @Override public Float value(Fieldable field) { + @Override + public Float value(Fieldable field) { byte[] value = field.getBinaryValue(); if (value == null) { return null; @@ -137,15 +134,18 @@ public class BoostFieldMapper extends NumberFieldMapper implements Intern return Numbers.bytesToFloat(value); } - @Override public Float valueFromString(String value) { + @Override + public Float valueFromString(String value) { return Float.parseFloat(value); } - @Override public String indexedValue(String value) { + @Override + public String indexedValue(String value) { return NumericUtils.floatToPrefixCoded(Float.parseFloat(value)); } - @Override public Query fuzzyQuery(String value, String minSim, int prefixLength, int maxExpansions) { + @Override + public Query fuzzyQuery(String value, String minSim, int prefixLength, int maxExpansions) { float iValue = Float.parseFloat(value); float iSim = Float.parseFloat(minSim); return NumericRangeQuery.newFloatRange(names.indexName(), precisionStep, @@ -154,7 +154,8 @@ public class BoostFieldMapper extends NumberFieldMapper implements Intern true, true); } - @Override public Query fuzzyQuery(String value, double minSim, int prefixLength, int maxExpansions) { + @Override + public Query fuzzyQuery(String value, double minSim, int prefixLength, int maxExpansions) { float iValue = Float.parseFloat(value); float iSim = (float) (minSim * dFuzzyFactor); return NumericRangeQuery.newFloatRange(names.indexName(), precisionStep, @@ -163,41 +164,49 @@ public class BoostFieldMapper extends NumberFieldMapper implements Intern true, true); } - @Override public Query rangeQuery(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { + @Override + public Query rangeQuery(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { return NumericRangeQuery.newFloatRange(names.indexName(), precisionStep, lowerTerm == null ? null : Float.parseFloat(lowerTerm), upperTerm == null ? null : Float.parseFloat(upperTerm), includeLower, includeUpper); } - @Override public Filter rangeFilter(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { + @Override + public Filter rangeFilter(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { return NumericRangeFilter.newFloatRange(names.indexName(), precisionStep, lowerTerm == null ? null : Float.parseFloat(lowerTerm), upperTerm == null ? null : Float.parseFloat(upperTerm), includeLower, includeUpper); } - @Override public Filter rangeFilter(FieldDataCache fieldDataCache, String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { + @Override + public Filter rangeFilter(FieldDataCache fieldDataCache, String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { return NumericRangeFieldDataFilter.newFloatRange(fieldDataCache, names.indexName(), lowerTerm == null ? null : Float.parseFloat(lowerTerm), upperTerm == null ? null : Float.parseFloat(upperTerm), includeLower, includeUpper); } - @Override public void preParse(ParseContext context) throws IOException { + @Override + public void preParse(ParseContext context) throws IOException { } - @Override public void postParse(ParseContext context) throws IOException { + @Override + public void postParse(ParseContext context) throws IOException { } - @Override public void validate(ParseContext context) throws MapperParsingException { + @Override + public void validate(ParseContext context) throws MapperParsingException { } - @Override public boolean includeInObject() { + @Override + public boolean includeInObject() { return true; } - @Override public void parse(ParseContext context) throws IOException { + @Override + public void parse(ParseContext context) throws IOException { // we override parse since we want to handle cases where it is not indexed and not stored (the default) float value = parseFloatValue(context); if (!Float.isNaN(value)) { @@ -206,7 +215,8 @@ public class BoostFieldMapper extends NumberFieldMapper implements Intern super.parse(context); } - @Override protected Fieldable parseCreateField(ParseContext context) throws IOException { + @Override + protected Fieldable parseCreateField(ParseContext context) throws IOException { final float value = parseFloatValue(context); if (Float.isNaN(value)) { return null; @@ -228,15 +238,18 @@ public class BoostFieldMapper extends NumberFieldMapper implements Intern return value; } - @Override public FieldDataType fieldDataType() { + @Override + public FieldDataType fieldDataType() { return FieldDataType.DefaultTypes.FLOAT; } - @Override protected String contentType() { + @Override + protected String contentType() { return CONTENT_TYPE; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { // all are defaults, don't write it at all if (name().equals(Defaults.NAME) && nullValue == null) { return builder; @@ -252,7 +265,8 @@ public class BoostFieldMapper extends NumberFieldMapper implements Intern return builder; } - @Override public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { + @Override + public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { // do nothing here, no merging, but also no exception } } diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/IdFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/internal/IdFieldMapper.java index 0a290e4f411..04c1e0ee5c7 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/IdFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/IdFieldMapper.java @@ -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.index.mapper.internal; +import com.google.common.collect.ImmutableList; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.document.Fieldable; @@ -27,17 +28,10 @@ import org.apache.lucene.search.Filter; import org.apache.lucene.search.Query; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.collect.ImmutableList; import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.index.mapper.InternalMapper; -import org.elasticsearch.index.mapper.Mapper; -import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MergeContext; -import org.elasticsearch.index.mapper.MergeMappingException; -import org.elasticsearch.index.mapper.ParseContext; -import org.elasticsearch.index.mapper.RootMapper; +import org.elasticsearch.index.mapper.*; import org.elasticsearch.index.mapper.core.AbstractFieldMapper; import org.elasticsearch.index.query.QueryParseContext; import org.elasticsearch.index.search.UidFilter; @@ -45,11 +39,11 @@ import org.elasticsearch.index.search.UidFilter; import java.io.IOException; import java.util.Map; -import static org.elasticsearch.index.mapper.MapperBuilders.*; -import static org.elasticsearch.index.mapper.core.TypeParsers.*; +import static org.elasticsearch.index.mapper.MapperBuilders.id; +import static org.elasticsearch.index.mapper.core.TypeParsers.parseField; /** - * @author kimchy (shay.banon) + * */ public class IdFieldMapper extends AbstractFieldMapper implements InternalMapper, RootMapper { @@ -85,13 +79,15 @@ public class IdFieldMapper extends AbstractFieldMapper implements Intern return builder; } - @Override public IdFieldMapper build(BuilderContext context) { + @Override + public IdFieldMapper build(BuilderContext context) { return new IdFieldMapper(name, indexName, index, store, termVector, boost, omitNorms, omitTermFreqAndPositions, path); } } public static class TypeParser implements Mapper.TypeParser { - @Override public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { + @Override + public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { IdFieldMapper.Builder builder = id(); parseField(builder, builder.name, node, parserContext); for (Map.Entry entry : node.entrySet()) { @@ -136,27 +132,33 @@ public class IdFieldMapper extends AbstractFieldMapper implements Intern return field == null ? null : value(field); } - @Override public String value(Fieldable field) { + @Override + public String value(Fieldable field) { return field.stringValue(); } - @Override public String valueFromString(String value) { + @Override + public String valueFromString(String value) { return value; } - @Override public String valueAsString(Fieldable field) { + @Override + public String valueAsString(Fieldable field) { return value(field); } - @Override public String indexedValue(String value) { + @Override + public String indexedValue(String value) { return value; } - @Override public boolean useFieldQueryWithQueryString() { + @Override + public boolean useFieldQueryWithQueryString() { return true; } - @Override public Query fieldQuery(String value, @Nullable QueryParseContext context) { + @Override + public Query fieldQuery(String value, @Nullable QueryParseContext context) { if (indexed() || context == null) { return super.fieldQuery(value, context); } @@ -165,39 +167,46 @@ public class IdFieldMapper extends AbstractFieldMapper implements Intern return new ConstantScoreQuery(filter); } - @Override public Filter fieldFilter(String value, @Nullable QueryParseContext context) { + @Override + public Filter fieldFilter(String value, @Nullable QueryParseContext context) { if (indexed() || context == null) { return super.fieldFilter(value, context); } return new UidFilter(context.mapperService().types(), ImmutableList.of(value), context.indexCache().bloomCache()); } - @Override public void preParse(ParseContext context) throws IOException { + @Override + public void preParse(ParseContext context) throws IOException { if (context.sourceToParse().id() != null) { context.id(context.sourceToParse().id()); super.parse(context); } } - @Override public void postParse(ParseContext context) throws IOException { + @Override + public void postParse(ParseContext context) throws IOException { if (context.id() == null && !context.sourceToParse().flyweight()) { throw new MapperParsingException("No id found while parsing the content source"); } // it either get built in the preParse phase, or get parsed... } - @Override public void parse(ParseContext context) throws IOException { + @Override + public void parse(ParseContext context) throws IOException { super.parse(context); } - @Override public void validate(ParseContext context) throws MapperParsingException { + @Override + public void validate(ParseContext context) throws MapperParsingException { } - @Override public boolean includeInObject() { + @Override + public boolean includeInObject() { return true; } - @Override protected Field parseCreateField(ParseContext context) throws IOException { + @Override + protected Field parseCreateField(ParseContext context) throws IOException { XContentParser parser = context.parser(); if (parser.currentName() != null && parser.currentName().equals(Defaults.NAME) && parser.currentToken().isValue()) { // we are in the parse Phase @@ -219,11 +228,13 @@ public class IdFieldMapper extends AbstractFieldMapper implements Intern } } - @Override protected String contentType() { + @Override + protected String contentType() { return CONTENT_TYPE; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { // if all are defaults, no sense to write it at all if (store == Defaults.STORE && index == Defaults.INDEX && path == Defaults.PATH) { return builder; @@ -242,7 +253,8 @@ public class IdFieldMapper extends AbstractFieldMapper implements Intern return builder; } - @Override public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { + @Override + public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { // do nothing here, no merging, but also no exception } } diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/IndexFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/internal/IndexFieldMapper.java index 4cb407d3f9f..84adc02c699 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/IndexFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/IndexFieldMapper.java @@ -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,24 +26,17 @@ import org.apache.lucene.index.Term; import org.elasticsearch.common.Strings; import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.index.mapper.InternalMapper; -import org.elasticsearch.index.mapper.Mapper; -import org.elasticsearch.index.mapper.MapperBuilders; -import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MergeContext; -import org.elasticsearch.index.mapper.MergeMappingException; -import org.elasticsearch.index.mapper.ParseContext; -import org.elasticsearch.index.mapper.RootMapper; +import org.elasticsearch.index.mapper.*; import org.elasticsearch.index.mapper.core.AbstractFieldMapper; import java.io.IOException; import java.util.Map; -import static org.elasticsearch.common.xcontent.support.XContentMapValues.*; -import static org.elasticsearch.index.mapper.core.TypeParsers.*; +import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeBooleanValue; +import static org.elasticsearch.index.mapper.core.TypeParsers.parseField; /** - * @author kimchy (shay.banon) + * */ public class IndexFieldMapper extends AbstractFieldMapper implements InternalMapper, RootMapper { @@ -79,13 +72,15 @@ public class IndexFieldMapper extends AbstractFieldMapper implements Int return this; } - @Override public IndexFieldMapper build(BuilderContext context) { + @Override + public IndexFieldMapper build(BuilderContext context) { return new IndexFieldMapper(name, indexName, store, termVector, boost, omitNorms, omitTermFreqAndPositions, enabled); } } public static class TypeParser implements Mapper.TypeParser { - @Override public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { + @Override + public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { IndexFieldMapper.Builder builder = MapperBuilders.index(); parseField(builder, builder.name, node, parserContext); @@ -127,19 +122,23 @@ public class IndexFieldMapper extends AbstractFieldMapper implements Int return field == null ? null : value(field); } - @Override public String value(Fieldable field) { + @Override + public String value(Fieldable field) { return field.stringValue(); } - @Override public String valueFromString(String value) { + @Override + public String valueFromString(String value) { return value; } - @Override public String valueAsString(Fieldable field) { + @Override + public String valueAsString(Fieldable field) { return value(field); } - @Override public String indexedValue(String value) { + @Override + public String indexedValue(String value) { return value; } @@ -147,37 +146,45 @@ public class IndexFieldMapper extends AbstractFieldMapper implements Int return names().createIndexNameTerm(value); } - @Override public void preParse(ParseContext context) throws IOException { + @Override + public void preParse(ParseContext context) throws IOException { // we pre parse it and not in parse, since its not part of the root object super.parse(context); } - @Override public void postParse(ParseContext context) throws IOException { + @Override + public void postParse(ParseContext context) throws IOException { } - @Override public void parse(ParseContext context) throws IOException { + @Override + public void parse(ParseContext context) throws IOException { } - @Override public void validate(ParseContext context) throws MapperParsingException { + @Override + public void validate(ParseContext context) throws MapperParsingException { } - @Override public boolean includeInObject() { + @Override + public boolean includeInObject() { return false; } - @Override protected Field parseCreateField(ParseContext context) throws IOException { + @Override + protected Field parseCreateField(ParseContext context) throws IOException { if (!enabled) { return null; } return new Field(names.indexName(), context.index(), store, index); } - @Override protected String contentType() { + @Override + protected String contentType() { return CONTENT_TYPE; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { // if all defaults, no need to write it at all if (store == Defaults.STORE && enabled == Defaults.ENABLED) { return builder; @@ -193,7 +200,8 @@ public class IndexFieldMapper extends AbstractFieldMapper implements Int return builder; } - @Override public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { + @Override + public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { // do nothing here, no merging, but also no exception } } diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java index a4be699ff3b..b82576ad577 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java @@ -30,14 +30,7 @@ import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Strings; import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.index.mapper.InternalMapper; -import org.elasticsearch.index.mapper.Mapper; -import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MergeContext; -import org.elasticsearch.index.mapper.MergeMappingException; -import org.elasticsearch.index.mapper.ParseContext; -import org.elasticsearch.index.mapper.RootMapper; -import org.elasticsearch.index.mapper.Uid; +import org.elasticsearch.index.mapper.*; import org.elasticsearch.index.mapper.core.AbstractFieldMapper; import org.elasticsearch.index.query.QueryParseContext; @@ -45,7 +38,7 @@ import java.io.IOException; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class ParentFieldMapper extends AbstractFieldMapper implements InternalMapper, RootMapper { @@ -76,7 +69,8 @@ public class ParentFieldMapper extends AbstractFieldMapper implements Inter return builder; } - @Override public ParentFieldMapper build(BuilderContext context) { + @Override + public ParentFieldMapper build(BuilderContext context) { if (type == null) { throw new MapperParsingException("Parent mapping must contain the parent type"); } @@ -85,7 +79,8 @@ public class ParentFieldMapper extends AbstractFieldMapper implements Inter } public static class TypeParser implements Mapper.TypeParser { - @Override public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { + @Override + public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { ParentFieldMapper.Builder builder = new ParentFieldMapper.Builder(); for (Map.Entry entry : node.entrySet()) { String fieldName = Strings.toUnderscoreCase(entry.getKey()); @@ -110,21 +105,26 @@ public class ParentFieldMapper extends AbstractFieldMapper implements Inter return type; } - @Override public void preParse(ParseContext context) throws IOException { + @Override + public void preParse(ParseContext context) throws IOException { } - @Override public void postParse(ParseContext context) throws IOException { + @Override + public void postParse(ParseContext context) throws IOException { parse(context); } - @Override public void validate(ParseContext context) throws MapperParsingException { + @Override + public void validate(ParseContext context) throws MapperParsingException { } - @Override public boolean includeInObject() { + @Override + public boolean includeInObject() { return true; } - @Override protected Field parseCreateField(ParseContext context) throws IOException { + @Override + protected Field parseCreateField(ParseContext context) throws IOException { if (context.parser().currentName() != null && context.parser().currentName().equals(Defaults.NAME)) { // we are in the parsing of _parent phase String parentId = context.parser().text(); @@ -149,19 +149,23 @@ public class ParentFieldMapper extends AbstractFieldMapper implements Inter return null; } - @Override public Uid value(Fieldable field) { + @Override + public Uid value(Fieldable field) { return Uid.createUid(field.stringValue()); } - @Override public Uid valueFromString(String value) { + @Override + public Uid valueFromString(String value) { return Uid.createUid(value); } - @Override public String valueAsString(Fieldable field) { + @Override + public String valueAsString(Fieldable field) { return field.stringValue(); } - @Override public Object valueForSearch(Fieldable field) { + @Override + public Object valueForSearch(Fieldable field) { String fieldValue = field.stringValue(); if (fieldValue == null) { return null; @@ -173,21 +177,24 @@ public class ParentFieldMapper extends AbstractFieldMapper implements Inter return fieldValue.substring(index + 1); } - @Override public String indexedValue(String value) { + @Override + public String indexedValue(String value) { if (value.indexOf(Uid.DELIMITER) == -1) { return Uid.createUid(type, value); } return value; } - @Override public Query fieldQuery(String value, @Nullable QueryParseContext context) { + @Override + public Query fieldQuery(String value, @Nullable QueryParseContext context) { if (context == null) { return super.fieldQuery(value, context); } return new ConstantScoreQuery(fieldFilter(value, context)); } - @Override public Filter fieldFilter(String value, @Nullable QueryParseContext context) { + @Override + public Filter fieldFilter(String value, @Nullable QueryParseContext context) { if (context == null) { return super.fieldFilter(value, context); } @@ -202,7 +209,8 @@ public class ParentFieldMapper extends AbstractFieldMapper implements Inter /** * We don't need to analyzer the text, and we need to convert it to UID... */ - @Override public boolean useFieldQueryWithQueryString() { + @Override + public boolean useFieldQueryWithQueryString() { return true; } @@ -214,18 +222,21 @@ public class ParentFieldMapper extends AbstractFieldMapper implements Inter return names().createIndexNameTerm(uid); } - @Override protected String contentType() { + @Override + protected String contentType() { return CONTENT_TYPE; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(CONTENT_TYPE); builder.field("type", type); builder.endObject(); return builder; } - @Override public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { + @Override + public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { // do nothing here, no merging, but also no exception } } diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/RoutingFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/internal/RoutingFieldMapper.java index 14b4688d1cb..604953bb228 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/RoutingFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/RoutingFieldMapper.java @@ -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,25 +25,19 @@ import org.apache.lucene.document.Fieldable; import org.elasticsearch.common.Strings; import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.index.mapper.InternalMapper; -import org.elasticsearch.index.mapper.Mapper; -import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MergeContext; -import org.elasticsearch.index.mapper.MergeMappingException; -import org.elasticsearch.index.mapper.ParseContext; -import org.elasticsearch.index.mapper.RootMapper; +import org.elasticsearch.index.mapper.*; import org.elasticsearch.index.mapper.core.AbstractFieldMapper; import org.elasticsearch.index.mapper.core.NumberFieldMapper; import java.io.IOException; import java.util.Map; -import static org.elasticsearch.common.xcontent.support.XContentMapValues.*; -import static org.elasticsearch.index.mapper.MapperBuilders.*; -import static org.elasticsearch.index.mapper.core.TypeParsers.*; +import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeBooleanValue; +import static org.elasticsearch.index.mapper.MapperBuilders.routing; +import static org.elasticsearch.index.mapper.core.TypeParsers.parseField; /** - * @author kimchy (shay.banon) + * */ public class RoutingFieldMapper extends AbstractFieldMapper implements InternalMapper, RootMapper { @@ -82,13 +76,15 @@ public class RoutingFieldMapper extends AbstractFieldMapper implements I return builder; } - @Override public RoutingFieldMapper build(BuilderContext context) { + @Override + public RoutingFieldMapper build(BuilderContext context) { return new RoutingFieldMapper(store, index, required, path); } } public static class TypeParser implements Mapper.TypeParser { - @Override public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { + @Override + public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { RoutingFieldMapper.Builder builder = routing(); parseField(builder, builder.name, node, parserContext); for (Map.Entry entry : node.entrySet()) { @@ -137,23 +133,28 @@ public class RoutingFieldMapper extends AbstractFieldMapper implements I return field == null ? null : value(field); } - @Override public String value(Fieldable field) { + @Override + public String value(Fieldable field) { return field.stringValue(); } - @Override public String valueFromString(String value) { + @Override + public String valueFromString(String value) { return value; } - @Override public String valueAsString(Fieldable field) { + @Override + public String valueAsString(Fieldable field) { return value(field); } - @Override public String indexedValue(String value) { + @Override + public String indexedValue(String value) { return value; } - @Override public void validate(ParseContext context) throws MapperParsingException { + @Override + public void validate(ParseContext context) throws MapperParsingException { String routing = context.sourceToParse().routing(); if (path != null && routing != null) { // we have a path, check if we can validate we have the same routing value as the one in the doc... @@ -177,24 +178,29 @@ public class RoutingFieldMapper extends AbstractFieldMapper implements I } } - @Override public void preParse(ParseContext context) throws IOException { + @Override + public void preParse(ParseContext context) throws IOException { super.parse(context); } - @Override public void postParse(ParseContext context) throws IOException { + @Override + public void postParse(ParseContext context) throws IOException { } - @Override public void parse(ParseContext context) throws IOException { + @Override + public void parse(ParseContext context) throws IOException { // no need ot parse here, we either get the routing in the sourceToParse // or we don't have routing, if we get it in sourceToParse, we process it in preParse // which will always be called } - @Override public boolean includeInObject() { + @Override + public boolean includeInObject() { return true; } - @Override protected Field parseCreateField(ParseContext context) throws IOException { + @Override + protected Field parseCreateField(ParseContext context) throws IOException { if (context.sourceToParse().routing() != null) { String routing = context.sourceToParse().routing(); if (routing != null) { @@ -209,11 +215,13 @@ public class RoutingFieldMapper extends AbstractFieldMapper implements I } - @Override protected String contentType() { + @Override + protected String contentType() { return CONTENT_TYPE; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { // if all are defaults, no sense to write it at all if (index == Defaults.INDEX && store == Defaults.STORE && required == Defaults.REQUIRED && path == Defaults.PATH) { return builder; @@ -235,7 +243,8 @@ public class RoutingFieldMapper extends AbstractFieldMapper implements I return builder; } - @Override public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { + @Override + public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { // do nothing here, no merging, but also no exception } } diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/SizeFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/internal/SizeFieldMapper.java index 4599c521b02..1ff3eabc710 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/SizeFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/SizeFieldMapper.java @@ -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,19 +23,14 @@ import org.apache.lucene.document.Field; import org.apache.lucene.document.Fieldable; import org.elasticsearch.common.Strings; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.index.mapper.Mapper; -import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MergeContext; -import org.elasticsearch.index.mapper.MergeMappingException; -import org.elasticsearch.index.mapper.ParseContext; -import org.elasticsearch.index.mapper.RootMapper; +import org.elasticsearch.index.mapper.*; import org.elasticsearch.index.mapper.core.IntegerFieldMapper; import java.io.IOException; import java.util.Map; -import static org.elasticsearch.common.xcontent.support.XContentMapValues.*; -import static org.elasticsearch.index.mapper.core.TypeParsers.*; +import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeBooleanValue; +import static org.elasticsearch.index.mapper.core.TypeParsers.parseStore; public class SizeFieldMapper extends IntegerFieldMapper implements RootMapper { @@ -68,13 +63,15 @@ public class SizeFieldMapper extends IntegerFieldMapper implements RootMapper { return builder; } - @Override public SizeFieldMapper build(BuilderContext context) { + @Override + public SizeFieldMapper build(BuilderContext context) { return new SizeFieldMapper(enabled, store); } } public static class TypeParser implements Mapper.TypeParser { - @Override public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { + @Override + public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { SizeFieldMapper.Builder builder = new SizeFieldMapper.Builder(); for (Map.Entry entry : node.entrySet()) { String fieldName = Strings.toUnderscoreCase(entry.getKey()); @@ -100,7 +97,8 @@ public class SizeFieldMapper extends IntegerFieldMapper implements RootMapper { this.enabled = enabled; } - @Override protected String contentType() { + @Override + protected String contentType() { return Defaults.NAME; } @@ -108,33 +106,40 @@ public class SizeFieldMapper extends IntegerFieldMapper implements RootMapper { return this.enabled; } - @Override public void validate(ParseContext context) throws MapperParsingException { + @Override + public void validate(ParseContext context) throws MapperParsingException { } - @Override public void preParse(ParseContext context) throws IOException { + @Override + public void preParse(ParseContext context) throws IOException { } - @Override public void postParse(ParseContext context) throws IOException { + @Override + public void postParse(ParseContext context) throws IOException { // we post parse it so we get the size stored, possibly compressed (source will be preParse) super.parse(context); } - @Override public void parse(ParseContext context) throws IOException { + @Override + public void parse(ParseContext context) throws IOException { // nothing to do here, we call the parent in postParse } - @Override public boolean includeInObject() { + @Override + public boolean includeInObject() { return false; } - @Override protected Fieldable parseCreateField(ParseContext context) throws IOException { + @Override + protected Fieldable parseCreateField(ParseContext context) throws IOException { if (!enabled) { return null; } return new CustomIntegerNumericField(this, context.sourceLength()); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { // all are defaults, no need to write it at all if (enabled == Defaults.ENABLED && store == Defaults.STORE) { return builder; @@ -150,7 +155,8 @@ public class SizeFieldMapper extends IntegerFieldMapper implements RootMapper { return builder; } - @Override public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { + @Override + public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { // maybe allow to change enabled? But then we need to figure out null for default value } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/SourceFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/internal/SourceFieldMapper.java index 7ac5f53666b..b5596fc6bdd 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/SourceFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/SourceFieldMapper.java @@ -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,24 +38,18 @@ import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.common.xcontent.support.XContentMapValues; -import org.elasticsearch.index.mapper.InternalMapper; -import org.elasticsearch.index.mapper.Mapper; -import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MergeContext; -import org.elasticsearch.index.mapper.MergeMappingException; -import org.elasticsearch.index.mapper.ParseContext; -import org.elasticsearch.index.mapper.RootMapper; +import org.elasticsearch.index.mapper.*; import org.elasticsearch.index.mapper.core.AbstractFieldMapper; import java.io.IOException; import java.util.List; import java.util.Map; -import static org.elasticsearch.common.xcontent.support.XContentMapValues.*; -import static org.elasticsearch.index.mapper.MapperBuilders.*; +import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeBooleanValue; +import static org.elasticsearch.index.mapper.MapperBuilders.source; /** - * @author kimchy (shay.banon) + * */ public class SourceFieldMapper extends AbstractFieldMapper implements InternalMapper, RootMapper { @@ -115,13 +109,15 @@ public class SourceFieldMapper extends AbstractFieldMapper implements In return this; } - @Override public SourceFieldMapper build(BuilderContext context) { + @Override + public SourceFieldMapper build(BuilderContext context) { return new SourceFieldMapper(name, enabled, compress, compressThreshold, includes, excludes); } } public static class TypeParser implements Mapper.TypeParser { - @Override public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { + @Override + public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { SourceFieldMapper.Builder builder = source(); for (Map.Entry entry : node.entrySet()) { @@ -192,25 +188,31 @@ public class SourceFieldMapper extends AbstractFieldMapper implements In return SourceFieldSelector.INSTANCE; } - @Override public void preParse(ParseContext context) throws IOException { + @Override + public void preParse(ParseContext context) throws IOException { super.parse(context); } - @Override public void postParse(ParseContext context) throws IOException { + @Override + public void postParse(ParseContext context) throws IOException { } - @Override public void parse(ParseContext context) throws IOException { + @Override + public void parse(ParseContext context) throws IOException { // nothing to do here, we will call it in pre parse } - @Override public void validate(ParseContext context) throws MapperParsingException { + @Override + public void validate(ParseContext context) throws MapperParsingException { } - @Override public boolean includeInObject() { + @Override + public boolean includeInObject() { return false; } - @Override protected Field parseCreateField(ParseContext context) throws IOException { + @Override + protected Field parseCreateField(ParseContext context) throws IOException { if (!enabled) { return null; } @@ -273,7 +275,8 @@ public class SourceFieldMapper extends AbstractFieldMapper implements In return field.getBinaryValue(); } - @Override public byte[] value(Fieldable field) { + @Override + public byte[] value(Fieldable field) { byte[] value = field.getBinaryValue(); if (value == null) { return value; @@ -288,23 +291,28 @@ public class SourceFieldMapper extends AbstractFieldMapper implements In return value; } - @Override public byte[] valueFromString(String value) { + @Override + public byte[] valueFromString(String value) { return null; } - @Override public String valueAsString(Fieldable field) { + @Override + public String valueAsString(Fieldable field) { throw new UnsupportedOperationException(); } - @Override public String indexedValue(String value) { + @Override + public String indexedValue(String value) { return value; } - @Override protected String contentType() { + @Override + protected String contentType() { return CONTENT_TYPE; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { // all are defaults, no need to write it at all if (enabled == Defaults.ENABLED && compress == null && compressThreshold == -1 && includes.length == 0 && excludes.length == 0) { return builder; @@ -329,7 +337,8 @@ public class SourceFieldMapper extends AbstractFieldMapper implements In return builder; } - @Override public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { + @Override + public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { SourceFieldMapper sourceMergeWith = (SourceFieldMapper) mergeWith; if (!mergeContext.mergeFlags().simulate()) { if (sourceMergeWith.compress != null) { diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/SourceFieldSelector.java b/src/main/java/org/elasticsearch/index/mapper/internal/SourceFieldSelector.java index dbbba2c3cbc..aae7548b32b 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/SourceFieldSelector.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/SourceFieldSelector.java @@ -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.common.lucene.document.ResetFieldSelector; /** * An optimized field selector that loads just the uid. * - * @author kimchy (shay.banon) + * */ public class SourceFieldSelector implements ResetFieldSelector { @@ -35,13 +35,15 @@ public class SourceFieldSelector implements ResetFieldSelector { } - @Override public FieldSelectorResult accept(String fieldName) { + @Override + public FieldSelectorResult accept(String fieldName) { if (SourceFieldMapper.NAME.equals(fieldName)) { return FieldSelectorResult.LOAD_AND_BREAK; } return FieldSelectorResult.NO_LOAD; } - @Override public void reset() { + @Override + public void reset() { } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/TTLFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/internal/TTLFieldMapper.java index ed9955dabc2..aa179f1da2f 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/TTLFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/TTLFieldMapper.java @@ -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,7 @@ import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.AlreadyExpiredException; -import org.elasticsearch.index.mapper.InternalMapper; -import org.elasticsearch.index.mapper.Mapper; -import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MergeContext; -import org.elasticsearch.index.mapper.MergeMappingException; -import org.elasticsearch.index.mapper.ParseContext; -import org.elasticsearch.index.mapper.RootMapper; +import org.elasticsearch.index.mapper.*; import org.elasticsearch.index.mapper.core.LongFieldMapper; import org.elasticsearch.index.mapper.core.NumberFieldMapper; import org.elasticsearch.search.internal.SearchContext; @@ -41,8 +35,9 @@ import java.io.IOException; import java.util.Date; import java.util.Map; -import static org.elasticsearch.common.xcontent.support.XContentMapValues.*; -import static org.elasticsearch.index.mapper.core.TypeParsers.*; +import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeBooleanValue; +import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeTimeValue; +import static org.elasticsearch.index.mapper.core.TypeParsers.parseField; public class TTLFieldMapper extends LongFieldMapper implements InternalMapper, RootMapper { @@ -78,13 +73,15 @@ public class TTLFieldMapper extends LongFieldMapper implements InternalMapper, R return builder; } - @Override public TTLFieldMapper build(BuilderContext context) { + @Override + public TTLFieldMapper build(BuilderContext context) { return new TTLFieldMapper(store, index, enabled, defaultTTL); } } public static class TypeParser implements Mapper.TypeParser { - @Override public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { + @Override + public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { TTLFieldMapper.Builder builder = new TTLFieldMapper.Builder(); parseField(builder, builder.name, node, parserContext); for (Map.Entry entry : node.entrySet()) { @@ -127,7 +124,8 @@ public class TTLFieldMapper extends LongFieldMapper implements InternalMapper, R } // Overrides valueForSearch to display live value of remaining ttl - @Override public Object valueForSearch(Fieldable field) { + @Override + public Object valueForSearch(Fieldable field) { long now; SearchContext searchContext = SearchContext.current(); if (searchContext != null) { @@ -144,17 +142,21 @@ public class TTLFieldMapper extends LongFieldMapper implements InternalMapper, R return expirationTime - System.currentTimeMillis(); } - @Override public void validate(ParseContext context) throws MapperParsingException { + @Override + public void validate(ParseContext context) throws MapperParsingException { } - @Override public void preParse(ParseContext context) throws IOException { + @Override + public void preParse(ParseContext context) throws IOException { } - @Override public void postParse(ParseContext context) throws IOException { + @Override + public void postParse(ParseContext context) throws IOException { super.parse(context); } - @Override public void parse(ParseContext context) throws IOException, MapperParsingException { + @Override + public void parse(ParseContext context) throws IOException, MapperParsingException { if (context.sourceToParse().ttl() < 0) { // no ttl has been provided externally long ttl; if (context.parser().currentToken() == XContentParser.Token.VALUE_STRING) { @@ -169,11 +171,13 @@ public class TTLFieldMapper extends LongFieldMapper implements InternalMapper, R } } - @Override public boolean includeInObject() { + @Override + public boolean includeInObject() { return true; } - @Override protected Fieldable parseCreateField(ParseContext context) throws IOException, AlreadyExpiredException { + @Override + protected Fieldable parseCreateField(ParseContext context) throws IOException, AlreadyExpiredException { if (enabled) { long ttl = context.sourceToParse().ttl(); if (ttl <= 0 && defaultTTL > 0) { // no ttl provided so we use the default value @@ -194,7 +198,8 @@ public class TTLFieldMapper extends LongFieldMapper implements InternalMapper, R return null; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { // if all are defaults, no sense to write it at all if (enabled == Defaults.ENABLED && defaultTTL == Defaults.DEFAULT) { return builder; @@ -210,7 +215,8 @@ public class TTLFieldMapper extends LongFieldMapper implements InternalMapper, R return builder; } - @Override public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { + @Override + public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { // do nothing here, no merging, but also no exception } } diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/TimestampFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/internal/TimestampFieldMapper.java index 4b537865453..033c5670a87 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/TimestampFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/TimestampFieldMapper.java @@ -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,13 +25,7 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.joda.FormatDateTimeFormatter; import org.elasticsearch.common.joda.Joda; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.index.mapper.InternalMapper; -import org.elasticsearch.index.mapper.Mapper; -import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MergeContext; -import org.elasticsearch.index.mapper.MergeMappingException; -import org.elasticsearch.index.mapper.ParseContext; -import org.elasticsearch.index.mapper.RootMapper; +import org.elasticsearch.index.mapper.*; import org.elasticsearch.index.mapper.core.DateFieldMapper; import org.elasticsearch.index.mapper.core.LongFieldMapper; import org.elasticsearch.index.mapper.core.NumberFieldMapper; @@ -40,12 +34,12 @@ import java.io.IOException; import java.util.Map; import java.util.concurrent.TimeUnit; -import static org.elasticsearch.common.xcontent.support.XContentMapValues.*; -import static org.elasticsearch.index.mapper.MapperBuilders.*; -import static org.elasticsearch.index.mapper.core.TypeParsers.*; +import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeBooleanValue; +import static org.elasticsearch.index.mapper.MapperBuilders.timestamp; +import static org.elasticsearch.index.mapper.core.TypeParsers.parseDateTimeFormatter; +import static org.elasticsearch.index.mapper.core.TypeParsers.parseField; /** - * @author paikan (benjamin.deveze) */ public class TimestampFieldMapper extends DateFieldMapper implements InternalMapper, RootMapper { @@ -89,7 +83,8 @@ public class TimestampFieldMapper extends DateFieldMapper implements InternalMap return builder; } - @Override public TimestampFieldMapper build(BuilderContext context) { + @Override + public TimestampFieldMapper build(BuilderContext context) { boolean parseUpperInclusive = Defaults.PARSE_UPPER_INCLUSIVE; if (context.indexSettings() != null) { parseUpperInclusive = context.indexSettings().getAsBoolean("index.mapping.date.parse_upper_inclusive", Defaults.PARSE_UPPER_INCLUSIVE); @@ -99,7 +94,8 @@ public class TimestampFieldMapper extends DateFieldMapper implements InternalMap } public static class TypeParser implements Mapper.TypeParser { - @Override public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { + @Override + public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { TimestampFieldMapper.Builder builder = timestamp(); parseField(builder, builder.name, node, parserContext); for (Map.Entry entry : node.entrySet()) { @@ -149,11 +145,13 @@ public class TimestampFieldMapper extends DateFieldMapper implements InternalMap /** * Override the default behavior to return a timestamp */ - @Override public Object valueForSearch(Fieldable field) { + @Override + public Object valueForSearch(Fieldable field) { return value(field); } - @Override public String valueAsString(Fieldable field) { + @Override + public String valueAsString(Fieldable field) { Long value = value(field); if (value == null) { return null; @@ -161,25 +159,31 @@ public class TimestampFieldMapper extends DateFieldMapper implements InternalMap return value.toString(); } - @Override public void validate(ParseContext context) throws MapperParsingException { + @Override + public void validate(ParseContext context) throws MapperParsingException { } - @Override public void preParse(ParseContext context) throws IOException { + @Override + public void preParse(ParseContext context) throws IOException { super.parse(context); } - @Override public void postParse(ParseContext context) throws IOException { + @Override + public void postParse(ParseContext context) throws IOException { } - @Override public void parse(ParseContext context) throws IOException { + @Override + public void parse(ParseContext context) throws IOException { // nothing to do here, we call the parent in preParse } - @Override public boolean includeInObject() { + @Override + public boolean includeInObject() { return true; } - @Override protected Fieldable parseCreateField(ParseContext context) throws IOException { + @Override + protected Fieldable parseCreateField(ParseContext context) throws IOException { if (enabled) { long timestamp = context.sourceToParse().timestamp(); if (!indexed() && !stored()) { @@ -191,11 +195,13 @@ public class TimestampFieldMapper extends DateFieldMapper implements InternalMap return null; } - @Override protected String contentType() { + @Override + protected String contentType() { return CONTENT_TYPE; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { // if all are defaults, no sense to write it at all if (index == Defaults.INDEX && store == Defaults.STORE && enabled == Defaults.ENABLED && path == Defaults.PATH && dateTimeFormatter.format().equals(Defaults.DATE_TIME_FORMATTER.format())) { @@ -221,7 +227,8 @@ public class TimestampFieldMapper extends DateFieldMapper implements InternalMap return builder; } - @Override public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { + @Override + public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { // do nothing here, no merging, but also no exception } } diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/TypeFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/internal/TypeFieldMapper.java index 66f94005aaf..f75eaa8c4ee 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/TypeFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/TypeFieldMapper.java @@ -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,25 +31,18 @@ import org.elasticsearch.common.Nullable; import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.common.lucene.search.TermFilter; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.index.mapper.InternalMapper; -import org.elasticsearch.index.mapper.Mapper; -import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MergeContext; -import org.elasticsearch.index.mapper.MergeMappingException; -import org.elasticsearch.index.mapper.ParseContext; -import org.elasticsearch.index.mapper.RootMapper; -import org.elasticsearch.index.mapper.Uid; +import org.elasticsearch.index.mapper.*; import org.elasticsearch.index.mapper.core.AbstractFieldMapper; import org.elasticsearch.index.query.QueryParseContext; import java.io.IOException; import java.util.Map; -import static org.elasticsearch.index.mapper.MapperBuilders.*; -import static org.elasticsearch.index.mapper.core.TypeParsers.*; +import static org.elasticsearch.index.mapper.MapperBuilders.type; +import static org.elasticsearch.index.mapper.core.TypeParsers.parseField; /** - * @author kimchy (shay.banon) + * */ public class TypeFieldMapper extends AbstractFieldMapper implements InternalMapper, RootMapper { @@ -79,13 +72,15 @@ public class TypeFieldMapper extends AbstractFieldMapper implements Inte omitTermFreqAndPositions = Defaults.OMIT_TERM_FREQ_AND_POSITIONS; } - @Override public TypeFieldMapper build(BuilderContext context) { + @Override + public TypeFieldMapper build(BuilderContext context) { return new TypeFieldMapper(name, indexName, index, store, termVector, boost, omitNorms, omitTermFreqAndPositions); } } public static class TypeParser implements Mapper.TypeParser { - @Override public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { + @Override + public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { TypeFieldMapper.Builder builder = type(); parseField(builder, builder.name, node, parserContext); return builder; @@ -113,19 +108,23 @@ public class TypeFieldMapper extends AbstractFieldMapper implements Inte return field == null ? null : value(field); } - @Override public String value(Fieldable field) { + @Override + public String value(Fieldable field) { return field.stringValue(); } - @Override public String valueFromString(String value) { + @Override + public String valueFromString(String value) { return value; } - @Override public String valueAsString(Fieldable field) { + @Override + public String valueAsString(Fieldable field) { return value(field); } - @Override public String indexedValue(String value) { + @Override + public String indexedValue(String value) { return value; } @@ -133,51 +132,62 @@ public class TypeFieldMapper extends AbstractFieldMapper implements Inte return names().createIndexNameTerm(value); } - @Override public Filter fieldFilter(String value, @Nullable QueryParseContext context) { + @Override + public Filter fieldFilter(String value, @Nullable QueryParseContext context) { if (index == Field.Index.NO) { return new PrefixFilter(UidFieldMapper.TERM_FACTORY.createTerm(Uid.typePrefix(value))); } return new TermFilter(names().createIndexNameTerm(value)); } - @Override public Query fieldQuery(String value, @Nullable QueryParseContext context) { + @Override + public Query fieldQuery(String value, @Nullable QueryParseContext context) { return new DeletionAwareConstantScoreQuery(context.cacheFilter(fieldFilter(value, context), null)); } - @Override public boolean useFieldQueryWithQueryString() { + @Override + public boolean useFieldQueryWithQueryString() { return true; } - @Override public void preParse(ParseContext context) throws IOException { + @Override + public void preParse(ParseContext context) throws IOException { super.parse(context); } - @Override public void postParse(ParseContext context) throws IOException { + @Override + public void postParse(ParseContext context) throws IOException { } - @Override public void parse(ParseContext context) throws IOException { + @Override + public void parse(ParseContext context) throws IOException { // we parse in pre parse } - @Override public void validate(ParseContext context) throws MapperParsingException { + @Override + public void validate(ParseContext context) throws MapperParsingException { } - @Override public boolean includeInObject() { + @Override + public boolean includeInObject() { return false; } - @Override protected Field parseCreateField(ParseContext context) throws IOException { + @Override + protected Field parseCreateField(ParseContext context) throws IOException { if (index == Field.Index.NO && store == Field.Store.NO) { return null; } return new Field(names.indexName(), false, context.type(), store, index, termVector); } - @Override protected String contentType() { + @Override + protected String contentType() { return CONTENT_TYPE; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { // if all are defaults, no sense to write it at all if (store == Defaults.STORE && index == Defaults.INDEX) { return builder; @@ -193,7 +203,8 @@ public class TypeFieldMapper extends AbstractFieldMapper implements Inte return builder; } - @Override public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { + @Override + public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { // do nothing here, no merging, but also no exception } } diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/UidFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/internal/UidFieldMapper.java index 48e199299ce..232374563e4 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/UidFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/UidFieldMapper.java @@ -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,23 +25,16 @@ import org.apache.lucene.index.Term; import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.common.lucene.uid.UidField; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.index.mapper.InternalMapper; -import org.elasticsearch.index.mapper.Mapper; -import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MergeContext; -import org.elasticsearch.index.mapper.MergeMappingException; -import org.elasticsearch.index.mapper.ParseContext; -import org.elasticsearch.index.mapper.RootMapper; -import org.elasticsearch.index.mapper.Uid; +import org.elasticsearch.index.mapper.*; import org.elasticsearch.index.mapper.core.AbstractFieldMapper; import java.io.IOException; import java.util.Map; -import static org.elasticsearch.index.mapper.MapperBuilders.*; +import static org.elasticsearch.index.mapper.MapperBuilders.uid; /** - * @author kimchy (shay.banon) + * */ public class UidFieldMapper extends AbstractFieldMapper implements InternalMapper, RootMapper { @@ -67,19 +60,22 @@ public class UidFieldMapper extends AbstractFieldMapper implements Internal this.indexName = name; } - @Override public UidFieldMapper build(BuilderContext context) { + @Override + public UidFieldMapper build(BuilderContext context) { return new UidFieldMapper(name, indexName); } } public static class TypeParser implements Mapper.TypeParser { - @Override public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { + @Override + public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { return uid(); } } private ThreadLocal fieldCache = new ThreadLocal() { - @Override protected UidField initialValue() { + @Override + protected UidField initialValue() { return new UidField(names().indexName(), "", 0); } }; @@ -97,7 +93,8 @@ public class UidFieldMapper extends AbstractFieldMapper implements Internal Defaults.OMIT_NORMS, Defaults.OMIT_TERM_FREQ_AND_POSITIONS, Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER); } - @Override public void preParse(ParseContext context) throws IOException { + @Override + public void preParse(ParseContext context) throws IOException { // if we have the id provided, fill it, and parse now if (context.sourceToParse().id() != null) { context.id(context.sourceToParse().id()); @@ -105,7 +102,8 @@ public class UidFieldMapper extends AbstractFieldMapper implements Internal } } - @Override public void postParse(ParseContext context) throws IOException { + @Override + public void postParse(ParseContext context) throws IOException { if (context.id() == null && !context.sourceToParse().flyweight()) { throw new MapperParsingException("No id found while parsing the content source"); } @@ -127,18 +125,22 @@ public class UidFieldMapper extends AbstractFieldMapper implements Internal } } - @Override public void parse(ParseContext context) throws IOException { + @Override + public void parse(ParseContext context) throws IOException { // nothing to do here, we either do it in post parse, or in pre parse. } - @Override public void validate(ParseContext context) throws MapperParsingException { + @Override + public void validate(ParseContext context) throws MapperParsingException { } - @Override public boolean includeInObject() { + @Override + public boolean includeInObject() { return false; } - @Override protected Fieldable parseCreateField(ParseContext context) throws IOException { + @Override + protected Fieldable parseCreateField(ParseContext context) throws IOException { context.uid(Uid.createUid(context.stringBuilder(), context.type(), context.id())); // so, caching uid stream and field is fine // since we don't do any mapping parsing without immediate indexing @@ -148,19 +150,23 @@ public class UidFieldMapper extends AbstractFieldMapper implements Internal return field; // version get updated by the engine } - @Override public Uid value(Fieldable field) { + @Override + public Uid value(Fieldable field) { return Uid.createUid(field.stringValue()); } - @Override public Uid valueFromString(String value) { + @Override + public Uid valueFromString(String value) { return Uid.createUid(value); } - @Override public String valueAsString(Fieldable field) { + @Override + public String valueAsString(Fieldable field) { return field.stringValue(); } - @Override public String indexedValue(String value) { + @Override + public String indexedValue(String value) { return value; } @@ -172,20 +178,24 @@ public class UidFieldMapper extends AbstractFieldMapper implements Internal return names().createIndexNameTerm(uid); } - @Override public void close() { + @Override + public void close() { fieldCache.remove(); } - @Override protected String contentType() { + @Override + protected String contentType() { return CONTENT_TYPE; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { // for now, don't output it at all return builder; } - @Override public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { + @Override + public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { // do nothing here, no merging, but also no exception } } diff --git a/src/main/java/org/elasticsearch/index/mapper/ip/IpFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/ip/IpFieldMapper.java index be24774e7c5..1ebd4fa2862 100644 --- a/src/main/java/org/elasticsearch/index/mapper/ip/IpFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/ip/IpFieldMapper.java @@ -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,11 +22,7 @@ package org.elasticsearch.index.mapper.ip; import org.apache.lucene.analysis.NumericTokenStream; import org.apache.lucene.document.Field; import org.apache.lucene.document.Fieldable; -import org.apache.lucene.search.Filter; -import org.apache.lucene.search.FuzzyQuery; -import org.apache.lucene.search.NumericRangeFilter; -import org.apache.lucene.search.NumericRangeQuery; -import org.apache.lucene.search.Query; +import org.apache.lucene.search.*; import org.apache.lucene.util.NumericUtils; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.Numbers; @@ -38,11 +34,7 @@ import org.elasticsearch.index.analysis.NumericAnalyzer; import org.elasticsearch.index.analysis.NumericTokenizer; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldDataType; -import org.elasticsearch.index.mapper.Mapper; -import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MergeContext; -import org.elasticsearch.index.mapper.MergeMappingException; -import org.elasticsearch.index.mapper.ParseContext; +import org.elasticsearch.index.mapper.*; import org.elasticsearch.index.mapper.core.LongFieldMapper; import org.elasticsearch.index.mapper.core.NumberFieldMapper; import org.elasticsearch.index.search.NumericRangeFieldDataFilter; @@ -52,11 +44,11 @@ import java.io.Reader; import java.util.Map; import java.util.regex.Pattern; -import static org.elasticsearch.index.mapper.MapperBuilders.*; -import static org.elasticsearch.index.mapper.core.TypeParsers.*; +import static org.elasticsearch.index.mapper.MapperBuilders.ipField; +import static org.elasticsearch.index.mapper.core.TypeParsers.parseNumberField; /** - * @author kimchy (shay.banon) + * */ public class IpFieldMapper extends NumberFieldMapper { @@ -106,7 +98,8 @@ public class IpFieldMapper extends NumberFieldMapper { return this; } - @Override public IpFieldMapper build(BuilderContext context) { + @Override + public IpFieldMapper build(BuilderContext context) { IpFieldMapper fieldMapper = new IpFieldMapper(buildNames(context), precisionStep, index, store, boost, omitNorms, omitTermFreqAndPositions, nullValue); fieldMapper.includeInAll(includeInAll); @@ -115,7 +108,8 @@ public class IpFieldMapper extends NumberFieldMapper { } public static class TypeParser implements Mapper.TypeParser { - @Override public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { + @Override + public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { IpFieldMapper.Builder builder = ipField(name); parseNumberField(builder, name, node, parserContext); for (Map.Entry entry : node.entrySet()) { @@ -141,11 +135,13 @@ public class IpFieldMapper extends NumberFieldMapper { this.nullValue = nullValue; } - @Override protected int maxPrecisionStep() { + @Override + protected int maxPrecisionStep() { return 64; } - @Override public Long value(Fieldable field) { + @Override + public Long value(Fieldable field) { byte[] value = field.getBinaryValue(); if (value == null) { return null; @@ -153,18 +149,21 @@ public class IpFieldMapper extends NumberFieldMapper { return Numbers.bytesToLong(value); } - @Override public Long valueFromString(String value) { + @Override + public Long valueFromString(String value) { return ipToLong(value); } /** * IPs should return as a string, delegates to {@link #valueAsString(org.apache.lucene.document.Fieldable)}. */ - @Override public Object valueForSearch(Fieldable field) { + @Override + public Object valueForSearch(Fieldable field) { return valueAsString(field); } - @Override public String valueAsString(Fieldable field) { + @Override + public String valueAsString(Fieldable field) { Long value = value(field); if (value == null) { return null; @@ -172,11 +171,13 @@ public class IpFieldMapper extends NumberFieldMapper { return longToIp(value); } - @Override public String indexedValue(String value) { + @Override + public String indexedValue(String value) { return NumericUtils.longToPrefixCoded(ipToLong(value)); } - @Override public Query fuzzyQuery(String value, String minSim, int prefixLength, int maxExpansions) { + @Override + public Query fuzzyQuery(String value, String minSim, int prefixLength, int maxExpansions) { long iValue = ipToLong(value); long iSim; try { @@ -194,32 +195,37 @@ public class IpFieldMapper extends NumberFieldMapper { true, true); } - @Override public Query fuzzyQuery(String value, double minSim, int prefixLength, int maxExpansions) { + @Override + public Query fuzzyQuery(String value, double minSim, int prefixLength, int maxExpansions) { return new FuzzyQuery(names().createIndexNameTerm(value), (float) minSim, prefixLength, maxExpansions); } - @Override public Query rangeQuery(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { + @Override + public Query rangeQuery(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { return NumericRangeQuery.newLongRange(names.indexName(), precisionStep, lowerTerm == null ? null : ipToLong(lowerTerm), upperTerm == null ? null : ipToLong(upperTerm), includeLower, includeUpper); } - @Override public Filter rangeFilter(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { + @Override + public Filter rangeFilter(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { return NumericRangeFilter.newLongRange(names.indexName(), precisionStep, lowerTerm == null ? null : ipToLong(lowerTerm), upperTerm == null ? null : ipToLong(upperTerm), includeLower, includeUpper); } - @Override public Filter rangeFilter(FieldDataCache fieldDataCache, String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { + @Override + public Filter rangeFilter(FieldDataCache fieldDataCache, String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper) { return NumericRangeFieldDataFilter.newLongRange(fieldDataCache, names.indexName(), lowerTerm == null ? null : ipToLong(lowerTerm), upperTerm == null ? null : ipToLong(upperTerm), includeLower, includeUpper); } - @Override protected Fieldable parseCreateField(ParseContext context) throws IOException { + @Override + protected Fieldable parseCreateField(ParseContext context) throws IOException { String ipAsString; if (context.externalValueSet()) { ipAsString = (String) context.externalValue(); @@ -245,15 +251,18 @@ public class IpFieldMapper extends NumberFieldMapper { return new LongFieldMapper.CustomLongNumericField(this, value); } - @Override public FieldDataType fieldDataType() { + @Override + public FieldDataType fieldDataType() { return FieldDataType.DefaultTypes.LONG; } - @Override protected String contentType() { + @Override + protected String contentType() { return CONTENT_TYPE; } - @Override public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { + @Override + public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { super.merge(mergeWith, mergeContext); if (!this.getClass().equals(mergeWith.getClass())) { return; @@ -263,7 +272,8 @@ public class IpFieldMapper extends NumberFieldMapper { } } - @Override protected void doXContentBody(XContentBuilder builder) throws IOException { + @Override + protected void doXContentBody(XContentBuilder builder) throws IOException { super.doXContentBody(builder); if (index != Defaults.INDEX) { builder.field("index", index.name().toLowerCase()); @@ -303,7 +313,8 @@ public class IpFieldMapper extends NumberFieldMapper { this.precisionStep = precisionStep; } - @Override protected NumericIpTokenizer createNumericTokenizer(Reader reader, char[] buffer) throws IOException { + @Override + protected NumericIpTokenizer createNumericTokenizer(Reader reader, char[] buffer) throws IOException { return new NumericIpTokenizer(reader, precisionStep, buffer); } } @@ -318,7 +329,8 @@ public class IpFieldMapper extends NumberFieldMapper { super(reader, new NumericTokenStream(precisionStep), buffer, null); } - @Override protected void setValue(NumericTokenStream tokenStream, String value) { + @Override + protected void setValue(NumericTokenStream tokenStream, String value) { tokenStream.setLongValue(ipToLong(value)); } } diff --git a/src/main/java/org/elasticsearch/index/mapper/multifield/MultiFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/multifield/MultiFieldMapper.java index 0c5f5327d1a..e7159aacde9 100644 --- a/src/main/java/org/elasticsearch/index/mapper/multifield/MultiFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/multifield/MultiFieldMapper.java @@ -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,35 +19,23 @@ package org.elasticsearch.index.mapper.multifield; +import com.google.common.collect.ImmutableMap; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.index.mapper.ContentPath; -import org.elasticsearch.index.mapper.FieldMapper; -import org.elasticsearch.index.mapper.FieldMapperListener; -import org.elasticsearch.index.mapper.Mapper; -import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MergeContext; -import org.elasticsearch.index.mapper.MergeMappingException; -import org.elasticsearch.index.mapper.ObjectMapperListener; -import org.elasticsearch.index.mapper.ParseContext; +import org.elasticsearch.index.mapper.*; import org.elasticsearch.index.mapper.core.AbstractFieldMapper; import org.elasticsearch.index.mapper.internal.AllFieldMapper; import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; +import java.util.*; -import static org.elasticsearch.common.collect.Lists.*; -import static org.elasticsearch.common.collect.MapBuilder.*; -import static org.elasticsearch.index.mapper.MapperBuilders.*; -import static org.elasticsearch.index.mapper.core.TypeParsers.*; +import static com.google.common.collect.Lists.newArrayList; +import static org.elasticsearch.common.collect.MapBuilder.newMapBuilder; +import static org.elasticsearch.index.mapper.MapperBuilders.multiField; +import static org.elasticsearch.index.mapper.core.TypeParsers.parsePathType; /** - * @author kimchy (shay.banon) + * */ public class MultiFieldMapper implements Mapper, AllFieldMapper.IncludeInAll { @@ -84,7 +72,8 @@ public class MultiFieldMapper implements Mapper, AllFieldMapper.IncludeInAll { return this; } - @Override public MultiFieldMapper build(BuilderContext context) { + @Override + public MultiFieldMapper build(BuilderContext context) { ContentPath.Type origPathType = context.path().pathType(); context.path().pathType(pathType); @@ -108,7 +97,8 @@ public class MultiFieldMapper implements Mapper, AllFieldMapper.IncludeInAll { } public static class TypeParser implements Mapper.TypeParser { - @Override public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { + @Override + public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { MultiFieldMapper.Builder builder = multiField(name); for (Map.Entry entry : node.entrySet()) { @@ -170,17 +160,20 @@ public class MultiFieldMapper implements Mapper, AllFieldMapper.IncludeInAll { } } - @Override public String name() { + @Override + public String name() { return this.name; } - @Override public void includeInAll(Boolean includeInAll) { + @Override + public void includeInAll(Boolean includeInAll) { if (includeInAll != null && defaultMapper != null && (defaultMapper instanceof AllFieldMapper.IncludeInAll)) { ((AllFieldMapper.IncludeInAll) defaultMapper).includeInAll(includeInAll); } } - @Override public void includeInAllIfNotSet(Boolean includeInAll) { + @Override + public void includeInAllIfNotSet(Boolean includeInAll) { if (includeInAll != null && defaultMapper != null && (defaultMapper instanceof AllFieldMapper.IncludeInAll)) { ((AllFieldMapper.IncludeInAll) defaultMapper).includeInAllIfNotSet(includeInAll); } @@ -198,7 +191,8 @@ public class MultiFieldMapper implements Mapper, AllFieldMapper.IncludeInAll { return this.mappers; } - @Override public void parse(ParseContext context) throws IOException { + @Override + public void parse(ParseContext context) throws IOException { ContentPath.Type origPathType = context.path().pathType(); context.path().pathType(pathType); @@ -216,7 +210,8 @@ public class MultiFieldMapper implements Mapper, AllFieldMapper.IncludeInAll { context.path().pathType(origPathType); } - @Override public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { + @Override + public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { if (!(mergeWith instanceof MultiFieldMapper) && !(mergeWith instanceof AbstractFieldMapper)) { mergeContext.addConflict("Can't merge a non multi_field / non simple mapping [" + mergeWith.name() + "] with a multi_field mapping [" + name() + "]"); return; @@ -274,7 +269,8 @@ public class MultiFieldMapper implements Mapper, AllFieldMapper.IncludeInAll { } } - @Override public void close() { + @Override + public void close() { if (defaultMapper != null) { defaultMapper.close(); } @@ -283,7 +279,8 @@ public class MultiFieldMapper implements Mapper, AllFieldMapper.IncludeInAll { } } - @Override public void traverse(FieldMapperListener fieldMapperListener) { + @Override + public void traverse(FieldMapperListener fieldMapperListener) { if (defaultMapper != null) { defaultMapper.traverse(fieldMapperListener); } @@ -292,10 +289,12 @@ public class MultiFieldMapper implements Mapper, AllFieldMapper.IncludeInAll { } } - @Override public void traverse(ObjectMapperListener objectMapperListener) { + @Override + public void traverse(ObjectMapperListener objectMapperListener) { } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(name); builder.field("type", CONTENT_TYPE); if (pathType != Defaults.PATH_TYPE) { diff --git a/src/main/java/org/elasticsearch/index/mapper/object/ArrayValueMapperParser.java b/src/main/java/org/elasticsearch/index/mapper/object/ArrayValueMapperParser.java index 84ffd89701f..fbd904f2a3c 100644 --- a/src/main/java/org/elasticsearch/index/mapper/object/ArrayValueMapperParser.java +++ b/src/main/java/org/elasticsearch/index/mapper/object/ArrayValueMapperParser.java @@ -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 @@ package org.elasticsearch.index.mapper.object; * A marker interface indicating that this mapper can handle array value, and the array * itself should be passed to it. * - * @author kimchy (shay.banon) + * */ public interface ArrayValueMapperParser { } diff --git a/src/main/java/org/elasticsearch/index/mapper/object/DynamicTemplate.java b/src/main/java/org/elasticsearch/index/mapper/object/DynamicTemplate.java index 127018e3efb..87c72235b77 100644 --- a/src/main/java/org/elasticsearch/index/mapper/object/DynamicTemplate.java +++ b/src/main/java/org/elasticsearch/index/mapper/object/DynamicTemplate.java @@ -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.index.mapper.object; +import com.google.common.collect.Maps; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.collect.Maps; import org.elasticsearch.common.regex.Regex; import org.elasticsearch.index.mapper.ContentPath; import org.elasticsearch.index.mapper.MapperParsingException; @@ -32,7 +32,7 @@ import java.util.Map; import java.util.TreeMap; /** - * @author kimchy (shay.banon) + * */ public class DynamicTemplate { diff --git a/src/main/java/org/elasticsearch/index/mapper/object/ObjectMapper.java b/src/main/java/org/elasticsearch/index/mapper/object/ObjectMapper.java index a5d5b08299e..5ffe5fad3c8 100644 --- a/src/main/java/org/elasticsearch/index/mapper/object/ObjectMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/object/ObjectMapper.java @@ -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.index.mapper.object; +import com.google.common.collect.ImmutableMap; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.document.Fieldable; import org.apache.lucene.search.Filter; import org.elasticsearch.ElasticSearchIllegalStateException; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.joda.FormatDateTimeFormatter; import org.elasticsearch.common.lucene.search.TermFilter; import org.elasticsearch.common.lucene.uid.UidField; @@ -40,21 +40,17 @@ import org.elasticsearch.index.mapper.internal.UidFieldMapper; import org.elasticsearch.index.mapper.multifield.MultiFieldMapper; import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; +import java.util.*; -import static org.elasticsearch.common.collect.ImmutableMap.*; -import static org.elasticsearch.common.collect.Lists.*; -import static org.elasticsearch.common.collect.MapBuilder.*; -import static org.elasticsearch.common.xcontent.support.XContentMapValues.*; +import static com.google.common.collect.ImmutableMap.copyOf; +import static com.google.common.collect.Lists.newArrayList; +import static org.elasticsearch.common.collect.MapBuilder.newMapBuilder; +import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeBooleanValue; import static org.elasticsearch.index.mapper.MapperBuilders.*; -import static org.elasticsearch.index.mapper.core.TypeParsers.*; +import static org.elasticsearch.index.mapper.core.TypeParsers.parsePathType; /** - * @author kimchy (shay.banon) + * */ @ThreadSafe public class ObjectMapper implements Mapper, AllFieldMapper.IncludeInAll { @@ -157,7 +153,8 @@ public class ObjectMapper implements Mapper, AllFieldMapper.IncludeInAll { return this.builder; } - @Override public Y build(BuilderContext context) { + @Override + public Y build(BuilderContext context) { ContentPath.Type origPathType = context.path().pathType(); context.path().pathType(pathType); context.path().add(name); @@ -182,7 +179,8 @@ public class ObjectMapper implements Mapper, AllFieldMapper.IncludeInAll { } public static class TypeParser implements Mapper.TypeParser { - @Override public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { + @Override + public Mapper.Builder parse(String name, Map node, ParserContext parserContext) throws MapperParsingException { Map objectNode = node; ObjectMapper.Builder builder = createBuilder(name); @@ -306,11 +304,13 @@ public class ObjectMapper implements Mapper, AllFieldMapper.IncludeInAll { this.nestedTypeFilter = new TermFilter(TypeFieldMapper.TERM_FACTORY.createTerm(nestedTypePath)); } - @Override public String name() { + @Override + public String name() { return this.name; } - @Override public void includeInAll(Boolean includeInAll) { + @Override + public void includeInAll(Boolean includeInAll) { if (includeInAll == null) { return; } @@ -323,7 +323,8 @@ public class ObjectMapper implements Mapper, AllFieldMapper.IncludeInAll { } } - @Override public void includeInAllIfNotSet(Boolean includeInAll) { + @Override + public void includeInAllIfNotSet(Boolean includeInAll) { if (this.includeInAll == null) { this.includeInAll = includeInAll; } @@ -353,13 +354,15 @@ public class ObjectMapper implements Mapper, AllFieldMapper.IncludeInAll { return this; } - @Override public void traverse(FieldMapperListener fieldMapperListener) { + @Override + public void traverse(FieldMapperListener fieldMapperListener) { for (Mapper mapper : mappers.values()) { mapper.traverse(fieldMapperListener); } } - @Override public void traverse(ObjectMapperListener objectMapperListener) { + @Override + public void traverse(ObjectMapperListener objectMapperListener) { objectMapperListener.objectMapper(this); for (Mapper mapper : mappers.values()) { mapper.traverse(objectMapperListener); @@ -523,12 +526,14 @@ public class ObjectMapper implements Mapper, AllFieldMapper.IncludeInAll { // we need to traverse in case we have a dynamic template and need to add field mappers // introduced by it objectMapper.traverse(new FieldMapperListener() { - @Override public void fieldMapper(FieldMapper fieldMapper) { + @Override + public void fieldMapper(FieldMapper fieldMapper) { context.docMapper().addFieldMapper(fieldMapper); } }); objectMapper.traverse(new ObjectMapperListener() { - @Override public void objectMapper(ObjectMapper objectMapper) { + @Override + public void objectMapper(ObjectMapper objectMapper) { context.docMapper().addObjectMapper(objectMapper); } }); @@ -748,7 +753,8 @@ public class ObjectMapper implements Mapper, AllFieldMapper.IncludeInAll { } if (newMapper) { mapper.traverse(new FieldMapperListener() { - @Override public void fieldMapper(FieldMapper fieldMapper) { + @Override + public void fieldMapper(FieldMapper fieldMapper) { context.docMapper().addFieldMapper(fieldMapper); } }); @@ -756,7 +762,8 @@ public class ObjectMapper implements Mapper, AllFieldMapper.IncludeInAll { mapper.parse(context); } - @Override public void merge(final Mapper mergeWith, final MergeContext mergeContext) throws MergeMappingException { + @Override + public void merge(final Mapper mergeWith, final MergeContext mergeContext) throws MergeMappingException { if (!(mergeWith instanceof ObjectMapper)) { mergeContext.addConflict("Can't merge a non object mapping [" + mergeWith.name() + "] with an object mapping [" + name() + "]"); return; @@ -795,12 +802,14 @@ public class ObjectMapper implements Mapper, AllFieldMapper.IncludeInAll { // call this outside of the mutex for (Mapper mapper : mappersToTraverse) { mapper.traverse(new FieldMapperListener() { - @Override public void fieldMapper(FieldMapper fieldMapper) { + @Override + public void fieldMapper(FieldMapper fieldMapper) { mergeContext.docMapper().addFieldMapper(fieldMapper); } }); mapper.traverse(new ObjectMapperListener() { - @Override public void objectMapper(ObjectMapper objectMapper) { + @Override + public void objectMapper(ObjectMapper objectMapper) { mergeContext.docMapper().addObjectMapper(objectMapper); } }); @@ -811,13 +820,15 @@ public class ObjectMapper implements Mapper, AllFieldMapper.IncludeInAll { } - @Override public void close() { + @Override + public void close() { for (Mapper mapper : mappers.values()) { mapper.close(); } } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { toXContent(builder, params, null, Mapper.EMPTY_ARRAY); return builder; } diff --git a/src/main/java/org/elasticsearch/index/mapper/object/RootObjectMapper.java b/src/main/java/org/elasticsearch/index/mapper/object/RootObjectMapper.java index 60f565eb4d2..08aa8093bd2 100644 --- a/src/main/java/org/elasticsearch/index/mapper/object/RootObjectMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/object/RootObjectMapper.java @@ -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,17 +19,13 @@ package org.elasticsearch.index.mapper.object; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.collect.Sets; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; import org.elasticsearch.common.joda.FormatDateTimeFormatter; import org.elasticsearch.common.joda.Joda; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.index.mapper.ContentPath; -import org.elasticsearch.index.mapper.Mapper; -import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MergeContext; -import org.elasticsearch.index.mapper.ParseContext; +import org.elasticsearch.index.mapper.*; import org.elasticsearch.index.mapper.core.DateFieldMapper; import java.io.IOException; @@ -38,12 +34,12 @@ import java.util.List; import java.util.Map; import java.util.Set; -import static org.elasticsearch.common.collect.Lists.*; -import static org.elasticsearch.common.xcontent.support.XContentMapValues.*; -import static org.elasticsearch.index.mapper.core.TypeParsers.*; +import static com.google.common.collect.Lists.newArrayList; +import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeBooleanValue; +import static org.elasticsearch.index.mapper.core.TypeParsers.parseDateTimeFormatter; /** - * @author kimchy (shay.banon) + * */ public class RootObjectMapper extends ObjectMapper { @@ -101,7 +97,8 @@ public class RootObjectMapper extends ObjectMapper { } - @Override protected ObjectMapper createMapper(String name, String fullPath, boolean enabled, Nested nested, Dynamic dynamic, ContentPath.Type pathType, Map mappers) { + @Override + protected ObjectMapper createMapper(String name, String fullPath, boolean enabled, Nested nested, Dynamic dynamic, ContentPath.Type pathType, Map mappers) { assert !nested.isNested(); FormatDateTimeFormatter[] dates = null; if (dynamicDateTimeFormatters == null) { @@ -125,11 +122,13 @@ public class RootObjectMapper extends ObjectMapper { public static class TypeParser extends ObjectMapper.TypeParser { - @Override protected ObjectMapper.Builder createBuilder(String name) { + @Override + protected ObjectMapper.Builder createBuilder(String name) { return new Builder(name); } - @Override protected void processField(ObjectMapper.Builder builder, String fieldName, Object fieldNode) { + @Override + protected void processField(ObjectMapper.Builder builder, String fieldName, Object fieldNode) { if (fieldName.equals("date_formats") || fieldName.equals("dynamic_date_formats")) { List dateTimeFormatters = newArrayList(); if (fieldNode instanceof List) { @@ -228,7 +227,8 @@ public class RootObjectMapper extends ObjectMapper { return null; } - @Override protected void doMerge(ObjectMapper mergeWith, MergeContext mergeContext) { + @Override + protected void doMerge(ObjectMapper mergeWith, MergeContext mergeContext) { RootObjectMapper mergeWithObject = (RootObjectMapper) mergeWith; if (!mergeContext.mergeFlags().simulate()) { // merge them @@ -249,7 +249,8 @@ public class RootObjectMapper extends ObjectMapper { } } - @Override protected void doXContent(XContentBuilder builder, ToXContent.Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, ToXContent.Params params) throws IOException { if (dynamicDateTimeFormatters != Defaults.DYNAMIC_DATE_TIME_FORMATTERS) { if (dynamicDateTimeFormatters.length > 0) { builder.startArray("dynamic_date_formats"); diff --git a/src/main/java/org/elasticsearch/index/mapper/selector/AllButSourceFieldSelector.java b/src/main/java/org/elasticsearch/index/mapper/selector/AllButSourceFieldSelector.java index 5f8267c165b..2f9101a4266 100644 --- a/src/main/java/org/elasticsearch/index/mapper/selector/AllButSourceFieldSelector.java +++ b/src/main/java/org/elasticsearch/index/mapper/selector/AllButSourceFieldSelector.java @@ -26,19 +26,21 @@ import org.elasticsearch.index.mapper.internal.SourceFieldMapper; /** * A field selector that loads all fields except the source field. * - * @author kimchy (shay.banon) + * */ public class AllButSourceFieldSelector implements ResetFieldSelector { public static final AllButSourceFieldSelector INSTANCE = new AllButSourceFieldSelector(); - @Override public FieldSelectorResult accept(String fieldName) { + @Override + public FieldSelectorResult accept(String fieldName) { if (SourceFieldMapper.NAME.equals(fieldName)) { return FieldSelectorResult.NO_LOAD; } return FieldSelectorResult.LOAD; } - @Override public void reset() { + @Override + public void reset() { } } diff --git a/src/main/java/org/elasticsearch/index/mapper/selector/FieldMappersFieldSelector.java b/src/main/java/org/elasticsearch/index/mapper/selector/FieldMappersFieldSelector.java index d922a24b145..dc045469b6a 100644 --- a/src/main/java/org/elasticsearch/index/mapper/selector/FieldMappersFieldSelector.java +++ b/src/main/java/org/elasticsearch/index/mapper/selector/FieldMappersFieldSelector.java @@ -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.index.mapper.FieldMappers; import java.util.HashSet; /** - * @author kimchy (shay.banon) + * */ public class FieldMappersFieldSelector implements ResetFieldSelector { @@ -43,13 +43,15 @@ public class FieldMappersFieldSelector implements ResetFieldSelector { } } - @Override public FieldSelectorResult accept(String fieldName) { + @Override + public FieldSelectorResult accept(String fieldName) { if (names.contains(fieldName)) { return FieldSelectorResult.LOAD; } return FieldSelectorResult.NO_LOAD; } - @Override public void reset() { + @Override + public void reset() { } } diff --git a/src/main/java/org/elasticsearch/index/mapper/selector/UidAndSourceFieldSelector.java b/src/main/java/org/elasticsearch/index/mapper/selector/UidAndSourceFieldSelector.java index 9d30ec512bf..3c7d6924963 100644 --- a/src/main/java/org/elasticsearch/index/mapper/selector/UidAndSourceFieldSelector.java +++ b/src/main/java/org/elasticsearch/index/mapper/selector/UidAndSourceFieldSelector.java @@ -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,13 +27,14 @@ import org.elasticsearch.index.mapper.internal.UidFieldMapper; /** * An optimized field selector that loads just the uid and the source. * - * @author kimchy (shay.banon) + * */ public class UidAndSourceFieldSelector implements ResetFieldSelector { private int match = 0; - @Override public FieldSelectorResult accept(String fieldName) { + @Override + public FieldSelectorResult accept(String fieldName) { if (UidFieldMapper.NAME.equals(fieldName)) { if (++match == 2) { return FieldSelectorResult.LOAD_AND_BREAK; @@ -49,7 +50,8 @@ public class UidAndSourceFieldSelector implements ResetFieldSelector { return FieldSelectorResult.NO_LOAD; } - @Override public void reset() { + @Override + public void reset() { match = 0; } } diff --git a/src/main/java/org/elasticsearch/index/mapper/selector/UidFieldSelector.java b/src/main/java/org/elasticsearch/index/mapper/selector/UidFieldSelector.java index 9aa024f4edb..f9b18d77c89 100644 --- a/src/main/java/org/elasticsearch/index/mapper/selector/UidFieldSelector.java +++ b/src/main/java/org/elasticsearch/index/mapper/selector/UidFieldSelector.java @@ -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.index.mapper.internal.UidFieldMapper; /** * An optimized field selector that loads just the uid. * - * @author kimchy (shay.banon) + * */ public class UidFieldSelector implements ResetFieldSelector { @@ -36,13 +36,15 @@ public class UidFieldSelector implements ResetFieldSelector { } - @Override public FieldSelectorResult accept(String fieldName) { + @Override + public FieldSelectorResult accept(String fieldName) { if (UidFieldMapper.NAME.equals(fieldName)) { return FieldSelectorResult.LOAD_AND_BREAK; } return FieldSelectorResult.NO_LOAD; } - @Override public void reset() { + @Override + public void reset() { } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/merge/MergeStats.java b/src/main/java/org/elasticsearch/index/merge/MergeStats.java index cbace9b0071..9a0617e85f8 100644 --- a/src/main/java/org/elasticsearch/index/merge/MergeStats.java +++ b/src/main/java/org/elasticsearch/index/merge/MergeStats.java @@ -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 @@ -128,7 +128,8 @@ public class MergeStats implements Streamable, ToXContent { return stats; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(Fields.MERGES); builder.field(Fields.CURRENT, current); builder.field(Fields.CURRENT_DOCS, currentNumDocs); @@ -158,7 +159,8 @@ public class MergeStats implements Streamable, ToXContent { static final XContentBuilderString TOTAL_SIZE_IN_BYTES = new XContentBuilderString("total_size_in_bytes"); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { total = in.readVLong(); totalTimeInMillis = in.readVLong(); totalNumDocs = in.readVLong(); @@ -168,7 +170,8 @@ public class MergeStats implements Streamable, ToXContent { currentSizeInBytes = in.readVLong(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeVLong(total); out.writeVLong(totalTimeInMillis); out.writeVLong(totalNumDocs); diff --git a/src/main/java/org/elasticsearch/index/merge/policy/EnableMergePolicy.java b/src/main/java/org/elasticsearch/index/merge/policy/EnableMergePolicy.java index 37652a09977..006e445f1a0 100644 --- a/src/main/java/org/elasticsearch/index/merge/policy/EnableMergePolicy.java +++ b/src/main/java/org/elasticsearch/index/merge/policy/EnableMergePolicy.java @@ -22,11 +22,11 @@ package org.elasticsearch.index.merge.policy; /** * Allows to control if merge should be enabled on the current thread or not. Defaults to * not being enabled. - * + *

    *

    This allows us to disable merging for things like adding docs or refresh (which might block * if no threads are there to handle the merge) and do it on flush (for example) or on explicit API call. * - * @author kimchy (shay.banon) + * */ public interface EnableMergePolicy { diff --git a/src/main/java/org/elasticsearch/index/merge/policy/LogByteSizeMergePolicyProvider.java b/src/main/java/org/elasticsearch/index/merge/policy/LogByteSizeMergePolicyProvider.java index 317b6e33bb4..fcede657031 100644 --- a/src/main/java/org/elasticsearch/index/merge/policy/LogByteSizeMergePolicyProvider.java +++ b/src/main/java/org/elasticsearch/index/merge/policy/LogByteSizeMergePolicyProvider.java @@ -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 @@ -40,7 +40,7 @@ import java.util.Set; import java.util.concurrent.CopyOnWriteArraySet; /** - * @author kimchy (shay.banon) + * */ public class LogByteSizeMergePolicyProvider extends AbstractIndexShardComponent implements MergePolicyProvider { @@ -58,7 +58,8 @@ public class LogByteSizeMergePolicyProvider extends AbstractIndexShardComponent private final ApplySettings applySettings = new ApplySettings(); - @Inject public LogByteSizeMergePolicyProvider(Store store, IndexSettingsService indexSettingsService) { + @Inject + public LogByteSizeMergePolicyProvider(Store store, IndexSettingsService indexSettingsService) { super(store.shardId(), store.indexSettings()); Preconditions.checkNotNull(store, "Store must be provided to merge policy"); this.indexSettingsService = indexSettingsService; @@ -76,7 +77,8 @@ public class LogByteSizeMergePolicyProvider extends AbstractIndexShardComponent indexSettingsService.addListener(applySettings); } - @Override public LogByteSizeMergePolicy newMergePolicy() { + @Override + public LogByteSizeMergePolicy newMergePolicy() { CustomLogByteSizeMergePolicy mergePolicy; if (asyncMerge) { mergePolicy = new EnableMergeLogByteSizeMergePolicy(this); @@ -94,7 +96,8 @@ public class LogByteSizeMergePolicyProvider extends AbstractIndexShardComponent return mergePolicy; } - @Override public void close(boolean delete) throws ElasticSearchException { + @Override + public void close(boolean delete) throws ElasticSearchException { indexSettingsService.removeListener(applySettings); } @@ -109,7 +112,8 @@ public class LogByteSizeMergePolicyProvider extends AbstractIndexShardComponent } class ApplySettings implements IndexSettingsService.Listener { - @Override public void onRefreshSettings(Settings settings) { + @Override + public void onRefreshSettings(Settings settings) { ByteSizeValue minMergeSize = settings.getAsBytesSize("index.merge.policy.min_merge_size", LogByteSizeMergePolicyProvider.this.minMergeSize); if (!minMergeSize.equals(LogByteSizeMergePolicyProvider.this.minMergeSize)) { logger.info("updating min_merge_size from [{}] to [{}]", LogByteSizeMergePolicyProvider.this.minMergeSize, minMergeSize); @@ -166,7 +170,8 @@ public class LogByteSizeMergePolicyProvider extends AbstractIndexShardComponent this.provider = provider; } - @Override public void close() { + @Override + public void close() { super.close(); provider.policies.remove(this); } @@ -175,7 +180,8 @@ public class LogByteSizeMergePolicyProvider extends AbstractIndexShardComponent public static class EnableMergeLogByteSizeMergePolicy extends CustomLogByteSizeMergePolicy implements EnableMergePolicy { private final ThreadLocal enableMerge = new ThreadLocal() { - @Override protected Boolean initialValue() { + @Override + protected Boolean initialValue() { return Boolean.FALSE; } }; @@ -184,38 +190,45 @@ public class LogByteSizeMergePolicyProvider extends AbstractIndexShardComponent super(provider); } - @Override public void enableMerge() { + @Override + public void enableMerge() { enableMerge.set(Boolean.TRUE); } - @Override public void disableMerge() { + @Override + public void disableMerge() { enableMerge.set(Boolean.FALSE); } - @Override public boolean isMergeEnabled() { + @Override + public boolean isMergeEnabled() { return enableMerge.get() == Boolean.TRUE; } - @Override public void close() { + @Override + public void close() { enableMerge.remove(); super.close(); } - @Override public MergeSpecification findMerges(SegmentInfos infos) throws IOException { + @Override + public MergeSpecification findMerges(SegmentInfos infos) throws IOException { if (enableMerge.get() == Boolean.FALSE) { return null; } return super.findMerges(infos); } - @Override public MergeSpecification findForcedMerges(SegmentInfos infos, int maxSegmentCount, Map segmentsToMerge) throws IOException { + @Override + public MergeSpecification findForcedMerges(SegmentInfos infos, int maxSegmentCount, Map segmentsToMerge) throws IOException { if (enableMerge.get() == Boolean.FALSE) { return null; } return super.findForcedMerges(infos, maxSegmentCount, segmentsToMerge); } - @Override public MergeSpecification findForcedDeletesMerges(SegmentInfos infos) throws CorruptIndexException, IOException { + @Override + public MergeSpecification findForcedDeletesMerges(SegmentInfos infos) throws CorruptIndexException, IOException { if (enableMerge.get() == Boolean.FALSE) { return null; } diff --git a/src/main/java/org/elasticsearch/index/merge/policy/LogDocMergePolicyProvider.java b/src/main/java/org/elasticsearch/index/merge/policy/LogDocMergePolicyProvider.java index 49c1d8a469d..4467e20a173 100644 --- a/src/main/java/org/elasticsearch/index/merge/policy/LogDocMergePolicyProvider.java +++ b/src/main/java/org/elasticsearch/index/merge/policy/LogDocMergePolicyProvider.java @@ -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,7 +38,7 @@ import java.util.Set; import java.util.concurrent.CopyOnWriteArraySet; /** - * @author kimchy (shay.banon) + * */ public class LogDocMergePolicyProvider extends AbstractIndexShardComponent implements MergePolicyProvider { @@ -55,7 +55,8 @@ public class LogDocMergePolicyProvider extends AbstractIndexShardComponent imple private final ApplySettings applySettings = new ApplySettings(); - @Inject public LogDocMergePolicyProvider(Store store, IndexSettingsService indexSettingsService) { + @Inject + public LogDocMergePolicyProvider(Store store, IndexSettingsService indexSettingsService) { super(store.shardId(), store.indexSettings()); Preconditions.checkNotNull(store, "Store must be provided to merge policy"); this.indexSettingsService = indexSettingsService; @@ -72,11 +73,13 @@ public class LogDocMergePolicyProvider extends AbstractIndexShardComponent imple indexSettingsService.addListener(applySettings); } - @Override public void close(boolean delete) throws ElasticSearchException { + @Override + public void close(boolean delete) throws ElasticSearchException { indexSettingsService.removeListener(applySettings); } - @Override public LogDocMergePolicy newMergePolicy() { + @Override + public LogDocMergePolicy newMergePolicy() { CustomLogDocMergePolicy mergePolicy; if (asyncMerge) { mergePolicy = new EnableMergeLogDocMergePolicy(this); @@ -102,7 +105,8 @@ public class LogDocMergePolicyProvider extends AbstractIndexShardComponent imple } class ApplySettings implements IndexSettingsService.Listener { - @Override public void onRefreshSettings(Settings settings) { + @Override + public void onRefreshSettings(Settings settings) { int minMergeDocs = settings.getAsInt("index.merge.policy.min_merge_docs", LogDocMergePolicyProvider.this.minMergeDocs); if (minMergeDocs != LogDocMergePolicyProvider.this.minMergeDocs) { logger.info("updating min_merge_docs from [{}] to [{}]", LogDocMergePolicyProvider.this.minMergeDocs, minMergeDocs); @@ -150,7 +154,8 @@ public class LogDocMergePolicyProvider extends AbstractIndexShardComponent imple this.provider = provider; } - @Override public void close() { + @Override + public void close() { super.close(); provider.policies.remove(this); } @@ -159,7 +164,8 @@ public class LogDocMergePolicyProvider extends AbstractIndexShardComponent imple public static class EnableMergeLogDocMergePolicy extends CustomLogDocMergePolicy implements EnableMergePolicy { private final ThreadLocal enableMerge = new ThreadLocal() { - @Override protected Boolean initialValue() { + @Override + protected Boolean initialValue() { return Boolean.FALSE; } }; @@ -168,38 +174,45 @@ public class LogDocMergePolicyProvider extends AbstractIndexShardComponent imple super(provider); } - @Override public void enableMerge() { + @Override + public void enableMerge() { enableMerge.set(Boolean.TRUE); } - @Override public void disableMerge() { + @Override + public void disableMerge() { enableMerge.set(Boolean.FALSE); } - @Override public boolean isMergeEnabled() { + @Override + public boolean isMergeEnabled() { return enableMerge.get() == Boolean.TRUE; } - @Override public void close() { + @Override + public void close() { enableMerge.remove(); super.close(); } - @Override public MergeSpecification findMerges(SegmentInfos infos) throws IOException { + @Override + public MergeSpecification findMerges(SegmentInfos infos) throws IOException { if (enableMerge.get() == Boolean.FALSE) { return null; } return super.findMerges(infos); } - @Override public MergeSpecification findForcedMerges(SegmentInfos infos, int maxSegmentCount, Map segmentsToMerge) throws IOException { + @Override + public MergeSpecification findForcedMerges(SegmentInfos infos, int maxSegmentCount, Map segmentsToMerge) throws IOException { if (enableMerge.get() == Boolean.FALSE) { return null; } return super.findForcedMerges(infos, maxSegmentCount, segmentsToMerge); } - @Override public MergeSpecification findForcedDeletesMerges(SegmentInfos infos) throws CorruptIndexException, IOException { + @Override + public MergeSpecification findForcedDeletesMerges(SegmentInfos infos) throws CorruptIndexException, IOException { if (enableMerge.get() == Boolean.FALSE) { return null; } diff --git a/src/main/java/org/elasticsearch/index/merge/policy/MergePolicyModule.java b/src/main/java/org/elasticsearch/index/merge/policy/MergePolicyModule.java index 02f8dca9e13..253fa6ce490 100644 --- a/src/main/java/org/elasticsearch/index/merge/policy/MergePolicyModule.java +++ b/src/main/java/org/elasticsearch/index/merge/policy/MergePolicyModule.java @@ -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.inject.AbstractModule; import org.elasticsearch.common.settings.Settings; /** - * @author kimchy (Shay Banon) + * */ public class MergePolicyModule extends AbstractModule { @@ -33,7 +33,8 @@ public class MergePolicyModule extends AbstractModule { this.settings = settings; } - @Override protected void configure() { + @Override + protected void configure() { bind(MergePolicyProvider.class) .to(settings.getAsClass("index.merge.policy.type", TieredMergePolicyProvider.class, "org.elasticsearch.index.merge.policy.", "MergePolicyProvider")) .asEagerSingleton(); diff --git a/src/main/java/org/elasticsearch/index/merge/policy/MergePolicyProvider.java b/src/main/java/org/elasticsearch/index/merge/policy/MergePolicyProvider.java index 67875698381..71c79dbe5c8 100644 --- a/src/main/java/org/elasticsearch/index/merge/policy/MergePolicyProvider.java +++ b/src/main/java/org/elasticsearch/index/merge/policy/MergePolicyProvider.java @@ -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.index.CloseableIndexComponent; import org.elasticsearch.index.shard.IndexShardComponent; /** - * @author kimchy (Shay Banon) + * */ public interface MergePolicyProvider extends IndexShardComponent, CloseableIndexComponent { diff --git a/src/main/java/org/elasticsearch/index/merge/policy/TieredMergePolicyProvider.java b/src/main/java/org/elasticsearch/index/merge/policy/TieredMergePolicyProvider.java index c6b33a72130..5acb1df1a47 100644 --- a/src/main/java/org/elasticsearch/index/merge/policy/TieredMergePolicyProvider.java +++ b/src/main/java/org/elasticsearch/index/merge/policy/TieredMergePolicyProvider.java @@ -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,11 +19,7 @@ package org.elasticsearch.index.merge.policy; -import org.apache.lucene.index.CorruptIndexException; -import org.apache.lucene.index.MergePolicy; -import org.apache.lucene.index.SegmentInfo; -import org.apache.lucene.index.SegmentInfos; -import org.apache.lucene.index.TieredMergePolicy; +import org.apache.lucene.index.*; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.common.inject.Inject; @@ -57,7 +53,8 @@ public class TieredMergePolicyProvider extends AbstractIndexShardComponent imple private final ApplySettings applySettings = new ApplySettings(); - @Inject public TieredMergePolicyProvider(Store store, IndexSettingsService indexSettingsService) { + @Inject + public TieredMergePolicyProvider(Store store, IndexSettingsService indexSettingsService) { super(store.shardId(), store.indexSettings()); this.indexSettingsService = indexSettingsService; @@ -79,7 +76,8 @@ public class TieredMergePolicyProvider extends AbstractIndexShardComponent imple } - @Override public TieredMergePolicy newMergePolicy() { + @Override + public TieredMergePolicy newMergePolicy() { CustomTieredMergePolicyProvider mergePolicy; if (asyncMerge) { mergePolicy = new EnableMergeTieredMergePolicyProvider(this); @@ -97,7 +95,8 @@ public class TieredMergePolicyProvider extends AbstractIndexShardComponent imple return mergePolicy; } - @Override public void close(boolean delete) throws ElasticSearchException { + @Override + public void close(boolean delete) throws ElasticSearchException { indexSettingsService.removeListener(applySettings); } @@ -115,7 +114,8 @@ public class TieredMergePolicyProvider extends AbstractIndexShardComponent imple } class ApplySettings implements IndexSettingsService.Listener { - @Override public void onRefreshSettings(Settings settings) { + @Override + public void onRefreshSettings(Settings settings) { double expungeDeletesPctAllowed = settings.getAsDouble("index.merge.policy.expunge_deletes_allowed", TieredMergePolicyProvider.this.forceMergeDeletesPctAllowed); if (expungeDeletesPctAllowed != TieredMergePolicyProvider.this.forceMergeDeletesPctAllowed) { logger.info("updating [expunge_deletes_allowed] from [{}] to [{}]", TieredMergePolicyProvider.this.forceMergeDeletesPctAllowed, expungeDeletesPctAllowed); @@ -199,7 +199,8 @@ public class TieredMergePolicyProvider extends AbstractIndexShardComponent imple this.provider = provider; } - @Override public void close() { + @Override + public void close() { super.close(); provider.policies.remove(this); } @@ -208,7 +209,8 @@ public class TieredMergePolicyProvider extends AbstractIndexShardComponent imple public static class EnableMergeTieredMergePolicyProvider extends CustomTieredMergePolicyProvider implements EnableMergePolicy { private final ThreadLocal enableMerge = new ThreadLocal() { - @Override protected Boolean initialValue() { + @Override + protected Boolean initialValue() { return Boolean.FALSE; } }; @@ -217,38 +219,45 @@ public class TieredMergePolicyProvider extends AbstractIndexShardComponent imple super(provider); } - @Override public void enableMerge() { + @Override + public void enableMerge() { enableMerge.set(Boolean.TRUE); } - @Override public void disableMerge() { + @Override + public void disableMerge() { enableMerge.set(Boolean.FALSE); } - @Override public boolean isMergeEnabled() { + @Override + public boolean isMergeEnabled() { return enableMerge.get() == Boolean.TRUE; } - @Override public void close() { + @Override + public void close() { enableMerge.remove(); super.close(); } - @Override public MergePolicy.MergeSpecification findMerges(SegmentInfos infos) throws IOException { + @Override + public MergePolicy.MergeSpecification findMerges(SegmentInfos infos) throws IOException { if (enableMerge.get() == Boolean.FALSE) { return null; } return super.findMerges(infos); } - @Override public MergeSpecification findForcedMerges(SegmentInfos infos, int maxSegmentCount, Map segmentsToMerge) throws IOException { + @Override + public MergeSpecification findForcedMerges(SegmentInfos infos, int maxSegmentCount, Map segmentsToMerge) throws IOException { if (enableMerge.get() == Boolean.FALSE) { return null; } return super.findForcedMerges(infos, maxSegmentCount, segmentsToMerge); } - @Override public MergeSpecification findForcedDeletesMerges(SegmentInfos infos) throws CorruptIndexException, IOException { + @Override + public MergeSpecification findForcedDeletesMerges(SegmentInfos infos) throws CorruptIndexException, IOException { if (enableMerge.get() == Boolean.FALSE) { return null; } diff --git a/src/main/java/org/elasticsearch/index/merge/scheduler/ConcurrentMergeSchedulerProvider.java b/src/main/java/org/elasticsearch/index/merge/scheduler/ConcurrentMergeSchedulerProvider.java index 5dcd371283e..3a5de07697b 100644 --- a/src/main/java/org/elasticsearch/index/merge/scheduler/ConcurrentMergeSchedulerProvider.java +++ b/src/main/java/org/elasticsearch/index/merge/scheduler/ConcurrentMergeSchedulerProvider.java @@ -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,11 +19,7 @@ package org.elasticsearch.index.merge.scheduler; -import org.apache.lucene.index.CorruptIndexException; -import org.apache.lucene.index.IndexWriter; -import org.apache.lucene.index.MergePolicy; -import org.apache.lucene.index.MergeScheduler; -import org.apache.lucene.index.TrackingConcurrentMergeScheduler; +import org.apache.lucene.index.*; import org.apache.lucene.store.AlreadyClosedException; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.logging.ESLogger; @@ -39,7 +35,7 @@ import java.util.Set; import java.util.concurrent.CopyOnWriteArraySet; /** - * @author kimchy (shay.banon) + * */ public class ConcurrentMergeSchedulerProvider extends AbstractIndexShardComponent implements MergeSchedulerProvider { @@ -48,7 +44,8 @@ public class ConcurrentMergeSchedulerProvider extends AbstractIndexShardComponen private Set schedulers = new CopyOnWriteArraySet(); - @Inject public ConcurrentMergeSchedulerProvider(ShardId shardId, @IndexSettings Settings indexSettings) { + @Inject + public ConcurrentMergeSchedulerProvider(ShardId shardId, @IndexSettings Settings indexSettings) { super(shardId, indexSettings); // TODO LUCENE MONITOR this will change in Lucene 4.0 @@ -57,7 +54,8 @@ public class ConcurrentMergeSchedulerProvider extends AbstractIndexShardComponen logger.debug("using [concurrent] merge scheduler with max_thread_count[{}]", maxThreadCount); } - @Override public MergeScheduler newMergeScheduler() { + @Override + public MergeScheduler newMergeScheduler() { CustomConcurrentMergeScheduler concurrentMergeScheduler = new CustomConcurrentMergeScheduler(logger, shardId, this); concurrentMergeScheduler.setMaxMergeCount(maxMergeCount); concurrentMergeScheduler.setMaxThreadCount(maxThreadCount); @@ -65,7 +63,8 @@ public class ConcurrentMergeSchedulerProvider extends AbstractIndexShardComponen return concurrentMergeScheduler; } - @Override public MergeStats stats() { + @Override + public MergeStats stats() { MergeStats mergeStats = new MergeStats(); for (CustomConcurrentMergeScheduler scheduler : schedulers) { mergeStats.add(scheduler.totalMerges(), scheduler.totalMergeTime(), scheduler.totalMergeNumDocs(), scheduler.totalMergeSizeInBytes(), @@ -86,7 +85,8 @@ public class ConcurrentMergeSchedulerProvider extends AbstractIndexShardComponen this.provider = provider; } - @Override public void merge(IndexWriter writer) throws CorruptIndexException, IOException { + @Override + public void merge(IndexWriter writer) throws CorruptIndexException, IOException { try { // if merge is not enabled, don't do any merging... if (writer.getConfig().getMergePolicy() instanceof EnableMergePolicy) { @@ -108,18 +108,21 @@ public class ConcurrentMergeSchedulerProvider extends AbstractIndexShardComponen } } - @Override protected MergeThread getMergeThread(IndexWriter writer, MergePolicy.OneMerge merge) throws IOException { + @Override + protected MergeThread getMergeThread(IndexWriter writer, MergePolicy.OneMerge merge) throws IOException { MergeThread thread = super.getMergeThread(writer, merge); thread.setName("[" + shardId.index().name() + "][" + shardId.id() + "]: " + thread.getName()); return thread; } - @Override protected void handleMergeException(Throwable exc) { + @Override + protected void handleMergeException(Throwable exc) { logger.warn("failed to merge", exc); super.handleMergeException(exc); } - @Override public void close() { + @Override + public void close() { super.close(); provider.schedulers.remove(this); } diff --git a/src/main/java/org/elasticsearch/index/merge/scheduler/MergeSchedulerModule.java b/src/main/java/org/elasticsearch/index/merge/scheduler/MergeSchedulerModule.java index b90d708282f..6740da2ca74 100644 --- a/src/main/java/org/elasticsearch/index/merge/scheduler/MergeSchedulerModule.java +++ b/src/main/java/org/elasticsearch/index/merge/scheduler/MergeSchedulerModule.java @@ -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,10 +22,10 @@ package org.elasticsearch.index.merge.scheduler; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.settings.Settings; -import static org.elasticsearch.index.merge.scheduler.MergeSchedulerModule.MergeSchedulerSettings.*; +import static org.elasticsearch.index.merge.scheduler.MergeSchedulerModule.MergeSchedulerSettings.TYPE; /** - * @author kimchy (shay.banon) + * */ public class MergeSchedulerModule extends AbstractModule { @@ -39,7 +39,8 @@ public class MergeSchedulerModule extends AbstractModule { this.settings = settings; } - @Override protected void configure() { + @Override + protected void configure() { bind(MergeSchedulerProvider.class) .to(settings.getAsClass(TYPE, ConcurrentMergeSchedulerProvider.class, "org.elasticsearch.index.scheduler.", "MergeSchedulerProvider")) .asEagerSingleton(); diff --git a/src/main/java/org/elasticsearch/index/merge/scheduler/MergeSchedulerProvider.java b/src/main/java/org/elasticsearch/index/merge/scheduler/MergeSchedulerProvider.java index 3755444166a..2d03278029d 100644 --- a/src/main/java/org/elasticsearch/index/merge/scheduler/MergeSchedulerProvider.java +++ b/src/main/java/org/elasticsearch/index/merge/scheduler/MergeSchedulerProvider.java @@ -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.index.merge.MergeStats; import org.elasticsearch.index.shard.IndexShardComponent; /** - * @author kimchy (Shay Banon) + * */ public interface MergeSchedulerProvider extends IndexShardComponent { diff --git a/src/main/java/org/elasticsearch/index/merge/scheduler/SerialMergeSchedulerProvider.java b/src/main/java/org/elasticsearch/index/merge/scheduler/SerialMergeSchedulerProvider.java index 860fcd4feb3..4300437bf00 100644 --- a/src/main/java/org/elasticsearch/index/merge/scheduler/SerialMergeSchedulerProvider.java +++ b/src/main/java/org/elasticsearch/index/merge/scheduler/SerialMergeSchedulerProvider.java @@ -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,24 +38,27 @@ import java.util.Set; import java.util.concurrent.CopyOnWriteArraySet; /** - * @author kimchy (shay.banon) + * */ public class SerialMergeSchedulerProvider extends AbstractIndexShardComponent implements MergeSchedulerProvider { private Set schedulers = new CopyOnWriteArraySet(); - @Inject public SerialMergeSchedulerProvider(ShardId shardId, @IndexSettings Settings indexSettings) { + @Inject + public SerialMergeSchedulerProvider(ShardId shardId, @IndexSettings Settings indexSettings) { super(shardId, indexSettings); logger.trace("using [serial] merge scheduler"); } - @Override public MergeScheduler newMergeScheduler() { + @Override + public MergeScheduler newMergeScheduler() { CustomSerialMergeScheduler scheduler = new CustomSerialMergeScheduler(logger, this); schedulers.add(scheduler); return scheduler; } - @Override public MergeStats stats() { + @Override + public MergeStats stats() { MergeStats mergeStats = new MergeStats(); for (CustomSerialMergeScheduler scheduler : schedulers) { mergeStats.add(scheduler.totalMerges(), scheduler.totalMergeTime(), scheduler.totalMergeNumDocs(), scheduler.totalMergeSizeInBytes(), @@ -73,7 +76,8 @@ public class SerialMergeSchedulerProvider extends AbstractIndexShardComponent im this.provider = provider; } - @Override public void merge(IndexWriter writer) throws CorruptIndexException, IOException { + @Override + public void merge(IndexWriter writer) throws CorruptIndexException, IOException { try { // if merge is not enabled, don't do any merging... if (writer.getConfig().getMergePolicy() instanceof EnableMergePolicy) { @@ -95,7 +99,8 @@ public class SerialMergeSchedulerProvider extends AbstractIndexShardComponent im } } - @Override public void close() { + @Override + public void close() { super.close(); provider.schedulers.remove(this); } diff --git a/src/main/java/org/elasticsearch/index/percolator/PercolateIndexUnavailable.java b/src/main/java/org/elasticsearch/index/percolator/PercolateIndexUnavailable.java index 313539febb2..935ca22918c 100644 --- a/src/main/java/org/elasticsearch/index/percolator/PercolateIndexUnavailable.java +++ b/src/main/java/org/elasticsearch/index/percolator/PercolateIndexUnavailable.java @@ -22,7 +22,7 @@ package org.elasticsearch.index.percolator; import org.elasticsearch.index.Index; /** - * @author kimchy (shay.banon) + * */ public class PercolateIndexUnavailable extends PercolatorException { diff --git a/src/main/java/org/elasticsearch/index/percolator/PercolatorException.java b/src/main/java/org/elasticsearch/index/percolator/PercolatorException.java index 17c2c60d348..ebc345208df 100644 --- a/src/main/java/org/elasticsearch/index/percolator/PercolatorException.java +++ b/src/main/java/org/elasticsearch/index/percolator/PercolatorException.java @@ -23,7 +23,7 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexException; /** - * @author kimchy (shay.banon) + * */ public class PercolatorException extends IndexException { diff --git a/src/main/java/org/elasticsearch/index/percolator/PercolatorExecutor.java b/src/main/java/org/elasticsearch/index/percolator/PercolatorExecutor.java index 7b07bbc174c..ef3d18ed69f 100644 --- a/src/main/java/org/elasticsearch/index/percolator/PercolatorExecutor.java +++ b/src/main/java/org/elasticsearch/index/percolator/PercolatorExecutor.java @@ -19,6 +19,7 @@ package org.elasticsearch.index.percolator; +import com.google.common.collect.ImmutableMap; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.document.Fieldable; import org.apache.lucene.index.IndexReader; @@ -31,7 +32,6 @@ import org.elasticsearch.ElasticSearchException; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Preconditions; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.collect.MapBuilder; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.io.BytesStream; @@ -49,11 +49,7 @@ import org.elasticsearch.index.cache.IndexCache; import org.elasticsearch.index.engine.Engine; import org.elasticsearch.index.field.data.FieldData; import org.elasticsearch.index.field.data.FieldDataType; -import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MapperService; -import org.elasticsearch.index.mapper.ParsedDocument; -import org.elasticsearch.index.mapper.Uid; +import org.elasticsearch.index.mapper.*; import org.elasticsearch.index.mapper.internal.UidFieldMapper; import org.elasticsearch.index.query.IndexQueryParserService; import org.elasticsearch.index.query.QueryBuilder; @@ -69,10 +65,10 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import static org.elasticsearch.index.mapper.SourceToParse.*; +import static org.elasticsearch.index.mapper.SourceToParse.source; /** - * @author kimchy (shay.banon) + * */ public class PercolatorExecutor extends AbstractIndexComponent { @@ -112,7 +108,8 @@ public class PercolatorExecutor extends AbstractIndexComponent { public static class DocAndSourceQueryRequest { private final ParsedDocument doc; - @Nullable private final String query; + @Nullable + private final String query; public DocAndSourceQueryRequest(ParsedDocument doc, @Nullable String query) { this.doc = doc; @@ -123,7 +120,8 @@ public class PercolatorExecutor extends AbstractIndexComponent { return this.doc; } - @Nullable String query() { + @Nullable + String query() { return this.query; } } @@ -131,7 +129,8 @@ public class PercolatorExecutor extends AbstractIndexComponent { public static class DocAndQueryRequest { private final ParsedDocument doc; - @Nullable private final Query query; + @Nullable + private final Query query; public DocAndQueryRequest(ParsedDocument doc, @Nullable Query query) { this.doc = doc; @@ -142,7 +141,8 @@ public class PercolatorExecutor extends AbstractIndexComponent { return this.doc; } - @Nullable Query query() { + @Nullable + Query query() { return this.query; } } @@ -176,9 +176,10 @@ public class PercolatorExecutor extends AbstractIndexComponent { private IndicesService indicesService; - @Inject public PercolatorExecutor(Index index, @IndexSettings Settings indexSettings, - MapperService mapperService, IndexQueryParserService queryParserService, - IndexCache indexCache) { + @Inject + public PercolatorExecutor(Index index, @IndexSettings Settings indexSettings, + MapperService mapperService, IndexQueryParserService queryParserService, + IndexCache indexCache) { super(index, indexSettings); this.mapperService = mapperService; this.queryParserService = queryParserService; @@ -407,10 +408,12 @@ public class PercolatorExecutor extends AbstractIndexComponent { private FieldData fieldData; - @Override public void setScorer(Scorer scorer) throws IOException { + @Override + public void setScorer(Scorer scorer) throws IOException { } - @Override public void collect(int doc) throws IOException { + @Override + public void collect(int doc) throws IOException { String uid = fieldData.stringValue(doc); if (uid == null) { return; @@ -432,12 +435,14 @@ public class PercolatorExecutor extends AbstractIndexComponent { } } - @Override public void setNextReader(IndexReader reader, int docBase) throws IOException { + @Override + public void setNextReader(IndexReader reader, int docBase) throws IOException { // we use the UID because id might not be indexed fieldData = percolatorIndex.cache().fieldData().cache(FieldDataType.DefaultTypes.STRING, reader, UidFieldMapper.NAME); } - @Override public boolean acceptsDocsOutOfOrder() { + @Override + public boolean acceptsDocsOutOfOrder() { return true; } } diff --git a/src/main/java/org/elasticsearch/index/percolator/PercolatorModule.java b/src/main/java/org/elasticsearch/index/percolator/PercolatorModule.java index 812554e3494..94e9ecedf02 100644 --- a/src/main/java/org/elasticsearch/index/percolator/PercolatorModule.java +++ b/src/main/java/org/elasticsearch/index/percolator/PercolatorModule.java @@ -22,11 +22,12 @@ package org.elasticsearch.index.percolator; import org.elasticsearch.common.inject.AbstractModule; /** - * @author kimchy (shay.banon) + * */ public class PercolatorModule extends AbstractModule { - @Override protected void configure() { + @Override + protected void configure() { bind(PercolatorExecutor.class).asEagerSingleton(); bind(PercolatorService.class).asEagerSingleton(); } diff --git a/src/main/java/org/elasticsearch/index/percolator/PercolatorService.java b/src/main/java/org/elasticsearch/index/percolator/PercolatorService.java index 04dd1410858..a3123120207 100644 --- a/src/main/java/org/elasticsearch/index/percolator/PercolatorService.java +++ b/src/main/java/org/elasticsearch/index/percolator/PercolatorService.java @@ -19,15 +19,11 @@ package org.elasticsearch.index.percolator; +import com.google.common.collect.Maps; import org.apache.lucene.document.Document; import org.apache.lucene.document.Fieldable; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.search.Collector; -import org.apache.lucene.search.DeletionAwareConstantScoreQuery; -import org.apache.lucene.search.Filter; -import org.apache.lucene.search.Query; -import org.apache.lucene.search.Scorer; -import org.elasticsearch.common.collect.Maps; +import org.apache.lucene.search.*; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.lucene.search.TermFilter; import org.elasticsearch.common.settings.Settings; @@ -51,7 +47,7 @@ import java.io.IOException; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class PercolatorService extends AbstractIndexComponent { @@ -69,8 +65,9 @@ public class PercolatorService extends AbstractIndexComponent { private boolean initialQueriesFetchDone = false; - @Inject public PercolatorService(Index index, @IndexSettings Settings indexSettings, IndicesService indicesService, - PercolatorExecutor percolator) { + @Inject + public PercolatorService(Index index, @IndexSettings Settings indexSettings, IndicesService indicesService, + PercolatorExecutor percolator) { super(index, indexSettings); this.indicesService = indicesService; this.percolator = percolator; @@ -167,10 +164,12 @@ public class PercolatorService extends AbstractIndexComponent { return this.queries; } - @Override public void setScorer(Scorer scorer) throws IOException { + @Override + public void setScorer(Scorer scorer) throws IOException { } - @Override public void collect(int doc) throws IOException { + @Override + public void collect(int doc) throws IOException { // the _source is the query Document document = reader.document(doc, new UidAndSourceFieldSelector()); String id = Uid.createUid(document.get(UidFieldMapper.NAME)).id(); @@ -182,18 +181,21 @@ public class PercolatorService extends AbstractIndexComponent { } } - @Override public void setNextReader(IndexReader reader, int docBase) throws IOException { + @Override + public void setNextReader(IndexReader reader, int docBase) throws IOException { this.reader = reader; } - @Override public boolean acceptsDocsOutOfOrder() { + @Override + public boolean acceptsDocsOutOfOrder() { return true; } } class ShardLifecycleListener extends IndicesLifecycle.Listener { - @Override public void afterIndexShardCreated(IndexShard indexShard) { + @Override + public void afterIndexShardCreated(IndexShard indexShard) { // add a listener that will update based on changes done to the _percolate index // the relevant indices with loaded queries if (indexShard.shardId().index().name().equals(INDEX_NAME)) { @@ -201,7 +203,8 @@ public class PercolatorService extends AbstractIndexComponent { } } - @Override public void afterIndexShardStarted(IndexShard indexShard) { + @Override + public void afterIndexShardStarted(IndexShard indexShard) { if (indexShard.shardId().index().name().equals(INDEX_NAME)) { // percolator index has started, fetch what we can from it and initialize the indices // we have @@ -252,21 +255,24 @@ public class PercolatorService extends AbstractIndexComponent { class RealTimePercolatorOperationListener extends IndexingOperationListener { - @Override public Engine.Create preCreate(Engine.Create create) { + @Override + public Engine.Create preCreate(Engine.Create create) { if (create.type().equals(index().name())) { percolator.addQuery(create.id(), create.source(), create.sourceOffset(), create.sourceLength()); } return create; } - @Override public Engine.Index preIndex(Engine.Index index) { + @Override + public Engine.Index preIndex(Engine.Index index) { if (index.type().equals(index().name())) { percolator.addQuery(index.id(), index.source(), index.sourceOffset(), index.sourceLength()); } return index; } - @Override public Engine.Delete preDelete(Engine.Delete delete) { + @Override + public Engine.Delete preDelete(Engine.Delete delete) { if (delete.type().equals(index().name())) { percolator.removeQuery(delete.id()); } diff --git a/src/main/java/org/elasticsearch/index/query/AndFilterBuilder.java b/src/main/java/org/elasticsearch/index/query/AndFilterBuilder.java index abb3c09475d..3c93f43ecf9 100644 --- a/src/main/java/org/elasticsearch/index/query/AndFilterBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/AndFilterBuilder.java @@ -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,7 +19,7 @@ package org.elasticsearch.index.query; -import org.elasticsearch.common.collect.Lists; +import com.google.common.collect.Lists; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; @@ -28,7 +28,7 @@ import java.util.ArrayList; /** * A filter that matches documents matching boolean combinations of other filters. * - * @author kimchy (shay.banon) + * */ public class AndFilterBuilder extends BaseFilterBuilder { @@ -74,7 +74,8 @@ public class AndFilterBuilder extends BaseFilterBuilder { return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(AndFilterParser.NAME); builder.startArray("filters"); for (FilterBuilder filter : filters) { diff --git a/src/main/java/org/elasticsearch/index/query/AndFilterParser.java b/src/main/java/org/elasticsearch/index/query/AndFilterParser.java index ccf618ea959..2b58832da14 100644 --- a/src/main/java/org/elasticsearch/index/query/AndFilterParser.java +++ b/src/main/java/org/elasticsearch/index/query/AndFilterParser.java @@ -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,23 +28,26 @@ import org.elasticsearch.index.cache.filter.support.CacheKeyFilter; import java.io.IOException; import java.util.ArrayList; -import static org.elasticsearch.common.collect.Lists.*; +import static com.google.common.collect.Lists.newArrayList; /** - * @author kimchy (shay.banon) + * */ public class AndFilterParser implements FilterParser { public static final String NAME = "and"; - @Inject public AndFilterParser() { + @Inject + public AndFilterParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME}; } - @Override public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); ArrayList filters = newArrayList(); diff --git a/src/main/java/org/elasticsearch/index/query/BaseFilterBuilder.java b/src/main/java/org/elasticsearch/index/query/BaseFilterBuilder.java index 822791abe6e..e30cd4130f7 100644 --- a/src/main/java/org/elasticsearch/index/query/BaseFilterBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/BaseFilterBuilder.java @@ -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,11 +24,12 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public abstract class BaseFilterBuilder implements FilterBuilder { - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); doXContent(builder, params); builder.endObject(); diff --git a/src/main/java/org/elasticsearch/index/query/BaseQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/BaseQueryBuilder.java index f77543da14d..e5bd7512624 100644 --- a/src/main/java/org/elasticsearch/index/query/BaseQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/BaseQueryBuilder.java @@ -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,11 +27,12 @@ import org.elasticsearch.common.xcontent.XContentType; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public abstract class BaseQueryBuilder implements QueryBuilder { - @Override public String toString() { + @Override + public String toString() { try { XContentBuilder builder = XContentFactory.jsonBuilder(); builder.prettyPrint(); @@ -42,11 +43,13 @@ public abstract class BaseQueryBuilder implements QueryBuilder { } } - @Override public BytesStream buildAsUnsafeBytes() throws QueryBuilderException { + @Override + public BytesStream buildAsUnsafeBytes() throws QueryBuilderException { return buildAsUnsafeBytes(XContentType.JSON); } - @Override public BytesStream buildAsUnsafeBytes(XContentType contentType) throws QueryBuilderException { + @Override + public BytesStream buildAsUnsafeBytes(XContentType contentType) throws QueryBuilderException { try { XContentBuilder builder = XContentFactory.contentBuilder(contentType); toXContent(builder, EMPTY_PARAMS); @@ -56,11 +59,13 @@ public abstract class BaseQueryBuilder implements QueryBuilder { } } - @Override public byte[] buildAsBytes() throws QueryBuilderException { + @Override + public byte[] buildAsBytes() throws QueryBuilderException { return buildAsBytes(XContentType.JSON); } - @Override public byte[] buildAsBytes(XContentType contentType) throws QueryBuilderException { + @Override + public byte[] buildAsBytes(XContentType contentType) throws QueryBuilderException { try { XContentBuilder builder = XContentFactory.contentBuilder(contentType); toXContent(builder, EMPTY_PARAMS); @@ -70,7 +75,8 @@ public abstract class BaseQueryBuilder implements QueryBuilder { } } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); doXContent(builder, params); builder.endObject(); diff --git a/src/main/java/org/elasticsearch/index/query/BoolFilterBuilder.java b/src/main/java/org/elasticsearch/index/query/BoolFilterBuilder.java index 418c84ac064..e24371ea04c 100644 --- a/src/main/java/org/elasticsearch/index/query/BoolFilterBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/BoolFilterBuilder.java @@ -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.util.ArrayList; /** * A filter that matches documents matching boolean combinations of other filters. * - * @author kimchy (shay.banon) + * */ public class BoolFilterBuilder extends BaseFilterBuilder { @@ -86,7 +86,8 @@ public class BoolFilterBuilder extends BaseFilterBuilder { return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject("bool"); for (Clause clause : clauses) { if (clause.occur == BooleanClause.Occur.MUST) { diff --git a/src/main/java/org/elasticsearch/index/query/BoolFilterParser.java b/src/main/java/org/elasticsearch/index/query/BoolFilterParser.java index db4d38cf832..5aa489ae4dc 100644 --- a/src/main/java/org/elasticsearch/index/query/BoolFilterParser.java +++ b/src/main/java/org/elasticsearch/index/query/BoolFilterParser.java @@ -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,20 +30,23 @@ import org.elasticsearch.index.cache.filter.support.CacheKeyFilter; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class BoolFilterParser implements FilterParser { public static final String NAME = "bool"; - @Inject public BoolFilterParser() { + @Inject + public BoolFilterParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME}; } - @Override public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); XBooleanFilter boolFilter = new XBooleanFilter(); diff --git a/src/main/java/org/elasticsearch/index/query/BoolQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/BoolQueryBuilder.java index 751af7a9518..df563ac9177 100644 --- a/src/main/java/org/elasticsearch/index/query/BoolQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/BoolQueryBuilder.java @@ -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.util.List; /** * A Query that matches documents matching boolean combinations of other queries. * - * @author kimchy (shay.banon) + * */ public class BoolQueryBuilder extends BaseQueryBuilder { @@ -91,11 +91,11 @@ public class BoolQueryBuilder extends BaseQueryBuilder { /** * Specifies a minimum number of the optional (should) boolean clauses which must be satisfied. - * + *

    *

    By default no optional clauses are necessary for a match * (unless there are no required clauses). If this method is used, * then the specified number of clauses is required. - * + *

    *

    Use of this method is totally independent of specifying that * any specific clauses are required (or prohibited). This number will * only be compared against the number of matching optional clauses. @@ -114,7 +114,8 @@ public class BoolQueryBuilder extends BaseQueryBuilder { return !mustClauses.isEmpty() || !mustNotClauses.isEmpty() || !shouldClauses.isEmpty(); } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject("bool"); doXArrayContent("must", mustClauses, builder, params); doXArrayContent("must_not", mustNotClauses, builder, params); diff --git a/src/main/java/org/elasticsearch/index/query/BoolQueryParser.java b/src/main/java/org/elasticsearch/index/query/BoolQueryParser.java index 47881b22952..eefa2914ab9 100644 --- a/src/main/java/org/elasticsearch/index/query/BoolQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/BoolQueryParser.java @@ -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,25 +29,29 @@ import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; import java.util.List; -import static org.elasticsearch.common.collect.Lists.*; -import static org.elasticsearch.common.lucene.search.Queries.*; +import static com.google.common.collect.Lists.newArrayList; +import static org.elasticsearch.common.lucene.search.Queries.fixNegativeQueryIfNeeded; +import static org.elasticsearch.common.lucene.search.Queries.optimizeQuery; /** - * @author kimchy (shay.banon) + * */ public class BoolQueryParser implements QueryParser { public static final String NAME = "bool"; - @Inject public BoolQueryParser(Settings settings) { + @Inject + public BoolQueryParser(Settings settings) { BooleanQuery.setMaxClauseCount(settings.getAsInt("index.query.bool.max_clause_count", BooleanQuery.getMaxClauseCount())); } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); boolean disableCoord = false; diff --git a/src/main/java/org/elasticsearch/index/query/BoostingQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/BoostingQueryBuilder.java index 23373ad9335..7987189d236 100644 --- a/src/main/java/org/elasticsearch/index/query/BoostingQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/BoostingQueryBuilder.java @@ -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 java.io.IOException; * The BoostingQuery class can be used to effectively demote results that match a given query. * Unlike the "NOT" clause, this still selects documents that contain undesirable terms, * but reduces their overall score: - * + *

    * Query balancedQuery = new BoostingQuery(positiveQuery, negativeQuery, 0.01f); * In this scenario the positiveQuery contains the mandatory, desirable criteria which is used to * select all matching documents, and the negativeQuery contains the undesirable elements which @@ -69,7 +69,8 @@ public class BoostingQueryBuilder extends BaseQueryBuilder { return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { if (positiveQuery == null) { throw new QueryBuilderException("boosting query requires positive query to be set"); } diff --git a/src/main/java/org/elasticsearch/index/query/BoostingQueryParser.java b/src/main/java/org/elasticsearch/index/query/BoostingQueryParser.java index 18430c23f7a..1c49c0947cb 100644 --- a/src/main/java/org/elasticsearch/index/query/BoostingQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/BoostingQueryParser.java @@ -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,14 +33,17 @@ public class BoostingQueryParser implements QueryParser { public static final String NAME = "boosting"; - @Inject public BoostingQueryParser() { + @Inject + public BoostingQueryParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); Query positiveQuery = null; diff --git a/src/main/java/org/elasticsearch/index/query/ConstantScoreQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/ConstantScoreQueryBuilder.java index 812fafe764c..ca54e735a33 100644 --- a/src/main/java/org/elasticsearch/index/query/ConstantScoreQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/ConstantScoreQueryBuilder.java @@ -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 java.io.IOException; * A query that wraps a filter and simply returns a constant score equal to the * query boost for every document in the filter. * - * @author kimchy (shay.banon) + * */ public class ConstantScoreQueryBuilder extends BaseQueryBuilder { @@ -54,7 +54,8 @@ public class ConstantScoreQueryBuilder extends BaseQueryBuilder { return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(ConstantScoreQueryParser.NAME); builder.field("filter"); filterBuilder.toXContent(builder, params); diff --git a/src/main/java/org/elasticsearch/index/query/ConstantScoreQueryParser.java b/src/main/java/org/elasticsearch/index/query/ConstantScoreQueryParser.java index 684738c0ae3..03114031e1c 100644 --- a/src/main/java/org/elasticsearch/index/query/ConstantScoreQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/ConstantScoreQueryParser.java @@ -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,20 +31,23 @@ import org.elasticsearch.index.cache.filter.support.CacheKeyFilter; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class ConstantScoreQueryParser implements QueryParser { public static final String NAME = "constant_score"; - @Inject public ConstantScoreQueryParser() { + @Inject + public ConstantScoreQueryParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME, Strings.toCamelCase(NAME)}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); Filter filter = null; diff --git a/src/main/java/org/elasticsearch/index/query/CustomBoostFactorQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/CustomBoostFactorQueryBuilder.java index c2e2585e6b4..eda5a8d0c6a 100644 --- a/src/main/java/org/elasticsearch/index/query/CustomBoostFactorQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/CustomBoostFactorQueryBuilder.java @@ -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.IOException; /** * A query that simply applies the boost factor to another query (multiply it). * - * @author kimchy (shay.banon) + * */ public class CustomBoostFactorQueryBuilder extends BaseQueryBuilder { @@ -51,7 +51,8 @@ public class CustomBoostFactorQueryBuilder extends BaseQueryBuilder { return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(CustomBoostFactorQueryParser.NAME); builder.field("query"); queryBuilder.toXContent(builder, params); diff --git a/src/main/java/org/elasticsearch/index/query/CustomBoostFactorQueryParser.java b/src/main/java/org/elasticsearch/index/query/CustomBoostFactorQueryParser.java index 92b97fa29ed..863718b24bc 100644 --- a/src/main/java/org/elasticsearch/index/query/CustomBoostFactorQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/CustomBoostFactorQueryParser.java @@ -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,20 +29,23 @@ import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class CustomBoostFactorQueryParser implements QueryParser { public static final String NAME = "custom_boost_factor"; - @Inject public CustomBoostFactorQueryParser() { + @Inject + public CustomBoostFactorQueryParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME, Strings.toCamelCase(NAME)}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); Query query = null; diff --git a/src/main/java/org/elasticsearch/index/query/CustomFiltersScoreQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/CustomFiltersScoreQueryBuilder.java index c4bb3fdda0c..4ec6da661ab 100644 --- a/src/main/java/org/elasticsearch/index/query/CustomFiltersScoreQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/CustomFiltersScoreQueryBuilder.java @@ -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.index.query; -import org.elasticsearch.common.collect.Maps; -import org.elasticsearch.common.trove.list.array.TFloatArrayList; +import com.google.common.collect.Maps; +import gnu.trove.list.array.TFloatArrayList; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; @@ -30,7 +30,7 @@ import java.util.Map; /** * A query that uses a filters with a script associated with them to compute the score. * - * @author kimchy (shay.banon) + * */ public class CustomFiltersScoreQueryBuilder extends BaseQueryBuilder { @@ -111,7 +111,8 @@ public class CustomFiltersScoreQueryBuilder extends BaseQueryBuilder { return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(CustomFiltersScoreQueryParser.NAME); builder.field("query"); queryBuilder.toXContent(builder, params); diff --git a/src/main/java/org/elasticsearch/index/query/CustomFiltersScoreQueryParser.java b/src/main/java/org/elasticsearch/index/query/CustomFiltersScoreQueryParser.java index 046cf68f44e..c2a95572008 100644 --- a/src/main/java/org/elasticsearch/index/query/CustomFiltersScoreQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/CustomFiltersScoreQueryParser.java @@ -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.index.query; +import gnu.trove.list.array.TFloatArrayList; import org.apache.lucene.search.Filter; import org.apache.lucene.search.Query; import org.elasticsearch.ElasticSearchIllegalStateException; @@ -27,7 +28,6 @@ import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.lucene.search.function.BoostScoreFunction; import org.elasticsearch.common.lucene.search.function.FiltersFunctionScoreQuery; import org.elasticsearch.common.lucene.search.function.ScoreFunction; -import org.elasticsearch.common.trove.list.array.TFloatArrayList; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.script.SearchScript; import org.elasticsearch.search.internal.SearchContext; @@ -37,20 +37,23 @@ import java.util.ArrayList; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class CustomFiltersScoreQueryParser implements QueryParser { public static final String NAME = "custom_filters_score"; - @Inject public CustomFiltersScoreQueryParser() { + @Inject + public CustomFiltersScoreQueryParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME, Strings.toCamelCase(NAME)}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); Query query = null; diff --git a/src/main/java/org/elasticsearch/index/query/CustomScoreQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/CustomScoreQueryBuilder.java index ac39474e275..819f5518522 100644 --- a/src/main/java/org/elasticsearch/index/query/CustomScoreQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/CustomScoreQueryBuilder.java @@ -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,7 +19,7 @@ package org.elasticsearch.index.query; -import org.elasticsearch.common.collect.Maps; +import com.google.common.collect.Maps; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; @@ -28,7 +28,7 @@ import java.util.Map; /** * A query that uses a script to compute the score. * - * @author kimchy (shay.banon) + * */ public class CustomScoreQueryBuilder extends BaseQueryBuilder { @@ -99,7 +99,8 @@ public class CustomScoreQueryBuilder extends BaseQueryBuilder { return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(CustomScoreQueryParser.NAME); builder.field("query"); queryBuilder.toXContent(builder, params); diff --git a/src/main/java/org/elasticsearch/index/query/CustomScoreQueryParser.java b/src/main/java/org/elasticsearch/index/query/CustomScoreQueryParser.java index f94ffd2f9b1..3741c71afe8 100644 --- a/src/main/java/org/elasticsearch/index/query/CustomScoreQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/CustomScoreQueryParser.java @@ -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,20 +35,23 @@ import java.io.IOException; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class CustomScoreQueryParser implements QueryParser { public static final String NAME = "custom_score"; - @Inject public CustomScoreQueryParser() { + @Inject + public CustomScoreQueryParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME, Strings.toCamelCase(NAME)}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); Query query = null; @@ -109,24 +112,28 @@ public class CustomScoreQueryParser implements QueryParser { this.script = script; } - @Override public void setNextReader(IndexReader reader) { + @Override + public void setNextReader(IndexReader reader) { script.setNextReader(reader); } - @Override public float score(int docId, float subQueryScore) { + @Override + public float score(int docId, float subQueryScore) { script.setNextDocId(docId); script.setNextScore(subQueryScore); return script.runAsFloat(); } - @Override public Explanation explain(int docId, Explanation subQueryExpl) { + @Override + public Explanation explain(int docId, Explanation subQueryExpl) { float score = score(docId, subQueryExpl.getValue()); Explanation exp = new Explanation(score, "script score function: product of:"); exp.addDetail(subQueryExpl); return exp; } - @Override public String toString() { + @Override + public String toString() { return "script[" + sScript + "], params [" + params + "]"; } } diff --git a/src/main/java/org/elasticsearch/index/query/DisMaxQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/DisMaxQueryBuilder.java index 682e4b6eb71..1eed06ed1e0 100644 --- a/src/main/java/org/elasticsearch/index/query/DisMaxQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/DisMaxQueryBuilder.java @@ -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,14 +24,14 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; import java.util.ArrayList; -import static org.elasticsearch.common.collect.Lists.*; +import static com.google.common.collect.Lists.newArrayList; /** * A query that generates the union of documents produced by its sub-queries, and that scores each document * with the maximum score for that document as produced by any sub-query, plus a tie breaking increment for any * additional matching sub-queries. * - * @author kimchy (shay.banon) + * */ public class DisMaxQueryBuilder extends BaseQueryBuilder { @@ -69,7 +69,8 @@ public class DisMaxQueryBuilder extends BaseQueryBuilder { return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(DisMaxQueryParser.NAME); if (tieBreaker != -1) { builder.field("tie_breaker", tieBreaker); diff --git a/src/main/java/org/elasticsearch/index/query/DisMaxQueryParser.java b/src/main/java/org/elasticsearch/index/query/DisMaxQueryParser.java index 337835d8a93..8618dfd3d22 100644 --- a/src/main/java/org/elasticsearch/index/query/DisMaxQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/DisMaxQueryParser.java @@ -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,23 +28,26 @@ import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; import java.util.List; -import static org.elasticsearch.common.collect.Lists.*; +import static com.google.common.collect.Lists.newArrayList; /** - * @author kimchy (shay.banon) + * */ public class DisMaxQueryParser implements QueryParser { public static final String NAME = "dis_max"; - @Inject public DisMaxQueryParser() { + @Inject + public DisMaxQueryParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME, Strings.toCamelCase(NAME)}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); float boost = 1.0f; diff --git a/src/main/java/org/elasticsearch/index/query/ExistsFilterBuilder.java b/src/main/java/org/elasticsearch/index/query/ExistsFilterBuilder.java index 3c9a29c43fc..bdda5b84e10 100644 --- a/src/main/java/org/elasticsearch/index/query/ExistsFilterBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/ExistsFilterBuilder.java @@ -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.IOException; /** * Constructs a filter that only match on documents that the field has a value in them. * - * @author kimchy (shay.banon) + * */ public class ExistsFilterBuilder extends BaseFilterBuilder { @@ -47,7 +47,8 @@ public class ExistsFilterBuilder extends BaseFilterBuilder { } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(ExistsFilterParser.NAME); builder.field("field", name); if (filterName != null) { diff --git a/src/main/java/org/elasticsearch/index/query/ExistsFilterParser.java b/src/main/java/org/elasticsearch/index/query/ExistsFilterParser.java index 3156c23a334..e8613ae2f93 100644 --- a/src/main/java/org/elasticsearch/index/query/ExistsFilterParser.java +++ b/src/main/java/org/elasticsearch/index/query/ExistsFilterParser.java @@ -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,23 +27,26 @@ import org.elasticsearch.index.mapper.MapperService; import java.io.IOException; -import static org.elasticsearch.index.query.support.QueryParsers.*; +import static org.elasticsearch.index.query.support.QueryParsers.wrapSmartNameFilter; /** - * @author kimchy (shay.banon) + * */ public class ExistsFilterParser implements FilterParser { public static final String NAME = "exists"; - @Inject public ExistsFilterParser() { + @Inject + public ExistsFilterParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME}; } - @Override public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); String fieldName = null; diff --git a/src/main/java/org/elasticsearch/index/query/FQueryFilterParser.java b/src/main/java/org/elasticsearch/index/query/FQueryFilterParser.java index 57f3c8560c4..27499c957c1 100644 --- a/src/main/java/org/elasticsearch/index/query/FQueryFilterParser.java +++ b/src/main/java/org/elasticsearch/index/query/FQueryFilterParser.java @@ -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,20 +32,23 @@ import java.io.IOException; * The "fquery" filter is the same as the {@link QueryFilterParser} except that it allows also to * associate a name with the query filter. * - * @author kimchy (shay.banon) + * */ public class FQueryFilterParser implements FilterParser { public static final String NAME = "fquery"; - @Inject public FQueryFilterParser() { + @Inject + public FQueryFilterParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME}; } - @Override public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); Query query = null; diff --git a/src/main/java/org/elasticsearch/index/query/FieldMaskingSpanQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/FieldMaskingSpanQueryBuilder.java index 781621bc116..e9d7aed2444 100644 --- a/src/main/java/org/elasticsearch/index/query/FieldMaskingSpanQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/FieldMaskingSpanQueryBuilder.java @@ -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.common.xcontent.XContentBuilder; import java.io.IOException; /** - * @author kimchy (Shay Banon) + * */ public class FieldMaskingSpanQueryBuilder extends BaseQueryBuilder implements SpanQueryBuilder { @@ -44,7 +44,8 @@ public class FieldMaskingSpanQueryBuilder extends BaseQueryBuilder implements Sp return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(FieldMaskingSpanQueryParser.NAME); builder.field("query"); queryBuilder.toXContent(builder, params); diff --git a/src/main/java/org/elasticsearch/index/query/FieldMaskingSpanQueryParser.java b/src/main/java/org/elasticsearch/index/query/FieldMaskingSpanQueryParser.java index 2661f98ff88..624f03ecc46 100644 --- a/src/main/java/org/elasticsearch/index/query/FieldMaskingSpanQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/FieldMaskingSpanQueryParser.java @@ -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,20 +30,23 @@ import org.elasticsearch.index.mapper.FieldMapper; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class FieldMaskingSpanQueryParser implements QueryParser { public static final String NAME = "field_masking_span"; - @Inject public FieldMaskingSpanQueryParser() { + @Inject + public FieldMaskingSpanQueryParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME, Strings.toCamelCase(NAME)}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); float boost = 1.0f; diff --git a/src/main/java/org/elasticsearch/index/query/FieldQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/FieldQueryBuilder.java index 44e5b92ab24..46db66c38a3 100644 --- a/src/main/java/org/elasticsearch/index/query/FieldQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/FieldQueryBuilder.java @@ -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; * version of {@link QueryStringQueryBuilder} that simply runs against * a single field. * - * @author kimchy (shay.banon) + * */ public class FieldQueryBuilder extends BaseQueryBuilder { @@ -166,11 +166,11 @@ public class FieldQueryBuilder extends BaseQueryBuilder { /** * Sets the boolean operator of the query parser used to parse the query string. - * + *

    *

    In default mode ({@link FieldQueryBuilder.Operator#OR}) terms without any modifiers * are considered optional: for example capital of Hungary is equal to * capital OR of OR Hungary. - * + *

    *

    In {@link FieldQueryBuilder.Operator#AND} mode terms are considered to be in conjunction: the * above mentioned query is parsed as capital AND of AND Hungary */ @@ -195,7 +195,7 @@ public class FieldQueryBuilder extends BaseQueryBuilder { * when the analyzer returns more than one term from whitespace * delimited text. * NOTE: this behavior may not be suitable for all languages. - *

    + *

    * Set to false if phrase queries should only be generated when * surrounded by double quotes. */ @@ -225,7 +225,7 @@ public class FieldQueryBuilder extends BaseQueryBuilder { /** * Set to true to enable position increments in result query. Defaults to * true. - * + *

    *

    When set, result phrase and multi-phrase queries will be aware of position increments. * Useful when e.g. a StopFilter increases the position increment of the token that follows an omitted token. */ @@ -283,7 +283,8 @@ public class FieldQueryBuilder extends BaseQueryBuilder { return this; } - @Override public void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(FieldQueryParser.NAME); if (!extraSet) { builder.field(name, query); diff --git a/src/main/java/org/elasticsearch/index/query/FieldQueryParser.java b/src/main/java/org/elasticsearch/index/query/FieldQueryParser.java index 670c525672c..4c5a768100b 100644 --- a/src/main/java/org/elasticsearch/index/query/FieldQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/FieldQueryParser.java @@ -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,23 +31,27 @@ import org.elasticsearch.index.query.support.QueryParsers; import java.io.IOException; -import static org.elasticsearch.common.lucene.search.Queries.*; +import static org.elasticsearch.common.lucene.search.Queries.fixNegativeQueryIfNeeded; +import static org.elasticsearch.common.lucene.search.Queries.optimizeQuery; /** - * @author kimchy (shay.banon) + * */ public class FieldQueryParser implements QueryParser { public static final String NAME = "field"; - @Inject public FieldQueryParser() { + @Inject + public FieldQueryParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); XContentParser.Token token = parser.nextToken(); diff --git a/src/main/java/org/elasticsearch/index/query/FilterBuilder.java b/src/main/java/org/elasticsearch/index/query/FilterBuilder.java index fe0324e468c..fcdcf20b0c4 100644 --- a/src/main/java/org/elasticsearch/index/query/FilterBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/FilterBuilder.java @@ -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.index.query; import org.elasticsearch.common.xcontent.ToXContent; /** - * @author kimchy (shay.banon) + * */ public interface FilterBuilder extends ToXContent { diff --git a/src/main/java/org/elasticsearch/index/query/FilterBuilders.java b/src/main/java/org/elasticsearch/index/query/FilterBuilders.java index ecad418f145..9c9a759196f 100644 --- a/src/main/java/org/elasticsearch/index/query/FilterBuilders.java +++ b/src/main/java/org/elasticsearch/index/query/FilterBuilders.java @@ -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.common.Nullable; /** * A static factory for simple "import static" usage. * - * @author kimchy (shay.banon) + * */ public abstract class FilterBuilders { diff --git a/src/main/java/org/elasticsearch/index/query/FilterParser.java b/src/main/java/org/elasticsearch/index/query/FilterParser.java index a269429758f..2acc261dba6 100644 --- a/src/main/java/org/elasticsearch/index/query/FilterParser.java +++ b/src/main/java/org/elasticsearch/index/query/FilterParser.java @@ -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.Filter; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public interface FilterParser { diff --git a/src/main/java/org/elasticsearch/index/query/FilterParserFactory.java b/src/main/java/org/elasticsearch/index/query/FilterParserFactory.java index b05d17a64f7..69d86b463c4 100644 --- a/src/main/java/org/elasticsearch/index/query/FilterParserFactory.java +++ b/src/main/java/org/elasticsearch/index/query/FilterParserFactory.java @@ -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.index.query; import org.elasticsearch.common.settings.Settings; /** - * @author kimchy (shay.banon) + * */ public interface FilterParserFactory { diff --git a/src/main/java/org/elasticsearch/index/query/FilteredQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/FilteredQueryBuilder.java index 5f69ab7f42e..525262dceb3 100644 --- a/src/main/java/org/elasticsearch/index/query/FilteredQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/FilteredQueryBuilder.java @@ -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.IOException; /** * A query that applies a filter to the results of another query. * - * @author kimchy (shay.banon) + * */ public class FilteredQueryBuilder extends BaseQueryBuilder { @@ -56,7 +56,8 @@ public class FilteredQueryBuilder extends BaseQueryBuilder { return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(FilteredQueryParser.NAME); builder.field("query"); queryBuilder.toXContent(builder, params); diff --git a/src/main/java/org/elasticsearch/index/query/FilteredQueryParser.java b/src/main/java/org/elasticsearch/index/query/FilteredQueryParser.java index 0dea76b6341..808e083805e 100644 --- a/src/main/java/org/elasticsearch/index/query/FilteredQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/FilteredQueryParser.java @@ -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,20 +31,23 @@ import org.elasticsearch.index.cache.filter.support.CacheKeyFilter; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class FilteredQueryParser implements QueryParser { public static final String NAME = "filtered"; - @Inject public FilteredQueryParser() { + @Inject + public FilteredQueryParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); Query query = null; diff --git a/src/main/java/org/elasticsearch/index/query/FuzzyLikeThisFieldQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/FuzzyLikeThisFieldQueryBuilder.java index 7c43297ccae..11bc8d6e1fc 100644 --- a/src/main/java/org/elasticsearch/index/query/FuzzyLikeThisFieldQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/FuzzyLikeThisFieldQueryBuilder.java @@ -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.common.xcontent.XContentBuilder; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class FuzzyLikeThisFieldQueryBuilder extends BaseQueryBuilder { @@ -89,7 +89,8 @@ public class FuzzyLikeThisFieldQueryBuilder extends BaseQueryBuilder { return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(FuzzyLikeThisFieldQueryParser.NAME); builder.startObject(name); if (likeText == null) { diff --git a/src/main/java/org/elasticsearch/index/query/FuzzyLikeThisFieldQueryParser.java b/src/main/java/org/elasticsearch/index/query/FuzzyLikeThisFieldQueryParser.java index 5358edb2912..db24e45faa7 100644 --- a/src/main/java/org/elasticsearch/index/query/FuzzyLikeThisFieldQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/FuzzyLikeThisFieldQueryParser.java @@ -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.index.mapper.MapperService; import java.io.IOException; -import static org.elasticsearch.index.query.support.QueryParsers.*; +import static org.elasticsearch.index.query.support.QueryParsers.wrapSmartNameQuery; /** *

    @@ -43,20 +43,23 @@ import static org.elasticsearch.index.query.support.QueryParsers.*;
      * }
      * 
    * - * @author kimchy (shay.banon) + * */ public class FuzzyLikeThisFieldQueryParser implements QueryParser { public static final String NAME = "flt_field"; - @Inject public FuzzyLikeThisFieldQueryParser() { + @Inject + public FuzzyLikeThisFieldQueryParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME, "fuzzy_like_this_field", Strings.toCamelCase(NAME), "fuzzyLikeThisField"}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); int maxNumTerms = 25; diff --git a/src/main/java/org/elasticsearch/index/query/FuzzyLikeThisQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/FuzzyLikeThisQueryBuilder.java index 9c4a7cc7cd5..55724a9ede4 100644 --- a/src/main/java/org/elasticsearch/index/query/FuzzyLikeThisQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/FuzzyLikeThisQueryBuilder.java @@ -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.common.xcontent.XContentBuilder; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class FuzzyLikeThisQueryBuilder extends BaseQueryBuilder { @@ -96,7 +96,8 @@ public class FuzzyLikeThisQueryBuilder extends BaseQueryBuilder { return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(FuzzyLikeThisQueryParser.NAME); if (fields != null) { builder.startArray("fields"); diff --git a/src/main/java/org/elasticsearch/index/query/FuzzyLikeThisQueryParser.java b/src/main/java/org/elasticsearch/index/query/FuzzyLikeThisQueryParser.java index ad9ae0dc8cd..5cb0f9acb76 100644 --- a/src/main/java/org/elasticsearch/index/query/FuzzyLikeThisQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/FuzzyLikeThisQueryParser.java @@ -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.index.query; +import com.google.common.collect.Lists; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.search.FuzzyLikeThisQuery; import org.apache.lucene.search.Query; -import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.mapper.internal.AllFieldMapper; @@ -42,20 +42,23 @@ import java.util.List; * } * * - * @author kimchy (shay.banon) + * */ public class FuzzyLikeThisQueryParser implements QueryParser { public static final String NAME = "flt"; - @Inject public FuzzyLikeThisQueryParser() { + @Inject + public FuzzyLikeThisQueryParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME, "fuzzy_like_this", "fuzzyLikeThis"}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); int maxNumTerms = 25; diff --git a/src/main/java/org/elasticsearch/index/query/FuzzyQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/FuzzyQueryBuilder.java index f1215f5200c..1b2bf38a067 100644 --- a/src/main/java/org/elasticsearch/index/query/FuzzyQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/FuzzyQueryBuilder.java @@ -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.IOException; /** * A Query that does fuzzy matching for a specific value. * - * @author kimchy (shay.banon) + * */ public class FuzzyQueryBuilder extends BaseQueryBuilder { @@ -75,7 +75,8 @@ public class FuzzyQueryBuilder extends BaseQueryBuilder { return this; } - @Override public void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(FuzzyQueryParser.NAME); if (boost == -1 && minSimilarity == null && prefixLength == null) { builder.field(name, value); diff --git a/src/main/java/org/elasticsearch/index/query/FuzzyQueryParser.java b/src/main/java/org/elasticsearch/index/query/FuzzyQueryParser.java index a6778825b52..1f57c03319b 100644 --- a/src/main/java/org/elasticsearch/index/query/FuzzyQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/FuzzyQueryParser.java @@ -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,23 +28,26 @@ import org.elasticsearch.index.mapper.MapperService; import java.io.IOException; -import static org.elasticsearch.index.query.support.QueryParsers.*; +import static org.elasticsearch.index.query.support.QueryParsers.wrapSmartNameQuery; /** - * @author kimchy (shay.banon) + * */ public class FuzzyQueryParser implements QueryParser { public static final String NAME = "fuzzy"; - @Inject public FuzzyQueryParser() { + @Inject + public FuzzyQueryParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); XContentParser.Token token = parser.nextToken(); diff --git a/src/main/java/org/elasticsearch/index/query/GeoBoundingBoxFilterBuilder.java b/src/main/java/org/elasticsearch/index/query/GeoBoundingBoxFilterBuilder.java index db8204c6861..0c141a6e911 100644 --- a/src/main/java/org/elasticsearch/index/query/GeoBoundingBoxFilterBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/GeoBoundingBoxFilterBuilder.java @@ -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.index.search.geo.Point; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class GeoBoundingBoxFilterBuilder extends BaseFilterBuilder { @@ -116,7 +116,8 @@ public class GeoBoundingBoxFilterBuilder extends BaseFilterBuilder { return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(GeoBoundingBoxFilterParser.NAME); builder.startObject(name); diff --git a/src/main/java/org/elasticsearch/index/query/GeoBoundingBoxFilterParser.java b/src/main/java/org/elasticsearch/index/query/GeoBoundingBoxFilterParser.java index 04f0dd1130d..a17861a33e1 100644 --- a/src/main/java/org/elasticsearch/index/query/GeoBoundingBoxFilterParser.java +++ b/src/main/java/org/elasticsearch/index/query/GeoBoundingBoxFilterParser.java @@ -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,31 +26,30 @@ import org.elasticsearch.index.cache.filter.support.CacheKeyFilter; import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.geo.GeoPointFieldMapper; -import org.elasticsearch.index.search.geo.GeoHashUtils; -import org.elasticsearch.index.search.geo.GeoUtils; -import org.elasticsearch.index.search.geo.InMemoryGeoBoundingBoxFilter; -import org.elasticsearch.index.search.geo.IndexedGeoBoundingBoxFilter; -import org.elasticsearch.index.search.geo.Point; +import org.elasticsearch.index.search.geo.*; import java.io.IOException; -import static org.elasticsearch.index.query.support.QueryParsers.*; +import static org.elasticsearch.index.query.support.QueryParsers.wrapSmartNameFilter; /** - * @author kimchy (shay.banon) + * */ public class GeoBoundingBoxFilterParser implements FilterParser { public static final String NAME = "geo_bbox"; - @Inject public GeoBoundingBoxFilterParser() { + @Inject + public GeoBoundingBoxFilterParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME, "geoBbox", "geo_bounding_box", "geoBoundingBox"}; } - @Override public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); boolean cache = false; diff --git a/src/main/java/org/elasticsearch/index/query/GeoDistanceFilterBuilder.java b/src/main/java/org/elasticsearch/index/query/GeoDistanceFilterBuilder.java index ef3cd4b34ed..9ebce3b95c0 100644 --- a/src/main/java/org/elasticsearch/index/query/GeoDistanceFilterBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/GeoDistanceFilterBuilder.java @@ -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.index.search.geo.GeoDistance; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class GeoDistanceFilterBuilder extends BaseFilterBuilder { @@ -115,7 +115,8 @@ public class GeoDistanceFilterBuilder extends BaseFilterBuilder { return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(GeoDistanceFilterParser.NAME); if (geohash != null) { builder.field(name, geohash); diff --git a/src/main/java/org/elasticsearch/index/query/GeoDistanceFilterParser.java b/src/main/java/org/elasticsearch/index/query/GeoDistanceFilterParser.java index 46bbd8e4d26..f03c5109598 100644 --- a/src/main/java/org/elasticsearch/index/query/GeoDistanceFilterParser.java +++ b/src/main/java/org/elasticsearch/index/query/GeoDistanceFilterParser.java @@ -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.index.search.geo.GeoUtils; import java.io.IOException; -import static org.elasticsearch.index.query.support.QueryParsers.*; +import static org.elasticsearch.index.query.support.QueryParsers.wrapSmartNameFilter; /** *
    @@ -45,20 +45,23 @@ import static org.elasticsearch.index.query.support.QueryParsers.*;
      * }
      * 
    * - * @author kimchy (shay.banon) + * */ public class GeoDistanceFilterParser implements FilterParser { public static final String NAME = "geo_distance"; - @Inject public GeoDistanceFilterParser() { + @Inject + public GeoDistanceFilterParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME, "geoDistance"}; } - @Override public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); XContentParser.Token token; diff --git a/src/main/java/org/elasticsearch/index/query/GeoDistanceRangeFilterBuilder.java b/src/main/java/org/elasticsearch/index/query/GeoDistanceRangeFilterBuilder.java index d3e32e2e135..4bbe6145c9a 100644 --- a/src/main/java/org/elasticsearch/index/query/GeoDistanceRangeFilterBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/GeoDistanceRangeFilterBuilder.java @@ -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.index.search.geo.GeoDistance; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class GeoDistanceRangeFilterBuilder extends BaseFilterBuilder { @@ -151,7 +151,8 @@ public class GeoDistanceRangeFilterBuilder extends BaseFilterBuilder { return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(GeoDistanceRangeFilterParser.NAME); if (geohash != null) { builder.field(name, geohash); diff --git a/src/main/java/org/elasticsearch/index/query/GeoDistanceRangeFilterParser.java b/src/main/java/org/elasticsearch/index/query/GeoDistanceRangeFilterParser.java index 1ba878978fe..a8823dce28d 100644 --- a/src/main/java/org/elasticsearch/index/query/GeoDistanceRangeFilterParser.java +++ b/src/main/java/org/elasticsearch/index/query/GeoDistanceRangeFilterParser.java @@ -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.index.search.geo.GeoUtils; import java.io.IOException; -import static org.elasticsearch.index.query.support.QueryParsers.*; +import static org.elasticsearch.index.query.support.QueryParsers.wrapSmartNameFilter; /** *
    @@ -45,20 +45,23 @@ import static org.elasticsearch.index.query.support.QueryParsers.*;
      * }
      * 
    * - * @author kimchy (shay.banon) + * */ public class GeoDistanceRangeFilterParser implements FilterParser { public static final String NAME = "geo_distance_range"; - @Inject public GeoDistanceRangeFilterParser() { + @Inject + public GeoDistanceRangeFilterParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME, "geoDistanceRange"}; } - @Override public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); XContentParser.Token token; diff --git a/src/main/java/org/elasticsearch/index/query/GeoPolygonFilterBuilder.java b/src/main/java/org/elasticsearch/index/query/GeoPolygonFilterBuilder.java index 1d6ea246d63..d622307a872 100644 --- a/src/main/java/org/elasticsearch/index/query/GeoPolygonFilterBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/GeoPolygonFilterBuilder.java @@ -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,7 +19,7 @@ package org.elasticsearch.index.query; -import org.elasticsearch.common.collect.Lists; +import com.google.common.collect.Lists; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.index.search.geo.GeoHashUtils; import org.elasticsearch.index.search.geo.Point; @@ -28,7 +28,7 @@ import java.io.IOException; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class GeoPolygonFilterBuilder extends BaseFilterBuilder { @@ -83,7 +83,8 @@ public class GeoPolygonFilterBuilder extends BaseFilterBuilder { return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(GeoPolygonFilterParser.NAME); builder.startObject(name); diff --git a/src/main/java/org/elasticsearch/index/query/GeoPolygonFilterParser.java b/src/main/java/org/elasticsearch/index/query/GeoPolygonFilterParser.java index 2996b2386d1..620f7c2082d 100644 --- a/src/main/java/org/elasticsearch/index/query/GeoPolygonFilterParser.java +++ b/src/main/java/org/elasticsearch/index/query/GeoPolygonFilterParser.java @@ -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.index.query; +import com.google.common.collect.Lists; import org.apache.lucene.search.Filter; -import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.cache.filter.support.CacheKeyFilter; @@ -36,7 +36,7 @@ import org.elasticsearch.index.search.geo.Point; import java.io.IOException; import java.util.List; -import static org.elasticsearch.index.query.support.QueryParsers.*; +import static org.elasticsearch.index.query.support.QueryParsers.wrapSmartNameFilter; /** *
    @@ -50,20 +50,23 @@ import static org.elasticsearch.index.query.support.QueryParsers.*;
      * }
      * 
    * - * @author kimchy (shay.banon) + * */ public class GeoPolygonFilterParser implements FilterParser { public static final String NAME = "geo_polygon"; - @Inject public GeoPolygonFilterParser() { + @Inject + public GeoPolygonFilterParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME, "geoPolygon"}; } - @Override public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); boolean cache = false; diff --git a/src/main/java/org/elasticsearch/index/query/HasChildFilterBuilder.java b/src/main/java/org/elasticsearch/index/query/HasChildFilterBuilder.java index 0826a4e7eab..3b65784307a 100644 --- a/src/main/java/org/elasticsearch/index/query/HasChildFilterBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/HasChildFilterBuilder.java @@ -24,7 +24,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class HasChildFilterBuilder extends BaseFilterBuilder { @@ -54,7 +54,8 @@ public class HasChildFilterBuilder extends BaseFilterBuilder { return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(HasChildFilterParser.NAME); builder.field("query"); queryBuilder.toXContent(builder, params); diff --git a/src/main/java/org/elasticsearch/index/query/HasChildFilterParser.java b/src/main/java/org/elasticsearch/index/query/HasChildFilterParser.java index 6815a8fb1fb..fa9145517b6 100644 --- a/src/main/java/org/elasticsearch/index/query/HasChildFilterParser.java +++ b/src/main/java/org/elasticsearch/index/query/HasChildFilterParser.java @@ -32,20 +32,23 @@ import org.elasticsearch.search.internal.SearchContext; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class HasChildFilterParser implements FilterParser { public static final String NAME = "has_child"; - @Inject public HasChildFilterParser() { + @Inject + public HasChildFilterParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME, Strings.toCamelCase(NAME)}; } - @Override public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); Query query = null; diff --git a/src/main/java/org/elasticsearch/index/query/HasChildQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/HasChildQueryBuilder.java index 666855b5644..0e38f185eaf 100644 --- a/src/main/java/org/elasticsearch/index/query/HasChildQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/HasChildQueryBuilder.java @@ -24,7 +24,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class HasChildQueryBuilder extends BaseQueryBuilder { @@ -59,7 +59,8 @@ public class HasChildQueryBuilder extends BaseQueryBuilder { return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(HasChildQueryParser.NAME); builder.field("query"); queryBuilder.toXContent(builder, params); diff --git a/src/main/java/org/elasticsearch/index/query/HasChildQueryParser.java b/src/main/java/org/elasticsearch/index/query/HasChildQueryParser.java index 6e537c582bd..83eb356b58e 100644 --- a/src/main/java/org/elasticsearch/index/query/HasChildQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/HasChildQueryParser.java @@ -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,20 +32,23 @@ import org.elasticsearch.search.internal.SearchContext; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class HasChildQueryParser implements QueryParser { public static final String NAME = "has_child"; - @Inject public HasChildQueryParser() { + @Inject + public HasChildQueryParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME, Strings.toCamelCase(NAME)}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); Query query = null; diff --git a/src/main/java/org/elasticsearch/index/query/IdsFilterBuilder.java b/src/main/java/org/elasticsearch/index/query/IdsFilterBuilder.java index 3eb55ed05b3..479b6e971c8 100644 --- a/src/main/java/org/elasticsearch/index/query/IdsFilterBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/IdsFilterBuilder.java @@ -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 @@ -67,7 +67,8 @@ public class IdsFilterBuilder extends BaseFilterBuilder { return this; } - @Override public void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(IdsFilterParser.NAME); if (types != null) { if (types.size() == 1) { diff --git a/src/main/java/org/elasticsearch/index/query/IdsFilterParser.java b/src/main/java/org/elasticsearch/index/query/IdsFilterParser.java index ecd9019aef3..e1e6c27aa2a 100644 --- a/src/main/java/org/elasticsearch/index/query/IdsFilterParser.java +++ b/src/main/java/org/elasticsearch/index/query/IdsFilterParser.java @@ -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.index.query; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Iterables; import org.apache.lucene.search.Filter; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.Iterables; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.search.UidFilter; @@ -37,14 +37,17 @@ public class IdsFilterParser implements FilterParser { public static final String NAME = "ids"; - @Inject public IdsFilterParser() { + @Inject + public IdsFilterParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME}; } - @Override public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); List ids = new ArrayList(); diff --git a/src/main/java/org/elasticsearch/index/query/IdsQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/IdsQueryBuilder.java index 7e195c54c8c..56b4031137f 100644 --- a/src/main/java/org/elasticsearch/index/query/IdsQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/IdsQueryBuilder.java @@ -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 @@ -65,7 +65,8 @@ public class IdsQueryBuilder extends BaseQueryBuilder { return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(IdsQueryParser.NAME); if (types != null) { if (types.size() == 1) { diff --git a/src/main/java/org/elasticsearch/index/query/IdsQueryParser.java b/src/main/java/org/elasticsearch/index/query/IdsQueryParser.java index 058c34591ae..77566035808 100644 --- a/src/main/java/org/elasticsearch/index/query/IdsQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/IdsQueryParser.java @@ -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.index.query; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Iterables; import org.apache.lucene.search.ConstantScoreQuery; import org.apache.lucene.search.Query; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.Iterables; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.search.UidFilter; @@ -41,14 +41,17 @@ public class IdsQueryParser implements QueryParser { public static final String NAME = "ids"; - @Inject public IdsQueryParser() { + @Inject + public IdsQueryParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); List ids = new ArrayList(); diff --git a/src/main/java/org/elasticsearch/index/query/IndexQueryParserModule.java b/src/main/java/org/elasticsearch/index/query/IndexQueryParserModule.java index 3e7a36325ef..be404edb35b 100644 --- a/src/main/java/org/elasticsearch/index/query/IndexQueryParserModule.java +++ b/src/main/java/org/elasticsearch/index/query/IndexQueryParserModule.java @@ -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.index.query; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.collect.Maps; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.Scopes; import org.elasticsearch.common.inject.assistedinject.FactoryProvider; @@ -31,7 +31,7 @@ import java.util.LinkedList; import java.util.Map; /** - * @author kimchy (Shay Banon) + * */ public class IndexQueryParserModule extends AbstractModule { @@ -142,7 +142,8 @@ public class IndexQueryParserModule extends AbstractModule { return this; } - @Override protected void configure() { + @Override + protected void configure() { bind(IndexQueryParserService.class).asEagerSingleton(); diff --git a/src/main/java/org/elasticsearch/index/query/IndexQueryParserService.java b/src/main/java/org/elasticsearch/index/query/IndexQueryParserService.java index 03441901db7..1729808ca7e 100644 --- a/src/main/java/org/elasticsearch/index/query/IndexQueryParserService.java +++ b/src/main/java/org/elasticsearch/index/query/IndexQueryParserService.java @@ -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,11 +19,11 @@ package org.elasticsearch.index.query; +import com.google.common.collect.ImmutableMap; import org.apache.lucene.search.Filter; import org.apache.lucene.search.Query; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.io.BytesStream; import org.elasticsearch.common.settings.Settings; @@ -44,12 +44,12 @@ import java.io.IOException; import java.util.List; import java.util.Map; -import static org.elasticsearch.common.collect.Lists.*; -import static org.elasticsearch.common.collect.Maps.*; -import static org.elasticsearch.common.settings.ImmutableSettings.Builder.*; +import static com.google.common.collect.Lists.newArrayList; +import static com.google.common.collect.Maps.newHashMap; +import static org.elasticsearch.common.settings.ImmutableSettings.Builder.EMPTY_SETTINGS; /** - * @author kimchy (shay.banon) + * */ public class IndexQueryParserService extends AbstractIndexComponent { @@ -59,7 +59,8 @@ public class IndexQueryParserService extends AbstractIndexComponent { } private ThreadLocal cache = new ThreadLocal() { - @Override protected QueryParseContext initialValue() { + @Override + protected QueryParseContext initialValue() { return new QueryParseContext(index, IndexQueryParserService.this); } }; @@ -80,13 +81,14 @@ public class IndexQueryParserService extends AbstractIndexComponent { private final Map filterParsers; - @Inject public IndexQueryParserService(Index index, @IndexSettings Settings indexSettings, - IndicesQueriesRegistry indicesQueriesRegistry, - ScriptService scriptService, AnalysisService analysisService, - MapperService mapperService, IndexCache indexCache, IndexEngine indexEngine, - @Nullable SimilarityService similarityService, - @Nullable Map namedQueryParsers, - @Nullable Map namedFilterParsers) { + @Inject + public IndexQueryParserService(Index index, @IndexSettings Settings indexSettings, + IndicesQueriesRegistry indicesQueriesRegistry, + ScriptService scriptService, AnalysisService analysisService, + MapperService mapperService, IndexCache indexCache, IndexEngine indexEngine, + @Nullable SimilarityService similarityService, + @Nullable Map namedQueryParsers, + @Nullable Map namedFilterParsers) { super(index, indexSettings); this.scriptService = scriptService; this.analysisService = analysisService; diff --git a/src/main/java/org/elasticsearch/index/query/IndicesQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/IndicesQueryBuilder.java index 07d5e4755e8..b9399c5d529 100644 --- a/src/main/java/org/elasticsearch/index/query/IndicesQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/IndicesQueryBuilder.java @@ -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 @@ -57,7 +57,8 @@ public class IndicesQueryBuilder extends BaseQueryBuilder { return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(IndicesQueryParser.NAME); builder.field("query"); queryBuilder.toXContent(builder, params); diff --git a/src/main/java/org/elasticsearch/index/query/IndicesQueryParser.java b/src/main/java/org/elasticsearch/index/query/IndicesQueryParser.java index 5a2e3c3ec12..64fe629ee72 100644 --- a/src/main/java/org/elasticsearch/index/query/IndicesQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/IndicesQueryParser.java @@ -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.index.query; +import com.google.common.collect.Sets; import org.apache.lucene.search.Query; -import org.elasticsearch.common.collect.Sets; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.lucene.search.MatchNoDocsQuery; import org.elasticsearch.common.lucene.search.Queries; @@ -36,14 +36,17 @@ public class IndicesQueryParser implements QueryParser { public static final String NAME = "indices"; - @Inject public IndicesQueryParser() { + @Inject + public IndicesQueryParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); Query query = null; diff --git a/src/main/java/org/elasticsearch/index/query/LimitFilterBuilder.java b/src/main/java/org/elasticsearch/index/query/LimitFilterBuilder.java index 794f306c3ee..12e31d172a5 100644 --- a/src/main/java/org/elasticsearch/index/query/LimitFilterBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/LimitFilterBuilder.java @@ -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,7 +31,8 @@ public class LimitFilterBuilder extends BaseFilterBuilder { this.limit = limit; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(LimitFilterParser.NAME); builder.field("value", limit); builder.endObject(); diff --git a/src/main/java/org/elasticsearch/index/query/LimitFilterParser.java b/src/main/java/org/elasticsearch/index/query/LimitFilterParser.java index 340c3a8b6a0..ea1001a613e 100644 --- a/src/main/java/org/elasticsearch/index/query/LimitFilterParser.java +++ b/src/main/java/org/elasticsearch/index/query/LimitFilterParser.java @@ -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,14 +30,17 @@ public class LimitFilterParser implements FilterParser { public static final String NAME = "limit"; - @Inject public LimitFilterParser() { + @Inject + public LimitFilterParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME}; } - @Override public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); int limit = -1; diff --git a/src/main/java/org/elasticsearch/index/query/MatchAllFilterBuilder.java b/src/main/java/org/elasticsearch/index/query/MatchAllFilterBuilder.java index 06d3feabf71..e51ccd28831 100644 --- a/src/main/java/org/elasticsearch/index/query/MatchAllFilterBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/MatchAllFilterBuilder.java @@ -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.IOException; /** * A filter that simply wraps a query. * - * @author kimchy (shay.banon) + * */ public class MatchAllFilterBuilder extends BaseFilterBuilder { @@ -36,7 +36,8 @@ public class MatchAllFilterBuilder extends BaseFilterBuilder { public MatchAllFilterBuilder() { } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(MatchAllFilterParser.NAME).endObject(); } } diff --git a/src/main/java/org/elasticsearch/index/query/MatchAllFilterParser.java b/src/main/java/org/elasticsearch/index/query/MatchAllFilterParser.java index 9aa74c3f50f..bafb81489af 100644 --- a/src/main/java/org/elasticsearch/index/query/MatchAllFilterParser.java +++ b/src/main/java/org/elasticsearch/index/query/MatchAllFilterParser.java @@ -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,20 +28,23 @@ import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class MatchAllFilterParser implements FilterParser { public static final String NAME = "match_all"; - @Inject public MatchAllFilterParser() { + @Inject + public MatchAllFilterParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME, Strings.toCamelCase(NAME)}; } - @Override public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); XContentParser.Token token; diff --git a/src/main/java/org/elasticsearch/index/query/MatchAllQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/MatchAllQueryBuilder.java index 1ebd889a3aa..d96308da046 100644 --- a/src/main/java/org/elasticsearch/index/query/MatchAllQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/MatchAllQueryBuilder.java @@ -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.IOException; /** * A query that matches on all documents. * - * @author kimchy (shay.banon) + * */ public class MatchAllQueryBuilder extends BaseQueryBuilder { @@ -51,7 +51,8 @@ public class MatchAllQueryBuilder extends BaseQueryBuilder { return this; } - @Override public void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(MatchAllQueryParser.NAME); if (boost != -1) { builder.field("boost", boost); diff --git a/src/main/java/org/elasticsearch/index/query/MatchAllQueryParser.java b/src/main/java/org/elasticsearch/index/query/MatchAllQueryParser.java index 45e9f4e8ef9..ab8dde26c88 100644 --- a/src/main/java/org/elasticsearch/index/query/MatchAllQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/MatchAllQueryParser.java @@ -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,20 +29,23 @@ import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class MatchAllQueryParser implements QueryParser { public static final String NAME = "match_all"; - @Inject public MatchAllQueryParser() { + @Inject + public MatchAllQueryParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME, Strings.toCamelCase(NAME)}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); float boost = 1.0f; diff --git a/src/main/java/org/elasticsearch/index/query/MissingFilterBuilder.java b/src/main/java/org/elasticsearch/index/query/MissingFilterBuilder.java index 55b9d36d2b6..28ccd656b61 100644 --- a/src/main/java/org/elasticsearch/index/query/MissingFilterBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/MissingFilterBuilder.java @@ -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.IOException; /** * Constructs a filter that only match on documents that the field has a value in them. * - * @author kimchy (shay.banon) + * */ public class MissingFilterBuilder extends BaseFilterBuilder { @@ -47,7 +47,8 @@ public class MissingFilterBuilder extends BaseFilterBuilder { } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(MissingFilterParser.NAME); builder.field("field", name); if (filterName != null) { diff --git a/src/main/java/org/elasticsearch/index/query/MissingFilterParser.java b/src/main/java/org/elasticsearch/index/query/MissingFilterParser.java index 9c98f7437fc..2bddd1163da 100644 --- a/src/main/java/org/elasticsearch/index/query/MissingFilterParser.java +++ b/src/main/java/org/elasticsearch/index/query/MissingFilterParser.java @@ -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,23 +28,26 @@ import org.elasticsearch.index.mapper.MapperService; import java.io.IOException; -import static org.elasticsearch.index.query.support.QueryParsers.*; +import static org.elasticsearch.index.query.support.QueryParsers.wrapSmartNameFilter; /** - * @author kimchy (shay.banon) + * */ public class MissingFilterParser implements FilterParser { public static final String NAME = "missing"; - @Inject public MissingFilterParser() { + @Inject + public MissingFilterParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME}; } - @Override public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); String fieldName = null; diff --git a/src/main/java/org/elasticsearch/index/query/MoreLikeThisFieldQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/MoreLikeThisFieldQueryBuilder.java index f7982910f87..33761f4cc10 100644 --- a/src/main/java/org/elasticsearch/index/query/MoreLikeThisFieldQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/MoreLikeThisFieldQueryBuilder.java @@ -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.IOException; /** * A more like this query that runs against a specific field. * - * @author kimchy (shay.banon) + * */ public class MoreLikeThisFieldQueryBuilder extends BaseQueryBuilder { @@ -90,7 +90,7 @@ public class MoreLikeThisFieldQueryBuilder extends BaseQueryBuilder { /** * Set the set of stopwords. - * + *

    *

    Any word in this set is considered "uninteresting" and ignored. Even if your Analyzer allows stopwords, you * might want to tell the MoreLikeThis code to ignore them, as for the purposes of document similarity it seems * reasonable to assume that "a stop word is never interesting". @@ -157,7 +157,8 @@ public class MoreLikeThisFieldQueryBuilder extends BaseQueryBuilder { return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(MoreLikeThisFieldQueryParser.NAME); builder.startObject(name); if (likeText == null) { diff --git a/src/main/java/org/elasticsearch/index/query/MoreLikeThisFieldQueryParser.java b/src/main/java/org/elasticsearch/index/query/MoreLikeThisFieldQueryParser.java index bb6424ae785..1eddb00cb99 100644 --- a/src/main/java/org/elasticsearch/index/query/MoreLikeThisFieldQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/MoreLikeThisFieldQueryParser.java @@ -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.index.query; +import com.google.common.collect.Sets; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.search.Query; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.collect.Sets; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.lucene.search.MoreLikeThisQuery; import org.elasticsearch.common.xcontent.XContentParser; @@ -31,23 +31,26 @@ import org.elasticsearch.index.mapper.MapperService; import java.io.IOException; import java.util.Set; -import static org.elasticsearch.index.query.support.QueryParsers.*; +import static org.elasticsearch.index.query.support.QueryParsers.wrapSmartNameQuery; /** - * @author kimchy (shay.banon) + * */ public class MoreLikeThisFieldQueryParser implements QueryParser { public static final String NAME = "mlt_field"; - @Inject public MoreLikeThisFieldQueryParser() { + @Inject + public MoreLikeThisFieldQueryParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME, "more_like_this_field", Strings.toCamelCase(NAME), "moreLikeThisField"}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); XContentParser.Token token = parser.nextToken(); diff --git a/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilder.java index fd138b5e3f1..5b1b4b282b9 100644 --- a/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilder.java @@ -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 java.io.IOException; * A more like this query that finds documents that are "like" the provided {@link #likeText(String)} * which is checked against the fields the query is constructed with. * - * @author kimchy (shay.banon) + * */ public class MoreLikeThisQueryBuilder extends BaseQueryBuilder { @@ -98,7 +98,7 @@ public class MoreLikeThisQueryBuilder extends BaseQueryBuilder { /** * Set the set of stopwords. - * + *

    *

    Any word in this set is considered "uninteresting" and ignored. Even if your Analyzer allows stopwords, you * might want to tell the MoreLikeThis code to ignore them, as for the purposes of document similarity it seems * reasonable to assume that "a stop word is never interesting". @@ -165,7 +165,8 @@ public class MoreLikeThisQueryBuilder extends BaseQueryBuilder { return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(MoreLikeThisQueryParser.NAME); if (fields != null) { builder.startArray("fields"); diff --git a/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryParser.java b/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryParser.java index f62747da69b..34241bdbbcd 100644 --- a/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryParser.java @@ -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.index.query; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.search.Query; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.collect.Sets; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.lucene.search.MoreLikeThisQuery; import org.elasticsearch.common.xcontent.XContentParser; @@ -33,20 +33,23 @@ import java.util.List; import java.util.Set; /** - * @author kimchy (shay.banon) + * */ public class MoreLikeThisQueryParser implements QueryParser { public static final String NAME = "mlt"; - @Inject public MoreLikeThisQueryParser() { + @Inject + public MoreLikeThisQueryParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME, "more_like_this", "moreLikeThis"}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); MoreLikeThisQuery mltQuery = new MoreLikeThisQuery(); diff --git a/src/main/java/org/elasticsearch/index/query/NestedFilterBuilder.java b/src/main/java/org/elasticsearch/index/query/NestedFilterBuilder.java index 7b8868e8d01..b9306028918 100644 --- a/src/main/java/org/elasticsearch/index/query/NestedFilterBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/NestedFilterBuilder.java @@ -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 @@ -75,7 +75,8 @@ public class NestedFilterBuilder extends BaseFilterBuilder { return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(NestedFilterParser.NAME); if (queryBuilder != null) { builder.field("query"); diff --git a/src/main/java/org/elasticsearch/index/query/NestedFilterParser.java b/src/main/java/org/elasticsearch/index/query/NestedFilterParser.java index fce19c47587..712f5c017db 100644 --- a/src/main/java/org/elasticsearch/index/query/NestedFilterParser.java +++ b/src/main/java/org/elasticsearch/index/query/NestedFilterParser.java @@ -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,11 +19,7 @@ package org.elasticsearch.index.query; -import org.apache.lucene.search.DeletionAwareConstantScoreQuery; -import org.apache.lucene.search.Filter; -import org.apache.lucene.search.FilteredQuery; -import org.apache.lucene.search.Query; -import org.apache.lucene.search.QueryWrapperFilter; +import org.apache.lucene.search.*; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; @@ -40,14 +36,17 @@ public class NestedFilterParser implements FilterParser { public static final String NAME = "nested"; - @Inject public NestedFilterParser() { + @Inject + public NestedFilterParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME, Strings.toCamelCase(NAME)}; } - @Override public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); Query query = null; diff --git a/src/main/java/org/elasticsearch/index/query/NestedQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/NestedQueryBuilder.java index b38acfe093d..c0aa187514d 100644 --- a/src/main/java/org/elasticsearch/index/query/NestedQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/NestedQueryBuilder.java @@ -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 @@ -70,7 +70,8 @@ public class NestedQueryBuilder extends BaseQueryBuilder { return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(NestedQueryParser.NAME); if (queryBuilder != null) { builder.field("query"); diff --git a/src/main/java/org/elasticsearch/index/query/NestedQueryParser.java b/src/main/java/org/elasticsearch/index/query/NestedQueryParser.java index c258f8bd981..8b515b6962d 100644 --- a/src/main/java/org/elasticsearch/index/query/NestedQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/NestedQueryParser.java @@ -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,11 +20,7 @@ package org.elasticsearch.index.query; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.search.DeletionAwareConstantScoreQuery; -import org.apache.lucene.search.DocIdSet; -import org.apache.lucene.search.Filter; -import org.apache.lucene.search.FilteredQuery; -import org.apache.lucene.search.Query; +import org.apache.lucene.search.*; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; @@ -40,14 +36,17 @@ public class NestedQueryParser implements QueryParser { public static final String NAME = "nested"; - @Inject public NestedQueryParser() { + @Inject + public NestedQueryParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME, Strings.toCamelCase(NAME)}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); Query query = null; @@ -154,19 +153,23 @@ public class NestedQueryParser implements QueryParser { Filter filter; - @Override public int hashCode() { + @Override + public int hashCode() { return filter.hashCode(); } - @Override public boolean equals(Object obj) { + @Override + public boolean equals(Object obj) { return filter.equals(obj); } - @Override public String toString() { + @Override + public String toString() { return filter.toString(); } - @Override public DocIdSet getDocIdSet(IndexReader reader) throws IOException { + @Override + public DocIdSet getDocIdSet(IndexReader reader) throws IOException { return filter.getDocIdSet(reader); } } diff --git a/src/main/java/org/elasticsearch/index/query/NotFilterBuilder.java b/src/main/java/org/elasticsearch/index/query/NotFilterBuilder.java index 899a7a22e65..ccf05f8fa90 100644 --- a/src/main/java/org/elasticsearch/index/query/NotFilterBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/NotFilterBuilder.java @@ -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.IOException; /** * A filter that matches documents matching boolean combinations of other filters. * - * @author kimchy (shay.banon) + * */ public class NotFilterBuilder extends BaseFilterBuilder { @@ -53,7 +53,8 @@ public class NotFilterBuilder extends BaseFilterBuilder { return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(NotFilterParser.NAME); builder.field("filter"); filter.toXContent(builder, params); diff --git a/src/main/java/org/elasticsearch/index/query/NotFilterParser.java b/src/main/java/org/elasticsearch/index/query/NotFilterParser.java index 1f39cc49eac..1b0dcf14877 100644 --- a/src/main/java/org/elasticsearch/index/query/NotFilterParser.java +++ b/src/main/java/org/elasticsearch/index/query/NotFilterParser.java @@ -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,20 +28,23 @@ import org.elasticsearch.index.cache.filter.support.CacheKeyFilter; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class NotFilterParser implements FilterParser { public static final String NAME = "not"; - @Inject public NotFilterParser() { + @Inject + public NotFilterParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME}; } - @Override public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); Filter filter = null; diff --git a/src/main/java/org/elasticsearch/index/query/NumericRangeFilterBuilder.java b/src/main/java/org/elasticsearch/index/query/NumericRangeFilterBuilder.java index 3683fa2e083..538cc6ce36e 100644 --- a/src/main/java/org/elasticsearch/index/query/NumericRangeFilterBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/NumericRangeFilterBuilder.java @@ -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,10 +25,10 @@ import java.io.IOException; /** * A filter that restricts search results to values that are within the given numeric range. - * + *

    *

    Uses the field data cache (loading all the values for the specified field into memory). * - * @author kimchy (shay.banon) + * */ public class NumericRangeFilterBuilder extends BaseFilterBuilder { @@ -353,7 +353,8 @@ public class NumericRangeFilterBuilder extends BaseFilterBuilder { return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(NumericRangeFilterParser.NAME); builder.startObject(name); diff --git a/src/main/java/org/elasticsearch/index/query/NumericRangeFilterParser.java b/src/main/java/org/elasticsearch/index/query/NumericRangeFilterParser.java index 387a7d75177..0a0e24f9524 100644 --- a/src/main/java/org/elasticsearch/index/query/NumericRangeFilterParser.java +++ b/src/main/java/org/elasticsearch/index/query/NumericRangeFilterParser.java @@ -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,23 +29,26 @@ import org.elasticsearch.index.mapper.core.NumberFieldMapper; import java.io.IOException; -import static org.elasticsearch.index.query.support.QueryParsers.*; +import static org.elasticsearch.index.query.support.QueryParsers.wrapSmartNameFilter; /** - * @author kimchy (shay.banon) + * */ public class NumericRangeFilterParser implements FilterParser { public static final String NAME = "numeric_range"; - @Inject public NumericRangeFilterParser() { + @Inject + public NumericRangeFilterParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME, "numericRange"}; } - @Override public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); boolean cache = false; // default to false, since its using fielddata cache diff --git a/src/main/java/org/elasticsearch/index/query/OrFilterBuilder.java b/src/main/java/org/elasticsearch/index/query/OrFilterBuilder.java index ff25f6eb50d..99a856764a3 100644 --- a/src/main/java/org/elasticsearch/index/query/OrFilterBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/OrFilterBuilder.java @@ -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,7 +19,7 @@ package org.elasticsearch.index.query; -import org.elasticsearch.common.collect.Lists; +import com.google.common.collect.Lists; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; @@ -28,7 +28,7 @@ import java.util.ArrayList; /** * A filter that matches documents matching boolean combinations of other filters. * - * @author kimchy (shay.banon) + * */ public class OrFilterBuilder extends BaseFilterBuilder { @@ -71,7 +71,8 @@ public class OrFilterBuilder extends BaseFilterBuilder { return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(OrFilterParser.NAME); builder.startArray("filters"); for (FilterBuilder filter : filters) { diff --git a/src/main/java/org/elasticsearch/index/query/OrFilterParser.java b/src/main/java/org/elasticsearch/index/query/OrFilterParser.java index 32e1d8a7c07..c1d6f0edf88 100644 --- a/src/main/java/org/elasticsearch/index/query/OrFilterParser.java +++ b/src/main/java/org/elasticsearch/index/query/OrFilterParser.java @@ -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,23 +28,26 @@ import org.elasticsearch.index.cache.filter.support.CacheKeyFilter; import java.io.IOException; import java.util.ArrayList; -import static org.elasticsearch.common.collect.Lists.*; +import static com.google.common.collect.Lists.newArrayList; /** - * @author kimchy (shay.banon) + * */ public class OrFilterParser implements FilterParser { public static final String NAME = "or"; - @Inject public OrFilterParser() { + @Inject + public OrFilterParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME}; } - @Override public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); ArrayList filters = newArrayList(); diff --git a/src/main/java/org/elasticsearch/index/query/ParsedQuery.java b/src/main/java/org/elasticsearch/index/query/ParsedQuery.java index 37453be295c..7db92ffd092 100644 --- a/src/main/java/org/elasticsearch/index/query/ParsedQuery.java +++ b/src/main/java/org/elasticsearch/index/query/ParsedQuery.java @@ -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,15 +19,15 @@ package org.elasticsearch.index.query; +import com.google.common.collect.ImmutableMap; import org.apache.lucene.search.Filter; import org.apache.lucene.search.Query; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.lucene.search.Queries; /** * The result of parsing a query. * - * @author kimchy (shay.banon) + * */ public class ParsedQuery { diff --git a/src/main/java/org/elasticsearch/index/query/PrefixFilterBuilder.java b/src/main/java/org/elasticsearch/index/query/PrefixFilterBuilder.java index 8acc0d14ef7..c6eb81b9f58 100644 --- a/src/main/java/org/elasticsearch/index/query/PrefixFilterBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/PrefixFilterBuilder.java @@ -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 java.io.IOException; * A filter that restricts search results to values that have a matching prefix in a given * field. * - * @author kimchy (shay.banon) + * */ public class PrefixFilterBuilder extends BaseFilterBuilder { @@ -73,7 +73,8 @@ public class PrefixFilterBuilder extends BaseFilterBuilder { return this; } - @Override public void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(PrefixFilterParser.NAME); builder.field(name, prefix); if (filterName != null) { diff --git a/src/main/java/org/elasticsearch/index/query/PrefixFilterParser.java b/src/main/java/org/elasticsearch/index/query/PrefixFilterParser.java index 260fafca448..41492a0b197 100644 --- a/src/main/java/org/elasticsearch/index/query/PrefixFilterParser.java +++ b/src/main/java/org/elasticsearch/index/query/PrefixFilterParser.java @@ -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,23 +29,26 @@ import org.elasticsearch.index.mapper.MapperService; import java.io.IOException; -import static org.elasticsearch.index.query.support.QueryParsers.*; +import static org.elasticsearch.index.query.support.QueryParsers.wrapSmartNameFilter; /** - * @author kimchy (shay.banon) + * */ public class PrefixFilterParser implements FilterParser { public static final String NAME = "prefix"; - @Inject public PrefixFilterParser() { + @Inject + public PrefixFilterParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME}; } - @Override public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); boolean cache = true; diff --git a/src/main/java/org/elasticsearch/index/query/PrefixQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/PrefixQueryBuilder.java index 02d90def3ad..d22ba5b3a6d 100644 --- a/src/main/java/org/elasticsearch/index/query/PrefixQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/PrefixQueryBuilder.java @@ -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.IOException; /** * A Query that matches documents containing terms with a specified prefix. * - * @author kimchy (shay.banon) + * */ public class PrefixQueryBuilder extends BaseQueryBuilder { @@ -63,7 +63,8 @@ public class PrefixQueryBuilder extends BaseQueryBuilder { return this; } - @Override public void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(PrefixQueryParser.NAME); if (boost == -1 && rewrite == null) { builder.field(name, prefix); diff --git a/src/main/java/org/elasticsearch/index/query/PrefixQueryParser.java b/src/main/java/org/elasticsearch/index/query/PrefixQueryParser.java index f06b79c8611..b8d33761765 100644 --- a/src/main/java/org/elasticsearch/index/query/PrefixQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/PrefixQueryParser.java @@ -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,23 +29,26 @@ import org.elasticsearch.index.query.support.QueryParsers; import java.io.IOException; -import static org.elasticsearch.index.query.support.QueryParsers.*; +import static org.elasticsearch.index.query.support.QueryParsers.wrapSmartNameQuery; /** - * @author kimchy (shay.banon) + * */ public class PrefixQueryParser implements QueryParser { public static final String NAME = "prefix"; - @Inject public PrefixQueryParser() { + @Inject + public PrefixQueryParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); XContentParser.Token token = parser.nextToken(); diff --git a/src/main/java/org/elasticsearch/index/query/QueryBuilder.java b/src/main/java/org/elasticsearch/index/query/QueryBuilder.java index 69332e806fc..c4101345b30 100644 --- a/src/main/java/org/elasticsearch/index/query/QueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/QueryBuilder.java @@ -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.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentType; /** - * @author kimchy (shay.banon) + * */ public interface QueryBuilder extends ToXContent { diff --git a/src/main/java/org/elasticsearch/index/query/QueryBuilderException.java b/src/main/java/org/elasticsearch/index/query/QueryBuilderException.java index 0e324cff649..8b450716555 100644 --- a/src/main/java/org/elasticsearch/index/query/QueryBuilderException.java +++ b/src/main/java/org/elasticsearch/index/query/QueryBuilderException.java @@ -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.index.query; import org.elasticsearch.ElasticSearchException; /** - * @author kimchy (Shay Banon) + * */ public class QueryBuilderException extends ElasticSearchException { diff --git a/src/main/java/org/elasticsearch/index/query/QueryBuilders.java b/src/main/java/org/elasticsearch/index/query/QueryBuilders.java index a7055de3d2c..e2ef8b706e3 100644 --- a/src/main/java/org/elasticsearch/index/query/QueryBuilders.java +++ b/src/main/java/org/elasticsearch/index/query/QueryBuilders.java @@ -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.common.Nullable; /** * A static factory for simple "import static" usage. * - * @author kimchy (shay.banon) + * */ public abstract class QueryBuilders { diff --git a/src/main/java/org/elasticsearch/index/query/QueryFilterBuilder.java b/src/main/java/org/elasticsearch/index/query/QueryFilterBuilder.java index 764d3c909e1..80cceeac4ce 100644 --- a/src/main/java/org/elasticsearch/index/query/QueryFilterBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/QueryFilterBuilder.java @@ -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.IOException; /** * A filter that simply wraps a query. * - * @author kimchy (shay.banon) + * */ public class QueryFilterBuilder extends BaseFilterBuilder { @@ -61,7 +61,8 @@ public class QueryFilterBuilder extends BaseFilterBuilder { return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { if (filterName == null && cache == null) { builder.field(QueryFilterParser.NAME); queryBuilder.toXContent(builder, params); diff --git a/src/main/java/org/elasticsearch/index/query/QueryFilterParser.java b/src/main/java/org/elasticsearch/index/query/QueryFilterParser.java index d42cac03fdd..0c97e78e21b 100644 --- a/src/main/java/org/elasticsearch/index/query/QueryFilterParser.java +++ b/src/main/java/org/elasticsearch/index/query/QueryFilterParser.java @@ -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,20 +27,23 @@ import org.elasticsearch.common.inject.Inject; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class QueryFilterParser implements FilterParser { public static final String NAME = "query"; - @Inject public QueryFilterParser() { + @Inject + public QueryFilterParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME}; } - @Override public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { Query query = parseContext.parseInnerQuery(); return new QueryWrapperFilter(query); } diff --git a/src/main/java/org/elasticsearch/index/query/QueryParseContext.java b/src/main/java/org/elasticsearch/index/query/QueryParseContext.java index 1965dfeb361..48fadc0450a 100644 --- a/src/main/java/org/elasticsearch/index/query/QueryParseContext.java +++ b/src/main/java/org/elasticsearch/index/query/QueryParseContext.java @@ -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,8 @@ package org.elasticsearch.index.query; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; import org.apache.lucene.queryParser.MapperQueryParser; import org.apache.lucene.queryParser.MultiFieldMapperQueryParser; import org.apache.lucene.queryParser.MultiFieldQueryParserSettings; @@ -27,8 +29,6 @@ import org.apache.lucene.search.Filter; import org.apache.lucene.search.Query; import org.apache.lucene.search.Similarity; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.Maps; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.Index; import org.elasticsearch.index.analysis.AnalysisService; @@ -45,7 +45,7 @@ import java.io.IOException; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class QueryParseContext { @@ -115,7 +115,8 @@ public class QueryParseContext { return indexQueryParser.indexEngine; } - @Nullable public SimilarityService similarityService() { + @Nullable + public SimilarityService similarityService() { return indexQueryParser.similarityService; } diff --git a/src/main/java/org/elasticsearch/index/query/QueryParser.java b/src/main/java/org/elasticsearch/index/query/QueryParser.java index 0a554a9a238..c57e0b0d178 100644 --- a/src/main/java/org/elasticsearch/index/query/QueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/QueryParser.java @@ -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.Query; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public interface QueryParser { diff --git a/src/main/java/org/elasticsearch/index/query/QueryParserFactory.java b/src/main/java/org/elasticsearch/index/query/QueryParserFactory.java index c6751cdd1a5..fab14f51701 100644 --- a/src/main/java/org/elasticsearch/index/query/QueryParserFactory.java +++ b/src/main/java/org/elasticsearch/index/query/QueryParserFactory.java @@ -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.index.query; import org.elasticsearch.common.settings.Settings; /** - * @author kimchy (shay.banon) + * */ public interface QueryParserFactory { diff --git a/src/main/java/org/elasticsearch/index/query/QueryParsingException.java b/src/main/java/org/elasticsearch/index/query/QueryParsingException.java index f42dd5bca8e..2bb8e847c3d 100644 --- a/src/main/java/org/elasticsearch/index/query/QueryParsingException.java +++ b/src/main/java/org/elasticsearch/index/query/QueryParsingException.java @@ -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.index.IndexException; import org.elasticsearch.rest.RestStatus; /** - * @author kimchy (Shay Banon) + * */ public class QueryParsingException extends IndexException { @@ -36,7 +36,8 @@ public class QueryParsingException extends IndexException { super(index, msg, cause); } - @Override public RestStatus status() { + @Override + public RestStatus status() { return RestStatus.BAD_REQUEST; } } diff --git a/src/main/java/org/elasticsearch/index/query/QueryStringQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/QueryStringQueryBuilder.java index cd14ca04e09..ff58326317c 100644 --- a/src/main/java/org/elasticsearch/index/query/QueryStringQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/QueryStringQueryBuilder.java @@ -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,14 +19,14 @@ package org.elasticsearch.index.query; -import org.elasticsearch.common.trove.impl.Constants; -import org.elasticsearch.common.trove.map.hash.TObjectFloatHashMap; +import gnu.trove.impl.Constants; +import gnu.trove.map.hash.TObjectFloatHashMap; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; import java.util.List; -import static org.elasticsearch.common.collect.Lists.*; +import static com.google.common.collect.Lists.newArrayList; /** * A query that parses a query string and runs it. There are two modes that this operates. The first, @@ -35,7 +35,7 @@ import static org.elasticsearch.common.collect.Lists.*; * (using {@link #field(String)}), will run the parsed query against the provided fields, and combine * them either using DisMax or a plain boolean query (see {@link #useDisMax(boolean)}). * - * @author kimchy (shay.baon) + * (shay.baon) */ public class QueryStringQueryBuilder extends BaseQueryBuilder { @@ -141,11 +141,11 @@ public class QueryStringQueryBuilder extends BaseQueryBuilder { /** * Sets the boolean operator of the query parser used to parse the query string. - * + *

    *

    In default mode ({@link FieldQueryBuilder.Operator#OR}) terms without any modifiers * are considered optional: for example capital of Hungary is equal to * capital OR of OR Hungary. - * + *

    *

    In {@link FieldQueryBuilder.Operator#AND} mode terms are considered to be in conjunction: the * above mentioned query is parsed as capital AND of AND Hungary */ @@ -168,7 +168,7 @@ public class QueryStringQueryBuilder extends BaseQueryBuilder { * when the analyzer returns more than one term from whitespace * delimited text. * NOTE: this behavior may not be suitable for all languages. - *

    + *

    * Set to false if phrase queries should only be generated when * surrounded by double quotes. */ @@ -197,7 +197,7 @@ public class QueryStringQueryBuilder extends BaseQueryBuilder { /** * Set to true to enable position increments in result query. Defaults to * true. - * + *

    *

    When set, result phrase and multi-phrase queries will be aware of position increments. * Useful when e.g. a StopFilter increases the position increment of the token that follows an omitted token. */ @@ -258,7 +258,8 @@ public class QueryStringQueryBuilder extends BaseQueryBuilder { return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(QueryStringQueryParser.NAME); builder.field("query", queryString); if (defaultField != null) { diff --git a/src/main/java/org/elasticsearch/index/query/QueryStringQueryParser.java b/src/main/java/org/elasticsearch/index/query/QueryStringQueryParser.java index bd03a19431d..ff2df060ed4 100644 --- a/src/main/java/org/elasticsearch/index/query/QueryStringQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/QueryStringQueryParser.java @@ -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,41 +19,45 @@ package org.elasticsearch.index.query; +import com.google.common.collect.Lists; +import gnu.trove.impl.Constants; +import gnu.trove.map.hash.TObjectFloatHashMap; import org.apache.lucene.queryParser.MapperQueryParser; import org.apache.lucene.queryParser.MultiFieldQueryParserSettings; import org.apache.lucene.queryParser.ParseException; import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.Query; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.lucene.search.Queries; import org.elasticsearch.common.regex.Regex; -import org.elasticsearch.common.trove.impl.Constants; -import org.elasticsearch.common.trove.map.hash.TObjectFloatHashMap; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.mapper.internal.AllFieldMapper; import org.elasticsearch.index.query.support.QueryParsers; import java.io.IOException; -import static org.elasticsearch.common.lucene.search.Queries.*; +import static org.elasticsearch.common.lucene.search.Queries.fixNegativeQueryIfNeeded; +import static org.elasticsearch.common.lucene.search.Queries.optimizeQuery; /** - * @author kimchy (shay.banon) + * */ public class QueryStringQueryParser implements QueryParser { public static final String NAME = "query_string"; - @Inject public QueryStringQueryParser() { + @Inject + public QueryStringQueryParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME, Strings.toCamelCase(NAME)}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); MultiFieldQueryParserSettings qpSettings = new MultiFieldQueryParserSettings(); diff --git a/src/main/java/org/elasticsearch/index/query/RangeFilterBuilder.java b/src/main/java/org/elasticsearch/index/query/RangeFilterBuilder.java index 9f34a7e0b23..2f639293cfd 100644 --- a/src/main/java/org/elasticsearch/index/query/RangeFilterBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/RangeFilterBuilder.java @@ -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.IOException; /** * A filter that restricts search results to values that are within the given range. * - * @author kimchy (shay.banon) + * */ public class RangeFilterBuilder extends BaseFilterBuilder { @@ -351,7 +351,8 @@ public class RangeFilterBuilder extends BaseFilterBuilder { return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(RangeFilterParser.NAME); builder.startObject(name); diff --git a/src/main/java/org/elasticsearch/index/query/RangeFilterParser.java b/src/main/java/org/elasticsearch/index/query/RangeFilterParser.java index bd3ff18de03..4871f94b490 100644 --- a/src/main/java/org/elasticsearch/index/query/RangeFilterParser.java +++ b/src/main/java/org/elasticsearch/index/query/RangeFilterParser.java @@ -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,23 +28,26 @@ import org.elasticsearch.index.mapper.MapperService; import java.io.IOException; -import static org.elasticsearch.index.query.support.QueryParsers.*; +import static org.elasticsearch.index.query.support.QueryParsers.wrapSmartNameFilter; /** - * @author kimchy (shay.banon) + * */ public class RangeFilterParser implements FilterParser { public static final String NAME = "range"; - @Inject public RangeFilterParser() { + @Inject + public RangeFilterParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME}; } - @Override public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); boolean cache = true; diff --git a/src/main/java/org/elasticsearch/index/query/RangeQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/RangeQueryBuilder.java index 5fa5c794842..c4035b794ee 100644 --- a/src/main/java/org/elasticsearch/index/query/RangeQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/RangeQueryBuilder.java @@ -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.IOException; /** * A Query that matches documents within an range of terms. * - * @author kimchy (shay.banon) + * */ public class RangeQueryBuilder extends BaseQueryBuilder { @@ -388,7 +388,8 @@ public class RangeQueryBuilder extends BaseQueryBuilder { return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(RangeQueryParser.NAME); builder.startObject(name); builder.field("from", from); diff --git a/src/main/java/org/elasticsearch/index/query/RangeQueryParser.java b/src/main/java/org/elasticsearch/index/query/RangeQueryParser.java index b56c0663941..14c678491ce 100644 --- a/src/main/java/org/elasticsearch/index/query/RangeQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/RangeQueryParser.java @@ -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,23 +27,26 @@ import org.elasticsearch.index.mapper.MapperService; import java.io.IOException; -import static org.elasticsearch.index.query.support.QueryParsers.*; +import static org.elasticsearch.index.query.support.QueryParsers.wrapSmartNameQuery; /** - * @author kimchy (shay.banon) + * */ public class RangeQueryParser implements QueryParser { public static final String NAME = "range"; - @Inject public RangeQueryParser() { + @Inject + public RangeQueryParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); XContentParser.Token token = parser.nextToken(); diff --git a/src/main/java/org/elasticsearch/index/query/ScriptFilterBuilder.java b/src/main/java/org/elasticsearch/index/query/ScriptFilterBuilder.java index e0f1675a6eb..3e7d9b0c31a 100644 --- a/src/main/java/org/elasticsearch/index/query/ScriptFilterBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/ScriptFilterBuilder.java @@ -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,10 +24,10 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; import java.util.Map; -import static org.elasticsearch.common.collect.Maps.*; +import static com.google.common.collect.Maps.newHashMap; /** - * @author kimchy (shay.banon) + * */ public class ScriptFilterBuilder extends BaseFilterBuilder { @@ -92,7 +92,8 @@ public class ScriptFilterBuilder extends BaseFilterBuilder { return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(ScriptFilterParser.NAME); builder.field("script", script); if (this.params != null) { diff --git a/src/main/java/org/elasticsearch/index/query/ScriptFilterParser.java b/src/main/java/org/elasticsearch/index/query/ScriptFilterParser.java index ab543733f2a..e9820711ea5 100644 --- a/src/main/java/org/elasticsearch/index/query/ScriptFilterParser.java +++ b/src/main/java/org/elasticsearch/index/query/ScriptFilterParser.java @@ -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.elasticsearch.index.query; +import com.google.common.collect.Maps; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.DocIdSet; import org.apache.lucene.search.Filter; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.ElasticSearchIllegalStateException; -import org.elasticsearch.common.collect.Maps; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.lucene.docset.GetDocSet; import org.elasticsearch.common.xcontent.XContentParser; @@ -37,20 +37,23 @@ import java.io.IOException; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class ScriptFilterParser implements FilterParser { public static final String NAME = "script"; - @Inject public ScriptFilterParser() { + @Inject + public ScriptFilterParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME}; } - @Override public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); XContentParser.Token token; @@ -123,7 +126,8 @@ public class ScriptFilterParser implements FilterParser { this.searchScript = context.scriptService().search(context.lookup(), scriptLang, script, params); } - @Override public String toString() { + @Override + public String toString() { StringBuilder buffer = new StringBuilder(); buffer.append("ScriptFilter("); buffer.append(script); @@ -131,7 +135,8 @@ public class ScriptFilterParser implements FilterParser { return buffer.toString(); } - @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; @@ -143,13 +148,15 @@ public class ScriptFilterParser implements FilterParser { return true; } - @Override public int hashCode() { + @Override + public int hashCode() { int result = script != null ? script.hashCode() : 0; result = 31 * result + (params != null ? params.hashCode() : 0); return result; } - @Override public DocIdSet getDocIdSet(final IndexReader reader) throws IOException { + @Override + public DocIdSet getDocIdSet(final IndexReader reader) throws IOException { searchScript.setNextReader(reader); return new ScriptDocSet(reader, searchScript); } @@ -163,11 +170,13 @@ public class ScriptFilterParser implements FilterParser { this.searchScript = searchScript; } - @Override public long sizeInBytes() { + @Override + public long sizeInBytes() { return 0; } - @Override public boolean isCacheable() { + @Override + public boolean isCacheable() { // not cacheable for several reasons: // 1. The script service is shared and holds the current reader executing against, and it // gets changed on each getDocIdSet (which is fine for sequential reader search) @@ -175,7 +184,8 @@ public class ScriptFilterParser implements FilterParser { return false; } - @Override public boolean get(int doc) { + @Override + public boolean get(int doc) { searchScript.setNextDocId(doc); Object val = searchScript.run(); if (val == null) { diff --git a/src/main/java/org/elasticsearch/index/query/SpanFirstQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/SpanFirstQueryBuilder.java index 0182fc08abc..74e440a0f42 100644 --- a/src/main/java/org/elasticsearch/index/query/SpanFirstQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/SpanFirstQueryBuilder.java @@ -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.common.xcontent.XContentBuilder; import java.io.IOException; /** - * @author kimchy (Shay Banon) + * */ public class SpanFirstQueryBuilder extends BaseQueryBuilder implements SpanQueryBuilder { @@ -44,7 +44,8 @@ public class SpanFirstQueryBuilder extends BaseQueryBuilder implements SpanQuery return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(SpanFirstQueryParser.NAME); builder.field("match"); matchBuilder.toXContent(builder, params); diff --git a/src/main/java/org/elasticsearch/index/query/SpanFirstQueryParser.java b/src/main/java/org/elasticsearch/index/query/SpanFirstQueryParser.java index eecd576c98d..3dcba37c86a 100644 --- a/src/main/java/org/elasticsearch/index/query/SpanFirstQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/SpanFirstQueryParser.java @@ -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,20 +29,23 @@ import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class SpanFirstQueryParser implements QueryParser { public static final String NAME = "span_first"; - @Inject public SpanFirstQueryParser() { + @Inject + public SpanFirstQueryParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME, Strings.toCamelCase(NAME)}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); float boost = 1.0f; diff --git a/src/main/java/org/elasticsearch/index/query/SpanNearQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/SpanNearQueryBuilder.java index ad6d3b25a02..19ad4da6e51 100644 --- a/src/main/java/org/elasticsearch/index/query/SpanNearQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/SpanNearQueryBuilder.java @@ -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.io.IOException; import java.util.ArrayList; /** - * @author kimchy (shay.banon) + * */ public class SpanNearQueryBuilder extends BaseQueryBuilder implements SpanQueryBuilder { @@ -64,7 +64,8 @@ public class SpanNearQueryBuilder extends BaseQueryBuilder implements SpanQueryB return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { if (clauses.isEmpty()) { throw new QueryBuilderException("Must have at least one clause when building a spanNear query"); } diff --git a/src/main/java/org/elasticsearch/index/query/SpanNearQueryParser.java b/src/main/java/org/elasticsearch/index/query/SpanNearQueryParser.java index ea5047d5944..2d7afbd651f 100644 --- a/src/main/java/org/elasticsearch/index/query/SpanNearQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/SpanNearQueryParser.java @@ -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,23 +29,26 @@ import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; import java.util.List; -import static org.elasticsearch.common.collect.Lists.*; +import static com.google.common.collect.Lists.newArrayList; /** - * @author kimchy (shay.banon) + * */ public class SpanNearQueryParser implements QueryParser { public static final String NAME = "span_near"; - @Inject public SpanNearQueryParser() { + @Inject + public SpanNearQueryParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME, Strings.toCamelCase(NAME)}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); float boost = 1.0f; diff --git a/src/main/java/org/elasticsearch/index/query/SpanNotQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/SpanNotQueryBuilder.java index 1201f82c628..39cc3b9cac0 100644 --- a/src/main/java/org/elasticsearch/index/query/SpanNotQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/SpanNotQueryBuilder.java @@ -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.common.xcontent.XContentBuilder; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class SpanNotQueryBuilder extends BaseQueryBuilder implements SpanQueryBuilder { @@ -49,7 +49,8 @@ public class SpanNotQueryBuilder extends BaseQueryBuilder implements SpanQueryBu return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { if (include == null) { throw new QueryBuilderException("Must specify include when using spanNot query"); } diff --git a/src/main/java/org/elasticsearch/index/query/SpanNotQueryParser.java b/src/main/java/org/elasticsearch/index/query/SpanNotQueryParser.java index 774dc8db304..6091f72bc00 100644 --- a/src/main/java/org/elasticsearch/index/query/SpanNotQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/SpanNotQueryParser.java @@ -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,20 +29,23 @@ import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class SpanNotQueryParser implements QueryParser { public static final String NAME = "span_not"; - @Inject public SpanNotQueryParser() { + @Inject + public SpanNotQueryParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME, Strings.toCamelCase(NAME)}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); float boost = 1.0f; diff --git a/src/main/java/org/elasticsearch/index/query/SpanOrQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/SpanOrQueryBuilder.java index bd55e8812b4..1892632d581 100644 --- a/src/main/java/org/elasticsearch/index/query/SpanOrQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/SpanOrQueryBuilder.java @@ -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.io.IOException; import java.util.ArrayList; /** - * @author kimchy (shay.banon) + * */ public class SpanOrQueryBuilder extends BaseQueryBuilder implements SpanQueryBuilder { @@ -43,7 +43,8 @@ public class SpanOrQueryBuilder extends BaseQueryBuilder implements SpanQueryBui return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { if (clauses.isEmpty()) { throw new QueryBuilderException("Must have at least one clause when building a spanOr query"); } diff --git a/src/main/java/org/elasticsearch/index/query/SpanOrQueryParser.java b/src/main/java/org/elasticsearch/index/query/SpanOrQueryParser.java index 7086ea7fa16..d3d1599ea3b 100644 --- a/src/main/java/org/elasticsearch/index/query/SpanOrQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/SpanOrQueryParser.java @@ -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,23 +29,26 @@ import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; import java.util.List; -import static org.elasticsearch.common.collect.Lists.*; +import static com.google.common.collect.Lists.newArrayList; /** - * @author kimchy (shay.banon) + * */ public class SpanOrQueryParser implements QueryParser { public static final String NAME = "span_or"; - @Inject public SpanOrQueryParser() { + @Inject + public SpanOrQueryParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME, Strings.toCamelCase(NAME)}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); float boost = 1.0f; diff --git a/src/main/java/org/elasticsearch/index/query/SpanQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/SpanQueryBuilder.java index ec81f24c6db..1142d2cc45a 100644 --- a/src/main/java/org/elasticsearch/index/query/SpanQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/SpanQueryBuilder.java @@ -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.index.query; /** - * @author kimchy (shay.banon) + * */ public interface SpanQueryBuilder extends QueryBuilder { diff --git a/src/main/java/org/elasticsearch/index/query/SpanTermQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/SpanTermQueryBuilder.java index d56567a35b4..690d7b0d894 100644 --- a/src/main/java/org/elasticsearch/index/query/SpanTermQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/SpanTermQueryBuilder.java @@ -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.common.xcontent.XContentBuilder; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class SpanTermQueryBuilder extends BaseQueryBuilder implements SpanQueryBuilder { @@ -64,7 +64,8 @@ public class SpanTermQueryBuilder extends BaseQueryBuilder implements SpanQueryB return this; } - @Override public void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(SpanTermQueryParser.NAME); if (boost == -1) { builder.field(name, value); diff --git a/src/main/java/org/elasticsearch/index/query/SpanTermQueryParser.java b/src/main/java/org/elasticsearch/index/query/SpanTermQueryParser.java index 989455e0397..e8ec4118952 100644 --- a/src/main/java/org/elasticsearch/index/query/SpanTermQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/SpanTermQueryParser.java @@ -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,23 +29,26 @@ import org.elasticsearch.index.mapper.MapperService; import java.io.IOException; -import static org.elasticsearch.index.query.support.QueryParsers.*; +import static org.elasticsearch.index.query.support.QueryParsers.wrapSmartNameQuery; /** - * @author kimchy (shay.banon) + * */ public class SpanTermQueryParser implements QueryParser { public static final String NAME = "span_term"; - @Inject public SpanTermQueryParser() { + @Inject + public SpanTermQueryParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME, Strings.toCamelCase(NAME)}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); XContentParser.Token token = parser.currentToken(); diff --git a/src/main/java/org/elasticsearch/index/query/TermFilterBuilder.java b/src/main/java/org/elasticsearch/index/query/TermFilterBuilder.java index 9cd797f1377..b6834fbfa18 100644 --- a/src/main/java/org/elasticsearch/index/query/TermFilterBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/TermFilterBuilder.java @@ -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.IOException; /** * A filter for a field based on a term. * - * @author kimchy (shay.banon) + * */ public class TermFilterBuilder extends BaseFilterBuilder { @@ -121,7 +121,8 @@ public class TermFilterBuilder extends BaseFilterBuilder { return this; } - @Override public void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(TermFilterParser.NAME); builder.field(name, value); if (filterName != null) { diff --git a/src/main/java/org/elasticsearch/index/query/TermFilterParser.java b/src/main/java/org/elasticsearch/index/query/TermFilterParser.java index 87d40726b02..c764a984fa5 100644 --- a/src/main/java/org/elasticsearch/index/query/TermFilterParser.java +++ b/src/main/java/org/elasticsearch/index/query/TermFilterParser.java @@ -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,23 +29,26 @@ import org.elasticsearch.index.mapper.MapperService; import java.io.IOException; -import static org.elasticsearch.index.query.support.QueryParsers.*; +import static org.elasticsearch.index.query.support.QueryParsers.wrapSmartNameFilter; /** - * @author kimchy (shay.banon) + * */ public class TermFilterParser implements FilterParser { public static final String NAME = "term"; - @Inject public TermFilterParser() { + @Inject + public TermFilterParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME}; } - @Override public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); boolean cache = true; // since usually term filter is on repeating terms, cache it by default diff --git a/src/main/java/org/elasticsearch/index/query/TermQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/TermQueryBuilder.java index beceae26861..1d7315a10c7 100644 --- a/src/main/java/org/elasticsearch/index/query/TermQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/TermQueryBuilder.java @@ -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.IOException; /** * A Query that matches documents containing a term. * - * @author kimchy (shay.banon) + * */ public class TermQueryBuilder extends BaseQueryBuilder { @@ -116,7 +116,8 @@ public class TermQueryBuilder extends BaseQueryBuilder { return this; } - @Override public void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(TermQueryParser.NAME); if (boost == -1) { builder.field(name, value); diff --git a/src/main/java/org/elasticsearch/index/query/TermQueryParser.java b/src/main/java/org/elasticsearch/index/query/TermQueryParser.java index 48bbe3b9332..3882470ec4b 100644 --- a/src/main/java/org/elasticsearch/index/query/TermQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/TermQueryParser.java @@ -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,23 +28,26 @@ import org.elasticsearch.index.mapper.MapperService; import java.io.IOException; -import static org.elasticsearch.index.query.support.QueryParsers.*; +import static org.elasticsearch.index.query.support.QueryParsers.wrapSmartNameQuery; /** - * @author kimchy (shay.banon) + * */ public class TermQueryParser implements QueryParser { public static final String NAME = "term"; - @Inject public TermQueryParser() { + @Inject + public TermQueryParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); XContentParser.Token token = parser.nextToken(); diff --git a/src/main/java/org/elasticsearch/index/query/TermsFilterBuilder.java b/src/main/java/org/elasticsearch/index/query/TermsFilterBuilder.java index fdc0f385042..2d69f44ceda 100644 --- a/src/main/java/org/elasticsearch/index/query/TermsFilterBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/TermsFilterBuilder.java @@ -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.IOException; /** * A filer for a field based on several terms matching on any of them. * - * @author kimchy (shay.banon) + * */ public class TermsFilterBuilder extends BaseFilterBuilder { @@ -137,7 +137,8 @@ public class TermsFilterBuilder extends BaseFilterBuilder { return this; } - @Override public void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(TermsFilterParser.NAME); builder.startArray(name); for (Object value : values) { diff --git a/src/main/java/org/elasticsearch/index/query/TermsFilterParser.java b/src/main/java/org/elasticsearch/index/query/TermsFilterParser.java index 9ace0678dd2..958d4eb2f8c 100644 --- a/src/main/java/org/elasticsearch/index/query/TermsFilterParser.java +++ b/src/main/java/org/elasticsearch/index/query/TermsFilterParser.java @@ -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,23 +30,26 @@ import org.elasticsearch.index.mapper.MapperService; import java.io.IOException; -import static org.elasticsearch.index.query.support.QueryParsers.*; +import static org.elasticsearch.index.query.support.QueryParsers.wrapSmartNameFilter; /** - * @author kimchy (shay.banon) + * */ public class TermsFilterParser implements FilterParser { public static final String NAME = "terms"; - @Inject public TermsFilterParser() { + @Inject + public TermsFilterParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME, "in"}; } - @Override public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); MapperService.SmartNameFieldMappers smartNameFieldMappers = null; diff --git a/src/main/java/org/elasticsearch/index/query/TermsQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/TermsQueryBuilder.java index 4856ad4baab..d9e6e409c87 100644 --- a/src/main/java/org/elasticsearch/index/query/TermsQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/TermsQueryBuilder.java @@ -24,7 +24,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class TermsQueryBuilder extends BaseQueryBuilder { @@ -140,7 +140,8 @@ public class TermsQueryBuilder extends BaseQueryBuilder { return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(TermsQueryParser.NAME); builder.startArray(name); for (Object value : values) { diff --git a/src/main/java/org/elasticsearch/index/query/TermsQueryParser.java b/src/main/java/org/elasticsearch/index/query/TermsQueryParser.java index dbd22025734..41960f8e6cd 100644 --- a/src/main/java/org/elasticsearch/index/query/TermsQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/TermsQueryParser.java @@ -32,9 +32,10 @@ import org.elasticsearch.index.mapper.MapperService; import java.io.IOException; import java.util.List; -import static org.elasticsearch.common.collect.Lists.*; -import static org.elasticsearch.common.lucene.search.Queries.*; -import static org.elasticsearch.index.query.support.QueryParsers.*; +import static com.google.common.collect.Lists.newArrayList; +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; /** *

    @@ -44,20 +45,23 @@ import static org.elasticsearch.index.query.support.QueryParsers.*;
      * }
      * 
    * - * @author kimchy (shay.banon) + * */ public class TermsQueryParser implements QueryParser { public static final String NAME = "terms"; - @Inject public TermsQueryParser() { + @Inject + public TermsQueryParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME, "in"}; // allow both "in" and "terms" (since its similar to the "terms" filter) } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); String fieldName = null; diff --git a/src/main/java/org/elasticsearch/index/query/TextQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/TextQueryBuilder.java index 71ce581d4e4..f1b5ad2070f 100644 --- a/src/main/java/org/elasticsearch/index/query/TextQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/TextQueryBuilder.java @@ -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 @@ -135,7 +135,8 @@ public class TextQueryBuilder extends BaseQueryBuilder { return this; } - @Override public void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(TextQueryParser.NAME); builder.startObject(name); diff --git a/src/main/java/org/elasticsearch/index/query/TextQueryParser.java b/src/main/java/org/elasticsearch/index/query/TextQueryParser.java index 2655db1bf61..f8a5551aae0 100644 --- a/src/main/java/org/elasticsearch/index/query/TextQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/TextQueryParser.java @@ -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,20 +28,23 @@ import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class TextQueryParser implements QueryParser { public static final String NAME = "text"; - @Inject public TextQueryParser() { + @Inject + public TextQueryParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME, "text_phrase", "textPhrase", "text_phrase_prefix", "textPhrasePrefix", "fuzzyText", "fuzzy_text"}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); org.elasticsearch.index.search.TextQueryParser.Type type = org.elasticsearch.index.search.TextQueryParser.Type.BOOLEAN; diff --git a/src/main/java/org/elasticsearch/index/query/TopChildrenQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/TopChildrenQueryBuilder.java index 6dce6fae7c2..b32e8f5373c 100644 --- a/src/main/java/org/elasticsearch/index/query/TopChildrenQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/TopChildrenQueryBuilder.java @@ -24,7 +24,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class TopChildrenQueryBuilder extends BaseQueryBuilder { @@ -91,7 +91,8 @@ public class TopChildrenQueryBuilder extends BaseQueryBuilder { return this; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(TopChildrenQueryParser.NAME); builder.field("query"); queryBuilder.toXContent(builder, params); diff --git a/src/main/java/org/elasticsearch/index/query/TopChildrenQueryParser.java b/src/main/java/org/elasticsearch/index/query/TopChildrenQueryParser.java index 802017f6997..87e221bc65b 100644 --- a/src/main/java/org/elasticsearch/index/query/TopChildrenQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/TopChildrenQueryParser.java @@ -31,20 +31,23 @@ import org.elasticsearch.search.internal.SearchContext; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class TopChildrenQueryParser implements QueryParser { public static final String NAME = "top_children"; - @Inject public TopChildrenQueryParser() { + @Inject + public TopChildrenQueryParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME, Strings.toCamelCase(NAME)}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); Query query = null; diff --git a/src/main/java/org/elasticsearch/index/query/TypeFilterBuilder.java b/src/main/java/org/elasticsearch/index/query/TypeFilterBuilder.java index bca4ba7e0e1..3d01faa11a7 100644 --- a/src/main/java/org/elasticsearch/index/query/TypeFilterBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/TypeFilterBuilder.java @@ -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,7 +31,8 @@ public class TypeFilterBuilder extends BaseFilterBuilder { this.type = type; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(TypeFilterParser.NAME); builder.field("value", type); builder.endObject(); diff --git a/src/main/java/org/elasticsearch/index/query/TypeFilterParser.java b/src/main/java/org/elasticsearch/index/query/TypeFilterParser.java index c1a82c84525..76a224a03a5 100644 --- a/src/main/java/org/elasticsearch/index/query/TypeFilterParser.java +++ b/src/main/java/org/elasticsearch/index/query/TypeFilterParser.java @@ -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,14 +32,17 @@ public class TypeFilterParser implements FilterParser { public static final String NAME = "type"; - @Inject public TypeFilterParser() { + @Inject + public TypeFilterParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME}; } - @Override public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); XContentParser.Token token = parser.nextToken(); diff --git a/src/main/java/org/elasticsearch/index/query/WildcardQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/WildcardQueryBuilder.java index 79589f53c0f..ddf90e08b31 100644 --- a/src/main/java/org/elasticsearch/index/query/WildcardQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/WildcardQueryBuilder.java @@ -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,7 +31,7 @@ import java.io.IOException; * a Wildcard term should not start with one of the wildcards * or * ?. * - * @author kimchy (shay.banon) + * */ public class WildcardQueryBuilder extends BaseQueryBuilder { @@ -73,7 +73,8 @@ public class WildcardQueryBuilder extends BaseQueryBuilder { return this; } - @Override public void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(WildcardQueryParser.NAME); if (boost == -1 && rewrite != null) { builder.field(name, wildcard); diff --git a/src/main/java/org/elasticsearch/index/query/WildcardQueryParser.java b/src/main/java/org/elasticsearch/index/query/WildcardQueryParser.java index 8258c2527d9..7a790be9d01 100644 --- a/src/main/java/org/elasticsearch/index/query/WildcardQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/WildcardQueryParser.java @@ -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,23 +29,26 @@ import org.elasticsearch.index.query.support.QueryParsers; import java.io.IOException; -import static org.elasticsearch.index.query.support.QueryParsers.*; +import static org.elasticsearch.index.query.support.QueryParsers.wrapSmartNameQuery; /** - * @author kimchy (shay.banon) + * */ public class WildcardQueryParser implements QueryParser { public static final String NAME = "wildcard"; - @Inject public WildcardQueryParser() { + @Inject + public WildcardQueryParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); XContentParser.Token token = parser.nextToken(); diff --git a/src/main/java/org/elasticsearch/index/query/WrapperQueryBuilder.java b/src/main/java/org/elasticsearch/index/query/WrapperQueryBuilder.java index 05c5e34ba8d..32d5b5cbb36 100644 --- a/src/main/java/org/elasticsearch/index/query/WrapperQueryBuilder.java +++ b/src/main/java/org/elasticsearch/index/query/WrapperQueryBuilder.java @@ -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 @@ package org.elasticsearch.index.query; * Time: 11:30 */ -import org.elasticsearch.common.base.Charsets; +import com.google.common.base.Charsets; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; @@ -34,7 +34,7 @@ import java.io.IOException; * A Query builder which allows building a query thanks to a JSON string or binary data. This is useful when you want * to use the Java Builder API but still have JSON query strings at hand that you want to combine with other * query builders. - * + *

    * Example usage in a boolean query : *

      * {@code
    @@ -43,8 +43,6 @@ import java.io.IOException;
      *      bool.must(new TermQueryBuilder("field2","value2");
      * }
      * 
    - * - * @author Cedric Champeau */ public class WrapperQueryBuilder extends BaseQueryBuilder { @@ -67,7 +65,8 @@ public class WrapperQueryBuilder extends BaseQueryBuilder { this.length = length; } - @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(WrapperQueryParser.NAME); builder.field("query", source, offset, length); builder.endObject(); diff --git a/src/main/java/org/elasticsearch/index/query/WrapperQueryParser.java b/src/main/java/org/elasticsearch/index/query/WrapperQueryParser.java index 226fb15ecb9..7783fc48c74 100644 --- a/src/main/java/org/elasticsearch/index/query/WrapperQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/WrapperQueryParser.java @@ -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,14 +33,17 @@ public class WrapperQueryParser implements QueryParser { public static final String NAME = "wrapper"; - @Inject public WrapperQueryParser() { + @Inject + public WrapperQueryParser() { } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{NAME}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); XContentParser.Token token = parser.nextToken(); diff --git a/src/main/java/org/elasticsearch/index/query/support/QueryParsers.java b/src/main/java/org/elasticsearch/index/query/support/QueryParsers.java index a8751d6a195..680b8ba133e 100644 --- a/src/main/java/org/elasticsearch/index/query/support/QueryParsers.java +++ b/src/main/java/org/elasticsearch/index/query/support/QueryParsers.java @@ -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,20 +19,20 @@ package org.elasticsearch.index.query.support; +import com.google.common.collect.ImmutableList; import org.apache.lucene.search.Filter; import org.apache.lucene.search.FilteredQuery; import org.apache.lucene.search.MultiTermQuery; import org.apache.lucene.search.Query; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.collect.ImmutableList; import org.elasticsearch.common.lucene.search.AndFilter; import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.query.QueryParseContext; /** - * @author kimchy (shay.banon) + * */ public final class QueryParsers { diff --git a/src/main/java/org/elasticsearch/index/refresh/RefreshStats.java b/src/main/java/org/elasticsearch/index/refresh/RefreshStats.java index 8d61c50803e..9ef99e63a49 100644 --- a/src/main/java/org/elasticsearch/index/refresh/RefreshStats.java +++ b/src/main/java/org/elasticsearch/index/refresh/RefreshStats.java @@ -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 @@ -84,7 +84,8 @@ public class RefreshStats implements Streamable, ToXContent { return refreshStats; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(Fields.REFRESH); builder.field(Fields.TOTAL, total); builder.field(Fields.TOTAL_TIME, totalTime().toString()); @@ -100,12 +101,14 @@ public class RefreshStats implements Streamable, ToXContent { static final XContentBuilderString TOTAL_TIME_IN_MILLIS = new XContentBuilderString("total_time_in_millis"); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { total = in.readVLong(); totalTimeInMillis = in.readVLong(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeVLong(total); out.writeVLong(totalTimeInMillis); } diff --git a/src/main/java/org/elasticsearch/index/search/NumericRangeFieldDataFilter.java b/src/main/java/org/elasticsearch/index/search/NumericRangeFieldDataFilter.java index 36a42846e63..7a4adbb9cb9 100644 --- a/src/main/java/org/elasticsearch/index/search/NumericRangeFieldDataFilter.java +++ b/src/main/java/org/elasticsearch/index/search/NumericRangeFieldDataFilter.java @@ -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 @@ -40,7 +40,7 @@ import java.io.IOException; * A numeric filter that can be much faster than {@link org.apache.lucene.search.NumericRangeFilter} at the * expense of loading numeric values of the field to memory using {@link org.elasticsearch.index.cache.field.data.FieldDataCache}. * - * @author kimchy (shay.banon) + * */ public abstract class NumericRangeFieldDataFilter extends Filter { @@ -120,7 +120,8 @@ public abstract class NumericRangeFieldDataFilter extends Filter { public static NumericRangeFieldDataFilter newByteRange(FieldDataCache fieldDataCache, String field, Byte lowerVal, Byte upperVal, boolean includeLower, boolean includeUpper) { return new NumericRangeFieldDataFilter(fieldDataCache, field, lowerVal, upperVal, includeLower, includeUpper) { - @Override public DocIdSet getDocIdSet(IndexReader reader) throws IOException { + @Override + public DocIdSet getDocIdSet(IndexReader reader) throws IOException { final byte inclusiveLowerPoint, inclusiveUpperPoint; if (lowerVal != null) { byte i = lowerVal.byteValue(); @@ -145,14 +146,16 @@ public abstract class NumericRangeFieldDataFilter extends Filter { final ByteFieldData fieldData = (ByteFieldData) this.fieldDataCache.cache(FieldDataType.DefaultTypes.BYTE, reader, field); return new GetDocSet(reader.maxDoc()) { - @Override public boolean isCacheable() { + @Override + public boolean isCacheable() { // not cacheable for several reasons: // 1. It is only relevant when _cache is set to true, and then, we really want to create in mem bitset // 2. Its already fast without in mem bitset, since it works with field data return false; } - @Override public boolean get(int doc) { + @Override + public boolean get(int doc) { if (!fieldData.hasValue(doc)) { return false; } @@ -177,7 +180,8 @@ public abstract class NumericRangeFieldDataFilter extends Filter { public static NumericRangeFieldDataFilter newShortRange(FieldDataCache fieldDataCache, String field, Short lowerVal, Short upperVal, boolean includeLower, boolean includeUpper) { return new NumericRangeFieldDataFilter(fieldDataCache, field, lowerVal, upperVal, includeLower, includeUpper) { - @Override public DocIdSet getDocIdSet(IndexReader reader) throws IOException { + @Override + public DocIdSet getDocIdSet(IndexReader reader) throws IOException { final short inclusiveLowerPoint, inclusiveUpperPoint; if (lowerVal != null) { short i = lowerVal.shortValue(); @@ -202,14 +206,16 @@ public abstract class NumericRangeFieldDataFilter extends Filter { final ShortFieldData fieldData = (ShortFieldData) this.fieldDataCache.cache(FieldDataType.DefaultTypes.SHORT, reader, field); return new GetDocSet(reader.maxDoc()) { - @Override public boolean isCacheable() { + @Override + public boolean isCacheable() { // not cacheable for several reasons: // 1. It is only relevant when _cache is set to true, and then, we really want to create in mem bitset // 2. Its already fast without in mem bitset, since it works with field data return false; } - @Override public boolean get(int doc) { + @Override + public boolean get(int doc) { if (!fieldData.hasValue(doc)) { return false; } @@ -233,7 +239,8 @@ public abstract class NumericRangeFieldDataFilter extends Filter { public static NumericRangeFieldDataFilter newIntRange(FieldDataCache fieldDataCache, String field, Integer lowerVal, Integer upperVal, boolean includeLower, boolean includeUpper) { return new NumericRangeFieldDataFilter(fieldDataCache, field, lowerVal, upperVal, includeLower, includeUpper) { - @Override public DocIdSet getDocIdSet(IndexReader reader) throws IOException { + @Override + public DocIdSet getDocIdSet(IndexReader reader) throws IOException { final int inclusiveLowerPoint, inclusiveUpperPoint; if (lowerVal != null) { int i = lowerVal.intValue(); @@ -258,14 +265,16 @@ public abstract class NumericRangeFieldDataFilter extends Filter { final IntFieldData fieldData = (IntFieldData) this.fieldDataCache.cache(FieldDataType.DefaultTypes.INT, reader, field); return new GetDocSet(reader.maxDoc()) { - @Override public boolean isCacheable() { + @Override + public boolean isCacheable() { // not cacheable for several reasons: // 1. It is only relevant when _cache is set to true, and then, we really want to create in mem bitset // 2. Its already fast without in mem bitset, since it works with field data return false; } - @Override public boolean get(int doc) { + @Override + public boolean get(int doc) { if (!fieldData.hasValue(doc)) { return false; } @@ -289,7 +298,8 @@ public abstract class NumericRangeFieldDataFilter extends Filter { public static NumericRangeFieldDataFilter newLongRange(FieldDataCache fieldDataCache, String field, Long lowerVal, Long upperVal, boolean includeLower, boolean includeUpper) { return new NumericRangeFieldDataFilter(fieldDataCache, field, lowerVal, upperVal, includeLower, includeUpper) { - @Override public DocIdSet getDocIdSet(IndexReader reader) throws IOException { + @Override + public DocIdSet getDocIdSet(IndexReader reader) throws IOException { final long inclusiveLowerPoint, inclusiveUpperPoint; if (lowerVal != null) { long i = lowerVal.longValue(); @@ -314,14 +324,16 @@ public abstract class NumericRangeFieldDataFilter extends Filter { final LongFieldData fieldData = (LongFieldData) this.fieldDataCache.cache(FieldDataType.DefaultTypes.LONG, reader, field); return new GetDocSet(reader.maxDoc()) { - @Override public boolean isCacheable() { + @Override + public boolean isCacheable() { // not cacheable for several reasons: // 1. It is only relevant when _cache is set to true, and then, we really want to create in mem bitset // 2. Its already fast without in mem bitset, since it works with field data return false; } - @Override public boolean get(int doc) { + @Override + public boolean get(int doc) { if (!fieldData.hasValue(doc)) { return false; } @@ -345,7 +357,8 @@ public abstract class NumericRangeFieldDataFilter extends Filter { public static NumericRangeFieldDataFilter newFloatRange(FieldDataCache fieldDataCache, String field, Float lowerVal, Float upperVal, boolean includeLower, boolean includeUpper) { return new NumericRangeFieldDataFilter(fieldDataCache, field, lowerVal, upperVal, includeLower, includeUpper) { - @Override public DocIdSet getDocIdSet(IndexReader reader) throws IOException { + @Override + public DocIdSet getDocIdSet(IndexReader reader) throws IOException { // we transform the floating point numbers to sortable integers // using NumericUtils to easier find the next bigger/lower value final float inclusiveLowerPoint, inclusiveUpperPoint; @@ -374,14 +387,16 @@ public abstract class NumericRangeFieldDataFilter extends Filter { final FloatFieldData fieldData = (FloatFieldData) this.fieldDataCache.cache(FieldDataType.DefaultTypes.FLOAT, reader, field); return new GetDocSet(reader.maxDoc()) { - @Override public boolean isCacheable() { + @Override + public boolean isCacheable() { // not cacheable for several reasons: // 1. It is only relevant when _cache is set to true, and then, we really want to create in mem bitset // 2. Its already fast without in mem bitset, since it works with field data return false; } - @Override public boolean get(int doc) { + @Override + public boolean get(int doc) { if (!fieldData.hasValue(doc)) { return false; } @@ -405,7 +420,8 @@ public abstract class NumericRangeFieldDataFilter extends Filter { public static NumericRangeFieldDataFilter newDoubleRange(FieldDataCache fieldDataCache, String field, Double lowerVal, Double upperVal, boolean includeLower, boolean includeUpper) { return new NumericRangeFieldDataFilter(fieldDataCache, field, lowerVal, upperVal, includeLower, includeUpper) { - @Override public DocIdSet getDocIdSet(IndexReader reader) throws IOException { + @Override + public DocIdSet getDocIdSet(IndexReader reader) throws IOException { // we transform the floating point numbers to sortable integers // using NumericUtils to easier find the next bigger/lower value final double inclusiveLowerPoint, inclusiveUpperPoint; @@ -434,14 +450,16 @@ public abstract class NumericRangeFieldDataFilter extends Filter { final DoubleFieldData fieldData = (DoubleFieldData) this.fieldDataCache.cache(FieldDataType.DefaultTypes.DOUBLE, reader, field); return new GetDocSet(reader.maxDoc()) { - @Override public boolean isCacheable() { + @Override + public boolean isCacheable() { // not cacheable for several reasons: // 1. It is only relevant when _cache is set to true, and then, we really want to create in mem bitset // 2. Its already fast without in mem bitset, since it works with field data return false; } - @Override public boolean get(int doc) { + @Override + public boolean get(int doc) { if (!fieldData.hasValue(doc)) { return false; } diff --git a/src/main/java/org/elasticsearch/index/search/TextQueryParser.java b/src/main/java/org/elasticsearch/index/search/TextQueryParser.java index 7fe2f0f8efc..90b759ac25f 100644 --- a/src/main/java/org/elasticsearch/index/search/TextQueryParser.java +++ b/src/main/java/org/elasticsearch/index/search/TextQueryParser.java @@ -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,13 +25,7 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute; import org.apache.lucene.index.Term; -import org.apache.lucene.search.BooleanClause; -import org.apache.lucene.search.BooleanQuery; -import org.apache.lucene.search.FuzzyQuery; -import org.apache.lucene.search.MultiPhraseQuery; -import org.apache.lucene.search.PhraseQuery; -import org.apache.lucene.search.Query; -import org.apache.lucene.search.TermQuery; +import org.apache.lucene.search.*; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.ElasticSearchIllegalStateException; import org.elasticsearch.common.Nullable; @@ -46,7 +40,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; -import static org.elasticsearch.index.query.support.QueryParsers.*; +import static org.elasticsearch.index.query.support.QueryParsers.wrapSmartNameQuery; public class TextQueryParser { diff --git a/src/main/java/org/elasticsearch/index/search/UidFilter.java b/src/main/java/org/elasticsearch/index/search/UidFilter.java index 6ad8088daf7..d84bbef6902 100644 --- a/src/main/java/org/elasticsearch/index/search/UidFilter.java +++ b/src/main/java/org/elasticsearch/index/search/UidFilter.java @@ -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 @@ -57,7 +57,8 @@ public class UidFilter extends Filter { // TODO Optimizations // - If we have a single id, we can create a SingleIdDocIdSet to save on mem // - We can use sorted int array DocIdSet to reserve memory compared to OpenBitSet in some cases - @Override public DocIdSet getDocIdSet(IndexReader reader) throws IOException { + @Override + public DocIdSet getDocIdSet(IndexReader reader) throws IOException { BloomFilter filter = bloomCache.filter(reader, UidFieldMapper.NAME, true); FixedBitSet set = null; TermDocs td = null; @@ -86,14 +87,16 @@ public class UidFilter extends Filter { return set; } - @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; UidFilter uidFilter = (UidFilter) o; return !uids.equals(uidFilter.uids); } - @Override public int hashCode() { + @Override + public int hashCode() { return uids.hashCode(); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/search/child/ChildCollector.java b/src/main/java/org/elasticsearch/index/search/child/ChildCollector.java index c4032b5f772..5dd6eef4046 100644 --- a/src/main/java/org/elasticsearch/index/search/child/ChildCollector.java +++ b/src/main/java/org/elasticsearch/index/search/child/ChildCollector.java @@ -33,7 +33,7 @@ import java.util.HashMap; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class ChildCollector extends Collector { @@ -64,11 +64,13 @@ public class ChildCollector extends Collector { return this.parentDocs; } - @Override public void setScorer(Scorer scorer) throws IOException { + @Override + public void setScorer(Scorer scorer) throws IOException { } - @Override public void collect(int doc) throws IOException { + @Override + public void collect(int doc) throws IOException { BytesWrap parentId = typeCache.parentIdByDoc(doc); if (parentId == null) { return; @@ -92,11 +94,13 @@ public class ChildCollector extends Collector { } } - @Override public void setNextReader(IndexReader reader, int docBase) throws IOException { + @Override + public void setNextReader(IndexReader reader, int docBase) throws IOException { typeCache = context.idCache().reader(reader).type(parentType); } - @Override public boolean acceptsDocsOutOfOrder() { + @Override + public boolean acceptsDocsOutOfOrder() { return true; } } diff --git a/src/main/java/org/elasticsearch/index/search/child/HasChildFilter.java b/src/main/java/org/elasticsearch/index/search/child/HasChildFilter.java index e9b04399a58..5a6c8c8a64b 100644 --- a/src/main/java/org/elasticsearch/index/search/child/HasChildFilter.java +++ b/src/main/java/org/elasticsearch/index/search/child/HasChildFilter.java @@ -32,7 +32,7 @@ import java.io.IOException; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class HasChildFilter extends Filter implements ScopePhase.CollectorPhase { @@ -56,36 +56,44 @@ public class HasChildFilter extends Filter implements ScopePhase.CollectorPhase this.searchContext = searchContext; } - @Override public Query query() { + @Override + public Query query() { return query; } - @Override public boolean requiresProcessing() { + @Override + public boolean requiresProcessing() { return parentDocs == null; } - @Override public Collector collector() { + @Override + public Collector collector() { return new ChildCollector(parentType, searchContext); } - @Override public void processCollector(Collector collector) { + @Override + public void processCollector(Collector collector) { this.parentDocs = ((ChildCollector) collector).parentDocs(); } - @Override public String scope() { + @Override + public String scope() { return this.scope; } - @Override public void clear() { + @Override + public void clear() { parentDocs = null; } - @Override public DocIdSet getDocIdSet(IndexReader reader) throws IOException { + @Override + public DocIdSet getDocIdSet(IndexReader reader) throws IOException { // ok to return null return parentDocs.get(reader.getCoreCacheKey()); } - @Override public String toString() { + @Override + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("child_filter[").append(childType).append("/").append(parentType).append("](").append(query).append(')'); return sb.toString(); diff --git a/src/main/java/org/elasticsearch/index/search/child/TopChildrenQuery.java b/src/main/java/org/elasticsearch/index/search/child/TopChildrenQuery.java index aaf1cf3753b..cf71ba6f2fe 100644 --- a/src/main/java/org/elasticsearch/index/search/child/TopChildrenQuery.java +++ b/src/main/java/org/elasticsearch/index/search/child/TopChildrenQuery.java @@ -19,34 +19,23 @@ package org.elasticsearch.index.search.child; +import gnu.trove.map.hash.TIntObjectHashMap; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.Term; -import org.apache.lucene.search.Explanation; -import org.apache.lucene.search.Query; -import org.apache.lucene.search.ScoreDoc; -import org.apache.lucene.search.Scorer; -import org.apache.lucene.search.Searcher; -import org.apache.lucene.search.Similarity; -import org.apache.lucene.search.TopDocs; -import org.apache.lucene.search.Weight; +import org.apache.lucene.search.*; import org.apache.lucene.util.ToStringUtils; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.ElasticSearchIllegalStateException; import org.elasticsearch.common.BytesWrap; import org.elasticsearch.common.lucene.search.EmptyScorer; -import org.elasticsearch.common.trove.map.hash.TIntObjectHashMap; import org.elasticsearch.search.internal.ScopePhase; import org.elasticsearch.search.internal.SearchContext; import java.io.IOException; -import java.util.Arrays; -import java.util.Comparator; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; +import java.util.*; /** - * @author kimchy (shay.banon) + * */ public class TopChildrenQuery extends Query implements ScopePhase.TopDocsPhase { @@ -96,32 +85,39 @@ public class TopChildrenQuery extends Query implements ScopePhase.TopDocsPhase { this.incrementalFactor = incrementalFactor; } - @Override public Query query() { + @Override + public Query query() { return this; } - @Override public String scope() { + @Override + public String scope() { return scope; } - @Override public void clear() { + @Override + public void clear() { parentDocs = null; numHits = 0; } - @Override public int numHits() { + @Override + public int numHits() { return numHits; } - @Override public int factor() { + @Override + public int factor() { return this.factor; } - @Override public int incrementalFactor() { + @Override + public int incrementalFactor() { return this.incrementalFactor; } - @Override public void processResults(TopDocs topDocs, SearchContext context) { + @Override + public void processResults(TopDocs topDocs, SearchContext context) { Map> parentDocsPerReader = new HashMap>(); for (ScoreDoc scoreDoc : topDocs.scoreDocs) { int readerIndex = context.searcher().readerIndex(scoreDoc.doc); @@ -177,7 +173,8 @@ public class TopChildrenQuery extends Query implements ScopePhase.TopDocsPhase { private static final ParentDocComparator PARENT_DOC_COMP = new ParentDocComparator(); static class ParentDocComparator implements Comparator { - @Override public int compare(ParentDoc o1, ParentDoc o2) { + @Override + public int compare(ParentDoc o1, ParentDoc o2) { return o1.docId - o2.docId; } } @@ -189,7 +186,8 @@ public class TopChildrenQuery extends Query implements ScopePhase.TopDocsPhase { public float sumScores = 0; } - @Override public Query rewrite(IndexReader reader) throws IOException { + @Override + public Query rewrite(IndexReader reader) throws IOException { Query newQ = query.rewrite(reader); if (newQ == query) return this; TopChildrenQuery bq = (TopChildrenQuery) this.clone(); @@ -197,11 +195,13 @@ public class TopChildrenQuery extends Query implements ScopePhase.TopDocsPhase { return bq; } - @Override public void extractTerms(Set terms) { + @Override + public void extractTerms(Set terms) { query.extractTerms(terms); } - @Override public Weight createWeight(Searcher searcher) throws IOException { + @Override + public Weight createWeight(Searcher searcher) throws IOException { if (parentDocs != null) { return new ParentWeight(searcher, query.weight(searcher)); } diff --git a/src/main/java/org/elasticsearch/index/search/geo/GeoDistance.java b/src/main/java/org/elasticsearch/index/search/geo/GeoDistance.java index 205249704d9..dbedbe638cd 100644 --- a/src/main/java/org/elasticsearch/index/search/geo/GeoDistance.java +++ b/src/main/java/org/elasticsearch/index/search/geo/GeoDistance.java @@ -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,24 +25,27 @@ import org.elasticsearch.common.unit.DistanceUnit; /** * Geo distance calculation. * - * @author kimchy (shay.banon) + * */ public enum GeoDistance { /** * Calculates distance as points on a plane. Faster, but less accurate than {@link #ARC}. */ PLANE() { - @Override public double calculate(double sourceLatitude, double sourceLongitude, double targetLatitude, double targetLongitude, DistanceUnit unit) { + @Override + public double calculate(double sourceLatitude, double sourceLongitude, double targetLatitude, double targetLongitude, DistanceUnit unit) { double px = targetLongitude - sourceLongitude; double py = targetLatitude - sourceLatitude; return Math.sqrt(px * px + py * py) * unit.getDistancePerDegree(); } - @Override public double normalize(double distance, DistanceUnit unit) { + @Override + public double normalize(double distance, DistanceUnit unit) { return distance; } - @Override public FixedSourceDistance fixedSourceDistance(double sourceLatitude, double sourceLongitude, DistanceUnit unit) { + @Override + public FixedSourceDistance fixedSourceDistance(double sourceLatitude, double sourceLongitude, DistanceUnit unit) { return new PlaneFixedSourceDistance(sourceLatitude, sourceLongitude, unit); } }, @@ -50,7 +53,8 @@ public enum GeoDistance { * Calculates distance factor. */ FACTOR() { - @Override public double calculate(double sourceLatitude, double sourceLongitude, double targetLatitude, double targetLongitude, DistanceUnit unit) { + @Override + public double calculate(double sourceLatitude, double sourceLongitude, double targetLatitude, double targetLongitude, DistanceUnit unit) { // TODO: we might want to normalize longitude as we did in LatLng... double longitudeDifference = targetLongitude - sourceLongitude; double a = Math.toRadians(90D - sourceLatitude); @@ -58,11 +62,13 @@ public enum GeoDistance { return (Math.cos(a) * Math.cos(c)) + (Math.sin(a) * Math.sin(c) * Math.cos(Math.toRadians(longitudeDifference))); } - @Override public double normalize(double distance, DistanceUnit unit) { + @Override + public double normalize(double distance, DistanceUnit unit) { return Math.cos(distance / unit.getEarthRadius()); } - @Override public FixedSourceDistance fixedSourceDistance(double sourceLatitude, double sourceLongitude, DistanceUnit unit) { + @Override + public FixedSourceDistance fixedSourceDistance(double sourceLatitude, double sourceLongitude, DistanceUnit unit) { return new FactorFixedSourceDistance(sourceLatitude, sourceLongitude, unit); } }, @@ -70,7 +76,8 @@ public enum GeoDistance { * Calculates distance as points in a globe. */ ARC() { - @Override public double calculate(double sourceLatitude, double sourceLongitude, double targetLatitude, double targetLongitude, DistanceUnit unit) { + @Override + public double calculate(double sourceLatitude, double sourceLongitude, double targetLatitude, double targetLongitude, DistanceUnit unit) { // TODO: we might want to normalize longitude as we did in LatLng... double longitudeDifference = targetLongitude - sourceLongitude; double a = Math.toRadians(90D - sourceLatitude); @@ -86,11 +93,13 @@ public enum GeoDistance { } } - @Override public double normalize(double distance, DistanceUnit unit) { + @Override + public double normalize(double distance, DistanceUnit unit) { return distance; } - @Override public FixedSourceDistance fixedSourceDistance(double sourceLatitude, double sourceLongitude, DistanceUnit unit) { + @Override + public FixedSourceDistance fixedSourceDistance(double sourceLatitude, double sourceLongitude, DistanceUnit unit) { return new ArcFixedSourceDistance(sourceLatitude, sourceLongitude, unit); } }; @@ -167,15 +176,18 @@ public enum GeoDistance { public static AlwaysDistanceBoundingCheck ALWAYS_INSTANCE = new AlwaysDistanceBoundingCheck(); private static class AlwaysDistanceBoundingCheck implements DistanceBoundingCheck { - @Override public boolean isWithin(double targetLatitude, double targetLongitude) { + @Override + public boolean isWithin(double targetLatitude, double targetLongitude) { return true; } - @Override public Point topLeft() { + @Override + public Point topLeft() { return null; } - @Override public Point bottomRight() { + @Override + public Point bottomRight() { return null; } } @@ -190,16 +202,19 @@ public enum GeoDistance { this.bottomRight = bottomRight; } - @Override public boolean isWithin(double targetLatitude, double targetLongitude) { + @Override + public boolean isWithin(double targetLatitude, double targetLongitude) { return (targetLatitude >= bottomRight.lat && targetLatitude <= topLeft.lat) && (targetLongitude >= topLeft.lon || targetLongitude <= bottomRight.lon); } - @Override public Point topLeft() { + @Override + public Point topLeft() { return topLeft; } - @Override public Point bottomRight() { + @Override + public Point bottomRight() { return bottomRight; } } @@ -213,16 +228,19 @@ public enum GeoDistance { this.bottomRight = bottomRight; } - @Override public boolean isWithin(double targetLatitude, double targetLongitude) { + @Override + public boolean isWithin(double targetLatitude, double targetLongitude) { return (targetLatitude >= bottomRight.lat && targetLatitude <= topLeft.lat) && (targetLongitude >= topLeft.lon && targetLongitude <= bottomRight.lon); } - @Override public Point topLeft() { + @Override + public Point topLeft() { return topLeft; } - @Override public Point bottomRight() { + @Override + public Point bottomRight() { return bottomRight; } } @@ -239,7 +257,8 @@ public enum GeoDistance { this.distancePerDegree = unit.getDistancePerDegree(); } - @Override public double calculate(double targetLatitude, double targetLongitude) { + @Override + public double calculate(double targetLatitude, double targetLongitude) { double px = targetLongitude - sourceLongitude; double py = targetLatitude - sourceLatitude; return Math.sqrt(px * px + py * py) * distancePerDegree; @@ -265,7 +284,8 @@ public enum GeoDistance { this.cosA = Math.cos(a); } - @Override public double calculate(double targetLatitude, double targetLongitude) { + @Override + public double calculate(double targetLatitude, double targetLongitude) { // TODO: we might want to normalize longitude as we did in LatLng... double longitudeDifference = targetLongitude - sourceLongitude; double c = Math.toRadians(90D - targetLatitude); @@ -293,7 +313,8 @@ public enum GeoDistance { this.cosA = Math.cos(a); } - @Override public double calculate(double targetLatitude, double targetLongitude) { + @Override + public double calculate(double targetLatitude, double targetLongitude) { // TODO: we might want to normalize longitude as we did in LatLng... double longitudeDifference = targetLongitude - sourceLongitude; double c = Math.toRadians(90D - targetLatitude); diff --git a/src/main/java/org/elasticsearch/index/search/geo/GeoDistanceDataComparator.java b/src/main/java/org/elasticsearch/index/search/geo/GeoDistanceDataComparator.java index 3b55fbec45d..5afeaa5260a 100644 --- a/src/main/java/org/elasticsearch/index/search/geo/GeoDistanceDataComparator.java +++ b/src/main/java/org/elasticsearch/index/search/geo/GeoDistanceDataComparator.java @@ -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,7 +34,7 @@ import org.elasticsearch.index.mapper.geo.GeoPointFieldDataType; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ // LUCENE MONITOR: Monitor against FieldComparator.Double public class GeoDistanceDataComparator extends FieldComparator { @@ -71,11 +71,13 @@ public class GeoDistanceDataComparator extends FieldComparator { this.mapperService = mapperService; } - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + @Override + public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { return new GeoDistanceDataComparator(numHits, fieldname, lat, lon, unit, geoDistance, fieldDataCache, mapperService); } - @Override public int reducedType() { + @Override + public int reducedType() { return SortField.DOUBLE; } } @@ -124,11 +126,13 @@ public class GeoDistanceDataComparator extends FieldComparator { this.indexFieldName = mapper.names().indexName(); } - @Override public void setNextReader(IndexReader reader, int docBase) throws IOException { + @Override + public void setNextReader(IndexReader reader, int docBase) throws IOException { fieldData = (GeoPointFieldData) fieldDataCache.cache(GeoPointFieldDataType.TYPE, reader, indexFieldName); } - @Override public int compare(int slot1, int slot2) { + @Override + public int compare(int slot1, int slot2) { final double v1 = values[slot1]; final double v2 = values[slot2]; if (v1 > v2) { @@ -140,7 +144,8 @@ public class GeoDistanceDataComparator extends FieldComparator { } } - @Override public int compareBottom(int doc) { + @Override + public int compareBottom(int doc) { double distance; if (!fieldData.hasValue(doc)) { // is this true? push this to the "end" @@ -158,7 +163,8 @@ public class GeoDistanceDataComparator extends FieldComparator { } } - @Override public void copy(int slot, int doc) { + @Override + public void copy(int slot, int doc) { double distance; if (!fieldData.hasValue(doc)) { // is this true? push this to the "end" @@ -169,11 +175,13 @@ public class GeoDistanceDataComparator extends FieldComparator { values[slot] = distance; } - @Override public void setBottom(final int bottom) { + @Override + public void setBottom(final int bottom) { this.bottom = values[bottom]; } - @Override public Comparable value(int slot) { + @Override + public Comparable value(int slot) { return Double.valueOf(values[slot]); } } diff --git a/src/main/java/org/elasticsearch/index/search/geo/GeoDistanceFilter.java b/src/main/java/org/elasticsearch/index/search/geo/GeoDistanceFilter.java index c5f65353bc7..2d68f5276eb 100644 --- a/src/main/java/org/elasticsearch/index/search/geo/GeoDistanceFilter.java +++ b/src/main/java/org/elasticsearch/index/search/geo/GeoDistanceFilter.java @@ -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,11 +19,11 @@ package org.elasticsearch.index.search.geo; +import com.google.common.collect.ImmutableList; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.DocIdSet; import org.apache.lucene.search.Filter; import org.elasticsearch.ElasticSearchIllegalArgumentException; -import org.elasticsearch.common.collect.ImmutableList; import org.elasticsearch.common.lucene.docset.AndDocSet; import org.elasticsearch.common.lucene.docset.DocSet; import org.elasticsearch.common.lucene.docset.DocSets; @@ -102,7 +102,8 @@ public class GeoDistanceFilter extends Filter { return fieldName; } - @Override public DocIdSet getDocIdSet(IndexReader reader) throws IOException { + @Override + public DocIdSet getDocIdSet(IndexReader reader) throws IOException { DocSet boundingBoxDocSet = null; if (boundingBoxFilter != null) { DocIdSet docIdSet = boundingBoxFilter.getDocIdSet(reader); @@ -166,14 +167,16 @@ public class GeoDistanceFilter extends Filter { this.distance = distance; } - @Override public boolean isCacheable() { + @Override + public boolean isCacheable() { // not cacheable for several reasons: // 1. It is only relevant when _cache is set to true, and then, we really want to create in mem bitset // 2. Its already fast without in mem bitset, since it works with field data return false; } - @Override public boolean get(int doc) { + @Override + public boolean get(int doc) { if (!fieldData.hasValue(doc)) { return false; } diff --git a/src/main/java/org/elasticsearch/index/search/geo/GeoDistanceRangeFilter.java b/src/main/java/org/elasticsearch/index/search/geo/GeoDistanceRangeFilter.java index 32ec4a4a4b5..0e28eb636db 100644 --- a/src/main/java/org/elasticsearch/index/search/geo/GeoDistanceRangeFilter.java +++ b/src/main/java/org/elasticsearch/index/search/geo/GeoDistanceRangeFilter.java @@ -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.elasticsearch.index.search.geo; +import com.google.common.collect.ImmutableList; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.DocIdSet; import org.apache.lucene.search.Filter; import org.apache.lucene.util.NumericUtils; import org.elasticsearch.ElasticSearchIllegalArgumentException; -import org.elasticsearch.common.collect.ImmutableList; import org.elasticsearch.common.lucene.docset.AndDocSet; import org.elasticsearch.common.lucene.docset.DocSet; import org.elasticsearch.common.lucene.docset.DocSets; @@ -38,7 +38,7 @@ import org.elasticsearch.index.mapper.geo.GeoPointFieldMapper; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class GeoDistanceRangeFilter extends Filter { @@ -115,7 +115,8 @@ public class GeoDistanceRangeFilter extends Filter { return fieldName; } - @Override public DocIdSet getDocIdSet(IndexReader reader) throws IOException { + @Override + public DocIdSet getDocIdSet(IndexReader reader) throws IOException { DocSet boundingBoxDocSet = null; if (boundingBoxFilter != null) { DocIdSet docIdSet = boundingBoxFilter.getDocIdSet(reader); @@ -185,14 +186,16 @@ public class GeoDistanceRangeFilter extends Filter { this.inclusiveUpperPoint = inclusiveUpperPoint; } - @Override public boolean isCacheable() { + @Override + public boolean isCacheable() { // not cacheable for several reasons: // 1. It is only relevant when _cache is set to true, and then, we really want to create in mem bitset // 2. Its already fast without in mem bitset, since it works with field data return false; } - @Override public boolean get(int doc) { + @Override + public boolean get(int doc) { if (!fieldData.hasValue(doc)) { return false; } diff --git a/src/main/java/org/elasticsearch/index/search/geo/GeoHashUtils.java b/src/main/java/org/elasticsearch/index/search/geo/GeoHashUtils.java index f54200e2f9c..af16ddc09f9 100644 --- a/src/main/java/org/elasticsearch/index/search/geo/GeoHashUtils.java +++ b/src/main/java/org/elasticsearch/index/search/geo/GeoHashUtils.java @@ -17,7 +17,7 @@ package org.elasticsearch.index.search.geo; -import org.elasticsearch.common.trove.map.hash.TIntIntHashMap; +import gnu.trove.map.hash.TIntIntHashMap; /** * Utilities for encoding and decoding geohashes. Based on diff --git a/src/main/java/org/elasticsearch/index/search/geo/GeoPolygonFilter.java b/src/main/java/org/elasticsearch/index/search/geo/GeoPolygonFilter.java index 67c1708b9c0..192ce50e741 100644 --- a/src/main/java/org/elasticsearch/index/search/geo/GeoPolygonFilter.java +++ b/src/main/java/org/elasticsearch/index/search/geo/GeoPolygonFilter.java @@ -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 org.elasticsearch.index.mapper.geo.GeoPointFieldDataType; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class GeoPolygonFilter extends Filter { @@ -54,7 +54,8 @@ public class GeoPolygonFilter extends Filter { return this.fieldName; } - @Override public DocIdSet getDocIdSet(IndexReader reader) throws IOException { + @Override + public DocIdSet getDocIdSet(IndexReader reader) throws IOException { final GeoPointFieldData fieldData = (GeoPointFieldData) fieldDataCache.cache(GeoPointFieldDataType.TYPE, reader, fieldName); return new GeoPolygonDocSet(reader.maxDoc(), fieldData, points); } @@ -69,14 +70,16 @@ public class GeoPolygonFilter extends Filter { this.points = points; } - @Override public boolean isCacheable() { + @Override + public boolean isCacheable() { // not cacheable for several reasons: // 1. It is only relevant when _cache is set to true, and then, we really want to create in mem bitset // 2. Its already fast without in mem bitset, since it works with field data return false; } - @Override public boolean get(int doc) { + @Override + public boolean get(int doc) { if (!fieldData.hasValue(doc)) { return false; } diff --git a/src/main/java/org/elasticsearch/index/search/geo/GeoUtils.java b/src/main/java/org/elasticsearch/index/search/geo/GeoUtils.java index 26cc0489471..69d560dcc7e 100644 --- a/src/main/java/org/elasticsearch/index/search/geo/GeoUtils.java +++ b/src/main/java/org/elasticsearch/index/search/geo/GeoUtils.java @@ -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 diff --git a/src/main/java/org/elasticsearch/index/search/geo/InMemoryGeoBoundingBoxFilter.java b/src/main/java/org/elasticsearch/index/search/geo/InMemoryGeoBoundingBoxFilter.java index 1b749a7d0d9..2a03366117e 100644 --- a/src/main/java/org/elasticsearch/index/search/geo/InMemoryGeoBoundingBoxFilter.java +++ b/src/main/java/org/elasticsearch/index/search/geo/InMemoryGeoBoundingBoxFilter.java @@ -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 org.elasticsearch.index.mapper.geo.GeoPointFieldDataType; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class InMemoryGeoBoundingBoxFilter extends Filter { @@ -61,7 +61,8 @@ public class InMemoryGeoBoundingBoxFilter extends Filter { return fieldName; } - @Override public DocIdSet getDocIdSet(IndexReader reader) throws IOException { + @Override + public DocIdSet getDocIdSet(IndexReader reader) throws IOException { final GeoPointFieldData fieldData = (GeoPointFieldData) fieldDataCache.cache(GeoPointFieldDataType.TYPE, reader, fieldName); //checks to see if bounding box crosses 180 degrees @@ -84,14 +85,16 @@ public class InMemoryGeoBoundingBoxFilter extends Filter { this.bottomRight = bottomRight; } - @Override public boolean isCacheable() { + @Override + public boolean isCacheable() { // not cacheable for several reasons: // 1. It is only relevant when _cache is set to true, and then, we really want to create in mem bitset // 2. Its already fast without in mem bitset, since it works with field data return false; } - @Override public boolean get(int doc) { + @Override + public boolean get(int doc) { if (!fieldData.hasValue(doc)) { return false; } @@ -132,14 +135,16 @@ public class InMemoryGeoBoundingBoxFilter extends Filter { this.bottomRight = bottomRight; } - @Override public boolean isCacheable() { + @Override + public boolean isCacheable() { // not cacheable for several reasons: // 1. It is only relevant when _cache is set to true, and then, we really want to create in mem bitset // 2. Its already fast without in mem bitset, since it works with field data return false; } - @Override public boolean get(int doc) { + @Override + public boolean get(int doc) { if (!fieldData.hasValue(doc)) { return false; } diff --git a/src/main/java/org/elasticsearch/index/search/geo/IndexedGeoBoundingBoxFilter.java b/src/main/java/org/elasticsearch/index/search/geo/IndexedGeoBoundingBoxFilter.java index a8226c10148..3895678176e 100644 --- a/src/main/java/org/elasticsearch/index/search/geo/IndexedGeoBoundingBoxFilter.java +++ b/src/main/java/org/elasticsearch/index/search/geo/IndexedGeoBoundingBoxFilter.java @@ -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 @@ -57,7 +57,8 @@ public class IndexedGeoBoundingBoxFilter { latFilter = fieldMapper.latMapper().rangeFilter(bottomRight.lat, topLeft.lat, true, true); } - @Override public FixedBitSet getDocIdSet(IndexReader reader) throws IOException { + @Override + public FixedBitSet getDocIdSet(IndexReader reader) throws IOException { FixedBitSet main; DocIdSet set = lonFilter1.getDocIdSet(reader); if (set == null || set == DocIdSet.EMPTY_DOCIDSET) { @@ -122,7 +123,8 @@ public class IndexedGeoBoundingBoxFilter { latFilter = fieldMapper.latMapper().rangeFilter(bottomRight.lat, topLeft.lat, true, true); } - @Override public FixedBitSet getDocIdSet(IndexReader reader) throws IOException { + @Override + public FixedBitSet getDocIdSet(IndexReader reader) throws IOException { FixedBitSet main; DocIdSet set = lonFilter.getDocIdSet(reader); if (set == null || set == DocIdSet.EMPTY_DOCIDSET) { diff --git a/src/main/java/org/elasticsearch/index/search/geo/Point.java b/src/main/java/org/elasticsearch/index/search/geo/Point.java index ca32c68a45b..4a1d7924037 100644 --- a/src/main/java/org/elasticsearch/index/search/geo/Point.java +++ b/src/main/java/org/elasticsearch/index/search/geo/Point.java @@ -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 diff --git a/src/main/java/org/elasticsearch/index/search/nested/BlockJoinQuery.java b/src/main/java/org/elasticsearch/index/search/nested/BlockJoinQuery.java index 1c19a285979..d06e35883ba 100644 --- a/src/main/java/org/elasticsearch/index/search/nested/BlockJoinQuery.java +++ b/src/main/java/org/elasticsearch/index/search/nested/BlockJoinQuery.java @@ -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,31 +39,31 @@ import java.util.Set; * document. At search time you provide a Filter * identifying the parents, however this Filter must provide * an {@link org.apache.lucene.util.FixedBitSet} per sub-reader. - * + *

    *

    Once the block index is built, use this query to wrap * any sub-query matching only child docs and join matches in that * child document space up to the parent document space. * You can then use this Query as a clause with * other queries in the parent document space.

    - * + *

    *

    The child documents must be orthogonal to the parent * documents: the wrapped child query must never * return a parent document.

    - * + *

    * If you'd like to retrieve {@link TopGroups} for the * resulting query, use the {@link BlockJoinCollector}. * Note that this is not necessary, ie, if you simply want * to collect the parent documents and don't need to see * which child documents matched under that parent, then * you can use any collector. - * + *

    *

    NOTE: If the overall query contains parent-only * matches, for example you OR a parent-only query with a * joined child-only query, then the resulting collected documents * will be correct, however the {@link TopGroups} you get * from {@link BlockJoinCollector} will not contain every * child for parents that had matched. - * + *

    *

    See {@link org.apache.lucene.search.join} for an * overview.

    * diff --git a/src/main/java/org/elasticsearch/index/search/nested/NestedChildrenCollector.java b/src/main/java/org/elasticsearch/index/search/nested/NestedChildrenCollector.java index 4199d683a6f..9bd98e26f25 100644 --- a/src/main/java/org/elasticsearch/index/search/nested/NestedChildrenCollector.java +++ b/src/main/java/org/elasticsearch/index/search/nested/NestedChildrenCollector.java @@ -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,31 +54,37 @@ public class NestedChildrenCollector extends FacetCollector { this.childFilter = childFilter; } - @Override public Facet facet() { + @Override + public Facet facet() { return collector.facet(); } - @Override public void setFilter(Filter filter) { + @Override + public void setFilter(Filter filter) { // delegate the facet_filter to the children collector.setFilter(filter); } - @Override public void setScorer(Scorer scorer) throws IOException { + @Override + public void setScorer(Scorer scorer) throws IOException { collector.setScorer(scorer); } - @Override public void setNextReader(IndexReader reader, int docBase) throws IOException { + @Override + public void setNextReader(IndexReader reader, int docBase) throws IOException { collector.setNextReader(reader, docBase); currentReader = reader; childDocs = DocSets.convert(reader, childFilter.getDocIdSet(reader)); parentDocs = ((FixedBitDocSet) parentFilter.getDocIdSet(reader)).set(); } - @Override public boolean acceptsDocsOutOfOrder() { + @Override + public boolean acceptsDocsOutOfOrder() { return collector.acceptsDocsOutOfOrder(); } - @Override public void collect(int parentDoc) throws IOException { + @Override + public void collect(int parentDoc) throws IOException { if (parentDoc == 0) { return; } diff --git a/src/main/java/org/elasticsearch/index/search/nested/NestedDocsFilter.java b/src/main/java/org/elasticsearch/index/search/nested/NestedDocsFilter.java index 27ee0d678be..872f04abb80 100644 --- a/src/main/java/org/elasticsearch/index/search/nested/NestedDocsFilter.java +++ b/src/main/java/org/elasticsearch/index/search/nested/NestedDocsFilter.java @@ -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 @@ -40,15 +40,18 @@ public class NestedDocsFilter extends Filter { } - @Override public DocIdSet getDocIdSet(IndexReader reader) throws IOException { + @Override + public DocIdSet getDocIdSet(IndexReader reader) throws IOException { return filter.getDocIdSet(reader); } - @Override public int hashCode() { + @Override + public int hashCode() { return hashCode; } - @Override public boolean equals(Object obj) { + @Override + public boolean equals(Object obj) { return obj == INSTANCE; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/search/nested/NonNestedDocsFilter.java b/src/main/java/org/elasticsearch/index/search/nested/NonNestedDocsFilter.java index f9f3deab85c..ac833b743fc 100644 --- a/src/main/java/org/elasticsearch/index/search/nested/NonNestedDocsFilter.java +++ b/src/main/java/org/elasticsearch/index/search/nested/NonNestedDocsFilter.java @@ -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,7 +41,8 @@ public class NonNestedDocsFilter extends Filter { } - @Override public DocIdSet getDocIdSet(IndexReader reader) throws IOException { + @Override + public DocIdSet getDocIdSet(IndexReader reader) throws IOException { DocIdSet docSet = filter.getDocIdSet(reader); if (docSet == null || docSet == DocIdSet.EMPTY_DOCIDSET) { // will almost never happen, and we need an OpenBitSet for the parent filter in @@ -52,11 +53,13 @@ public class NonNestedDocsFilter extends Filter { return docSet; } - @Override public int hashCode() { + @Override + public int hashCode() { return hashCode; } - @Override public boolean equals(Object obj) { + @Override + public boolean equals(Object obj) { return obj == INSTANCE; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/search/slowlog/ShardSlowLogSearchService.java b/src/main/java/org/elasticsearch/index/search/slowlog/ShardSlowLogSearchService.java index 9d9d2595397..a5be9796066 100644 --- a/src/main/java/org/elasticsearch/index/search/slowlog/ShardSlowLogSearchService.java +++ b/src/main/java/org/elasticsearch/index/search/slowlog/ShardSlowLogSearchService.java @@ -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 @@ -72,7 +72,8 @@ public class ShardSlowLogSearchService extends AbstractIndexShardComponent { } class ApplySettings implements IndexSettingsService.Listener { - @Override public void onRefreshSettings(Settings settings) { + @Override + public void onRefreshSettings(Settings settings) { long queryWarnThreshold = settings.getAsTime("index.search.slowlog.threshold.query.warn", TimeValue.timeValueNanos(ShardSlowLogSearchService.this.queryWarnThreshold)).nanos(); if (queryWarnThreshold != ShardSlowLogSearchService.this.queryWarnThreshold) { ShardSlowLogSearchService.this.queryWarnThreshold = queryWarnThreshold; @@ -121,7 +122,8 @@ public class ShardSlowLogSearchService extends AbstractIndexShardComponent { } } - @Inject public ShardSlowLogSearchService(ShardId shardId, @IndexSettings Settings indexSettings, IndexSettingsService indexSettingsService) { + @Inject + public ShardSlowLogSearchService(ShardId shardId, @IndexSettings Settings indexSettings, IndexSettingsService indexSettingsService) { super(shardId, indexSettings); this.reformat = componentSettings.getAsBoolean("reformat", true); @@ -182,7 +184,8 @@ public class ShardSlowLogSearchService extends AbstractIndexShardComponent { this.reformat = reformat; } - @Override public String toString() { + @Override + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("took[").append(TimeValue.timeValueNanos(tookInNanos)).append("], took_millis[").append(TimeUnit.NANOSECONDS.toMillis(tookInNanos)).append("], "); sb.append("search_type[").append(context.searchType()).append("], total_shards[").append(context.numberOfShards()).append("], "); diff --git a/src/main/java/org/elasticsearch/index/search/stats/SearchStats.java b/src/main/java/org/elasticsearch/index/search/stats/SearchStats.java index 7e8912ed0b7..d512a55e145 100644 --- a/src/main/java/org/elasticsearch/index/search/stats/SearchStats.java +++ b/src/main/java/org/elasticsearch/index/search/stats/SearchStats.java @@ -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 @@ -132,7 +132,8 @@ public class SearchStats implements Streamable, ToXContent { return stats; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { queryCount = in.readVLong(); queryTimeInMillis = in.readVLong(); queryCurrent = in.readVLong(); @@ -142,7 +143,8 @@ public class SearchStats implements Streamable, ToXContent { fetchCurrent = in.readVLong(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeVLong(queryCount); out.writeVLong(queryTimeInMillis); out.writeVLong(queryCurrent); @@ -152,7 +154,8 @@ public class SearchStats implements Streamable, ToXContent { out.writeVLong(fetchCurrent); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.field(Fields.QUERY_TOTAL, queryCount); builder.field(Fields.QUERY_TIME, queryTime().toString()); builder.field(Fields.QUERY_TIME_IN_MILLIS, queryTimeInMillis); @@ -169,7 +172,8 @@ public class SearchStats implements Streamable, ToXContent { private Stats totalStats; - @Nullable Map groupStats; + @Nullable + Map groupStats; public SearchStats() { totalStats = new Stats(); @@ -208,11 +212,13 @@ public class SearchStats implements Streamable, ToXContent { return this.totalStats; } - @Nullable public Map groupStats() { + @Nullable + public Map groupStats() { return this.groupStats; } - @Override public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException { builder.startObject(Fields.SEARCH); totalStats.toXContent(builder, params); if (groupStats != null && !groupStats.isEmpty()) { @@ -247,7 +253,8 @@ public class SearchStats implements Streamable, ToXContent { return searchStats; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { totalStats = Stats.readStats(in); if (in.readBoolean()) { int size = in.readVInt(); @@ -258,7 +265,8 @@ public class SearchStats implements Streamable, ToXContent { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { totalStats.writeTo(out); if (groupStats == null || groupStats.isEmpty()) { out.writeBoolean(false); diff --git a/src/main/java/org/elasticsearch/index/search/stats/ShardSearchModule.java b/src/main/java/org/elasticsearch/index/search/stats/ShardSearchModule.java index 12ea681d4c5..f68e3d28bbf 100644 --- a/src/main/java/org/elasticsearch/index/search/stats/ShardSearchModule.java +++ b/src/main/java/org/elasticsearch/index/search/stats/ShardSearchModule.java @@ -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,8 @@ import org.elasticsearch.index.search.slowlog.ShardSlowLogSearchService; */ public class ShardSearchModule extends AbstractModule { - @Override protected void configure() { + @Override + protected void configure() { bind(ShardSearchService.class).asEagerSingleton(); bind(ShardSlowLogSearchService.class).asEagerSingleton(); } diff --git a/src/main/java/org/elasticsearch/index/search/stats/ShardSearchService.java b/src/main/java/org/elasticsearch/index/search/stats/ShardSearchService.java index cc38a210b89..9ff09db14bd 100644 --- a/src/main/java/org/elasticsearch/index/search/stats/ShardSearchService.java +++ b/src/main/java/org/elasticsearch/index/search/stats/ShardSearchService.java @@ -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,7 +19,7 @@ package org.elasticsearch.index.search.stats; -import org.elasticsearch.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMap; import org.elasticsearch.common.collect.MapBuilder; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.metrics.CounterMetric; @@ -45,7 +45,8 @@ public class ShardSearchService extends AbstractIndexShardComponent { private volatile Map groupsStats = ImmutableMap.of(); - @Inject public ShardSearchService(ShardId shardId, @IndexSettings Settings indexSettings, ShardSlowLogSearchService slowLogSearchService) { + @Inject + public ShardSearchService(ShardId shardId, @IndexSettings Settings indexSettings, ShardSlowLogSearchService slowLogSearchService) { super(shardId, indexSettings); this.slowLogSearchService = slowLogSearchService; } diff --git a/src/main/java/org/elasticsearch/index/search/stats/StatsGroupsParseElement.java b/src/main/java/org/elasticsearch/index/search/stats/StatsGroupsParseElement.java index ce69c71a4d6..470063026c0 100644 --- a/src/main/java/org/elasticsearch/index/search/stats/StatsGroupsParseElement.java +++ b/src/main/java/org/elasticsearch/index/search/stats/StatsGroupsParseElement.java @@ -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,7 +19,7 @@ package org.elasticsearch.index.search.stats; -import org.elasticsearch.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.search.SearchParseElement; import org.elasticsearch.search.internal.SearchContext; @@ -31,7 +31,8 @@ import java.util.List; */ public class StatsGroupsParseElement implements SearchParseElement { - @Override public void parse(XContentParser parser, SearchContext context) throws Exception { + @Override + public void parse(XContentParser parser, SearchContext context) throws Exception { XContentParser.Token token = parser.currentToken(); if (token.isValue()) { context.groupStats(ImmutableList.of(parser.text())); diff --git a/src/main/java/org/elasticsearch/index/service/IndexService.java b/src/main/java/org/elasticsearch/index/service/IndexService.java index 930debe30a9..d26c8a61cb3 100644 --- a/src/main/java/org/elasticsearch/index/service/IndexService.java +++ b/src/main/java/org/elasticsearch/index/service/IndexService.java @@ -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.index.service; +import com.google.common.collect.ImmutableSet; import org.elasticsearch.ElasticSearchException; -import org.elasticsearch.common.collect.ImmutableSet; import org.elasticsearch.common.inject.Injector; import org.elasticsearch.index.IndexComponent; import org.elasticsearch.index.IndexShardMissingException; @@ -37,7 +37,7 @@ import org.elasticsearch.index.similarity.SimilarityService; import org.elasticsearch.index.store.IndexStore; /** - * @author kimchy (shay.banon) + * */ public interface IndexService extends IndexComponent, Iterable { diff --git a/src/main/java/org/elasticsearch/index/service/InternalIndexService.java b/src/main/java/org/elasticsearch/index/service/InternalIndexService.java index 12cf19c415c..0b11b974350 100644 --- a/src/main/java/org/elasticsearch/index/service/InternalIndexService.java +++ b/src/main/java/org/elasticsearch/index/service/InternalIndexService.java @@ -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,27 +19,19 @@ package org.elasticsearch.index.service; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.UnmodifiableIterator; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.ElasticSearchIllegalStateException; import org.elasticsearch.ElasticSearchInterruptedException; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.collect.UnmodifiableIterator; -import org.elasticsearch.common.inject.CreationException; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.inject.Injector; -import org.elasticsearch.common.inject.Injectors; -import org.elasticsearch.common.inject.ModulesBuilder; +import org.elasticsearch.common.inject.*; import org.elasticsearch.common.io.FileSystemUtils; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.gateway.none.NoneGateway; -import org.elasticsearch.index.AbstractIndexComponent; -import org.elasticsearch.index.CloseableIndexComponent; -import org.elasticsearch.index.Index; -import org.elasticsearch.index.IndexShardAlreadyExistsException; -import org.elasticsearch.index.IndexShardMissingException; +import org.elasticsearch.index.*; import org.elasticsearch.index.aliases.IndexAliasesService; import org.elasticsearch.index.analysis.AnalysisService; import org.elasticsearch.index.cache.IndexCache; @@ -85,11 +77,11 @@ import java.util.Set; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executor; -import static org.elasticsearch.common.collect.MapBuilder.*; -import static org.elasticsearch.common.collect.Maps.*; +import static com.google.common.collect.Maps.newHashMap; +import static org.elasticsearch.common.collect.MapBuilder.newMapBuilder; /** - * @author kimchy (shay.banon) + * */ public class InternalIndexService extends AbstractIndexComponent implements IndexService { @@ -131,10 +123,11 @@ public class InternalIndexService extends AbstractIndexComponent implements Inde private volatile boolean closed = false; - @Inject public InternalIndexService(Injector injector, Index index, @IndexSettings Settings indexSettings, NodeEnvironment nodeEnv, ThreadPool threadPool, - PercolatorService percolatorService, AnalysisService analysisService, MapperService mapperService, - IndexQueryParserService queryParserService, SimilarityService similarityService, IndexAliasesService aliasesService, - IndexCache indexCache, IndexEngine indexEngine, IndexGateway indexGateway, IndexStore indexStore) { + @Inject + public InternalIndexService(Injector injector, Index index, @IndexSettings Settings indexSettings, NodeEnvironment nodeEnv, ThreadPool threadPool, + PercolatorService percolatorService, AnalysisService analysisService, MapperService mapperService, + IndexQueryParserService queryParserService, SimilarityService similarityService, IndexAliasesService aliasesService, + IndexCache indexCache, IndexEngine indexEngine, IndexGateway indexGateway, IndexStore indexStore) { super(index, indexSettings); this.injector = injector; this.nodeEnv = nodeEnv; @@ -155,23 +148,28 @@ public class InternalIndexService extends AbstractIndexComponent implements Inde this.indicesLifecycle = (InternalIndicesLifecycle) injector.getInstance(IndicesLifecycle.class); } - @Override public int numberOfShards() { + @Override + public int numberOfShards() { return shards.size(); } - @Override public UnmodifiableIterator iterator() { + @Override + public UnmodifiableIterator iterator() { return shards.values().iterator(); } - @Override public boolean hasShard(int shardId) { + @Override + public boolean hasShard(int shardId) { return shards.containsKey(shardId); } - @Override public IndexShard shard(int shardId) { + @Override + public IndexShard shard(int shardId) { return shards.get(shardId); } - @Override public IndexShard shardSafe(int shardId) throws IndexShardMissingException { + @Override + public IndexShard shardSafe(int shardId) throws IndexShardMissingException { IndexShard indexShard = shard(shardId); if (indexShard == null) { throw new IndexShardMissingException(new ShardId(index, shardId)); @@ -179,51 +177,63 @@ public class InternalIndexService extends AbstractIndexComponent implements Inde return indexShard; } - @Override public ImmutableSet shardIds() { + @Override + public ImmutableSet shardIds() { return ImmutableSet.copyOf(shards.keySet()); } - @Override public Injector injector() { + @Override + public Injector injector() { return injector; } - @Override public IndexGateway gateway() { + @Override + public IndexGateway gateway() { return indexGateway; } - @Override public IndexStore store() { + @Override + public IndexStore store() { return indexStore; } - @Override public IndexCache cache() { + @Override + public IndexCache cache() { return indexCache; } - @Override public PercolatorService percolateService() { + @Override + public PercolatorService percolateService() { return this.percolatorService; } - @Override public AnalysisService analysisService() { + @Override + public AnalysisService analysisService() { return this.analysisService; } - @Override public MapperService mapperService() { + @Override + public MapperService mapperService() { return mapperService; } - @Override public IndexQueryParserService queryParserService() { + @Override + public IndexQueryParserService queryParserService() { return queryParserService; } - @Override public SimilarityService similarityService() { + @Override + public SimilarityService similarityService() { return similarityService; } - @Override public IndexAliasesService aliasesService() { + @Override + public IndexAliasesService aliasesService() { return aliasesService; } - @Override public IndexEngine engine() { + @Override + public IndexEngine engine() { return indexEngine; } @@ -236,7 +246,8 @@ public class InternalIndexService extends AbstractIndexComponent implements Inde for (final int shardId : shardIds) { executor = executor == null ? threadPool.cached() : executor; executor.execute(new Runnable() { - @Override public void run() { + @Override + public void run() { try { deleteShard(shardId, delete, !delete, delete, reason); } catch (Exception e) { @@ -254,11 +265,13 @@ public class InternalIndexService extends AbstractIndexComponent implements Inde } } - @Override public Injector shardInjector(int shardId) throws ElasticSearchException { + @Override + public Injector shardInjector(int shardId) throws ElasticSearchException { return shardsInjectors.get(shardId); } - @Override public Injector shardInjectorSafe(int shardId) throws IndexShardMissingException { + @Override + public Injector shardInjectorSafe(int shardId) throws IndexShardMissingException { Injector shardInjector = shardInjector(shardId); if (shardInjector == null) { throw new IndexShardMissingException(new ShardId(index, shardId)); @@ -266,7 +279,8 @@ public class InternalIndexService extends AbstractIndexComponent implements Inde return shardInjector; } - @Override public synchronized IndexShard createShard(int sShardId) throws ElasticSearchException { + @Override + public synchronized IndexShard createShard(int sShardId) throws ElasticSearchException { if (closed) { throw new ElasticSearchIllegalStateException("Can't create shard [" + index.name() + "][" + sShardId + "], closed"); } @@ -311,11 +325,13 @@ public class InternalIndexService extends AbstractIndexComponent implements Inde return indexShard; } - @Override public synchronized void cleanShard(int shardId, String reason) throws ElasticSearchException { + @Override + public synchronized void cleanShard(int shardId, String reason) throws ElasticSearchException { deleteShard(shardId, true, false, false, reason); } - @Override public synchronized void removeShard(int shardId, String reason) throws ElasticSearchException { + @Override + public synchronized void removeShard(int shardId, String reason) throws ElasticSearchException { deleteShard(shardId, false, false, false, reason); } diff --git a/src/main/java/org/elasticsearch/index/settings/IndexSettings.java b/src/main/java/org/elasticsearch/index/settings/IndexSettings.java index b66a4f5db53..908eca3cc40 100644 --- a/src/main/java/org/elasticsearch/index/settings/IndexSettings.java +++ b/src/main/java/org/elasticsearch/index/settings/IndexSettings.java @@ -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,11 +25,12 @@ import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.Target; -import static java.lang.annotation.ElementType.*; -import static java.lang.annotation.RetentionPolicy.*; +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.RetentionPolicy.RUNTIME; /** - * @author kimchy (Shay Banon) + * */ @BindingAnnotation diff --git a/src/main/java/org/elasticsearch/index/settings/IndexSettingsModule.java b/src/main/java/org/elasticsearch/index/settings/IndexSettingsModule.java index 0df677424ed..5e60b470649 100644 --- a/src/main/java/org/elasticsearch/index/settings/IndexSettingsModule.java +++ b/src/main/java/org/elasticsearch/index/settings/IndexSettingsModule.java @@ -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.common.settings.Settings; import org.elasticsearch.index.Index; /** - * @author kimchy (shay.banon) + * */ public class IndexSettingsModule extends AbstractModule { @@ -37,7 +37,8 @@ public class IndexSettingsModule extends AbstractModule { this.settings = settings; } - @Override protected void configure() { + @Override + protected void configure() { IndexSettingsService indexSettingsService = new IndexSettingsService(index, settings); bind(IndexSettingsService.class).toInstance(indexSettingsService); bind(Settings.class).annotatedWith(IndexSettings.class).toProvider(new IndexSettingsProvider(indexSettingsService)); diff --git a/src/main/java/org/elasticsearch/index/settings/IndexSettingsProvider.java b/src/main/java/org/elasticsearch/index/settings/IndexSettingsProvider.java index a15a4e6f510..5e6b68dc443 100644 --- a/src/main/java/org/elasticsearch/index/settings/IndexSettingsProvider.java +++ b/src/main/java/org/elasticsearch/index/settings/IndexSettingsProvider.java @@ -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,11 +32,13 @@ public class IndexSettingsProvider implements Provider { private final IndexSettingsService indexSettingsService; - @Inject public IndexSettingsProvider(IndexSettingsService indexSettingsService) { + @Inject + public IndexSettingsProvider(IndexSettingsService indexSettingsService) { this.indexSettingsService = indexSettingsService; } - @Override public Settings get() { + @Override + public Settings get() { return indexSettingsService.getSettings(); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/settings/IndexSettingsService.java b/src/main/java/org/elasticsearch/index/settings/IndexSettingsService.java index 216d714ce6d..2dc3d1e2eaf 100644 --- a/src/main/java/org/elasticsearch/index/settings/IndexSettingsService.java +++ b/src/main/java/org/elasticsearch/index/settings/IndexSettingsService.java @@ -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,7 +36,8 @@ public class IndexSettingsService extends AbstractIndexComponent { private final CopyOnWriteArrayList listeners = new CopyOnWriteArrayList(); - @Inject public IndexSettingsService(Index index, Settings settings) { + @Inject + public IndexSettingsService(Index index, Settings settings) { super(index, settings); this.settings = settings; } diff --git a/src/main/java/org/elasticsearch/index/shard/AbstractIndexShardComponent.java b/src/main/java/org/elasticsearch/index/shard/AbstractIndexShardComponent.java index aaf178b4213..1d192422d8f 100644 --- a/src/main/java/org/elasticsearch/index/shard/AbstractIndexShardComponent.java +++ b/src/main/java/org/elasticsearch/index/shard/AbstractIndexShardComponent.java @@ -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,10 +25,10 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.jmx.ManagedGroupName; -import static org.elasticsearch.index.shard.IndexShardManagement.*; +import static org.elasticsearch.index.shard.IndexShardManagement.buildShardGroupName; /** - * @author kimchy (shay.banon) + * */ public abstract class AbstractIndexShardComponent implements IndexShardComponent { @@ -56,11 +56,13 @@ public abstract class AbstractIndexShardComponent implements IndexShardComponent this.logger = Loggers.getLogger(getClass(), indexSettings, shardId); } - @Override public ShardId shardId() { + @Override + public ShardId shardId() { return this.shardId; } - @Override public Settings indexSettings() { + @Override + public Settings indexSettings() { return this.indexSettings; } diff --git a/src/main/java/org/elasticsearch/index/shard/DocsStats.java b/src/main/java/org/elasticsearch/index/shard/DocsStats.java index fd59b4171a5..831217c3912 100644 --- a/src/main/java/org/elasticsearch/index/shard/DocsStats.java +++ b/src/main/java/org/elasticsearch/index/shard/DocsStats.java @@ -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,17 +74,20 @@ public class DocsStats implements Streamable, ToXContent { return docsStats; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { count = in.readVLong(); deleted = in.readVLong(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeVLong(count); out.writeVLong(deleted); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(Fields.DOCS); builder.field(Fields.COUNT, count); builder.field(Fields.DELETED, deleted); diff --git a/src/main/java/org/elasticsearch/index/shard/IllegalIndexShardStateException.java b/src/main/java/org/elasticsearch/index/shard/IllegalIndexShardStateException.java index 9f899029985..d5b24f0e14d 100644 --- a/src/main/java/org/elasticsearch/index/shard/IllegalIndexShardStateException.java +++ b/src/main/java/org/elasticsearch/index/shard/IllegalIndexShardStateException.java @@ -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.index.shard; /** - * @author kimchy (Shay Banon) + * */ public class IllegalIndexShardStateException extends IndexShardException { diff --git a/src/main/java/org/elasticsearch/index/shard/IndexShardClosedException.java b/src/main/java/org/elasticsearch/index/shard/IndexShardClosedException.java index b51126ee4f1..cd9f741c531 100644 --- a/src/main/java/org/elasticsearch/index/shard/IndexShardClosedException.java +++ b/src/main/java/org/elasticsearch/index/shard/IndexShardClosedException.java @@ -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.index.shard; /** - * @author kimchy (Shay Banon) + * */ public class IndexShardClosedException extends IllegalIndexShardStateException { public IndexShardClosedException(ShardId shardId) { diff --git a/src/main/java/org/elasticsearch/index/shard/IndexShardComponent.java b/src/main/java/org/elasticsearch/index/shard/IndexShardComponent.java index 6a2b315dafc..70007ae43ff 100644 --- a/src/main/java/org/elasticsearch/index/shard/IndexShardComponent.java +++ b/src/main/java/org/elasticsearch/index/shard/IndexShardComponent.java @@ -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.index.shard; import org.elasticsearch.common.settings.Settings; /** - * @author kimchy (Shay Banon) + * */ public interface IndexShardComponent { diff --git a/src/main/java/org/elasticsearch/index/shard/IndexShardCreationException.java b/src/main/java/org/elasticsearch/index/shard/IndexShardCreationException.java index d23e820e1d1..a51eb86410a 100644 --- a/src/main/java/org/elasticsearch/index/shard/IndexShardCreationException.java +++ b/src/main/java/org/elasticsearch/index/shard/IndexShardCreationException.java @@ -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 diff --git a/src/main/java/org/elasticsearch/index/shard/IndexShardException.java b/src/main/java/org/elasticsearch/index/shard/IndexShardException.java index cebc30c7f4f..33c6cf9860d 100644 --- a/src/main/java/org/elasticsearch/index/shard/IndexShardException.java +++ b/src/main/java/org/elasticsearch/index/shard/IndexShardException.java @@ -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.index.shard; import org.elasticsearch.index.IndexException; /** - * @author kimchy (Shay Banon) + * */ public class IndexShardException extends IndexException { diff --git a/src/main/java/org/elasticsearch/index/shard/IndexShardManagement.java b/src/main/java/org/elasticsearch/index/shard/IndexShardManagement.java index 71934fb6b6d..f608e9a335b 100644 --- a/src/main/java/org/elasticsearch/index/shard/IndexShardManagement.java +++ b/src/main/java/org/elasticsearch/index/shard/IndexShardManagement.java @@ -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,10 +34,10 @@ import org.elasticsearch.jmx.ManagedAttribute; import java.io.IOException; -import static org.elasticsearch.index.IndexServiceManagement.*; +import static org.elasticsearch.index.IndexServiceManagement.buildIndexGroupName; /** - * @author kimchy (Shay Banon) + * */ @MBean(objectName = "", description = "") public class IndexShardManagement extends AbstractIndexShardComponent implements CloseableComponent { @@ -54,8 +54,9 @@ public class IndexShardManagement extends AbstractIndexShardComponent implements private final Translog translog; - @Inject public IndexShardManagement(ShardId shardId, @IndexSettings Settings indexSettings, JmxService jmxService, IndexShard indexShard, - Store store, Translog translog) { + @Inject + public IndexShardManagement(ShardId shardId, @IndexSettings Settings indexSettings, JmxService jmxService, IndexShard indexShard, + Store store, Translog translog) { super(shardId, indexSettings); this.jmxService = jmxService; this.indexShard = indexShard; diff --git a/src/main/java/org/elasticsearch/index/shard/IndexShardModule.java b/src/main/java/org/elasticsearch/index/shard/IndexShardModule.java index 92ec02edfe5..b39a7760d99 100644 --- a/src/main/java/org/elasticsearch/index/shard/IndexShardModule.java +++ b/src/main/java/org/elasticsearch/index/shard/IndexShardModule.java @@ -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.index.shard.service.IndexShard; import org.elasticsearch.index.shard.service.InternalIndexShard; /** - * @author kimchy (shay.banon) + * */ public class IndexShardModule extends AbstractModule { @@ -34,7 +34,8 @@ public class IndexShardModule extends AbstractModule { this.shardId = shardId; } - @Override protected void configure() { + @Override + protected void configure() { bind(ShardId.class).toInstance(shardId); bind(IndexShard.class).to(InternalIndexShard.class).asEagerSingleton(); bind(IndexShardManagement.class).asEagerSingleton(); diff --git a/src/main/java/org/elasticsearch/index/shard/IndexShardNotRecoveringException.java b/src/main/java/org/elasticsearch/index/shard/IndexShardNotRecoveringException.java index b0179ac4447..c6510338dde 100644 --- a/src/main/java/org/elasticsearch/index/shard/IndexShardNotRecoveringException.java +++ b/src/main/java/org/elasticsearch/index/shard/IndexShardNotRecoveringException.java @@ -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.index.shard; /** - * @author kimchy (Shay Banon) + * */ public class IndexShardNotRecoveringException extends IllegalIndexShardStateException { diff --git a/src/main/java/org/elasticsearch/index/shard/IndexShardNotStartedException.java b/src/main/java/org/elasticsearch/index/shard/IndexShardNotStartedException.java index e14de790367..91e5e5692c5 100644 --- a/src/main/java/org/elasticsearch/index/shard/IndexShardNotStartedException.java +++ b/src/main/java/org/elasticsearch/index/shard/IndexShardNotStartedException.java @@ -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.index.shard; /** - * @author kimchy (Shay Banon) + * */ public class IndexShardNotStartedException extends IllegalIndexShardStateException { diff --git a/src/main/java/org/elasticsearch/index/shard/IndexShardRecoveringException.java b/src/main/java/org/elasticsearch/index/shard/IndexShardRecoveringException.java index b3978a218da..980651f324b 100644 --- a/src/main/java/org/elasticsearch/index/shard/IndexShardRecoveringException.java +++ b/src/main/java/org/elasticsearch/index/shard/IndexShardRecoveringException.java @@ -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.index.shard; /** - * @author kimchy (Shay Banon) + * */ public class IndexShardRecoveringException extends IllegalIndexShardStateException { diff --git a/src/main/java/org/elasticsearch/index/shard/IndexShardRelocatedException.java b/src/main/java/org/elasticsearch/index/shard/IndexShardRelocatedException.java index a650588bd18..33a26e75b8e 100644 --- a/src/main/java/org/elasticsearch/index/shard/IndexShardRelocatedException.java +++ b/src/main/java/org/elasticsearch/index/shard/IndexShardRelocatedException.java @@ -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.index.shard; /** - * @author kimchy (Shay Banon) + * */ public class IndexShardRelocatedException extends IllegalIndexShardStateException { diff --git a/src/main/java/org/elasticsearch/index/shard/IndexShardStartedException.java b/src/main/java/org/elasticsearch/index/shard/IndexShardStartedException.java index cfff25e1bc3..f97cd7ceab0 100644 --- a/src/main/java/org/elasticsearch/index/shard/IndexShardStartedException.java +++ b/src/main/java/org/elasticsearch/index/shard/IndexShardStartedException.java @@ -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.index.shard; /** - * @author kimchy (Shay Banon) + * */ public class IndexShardStartedException extends IllegalIndexShardStateException { diff --git a/src/main/java/org/elasticsearch/index/shard/IndexShardState.java b/src/main/java/org/elasticsearch/index/shard/IndexShardState.java index 7946958161d..d219786ece3 100644 --- a/src/main/java/org/elasticsearch/index/shard/IndexShardState.java +++ b/src/main/java/org/elasticsearch/index/shard/IndexShardState.java @@ -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.index.shard; import org.elasticsearch.ElasticSearchIllegalArgumentException; /** - * @author kimchy (Shay Banon) + * */ public enum IndexShardState { CREATED((byte) 0), diff --git a/src/main/java/org/elasticsearch/index/shard/ShardId.java b/src/main/java/org/elasticsearch/index/shard/ShardId.java index 7870523e44d..05fb74a4fc4 100644 --- a/src/main/java/org/elasticsearch/index/shard/ShardId.java +++ b/src/main/java/org/elasticsearch/index/shard/ShardId.java @@ -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,7 +31,7 @@ import java.io.Serializable; /** * Allows for shard level components to be injected with the shard id. * - * @author kimchy (Shay Banon) + * */ @Immutable public class ShardId implements Serializable, Streamable { @@ -72,18 +72,21 @@ public class ShardId implements Serializable, Streamable { return id(); } - @Override public String toString() { + @Override + public String toString() { return "Index Shard [" + index.name() + "][" + shardId + "]"; } - @Override public boolean equals(Object o) { + @Override + public boolean equals(Object o) { if (this == o) return true; if (o == null) return false; ShardId shardId1 = (ShardId) o; return shardId == shardId1.shardId && index.name().equals(shardId1.index.name()); } - @Override public int hashCode() { + @Override + public int hashCode() { return hashCode; } @@ -99,12 +102,14 @@ public class ShardId implements Serializable, Streamable { return shardId; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { index = Index.readIndexName(in); shardId = in.readVInt(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { index.writeTo(out); out.writeVInt(shardId); } diff --git a/src/main/java/org/elasticsearch/index/shard/service/IndexShard.java b/src/main/java/org/elasticsearch/index/shard/service/IndexShard.java index 5b1354a0319..0457ad503ef 100644 --- a/src/main/java/org/elasticsearch/index/shard/service/IndexShard.java +++ b/src/main/java/org/elasticsearch/index/shard/service/IndexShard.java @@ -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 @@ -42,7 +42,7 @@ import org.elasticsearch.index.shard.IndexShardState; import org.elasticsearch.index.store.StoreStats; /** - * @author kimchy (shay.banon) + * */ @ThreadSafe public interface IndexShard extends IndexShardComponent { diff --git a/src/main/java/org/elasticsearch/index/shard/service/InternalIndexShard.java b/src/main/java/org/elasticsearch/index/shard/service/InternalIndexShard.java index 4bb205a08a7..520be6b0a02 100644 --- a/src/main/java/org/elasticsearch/index/shard/service/InternalIndexShard.java +++ b/src/main/java/org/elasticsearch/index/shard/service/InternalIndexShard.java @@ -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 @@ -42,22 +42,13 @@ import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.concurrent.ThreadSafe; import org.elasticsearch.index.aliases.IndexAliasesService; import org.elasticsearch.index.cache.IndexCache; -import org.elasticsearch.index.engine.Engine; -import org.elasticsearch.index.engine.EngineClosedException; -import org.elasticsearch.index.engine.EngineException; -import org.elasticsearch.index.engine.IgnoreOnRecoveryEngineException; -import org.elasticsearch.index.engine.OptimizeFailedEngineException; -import org.elasticsearch.index.engine.RefreshFailedEngineException; +import org.elasticsearch.index.engine.*; import org.elasticsearch.index.flush.FlushStats; import org.elasticsearch.index.get.GetStats; import org.elasticsearch.index.get.ShardGetService; import org.elasticsearch.index.indexing.IndexingStats; import org.elasticsearch.index.indexing.ShardIndexingService; -import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.mapper.MapperService; -import org.elasticsearch.index.mapper.ParsedDocument; -import org.elasticsearch.index.mapper.SourceToParse; -import org.elasticsearch.index.mapper.Uid; +import org.elasticsearch.index.mapper.*; import org.elasticsearch.index.merge.MergeStats; import org.elasticsearch.index.merge.scheduler.MergeSchedulerProvider; import org.elasticsearch.index.query.IndexQueryParserService; @@ -81,10 +72,10 @@ import java.nio.channels.ClosedByInterruptException; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; -import static org.elasticsearch.index.mapper.SourceToParse.*; +import static org.elasticsearch.index.mapper.SourceToParse.source; /** - * @author kimchy (shay.banon) + * */ @ThreadSafe public class InternalIndexShard extends AbstractIndexShardComponent implements IndexShard { @@ -140,8 +131,9 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I private final MeanMetric refreshMetric = new MeanMetric(); private final MeanMetric flushMetric = new MeanMetric(); - @Inject public InternalIndexShard(ShardId shardId, @IndexSettings Settings indexSettings, IndexSettingsService indexSettingsService, IndicesLifecycle indicesLifecycle, Store store, Engine engine, MergeSchedulerProvider mergeScheduler, Translog translog, - ThreadPool threadPool, MapperService mapperService, IndexQueryParserService queryParserService, IndexCache indexCache, IndexAliasesService indexAliasesService, ShardIndexingService indexingService, ShardGetService getService, ShardSearchService searchService) { + @Inject + public InternalIndexShard(ShardId shardId, @IndexSettings Settings indexSettings, IndexSettingsService indexSettingsService, IndicesLifecycle indicesLifecycle, Store store, Engine engine, MergeSchedulerProvider mergeScheduler, Translog translog, + ThreadPool threadPool, MapperService mapperService, IndexQueryParserService queryParserService, IndexCache indexCache, IndexAliasesService indexAliasesService, ShardIndexingService indexingService, ShardGetService getService, ShardSearchService searchService) { super(shardId, indexSettings); this.indicesLifecycle = (InternalIndicesLifecycle) indicesLifecycle; this.indexSettingsService = indexSettingsService; @@ -189,15 +181,18 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I return this.indexingService; } - @Override public ShardGetService getService() { + @Override + public ShardGetService getService() { return this.getService; } - @Override public ShardSearchService searchService() { + @Override + public ShardSearchService searchService() { return this.searchService; } - @Override public ShardRouting routingEntry() { + @Override + public ShardRouting routingEntry() { return this.shardRouting; } @@ -273,18 +268,21 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I return this; } - @Override public IndexShardState state() { + @Override + public IndexShardState state() { return state; } - @Override public Engine.Create prepareCreate(SourceToParse source) throws ElasticSearchException { + @Override + public Engine.Create prepareCreate(SourceToParse source) throws ElasticSearchException { long startTime = System.nanoTime(); DocumentMapper docMapper = mapperService.documentMapperWithAutoCreate(source.type()); ParsedDocument doc = docMapper.parse(source); return new Engine.Create(docMapper, docMapper.uidMapper().term(doc.uid()), doc).startTime(startTime); } - @Override public ParsedDocument create(Engine.Create create) throws ElasticSearchException { + @Override + public ParsedDocument create(Engine.Create create) throws ElasticSearchException { writeAllowed(); create = indexingService.preCreate(create); if (logger.isTraceEnabled()) { @@ -296,14 +294,16 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I return create.parsedDoc(); } - @Override public Engine.Index prepareIndex(SourceToParse source) throws ElasticSearchException { + @Override + public Engine.Index prepareIndex(SourceToParse source) throws ElasticSearchException { long startTime = System.nanoTime(); DocumentMapper docMapper = mapperService.documentMapperWithAutoCreate(source.type()); ParsedDocument doc = docMapper.parse(source); return new Engine.Index(docMapper, docMapper.uidMapper().term(doc.uid()), doc).startTime(startTime); } - @Override public ParsedDocument index(Engine.Index index) throws ElasticSearchException { + @Override + public ParsedDocument index(Engine.Index index) throws ElasticSearchException { writeAllowed(); index = indexingService.preIndex(index); try { @@ -320,13 +320,15 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I return index.parsedDoc(); } - @Override public Engine.Delete prepareDelete(String type, String id, long version) throws ElasticSearchException { + @Override + public Engine.Delete prepareDelete(String type, String id, long version) throws ElasticSearchException { long startTime = System.nanoTime(); DocumentMapper docMapper = mapperService.documentMapperWithAutoCreate(type); return new Engine.Delete(type, id, docMapper.uidMapper().term(type, id)).version(version).startTime(startTime); } - @Override public void delete(Engine.Delete delete) throws ElasticSearchException { + @Override + public void delete(Engine.Delete delete) throws ElasticSearchException { writeAllowed(); delete = indexingService.preDelete(delete); try { @@ -342,7 +344,8 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I indexingService.postDelete(delete); } - @Override public Engine.DeleteByQuery prepareDeleteByQuery(byte[] querySource, @Nullable String[] filteringAliases, String... types) throws ElasticSearchException { + @Override + public Engine.DeleteByQuery prepareDeleteByQuery(byte[] querySource, @Nullable String[] filteringAliases, String... types) throws ElasticSearchException { long startTime = System.nanoTime(); if (types == null) { types = Strings.EMPTY_ARRAY; @@ -355,7 +358,8 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I return new Engine.DeleteByQuery(query, querySource, filteringAliases, aliasFilter, types).startTime(startTime); } - @Override public void deleteByQuery(Engine.DeleteByQuery deleteByQuery) throws ElasticSearchException { + @Override + public void deleteByQuery(Engine.DeleteByQuery deleteByQuery) throws ElasticSearchException { writeAllowed(); if (logger.isTraceEnabled()) { logger.trace("delete_by_query [{}]", deleteByQuery.query()); @@ -366,17 +370,20 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I indexingService.postDeleteByQuery(deleteByQuery); } - @Override public Engine.GetResult get(Engine.Get get) throws ElasticSearchException { + @Override + public Engine.GetResult get(Engine.Get get) throws ElasticSearchException { readAllowed(); return engine.get(get); } - @Override public long count(float minScore, byte[] querySource, @Nullable String[] filteringAliases, String... types) throws ElasticSearchException { + @Override + public long count(float minScore, byte[] querySource, @Nullable String[] filteringAliases, String... types) throws ElasticSearchException { return count(minScore, querySource, 0, querySource.length, filteringAliases, types); } - @Override public long count(float minScore, byte[] querySource, int querySourceOffset, int querySourceLength, - @Nullable String[] filteringAliases, String... types) throws ElasticSearchException { + @Override + public long count(float minScore, byte[] querySource, int querySourceOffset, int querySourceLength, + @Nullable String[] filteringAliases, String... types) throws ElasticSearchException { readAllowed(); Query query; if (querySourceLength == 0) { @@ -403,7 +410,8 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I } } - @Override public void refresh(Engine.Refresh refresh) throws ElasticSearchException { + @Override + public void refresh(Engine.Refresh refresh) throws ElasticSearchException { writeAllowed(); if (logger.isTraceEnabled()) { logger.trace("refresh with {}", refresh); @@ -413,15 +421,18 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I refreshMetric.inc(System.nanoTime() - time); } - @Override public RefreshStats refreshStats() { + @Override + public RefreshStats refreshStats() { return new RefreshStats(refreshMetric.count(), TimeUnit.NANOSECONDS.toMillis(refreshMetric.sum())); } - @Override public FlushStats flushStats() { + @Override + public FlushStats flushStats() { return new FlushStats(flushMetric.count(), TimeUnit.NANOSECONDS.toMillis(flushMetric.sum())); } - @Override public DocsStats docStats() { + @Override + public DocsStats docStats() { Engine.Searcher searcher = null; try { searcher = engine.searcher(); @@ -435,19 +446,23 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I } } - @Override public IndexingStats indexingStats(String... types) { + @Override + public IndexingStats indexingStats(String... types) { return indexingService.stats(types); } - @Override public SearchStats searchStats(String... groups) { + @Override + public SearchStats searchStats(String... groups) { return searchService.stats(groups); } - @Override public GetStats getStats() { + @Override + public GetStats getStats() { return getService.stats(); } - @Override public StoreStats storeStats() { + @Override + public StoreStats storeStats() { try { return store.stats(); } catch (IOException e) { @@ -455,11 +470,13 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I } } - @Override public MergeStats mergeStats() { + @Override + public MergeStats mergeStats() { return mergeScheduler.stats(); } - @Override public void flush(Engine.Flush flush) throws ElasticSearchException { + @Override + public void flush(Engine.Flush flush) throws ElasticSearchException { writeAllowed(); if (logger.isTraceEnabled()) { logger.trace("flush with {}", flush); @@ -469,7 +486,8 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I flushMetric.inc(System.nanoTime() - time); } - @Override public void optimize(Engine.Optimize optimize) throws ElasticSearchException { + @Override + public void optimize(Engine.Optimize optimize) throws ElasticSearchException { writeAllowed(); if (logger.isTraceEnabled()) { logger.trace("optimize with {}", optimize); @@ -477,7 +495,8 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I engine.optimize(optimize); } - @Override public T snapshot(Engine.SnapshotHandler snapshotHandler) throws EngineException { + @Override + public T snapshot(Engine.SnapshotHandler snapshotHandler) throws EngineException { IndexShardState state = this.state; // one time volatile read // we allow snapshot on closed index shard, since we want to do one after we close the shard and before we close the engine if (state != IndexShardState.STARTED && state != IndexShardState.RELOCATED && state != IndexShardState.CLOSED) { @@ -486,12 +505,14 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I return engine.snapshot(snapshotHandler); } - @Override public void recover(Engine.RecoveryHandler recoveryHandler) throws EngineException { + @Override + public void recover(Engine.RecoveryHandler recoveryHandler) throws EngineException { writeAllowed(); engine.recover(recoveryHandler); } - @Override public Engine.Searcher searcher() { + @Override + public Engine.Searcher searcher() { readAllowed(); return engine.searcher(); } @@ -660,7 +681,8 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I } private class ApplyRefreshSettings implements IndexSettingsService.Listener { - @Override public void onRefreshSettings(Settings settings) { + @Override + public void onRefreshSettings(Settings settings) { synchronized (mutex) { if (state == IndexShardState.CLOSED) { return; @@ -682,7 +704,8 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I } private class EngineRefresher implements Runnable { - @Override public void run() { + @Override + public void run() { // we check before if a refresh is needed, if not, we reschedule, otherwise, we fork, refresh, and then reschedule if (!engine().refreshNeeded()) { synchronized (mutex) { @@ -693,7 +716,8 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I return; } threadPool.cached().execute(new Runnable() { - @Override public void run() { + @Override + public void run() { try { if (engine.refreshNeeded()) { refresh(new Engine.Refresh(false)); @@ -728,7 +752,8 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I } private class EngineMerger implements Runnable { - @Override public void run() { + @Override + public void run() { if (!engine().possibleMergeNeeded()) { synchronized (mutex) { if (state != IndexShardState.CLOSED) { @@ -738,7 +763,8 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I return; } threadPool.executor(ThreadPool.Names.MERGE).execute(new Runnable() { - @Override public void run() { + @Override + public void run() { try { engine.maybeMerge(); } catch (EngineClosedException e) { diff --git a/src/main/java/org/elasticsearch/index/similarity/AbstractSimilarityProvider.java b/src/main/java/org/elasticsearch/index/similarity/AbstractSimilarityProvider.java index a90dcdb1c8f..88b0ab3d7e5 100644 --- a/src/main/java/org/elasticsearch/index/similarity/AbstractSimilarityProvider.java +++ b/src/main/java/org/elasticsearch/index/similarity/AbstractSimilarityProvider.java @@ -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.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (Shay Banon) + * */ public abstract class AbstractSimilarityProvider extends AbstractIndexComponent implements SimilarityProvider { @@ -37,7 +37,8 @@ public abstract class AbstractSimilarityProvider extends A this.name = name; } - @Override public String name() { + @Override + public String name() { return this.name; } } diff --git a/src/main/java/org/elasticsearch/index/similarity/DefaultSimilarityProvider.java b/src/main/java/org/elasticsearch/index/similarity/DefaultSimilarityProvider.java index 0f0d6e5d6b9..afbe4fc0d2c 100644 --- a/src/main/java/org/elasticsearch/index/similarity/DefaultSimilarityProvider.java +++ b/src/main/java/org/elasticsearch/index/similarity/DefaultSimilarityProvider.java @@ -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,18 +27,20 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.settings.IndexSettings; /** - * @author kimchy (Shay Banon) + * */ public class DefaultSimilarityProvider extends AbstractSimilarityProvider { private DefaultSimilarity similarity; - @Inject public DefaultSimilarityProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public DefaultSimilarityProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name); this.similarity = new DefaultSimilarity(); } - @Override public DefaultSimilarity get() { + @Override + public DefaultSimilarity get() { return similarity; } } diff --git a/src/main/java/org/elasticsearch/index/similarity/SimilarityModule.java b/src/main/java/org/elasticsearch/index/similarity/SimilarityModule.java index 864e90d2f5b..a7d88923bae 100644 --- a/src/main/java/org/elasticsearch/index/similarity/SimilarityModule.java +++ b/src/main/java/org/elasticsearch/index/similarity/SimilarityModule.java @@ -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.settings.Settings; import java.util.Map; /** - * @author kimchy (Shay Banon) + * */ public class SimilarityModule extends AbstractModule { @@ -38,7 +38,8 @@ public class SimilarityModule extends AbstractModule { this.settings = settings; } - @Override protected void configure() { + @Override + protected void configure() { MapBinder similarityBinder = MapBinder.newMapBinder(binder(), String.class, SimilarityProviderFactory.class); diff --git a/src/main/java/org/elasticsearch/index/similarity/SimilarityProvider.java b/src/main/java/org/elasticsearch/index/similarity/SimilarityProvider.java index abc44f30a8d..b867f70352e 100644 --- a/src/main/java/org/elasticsearch/index/similarity/SimilarityProvider.java +++ b/src/main/java/org/elasticsearch/index/similarity/SimilarityProvider.java @@ -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.common.inject.Provider; import org.elasticsearch.index.IndexComponent; /** - * @author kimchy (Shay Banon) + * */ public interface SimilarityProvider extends IndexComponent, Provider { diff --git a/src/main/java/org/elasticsearch/index/similarity/SimilarityProviderFactory.java b/src/main/java/org/elasticsearch/index/similarity/SimilarityProviderFactory.java index 0cce0a841f6..05ae9efdc7a 100644 --- a/src/main/java/org/elasticsearch/index/similarity/SimilarityProviderFactory.java +++ b/src/main/java/org/elasticsearch/index/similarity/SimilarityProviderFactory.java @@ -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.index.similarity; import org.elasticsearch.common.settings.Settings; /** - * @author kimchy (Shay Banon) + * */ public interface SimilarityProviderFactory { diff --git a/src/main/java/org/elasticsearch/index/similarity/SimilarityService.java b/src/main/java/org/elasticsearch/index/similarity/SimilarityService.java index b5c9b138202..ca39c78a26e 100644 --- a/src/main/java/org/elasticsearch/index/similarity/SimilarityService.java +++ b/src/main/java/org/elasticsearch/index/similarity/SimilarityService.java @@ -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.index.similarity; +import com.google.common.collect.ImmutableMap; import org.apache.lucene.search.Similarity; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; @@ -31,10 +31,10 @@ import org.elasticsearch.index.settings.IndexSettings; import java.util.Map; -import static org.elasticsearch.common.collect.Maps.*; +import static com.google.common.collect.Maps.newHashMap; /** - * @author kimchy (Shay Banon) + * */ public class SimilarityService extends AbstractIndexComponent { @@ -46,8 +46,9 @@ public class SimilarityService extends AbstractIndexComponent { this(index, ImmutableSettings.Builder.EMPTY_SETTINGS, null); } - @Inject public SimilarityService(Index index, @IndexSettings Settings indexSettings, - @Nullable Map providerFactories) { + @Inject + public SimilarityService(Index index, @IndexSettings Settings indexSettings, + @Nullable Map providerFactories) { super(index, indexSettings); Map similarityProviders = newHashMap(); diff --git a/src/main/java/org/elasticsearch/index/store/DirectoryService.java b/src/main/java/org/elasticsearch/index/store/DirectoryService.java index 5687a34b1a9..769aae01aa7 100644 --- a/src/main/java/org/elasticsearch/index/store/DirectoryService.java +++ b/src/main/java/org/elasticsearch/index/store/DirectoryService.java @@ -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 diff --git a/src/main/java/org/elasticsearch/index/store/IndexStore.java b/src/main/java/org/elasticsearch/index/store/IndexStore.java index 27c3eedf26a..95e0f3bfe63 100644 --- a/src/main/java/org/elasticsearch/index/store/IndexStore.java +++ b/src/main/java/org/elasticsearch/index/store/IndexStore.java @@ -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; /** * Index store is an index level information of the {@link Store} each shard will use. * - * @author kimchy (shay.banon) + * */ public interface IndexStore extends IndexComponent { diff --git a/src/main/java/org/elasticsearch/index/store/IndexStoreModule.java b/src/main/java/org/elasticsearch/index/store/IndexStoreModule.java index c213387c0d9..46b5721e943 100644 --- a/src/main/java/org/elasticsearch/index/store/IndexStoreModule.java +++ b/src/main/java/org/elasticsearch/index/store/IndexStoreModule.java @@ -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.index.store; +import com.google.common.collect.ImmutableList; import org.apache.lucene.store.MMapDirectory; import org.apache.lucene.util.Constants; -import org.elasticsearch.common.collect.ImmutableList; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.inject.Modules; @@ -34,7 +34,7 @@ import org.elasticsearch.index.store.memory.MemoryIndexStoreModule; import org.elasticsearch.index.store.ram.RamIndexStoreModule; /** - * @author kimchy (shay.banon) + * */ public class IndexStoreModule extends AbstractModule implements SpawnModules { @@ -44,7 +44,8 @@ public class IndexStoreModule extends AbstractModule implements SpawnModules { this.settings = settings; } - @Override public Iterable spawnModules() { + @Override + public Iterable spawnModules() { Class indexStoreModule = NioFsIndexStoreModule.class; // Same logic as FSDirectory#open ... if ((Constants.WINDOWS || Constants.SUN_OS) @@ -72,6 +73,7 @@ public class IndexStoreModule extends AbstractModule implements SpawnModules { return ImmutableList.of(Modules.createModule(indexStoreModule, settings)); } - @Override protected void configure() { + @Override + protected void configure() { } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/store/Store.java b/src/main/java/org/elasticsearch/index/store/Store.java index 55ecdc52634..3af35610582 100644 --- a/src/main/java/org/elasticsearch/index/store/Store.java +++ b/src/main/java/org/elasticsearch/index/store/Store.java @@ -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,23 +19,17 @@ package org.elasticsearch.index.store; -import org.apache.lucene.store.Directory; -import org.apache.lucene.store.FSDirectory; -import org.apache.lucene.store.IndexInput; -import org.apache.lucene.store.IndexOutput; -import org.apache.lucene.store.Lock; -import org.apache.lucene.store.LockFactory; -import org.apache.lucene.store.SimpleFSDirectory; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; +import jsr166y.ThreadLocalRandom; +import org.apache.lucene.store.*; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.collect.MapBuilder; -import org.elasticsearch.common.collect.Maps; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.lucene.Directories; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.ByteSizeValue; -import org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom; import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.index.shard.AbstractIndexShardComponent; import org.elasticsearch.index.shard.ShardId; @@ -75,7 +69,8 @@ public class Store extends AbstractIndexShardComponent { private final boolean sync; - @Inject public Store(ShardId shardId, @IndexSettings Settings indexSettings, IndexStore indexStore, DirectoryService directoryService) throws IOException { + @Inject + public Store(ShardId shardId, @IndexSettings Settings indexSettings, IndexStore indexStore, DirectoryService directoryService) throws IOException { super(shardId, indexSettings); this.indexStore = indexStore; this.directoryService = directoryService; @@ -303,15 +298,18 @@ public class Store extends AbstractIndexShardComponent { return delegates; } - @Override public String[] listAll() throws IOException { + @Override + public String[] listAll() throws IOException { return files; } - @Override public boolean fileExists(String name) throws IOException { + @Override + public boolean fileExists(String name) throws IOException { return filesMetadata.containsKey(name); } - @Override public long fileModified(String name) throws IOException { + @Override + public long fileModified(String name) throws IOException { StoreFileMetaData metaData = filesMetadata.get(name); if (metaData == null) { throw new FileNotFoundException(name); @@ -323,7 +321,8 @@ public class Store extends AbstractIndexShardComponent { return metaData.directory().fileModified(name); } - @Override public void touchFile(String name) throws IOException { + @Override + public void touchFile(String name) throws IOException { synchronized (mutex) { StoreFileMetaData metaData = filesMetadata.get(name); if (metaData != null) { @@ -351,7 +350,8 @@ public class Store extends AbstractIndexShardComponent { } } - @Override public void deleteFile(String name) throws IOException { + @Override + public void deleteFile(String name) throws IOException { // we don't allow to delete the checksums files, only using the deleteChecksum method if (isChecksum(name)) { return; @@ -372,7 +372,8 @@ public class Store extends AbstractIndexShardComponent { } } - @Override public long fileLength(String name) throws IOException { + @Override + public long fileLength(String name) throws IOException { StoreFileMetaData metaData = filesMetadata.get(name); if (metaData == null) { throw new FileNotFoundException(name); @@ -384,7 +385,8 @@ public class Store extends AbstractIndexShardComponent { return metaData.directory().fileLength(name); } - @Override public IndexOutput createOutput(String name) throws IOException { + @Override + public IndexOutput createOutput(String name) throws IOException { return createOutput(name, true); } @@ -422,7 +424,8 @@ public class Store extends AbstractIndexShardComponent { } } - @Override public IndexInput openInput(String name) throws IOException { + @Override + public IndexInput openInput(String name) throws IOException { StoreFileMetaData metaData = filesMetadata.get(name); if (metaData == null) { throw new FileNotFoundException(name); @@ -430,7 +433,8 @@ public class Store extends AbstractIndexShardComponent { return metaData.directory().openInput(name); } - @Override public void close() throws IOException { + @Override + public void close() throws IOException { for (Directory delegate : delegates) { delegate.close(); } @@ -440,11 +444,13 @@ public class Store extends AbstractIndexShardComponent { } } - @Override public Lock makeLock(String name) { + @Override + public Lock makeLock(String name) { return delegates[0].makeLock(name); } - @Override public IndexInput openInput(String name, int bufferSize) throws IOException { + @Override + public IndexInput openInput(String name, int bufferSize) throws IOException { StoreFileMetaData metaData = filesMetadata.get(name); if (metaData == null) { throw new FileNotFoundException(name); @@ -452,23 +458,28 @@ public class Store extends AbstractIndexShardComponent { return metaData.directory().openInput(name, bufferSize); } - @Override public void clearLock(String name) throws IOException { + @Override + public void clearLock(String name) throws IOException { delegates[0].clearLock(name); } - @Override public void setLockFactory(LockFactory lockFactory) throws IOException { + @Override + public void setLockFactory(LockFactory lockFactory) throws IOException { delegates[0].setLockFactory(lockFactory); } - @Override public LockFactory getLockFactory() { + @Override + public LockFactory getLockFactory() { return delegates[0].getLockFactory(); } - @Override public String getLockID() { + @Override + public String getLockID() { return delegates[0].getLockID(); } - @Override public void sync(Collection names) throws IOException { + @Override + public void sync(Collection names) throws IOException { if (sync) { Map> map = Maps.newHashMap(); for (String name : names) { @@ -496,7 +507,8 @@ public class Store extends AbstractIndexShardComponent { } } - @Override public void sync(String name) throws IOException { + @Override + public void sync(String name) throws IOException { if (sync) { sync(ImmutableList.of(name)); } @@ -506,7 +518,8 @@ public class Store extends AbstractIndexShardComponent { } } - @Override public void forceSync(String name) throws IOException { + @Override + public void forceSync(String name) throws IOException { sync(ImmutableList.of(name)); } } @@ -544,7 +557,8 @@ public class Store extends AbstractIndexShardComponent { } } - @Override public void close() throws IOException { + @Override + public void close() throws IOException { delegate.close(); String checksum = null; if (digest != null) { @@ -557,14 +571,16 @@ public class Store extends AbstractIndexShardComponent { } } - @Override public void writeByte(byte b) throws IOException { + @Override + public void writeByte(byte b) throws IOException { delegate.writeByte(b); if (digest != null) { digest.update(b); } } - @Override public void writeBytes(byte[] b, int offset, int length) throws IOException { + @Override + public void writeBytes(byte[] b, int offset, int length) throws IOException { delegate.writeBytes(b, offset, length); if (digest != null) { digest.update(b, offset, length); @@ -576,30 +592,36 @@ public class Store extends AbstractIndexShardComponent { // delegate.copyBytes(input, numBytes); // } - @Override public void flush() throws IOException { + @Override + public void flush() throws IOException { delegate.flush(); } - @Override public long getFilePointer() { + @Override + public long getFilePointer() { return delegate.getFilePointer(); } - @Override public void seek(long pos) throws IOException { + @Override + public void seek(long pos) throws IOException { // seek might be called on files, which means that the checksum is not file checksum // but a checksum of the bytes written to this stream, which is the same for each // type of file in lucene delegate.seek(pos); } - @Override public long length() throws IOException { + @Override + public long length() throws IOException { return delegate.length(); } - @Override public void setLength(long length) throws IOException { + @Override + public void setLength(long length) throws IOException { delegate.setLength(length); } - @Override public void writeStringStringMap(Map map) throws IOException { + @Override + public void writeStringStringMap(Map map) throws IOException { delegate.writeStringStringMap(map); } } diff --git a/src/main/java/org/elasticsearch/index/store/StoreException.java b/src/main/java/org/elasticsearch/index/store/StoreException.java index 0dd1089ed3a..5b35726861b 100644 --- a/src/main/java/org/elasticsearch/index/store/StoreException.java +++ b/src/main/java/org/elasticsearch/index/store/StoreException.java @@ -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 StoreException extends IndexShardException { diff --git a/src/main/java/org/elasticsearch/index/store/StoreFileMetaData.java b/src/main/java/org/elasticsearch/index/store/StoreFileMetaData.java index 8605a2d3c6f..1b3fedba6e6 100644 --- a/src/main/java/org/elasticsearch/index/store/StoreFileMetaData.java +++ b/src/main/java/org/elasticsearch/index/store/StoreFileMetaData.java @@ -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.Streamable; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class StoreFileMetaData implements Streamable { @@ -73,7 +73,8 @@ public class StoreFileMetaData implements Streamable { return length; } - @Nullable public String checksum() { + @Nullable + public String checksum() { return this.checksum; } @@ -90,11 +91,13 @@ public class StoreFileMetaData implements Streamable { return md; } - @Override public String toString() { + @Override + public String toString() { return "name [" + name + "], length [" + length + "], checksum [" + checksum + "]"; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { name = in.readUTF(); length = in.readVLong(); if (in.readBoolean()) { @@ -102,7 +105,8 @@ public class StoreFileMetaData implements Streamable { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(name); out.writeVLong(length); if (checksum == null) { diff --git a/src/main/java/org/elasticsearch/index/store/StoreManagement.java b/src/main/java/org/elasticsearch/index/store/StoreManagement.java index 3abb5a44588..3616467c760 100644 --- a/src/main/java/org/elasticsearch/index/store/StoreManagement.java +++ b/src/main/java/org/elasticsearch/index/store/StoreManagement.java @@ -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,14 +27,15 @@ import org.elasticsearch.jmx.ManagedAttribute; import java.io.IOException; /** - * @author kimchy (Shay Banon) + * */ @MBean(objectName = "shardType=store", description = "The storage of the index shard") public class StoreManagement extends AbstractIndexShardComponent { private final Store store; - @Inject public StoreManagement(Store store) { + @Inject + public StoreManagement(Store store) { super(store.shardId(), store.indexSettings()); this.store = store; } diff --git a/src/main/java/org/elasticsearch/index/store/StoreModule.java b/src/main/java/org/elasticsearch/index/store/StoreModule.java index 296f71529a7..ea995b74bbb 100644 --- a/src/main/java/org/elasticsearch/index/store/StoreModule.java +++ b/src/main/java/org/elasticsearch/index/store/StoreModule.java @@ -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.inject.AbstractModule; import org.elasticsearch.common.settings.Settings; /** - * @author kimchy (Shay Banon) + * */ public class StoreModule extends AbstractModule { @@ -36,7 +36,8 @@ public class StoreModule extends AbstractModule { this.settings = settings; } - @Override protected void configure() { + @Override + protected void configure() { bind(DirectoryService.class).to(indexStore.shardDirectory()).asEagerSingleton(); bind(StoreManagement.class).asEagerSingleton(); bind(Store.class).asEagerSingleton(); diff --git a/src/main/java/org/elasticsearch/index/store/StoreStats.java b/src/main/java/org/elasticsearch/index/store/StoreStats.java index 30296b51862..fb1d0d7100c 100644 --- a/src/main/java/org/elasticsearch/index/store/StoreStats.java +++ b/src/main/java/org/elasticsearch/index/store/StoreStats.java @@ -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 @@ -73,15 +73,18 @@ public class StoreStats implements Streamable, ToXContent { return store; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { sizeInBytes = in.readVLong(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeVLong(sizeInBytes); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(Fields.STORE); builder.field(Fields.SIZE, size().toString()); builder.field(Fields.SIZE_IN_BYTES, sizeInBytes); diff --git a/src/main/java/org/elasticsearch/index/store/fs/FsDirectoryService.java b/src/main/java/org/elasticsearch/index/store/fs/FsDirectoryService.java index 0de110e3965..9264e17d748 100644 --- a/src/main/java/org/elasticsearch/index/store/fs/FsDirectoryService.java +++ b/src/main/java/org/elasticsearch/index/store/fs/FsDirectoryService.java @@ -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,7 @@ package org.elasticsearch.index.store.fs; -import org.apache.lucene.store.Directory; -import org.apache.lucene.store.FSDirectory; -import org.apache.lucene.store.LockFactory; -import org.apache.lucene.store.NativeFSLockFactory; -import org.apache.lucene.store.NoLockFactory; -import org.apache.lucene.store.SimpleFSLockFactory; +import org.apache.lucene.store.*; import org.elasticsearch.common.io.FileSystemUtils; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.settings.IndexSettings; @@ -61,7 +56,8 @@ public abstract class FsDirectoryService extends AbstractIndexShardComponent imp return lockFactory; } - @Override public void renameFile(Directory dir, String from, String to) throws IOException { + @Override + public void renameFile(Directory dir, String from, String to) throws IOException { File directory = ((FSDirectory) dir).getDirectory(); File old = new File(directory, from); File nu = new File(directory, to); @@ -90,7 +86,8 @@ public abstract class FsDirectoryService extends AbstractIndexShardComponent imp } } - @Override public void fullDelete(Directory dir) throws IOException { + @Override + public void fullDelete(Directory dir) throws IOException { FSDirectory fsDirectory = (FSDirectory) dir; FileSystemUtils.deleteRecursively(fsDirectory.getDirectory()); // if we are the last ones, delete also the actual index diff --git a/src/main/java/org/elasticsearch/index/store/fs/FsIndexStore.java b/src/main/java/org/elasticsearch/index/store/fs/FsIndexStore.java index c184135572a..537147faf0d 100644 --- a/src/main/java/org/elasticsearch/index/store/fs/FsIndexStore.java +++ b/src/main/java/org/elasticsearch/index/store/fs/FsIndexStore.java @@ -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,7 +34,7 @@ import java.io.File; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public abstract class FsIndexStore extends AbstractIndexStore { @@ -52,11 +52,13 @@ public abstract class FsIndexStore extends AbstractIndexStore { } } - @Override public boolean persistent() { + @Override + public boolean persistent() { return true; } - @Override public ByteSizeValue backingStoreTotalSpace() { + @Override + public ByteSizeValue backingStoreTotalSpace() { if (locations == null) { return new ByteSizeValue(0); } @@ -67,7 +69,8 @@ public abstract class FsIndexStore extends AbstractIndexStore { return new ByteSizeValue(totalSpace); } - @Override public ByteSizeValue backingStoreFreeSpace() { + @Override + public ByteSizeValue backingStoreFreeSpace() { if (locations == null) { return new ByteSizeValue(0); } @@ -78,7 +81,8 @@ public abstract class FsIndexStore extends AbstractIndexStore { return new ByteSizeValue(usableSpace); } - @Override public boolean canDeleteUnallocated(ShardId shardId) { + @Override + public boolean canDeleteUnallocated(ShardId shardId) { if (locations == null) { return false; } @@ -93,7 +97,8 @@ public abstract class FsIndexStore extends AbstractIndexStore { return false; } - @Override public void deleteUnallocated(ShardId shardId) throws IOException { + @Override + public void deleteUnallocated(ShardId shardId) throws IOException { if (locations == null) { return; } diff --git a/src/main/java/org/elasticsearch/index/store/fs/MmapFsDirectoryService.java b/src/main/java/org/elasticsearch/index/store/fs/MmapFsDirectoryService.java index 7a12ca5754e..ad3f2589283 100644 --- a/src/main/java/org/elasticsearch/index/store/fs/MmapFsDirectoryService.java +++ b/src/main/java/org/elasticsearch/index/store/fs/MmapFsDirectoryService.java @@ -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,11 +35,13 @@ import java.io.IOException; */ public class MmapFsDirectoryService extends FsDirectoryService { - @Inject public MmapFsDirectoryService(ShardId shardId, @IndexSettings Settings indexSettings, IndexStore indexStore) { + @Inject + public MmapFsDirectoryService(ShardId shardId, @IndexSettings Settings indexSettings, IndexStore indexStore) { super(shardId, indexSettings, indexStore); } - @Override public Directory[] build() throws IOException { + @Override + public Directory[] build() throws IOException { File[] locations = indexStore.shardIndexLocations(shardId); Directory[] dirs = new Directory[locations.length]; for (int i = 0; i < dirs.length; i++) { diff --git a/src/main/java/org/elasticsearch/index/store/fs/MmapFsIndexStore.java b/src/main/java/org/elasticsearch/index/store/fs/MmapFsIndexStore.java index ef779767500..3942fe7b7c9 100644 --- a/src/main/java/org/elasticsearch/index/store/fs/MmapFsIndexStore.java +++ b/src/main/java/org/elasticsearch/index/store/fs/MmapFsIndexStore.java @@ -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,15 +28,17 @@ import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.index.store.DirectoryService; /** - * @author kimchy (shay.banon) + * */ public class MmapFsIndexStore extends FsIndexStore { - @Inject public MmapFsIndexStore(Index index, @IndexSettings Settings indexSettings, IndexService indexService, NodeEnvironment nodeEnv) { + @Inject + public MmapFsIndexStore(Index index, @IndexSettings Settings indexSettings, IndexService indexService, NodeEnvironment nodeEnv) { super(index, indexSettings, indexService, nodeEnv); } - @Override public Class shardDirectory() { + @Override + public Class shardDirectory() { return MmapFsDirectoryService.class; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/store/fs/MmapFsIndexStoreModule.java b/src/main/java/org/elasticsearch/index/store/fs/MmapFsIndexStoreModule.java index 7261bde83dd..75266753fb1 100644 --- a/src/main/java/org/elasticsearch/index/store/fs/MmapFsIndexStoreModule.java +++ b/src/main/java/org/elasticsearch/index/store/fs/MmapFsIndexStoreModule.java @@ -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,11 +23,12 @@ import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.index.store.IndexStore; /** - * @author kimchy (shay.banon) + * */ public class MmapFsIndexStoreModule extends AbstractModule { - @Override protected void configure() { + @Override + protected void configure() { bind(IndexStore.class).to(MmapFsIndexStore.class).asEagerSingleton(); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/store/fs/NioFsDirectoryService.java b/src/main/java/org/elasticsearch/index/store/fs/NioFsDirectoryService.java index 5f1efb09c22..5474a75bd10 100644 --- a/src/main/java/org/elasticsearch/index/store/fs/NioFsDirectoryService.java +++ b/src/main/java/org/elasticsearch/index/store/fs/NioFsDirectoryService.java @@ -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,11 +35,13 @@ import java.io.IOException; */ public class NioFsDirectoryService extends FsDirectoryService { - @Inject public NioFsDirectoryService(ShardId shardId, @IndexSettings Settings indexSettings, IndexStore indexStore) { + @Inject + public NioFsDirectoryService(ShardId shardId, @IndexSettings Settings indexSettings, IndexStore indexStore) { super(shardId, indexSettings, indexStore); } - @Override public Directory[] build() throws IOException { + @Override + public Directory[] build() throws IOException { File[] locations = indexStore.shardIndexLocations(shardId); Directory[] dirs = new Directory[locations.length]; for (int i = 0; i < dirs.length; i++) { diff --git a/src/main/java/org/elasticsearch/index/store/fs/NioFsIndexStore.java b/src/main/java/org/elasticsearch/index/store/fs/NioFsIndexStore.java index c19ae47854d..bfd12df5fca 100644 --- a/src/main/java/org/elasticsearch/index/store/fs/NioFsIndexStore.java +++ b/src/main/java/org/elasticsearch/index/store/fs/NioFsIndexStore.java @@ -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,15 +28,17 @@ import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.index.store.DirectoryService; /** - * @author kimchy (shay.banon) + * */ public class NioFsIndexStore extends FsIndexStore { - @Inject public NioFsIndexStore(Index index, @IndexSettings Settings indexSettings, IndexService indexService, NodeEnvironment nodeEnv) { + @Inject + public NioFsIndexStore(Index index, @IndexSettings Settings indexSettings, IndexService indexService, NodeEnvironment nodeEnv) { super(index, indexSettings, indexService, nodeEnv); } - @Override public Class shardDirectory() { + @Override + public Class shardDirectory() { return NioFsDirectoryService.class; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/store/fs/NioFsIndexStoreModule.java b/src/main/java/org/elasticsearch/index/store/fs/NioFsIndexStoreModule.java index 77541f4c29e..00a33e5b2cc 100644 --- a/src/main/java/org/elasticsearch/index/store/fs/NioFsIndexStoreModule.java +++ b/src/main/java/org/elasticsearch/index/store/fs/NioFsIndexStoreModule.java @@ -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,11 +23,12 @@ import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.index.store.IndexStore; /** - * @author kimchy (shay.banon) + * */ public class NioFsIndexStoreModule extends AbstractModule { - @Override protected void configure() { + @Override + protected void configure() { bind(IndexStore.class).to(NioFsIndexStore.class).asEagerSingleton(); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/store/fs/SimpleFsDirectoryService.java b/src/main/java/org/elasticsearch/index/store/fs/SimpleFsDirectoryService.java index 16514438bc4..174d1866162 100644 --- a/src/main/java/org/elasticsearch/index/store/fs/SimpleFsDirectoryService.java +++ b/src/main/java/org/elasticsearch/index/store/fs/SimpleFsDirectoryService.java @@ -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,11 +35,13 @@ import java.io.IOException; */ public class SimpleFsDirectoryService extends FsDirectoryService { - @Inject public SimpleFsDirectoryService(ShardId shardId, @IndexSettings Settings indexSettings, IndexStore indexStore) { + @Inject + public SimpleFsDirectoryService(ShardId shardId, @IndexSettings Settings indexSettings, IndexStore indexStore) { super(shardId, indexSettings, indexStore); } - @Override public Directory[] build() throws IOException { + @Override + public Directory[] build() throws IOException { File[] locations = indexStore.shardIndexLocations(shardId); Directory[] dirs = new Directory[locations.length]; for (int i = 0; i < dirs.length; i++) { diff --git a/src/main/java/org/elasticsearch/index/store/fs/SimpleFsIndexStore.java b/src/main/java/org/elasticsearch/index/store/fs/SimpleFsIndexStore.java index bc95287aedd..8726d520735 100644 --- a/src/main/java/org/elasticsearch/index/store/fs/SimpleFsIndexStore.java +++ b/src/main/java/org/elasticsearch/index/store/fs/SimpleFsIndexStore.java @@ -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,15 +28,17 @@ import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.index.store.DirectoryService; /** - * @author kimchy (shay.banon) + * */ public class SimpleFsIndexStore extends FsIndexStore { - @Inject public SimpleFsIndexStore(Index index, @IndexSettings Settings indexSettings, IndexService indexService, NodeEnvironment nodeEnv) { + @Inject + public SimpleFsIndexStore(Index index, @IndexSettings Settings indexSettings, IndexService indexService, NodeEnvironment nodeEnv) { super(index, indexSettings, indexService, nodeEnv); } - @Override public Class shardDirectory() { + @Override + public Class shardDirectory() { return SimpleFsDirectoryService.class; } } diff --git a/src/main/java/org/elasticsearch/index/store/fs/SimpleFsIndexStoreModule.java b/src/main/java/org/elasticsearch/index/store/fs/SimpleFsIndexStoreModule.java index d1a0eddb8b0..777cdf783bd 100644 --- a/src/main/java/org/elasticsearch/index/store/fs/SimpleFsIndexStoreModule.java +++ b/src/main/java/org/elasticsearch/index/store/fs/SimpleFsIndexStoreModule.java @@ -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,11 +23,12 @@ import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.index.store.IndexStore; /** - * @author kimchy (shay.banon) + * */ public class SimpleFsIndexStoreModule extends AbstractModule { - @Override protected void configure() { + @Override + protected void configure() { bind(IndexStore.class).to(SimpleFsIndexStore.class).asEagerSingleton(); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/store/memory/ByteBufferDirectoryService.java b/src/main/java/org/elasticsearch/index/store/memory/ByteBufferDirectoryService.java index 3a99a0b477b..72a071193b0 100644 --- a/src/main/java/org/elasticsearch/index/store/memory/ByteBufferDirectoryService.java +++ b/src/main/java/org/elasticsearch/index/store/memory/ByteBufferDirectoryService.java @@ -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,20 +41,24 @@ public class ByteBufferDirectoryService extends AbstractIndexShardComponent impl private final ByteBufferCache byteBufferCache; - @Inject public ByteBufferDirectoryService(ShardId shardId, @IndexSettings Settings indexSettings, IndexStore indexStore, ByteBufferCache byteBufferCache) { + @Inject + public ByteBufferDirectoryService(ShardId shardId, @IndexSettings Settings indexSettings, IndexStore indexStore, ByteBufferCache byteBufferCache) { super(shardId, indexSettings); this.byteBufferCache = byteBufferCache; } - @Override public Directory[] build() { + @Override + public Directory[] build() { return new Directory[]{new CustomByteBufferDirectory(byteBufferCache)}; } - @Override public void renameFile(Directory dir, String from, String to) throws IOException { + @Override + public void renameFile(Directory dir, String from, String to) throws IOException { ((CustomByteBufferDirectory) dir).renameTo(from, to); } - @Override public void fullDelete(Directory dir) { + @Override + public void fullDelete(Directory dir) { } static class CustomByteBufferDirectory extends ByteBufferDirectory { diff --git a/src/main/java/org/elasticsearch/index/store/memory/ByteBufferIndexStore.java b/src/main/java/org/elasticsearch/index/store/memory/ByteBufferIndexStore.java index c1b9aa9c57e..fc78d960b41 100644 --- a/src/main/java/org/elasticsearch/index/store/memory/ByteBufferIndexStore.java +++ b/src/main/java/org/elasticsearch/index/store/memory/ByteBufferIndexStore.java @@ -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,27 +33,31 @@ import org.elasticsearch.monitor.jvm.JvmInfo; import org.elasticsearch.monitor.jvm.JvmStats; /** - * @author kimchy (shay.banon) + * */ public class ByteBufferIndexStore extends AbstractIndexStore { private final boolean direct; - @Inject public ByteBufferIndexStore(Index index, @IndexSettings Settings indexSettings, IndexService indexService, - ByteBufferCache byteBufferCache) { + @Inject + public ByteBufferIndexStore(Index index, @IndexSettings Settings indexSettings, IndexService indexService, + ByteBufferCache byteBufferCache) { super(index, indexSettings, indexService); this.direct = byteBufferCache.direct(); } - @Override public boolean persistent() { + @Override + public boolean persistent() { return false; } - @Override public Class shardDirectory() { + @Override + public Class shardDirectory() { return ByteBufferDirectoryService.class; } - @Override public ByteSizeValue backingStoreTotalSpace() { + @Override + public ByteSizeValue backingStoreTotalSpace() { if (direct) { // TODO, we can use sigar... return new ByteSizeValue(-1, ByteSizeUnit.BYTES); @@ -61,7 +65,8 @@ public class ByteBufferIndexStore extends AbstractIndexStore { return JvmInfo.jvmInfo().mem().heapMax(); } - @Override public ByteSizeValue backingStoreFreeSpace() { + @Override + public ByteSizeValue backingStoreFreeSpace() { if (direct) { return new ByteSizeValue(-1, ByteSizeUnit.BYTES); } diff --git a/src/main/java/org/elasticsearch/index/store/memory/MemoryIndexStoreModule.java b/src/main/java/org/elasticsearch/index/store/memory/MemoryIndexStoreModule.java index 0b66de8cea6..89d9a2c8d90 100644 --- a/src/main/java/org/elasticsearch/index/store/memory/MemoryIndexStoreModule.java +++ b/src/main/java/org/elasticsearch/index/store/memory/MemoryIndexStoreModule.java @@ -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.common.settings.Settings; import org.elasticsearch.index.store.IndexStore; /** - * @author kimchy (shay.banon) + * */ public class MemoryIndexStoreModule extends AbstractModule { @@ -34,7 +34,8 @@ public class MemoryIndexStoreModule extends AbstractModule { this.settings = settings; } - @Override protected void configure() { + @Override + protected void configure() { bind(IndexStore.class).to(ByteBufferIndexStore.class).asEagerSingleton(); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/store/ram/RamDirectoryService.java b/src/main/java/org/elasticsearch/index/store/ram/RamDirectoryService.java index c598cb7c352..54460023377 100644 --- a/src/main/java/org/elasticsearch/index/store/ram/RamDirectoryService.java +++ b/src/main/java/org/elasticsearch/index/store/ram/RamDirectoryService.java @@ -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,19 +36,23 @@ import java.io.IOException; */ public class RamDirectoryService extends AbstractIndexShardComponent implements DirectoryService { - @Inject public RamDirectoryService(ShardId shardId, @IndexSettings Settings indexSettings) { + @Inject + public RamDirectoryService(ShardId shardId, @IndexSettings Settings indexSettings) { super(shardId, indexSettings); } - @Override public Directory[] build() { + @Override + public Directory[] build() { return new Directory[]{new CustomRAMDirectory()}; } - @Override public void renameFile(Directory dir, String from, String to) throws IOException { + @Override + public void renameFile(Directory dir, String from, String to) throws IOException { ((CustomRAMDirectory) dir).renameTo(from, to); } - @Override public void fullDelete(Directory dir) { + @Override + public void fullDelete(Directory dir) { } static class CustomRAMDirectory extends RAMDirectory { diff --git a/src/main/java/org/elasticsearch/index/store/ram/RamIndexStore.java b/src/main/java/org/elasticsearch/index/store/ram/RamIndexStore.java index abd9b19034c..8d096aaf20b 100644 --- a/src/main/java/org/elasticsearch/index/store/ram/RamIndexStore.java +++ b/src/main/java/org/elasticsearch/index/store/ram/RamIndexStore.java @@ -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,27 +31,32 @@ import org.elasticsearch.monitor.jvm.JvmInfo; import org.elasticsearch.monitor.jvm.JvmStats; /** - * @author kimchy (shay.banon) + * */ public class RamIndexStore extends AbstractIndexStore { - @Inject public RamIndexStore(Index index, @IndexSettings Settings indexSettings, IndexService indexService) { + @Inject + public RamIndexStore(Index index, @IndexSettings Settings indexSettings, IndexService indexService) { super(index, indexSettings, indexService); } - @Override public boolean persistent() { + @Override + public boolean persistent() { return false; } - @Override public Class shardDirectory() { + @Override + public Class shardDirectory() { return RamDirectoryService.class; } - @Override public ByteSizeValue backingStoreTotalSpace() { + @Override + public ByteSizeValue backingStoreTotalSpace() { return JvmInfo.jvmInfo().getMem().heapMax(); } - @Override public ByteSizeValue backingStoreFreeSpace() { + @Override + public ByteSizeValue backingStoreFreeSpace() { return JvmStats.jvmStats().getMem().heapUsed(); } } diff --git a/src/main/java/org/elasticsearch/index/store/ram/RamIndexStoreModule.java b/src/main/java/org/elasticsearch/index/store/ram/RamIndexStoreModule.java index 02f8d23d128..950a9fcb76a 100644 --- a/src/main/java/org/elasticsearch/index/store/ram/RamIndexStoreModule.java +++ b/src/main/java/org/elasticsearch/index/store/ram/RamIndexStoreModule.java @@ -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,11 +23,12 @@ import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.index.store.IndexStore; /** - * @author kimchy (shay.banon) + * */ public class RamIndexStoreModule extends AbstractModule { - @Override protected void configure() { + @Override + protected void configure() { bind(IndexStore.class).to(RamIndexStore.class).asEagerSingleton(); } } diff --git a/src/main/java/org/elasticsearch/index/store/support/AbstractIndexStore.java b/src/main/java/org/elasticsearch/index/store/support/AbstractIndexStore.java index 541895d9d58..b30b7e26e8f 100644 --- a/src/main/java/org/elasticsearch/index/store/support/AbstractIndexStore.java +++ b/src/main/java/org/elasticsearch/index/store/support/AbstractIndexStore.java @@ -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 org.elasticsearch.index.store.IndexStore; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public abstract class AbstractIndexStore extends AbstractIndexComponent implements IndexStore { @@ -41,11 +41,13 @@ public abstract class AbstractIndexStore extends AbstractIndexComponent implemen this.indexService = indexService; } - @Override public boolean canDeleteUnallocated(ShardId shardId) { + @Override + public boolean canDeleteUnallocated(ShardId shardId) { return false; } - @Override public void deleteUnallocated(ShardId shardId) throws IOException { + @Override + public void deleteUnallocated(ShardId shardId) throws IOException { // do nothing here... } } diff --git a/src/main/java/org/elasticsearch/index/store/support/ForceSyncDirectory.java b/src/main/java/org/elasticsearch/index/store/support/ForceSyncDirectory.java index 0455e68883c..ec916a08815 100644 --- a/src/main/java/org/elasticsearch/index/store/support/ForceSyncDirectory.java +++ b/src/main/java/org/elasticsearch/index/store/support/ForceSyncDirectory.java @@ -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 java.io.IOException; /** * A custom directory that allows to forceSync (since the actual directory might disable it) * - * @author kimchy (shay.banon) + * */ public interface ForceSyncDirectory { diff --git a/src/main/java/org/elasticsearch/index/translog/Translog.java b/src/main/java/org/elasticsearch/index/translog/Translog.java index 480676dffc7..2fe122d8410 100644 --- a/src/main/java/org/elasticsearch/index/translog/Translog.java +++ b/src/main/java/org/elasticsearch/index/translog/Translog.java @@ -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,7 +38,7 @@ import java.io.IOException; import java.io.InputStream; /** - * @author kimchy (shay.banon) + * */ @ThreadSafe public interface Translog extends IndexShardComponent { @@ -67,7 +67,7 @@ public interface Translog extends IndexShardComponent { /** * Creates a new transaction log internally. - * + *

    *

    Can only be called by one thread. */ void newTranslog(long id) throws TranslogException; @@ -75,14 +75,14 @@ public interface Translog extends IndexShardComponent { /** * Creates a new transient translog, where added ops will be added to the current one, and to * it. - * + *

    *

    Can only be called by one thread. */ void newTransientTranslog(long id) throws TranslogException; /** * Swaps the transient translog to be the current one. - * + *

    *

    Can only be called by one thread. */ void makeTransientCurrent(); @@ -125,7 +125,7 @@ public interface Translog extends IndexShardComponent { /** * Closes the transaction log. - * + *

    *

    Can only be called by one thread. */ void close(boolean delete); @@ -278,11 +278,13 @@ public interface Translog extends IndexShardComponent { this.sourceLength = source.length; } - @Override public Type opType() { + @Override + public Type opType() { return Type.CREATE; } - @Override public long estimateSize() { + @Override + public long estimateSize() { return ((id.length() + type.length()) * 2) + source.length + 12; } @@ -326,7 +328,8 @@ public interface Translog extends IndexShardComponent { return this.version; } - @Override public Source readSource(BytesStreamInput in) throws IOException { + @Override + public Source readSource(BytesStreamInput in) throws IOException { int version = in.readVInt(); // version id = in.readUTF(); type = in.readUTF(); @@ -357,7 +360,8 @@ public interface Translog extends IndexShardComponent { return new Source(source, routing, parent, timestamp, ttl); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { int version = in.readVInt(); // version id = in.readUTF(); type = in.readUTF(); @@ -386,7 +390,8 @@ public interface Translog extends IndexShardComponent { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeVInt(5); // version out.writeUTF(id); out.writeUTF(type); @@ -446,11 +451,13 @@ public interface Translog extends IndexShardComponent { this.sourceLength = source.length; } - @Override public Type opType() { + @Override + public Type opType() { return Type.SAVE; } - @Override public long estimateSize() { + @Override + public long estimateSize() { return ((id.length() + type.length()) * 2) + source.length + 12; } @@ -494,7 +501,8 @@ public interface Translog extends IndexShardComponent { return this.version; } - @Override public Source readSource(BytesStreamInput in) throws IOException { + @Override + public Source readSource(BytesStreamInput in) throws IOException { int version = in.readVInt(); // version id = in.readUTF(); type = in.readUTF(); @@ -525,7 +533,8 @@ public interface Translog extends IndexShardComponent { return new Source(source, routing, parent, timestamp, ttl); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { int version = in.readVInt(); // version id = in.readUTF(); type = in.readUTF(); @@ -554,7 +563,8 @@ public interface Translog extends IndexShardComponent { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeVInt(5); // version out.writeUTF(id); out.writeUTF(type); @@ -594,11 +604,13 @@ public interface Translog extends IndexShardComponent { this.uid = uid; } - @Override public Type opType() { + @Override + public Type opType() { return Type.DELETE; } - @Override public long estimateSize() { + @Override + public long estimateSize() { return ((uid.field().length() + uid.text().length()) * 2) + 20; } @@ -610,11 +622,13 @@ public interface Translog extends IndexShardComponent { return this.version; } - @Override public Source readSource(BytesStreamInput in) throws IOException { + @Override + public Source readSource(BytesStreamInput in) throws IOException { throw new ElasticSearchIllegalStateException("trying to read doc source from delete operation"); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { int version = in.readVInt(); // version uid = new Term(in.readUTF(), in.readUTF()); if (version >= 1) { @@ -622,7 +636,8 @@ public interface Translog extends IndexShardComponent { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeVInt(1); // version out.writeUTF(uid.field()); out.writeUTF(uid.text()); @@ -632,7 +647,8 @@ public interface Translog extends IndexShardComponent { static class DeleteByQuery implements Operation { private byte[] source; - @Nullable private String[] filteringAliases; + @Nullable + private String[] filteringAliases; private String[] types = Strings.EMPTY_ARRAY; public DeleteByQuery() { @@ -648,11 +664,13 @@ public interface Translog extends IndexShardComponent { this.filteringAliases = filteringAliases; } - @Override public Type opType() { + @Override + public Type opType() { return Type.DELETE_BY_QUERY; } - @Override public long estimateSize() { + @Override + public long estimateSize() { return source.length + 8; } @@ -668,11 +686,13 @@ public interface Translog extends IndexShardComponent { return this.types; } - @Override public Source readSource(BytesStreamInput in) throws IOException { + @Override + public Source readSource(BytesStreamInput in) throws IOException { throw new ElasticSearchIllegalStateException("trying to read doc source from delete_by_query operation"); } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { int version = in.readVInt(); // version source = new byte[in.readVInt()]; in.readFully(source); @@ -700,7 +720,8 @@ public interface Translog extends IndexShardComponent { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeVInt(2); // version out.writeVInt(source.length); out.writeBytes(source); diff --git a/src/main/java/org/elasticsearch/index/translog/TranslogException.java b/src/main/java/org/elasticsearch/index/translog/TranslogException.java index 4e37605b33e..61b9b568723 100644 --- a/src/main/java/org/elasticsearch/index/translog/TranslogException.java +++ b/src/main/java/org/elasticsearch/index/translog/TranslogException.java @@ -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 TranslogException extends IndexShardException { diff --git a/src/main/java/org/elasticsearch/index/translog/TranslogModule.java b/src/main/java/org/elasticsearch/index/translog/TranslogModule.java index ca282e23346..e3e74c97a37 100644 --- a/src/main/java/org/elasticsearch/index/translog/TranslogModule.java +++ b/src/main/java/org/elasticsearch/index/translog/TranslogModule.java @@ -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.common.settings.Settings; import org.elasticsearch.index.translog.fs.FsTranslog; /** - * @author kimchy (shay.banon) + * */ public class TranslogModule extends AbstractModule { @@ -39,7 +39,8 @@ public class TranslogModule extends AbstractModule { this.settings = settings; } - @Override protected void configure() { + @Override + protected void configure() { bind(Translog.class) .to(settings.getAsClass(TranslogSettings.TYPE, FsTranslog.class)) .in(Scopes.SINGLETON); diff --git a/src/main/java/org/elasticsearch/index/translog/TranslogService.java b/src/main/java/org/elasticsearch/index/translog/TranslogService.java index a2b7022b8bd..48365f4f868 100644 --- a/src/main/java/org/elasticsearch/index/translog/TranslogService.java +++ b/src/main/java/org/elasticsearch/index/translog/TranslogService.java @@ -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,10 +38,10 @@ import org.elasticsearch.threadpool.ThreadPool; import java.util.concurrent.ScheduledFuture; -import static org.elasticsearch.common.unit.TimeValue.*; +import static org.elasticsearch.common.unit.TimeValue.timeValueMillis; /** - * @author kimchy (shay.banon) + * */ public class TranslogService extends AbstractIndexShardComponent { @@ -67,7 +67,8 @@ public class TranslogService extends AbstractIndexShardComponent { private final ApplySettings applySettings = new ApplySettings(); - @Inject public TranslogService(ShardId shardId, @IndexSettings Settings indexSettings, IndexSettingsService indexSettingsService, ThreadPool threadPool, IndexShard indexShard, Translog translog) { + @Inject + public TranslogService(ShardId shardId, @IndexSettings Settings indexSettings, IndexSettingsService indexSettingsService, ThreadPool threadPool, IndexShard indexShard, Translog translog) { super(shardId, indexSettings); this.threadPool = threadPool; this.indexSettingsService = indexSettingsService; @@ -103,7 +104,8 @@ public class TranslogService extends AbstractIndexShardComponent { } class ApplySettings implements IndexSettingsService.Listener { - @Override public void onRefreshSettings(Settings settings) { + @Override + public void onRefreshSettings(Settings settings) { int flushThresholdOperations = settings.getAsInt("index.translog.flush_threshold_ops", TranslogService.this.flushThresholdOperations); if (flushThresholdOperations != TranslogService.this.flushThresholdOperations) { logger.info("updating flush_threshold_ops from [{}] to [{}]", TranslogService.this.flushThresholdOperations, flushThresholdOperations); @@ -131,7 +133,8 @@ public class TranslogService extends AbstractIndexShardComponent { private volatile long lastFlushTime = System.currentTimeMillis(); - @Override public void run() { + @Override + public void run() { if (indexShard.state() == IndexShardState.CLOSED) { return; } @@ -164,7 +167,8 @@ public class TranslogService extends AbstractIndexShardComponent { private void asyncFlushAndReschedule() { threadPool.executor(ThreadPool.Names.MANAGEMENT).execute(new Runnable() { - @Override public void run() { + @Override + public void run() { try { if (indexShard.state() == IndexShardState.STARTED) { indexShard.flush(new Engine.Flush()); diff --git a/src/main/java/org/elasticsearch/index/translog/TranslogStreams.java b/src/main/java/org/elasticsearch/index/translog/TranslogStreams.java index 4bdbc926ae4..b2aa1ae6784 100644 --- a/src/main/java/org/elasticsearch/index/translog/TranslogStreams.java +++ b/src/main/java/org/elasticsearch/index/translog/TranslogStreams.java @@ -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 TranslogStreams { diff --git a/src/main/java/org/elasticsearch/index/translog/fs/FsChannelSnapshot.java b/src/main/java/org/elasticsearch/index/translog/fs/FsChannelSnapshot.java index 69870d98af7..d3312f3700c 100644 --- a/src/main/java/org/elasticsearch/index/translog/fs/FsChannelSnapshot.java +++ b/src/main/java/org/elasticsearch/index/translog/fs/FsChannelSnapshot.java @@ -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,7 +32,7 @@ import java.nio.ByteBuffer; import java.nio.channels.FileChannel; /** - * @author kimchy (shay.banon) + * */ public class FsChannelSnapshot implements Translog.Snapshot { @@ -60,31 +60,38 @@ public class FsChannelSnapshot implements Translog.Snapshot { this.totalOperations = totalOperations; } - @Override public long translogId() { + @Override + public long translogId() { return this.id; } - @Override public long position() { + @Override + public long position() { return this.position; } - @Override public long length() { + @Override + public long length() { return this.length; } - @Override public int estimatedTotalOperations() { + @Override + public int estimatedTotalOperations() { return this.totalOperations; } - @Override public InputStream stream() throws IOException { + @Override + public InputStream stream() throws IOException { return new FileChannelInputStream(channel, position, lengthInBytes()); } - @Override public long lengthInBytes() { + @Override + public long lengthInBytes() { return length - position; } - @Override public boolean hasNext() { + @Override + public boolean hasNext() { try { if (position > length) { return false; @@ -120,15 +127,18 @@ public class FsChannelSnapshot implements Translog.Snapshot { } } - @Override public Translog.Operation next() { + @Override + public Translog.Operation next() { return this.lastOperationRead; } - @Override public void seekForward(long length) { + @Override + public void seekForward(long length) { this.position += length; } - @Override public boolean release() throws ElasticSearchException { + @Override + public boolean release() throws ElasticSearchException { raf.decreaseRefCount(true); return true; } diff --git a/src/main/java/org/elasticsearch/index/translog/fs/FsTranslog.java b/src/main/java/org/elasticsearch/index/translog/fs/FsTranslog.java index 5489ab6824f..746c75bcca2 100644 --- a/src/main/java/org/elasticsearch/index/translog/fs/FsTranslog.java +++ b/src/main/java/org/elasticsearch/index/translog/fs/FsTranslog.java @@ -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.elasticsearch.index.translog.fs; +import jsr166y.ThreadLocalRandom; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.io.FileSystemUtils; import org.elasticsearch.common.io.stream.BytesStreamOutput; import org.elasticsearch.common.io.stream.CachedStreamOutput; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom; import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.index.shard.AbstractIndexShardComponent; @@ -40,7 +40,7 @@ import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; /** - * @author kimchy (shay.banon) + * */ public class FsTranslog extends AbstractIndexShardComponent implements Translog { @@ -52,7 +52,8 @@ public class FsTranslog extends AbstractIndexShardComponent implements Translog private boolean syncOnEachOperation = false; - @Inject public FsTranslog(ShardId shardId, @IndexSettings Settings indexSettings, NodeEnvironment nodeEnv) { + @Inject + public FsTranslog(ShardId shardId, @IndexSettings Settings indexSettings, NodeEnvironment nodeEnv) { super(shardId, indexSettings); File[] shardLocations = nodeEnv.shardLocations(shardId); this.locations = new File[shardLocations.length]; @@ -72,7 +73,8 @@ public class FsTranslog extends AbstractIndexShardComponent implements Translog return locations; } - @Override public long currentId() { + @Override + public long currentId() { FsTranslogFile current1 = this.current; if (current1 == null) { return -1; @@ -80,7 +82,8 @@ public class FsTranslog extends AbstractIndexShardComponent implements Translog return current1.id(); } - @Override public int estimatedNumberOfOperations() { + @Override + public int estimatedNumberOfOperations() { FsTranslogFile current1 = this.current; if (current1 == null) { return 0; @@ -88,11 +91,13 @@ public class FsTranslog extends AbstractIndexShardComponent implements Translog return current1.estimatedNumberOfOperations(); } - @Override public long memorySizeInBytes() { + @Override + public long memorySizeInBytes() { return 0; } - @Override public long translogSizeInBytes() { + @Override + public long translogSizeInBytes() { FsTranslogFile current1 = this.current; if (current1 == null) { return 0; @@ -100,7 +105,8 @@ public class FsTranslog extends AbstractIndexShardComponent implements Translog return current1.translogSizeInBytes(); } - @Override public void clearUnreferenced() { + @Override + public void clearUnreferenced() { rwl.writeLock().lock(); try { for (File location : locations) { @@ -126,7 +132,8 @@ public class FsTranslog extends AbstractIndexShardComponent implements Translog } } - @Override public void newTranslog(long id) throws TranslogException { + @Override + public void newTranslog(long id) throws TranslogException { rwl.writeLock().lock(); try { FsTranslogFile newFile; @@ -161,7 +168,8 @@ public class FsTranslog extends AbstractIndexShardComponent implements Translog } } - @Override public void newTransientTranslog(long id) throws TranslogException { + @Override + public void newTransientTranslog(long id) throws TranslogException { rwl.writeLock().lock(); try { assert this.trans == null; @@ -184,7 +192,8 @@ public class FsTranslog extends AbstractIndexShardComponent implements Translog } } - @Override public void makeTransientCurrent() { + @Override + public void makeTransientCurrent() { FsTranslogFile old; rwl.writeLock().lock(); try { @@ -198,7 +207,8 @@ public class FsTranslog extends AbstractIndexShardComponent implements Translog old.close(true); } - @Override public void revertTransient() { + @Override + public void revertTransient() { FsTranslogFile old; rwl.writeLock().lock(); try { @@ -234,7 +244,8 @@ public class FsTranslog extends AbstractIndexShardComponent implements Translog } } - @Override public Location add(Operation operation) throws TranslogException { + @Override + public Location add(Operation operation) throws TranslogException { CachedStreamOutput.Entry cachedEntry = CachedStreamOutput.popEntry(); rwl.readLock().lock(); try { @@ -268,7 +279,8 @@ public class FsTranslog extends AbstractIndexShardComponent implements Translog } } - @Override public FsChannelSnapshot snapshot() throws TranslogException { + @Override + public FsChannelSnapshot snapshot() throws TranslogException { while (true) { FsChannelSnapshot snapshot = current.snapshot(); if (snapshot != null) { @@ -278,7 +290,8 @@ public class FsTranslog extends AbstractIndexShardComponent implements Translog } } - @Override public Snapshot snapshot(Snapshot snapshot) { + @Override + public Snapshot snapshot(Snapshot snapshot) { FsChannelSnapshot snap = snapshot(); if (snap.translogId() == snapshot.translogId()) { snap.seekForward(snapshot.position()); @@ -286,7 +299,8 @@ public class FsTranslog extends AbstractIndexShardComponent implements Translog return snap; } - @Override public void sync() { + @Override + public void sync() { FsTranslogFile current1 = this.current; if (current1 == null) { return; @@ -294,11 +308,13 @@ public class FsTranslog extends AbstractIndexShardComponent implements Translog current1.sync(); } - @Override public void syncOnEachOperation(boolean syncOnEachOperation) { + @Override + public void syncOnEachOperation(boolean syncOnEachOperation) { this.syncOnEachOperation = syncOnEachOperation; } - @Override public void close(boolean delete) { + @Override + public void close(boolean delete) { rwl.writeLock().lock(); try { FsTranslogFile current1 = this.current; diff --git a/src/main/java/org/elasticsearch/index/translog/fs/FsTranslogFile.java b/src/main/java/org/elasticsearch/index/translog/fs/FsTranslogFile.java index bfb47ffa8ca..4c4c5c4dccd 100644 --- a/src/main/java/org/elasticsearch/index/translog/fs/FsTranslogFile.java +++ b/src/main/java/org/elasticsearch/index/translog/fs/FsTranslogFile.java @@ -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 diff --git a/src/main/java/org/elasticsearch/index/translog/fs/RafReference.java b/src/main/java/org/elasticsearch/index/translog/fs/RafReference.java index 9a17fa26887..c32886816d4 100644 --- a/src/main/java/org/elasticsearch/index/translog/fs/RafReference.java +++ b/src/main/java/org/elasticsearch/index/translog/fs/RafReference.java @@ -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 java.nio.channels.FileChannel; import java.util.concurrent.atomic.AtomicInteger; /** - * @author kimchy (shay.banon) + * */ public class RafReference { diff --git a/src/main/java/org/elasticsearch/indices/AliasFilterParsingException.java b/src/main/java/org/elasticsearch/indices/AliasFilterParsingException.java index 09fe1a5ffbb..4f898125d8a 100644 --- a/src/main/java/org/elasticsearch/indices/AliasFilterParsingException.java +++ b/src/main/java/org/elasticsearch/indices/AliasFilterParsingException.java @@ -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.Index; import org.elasticsearch.index.IndexException; /** - * @author imotov + * */ public class AliasFilterParsingException extends IndexException { diff --git a/src/main/java/org/elasticsearch/indices/IndexAlreadyExistsException.java b/src/main/java/org/elasticsearch/indices/IndexAlreadyExistsException.java index a0699e5d4e0..625bb13527a 100644 --- a/src/main/java/org/elasticsearch/indices/IndexAlreadyExistsException.java +++ b/src/main/java/org/elasticsearch/indices/IndexAlreadyExistsException.java @@ -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.index.IndexException; import org.elasticsearch.rest.RestStatus; /** - * @author kimchy (shay.banon) + * */ public class IndexAlreadyExistsException extends IndexException { @@ -32,7 +32,8 @@ public class IndexAlreadyExistsException extends IndexException { super(index, "Already exists"); } - @Override public RestStatus status() { + @Override + public RestStatus status() { return RestStatus.BAD_REQUEST; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/indices/IndexCreationException.java b/src/main/java/org/elasticsearch/indices/IndexCreationException.java index a17446f0dbd..5d38abcfa0b 100644 --- a/src/main/java/org/elasticsearch/indices/IndexCreationException.java +++ b/src/main/java/org/elasticsearch/indices/IndexCreationException.java @@ -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 diff --git a/src/main/java/org/elasticsearch/indices/IndexMissingException.java b/src/main/java/org/elasticsearch/indices/IndexMissingException.java index 90ec3943621..3d132d4a9cb 100644 --- a/src/main/java/org/elasticsearch/indices/IndexMissingException.java +++ b/src/main/java/org/elasticsearch/indices/IndexMissingException.java @@ -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.index.IndexException; import org.elasticsearch.rest.RestStatus; /** - * @author kimchy (Shay Banon) + * */ public class IndexMissingException extends IndexException { @@ -32,7 +32,8 @@ public class IndexMissingException extends IndexException { super(index, "missing"); } - @Override public RestStatus status() { + @Override + public RestStatus status() { return RestStatus.NOT_FOUND; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/indices/IndexTemplateAlreadyExistsException.java b/src/main/java/org/elasticsearch/indices/IndexTemplateAlreadyExistsException.java index 197dc008e8c..8566ff63ded 100644 --- a/src/main/java/org/elasticsearch/indices/IndexTemplateAlreadyExistsException.java +++ b/src/main/java/org/elasticsearch/indices/IndexTemplateAlreadyExistsException.java @@ -23,7 +23,7 @@ import org.elasticsearch.ElasticSearchException; import org.elasticsearch.rest.RestStatus; /** - * @author kimchy (shay.banon) + * */ public class IndexTemplateAlreadyExistsException extends ElasticSearchException { @@ -38,7 +38,8 @@ public class IndexTemplateAlreadyExistsException extends ElasticSearchException return this.name; } - @Override public RestStatus status() { + @Override + public RestStatus status() { return RestStatus.BAD_REQUEST; } } diff --git a/src/main/java/org/elasticsearch/indices/IndexTemplateMissingException.java b/src/main/java/org/elasticsearch/indices/IndexTemplateMissingException.java index 96575ccba3f..fe3dd22f067 100644 --- a/src/main/java/org/elasticsearch/indices/IndexTemplateMissingException.java +++ b/src/main/java/org/elasticsearch/indices/IndexTemplateMissingException.java @@ -23,7 +23,7 @@ import org.elasticsearch.ElasticSearchException; import org.elasticsearch.rest.RestStatus; /** - * @author kimchy (shay.banon) + * */ public class IndexTemplateMissingException extends ElasticSearchException { @@ -39,7 +39,8 @@ public class IndexTemplateMissingException extends ElasticSearchException { } - @Override public RestStatus status() { + @Override + public RestStatus status() { return RestStatus.NOT_FOUND; } } diff --git a/src/main/java/org/elasticsearch/indices/IndicesLifecycle.java b/src/main/java/org/elasticsearch/indices/IndicesLifecycle.java index 44853702226..05554d339c6 100644 --- a/src/main/java/org/elasticsearch/indices/IndicesLifecycle.java +++ b/src/main/java/org/elasticsearch/indices/IndicesLifecycle.java @@ -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.index.shard.service.IndexShard; * A global component allowing to register for lifecycle of an index (create/closed) and * an index shard (created/closed). * - * @author kimchy (shay.banon) + * */ public interface IndicesLifecycle { diff --git a/src/main/java/org/elasticsearch/indices/IndicesModule.java b/src/main/java/org/elasticsearch/indices/IndicesModule.java index 89f85c6050f..dd8ba0086fa 100644 --- a/src/main/java/org/elasticsearch/indices/IndicesModule.java +++ b/src/main/java/org/elasticsearch/indices/IndicesModule.java @@ -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,7 +19,7 @@ package org.elasticsearch.indices; -import org.elasticsearch.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.inject.SpawnModules; @@ -36,7 +36,7 @@ import org.elasticsearch.indices.store.TransportNodesListShardStoreMetaData; import org.elasticsearch.indices.ttl.IndicesTTLService; /** - * @author kimchy (shay.banon) + * */ public class IndicesModule extends AbstractModule implements SpawnModules { @@ -46,11 +46,13 @@ public class IndicesModule extends AbstractModule implements SpawnModules { this.settings = settings; } - @Override public Iterable spawnModules() { + @Override + public Iterable spawnModules() { return ImmutableList.of(new IndicesQueriesModule(), new IndicesAnalysisModule()); } - @Override protected void configure() { + @Override + protected void configure() { bind(IndicesLifecycle.class).to(InternalIndicesLifecycle.class).asEagerSingleton(); bind(IndicesService.class).to(InternalIndicesService.class).asEagerSingleton(); diff --git a/src/main/java/org/elasticsearch/indices/IndicesService.java b/src/main/java/org/elasticsearch/indices/IndicesService.java index faa329b3894..d1328333dd8 100644 --- a/src/main/java/org/elasticsearch/indices/IndicesService.java +++ b/src/main/java/org/elasticsearch/indices/IndicesService.java @@ -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.index.service.IndexService; import java.util.Set; /** - * @author kimchy (shay.banon) + * */ @ThreadSafe public interface IndicesService extends Iterable, LifecycleComponent { diff --git a/src/main/java/org/elasticsearch/indices/InternalIndicesLifecycle.java b/src/main/java/org/elasticsearch/indices/InternalIndicesLifecycle.java index 6b9987a0241..ad88e23a2ce 100644 --- a/src/main/java/org/elasticsearch/indices/InternalIndicesLifecycle.java +++ b/src/main/java/org/elasticsearch/indices/InternalIndicesLifecycle.java @@ -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,13 +31,14 @@ import org.elasticsearch.index.shard.service.IndexShard; import java.util.concurrent.CopyOnWriteArrayList; /** - * @author kimchy (shay.banon) + * */ public class InternalIndicesLifecycle extends AbstractComponent implements IndicesLifecycle { private final CopyOnWriteArrayList listeners = new CopyOnWriteArrayList(); - @Inject public InternalIndicesLifecycle(Settings settings) { + @Inject + public InternalIndicesLifecycle(Settings settings) { super(settings); } diff --git a/src/main/java/org/elasticsearch/indices/InternalIndicesService.java b/src/main/java/org/elasticsearch/indices/InternalIndicesService.java index 44c1a66cd2b..d9eed2dad66 100644 --- a/src/main/java/org/elasticsearch/indices/InternalIndicesService.java +++ b/src/main/java/org/elasticsearch/indices/InternalIndicesService.java @@ -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,30 +19,21 @@ package org.elasticsearch.indices; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.UnmodifiableIterator; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.ElasticSearchIllegalStateException; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.collect.UnmodifiableIterator; import org.elasticsearch.common.component.AbstractLifecycleComponent; -import org.elasticsearch.common.inject.CreationException; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.inject.Injector; -import org.elasticsearch.common.inject.Injectors; -import org.elasticsearch.common.inject.ModulesBuilder; +import org.elasticsearch.common.inject.*; import org.elasticsearch.common.io.FileSystemUtils; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.EsExecutors; import org.elasticsearch.common.util.concurrent.ThreadSafe; import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.gateway.Gateway; -import org.elasticsearch.index.CloseableIndexComponent; -import org.elasticsearch.index.Index; -import org.elasticsearch.index.IndexModule; -import org.elasticsearch.index.IndexNameModule; -import org.elasticsearch.index.IndexServiceManagement; -import org.elasticsearch.index.LocalNodeIdModule; +import org.elasticsearch.index.*; import org.elasticsearch.index.aliases.IndexAliasesServiceModule; import org.elasticsearch.index.analysis.AnalysisModule; import org.elasticsearch.index.analysis.AnalysisService; @@ -89,14 +80,15 @@ import java.util.concurrent.Executor; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import static org.elasticsearch.cluster.metadata.IndexMetaData.*; -import static org.elasticsearch.common.collect.MapBuilder.*; -import static org.elasticsearch.common.collect.Maps.*; -import static org.elasticsearch.common.collect.Sets.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; +import static com.google.common.collect.Maps.newHashMap; +import static com.google.common.collect.Sets.newHashSet; +import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS; +import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; +import static org.elasticsearch.common.collect.MapBuilder.newMapBuilder; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; /** - * @author kimchy (shay.banon) + * */ @ThreadSafe public class InternalIndicesService extends AbstractLifecycleComponent implements IndicesService { @@ -121,7 +113,8 @@ public class InternalIndicesService extends AbstractLifecycleComponent indices = ImmutableSet.copyOf(this.indices.keySet()); final CountDownLatch latch = new CountDownLatch(indices.size()); @@ -147,7 +142,8 @@ public class InternalIndicesService extends AbstractLifecycleComponent iterator() { + @Override + public UnmodifiableIterator iterator() { return indices.values().iterator(); } @@ -238,7 +238,8 @@ public class InternalIndicesService extends AbstractLifecycleComponent>> evictionListeners = new CopyOnWriteArrayList>>(); - @Inject public IndicesNodeFilterCache(Settings settings, ThreadPool threadPool, NodeSettingsService nodeSettingsService) { + @Inject + public IndicesNodeFilterCache(Settings settings, ThreadPool threadPool, NodeSettingsService nodeSettingsService) { super(settings); this.threadPool = threadPool; this.size = componentSettings.get("size", "20%"); @@ -98,14 +99,16 @@ public class IndicesNodeFilterCache extends AbstractComponent implements Evictio return this.cache; } - @Override public void onEviction(AbstractWeightedFilterCache.FilterCacheKey filterCacheKey, FilterCacheValue docSetFilterCacheValue) { + @Override + public void onEviction(AbstractWeightedFilterCache.FilterCacheKey filterCacheKey, FilterCacheValue docSetFilterCacheValue) { for (EvictionListener> listener : evictionListeners) { listener.onEviction(filterCacheKey, docSetFilterCacheValue); } } class ApplySettings implements NodeSettingsService.Listener { - @Override public void onRefreshSettings(Settings settings) { + @Override + public void onRefreshSettings(Settings settings) { String size = settings.get("indices.cache.filter.size", IndicesNodeFilterCache.this.size); if (!size.equals(IndicesNodeFilterCache.this.size)) { logger.info("updating [indices.cache.filter.size] from [{}] to [{}]", IndicesNodeFilterCache.this.size, size); diff --git a/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java b/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java index 77350159452..1f2d5271798 100644 --- a/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java +++ b/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java @@ -19,28 +19,20 @@ package org.elasticsearch.indices.cluster; +import com.google.common.collect.Lists; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.cluster.ClusterChangedEvent; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.ClusterStateListener; -import org.elasticsearch.cluster.action.index.NodeAliasesUpdatedAction; -import org.elasticsearch.cluster.action.index.NodeIndexCreatedAction; -import org.elasticsearch.cluster.action.index.NodeIndexDeletedAction; -import org.elasticsearch.cluster.action.index.NodeMappingCreatedAction; -import org.elasticsearch.cluster.action.index.NodeMappingRefreshAction; +import org.elasticsearch.cluster.action.index.*; import org.elasticsearch.cluster.action.shard.ShardStateAction; import org.elasticsearch.cluster.metadata.AliasMetaData; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.MappingMetaData; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodes; -import org.elasticsearch.cluster.routing.IndexShardRoutingTable; -import org.elasticsearch.cluster.routing.MutableShardRouting; -import org.elasticsearch.cluster.routing.RoutingNode; -import org.elasticsearch.cluster.routing.RoutingTable; -import org.elasticsearch.cluster.routing.ShardRouting; -import org.elasticsearch.common.collect.Lists; +import org.elasticsearch.cluster.routing.*; import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.component.AbstractLifecycleComponent; import org.elasticsearch.common.compress.CompressedString; @@ -73,11 +65,11 @@ import java.util.List; import java.util.Set; import java.util.concurrent.ConcurrentMap; -import static org.elasticsearch.ExceptionsHelper.*; -import static org.elasticsearch.common.collect.Sets.*; +import static com.google.common.collect.Sets.newHashSet; +import static org.elasticsearch.ExceptionsHelper.detailedMessage; /** - * @author kimchy (shay.banon) + * */ public class IndicesClusterStateService extends AbstractLifecycleComponent implements ClusterStateListener { @@ -109,12 +101,13 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent { @@ -69,7 +69,8 @@ public class IndexingMemoryBufferController extends AbstractLifecycleComponent queryParsers; private ImmutableMap filterParsers; - @Inject public IndicesQueriesRegistry(Settings settings) { + @Inject + public IndicesQueriesRegistry(Settings settings) { Map queryParsers = Maps.newHashMap(); addQueryParser(queryParsers, new TextQueryParser()); addQueryParser(queryParsers, new NestedQueryParser()); diff --git a/src/main/java/org/elasticsearch/indices/recovery/IgnoreRecoveryException.java b/src/main/java/org/elasticsearch/indices/recovery/IgnoreRecoveryException.java index 08c28d2f1b7..7f6efe7d5ba 100644 --- a/src/main/java/org/elasticsearch/indices/recovery/IgnoreRecoveryException.java +++ b/src/main/java/org/elasticsearch/indices/recovery/IgnoreRecoveryException.java @@ -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.ElasticSearchException; /** * An exception marking that this recovery attempt should be ignored (since probably, we already recovered). * - * @author kimchy (Shay Banon) + * */ public class IgnoreRecoveryException extends ElasticSearchException { diff --git a/src/main/java/org/elasticsearch/indices/recovery/RecoverFilesRecoveryException.java b/src/main/java/org/elasticsearch/indices/recovery/RecoverFilesRecoveryException.java index 3e12af62b91..b7f0386e8c1 100644 --- a/src/main/java/org/elasticsearch/indices/recovery/RecoverFilesRecoveryException.java +++ b/src/main/java/org/elasticsearch/indices/recovery/RecoverFilesRecoveryException.java @@ -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.index.shard.IndexShardException; import org.elasticsearch.index.shard.ShardId; /** - * @author kimchy (shay.banon) + * */ public class RecoverFilesRecoveryException extends IndexShardException implements ElasticSearchWrapperException { diff --git a/src/main/java/org/elasticsearch/indices/recovery/RecoveryCleanFilesRequest.java b/src/main/java/org/elasticsearch/indices/recovery/RecoveryCleanFilesRequest.java index b42df9a941a..fad9ce736a4 100644 --- a/src/main/java/org/elasticsearch/indices/recovery/RecoveryCleanFilesRequest.java +++ b/src/main/java/org/elasticsearch/indices/recovery/RecoveryCleanFilesRequest.java @@ -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,7 +19,7 @@ package org.elasticsearch.indices.recovery; -import org.elasticsearch.common.collect.Sets; +import com.google.common.collect.Sets; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Streamable; @@ -29,7 +29,7 @@ import java.io.IOException; import java.util.Set; /** - * @author kimchy (shay.banon) + * */ class RecoveryCleanFilesRequest implements Streamable { @@ -53,7 +53,8 @@ class RecoveryCleanFilesRequest implements Streamable { return snapshotFiles; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { shardId = ShardId.readShardId(in); int size = in.readVInt(); snapshotFiles = Sets.newHashSetWithExpectedSize(size); @@ -62,7 +63,8 @@ class RecoveryCleanFilesRequest implements Streamable { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { shardId.writeTo(out); out.writeVInt(snapshotFiles.size()); for (String snapshotFile : snapshotFiles) { diff --git a/src/main/java/org/elasticsearch/indices/recovery/RecoveryFailedException.java b/src/main/java/org/elasticsearch/indices/recovery/RecoveryFailedException.java index 08ed81b70d1..af6fcdc52ce 100644 --- a/src/main/java/org/elasticsearch/indices/recovery/RecoveryFailedException.java +++ b/src/main/java/org/elasticsearch/indices/recovery/RecoveryFailedException.java @@ -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.cluster.node.DiscoveryNode; import org.elasticsearch.index.shard.ShardId; /** - * @author kimchy (shay.banon) + * */ public class RecoveryFailedException extends ElasticSearchException { diff --git a/src/main/java/org/elasticsearch/indices/recovery/RecoveryFileChunkRequest.java b/src/main/java/org/elasticsearch/indices/recovery/RecoveryFileChunkRequest.java index 24f2292fd7d..da6cb17d950 100644 --- a/src/main/java/org/elasticsearch/indices/recovery/RecoveryFileChunkRequest.java +++ b/src/main/java/org/elasticsearch/indices/recovery/RecoveryFileChunkRequest.java @@ -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.index.shard.ShardId; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ class RecoveryFileChunkRequest implements Streamable { @@ -65,7 +65,8 @@ class RecoveryFileChunkRequest implements Streamable { return position; } - @Nullable public String checksum() { + @Nullable + public String checksum() { return this.checksum; } @@ -87,7 +88,8 @@ class RecoveryFileChunkRequest implements Streamable { return request; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { shardId = ShardId.readShardId(in); name = in.readUTF(); position = in.readVLong(); @@ -100,7 +102,8 @@ class RecoveryFileChunkRequest implements Streamable { in.readFully(content); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { shardId.writeTo(out); out.writeUTF(name); out.writeVLong(position); @@ -115,7 +118,8 @@ class RecoveryFileChunkRequest implements Streamable { out.writeBytes(content, 0, contentLength); } - @Override public String toString() { + @Override + public String toString() { return shardId + ": name='" + name + '\'' + ", position=" + position + ", length=" + length; diff --git a/src/main/java/org/elasticsearch/indices/recovery/RecoveryFilesInfoRequest.java b/src/main/java/org/elasticsearch/indices/recovery/RecoveryFilesInfoRequest.java index 7683172e51e..0432baf0b41 100644 --- a/src/main/java/org/elasticsearch/indices/recovery/RecoveryFilesInfoRequest.java +++ b/src/main/java/org/elasticsearch/indices/recovery/RecoveryFilesInfoRequest.java @@ -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.ArrayList; import java.util.List; /** - * @author kimchy (shay.banon) + * */ class RecoveryFilesInfoRequest implements Streamable { @@ -55,7 +55,8 @@ class RecoveryFilesInfoRequest implements Streamable { this.phase1ExistingTotalSize = phase1ExistingTotalSize; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { shardId = ShardId.readShardId(in); int size = in.readVInt(); phase1FileNames = new ArrayList(size); @@ -85,7 +86,8 @@ class RecoveryFilesInfoRequest implements Streamable { phase1ExistingTotalSize = in.readVLong(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { shardId.writeTo(out); out.writeVInt(phase1FileNames.size()); diff --git a/src/main/java/org/elasticsearch/indices/recovery/RecoveryFinalizeRecoveryRequest.java b/src/main/java/org/elasticsearch/indices/recovery/RecoveryFinalizeRecoveryRequest.java index 029403e8dfb..b0c5e1b89bc 100644 --- a/src/main/java/org/elasticsearch/indices/recovery/RecoveryFinalizeRecoveryRequest.java +++ b/src/main/java/org/elasticsearch/indices/recovery/RecoveryFinalizeRecoveryRequest.java @@ -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.index.shard.ShardId; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ class RecoveryFinalizeRecoveryRequest implements Streamable { @@ -44,11 +44,13 @@ class RecoveryFinalizeRecoveryRequest implements Streamable { return shardId; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { shardId = ShardId.readShardId(in); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { shardId.writeTo(out); } } diff --git a/src/main/java/org/elasticsearch/indices/recovery/RecoveryPrepareForTranslogOperationsRequest.java b/src/main/java/org/elasticsearch/indices/recovery/RecoveryPrepareForTranslogOperationsRequest.java index 65bc7113438..5ce347accc5 100644 --- a/src/main/java/org/elasticsearch/indices/recovery/RecoveryPrepareForTranslogOperationsRequest.java +++ b/src/main/java/org/elasticsearch/indices/recovery/RecoveryPrepareForTranslogOperationsRequest.java @@ -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.index.shard.ShardId; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ class RecoveryPrepareForTranslogOperationsRequest implements Streamable { @@ -44,11 +44,13 @@ class RecoveryPrepareForTranslogOperationsRequest implements Streamable { return shardId; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { shardId = ShardId.readShardId(in); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { shardId.writeTo(out); } } diff --git a/src/main/java/org/elasticsearch/indices/recovery/RecoveryResponse.java b/src/main/java/org/elasticsearch/indices/recovery/RecoveryResponse.java index 738b5052a99..82c317d46e4 100644 --- a/src/main/java/org/elasticsearch/indices/recovery/RecoveryResponse.java +++ b/src/main/java/org/elasticsearch/indices/recovery/RecoveryResponse.java @@ -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,7 +19,7 @@ package org.elasticsearch.indices.recovery; -import org.elasticsearch.common.collect.Lists; +import com.google.common.collect.Lists; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Streamable; @@ -28,7 +28,7 @@ import java.io.IOException; import java.util.List; /** - * @author kimchy (shay.banon) + * */ class RecoveryResponse implements Streamable { @@ -50,7 +50,8 @@ class RecoveryResponse implements Streamable { RecoveryResponse() { } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { int size = in.readVInt(); phase1FileNames = Lists.newArrayListWithCapacity(size); for (int i = 0; i < size; i++) { @@ -83,7 +84,8 @@ class RecoveryResponse implements Streamable { phase3Time = in.readVLong(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeVInt(phase1FileNames.size()); for (String name : phase1FileNames) { out.writeUTF(name); diff --git a/src/main/java/org/elasticsearch/indices/recovery/RecoverySettings.java b/src/main/java/org/elasticsearch/indices/recovery/RecoverySettings.java index e346e45f4b0..737d5e6b4f8 100644 --- a/src/main/java/org/elasticsearch/indices/recovery/RecoverySettings.java +++ b/src/main/java/org/elasticsearch/indices/recovery/RecoverySettings.java @@ -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.indices.recovery; +import com.google.common.base.Objects; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.common.RateLimiter; -import org.elasticsearch.common.base.Objects; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -59,7 +59,8 @@ public class RecoverySettings extends AbstractComponent { private volatile ByteSizeValue maxSizePerSec; private volatile RateLimiter rateLimiter; - @Inject public RecoverySettings(Settings settings, NodeSettingsService nodeSettingsService) { + @Inject + public RecoverySettings(Settings settings, NodeSettingsService nodeSettingsService) { super(settings); this.fileChunkSize = componentSettings.getAsBytesSize("file_chunk_size", settings.getAsBytesSize("index.shard.recovery.file_chunk_size", new ByteSizeValue(100, ByteSizeUnit.KB))); @@ -116,7 +117,8 @@ public class RecoverySettings extends AbstractComponent { } class ApplySettings implements NodeSettingsService.Listener { - @Override public void onRefreshSettings(Settings settings) { + @Override + public void onRefreshSettings(Settings settings) { ByteSizeValue maxSizePerSec = settings.getAsBytesSize("indices.recovery.max_size_per_sec", RecoverySettings.this.maxSizePerSec); if (!Objects.equal(maxSizePerSec, RecoverySettings.this.maxSizePerSec)) { logger.info("updating [indices.recovery.max_size_per_sec] from [{}] to [{}]", RecoverySettings.this.maxSizePerSec, maxSizePerSec); diff --git a/src/main/java/org/elasticsearch/indices/recovery/RecoverySource.java b/src/main/java/org/elasticsearch/indices/recovery/RecoverySource.java index 9b6a580d670..81ab3be8339 100644 --- a/src/main/java/org/elasticsearch/indices/recovery/RecoverySource.java +++ b/src/main/java/org/elasticsearch/indices/recovery/RecoverySource.java @@ -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.elasticsearch.indices.recovery; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; import org.apache.lucene.store.IndexInput; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.common.StopWatch; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.collect.Sets; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -39,11 +39,7 @@ import org.elasticsearch.index.store.StoreFileMetaData; import org.elasticsearch.index.translog.Translog; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.transport.BaseTransportRequestHandler; -import org.elasticsearch.transport.TransportChannel; -import org.elasticsearch.transport.TransportRequestOptions; -import org.elasticsearch.transport.TransportService; -import org.elasticsearch.transport.VoidTransportResponseHandler; +import org.elasticsearch.transport.*; import java.io.IOException; import java.util.List; @@ -74,8 +70,9 @@ public class RecoverySource extends AbstractComponent { private final RecoverySettings recoverySettings; - @Inject public RecoverySource(Settings settings, ThreadPool threadPool, TransportService transportService, IndicesService indicesService, - RecoverySettings recoverySettings) { + @Inject + public RecoverySource(Settings settings, ThreadPool threadPool, TransportService transportService, IndicesService indicesService, + RecoverySettings recoverySettings) { super(settings); this.threadPool = threadPool; this.transportService = transportService; @@ -91,7 +88,8 @@ public class RecoverySource extends AbstractComponent { logger.trace("[{}][{}] starting recovery to {}, mark_as_relocated {}", request.shardId().index().name(), request.shardId().id(), request.targetNode(), request.markAsRelocated()); final RecoveryResponse response = new RecoveryResponse(); shard.recover(new Engine.RecoveryHandler() { - @Override public void phase1(final SnapshotIndexCommit snapshot) throws ElasticSearchException { + @Override + public void phase1(final SnapshotIndexCommit snapshot) throws ElasticSearchException { long totalSize = 0; long existingTotalSize = 0; try { @@ -136,7 +134,8 @@ public class RecoverySource extends AbstractComponent { final AtomicReference lastException = new AtomicReference(); for (final String name : response.phase1FileNames) { recoverySettings.concurrentStreamPool().execute(new Runnable() { - @Override public void run() { + @Override + public void run() { IndexInput indexInput = null; try { final int BUFFER_SIZE = (int) recoverySettings.fileChunkSize().bytes(); @@ -196,7 +195,8 @@ public class RecoverySource extends AbstractComponent { } } - @Override public void phase2(Translog.Snapshot snapshot) throws ElasticSearchException { + @Override + public void phase2(Translog.Snapshot snapshot) throws ElasticSearchException { if (shard.state() == IndexShardState.CLOSED) { throw new IndexShardClosedException(request.shardId()); } @@ -213,7 +213,8 @@ public class RecoverySource extends AbstractComponent { response.phase2Operations = totalOperations; } - @Override public void phase3(Translog.Snapshot snapshot) throws ElasticSearchException { + @Override + public void phase3(Translog.Snapshot snapshot) throws ElasticSearchException { if (shard.state() == IndexShardState.CLOSED) { throw new IndexShardClosedException(request.shardId()); } @@ -277,15 +278,18 @@ public class RecoverySource extends AbstractComponent { class StartRecoveryTransportRequestHandler extends BaseTransportRequestHandler { - @Override public StartRecoveryRequest newInstance() { + @Override + public StartRecoveryRequest newInstance() { return new StartRecoveryRequest(); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.CACHED; } - @Override public void messageReceived(final StartRecoveryRequest request, final TransportChannel channel) throws Exception { + @Override + public void messageReceived(final StartRecoveryRequest request, final TransportChannel channel) throws Exception { RecoveryResponse response = recover(request); channel.sendResponse(response); } diff --git a/src/main/java/org/elasticsearch/indices/recovery/RecoveryStatus.java b/src/main/java/org/elasticsearch/indices/recovery/RecoveryStatus.java index bc43f54ba56..232fe71ac53 100644 --- a/src/main/java/org/elasticsearch/indices/recovery/RecoveryStatus.java +++ b/src/main/java/org/elasticsearch/indices/recovery/RecoveryStatus.java @@ -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 java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicLong; /** - * @author kimchy (shay.banon) + * */ public class RecoveryStatus { diff --git a/src/main/java/org/elasticsearch/indices/recovery/RecoveryTarget.java b/src/main/java/org/elasticsearch/indices/recovery/RecoveryTarget.java index 8bbff0d078a..a2e6e9ac55d 100644 --- a/src/main/java/org/elasticsearch/indices/recovery/RecoveryTarget.java +++ b/src/main/java/org/elasticsearch/indices/recovery/RecoveryTarget.java @@ -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.elasticsearch.indices.recovery; +import com.google.common.collect.Sets; import org.apache.lucene.store.AlreadyClosedException; import org.apache.lucene.store.IndexOutput; import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.StopWatch; -import org.elasticsearch.common.collect.Sets; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.io.stream.VoidStreamable; @@ -35,11 +35,7 @@ import org.elasticsearch.common.util.concurrent.ConcurrentCollections; import org.elasticsearch.index.IndexShardMissingException; import org.elasticsearch.index.engine.RecoveryEngineException; import org.elasticsearch.index.service.IndexService; -import org.elasticsearch.index.shard.IllegalIndexShardStateException; -import org.elasticsearch.index.shard.IndexShardClosedException; -import org.elasticsearch.index.shard.IndexShardNotStartedException; -import org.elasticsearch.index.shard.IndexShardState; -import org.elasticsearch.index.shard.ShardId; +import org.elasticsearch.index.shard.*; import org.elasticsearch.index.shard.service.IndexShard; import org.elasticsearch.index.shard.service.InternalIndexShard; import org.elasticsearch.index.store.Store; @@ -48,11 +44,7 @@ import org.elasticsearch.indices.IndexMissingException; import org.elasticsearch.indices.IndicesLifecycle; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.transport.BaseTransportRequestHandler; -import org.elasticsearch.transport.ConnectTransportException; -import org.elasticsearch.transport.FutureTransportResponseHandler; -import org.elasticsearch.transport.TransportChannel; -import org.elasticsearch.transport.TransportService; +import org.elasticsearch.transport.*; import java.io.IOException; import java.util.Collections; @@ -60,15 +52,15 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentMap; -import static org.elasticsearch.common.unit.TimeValue.*; +import static org.elasticsearch.common.unit.TimeValue.timeValueMillis; /** * The recovery target handles recoveries of peer shards of the shard+node to recover to. - * + *

    *

    Note, it can be safely assumed that there will only be a single recovery per shard (index+id) and * not several of them (since we don't allocate several shard replicas to the same node). * - * @author kimchy (shay.banon) + * */ public class RecoveryTarget extends AbstractComponent { @@ -91,8 +83,9 @@ public class RecoveryTarget extends AbstractComponent { private final ConcurrentMap onGoingRecoveries = ConcurrentCollections.newConcurrentMap(); - @Inject public RecoveryTarget(Settings settings, ThreadPool threadPool, TransportService transportService, IndicesService indicesService, - IndicesLifecycle indicesLifecycle, RecoverySettings recoverySettings) { + @Inject + public RecoveryTarget(Settings settings, ThreadPool threadPool, TransportService transportService, IndicesService indicesService, + IndicesLifecycle indicesLifecycle, RecoverySettings recoverySettings) { super(settings); this.threadPool = threadPool; this.transportService = transportService; @@ -107,7 +100,8 @@ public class RecoveryTarget extends AbstractComponent { transportService.registerHandler(Actions.FINALIZE, new FinalizeRecoveryRequestHandler()); indicesLifecycle.addListener(new IndicesLifecycle.Listener() { - @Override public void beforeIndexShardClosed(ShardId shardId, @Nullable IndexShard indexShard, boolean delete) { + @Override + public void beforeIndexShardClosed(ShardId shardId, @Nullable IndexShard indexShard, boolean delete) { removeAndCleanOnGoingRecovery(shardId); } }); @@ -157,7 +151,8 @@ public class RecoveryTarget extends AbstractComponent { return; } threadPool.cached().execute(new Runnable() { - @Override public void run() { + @Override + public void run() { doRecovery(shard, request, fromRetry, listener); } }); @@ -183,7 +178,8 @@ public class RecoveryTarget extends AbstractComponent { StopWatch stopWatch = new StopWatch().start(); RecoveryResponse recoveryStatus = transportService.submitRequest(request.sourceNode(), RecoverySource.Actions.START_RECOVERY, request, new FutureTransportResponseHandler() { - @Override public RecoveryResponse newInstance() { + @Override + public RecoveryResponse newInstance() { return new RecoveryResponse(); } }).txGet(); @@ -296,15 +292,18 @@ public class RecoveryTarget extends AbstractComponent { class PrepareForTranslogOperationsRequestHandler extends BaseTransportRequestHandler { - @Override public RecoveryPrepareForTranslogOperationsRequest newInstance() { + @Override + public RecoveryPrepareForTranslogOperationsRequest newInstance() { return new RecoveryPrepareForTranslogOperationsRequest(); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.CACHED; } - @Override public void messageReceived(RecoveryPrepareForTranslogOperationsRequest request, TransportChannel channel) throws Exception { + @Override + public void messageReceived(RecoveryPrepareForTranslogOperationsRequest request, TransportChannel channel) throws Exception { InternalIndexShard shard = (InternalIndexShard) indicesService.indexServiceSafe(request.shardId().index().name()).shardSafe(request.shardId().id()); RecoveryStatus onGoingRecovery = onGoingRecoveries.get(shard.shardId()); @@ -321,15 +320,18 @@ public class RecoveryTarget extends AbstractComponent { class FinalizeRecoveryRequestHandler extends BaseTransportRequestHandler { - @Override public RecoveryFinalizeRecoveryRequest newInstance() { + @Override + public RecoveryFinalizeRecoveryRequest newInstance() { return new RecoveryFinalizeRecoveryRequest(); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.CACHED; } - @Override public void messageReceived(RecoveryFinalizeRecoveryRequest request, TransportChannel channel) throws Exception { + @Override + public void messageReceived(RecoveryFinalizeRecoveryRequest request, TransportChannel channel) throws Exception { InternalIndexShard shard = (InternalIndexShard) indicesService.indexServiceSafe(request.shardId().index().name()).shardSafe(request.shardId().id()); RecoveryStatus peerRecoveryStatus = onGoingRecoveries.get(shard.shardId()); if (peerRecoveryStatus == null) { @@ -347,15 +349,18 @@ public class RecoveryTarget extends AbstractComponent { class TranslogOperationsRequestHandler extends BaseTransportRequestHandler { - @Override public RecoveryTranslogOperationsRequest newInstance() { + @Override + public RecoveryTranslogOperationsRequest newInstance() { return new RecoveryTranslogOperationsRequest(); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.CACHED; } - @Override public void messageReceived(RecoveryTranslogOperationsRequest request, TransportChannel channel) throws Exception { + @Override + public void messageReceived(RecoveryTranslogOperationsRequest request, TransportChannel channel) throws Exception { InternalIndexShard shard = (InternalIndexShard) indicesService.indexServiceSafe(request.shardId().index().name()).shardSafe(request.shardId().id()); for (Translog.Operation operation : request.operations()) { shard.performRecoveryOperation(operation); @@ -374,15 +379,18 @@ public class RecoveryTarget extends AbstractComponent { class FilesInfoRequestHandler extends BaseTransportRequestHandler { - @Override public RecoveryFilesInfoRequest newInstance() { + @Override + public RecoveryFilesInfoRequest newInstance() { return new RecoveryFilesInfoRequest(); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.CACHED; } - @Override public void messageReceived(RecoveryFilesInfoRequest request, TransportChannel channel) throws Exception { + @Override + public void messageReceived(RecoveryFilesInfoRequest request, TransportChannel channel) throws Exception { InternalIndexShard shard = (InternalIndexShard) indicesService.indexServiceSafe(request.shardId.index().name()).shardSafe(request.shardId.id()); RecoveryStatus onGoingRecovery = onGoingRecoveries.get(shard.shardId()); if (onGoingRecovery == null) { @@ -402,15 +410,18 @@ public class RecoveryTarget extends AbstractComponent { class CleanFilesRequestHandler extends BaseTransportRequestHandler { - @Override public RecoveryCleanFilesRequest newInstance() { + @Override + public RecoveryCleanFilesRequest newInstance() { return new RecoveryCleanFilesRequest(); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.CACHED; } - @Override public void messageReceived(RecoveryCleanFilesRequest request, TransportChannel channel) throws Exception { + @Override + public void messageReceived(RecoveryCleanFilesRequest request, TransportChannel channel) throws Exception { InternalIndexShard shard = (InternalIndexShard) indicesService.indexServiceSafe(request.shardId().index().name()).shardSafe(request.shardId().id()); RecoveryStatus onGoingRecovery = onGoingRecoveries.get(shard.shardId()); if (onGoingRecovery == null) { @@ -467,15 +478,18 @@ public class RecoveryTarget extends AbstractComponent { class FileChunkTransportRequestHandler extends BaseTransportRequestHandler { - @Override public RecoveryFileChunkRequest newInstance() { + @Override + public RecoveryFileChunkRequest newInstance() { return new RecoveryFileChunkRequest(); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.CACHED; } - @Override public void messageReceived(final RecoveryFileChunkRequest request, TransportChannel channel) throws Exception { + @Override + public void messageReceived(final RecoveryFileChunkRequest request, TransportChannel channel) throws Exception { InternalIndexShard shard = (InternalIndexShard) indicesService.indexServiceSafe(request.shardId().index().name()).shardSafe(request.shardId().id()); RecoveryStatus onGoingRecovery = onGoingRecoveries.get(shard.shardId()); if (onGoingRecovery == null) { diff --git a/src/main/java/org/elasticsearch/indices/recovery/RecoveryTranslogOperationsRequest.java b/src/main/java/org/elasticsearch/indices/recovery/RecoveryTranslogOperationsRequest.java index 7db2df0c4dd..392eba0a447 100644 --- a/src/main/java/org/elasticsearch/indices/recovery/RecoveryTranslogOperationsRequest.java +++ b/src/main/java/org/elasticsearch/indices/recovery/RecoveryTranslogOperationsRequest.java @@ -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,7 +19,7 @@ package org.elasticsearch.indices.recovery; -import org.elasticsearch.common.collect.Lists; +import com.google.common.collect.Lists; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Streamable; @@ -31,7 +31,7 @@ import java.io.IOException; import java.util.List; /** - * @author kimchy (shay.banon) + * */ class RecoveryTranslogOperationsRequest implements Streamable { @@ -54,7 +54,8 @@ class RecoveryTranslogOperationsRequest implements Streamable { return operations; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { shardId = ShardId.readShardId(in); int size = in.readVInt(); operations = Lists.newArrayListWithExpectedSize(size); @@ -63,7 +64,8 @@ class RecoveryTranslogOperationsRequest implements Streamable { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { shardId.writeTo(out); out.writeVInt(operations.size()); for (Translog.Operation operation : operations) { diff --git a/src/main/java/org/elasticsearch/indices/recovery/StartRecoveryRequest.java b/src/main/java/org/elasticsearch/indices/recovery/StartRecoveryRequest.java index bddbd0d803c..80970a1fcf4 100644 --- a/src/main/java/org/elasticsearch/indices/recovery/StartRecoveryRequest.java +++ b/src/main/java/org/elasticsearch/indices/recovery/StartRecoveryRequest.java @@ -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.indices.recovery; +import com.google.common.collect.Maps; import org.elasticsearch.cluster.node.DiscoveryNode; -import org.elasticsearch.common.collect.Maps; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Streamable; @@ -31,7 +31,7 @@ import java.io.IOException; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class StartRecoveryRequest implements Streamable { @@ -85,7 +85,8 @@ public class StartRecoveryRequest implements Streamable { return existingFiles; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { shardId = ShardId.readShardId(in); sourceNode = DiscoveryNode.readNode(in); targetNode = DiscoveryNode.readNode(in); @@ -98,7 +99,8 @@ public class StartRecoveryRequest implements Streamable { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { shardId.writeTo(out); sourceNode.writeTo(out); targetNode.writeTo(out); diff --git a/src/main/java/org/elasticsearch/indices/store/IndicesStore.java b/src/main/java/org/elasticsearch/indices/store/IndicesStore.java index 0a49d518691..37988505937 100644 --- a/src/main/java/org/elasticsearch/indices/store/IndicesStore.java +++ b/src/main/java/org/elasticsearch/indices/store/IndicesStore.java @@ -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,11 +22,7 @@ package org.elasticsearch.indices.store; import org.elasticsearch.cluster.ClusterChangedEvent; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.ClusterStateListener; -import org.elasticsearch.cluster.routing.IndexRoutingTable; -import org.elasticsearch.cluster.routing.IndexShardRoutingTable; -import org.elasticsearch.cluster.routing.RoutingTable; -import org.elasticsearch.cluster.routing.ShardRouting; -import org.elasticsearch.cluster.routing.ShardRoutingState; +import org.elasticsearch.cluster.routing.*; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.io.FileSystemUtils; @@ -39,7 +35,7 @@ import org.elasticsearch.indices.IndicesService; import java.io.File; /** - * @author kimchy (shay.banon) + * */ public class IndicesStore extends AbstractComponent implements ClusterStateListener { @@ -49,7 +45,8 @@ public class IndicesStore extends AbstractComponent implements ClusterStateListe private final ClusterService clusterService; - @Inject public IndicesStore(Settings settings, NodeEnvironment nodeEnv, IndicesService indicesService, ClusterService clusterService) { + @Inject + public IndicesStore(Settings settings, NodeEnvironment nodeEnv, IndicesService indicesService, ClusterService clusterService) { super(settings); this.nodeEnv = nodeEnv; this.indicesService = indicesService; @@ -61,7 +58,8 @@ public class IndicesStore extends AbstractComponent implements ClusterStateListe clusterService.remove(this); } - @Override public void clusterChanged(ClusterChangedEvent event) { + @Override + public void clusterChanged(ClusterChangedEvent event) { if (!event.routingTableChanged()) { return; } diff --git a/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetaData.java b/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetaData.java index c36b31536ee..f1b07ad6b9c 100644 --- a/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetaData.java +++ b/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetaData.java @@ -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,22 +19,18 @@ package org.elasticsearch.indices.store; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.action.ActionFuture; import org.elasticsearch.action.FailedNodeException; -import org.elasticsearch.action.support.nodes.NodeOperationRequest; -import org.elasticsearch.action.support.nodes.NodeOperationResponse; -import org.elasticsearch.action.support.nodes.NodesOperationRequest; -import org.elasticsearch.action.support.nodes.NodesOperationResponse; -import org.elasticsearch.action.support.nodes.TransportNodesOperationAction; +import org.elasticsearch.action.support.nodes.*; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.collect.Maps; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -60,7 +56,7 @@ import java.util.Set; import java.util.concurrent.atomic.AtomicReferenceArray; /** - * @author kimchy (shay.banon) + * */ public class TransportNodesListShardStoreMetaData extends TransportNodesOperationAction { @@ -68,8 +64,9 @@ public class TransportNodesListShardStoreMetaData extends TransportNodesOperatio private final NodeEnvironment nodeEnv; - @Inject public TransportNodesListShardStoreMetaData(Settings settings, ClusterName clusterName, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, - IndicesService indicesService, NodeEnvironment nodeEnv) { + @Inject + public TransportNodesListShardStoreMetaData(Settings settings, ClusterName clusterName, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, + IndicesService indicesService, NodeEnvironment nodeEnv) { super(settings, clusterName, threadPool, clusterService, transportService); this.indicesService = indicesService; this.nodeEnv = nodeEnv; @@ -79,35 +76,43 @@ public class TransportNodesListShardStoreMetaData extends TransportNodesOperatio return execute(new Request(shardId, onlyUnallocated, nodesIds).timeout(timeout)); } - @Override protected String executor() { + @Override + protected String executor() { return ThreadPool.Names.CACHED; } - @Override protected String transportAction() { + @Override + protected String transportAction() { return "/cluster/nodes/indices/shard/store"; } - @Override protected String transportNodeAction() { + @Override + protected String transportNodeAction() { return "/cluster/nodes/indices/shard/store/node"; } - @Override protected Request newRequest() { + @Override + protected Request newRequest() { return new Request(); } - @Override protected NodeRequest newNodeRequest() { + @Override + protected NodeRequest newNodeRequest() { return new NodeRequest(); } - @Override protected NodeRequest newNodeRequest(String nodeId, Request request) { + @Override + protected NodeRequest newNodeRequest(String nodeId, Request request) { return new NodeRequest(nodeId, request.shardId, request.unallocated); } - @Override protected NodeStoreFilesMetaData newNodeResponse() { + @Override + protected NodeStoreFilesMetaData newNodeResponse() { return new NodeStoreFilesMetaData(); } - @Override protected NodesStoreFilesMetaData newResponse(Request request, AtomicReferenceArray responses) { + @Override + protected NodesStoreFilesMetaData newResponse(Request request, AtomicReferenceArray responses) { final List nodeStoreFilesMetaDatas = Lists.newArrayList(); final List failures = Lists.newArrayList(); for (int i = 0; i < responses.length(); i++) { @@ -122,7 +127,8 @@ public class TransportNodesListShardStoreMetaData extends TransportNodesOperatio failures.toArray(new FailedNodeException[failures.size()])); } - @Override protected NodeStoreFilesMetaData nodeOperation(NodeRequest request) throws ElasticSearchException { + @Override + protected NodeStoreFilesMetaData nodeOperation(NodeRequest request) throws ElasticSearchException { if (request.unallocated) { IndexService indexService = indicesService.indexService(request.shardId.index().name()); if (indexService == null) { @@ -202,7 +208,8 @@ public class TransportNodesListShardStoreMetaData extends TransportNodesOperatio return new StoreFilesMetaData(false, shardId, files); } - @Override protected boolean accumulateExceptions() { + @Override + protected boolean accumulateExceptions() { return true; } @@ -236,7 +243,8 @@ public class TransportNodesListShardStoreMetaData extends TransportNodesOperatio return totalSizeInBytes; } - @Override public Iterator iterator() { + @Override + public Iterator iterator() { return files.values().iterator(); } @@ -254,7 +262,8 @@ public class TransportNodesListShardStoreMetaData extends TransportNodesOperatio return md; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { allocated = in.readBoolean(); shardId = ShardId.readShardId(in); int size = in.readVInt(); @@ -265,7 +274,8 @@ public class TransportNodesListShardStoreMetaData extends TransportNodesOperatio } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(allocated); shardId.writeTo(out); out.writeVInt(files.size()); @@ -297,18 +307,21 @@ public class TransportNodesListShardStoreMetaData extends TransportNodesOperatio this.unallocated = unallocated; } - @Override public Request timeout(TimeValue timeout) { + @Override + public Request timeout(TimeValue timeout) { super.timeout(timeout); return this; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); shardId = ShardId.readShardId(in); unallocated = in.readBoolean(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); shardId.writeTo(out); out.writeBoolean(unallocated); @@ -331,7 +344,8 @@ public class TransportNodesListShardStoreMetaData extends TransportNodesOperatio return failures; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); nodes = new NodeStoreFilesMetaData[in.readVInt()]; for (int i = 0; i < nodes.length; i++) { @@ -339,7 +353,8 @@ public class TransportNodesListShardStoreMetaData extends TransportNodesOperatio } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeVInt(nodes.length); for (NodeStoreFilesMetaData response : nodes) { @@ -364,13 +379,15 @@ public class TransportNodesListShardStoreMetaData extends TransportNodesOperatio this.unallocated = unallocated; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); shardId = ShardId.readShardId(in); unallocated = in.readBoolean(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); shardId.writeTo(out); out.writeBoolean(unallocated); @@ -399,14 +416,16 @@ public class TransportNodesListShardStoreMetaData extends TransportNodesOperatio return resp; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { super.readFrom(in); if (in.readBoolean()) { storeFilesMetaData = StoreFilesMetaData.readStoreFilesMetaData(in); } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); if (storeFilesMetaData == null) { out.writeBoolean(false); diff --git a/src/main/java/org/elasticsearch/indices/ttl/IndicesTTLService.java b/src/main/java/org/elasticsearch/indices/ttl/IndicesTTLService.java index 05f296c584c..07be34a3f9a 100644 --- a/src/main/java/org/elasticsearch/indices/ttl/IndicesTTLService.java +++ b/src/main/java/org/elasticsearch/indices/ttl/IndicesTTLService.java @@ -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 @@ -73,7 +73,8 @@ public class IndicesTTLService extends AbstractLifecycleComponent 0) || bulkRequest.numberOfActions() >= bulkSize) { try { bulkRequest.execute(new ActionListener() { - @Override public void onResponse(BulkResponse bulkResponse) { + @Override + public void onResponse(BulkResponse bulkResponse) { logger.trace("bulk took " + bulkResponse.getTookInMillis() + "ms"); } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { logger.warn("failed to execute bulk"); } }); @@ -247,7 +253,8 @@ public class IndicesTTLService extends AbstractLifecycleComponent void hear(TypeLiteral typeLiteral, TypeEncounter typeEncounter) { + @Override + public void hear(TypeLiteral typeLiteral, TypeEncounter typeEncounter) { Class type = typeLiteral.getRawType(); if (type.isAnnotationPresent(MBean.class)) { typeEncounter.register(new JmxExporterInjectionListener(jmxService)); @@ -71,7 +73,8 @@ public class JmxModule extends AbstractModule { this.jmxService = jmxService; } - @Override public void afterInjection(I instance) { + @Override + public void afterInjection(I instance) { jmxService.registerMBean(instance); } } diff --git a/src/main/java/org/elasticsearch/jmx/JmxRegistrationException.java b/src/main/java/org/elasticsearch/jmx/JmxRegistrationException.java index 8b347c2662f..9f2c535a355 100644 --- a/src/main/java/org/elasticsearch/jmx/JmxRegistrationException.java +++ b/src/main/java/org/elasticsearch/jmx/JmxRegistrationException.java @@ -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.jmx; /** - * @author kimchy (Shay Banon) + * */ public class JmxRegistrationException extends JmxException { diff --git a/src/main/java/org/elasticsearch/jmx/JmxService.java b/src/main/java/org/elasticsearch/jmx/JmxService.java index 3075d4e2f98..2984e1deadd 100644 --- a/src/main/java/org/elasticsearch/jmx/JmxService.java +++ b/src/main/java/org/elasticsearch/jmx/JmxService.java @@ -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.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.atomic.AtomicReference; /** - * @author kimchy (shay.banon) + * */ public class JmxService { @@ -113,7 +113,8 @@ public class JmxService { PortsRange portsRange = new PortsRange(port); final AtomicReference lastException = new AtomicReference(); boolean success = portsRange.iterate(new PortsRange.PortCallback() { - @Override public boolean onPortNumber(int portNumber) { + @Override + public boolean onPortNumber(int portNumber) { try { LocateRegistry.createRegistry(portNumber); serviceUrl = settings.get("jmx.service_url", JMXRMI_URI_PATTERN).replace("{jmx.port}", Integer.toString(portNumber)); diff --git a/src/main/java/org/elasticsearch/jmx/MBean.java b/src/main/java/org/elasticsearch/jmx/MBean.java index 2efd4d636a0..1b3deb75eb1 100644 --- a/src/main/java/org/elasticsearch/jmx/MBean.java +++ b/src/main/java/org/elasticsearch/jmx/MBean.java @@ -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.jmx; import java.lang.annotation.*; /** - * @author kimchy (Shay Banon) + * */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE}) diff --git a/src/main/java/org/elasticsearch/jmx/ManagedAttribute.java b/src/main/java/org/elasticsearch/jmx/ManagedAttribute.java index 09948ee3f94..5b280b542aa 100644 --- a/src/main/java/org/elasticsearch/jmx/ManagedAttribute.java +++ b/src/main/java/org/elasticsearch/jmx/ManagedAttribute.java @@ -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.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * @author kimchy (Shay Banon) + * */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD, ElementType.FIELD}) diff --git a/src/main/java/org/elasticsearch/jmx/ManagedGroupName.java b/src/main/java/org/elasticsearch/jmx/ManagedGroupName.java index e435a9cc144..e2ffa1e6136 100644 --- a/src/main/java/org/elasticsearch/jmx/ManagedGroupName.java +++ b/src/main/java/org/elasticsearch/jmx/ManagedGroupName.java @@ -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.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * @author kimchy (Shay Banon) + * */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD}) diff --git a/src/main/java/org/elasticsearch/jmx/ManagedOperation.java b/src/main/java/org/elasticsearch/jmx/ManagedOperation.java index b5c6aa12d46..d5890f688bf 100644 --- a/src/main/java/org/elasticsearch/jmx/ManagedOperation.java +++ b/src/main/java/org/elasticsearch/jmx/ManagedOperation.java @@ -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.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * @author kimchy (Shay Banon) + * */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD}) diff --git a/src/main/java/org/elasticsearch/jmx/ResourceDMBean.java b/src/main/java/org/elasticsearch/jmx/ResourceDMBean.java index ff73a017fa8..e4c6dcd1ded 100644 --- a/src/main/java/org/elasticsearch/jmx/ResourceDMBean.java +++ b/src/main/java/org/elasticsearch/jmx/ResourceDMBean.java @@ -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,11 +19,11 @@ package org.elasticsearch.jmx; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import org.elasticsearch.common.Classes; import org.elasticsearch.common.Preconditions; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.collect.MapBuilder; import org.elasticsearch.common.logging.ESLogger; @@ -37,10 +37,10 @@ import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; -import static org.elasticsearch.common.collect.MapBuilder.*; +import static org.elasticsearch.common.collect.MapBuilder.newMapBuilder; /** - * @author kimchy (Shay Banon) + * */ public class ResourceDMBean implements DynamicMBean { private static final Class[] primitives = {int.class, byte.class, short.class, long.class, diff --git a/src/main/java/org/elasticsearch/jmx/action/GetJmxServiceUrlAction.java b/src/main/java/org/elasticsearch/jmx/action/GetJmxServiceUrlAction.java index 12ff0f15e35..b91612a9aae 100644 --- a/src/main/java/org/elasticsearch/jmx/action/GetJmxServiceUrlAction.java +++ b/src/main/java/org/elasticsearch/jmx/action/GetJmxServiceUrlAction.java @@ -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.TransportChannel; import org.elasticsearch.transport.TransportService; /** - * @author kimchy (Shay Banon) + * */ public class GetJmxServiceUrlAction extends AbstractComponent { @@ -45,8 +45,9 @@ public class GetJmxServiceUrlAction extends AbstractComponent { private final ClusterService clusterService; - @Inject public GetJmxServiceUrlAction(Settings settings, JmxService jmxService, - TransportService transportService, ClusterService clusterService) { + @Inject + public GetJmxServiceUrlAction(Settings settings, JmxService jmxService, + TransportService transportService, ClusterService clusterService) { super(settings); this.jmxService = jmxService; this.transportService = transportService; @@ -60,7 +61,8 @@ public class GetJmxServiceUrlAction extends AbstractComponent { return jmxService.publishUrl(); } else { return transportService.submitRequest(node, GetJmxServiceUrlTransportHandler.ACTION, VoidStreamable.INSTANCE, new FutureTransportResponseHandler() { - @Override public StringStreamable newInstance() { + @Override + public StringStreamable newInstance() { return new StringStreamable(); } }).txGet().get(); @@ -71,15 +73,18 @@ public class GetJmxServiceUrlAction extends AbstractComponent { static final String ACTION = "jmx/publishUrl"; - @Override public VoidStreamable newInstance() { + @Override + public VoidStreamable newInstance() { return VoidStreamable.INSTANCE; } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } - @Override public void messageReceived(VoidStreamable request, TransportChannel channel) throws Exception { + @Override + public void messageReceived(VoidStreamable request, TransportChannel channel) throws Exception { channel.sendResponse(new StringStreamable(jmxService.publishUrl())); } } diff --git a/src/main/java/org/elasticsearch/monitor/MonitorModule.java b/src/main/java/org/elasticsearch/monitor/MonitorModule.java index 38cca916e48..a2f95bc28d8 100644 --- a/src/main/java/org/elasticsearch/monitor/MonitorModule.java +++ b/src/main/java/org/elasticsearch/monitor/MonitorModule.java @@ -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 @@ -49,13 +49,13 @@ import org.elasticsearch.monitor.sigar.SigarService; import java.util.Map; -import static org.elasticsearch.monitor.dump.cluster.ClusterDumpContributor.*; -import static org.elasticsearch.monitor.dump.heap.HeapDumpContributor.*; -import static org.elasticsearch.monitor.dump.summary.SummaryDumpContributor.*; -import static org.elasticsearch.monitor.dump.thread.ThreadDumpContributor.*; +import static org.elasticsearch.monitor.dump.cluster.ClusterDumpContributor.CLUSTER; +import static org.elasticsearch.monitor.dump.heap.HeapDumpContributor.HEAP_DUMP; +import static org.elasticsearch.monitor.dump.summary.SummaryDumpContributor.SUMMARY; +import static org.elasticsearch.monitor.dump.thread.ThreadDumpContributor.THREAD_DUMP; /** - * @author kimchy (Shay Banon) + * */ public class MonitorModule extends AbstractModule { @@ -69,7 +69,8 @@ public class MonitorModule extends AbstractModule { this.settings = settings; } - @Override protected void configure() { + @Override + protected void configure() { boolean sigarLoaded = false; try { settings.getClassLoader().loadClass("org.hyperic.sigar.Sigar"); diff --git a/src/main/java/org/elasticsearch/monitor/MonitorService.java b/src/main/java/org/elasticsearch/monitor/MonitorService.java index a8090031b83..a3dbed43301 100644 --- a/src/main/java/org/elasticsearch/monitor/MonitorService.java +++ b/src/main/java/org/elasticsearch/monitor/MonitorService.java @@ -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 org.elasticsearch.monitor.os.OsService; import org.elasticsearch.monitor.process.ProcessService; /** - * @author kimchy (shay.banon) + * */ public class MonitorService extends AbstractLifecycleComponent { @@ -44,8 +44,9 @@ public class MonitorService extends AbstractLifecycleComponent { private final NetworkService networkService; - @Inject public MonitorService(Settings settings, JvmMonitorService jvmMonitorService, - OsService osService, ProcessService processService, JvmService jvmService, NetworkService networkService) { + @Inject + public MonitorService(Settings settings, JvmMonitorService jvmMonitorService, + OsService osService, ProcessService processService, JvmService jvmService, NetworkService networkService) { super(settings); this.jvmMonitorService = jvmMonitorService; this.osService = osService; @@ -70,15 +71,18 @@ public class MonitorService extends AbstractLifecycleComponent { return this.networkService; } - @Override protected void doStart() throws ElasticSearchException { + @Override + protected void doStart() throws ElasticSearchException { jvmMonitorService.start(); } - @Override protected void doStop() throws ElasticSearchException { + @Override + protected void doStop() throws ElasticSearchException { jvmMonitorService.stop(); } - @Override protected void doClose() throws ElasticSearchException { + @Override + protected void doClose() throws ElasticSearchException { jvmMonitorService.close(); } } diff --git a/src/main/java/org/elasticsearch/monitor/dump/AbstractDump.java b/src/main/java/org/elasticsearch/monitor/dump/AbstractDump.java index 728cf1a80cc..4e14fab2d51 100644 --- a/src/main/java/org/elasticsearch/monitor/dump/AbstractDump.java +++ b/src/main/java/org/elasticsearch/monitor/dump/AbstractDump.java @@ -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,15 +19,15 @@ package org.elasticsearch.monitor.dump; +import com.google.common.collect.ImmutableMap; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.collect.ImmutableMap; import java.io.*; import java.util.ArrayList; import java.util.Map; /** - * @author kimchy (Shay Banon) + * */ public abstract class AbstractDump implements Dump { @@ -48,23 +48,28 @@ public abstract class AbstractDump implements Dump { this.context = context; } - @Override public long timestamp() { + @Override + public long timestamp() { return timestamp; } - @Override public Map context() { + @Override + public Map context() { return this.context; } - @Override public String cause() { + @Override + public String cause() { return cause; } - @Override public File[] files() { + @Override + public File[] files() { return files.toArray(new File[files.size()]); } - @Override public File createFile(String name) throws DumpException { + @Override + public File createFile(String name) throws DumpException { File file = doCreateFile(name); files.add(file); return file; @@ -72,7 +77,8 @@ public abstract class AbstractDump implements Dump { protected abstract File doCreateFile(String name) throws DumpException; - @Override public OutputStream createFileOutputStream(String name) throws DumpException { + @Override + public OutputStream createFileOutputStream(String name) throws DumpException { try { return new FileOutputStream(createFile(name)); } catch (FileNotFoundException e) { @@ -80,7 +86,8 @@ public abstract class AbstractDump implements Dump { } } - @Override public Writer createFileWriter(String name) throws DumpException { + @Override + public Writer createFileWriter(String name) throws DumpException { try { return new FileWriter(createFile(name)); } catch (IOException e) { diff --git a/src/main/java/org/elasticsearch/monitor/dump/Dump.java b/src/main/java/org/elasticsearch/monitor/dump/Dump.java index 4f4d9844003..0f6033f1a42 100644 --- a/src/main/java/org/elasticsearch/monitor/dump/Dump.java +++ b/src/main/java/org/elasticsearch/monitor/dump/Dump.java @@ -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.io.Writer; import java.util.Map; /** - * @author kimchy (Shay Banon) + * */ public interface Dump { diff --git a/src/main/java/org/elasticsearch/monitor/dump/DumpContributionFailedException.java b/src/main/java/org/elasticsearch/monitor/dump/DumpContributionFailedException.java index 25634754178..f2935e7b14c 100644 --- a/src/main/java/org/elasticsearch/monitor/dump/DumpContributionFailedException.java +++ b/src/main/java/org/elasticsearch/monitor/dump/DumpContributionFailedException.java @@ -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.monitor.dump; /** - * @author kimchy (Shay Banon) + * */ public class DumpContributionFailedException extends DumpException { diff --git a/src/main/java/org/elasticsearch/monitor/dump/DumpContributor.java b/src/main/java/org/elasticsearch/monitor/dump/DumpContributor.java index 0a1fb72a08a..7409b343f55 100644 --- a/src/main/java/org/elasticsearch/monitor/dump/DumpContributor.java +++ b/src/main/java/org/elasticsearch/monitor/dump/DumpContributor.java @@ -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.monitor.dump; /** - * @author kimchy (Shay Banon) + * */ public interface DumpContributor { diff --git a/src/main/java/org/elasticsearch/monitor/dump/DumpContributorFactory.java b/src/main/java/org/elasticsearch/monitor/dump/DumpContributorFactory.java index dd31e145665..4eb1d312c14 100644 --- a/src/main/java/org/elasticsearch/monitor/dump/DumpContributorFactory.java +++ b/src/main/java/org/elasticsearch/monitor/dump/DumpContributorFactory.java @@ -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.monitor.dump; import org.elasticsearch.common.settings.Settings; /** - * @author kimchy (Shay Banon) + * */ public interface DumpContributorFactory { diff --git a/src/main/java/org/elasticsearch/monitor/dump/DumpException.java b/src/main/java/org/elasticsearch/monitor/dump/DumpException.java index 2901d5d2e8b..8a286eec720 100644 --- a/src/main/java/org/elasticsearch/monitor/dump/DumpException.java +++ b/src/main/java/org/elasticsearch/monitor/dump/DumpException.java @@ -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.monitor.dump; import org.elasticsearch.ElasticSearchException; /** - * @author kimchy (Shay Banon) + * */ public class DumpException extends ElasticSearchException { diff --git a/src/main/java/org/elasticsearch/monitor/dump/DumpGenerationFailedException.java b/src/main/java/org/elasticsearch/monitor/dump/DumpGenerationFailedException.java index 547ee6480f1..bb52f538dd8 100644 --- a/src/main/java/org/elasticsearch/monitor/dump/DumpGenerationFailedException.java +++ b/src/main/java/org/elasticsearch/monitor/dump/DumpGenerationFailedException.java @@ -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.monitor.dump; /** - * @author kimchy (Shay Banon) + * */ public class DumpGenerationFailedException extends DumpException { diff --git a/src/main/java/org/elasticsearch/monitor/dump/DumpGenerator.java b/src/main/java/org/elasticsearch/monitor/dump/DumpGenerator.java index e5e0c1217a3..b1e4908814c 100644 --- a/src/main/java/org/elasticsearch/monitor/dump/DumpGenerator.java +++ b/src/main/java/org/elasticsearch/monitor/dump/DumpGenerator.java @@ -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.File; import java.util.Map; /** - * @author kimchy (Shay Banon) + * */ public interface DumpGenerator { diff --git a/src/main/java/org/elasticsearch/monitor/dump/DumpMonitorService.java b/src/main/java/org/elasticsearch/monitor/dump/DumpMonitorService.java index 9c71110ab45..00b12c3b528 100644 --- a/src/main/java/org/elasticsearch/monitor/dump/DumpMonitorService.java +++ b/src/main/java/org/elasticsearch/monitor/dump/DumpMonitorService.java @@ -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,14 +32,14 @@ import org.elasticsearch.monitor.dump.thread.ThreadDumpContributor; import java.io.File; import java.util.Map; -import static org.elasticsearch.common.collect.Maps.*; -import static org.elasticsearch.common.settings.ImmutableSettings.Builder.*; -import static org.elasticsearch.monitor.dump.heap.HeapDumpContributor.*; -import static org.elasticsearch.monitor.dump.summary.SummaryDumpContributor.*; -import static org.elasticsearch.monitor.dump.thread.ThreadDumpContributor.*; +import static com.google.common.collect.Maps.newHashMap; +import static org.elasticsearch.common.settings.ImmutableSettings.Builder.EMPTY_SETTINGS; +import static org.elasticsearch.monitor.dump.heap.HeapDumpContributor.HEAP_DUMP; +import static org.elasticsearch.monitor.dump.summary.SummaryDumpContributor.SUMMARY; +import static org.elasticsearch.monitor.dump.thread.ThreadDumpContributor.THREAD_DUMP; /** - * @author kimchy (Shay Banon) + * */ public class DumpMonitorService extends AbstractComponent { @@ -56,8 +56,9 @@ public class DumpMonitorService extends AbstractComponent { this(EMPTY_SETTINGS, new Environment(EMPTY_SETTINGS), null, null); } - @Inject public DumpMonitorService(Settings settings, Environment environment, - @Nullable ClusterService clusterService, @Nullable Map contributors) { + @Inject + public DumpMonitorService(Settings settings, Environment environment, + @Nullable ClusterService clusterService, @Nullable Map contributors) { super(settings); this.clusterService = clusterService; this.contributors = contributors; diff --git a/src/main/java/org/elasticsearch/monitor/dump/SimpleDump.java b/src/main/java/org/elasticsearch/monitor/dump/SimpleDump.java index e962c582f25..7146144cda8 100644 --- a/src/main/java/org/elasticsearch/monitor/dump/SimpleDump.java +++ b/src/main/java/org/elasticsearch/monitor/dump/SimpleDump.java @@ -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.FileNotFoundException; import java.util.Map; /** - * @author kimchy (Shay Banon) + * */ public class SimpleDump extends AbstractDump { @@ -37,11 +37,13 @@ public class SimpleDump extends AbstractDump { this.location = location; } - @Override protected File doCreateFile(String name) throws DumpException { + @Override + protected File doCreateFile(String name) throws DumpException { return new File(location, name); } - @Override public void finish() throws DumpException { + @Override + public void finish() throws DumpException { } } diff --git a/src/main/java/org/elasticsearch/monitor/dump/SimpleDumpGenerator.java b/src/main/java/org/elasticsearch/monitor/dump/SimpleDumpGenerator.java index 6d5b6038e07..960c8ccd623 100644 --- a/src/main/java/org/elasticsearch/monitor/dump/SimpleDumpGenerator.java +++ b/src/main/java/org/elasticsearch/monitor/dump/SimpleDumpGenerator.java @@ -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.monitor.dump; +import com.google.common.collect.ImmutableMap; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.io.FileSystemUtils; import java.io.File; @@ -30,7 +30,7 @@ import java.util.ArrayList; import java.util.Map; /** - * @author kimchy (Shay Banon) + * */ public class SimpleDumpGenerator implements DumpGenerator { diff --git a/src/main/java/org/elasticsearch/monitor/dump/cluster/ClusterDumpContributor.java b/src/main/java/org/elasticsearch/monitor/dump/cluster/ClusterDumpContributor.java index 862b331ccdd..bebb99b9f1a 100644 --- a/src/main/java/org/elasticsearch/monitor/dump/cluster/ClusterDumpContributor.java +++ b/src/main/java/org/elasticsearch/monitor/dump/cluster/ClusterDumpContributor.java @@ -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,7 +33,7 @@ import org.elasticsearch.monitor.dump.DumpContributor; import java.io.PrintWriter; /** - * @author kimchy (Shay Banon) + * */ public class ClusterDumpContributor implements DumpContributor { @@ -43,16 +43,19 @@ public class ClusterDumpContributor implements DumpContributor { private final ClusterService clusterService; - @Inject public ClusterDumpContributor(ClusterService clusterService, @Assisted String name, @Assisted Settings settings) { + @Inject + public ClusterDumpContributor(ClusterService clusterService, @Assisted String name, @Assisted Settings settings) { this.clusterService = clusterService; this.name = name; } - @Override public String getName() { + @Override + public String getName() { return name; } - @Override public void contribute(Dump dump) throws DumpContributionFailedException { + @Override + public void contribute(Dump dump) throws DumpContributionFailedException { ClusterState clusterState = clusterService.state(); DiscoveryNodes nodes = clusterState.nodes(); RoutingTable routingTable = clusterState.routingTable(); diff --git a/src/main/java/org/elasticsearch/monitor/dump/heap/HeapDumpContributor.java b/src/main/java/org/elasticsearch/monitor/dump/heap/HeapDumpContributor.java index 0cd39997400..e94eb2b5943 100644 --- a/src/main/java/org/elasticsearch/monitor/dump/heap/HeapDumpContributor.java +++ b/src/main/java/org/elasticsearch/monitor/dump/heap/HeapDumpContributor.java @@ -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.monitor.dump.DumpContributor; import java.lang.reflect.Method; /** - * @author kimchy (Shay Banon) + * */ public class HeapDumpContributor implements DumpContributor { @@ -40,7 +40,8 @@ public class HeapDumpContributor implements DumpContributor { private final String name; - @Inject public HeapDumpContributor(@Assisted String name, @Assisted Settings settings) { + @Inject + public HeapDumpContributor(@Assisted String name, @Assisted Settings settings) { this.name = name; Method heapDumpMethod; Object diagnosticMBean; @@ -49,8 +50,7 @@ public class HeapDumpContributor implements DumpContributor { Method method = managementFactoryClass.getMethod("getDiagnosticMXBean"); diagnosticMBean = method.invoke(null); heapDumpMethod = diagnosticMBean.getClass().getMethod("dumpHeap", String.class, boolean.class); - } - catch (Exception _ex) { + } catch (Exception _ex) { heapDumpMethod = null; diagnosticMBean = null; } @@ -58,11 +58,13 @@ public class HeapDumpContributor implements DumpContributor { this.diagnosticMBean = diagnosticMBean; } - @Override public String getName() { + @Override + public String getName() { return name; } - @Override public void contribute(Dump dump) throws DumpContributionFailedException { + @Override + public void contribute(Dump dump) throws DumpContributionFailedException { if (heapDumpMethod == null) { throw new DumpContributionFailedException(getName(), "Heap dump not enalbed on this JVM"); } diff --git a/src/main/java/org/elasticsearch/monitor/dump/summary/SummaryDumpContributor.java b/src/main/java/org/elasticsearch/monitor/dump/summary/SummaryDumpContributor.java index f953c5ad0ed..552bfe84339 100644 --- a/src/main/java/org/elasticsearch/monitor/dump/summary/SummaryDumpContributor.java +++ b/src/main/java/org/elasticsearch/monitor/dump/summary/SummaryDumpContributor.java @@ -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,7 +33,7 @@ import java.util.Collection; import java.util.Date; /** - * @author kimchy (Shay Banon) + * */ public class SummaryDumpContributor implements DumpContributor { @@ -44,7 +44,8 @@ public class SummaryDumpContributor implements DumpContributor { private final String name; - @Inject public SummaryDumpContributor(@Assisted String name, @Assisted Settings settings) { + @Inject + public SummaryDumpContributor(@Assisted String name, @Assisted Settings settings) { this.name = name; } diff --git a/src/main/java/org/elasticsearch/monitor/dump/thread/ThreadDumpContributor.java b/src/main/java/org/elasticsearch/monitor/dump/thread/ThreadDumpContributor.java index a9131326f98..de2ae2e9acc 100644 --- a/src/main/java/org/elasticsearch/monitor/dump/thread/ThreadDumpContributor.java +++ b/src/main/java/org/elasticsearch/monitor/dump/thread/ThreadDumpContributor.java @@ -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,7 +33,7 @@ import java.lang.management.ThreadInfo; import java.lang.management.ThreadMXBean; /** - * @author kimchy (Shay Banon) + * */ public class ThreadDumpContributor implements DumpContributor { @@ -43,15 +43,18 @@ public class ThreadDumpContributor implements DumpContributor { private final String name; - @Inject public ThreadDumpContributor(@Assisted String name, @Assisted Settings settings) { + @Inject + public ThreadDumpContributor(@Assisted String name, @Assisted Settings settings) { this.name = name; } - @Override public String getName() { + @Override + public String getName() { return name; } - @Override public void contribute(Dump dump) throws DumpContributionFailedException { + @Override + public void contribute(Dump dump) throws DumpContributionFailedException { PrintWriter writer = new PrintWriter(dump.createFileWriter("threads.txt")); try { processDeadlocks(writer); diff --git a/src/main/java/org/elasticsearch/monitor/jvm/DeadlockAnalyzer.java b/src/main/java/org/elasticsearch/monitor/jvm/DeadlockAnalyzer.java index edc33925018..9659a97bc2f 100644 --- a/src/main/java/org/elasticsearch/monitor/jvm/DeadlockAnalyzer.java +++ b/src/main/java/org/elasticsearch/monitor/jvm/DeadlockAnalyzer.java @@ -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.monitor.jvm; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import java.lang.management.ManagementFactory; import java.lang.management.ThreadInfo; @@ -28,7 +28,7 @@ import java.lang.management.ThreadMXBean; import java.util.*; /** - * @author kimchy (Shay Banon) + * */ public class DeadlockAnalyzer { @@ -146,7 +146,8 @@ public class DeadlockAnalyzer { return members; } - @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; @@ -157,14 +158,16 @@ public class DeadlockAnalyzer { return true; } - @Override public int hashCode() { + @Override + public int hashCode() { int result = members != null ? Arrays.hashCode(members) : 0; result = 31 * result + (description != null ? description.hashCode() : 0); result = 31 * result + (memberIds != null ? memberIds.hashCode() : 0); return result; } - @Override public String toString() { + @Override + public String toString() { return description; } } diff --git a/src/main/java/org/elasticsearch/monitor/jvm/JvmInfo.java b/src/main/java/org/elasticsearch/monitor/jvm/JvmInfo.java index 7c432c5c7b0..e721a26cefd 100644 --- a/src/main/java/org/elasticsearch/monitor/jvm/JvmInfo.java +++ b/src/main/java/org/elasticsearch/monitor/jvm/JvmInfo.java @@ -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 java.util.HashMap; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class JvmInfo implements Streamable, Serializable, ToXContent { @@ -194,7 +194,8 @@ public class JvmInfo implements Streamable, Serializable, ToXContent { return systemProperties; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject("jvm"); builder.field("pid", pid); builder.field("version", version); @@ -224,7 +225,8 @@ public class JvmInfo implements Streamable, Serializable, ToXContent { return jvmInfo; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { pid = in.readLong(); version = in.readUTF(); vmName = in.readUTF(); @@ -246,7 +248,8 @@ public class JvmInfo implements Streamable, Serializable, ToXContent { mem.readFrom(in); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeLong(pid); out.writeUTF(version); out.writeUTF(vmName); @@ -315,14 +318,16 @@ public class JvmInfo implements Streamable, Serializable, ToXContent { return mem; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { heapInit = in.readVLong(); heapMax = in.readVLong(); nonHeapInit = in.readVLong(); nonHeapMax = in.readVLong(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeVLong(heapInit); out.writeVLong(heapMax); out.writeVLong(nonHeapInit); diff --git a/src/main/java/org/elasticsearch/monitor/jvm/JvmMonitorService.java b/src/main/java/org/elasticsearch/monitor/jvm/JvmMonitorService.java index cb64800cb30..43313936907 100644 --- a/src/main/java/org/elasticsearch/monitor/jvm/JvmMonitorService.java +++ b/src/main/java/org/elasticsearch/monitor/jvm/JvmMonitorService.java @@ -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.monitor.jvm; +import com.google.common.collect.ImmutableSet; import org.elasticsearch.ElasticSearchException; -import org.elasticsearch.common.collect.ImmutableSet; import org.elasticsearch.common.component.AbstractLifecycleComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -33,14 +33,16 @@ import java.util.HashSet; import java.util.Set; import java.util.concurrent.ScheduledFuture; -import static org.elasticsearch.common.unit.TimeValue.*; -import static org.elasticsearch.monitor.dump.summary.SummaryDumpContributor.*; -import static org.elasticsearch.monitor.dump.thread.ThreadDumpContributor.*; -import static org.elasticsearch.monitor.jvm.DeadlockAnalyzer.*; -import static org.elasticsearch.monitor.jvm.JvmStats.*; +import static org.elasticsearch.common.unit.TimeValue.timeValueMillis; +import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; +import static org.elasticsearch.monitor.dump.summary.SummaryDumpContributor.SUMMARY; +import static org.elasticsearch.monitor.dump.thread.ThreadDumpContributor.THREAD_DUMP; +import static org.elasticsearch.monitor.jvm.DeadlockAnalyzer.deadlockAnalyzer; +import static org.elasticsearch.monitor.jvm.JvmStats.GarbageCollector; +import static org.elasticsearch.monitor.jvm.JvmStats.jvmStats; /** - * @author kimchy (shay.banon) + * */ public class JvmMonitorService extends AbstractLifecycleComponent { @@ -56,7 +58,8 @@ public class JvmMonitorService extends AbstractLifecycleComponent *

    Supported Platforms: All. */ public short percent() { @@ -235,7 +242,7 @@ public class ProcessStats implements Streamable, Serializable, ToXContent { /** * Get the Process cpu usage. - * + *

    *

    Supported Platforms: All. */ public short getPercent() { @@ -244,7 +251,7 @@ public class ProcessStats implements Streamable, Serializable, ToXContent { /** * Get the Process cpu kernel time. - * + *

    *

    Supported Platforms: All. */ public TimeValue sys() { @@ -253,7 +260,7 @@ public class ProcessStats implements Streamable, Serializable, ToXContent { /** * Get the Process cpu kernel time. - * + *

    *

    Supported Platforms: All. */ public TimeValue getSys() { @@ -262,7 +269,7 @@ public class ProcessStats implements Streamable, Serializable, ToXContent { /** * Get the Process cpu user time. - * + *

    *

    Supported Platforms: All. */ public TimeValue user() { @@ -271,7 +278,7 @@ public class ProcessStats implements Streamable, Serializable, ToXContent { /** * Get the Process cpu time (sum of User and Sys). - * + *

    * Supported Platforms: All. */ public TimeValue total() { @@ -280,7 +287,7 @@ public class ProcessStats implements Streamable, Serializable, ToXContent { /** * Get the Process cpu time (sum of User and Sys). - * + *

    * Supported Platforms: All. */ public TimeValue getTotal() { @@ -289,7 +296,7 @@ public class ProcessStats implements Streamable, Serializable, ToXContent { /** * Get the Process cpu user time. - * + *

    *

    Supported Platforms: All. */ public TimeValue getUser() { diff --git a/src/main/java/org/elasticsearch/monitor/process/SigarProcessProbe.java b/src/main/java/org/elasticsearch/monitor/process/SigarProcessProbe.java index 440654db126..83a1f7dc0a4 100644 --- a/src/main/java/org/elasticsearch/monitor/process/SigarProcessProbe.java +++ b/src/main/java/org/elasticsearch/monitor/process/SigarProcessProbe.java @@ -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,22 +29,25 @@ import org.hyperic.sigar.Sigar; import org.hyperic.sigar.SigarException; /** - * @author kimchy (shay.banon) + * */ public class SigarProcessProbe extends AbstractComponent implements ProcessProbe { private final SigarService sigarService; - @Inject public SigarProcessProbe(Settings settings, SigarService sigarService) { + @Inject + public SigarProcessProbe(Settings settings, SigarService sigarService) { super(settings); this.sigarService = sigarService; } - @Override public synchronized ProcessInfo processInfo() { + @Override + public synchronized ProcessInfo processInfo() { return new ProcessInfo(sigarService.sigar().getPid(), JmxProcessProbe.getMaxFileDescriptorCount()); } - @Override public synchronized ProcessStats processStats() { + @Override + public synchronized ProcessStats processStats() { Sigar sigar = sigarService.sigar(); ProcessStats stats = new ProcessStats(); stats.timestamp = System.currentTimeMillis(); diff --git a/src/main/java/org/elasticsearch/monitor/sigar/SigarService.java b/src/main/java/org/elasticsearch/monitor/sigar/SigarService.java index 59891357dca..f3c2ccee519 100644 --- a/src/main/java/org/elasticsearch/monitor/sigar/SigarService.java +++ b/src/main/java/org/elasticsearch/monitor/sigar/SigarService.java @@ -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,13 +25,14 @@ import org.elasticsearch.common.settings.Settings; import org.hyperic.sigar.Sigar; /** - * @author kimchy (shay.banon) + * */ public class SigarService extends AbstractComponent { private final Sigar sigar; - @Inject public SigarService(Settings settings) { + @Inject + public SigarService(Settings settings) { super(settings); Sigar sigar = null; diff --git a/src/main/java/org/elasticsearch/node/Node.java b/src/main/java/org/elasticsearch/node/Node.java index c2eb023e1a0..8e0f40699d0 100644 --- a/src/main/java/org/elasticsearch/node/Node.java +++ b/src/main/java/org/elasticsearch/node/Node.java @@ -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,11 +25,11 @@ import org.elasticsearch.common.settings.Settings; /** * A node represent a node within a cluster (cluster.name). The {@link #client()} can be used * in order to use a {@link Client} to perform actions/operations against the cluster. - * + *

    *

    In order to create a node, the {@link NodeBuilder} can be used. When done with it, make sure to * call {@link #close()} on it. * - * @author kimchy (shay.banon) + * */ public interface Node { diff --git a/src/main/java/org/elasticsearch/node/NodeBuilder.java b/src/main/java/org/elasticsearch/node/NodeBuilder.java index 6942edadd9e..96df3db005f 100644 --- a/src/main/java/org/elasticsearch/node/NodeBuilder.java +++ b/src/main/java/org/elasticsearch/node/NodeBuilder.java @@ -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,35 +25,35 @@ import org.elasticsearch.node.internal.InternalNode; /** * A node builder is used to construct a {@link Node} instance. - * + *

    *

    Settings will be loaded relative to the ES home (with or without config/ prefix) and if not found, * within the classpath (with or without config/ prefix). The settings file loaded can either be named * elasticsearch.yml or elasticsearch.json). Loading settings can be disabled by calling * {@link #loadConfigSettings(boolean)} with false. - * + *

    *

    Explicit settings can be passed by using the {@link #settings(Settings)} method. - * + *

    *

    In any case, settings will be resolved from system properties as well that are either prefixed with es. * or elasticsearch.. - * + *

    *

    An example for creating a simple node with optional settings loaded from the classpath: - * + *

    *

      * Node node = NodeBuilder.nodeBuilder().node();
      * 
    - * + *

    *

    An example for creating a node with explicit settings (in this case, a node in the cluster that does not hold * data): - * + *

    *

      * Node node = NodeBuilder.nodeBuilder()
      *                      .settings(ImmutableSettings.settingsBuilder().put("node.data", false)
      *                      .node();
      * 
    - * + *

    *

    When done with the node, make sure you call {@link Node#close()} on it. * - * @author kimchy (shay.banon) + * */ public class NodeBuilder { diff --git a/src/main/java/org/elasticsearch/node/NodeClosedException.java b/src/main/java/org/elasticsearch/node/NodeClosedException.java index 69cfff4060c..28fa3a9f711 100644 --- a/src/main/java/org/elasticsearch/node/NodeClosedException.java +++ b/src/main/java/org/elasticsearch/node/NodeClosedException.java @@ -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.cluster.node.DiscoveryNode; /** * An exception indicating that node is closed. * - * @author kimchy (shay.banon) + * */ public class NodeClosedException extends ElasticSearchException { diff --git a/src/main/java/org/elasticsearch/node/internal/InternalNode.java b/src/main/java/org/elasticsearch/node/internal/InternalNode.java index c787558f0df..47405382e54 100644 --- a/src/main/java/org/elasticsearch/node/internal/InternalNode.java +++ b/src/main/java/org/elasticsearch/node/internal/InternalNode.java @@ -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 @@ -43,6 +43,7 @@ import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.network.NetworkService; +import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.SettingsModule; import org.elasticsearch.common.thread.ThreadLocals; @@ -85,10 +86,8 @@ import org.elasticsearch.transport.TransportService; import java.util.concurrent.TimeUnit; -import static org.elasticsearch.common.settings.ImmutableSettings.*; - /** - * @author kimchy (shay.banon) + * */ public final class InternalNode implements Node { @@ -105,7 +104,7 @@ public final class InternalNode implements Node { private final Client client; public InternalNode() throws ElasticSearchException { - this(Builder.EMPTY_SETTINGS, true); + this(ImmutableSettings.Builder.EMPTY_SETTINGS, true); } public InternalNode(Settings pSettings, boolean loadConfigSettings) throws ElasticSearchException { @@ -152,11 +151,13 @@ public final class InternalNode implements Node { logger.info("{{}}[{}]: initialized", Version.CURRENT, JvmInfo.jvmInfo().pid()); } - @Override public Settings settings() { + @Override + public Settings settings() { return this.settings; } - @Override public Client client() { + @Override + public Client client() { return client; } @@ -198,7 +199,8 @@ public final class InternalNode implements Node { return this; } - @Override public Node stop() { + @Override + public Node stop() { if (!lifecycle.moveToStopped()) { return this; } @@ -328,7 +330,8 @@ public final class InternalNode implements Node { logger.info("{{}}[{}]: closed", Version.CURRENT, JvmInfo.jvmInfo().pid()); } - @Override public boolean isClosed() { + @Override + public boolean isClosed() { return lifecycle.closed(); } @@ -340,7 +343,8 @@ public final class InternalNode implements Node { final InternalNode node = new InternalNode(); node.start(); Runtime.getRuntime().addShutdownHook(new Thread() { - @Override public void run() { + @Override + public void run() { node.close(); } }); diff --git a/src/main/java/org/elasticsearch/node/internal/InternalSettingsPerparer.java b/src/main/java/org/elasticsearch/node/internal/InternalSettingsPerparer.java index 125a15f275b..ce7605bb05a 100644 --- a/src/main/java/org/elasticsearch/node/internal/InternalSettingsPerparer.java +++ b/src/main/java/org/elasticsearch/node/internal/InternalSettingsPerparer.java @@ -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,11 +27,11 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.env.FailedToResolveConfigException; -import static org.elasticsearch.common.Strings.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; +import static org.elasticsearch.common.Strings.cleanPath; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; /** - * @author kimchy (shay.banon) + * */ public class InternalSettingsPerparer { diff --git a/src/main/java/org/elasticsearch/node/internal/NodeModule.java b/src/main/java/org/elasticsearch/node/internal/NodeModule.java index 49f6511848b..b813ae9140d 100644 --- a/src/main/java/org/elasticsearch/node/internal/NodeModule.java +++ b/src/main/java/org/elasticsearch/node/internal/NodeModule.java @@ -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.node.service.NodeService; import org.elasticsearch.node.settings.NodeSettingsService; /** - * @author kimchy (shay.banon) + * */ public class NodeModule extends AbstractModule { @@ -35,7 +35,8 @@ public class NodeModule extends AbstractModule { this.node = node; } - @Override protected void configure() { + @Override + protected void configure() { bind(Node.class).toInstance(node); bind(NodeSettingsService.class).asEagerSingleton(); bind(NodeService.class).asEagerSingleton(); diff --git a/src/main/java/org/elasticsearch/node/package-info.java b/src/main/java/org/elasticsearch/node/package-info.java index 7f5b2b1cda5..2c61e062334 100644 --- a/src/main/java/org/elasticsearch/node/package-info.java +++ b/src/main/java/org/elasticsearch/node/package-info.java @@ -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 diff --git a/src/main/java/org/elasticsearch/node/service/NodeService.java b/src/main/java/org/elasticsearch/node/service/NodeService.java index 8a2178fef43..28537bfed74 100644 --- a/src/main/java/org/elasticsearch/node/service/NodeService.java +++ b/src/main/java/org/elasticsearch/node/service/NodeService.java @@ -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,11 +19,11 @@ package org.elasticsearch.node.service; +import com.google.common.collect.ImmutableMap; import org.elasticsearch.action.admin.cluster.node.info.NodeInfo; import org.elasticsearch.action.admin.cluster.node.stats.NodeStats; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.collect.MapBuilder; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; @@ -45,11 +45,13 @@ public class NodeService extends AbstractComponent { private final IndicesService indicesService; - @Nullable private HttpServer httpServer; + @Nullable + private HttpServer httpServer; private volatile ImmutableMap nodeAttributes = ImmutableMap.of(); - @Inject public NodeService(Settings settings, MonitorService monitorService, ClusterService clusterService, TransportService transportService, IndicesService indicesService) { + @Inject + public NodeService(Settings settings, MonitorService monitorService, ClusterService clusterService, TransportService transportService, IndicesService indicesService) { super(settings); this.monitorService = monitorService; this.clusterService = clusterService; diff --git a/src/main/java/org/elasticsearch/node/settings/NodeSettingsService.java b/src/main/java/org/elasticsearch/node/settings/NodeSettingsService.java index f09e604c1df..994c15424e2 100644 --- a/src/main/java/org/elasticsearch/node/settings/NodeSettingsService.java +++ b/src/main/java/org/elasticsearch/node/settings/NodeSettingsService.java @@ -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 @@ -40,7 +40,8 @@ public class NodeSettingsService extends AbstractComponent implements ClusterSta private final CopyOnWriteArrayList listeners = new CopyOnWriteArrayList(); - @Inject public NodeSettingsService(Settings settings) { + @Inject + public NodeSettingsService(Settings settings) { super(settings); } @@ -49,7 +50,8 @@ public class NodeSettingsService extends AbstractComponent implements ClusterSta clusterService.add(this); } - @Override public void clusterChanged(ClusterChangedEvent event) { + @Override + public void clusterChanged(ClusterChangedEvent event) { // nothing to do until we actually recover from the gateway or any other block indicates we need to disable persistency if (event.state().blocks().disableStatePersistence()) { return; diff --git a/src/main/java/org/elasticsearch/plugins/AbstractPlugin.java b/src/main/java/org/elasticsearch/plugins/AbstractPlugin.java index 17a98762519..426d1e4e92f 100644 --- a/src/main/java/org/elasticsearch/plugins/AbstractPlugin.java +++ b/src/main/java/org/elasticsearch/plugins/AbstractPlugin.java @@ -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,7 +19,7 @@ package org.elasticsearch.plugins; -import org.elasticsearch.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList; import org.elasticsearch.common.component.LifecycleComponent; import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.settings.ImmutableSettings; @@ -31,57 +31,65 @@ import java.util.Collection; /** * A base class for a plugin. * - * @author kimchy (shay.banon) + * */ public abstract class AbstractPlugin implements Plugin { /** * Defaults to return an empty list. */ - @Override public Collection> modules() { + @Override + public Collection> modules() { return ImmutableList.of(); } /** * Defaults to return an empty list. */ - @Override public Collection> services() { + @Override + public Collection> services() { return ImmutableList.of(); } /** * Defaults to return an empty list. */ - @Override public Collection> indexModules() { + @Override + public Collection> indexModules() { return ImmutableList.of(); } /** * Defaults to return an empty list. */ - @Override public Collection> indexServices() { + @Override + public Collection> indexServices() { return ImmutableList.of(); } /** * Defaults to return an empty list. */ - @Override public Collection> shardModules() { + @Override + public Collection> shardModules() { return ImmutableList.of(); } /** * Defaults to return an empty list. */ - @Override public Collection> shardServices() { + @Override + public Collection> shardServices() { return ImmutableList.of(); } - @Override public void processModule(Module module) { + @Override + public void processModule(Module module) { // nothing to do here } - @Override public Settings additionalSettings() { + @Override + public Settings additionalSettings() { return ImmutableSettings.Builder.EMPTY_SETTINGS; } diff --git a/src/main/java/org/elasticsearch/plugins/IndexPluginsModule.java b/src/main/java/org/elasticsearch/plugins/IndexPluginsModule.java index f5c8ab17990..eefb534f14b 100644 --- a/src/main/java/org/elasticsearch/plugins/IndexPluginsModule.java +++ b/src/main/java/org/elasticsearch/plugins/IndexPluginsModule.java @@ -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,7 +19,7 @@ package org.elasticsearch.plugins; -import org.elasticsearch.common.collect.Lists; +import com.google.common.collect.Lists; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.inject.PreProcessModule; @@ -29,10 +29,10 @@ import org.elasticsearch.common.settings.Settings; import java.util.Collection; import java.util.List; -import static org.elasticsearch.common.inject.Modules.*; +import static org.elasticsearch.common.inject.Modules.createModule; /** - * @author kimchy (shay.banon) + * */ public class IndexPluginsModule extends AbstractModule implements SpawnModules, PreProcessModule { @@ -45,7 +45,8 @@ public class IndexPluginsModule extends AbstractModule implements SpawnModules, this.pluginsService = pluginsService; } - @Override public Iterable spawnModules() { + @Override + public Iterable spawnModules() { List modules = Lists.newArrayList(); Collection> modulesClasses = pluginsService.indexModules(); for (Class moduleClass : modulesClasses) { @@ -54,10 +55,12 @@ public class IndexPluginsModule extends AbstractModule implements SpawnModules, return modules; } - @Override public void processModule(Module module) { + @Override + public void processModule(Module module) { pluginsService.processModule(module); } - @Override protected void configure() { + @Override + protected void configure() { } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/plugins/Plugin.java b/src/main/java/org/elasticsearch/plugins/Plugin.java index 3572b7ed748..33852effb11 100644 --- a/src/main/java/org/elasticsearch/plugins/Plugin.java +++ b/src/main/java/org/elasticsearch/plugins/Plugin.java @@ -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.Collection; /** * An extension point allowing to plug in custom functionality. * - * @author kimchy (shay.banon) + * */ public interface Plugin { diff --git a/src/main/java/org/elasticsearch/plugins/PluginManager.java b/src/main/java/org/elasticsearch/plugins/PluginManager.java index 472b5c3f79d..89cf71e049b 100644 --- a/src/main/java/org/elasticsearch/plugins/PluginManager.java +++ b/src/main/java/org/elasticsearch/plugins/PluginManager.java @@ -21,10 +21,10 @@ import java.util.Enumeration; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; -import static org.elasticsearch.common.settings.ImmutableSettings.Builder.*; +import static org.elasticsearch.common.settings.ImmutableSettings.Builder.EMPTY_SETTINGS; /** - * @author kimchy (shay.banon) + * */ public class PluginManager { diff --git a/src/main/java/org/elasticsearch/plugins/PluginsModule.java b/src/main/java/org/elasticsearch/plugins/PluginsModule.java index a92bb35b7a1..c43aa4c66cd 100644 --- a/src/main/java/org/elasticsearch/plugins/PluginsModule.java +++ b/src/main/java/org/elasticsearch/plugins/PluginsModule.java @@ -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,7 +19,7 @@ package org.elasticsearch.plugins; -import org.elasticsearch.common.collect.Lists; +import com.google.common.collect.Lists; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.inject.PreProcessModule; @@ -29,10 +29,10 @@ import org.elasticsearch.common.settings.Settings; import java.util.Collection; import java.util.List; -import static org.elasticsearch.common.inject.Modules.*; +import static org.elasticsearch.common.inject.Modules.createModule; /** - * @author kimchy (shay.banon) + * */ public class PluginsModule extends AbstractModule implements SpawnModules, PreProcessModule { @@ -45,7 +45,8 @@ public class PluginsModule extends AbstractModule implements SpawnModules, PrePr this.pluginsService = pluginsService; } - @Override public Iterable spawnModules() { + @Override + public Iterable spawnModules() { List modules = Lists.newArrayList(); Collection> modulesClasses = pluginsService.modules(); for (Class moduleClass : modulesClasses) { @@ -54,11 +55,13 @@ public class PluginsModule extends AbstractModule implements SpawnModules, PrePr return modules; } - @Override public void processModule(Module module) { + @Override + public void processModule(Module module) { pluginsService.processModule(module); } - @Override protected void configure() { + @Override + protected void configure() { bind(PluginsService.class).toInstance(pluginsService); } } diff --git a/src/main/java/org/elasticsearch/plugins/PluginsService.java b/src/main/java/org/elasticsearch/plugins/PluginsService.java index cc1e959b2c6..b82d89112cb 100644 --- a/src/main/java/org/elasticsearch/plugins/PluginsService.java +++ b/src/main/java/org/elasticsearch/plugins/PluginsService.java @@ -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,11 +19,11 @@ package org.elasticsearch.plugins; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; import org.elasticsearch.ElasticSearchException; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.collect.Maps; -import org.elasticsearch.common.collect.Sets; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.component.LifecycleComponent; import org.elasticsearch.common.inject.Inject; @@ -38,17 +38,12 @@ import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Method; import java.net.URL; -import java.util.Collection; -import java.util.Enumeration; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; +import java.util.*; -import static org.elasticsearch.common.collect.Maps.*; +import static com.google.common.collect.Maps.newHashMap; /** - * @author kimchy (shay.banon) + * */ public class PluginsService extends AbstractComponent { @@ -56,7 +51,8 @@ public class PluginsService extends AbstractComponent { private final ImmutableMap plugins; - @Inject public PluginsService(Settings settings, Environment environment) { + @Inject + public PluginsService(Settings settings, Environment environment) { super(settings); this.environment = environment; diff --git a/src/main/java/org/elasticsearch/plugins/ShardsPluginsModule.java b/src/main/java/org/elasticsearch/plugins/ShardsPluginsModule.java index da6617bc2c7..0c56b0c262d 100644 --- a/src/main/java/org/elasticsearch/plugins/ShardsPluginsModule.java +++ b/src/main/java/org/elasticsearch/plugins/ShardsPluginsModule.java @@ -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,7 +19,7 @@ package org.elasticsearch.plugins; -import org.elasticsearch.common.collect.Lists; +import com.google.common.collect.Lists; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.inject.PreProcessModule; @@ -29,10 +29,10 @@ import org.elasticsearch.common.settings.Settings; import java.util.Collection; import java.util.List; -import static org.elasticsearch.common.inject.Modules.*; +import static org.elasticsearch.common.inject.Modules.createModule; /** - * @author kimchy (shay.banon) + * */ public class ShardsPluginsModule extends AbstractModule implements SpawnModules, PreProcessModule { @@ -45,7 +45,8 @@ public class ShardsPluginsModule extends AbstractModule implements SpawnModules, this.pluginsService = pluginsService; } - @Override public Iterable spawnModules() { + @Override + public Iterable spawnModules() { List modules = Lists.newArrayList(); Collection> modulesClasses = pluginsService.shardModules(); for (Class moduleClass : modulesClasses) { @@ -54,10 +55,12 @@ public class ShardsPluginsModule extends AbstractModule implements SpawnModules, return modules; } - @Override public void processModule(Module module) { + @Override + public void processModule(Module module) { pluginsService.processModule(module); } - @Override protected void configure() { + @Override + protected void configure() { } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/rest/AbstractRestResponse.java b/src/main/java/org/elasticsearch/rest/AbstractRestResponse.java index ebf8b2cf12e..a2b2de29fe4 100644 --- a/src/main/java/org/elasticsearch/rest/AbstractRestResponse.java +++ b/src/main/java/org/elasticsearch/rest/AbstractRestResponse.java @@ -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,23 +20,27 @@ package org.elasticsearch.rest; /** - * @author kimchy (Shay Banon) + * */ public abstract class AbstractRestResponse implements RestResponse { - @Override public byte[] prefixContent() { + @Override + public byte[] prefixContent() { return null; } - @Override public int prefixContentLength() { + @Override + public int prefixContentLength() { return -1; } - @Override public byte[] suffixContent() { + @Override + public byte[] suffixContent() { return null; } - @Override public int suffixContentLength() { + @Override + public int suffixContentLength() { return -1; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/rest/BaseRestHandler.java b/src/main/java/org/elasticsearch/rest/BaseRestHandler.java index a689208dbb4..6d100a4b0e5 100644 --- a/src/main/java/org/elasticsearch/rest/BaseRestHandler.java +++ b/src/main/java/org/elasticsearch/rest/BaseRestHandler.java @@ -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.common.component.AbstractComponent; import org.elasticsearch.common.settings.Settings; /** - * @author kimchy (Shay Banon) + * */ public abstract class BaseRestHandler extends AbstractComponent implements RestHandler { diff --git a/src/main/java/org/elasticsearch/rest/BytesRestResponse.java b/src/main/java/org/elasticsearch/rest/BytesRestResponse.java index 72714e2ad2b..a1dcd0e84a2 100644 --- a/src/main/java/org/elasticsearch/rest/BytesRestResponse.java +++ b/src/main/java/org/elasticsearch/rest/BytesRestResponse.java @@ -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,23 +32,28 @@ public class BytesRestResponse extends AbstractRestResponse { this.contentType = contentType; } - @Override public boolean contentThreadSafe() { + @Override + public boolean contentThreadSafe() { return true; } - @Override public String contentType() { + @Override + public String contentType() { return contentType; } - @Override public byte[] content() throws IOException { + @Override + public byte[] content() throws IOException { return bytes; } - @Override public int contentLength() throws IOException { + @Override + public int contentLength() throws IOException { return bytes.length; } - @Override public RestStatus status() { + @Override + public RestStatus status() { return RestStatus.OK; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/rest/RestChannel.java b/src/main/java/org/elasticsearch/rest/RestChannel.java index 2bba2fc0f00..5bfe750819c 100644 --- a/src/main/java/org/elasticsearch/rest/RestChannel.java +++ b/src/main/java/org/elasticsearch/rest/RestChannel.java @@ -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.rest; /** - * @author kimchy (Shay Banon) + * */ public interface RestChannel { diff --git a/src/main/java/org/elasticsearch/rest/RestController.java b/src/main/java/org/elasticsearch/rest/RestController.java index fab070c9db3..6906afe8638 100644 --- a/src/main/java/org/elasticsearch/rest/RestController.java +++ b/src/main/java/org/elasticsearch/rest/RestController.java @@ -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 org.elasticsearch.rest.support.RestUtils; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class RestController extends AbstractLifecycleComponent { @@ -41,17 +41,21 @@ public class RestController extends AbstractLifecycleComponent { private final PathTrie headHandlers = new PathTrie(RestUtils.REST_DECODER); private final PathTrie optionsHandlers = new PathTrie(RestUtils.REST_DECODER); - @Inject public RestController(Settings settings) { + @Inject + public RestController(Settings settings) { super(settings); } - @Override protected void doStart() throws ElasticSearchException { + @Override + protected void doStart() throws ElasticSearchException { } - @Override protected void doStop() throws ElasticSearchException { + @Override + protected void doStop() throws ElasticSearchException { } - @Override protected void doClose() throws ElasticSearchException { + @Override + protected void doClose() throws ElasticSearchException { } public void registerHandler(RestRequest.Method method, String path, RestHandler handler) { diff --git a/src/main/java/org/elasticsearch/rest/RestHandler.java b/src/main/java/org/elasticsearch/rest/RestHandler.java index 6b2d437f367..98cee8cb082 100644 --- a/src/main/java/org/elasticsearch/rest/RestHandler.java +++ b/src/main/java/org/elasticsearch/rest/RestHandler.java @@ -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.rest; /** - * @author kimchy (Shay Banon) + * */ public interface RestHandler { diff --git a/src/main/java/org/elasticsearch/rest/RestModule.java b/src/main/java/org/elasticsearch/rest/RestModule.java index 1e586dfc7ec..1141dc3699e 100644 --- a/src/main/java/org/elasticsearch/rest/RestModule.java +++ b/src/main/java/org/elasticsearch/rest/RestModule.java @@ -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,7 +19,7 @@ package org.elasticsearch.rest; -import org.elasticsearch.common.collect.Lists; +import com.google.common.collect.Lists; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.action.RestActionModule; @@ -27,7 +27,7 @@ import org.elasticsearch.rest.action.RestActionModule; import java.util.List; /** - * @author kimchy (Shay Banon) + * */ public class RestModule extends AbstractModule { @@ -43,7 +43,8 @@ public class RestModule extends AbstractModule { } - @Override protected void configure() { + @Override + protected void configure() { bind(RestController.class).asEagerSingleton(); new RestActionModule(restPluginsActions).configure(binder()); } diff --git a/src/main/java/org/elasticsearch/rest/RestRequest.java b/src/main/java/org/elasticsearch/rest/RestRequest.java index a3812ae81ff..dcf60775c3b 100644 --- a/src/main/java/org/elasticsearch/rest/RestRequest.java +++ b/src/main/java/org/elasticsearch/rest/RestRequest.java @@ -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.xcontent.ToXContent; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public interface RestRequest extends ToXContent.Params { diff --git a/src/main/java/org/elasticsearch/rest/RestResponse.java b/src/main/java/org/elasticsearch/rest/RestResponse.java index ceafb681f8c..a92011e44dc 100644 --- a/src/main/java/org/elasticsearch/rest/RestResponse.java +++ b/src/main/java/org/elasticsearch/rest/RestResponse.java @@ -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.rest; import java.io.IOException; /** - * @author kimchy (Shay Banon) + * */ public interface RestResponse { diff --git a/src/main/java/org/elasticsearch/rest/RestStatus.java b/src/main/java/org/elasticsearch/rest/RestStatus.java index 8a4ad5890f1..63093cbe1ba 100644 --- a/src/main/java/org/elasticsearch/rest/RestStatus.java +++ b/src/main/java/org/elasticsearch/rest/RestStatus.java @@ -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 @@ -58,7 +58,7 @@ public enum RestStatus { * entity format is specified by the media type given in the Content-Type header field. The origin server MUST * create the resource before returning the 201 status code. If the action cannot be carried out immediately, the * server SHOULD respond with 202 (Accepted) response instead. - * + *

    *

    A 201 response MAY contain an ETag response header field indicating the current value of the entity tag * for the requested variant just created, see section 14.19. */ @@ -67,7 +67,7 @@ public enum RestStatus { * The request has been accepted for processing, but the processing has not been completed. The request might * or might not eventually be acted upon, as it might be disallowed when processing actually takes place. There * is no facility for re-sending a status code from an asynchronous operation such as this. - * + *

    *

    The 202 response is intentionally non-committal. Its purpose is to allow a server to accept a request for * some other process (perhaps a batch-oriented process that is only run once per day) without requiring that * the user agent's connection to the server persist until the process is completed. The entity returned with @@ -87,12 +87,12 @@ public enum RestStatus { * The server has fulfilled the request but does not need to return an entity-body, and might want to return * updated meta information. The response MAY include new or updated meta information in the form of * entity-headers, which if present SHOULD be associated with the requested variant. - * + *

    *

    If the client is a user agent, it SHOULD NOT change its document view from that which caused the request * to be sent. This response is primarily intended to allow input for actions to take place without causing a * change to the user agent's active document view, although any new or updated meta information SHOULD be * applied to the document currently in the user agent's active view. - * + *

    *

    The 204 response MUST NOT include a message-body, and thus is always terminated by the first empty * line after the header fields. */ @@ -108,7 +108,7 @@ public enum RestStatus { * The server has fulfilled the partial GET request for the resource. The request MUST have included a Range * header field (section 14.35) indicating the desired range, and MAY have included an If-Range header * field (section 14.27) to make the request conditional. - * + *

    *

    The response MUST include the following header fields: *

      *
    • Either a Content-Range header field (section 14.16) indicating the range included with this response, @@ -120,33 +120,33 @@ public enum RestStatus { *
    • Expires, Cache-Control, and/or Vary, if the field-value might differ from that sent in any previous * response for the same variant
    • *
    - * + *

    *

    If the 206 response is the result of an If-Range request that used a strong cache validator * (see section 13.3.3), the response SHOULD NOT include other entity-headers. If the response is the result * of an If-Range request that used a weak validator, the response MUST NOT include other entity-headers; * this prevents inconsistencies between cached entity-bodies and updated headers. Otherwise, the response MUST * include all of the entity-headers that would have been returned with a 200 (OK) response to the same request. - * + *

    *

    A cache MUST NOT combine a 206 response with other previously cached content if the ETag or Last-Modified * headers do not match exactly, see 13.5.4. - * + *

    *

    A cache that does not support the Range and Content-Range headers MUST NOT cache 206 (Partial) responses. */ PARTIAL_CONTENT(206), /** * The 207 (Multi-Status) status code provides status for multiple independent operations (see Section 13 for * more information). - * + *

    *

    A Multi-Status response conveys information about multiple resources in situations where multiple status * codes might be appropriate. The default Multi-Status response body is a text/xml or application/xml HTTP * entity with a 'multistatus' root element. Further elements contain 200, 300, 400, and 500 series status codes * generated during the method invocation. 100 series status codes SHOULD NOT be recorded in a 'response' * XML element. - * + *

    *

    Although '207' is used as the overall response status code, the recipient needs to consult the contents * of the multistatus response body for further information about the success or failure of the method execution. * The response MAY be used in success, partial success and also in failure situations. - * + *

    *

    The 'multistatus' root element holds zero or more 'response' elements in any order, each with * information about an individual resource. Each 'response' element MUST have an 'href' element * to identify the resource. @@ -156,13 +156,13 @@ public enum RestStatus { * The requested resource corresponds to any one of a set of representations, each with its own specific * location, and agent-driven negotiation information (section 12) is being provided so that the user (or user * agent) can select a preferred representation and redirect its request to that location. - * + *

    *

    Unless it was a HEAD request, the response SHOULD include an entity containing a list of resource * characteristics and location(s) from which the user or user agent can choose the one most appropriate. * The entity format is specified by the media type given in the Content-Type header field. Depending upon the * format and the capabilities of the user agent, selection of the most appropriate choice MAY be performed * automatically. However, this specification does not define any standard for such automatic selection. - * + *

    *

    If the server has a preferred choice of representation, it SHOULD include the specific URI for that * representation in the Location field; user agents MAY use the Location field value for automatic redirection. * This response is cacheable unless indicated otherwise. @@ -173,10 +173,10 @@ public enum RestStatus { * SHOULD use one of the returned URIs. Clients with link editing capabilities ought to automatically re-link * references to the Request-URI to one or more of the new references returned by the server, where possible. * This response is cacheable unless indicated otherwise. - * + *

    *

    The new permanent URI SHOULD be given by the Location field in the response. Unless the request method * was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s). - * + *

    *

    If the 301 status code is received in response to a request other than GET or HEAD, the user agent * MUST NOT automatically redirect the request unless it can be confirmed by the user, since this might change * the conditions under which the request was issued. @@ -186,10 +186,10 @@ public enum RestStatus { * The requested resource resides temporarily under a different URI. Since the redirection might be altered on * occasion, the client SHOULD continue to use the Request-URI for future requests. This response is only * cacheable if indicated by a Cache-Control or Expires header field. - * + *

    *

    The temporary URI SHOULD be given by the Location field in the response. Unless the request method was * HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s). - * + *

    *

    If the 302 status code is received in response to a request other than GET or HEAD, the user agent * MUST NOT automatically redirect the request unless it can be confirmed by the user, since this might change * the conditions under which the request was issued. @@ -201,7 +201,7 @@ public enum RestStatus { * user agent to a selected resource. The new URI is not a substitute reference for the originally requested * resource. The 303 response MUST NOT be cached, but the response to the second (redirected) request might be * cacheable. - * + *

    *

    The different URI SHOULD be given by the Location field in the response. Unless the request method was * HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s). */ @@ -210,7 +210,7 @@ public enum RestStatus { * If the client has performed a conditional GET request and access is allowed, but the document has not been * modified, the server SHOULD respond with this status code. The 304 response MUST NOT contain a message-body, * and thus is always terminated by the first empty line after the header fields. - * + *

    *

    The response MUST include the following header fields: *

      *
    • Date, unless its omission is required by section 14.18.1 @@ -222,14 +222,14 @@ public enum RestStatus { *
    • Expires, Cache-Control, and/or Vary, if the field-value might differ from that sent in any previous * response for the same variant
    • *
    - * + *

    *

    If the conditional GET used a strong cache validator (see section 13.3.3), the response SHOULD NOT include * other entity-headers. Otherwise (i.e., the conditional GET used a weak validator), the response MUST NOT * include other entity-headers; this prevents inconsistencies between cached entity-bodies and updated headers. - * + *

    *

    If a 304 response indicates an entity not currently cached, then the cache MUST disregard the response * and repeat the request without the conditional. - * + *

    *

    If a cache uses a received 304 response to update a cache entry, the cache MUST update the entry to * reflect any new field values given in the response. */ @@ -244,12 +244,12 @@ public enum RestStatus { * The requested resource resides temporarily under a different URI. Since the redirection MAY be altered on * occasion, the client SHOULD continue to use the Request-URI for future requests. This response is only * cacheable if indicated by a Cache-Control or Expires header field. - * + *

    *

    The temporary URI SHOULD be given by the Location field in the response. Unless the request method was * HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s) , * since many pre-HTTP/1.1 user agents do not understand the 307 status. Therefore, the note SHOULD contain * the information necessary for a user to repeat the original request on the new URI. - * + *

    *

    If the 307 status code is received in response to a request other than GET or HEAD, the user agent MUST NOT * automatically redirect the request unless it can be confirmed by the user, since this might change the * conditions under which the request was issued. @@ -299,17 +299,17 @@ public enum RestStatus { /** * The resource identified by the request is only capable of generating response entities which have content * characteristics not acceptable according to the accept headers sent in the request. - * + *

    *

    Unless it was a HEAD request, the response SHOULD include an entity containing a list of available entity * characteristics and location(s) from which the user or user agent can choose the one most appropriate. * The entity format is specified by the media type given in the Content-Type header field. Depending upon the * format and the capabilities of the user agent, selection of the most appropriate choice MAY be performed * automatically. However, this specification does not define any standard for such automatic selection. - * + *

    *

    Note: HTTP/1.1 servers are allowed to return responses which are not acceptable according to the accept * headers sent in the request. In some cases, this may even be preferable to sending a 406 response. User * agents are encouraged to inspect the headers of an incoming response to determine if it is acceptable. - * + *

    *

    If the response could be unacceptable, a user agent SHOULD temporarily stop receipt of more data and query * the user for a decision on further actions. */ @@ -333,7 +333,7 @@ public enum RestStatus { * resubmit the request. The response body SHOULD include enough information for the user to recognize the * source of the conflict. Ideally, the response entity would include enough information for the user or user * agent to fix the problem; however, that might not be possible and is not required. - * + *

    *

    Conflicts are most likely to occur in response to a PUT request. For example, if versioning were being * used and the entity being PUT included changes to a resource which conflict with those made by an earlier * (third-party) request, the server might use the 409 response to indicate that it can't complete the request. @@ -347,7 +347,7 @@ public enum RestStatus { * the Request-URI after user approval. If the server does not know, or has no facility to determine, whether or * not the condition is permanent, the status code 404 (Not Found) SHOULD be used instead. This response is * cacheable unless indicated otherwise. - * + *

    *

    The 410 response is primarily intended to assist the task of web maintenance by notifying the recipient * that the resource is intentionally unavailable and that the server owners desire that remote links to that * resource be removed. Such an event is common for limited-time, promotional services and for resources belonging @@ -371,7 +371,7 @@ public enum RestStatus { /** * The server is refusing to process a request because the request entity is larger than the server is willing * or able to process. The server MAY close the connection to prevent the client from continuing the request. - * + *

    *

    If the condition is temporary, the server SHOULD include a Retry-After header field to indicate that it * is temporary and after what time the client MAY try again. */ @@ -396,7 +396,7 @@ public enum RestStatus { * selected resource, and the request did not include an If-Range request-header field. (For byte-ranges, this * means that the first-byte-pos of all of the byte-range-spec values were greater than the current length of * the selected resource.) - * + *

    *

    When this status code is returned for a byte-range request, the response SHOULD include a Content-Range * entity-header field specifying the current length of the selected resource (see section 14.16). This * response MUST NOT use the multipart/byteranges content-type. diff --git a/src/main/java/org/elasticsearch/rest/StringRestResponse.java b/src/main/java/org/elasticsearch/rest/StringRestResponse.java index ec3cc7a5a32..f517bd65a3e 100644 --- a/src/main/java/org/elasticsearch/rest/StringRestResponse.java +++ b/src/main/java/org/elasticsearch/rest/StringRestResponse.java @@ -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,12 +23,13 @@ import org.apache.lucene.util.UnicodeUtil; import org.elasticsearch.common.thread.ThreadLocals; /** - * @author kimchy (shay.banon) + * */ public class StringRestResponse extends Utf8RestResponse { private static ThreadLocal> cache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { return new ThreadLocals.CleanableValue(new UnicodeUtil.UTF8Result()); } }; diff --git a/src/main/java/org/elasticsearch/rest/Utf8RestResponse.java b/src/main/java/org/elasticsearch/rest/Utf8RestResponse.java index 2197969f957..5471cb645a7 100644 --- a/src/main/java/org/elasticsearch/rest/Utf8RestResponse.java +++ b/src/main/java/org/elasticsearch/rest/Utf8RestResponse.java @@ -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,10 +23,10 @@ import org.apache.lucene.util.UnicodeUtil; /** * An http response that is built on top of {@link org.apache.lucene.util.UnicodeUtil.UTF8Result}. - * + *

    *

    Note, this class assumes that the utf8 result is not thread safe. * - * @author kimchy (shay.banon) + * */ public class Utf8RestResponse extends AbstractRestResponse implements RestResponse { @@ -63,39 +63,48 @@ public class Utf8RestResponse extends AbstractRestResponse implements RestRespon this.suffixUtf8Result = suffixUtf8Result; } - @Override public boolean contentThreadSafe() { + @Override + public boolean contentThreadSafe() { return false; } - @Override public String contentType() { + @Override + public String contentType() { return "text/plain; charset=UTF-8"; } - @Override public byte[] content() { + @Override + public byte[] content() { return utf8Result.result; } - @Override public int contentLength() { + @Override + public int contentLength() { return utf8Result.length; } - @Override public RestStatus status() { + @Override + public RestStatus status() { return status; } - @Override public byte[] prefixContent() { + @Override + public byte[] prefixContent() { return prefixUtf8Result != null ? prefixUtf8Result.result : null; } - @Override public int prefixContentLength() { + @Override + public int prefixContentLength() { return prefixUtf8Result != null ? prefixUtf8Result.length : 0; } - @Override public byte[] suffixContent() { + @Override + public byte[] suffixContent() { return suffixUtf8Result != null ? suffixUtf8Result.result : null; } - @Override public int suffixContentLength() { + @Override + public int suffixContentLength() { return suffixUtf8Result != null ? suffixUtf8Result.length : 0; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/rest/XContentRestResponse.java b/src/main/java/org/elasticsearch/rest/XContentRestResponse.java index dd03b1cbbe7..7bbfe19f3f0 100644 --- a/src/main/java/org/elasticsearch/rest/XContentRestResponse.java +++ b/src/main/java/org/elasticsearch/rest/XContentRestResponse.java @@ -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.xcontent.XContentBuilder; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class XContentRestResponse extends AbstractRestResponse { @@ -40,7 +40,8 @@ public class XContentRestResponse extends AbstractRestResponse { } private static ThreadLocal> prefixCache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { return new ThreadLocals.CleanableValue(new UnicodeUtil.UTF8Result()); } }; @@ -61,48 +62,57 @@ public class XContentRestResponse extends AbstractRestResponse { return this.builder; } - @Override public String contentType() { + @Override + public String contentType() { return builder.contentType().restContentType(); } - @Override public boolean contentThreadSafe() { + @Override + public boolean contentThreadSafe() { return false; } - @Override public byte[] content() throws IOException { + @Override + public byte[] content() throws IOException { return builder.underlyingBytes(); } - @Override public int contentLength() throws IOException { + @Override + public int contentLength() throws IOException { return builder.underlyingBytesLength(); } - @Override public RestStatus status() { + @Override + public RestStatus status() { return this.status; } - @Override public byte[] prefixContent() { + @Override + public byte[] prefixContent() { if (prefixUtf8Result != null) { return prefixUtf8Result.result; } return null; } - @Override public int prefixContentLength() { + @Override + public int prefixContentLength() { if (prefixUtf8Result != null) { return prefixUtf8Result.length; } return 0; } - @Override public byte[] suffixContent() { + @Override + public byte[] suffixContent() { if (prefixUtf8Result != null) { return END_JSONP; } return null; } - @Override public int suffixContentLength() { + @Override + public int suffixContentLength() { if (prefixUtf8Result != null) { return END_JSONP.length; } diff --git a/src/main/java/org/elasticsearch/rest/XContentThrowableRestResponse.java b/src/main/java/org/elasticsearch/rest/XContentThrowableRestResponse.java index 79c5d87b2b7..a5fe214347c 100644 --- a/src/main/java/org/elasticsearch/rest/XContentThrowableRestResponse.java +++ b/src/main/java/org/elasticsearch/rest/XContentThrowableRestResponse.java @@ -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,11 +24,11 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; -import static org.elasticsearch.ExceptionsHelper.*; -import static org.elasticsearch.rest.action.support.RestXContentBuilder.*; +import static org.elasticsearch.ExceptionsHelper.detailedMessage; +import static org.elasticsearch.rest.action.support.RestXContentBuilder.restContentBuilder; /** - * @author kimchy (shay.banon) + * */ public class XContentThrowableRestResponse extends XContentRestResponse { diff --git a/src/main/java/org/elasticsearch/rest/action/RestActionModule.java b/src/main/java/org/elasticsearch/rest/action/RestActionModule.java index 085baba9f59..d899a59ad89 100644 --- a/src/main/java/org/elasticsearch/rest/action/RestActionModule.java +++ b/src/main/java/org/elasticsearch/rest/action/RestActionModule.java @@ -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,7 +19,7 @@ package org.elasticsearch.rest.action; -import org.elasticsearch.common.collect.Lists; +import com.google.common.collect.Lists; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.action.admin.cluster.health.RestClusterHealthAction; @@ -74,7 +74,7 @@ import org.elasticsearch.rest.action.search.RestSearchScrollAction; import java.util.List; /** - * @author kimchy (Shay Banon) + * */ public class RestActionModule extends AbstractModule { private List> restPluginsActions = Lists.newArrayList(); @@ -83,7 +83,8 @@ public class RestActionModule extends AbstractModule { this.restPluginsActions = restPluginsActions; } - @Override protected void configure() { + @Override + protected void configure() { for (Class restAction : restPluginsActions) { bind(restAction).asEagerSingleton(); } diff --git a/src/main/java/org/elasticsearch/rest/action/admin/cluster/health/RestClusterHealthAction.java b/src/main/java/org/elasticsearch/rest/action/admin/cluster/health/RestClusterHealthAction.java index 347bfafde6f..bdda24d13c8 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/cluster/health/RestClusterHealthAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/cluster/health/RestClusterHealthAction.java @@ -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,22 +32,24 @@ import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; -import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.rest.RestStatus.*; +import static org.elasticsearch.client.Requests.clusterHealthRequest; +import static org.elasticsearch.rest.RestStatus.PRECONDITION_FAILED; /** - * @author kimchy (shay.banon) + * */ public class RestClusterHealthAction extends BaseRestHandler { - @Inject public RestClusterHealthAction(Settings settings, Client client, RestController controller) { + @Inject + public RestClusterHealthAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(RestRequest.Method.GET, "/_cluster/health", this); controller.registerHandler(RestRequest.Method.GET, "/_cluster/health/{index}", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { ClusterHealthRequest clusterHealthRequest = clusterHealthRequest(RestActions.splitIndices(request.param("index"))); int level = 0; try { @@ -80,7 +82,8 @@ public class RestClusterHealthAction extends BaseRestHandler { } final int fLevel = level; client.admin().cluster().health(clusterHealthRequest, new ActionListener() { - @Override public void onResponse(ClusterHealthResponse response) { + @Override + public void onResponse(ClusterHealthResponse response) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject(); @@ -175,7 +178,8 @@ public class RestClusterHealthAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/info/RestNodesInfoAction.java b/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/info/RestNodesInfoAction.java index 72b8ea7feb7..20f46ba31f6 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/info/RestNodesInfoAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/info/RestNodesInfoAction.java @@ -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,13 +28,7 @@ import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.SettingsFilter; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.RestStatus; -import org.elasticsearch.rest.XContentRestResponse; -import org.elasticsearch.rest.XContentThrowableRestResponse; +import org.elasticsearch.rest.*; import org.elasticsearch.rest.action.support.RestActions; import org.elasticsearch.rest.action.support.RestXContentBuilder; @@ -42,14 +36,15 @@ import java.io.IOException; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class RestNodesInfoAction extends BaseRestHandler { private final SettingsFilter settingsFilter; - @Inject public RestNodesInfoAction(Settings settings, Client client, RestController controller, - SettingsFilter settingsFilter) { + @Inject + public RestNodesInfoAction(Settings settings, Client client, RestController controller, + SettingsFilter settingsFilter) { super(settings, client); controller.registerHandler(RestRequest.Method.GET, "/_cluster/nodes", this); controller.registerHandler(RestRequest.Method.GET, "/_cluster/nodes/{nodeId}", this); @@ -57,13 +52,15 @@ public class RestNodesInfoAction extends BaseRestHandler { this.settingsFilter = settingsFilter; } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { String[] nodesIds = RestActions.splitNodes(request.param("nodeId")); final boolean includeSettings = request.paramAsBoolean("settings", false); NodesInfoRequest nodesInfoRequest = new NodesInfoRequest(nodesIds); nodesInfoRequest.listenerThreaded(false); client.admin().cluster().nodesInfo(nodesInfoRequest, new ActionListener() { - @Override public void onResponse(NodesInfoResponse result) { + @Override + public void onResponse(NodesInfoResponse result) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject(); @@ -125,7 +122,8 @@ public class RestNodesInfoAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/restart/RestNodesRestartAction.java b/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/restart/RestNodesRestartAction.java index 1d23c0514d0..55c2104e4a3 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/restart/RestNodesRestartAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/restart/RestNodesRestartAction.java @@ -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,27 +31,30 @@ import org.elasticsearch.rest.action.support.RestActions; import java.io.IOException; -import static org.elasticsearch.rest.action.support.RestXContentBuilder.*; +import static org.elasticsearch.rest.action.support.RestXContentBuilder.restContentBuilder; /** - * @author kimchy (shay.banon) + * */ public class RestNodesRestartAction extends BaseRestHandler { - @Inject public RestNodesRestartAction(Settings settings, Client client, RestController controller) { + @Inject + public RestNodesRestartAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(RestRequest.Method.POST, "/_cluster/nodes/_restart", this); controller.registerHandler(RestRequest.Method.POST, "/_cluster/nodes/{nodeId}/_restart", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { String[] nodesIds = RestActions.splitNodes(request.param("nodeId")); NodesRestartRequest nodesRestartRequest = new NodesRestartRequest(nodesIds); nodesRestartRequest.listenerThreaded(false); nodesRestartRequest.delay(request.paramAsTime("delay", nodesRestartRequest.delay())); client.admin().cluster().nodesRestart(nodesRestartRequest, new ActionListener() { - @Override public void onResponse(NodesRestartResponse result) { + @Override + public void onResponse(NodesRestartResponse result) { try { XContentBuilder builder = restContentBuilder(request); builder.startObject(); @@ -72,7 +75,8 @@ public class RestNodesRestartAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/shutdown/RestNodesShutdownAction.java b/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/shutdown/RestNodesShutdownAction.java index 55b987910d1..60d2222ece6 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/shutdown/RestNodesShutdownAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/shutdown/RestNodesShutdownAction.java @@ -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,25 +27,20 @@ import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.RestStatus; -import org.elasticsearch.rest.XContentRestResponse; -import org.elasticsearch.rest.XContentThrowableRestResponse; +import org.elasticsearch.rest.*; import org.elasticsearch.rest.action.support.RestActions; import java.io.IOException; -import static org.elasticsearch.rest.action.support.RestXContentBuilder.*; +import static org.elasticsearch.rest.action.support.RestXContentBuilder.restContentBuilder; /** - * @author kimchy (shay.banon) + * */ public class RestNodesShutdownAction extends BaseRestHandler { - @Inject public RestNodesShutdownAction(Settings settings, Client client, RestController controller) { + @Inject + public RestNodesShutdownAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(RestRequest.Method.POST, "/_shutdown", this); @@ -53,14 +48,16 @@ public class RestNodesShutdownAction extends BaseRestHandler { controller.registerHandler(RestRequest.Method.POST, "/_cluster/nodes/{nodeId}/_shutdown", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { String[] nodesIds = RestActions.splitNodes(request.param("nodeId")); NodesShutdownRequest nodesShutdownRequest = new NodesShutdownRequest(nodesIds); nodesShutdownRequest.listenerThreaded(false); nodesShutdownRequest.delay(request.paramAsTime("delay", nodesShutdownRequest.delay())); nodesShutdownRequest.exit(request.paramAsBoolean("exit", nodesShutdownRequest.exit())); client.admin().cluster().nodesShutdown(nodesShutdownRequest, new ActionListener() { - @Override public void onResponse(NodesShutdownResponse response) { + @Override + public void onResponse(NodesShutdownResponse response) { try { XContentBuilder builder = restContentBuilder(request); builder.startObject(); @@ -81,7 +78,8 @@ public class RestNodesShutdownAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/stats/RestNodesStatsAction.java b/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/stats/RestNodesStatsAction.java index 3474e7440d3..19d5ecf45fe 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/stats/RestNodesStatsAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/stats/RestNodesStatsAction.java @@ -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,35 +27,32 @@ import org.elasticsearch.client.Client; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.RestStatus; -import org.elasticsearch.rest.XContentRestResponse; -import org.elasticsearch.rest.XContentThrowableRestResponse; +import org.elasticsearch.rest.*; import org.elasticsearch.rest.action.support.RestActions; import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class RestNodesStatsAction extends BaseRestHandler { - @Inject public RestNodesStatsAction(Settings settings, Client client, RestController controller) { + @Inject + public RestNodesStatsAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(RestRequest.Method.GET, "/_cluster/nodes/stats", this); controller.registerHandler(RestRequest.Method.GET, "/_cluster/nodes/{nodeId}/stats", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { String[] nodesIds = RestActions.splitNodes(request.param("nodeId")); NodesStatsRequest nodesStatsRequest = new NodesStatsRequest(nodesIds); nodesStatsRequest.listenerThreaded(false); client.admin().cluster().nodesStats(nodesStatsRequest, new ActionListener() { - @Override public void onResponse(NodesStatsResponse result) { + @Override + public void onResponse(NodesStatsResponse result) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject(); @@ -101,7 +98,8 @@ public class RestNodesStatsAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/cluster/ping/broadcast/RestBroadcastPingAction.java b/src/main/java/org/elasticsearch/rest/action/admin/cluster/ping/broadcast/RestBroadcastPingAction.java index fa6df2abac3..5c66db54594 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/cluster/ping/broadcast/RestBroadcastPingAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/cluster/ping/broadcast/RestBroadcastPingAction.java @@ -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,21 +33,23 @@ import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; -import static org.elasticsearch.rest.RestStatus.*; -import static org.elasticsearch.rest.action.support.RestActions.*; +import static org.elasticsearch.rest.RestStatus.OK; +import static org.elasticsearch.rest.action.support.RestActions.buildBroadcastShardsHeader; /** - * @author kimchy (Shay Banon) + * */ public class RestBroadcastPingAction extends BaseRestHandler { - @Inject public RestBroadcastPingAction(Settings settings, Client client, RestController controller) { + @Inject + public RestBroadcastPingAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(RestRequest.Method.GET, "/{index}/_ping/broadcast", this); controller.registerHandler(RestRequest.Method.GET, "/_cluster/{index}/_ping/broadcast", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { BroadcastPingRequest broadcastPingRequest = new BroadcastPingRequest(RestActions.splitIndices(request.param("index"))); broadcastPingRequest.queryHint(request.param("query_hint")); BroadcastOperationThreading operationThreading = BroadcastOperationThreading.fromString(request.param("operation_threading"), BroadcastOperationThreading.SINGLE_THREAD); @@ -57,7 +59,8 @@ public class RestBroadcastPingAction extends BaseRestHandler { } broadcastPingRequest.operationThreading(operationThreading); client.admin().cluster().ping(broadcastPingRequest, new ActionListener() { - @Override public void onResponse(BroadcastPingResponse response) { + @Override + public void onResponse(BroadcastPingResponse response) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject(); @@ -70,7 +73,8 @@ public class RestBroadcastPingAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/cluster/ping/replication/RestReplicationPingAction.java b/src/main/java/org/elasticsearch/rest/action/admin/cluster/ping/replication/RestReplicationPingAction.java index d74c00e714f..b92be615217 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/cluster/ping/replication/RestReplicationPingAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/cluster/ping/replication/RestReplicationPingAction.java @@ -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,20 +35,22 @@ import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; -import static org.elasticsearch.rest.RestStatus.*; +import static org.elasticsearch.rest.RestStatus.OK; /** - * @author kimchy (Shay Banon) + * */ public class RestReplicationPingAction extends BaseRestHandler { - @Inject public RestReplicationPingAction(Settings settings, Client client, RestController controller) { + @Inject + public RestReplicationPingAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(RestRequest.Method.GET, "/{index}/_ping/replication", this); controller.registerHandler(RestRequest.Method.GET, "/_cluster/{index}/_ping/replication", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { ReplicationPingRequest replicationPingRequest = new ReplicationPingRequest(RestActions.splitIndices(request.param("index"))); replicationPingRequest.timeout(request.paramAsTime("timeout", ShardReplicationPingRequest.DEFAULT_TIMEOUT)); replicationPingRequest.listenerThreaded(false); @@ -57,7 +59,8 @@ public class RestReplicationPingAction extends BaseRestHandler { replicationPingRequest.replicationType(ReplicationType.fromString(replicationType)); } client.admin().cluster().ping(replicationPingRequest, new ActionListener() { - @Override public void onResponse(ReplicationPingResponse result) { + @Override + public void onResponse(ReplicationPingResponse result) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject(); @@ -79,7 +82,8 @@ public class RestReplicationPingAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/cluster/ping/single/RestSinglePingAction.java b/src/main/java/org/elasticsearch/rest/action/admin/cluster/ping/single/RestSinglePingAction.java index 7e35fef8f20..fa5d044d8ed 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/cluster/ping/single/RestSinglePingAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/cluster/ping/single/RestSinglePingAction.java @@ -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,27 +31,30 @@ import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; -import static org.elasticsearch.rest.RestStatus.*; +import static org.elasticsearch.rest.RestStatus.OK; /** - * @author kimchy (Shay Banon) + * */ public class RestSinglePingAction extends BaseRestHandler { - @Inject public RestSinglePingAction(Settings settings, Client client, RestController controller) { + @Inject + public RestSinglePingAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(RestRequest.Method.GET, "/{index}/{type}/{id}/_ping", this); controller.registerHandler(RestRequest.Method.GET, "/_cluster/{index}/{type}/{id}/_ping", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { SinglePingRequest singlePingRequest = new SinglePingRequest(request.param("index"), request.param("type"), request.param("id")); // no need to have a threaded listener since we just send back a response singlePingRequest.listenerThreaded(false); // if we have a local operation, execute it on a thread since we don't spawn singlePingRequest.operationThreaded(true); client.admin().cluster().ping(singlePingRequest, new ActionListener() { - @Override public void onResponse(SinglePingResponse result) { + @Override + public void onResponse(SinglePingResponse result) { try { XContentBuilder generator = RestXContentBuilder.restContentBuilder(request); generator.startObject().field("ok", true).endObject(); @@ -61,7 +64,8 @@ public class RestSinglePingAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/cluster/reroute/RestClusterRerouteAction.java b/src/main/java/org/elasticsearch/rest/action/admin/cluster/reroute/RestClusterRerouteAction.java index d8ddb2e56a8..6851226a494 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/cluster/reroute/RestClusterRerouteAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/cluster/reroute/RestClusterRerouteAction.java @@ -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,13 +27,7 @@ import org.elasticsearch.client.Requests; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.SettingsFilter; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.RestStatus; -import org.elasticsearch.rest.StringRestResponse; -import org.elasticsearch.rest.XContentThrowableRestResponse; +import org.elasticsearch.rest.*; import java.io.IOException; @@ -41,16 +35,19 @@ import java.io.IOException; */ public class RestClusterRerouteAction extends BaseRestHandler { - @Inject public RestClusterRerouteAction(Settings settings, Client client, RestController controller, - SettingsFilter settingsFilter) { + @Inject + public RestClusterRerouteAction(Settings settings, Client client, RestController controller, + SettingsFilter settingsFilter) { super(settings, client); controller.registerHandler(RestRequest.Method.POST, "/_cluster/reroute", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { final ClusterRerouteRequest clusterRerouteRequest = Requests.clusterRerouteRequest(); client.admin().cluster().reroute(clusterRerouteRequest, new ActionListener() { - @Override public void onResponse(ClusterRerouteResponse response) { + @Override + public void onResponse(ClusterRerouteResponse response) { try { channel.sendResponse(new StringRestResponse(RestStatus.OK)); } catch (Exception e) { @@ -58,7 +55,8 @@ public class RestClusterRerouteAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { if (logger.isDebugEnabled()) { logger.debug("failed to handle cluster reroute", e); } diff --git a/src/main/java/org/elasticsearch/rest/action/admin/cluster/settings/RestClusterGetSettingsAction.java b/src/main/java/org/elasticsearch/rest/action/admin/cluster/settings/RestClusterGetSettingsAction.java index 71eab856314..6980ec2767c 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/cluster/settings/RestClusterGetSettingsAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/cluster/settings/RestClusterGetSettingsAction.java @@ -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,13 +27,7 @@ import org.elasticsearch.client.Requests; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.RestStatus; -import org.elasticsearch.rest.XContentRestResponse; -import org.elasticsearch.rest.XContentThrowableRestResponse; +import org.elasticsearch.rest.*; import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; @@ -43,17 +37,20 @@ import java.util.Map; */ public class RestClusterGetSettingsAction extends BaseRestHandler { - @Inject public RestClusterGetSettingsAction(Settings settings, Client client, RestController controller) { + @Inject + public RestClusterGetSettingsAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(RestRequest.Method.GET, "/_cluster/settings", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { ClusterStateRequest clusterStateRequest = Requests.clusterStateRequest() .filterRoutingTable(true) .filterNodes(true); client.admin().cluster().state(clusterStateRequest, new ActionListener() { - @Override public void onResponse(ClusterStateResponse response) { + @Override + public void onResponse(ClusterStateResponse response) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject(); @@ -78,7 +75,8 @@ public class RestClusterGetSettingsAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/cluster/settings/RestClusterUpdateSettingsAction.java b/src/main/java/org/elasticsearch/rest/action/admin/cluster/settings/RestClusterUpdateSettingsAction.java index 6560f55324f..16b1110e814 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/cluster/settings/RestClusterUpdateSettingsAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/cluster/settings/RestClusterUpdateSettingsAction.java @@ -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,13 +28,7 @@ import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentType; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.RestStatus; -import org.elasticsearch.rest.StringRestResponse; -import org.elasticsearch.rest.XContentThrowableRestResponse; +import org.elasticsearch.rest.*; import java.io.IOException; import java.util.Map; @@ -43,12 +37,14 @@ import java.util.Map; */ public class RestClusterUpdateSettingsAction extends BaseRestHandler { - @Inject public RestClusterUpdateSettingsAction(Settings settings, Client client, RestController controller) { + @Inject + public RestClusterUpdateSettingsAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(RestRequest.Method.PUT, "/_cluster/settings", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { final ClusterUpdateSettingsRequest clusterUpdateSettingsRequest = Requests.clusterUpdateSettingsRequest(); try { @@ -72,7 +68,8 @@ public class RestClusterUpdateSettingsAction extends BaseRestHandler { } client.admin().cluster().updateSettings(clusterUpdateSettingsRequest, new ActionListener() { - @Override public void onResponse(ClusterUpdateSettingsResponse response) { + @Override + public void onResponse(ClusterUpdateSettingsResponse response) { try { channel.sendResponse(new StringRestResponse(RestStatus.OK)); } catch (Exception e) { @@ -80,7 +77,8 @@ public class RestClusterUpdateSettingsAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { if (logger.isDebugEnabled()) { logger.debug("failed to handle cluster state", e); } diff --git a/src/main/java/org/elasticsearch/rest/action/admin/cluster/state/RestClusterStateAction.java b/src/main/java/org/elasticsearch/rest/action/admin/cluster/state/RestClusterStateAction.java index 95bd6a5b503..11a32b79e8d 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/cluster/state/RestClusterStateAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/cluster/state/RestClusterStateAction.java @@ -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.rest.action.admin.cluster.state; +import com.google.common.collect.ImmutableSet; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest; import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; @@ -36,7 +37,6 @@ import org.elasticsearch.cluster.routing.RoutingNode; import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.cluster.routing.allocation.AllocationExplanation; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.collect.ImmutableSet; import org.elasticsearch.common.compress.CompressedString; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -54,21 +54,23 @@ import java.util.List; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class RestClusterStateAction extends BaseRestHandler { private final SettingsFilter settingsFilter; - @Inject public RestClusterStateAction(Settings settings, Client client, RestController controller, - SettingsFilter settingsFilter) { + @Inject + public RestClusterStateAction(Settings settings, Client client, RestController controller, + SettingsFilter settingsFilter) { super(settings, client); controller.registerHandler(RestRequest.Method.GET, "/_cluster/state", this); this.settingsFilter = settingsFilter; } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { final ClusterStateRequest clusterStateRequest = Requests.clusterStateRequest(); clusterStateRequest.filterNodes(request.paramAsBoolean("filter_nodes", clusterStateRequest.filterNodes())); clusterStateRequest.filterRoutingTable(request.paramAsBoolean("filter_routing_table", clusterStateRequest.filterRoutingTable())); @@ -78,7 +80,8 @@ public class RestClusterStateAction extends BaseRestHandler { clusterStateRequest.filteredIndexTemplates(request.paramAsStringArray("filter_index_templates", Strings.EMPTY_ARRAY)); clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local())); client.admin().cluster().state(clusterStateRequest, new ActionListener() { - @Override public void onResponse(ClusterStateResponse response) { + @Override + public void onResponse(ClusterStateResponse response) { try { ClusterState state = response.state(); XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); @@ -297,7 +300,8 @@ public class RestClusterStateAction extends BaseRestHandler { .endObject(); } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { if (logger.isDebugEnabled()) { logger.debug("failed to handle cluster state", e); } diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/RestGetIndicesAliasesAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/RestGetIndicesAliasesAction.java index 4389f7af73f..8084b52ce8b 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/RestGetIndicesAliasesAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/RestGetIndicesAliasesAction.java @@ -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,32 +31,29 @@ import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.XContentRestResponse; -import org.elasticsearch.rest.XContentThrowableRestResponse; +import org.elasticsearch.rest.*; import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; -import static org.elasticsearch.rest.RestRequest.Method.*; -import static org.elasticsearch.rest.RestStatus.*; -import static org.elasticsearch.rest.action.support.RestActions.*; +import static org.elasticsearch.rest.RestRequest.Method.GET; +import static org.elasticsearch.rest.RestStatus.OK; +import static org.elasticsearch.rest.action.support.RestActions.splitIndices; /** - * @author imotov + * */ public class RestGetIndicesAliasesAction extends BaseRestHandler { - @Inject public RestGetIndicesAliasesAction(Settings settings, Client client, RestController controller) { + @Inject + public RestGetIndicesAliasesAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(GET, "/_aliases", this); controller.registerHandler(GET, "/{index}/_aliases", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { final String[] indices = splitIndices(request.param("index")); ClusterStateRequest clusterStateRequest = Requests.clusterStateRequest() @@ -65,7 +62,8 @@ public class RestGetIndicesAliasesAction extends BaseRestHandler { .filteredIndices(indices); client.admin().cluster().state(clusterStateRequest, new ActionListener() { - @Override public void onResponse(ClusterStateResponse response) { + @Override + public void onResponse(ClusterStateResponse response) { try { MetaData metaData = response.state().metaData(); XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); @@ -91,7 +89,8 @@ public class RestGetIndicesAliasesAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/RestIndicesAliasesAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/RestIndicesAliasesAction.java index 83b2c5feda4..6d045f618ae 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/RestIndicesAliasesAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/RestIndicesAliasesAction.java @@ -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,33 +30,30 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.XContentRestResponse; -import org.elasticsearch.rest.XContentThrowableRestResponse; +import org.elasticsearch.rest.*; import java.io.IOException; import java.util.Map; -import static org.elasticsearch.cluster.metadata.AliasAction.*; -import static org.elasticsearch.common.unit.TimeValue.*; -import static org.elasticsearch.rest.RestRequest.Method.*; -import static org.elasticsearch.rest.RestStatus.*; -import static org.elasticsearch.rest.action.support.RestXContentBuilder.*; +import static org.elasticsearch.cluster.metadata.AliasAction.newAddAliasAction; +import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; +import static org.elasticsearch.rest.RestRequest.Method.POST; +import static org.elasticsearch.rest.RestStatus.OK; +import static org.elasticsearch.rest.action.support.RestXContentBuilder.restContentBuilder; /** - * @author kimchy (shay.banon) + * */ public class RestIndicesAliasesAction extends BaseRestHandler { - @Inject public RestIndicesAliasesAction(Settings settings, Client client, RestController controller) { + @Inject + public RestIndicesAliasesAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(POST, "/_aliases", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { IndicesAliasesRequest indicesAliasesRequest = new IndicesAliasesRequest(); try { // { @@ -153,7 +150,8 @@ public class RestIndicesAliasesAction extends BaseRestHandler { return; } client.admin().indices().aliases(indicesAliasesRequest, new ActionListener() { - @Override public void onResponse(IndicesAliasesResponse response) { + @Override + public void onResponse(IndicesAliasesResponse response) { try { XContentBuilder builder = restContentBuilder(request); builder.startObject() @@ -166,7 +164,8 @@ public class RestIndicesAliasesAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/analyze/RestAnalyzeAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/analyze/RestAnalyzeAction.java index 73afdfad2c5..242cda862f9 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/analyze/RestAnalyzeAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/analyze/RestAnalyzeAction.java @@ -27,31 +27,29 @@ import org.elasticsearch.client.Client; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.XContentRestResponse; -import org.elasticsearch.rest.XContentThrowableRestResponse; +import org.elasticsearch.rest.*; import java.io.IOException; -import static org.elasticsearch.rest.RestRequest.Method.*; -import static org.elasticsearch.rest.RestStatus.*; -import static org.elasticsearch.rest.action.support.RestXContentBuilder.*; +import static org.elasticsearch.rest.RestRequest.Method.GET; +import static org.elasticsearch.rest.RestRequest.Method.POST; +import static org.elasticsearch.rest.RestStatus.OK; +import static org.elasticsearch.rest.action.support.RestXContentBuilder.restContentBuilder; /** - * @author kimchy (shay.banon) + * */ public class RestAnalyzeAction extends BaseRestHandler { - @Inject public RestAnalyzeAction(Settings settings, Client client, RestController controller) { + @Inject + public RestAnalyzeAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(GET, "/{index}/_analyze", this); controller.registerHandler(POST, "/{index}/_analyze", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { String text = request.param("text"); if (text == null && request.hasContent()) { text = request.contentAsString(); @@ -70,7 +68,8 @@ public class RestAnalyzeAction extends BaseRestHandler { analyzeRequest.analyzer(request.param("analyzer")); analyzeRequest.field(request.param("field")); client.admin().indices().analyze(analyzeRequest, new ActionListener() { - @Override public void onResponse(AnalyzeResponse response) { + @Override + public void onResponse(AnalyzeResponse response) { try { XContentBuilder builder = restContentBuilder(request); builder.startObject(); @@ -82,7 +81,8 @@ public class RestAnalyzeAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/cache/clear/RestClearIndicesCacheAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/cache/clear/RestClearIndicesCacheAction.java index c9836b52e18..b51419d9a05 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/cache/clear/RestClearIndicesCacheAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/cache/clear/RestClearIndicesCacheAction.java @@ -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,27 +27,25 @@ import org.elasticsearch.client.Client; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.XContentRestResponse; -import org.elasticsearch.rest.XContentThrowableRestResponse; +import org.elasticsearch.rest.*; import org.elasticsearch.rest.action.support.RestActions; import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; -import static org.elasticsearch.rest.RestRequest.Method.*; -import static org.elasticsearch.rest.RestStatus.*; -import static org.elasticsearch.rest.action.support.RestActions.*; +import static org.elasticsearch.rest.RestRequest.Method.GET; +import static org.elasticsearch.rest.RestRequest.Method.POST; +import static org.elasticsearch.rest.RestStatus.BAD_REQUEST; +import static org.elasticsearch.rest.RestStatus.OK; +import static org.elasticsearch.rest.action.support.RestActions.buildBroadcastShardsHeader; /** - * @author kimchy (Shay Banon) + * */ public class RestClearIndicesCacheAction extends BaseRestHandler { - @Inject public RestClearIndicesCacheAction(Settings settings, Client client, RestController controller) { + @Inject + public RestClearIndicesCacheAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(POST, "/_cache/clear", this); controller.registerHandler(POST, "/{index}/_cache/clear", this); @@ -56,7 +54,8 @@ public class RestClearIndicesCacheAction extends BaseRestHandler { controller.registerHandler(GET, "/{index}/_cache/clear", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { ClearIndicesCacheRequest clearIndicesCacheRequest = new ClearIndicesCacheRequest(RestActions.splitIndices(request.param("index"))); try { clearIndicesCacheRequest.filterCache(request.paramAsBoolean("filter", clearIndicesCacheRequest.filterCache())); @@ -83,7 +82,8 @@ public class RestClearIndicesCacheAction extends BaseRestHandler { return; } client.admin().indices().clearCache(clearIndicesCacheRequest, new ActionListener() { - @Override public void onResponse(ClearIndicesCacheResponse response) { + @Override + public void onResponse(ClearIndicesCacheResponse response) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject(); @@ -98,7 +98,8 @@ public class RestClearIndicesCacheAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/close/RestCloseIndexAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/close/RestCloseIndexAction.java index c9225a7fbbb..8b475c7f807 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/close/RestCloseIndexAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/close/RestCloseIndexAction.java @@ -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,24 +32,27 @@ import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; -import static org.elasticsearch.common.unit.TimeValue.*; -import static org.elasticsearch.rest.RestStatus.*; +import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; +import static org.elasticsearch.rest.RestStatus.OK; /** - * @author kimchy (shay.banon) + * */ public class RestCloseIndexAction extends BaseRestHandler { - @Inject public RestCloseIndexAction(Settings settings, Client client, RestController controller) { + @Inject + public RestCloseIndexAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(RestRequest.Method.POST, "/{index}/_close", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { CloseIndexRequest closeIndexRequest = new CloseIndexRequest(request.param("index")); closeIndexRequest.timeout(request.paramAsTime("timeout", timeValueSeconds(10))); client.admin().indices().close(closeIndexRequest, new ActionListener() { - @Override public void onResponse(CloseIndexResponse response) { + @Override + public void onResponse(CloseIndexResponse response) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject() @@ -62,7 +65,8 @@ public class RestCloseIndexAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/create/RestCreateIndexAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/create/RestCreateIndexAction.java index 6900a97cbb5..4da14edf623 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/create/RestCreateIndexAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/create/RestCreateIndexAction.java @@ -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,33 +29,31 @@ import org.elasticsearch.common.settings.SettingsException; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentType; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.XContentRestResponse; -import org.elasticsearch.rest.XContentThrowableRestResponse; +import org.elasticsearch.rest.*; import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; import java.util.Map; -import static org.elasticsearch.common.unit.TimeValue.*; -import static org.elasticsearch.rest.RestStatus.*; +import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; +import static org.elasticsearch.rest.RestStatus.BAD_REQUEST; +import static org.elasticsearch.rest.RestStatus.OK; /** - * @author kimchy (shay.banon) + * */ public class RestCreateIndexAction extends BaseRestHandler { - @Inject public RestCreateIndexAction(Settings settings, Client client, RestController controller) { + @Inject + public RestCreateIndexAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(RestRequest.Method.PUT, "/{index}", this); controller.registerHandler(RestRequest.Method.POST, "/{index}", this); } @SuppressWarnings({"unchecked"}) - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { CreateIndexRequest createIndexRequest = new CreateIndexRequest(request.param("index")); if (request.hasContent()) { XContentType xContentType = XContentFactory.xContentType(request.contentByteArray(), request.contentByteArrayOffset(), request.contentLength()); @@ -105,7 +103,8 @@ public class RestCreateIndexAction extends BaseRestHandler { createIndexRequest.timeout(request.paramAsTime("timeout", timeValueSeconds(10))); client.admin().indices().create(createIndexRequest, new ActionListener() { - @Override public void onResponse(CreateIndexResponse response) { + @Override + public void onResponse(CreateIndexResponse response) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject() @@ -118,7 +117,8 @@ public class RestCreateIndexAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/delete/RestDeleteIndexAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/delete/RestDeleteIndexAction.java index 9f664c19c52..dc07306d7c5 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/delete/RestDeleteIndexAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/delete/RestDeleteIndexAction.java @@ -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,26 +32,29 @@ import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; -import static org.elasticsearch.common.unit.TimeValue.*; -import static org.elasticsearch.rest.RestStatus.*; -import static org.elasticsearch.rest.action.support.RestActions.*; +import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; +import static org.elasticsearch.rest.RestStatus.OK; +import static org.elasticsearch.rest.action.support.RestActions.splitIndices; /** - * @author kimchy (shay.banon) + * */ public class RestDeleteIndexAction extends BaseRestHandler { - @Inject public RestDeleteIndexAction(Settings settings, Client client, RestController controller) { + @Inject + public RestDeleteIndexAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(RestRequest.Method.DELETE, "/", this); controller.registerHandler(RestRequest.Method.DELETE, "/{index}", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(splitIndices(request.param("index"))); deleteIndexRequest.timeout(request.paramAsTime("timeout", timeValueSeconds(10))); client.admin().indices().delete(deleteIndexRequest, new ActionListener() { - @Override public void onResponse(DeleteIndexResponse response) { + @Override + public void onResponse(DeleteIndexResponse response) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject() @@ -64,7 +67,8 @@ public class RestDeleteIndexAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/exists/RestIndicesExistsAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/exists/RestIndicesExistsAction.java index 391ef7461a8..b2a34e0c372 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/exists/RestIndicesExistsAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/exists/RestIndicesExistsAction.java @@ -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,37 +26,36 @@ import org.elasticsearch.client.Client; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.SettingsFilter; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.StringRestResponse; +import org.elasticsearch.rest.*; -import static org.elasticsearch.rest.RestRequest.Method.*; +import static org.elasticsearch.rest.RestRequest.Method.HEAD; import static org.elasticsearch.rest.RestStatus.*; -import static org.elasticsearch.rest.action.support.RestActions.*; +import static org.elasticsearch.rest.action.support.RestActions.splitIndices; /** - * @author kimchy (Shay Banon) + * */ public class RestIndicesExistsAction extends BaseRestHandler { private final SettingsFilter settingsFilter; - @Inject public RestIndicesExistsAction(Settings settings, Client client, RestController controller, - SettingsFilter settingsFilter) { + @Inject + public RestIndicesExistsAction(Settings settings, Client client, RestController controller, + SettingsFilter settingsFilter) { super(settings, client); controller.registerHandler(HEAD, "/{index}", this); this.settingsFilter = settingsFilter; } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { IndicesExistsRequest indicesExistsRequest = new IndicesExistsRequest(splitIndices(request.param("index"))); // we just send back a response, no need to fork a listener indicesExistsRequest.listenerThreaded(false); client.admin().indices().exists(indicesExistsRequest, new ActionListener() { - @Override public void onResponse(IndicesExistsResponse response) { + @Override + public void onResponse(IndicesExistsResponse response) { try { if (response.exists()) { channel.sendResponse(new StringRestResponse(OK)); @@ -68,7 +67,8 @@ public class RestIndicesExistsAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new StringRestResponse(INTERNAL_SERVER_ERROR)); } catch (Exception e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/flush/RestFlushAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/flush/RestFlushAction.java index 0ac69dc42b3..0d731af5224 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/flush/RestFlushAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/flush/RestFlushAction.java @@ -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,27 +27,24 @@ import org.elasticsearch.client.Client; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.XContentRestResponse; -import org.elasticsearch.rest.XContentThrowableRestResponse; +import org.elasticsearch.rest.*; import org.elasticsearch.rest.action.support.RestActions; import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; -import static org.elasticsearch.rest.RestRequest.Method.*; -import static org.elasticsearch.rest.RestStatus.*; -import static org.elasticsearch.rest.action.support.RestActions.*; +import static org.elasticsearch.rest.RestRequest.Method.GET; +import static org.elasticsearch.rest.RestRequest.Method.POST; +import static org.elasticsearch.rest.RestStatus.OK; +import static org.elasticsearch.rest.action.support.RestActions.buildBroadcastShardsHeader; /** - * @author kimchy (Shay Banon) + * */ public class RestFlushAction extends BaseRestHandler { - @Inject public RestFlushAction(Settings settings, Client client, RestController controller) { + @Inject + public RestFlushAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(POST, "/_flush", this); controller.registerHandler(POST, "/{index}/_flush", this); @@ -56,7 +53,8 @@ public class RestFlushAction extends BaseRestHandler { controller.registerHandler(GET, "/{index}/_flush", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { FlushRequest flushRequest = new FlushRequest(RestActions.splitIndices(request.param("index"))); // we just send back a response, no need to fork a listener flushRequest.listenerThreaded(false); @@ -70,7 +68,8 @@ public class RestFlushAction extends BaseRestHandler { flushRequest.full(request.paramAsBoolean("full", flushRequest.full())); flushRequest.force(request.paramAsBoolean("force", flushRequest.force())); client.admin().indices().flush(flushRequest, new ActionListener() { - @Override public void onResponse(FlushResponse response) { + @Override + public void onResponse(FlushResponse response) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject(); @@ -85,7 +84,8 @@ public class RestFlushAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/gateway/snapshot/RestGatewaySnapshotAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/gateway/snapshot/RestGatewaySnapshotAction.java index 97f99c3c4f9..9dce9e1b76f 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/gateway/snapshot/RestGatewaySnapshotAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/gateway/snapshot/RestGatewaySnapshotAction.java @@ -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,26 +32,29 @@ import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; -import static org.elasticsearch.rest.RestRequest.Method.*; -import static org.elasticsearch.rest.RestStatus.*; -import static org.elasticsearch.rest.action.support.RestActions.*; +import static org.elasticsearch.rest.RestRequest.Method.POST; +import static org.elasticsearch.rest.RestStatus.OK; +import static org.elasticsearch.rest.action.support.RestActions.buildBroadcastShardsHeader; /** - * @author kimchy (Shay Banon) + * */ public class RestGatewaySnapshotAction extends BaseRestHandler { - @Inject public RestGatewaySnapshotAction(Settings settings, Client client, RestController controller) { + @Inject + public RestGatewaySnapshotAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(POST, "/_gateway/snapshot", this); controller.registerHandler(POST, "/{index}/_gateway/snapshot", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { GatewaySnapshotRequest gatewaySnapshotRequest = new GatewaySnapshotRequest(RestActions.splitIndices(request.param("index"))); gatewaySnapshotRequest.listenerThreaded(false); client.admin().indices().gatewaySnapshot(gatewaySnapshotRequest, new ActionListener() { - @Override public void onResponse(GatewaySnapshotResponse response) { + @Override + public void onResponse(GatewaySnapshotResponse response) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject(); @@ -66,7 +69,8 @@ public class RestGatewaySnapshotAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/mapping/delete/RestDeleteMappingAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/mapping/delete/RestDeleteMappingAction.java index 7d009afa63e..ab82b55b787 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/mapping/delete/RestDeleteMappingAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/mapping/delete/RestDeleteMappingAction.java @@ -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,27 +31,30 @@ import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; -import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.rest.RestRequest.Method.*; -import static org.elasticsearch.rest.RestStatus.*; -import static org.elasticsearch.rest.action.support.RestActions.*; +import static org.elasticsearch.client.Requests.deleteMappingRequest; +import static org.elasticsearch.rest.RestRequest.Method.DELETE; +import static org.elasticsearch.rest.RestStatus.OK; +import static org.elasticsearch.rest.action.support.RestActions.splitIndices; /** - * @author kimchy (shay.banon) + * */ public class RestDeleteMappingAction extends BaseRestHandler { - @Inject public RestDeleteMappingAction(Settings settings, Client client, RestController controller) { + @Inject + public RestDeleteMappingAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(DELETE, "/{index}/{type}/_mapping", this); controller.registerHandler(DELETE, "/{index}/{type}", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { DeleteMappingRequest deleteMappingRequest = deleteMappingRequest(splitIndices(request.param("index"))); deleteMappingRequest.type(request.param("type")); client.admin().indices().deleteMapping(deleteMappingRequest, new ActionListener() { - @Override public void onResponse(DeleteMappingResponse response) { + @Override + public void onResponse(DeleteMappingResponse response) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject() @@ -63,7 +66,8 @@ public class RestDeleteMappingAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/mapping/get/RestGetMappingAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/mapping/get/RestGetMappingAction.java index 6a9ddb7075e..b99c4863d48 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/mapping/get/RestGetMappingAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/mapping/get/RestGetMappingAction.java @@ -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.rest.action.admin.indices.mapping.get; +import com.google.common.collect.ImmutableSet; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest; import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; @@ -27,41 +28,38 @@ import org.elasticsearch.client.Requests; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.MappingMetaData; import org.elasticsearch.cluster.metadata.MetaData; -import org.elasticsearch.common.collect.ImmutableSet; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.index.Index; import org.elasticsearch.indices.IndexMissingException; import org.elasticsearch.indices.TypeMissingException; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.XContentRestResponse; -import org.elasticsearch.rest.XContentThrowableRestResponse; +import org.elasticsearch.rest.*; import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; import java.util.Set; -import static org.elasticsearch.rest.RestRequest.Method.*; -import static org.elasticsearch.rest.RestStatus.*; -import static org.elasticsearch.rest.action.support.RestActions.*; +import static org.elasticsearch.rest.RestRequest.Method.GET; +import static org.elasticsearch.rest.RestStatus.OK; +import static org.elasticsearch.rest.action.support.RestActions.splitIndices; +import static org.elasticsearch.rest.action.support.RestActions.splitTypes; /** - * @author kimchy (shay.banon) + * */ public class RestGetMappingAction extends BaseRestHandler { - @Inject public RestGetMappingAction(Settings settings, Client client, RestController controller) { + @Inject + public RestGetMappingAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(GET, "/_mapping", this); controller.registerHandler(GET, "/{index}/_mapping", this); controller.registerHandler(GET, "/{index}/{type}/_mapping", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { final String[] indices = splitIndices(request.param("index")); final Set types = ImmutableSet.copyOf(splitTypes(request.param("type"))); @@ -71,7 +69,8 @@ public class RestGetMappingAction extends BaseRestHandler { .filteredIndices(indices); client.admin().cluster().state(clusterStateRequest, new ActionListener() { - @Override public void onResponse(ClusterStateResponse response) { + @Override + public void onResponse(ClusterStateResponse response) { try { MetaData metaData = response.state().metaData(); XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); @@ -122,7 +121,8 @@ public class RestGetMappingAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/mapping/put/RestPutMappingAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/mapping/put/RestPutMappingAction.java index a3732b3cf30..d45c03adb33 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/mapping/put/RestPutMappingAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/mapping/put/RestPutMappingAction.java @@ -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,18 +31,20 @@ import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; -import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.common.unit.TimeValue.*; -import static org.elasticsearch.rest.RestRequest.Method.*; -import static org.elasticsearch.rest.RestStatus.*; -import static org.elasticsearch.rest.action.support.RestActions.*; +import static org.elasticsearch.client.Requests.putMappingRequest; +import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; +import static org.elasticsearch.rest.RestRequest.Method.POST; +import static org.elasticsearch.rest.RestRequest.Method.PUT; +import static org.elasticsearch.rest.RestStatus.OK; +import static org.elasticsearch.rest.action.support.RestActions.splitIndices; /** - * @author kimchy (shay.banon) + * */ public class RestPutMappingAction extends BaseRestHandler { - @Inject public RestPutMappingAction(Settings settings, Client client, RestController controller) { + @Inject + public RestPutMappingAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(PUT, "/{index}/_mapping", this); controller.registerHandler(PUT, "/{index}/{type}/_mapping", this); @@ -51,14 +53,16 @@ public class RestPutMappingAction extends BaseRestHandler { controller.registerHandler(POST, "/{index}/{type}/_mapping", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { PutMappingRequest putMappingRequest = putMappingRequest(splitIndices(request.param("index"))); putMappingRequest.type(request.param("type")); putMappingRequest.source(request.contentAsString()); putMappingRequest.timeout(request.paramAsTime("timeout", timeValueSeconds(10))); putMappingRequest.ignoreConflicts(request.paramAsBoolean("ignore_conflicts", putMappingRequest.ignoreConflicts())); client.admin().indices().putMapping(putMappingRequest, new ActionListener() { - @Override public void onResponse(PutMappingResponse response) { + @Override + public void onResponse(PutMappingResponse response) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject() @@ -71,7 +75,8 @@ public class RestPutMappingAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/open/RestOpenIndexAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/open/RestOpenIndexAction.java index be9d55cd8a6..3cd38d2f7f5 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/open/RestOpenIndexAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/open/RestOpenIndexAction.java @@ -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,24 +32,27 @@ import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; -import static org.elasticsearch.common.unit.TimeValue.*; -import static org.elasticsearch.rest.RestStatus.*; +import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; +import static org.elasticsearch.rest.RestStatus.OK; /** - * @author kimchy (shay.banon) + * */ public class RestOpenIndexAction extends BaseRestHandler { - @Inject public RestOpenIndexAction(Settings settings, Client client, RestController controller) { + @Inject + public RestOpenIndexAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(RestRequest.Method.POST, "/{index}/_open", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { OpenIndexRequest openIndexRequest = new OpenIndexRequest(request.param("index")); openIndexRequest.timeout(request.paramAsTime("timeout", timeValueSeconds(10))); client.admin().indices().open(openIndexRequest, new ActionListener() { - @Override public void onResponse(OpenIndexResponse response) { + @Override + public void onResponse(OpenIndexResponse response) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject() @@ -62,7 +65,8 @@ public class RestOpenIndexAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/optimize/RestOptimizeAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/optimize/RestOptimizeAction.java index e51268908f9..b76ed7d8947 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/optimize/RestOptimizeAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/optimize/RestOptimizeAction.java @@ -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,16 +33,19 @@ import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; -import static org.elasticsearch.rest.RestRequest.Method.*; -import static org.elasticsearch.rest.RestStatus.*; -import static org.elasticsearch.rest.action.support.RestActions.*; +import static org.elasticsearch.rest.RestRequest.Method.GET; +import static org.elasticsearch.rest.RestRequest.Method.POST; +import static org.elasticsearch.rest.RestStatus.BAD_REQUEST; +import static org.elasticsearch.rest.RestStatus.OK; +import static org.elasticsearch.rest.action.support.RestActions.buildBroadcastShardsHeader; /** - * @author kimchy (Shay Banon) + * */ public class RestOptimizeAction extends BaseRestHandler { - @Inject public RestOptimizeAction(Settings settings, Client client, RestController controller) { + @Inject + public RestOptimizeAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(POST, "/_optimize", this); controller.registerHandler(POST, "/{index}/_optimize", this); @@ -51,7 +54,8 @@ public class RestOptimizeAction extends BaseRestHandler { controller.registerHandler(GET, "/{index}/_optimize", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { OptimizeRequest optimizeRequest = new OptimizeRequest(RestActions.splitIndices(request.param("index"))); try { optimizeRequest.waitForMerge(request.paramAsBoolean("wait_for_merge", optimizeRequest.waitForMerge())); @@ -78,7 +82,8 @@ public class RestOptimizeAction extends BaseRestHandler { return; } client.admin().indices().optimize(optimizeRequest, new ActionListener() { - @Override public void onResponse(OptimizeResponse response) { + @Override + public void onResponse(OptimizeResponse response) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject(); @@ -93,7 +98,8 @@ public class RestOptimizeAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/refresh/RestRefreshAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/refresh/RestRefreshAction.java index df6ba0f6f6b..ffc88a74eb0 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/refresh/RestRefreshAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/refresh/RestRefreshAction.java @@ -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,16 +33,18 @@ import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; -import static org.elasticsearch.rest.RestRequest.Method.*; -import static org.elasticsearch.rest.RestStatus.*; -import static org.elasticsearch.rest.action.support.RestActions.*; +import static org.elasticsearch.rest.RestRequest.Method.GET; +import static org.elasticsearch.rest.RestRequest.Method.POST; +import static org.elasticsearch.rest.RestStatus.OK; +import static org.elasticsearch.rest.action.support.RestActions.buildBroadcastShardsHeader; /** - * @author kimchy (Shay Banon) + * */ public class RestRefreshAction extends BaseRestHandler { - @Inject public RestRefreshAction(Settings settings, Client client, RestController controller) { + @Inject + public RestRefreshAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(POST, "/_refresh", this); controller.registerHandler(POST, "/{index}/_refresh", this); @@ -51,7 +53,8 @@ public class RestRefreshAction extends BaseRestHandler { controller.registerHandler(GET, "/{index}/_refresh", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { RefreshRequest refreshRequest = new RefreshRequest(RestActions.splitIndices(request.param("index"))); // we just send back a response, no need to fork a listener refreshRequest.listenerThreaded(false); @@ -62,7 +65,8 @@ public class RestRefreshAction extends BaseRestHandler { } refreshRequest.operationThreading(operationThreading); client.admin().indices().refresh(refreshRequest, new ActionListener() { - @Override public void onResponse(RefreshResponse response) { + @Override + public void onResponse(RefreshResponse response) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject(); @@ -77,7 +81,8 @@ public class RestRefreshAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/segments/RestIndicesSegmentsAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/segments/RestIndicesSegmentsAction.java index dbaebcfb288..781514c86d9 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/segments/RestIndicesSegmentsAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/segments/RestIndicesSegmentsAction.java @@ -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,31 +27,29 @@ import org.elasticsearch.client.Client; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.XContentRestResponse; -import org.elasticsearch.rest.XContentThrowableRestResponse; +import org.elasticsearch.rest.*; import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; -import static org.elasticsearch.rest.RestRequest.Method.*; -import static org.elasticsearch.rest.RestStatus.*; -import static org.elasticsearch.rest.action.support.RestActions.*; +import static org.elasticsearch.rest.RestRequest.Method.GET; +import static org.elasticsearch.rest.RestStatus.OK; +import static org.elasticsearch.rest.action.support.RestActions.buildBroadcastShardsHeader; +import static org.elasticsearch.rest.action.support.RestActions.splitIndices; /** */ public class RestIndicesSegmentsAction extends BaseRestHandler { - @Inject public RestIndicesSegmentsAction(Settings settings, Client client, RestController controller) { + @Inject + public RestIndicesSegmentsAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(GET, "/_segments", this); controller.registerHandler(GET, "/{index}/_segments", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { IndicesSegmentsRequest indicesSegmentsRequest = new IndicesSegmentsRequest(splitIndices(request.param("index"))); // we just send back a response, no need to fork a listener indicesSegmentsRequest.listenerThreaded(false); @@ -62,7 +60,8 @@ public class RestIndicesSegmentsAction extends BaseRestHandler { } indicesSegmentsRequest.operationThreading(operationThreading); client.admin().indices().segments(indicesSegmentsRequest, new ActionListener() { - @Override public void onResponse(IndicesSegmentResponse response) { + @Override + public void onResponse(IndicesSegmentResponse response) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject(); @@ -76,7 +75,8 @@ public class RestIndicesSegmentsAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/settings/RestGetSettingsAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/settings/RestGetSettingsAction.java index 0565de34656..1f435a2e67b 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/settings/RestGetSettingsAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/settings/RestGetSettingsAction.java @@ -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,26 +30,22 @@ import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.SettingsFilter; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.XContentRestResponse; -import org.elasticsearch.rest.XContentThrowableRestResponse; +import org.elasticsearch.rest.*; import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; import java.util.Map; -import static org.elasticsearch.rest.RestRequest.Method.*; -import static org.elasticsearch.rest.RestStatus.*; -import static org.elasticsearch.rest.action.support.RestActions.*; +import static org.elasticsearch.rest.RestRequest.Method.GET; +import static org.elasticsearch.rest.RestStatus.OK; +import static org.elasticsearch.rest.action.support.RestActions.splitIndices; public class RestGetSettingsAction extends BaseRestHandler { private final SettingsFilter settingsFilter; - @Inject public RestGetSettingsAction(Settings settings, Client client, RestController controller, SettingsFilter settingsFilter) { + @Inject + public RestGetSettingsAction(Settings settings, Client client, RestController controller, SettingsFilter settingsFilter) { super(settings, client); controller.registerHandler(GET, "/_settings", this); controller.registerHandler(GET, "/{index}/_settings", this); @@ -57,7 +53,8 @@ public class RestGetSettingsAction extends BaseRestHandler { this.settingsFilter = settingsFilter; } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { final String[] indices = splitIndices(request.param("index")); ClusterStateRequest clusterStateRequest = Requests.clusterStateRequest() @@ -66,7 +63,8 @@ public class RestGetSettingsAction extends BaseRestHandler { .filteredIndices(indices); client.admin().cluster().state(clusterStateRequest, new ActionListener() { - @Override public void onResponse(ClusterStateResponse response) { + @Override + public void onResponse(ClusterStateResponse response) { try { MetaData metaData = response.state().metaData(); XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); @@ -93,7 +91,8 @@ public class RestGetSettingsAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/settings/RestUpdateSettingsAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/settings/RestUpdateSettingsAction.java index e9bac05de1c..55cf966ce0f 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/settings/RestUpdateSettingsAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/settings/RestUpdateSettingsAction.java @@ -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,33 +29,31 @@ import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.SettingsException; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.XContentRestResponse; -import org.elasticsearch.rest.XContentThrowableRestResponse; +import org.elasticsearch.rest.*; import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; import java.util.Map; -import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.rest.RestStatus.*; -import static org.elasticsearch.rest.action.support.RestActions.*; +import static org.elasticsearch.client.Requests.updateSettingsRequest; +import static org.elasticsearch.rest.RestStatus.BAD_REQUEST; +import static org.elasticsearch.rest.RestStatus.OK; +import static org.elasticsearch.rest.action.support.RestActions.splitIndices; /** - * @author kimchy (shay.banon) + * */ public class RestUpdateSettingsAction extends BaseRestHandler { - @Inject public RestUpdateSettingsAction(Settings settings, Client client, RestController controller) { + @Inject + public RestUpdateSettingsAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(RestRequest.Method.PUT, "/{index}/_settings", this); controller.registerHandler(RestRequest.Method.PUT, "/_settings", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { UpdateSettingsRequest updateSettingsRequest = updateSettingsRequest(splitIndices(request.param("index"))); ImmutableSettings.Builder updateSettings = ImmutableSettings.settingsBuilder(); String bodySettings = request.contentAsString(); @@ -80,7 +78,8 @@ public class RestUpdateSettingsAction extends BaseRestHandler { updateSettingsRequest.settings(updateSettings); client.admin().indices().updateSettings(updateSettingsRequest, new ActionListener() { - @Override public void onResponse(UpdateSettingsResponse updateSettingsResponse) { + @Override + public void onResponse(UpdateSettingsResponse updateSettingsResponse) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject() @@ -92,7 +91,8 @@ public class RestUpdateSettingsAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/stats/RestIndicesStatsAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/stats/RestIndicesStatsAction.java index dcedb8094f0..5f4f27beac7 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/stats/RestIndicesStatsAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/stats/RestIndicesStatsAction.java @@ -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,26 +27,21 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestHandler; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.XContentRestResponse; -import org.elasticsearch.rest.XContentThrowableRestResponse; +import org.elasticsearch.rest.*; import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; -import static org.elasticsearch.rest.RestRequest.Method.*; -import static org.elasticsearch.rest.RestStatus.*; +import static org.elasticsearch.rest.RestRequest.Method.GET; +import static org.elasticsearch.rest.RestStatus.OK; import static org.elasticsearch.rest.action.support.RestActions.*; /** */ public class RestIndicesStatsAction extends BaseRestHandler { - @Inject public RestIndicesStatsAction(Settings settings, Client client, RestController controller) { + @Inject + public RestIndicesStatsAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(GET, "/_stats", this); controller.registerHandler(GET, "/{index}/_stats", this); @@ -80,7 +75,8 @@ public class RestIndicesStatsAction extends BaseRestHandler { controller.registerHandler(GET, "/{index}/_stats/flush", new RestFlushStatsHandler()); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { IndicesStatsRequest indicesStatsRequest = new IndicesStatsRequest(); boolean clear = request.paramAsBoolean("clear", false); if (clear) { @@ -101,7 +97,8 @@ public class RestIndicesStatsAction extends BaseRestHandler { indicesStatsRequest.flush(request.paramAsBoolean("flush", indicesStatsRequest.flush())); client.admin().indices().stats(indicesStatsRequest, new ActionListener() { - @Override public void onResponse(IndicesStats response) { + @Override + public void onResponse(IndicesStats response) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject(); @@ -115,7 +112,8 @@ public class RestIndicesStatsAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { @@ -127,14 +125,16 @@ public class RestIndicesStatsAction extends BaseRestHandler { class RestDocsStatsHandler implements RestHandler { - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { IndicesStatsRequest indicesStatsRequest = new IndicesStatsRequest(); indicesStatsRequest.clear().docs(true); indicesStatsRequest.indices(splitIndices(request.param("index"))); indicesStatsRequest.types(splitTypes(request.param("types"))); client.admin().indices().stats(indicesStatsRequest, new ActionListener() { - @Override public void onResponse(IndicesStats response) { + @Override + public void onResponse(IndicesStats response) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject(); @@ -148,7 +148,8 @@ public class RestIndicesStatsAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { @@ -161,14 +162,16 @@ public class RestIndicesStatsAction extends BaseRestHandler { class RestStoreStatsHandler implements RestHandler { - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { IndicesStatsRequest indicesStatsRequest = new IndicesStatsRequest(); indicesStatsRequest.clear().store(true); indicesStatsRequest.indices(splitIndices(request.param("index"))); indicesStatsRequest.types(splitTypes(request.param("types"))); client.admin().indices().stats(indicesStatsRequest, new ActionListener() { - @Override public void onResponse(IndicesStats response) { + @Override + public void onResponse(IndicesStats response) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject(); @@ -182,7 +185,8 @@ public class RestIndicesStatsAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { @@ -195,7 +199,8 @@ public class RestIndicesStatsAction extends BaseRestHandler { class RestIndexingStatsHandler implements RestHandler { - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { IndicesStatsRequest indicesStatsRequest = new IndicesStatsRequest(); indicesStatsRequest.clear().indexing(true); indicesStatsRequest.indices(splitIndices(request.param("index"))); @@ -208,7 +213,8 @@ public class RestIndicesStatsAction extends BaseRestHandler { } client.admin().indices().stats(indicesStatsRequest, new ActionListener() { - @Override public void onResponse(IndicesStats response) { + @Override + public void onResponse(IndicesStats response) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject(); @@ -222,7 +228,8 @@ public class RestIndicesStatsAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { @@ -235,7 +242,8 @@ public class RestIndicesStatsAction extends BaseRestHandler { class RestSearchStatsHandler implements RestHandler { - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { IndicesStatsRequest indicesStatsRequest = new IndicesStatsRequest(); indicesStatsRequest.clear().search(true); indicesStatsRequest.indices(splitIndices(request.param("index"))); @@ -248,7 +256,8 @@ public class RestIndicesStatsAction extends BaseRestHandler { } client.admin().indices().stats(indicesStatsRequest, new ActionListener() { - @Override public void onResponse(IndicesStats response) { + @Override + public void onResponse(IndicesStats response) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject(); @@ -262,7 +271,8 @@ public class RestIndicesStatsAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { @@ -275,13 +285,15 @@ public class RestIndicesStatsAction extends BaseRestHandler { class RestGetStatsHandler implements RestHandler { - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { IndicesStatsRequest indicesStatsRequest = new IndicesStatsRequest(); indicesStatsRequest.clear().get(true); indicesStatsRequest.indices(splitIndices(request.param("index"))); client.admin().indices().stats(indicesStatsRequest, new ActionListener() { - @Override public void onResponse(IndicesStats response) { + @Override + public void onResponse(IndicesStats response) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject(); @@ -295,7 +307,8 @@ public class RestIndicesStatsAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { @@ -308,14 +321,16 @@ public class RestIndicesStatsAction extends BaseRestHandler { class RestMergeStatsHandler implements RestHandler { - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { IndicesStatsRequest indicesStatsRequest = new IndicesStatsRequest(); indicesStatsRequest.clear().merge(true); indicesStatsRequest.indices(splitIndices(request.param("index"))); indicesStatsRequest.types(splitTypes(request.param("types"))); client.admin().indices().stats(indicesStatsRequest, new ActionListener() { - @Override public void onResponse(IndicesStats response) { + @Override + public void onResponse(IndicesStats response) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject(); @@ -329,7 +344,8 @@ public class RestIndicesStatsAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { @@ -342,14 +358,16 @@ public class RestIndicesStatsAction extends BaseRestHandler { class RestFlushStatsHandler implements RestHandler { - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { IndicesStatsRequest indicesStatsRequest = new IndicesStatsRequest(); indicesStatsRequest.clear().flush(true); indicesStatsRequest.indices(splitIndices(request.param("index"))); indicesStatsRequest.types(splitTypes(request.param("types"))); client.admin().indices().stats(indicesStatsRequest, new ActionListener() { - @Override public void onResponse(IndicesStats response) { + @Override + public void onResponse(IndicesStats response) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject(); @@ -363,7 +381,8 @@ public class RestIndicesStatsAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { @@ -376,14 +395,16 @@ public class RestIndicesStatsAction extends BaseRestHandler { class RestRefreshStatsHandler implements RestHandler { - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { IndicesStatsRequest indicesStatsRequest = new IndicesStatsRequest(); indicesStatsRequest.clear().refresh(true); indicesStatsRequest.indices(splitIndices(request.param("index"))); indicesStatsRequest.types(splitTypes(request.param("types"))); client.admin().indices().stats(indicesStatsRequest, new ActionListener() { - @Override public void onResponse(IndicesStats response) { + @Override + public void onResponse(IndicesStats response) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject(); @@ -397,7 +418,8 @@ public class RestIndicesStatsAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/status/RestIndicesStatusAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/status/RestIndicesStatusAction.java index 7774c071962..36ebbd7562c 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/status/RestIndicesStatusAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/status/RestIndicesStatusAction.java @@ -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,19 +33,21 @@ import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; -import static org.elasticsearch.rest.RestRequest.Method.*; -import static org.elasticsearch.rest.RestStatus.*; -import static org.elasticsearch.rest.action.support.RestActions.*; +import static org.elasticsearch.rest.RestRequest.Method.GET; +import static org.elasticsearch.rest.RestStatus.OK; +import static org.elasticsearch.rest.action.support.RestActions.buildBroadcastShardsHeader; +import static org.elasticsearch.rest.action.support.RestActions.splitIndices; /** - * @author kimchy (Shay Banon) + * */ public class RestIndicesStatusAction extends BaseRestHandler { private final SettingsFilter settingsFilter; - @Inject public RestIndicesStatusAction(Settings settings, Client client, RestController controller, - SettingsFilter settingsFilter) { + @Inject + public RestIndicesStatusAction(Settings settings, Client client, RestController controller, + SettingsFilter settingsFilter) { super(settings, client); controller.registerHandler(GET, "/_status", this); controller.registerHandler(GET, "/{index}/_status", this); @@ -53,7 +55,8 @@ public class RestIndicesStatusAction extends BaseRestHandler { this.settingsFilter = settingsFilter; } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { IndicesStatusRequest indicesStatusRequest = new IndicesStatusRequest(splitIndices(request.param("index"))); // we just send back a response, no need to fork a listener indicesStatusRequest.listenerThreaded(false); @@ -66,7 +69,8 @@ public class RestIndicesStatusAction extends BaseRestHandler { } indicesStatusRequest.operationThreading(operationThreading); client.admin().indices().status(indicesStatusRequest, new ActionListener() { - @Override public void onResponse(IndicesStatusResponse response) { + @Override + public void onResponse(IndicesStatusResponse response) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject(); @@ -80,7 +84,8 @@ public class RestIndicesStatusAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/template/delete/RestDeleteIndexTemplateAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/template/delete/RestDeleteIndexTemplateAction.java index dd293784e56..f581da03da0 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/template/delete/RestDeleteIndexTemplateAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/template/delete/RestDeleteIndexTemplateAction.java @@ -32,24 +32,27 @@ import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; -import static org.elasticsearch.common.unit.TimeValue.*; -import static org.elasticsearch.rest.RestStatus.*; +import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; +import static org.elasticsearch.rest.RestStatus.OK; /** - * @author kimchy (shay.banon) + * */ public class RestDeleteIndexTemplateAction extends BaseRestHandler { - @Inject public RestDeleteIndexTemplateAction(Settings settings, Client client, RestController controller) { + @Inject + public RestDeleteIndexTemplateAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(RestRequest.Method.DELETE, "/_template/{name}", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { DeleteIndexTemplateRequest deleteIndexTemplateRequest = new DeleteIndexTemplateRequest(request.param("name")); deleteIndexTemplateRequest.timeout(request.paramAsTime("timeout", timeValueSeconds(10))); client.admin().indices().deleteTemplate(deleteIndexTemplateRequest, new ActionListener() { - @Override public void onResponse(DeleteIndexTemplateResponse response) { + @Override + public void onResponse(DeleteIndexTemplateResponse response) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject() @@ -62,7 +65,8 @@ public class RestDeleteIndexTemplateAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/template/get/RestGetIndexTemplateAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/template/get/RestGetIndexTemplateAction.java index a065e61345d..c3ec9a6f69f 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/template/get/RestGetIndexTemplateAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/template/get/RestGetIndexTemplateAction.java @@ -39,25 +39,27 @@ import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; import java.util.Map; -import static org.elasticsearch.rest.RestRequest.Method.*; -import static org.elasticsearch.rest.RestStatus.*; +import static org.elasticsearch.rest.RestRequest.Method.GET; +import static org.elasticsearch.rest.RestStatus.OK; /** - * @author kimchy (shay.banon) + * */ public class RestGetIndexTemplateAction extends BaseRestHandler { private final SettingsFilter settingsFilter; - @Inject public RestGetIndexTemplateAction(Settings settings, Client client, RestController controller, - SettingsFilter settingsFilter) { + @Inject + public RestGetIndexTemplateAction(Settings settings, Client client, RestController controller, + SettingsFilter settingsFilter) { super(settings, client); this.settingsFilter = settingsFilter; controller.registerHandler(GET, "/_template/{name}", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { ClusterStateRequest clusterStateRequest = Requests.clusterStateRequest() .filterRoutingTable(true) .filterNodes(true) @@ -65,7 +67,8 @@ public class RestGetIndexTemplateAction extends BaseRestHandler { .filteredIndices("_na"); client.admin().cluster().state(clusterStateRequest, new ActionListener() { - @Override public void onResponse(ClusterStateResponse response) { + @Override + public void onResponse(ClusterStateResponse response) { try { MetaData metaData = response.state().metaData(); XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); @@ -109,7 +112,8 @@ public class RestGetIndexTemplateAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/template/put/RestPutIndexTemplateAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/template/put/RestPutIndexTemplateAction.java index b5a97f18eb1..ecc95753559 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/template/put/RestPutIndexTemplateAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/template/put/RestPutIndexTemplateAction.java @@ -30,41 +30,38 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilderString; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.support.XContentMapValues; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestHandler; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.XContentRestResponse; -import org.elasticsearch.rest.XContentThrowableRestResponse; +import org.elasticsearch.rest.*; import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; import java.util.Map; -import static org.elasticsearch.common.unit.TimeValue.*; -import static org.elasticsearch.rest.RestStatus.*; +import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; +import static org.elasticsearch.rest.RestStatus.OK; /** - * @author kimchy (shay.banon) + * */ public class RestPutIndexTemplateAction extends BaseRestHandler { - @Inject public RestPutIndexTemplateAction(Settings settings, Client client, RestController controller) { + @Inject + public RestPutIndexTemplateAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(RestRequest.Method.PUT, "/_template/{name}", this); controller.registerHandler(RestRequest.Method.POST, "/_template/{name}", new CreateHandler()); } final class CreateHandler implements RestHandler { - @Override public void handleRequest(RestRequest request, RestChannel channel) { + @Override + public void handleRequest(RestRequest request, RestChannel channel) { request.params().put("create", "true"); RestPutIndexTemplateAction.this.handleRequest(request, channel); } } @SuppressWarnings({"unchecked"}) - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { PutIndexTemplateRequest putRequest = new PutIndexTemplateRequest(request.param("name")); try { @@ -110,7 +107,8 @@ public class RestPutIndexTemplateAction extends BaseRestHandler { putRequest.order(request.paramAsInt("order", putRequest.order())); client.admin().indices().putTemplate(putRequest, new ActionListener() { - @Override public void onResponse(PutIndexTemplateResponse response) { + @Override + public void onResponse(PutIndexTemplateResponse response) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject() @@ -123,7 +121,8 @@ public class RestPutIndexTemplateAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/bulk/RestBulkAction.java b/src/main/java/org/elasticsearch/rest/action/bulk/RestBulkAction.java index 916607b25af..a7b4e4172d6 100644 --- a/src/main/java/org/elasticsearch/rest/action/bulk/RestBulkAction.java +++ b/src/main/java/org/elasticsearch/rest/action/bulk/RestBulkAction.java @@ -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,18 +32,15 @@ import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilderString; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.XContentRestResponse; -import org.elasticsearch.rest.XContentThrowableRestResponse; +import org.elasticsearch.rest.*; import java.io.IOException; -import static org.elasticsearch.rest.RestRequest.Method.*; -import static org.elasticsearch.rest.RestStatus.*; -import static org.elasticsearch.rest.action.support.RestXContentBuilder.*; +import static org.elasticsearch.rest.RestRequest.Method.POST; +import static org.elasticsearch.rest.RestRequest.Method.PUT; +import static org.elasticsearch.rest.RestStatus.BAD_REQUEST; +import static org.elasticsearch.rest.RestStatus.OK; +import static org.elasticsearch.rest.action.support.RestXContentBuilder.restContentBuilder; /** *

    @@ -54,11 +51,12 @@ import static org.elasticsearch.rest.action.support.RestXContentBuilder.*;
      * { "type1" : { "field1" : "value1" } }
      * 
    * - * @author kimchy (shay.banon) + * */ public class RestBulkAction extends BaseRestHandler { - @Inject public RestBulkAction(Settings settings, Client client, RestController controller) { + @Inject + public RestBulkAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(POST, "/_bulk", this); @@ -69,7 +67,8 @@ public class RestBulkAction extends BaseRestHandler { controller.registerHandler(PUT, "/{index}/{type}/_bulk", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { BulkRequest bulkRequest = Requests.bulkRequest(); String defaultIndex = request.param("index"); String defaultType = request.param("type"); @@ -96,7 +95,8 @@ public class RestBulkAction extends BaseRestHandler { } client.bulk(bulkRequest, new ActionListener() { - @Override public void onResponse(BulkResponse response) { + @Override + public void onResponse(BulkResponse response) { try { XContentBuilder builder = restContentBuilder(request); builder.startObject(); @@ -139,7 +139,8 @@ public class RestBulkAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/count/RestCountAction.java b/src/main/java/org/elasticsearch/rest/action/count/RestCountAction.java index 6b9ba60b134..d755fcc250c 100644 --- a/src/main/java/org/elasticsearch/rest/action/count/RestCountAction.java +++ b/src/main/java/org/elasticsearch/rest/action/count/RestCountAction.java @@ -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,28 +27,27 @@ import org.elasticsearch.client.Client; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.XContentRestResponse; -import org.elasticsearch.rest.XContentThrowableRestResponse; +import org.elasticsearch.rest.*; import org.elasticsearch.rest.action.support.RestActions; import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; -import static org.elasticsearch.action.count.CountRequest.*; -import static org.elasticsearch.rest.RestRequest.Method.*; -import static org.elasticsearch.rest.RestStatus.*; -import static org.elasticsearch.rest.action.support.RestActions.*; +import static org.elasticsearch.action.count.CountRequest.DEFAULT_MIN_SCORE; +import static org.elasticsearch.rest.RestRequest.Method.GET; +import static org.elasticsearch.rest.RestRequest.Method.POST; +import static org.elasticsearch.rest.RestStatus.BAD_REQUEST; +import static org.elasticsearch.rest.RestStatus.OK; +import static org.elasticsearch.rest.action.support.RestActions.buildBroadcastShardsHeader; +import static org.elasticsearch.rest.action.support.RestActions.splitTypes; /** - * @author kimchy (Shay Banon) + * */ public class RestCountAction extends BaseRestHandler { - @Inject public RestCountAction(Settings settings, Client client, RestController controller) { + @Inject + public RestCountAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(POST, "/_count", this); controller.registerHandler(GET, "/_count", this); @@ -58,7 +57,8 @@ public class RestCountAction extends BaseRestHandler { controller.registerHandler(GET, "/{index}/{type}/_count", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { CountRequest countRequest = new CountRequest(RestActions.splitIndices(request.param("index"))); // we just send back a response, no need to fork a listener countRequest.listenerThreaded(false); @@ -97,7 +97,8 @@ public class RestCountAction extends BaseRestHandler { } client.count(countRequest, new ActionListener() { - @Override public void onResponse(CountResponse response) { + @Override + public void onResponse(CountResponse response) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject(); @@ -112,7 +113,8 @@ public class RestCountAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/delete/RestDeleteAction.java b/src/main/java/org/elasticsearch/rest/action/delete/RestDeleteAction.java index 3583b56d646..7309d443a58 100644 --- a/src/main/java/org/elasticsearch/rest/action/delete/RestDeleteAction.java +++ b/src/main/java/org/elasticsearch/rest/action/delete/RestDeleteAction.java @@ -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,32 +30,29 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilderString; import org.elasticsearch.index.VersionType; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.RestStatus; -import org.elasticsearch.rest.XContentRestResponse; -import org.elasticsearch.rest.XContentThrowableRestResponse; +import org.elasticsearch.rest.*; import org.elasticsearch.rest.action.support.RestActions; import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; -import static org.elasticsearch.rest.RestRequest.Method.*; -import static org.elasticsearch.rest.RestStatus.*; +import static org.elasticsearch.rest.RestRequest.Method.DELETE; +import static org.elasticsearch.rest.RestStatus.NOT_FOUND; +import static org.elasticsearch.rest.RestStatus.OK; /** - * @author kimchy (shay.banon) + * */ public class RestDeleteAction extends BaseRestHandler { - @Inject public RestDeleteAction(Settings settings, Client client, RestController controller) { + @Inject + public RestDeleteAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(DELETE, "/{index}/{type}/{id}", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { DeleteRequest deleteRequest = new DeleteRequest(request.param("index"), request.param("type"), request.param("id")); deleteRequest.parent(request.param("parent")); deleteRequest.routing(request.param("routing")); @@ -78,7 +75,8 @@ public class RestDeleteAction extends BaseRestHandler { } client.delete(deleteRequest, new ActionListener() { - @Override public void onResponse(DeleteResponse result) { + @Override + public void onResponse(DeleteResponse result) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject() @@ -99,7 +97,8 @@ public class RestDeleteAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/deletebyquery/RestDeleteByQueryAction.java b/src/main/java/org/elasticsearch/rest/action/deletebyquery/RestDeleteByQueryAction.java index f7260cae5a9..81588388110 100644 --- a/src/main/java/org/elasticsearch/rest/action/deletebyquery/RestDeleteByQueryAction.java +++ b/src/main/java/org/elasticsearch/rest/action/deletebyquery/RestDeleteByQueryAction.java @@ -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,33 +30,32 @@ import org.elasticsearch.client.Client; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.XContentRestResponse; -import org.elasticsearch.rest.XContentThrowableRestResponse; +import org.elasticsearch.rest.*; import org.elasticsearch.rest.action.support.RestActions; import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; -import static org.elasticsearch.rest.RestRequest.Method.*; -import static org.elasticsearch.rest.RestStatus.*; -import static org.elasticsearch.rest.action.support.RestActions.*; +import static org.elasticsearch.rest.RestRequest.Method.DELETE; +import static org.elasticsearch.rest.RestStatus.OK; +import static org.elasticsearch.rest.RestStatus.PRECONDITION_FAILED; +import static org.elasticsearch.rest.action.support.RestActions.splitIndices; +import static org.elasticsearch.rest.action.support.RestActions.splitTypes; /** - * @author kimchy (Shay Banon) + * */ public class RestDeleteByQueryAction extends BaseRestHandler { - @Inject public RestDeleteByQueryAction(Settings settings, Client client, RestController controller) { + @Inject + public RestDeleteByQueryAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(DELETE, "/{index}/_query", this); controller.registerHandler(DELETE, "/{index}/{type}/_query", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { DeleteByQueryRequest deleteByQueryRequest = new DeleteByQueryRequest(splitIndices(request.param("index"))); // we just build a response and send it, no need to fork a thread deleteByQueryRequest.listenerThreaded(false); @@ -93,7 +92,8 @@ public class RestDeleteByQueryAction extends BaseRestHandler { return; } client.deleteByQuery(deleteByQueryRequest, new ActionListener() { - @Override public void onResponse(DeleteByQueryResponse result) { + @Override + public void onResponse(DeleteByQueryResponse result) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject().field("ok", true); @@ -119,7 +119,8 @@ public class RestDeleteByQueryAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/get/RestGetAction.java b/src/main/java/org/elasticsearch/rest/action/get/RestGetAction.java index 6041a332cc2..749cc30c968 100644 --- a/src/main/java/org/elasticsearch/rest/action/get/RestGetAction.java +++ b/src/main/java/org/elasticsearch/rest/action/get/RestGetAction.java @@ -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,30 +27,28 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.XContentRestResponse; -import org.elasticsearch.rest.XContentThrowableRestResponse; +import org.elasticsearch.rest.*; import java.io.IOException; -import static org.elasticsearch.rest.RestRequest.Method.*; -import static org.elasticsearch.rest.RestStatus.*; -import static org.elasticsearch.rest.action.support.RestXContentBuilder.*; +import static org.elasticsearch.rest.RestRequest.Method.GET; +import static org.elasticsearch.rest.RestStatus.NOT_FOUND; +import static org.elasticsearch.rest.RestStatus.OK; +import static org.elasticsearch.rest.action.support.RestXContentBuilder.restContentBuilder; /** - * @author kimchy (Shay Banon) + * */ public class RestGetAction extends BaseRestHandler { - @Inject public RestGetAction(Settings settings, Client client, RestController controller) { + @Inject + public RestGetAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(GET, "/{index}/{type}/{id}", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { final GetRequest getRequest = new GetRequest(request.param("index"), request.param("type"), request.param("id")); // no need to have a threaded listener since we just send back a response getRequest.listenerThreaded(false); @@ -71,7 +69,8 @@ public class RestGetAction extends BaseRestHandler { client.get(getRequest, new ActionListener() { - @Override public void onResponse(GetResponse response) { + @Override + public void onResponse(GetResponse response) { try { XContentBuilder builder = restContentBuilder(request); @@ -86,7 +85,8 @@ public class RestGetAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/get/RestMultiGetAction.java b/src/main/java/org/elasticsearch/rest/action/get/RestMultiGetAction.java index 8637a596258..946f0ae44f6 100644 --- a/src/main/java/org/elasticsearch/rest/action/get/RestMultiGetAction.java +++ b/src/main/java/org/elasticsearch/rest/action/get/RestMultiGetAction.java @@ -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,22 +27,20 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.XContentRestResponse; -import org.elasticsearch.rest.XContentThrowableRestResponse; +import org.elasticsearch.rest.*; import java.io.IOException; -import static org.elasticsearch.rest.RestRequest.Method.*; -import static org.elasticsearch.rest.RestStatus.*; -import static org.elasticsearch.rest.action.support.RestXContentBuilder.*; +import static org.elasticsearch.rest.RestRequest.Method.GET; +import static org.elasticsearch.rest.RestRequest.Method.POST; +import static org.elasticsearch.rest.RestStatus.BAD_REQUEST; +import static org.elasticsearch.rest.RestStatus.OK; +import static org.elasticsearch.rest.action.support.RestXContentBuilder.restContentBuilder; public class RestMultiGetAction extends BaseRestHandler { - @Inject public RestMultiGetAction(Settings settings, Client client, RestController controller) { + @Inject + public RestMultiGetAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(GET, "/_mget", this); controller.registerHandler(POST, "/_mget", this); @@ -52,7 +50,8 @@ public class RestMultiGetAction extends BaseRestHandler { controller.registerHandler(POST, "/{index}/{type}/_mget", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { MultiGetRequest multiGetRequest = new MultiGetRequest(); multiGetRequest.listenerThreaded(false); multiGetRequest.refresh(request.paramAsBoolean("refresh", multiGetRequest.refresh())); @@ -78,7 +77,8 @@ public class RestMultiGetAction extends BaseRestHandler { } client.multiGet(multiGetRequest, new ActionListener() { - @Override public void onResponse(MultiGetResponse response) { + @Override + public void onResponse(MultiGetResponse response) { try { XContentBuilder builder = restContentBuilder(request); response.toXContent(builder, request); @@ -88,7 +88,8 @@ public class RestMultiGetAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/index/RestIndexAction.java b/src/main/java/org/elasticsearch/rest/action/index/RestIndexAction.java index 4472047e1d3..14f702a1cf2 100644 --- a/src/main/java/org/elasticsearch/rest/action/index/RestIndexAction.java +++ b/src/main/java/org/elasticsearch/rest/action/index/RestIndexAction.java @@ -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,28 +30,23 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilderString; import org.elasticsearch.index.VersionType; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestHandler; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.RestStatus; -import org.elasticsearch.rest.XContentRestResponse; -import org.elasticsearch.rest.XContentThrowableRestResponse; +import org.elasticsearch.rest.*; import org.elasticsearch.rest.action.support.RestActions; import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; -import static org.elasticsearch.rest.RestRequest.Method.*; +import static org.elasticsearch.rest.RestRequest.Method.POST; +import static org.elasticsearch.rest.RestRequest.Method.PUT; import static org.elasticsearch.rest.RestStatus.*; /** - * @author kimchy (shay.banon) + * */ public class RestIndexAction extends BaseRestHandler { - @Inject public RestIndexAction(Settings settings, Client client, RestController controller) { + @Inject + public RestIndexAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(POST, "/{index}/{type}", this); // auto id creation controller.registerHandler(PUT, "/{index}/{type}/{id}", this); @@ -61,13 +56,15 @@ public class RestIndexAction extends BaseRestHandler { } final class CreateHandler implements RestHandler { - @Override public void handleRequest(RestRequest request, RestChannel channel) { + @Override + public void handleRequest(RestRequest request, RestChannel channel) { request.params().put("op_type", "create"); RestIndexAction.this.handleRequest(request, channel); } } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { IndexRequest indexRequest = new IndexRequest(request.param("index"), request.param("type"), request.param("id")); indexRequest.routing(request.param("routing")); indexRequest.parent(request.param("parent")); // order is important, set it after routing, so it will set the routing @@ -110,7 +107,8 @@ public class RestIndexAction extends BaseRestHandler { // we don't spawn, then fork if local indexRequest.operationThreaded(true); client.index(indexRequest, new ActionListener() { - @Override public void onResponse(IndexResponse response) { + @Override + public void onResponse(IndexResponse response) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject() @@ -137,7 +135,8 @@ public class RestIndexAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/main/RestMainAction.java b/src/main/java/org/elasticsearch/rest/action/main/RestMainAction.java index edc0ae32c4a..2db12a240cd 100644 --- a/src/main/java/org/elasticsearch/rest/action/main/RestMainAction.java +++ b/src/main/java/org/elasticsearch/rest/action/main/RestMainAction.java @@ -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,34 +19,28 @@ package org.elasticsearch.rest.action.main; +import jsr166y.ThreadLocalRandom; import org.elasticsearch.Version; import org.elasticsearch.client.Client; import org.elasticsearch.common.Classes; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentType; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.RestStatus; -import org.elasticsearch.rest.StringRestResponse; -import org.elasticsearch.rest.XContentRestResponse; -import org.elasticsearch.rest.XContentThrowableRestResponse; +import org.elasticsearch.rest.*; import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; import java.util.List; import java.util.Map; -import static org.elasticsearch.rest.RestRequest.Method.*; +import static org.elasticsearch.rest.RestRequest.Method.GET; +import static org.elasticsearch.rest.RestRequest.Method.HEAD; /** - * @author kimchy (Shay Banon) + * */ public class RestMainAction extends BaseRestHandler { @@ -54,7 +48,8 @@ public class RestMainAction extends BaseRestHandler { private final int quotesSize; - @Inject public RestMainAction(Settings settings, Client client, RestController controller) { + @Inject + public RestMainAction(Settings settings, Client client, RestController controller) { super(settings, client); Map rootNode; int quotesSize; @@ -74,7 +69,8 @@ public class RestMainAction extends BaseRestHandler { controller.registerHandler(HEAD, "/", this); } - @Override public void handleRequest(RestRequest request, RestChannel channel) { + @Override + public void handleRequest(RestRequest request, RestChannel channel) { try { if (request.method() == RestRequest.Method.HEAD) { channel.sendResponse(new StringRestResponse(RestStatus.OK)); diff --git a/src/main/java/org/elasticsearch/rest/action/main/quotes.json b/src/main/java/org/elasticsearch/rest/action/main/quotes.json index 9740cfc638a..bd4f3de4d48 100644 --- a/src/main/java/org/elasticsearch/rest/action/main/quotes.json +++ b/src/main/java/org/elasticsearch/rest/action/main/quotes.json @@ -1,164 +1,164 @@ { - quotes : [ + quotes:[ { - book : "The Hitchhiker's Guide to the Galaxy", - chapter: "Introduction", - text : ["This planet has - or rather had - a problem, which was this: most of the people living on it were unhappy for pretty much all of the time. Many solutions were suggested for this problem, but most of these were largely concerned with the movement of small green pieces of paper, which was odd because on the whole it wasn't the small green pieces of paper that were unhappy."] + book:"The Hitchhiker's Guide to the Galaxy", + chapter:"Introduction", + text:["This planet has - or rather had - a problem, which was this: most of the people living on it were unhappy for pretty much all of the time. Many solutions were suggested for this problem, but most of these were largely concerned with the movement of small green pieces of paper, which was odd because on the whole it wasn't the small green pieces of paper that were unhappy."] }, { - book : "The Hitchhiker's Guide to the Galaxy", - chapter: "Introduction", - text : ["Many were increasingly of the opinion that they'd all made a big mistake in coming down from the trees in the first place. And some said that even the trees had been a bad move, and that no one should ever have left the oceans."] + book:"The Hitchhiker's Guide to the Galaxy", + chapter:"Introduction", + text:["Many were increasingly of the opinion that they'd all made a big mistake in coming down from the trees in the first place. And some said that even the trees had been a bad move, and that no one should ever have left the oceans."] }, { - book : "The Hitchhiker's Guide to the Galaxy", - chapter: "Introduction", - text : ["In many of the more relaxed civilizations on the Outer Eastern Rim of the Galaxy, the Hitch-Hiker's Guide has already supplanted the great Encyclopaedia Galactica as the standard repository of all knowledge and wisdom, for though it has many omissions and contains much that is apocryphal, or at least wildly inaccurate, it scores over the older, more pedestrian work in two important respects.", + book:"The Hitchhiker's Guide to the Galaxy", + chapter:"Introduction", + text:["In many of the more relaxed civilizations on the Outer Eastern Rim of the Galaxy, the Hitch-Hiker's Guide has already supplanted the great Encyclopaedia Galactica as the standard repository of all knowledge and wisdom, for though it has many omissions and contains much that is apocryphal, or at least wildly inaccurate, it scores over the older, more pedestrian work in two important respects.", "First, it is slightly cheaper; and secondly it has the words DON'T PANIC inscribed in large friendly letters on its cover." ] }, { - book : "The Hitchhiker's Guide to the Galaxy", - chapter: "Chapter 1", - text : [ + book:"The Hitchhiker's Guide to the Galaxy", + chapter:"Chapter 1", + text:[ "\"Some factual information for you. Have you any idea how much damage that bulldozer would suffer if I just let it roll straight over you?\"", "\"How much?\" said Arthur.", "\"None at all,\" said Mr Prosser." ] }, { - book : "The Hitchhiker's Guide to the Galaxy", - chapter: "Chapter 1", - text : [ + book:"The Hitchhiker's Guide to the Galaxy", + chapter:"Chapter 1", + text:[ "\"The mere thought,\" growled Mr. Prosser, \"hadn't even begun to speculate,\" he continued, settling himself back, \"about the merest possibility of crossing my mind.\"" ] }, { - book : "The Hitchhiker's Guide to the Galaxy", - chapter: "Chapter 2", - text : [ + book:"The Hitchhiker's Guide to the Galaxy", + chapter:"Chapter 2", + text:[ "[The Guide] says that the best drink in existence is the Pan Galactic Gargle Blaster. It says that the effect of a Pan Galactic Gargle Blaster is like having your brains smashed out by a slice of lemon wrapped round a large gold brick." ] }, { - book : "The Hitchhiker's Guide to the Galaxy", - chapter: "Chapter 2", - text : [ + book:"The Hitchhiker's Guide to the Galaxy", + chapter:"Chapter 2", + text:[ "\"Time is an illusion. Lunchtime doubly so.\"", "\"Very deep,\" said Arthur, \"you should send that in to the Reader's Digest. They've got a page for people like you.\"" ] }, { - book : "The Hitchhiker's Guide to the Galaxy", - chapter: "Chapter 2", - text : [ + book:"The Hitchhiker's Guide to the Galaxy", + chapter:"Chapter 2", + text:[ "\"This must be Thursday,\" said Arthur to himself, sinking low over his beer, \"I never could get the hang of Thursdays.\"" ] }, { - book : "The Hitchhiker's Guide to the Galaxy", - chapter: "Chapter 3", - text : [ + book:"The Hitchhiker's Guide to the Galaxy", + chapter:"Chapter 3", + text:[ "The ships hung in the sky in much the same way that bricks don't." ] }, { - book : "The Hitchhiker's Guide to the Galaxy", - chapter: "Chapter 5", - text : [ + book:"The Hitchhiker's Guide to the Galaxy", + chapter:"Chapter 5", + text:[ "One of the things Ford Prefect had always found hardest to understand about humans was their habit of continually stating and repeating the very very obvious, as in It's a nice day, or You're very tall, or Oh dear you seem to have fallen down a thirty-foot well, are you alright? At first Ford had formed a theory to account for this strange behaviour. If human beings don't keep exercising their lips, he thought, their mouths probably seize up. After a few months' consideration and observation he abandoned this theory in favour of a new one. If they don't keep on exercising their lips, he thought, their brains start working. After a while he abandoned this one as well as being obstructively cynical." ] }, { - book : "The Hitchhiker's Guide to the Galaxy", - chapter: "Chapter 7", - text : [ + book:"The Hitchhiker's Guide to the Galaxy", + chapter:"Chapter 7", + text:[ "\"You know,\" said Arthur, \"it's at times like this, when I'm trapped in a Vogon airlock with a man from Betelgeuse, and about to die of asphyxiation in deep space that I really wish I'd listened to what my mother told me when I was young.\"", "\"Why, what did she tell you?\"", "\"I don't know, I didn't listen.\"" ] }, { - book : "The Hitchhiker's Guide to the Galaxy", - chapter: "Chapter 8", - text : [ + book:"The Hitchhiker's Guide to the Galaxy", + chapter:"Chapter 8", + text:[ "\"Space,\" it says, \"is big. Really big. You just won't believe how vastly hugely mindbogglingly big it is. I mean you may think it's a long way down the road to the chemist, but that's just peanuts to space, LISTEN!\" and so on..." ] }, { - book : "The Hitchhiker's Guide to the Galaxy", - chapter: "Chapter 9", - text : [ + book:"The Hitchhiker's Guide to the Galaxy", + chapter:"Chapter 9", + text:[ "Arthur looked up. \"Ford!\" he said, \"there's an infinite number of monkeys outside who want to talk to us about this script for Hamlet they've worked out.\"" ] }, { - book : "The Hitchhiker's Guide to the Galaxy", - chapter: "Chapter 9", - text : [ + book:"The Hitchhiker's Guide to the Galaxy", + chapter:"Chapter 9", + text:[ "\"Ford,\" he said, \"you're turning into a penguin. Stop it\"" ] }, { - book : "The Hitchhiker's Guide to the Galaxy", - chapter: "Chapter 9", - text : [ + book:"The Hitchhiker's Guide to the Galaxy", + chapter:"Chapter 9", + text:[ "\"But that's not the point!\" raged Ford \"The point is that I am now a perfectly safe penguin, and my colleague here is rapidly running out of limbs!\"" ] }, { - book : "The Hitchhiker's Guide to the Galaxy", - chapter: "Chapter 11", - text : [ + book:"The Hitchhiker's Guide to the Galaxy", + chapter:"Chapter 11", + text:[ "\"Five to one against and falling...\" she said, \"four to one against and falling...three to one...two...one...probability factor of one to one...we have normality, I repeat we have normality.\" She turned her microphone off – then turned it back on, with a slight smile and continued: \"Anything you still can’t cope with is therefore your own problem.\"" ] }, { - book : "The Hitchhiker's Guide to the Galaxy", - chapter: "Chapter 11", - text : [ + book:"The Hitchhiker's Guide to the Galaxy", + chapter:"Chapter 11", + text:[ "\"I think you ought to know I'm feeling very depressed,\" Marvin said." ] }, { - book : "The Hitchhiker's Guide to the Galaxy", - chapter: "Chapter 11", - text : [ + book:"The Hitchhiker's Guide to the Galaxy", + chapter:"Chapter 11", + text:[ "He reached out and pressed an invitingly large red button on a nearby panel. The panel lit up with the words Please do not press this button again." ] }, { - book : "The Hitchhiker's Guide to the Galaxy", - chapter: "Chapter 11", - text : [ + book:"The Hitchhiker's Guide to the Galaxy", + chapter:"Chapter 11", + text:[ "\"All the doors in this spaceship have a cheerful and sunny disposition. It is their pleasure to open for you, and their satisfaction to close again with the knowledge of a job well done.\"" ] }, { - book : "The Hitchhiker's Guide to the Galaxy", - chapter: "Chapter 11", - text : [ + book:"The Hitchhiker's Guide to the Galaxy", + chapter:"Chapter 11", + text:[ "\"Come on,\" he droned, \"I've been ordered to take you down to the bridge. Here I am, brain the size of a planet and they ask me to take you down to the bridge. Call that job satisfaction? 'Cos I don't.\"" ] }, { - book : "The Hitchhiker's Guide to the Galaxy", - chapter: "Chapter 11", - text : [ + book:"The Hitchhiker's Guide to the Galaxy", + chapter:"Chapter 11", + text:[ "\"Sorry, did I say something wrong?\" said Marvin, dragging himself on regardless. \"Pardon me for breathing, which I never do anyway so I don't know why I bother to say it, oh God I'm so depressed. Here's another one of those self-satisfied doors. Life! Don't talk to me about life.\"" ] }, { - book : "The Hitchhiker's Guide to the Galaxy", - chapter: "Chapter 12", - text : [ + book:"The Hitchhiker's Guide to the Galaxy", + chapter:"Chapter 12", + text:[ "If there's anything bigger than my ego around, I want it caught and shot now." ] }, { - book : "The Hitchhiker's Guide to the Galaxy", - chapter: "Chapter 13", - text : [ + book:"The Hitchhiker's Guide to the Galaxy", + chapter:"Chapter 13", + text:[ "Marvin trudged on down the corridor, still moaning.", "\"...and then of course I've got this terrible pain in all the diodes down my left hand side...\"", "\"No?\" said Arthur grimly as he walked along beside him. \"Really?\"", @@ -167,60 +167,60 @@ ] }, { - book : "The Hitchhiker's Guide to the Galaxy", - chapter: "Chapter 16", - text : [ + book:"The Hitchhiker's Guide to the Galaxy", + chapter:"Chapter 16", + text:[ "Isn’t it enough to see that a garden is beautiful without having to believe that there are fairies at the bottom of it too?" ] }, { - book : "The Hitchhiker's Guide to the Galaxy", - chapter: "Chapter 17", - text : [ + book:"The Hitchhiker's Guide to the Galaxy", + chapter:"Chapter 17", + text:[ "He had found a Nutri-Matic machine which had provided him with a plastic cup filled with a liquid that was almost, but not quite, entirely unlike tea." ] }, { - book : "The Hitchhiker's Guide to the Galaxy", - chapter: "Chapter 18", - text : [ + book:"The Hitchhiker's Guide to the Galaxy", + chapter:"Chapter 18", + text:[ "Curiously enough, the only thing that went through the mind of the bowl of petunias as it fell was Oh no, not again. Many people have speculated that if we knew exactly why the bowl of petunias had thought that we would know a lot more about the nature of the Universe than we do now." ] }, { - book : "The Hitchhiker's Guide to the Galaxy", - chapter: "Chapter 20", - text : [ + book:"The Hitchhiker's Guide to the Galaxy", + chapter:"Chapter 20", + text:[ "\"Life,\" said Marvin dolefully, \"loathe it or ignore it, you can't like it.\"" ] }, { - book : "The Hitchhiker's Guide to the Galaxy", - chapter: "Chapter 23", - text : [ + book:"The Hitchhiker's Guide to the Galaxy", + chapter:"Chapter 23", + text:[ "For instance, on the planet Earth, man had always assumed that he was more intelligent than dolphins because he had achieved so much - the wheel, New York, wars and so on - whilst all the dolphins had ever done was muck about in the water having a good time. But conversely, the dolphins had always believed that they were far more intelligent than man - for precisely the same reasons.", "The last ever dolphin message was misinterpreted as a surprisingly sophisticated attempt to do a double-backwards-somersault through a hoop whilst whistling the 'Star Spangled Banner', but in fact the message was this: So long and thanks for all the fish." ] }, { - book : "The Hitchhiker's Guide to the Galaxy", - chapter: "Chapter 24", - text : [ + book:"The Hitchhiker's Guide to the Galaxy", + chapter:"Chapter 24", + text:[ "Looking up into the night sky is looking into infinity - distance is incomprehensible and therefore meaningless." ] }, { - book : "The Hitchhiker's Guide to the Galaxy", - chapter: "Chapter 27", - text : [ + book:"The Hitchhiker's Guide to the Galaxy", + chapter:"Chapter 27", + text:[ "\"Forty-two,\" said Deep Thought, with infinite majesty and calm.", "\"The Answer to the Great Question, of Life, the Universe and Everything\"" ] }, { - book : "The Hitchhiker's Guide to the Galaxy", - chapter: "Chapter 30", - text : [ + book:"The Hitchhiker's Guide to the Galaxy", + chapter:"Chapter 30", + text:[ "\"The chances of finding out what's really going on in the universe are so remote, the only thing to do is hang the sense of it and keep yourself occupied. Look at me, I design fjords. I'd far rather be happy than right any day.\"", "\"And are you?\"", "\"No, that's where it all falls apart I'm afraid.\"", @@ -228,65 +228,65 @@ ] }, { - book : "The Hitchhiker's Guide to the Galaxy", - chapter: "Chapter 34", - text : [ + book:"The Hitchhiker's Guide to the Galaxy", + chapter:"Chapter 34", + text:[ "\"What's up?\"", "\"I don't know,\" said Marvin, \"I've never been there.\"" ] }, { - book : "The Hitchhiker's Guide to the Galaxy", - chapter: "Chapter 35", - text : [ + book:"The Hitchhiker's Guide to the Galaxy", + chapter:"Chapter 35", + text:[ "It said: \"The History of every major Galactic Civilization tends to pass through three distinct and recognizable phases, those of Survival, Inquiry and Sophistication, otherwise known as the How, Why and Where phases.", "\"For instance, the first phase is characterized by the question How can we eat? the second by the question Why do we eat? and the third by the question Where shall we have lunch?\"" ] }, { - book : "The Restaurant at the End of the Universe", - chapter: "Preface", - text : [ + book:"The Restaurant at the End of the Universe", + chapter:"Preface", + text:[ "There is a theory which states that if ever anyone discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable.", "There is another theory which states that this has already happened." ] }, { - book : "The Restaurant at the End of the Universe", - chapter: "Chapter 1", - text : [ + book:"The Restaurant at the End of the Universe", + chapter:"Chapter 1", + text:[ "The story so far:", "In the beginning the Universe was created.", "This has made a lot of people very angry and has been widely regarded as a bad move." ] }, { - book : "The Restaurant at the End of the Universe", - chapter: "Chapter 2", - text : [ + book:"The Restaurant at the End of the Universe", + chapter:"Chapter 2", + text:[ "\"Share and Enjoy\" is the company motto of the hugely successful Sirius Cybernetics Corporation Complaints division, which now covers the major land masses of three medium sized planets and is the only part of the Corporation to have shown a consistent profit in recent years." ] }, { - book : "The Restaurant at the End of the Universe", - chapter: "Chapter 2", - text : [ + book:"The Restaurant at the End of the Universe", + chapter:"Chapter 2", + text:[ "The protruding upper halves of the letters now appear, in the local language, to read \"Go stick your head in a pig\", and are no longer illuminated, except at times of special celebration." ] }, { - book : "The Restaurant at the End of the Universe", - chapter: "Chapter 3", - text : [ + book:"The Restaurant at the End of the Universe", + chapter:"Chapter 3", + text:[ "Quite how Zaphod Beeblebrox arrived at the idea of holding a seance at this point is something he was never quite clear on.", "Obviously the subject of death was in the air, but more as something to be avoided than harped upon.", "Possibly the horror that Zaphod experienced at the prospect of being reunited with his deceased relatives led on to the thought that they might just feel the same way about him and, what's more, be able to do something about helping to postpone this reunion." ] }, { - book : "The Restaurant at the End of the Universe", - chapter: "Chapter 3", - text : [ + book:"The Restaurant at the End of the Universe", + chapter:"Chapter 3", + text:[ "\"Concentrate,\" hissed Zaphod, \"on his name.\"", "\"What is it?\" asked Arthur.", "\"Zaphod Beeblebrox the Fourth.\"", @@ -299,44 +299,44 @@ ] }, { - book : "The Restaurant at the End of the Universe", - chapter: "Chapter 6", - text : [ + book:"The Restaurant at the End of the Universe", + chapter:"Chapter 6", + text:[ "The Guide is definitive. Reality is frequently inaccurate." ] }, { - book : "The Restaurant at the End of the Universe", - chapter: "Chapter 6", - text : [ + book:"The Restaurant at the End of the Universe", + chapter:"Chapter 6", + text:[ "\"Listen, three eyes,\" he said, \"don't you try to outweird me, I get stranger things than you free with my breakfast cereal.\"" ] }, { - book : "The Restaurant at the End of the Universe", - chapter: "Chapter 17", - text : [ + book:"The Restaurant at the End of the Universe", + chapter:"Chapter 17", + text:[ "I am the main Dish of the Day. May I interest you in parts of my body?" ] }, { - book : "The Restaurant at the End of the Universe", - chapter: "Chapter 17", - text : [ + book:"The Restaurant at the End of the Universe", + chapter:"Chapter 17", + text:[ "Shee, you guys are so unhip it's a wonder your bums don't fall off." ] }, { - book : "The Restaurant at the End of the Universe", - chapter: "Chapter 18", - text : [ + book:"The Restaurant at the End of the Universe", + chapter:"Chapter 18", + text:[ "\"The first ten million years were the worst,\" said Marvin, \"and the second ten million years, they were the worst too. The third ten million years I didn't enjoy at all. After that I went into a bit of a decline.\"" ] }, { - book : "The Restaurant at the End of the Universe", - chapter: "Chapter 18", - text : [ + book:"The Restaurant at the End of the Universe", + chapter:"Chapter 18", + text:[ "\"Er...\" he said, \"hello. Er, look, I'm sorry I'm a bit late. I've had the most ghastly time, all sorts of things cropping up at the last moment.\"", "He seemed nervous of the expectant awed hush. He cleared his throat.", "\"Er, how are we for time?\" he said, \"have I just got a min—\"", @@ -344,52 +344,52 @@ ] }, { - book : "The Restaurant at the End of the Universe", - chapter: "Chapter 19", - text : [ + book:"The Restaurant at the End of the Universe", + chapter:"Chapter 19", + text:[ "It is known that there are an infinite number of worlds, simply because there is an infinite amount of space for them to be in. However, not every one of them is inhabited. Therefore, there must be a finite number of inhabited worlds. Any finite number divided by infinity is as near to nothing as makes no odds, so the average population of all the planets in the Universe can be said to be zero. From this it follows that the population of the whole Universe is also zero, and that any people you may meet from time to time are merely the products of a deranged imagination." ] }, { - book : "The Restaurant at the End of the Universe", - chapter: "Chapter 20", - text : [ + book:"The Restaurant at the End of the Universe", + chapter:"Chapter 20", + text:[ "The ship was rocking and swaying sickeningly as Ford and Zaphod tried to wrest control from the autopilot. The engines howled and whined like tired children in a supermarket." ] }, { - book : "The Restaurant at the End of the Universe", - chapter: "Chapter 22", - text : [ + book:"The Restaurant at the End of the Universe", + chapter:"Chapter 22", + text:[ "The trouble with most forms of transport, he thought, is basically one of them not being worth all the bother. On Earth – when there had been an Earth, before it was demolished to make way for a new hyperspace bypass – the problem had been with cars. The disadvantages involved in pulling lots of black sticky slime from out of the ground where it had been safely hidden out of harm's way, turning it into tar to cover the land with, smoke to fill the air with and pouring the rest into the sea, all seemed to outweigh the advantages of being able to get more quickly from one place to another – particularly when the place you arrived at had probably become, as a result of this, very similar to the place you had left, i.e. covered with tar, full of smoke and short of fish." ] }, { - book : "The Restaurant at the End of the Universe", - chapter: "Chapter 23", - text : [ + book:"The Restaurant at the End of the Universe", + chapter:"Chapter 23", + text:[ "The designer of the gun had clearly not been instructed to beat about the bush. \"Make it evil,\" he'd been told. \"Make it totally clear that this gun has a right end and a wrong end. Make it totally clear to anyone standing at the wrong end that things are going badly for them. If that means sticking all sort of spikes and prongs and blackened bits all over it then so be it. This is not a gun for hanging over the fireplace or sticking in the umbrella stand, it is a gun for going out and making people miserable with.\"" ] }, { - book : "The Restaurant at the End of the Universe", - chapter: "Chapter 28", - text : [ + book:"The Restaurant at the End of the Universe", + chapter:"Chapter 28", + text:[ "The major problem — one of the major problems, for there are several — one of the many major problems with governing people is that of whom you get to do it; or rather of who manages to get people to let them do it to them.", "To summarize: it is a well known fact that those people who most want to rule people are, ipso facto, those least suited to do it. To summarize the summary: anyone who is capable of getting themselves made President should on no account be allowed to do the job. To summarize the summary of the summary: people are a problem." ] }, { - book : "The Restaurant at the End of the Universe", - chapter: "Chapter 29", - text : [ + book:"The Restaurant at the End of the Universe", + chapter:"Chapter 29", + text:[ "\"How can I tell,\" said the man, \"that the past isn't a fiction designed to account for the discrepancy between my immediate physical sensations and my state of mind?\"" ] }, { - book : "The Restaurant at the End of the Universe", - chapter: "Chapter 32", - text : [ + book:"The Restaurant at the End of the Universe", + chapter:"Chapter 32", + text:[ "\"Well, you’re obviously being totally naive of course\", said the girl, \"When you’ve been in marketing as long as I have, you'll know that before any new product can be developed it has to be properly researched. We’ve got to find out what people want from fire, how they relate to it, what sort of image it has for them.\"", "The crowd were tense. They were expecting something wonderful from Ford.", "\"Stick it up your nose,\" he said.", @@ -397,9 +397,9 @@ ] }, { - book : "The Restaurant at the End of the Universe", - chapter: "Chapter 32", - text : [ + book:"The Restaurant at the End of the Universe", + chapter:"Chapter 32", + text:[ "\"And the wheel,\" said the Captain, \"What about this wheel thingy? It sounds a terribly interesting project.\"", "\"Ah,\" said the marketing girl, \"Well, we're having a little difficulty there.\"", "\"Difficulty?\" exclaimed Ford. \"Difficulty? What do you mean, difficulty? It's the single simplest machine in the entire Universe!\"", @@ -408,23 +408,23 @@ ] }, { - book : "Life, the Universe and Everything", - chapter: "Chapter 1", - text : [ + book:"Life, the Universe and Everything", + chapter:"Chapter 1", + text:[ "The regular early morning yell of horror was the sound of Arthur Dent waking up and suddenly remembering where he was." ] }, { - book : "Life, the Universe and Everything", - chapter: "Chapter 1", - text : [ + book:"Life, the Universe and Everything", + chapter:"Chapter 1", + text:[ "In the end, it was the Sunday afternoons he couldn't cope with, and that terrible listlessness that starts to set in about 2:55, when you know you’ve taken all the baths that you can usefully take that day, that however hard you stare at any given paragraph in the newspaper you will never actually read it, or use the revolutionary new pruning technique it describes, and that as you stare at the clock the hands will move relentlessly on to four o’clock, and you will enter the long dark teatime of the soul." ] }, { - book : "Life, the Universe and Everything", - chapter: "Chapter 2", - text : [ + book:"Life, the Universe and Everything", + chapter:"Chapter 2", + text:[ "\"Africa was very interesting,\" said Ford, \"I behaved very oddly there.\" [...] \"I took up being cruel to animals,\" he said airily. \"But only,\" he added, \"as a hobby.\"", "\"Oh yes,\" said Arthur, warily.", "\"Yes,\" Ford assured him. \"I won't disturb you with the details because they would—\"", @@ -433,16 +433,16 @@ ] }, { - book : "Life, the Universe and Everything", - chapter: "Chapter 2", - text : [ + book:"Life, the Universe and Everything", + chapter:"Chapter 2", + text:[ "He gazed keenly into the distance and looked as if he would quite like the wind to blow his hair back dramatically at that point, but the wind was busy fooling around with some leaves a little way off." ] }, { - book : "Life, the Universe and Everything", - chapter: "Chapter 2", - text : [ + book:"Life, the Universe and Everything", + chapter:"Chapter 2", + text:[ "\"I have detected,\" he said, \"disturbances in the wash.\" [...]", "\"The wash?\" said Arthur.", "\"The space-time wash,\" said Ford. [...]", @@ -454,9 +454,9 @@ ] }, { - book : "Life, the Universe and Everything", - chapter: "Chapter 2", - text : [ + book:"Life, the Universe and Everything", + chapter:"Chapter 2", + text:[ "\"There!\" said Ford, shooting out his arm. \"There, behind that sofa!\"", "Arthur looked. Much to his surprise, there was a velvet paisley-covered Chesterfield sofa in the field in front of them. He boggled intelligently at it. Shrewd questions sprang into his mind.", "\"Why,\" he said, \"is there a sofa in that field?\"", @@ -465,38 +465,38 @@ ] }, { - book : "Life, the Universe and Everything", - chapter: "Chapter 6", - text : [ + book:"Life, the Universe and Everything", + chapter:"Chapter 6", + text:[ "\"My doctor says that I have a malformed public-duty gland and a natural deficiency in moral fibre,\" Ford muttered to himself, \"and that I am therefore excused from saving Universes.\"" ] }, { - book : "Life, the Universe and Everything", - chapter: "Chapter 9", - text : [ + book:"Life, the Universe and Everything", + chapter:"Chapter 9", + text:[ "There is a moment in every dawn when light floats, there is the possibility of magic. Creation holds its breath.", "The moment passed as it regularly did on Squornshellous Zeta, without incident." ] }, { - book : "Life, the Universe and Everything", - chapter: "Chapter 9", - text : [ + book:"Life, the Universe and Everything", + chapter:"Chapter 9", + text:[ "Very few things actually get manufactured these days, because in an infinitely large Universe such as, for instance, the one in which we live, most things one could possibly imagine, and a lot of things one would rather not, grow somewhere." ] }, { - book : "Life, the Universe and Everything", - chapter: "Chapter 9", - text : [ + book:"Life, the Universe and Everything", + chapter:"Chapter 9", + text:[ "\"My capacity for happiness,\" he added, \"you could fit into a matchbox without taking out the matches first.\" —Marvin" ] }, { - book : "Life, the Universe and Everything", - chapter: "Chapter 9", - text : [ + book:"Life, the Universe and Everything", + chapter:"Chapter 9", + text:[ "\"You may not instantly see why I bring the subject up, but that is because my mind works so phenomenally fast, and I am at a rough estimate thirty billion times more intelligent than you. Let me give you an example. Think of a number, any number.\"", "\"Er, five,\" said the mattress.", "\"Wrong,\" said Marvin. \"You see?\"", @@ -504,16 +504,16 @@ ] }, { - book : "Life, the Universe and Everything", - chapter: "Chapter 9", - text : [ + book:"Life, the Universe and Everything", + chapter:"Chapter 9", + text:[ "\"I would like to say that it is a very great pleasure, honour and privilege for me to open this bridge, but I can't because my lying circuits are all out of commission.\" —Marvin" ] }, { - book : "Life, the Universe and Everything", - chapter: "Chapter 11", - text : [ + book:"Life, the Universe and Everything", + chapter:"Chapter 11", + text:[ "[...] the renewed shock had nearly made him spill his drink. He drained it quickly before anything serious happened to it. He then had another quick one to follow the first one down and check that it was all right.", "\"Freedom,\" he said aloud.", "Trillian came on to the bridge at that point and said several enthusiastic things on the subject of freedom.", @@ -523,52 +523,52 @@ ] }, { - book : "Life, the Universe and Everything", - chapter: "Chapter 11", - text : [ + book:"Life, the Universe and Everything", + chapter:"Chapter 11", + text:[ "There is an art, it says, or rather, a knack to flying. The knack lies in learning how to throw yourself at the ground and miss. [...] Clearly, it is this second part, the missing, which presents the difficulties." ] }, { - book : "Life, the Universe and Everything", - chapter: "Chapter 11", - text : [ + book:"Life, the Universe and Everything", + chapter:"Chapter 11", + text:[ "He sat up sharply and started to pull clothes on. He decided that there must be someone in the Universe feeling more wretched, miserable and forsaken than himself, and he determined to set out and find him.", "Halfway to the bridge it occurred to him that it might be Marvin, and he returned to bed." ] }, { - book : "Life, the Universe and Everything", - chapter: "Chapter 18", - text : [ + book:"Life, the Universe and Everything", + chapter:"Chapter 18", + text:[ "They obstinately persisted in their absence." ] }, { - book : "Life, the Universe and Everything", - chapter: "Chapter 24", - text : [ + book:"Life, the Universe and Everything", + chapter:"Chapter 24", + text:[ "It is a mistake to think you can solve any major problems just with potatoes." ] }, { - book : "Life, the Universe and Everything", - chapter: "Chapter 31", - text : [ + book:"Life, the Universe and Everything", + chapter:"Chapter 31", + text:[ "\"That young girl,\" Marvin added unexpectedly, \"is one of the least benightedly unintelligent organic life forms it has been my profound lack of pleasure not to be able to avoid meeting.\"" ] }, { - book : "Life, the Universe and Everything", - chapter: "Chapter 33", - text : [ + book:"Life, the Universe and Everything", + chapter:"Chapter 33", + text:[ "He hoped and prayed that there wasn't an afterlife. Then he realized there was a contradiction involved here and merely hoped that there wasn't an afterlife." ] }, { - book : "So Long And Thanks for All the Fish", - chapter: "Prologue", - text : [ + book:"So Long And Thanks for All the Fish", + chapter:"Prologue", + text:[ "Many were increasingly of the opinion that they'd all made a big mistake in coming down from the trees in the first place. And some said that even the trees had been a bad move, and that no one should ever have left the oceans.", "And then, one Thursday, nearly two thousand years after one man had been nailed to a tree for saying how great it would be to be nice to people for a change, a girl sitting on her own in a small café in Rickmansworth suddenly realized what it was that had been going wrong all this time, and she finally knew how the world could be made a good and happy place. This time it was right, it would work, and no one would have to get nailed to anything.", "Sadly, however, before she could get to a phone to tell anyone about it, the Earth was unexpectedly demolished to make way for a new hyperspace bypass, and so the idea was lost, seemingly for ever.", @@ -576,9 +576,9 @@ ] }, { - book : "So Long And Thanks for All the Fish", - chapter: "Chapter 21", - text : [ + book:"So Long And Thanks for All the Fish", + chapter:"Chapter 21", + text:[ "The problem is, or rather one of the problems, for there are many, a sizeable proportion of which are continually clogging up the civil, commercial, and criminal courts in all areas of the Galaxy, and especially, where possible, the more corrupt ones, this.", "The previous sentence makes sense. That is not the problem.", "This is:", @@ -587,65 +587,65 @@ ] }, { - book : "So Long And Thanks for All the Fish", - chapter: "Chapter 23", - text : [ + book:"So Long And Thanks for All the Fish", + chapter:"Chapter 23", + text:[ "Ford: \"Life,\" he said, \"is like a grapefruit.\"", "Creature:\"Er, how so?\"", "Ford: \"Well, it's sort of orangey-yellow and dimpled on the outside, wet and squidgy in the middle. It's got pips inside, too. Oh, and some people have half a one for breakfast.\"" ] }, { - book : "So Long And Thanks for All the Fish", - chapter: "Chapter 25", - text : [ + book:"So Long And Thanks for All the Fish", + chapter:"Chapter 25", + text:[ "\"This Arthur Dent,\" comes the cry from the furthest reaches of the galaxy, and has even now been found inscribed on a mysterious deep space probe thought to originate from an alien galaxy at a distance too hideous to contemplate, \"what is he, man or mouse? Is he interested in nothing more than tea and the wider issues of life? Has he no spirit? has he no passion? Does he not, to put it in a nutshell, fuck?\"", "Those who wish to know should read on. Others may wish to skip on to the last chapter which is a good bit and has Marvin in it." ] }, { - book : "So Long And Thanks for All the Fish", - chapter: "Chapter 31", - text : [ + book:"So Long And Thanks for All the Fish", + chapter:"Chapter 31", + text:[ "The sign said:", "Hold stick near centre of its length. Moisten pointed end in mouth. Insert in tooth space, blunt end next to gum. Use gentle in-out motion.", "It seemed to me,\" said Wonko the Sane, \"that any civilization that had so far lost its head as to need to include a set of detailed instructions for use in a packet of toothpicks, was no longer a civilization in which I could live and stay sane.\"" ] }, { - book : "So Long And Thanks for All the Fish", - chapter: "Chapter 35", - text : [ + book:"So Long And Thanks for All the Fish", + chapter:"Chapter 35", + text:[ "The Hitchhiker's Guide to the Galaxy [...] says of the Sirius Cybernetics Corporation products that \"it is very easy to be blinded to the essential uselessness of them by the sense of achievement you get from getting them to work at all.\"" ] }, { - book : "So Long And Thanks for All the Fish", - chapter: "Chapter 40", - text : [ + book:"So Long And Thanks for All the Fish", + chapter:"Chapter 40", + text:[ "\"So much time,\" it groaned, \"oh so much time. And pain as well, so much of that, and so much time to suffer it in too. One or the other on its own I could probably manage. It's the two together that really get me down.\"" ] }, { - book : "So Long And Thanks for All the Fish", - chapter: "Chapter 40", - text : [ + book:"So Long And Thanks for All the Fish", + chapter:"Chapter 40", + text:[ "\"Ha!\" snapped Marvin. \"Ha!\" he repeated. \"What do you know of always? You say 'always' to me, who, because of the silly little errands your organic lifeforms keep on sending me through time on, am now thirty-seven times older than the Universe itself? Pick your words with a little more care,\" he coughed, \"and tact.\"" ] }, { - book : "So Long And Thanks for All the Fish", - chapter: "Chapter 40", - text : [ + book:"So Long And Thanks for All the Fish", + chapter:"Chapter 40", + text:[ "\"We apologise for the inconvenience.\" God's Final Message to His Creation, written in letters of fire on the side of the Quentulus Quazgar Mountains.", "\"I think,\" Marvin murmured at last, from deep within his corroding rattling thorax, \"I feel good about it.\"", "The lights went out in his eyes for absolutely the very last time ever." ] }, { - book : "So Long And Thanks for All the Fish", - chapter: "Epilogue", - text : [ + book:"So Long And Thanks for All the Fish", + chapter:"Epilogue", + text:[ "There was a point to this story, but it has temporarily escaped the chronicler's mind." ] } diff --git a/src/main/java/org/elasticsearch/rest/action/mlt/RestMoreLikeThisAction.java b/src/main/java/org/elasticsearch/rest/action/mlt/RestMoreLikeThisAction.java index f00599b830b..443dcc881af 100644 --- a/src/main/java/org/elasticsearch/rest/action/mlt/RestMoreLikeThisAction.java +++ b/src/main/java/org/elasticsearch/rest/action/mlt/RestMoreLikeThisAction.java @@ -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,34 +27,33 @@ import org.elasticsearch.client.Client; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.XContentRestResponse; -import org.elasticsearch.rest.XContentThrowableRestResponse; +import org.elasticsearch.rest.*; import org.elasticsearch.search.Scroll; import java.io.IOException; -import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.common.unit.TimeValue.*; -import static org.elasticsearch.rest.RestRequest.Method.*; -import static org.elasticsearch.rest.RestStatus.*; -import static org.elasticsearch.rest.action.support.RestXContentBuilder.*; +import static org.elasticsearch.client.Requests.moreLikeThisRequest; +import static org.elasticsearch.common.unit.TimeValue.parseTimeValue; +import static org.elasticsearch.rest.RestRequest.Method.GET; +import static org.elasticsearch.rest.RestRequest.Method.POST; +import static org.elasticsearch.rest.RestStatus.BAD_REQUEST; +import static org.elasticsearch.rest.RestStatus.OK; +import static org.elasticsearch.rest.action.support.RestXContentBuilder.restContentBuilder; /** - * @author kimchy (shay.banon) + * */ public class RestMoreLikeThisAction extends BaseRestHandler { - @Inject public RestMoreLikeThisAction(Settings settings, Client client, RestController controller) { + @Inject + public RestMoreLikeThisAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(GET, "/{index}/{type}/{id}/_mlt", this); controller.registerHandler(POST, "/{index}/{type}/{id}/_mlt", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { MoreLikeThisRequest mltRequest = moreLikeThisRequest(request.param("index")).type(request.param("type")).id(request.param("id")); try { mltRequest.fields(request.paramAsStringArray("mlt_fields", null)); @@ -97,7 +96,8 @@ public class RestMoreLikeThisAction extends BaseRestHandler { } client.moreLikeThis(mltRequest, new ActionListener() { - @Override public void onResponse(SearchResponse response) { + @Override + public void onResponse(SearchResponse response) { try { XContentBuilder builder = restContentBuilder(request); builder.startObject(); @@ -109,7 +109,8 @@ public class RestMoreLikeThisAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/percolate/RestPercolateAction.java b/src/main/java/org/elasticsearch/rest/action/percolate/RestPercolateAction.java index a29de1e39b1..06da3a722d2 100644 --- a/src/main/java/org/elasticsearch/rest/action/percolate/RestPercolateAction.java +++ b/src/main/java/org/elasticsearch/rest/action/percolate/RestPercolateAction.java @@ -32,21 +32,24 @@ import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; -import static org.elasticsearch.rest.RestRequest.Method.*; -import static org.elasticsearch.rest.RestStatus.*; +import static org.elasticsearch.rest.RestRequest.Method.GET; +import static org.elasticsearch.rest.RestRequest.Method.POST; +import static org.elasticsearch.rest.RestStatus.OK; /** - * @author kimchy (shay.banon) + * */ public class RestPercolateAction extends BaseRestHandler { - @Inject public RestPercolateAction(Settings settings, Client client, RestController controller) { + @Inject + public RestPercolateAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(GET, "/{index}/{type}/_percolate", this); controller.registerHandler(POST, "/{index}/{type}/_percolate", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { PercolateRequest percolateRequest = new PercolateRequest(request.param("index"), request.param("type")); percolateRequest.source(request.contentByteArray(), request.contentByteArrayOffset(), request.contentLength(), request.contentUnsafe()); @@ -57,7 +60,8 @@ public class RestPercolateAction extends BaseRestHandler { percolateRequest.preferLocal(request.paramAsBoolean("prefer_local", percolateRequest.preferLocalShard())); client.percolate(percolateRequest, new ActionListener() { - @Override public void onResponse(PercolateResponse response) { + @Override + public void onResponse(PercolateResponse response) { try { XContentBuilder builder = RestXContentBuilder.restContentBuilder(request); builder.startObject(); @@ -77,7 +81,8 @@ public class RestPercolateAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java b/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java index 8847ed9bf57..d318c550f6b 100644 --- a/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java +++ b/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java @@ -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,12 +31,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryStringQueryBuilder; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.XContentRestResponse; -import org.elasticsearch.rest.XContentThrowableRestResponse; +import org.elasticsearch.rest.*; import org.elasticsearch.rest.action.support.RestActions; import org.elasticsearch.search.Scroll; import org.elasticsearch.search.builder.SearchSourceBuilder; @@ -44,17 +39,19 @@ import org.elasticsearch.search.sort.SortOrder; import java.io.IOException; -import static org.elasticsearch.common.unit.TimeValue.*; -import static org.elasticsearch.rest.RestRequest.Method.*; -import static org.elasticsearch.rest.RestStatus.*; -import static org.elasticsearch.rest.action.support.RestXContentBuilder.*; +import static org.elasticsearch.common.unit.TimeValue.parseTimeValue; +import static org.elasticsearch.rest.RestRequest.Method.GET; +import static org.elasticsearch.rest.RestRequest.Method.POST; +import static org.elasticsearch.rest.RestStatus.BAD_REQUEST; +import static org.elasticsearch.rest.action.support.RestXContentBuilder.restContentBuilder; /** - * @author kimchy (shay.banon) + * */ public class RestSearchAction extends BaseRestHandler { - @Inject public RestSearchAction(Settings settings, Client client, RestController controller) { + @Inject + public RestSearchAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(GET, "/_search", this); controller.registerHandler(POST, "/_search", this); @@ -64,7 +61,8 @@ public class RestSearchAction extends BaseRestHandler { controller.registerHandler(POST, "/{index}/{type}/_search", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { SearchRequest searchRequest; try { searchRequest = parseSearchRequest(request); @@ -90,7 +88,8 @@ public class RestSearchAction extends BaseRestHandler { return; } client.search(searchRequest, new ActionListener() { - @Override public void onResponse(SearchResponse response) { + @Override + public void onResponse(SearchResponse response) { try { XContentBuilder builder = restContentBuilder(request); builder.startObject(); @@ -105,7 +104,8 @@ public class RestSearchAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/search/RestSearchScrollAction.java b/src/main/java/org/elasticsearch/rest/action/search/RestSearchScrollAction.java index cead1a36827..aa635c99ac1 100644 --- a/src/main/java/org/elasticsearch/rest/action/search/RestSearchScrollAction.java +++ b/src/main/java/org/elasticsearch/rest/action/search/RestSearchScrollAction.java @@ -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,27 +27,24 @@ import org.elasticsearch.client.Client; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.XContentRestResponse; -import org.elasticsearch.rest.XContentThrowableRestResponse; +import org.elasticsearch.rest.*; import org.elasticsearch.search.Scroll; import java.io.IOException; -import static org.elasticsearch.common.unit.TimeValue.*; -import static org.elasticsearch.rest.RestRequest.Method.*; -import static org.elasticsearch.rest.RestStatus.*; -import static org.elasticsearch.rest.action.support.RestXContentBuilder.*; +import static org.elasticsearch.common.unit.TimeValue.parseTimeValue; +import static org.elasticsearch.rest.RestRequest.Method.GET; +import static org.elasticsearch.rest.RestRequest.Method.POST; +import static org.elasticsearch.rest.RestStatus.BAD_REQUEST; +import static org.elasticsearch.rest.action.support.RestXContentBuilder.restContentBuilder; /** - * @author kimchy (shay.banon) + * */ public class RestSearchScrollAction extends BaseRestHandler { - @Inject public RestSearchScrollAction(Settings settings, Client client, RestController controller) { + @Inject + public RestSearchScrollAction(Settings settings, Client client, RestController controller) { super(settings, client); controller.registerHandler(GET, "/_search/scroll", this); @@ -56,7 +53,8 @@ public class RestSearchScrollAction extends BaseRestHandler { controller.registerHandler(POST, "/_search/scroll/{scroll_id}", this); } - @Override public void handleRequest(final RestRequest request, final RestChannel channel) { + @Override + public void handleRequest(final RestRequest request, final RestChannel channel) { String scrollId = request.param("scroll_id"); if (scrollId == null && request.hasContent()) { scrollId = request.contentAsString(); @@ -87,7 +85,8 @@ public class RestSearchScrollAction extends BaseRestHandler { } client.searchScroll(searchScrollRequest, new ActionListener() { - @Override public void onResponse(SearchResponse response) { + @Override + public void onResponse(SearchResponse response) { try { XContentBuilder builder = restContentBuilder(request); builder.startObject(); @@ -99,7 +98,8 @@ public class RestSearchScrollAction extends BaseRestHandler { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { try { channel.sendResponse(new XContentThrowableRestResponse(request, e)); } catch (IOException e1) { diff --git a/src/main/java/org/elasticsearch/rest/action/support/RestActions.java b/src/main/java/org/elasticsearch/rest/action/support/RestActions.java index 2f69fd2a183..ae4bd7b8db9 100644 --- a/src/main/java/org/elasticsearch/rest/action/support/RestActions.java +++ b/src/main/java/org/elasticsearch/rest/action/support/RestActions.java @@ -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,7 +31,7 @@ import org.elasticsearch.rest.RestRequest; import java.io.IOException; /** - * @author kimchy (Shay Banon) + * */ public class RestActions { diff --git a/src/main/java/org/elasticsearch/rest/action/support/RestXContentBuilder.java b/src/main/java/org/elasticsearch/rest/action/support/RestXContentBuilder.java index 007d6c57a45..ed262178ecd 100644 --- a/src/main/java/org/elasticsearch/rest/action/support/RestXContentBuilder.java +++ b/src/main/java/org/elasticsearch/rest/action/support/RestXContentBuilder.java @@ -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,17 +24,13 @@ import org.elasticsearch.common.io.stream.BytesStreamInput; import org.elasticsearch.common.io.stream.CachedStreamInput; import org.elasticsearch.common.io.stream.CachedStreamOutput; import org.elasticsearch.common.io.stream.LZFStreamInput; -import org.elasticsearch.common.xcontent.ToXContent; -import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.common.xcontent.XContentFactory; -import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.common.xcontent.XContentType; +import org.elasticsearch.common.xcontent.*; import org.elasticsearch.rest.RestRequest; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class RestXContentBuilder { diff --git a/src/main/java/org/elasticsearch/rest/support/AbstractRestRequest.java b/src/main/java/org/elasticsearch/rest/support/AbstractRestRequest.java index 9fabe0116fa..be847e58e59 100644 --- a/src/main/java/org/elasticsearch/rest/support/AbstractRestRequest.java +++ b/src/main/java/org/elasticsearch/rest/support/AbstractRestRequest.java @@ -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,19 +26,21 @@ import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.rest.RestRequest; -import static org.elasticsearch.common.unit.ByteSizeValue.*; -import static org.elasticsearch.common.unit.TimeValue.*; +import static org.elasticsearch.common.unit.ByteSizeValue.parseBytesSizeValue; +import static org.elasticsearch.common.unit.TimeValue.parseTimeValue; /** - * @author kimchy (shay.banon) + * */ public abstract class AbstractRestRequest implements RestRequest { - @Override public final String path() { + @Override + public final String path() { return RestUtils.decodeComponent(rawPath()); } - @Override public float paramAsFloat(String key, float defaultValue) { + @Override + public float paramAsFloat(String key, float defaultValue) { String sValue = param(key); if (sValue == null) { return defaultValue; @@ -50,7 +52,8 @@ public abstract class AbstractRestRequest implements RestRequest { } } - @Override public int paramAsInt(String key, int defaultValue) { + @Override + public int paramAsInt(String key, int defaultValue) { String sValue = param(key); if (sValue == null) { return defaultValue; @@ -62,7 +65,8 @@ public abstract class AbstractRestRequest implements RestRequest { } } - @Override public long paramAsLong(String key, long defaultValue) { + @Override + public long paramAsLong(String key, long defaultValue) { String sValue = param(key); if (sValue == null) { return defaultValue; @@ -74,11 +78,13 @@ public abstract class AbstractRestRequest implements RestRequest { } } - @Override public boolean paramAsBoolean(String key, boolean defaultValue) { + @Override + public boolean paramAsBoolean(String key, boolean defaultValue) { return Booleans.parseBoolean(param(key), defaultValue); } - @Override public Boolean paramAsBooleanOptional(String key, Boolean defaultValue) { + @Override + public Boolean paramAsBooleanOptional(String key, Boolean defaultValue) { String sValue = param(key); if (sValue == null) { return defaultValue; @@ -86,15 +92,18 @@ public abstract class AbstractRestRequest implements RestRequest { return !(sValue.equals("false") || sValue.equals("0") || sValue.equals("off")); } - @Override public TimeValue paramAsTime(String key, TimeValue defaultValue) { + @Override + public TimeValue paramAsTime(String key, TimeValue defaultValue) { return parseTimeValue(param(key), defaultValue); } - @Override public ByteSizeValue paramAsSize(String key, ByteSizeValue defaultValue) { + @Override + public ByteSizeValue paramAsSize(String key, ByteSizeValue defaultValue) { return parseBytesSizeValue(param(key), defaultValue); } - @Override public String[] paramAsStringArray(String key, String[] defaultValue) { + @Override + public String[] paramAsStringArray(String key, String[] defaultValue) { String value = param(key); if (value == null) { return defaultValue; diff --git a/src/main/java/org/elasticsearch/rest/support/RestUtils.java b/src/main/java/org/elasticsearch/rest/support/RestUtils.java index 40a26344574..0ec99fc2482 100644 --- a/src/main/java/org/elasticsearch/rest/support/RestUtils.java +++ b/src/main/java/org/elasticsearch/rest/support/RestUtils.java @@ -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,20 +19,21 @@ package org.elasticsearch.rest.support; +import com.google.common.base.Charsets; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.base.Charsets; import org.elasticsearch.common.path.PathTrie; import java.nio.charset.Charset; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class RestUtils { public static PathTrie.Decoder REST_DECODER = new PathTrie.Decoder() { - @Override public String decode(String value) { + @Override + public String decode(String value) { return RestUtils.decodeComponent(value); } }; @@ -98,7 +99,7 @@ public class RestUtils { /** * Decodes a bit of an URL encoded by a browser. - *

    + *

    * This is equivalent to calling {@link #decodeComponent(String, Charset)} * with the UTF-8 charset (recommended to comply with RFC 3986, Section 2). * @@ -114,13 +115,13 @@ public class RestUtils { /** * Decodes a bit of an URL encoded by a browser. - *

    + *

    * The string is expected to be encoded as per RFC 3986, Section 2. * This is the encoding used by JavaScript functions {@code encodeURI} * and {@code encodeURIComponent}, but not {@code escape}. For example * in this encoding, é (in Unicode {@code U+00E9} or in UTF-8 * {@code 0xC3 0xA9}) is encoded as {@code %C3%A9} or {@code %c3%a9}. - *

    + *

    * This is essentially equivalent to calling * {@link java.net.URLDecoder URLDecoder}.{@link * java.net.URLDecoder#decode(String, String)} diff --git a/src/main/java/org/elasticsearch/river/AbstractRiverComponent.java b/src/main/java/org/elasticsearch/river/AbstractRiverComponent.java index f898e57404c..282286c4f62 100644 --- a/src/main/java/org/elasticsearch/river/AbstractRiverComponent.java +++ b/src/main/java/org/elasticsearch/river/AbstractRiverComponent.java @@ -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 class AbstractRiverComponent implements RiverComponent { @@ -40,7 +40,8 @@ public class AbstractRiverComponent implements RiverComponent { this.logger = Loggers.getLogger(getClass(), settings.globalSettings(), riverName); } - @Override public RiverName riverName() { + @Override + public RiverName riverName() { return riverName; } diff --git a/src/main/java/org/elasticsearch/river/River.java b/src/main/java/org/elasticsearch/river/River.java index 47ef816a91d..b46fbf3eb60 100644 --- a/src/main/java/org/elasticsearch/river/River.java +++ b/src/main/java/org/elasticsearch/river/River.java @@ -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.river; /** - * @author kimchy (shay.banon) + * */ public interface River extends RiverComponent { diff --git a/src/main/java/org/elasticsearch/river/RiverComponent.java b/src/main/java/org/elasticsearch/river/RiverComponent.java index 6ddec5c9042..91d4a51b1ba 100644 --- a/src/main/java/org/elasticsearch/river/RiverComponent.java +++ b/src/main/java/org/elasticsearch/river/RiverComponent.java @@ -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.river; /** - * @author kimchy (shay.banon) + * */ public interface RiverComponent { diff --git a/src/main/java/org/elasticsearch/river/RiverException.java b/src/main/java/org/elasticsearch/river/RiverException.java index 9e81de328b7..6f28bcd3eca 100644 --- a/src/main/java/org/elasticsearch/river/RiverException.java +++ b/src/main/java/org/elasticsearch/river/RiverException.java @@ -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.river; import org.elasticsearch.ElasticSearchException; /** - * @author kimchy (shay.banon) + * */ public class RiverException extends ElasticSearchException { diff --git a/src/main/java/org/elasticsearch/river/RiverIndexName.java b/src/main/java/org/elasticsearch/river/RiverIndexName.java index 1b23bd1e30c..3331a3aae52 100644 --- a/src/main/java/org/elasticsearch/river/RiverIndexName.java +++ b/src/main/java/org/elasticsearch/river/RiverIndexName.java @@ -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,11 +26,12 @@ import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.Target; -import static java.lang.annotation.ElementType.*; -import static java.lang.annotation.RetentionPolicy.*; +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.RetentionPolicy.RUNTIME; /** - * @author kimchy (Shay Banon) + * */ @BindingAnnotation diff --git a/src/main/java/org/elasticsearch/river/RiverModule.java b/src/main/java/org/elasticsearch/river/RiverModule.java index 0a004e21f3c..5a890b670a7 100644 --- a/src/main/java/org/elasticsearch/river/RiverModule.java +++ b/src/main/java/org/elasticsearch/river/RiverModule.java @@ -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.river; +import com.google.common.collect.ImmutableList; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.collect.ImmutableList; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.inject.Modules; @@ -30,10 +30,10 @@ import org.elasticsearch.common.settings.Settings; import java.util.Map; -import static org.elasticsearch.common.Strings.*; +import static org.elasticsearch.common.Strings.toCamelCase; /** - * @author kimchy (shay.banon) + * */ public class RiverModule extends AbstractModule implements SpawnModules { @@ -52,11 +52,13 @@ public class RiverModule extends AbstractModule implements SpawnModules { this.typesRegistry = typesRegistry; } - @Override public Iterable spawnModules() { + @Override + public Iterable spawnModules() { return ImmutableList.of(Modules.createModule(loadTypeModule(riverName.type(), "org.elasticsearch.river.", "RiverModule"), globalSettings)); } - @Override protected void configure() { + @Override + protected void configure() { bind(RiverSettings.class).toInstance(new RiverSettings(globalSettings, settings)); } diff --git a/src/main/java/org/elasticsearch/river/RiverName.java b/src/main/java/org/elasticsearch/river/RiverName.java index 74b1ef67745..c80e223e0f4 100644 --- a/src/main/java/org/elasticsearch/river/RiverName.java +++ b/src/main/java/org/elasticsearch/river/RiverName.java @@ -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.river; import java.io.Serializable; /** - * @author kimchy (shay.banon) + * */ public class RiverName implements Serializable { @@ -51,7 +51,8 @@ public class RiverName implements Serializable { return name(); } - @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; @@ -63,7 +64,8 @@ public class RiverName implements Serializable { return true; } - @Override public int hashCode() { + @Override + public int hashCode() { int result = type != null ? type.hashCode() : 0; result = 31 * result + (name != null ? name.hashCode() : 0); return result; diff --git a/src/main/java/org/elasticsearch/river/RiverNameModule.java b/src/main/java/org/elasticsearch/river/RiverNameModule.java index cdb20086c6b..112043a47df 100644 --- a/src/main/java/org/elasticsearch/river/RiverNameModule.java +++ b/src/main/java/org/elasticsearch/river/RiverNameModule.java @@ -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.river; import org.elasticsearch.common.inject.AbstractModule; /** - * @author kimchy (shay.banon) + * */ public class RiverNameModule extends AbstractModule { @@ -32,7 +32,8 @@ public class RiverNameModule extends AbstractModule { this.riverName = riverName; } - @Override protected void configure() { + @Override + protected void configure() { bind(RiverName.class).toInstance(riverName); } } diff --git a/src/main/java/org/elasticsearch/river/RiverSettings.java b/src/main/java/org/elasticsearch/river/RiverSettings.java index 0fed09556e0..fbe6d64e241 100644 --- a/src/main/java/org/elasticsearch/river/RiverSettings.java +++ b/src/main/java/org/elasticsearch/river/RiverSettings.java @@ -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.common.settings.Settings; import java.util.Map; /** - * @author kimchy (shayy.banon) + * (shayy.banon) */ public class RiverSettings { diff --git a/src/main/java/org/elasticsearch/river/RiversManager.java b/src/main/java/org/elasticsearch/river/RiversManager.java index 253947664f8..3b192dce887 100644 --- a/src/main/java/org/elasticsearch/river/RiversManager.java +++ b/src/main/java/org/elasticsearch/river/RiversManager.java @@ -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.river.cluster.RiverClusterService; import org.elasticsearch.river.routing.RiversRouter; /** - * @author kimchy (shay.banon) + * */ public class RiversManager extends AbstractLifecycleComponent { @@ -37,26 +37,30 @@ public class RiversManager extends AbstractLifecycleComponent { private final RiversRouter riversRouter; - @Inject public RiversManager(Settings settings, RiversService riversService, RiverClusterService clusterService, RiversRouter riversRouter) { + @Inject + public RiversManager(Settings settings, RiversService riversService, RiverClusterService clusterService, RiversRouter riversRouter) { super(settings); this.riversService = riversService; this.clusterService = clusterService; this.riversRouter = riversRouter; } - @Override protected void doStart() throws ElasticSearchException { + @Override + protected void doStart() throws ElasticSearchException { riversRouter.start(); riversService.start(); clusterService.start(); } - @Override protected void doStop() throws ElasticSearchException { + @Override + protected void doStop() throws ElasticSearchException { riversRouter.stop(); clusterService.stop(); riversService.stop(); } - @Override protected void doClose() throws ElasticSearchException { + @Override + protected void doClose() throws ElasticSearchException { riversRouter.close(); clusterService.close(); riversService.close(); diff --git a/src/main/java/org/elasticsearch/river/RiversModule.java b/src/main/java/org/elasticsearch/river/RiversModule.java index 96d10c52bcc..9478d0d891a 100644 --- a/src/main/java/org/elasticsearch/river/RiversModule.java +++ b/src/main/java/org/elasticsearch/river/RiversModule.java @@ -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.river; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.Maps; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.settings.Settings; @@ -30,7 +30,7 @@ import org.elasticsearch.river.routing.RiversRouter; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class RiversModule extends AbstractModule { @@ -52,7 +52,8 @@ public class RiversModule extends AbstractModule { riverTypes.put(type, module); } - @Override protected void configure() { + @Override + protected void configure() { bind(String.class).annotatedWith(RiverIndexName.class).toInstance(RiverIndexName.Conf.indexName(settings)); bind(RiversService.class).asEagerSingleton(); bind(RiverClusterService.class).asEagerSingleton(); diff --git a/src/main/java/org/elasticsearch/river/RiversPluginsModule.java b/src/main/java/org/elasticsearch/river/RiversPluginsModule.java index 9c4c52487f9..2a97bf50e14 100644 --- a/src/main/java/org/elasticsearch/river/RiversPluginsModule.java +++ b/src/main/java/org/elasticsearch/river/RiversPluginsModule.java @@ -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 @@ -40,10 +40,12 @@ public class RiversPluginsModule extends AbstractModule implements PreProcessMod this.pluginsService = pluginsService; } - @Override public void processModule(Module module) { + @Override + public void processModule(Module module) { pluginsService.processModule(module); } - @Override protected void configure() { + @Override + protected void configure() { } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/river/RiversService.java b/src/main/java/org/elasticsearch/river/RiversService.java index 2c1bcb270f6..3b9d200d1e4 100644 --- a/src/main/java/org/elasticsearch/river/RiversService.java +++ b/src/main/java/org/elasticsearch/river/RiversService.java @@ -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,9 @@ package org.elasticsearch.river; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Maps; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.action.ActionListener; @@ -29,10 +32,7 @@ import org.elasticsearch.client.Client; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.block.ClusterBlockException; import org.elasticsearch.cluster.node.DiscoveryNode; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.ImmutableSet; import org.elasticsearch.common.collect.MapBuilder; -import org.elasticsearch.common.collect.Maps; import org.elasticsearch.common.component.AbstractLifecycleComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.Injector; @@ -55,7 +55,7 @@ import java.util.Map; import java.util.concurrent.CountDownLatch; /** - * @author kimchy (shay.banon) + * */ public class RiversService extends AbstractLifecycleComponent { @@ -75,7 +75,8 @@ public class RiversService extends AbstractLifecycleComponent { private volatile ImmutableMap rivers = ImmutableMap.of(); - @Inject public RiversService(Settings settings, Client client, ThreadPool threadPool, ClusterService clusterService, RiversTypesRegistry typesRegistry, RiverClusterService riverClusterService, Injector injector) { + @Inject + public RiversService(Settings settings, Client client, ThreadPool threadPool, ClusterService clusterService, RiversTypesRegistry typesRegistry, RiverClusterService riverClusterService, Injector injector) { super(settings); this.riverIndexName = RiverIndexName.Conf.indexName(settings); this.client = client; @@ -86,15 +87,18 @@ public class RiversService extends AbstractLifecycleComponent { riverClusterService.add(new ApplyRivers()); } - @Override protected void doStart() throws ElasticSearchException { + @Override + protected void doStart() throws ElasticSearchException { } - @Override protected void doStop() throws ElasticSearchException { + @Override + protected void doStop() throws ElasticSearchException { ImmutableSet indices = ImmutableSet.copyOf(this.rivers.keySet()); final CountDownLatch latch = new CountDownLatch(indices.size()); for (final RiverName riverName : indices) { threadPool.cached().execute(new Runnable() { - @Override public void run() { + @Override + public void run() { try { closeRiver(riverName); } catch (Exception e) { @@ -112,7 +116,8 @@ public class RiversService extends AbstractLifecycleComponent { } } - @Override protected void doClose() throws ElasticSearchException { + @Override + protected void doClose() throws ElasticSearchException { } public synchronized void createRiver(RiverName riverName, Map settings) throws ElasticSearchException { @@ -197,7 +202,8 @@ public class RiversService extends AbstractLifecycleComponent { } private class ApplyRivers implements RiverClusterStateListener { - @Override public void riverClusterChanged(RiverClusterChangedEvent event) { + @Override + public void riverClusterChanged(RiverClusterChangedEvent event) { DiscoveryNode localNode = clusterService.localNode(); RiverClusterState state = event.state(); @@ -224,7 +230,8 @@ public class RiversService extends AbstractLifecycleComponent { continue; } client.prepareGet(riverIndexName, routing.riverName().name(), "_meta").setListenerThreaded(true).execute(new ActionListener() { - @Override public void onResponse(GetResponse getResponse) { + @Override + public void onResponse(GetResponse getResponse) { if (!rivers.containsKey(routing.riverName())) { if (getResponse.exists()) { // only create the river if it exists, otherwise, the indexing meta data has not been visible yet... @@ -233,7 +240,8 @@ public class RiversService extends AbstractLifecycleComponent { } } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { // if its this is a failure that need to be retried, then do it // this might happen if the state of the river index has not been propagated yet to this node, which // should happen pretty fast since we managed to get the _meta in the RiversRouter @@ -242,7 +250,8 @@ public class RiversService extends AbstractLifecycleComponent { logger.debug("failed to get _meta from [{}]/[{}], retrying...", e, routing.riverName().type(), routing.riverName().name()); final ActionListener listener = this; threadPool.schedule(TimeValue.timeValueSeconds(5), ThreadPool.Names.SAME, new Runnable() { - @Override public void run() { + @Override + public void run() { client.prepareGet(riverIndexName, routing.riverName().name(), "_meta").setListenerThreaded(true).execute(listener); } }); diff --git a/src/main/java/org/elasticsearch/river/RiversTypesRegistry.java b/src/main/java/org/elasticsearch/river/RiversTypesRegistry.java index 65bf7bdcad4..888bab9689c 100644 --- a/src/main/java/org/elasticsearch/river/RiversTypesRegistry.java +++ b/src/main/java/org/elasticsearch/river/RiversTypesRegistry.java @@ -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,7 +19,7 @@ package org.elasticsearch.river; -import org.elasticsearch.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMap; import org.elasticsearch.common.inject.Module; /** diff --git a/src/main/java/org/elasticsearch/river/cluster/PublishRiverClusterStateAction.java b/src/main/java/org/elasticsearch/river/cluster/PublishRiverClusterStateAction.java index 631dec6713d..51ce936b096 100644 --- a/src/main/java/org/elasticsearch/river/cluster/PublishRiverClusterStateAction.java +++ b/src/main/java/org/elasticsearch/river/cluster/PublishRiverClusterStateAction.java @@ -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,7 +34,7 @@ import org.elasticsearch.transport.*; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class PublishRiverClusterStateAction extends AbstractComponent { @@ -78,7 +78,8 @@ public class PublishRiverClusterStateAction extends AbstractComponent { } transportService.sendRequest(node, PublishClusterStateRequestHandler.ACTION, new PublishClusterStateRequest(clusterState), new VoidTransportResponseHandler(ThreadPool.Names.SAME) { - @Override public void handleException(TransportException exp) { + @Override + public void handleException(TransportException exp) { logger.debug("failed to send cluster state to [{}], should be detected as failed soon...", exp, node); } }); @@ -96,11 +97,13 @@ public class PublishRiverClusterStateAction extends AbstractComponent { this.clusterState = clusterState; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { clusterState = RiverClusterState.Builder.readFrom(in); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { RiverClusterState.Builder.writeTo(clusterState, out); } } @@ -109,15 +112,18 @@ public class PublishRiverClusterStateAction extends AbstractComponent { static final String ACTION = "river/state/publish"; - @Override public PublishClusterStateRequest newInstance() { + @Override + public PublishClusterStateRequest newInstance() { return new PublishClusterStateRequest(); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } - @Override public void messageReceived(PublishClusterStateRequest request, TransportChannel channel) throws Exception { + @Override + public void messageReceived(PublishClusterStateRequest request, TransportChannel channel) throws Exception { listener.onNewClusterState(request.clusterState); channel.sendResponse(VoidStreamable.INSTANCE); } diff --git a/src/main/java/org/elasticsearch/river/cluster/RiverClusterChangedEvent.java b/src/main/java/org/elasticsearch/river/cluster/RiverClusterChangedEvent.java index d31bed2091d..48dc17624b4 100644 --- a/src/main/java/org/elasticsearch/river/cluster/RiverClusterChangedEvent.java +++ b/src/main/java/org/elasticsearch/river/cluster/RiverClusterChangedEvent.java @@ -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.river.cluster; /** - * @author kimchy (shay.banon) + * */ public class RiverClusterChangedEvent { diff --git a/src/main/java/org/elasticsearch/river/cluster/RiverClusterService.java b/src/main/java/org/elasticsearch/river/cluster/RiverClusterService.java index cef5cf55c5f..afa56a83126 100644 --- a/src/main/java/org/elasticsearch/river/cluster/RiverClusterService.java +++ b/src/main/java/org/elasticsearch/river/cluster/RiverClusterService.java @@ -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,11 +32,11 @@ import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; -import static java.util.concurrent.Executors.*; -import static org.elasticsearch.common.util.concurrent.EsExecutors.*; +import static java.util.concurrent.Executors.newSingleThreadExecutor; +import static org.elasticsearch.common.util.concurrent.EsExecutors.daemonThreadFactory; /** - * @author kimchy (shay.banon) + * */ public class RiverClusterService extends AbstractLifecycleComponent { @@ -50,18 +50,21 @@ public class RiverClusterService extends AbstractLifecycleComponent implements ClusterStateListener { @@ -59,7 +59,8 @@ public class RiversRouter extends AbstractLifecycleComponent imple private final RiverClusterService riverClusterService; - @Inject public RiversRouter(Settings settings, Client client, ClusterService clusterService, RiverClusterService riverClusterService) { + @Inject + public RiversRouter(Settings settings, Client client, ClusterService clusterService, RiverClusterService riverClusterService) { super(settings); this.riverIndexName = RiverIndexName.Conf.indexName(settings); this.riverClusterService = riverClusterService; @@ -67,21 +68,26 @@ public class RiversRouter extends AbstractLifecycleComponent imple clusterService.add(this); } - @Override protected void doStart() throws ElasticSearchException { + @Override + protected void doStart() throws ElasticSearchException { } - @Override protected void doStop() throws ElasticSearchException { + @Override + protected void doStop() throws ElasticSearchException { } - @Override protected void doClose() throws ElasticSearchException { + @Override + protected void doClose() throws ElasticSearchException { } - @Override public void clusterChanged(final ClusterChangedEvent event) { + @Override + public void clusterChanged(final ClusterChangedEvent event) { if (!event.localNodeMaster()) { return; } riverClusterService.submitStateUpdateTask("reroute_rivers_node_changed", new RiverClusterStateUpdateTask() { - @Override public RiverClusterState execute(RiverClusterState currentState) { + @Override + public RiverClusterState execute(RiverClusterState currentState) { if (!event.state().metaData().hasIndex(riverIndexName)) { // if there are routings, publish an empty one (so it will be deleted on nodes), otherwise, return the same state if (!currentState.routing().isEmpty()) { @@ -157,7 +163,7 @@ public class RiversRouter extends AbstractLifecycleComponent imple l.add(routing); } } - for (Iterator it = unassigned.iterator(); it.hasNext();) { + for (Iterator it = unassigned.iterator(); it.hasNext(); ) { RiverRouting routing = it.next(); DiscoveryNode smallest = null; int smallestSize = Integer.MAX_VALUE; diff --git a/src/main/java/org/elasticsearch/river/routing/RiversRouting.java b/src/main/java/org/elasticsearch/river/routing/RiversRouting.java index 5ffa919b811..30d06b5cde5 100644 --- a/src/main/java/org/elasticsearch/river/routing/RiversRouting.java +++ b/src/main/java/org/elasticsearch/river/routing/RiversRouting.java @@ -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,7 +19,7 @@ package org.elasticsearch.river.routing; -import org.elasticsearch.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMap; import org.elasticsearch.common.collect.MapBuilder; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -29,7 +29,7 @@ import java.io.IOException; import java.util.Iterator; /** - * @author kimchy (shay.banon) + * */ public class RiversRouting implements Iterable { @@ -58,7 +58,8 @@ public class RiversRouting implements Iterable { return false; } - @Override public Iterator iterator() { + @Override + public Iterator iterator() { return rivers.values().iterator(); } diff --git a/src/main/java/org/elasticsearch/script/AbstractDoubleSearchScript.java b/src/main/java/org/elasticsearch/script/AbstractDoubleSearchScript.java index fb71a28e719..1838d3c575e 100644 --- a/src/main/java/org/elasticsearch/script/AbstractDoubleSearchScript.java +++ b/src/main/java/org/elasticsearch/script/AbstractDoubleSearchScript.java @@ -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,17 +25,21 @@ package org.elasticsearch.script; */ public abstract class AbstractDoubleSearchScript extends AbstractSearchScript { - @Override public Object run() { + @Override + public Object run() { return runAsDouble(); } - @Override public abstract double runAsDouble(); + @Override + public abstract double runAsDouble(); - @Override public long runAsLong() { + @Override + public long runAsLong() { return (long) runAsDouble(); } - @Override public float runAsFloat() { + @Override + public float runAsFloat() { return (float) runAsDouble(); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/script/AbstractExecutableScript.java b/src/main/java/org/elasticsearch/script/AbstractExecutableScript.java index 63397326d20..c34d3b84987 100644 --- a/src/main/java/org/elasticsearch/script/AbstractExecutableScript.java +++ b/src/main/java/org/elasticsearch/script/AbstractExecutableScript.java @@ -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,10 +21,12 @@ package org.elasticsearch.script; public abstract class AbstractExecutableScript implements ExecutableScript { - @Override public void setNextVar(String name, Object value) { + @Override + public void setNextVar(String name, Object value) { } - @Override public Object unwrap(Object value) { + @Override + public Object unwrap(Object value) { return value; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/script/AbstractFloatSearchScript.java b/src/main/java/org/elasticsearch/script/AbstractFloatSearchScript.java index 4ce94368be7..3657d13a332 100644 --- a/src/main/java/org/elasticsearch/script/AbstractFloatSearchScript.java +++ b/src/main/java/org/elasticsearch/script/AbstractFloatSearchScript.java @@ -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,17 +25,21 @@ package org.elasticsearch.script; */ public abstract class AbstractFloatSearchScript extends AbstractSearchScript { - @Override public Object run() { + @Override + public Object run() { return runAsFloat(); } - @Override public abstract float runAsFloat(); + @Override + public abstract float runAsFloat(); - @Override public double runAsDouble() { + @Override + public double runAsDouble() { return runAsFloat(); } - @Override public long runAsLong() { + @Override + public long runAsLong() { return (long) runAsFloat(); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/script/AbstractLongSearchScript.java b/src/main/java/org/elasticsearch/script/AbstractLongSearchScript.java index 28af7384177..3117879deaa 100644 --- a/src/main/java/org/elasticsearch/script/AbstractLongSearchScript.java +++ b/src/main/java/org/elasticsearch/script/AbstractLongSearchScript.java @@ -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,17 +25,21 @@ package org.elasticsearch.script; */ public abstract class AbstractLongSearchScript extends AbstractSearchScript { - @Override public Object run() { + @Override + public Object run() { return runAsLong(); } - @Override public abstract long runAsLong(); + @Override + public abstract long runAsLong(); - @Override public double runAsDouble() { + @Override + public double runAsDouble() { return runAsLong(); } - @Override public float runAsFloat() { + @Override + public float runAsFloat() { return runAsLong(); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/script/AbstractSearchScript.java b/src/main/java/org/elasticsearch/script/AbstractSearchScript.java index 709cc9b8e1a..46b691ba329 100644 --- a/src/main/java/org/elasticsearch/script/AbstractSearchScript.java +++ b/src/main/java/org/elasticsearch/script/AbstractSearchScript.java @@ -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,11 +30,11 @@ import java.util.Map; /** * A base class for any script type that is used during the search process (custom score, facets, and so on). - * + *

    *

    If the script returns a specific numeric type, consider overriding the type specific base classes * such as {@link AbstractDoubleSearchScript}, {@link AbstractFloatSearchScript} and {@link AbstractLongSearchScript} * for better performance. - * + *

    *

    The use is required to implement the {@link #run()} method. */ public abstract class AbstractSearchScript extends AbstractExecutableScript implements SearchScript { @@ -77,35 +77,43 @@ public abstract class AbstractSearchScript extends AbstractExecutableScript impl this.lookup = lookup; } - @Override public void setScorer(Scorer scorer) { + @Override + public void setScorer(Scorer scorer) { lookup.setScorer(scorer); } - @Override public void setNextReader(IndexReader reader) { + @Override + public void setNextReader(IndexReader reader) { lookup.setNextReader(reader); } - @Override public void setNextDocId(int doc) { + @Override + public void setNextDocId(int doc) { lookup.setNextDocId(doc); } - @Override public void setNextSource(Map source) { + @Override + public void setNextSource(Map source) { lookup.source().setNextSource(source); } - @Override public void setNextScore(float score) { + @Override + public void setNextScore(float score) { this.score = score; } - @Override public float runAsFloat() { + @Override + public float runAsFloat() { return ((Number) run()).floatValue(); } - @Override public long runAsLong() { + @Override + public long runAsLong() { return ((Number) run()).longValue(); } - @Override public double runAsDouble() { + @Override + public double runAsDouble() { return ((Number) run()).doubleValue(); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/script/CompiledScript.java b/src/main/java/org/elasticsearch/script/CompiledScript.java index a78f18ddfce..b29cfd3fce4 100644 --- a/src/main/java/org/elasticsearch/script/CompiledScript.java +++ b/src/main/java/org/elasticsearch/script/CompiledScript.java @@ -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.script; /** - * @author kimchy (shay.banon) + * */ public class CompiledScript { diff --git a/src/main/java/org/elasticsearch/script/ExecutableScript.java b/src/main/java/org/elasticsearch/script/ExecutableScript.java index cfdc2491b95..f10a88071a7 100644 --- a/src/main/java/org/elasticsearch/script/ExecutableScript.java +++ b/src/main/java/org/elasticsearch/script/ExecutableScript.java @@ -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.common.util.concurrent.NotThreadSafe; /** * An executable script, can't be used concurrently. * - * @author kimchy (shay.banon) + * */ @NotThreadSafe public interface ExecutableScript { diff --git a/src/main/java/org/elasticsearch/script/NativeScriptEngineService.java b/src/main/java/org/elasticsearch/script/NativeScriptEngineService.java index 7ea505efc6b..a8d8e7cfe06 100644 --- a/src/main/java/org/elasticsearch/script/NativeScriptEngineService.java +++ b/src/main/java/org/elasticsearch/script/NativeScriptEngineService.java @@ -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.script; +import com.google.common.collect.ImmutableMap; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -36,20 +36,24 @@ public class NativeScriptEngineService extends AbstractComponent implements Scri private final ImmutableMap scripts; - @Inject public NativeScriptEngineService(Settings settings, Map scripts) { + @Inject + public NativeScriptEngineService(Settings settings, Map scripts) { super(settings); this.scripts = ImmutableMap.copyOf(scripts); } - @Override public String[] types() { + @Override + public String[] types() { return new String[]{"native"}; } - @Override public String[] extensions() { + @Override + public String[] extensions() { return new String[0]; } - @Override public Object compile(String script) { + @Override + public Object compile(String script) { NativeScriptFactory scriptFactory = scripts.get(script); if (scriptFactory != null) { return scriptFactory; @@ -57,26 +61,31 @@ public class NativeScriptEngineService extends AbstractComponent implements Scri throw new ElasticSearchIllegalArgumentException("Native script [" + script + "] not found"); } - @Override public ExecutableScript executable(Object compiledScript, @Nullable Map vars) { + @Override + public ExecutableScript executable(Object compiledScript, @Nullable Map vars) { NativeScriptFactory scriptFactory = (NativeScriptFactory) compiledScript; return scriptFactory.newScript(vars); } - @Override public SearchScript search(Object compiledScript, SearchLookup lookup, @Nullable Map vars) { + @Override + public SearchScript search(Object compiledScript, SearchLookup lookup, @Nullable Map vars) { NativeScriptFactory scriptFactory = (NativeScriptFactory) compiledScript; AbstractSearchScript script = (AbstractSearchScript) scriptFactory.newScript(vars); script.setLookup(lookup); return script; } - @Override public Object execute(Object compiledScript, Map vars) { + @Override + public Object execute(Object compiledScript, Map vars) { return executable(compiledScript, vars).run(); } - @Override public Object unwrap(Object value) { + @Override + public Object unwrap(Object value) { return value; } - @Override public void close() { + @Override + public void close() { } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/script/NativeScriptFactory.java b/src/main/java/org/elasticsearch/script/NativeScriptFactory.java index 78b3345918e..9fd1f8d9732 100644 --- a/src/main/java/org/elasticsearch/script/NativeScriptFactory.java +++ b/src/main/java/org/elasticsearch/script/NativeScriptFactory.java @@ -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 diff --git a/src/main/java/org/elasticsearch/script/ScriptEngineService.java b/src/main/java/org/elasticsearch/script/ScriptEngineService.java index 0be4cdbb635..a020abd33f8 100644 --- a/src/main/java/org/elasticsearch/script/ScriptEngineService.java +++ b/src/main/java/org/elasticsearch/script/ScriptEngineService.java @@ -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.search.lookup.SearchLookup; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public interface ScriptEngineService { diff --git a/src/main/java/org/elasticsearch/script/ScriptException.java b/src/main/java/org/elasticsearch/script/ScriptException.java index a601c59ab1b..aef54ea0de4 100644 --- a/src/main/java/org/elasticsearch/script/ScriptException.java +++ b/src/main/java/org/elasticsearch/script/ScriptException.java @@ -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.script; import org.elasticsearch.ElasticSearchException; /** - * @author kimchy (shay.banon) + * */ public class ScriptException extends ElasticSearchException { diff --git a/src/main/java/org/elasticsearch/script/ScriptModule.java b/src/main/java/org/elasticsearch/script/ScriptModule.java index ca33fe69b79..2932eca2113 100644 --- a/src/main/java/org/elasticsearch/script/ScriptModule.java +++ b/src/main/java/org/elasticsearch/script/ScriptModule.java @@ -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.script; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import org.elasticsearch.ElasticSearchIllegalArgumentException; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.collect.Maps; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.multibindings.MapBinder; import org.elasticsearch.common.inject.multibindings.Multibinder; @@ -32,7 +32,7 @@ import java.util.List; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class ScriptModule extends AbstractModule { @@ -54,7 +54,8 @@ public class ScriptModule extends AbstractModule { scripts.put(name, script); } - @Override protected void configure() { + @Override + protected void configure() { MapBinder scriptsBinder = MapBinder.newMapBinder(binder(), String.class, NativeScriptFactory.class); for (Map.Entry> entry : scripts.entrySet()) { diff --git a/src/main/java/org/elasticsearch/script/ScriptService.java b/src/main/java/org/elasticsearch/script/ScriptService.java index 15a994561c7..c2615cf1f72 100644 --- a/src/main/java/org/elasticsearch/script/ScriptService.java +++ b/src/main/java/org/elasticsearch/script/ScriptService.java @@ -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,11 +19,11 @@ package org.elasticsearch.script; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.MapMaker; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.collect.MapMaker; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.io.Streams; @@ -44,7 +44,7 @@ import java.util.Set; import java.util.concurrent.ConcurrentMap; /** - * @author kimchy (shay.banon) + * */ public class ScriptService extends AbstractComponent { @@ -63,7 +63,8 @@ public class ScriptService extends AbstractComponent { ); } - @Inject public ScriptService(Settings settings, Environment env, Set scriptEngines) { + @Inject + public ScriptService(Settings settings, Environment env, Set scriptEngines) { super(settings); this.defaultLang = componentSettings.get("default_lang", "mvel"); @@ -191,24 +192,28 @@ public class ScriptService extends AbstractComponent { this.script = script; } - @Override public boolean equals(Object o) { + @Override + public boolean equals(Object o) { CacheKey other = (CacheKey) o; return lang.equals(other.lang) && script.equals(other.script); } - @Override public int hashCode() { + @Override + public int hashCode() { return lang.hashCode() + 31 * script.hashCode(); } } public static class DocScoreNativeScriptFactory implements NativeScriptFactory { - @Override public ExecutableScript newScript(@Nullable Map params) { + @Override + public ExecutableScript newScript(@Nullable Map params) { return new DocScoreSearchScript(); } } public static class DocScoreSearchScript extends AbstractFloatSearchScript { - @Override public float runAsFloat() { + @Override + public float runAsFloat() { try { return doc().score(); } catch (IOException e) { diff --git a/src/main/java/org/elasticsearch/script/mvel/MvelScriptEngineService.java b/src/main/java/org/elasticsearch/script/mvel/MvelScriptEngineService.java index 3e66c24bfab..e3db194c3e2 100644 --- a/src/main/java/org/elasticsearch/script/mvel/MvelScriptEngineService.java +++ b/src/main/java/org/elasticsearch/script/mvel/MvelScriptEngineService.java @@ -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,16 +25,16 @@ import org.elasticsearch.common.Nullable; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.math.UnboxedMathUtils; -import org.elasticsearch.common.mvel2.MVEL; -import org.elasticsearch.common.mvel2.ParserConfiguration; -import org.elasticsearch.common.mvel2.ParserContext; -import org.elasticsearch.common.mvel2.compiler.ExecutableStatement; -import org.elasticsearch.common.mvel2.integration.impl.MapVariableResolverFactory; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.script.ExecutableScript; import org.elasticsearch.script.ScriptEngineService; import org.elasticsearch.script.SearchScript; import org.elasticsearch.search.lookup.SearchLookup; +import org.mvel2.MVEL; +import org.mvel2.ParserConfiguration; +import org.mvel2.ParserContext; +import org.mvel2.compiler.ExecutableStatement; +import org.mvel2.integration.impl.MapVariableResolverFactory; import java.lang.reflect.Method; import java.lang.reflect.Modifier; @@ -42,19 +42,20 @@ import java.util.HashMap; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class MvelScriptEngineService extends AbstractComponent implements ScriptEngineService { private final ParserConfiguration parserConfiguration; - @Inject public MvelScriptEngineService(Settings settings) { + @Inject + public MvelScriptEngineService(Settings settings) { super(settings); parserConfiguration = new ParserConfiguration(); parserConfiguration.addPackageImport("java.util"); - parserConfiguration.addPackageImport("org.elasticsearch.common.trove"); - parserConfiguration.addPackageImport("org.elasticsearch.common.joda"); + parserConfiguration.addPackageImport("gnu.trove"); + parserConfiguration.addPackageImport("org.joda"); parserConfiguration.addImport("time", MVEL.getStaticMethod(System.class, "currentTimeMillis", new Class[0])); // unboxed version of Math, better performance since conversion from boxed to unboxed my mvel is not needed for (Method m : UnboxedMathUtils.class.getMethods()) { @@ -64,35 +65,43 @@ public class MvelScriptEngineService extends AbstractComponent implements Script } } - @Override public void close() { + @Override + public void close() { // nothing to do here... } - @Override public String[] types() { + @Override + public String[] types() { return new String[]{"mvel"}; } - @Override public String[] extensions() { + @Override + public String[] extensions() { return new String[]{"mvel"}; } - @Override public Object compile(String script) { + @Override + public Object compile(String script) { return MVEL.compileExpression(script, new ParserContext(parserConfiguration)); } - @Override public Object execute(Object compiledScript, Map vars) { + @Override + public Object execute(Object compiledScript, Map vars) { return MVEL.executeExpression(compiledScript, vars); } - @Override public ExecutableScript executable(Object compiledScript, Map vars) { + @Override + public ExecutableScript executable(Object compiledScript, Map vars) { return new MvelExecutableScript(compiledScript, vars); } - @Override public SearchScript search(Object compiledScript, SearchLookup lookup, @Nullable Map vars) { + @Override + public SearchScript search(Object compiledScript, SearchLookup lookup, @Nullable Map vars) { return new MvelSearchScript(compiledScript, lookup, vars); } - @Override public Object unwrap(Object value) { + @Override + public Object unwrap(Object value) { return value; } @@ -111,15 +120,18 @@ public class MvelScriptEngineService extends AbstractComponent implements Script } } - @Override public void setNextVar(String name, Object value) { + @Override + public void setNextVar(String name, Object value) { resolver.createVariable(name, value); } - @Override public Object run() { + @Override + public Object run() { return script.getValue(null, resolver); } - @Override public Object unwrap(Object value) { + @Override + public Object unwrap(Object value) { return value; } } @@ -145,47 +157,58 @@ public class MvelScriptEngineService extends AbstractComponent implements Script } } - @Override public void setScorer(Scorer scorer) { + @Override + public void setScorer(Scorer scorer) { lookup.setScorer(scorer); } - @Override public void setNextReader(IndexReader reader) { + @Override + public void setNextReader(IndexReader reader) { lookup.setNextReader(reader); } - @Override public void setNextDocId(int doc) { + @Override + public void setNextDocId(int doc) { lookup.setNextDocId(doc); } - @Override public void setNextScore(float score) { + @Override + public void setNextScore(float score) { resolver.createVariable("_score", score); } - @Override public void setNextVar(String name, Object value) { + @Override + public void setNextVar(String name, Object value) { resolver.createVariable(name, value); } - @Override public void setNextSource(Map source) { + @Override + public void setNextSource(Map source) { lookup.source().setNextSource(source); } - @Override public Object run() { + @Override + public Object run() { return script.getValue(null, resolver); } - @Override public float runAsFloat() { + @Override + public float runAsFloat() { return ((Number) run()).floatValue(); } - @Override public long runAsLong() { + @Override + public long runAsLong() { return ((Number) run()).longValue(); } - @Override public double runAsDouble() { + @Override + public double runAsDouble() { return ((Number) run()).doubleValue(); } - @Override public Object unwrap(Object value) { + @Override + public Object unwrap(Object value) { return value; } } diff --git a/src/main/java/org/elasticsearch/search/Scroll.java b/src/main/java/org/elasticsearch/search/Scroll.java index 151ff92153d..b01016c7b61 100644 --- a/src/main/java/org/elasticsearch/search/Scroll.java +++ b/src/main/java/org/elasticsearch/search/Scroll.java @@ -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,13 @@ 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 scroll enables scrolling of search request. It holds a {@link #keepAlive()} time that * will control how long to keep the scrolling resources open. * - * @author kimchy (shay.banon) + * */ public class Scroll implements Streamable { @@ -62,13 +62,15 @@ public class Scroll implements Streamable { return scroll; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { if (in.readBoolean()) { keepAlive = readTimeValue(in); } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { if (keepAlive == null) { out.writeBoolean(false); } else { diff --git a/src/main/java/org/elasticsearch/search/SearchContextException.java b/src/main/java/org/elasticsearch/search/SearchContextException.java index c0f679835d1..2f81ddc7e47 100644 --- a/src/main/java/org/elasticsearch/search/SearchContextException.java +++ b/src/main/java/org/elasticsearch/search/SearchContextException.java @@ -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.search; import org.elasticsearch.search.internal.SearchContext; /** - * @author kimchy (shay.banon) + * */ public class SearchContextException extends SearchException { diff --git a/src/main/java/org/elasticsearch/search/SearchContextMissingException.java b/src/main/java/org/elasticsearch/search/SearchContextMissingException.java index 21c4fa0a7af..495f297a742 100644 --- a/src/main/java/org/elasticsearch/search/SearchContextMissingException.java +++ b/src/main/java/org/elasticsearch/search/SearchContextMissingException.java @@ -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.search; import org.elasticsearch.ElasticSearchException; /** - * @author kimchy (Shay Banon) + * */ public class SearchContextMissingException extends ElasticSearchException { diff --git a/src/main/java/org/elasticsearch/search/SearchException.java b/src/main/java/org/elasticsearch/search/SearchException.java index 5519af12aa9..017bb7223e8 100644 --- a/src/main/java/org/elasticsearch/search/SearchException.java +++ b/src/main/java/org/elasticsearch/search/SearchException.java @@ -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.search; import org.elasticsearch.ElasticSearchException; /** - * @author kimchy (Shay Banon) + * */ public class SearchException extends ElasticSearchException { diff --git a/src/main/java/org/elasticsearch/search/SearchHit.java b/src/main/java/org/elasticsearch/search/SearchHit.java index 22938fa827d..05f8fe4489a 100644 --- a/src/main/java/org/elasticsearch/search/SearchHit.java +++ b/src/main/java/org/elasticsearch/search/SearchHit.java @@ -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.Map; /** * A single search hit. * - * @author kimchy (shay.banon) + * * @see SearchHits */ public interface SearchHit extends Streamable, ToXContent, Iterable { diff --git a/src/main/java/org/elasticsearch/search/SearchHitField.java b/src/main/java/org/elasticsearch/search/SearchHitField.java index b58796c657d..773e6c0b7ad 100644 --- a/src/main/java/org/elasticsearch/search/SearchHitField.java +++ b/src/main/java/org/elasticsearch/search/SearchHitField.java @@ -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.util.List; /** * A single field name and values part of a {@link SearchHit}. * - * @author kimchy (shay.banon) + * * @see SearchHit */ public interface SearchHitField extends Streamable, Iterable { diff --git a/src/main/java/org/elasticsearch/search/SearchHits.java b/src/main/java/org/elasticsearch/search/SearchHits.java index e9f915988b1..ea087c15050 100644 --- a/src/main/java/org/elasticsearch/search/SearchHits.java +++ b/src/main/java/org/elasticsearch/search/SearchHits.java @@ -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.common.xcontent.ToXContent; /** * The hits of a search request. * - * @author kimchy (shay.banon) + * */ public interface SearchHits extends Streamable, ToXContent, Iterable { diff --git a/src/main/java/org/elasticsearch/search/SearchModule.java b/src/main/java/org/elasticsearch/search/SearchModule.java index 2251e3c64ee..6666c21a87d 100644 --- a/src/main/java/org/elasticsearch/search/SearchModule.java +++ b/src/main/java/org/elasticsearch/search/SearchModule.java @@ -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,7 +19,7 @@ package org.elasticsearch.search; -import org.elasticsearch.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.inject.SpawnModules; @@ -36,15 +36,17 @@ import org.elasticsearch.search.highlight.HighlightPhase; import org.elasticsearch.search.query.QueryPhase; /** - * @author kimchy (shay.banon) + * */ public class SearchModule extends AbstractModule implements SpawnModules { - @Override public Iterable spawnModules() { + @Override + public Iterable spawnModules() { return ImmutableList.of(new TransportSearchModule(), new FacetModule()); } - @Override protected void configure() { + @Override + protected void configure() { bind(DfsPhase.class).asEagerSingleton(); bind(QueryPhase.class).asEagerSingleton(); bind(SearchService.class).asEagerSingleton(); diff --git a/src/main/java/org/elasticsearch/search/SearchParseElement.java b/src/main/java/org/elasticsearch/search/SearchParseElement.java index e740487de1d..271a85ffd97 100644 --- a/src/main/java/org/elasticsearch/search/SearchParseElement.java +++ b/src/main/java/org/elasticsearch/search/SearchParseElement.java @@ -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.xcontent.XContentParser; import org.elasticsearch.search.internal.SearchContext; /** - * @author kimchy (shay.banon) + * */ public interface SearchParseElement { diff --git a/src/main/java/org/elasticsearch/search/SearchParseException.java b/src/main/java/org/elasticsearch/search/SearchParseException.java index 4d042340ca1..ca917d55bf5 100644 --- a/src/main/java/org/elasticsearch/search/SearchParseException.java +++ b/src/main/java/org/elasticsearch/search/SearchParseException.java @@ -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.rest.RestStatus; import org.elasticsearch.search.internal.SearchContext; /** - * @author kimchy (shay.banon) + * */ public class SearchParseException extends SearchContextException { @@ -35,7 +35,8 @@ public class SearchParseException extends SearchContextException { super(context, "Parse Failure [" + msg + "]", cause); } - @Override public RestStatus status() { + @Override + public RestStatus status() { return RestStatus.BAD_REQUEST; } } diff --git a/src/main/java/org/elasticsearch/search/SearchPhase.java b/src/main/java/org/elasticsearch/search/SearchPhase.java index f9e2c3c5e0b..78e7a4df981 100644 --- a/src/main/java/org/elasticsearch/search/SearchPhase.java +++ b/src/main/java/org/elasticsearch/search/SearchPhase.java @@ -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.search.internal.SearchContext; import java.util.Map; /** - * @author kimchy (Shay Banon) + * */ public interface SearchPhase { diff --git a/src/main/java/org/elasticsearch/search/SearchPhaseResult.java b/src/main/java/org/elasticsearch/search/SearchPhaseResult.java index 7ee048b6e32..d71a621291b 100644 --- a/src/main/java/org/elasticsearch/search/SearchPhaseResult.java +++ b/src/main/java/org/elasticsearch/search/SearchPhaseResult.java @@ -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.search; import org.elasticsearch.common.io.stream.Streamable; /** - * @author kimchy (shay.banon) + * */ public interface SearchPhaseResult extends Streamable { diff --git a/src/main/java/org/elasticsearch/search/SearchService.java b/src/main/java/org/elasticsearch/search/SearchService.java index 9500203a707..956ab8b83f4 100644 --- a/src/main/java/org/elasticsearch/search/SearchService.java +++ b/src/main/java/org/elasticsearch/search/SearchService.java @@ -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.search; +import com.google.common.collect.ImmutableMap; import org.apache.lucene.search.Filter; import org.apache.lucene.search.TopDocs; import org.elasticsearch.ElasticSearchException; @@ -26,7 +27,6 @@ import org.elasticsearch.action.search.SearchType; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Unicode; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.component.AbstractLifecycleComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -47,19 +47,11 @@ import org.elasticsearch.script.ScriptService; import org.elasticsearch.search.dfs.CachedDfSource; import org.elasticsearch.search.dfs.DfsPhase; import org.elasticsearch.search.dfs.DfsSearchResult; -import org.elasticsearch.search.fetch.FetchPhase; -import org.elasticsearch.search.fetch.FetchSearchRequest; -import org.elasticsearch.search.fetch.FetchSearchResult; -import org.elasticsearch.search.fetch.QueryFetchSearchResult; -import org.elasticsearch.search.fetch.ScrollQueryFetchSearchResult; +import org.elasticsearch.search.fetch.*; import org.elasticsearch.search.internal.InternalScrollSearchRequest; import org.elasticsearch.search.internal.InternalSearchRequest; import org.elasticsearch.search.internal.SearchContext; -import org.elasticsearch.search.query.QueryPhase; -import org.elasticsearch.search.query.QueryPhaseExecutionException; -import org.elasticsearch.search.query.QuerySearchRequest; -import org.elasticsearch.search.query.QuerySearchResult; -import org.elasticsearch.search.query.ScrollQuerySearchResult; +import org.elasticsearch.search.query.*; import org.elasticsearch.threadpool.ThreadPool; import java.io.IOException; @@ -68,10 +60,10 @@ import java.util.Map; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.atomic.AtomicLong; -import static org.elasticsearch.common.unit.TimeValue.*; +import static org.elasticsearch.common.unit.TimeValue.timeValueMinutes; /** - * @author kimchy (shay.banon) + * */ public class SearchService extends AbstractLifecycleComponent { @@ -103,8 +95,9 @@ public class SearchService extends AbstractLifecycleComponent { private final ImmutableMap elementParsers; - @Inject public SearchService(Settings settings, ClusterService clusterService, IndicesService indicesService, IndicesLifecycle indicesLifecycle, ThreadPool threadPool, - ScriptService scriptService, DfsPhase dfsPhase, QueryPhase queryPhase, FetchPhase fetchPhase) { + @Inject + public SearchService(Settings settings, ClusterService clusterService, IndicesService indicesService, IndicesLifecycle indicesLifecycle, ThreadPool threadPool, + ScriptService scriptService, DfsPhase dfsPhase, QueryPhase queryPhase, FetchPhase fetchPhase) { super(settings); this.threadPool = threadPool; this.clusterService = clusterService; @@ -129,17 +122,20 @@ public class SearchService extends AbstractLifecycleComponent { this.keepAliveReaper = threadPool.scheduleWithFixedDelay(new Reaper(), keepAliveInterval); } - @Override protected void doStart() throws ElasticSearchException { + @Override + protected void doStart() throws ElasticSearchException { } - @Override protected void doStop() throws ElasticSearchException { + @Override + protected void doStop() throws ElasticSearchException { for (SearchContext context : activeContexts.values()) { freeContext(context); } activeContexts.clear(); } - @Override protected void doClose() throws ElasticSearchException { + @Override + protected void doClose() throws ElasticSearchException { keepAliveReaper.cancel(false); indicesService.indicesLifecycle().removeListener(indicesLifecycleListener); } @@ -619,17 +615,20 @@ public class SearchService extends AbstractLifecycleComponent { class CleanContextOnIndicesLifecycleListener extends IndicesLifecycle.Listener { - @Override public void beforeIndexClosed(IndexService indexService, boolean delete) { + @Override + public void beforeIndexClosed(IndexService indexService, boolean delete) { releaseContextsForIndex(indexService.index()); } - @Override public void beforeIndexShardClosed(ShardId shardId, @Nullable IndexShard indexShard, boolean delete) { + @Override + public void beforeIndexShardClosed(ShardId shardId, @Nullable IndexShard indexShard, boolean delete) { releaseContextsForShard(shardId); } } class Reaper implements Runnable { - @Override public void run() { + @Override + public void run() { long time = threadPool.estimatedTimeInMillis(); for (SearchContext context : activeContexts.values()) { if (context.lastAccessTime() == -1) { // its being processed or timeout is disabled diff --git a/src/main/java/org/elasticsearch/search/SearchShardTarget.java b/src/main/java/org/elasticsearch/search/SearchShardTarget.java index c21da6fdc77..e7ba7e07055 100644 --- a/src/main/java/org/elasticsearch/search/SearchShardTarget.java +++ b/src/main/java/org/elasticsearch/search/SearchShardTarget.java @@ -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.io.Serializable; /** * The target that the search request was executed on. * - * @author kimchy (shay.banon) + * */ public class SearchShardTarget implements Streamable, Serializable, Comparable { @@ -50,11 +50,13 @@ public class SearchShardTarget implements Streamable, Serializable, Comparable spawnModules() { + @Override + public Iterable spawnModules() { return ImmutableList.of(new TransportFacetModule()); } - @Override protected void configure() { + @Override + protected void configure() { } } diff --git a/src/main/java/org/elasticsearch/search/action/SearchServiceListener.java b/src/main/java/org/elasticsearch/search/action/SearchServiceListener.java index 2efc2e0d89e..2751994ce82 100644 --- a/src/main/java/org/elasticsearch/search/action/SearchServiceListener.java +++ b/src/main/java/org/elasticsearch/search/action/SearchServiceListener.java @@ -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.search.action; /** - * @author kimchy (Shay Banon) + * */ public interface SearchServiceListener { diff --git a/src/main/java/org/elasticsearch/search/action/SearchServiceTransportAction.java b/src/main/java/org/elasticsearch/search/action/SearchServiceTransportAction.java index 6b0accd8fcd..3e44a29a770 100644 --- a/src/main/java/org/elasticsearch/search/action/SearchServiceTransportAction.java +++ b/src/main/java/org/elasticsearch/search/action/SearchServiceTransportAction.java @@ -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 org.elasticsearch.transport.*; * An encapsulation of {@link org.elasticsearch.search.SearchService} operations exposed through * transport. * - * @author kimchy (Shay Banon) + * */ public class SearchServiceTransportAction extends AbstractComponent { @@ -58,7 +58,8 @@ public class SearchServiceTransportAction extends AbstractComponent { this.logger = logger; } - @Override public void handleException(TransportException exp) { + @Override + public void handleException(TransportException exp) { logger.warn("Failed to send release search context", exp); } } @@ -71,7 +72,8 @@ public class SearchServiceTransportAction extends AbstractComponent { private final FreeContextResponseHandler freeContextResponseHandler = new FreeContextResponseHandler(logger); - @Inject public SearchServiceTransportAction(Settings settings, TransportService transportService, ClusterService clusterService, SearchService searchService) { + @Inject + public SearchServiceTransportAction(Settings settings, TransportService transportService, ClusterService clusterService, SearchService searchService) { super(settings); this.transportService = transportService; this.clusterService = clusterService; @@ -109,19 +111,23 @@ public class SearchServiceTransportAction extends AbstractComponent { } else { transportService.sendRequest(node, SearchDfsTransportHandler.ACTION, request, new BaseTransportResponseHandler() { - @Override public DfsSearchResult newInstance() { + @Override + public DfsSearchResult newInstance() { return new DfsSearchResult(); } - @Override public void handleResponse(DfsSearchResult response) { + @Override + public void handleResponse(DfsSearchResult response) { listener.onResult(response); } - @Override public void handleException(TransportException exp) { + @Override + public void handleException(TransportException exp) { listener.onFailure(exp); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } }); @@ -139,19 +145,23 @@ public class SearchServiceTransportAction extends AbstractComponent { } else { transportService.sendRequest(node, SearchQueryTransportHandler.ACTION, request, new BaseTransportResponseHandler() { - @Override public QuerySearchResult newInstance() { + @Override + public QuerySearchResult newInstance() { return new QuerySearchResult(); } - @Override public void handleResponse(QuerySearchResult response) { + @Override + public void handleResponse(QuerySearchResult response) { listener.onResult(response); } - @Override public void handleException(TransportException exp) { + @Override + public void handleException(TransportException exp) { listener.onFailure(exp); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } }); @@ -169,19 +179,23 @@ public class SearchServiceTransportAction extends AbstractComponent { } else { transportService.sendRequest(node, SearchQueryByIdTransportHandler.ACTION, request, new BaseTransportResponseHandler() { - @Override public QuerySearchResult newInstance() { + @Override + public QuerySearchResult newInstance() { return new QuerySearchResult(); } - @Override public void handleResponse(QuerySearchResult response) { + @Override + public void handleResponse(QuerySearchResult response) { listener.onResult(response); } - @Override public void handleException(TransportException exp) { + @Override + public void handleException(TransportException exp) { listener.onFailure(exp); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } }); @@ -199,19 +213,23 @@ public class SearchServiceTransportAction extends AbstractComponent { } else { transportService.sendRequest(node, SearchQueryScrollTransportHandler.ACTION, request, new BaseTransportResponseHandler() { - @Override public ScrollQuerySearchResult newInstance() { + @Override + public ScrollQuerySearchResult newInstance() { return new ScrollQuerySearchResult(); } - @Override public void handleResponse(ScrollQuerySearchResult response) { + @Override + public void handleResponse(ScrollQuerySearchResult response) { listener.onResult(response.queryResult()); } - @Override public void handleException(TransportException exp) { + @Override + public void handleException(TransportException exp) { listener.onFailure(exp); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } }); @@ -229,19 +247,23 @@ public class SearchServiceTransportAction extends AbstractComponent { } else { transportService.sendRequest(node, SearchQueryFetchTransportHandler.ACTION, request, new BaseTransportResponseHandler() { - @Override public QueryFetchSearchResult newInstance() { + @Override + public QueryFetchSearchResult newInstance() { return new QueryFetchSearchResult(); } - @Override public void handleResponse(QueryFetchSearchResult response) { + @Override + public void handleResponse(QueryFetchSearchResult response) { listener.onResult(response); } - @Override public void handleException(TransportException exp) { + @Override + public void handleException(TransportException exp) { listener.onFailure(exp); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } }); @@ -259,19 +281,23 @@ public class SearchServiceTransportAction extends AbstractComponent { } else { transportService.sendRequest(node, SearchQueryQueryFetchTransportHandler.ACTION, request, new BaseTransportResponseHandler() { - @Override public QueryFetchSearchResult newInstance() { + @Override + public QueryFetchSearchResult newInstance() { return new QueryFetchSearchResult(); } - @Override public void handleResponse(QueryFetchSearchResult response) { + @Override + public void handleResponse(QueryFetchSearchResult response) { listener.onResult(response); } - @Override public void handleException(TransportException exp) { + @Override + public void handleException(TransportException exp) { listener.onFailure(exp); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } }); @@ -289,19 +315,23 @@ public class SearchServiceTransportAction extends AbstractComponent { } else { transportService.sendRequest(node, SearchQueryFetchScrollTransportHandler.ACTION, request, new BaseTransportResponseHandler() { - @Override public ScrollQueryFetchSearchResult newInstance() { + @Override + public ScrollQueryFetchSearchResult newInstance() { return new ScrollQueryFetchSearchResult(); } - @Override public void handleResponse(ScrollQueryFetchSearchResult response) { + @Override + public void handleResponse(ScrollQueryFetchSearchResult response) { listener.onResult(response.result()); } - @Override public void handleException(TransportException exp) { + @Override + public void handleException(TransportException exp) { listener.onFailure(exp); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } }); @@ -319,19 +349,23 @@ public class SearchServiceTransportAction extends AbstractComponent { } else { transportService.sendRequest(node, SearchFetchByIdTransportHandler.ACTION, request, new BaseTransportResponseHandler() { - @Override public FetchSearchResult newInstance() { + @Override + public FetchSearchResult newInstance() { return new FetchSearchResult(); } - @Override public void handleResponse(FetchSearchResult response) { + @Override + public void handleResponse(FetchSearchResult response) { listener.onResult(response); } - @Override public void handleException(TransportException exp) { + @Override + public void handleException(TransportException exp) { listener.onFailure(exp); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } }); @@ -349,19 +383,23 @@ public class SearchServiceTransportAction extends AbstractComponent { } else { transportService.sendRequest(node, SearchScanTransportHandler.ACTION, request, new BaseTransportResponseHandler() { - @Override public QuerySearchResult newInstance() { + @Override + public QuerySearchResult newInstance() { return new QuerySearchResult(); } - @Override public void handleResponse(QuerySearchResult response) { + @Override + public void handleResponse(QuerySearchResult response) { listener.onResult(response); } - @Override public void handleException(TransportException exp) { + @Override + public void handleException(TransportException exp) { listener.onFailure(exp); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } }); @@ -379,19 +417,23 @@ public class SearchServiceTransportAction extends AbstractComponent { } else { transportService.sendRequest(node, SearchScanScrollTransportHandler.ACTION, request, new BaseTransportResponseHandler() { - @Override public ScrollQueryFetchSearchResult newInstance() { + @Override + public ScrollQueryFetchSearchResult newInstance() { return new ScrollQueryFetchSearchResult(); } - @Override public void handleResponse(ScrollQueryFetchSearchResult response) { + @Override + public void handleResponse(ScrollQueryFetchSearchResult response) { listener.onResult(response.result()); } - @Override public void handleException(TransportException exp) { + @Override + public void handleException(TransportException exp) { listener.onFailure(exp); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } }); @@ -402,16 +444,19 @@ public class SearchServiceTransportAction extends AbstractComponent { static final String ACTION = "search/freeContext"; - @Override public LongStreamable newInstance() { + @Override + public LongStreamable newInstance() { return new LongStreamable(); } - @Override public void messageReceived(LongStreamable request, TransportChannel channel) throws Exception { + @Override + public void messageReceived(LongStreamable request, TransportChannel channel) throws Exception { searchService.freeContext(request.get()); channel.sendResponse(VoidStreamable.INSTANCE); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SEARCH; } } @@ -421,16 +466,19 @@ public class SearchServiceTransportAction extends AbstractComponent { static final String ACTION = "search/phase/dfs"; - @Override public InternalSearchRequest newInstance() { + @Override + public InternalSearchRequest newInstance() { return new InternalSearchRequest(); } - @Override public void messageReceived(InternalSearchRequest request, TransportChannel channel) throws Exception { + @Override + public void messageReceived(InternalSearchRequest request, TransportChannel channel) throws Exception { DfsSearchResult result = searchService.executeDfsPhase(request); channel.sendResponse(result); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SEARCH; } } @@ -439,16 +487,19 @@ public class SearchServiceTransportAction extends AbstractComponent { static final String ACTION = "search/phase/query"; - @Override public InternalSearchRequest newInstance() { + @Override + public InternalSearchRequest newInstance() { return new InternalSearchRequest(); } - @Override public void messageReceived(InternalSearchRequest request, TransportChannel channel) throws Exception { + @Override + public void messageReceived(InternalSearchRequest request, TransportChannel channel) throws Exception { QuerySearchResult result = searchService.executeQueryPhase(request); channel.sendResponse(result); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SEARCH; } } @@ -457,16 +508,19 @@ public class SearchServiceTransportAction extends AbstractComponent { static final String ACTION = "search/phase/query/id"; - @Override public QuerySearchRequest newInstance() { + @Override + public QuerySearchRequest newInstance() { return new QuerySearchRequest(); } - @Override public void messageReceived(QuerySearchRequest request, TransportChannel channel) throws Exception { + @Override + public void messageReceived(QuerySearchRequest request, TransportChannel channel) throws Exception { QuerySearchResult result = searchService.executeQueryPhase(request); channel.sendResponse(result); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SEARCH; } } @@ -475,16 +529,19 @@ public class SearchServiceTransportAction extends AbstractComponent { static final String ACTION = "search/phase/query/scroll"; - @Override public InternalScrollSearchRequest newInstance() { + @Override + public InternalScrollSearchRequest newInstance() { return new InternalScrollSearchRequest(); } - @Override public void messageReceived(InternalScrollSearchRequest request, TransportChannel channel) throws Exception { + @Override + public void messageReceived(InternalScrollSearchRequest request, TransportChannel channel) throws Exception { ScrollQuerySearchResult result = searchService.executeQueryPhase(request); channel.sendResponse(result); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SEARCH; } } @@ -493,16 +550,19 @@ public class SearchServiceTransportAction extends AbstractComponent { static final String ACTION = "search/phase/query+fetch"; - @Override public InternalSearchRequest newInstance() { + @Override + public InternalSearchRequest newInstance() { return new InternalSearchRequest(); } - @Override public void messageReceived(InternalSearchRequest request, TransportChannel channel) throws Exception { + @Override + public void messageReceived(InternalSearchRequest request, TransportChannel channel) throws Exception { QueryFetchSearchResult result = searchService.executeFetchPhase(request); channel.sendResponse(result); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SEARCH; } } @@ -511,16 +571,19 @@ public class SearchServiceTransportAction extends AbstractComponent { static final String ACTION = "search/phase/query/query+fetch"; - @Override public QuerySearchRequest newInstance() { + @Override + public QuerySearchRequest newInstance() { return new QuerySearchRequest(); } - @Override public void messageReceived(QuerySearchRequest request, TransportChannel channel) throws Exception { + @Override + public void messageReceived(QuerySearchRequest request, TransportChannel channel) throws Exception { QueryFetchSearchResult result = searchService.executeFetchPhase(request); channel.sendResponse(result); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SEARCH; } } @@ -529,16 +592,19 @@ public class SearchServiceTransportAction extends AbstractComponent { static final String ACTION = "search/phase/fetch/id"; - @Override public FetchSearchRequest newInstance() { + @Override + public FetchSearchRequest newInstance() { return new FetchSearchRequest(); } - @Override public void messageReceived(FetchSearchRequest request, TransportChannel channel) throws Exception { + @Override + public void messageReceived(FetchSearchRequest request, TransportChannel channel) throws Exception { FetchSearchResult result = searchService.executeFetchPhase(request); channel.sendResponse(result); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SEARCH; } } @@ -547,16 +613,19 @@ public class SearchServiceTransportAction extends AbstractComponent { static final String ACTION = "search/phase/query+fetch/scroll"; - @Override public InternalScrollSearchRequest newInstance() { + @Override + public InternalScrollSearchRequest newInstance() { return new InternalScrollSearchRequest(); } - @Override public void messageReceived(InternalScrollSearchRequest request, TransportChannel channel) throws Exception { + @Override + public void messageReceived(InternalScrollSearchRequest request, TransportChannel channel) throws Exception { ScrollQueryFetchSearchResult result = searchService.executeFetchPhase(request); channel.sendResponse(result); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SEARCH; } } @@ -565,16 +634,19 @@ public class SearchServiceTransportAction extends AbstractComponent { static final String ACTION = "search/phase/scan"; - @Override public InternalSearchRequest newInstance() { + @Override + public InternalSearchRequest newInstance() { return new InternalSearchRequest(); } - @Override public void messageReceived(InternalSearchRequest request, TransportChannel channel) throws Exception { + @Override + public void messageReceived(InternalSearchRequest request, TransportChannel channel) throws Exception { QuerySearchResult result = searchService.executeScan(request); channel.sendResponse(result); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SEARCH; } } @@ -583,16 +655,19 @@ public class SearchServiceTransportAction extends AbstractComponent { static final String ACTION = "search/phase/scan/scroll"; - @Override public InternalScrollSearchRequest newInstance() { + @Override + public InternalScrollSearchRequest newInstance() { return new InternalScrollSearchRequest(); } - @Override public void messageReceived(InternalScrollSearchRequest request, TransportChannel channel) throws Exception { + @Override + public void messageReceived(InternalScrollSearchRequest request, TransportChannel channel) throws Exception { ScrollQueryFetchSearchResult result = searchService.executeScan(request); channel.sendResponse(result); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SEARCH; } } diff --git a/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java b/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java index 552ed9ec1c1..1b9fd6e77fd 100644 --- a/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java +++ b/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java @@ -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,14 +19,14 @@ package org.elasticsearch.search.builder; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; +import gnu.trove.iterator.TObjectFloatIterator; +import gnu.trove.map.hash.TObjectFloatHashMap; import org.elasticsearch.ElasticSearchGenerationException; import org.elasticsearch.client.Requests; import org.elasticsearch.common.Unicode; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.io.BytesStream; -import org.elasticsearch.common.trove.iterator.TObjectFloatIterator; -import org.elasticsearch.common.trove.map.hash.TObjectFloatHashMap; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; @@ -48,7 +48,7 @@ import java.util.Map; * A search source builder allowing to easily build search source. Simple construction * using {@link org.elasticsearch.search.builder.SearchSourceBuilder#searchSource()}. * - * @author kimchy (shay.banon) + * * @see org.elasticsearch.action.search.SearchRequest#source(SearchSourceBuilder) */ public class SearchSourceBuilder implements ToXContent { @@ -485,7 +485,8 @@ public class SearchSourceBuilder implements ToXContent { return this; } - @Override public String toString() { + @Override + public String toString() { try { XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON).prettyPrint(); toXContent(builder, ToXContent.EMPTY_PARAMS); @@ -520,7 +521,8 @@ public class SearchSourceBuilder implements ToXContent { } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); if (from != -1) { diff --git a/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilderException.java b/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilderException.java index 11d41ae70c0..08259c3ec4b 100644 --- a/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilderException.java +++ b/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilderException.java @@ -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.search.builder; import org.elasticsearch.ElasticSearchException; /** - * @author kimchy (Shay Banon) + * */ public class SearchSourceBuilderException extends ElasticSearchException { diff --git a/src/main/java/org/elasticsearch/search/controller/ScoreDocQueue.java b/src/main/java/org/elasticsearch/search/controller/ScoreDocQueue.java index 39dca4cc560..a9cbcb7c21e 100644 --- a/src/main/java/org/elasticsearch/search/controller/ScoreDocQueue.java +++ b/src/main/java/org/elasticsearch/search/controller/ScoreDocQueue.java @@ -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.util.PriorityQueue; /** *

    Same as lucene {@link org.apache.lucene.search.HitQueue}. * - * @author kimchy (Shay Banon) + * */ public class ScoreDocQueue extends PriorityQueue { diff --git a/src/main/java/org/elasticsearch/search/controller/SearchPhaseController.java b/src/main/java/org/elasticsearch/search/controller/SearchPhaseController.java index c9df81a67a2..3251ecc1479 100644 --- a/src/main/java/org/elasticsearch/search/controller/SearchPhaseController.java +++ b/src/main/java/org/elasticsearch/search/controller/SearchPhaseController.java @@ -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,24 +19,20 @@ package org.elasticsearch.search.controller; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Ordering; +import gnu.trove.ExtTIntArrayList; +import gnu.trove.impl.Constants; +import gnu.trove.map.hash.TObjectIntHashMap; import org.apache.lucene.index.Term; -import org.apache.lucene.search.FieldDoc; -import org.apache.lucene.search.ScoreDoc; -import org.apache.lucene.search.ShardFieldDocSortedHitQueue; -import org.apache.lucene.search.SortField; -import org.apache.lucene.search.TopFieldDocs; +import org.apache.lucene.search.*; import org.apache.lucene.util.PriorityQueue; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.collect.Iterables; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.collect.Maps; -import org.elasticsearch.common.collect.Ordering; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.trove.ExtTIntArrayList; -import org.elasticsearch.common.trove.impl.Constants; -import org.elasticsearch.common.trove.map.hash.TObjectIntHashMap; import org.elasticsearch.search.SearchShardTarget; import org.elasticsearch.search.dfs.AggregatedDfs; import org.elasticsearch.search.dfs.DfsSearchResult; @@ -57,12 +53,13 @@ import java.util.List; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class SearchPhaseController extends AbstractComponent { public static Ordering QUERY_RESULT_ORDERING = new Ordering() { - @Override public int compare(@Nullable QuerySearchResultProvider o1, @Nullable QuerySearchResultProvider o2) { + @Override + public int compare(@Nullable QuerySearchResultProvider o1, @Nullable QuerySearchResultProvider o2) { int i = o1.shardTarget().index().compareTo(o2.shardTarget().index()); if (i == 0) { i = o1.shardTarget().shardId() - o2.shardTarget().shardId(); @@ -77,7 +74,8 @@ public class SearchPhaseController extends AbstractComponent { private final boolean optimizeSingleShard; - @Inject public SearchPhaseController(Settings settings, FacetProcessors facetProcessors) { + @Inject + public SearchPhaseController(Settings settings, FacetProcessors facetProcessors) { super(settings); this.facetProcessors = facetProcessors; this.optimizeSingleShard = componentSettings.getAsBoolean("optimize_single_shard", true); diff --git a/src/main/java/org/elasticsearch/search/controller/ShardDoc.java b/src/main/java/org/elasticsearch/search/controller/ShardDoc.java index 56f7022d64e..c4265e809fd 100644 --- a/src/main/java/org/elasticsearch/search/controller/ShardDoc.java +++ b/src/main/java/org/elasticsearch/search/controller/ShardDoc.java @@ -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.search.controller; import org.elasticsearch.search.SearchShardTarget; /** - * @author kimchy (shay.banon) + * */ public interface ShardDoc { diff --git a/src/main/java/org/elasticsearch/search/controller/ShardFieldDoc.java b/src/main/java/org/elasticsearch/search/controller/ShardFieldDoc.java index 386e8194ccf..a3c7d20df76 100644 --- a/src/main/java/org/elasticsearch/search/controller/ShardFieldDoc.java +++ b/src/main/java/org/elasticsearch/search/controller/ShardFieldDoc.java @@ -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.FieldDoc; import org.elasticsearch.search.SearchShardTarget; /** - * @author kimchy (shay.banon) + * */ public class ShardFieldDoc extends FieldDoc implements ShardDoc { @@ -39,15 +39,18 @@ public class ShardFieldDoc extends FieldDoc implements ShardDoc { this.shardTarget = shardTarget; } - @Override public SearchShardTarget shardTarget() { + @Override + public SearchShardTarget shardTarget() { return this.shardTarget; } - @Override public int docId() { + @Override + public int docId() { return this.doc; } - @Override public float score() { + @Override + public float score() { return score; } } diff --git a/src/main/java/org/elasticsearch/search/controller/ShardScoreDoc.java b/src/main/java/org/elasticsearch/search/controller/ShardScoreDoc.java index 683648b03f4..c0be8b855a1 100644 --- a/src/main/java/org/elasticsearch/search/controller/ShardScoreDoc.java +++ b/src/main/java/org/elasticsearch/search/controller/ShardScoreDoc.java @@ -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.ScoreDoc; import org.elasticsearch.search.SearchShardTarget; /** - * @author kimchy (Shay Banon) + * */ public class ShardScoreDoc extends ScoreDoc implements ShardDoc { @@ -34,15 +34,18 @@ public class ShardScoreDoc extends ScoreDoc implements ShardDoc { this.shardTarget = shardTarget; } - @Override public SearchShardTarget shardTarget() { + @Override + public SearchShardTarget shardTarget() { return this.shardTarget; } - @Override public int docId() { + @Override + public int docId() { return doc; } - @Override public float score() { + @Override + public float score() { return score; } } diff --git a/src/main/java/org/elasticsearch/search/count/CountSearchResult.java b/src/main/java/org/elasticsearch/search/count/CountSearchResult.java index 10a393c134e..2e3dc9fdded 100644 --- a/src/main/java/org/elasticsearch/search/count/CountSearchResult.java +++ b/src/main/java/org/elasticsearch/search/count/CountSearchResult.java @@ -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,20 +54,24 @@ public class CountSearchResult implements Streamable, SearchPhaseResult { return this.totalHits; } - @Override public SearchShardTarget shardTarget() { + @Override + public SearchShardTarget shardTarget() { return shardTarget; } - @Override public void shardTarget(SearchShardTarget shardTarget) { + @Override + public void shardTarget(SearchShardTarget shardTarget) { this.shardTarget = shardTarget; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { id = in.readLong(); totalHits = in.readVLong(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeLong(id); out.writeVLong(totalHits); } diff --git a/src/main/java/org/elasticsearch/search/dfs/AggregatedDfs.java b/src/main/java/org/elasticsearch/search/dfs/AggregatedDfs.java index 069d71644d9..72fbdb702bc 100644 --- a/src/main/java/org/elasticsearch/search/dfs/AggregatedDfs.java +++ b/src/main/java/org/elasticsearch/search/dfs/AggregatedDfs.java @@ -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,19 +19,19 @@ package org.elasticsearch.search.dfs; +import gnu.trove.ExtTObjectIntHasMap; +import gnu.trove.impl.Constants; +import gnu.trove.iterator.TObjectIntIterator; +import gnu.trove.map.hash.TObjectIntHashMap; import org.apache.lucene.index.Term; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Streamable; -import org.elasticsearch.common.trove.ExtTObjectIntHasMap; -import org.elasticsearch.common.trove.impl.Constants; -import org.elasticsearch.common.trove.iterator.TObjectIntIterator; -import org.elasticsearch.common.trove.map.hash.TObjectIntHashMap; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class AggregatedDfs implements Streamable { @@ -62,7 +62,8 @@ public class AggregatedDfs implements Streamable { return result; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { int size = in.readVInt(); dfMap = new ExtTObjectIntHasMap(size, Constants.DEFAULT_LOAD_FACTOR, -1); for (int i = 0; i < size; i++) { @@ -71,10 +72,11 @@ public class AggregatedDfs implements Streamable { maxDoc = in.readVLong(); } - @Override public void writeTo(final StreamOutput out) throws IOException { + @Override + public void writeTo(final StreamOutput out) throws IOException { out.writeVInt(dfMap.size()); - for (TObjectIntIterator it = dfMap.iterator(); it.hasNext();) { + for (TObjectIntIterator it = dfMap.iterator(); it.hasNext(); ) { it.advance(); out.writeUTF(it.key().field()); out.writeUTF(it.key().text()); diff --git a/src/main/java/org/elasticsearch/search/dfs/CachedDfSource.java b/src/main/java/org/elasticsearch/search/dfs/CachedDfSource.java index 80f5804de91..d2a50b97d16 100644 --- a/src/main/java/org/elasticsearch/search/dfs/CachedDfSource.java +++ b/src/main/java/org/elasticsearch/search/dfs/CachedDfSource.java @@ -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.apache.lucene.search.*; import java.io.IOException; /** - * @author kimchy (Shay Banon) + * */ public class CachedDfSource extends Searcher { diff --git a/src/main/java/org/elasticsearch/search/dfs/DfsPhase.java b/src/main/java/org/elasticsearch/search/dfs/DfsPhase.java index 8d8cf941120..34615bed346 100644 --- a/src/main/java/org/elasticsearch/search/dfs/DfsPhase.java +++ b/src/main/java/org/elasticsearch/search/dfs/DfsPhase.java @@ -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.search.dfs; +import com.google.common.collect.ImmutableMap; +import gnu.trove.set.hash.THashSet; import org.apache.lucene.index.Term; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.thread.ThreadLocals; -import org.elasticsearch.common.trove.set.hash.THashSet; import org.elasticsearch.search.SearchParseElement; import org.elasticsearch.search.SearchPhase; import org.elasticsearch.search.internal.SearchContext; @@ -30,21 +30,24 @@ import org.elasticsearch.search.internal.SearchContext; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class DfsPhase implements SearchPhase { private static ThreadLocal>> cachedTermsSet = new ThreadLocal>>() { - @Override protected ThreadLocals.CleanableValue> initialValue() { + @Override + protected ThreadLocals.CleanableValue> initialValue() { return new ThreadLocals.CleanableValue>(new THashSet()); } }; - @Override public Map parseElements() { + @Override + public Map parseElements() { return ImmutableMap.of(); } - @Override public void preProcess(SearchContext context) { + @Override + public void preProcess(SearchContext context) { } public void execute(SearchContext context) { diff --git a/src/main/java/org/elasticsearch/search/dfs/DfsPhaseExecutionException.java b/src/main/java/org/elasticsearch/search/dfs/DfsPhaseExecutionException.java index aeb4c04c9f2..7b2637c7e33 100644 --- a/src/main/java/org/elasticsearch/search/dfs/DfsPhaseExecutionException.java +++ b/src/main/java/org/elasticsearch/search/dfs/DfsPhaseExecutionException.java @@ -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.search.SearchContextException; import org.elasticsearch.search.internal.SearchContext; /** - * @author kimchy (Shay Banon) + * */ public class DfsPhaseExecutionException extends SearchContextException { diff --git a/src/main/java/org/elasticsearch/search/dfs/DfsSearchResult.java b/src/main/java/org/elasticsearch/search/dfs/DfsSearchResult.java index fc642d85600..17ccdb3a8a6 100644 --- a/src/main/java/org/elasticsearch/search/dfs/DfsSearchResult.java +++ b/src/main/java/org/elasticsearch/search/dfs/DfsSearchResult.java @@ -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.search.SearchShardTarget; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class DfsSearchResult implements SearchPhaseResult { @@ -63,7 +63,8 @@ public class DfsSearchResult implements SearchPhaseResult { return shardTarget; } - @Override public void shardTarget(SearchShardTarget shardTarget) { + @Override + public void shardTarget(SearchShardTarget shardTarget) { this.shardTarget = shardTarget; } @@ -96,7 +97,8 @@ public class DfsSearchResult implements SearchPhaseResult { return result; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { id = in.readLong(); // shardTarget = readSearchShardTarget(in); int termsSize = in.readVInt(); @@ -120,7 +122,8 @@ public class DfsSearchResult implements SearchPhaseResult { maxDoc = in.readVInt(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeLong(id); // shardTarget.writeTo(out); out.writeVInt(terms.length); diff --git a/src/main/java/org/elasticsearch/search/facet/AbstractFacetBuilder.java b/src/main/java/org/elasticsearch/search/facet/AbstractFacetBuilder.java index 2819b895e21..05863897394 100644 --- a/src/main/java/org/elasticsearch/search/facet/AbstractFacetBuilder.java +++ b/src/main/java/org/elasticsearch/search/facet/AbstractFacetBuilder.java @@ -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.search.internal.ContextIndexSearcher; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public abstract class AbstractFacetBuilder implements ToXContent { diff --git a/src/main/java/org/elasticsearch/search/facet/AbstractFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/AbstractFacetCollector.java index 271f493ccab..03b49384ae2 100644 --- a/src/main/java/org/elasticsearch/search/facet/AbstractFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/AbstractFacetCollector.java @@ -19,10 +19,10 @@ package org.elasticsearch.search.facet; +import com.google.common.collect.ImmutableList; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.Filter; import org.apache.lucene.search.Scorer; -import org.elasticsearch.common.collect.ImmutableList; import org.elasticsearch.common.lucene.docset.DocSet; import org.elasticsearch.common.lucene.docset.DocSets; import org.elasticsearch.common.lucene.search.AndFilter; @@ -30,7 +30,7 @@ import org.elasticsearch.common.lucene.search.AndFilter; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public abstract class AbstractFacetCollector extends FacetCollector { @@ -48,7 +48,8 @@ public abstract class AbstractFacetCollector extends FacetCollector { return this.filter; } - @Override public void setFilter(Filter filter) { + @Override + public void setFilter(Filter filter) { if (this.filter == null) { this.filter = filter; } else { @@ -56,15 +57,18 @@ public abstract class AbstractFacetCollector extends FacetCollector { } } - @Override public void setScorer(Scorer scorer) throws IOException { + @Override + public void setScorer(Scorer scorer) throws IOException { // usually, there is nothing to do here } - @Override public boolean acceptsDocsOutOfOrder() { + @Override + public boolean acceptsDocsOutOfOrder() { return true; // when working on FieldData, docs can be out of order } - @Override public void setNextReader(IndexReader reader, int docBase) throws IOException { + @Override + public void setNextReader(IndexReader reader, int docBase) throws IOException { if (filter != null) { docSet = DocSets.convert(reader, filter.getDocIdSet(reader)); } @@ -73,7 +77,8 @@ public abstract class AbstractFacetCollector extends FacetCollector { protected abstract void doSetNextReader(IndexReader reader, int docBase) throws IOException; - @Override public void collect(int doc) throws IOException { + @Override + public void collect(int doc) throws IOException { if (docSet == null) { doCollect(doc); } else if (docSet.get(doc)) { diff --git a/src/main/java/org/elasticsearch/search/facet/Facet.java b/src/main/java/org/elasticsearch/search/facet/Facet.java index aaf1509d8e2..ee2e605b701 100644 --- a/src/main/java/org/elasticsearch/search/facet/Facet.java +++ b/src/main/java/org/elasticsearch/search/facet/Facet.java @@ -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.search.facet; /** * A search facet. * - * @author kimchy (shay.banon) + * */ public interface Facet { diff --git a/src/main/java/org/elasticsearch/search/facet/FacetBinaryParseElement.java b/src/main/java/org/elasticsearch/search/facet/FacetBinaryParseElement.java index 84514187f5b..d374b157a78 100644 --- a/src/main/java/org/elasticsearch/search/facet/FacetBinaryParseElement.java +++ b/src/main/java/org/elasticsearch/search/facet/FacetBinaryParseElement.java @@ -25,15 +25,17 @@ import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.search.internal.SearchContext; /** - * @author kimchy (shay.banon) + * */ public class FacetBinaryParseElement extends FacetParseElement { - @Inject public FacetBinaryParseElement(FacetProcessors facetProcessors) { + @Inject + public FacetBinaryParseElement(FacetProcessors facetProcessors) { super(facetProcessors); } - @Override public void parse(XContentParser parser, SearchContext context) throws Exception { + @Override + public void parse(XContentParser parser, SearchContext context) throws Exception { byte[] facetSource = parser.binaryValue(); XContentParser fSourceParser = XContentFactory.xContent(facetSource).createParser(facetSource); try { diff --git a/src/main/java/org/elasticsearch/search/facet/FacetBuilders.java b/src/main/java/org/elasticsearch/search/facet/FacetBuilders.java index 5f809e39444..410a9305696 100644 --- a/src/main/java/org/elasticsearch/search/facet/FacetBuilders.java +++ b/src/main/java/org/elasticsearch/search/facet/FacetBuilders.java @@ -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.search.facet.terms.TermsFacetBuilder; import org.elasticsearch.search.facet.termsstats.TermsStatsFacetBuilder; /** - * @author kimchy (shay.banon) + * */ public class FacetBuilders { diff --git a/src/main/java/org/elasticsearch/search/facet/FacetCollector.java b/src/main/java/org/elasticsearch/search/facet/FacetCollector.java index f3226788dc5..ef07e21ddc1 100644 --- a/src/main/java/org/elasticsearch/search/facet/FacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/FacetCollector.java @@ -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.Collector; import org.apache.lucene.search.Filter; /** - * @author kimchy (shay.banon) + * */ public abstract class FacetCollector extends Collector { diff --git a/src/main/java/org/elasticsearch/search/facet/FacetModule.java b/src/main/java/org/elasticsearch/search/facet/FacetModule.java index 7302b717cc8..24c444f2e74 100644 --- a/src/main/java/org/elasticsearch/search/facet/FacetModule.java +++ b/src/main/java/org/elasticsearch/search/facet/FacetModule.java @@ -19,7 +19,7 @@ package org.elasticsearch.search.facet; -import org.elasticsearch.common.collect.Lists; +import com.google.common.collect.Lists; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.multibindings.Multibinder; import org.elasticsearch.search.facet.datehistogram.DateHistogramFacetProcessor; @@ -35,7 +35,7 @@ import org.elasticsearch.search.facet.termsstats.TermsStatsFacetProcessor; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class FacetModule extends AbstractModule { @@ -57,7 +57,8 @@ public class FacetModule extends AbstractModule { processors.add(facetProcessor); } - @Override protected void configure() { + @Override + protected void configure() { Multibinder multibinder = Multibinder.newSetBinder(binder(), FacetProcessor.class); for (Class processor : processors) { multibinder.addBinding().to(processor); diff --git a/src/main/java/org/elasticsearch/search/facet/FacetParseElement.java b/src/main/java/org/elasticsearch/search/facet/FacetParseElement.java index f9ae99f97e3..214e641bd63 100644 --- a/src/main/java/org/elasticsearch/search/facet/FacetParseElement.java +++ b/src/main/java/org/elasticsearch/search/facet/FacetParseElement.java @@ -19,8 +19,8 @@ package org.elasticsearch.search.facet; +import com.google.common.collect.Lists; import org.apache.lucene.search.Filter; -import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.mapper.MapperService; @@ -51,17 +51,19 @@ import java.util.List; * } * * - * @author kimchy (shay.banon) + * */ public class FacetParseElement implements SearchParseElement { private final FacetProcessors facetProcessors; - @Inject public FacetParseElement(FacetProcessors facetProcessors) { + @Inject + public FacetParseElement(FacetProcessors facetProcessors) { this.facetProcessors = facetProcessors; } - @Override public void parse(XContentParser parser, SearchContext context) throws Exception { + @Override + public void parse(XContentParser parser, SearchContext context) throws Exception { XContentParser.Token token; List facetCollectors = null; diff --git a/src/main/java/org/elasticsearch/search/facet/FacetPhase.java b/src/main/java/org/elasticsearch/search/facet/FacetPhase.java index b05dedf0b95..ff3fb5191e3 100644 --- a/src/main/java/org/elasticsearch/search/facet/FacetPhase.java +++ b/src/main/java/org/elasticsearch/search/facet/FacetPhase.java @@ -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,16 +19,11 @@ package org.elasticsearch.search.facet; -import org.apache.lucene.search.Collector; -import org.apache.lucene.search.DeletionAwareConstantScoreQuery; -import org.apache.lucene.search.Filter; -import org.apache.lucene.search.FilteredQuery; -import org.apache.lucene.search.MultiCollector; -import org.apache.lucene.search.Query; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import org.apache.lucene.search.*; import org.elasticsearch.ElasticSearchException; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.collect.Maps; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.lucene.search.Queries; import org.elasticsearch.index.search.nested.BlockJoinQuery; @@ -44,7 +39,7 @@ import java.util.List; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class FacetPhase implements SearchPhase { @@ -52,16 +47,19 @@ public class FacetPhase implements SearchPhase { private final FacetBinaryParseElement facetBinaryParseElement; - @Inject public FacetPhase(FacetParseElement facetParseElement, FacetBinaryParseElement facetBinaryParseElement) { + @Inject + public FacetPhase(FacetParseElement facetParseElement, FacetBinaryParseElement facetBinaryParseElement) { this.facetParseElement = facetParseElement; this.facetBinaryParseElement = facetBinaryParseElement; } - @Override public Map parseElements() { + @Override + public Map parseElements() { return ImmutableMap.of("facets", facetParseElement, "facets_binary", facetBinaryParseElement, "facetsBinary", facetBinaryParseElement); } - @Override public void preProcess(SearchContext context) { + @Override + public void preProcess(SearchContext context) { // add specific facets to nested queries... if (context.nestedQueries() != null) { for (Map.Entry entry : context.nestedQueries().entrySet()) { @@ -77,7 +75,8 @@ public class FacetPhase implements SearchPhase { } } - @Override public void execute(SearchContext context) throws ElasticSearchException { + @Override + public void execute(SearchContext context) throws ElasticSearchException { if (context.facets() == null || context.facets().facetCollectors() == null) { return; } diff --git a/src/main/java/org/elasticsearch/search/facet/FacetPhaseExecutionException.java b/src/main/java/org/elasticsearch/search/facet/FacetPhaseExecutionException.java index 0855a97d957..3ce99cfaff4 100644 --- a/src/main/java/org/elasticsearch/search/facet/FacetPhaseExecutionException.java +++ b/src/main/java/org/elasticsearch/search/facet/FacetPhaseExecutionException.java @@ -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.search.facet; import org.elasticsearch.ElasticSearchException; /** - * @author kimchy (shay.banon) + * */ public class FacetPhaseExecutionException extends ElasticSearchException { diff --git a/src/main/java/org/elasticsearch/search/facet/FacetProcessor.java b/src/main/java/org/elasticsearch/search/facet/FacetProcessor.java index a8fe61b9fff..e44734617e9 100644 --- a/src/main/java/org/elasticsearch/search/facet/FacetProcessor.java +++ b/src/main/java/org/elasticsearch/search/facet/FacetProcessor.java @@ -26,7 +26,7 @@ import java.io.IOException; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public interface FacetProcessor { diff --git a/src/main/java/org/elasticsearch/search/facet/FacetProcessors.java b/src/main/java/org/elasticsearch/search/facet/FacetProcessors.java index fb9541fae7d..4d369324d98 100644 --- a/src/main/java/org/elasticsearch/search/facet/FacetProcessors.java +++ b/src/main/java/org/elasticsearch/search/facet/FacetProcessors.java @@ -19,20 +19,21 @@ package org.elasticsearch.search.facet; -import org.elasticsearch.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMap; import org.elasticsearch.common.collect.MapBuilder; import org.elasticsearch.common.inject.Inject; import java.util.Set; /** - * @author kimchy (shay.banon) + * */ public class FacetProcessors { private final ImmutableMap processors; - @Inject public FacetProcessors(Set processors) { + @Inject + public FacetProcessors(Set processors) { MapBuilder builder = MapBuilder.newMapBuilder(); for (FacetProcessor processor : processors) { for (String type : processor.types()) { diff --git a/src/main/java/org/elasticsearch/search/facet/Facets.java b/src/main/java/org/elasticsearch/search/facet/Facets.java index b86f885204a..4adc5838180 100644 --- a/src/main/java/org/elasticsearch/search/facet/Facets.java +++ b/src/main/java/org/elasticsearch/search/facet/Facets.java @@ -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.Map; /** * Facets of search action. * - * @author kimchy (shay.banon) + * */ public interface Facets extends Iterable { diff --git a/src/main/java/org/elasticsearch/search/facet/InternalFacet.java b/src/main/java/org/elasticsearch/search/facet/InternalFacet.java index 45ee6399464..d2b94355f52 100644 --- a/src/main/java/org/elasticsearch/search/facet/InternalFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/InternalFacet.java @@ -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,7 +19,7 @@ package org.elasticsearch.search.facet; -import org.elasticsearch.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMap; import org.elasticsearch.common.collect.MapBuilder; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.Streamable; @@ -28,7 +28,7 @@ import org.elasticsearch.common.xcontent.ToXContent; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public interface InternalFacet extends Facet, Streamable, ToXContent { diff --git a/src/main/java/org/elasticsearch/search/facet/InternalFacets.java b/src/main/java/org/elasticsearch/search/facet/InternalFacets.java index 0d598ef7e30..a32e5070909 100644 --- a/src/main/java/org/elasticsearch/search/facet/InternalFacets.java +++ b/src/main/java/org/elasticsearch/search/facet/InternalFacets.java @@ -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.search.facet; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.Lists; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Lists; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Streamable; @@ -34,10 +34,10 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import static org.elasticsearch.common.collect.Maps.*; +import static com.google.common.collect.Maps.newHashMap; /** - * @author kimchy (shay.banon) + * */ public class InternalFacets implements Facets, Streamable, ToXContent, Iterable { @@ -59,7 +59,8 @@ public class InternalFacets implements Facets, Streamable, ToXContent, Iterable< /** * Iterates over the {@link Facet}s. */ - @Override public Iterator iterator() { + @Override + public Iterator iterator() { return facets.iterator(); } @@ -95,14 +96,17 @@ public class InternalFacets implements Facets, Streamable, ToXContent, Iterable< /** * Returns the facet by name already casted to the specified type. */ - @Override public T facet(Class facetType, String name) { + @Override + public T facet(Class facetType, String name) { return facetType.cast(facet(name)); } /** * A facet of the specified name. */ - @SuppressWarnings({"unchecked"}) @Override public T facet(String name) { + @SuppressWarnings({"unchecked"}) + @Override + public T facet(String name) { return (T) facetsAsMap().get(name); } @@ -110,7 +114,8 @@ public class InternalFacets implements Facets, Streamable, ToXContent, Iterable< static final XContentBuilderString FACETS = new XContentBuilderString("facets"); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(Fields.FACETS); for (Facet facet : facets) { ((InternalFacet) facet).toXContent(builder, params); @@ -125,7 +130,8 @@ public class InternalFacets implements Facets, Streamable, ToXContent, Iterable< return result; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { int size = in.readVInt(); if (size == 0) { facets = ImmutableList.of(); @@ -140,7 +146,8 @@ public class InternalFacets implements Facets, Streamable, ToXContent, Iterable< } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeVInt(facets.size()); for (Facet facet : facets) { InternalFacet internalFacet = (InternalFacet) facet; diff --git a/src/main/java/org/elasticsearch/search/facet/OptimizeGlobalFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/OptimizeGlobalFacetCollector.java index ff95fa3a98f..bb84ae905cb 100644 --- a/src/main/java/org/elasticsearch/search/facet/OptimizeGlobalFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/OptimizeGlobalFacetCollector.java @@ -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 diff --git a/src/main/java/org/elasticsearch/search/facet/SearchContextFacets.java b/src/main/java/org/elasticsearch/search/facet/SearchContextFacets.java index 29101034b27..489371e2f6e 100644 --- a/src/main/java/org/elasticsearch/search/facet/SearchContextFacets.java +++ b/src/main/java/org/elasticsearch/search/facet/SearchContextFacets.java @@ -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.search.facet; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class SearchContextFacets { diff --git a/src/main/java/org/elasticsearch/search/facet/TransportFacetModule.java b/src/main/java/org/elasticsearch/search/facet/TransportFacetModule.java index 327c947b420..8633fb801fd 100644 --- a/src/main/java/org/elasticsearch/search/facet/TransportFacetModule.java +++ b/src/main/java/org/elasticsearch/search/facet/TransportFacetModule.java @@ -31,11 +31,12 @@ import org.elasticsearch.search.facet.terms.InternalTermsFacet; import org.elasticsearch.search.facet.termsstats.InternalTermsStatsFacet; /** - * @author kimchy (shay.banon) + * */ public class TransportFacetModule extends AbstractModule { - @Override protected void configure() { + @Override + protected void configure() { InternalFilterFacet.registerStreams(); InternalQueryFacet.registerStreams(); InternalGeoDistanceFacet.registerStreams(); diff --git a/src/main/java/org/elasticsearch/search/facet/datehistogram/CountDateHistogramFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/datehistogram/CountDateHistogramFacetCollector.java index 9f325617e6e..e34ba452552 100644 --- a/src/main/java/org/elasticsearch/search/facet/datehistogram/CountDateHistogramFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/datehistogram/CountDateHistogramFacetCollector.java @@ -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,9 @@ package org.elasticsearch.search.facet.datehistogram; +import gnu.trove.map.hash.TLongLongHashMap; import org.apache.lucene.index.IndexReader; import org.elasticsearch.common.CacheRecycler; -import org.elasticsearch.common.joda.time.MutableDateTime; -import org.elasticsearch.common.trove.map.hash.TLongLongHashMap; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.longs.LongFieldData; @@ -32,6 +31,7 @@ import org.elasticsearch.search.facet.AbstractFacetCollector; import org.elasticsearch.search.facet.Facet; import org.elasticsearch.search.facet.FacetPhaseExecutionException; import org.elasticsearch.search.internal.SearchContext; +import org.joda.time.MutableDateTime; import java.io.IOException; @@ -39,7 +39,7 @@ import java.io.IOException; * A date histogram facet collector that uses the same field as the key as well as the * value. * - * @author kimchy (shay.banon) + * */ public class CountDateHistogramFacetCollector extends AbstractFacetCollector { @@ -85,15 +85,18 @@ public class CountDateHistogramFacetCollector extends AbstractFacetCollector { } } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { fieldData.forEachValueInDoc(doc, dateTime, histoProc); } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { fieldData = (LongFieldData) fieldDataCache.cache(fieldDataType, reader, indexFieldName); } - @Override public Facet facet() { + @Override + public Facet facet() { return new InternalCountDateHistogramFacet(facetName, comparatorType, histoProc.counts(), true); } @@ -105,7 +108,8 @@ public class CountDateHistogramFacetCollector extends AbstractFacetCollector { protected final TLongLongHashMap counts = CacheRecycler.popLongLongMap(); - @Override public void onValue(int docId, MutableDateTime dateTime) { + @Override + public void onValue(int docId, MutableDateTime dateTime) { counts.adjustOrPutValue(dateTime.getMillis(), 1, 1); } @@ -122,7 +126,8 @@ public class CountDateHistogramFacetCollector extends AbstractFacetCollector { this.interval = interval; } - @Override public void onValue(int docId, MutableDateTime dateTime) { + @Override + public void onValue(int docId, MutableDateTime dateTime) { long bucket = bucket(dateTime.getMillis(), interval); counts.adjustOrPutValue(bucket, 1, 1); } diff --git a/src/main/java/org/elasticsearch/search/facet/datehistogram/DateHistogramFacet.java b/src/main/java/org/elasticsearch/search/facet/datehistogram/DateHistogramFacet.java index f7cbc82ce5a..c54c20dc84f 100644 --- a/src/main/java/org/elasticsearch/search/facet/datehistogram/DateHistogramFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/datehistogram/DateHistogramFacet.java @@ -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.util.List; /** * A date histogram facet. * - * @author kimchy (shay.banon) + * */ public interface DateHistogramFacet extends Facet, Iterable { @@ -50,7 +50,8 @@ public interface DateHistogramFacet extends Facet, Iterable() { - @Override public int compare(Entry o1, Entry o2) { + @Override + public int compare(Entry o1, Entry o2) { // push nulls to the end if (o1 == null) { return 1; @@ -63,7 +64,8 @@ public interface DateHistogramFacet extends Facet, Iterable() { - @Override public int compare(Entry o1, Entry o2) { + @Override + public int compare(Entry o1, Entry o2) { // push nulls to the end if (o1 == null) { return 1; @@ -76,7 +78,8 @@ public interface DateHistogramFacet extends Facet, Iterable() { - @Override public int compare(Entry o1, Entry o2) { + @Override + public int compare(Entry o1, Entry o2) { // push nulls to the end if (o1 == null) { return 1; diff --git a/src/main/java/org/elasticsearch/search/facet/datehistogram/DateHistogramFacetBuilder.java b/src/main/java/org/elasticsearch/search/facet/datehistogram/DateHistogramFacetBuilder.java index 51542fc785f..a7214ff1028 100644 --- a/src/main/java/org/elasticsearch/search/facet/datehistogram/DateHistogramFacetBuilder.java +++ b/src/main/java/org/elasticsearch/search/facet/datehistogram/DateHistogramFacetBuilder.java @@ -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,7 +19,7 @@ package org.elasticsearch.search.facet.datehistogram; -import org.elasticsearch.common.collect.Maps; +import com.google.common.collect.Maps; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.index.query.FilterBuilder; import org.elasticsearch.search.builder.SearchSourceBuilderException; @@ -31,7 +31,7 @@ import java.util.Map; /** * A facet builder of date histogram facets. * - * @author kimchy (shay.banon) + * */ public class DateHistogramFacetBuilder extends AbstractFacetBuilder { private String keyFieldName; @@ -129,7 +129,8 @@ public class DateHistogramFacetBuilder extends AbstractFacetBuilder { * Should the facet run in global mode (not bounded by the search query) or not (bounded by * the search query). Defaults to false. */ - @Override public DateHistogramFacetBuilder global(boolean global) { + @Override + public DateHistogramFacetBuilder global(boolean global) { super.global(global); return this; } @@ -137,7 +138,8 @@ public class DateHistogramFacetBuilder extends AbstractFacetBuilder { /** * Marks the facet to run in a specific scope. */ - @Override public DateHistogramFacetBuilder scope(String scope) { + @Override + public DateHistogramFacetBuilder scope(String scope) { super.scope(scope); return this; } @@ -145,7 +147,8 @@ public class DateHistogramFacetBuilder extends AbstractFacetBuilder { /** * An additional filter used to further filter down the set of documents the facet will run on. */ - @Override public DateHistogramFacetBuilder facetFilter(FilterBuilder filter) { + @Override + public DateHistogramFacetBuilder facetFilter(FilterBuilder filter) { this.facetFilter = filter; return this; } @@ -160,7 +163,8 @@ public class DateHistogramFacetBuilder extends AbstractFacetBuilder { } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { if (keyFieldName == null) { throw new SearchSourceBuilderException("field must be set on date histogram facet for facet [" + name + "]"); } diff --git a/src/main/java/org/elasticsearch/search/facet/datehistogram/DateHistogramFacetProcessor.java b/src/main/java/org/elasticsearch/search/facet/datehistogram/DateHistogramFacetProcessor.java index b65f21c002a..73199af739d 100644 --- a/src/main/java/org/elasticsearch/search/facet/datehistogram/DateHistogramFacetProcessor.java +++ b/src/main/java/org/elasticsearch/search/facet/datehistogram/DateHistogramFacetProcessor.java @@ -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,17 +19,13 @@ package org.elasticsearch.search.facet.datehistogram; -import org.elasticsearch.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMap; +import gnu.trove.impl.Constants; +import gnu.trove.map.hash.TObjectIntHashMap; import org.elasticsearch.common.collect.MapBuilder; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.joda.time.Chronology; -import org.elasticsearch.common.joda.time.DateTimeField; -import org.elasticsearch.common.joda.time.DateTimeZone; -import org.elasticsearch.common.joda.time.MutableDateTime; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.trove.impl.Constants; -import org.elasticsearch.common.trove.map.hash.TObjectIntHashMap; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.field.data.FieldDataType; @@ -39,20 +35,25 @@ import org.elasticsearch.search.facet.FacetCollector; import org.elasticsearch.search.facet.FacetPhaseExecutionException; import org.elasticsearch.search.facet.FacetProcessor; import org.elasticsearch.search.internal.SearchContext; +import org.joda.time.Chronology; +import org.joda.time.DateTimeField; +import org.joda.time.DateTimeZone; +import org.joda.time.MutableDateTime; import java.io.IOException; import java.util.List; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class DateHistogramFacetProcessor extends AbstractComponent implements FacetProcessor { private final ImmutableMap dateFieldParsers; private final TObjectIntHashMap rounding = new TObjectIntHashMap(Constants.DEFAULT_CAPACITY, Constants.DEFAULT_LOAD_FACTOR, -1); - @Inject public DateHistogramFacetProcessor(Settings settings) { + @Inject + public DateHistogramFacetProcessor(Settings settings) { super(settings); InternalDateHistogramFacet.registerStreams(); @@ -83,11 +84,13 @@ public class DateHistogramFacetProcessor extends AbstractComponent implements Fa rounding.put("halfCeiling", MutableDateTime.ROUND_HALF_CEILING); } - @Override public String[] types() { + @Override + public String[] types() { return new String[]{DateHistogramFacet.TYPE, "dateHistogram"}; } - @Override public FacetCollector parse(String facetName, XContentParser parser, SearchContext context) throws IOException { + @Override + public FacetCollector parse(String facetName, XContentParser parser, SearchContext context) throws IOException { String keyField = null; String valueField = null; String valueScript = null; @@ -205,7 +208,8 @@ public class DateHistogramFacetProcessor extends AbstractComponent implements Fa } } - @Override public Facet reduce(String name, List facets) { + @Override + public Facet reduce(String name, List facets) { InternalDateHistogramFacet first = (InternalDateHistogramFacet) facets.get(0); return first.reduce(name, facets); } @@ -215,43 +219,50 @@ public class DateHistogramFacetProcessor extends AbstractComponent implements Fa DateTimeField parse(Chronology chronology); static class WeekOfWeekyear implements DateFieldParser { - @Override public DateTimeField parse(Chronology chronology) { + @Override + public DateTimeField parse(Chronology chronology) { return chronology.weekOfWeekyear(); } } static class YearOfCentury implements DateFieldParser { - @Override public DateTimeField parse(Chronology chronology) { + @Override + public DateTimeField parse(Chronology chronology) { return chronology.yearOfCentury(); } } static class MonthOfYear implements DateFieldParser { - @Override public DateTimeField parse(Chronology chronology) { + @Override + public DateTimeField parse(Chronology chronology) { return chronology.monthOfYear(); } } static class DayOfMonth implements DateFieldParser { - @Override public DateTimeField parse(Chronology chronology) { + @Override + public DateTimeField parse(Chronology chronology) { return chronology.dayOfMonth(); } } static class HourOfDay implements DateFieldParser { - @Override public DateTimeField parse(Chronology chronology) { + @Override + public DateTimeField parse(Chronology chronology) { return chronology.hourOfDay(); } } static class MinuteOfHour implements DateFieldParser { - @Override public DateTimeField parse(Chronology chronology) { + @Override + public DateTimeField parse(Chronology chronology) { return chronology.minuteOfHour(); } } static class SecondOfMinute implements DateFieldParser { - @Override public DateTimeField parse(Chronology chronology) { + @Override + public DateTimeField parse(Chronology chronology) { return chronology.secondOfMinute(); } } diff --git a/src/main/java/org/elasticsearch/search/facet/datehistogram/InternalCountDateHistogramFacet.java b/src/main/java/org/elasticsearch/search/facet/datehistogram/InternalCountDateHistogramFacet.java index 8dc1fbe7556..3aca1854bc7 100644 --- a/src/main/java/org/elasticsearch/search/facet/datehistogram/InternalCountDateHistogramFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/datehistogram/InternalCountDateHistogramFacet.java @@ -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,11 +19,11 @@ package org.elasticsearch.search.facet.datehistogram; +import gnu.trove.iterator.TLongLongIterator; +import gnu.trove.map.hash.TLongLongHashMap; import org.elasticsearch.common.CacheRecycler; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.trove.iterator.TLongLongIterator; -import org.elasticsearch.common.trove.map.hash.TLongLongHashMap; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilderString; import org.elasticsearch.search.facet.Facet; @@ -34,7 +34,7 @@ import java.util.Iterator; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class InternalCountDateHistogramFacet extends InternalDateHistogramFacet { @@ -45,12 +45,14 @@ public class InternalCountDateHistogramFacet extends InternalDateHistogramFacet } static Stream STREAM = new Stream() { - @Override public Facet readFacet(String type, StreamInput in) throws IOException { + @Override + public Facet readFacet(String type, StreamInput in) throws IOException { return readHistogramFacet(in); } }; - @Override public String streamType() { + @Override + public String streamType() { return STREAM_TYPE; } @@ -67,59 +69,73 @@ public class InternalCountDateHistogramFacet extends InternalDateHistogramFacet this.count = count; } - @Override public long time() { + @Override + public long time() { return time; } - @Override public long getTime() { + @Override + public long getTime() { return time(); } - @Override public long count() { + @Override + public long count() { return count; } - @Override public long getCount() { + @Override + public long getCount() { return count(); } - @Override public long totalCount() { + @Override + public long totalCount() { return 0; } - @Override public long getTotalCount() { + @Override + public long getTotalCount() { return 0; } - @Override public double total() { + @Override + public double total() { return Double.NaN; } - @Override public double getTotal() { + @Override + public double getTotal() { return total(); } - @Override public double mean() { + @Override + public double mean() { return Double.NaN; } - @Override public double getMean() { + @Override + public double getMean() { return mean(); } - @Override public double min() { + @Override + public double min() { return Double.NaN; } - @Override public double getMin() { + @Override + public double getMin() { return Double.NaN; } - @Override public double max() { + @Override + public double max() { return Double.NaN; } - @Override public double getMax() { + @Override + public double getMax() { return Double.NaN; } } @@ -143,31 +159,38 @@ public class InternalCountDateHistogramFacet extends InternalDateHistogramFacet this.cachedCounts = cachedCounts; } - @Override public String name() { + @Override + public String name() { return this.name; } - @Override public String getName() { + @Override + public String getName() { return name(); } - @Override public String type() { + @Override + public String type() { return TYPE; } - @Override public String getType() { + @Override + public String getType() { return type(); } - @Override public List entries() { + @Override + public List entries() { return Arrays.asList(computeEntries()); } - @Override public List getEntries() { + @Override + public List getEntries() { return entries(); } - @Override public Iterator iterator() { + @Override + public Iterator iterator() { return (Iterator) entries().iterator(); } @@ -185,7 +208,7 @@ public class InternalCountDateHistogramFacet extends InternalDateHistogramFacet } entries = new CountEntry[counts.size()]; int i = 0; - for (TLongLongIterator it = counts.iterator(); it.hasNext();) { + for (TLongLongIterator it = counts.iterator(); it.hasNext(); ) { it.advance(); entries[i++] = new CountEntry(it.key(), it.value()); } @@ -194,7 +217,8 @@ public class InternalCountDateHistogramFacet extends InternalDateHistogramFacet return entries; } - @Override public Facet reduce(String name, List facets) { + @Override + public Facet reduce(String name, List facets) { if (facets.size() == 1) { return facets.get(0); } @@ -202,7 +226,7 @@ public class InternalCountDateHistogramFacet extends InternalDateHistogramFacet for (Facet facet : facets) { InternalCountDateHistogramFacet histoFacet = (InternalCountDateHistogramFacet) facet; - for (TLongLongIterator it = histoFacet.counts.iterator(); it.hasNext();) { + for (TLongLongIterator it = histoFacet.counts.iterator(); it.hasNext(); ) { it.advance(); counts.adjustOrPutValue(it.key(), it.value(), it.value()); } @@ -220,7 +244,8 @@ public class InternalCountDateHistogramFacet extends InternalDateHistogramFacet static final XContentBuilderString COUNT = new XContentBuilderString("count"); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(name); builder.field(Fields._TYPE, TYPE); builder.startArray(Fields.ENTRIES); @@ -241,7 +266,8 @@ public class InternalCountDateHistogramFacet extends InternalDateHistogramFacet return facet; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { name = in.readUTF(); comparatorType = ComparatorType.fromId(in.readByte()); @@ -254,11 +280,12 @@ public class InternalCountDateHistogramFacet extends InternalDateHistogramFacet } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(name); out.writeByte(comparatorType.id()); out.writeVInt(counts.size()); - for (TLongLongIterator it = counts.iterator(); it.hasNext();) { + for (TLongLongIterator it = counts.iterator(); it.hasNext(); ) { it.advance(); out.writeLong(it.key()); out.writeVLong(it.value()); diff --git a/src/main/java/org/elasticsearch/search/facet/datehistogram/InternalDateHistogramFacet.java b/src/main/java/org/elasticsearch/search/facet/datehistogram/InternalDateHistogramFacet.java index 7b150537f44..0e5287e59bf 100644 --- a/src/main/java/org/elasticsearch/search/facet/datehistogram/InternalDateHistogramFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/datehistogram/InternalDateHistogramFacet.java @@ -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.search.facet.InternalFacet; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public abstract class InternalDateHistogramFacet implements DateHistogramFacet, InternalFacet { diff --git a/src/main/java/org/elasticsearch/search/facet/datehistogram/InternalFullDateHistogramFacet.java b/src/main/java/org/elasticsearch/search/facet/datehistogram/InternalFullDateHistogramFacet.java index 4e54d212762..d94a1462ac5 100644 --- a/src/main/java/org/elasticsearch/search/facet/datehistogram/InternalFullDateHistogramFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/datehistogram/InternalFullDateHistogramFacet.java @@ -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,25 +19,19 @@ package org.elasticsearch.search.facet.datehistogram; +import gnu.trove.ExtTLongObjectHashMap; import org.elasticsearch.common.CacheRecycler; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.trove.ExtTLongObjectHashMap; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilderString; import org.elasticsearch.search.facet.Facet; import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; +import java.util.*; /** - * @author kimchy (shay.banon) + * */ public class InternalFullDateHistogramFacet extends InternalDateHistogramFacet { @@ -48,12 +42,14 @@ public class InternalFullDateHistogramFacet extends InternalDateHistogramFacet { } static Stream STREAM = new Stream() { - @Override public Facet readFacet(String type, StreamInput in) throws IOException { + @Override + public Facet readFacet(String type, StreamInput in) throws IOException { return readHistogramFacet(in); } }; - @Override public String streamType() { + @Override + public String streamType() { return STREAM_TYPE; } @@ -78,62 +74,76 @@ public class InternalFullDateHistogramFacet extends InternalDateHistogramFacet { this.total = total; } - @Override public long time() { + @Override + public long time() { return time; } - @Override public long getTime() { + @Override + public long getTime() { return time(); } - @Override public long count() { + @Override + public long count() { return count; } - @Override public long getCount() { + @Override + public long getCount() { return count(); } - @Override public double total() { + @Override + public double total() { return total; } - @Override public double getTotal() { + @Override + public double getTotal() { return total(); } - @Override public long totalCount() { + @Override + public long totalCount() { return totalCount; } - @Override public long getTotalCount() { + @Override + public long getTotalCount() { return this.totalCount; } - @Override public double mean() { + @Override + public double mean() { if (totalCount == 0) { return totalCount; } return total / totalCount; } - @Override public double getMean() { + @Override + public double getMean() { return total / totalCount; } - @Override public double min() { + @Override + public double min() { return this.min; } - @Override public double getMin() { + @Override + public double getMin() { return this.min; } - @Override public double max() { + @Override + public double max() { return this.max; } - @Override public double getMax() { + @Override + public double getMax() { return this.max; } } @@ -157,34 +167,41 @@ public class InternalFullDateHistogramFacet extends InternalDateHistogramFacet { this.entries = entries.valueCollection(); } - @Override public String name() { + @Override + public String name() { return this.name; } - @Override public String getName() { + @Override + public String getName() { return name(); } - @Override public String type() { + @Override + public String type() { return TYPE; } - @Override public String getType() { + @Override + public String getType() { return type(); } - @Override public List entries() { + @Override + public List entries() { if (!(entries instanceof List)) { entries = new ArrayList(entries); } return (List) entries; } - @Override public List getEntries() { + @Override + public List getEntries() { return entries(); } - @Override public Iterator iterator() { + @Override + public Iterator iterator() { return (Iterator) entries().iterator(); } @@ -196,7 +213,8 @@ public class InternalFullDateHistogramFacet extends InternalDateHistogramFacet { } } - @Override public Facet reduce(String name, List facets) { + @Override + public Facet reduce(String name, List facets) { if (facets.size() == 1) { // we need to sort it InternalFullDateHistogramFacet internalFacet = (InternalFullDateHistogramFacet) facets.get(0); @@ -263,7 +281,8 @@ public class InternalFullDateHistogramFacet extends InternalDateHistogramFacet { static final XContentBuilderString MAX = new XContentBuilderString("max"); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(name); builder.field(Fields._TYPE, TYPE); builder.startArray(Fields.ENTRIES); @@ -289,7 +308,8 @@ public class InternalFullDateHistogramFacet extends InternalDateHistogramFacet { return facet; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { name = in.readUTF(); comparatorType = ComparatorType.fromId(in.readByte()); @@ -301,7 +321,8 @@ public class InternalFullDateHistogramFacet extends InternalDateHistogramFacet { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(name); out.writeByte(comparatorType.id()); out.writeVInt(entries.size()); diff --git a/src/main/java/org/elasticsearch/search/facet/datehistogram/ValueDateHistogramFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/datehistogram/ValueDateHistogramFacetCollector.java index 64a64d25ae0..a42016fde4f 100644 --- a/src/main/java/org/elasticsearch/search/facet/datehistogram/ValueDateHistogramFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/datehistogram/ValueDateHistogramFacetCollector.java @@ -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,9 @@ package org.elasticsearch.search.facet.datehistogram; +import gnu.trove.ExtTLongObjectHashMap; import org.apache.lucene.index.IndexReader; import org.elasticsearch.common.CacheRecycler; -import org.elasticsearch.common.joda.time.MutableDateTime; -import org.elasticsearch.common.trove.ExtTLongObjectHashMap; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.NumericFieldData; @@ -33,13 +32,14 @@ import org.elasticsearch.search.facet.AbstractFacetCollector; import org.elasticsearch.search.facet.Facet; import org.elasticsearch.search.facet.FacetPhaseExecutionException; import org.elasticsearch.search.internal.SearchContext; +import org.joda.time.MutableDateTime; import java.io.IOException; /** * A histogram facet collector that uses different fields for the key and the value. * - * @author kimchy (shay.banon) + * */ public class ValueDateHistogramFacetCollector extends AbstractFacetCollector { @@ -90,16 +90,19 @@ public class ValueDateHistogramFacetCollector extends AbstractFacetCollector { this.histoProc = new DateHistogramProc(interval); } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { keyFieldData.forEachValueInDoc(doc, dateTime, histoProc); } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { keyFieldData = (LongFieldData) fieldDataCache.cache(keyFieldDataType, reader, keyIndexFieldName); histoProc.valueFieldData = (NumericFieldData) fieldDataCache.cache(valueFieldDataType, reader, valueIndexFieldName); } - @Override public Facet facet() { + @Override + public Facet facet() { return new InternalFullDateHistogramFacet(facetName, comparatorType, histoProc.entries, true); } @@ -117,7 +120,8 @@ public class ValueDateHistogramFacetCollector extends AbstractFacetCollector { this.interval = interval; } - @Override public void onValue(int docId, MutableDateTime dateTime) { + @Override + public void onValue(int docId, MutableDateTime dateTime) { long time = dateTime.getMillis(); if (interval != 1) { time = CountDateHistogramFacetCollector.bucket(time, interval); @@ -137,7 +141,8 @@ public class ValueDateHistogramFacetCollector extends AbstractFacetCollector { InternalFullDateHistogramFacet.FullEntry entry; - @Override public void onValue(int docId, double value) { + @Override + public void onValue(int docId, double value) { entry.totalCount++; entry.total += value; if (value < entry.min) { diff --git a/src/main/java/org/elasticsearch/search/facet/datehistogram/ValueScriptDateHistogramFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/datehistogram/ValueScriptDateHistogramFacetCollector.java index 397b8745b2d..d89afdf1651 100644 --- a/src/main/java/org/elasticsearch/search/facet/datehistogram/ValueScriptDateHistogramFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/datehistogram/ValueScriptDateHistogramFacetCollector.java @@ -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,11 +19,10 @@ package org.elasticsearch.search.facet.datehistogram; +import gnu.trove.ExtTLongObjectHashMap; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.Scorer; import org.elasticsearch.common.CacheRecycler; -import org.elasticsearch.common.joda.time.MutableDateTime; -import org.elasticsearch.common.trove.ExtTLongObjectHashMap; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.longs.LongFieldData; @@ -34,6 +33,7 @@ import org.elasticsearch.search.facet.AbstractFacetCollector; import org.elasticsearch.search.facet.Facet; import org.elasticsearch.search.facet.FacetPhaseExecutionException; import org.elasticsearch.search.internal.SearchContext; +import org.joda.time.MutableDateTime; import java.io.IOException; import java.util.Map; @@ -42,7 +42,7 @@ import java.util.Map; * A histogram facet collector that uses the same field as the key as well as the * value. * - * @author kimchy (shay.banon) + * */ public class ValueScriptDateHistogramFacetCollector extends AbstractFacetCollector { @@ -92,20 +92,24 @@ public class ValueScriptDateHistogramFacetCollector extends AbstractFacetCollect } } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { fieldData.forEachValueInDoc(doc, dateTime, histoProc); } - @Override public void setScorer(Scorer scorer) throws IOException { + @Override + public void setScorer(Scorer scorer) throws IOException { valueScript.setScorer(scorer); } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { fieldData = (LongFieldData) fieldDataCache.cache(fieldDataType, reader, indexFieldName); valueScript.setNextReader(reader); } - @Override public Facet facet() { + @Override + public Facet facet() { return new InternalFullDateHistogramFacet(facetName, comparatorType, histoProc.entries, true); } @@ -119,7 +123,8 @@ public class ValueScriptDateHistogramFacetCollector extends AbstractFacetCollect this.valueScript = valueScript; } - @Override public void onValue(int docId, MutableDateTime dateTime) { + @Override + public void onValue(int docId, MutableDateTime dateTime) { valueScript.setNextDocId(docId); long time = dateTime.getMillis(); double scriptValue = valueScript.runAsDouble(); @@ -151,7 +156,8 @@ public class ValueScriptDateHistogramFacetCollector extends AbstractFacetCollect this.interval = interval; } - @Override public void onValue(int docId, MutableDateTime dateTime) { + @Override + public void onValue(int docId, MutableDateTime dateTime) { valueScript.setNextDocId(docId); long time = CountDateHistogramFacetCollector.bucket(dateTime.getMillis(), interval); diff --git a/src/main/java/org/elasticsearch/search/facet/filter/FilterFacet.java b/src/main/java/org/elasticsearch/search/facet/filter/FilterFacet.java index d90f8931b59..2c4ef297f3c 100644 --- a/src/main/java/org/elasticsearch/search/facet/filter/FilterFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/filter/FilterFacet.java @@ -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.search.facet.Facet; /** * A query facets returns the count (number of hits) for a facet based on a query. * - * @author kimchy (shay.banon) + * */ public interface FilterFacet extends Facet { diff --git a/src/main/java/org/elasticsearch/search/facet/filter/FilterFacetBuilder.java b/src/main/java/org/elasticsearch/search/facet/filter/FilterFacetBuilder.java index 614a4bbe1e9..5b625f3bfb7 100644 --- a/src/main/java/org/elasticsearch/search/facet/filter/FilterFacetBuilder.java +++ b/src/main/java/org/elasticsearch/search/facet/filter/FilterFacetBuilder.java @@ -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.search.facet.AbstractFacetBuilder; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class FilterFacetBuilder extends AbstractFacetBuilder { @@ -40,7 +40,8 @@ public class FilterFacetBuilder extends AbstractFacetBuilder { /** * Marks the facet to run in a global scope, not bounded by any query. */ - @Override public FilterFacetBuilder global(boolean global) { + @Override + public FilterFacetBuilder global(boolean global) { super.global(global); return this; } @@ -48,7 +49,8 @@ public class FilterFacetBuilder extends AbstractFacetBuilder { /** * Marks the facet to run in a specific scope. */ - @Override public FilterFacetBuilder scope(String scope) { + @Override + public FilterFacetBuilder scope(String scope) { super.scope(scope); return this; } @@ -72,7 +74,8 @@ public class FilterFacetBuilder extends AbstractFacetBuilder { return this; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { if (filter == null) { throw new SearchSourceBuilderException("filter must be set on filter facet for facet [" + name + "]"); } diff --git a/src/main/java/org/elasticsearch/search/facet/filter/FilterFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/filter/FilterFacetCollector.java index 96f8c65c170..6cba434dcdd 100644 --- a/src/main/java/org/elasticsearch/search/facet/filter/FilterFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/filter/FilterFacetCollector.java @@ -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,11 +20,7 @@ package org.elasticsearch.search.facet.filter; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.search.DeletionAwareConstantScoreQuery; -import org.apache.lucene.search.Filter; -import org.apache.lucene.search.FilteredQuery; -import org.apache.lucene.search.Query; -import org.apache.lucene.search.TotalHitCountCollector; +import org.apache.lucene.search.*; import org.elasticsearch.common.lucene.docset.DocSet; import org.elasticsearch.common.lucene.docset.DocSets; import org.elasticsearch.index.cache.filter.FilterCache; @@ -36,7 +32,7 @@ import org.elasticsearch.search.internal.SearchContext; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class FilterFacetCollector extends AbstractFacetCollector implements OptimizeGlobalFacetCollector { @@ -51,7 +47,8 @@ public class FilterFacetCollector extends AbstractFacetCollector implements Opti this.filter = filter; } - @Override public void optimizedGlobalExecution(SearchContext searchContext) throws IOException { + @Override + public void optimizedGlobalExecution(SearchContext searchContext) throws IOException { Query query = new DeletionAwareConstantScoreQuery(filter); if (super.filter != null) { query = new FilteredQuery(query, super.filter); @@ -65,17 +62,20 @@ public class FilterFacetCollector extends AbstractFacetCollector implements Opti count = collector.getTotalHits(); } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { docSet = DocSets.convert(reader, filter.getDocIdSet(reader)); } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { if (docSet.get(doc)) { count++; } } - @Override public Facet facet() { + @Override + public Facet facet() { return new InternalFilterFacet(facetName, count); } } diff --git a/src/main/java/org/elasticsearch/search/facet/filter/FilterFacetProcessor.java b/src/main/java/org/elasticsearch/search/facet/filter/FilterFacetProcessor.java index 54183a73eaf..3f64a17aff5 100644 --- a/src/main/java/org/elasticsearch/search/facet/filter/FilterFacetProcessor.java +++ b/src/main/java/org/elasticsearch/search/facet/filter/FilterFacetProcessor.java @@ -33,25 +33,29 @@ import java.io.IOException; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class FilterFacetProcessor extends AbstractComponent implements FacetProcessor { - @Inject public FilterFacetProcessor(Settings settings) { + @Inject + public FilterFacetProcessor(Settings settings) { super(settings); InternalFilterFacet.registerStreams(); } - @Override public String[] types() { + @Override + public String[] types() { return new String[]{FilterFacet.TYPE}; } - @Override public FacetCollector parse(String facetName, XContentParser parser, SearchContext context) throws IOException { + @Override + public FacetCollector parse(String facetName, XContentParser parser, SearchContext context) throws IOException { Filter facetFilter = context.queryParserService().parseInnerFilter(parser); return new FilterFacetCollector(facetName, facetFilter, context.filterCache()); } - @Override public Facet reduce(String name, List facets) { + @Override + public Facet reduce(String name, List facets) { if (facets.size() == 1) { return facets.get(0); } diff --git a/src/main/java/org/elasticsearch/search/facet/filter/InternalFilterFacet.java b/src/main/java/org/elasticsearch/search/facet/filter/InternalFilterFacet.java index f9981afb731..80392fd75d6 100644 --- a/src/main/java/org/elasticsearch/search/facet/filter/InternalFilterFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/filter/InternalFilterFacet.java @@ -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.search.facet.InternalFacet; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class InternalFilterFacet implements FilterFacet, InternalFacet { @@ -40,12 +40,14 @@ public class InternalFilterFacet implements FilterFacet, InternalFacet { } static Stream STREAM = new Stream() { - @Override public Facet readFacet(String type, StreamInput in) throws IOException { + @Override + public Facet readFacet(String type, StreamInput in) throws IOException { return readFilterFacet(in); } }; - @Override public String streamType() { + @Override + public String streamType() { return STREAM_TYPE; } @@ -62,11 +64,13 @@ public class InternalFilterFacet implements FilterFacet, InternalFacet { this.count = count; } - @Override public String type() { + @Override + public String type() { return TYPE; } - @Override public String getType() { + @Override + public String getType() { return TYPE; } @@ -77,7 +81,8 @@ public class InternalFilterFacet implements FilterFacet, InternalFacet { return name; } - @Override public String getName() { + @Override + public String getName() { return name(); } @@ -100,7 +105,8 @@ public class InternalFilterFacet implements FilterFacet, InternalFacet { static final XContentBuilderString COUNT = new XContentBuilderString("count"); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(name); builder.field(Fields._TYPE, FilterFacet.TYPE); builder.field(Fields.COUNT, count); @@ -114,12 +120,14 @@ public class InternalFilterFacet implements FilterFacet, InternalFacet { return result; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { name = in.readUTF(); count = in.readVLong(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(name); out.writeVLong(count); } diff --git a/src/main/java/org/elasticsearch/search/facet/geodistance/GeoDistanceFacet.java b/src/main/java/org/elasticsearch/search/facet/geodistance/GeoDistanceFacet.java index f7245085814..82d393abd32 100644 --- a/src/main/java/org/elasticsearch/search/facet/geodistance/GeoDistanceFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/geodistance/GeoDistanceFacet.java @@ -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.search.facet.Facet; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public interface GeoDistanceFacet extends Facet, Iterable { diff --git a/src/main/java/org/elasticsearch/search/facet/geodistance/GeoDistanceFacetBuilder.java b/src/main/java/org/elasticsearch/search/facet/geodistance/GeoDistanceFacetBuilder.java index a2294d7fa63..72c2c3b4521 100644 --- a/src/main/java/org/elasticsearch/search/facet/geodistance/GeoDistanceFacetBuilder.java +++ b/src/main/java/org/elasticsearch/search/facet/geodistance/GeoDistanceFacetBuilder.java @@ -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.search.facet.geodistance; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.collect.Maps; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import org.elasticsearch.common.unit.DistanceUnit; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.index.query.FilterBuilder; @@ -37,7 +37,7 @@ import java.util.Map; * number of hits within each distance range, and aggregated data (like totals of either the distance or * cusotm value fields). * - * @author kimchy (shay.banon) + * */ public class GeoDistanceFacetBuilder extends AbstractFacetBuilder { @@ -207,7 +207,8 @@ public class GeoDistanceFacetBuilder extends AbstractFacetBuilder { /** * Marks the facet to run in a specific scope. */ - @Override public GeoDistanceFacetBuilder scope(String scope) { + @Override + public GeoDistanceFacetBuilder scope(String scope) { super.scope(scope); return this; } @@ -226,7 +227,8 @@ public class GeoDistanceFacetBuilder extends AbstractFacetBuilder { return this; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { if (fieldName == null) { throw new SearchSourceBuilderException("field must be set on geo_distance facet for facet [" + name + "]"); } diff --git a/src/main/java/org/elasticsearch/search/facet/geodistance/GeoDistanceFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/geodistance/GeoDistanceFacetCollector.java index e2af4bb2adc..fa5b6b9eff1 100644 --- a/src/main/java/org/elasticsearch/search/facet/geodistance/GeoDistanceFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/geodistance/GeoDistanceFacetCollector.java @@ -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,7 +34,7 @@ import org.elasticsearch.search.internal.SearchContext; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class GeoDistanceFacetCollector extends AbstractFacetCollector { @@ -86,18 +86,21 @@ public class GeoDistanceFacetCollector extends AbstractFacetCollector { this.aggregator = new Aggregator(fixedSourceDistance, entries); } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { fieldData = (GeoPointFieldData) fieldDataCache.cache(GeoPointFieldDataType.TYPE, reader, indexFieldName); } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { for (GeoDistanceFacet.Entry entry : entries) { entry.foundInDoc = false; } fieldData.forEachValueInDoc(doc, aggregator); } - @Override public Facet facet() { + @Override + public Facet facet() { return new InternalGeoDistanceFacet(facetName, entries); } @@ -112,7 +115,8 @@ public class GeoDistanceFacetCollector extends AbstractFacetCollector { this.entries = entries; } - @Override public void onValue(int docId, double lat, double lon) { + @Override + public void onValue(int docId, double lat, double lon) { double distance = fixedSourceDistance.calculate(lat, lon); for (GeoDistanceFacet.Entry entry : entries) { if (entry.foundInDoc) { diff --git a/src/main/java/org/elasticsearch/search/facet/geodistance/GeoDistanceFacetProcessor.java b/src/main/java/org/elasticsearch/search/facet/geodistance/GeoDistanceFacetProcessor.java index 3cc42bed703..e456d91b182 100644 --- a/src/main/java/org/elasticsearch/search/facet/geodistance/GeoDistanceFacetProcessor.java +++ b/src/main/java/org/elasticsearch/search/facet/geodistance/GeoDistanceFacetProcessor.java @@ -19,7 +19,7 @@ package org.elasticsearch.search.facet.geodistance; -import org.elasticsearch.common.collect.Lists; +import com.google.common.collect.Lists; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -40,20 +40,23 @@ import java.util.List; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class GeoDistanceFacetProcessor extends AbstractComponent implements FacetProcessor { - @Inject public GeoDistanceFacetProcessor(Settings settings) { + @Inject + public GeoDistanceFacetProcessor(Settings settings) { super(settings); InternalGeoDistanceFacet.registerStreams(); } - @Override public String[] types() { + @Override + public String[] types() { return new String[]{GeoDistanceFacet.TYPE, "geoDistance"}; } - @Override public FacetCollector parse(String facetName, XContentParser parser, SearchContext context) throws IOException { + @Override + public FacetCollector parse(String facetName, XContentParser parser, SearchContext context) throws IOException { String fieldName = null; String valueFieldName = null; String valueScript = null; @@ -189,7 +192,8 @@ public class GeoDistanceFacetProcessor extends AbstractComponent implements Face context); } - @Override public Facet reduce(String name, List facets) { + @Override + public Facet reduce(String name, List facets) { InternalGeoDistanceFacet agg = null; for (Facet facet : facets) { InternalGeoDistanceFacet geoDistanceFacet = (InternalGeoDistanceFacet) facet; diff --git a/src/main/java/org/elasticsearch/search/facet/geodistance/InternalGeoDistanceFacet.java b/src/main/java/org/elasticsearch/search/facet/geodistance/InternalGeoDistanceFacet.java index 643a08cda0c..53b40e580ae 100644 --- a/src/main/java/org/elasticsearch/search/facet/geodistance/InternalGeoDistanceFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/geodistance/InternalGeoDistanceFacet.java @@ -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,7 +19,7 @@ package org.elasticsearch.search.facet.geodistance; -import org.elasticsearch.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -32,7 +32,7 @@ import java.util.Iterator; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class InternalGeoDistanceFacet implements GeoDistanceFacet, InternalFacet { @@ -43,12 +43,14 @@ public class InternalGeoDistanceFacet implements GeoDistanceFacet, InternalFacet } static Stream STREAM = new Stream() { - @Override public Facet readFacet(String type, StreamInput in) throws IOException { + @Override + public Facet readFacet(String type, StreamInput in) throws IOException { return readGeoDistanceFacet(in); } }; - @Override public String streamType() { + @Override + public String streamType() { return STREAM_TYPE; } @@ -64,31 +66,38 @@ public class InternalGeoDistanceFacet implements GeoDistanceFacet, InternalFacet this.entries = entries; } - @Override public String name() { + @Override + public String name() { return this.name; } - @Override public String getName() { + @Override + public String getName() { return name(); } - @Override public String type() { + @Override + public String type() { return TYPE; } - @Override public String getType() { + @Override + public String getType() { return type(); } - @Override public List entries() { + @Override + public List entries() { return ImmutableList.copyOf(entries); } - @Override public List getEntries() { + @Override + public List getEntries() { return entries(); } - @Override public Iterator iterator() { + @Override + public Iterator iterator() { return entries().iterator(); } @@ -98,7 +107,8 @@ public class InternalGeoDistanceFacet implements GeoDistanceFacet, InternalFacet return facet; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { name = in.readUTF(); entries = new Entry[in.readVInt()]; for (int i = 0; i < entries.length; i++) { @@ -106,7 +116,8 @@ public class InternalGeoDistanceFacet implements GeoDistanceFacet, InternalFacet } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(name); out.writeVInt(entries.length); for (Entry entry : entries) { @@ -134,7 +145,8 @@ public class InternalGeoDistanceFacet implements GeoDistanceFacet, InternalFacet static final XContentBuilderString MAX = new XContentBuilderString("max"); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(name); builder.field(Fields._TYPE, GeoDistanceFacet.TYPE); builder.startArray(Fields.RANGES); diff --git a/src/main/java/org/elasticsearch/search/facet/geodistance/ScriptGeoDistanceFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/geodistance/ScriptGeoDistanceFacetCollector.java index 5c1afc40e38..22f29ec5a82 100644 --- a/src/main/java/org/elasticsearch/search/facet/geodistance/ScriptGeoDistanceFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/geodistance/ScriptGeoDistanceFacetCollector.java @@ -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,7 +31,7 @@ import java.io.IOException; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class ScriptGeoDistanceFacetCollector extends GeoDistanceFacetCollector { @@ -49,16 +49,19 @@ public class ScriptGeoDistanceFacetCollector extends GeoDistanceFacetCollector { this.scriptAggregator = (Aggregator) this.aggregator; } - @Override public void setScorer(Scorer scorer) throws IOException { + @Override + public void setScorer(Scorer scorer) throws IOException { script.setScorer(scorer); } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { super.doSetNextReader(reader, docBase); script.setNextReader(reader); } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { script.setNextDocId(doc); this.scriptAggregator.scriptValue = script.runAsDouble(); super.doCollect(doc); @@ -77,7 +80,8 @@ public class ScriptGeoDistanceFacetCollector extends GeoDistanceFacetCollector { this.entries = entries; } - @Override public void onValue(int docId, double lat, double lon) { + @Override + public void onValue(int docId, double lat, double lon) { double distance = fixedSourceDistance.calculate(lat, lon); for (GeoDistanceFacet.Entry entry : entries) { if (entry.foundInDoc) { diff --git a/src/main/java/org/elasticsearch/search/facet/geodistance/ValueGeoDistanceFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/geodistance/ValueGeoDistanceFacetCollector.java index c44e97e97c9..c16ac70ae85 100644 --- a/src/main/java/org/elasticsearch/search/facet/geodistance/ValueGeoDistanceFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/geodistance/ValueGeoDistanceFacetCollector.java @@ -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,7 +32,7 @@ import org.elasticsearch.search.internal.SearchContext; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class ValueGeoDistanceFacetCollector extends GeoDistanceFacetCollector { @@ -53,7 +53,8 @@ public class ValueGeoDistanceFacetCollector extends GeoDistanceFacetCollector { this.aggregator = new Aggregator(fixedSourceDistance, entries); } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { super.doSetNextReader(reader, docBase); ((Aggregator) this.aggregator).valueFieldData = (NumericFieldData) fieldDataCache.cache(valueFieldDataType, reader, indexValueFieldName); } @@ -72,7 +73,8 @@ public class ValueGeoDistanceFacetCollector extends GeoDistanceFacetCollector { this.entries = entries; } - @Override public void onValue(int docId, double lat, double lon) { + @Override + public void onValue(int docId, double lat, double lon) { double distance = fixedSourceDistance.calculate(lat, lon); for (GeoDistanceFacet.Entry entry : entries) { if (entry.foundInDoc) { @@ -92,7 +94,8 @@ public class ValueGeoDistanceFacetCollector extends GeoDistanceFacetCollector { GeoDistanceFacet.Entry entry; - @Override public void onValue(int docId, double value) { + @Override + public void onValue(int docId, double value) { entry.totalCount++; entry.total += value; if (value < entry.min) { diff --git a/src/main/java/org/elasticsearch/search/facet/histogram/HistogramFacet.java b/src/main/java/org/elasticsearch/search/facet/histogram/HistogramFacet.java index ae373c6a649..24b1e2093eb 100644 --- a/src/main/java/org/elasticsearch/search/facet/histogram/HistogramFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/histogram/HistogramFacet.java @@ -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.util.List; /** * Numeric histogram facet. * - * @author kimchy (shay.banon) + * */ public interface HistogramFacet extends Facet, Iterable { @@ -50,7 +50,8 @@ public interface HistogramFacet extends Facet, Iterable { public static enum ComparatorType { KEY((byte) 0, "key", new Comparator() { - @Override public int compare(Entry o1, Entry o2) { + @Override + public int compare(Entry o1, Entry o2) { // push nulls to the end if (o1 == null) { return 1; @@ -63,7 +64,8 @@ public interface HistogramFacet extends Facet, Iterable { }), COUNT((byte) 1, "count", new Comparator() { - @Override public int compare(Entry o1, Entry o2) { + @Override + public int compare(Entry o1, Entry o2) { // push nulls to the end if (o1 == null) { return 1; @@ -76,7 +78,8 @@ public interface HistogramFacet extends Facet, Iterable { }), TOTAL((byte) 2, "total", new Comparator() { - @Override public int compare(Entry o1, Entry o2) { + @Override + public int compare(Entry o1, Entry o2) { // push nulls to the end if (o1 == null) { return 1; diff --git a/src/main/java/org/elasticsearch/search/facet/histogram/HistogramFacetBuilder.java b/src/main/java/org/elasticsearch/search/facet/histogram/HistogramFacetBuilder.java index b875fe6e249..ff8a3b0b937 100644 --- a/src/main/java/org/elasticsearch/search/facet/histogram/HistogramFacetBuilder.java +++ b/src/main/java/org/elasticsearch/search/facet/histogram/HistogramFacetBuilder.java @@ -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.concurrent.TimeUnit; /** * A facet builder of histogram facets. * - * @author kimchy (shay.banon) + * */ public class HistogramFacetBuilder extends AbstractFacetBuilder { private String keyFieldName; @@ -119,7 +119,8 @@ public class HistogramFacetBuilder extends AbstractFacetBuilder { /** * Marks the facet to run in a specific scope. */ - @Override public HistogramFacetBuilder scope(String scope) { + @Override + public HistogramFacetBuilder scope(String scope) { super.scope(scope); return this; } @@ -141,7 +142,8 @@ public class HistogramFacetBuilder extends AbstractFacetBuilder { return this; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { if (keyFieldName == null) { throw new SearchSourceBuilderException("field must be set on histogram facet for facet [" + name + "]"); } diff --git a/src/main/java/org/elasticsearch/search/facet/histogram/HistogramFacetProcessor.java b/src/main/java/org/elasticsearch/search/facet/histogram/HistogramFacetProcessor.java index 89740f6fbb2..e1060c261e0 100644 --- a/src/main/java/org/elasticsearch/search/facet/histogram/HistogramFacetProcessor.java +++ b/src/main/java/org/elasticsearch/search/facet/histogram/HistogramFacetProcessor.java @@ -32,11 +32,7 @@ import org.elasticsearch.search.facet.FacetProcessor; import org.elasticsearch.search.facet.histogram.bounded.BoundedCountHistogramFacetCollector; import org.elasticsearch.search.facet.histogram.bounded.BoundedValueHistogramFacetCollector; import org.elasticsearch.search.facet.histogram.bounded.BoundedValueScriptHistogramFacetCollector; -import org.elasticsearch.search.facet.histogram.unbounded.CountHistogramFacetCollector; -import org.elasticsearch.search.facet.histogram.unbounded.FullHistogramFacetCollector; -import org.elasticsearch.search.facet.histogram.unbounded.ScriptHistogramFacetCollector; -import org.elasticsearch.search.facet.histogram.unbounded.ValueHistogramFacetCollector; -import org.elasticsearch.search.facet.histogram.unbounded.ValueScriptHistogramFacetCollector; +import org.elasticsearch.search.facet.histogram.unbounded.*; import org.elasticsearch.search.internal.SearchContext; import java.io.IOException; @@ -44,20 +40,23 @@ import java.util.List; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class HistogramFacetProcessor extends AbstractComponent implements FacetProcessor { - @Inject public HistogramFacetProcessor(Settings settings) { + @Inject + public HistogramFacetProcessor(Settings settings) { super(settings); InternalHistogramFacet.registerStreams(); } - @Override public String[] types() { + @Override + public String[] types() { return new String[]{HistogramFacet.TYPE}; } - @Override public FacetCollector parse(String facetName, XContentParser parser, SearchContext context) throws IOException { + @Override + public FacetCollector parse(String facetName, XContentParser parser, SearchContext context) throws IOException { String keyField = null; String valueField = null; String keyScript = null; @@ -145,7 +144,8 @@ public class HistogramFacetProcessor extends AbstractComponent implements FacetP } } - @Override public Facet reduce(String name, List facets) { + @Override + public Facet reduce(String name, List facets) { InternalHistogramFacet first = (InternalHistogramFacet) facets.get(0); return first.reduce(name, facets); } diff --git a/src/main/java/org/elasticsearch/search/facet/histogram/HistogramScriptFacetBuilder.java b/src/main/java/org/elasticsearch/search/facet/histogram/HistogramScriptFacetBuilder.java index 196261243ec..ae6878a6757 100644 --- a/src/main/java/org/elasticsearch/search/facet/histogram/HistogramScriptFacetBuilder.java +++ b/src/main/java/org/elasticsearch/search/facet/histogram/HistogramScriptFacetBuilder.java @@ -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,7 +19,7 @@ package org.elasticsearch.search.facet.histogram; -import org.elasticsearch.common.collect.Maps; +import com.google.common.collect.Maps; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.index.query.FilterBuilder; import org.elasticsearch.search.builder.SearchSourceBuilderException; @@ -29,7 +29,7 @@ import java.io.IOException; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class HistogramScriptFacetBuilder extends AbstractFacetBuilder { private String lang; @@ -90,7 +90,8 @@ public class HistogramScriptFacetBuilder extends AbstractFacetBuilder { /** * Marks the facet to run in a global scope, not bounded by any query. */ - @Override public HistogramScriptFacetBuilder global(boolean global) { + @Override + public HistogramScriptFacetBuilder global(boolean global) { super.global(global); return this; } @@ -98,7 +99,8 @@ public class HistogramScriptFacetBuilder extends AbstractFacetBuilder { /** * Marks the facet to run in a specific scope. */ - @Override public HistogramScriptFacetBuilder scope(String scope) { + @Override + public HistogramScriptFacetBuilder scope(String scope) { super.scope(scope); return this; } @@ -127,7 +129,8 @@ public class HistogramScriptFacetBuilder extends AbstractFacetBuilder { return this; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { if (keyScript == null && keyFieldName == null) { throw new SearchSourceBuilderException("key_script or key_field must be set on histogram script facet for facet [" + name + "]"); } diff --git a/src/main/java/org/elasticsearch/search/facet/histogram/InternalHistogramFacet.java b/src/main/java/org/elasticsearch/search/facet/histogram/InternalHistogramFacet.java index 69b4b1bb8fd..f822825407c 100644 --- a/src/main/java/org/elasticsearch/search/facet/histogram/InternalHistogramFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/histogram/InternalHistogramFacet.java @@ -29,7 +29,7 @@ import org.elasticsearch.search.facet.histogram.unbounded.InternalFullHistogramF import java.util.List; /** - * @author kimchy (shay.banon) + * */ public abstract class InternalHistogramFacet implements HistogramFacet, InternalFacet { diff --git a/src/main/java/org/elasticsearch/search/facet/histogram/bounded/BoundedCountHistogramFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/histogram/bounded/BoundedCountHistogramFacetCollector.java index 6462458ca92..3db8973fa2e 100644 --- a/src/main/java/org/elasticsearch/search/facet/histogram/bounded/BoundedCountHistogramFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/histogram/bounded/BoundedCountHistogramFacetCollector.java @@ -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 @@ -79,15 +79,18 @@ public class BoundedCountHistogramFacetCollector extends AbstractFacetCollector histoProc = new HistogramProc(from, to, interval, offset, size); } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { fieldData.forEachValueInDoc(doc, histoProc); } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { fieldData = (NumericFieldData) fieldDataCache.cache(fieldDataType, reader, indexFieldName); } - @Override public Facet facet() { + @Override + public Facet facet() { return new InternalBoundedCountHistogramFacet(facetName, comparatorType, histoProc.interval, -histoProc.offset, histoProc.size, histoProc.counts, true); } @@ -113,7 +116,8 @@ public class BoundedCountHistogramFacetCollector extends AbstractFacetCollector this.counts = CacheRecycler.popIntArray(size); } - @Override public void onValue(int docId, long value) { + @Override + public void onValue(int docId, long value) { if (value <= from || value > to) { // bounds check return; } diff --git a/src/main/java/org/elasticsearch/search/facet/histogram/bounded/BoundedValueHistogramFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/histogram/bounded/BoundedValueHistogramFacetCollector.java index 730a2057388..a93f1f9949b 100644 --- a/src/main/java/org/elasticsearch/search/facet/histogram/bounded/BoundedValueHistogramFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/histogram/bounded/BoundedValueHistogramFacetCollector.java @@ -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 @@ -92,16 +92,19 @@ public class BoundedValueHistogramFacetCollector extends AbstractFacetCollector histoProc = new HistogramProc(from, to, interval, offset, size); } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { keyFieldData.forEachValueInDoc(doc, histoProc); } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { keyFieldData = (NumericFieldData) fieldDataCache.cache(keyFieldDataType, reader, keyIndexFieldName); histoProc.valueFieldData = (NumericFieldData) fieldDataCache.cache(valueFieldDataType, reader, valueIndexFieldName); } - @Override public Facet facet() { + @Override + public Facet facet() { return new InternalBoundedFullHistogramFacet(facetName, comparatorType, interval, -histoProc.offset, histoProc.size, histoProc.entries, true); } @@ -131,7 +134,8 @@ public class BoundedValueHistogramFacetCollector extends AbstractFacetCollector this.entries = CacheRecycler.popObjectArray(size); } - @Override public void onValue(int docId, long value) { + @Override + public void onValue(int docId, long value) { if (value <= from || value > to) { // bounds check return; } @@ -151,7 +155,8 @@ public class BoundedValueHistogramFacetCollector extends AbstractFacetCollector InternalBoundedFullHistogramFacet.FullEntry entry; - @Override public void onValue(int docId, double value) { + @Override + public void onValue(int docId, double value) { entry.totalCount++; entry.total += value; if (value < entry.min) { diff --git a/src/main/java/org/elasticsearch/search/facet/histogram/bounded/BoundedValueScriptHistogramFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/histogram/bounded/BoundedValueScriptHistogramFacetCollector.java index 4099e86585b..4a8a699b324 100644 --- a/src/main/java/org/elasticsearch/search/facet/histogram/bounded/BoundedValueScriptHistogramFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/histogram/bounded/BoundedValueScriptHistogramFacetCollector.java @@ -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,7 +38,7 @@ import java.io.IOException; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class BoundedValueScriptHistogramFacetCollector extends AbstractFacetCollector { @@ -89,20 +89,24 @@ public class BoundedValueScriptHistogramFacetCollector extends AbstractFacetColl histoProc = new HistogramProc(from, to, interval, offset, size, this.valueScript); } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { fieldData.forEachValueInDoc(doc, histoProc); } - @Override public void setScorer(Scorer scorer) throws IOException { + @Override + public void setScorer(Scorer scorer) throws IOException { valueScript.setScorer(scorer); } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { fieldData = (NumericFieldData) fieldDataCache.cache(fieldDataType, reader, indexFieldName); valueScript.setNextReader(reader); } - @Override public Facet facet() { + @Override + public Facet facet() { return new InternalBoundedFullHistogramFacet(facetName, comparatorType, histoProc.interval, -histoProc.offset, histoProc.size, histoProc.entries, true); } @@ -135,7 +139,8 @@ public class BoundedValueScriptHistogramFacetCollector extends AbstractFacetColl this.valueScript = valueScript; } - @Override public void onValue(int docId, long value) { + @Override + public void onValue(int docId, long value) { if (value <= from || value > to) { // bounds check return; } diff --git a/src/main/java/org/elasticsearch/search/facet/histogram/bounded/InternalBoundedCountHistogramFacet.java b/src/main/java/org/elasticsearch/search/facet/histogram/bounded/InternalBoundedCountHistogramFacet.java index 0822678e6b9..a27e65ae82d 100644 --- a/src/main/java/org/elasticsearch/search/facet/histogram/bounded/InternalBoundedCountHistogramFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/histogram/bounded/InternalBoundedCountHistogramFacet.java @@ -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,7 +34,7 @@ import java.util.Iterator; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class InternalBoundedCountHistogramFacet extends InternalHistogramFacet { @@ -45,12 +45,14 @@ public class InternalBoundedCountHistogramFacet extends InternalHistogramFacet { } static Stream STREAM = new Stream() { - @Override public Facet readFacet(String type, StreamInput in) throws IOException { + @Override + public Facet readFacet(String type, StreamInput in) throws IOException { return readHistogramFacet(in); } }; - @Override public String streamType() { + @Override + public String streamType() { return STREAM_TYPE; } @@ -67,59 +69,73 @@ public class InternalBoundedCountHistogramFacet extends InternalHistogramFacet { this.count = count; } - @Override public long key() { + @Override + public long key() { return key; } - @Override public long getKey() { + @Override + public long getKey() { return key(); } - @Override public long count() { + @Override + public long count() { return count; } - @Override public long getCount() { + @Override + public long getCount() { return count(); } - @Override public double total() { + @Override + public double total() { return Double.NaN; } - @Override public double getTotal() { + @Override + public double getTotal() { return total(); } - @Override public long totalCount() { + @Override + public long totalCount() { return 0; } - @Override public long getTotalCount() { + @Override + public long getTotalCount() { return 0; } - @Override public double mean() { + @Override + public double mean() { return Double.NaN; } - @Override public double getMean() { + @Override + public double getMean() { return mean(); } - @Override public double min() { + @Override + public double min() { return Double.NaN; } - @Override public double getMin() { + @Override + public double getMin() { return Double.NaN; } - @Override public double max() { + @Override + public double max() { return Double.NaN; } - @Override public double getMax() { + @Override + public double getMax() { return Double.NaN; } } @@ -149,31 +165,38 @@ public class InternalBoundedCountHistogramFacet extends InternalHistogramFacet { this.cachedCounts = cachedCounts; } - @Override public String name() { + @Override + public String name() { return this.name; } - @Override public String getName() { + @Override + public String getName() { return name(); } - @Override public String type() { + @Override + public String type() { return TYPE; } - @Override public String getType() { + @Override + public String getType() { return type(); } - @Override public List entries() { + @Override + public List entries() { return Arrays.asList(computeEntries()); } - @Override public List getEntries() { + @Override + public List getEntries() { return entries(); } - @Override public Iterator iterator() { + @Override + public Iterator iterator() { return (Iterator) entries().iterator(); } @@ -197,7 +220,8 @@ public class InternalBoundedCountHistogramFacet extends InternalHistogramFacet { } } - @Override public Facet reduce(String name, List facets) { + @Override + public Facet reduce(String name, List facets) { if (facets.size() == 1) { InternalBoundedCountHistogramFacet firstHistoFacet = (InternalBoundedCountHistogramFacet) facets.get(0); if (comparatorType != ComparatorType.KEY) { @@ -227,7 +251,8 @@ public class InternalBoundedCountHistogramFacet extends InternalHistogramFacet { static final XContentBuilderString COUNT = new XContentBuilderString("count"); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(name); builder.field(Fields._TYPE, HistogramFacet.TYPE); builder.startArray(Fields.ENTRIES); @@ -249,7 +274,8 @@ public class InternalBoundedCountHistogramFacet extends InternalHistogramFacet { return facet; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { name = in.readUTF(); comparatorType = ComparatorType.fromId(in.readByte()); offset = in.readLong(); @@ -262,7 +288,8 @@ public class InternalBoundedCountHistogramFacet extends InternalHistogramFacet { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(name); out.writeByte(comparatorType.id()); out.writeLong(offset); diff --git a/src/main/java/org/elasticsearch/search/facet/histogram/bounded/InternalBoundedFullHistogramFacet.java b/src/main/java/org/elasticsearch/search/facet/histogram/bounded/InternalBoundedFullHistogramFacet.java index b63794e534c..1063ed7ec42 100644 --- a/src/main/java/org/elasticsearch/search/facet/histogram/bounded/InternalBoundedFullHistogramFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/histogram/bounded/InternalBoundedFullHistogramFacet.java @@ -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 java.util.Iterator; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class InternalBoundedFullHistogramFacet extends InternalHistogramFacet { @@ -46,12 +46,14 @@ public class InternalBoundedFullHistogramFacet extends InternalHistogramFacet { } static Stream STREAM = new Stream() { - @Override public Facet readFacet(String type, StreamInput in) throws IOException { + @Override + public Facet readFacet(String type, StreamInput in) throws IOException { return readHistogramFacet(in); } }; - @Override public String streamType() { + @Override + public String streamType() { return STREAM_TYPE; } @@ -76,62 +78,76 @@ public class InternalBoundedFullHistogramFacet extends InternalHistogramFacet { this.total = total; } - @Override public long key() { + @Override + public long key() { return key; } - @Override public long getKey() { + @Override + public long getKey() { return key(); } - @Override public long count() { + @Override + public long count() { return count; } - @Override public long getCount() { + @Override + public long getCount() { return count(); } - @Override public double total() { + @Override + public double total() { return total; } - @Override public double getTotal() { + @Override + public double getTotal() { return total(); } - @Override public long totalCount() { + @Override + public long totalCount() { return totalCount; } - @Override public long getTotalCount() { + @Override + public long getTotalCount() { return this.totalCount; } - @Override public double mean() { + @Override + public double mean() { if (totalCount == 0) { return 0; } return total / totalCount; } - @Override public double getMean() { + @Override + public double getMean() { return total / totalCount; } - @Override public double min() { + @Override + public double min() { return this.min; } - @Override public double getMin() { + @Override + public double getMin() { return this.min; } - @Override public double max() { + @Override + public double max() { return this.max; } - @Override public double getMax() { + @Override + public double getMax() { return this.max; } } @@ -161,23 +177,28 @@ public class InternalBoundedFullHistogramFacet extends InternalHistogramFacet { this.cachedEntries = cachedEntries; } - @Override public String name() { + @Override + public String name() { return this.name; } - @Override public String getName() { + @Override + public String getName() { return name(); } - @Override public String type() { + @Override + public String type() { return TYPE; } - @Override public String getType() { + @Override + public String getType() { return type(); } - @Override public List entries() { + @Override + public List entries() { normalize(); if (entriesList == null) { Object[] newEntries = new Object[size]; @@ -188,11 +209,13 @@ public class InternalBoundedFullHistogramFacet extends InternalHistogramFacet { return (List) entriesList; } - @Override public List getEntries() { + @Override + public List getEntries() { return entries(); } - @Override public Iterator iterator() { + @Override + public Iterator iterator() { return (Iterator) entries().iterator(); } @@ -203,7 +226,8 @@ public class InternalBoundedFullHistogramFacet extends InternalHistogramFacet { } } - @Override public Facet reduce(String name, List facets) { + @Override + public Facet reduce(String name, List facets) { if (facets.size() == 1) { // we need to sort it InternalBoundedFullHistogramFacet internalFacet = (InternalBoundedFullHistogramFacet) facets.get(0); @@ -271,7 +295,8 @@ public class InternalBoundedFullHistogramFacet extends InternalHistogramFacet { static final XContentBuilderString MAX = new XContentBuilderString("max"); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(name); builder.field(Fields._TYPE, HistogramFacet.TYPE); builder.startArray(Fields.ENTRIES); @@ -309,7 +334,8 @@ public class InternalBoundedFullHistogramFacet extends InternalHistogramFacet { return facet; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { name = in.readUTF(); comparatorType = ComparatorType.fromId(in.readByte()); @@ -325,7 +351,8 @@ public class InternalBoundedFullHistogramFacet extends InternalHistogramFacet { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(name); out.writeByte(comparatorType.id()); out.writeLong(offset); diff --git a/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/CountHistogramFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/CountHistogramFacetCollector.java index 8acef77a505..e4bbdb09857 100644 --- a/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/CountHistogramFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/CountHistogramFacetCollector.java @@ -19,9 +19,9 @@ package org.elasticsearch.search.facet.histogram.unbounded; +import gnu.trove.map.hash.TLongLongHashMap; import org.apache.lucene.index.IndexReader; import org.elasticsearch.common.CacheRecycler; -import org.elasticsearch.common.trove.map.hash.TLongLongHashMap; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.NumericFieldData; @@ -39,7 +39,7 @@ import java.io.IOException; * A histogram facet collector that uses the same field as the key as well as the * value. * - * @author kimchy (shay.banon) + * */ public class CountHistogramFacetCollector extends AbstractFacetCollector { @@ -78,15 +78,18 @@ public class CountHistogramFacetCollector extends AbstractFacetCollector { histoProc = new HistogramProc(interval); } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { fieldData.forEachValueInDoc(doc, histoProc); } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { fieldData = (NumericFieldData) fieldDataCache.cache(fieldDataType, reader, indexFieldName); } - @Override public Facet facet() { + @Override + public Facet facet() { return new InternalCountHistogramFacet(facetName, comparatorType, histoProc.counts(), true); } @@ -104,7 +107,8 @@ public class CountHistogramFacetCollector extends AbstractFacetCollector { this.interval = interval; } - @Override public void onValue(int docId, double value) { + @Override + public void onValue(int docId, double value) { long bucket = bucket(value, interval); counts.adjustOrPutValue(bucket, 1, 1); } diff --git a/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/FullHistogramFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/FullHistogramFacetCollector.java index 53b1a56b449..7548dbd0b48 100644 --- a/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/FullHistogramFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/FullHistogramFacetCollector.java @@ -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.search.facet.histogram.unbounded; +import gnu.trove.ExtTLongObjectHashMap; import org.apache.lucene.index.IndexReader; import org.elasticsearch.common.CacheRecycler; -import org.elasticsearch.common.trove.ExtTLongObjectHashMap; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.NumericFieldData; @@ -39,7 +39,7 @@ import java.io.IOException; * A histogram facet collector that uses the same field as the key as well as the * value. * - * @author kimchy (shay.banon) + * */ public class FullHistogramFacetCollector extends AbstractFacetCollector { @@ -78,15 +78,18 @@ public class FullHistogramFacetCollector extends AbstractFacetCollector { histoProc = new HistogramProc(interval); } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { fieldData.forEachValueInDoc(doc, histoProc); } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { fieldData = (NumericFieldData) fieldDataCache.cache(fieldDataType, reader, indexFieldName); } - @Override public Facet facet() { + @Override + public Facet facet() { return new InternalFullHistogramFacet(facetName, comparatorType, histoProc.entries, true); } @@ -104,7 +107,8 @@ public class FullHistogramFacetCollector extends AbstractFacetCollector { this.interval = interval; } - @Override public void onValue(int docId, double value) { + @Override + public void onValue(int docId, double value) { long bucket = bucket(value, interval); InternalFullHistogramFacet.FullEntry entry = entries.get(bucket); if (entry == null) { diff --git a/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/InternalCountHistogramFacet.java b/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/InternalCountHistogramFacet.java index b9f9dfa745d..56e5f5d4304 100644 --- a/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/InternalCountHistogramFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/InternalCountHistogramFacet.java @@ -19,11 +19,11 @@ package org.elasticsearch.search.facet.histogram.unbounded; +import gnu.trove.iterator.TLongLongIterator; +import gnu.trove.map.hash.TLongLongHashMap; import org.elasticsearch.common.CacheRecycler; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.trove.iterator.TLongLongIterator; -import org.elasticsearch.common.trove.map.hash.TLongLongHashMap; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilderString; import org.elasticsearch.search.facet.Facet; @@ -36,7 +36,7 @@ import java.util.Iterator; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class InternalCountHistogramFacet extends InternalHistogramFacet { @@ -47,12 +47,14 @@ public class InternalCountHistogramFacet extends InternalHistogramFacet { } static Stream STREAM = new Stream() { - @Override public Facet readFacet(String type, StreamInput in) throws IOException { + @Override + public Facet readFacet(String type, StreamInput in) throws IOException { return readHistogramFacet(in); } }; - @Override public String streamType() { + @Override + public String streamType() { return STREAM_TYPE; } @@ -69,59 +71,73 @@ public class InternalCountHistogramFacet extends InternalHistogramFacet { this.count = count; } - @Override public long key() { + @Override + public long key() { return key; } - @Override public long getKey() { + @Override + public long getKey() { return key(); } - @Override public long count() { + @Override + public long count() { return count; } - @Override public long getCount() { + @Override + public long getCount() { return count(); } - @Override public double total() { + @Override + public double total() { return Double.NaN; } - @Override public double getTotal() { + @Override + public double getTotal() { return total(); } - @Override public long totalCount() { + @Override + public long totalCount() { return 0; } - @Override public long getTotalCount() { + @Override + public long getTotalCount() { return 0; } - @Override public double mean() { + @Override + public double mean() { return Double.NaN; } - @Override public double getMean() { + @Override + public double getMean() { return mean(); } - @Override public double min() { + @Override + public double min() { return Double.NaN; } - @Override public double getMin() { + @Override + public double getMin() { return Double.NaN; } - @Override public double max() { + @Override + public double max() { return Double.NaN; } - @Override public double getMax() { + @Override + public double getMax() { return Double.NaN; } } @@ -145,31 +161,38 @@ public class InternalCountHistogramFacet extends InternalHistogramFacet { this.cachedCounts = cachedCounts; } - @Override public String name() { + @Override + public String name() { return this.name; } - @Override public String getName() { + @Override + public String getName() { return name(); } - @Override public String type() { + @Override + public String type() { return TYPE; } - @Override public String getType() { + @Override + public String getType() { return type(); } - @Override public List entries() { + @Override + public List entries() { return Arrays.asList(computeEntries()); } - @Override public List getEntries() { + @Override + public List getEntries() { return entries(); } - @Override public Iterator iterator() { + @Override + public Iterator iterator() { return (Iterator) entries().iterator(); } @@ -179,7 +202,7 @@ public class InternalCountHistogramFacet extends InternalHistogramFacet { } entries = new CountEntry[counts.size()]; int i = 0; - for (TLongLongIterator it = counts.iterator(); it.hasNext();) { + for (TLongLongIterator it = counts.iterator(); it.hasNext(); ) { it.advance(); entries[i++] = new CountEntry(it.key(), it.value()); } @@ -196,7 +219,8 @@ public class InternalCountHistogramFacet extends InternalHistogramFacet { } } - @Override public Facet reduce(String name, List facets) { + @Override + public Facet reduce(String name, List facets) { if (facets.size() == 1) { return facets.get(0); } @@ -204,7 +228,7 @@ public class InternalCountHistogramFacet extends InternalHistogramFacet { for (Facet facet : facets) { InternalCountHistogramFacet histoFacet = (InternalCountHistogramFacet) facet; - for (TLongLongIterator it = histoFacet.counts.iterator(); it.hasNext();) { + for (TLongLongIterator it = histoFacet.counts.iterator(); it.hasNext(); ) { it.advance(); counts.adjustOrPutValue(it.key(), it.value(), it.value()); } @@ -221,7 +245,8 @@ public class InternalCountHistogramFacet extends InternalHistogramFacet { static final XContentBuilderString COUNT = new XContentBuilderString("count"); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(name); builder.field(Fields._TYPE, HistogramFacet.TYPE); builder.startArray(Fields.ENTRIES); @@ -242,7 +267,8 @@ public class InternalCountHistogramFacet extends InternalHistogramFacet { return facet; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { name = in.readUTF(); comparatorType = ComparatorType.fromId(in.readByte()); @@ -255,12 +281,13 @@ public class InternalCountHistogramFacet extends InternalHistogramFacet { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(name); out.writeByte(comparatorType.id()); // optimize the write, since we know we have the same buckets as keys out.writeVInt(counts.size()); - for (TLongLongIterator it = counts.iterator(); it.hasNext();) { + for (TLongLongIterator it = counts.iterator(); it.hasNext(); ) { it.advance(); out.writeLong(it.key()); out.writeVLong(it.value()); diff --git a/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/InternalFullHistogramFacet.java b/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/InternalFullHistogramFacet.java index 7df331816a2..c6740221448 100644 --- a/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/InternalFullHistogramFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/InternalFullHistogramFacet.java @@ -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.search.facet.histogram.unbounded; +import gnu.trove.ExtTLongObjectHashMap; import org.elasticsearch.common.CacheRecycler; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.trove.ExtTLongObjectHashMap; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilderString; import org.elasticsearch.search.facet.Facet; @@ -33,7 +33,7 @@ import java.io.IOException; import java.util.*; /** - * @author kimchy (shay.banon) + * */ public class InternalFullHistogramFacet extends InternalHistogramFacet { @@ -44,12 +44,14 @@ public class InternalFullHistogramFacet extends InternalHistogramFacet { } static Stream STREAM = new Stream() { - @Override public Facet readFacet(String type, StreamInput in) throws IOException { + @Override + public Facet readFacet(String type, StreamInput in) throws IOException { return readHistogramFacet(in); } }; - @Override public String streamType() { + @Override + public String streamType() { return STREAM_TYPE; } @@ -74,59 +76,73 @@ public class InternalFullHistogramFacet extends InternalHistogramFacet { this.total = total; } - @Override public long key() { + @Override + public long key() { return key; } - @Override public long getKey() { + @Override + public long getKey() { return key(); } - @Override public long count() { + @Override + public long count() { return count; } - @Override public long getCount() { + @Override + public long getCount() { return count(); } - @Override public double total() { + @Override + public double total() { return total; } - @Override public double getTotal() { + @Override + public double getTotal() { return total(); } - @Override public long totalCount() { + @Override + public long totalCount() { return totalCount; } - @Override public long getTotalCount() { + @Override + public long getTotalCount() { return this.totalCount; } - @Override public double mean() { + @Override + public double mean() { return total / totalCount; } - @Override public double getMean() { + @Override + public double getMean() { return total / totalCount; } - @Override public double min() { + @Override + public double min() { return this.min; } - @Override public double getMin() { + @Override + public double getMin() { return this.min; } - @Override public double max() { + @Override + public double max() { return this.max; } - @Override public double getMax() { + @Override + public double getMax() { return this.max; } } @@ -150,34 +166,41 @@ public class InternalFullHistogramFacet extends InternalHistogramFacet { this.entries = entries.valueCollection(); } - @Override public String name() { + @Override + public String name() { return this.name; } - @Override public String getName() { + @Override + public String getName() { return name(); } - @Override public String type() { + @Override + public String type() { return TYPE; } - @Override public String getType() { + @Override + public String getType() { return type(); } - @Override public List entries() { + @Override + public List entries() { if (!(entries instanceof List)) { entries = new ArrayList(entries); } return (List) entries; } - @Override public List getEntries() { + @Override + public List getEntries() { return entries(); } - @Override public Iterator iterator() { + @Override + public Iterator iterator() { return (Iterator) entries().iterator(); } @@ -189,7 +212,8 @@ public class InternalFullHistogramFacet extends InternalHistogramFacet { } } - @Override public Facet reduce(String name, List facets) { + @Override + public Facet reduce(String name, List facets) { if (facets.size() == 1) { // we need to sort it InternalFullHistogramFacet internalFacet = (InternalFullHistogramFacet) facets.get(0); @@ -256,7 +280,8 @@ public class InternalFullHistogramFacet extends InternalHistogramFacet { static final XContentBuilderString MAX = new XContentBuilderString("max"); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(name); builder.field(Fields._TYPE, HistogramFacet.TYPE); builder.startArray(Fields.ENTRIES); @@ -282,7 +307,8 @@ public class InternalFullHistogramFacet extends InternalHistogramFacet { return facet; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { name = in.readUTF(); comparatorType = ComparatorType.fromId(in.readByte()); @@ -294,7 +320,8 @@ public class InternalFullHistogramFacet extends InternalHistogramFacet { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(name); out.writeByte(comparatorType.id()); out.writeVInt(entries.size()); diff --git a/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/ScriptHistogramFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/ScriptHistogramFacetCollector.java index 51404fa9f48..3bdc1de2956 100644 --- a/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/ScriptHistogramFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/ScriptHistogramFacetCollector.java @@ -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.search.facet.histogram.unbounded; +import gnu.trove.ExtTLongObjectHashMap; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.Scorer; import org.elasticsearch.common.CacheRecycler; -import org.elasticsearch.common.trove.ExtTLongObjectHashMap; import org.elasticsearch.script.SearchScript; import org.elasticsearch.search.facet.AbstractFacetCollector; import org.elasticsearch.search.facet.Facet; @@ -33,7 +33,7 @@ import java.io.IOException; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class ScriptHistogramFacetCollector extends AbstractFacetCollector { @@ -55,7 +55,8 @@ public class ScriptHistogramFacetCollector extends AbstractFacetCollector { this.comparatorType = comparatorType; } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { keyScript.setNextDocId(doc); valueScript.setNextDocId(doc); long bucket; @@ -83,17 +84,20 @@ public class ScriptHistogramFacetCollector extends AbstractFacetCollector { } } - @Override public void setScorer(Scorer scorer) throws IOException { + @Override + public void setScorer(Scorer scorer) throws IOException { keyScript.setScorer(scorer); valueScript.setScorer(scorer); } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { keyScript.setNextReader(reader); valueScript.setNextReader(reader); } - @Override public Facet facet() { + @Override + public Facet facet() { return new InternalFullHistogramFacet(facetName, comparatorType, entries, true); } diff --git a/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/ValueHistogramFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/ValueHistogramFacetCollector.java index 85c039b1ca3..c00b7b2343a 100644 --- a/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/ValueHistogramFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/ValueHistogramFacetCollector.java @@ -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.search.facet.histogram.unbounded; +import gnu.trove.ExtTLongObjectHashMap; import org.apache.lucene.index.IndexReader; import org.elasticsearch.common.CacheRecycler; -import org.elasticsearch.common.trove.ExtTLongObjectHashMap; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.NumericFieldData; @@ -37,7 +37,7 @@ import java.io.IOException; /** * A histogram facet collector that uses different fields for the key and the value. * - * @author kimchy (shay.banon) + * */ public class ValueHistogramFacetCollector extends AbstractFacetCollector { @@ -87,16 +87,19 @@ public class ValueHistogramFacetCollector extends AbstractFacetCollector { histoProc = new HistogramProc(interval); } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { keyFieldData.forEachValueInDoc(doc, histoProc); } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { keyFieldData = (NumericFieldData) fieldDataCache.cache(keyFieldDataType, reader, keyIndexFieldName); histoProc.valueFieldData = (NumericFieldData) fieldDataCache.cache(valueFieldDataType, reader, valueIndexFieldName); } - @Override public Facet facet() { + @Override + public Facet facet() { return new InternalFullHistogramFacet(facetName, comparatorType, histoProc.entries, true); } @@ -114,7 +117,8 @@ public class ValueHistogramFacetCollector extends AbstractFacetCollector { this.interval = interval; } - @Override public void onValue(int docId, double value) { + @Override + public void onValue(int docId, double value) { long bucket = FullHistogramFacetCollector.bucket(value, interval); InternalFullHistogramFacet.FullEntry entry = entries.get(bucket); if (entry == null) { @@ -130,7 +134,8 @@ public class ValueHistogramFacetCollector extends AbstractFacetCollector { InternalFullHistogramFacet.FullEntry entry; - @Override public void onValue(int docId, double value) { + @Override + public void onValue(int docId, double value) { entry.totalCount++; entry.total += value; if (value < entry.min) { diff --git a/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/ValueScriptHistogramFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/ValueScriptHistogramFacetCollector.java index dd9bbee0ee3..6bfb40fe38d 100644 --- a/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/ValueScriptHistogramFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/ValueScriptHistogramFacetCollector.java @@ -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.search.facet.histogram.unbounded; +import gnu.trove.ExtTLongObjectHashMap; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.Scorer; import org.elasticsearch.common.CacheRecycler; -import org.elasticsearch.common.trove.ExtTLongObjectHashMap; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.NumericFieldData; @@ -42,7 +42,7 @@ import java.util.Map; * A histogram facet collector that uses the same field as the key as well as the * value. * - * @author kimchy (shay.banon) + * */ public class ValueScriptHistogramFacetCollector extends AbstractFacetCollector { @@ -85,20 +85,24 @@ public class ValueScriptHistogramFacetCollector extends AbstractFacetCollector { histoProc = new HistogramProc(interval, this.valueScript); } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { fieldData.forEachValueInDoc(doc, histoProc); } - @Override public void setScorer(Scorer scorer) throws IOException { + @Override + public void setScorer(Scorer scorer) throws IOException { valueScript.setScorer(scorer); } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { fieldData = (NumericFieldData) fieldDataCache.cache(fieldDataType, reader, indexFieldName); valueScript.setNextReader(reader); } - @Override public Facet facet() { + @Override + public Facet facet() { return new InternalFullHistogramFacet(facetName, comparatorType, histoProc.entries, true); } @@ -119,7 +123,8 @@ public class ValueScriptHistogramFacetCollector extends AbstractFacetCollector { this.valueScript = valueScript; } - @Override public void onValue(int docId, double value) { + @Override + public void onValue(int docId, double value) { valueScript.setNextDocId(docId); long bucket = bucket(value, interval); double scriptValue = valueScript.runAsDouble(); diff --git a/src/main/java/org/elasticsearch/search/facet/query/InternalQueryFacet.java b/src/main/java/org/elasticsearch/search/facet/query/InternalQueryFacet.java index e0146a574e9..394eaf7f85b 100644 --- a/src/main/java/org/elasticsearch/search/facet/query/InternalQueryFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/query/InternalQueryFacet.java @@ -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.search.facet.InternalFacet; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class InternalQueryFacet implements QueryFacet, InternalFacet { @@ -40,12 +40,14 @@ public class InternalQueryFacet implements QueryFacet, InternalFacet { } static Stream STREAM = new Stream() { - @Override public Facet readFacet(String type, StreamInput in) throws IOException { + @Override + public Facet readFacet(String type, StreamInput in) throws IOException { return readQueryFacet(in); } }; - @Override public String streamType() { + @Override + public String streamType() { return STREAM_TYPE; } @@ -62,11 +64,13 @@ public class InternalQueryFacet implements QueryFacet, InternalFacet { this.count = count; } - @Override public String type() { + @Override + public String type() { return TYPE; } - @Override public String getType() { + @Override + public String getType() { return TYPE; } @@ -77,7 +81,8 @@ public class InternalQueryFacet implements QueryFacet, InternalFacet { return name; } - @Override public String getName() { + @Override + public String getName() { return name(); } @@ -100,7 +105,8 @@ public class InternalQueryFacet implements QueryFacet, InternalFacet { static final XContentBuilderString COUNT = new XContentBuilderString("count"); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(name); builder.field(Fields._TYPE, QueryFacet.TYPE); builder.field(Fields.COUNT, count); @@ -114,12 +120,14 @@ public class InternalQueryFacet implements QueryFacet, InternalFacet { return result; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { name = in.readUTF(); count = in.readVLong(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(name); out.writeVLong(count); } diff --git a/src/main/java/org/elasticsearch/search/facet/query/QueryFacet.java b/src/main/java/org/elasticsearch/search/facet/query/QueryFacet.java index b141ad8d145..e8b7925eeca 100644 --- a/src/main/java/org/elasticsearch/search/facet/query/QueryFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/query/QueryFacet.java @@ -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.search.facet.Facet; /** * A query facets returns the count (number of hits) for a facet based on a query. * - * @author kimchy (shay.banon) + * */ public interface QueryFacet extends Facet { diff --git a/src/main/java/org/elasticsearch/search/facet/query/QueryFacetBuilder.java b/src/main/java/org/elasticsearch/search/facet/query/QueryFacetBuilder.java index 4e054c861ff..ef93258f9c5 100644 --- a/src/main/java/org/elasticsearch/search/facet/query/QueryFacetBuilder.java +++ b/src/main/java/org/elasticsearch/search/facet/query/QueryFacetBuilder.java @@ -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.search.facet.AbstractFacetBuilder; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class QueryFacetBuilder extends AbstractFacetBuilder { @@ -41,7 +41,8 @@ public class QueryFacetBuilder extends AbstractFacetBuilder { /** * Marks the facet to run in a global scope, not bounded by any query. */ - @Override public QueryFacetBuilder global(boolean global) { + @Override + public QueryFacetBuilder global(boolean global) { super.global(global); return this; } @@ -49,7 +50,8 @@ public class QueryFacetBuilder extends AbstractFacetBuilder { /** * Marks the facet to run in a specific scope. */ - @Override public QueryFacetBuilder scope(String scope) { + @Override + public QueryFacetBuilder scope(String scope) { super.scope(scope); return this; } @@ -73,7 +75,8 @@ public class QueryFacetBuilder extends AbstractFacetBuilder { return this; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { if (query == null) { throw new SearchSourceBuilderException("query must be set on query facet for facet [" + name + "]"); } diff --git a/src/main/java/org/elasticsearch/search/facet/query/QueryFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/query/QueryFacetCollector.java index 3792eb923fe..5bd3d4e9b54 100644 --- a/src/main/java/org/elasticsearch/search/facet/query/QueryFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/query/QueryFacetCollector.java @@ -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,13 +20,7 @@ package org.elasticsearch.search.facet.query; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.search.ConstantScoreQuery; -import org.apache.lucene.search.DeletionAwareConstantScoreQuery; -import org.apache.lucene.search.Filter; -import org.apache.lucene.search.FilteredQuery; -import org.apache.lucene.search.Query; -import org.apache.lucene.search.QueryWrapperFilter; -import org.apache.lucene.search.TotalHitCountCollector; +import org.apache.lucene.search.*; import org.elasticsearch.common.lucene.docset.DocSet; import org.elasticsearch.common.lucene.docset.DocSets; import org.elasticsearch.common.lucene.search.Queries; @@ -39,7 +33,7 @@ import org.elasticsearch.search.internal.SearchContext; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class QueryFacetCollector extends AbstractFacetCollector implements OptimizeGlobalFacetCollector { @@ -62,17 +56,20 @@ public class QueryFacetCollector extends AbstractFacetCollector implements Optim } } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { docSet = DocSets.convert(reader, filter.getDocIdSet(reader)); } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { if (docSet.get(doc)) { count++; } } - @Override public void optimizedGlobalExecution(SearchContext searchContext) throws IOException { + @Override + public void optimizedGlobalExecution(SearchContext searchContext) throws IOException { Query query = this.query; if (super.filter != null) { query = new FilteredQuery(query, super.filter); @@ -86,7 +83,8 @@ public class QueryFacetCollector extends AbstractFacetCollector implements Optim count = collector.getTotalHits(); } - @Override public Facet facet() { + @Override + public Facet facet() { return new InternalQueryFacet(facetName, count); } diff --git a/src/main/java/org/elasticsearch/search/facet/query/QueryFacetProcessor.java b/src/main/java/org/elasticsearch/search/facet/query/QueryFacetProcessor.java index 8881a405ebb..170f060fb45 100644 --- a/src/main/java/org/elasticsearch/search/facet/query/QueryFacetProcessor.java +++ b/src/main/java/org/elasticsearch/search/facet/query/QueryFacetProcessor.java @@ -33,25 +33,29 @@ import java.io.IOException; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class QueryFacetProcessor extends AbstractComponent implements FacetProcessor { - @Inject public QueryFacetProcessor(Settings settings) { + @Inject + public QueryFacetProcessor(Settings settings) { super(settings); InternalQueryFacet.registerStreams(); } - @Override public String[] types() { + @Override + public String[] types() { return new String[]{QueryFacet.TYPE}; } - @Override public FacetCollector parse(String facetName, XContentParser parser, SearchContext context) throws IOException { + @Override + public FacetCollector parse(String facetName, XContentParser parser, SearchContext context) throws IOException { Query facetQuery = context.queryParserService().parse(parser).query(); return new QueryFacetCollector(facetName, facetQuery, context.filterCache()); } - @Override public Facet reduce(String name, List facets) { + @Override + public Facet reduce(String name, List facets) { if (facets.size() == 1) { return facets.get(0); } diff --git a/src/main/java/org/elasticsearch/search/facet/range/InternalRangeFacet.java b/src/main/java/org/elasticsearch/search/facet/range/InternalRangeFacet.java index 722de608992..295bb4391d0 100644 --- a/src/main/java/org/elasticsearch/search/facet/range/InternalRangeFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/range/InternalRangeFacet.java @@ -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,7 +19,7 @@ package org.elasticsearch.search.facet.range; -import org.elasticsearch.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -32,7 +32,7 @@ import java.util.Iterator; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class InternalRangeFacet implements RangeFacet, InternalFacet { @@ -43,12 +43,14 @@ public class InternalRangeFacet implements RangeFacet, InternalFacet { } static Stream STREAM = new Stream() { - @Override public Facet readFacet(String type, StreamInput in) throws IOException { + @Override + public Facet readFacet(String type, StreamInput in) throws IOException { return readRangeFacet(in); } }; - @Override public String streamType() { + @Override + public String streamType() { return STREAM_TYPE; } @@ -64,31 +66,38 @@ public class InternalRangeFacet implements RangeFacet, InternalFacet { this.entries = entries; } - @Override public String name() { + @Override + public String name() { return this.name; } - @Override public String getName() { + @Override + public String getName() { return name(); } - @Override public String type() { + @Override + public String type() { return RangeFacet.TYPE; } - @Override public String getType() { + @Override + public String getType() { return RangeFacet.TYPE; } - @Override public List entries() { + @Override + public List entries() { return ImmutableList.copyOf(entries); } - @Override public List getEntries() { + @Override + public List getEntries() { return entries(); } - @Override public Iterator iterator() { + @Override + public Iterator iterator() { return entries().iterator(); } @@ -98,7 +107,8 @@ public class InternalRangeFacet implements RangeFacet, InternalFacet { return facet; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { name = in.readUTF(); entries = new Entry[in.readVInt()]; for (int i = 0; i < entries.length; i++) { @@ -120,7 +130,8 @@ public class InternalRangeFacet implements RangeFacet, InternalFacet { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(name); out.writeVInt(entries.length); for (Entry entry : entries) { @@ -161,7 +172,8 @@ public class InternalRangeFacet implements RangeFacet, InternalFacet { static final XContentBuilderString MAX = new XContentBuilderString("max"); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(name); builder.field(Fields._TYPE, "range"); builder.startArray(Fields.RANGES); diff --git a/src/main/java/org/elasticsearch/search/facet/range/KeyValueRangeFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/range/KeyValueRangeFacetCollector.java index f3ee9acc9d5..85ec4ec97e0 100644 --- a/src/main/java/org/elasticsearch/search/facet/range/KeyValueRangeFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/range/KeyValueRangeFacetCollector.java @@ -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,7 +32,7 @@ import org.elasticsearch.search.internal.SearchContext; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class KeyValueRangeFacetCollector extends AbstractFacetCollector { @@ -79,19 +79,22 @@ public class KeyValueRangeFacetCollector extends AbstractFacetCollector { this.rangeProc = new RangeProc(entries); } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { keyFieldData = (NumericFieldData) fieldDataCache.cache(keyFieldDataType, reader, keyIndexFieldName); rangeProc.valueFieldData = (NumericFieldData) fieldDataCache.cache(valueFieldDataType, reader, valueIndexFieldName); } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { for (RangeFacet.Entry entry : entries) { entry.foundInDoc = false; } keyFieldData.forEachValueInDoc(doc, rangeProc); } - @Override public Facet facet() { + @Override + public Facet facet() { return new InternalRangeFacet(facetName, entries); } @@ -105,7 +108,8 @@ public class KeyValueRangeFacetCollector extends AbstractFacetCollector { this.entries = entries; } - @Override public void onValue(int docId, double value) { + @Override + public void onValue(int docId, double value) { for (RangeFacet.Entry entry : entries) { if (entry.foundInDoc) { continue; diff --git a/src/main/java/org/elasticsearch/search/facet/range/RangeFacet.java b/src/main/java/org/elasticsearch/search/facet/range/RangeFacet.java index 0fd39cdf304..b655bd6d591 100644 --- a/src/main/java/org/elasticsearch/search/facet/range/RangeFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/range/RangeFacet.java @@ -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.search.facet.Facet; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public interface RangeFacet extends Facet, Iterable { diff --git a/src/main/java/org/elasticsearch/search/facet/range/RangeFacetBuilder.java b/src/main/java/org/elasticsearch/search/facet/range/RangeFacetBuilder.java index dd5f2df61d7..e4d374ba985 100644 --- a/src/main/java/org/elasticsearch/search/facet/range/RangeFacetBuilder.java +++ b/src/main/java/org/elasticsearch/search/facet/range/RangeFacetBuilder.java @@ -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,7 +19,7 @@ package org.elasticsearch.search.facet.range; -import org.elasticsearch.common.collect.Lists; +import com.google.common.collect.Lists; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.index.query.FilterBuilder; import org.elasticsearch.search.builder.SearchSourceBuilderException; @@ -31,7 +31,7 @@ import java.util.List; /** * A facet builder of range facets. * - * @author kimchy (shay.banon) + * */ public class RangeFacetBuilder extends AbstractFacetBuilder { @@ -136,7 +136,8 @@ public class RangeFacetBuilder extends AbstractFacetBuilder { /** * Marks the facet to run in a specific scope. */ - @Override public RangeFacetBuilder scope(String scope) { + @Override + public RangeFacetBuilder scope(String scope) { super.scope(scope); return this; } @@ -158,7 +159,8 @@ public class RangeFacetBuilder extends AbstractFacetBuilder { return this; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { if (keyFieldName == null) { throw new SearchSourceBuilderException("field must be set on range facet for facet [" + name + "]"); } diff --git a/src/main/java/org/elasticsearch/search/facet/range/RangeFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/range/RangeFacetCollector.java index 7ccceb2065b..41ebc8f30e7 100644 --- a/src/main/java/org/elasticsearch/search/facet/range/RangeFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/range/RangeFacetCollector.java @@ -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,7 +32,7 @@ import org.elasticsearch.search.internal.SearchContext; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class RangeFacetCollector extends AbstractFacetCollector { @@ -69,18 +69,21 @@ public class RangeFacetCollector extends AbstractFacetCollector { rangeProc = new RangeProc(entries); } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { fieldData = (NumericFieldData) fieldDataCache.cache(fieldDataType, reader, indexFieldName); } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { for (RangeFacet.Entry entry : entries) { entry.foundInDoc = false; } fieldData.forEachValueInDoc(doc, rangeProc); } - @Override public Facet facet() { + @Override + public Facet facet() { return new InternalRangeFacet(facetName, entries); } @@ -92,7 +95,8 @@ public class RangeFacetCollector extends AbstractFacetCollector { this.entries = entries; } - @Override public void onValue(int docId, double value) { + @Override + public void onValue(int docId, double value) { for (RangeFacet.Entry entry : entries) { if (entry.foundInDoc) { continue; diff --git a/src/main/java/org/elasticsearch/search/facet/range/RangeFacetProcessor.java b/src/main/java/org/elasticsearch/search/facet/range/RangeFacetProcessor.java index 793d39f650c..e7cd3ad86b3 100644 --- a/src/main/java/org/elasticsearch/search/facet/range/RangeFacetProcessor.java +++ b/src/main/java/org/elasticsearch/search/facet/range/RangeFacetProcessor.java @@ -19,7 +19,7 @@ package org.elasticsearch.search.facet.range; -import org.elasticsearch.common.collect.Lists; +import com.google.common.collect.Lists; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -36,20 +36,23 @@ import java.util.List; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class RangeFacetProcessor extends AbstractComponent implements FacetProcessor { - @Inject public RangeFacetProcessor(Settings settings) { + @Inject + public RangeFacetProcessor(Settings settings) { super(settings); InternalRangeFacet.registerStreams(); } - @Override public String[] types() { + @Override + public String[] types() { return new String[]{RangeFacet.TYPE}; } - @Override public FacetCollector parse(String facetName, XContentParser parser, SearchContext context) throws IOException { + @Override + public FacetCollector parse(String facetName, XContentParser parser, SearchContext context) throws IOException { String keyField = null; String valueField = null; String scriptLang = null; @@ -148,7 +151,8 @@ public class RangeFacetProcessor extends AbstractComponent implements FacetProce } } - @Override public Facet reduce(String name, List facets) { + @Override + public Facet reduce(String name, List facets) { if (facets.size() == 1) { return facets.get(0); } diff --git a/src/main/java/org/elasticsearch/search/facet/range/RangeScriptFacetBuilder.java b/src/main/java/org/elasticsearch/search/facet/range/RangeScriptFacetBuilder.java index 9cd30ce7ffc..b9351a9436f 100644 --- a/src/main/java/org/elasticsearch/search/facet/range/RangeScriptFacetBuilder.java +++ b/src/main/java/org/elasticsearch/search/facet/range/RangeScriptFacetBuilder.java @@ -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.search.facet.range; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.collect.Maps; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.index.query.FilterBuilder; import org.elasticsearch.search.builder.SearchSourceBuilderException; @@ -31,7 +31,7 @@ import java.util.List; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class RangeScriptFacetBuilder extends AbstractFacetBuilder { @@ -115,7 +115,8 @@ public class RangeScriptFacetBuilder extends AbstractFacetBuilder { /** * Marks the facet to run in a specific scope. */ - @Override public RangeScriptFacetBuilder scope(String scope) { + @Override + public RangeScriptFacetBuilder scope(String scope) { super.scope(scope); return this; } @@ -134,7 +135,8 @@ public class RangeScriptFacetBuilder extends AbstractFacetBuilder { return this; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { if (keyScript == null) { throw new SearchSourceBuilderException("key_script must be set on range script facet for facet [" + name + "]"); } diff --git a/src/main/java/org/elasticsearch/search/facet/range/ScriptRangeFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/range/ScriptRangeFacetCollector.java index 5758f9e106c..d07fdd11c8a 100644 --- a/src/main/java/org/elasticsearch/search/facet/range/ScriptRangeFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/range/ScriptRangeFacetCollector.java @@ -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.io.IOException; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class ScriptRangeFacetCollector extends AbstractFacetCollector { @@ -47,17 +47,20 @@ public class ScriptRangeFacetCollector extends AbstractFacetCollector { this.entries = entries; } - @Override public void setScorer(Scorer scorer) throws IOException { + @Override + public void setScorer(Scorer scorer) throws IOException { keyScript.setScorer(scorer); valueScript.setScorer(scorer); } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { keyScript.setNextReader(reader); valueScript.setNextReader(reader); } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { keyScript.setNextDocId(doc); valueScript.setNextDocId(doc); double key = keyScript.runAsDouble(); @@ -78,7 +81,8 @@ public class ScriptRangeFacetCollector extends AbstractFacetCollector { } } - @Override public Facet facet() { + @Override + public Facet facet() { return new InternalRangeFacet(facetName, entries); } } diff --git a/src/main/java/org/elasticsearch/search/facet/statistical/InternalStatisticalFacet.java b/src/main/java/org/elasticsearch/search/facet/statistical/InternalStatisticalFacet.java index 7c273b587fc..1c818bad28e 100644 --- a/src/main/java/org/elasticsearch/search/facet/statistical/InternalStatisticalFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/statistical/InternalStatisticalFacet.java @@ -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.search.facet.InternalFacet; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class InternalStatisticalFacet implements StatisticalFacet, InternalFacet { @@ -40,12 +40,14 @@ public class InternalStatisticalFacet implements StatisticalFacet, InternalFacet } static Stream STREAM = new Stream() { - @Override public Facet readFacet(String type, StreamInput in) throws IOException { + @Override + public Facet readFacet(String type, StreamInput in) throws IOException { return readStatisticalFacet(in); } }; - @Override public String streamType() { + @Override + public String streamType() { return STREAM_TYPE; } @@ -73,70 +75,86 @@ public class InternalStatisticalFacet implements StatisticalFacet, InternalFacet this.count = count; } - @Override public String name() { + @Override + public String name() { return this.name; } - @Override public String getName() { + @Override + public String getName() { return name(); } - @Override public String type() { + @Override + public String type() { return TYPE; } - @Override public String getType() { + @Override + public String getType() { return TYPE; } - @Override public long count() { + @Override + public long count() { return this.count; } - @Override public long getCount() { + @Override + public long getCount() { return count(); } - @Override public double total() { + @Override + public double total() { return this.total; } - @Override public double getTotal() { + @Override + public double getTotal() { return total(); } - @Override public double sumOfSquares() { + @Override + public double sumOfSquares() { return this.sumOfSquares; } - @Override public double getSumOfSquares() { + @Override + public double getSumOfSquares() { return sumOfSquares(); } - @Override public double mean() { + @Override + public double mean() { if (count == 0) { return 0; } return total / count; } - @Override public double getMean() { + @Override + public double getMean() { return mean(); } - @Override public double min() { + @Override + public double min() { return this.min; } - @Override public double getMin() { + @Override + public double getMin() { return min(); } - @Override public double max() { + @Override + public double max() { return this.max; } - @Override public double getMax() { + @Override + public double getMax() { return max(); } @@ -168,7 +186,8 @@ public class InternalStatisticalFacet implements StatisticalFacet, InternalFacet static final XContentBuilderString STD_DEVIATION = new XContentBuilderString("std_deviation"); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(name); builder.field(Fields._TYPE, StatisticalFacet.TYPE); builder.field(Fields.COUNT, count()); @@ -189,7 +208,8 @@ public class InternalStatisticalFacet implements StatisticalFacet, InternalFacet return facet; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { name = in.readUTF(); count = in.readVLong(); total = in.readDouble(); @@ -198,7 +218,8 @@ public class InternalStatisticalFacet implements StatisticalFacet, InternalFacet sumOfSquares = in.readDouble(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(name); out.writeVLong(count); out.writeDouble(total); diff --git a/src/main/java/org/elasticsearch/search/facet/statistical/ScriptStatisticalFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/statistical/ScriptStatisticalFacetCollector.java index 6b6bd460da0..164cee8f648 100644 --- a/src/main/java/org/elasticsearch/search/facet/statistical/ScriptStatisticalFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/statistical/ScriptStatisticalFacetCollector.java @@ -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.io.IOException; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class ScriptStatisticalFacetCollector extends AbstractFacetCollector { @@ -51,7 +51,8 @@ public class ScriptStatisticalFacetCollector extends AbstractFacetCollector { this.script = context.scriptService().search(context.lookup(), scriptLang, script, params); } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { script.setNextDocId(doc); double value = script.runAsDouble(); if (value < min) { @@ -65,15 +66,18 @@ public class ScriptStatisticalFacetCollector extends AbstractFacetCollector { count++; } - @Override public void setScorer(Scorer scorer) throws IOException { + @Override + public void setScorer(Scorer scorer) throws IOException { script.setScorer(scorer); } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { script.setNextReader(reader); } - @Override public Facet facet() { + @Override + public Facet facet() { return new InternalStatisticalFacet(facetName, min, max, total, sumOfSquares, count); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalFacet.java b/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalFacet.java index 2f8e51ba724..525042c4ebf 100644 --- a/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalFacet.java @@ -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.search.facet.Facet; /** * Numeric statistical information. * - * @author kimchy (shay.banon) + * */ public interface StatisticalFacet extends Facet { diff --git a/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalFacetBuilder.java b/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalFacetBuilder.java index 997c152b10a..435ae5e2b4b 100644 --- a/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalFacetBuilder.java +++ b/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalFacetBuilder.java @@ -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.search.facet.AbstractFacetBuilder; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class StatisticalFacetBuilder extends AbstractFacetBuilder { private String[] fieldsNames; @@ -61,7 +61,8 @@ public class StatisticalFacetBuilder extends AbstractFacetBuilder { /** * Marks the facet to run in a specific scope. */ - @Override public StatisticalFacetBuilder scope(String scope) { + @Override + public StatisticalFacetBuilder scope(String scope) { super.scope(scope); return this; } @@ -80,7 +81,8 @@ public class StatisticalFacetBuilder extends AbstractFacetBuilder { return this; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { if (fieldName == null && fieldsNames == null) { throw new SearchSourceBuilderException("field must be set on statistical facet for facet [" + name + "]"); } diff --git a/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalFacetCollector.java index dab58bd5a62..3d0f4134de9 100644 --- a/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalFacetCollector.java @@ -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,7 +32,7 @@ import org.elasticsearch.search.internal.SearchContext; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class StatisticalFacetCollector extends AbstractFacetCollector { @@ -64,15 +64,18 @@ public class StatisticalFacetCollector extends AbstractFacetCollector { fieldDataType = smartMappers.mapper().fieldDataType(); } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { fieldData.forEachValueInDoc(doc, statsProc); } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { fieldData = (NumericFieldData) fieldDataCache.cache(fieldDataType, reader, indexFieldName); } - @Override public Facet facet() { + @Override + public Facet facet() { return new InternalStatisticalFacet(facetName, statsProc.min(), statsProc.max(), statsProc.total(), statsProc.sumOfSquares(), statsProc.count()); } @@ -90,7 +93,8 @@ public class StatisticalFacetCollector extends AbstractFacetCollector { int missing; - @Override public void onValue(int docId, double value) { + @Override + public void onValue(int docId, double value) { if (value < min) { min = value; } @@ -102,7 +106,8 @@ public class StatisticalFacetCollector extends AbstractFacetCollector { count++; } - @Override public void onMissing(int docId) { + @Override + public void onMissing(int docId) { missing++; } diff --git a/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalFacetProcessor.java b/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalFacetProcessor.java index 514d3a2ae02..e51de35a7eb 100644 --- a/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalFacetProcessor.java +++ b/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalFacetProcessor.java @@ -19,7 +19,7 @@ package org.elasticsearch.search.facet.statistical; -import org.elasticsearch.common.collect.Lists; +import com.google.common.collect.Lists; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -35,20 +35,23 @@ import java.util.List; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class StatisticalFacetProcessor extends AbstractComponent implements FacetProcessor { - @Inject public StatisticalFacetProcessor(Settings settings) { + @Inject + public StatisticalFacetProcessor(Settings settings) { super(settings); InternalStatisticalFacet.registerStreams(); } - @Override public String[] types() { + @Override + public String[] types() { return new String[]{StatisticalFacet.TYPE}; } - @Override public FacetCollector parse(String facetName, XContentParser parser, SearchContext context) throws IOException { + @Override + public FacetCollector parse(String facetName, XContentParser parser, SearchContext context) throws IOException { String field = null; String[] fieldsNames = null; @@ -96,7 +99,8 @@ public class StatisticalFacetProcessor extends AbstractComponent implements Face } } - @Override public Facet reduce(String name, List facets) { + @Override + public Facet reduce(String name, List facets) { if (facets.size() == 1) { return facets.get(0); } diff --git a/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalFieldsFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalFieldsFacetCollector.java index 3d6beab172c..7a3620a8395 100644 --- a/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalFieldsFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalFieldsFacetCollector.java @@ -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,7 +32,7 @@ import org.elasticsearch.search.internal.SearchContext; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class StatisticalFieldsFacetCollector extends AbstractFacetCollector { @@ -65,19 +65,22 @@ public class StatisticalFieldsFacetCollector extends AbstractFacetCollector { } } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { for (NumericFieldData fieldData : fieldsData) { fieldData.forEachValueInDoc(doc, statsProc); } } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { for (int i = 0; i < indexFieldsNames.length; i++) { fieldsData[i] = (NumericFieldData) fieldDataCache.cache(fieldsDataType[i], reader, indexFieldsNames[i]); } } - @Override public Facet facet() { + @Override + public Facet facet() { return new InternalStatisticalFacet(facetName, statsProc.min(), statsProc.max(), statsProc.total(), statsProc.sumOfSquares(), statsProc.count()); } @@ -95,7 +98,8 @@ public class StatisticalFieldsFacetCollector extends AbstractFacetCollector { int missing; - @Override public void onValue(int docId, double value) { + @Override + public void onValue(int docId, double value) { if (value < min) { min = value; } @@ -107,7 +111,8 @@ public class StatisticalFieldsFacetCollector extends AbstractFacetCollector { count++; } - @Override public void onMissing(int docId) { + @Override + public void onMissing(int docId) { missing++; } diff --git a/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalScriptFacetBuilder.java b/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalScriptFacetBuilder.java index 52fea06b2da..873ac9fdf7a 100644 --- a/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalScriptFacetBuilder.java +++ b/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalScriptFacetBuilder.java @@ -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,7 +19,7 @@ package org.elasticsearch.search.facet.statistical; -import org.elasticsearch.common.collect.Maps; +import com.google.common.collect.Maps; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.index.query.FilterBuilder; import org.elasticsearch.search.builder.SearchSourceBuilderException; @@ -29,7 +29,7 @@ import java.io.IOException; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class StatisticalScriptFacetBuilder extends AbstractFacetBuilder { private String lang; @@ -51,7 +51,8 @@ public class StatisticalScriptFacetBuilder extends AbstractFacetBuilder { /** * Marks the facet to run in a specific scope. */ - @Override public AbstractFacetBuilder scope(String scope) { + @Override + public AbstractFacetBuilder scope(String scope) { super.scope(scope); return this; } @@ -91,7 +92,8 @@ public class StatisticalScriptFacetBuilder extends AbstractFacetBuilder { return this; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { if (script == null) { throw new SearchSourceBuilderException("script must be set on statistical script facet [" + name + "]"); } diff --git a/src/main/java/org/elasticsearch/search/facet/terms/InternalTermsFacet.java b/src/main/java/org/elasticsearch/search/facet/terms/InternalTermsFacet.java index ba88156acb1..bcc6a673d63 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/InternalTermsFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/InternalTermsFacet.java @@ -33,7 +33,7 @@ import org.elasticsearch.search.facet.terms.strings.InternalStringTermsFacet; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public abstract class InternalTermsFacet implements TermsFacet, InternalFacet { diff --git a/src/main/java/org/elasticsearch/search/facet/terms/TermsFacet.java b/src/main/java/org/elasticsearch/search/facet/terms/TermsFacet.java index bc31576c31f..59d03dc3cce 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/TermsFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/TermsFacet.java @@ -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.util.List; /** * Terms facet allows to return facets of the most popular terms within the search query. * - * @author kimchy (shay.banon) + * */ public interface TermsFacet extends Facet, Iterable { @@ -61,7 +61,8 @@ public interface TermsFacet extends Facet, Iterable { */ COUNT((byte) 0, new Comparator() { - @Override public int compare(Entry o1, Entry o2) { + @Override + public int compare(Entry o1, Entry o2) { int i = o2.count() - o1.count(); if (i == 0) { i = o2.compareTo(o1); @@ -77,7 +78,8 @@ public interface TermsFacet extends Facet, Iterable { */ REVERSE_COUNT((byte) 1, new Comparator() { - @Override public int compare(Entry o1, Entry o2) { + @Override + public int compare(Entry o1, Entry o2) { return -COUNT.comparator().compare(o1, o2); } }), @@ -86,7 +88,8 @@ public interface TermsFacet extends Facet, Iterable { */ TERM((byte) 2, new Comparator() { - @Override public int compare(Entry o1, Entry o2) { + @Override + public int compare(Entry o1, Entry o2) { return o1.compareTo(o2); } }), @@ -95,7 +98,8 @@ public interface TermsFacet extends Facet, Iterable { */ REVERSE_TERM((byte) 3, new Comparator() { - @Override public int compare(Entry o1, Entry o2) { + @Override + public int compare(Entry o1, Entry o2) { return -TERM.comparator().compare(o1, o2); } }); diff --git a/src/main/java/org/elasticsearch/search/facet/terms/TermsFacetBuilder.java b/src/main/java/org/elasticsearch/search/facet/terms/TermsFacetBuilder.java index 1f7ea355c3d..7f1657468f4 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/TermsFacetBuilder.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/TermsFacetBuilder.java @@ -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,7 +19,7 @@ package org.elasticsearch.search.facet.terms; -import org.elasticsearch.common.collect.Maps; +import com.google.common.collect.Maps; import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.index.query.FilterBuilder; @@ -32,7 +32,7 @@ import java.util.Map; /** * Term facets allow to collect frequency of terms within one (or more) field. * - * @author kimchy (shay.banon) + * */ public class TermsFacetBuilder extends AbstractFacetBuilder { private String fieldName; @@ -69,7 +69,8 @@ public class TermsFacetBuilder extends AbstractFacetBuilder { /** * Marks the facet to run in a specific scope. */ - @Override public TermsFacetBuilder scope(String scope) { + @Override + public TermsFacetBuilder scope(String scope) { super.scope(scope); return this; } @@ -204,7 +205,8 @@ public class TermsFacetBuilder extends AbstractFacetBuilder { return this; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { if (fieldName == null && fieldsNames == null && script == null) { throw new SearchSourceBuilderException("field/fields/script must be set on terms facet for facet [" + name + "]"); } diff --git a/src/main/java/org/elasticsearch/search/facet/terms/TermsFacetProcessor.java b/src/main/java/org/elasticsearch/search/facet/terms/TermsFacetProcessor.java index aa4d5a639eb..c613c4d4fff 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/TermsFacetProcessor.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/TermsFacetProcessor.java @@ -19,8 +19,8 @@ package org.elasticsearch.search.facet.terms; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.collect.Lists; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.regex.Regex; @@ -59,20 +59,23 @@ import java.util.Map; import java.util.regex.Pattern; /** - * @author kimchy (shay.banon) + * */ public class TermsFacetProcessor extends AbstractComponent implements FacetProcessor { - @Inject public TermsFacetProcessor(Settings settings) { + @Inject + public TermsFacetProcessor(Settings settings) { super(settings); InternalTermsFacet.registerStreams(); } - @Override public String[] types() { + @Override + public String[] types() { return new String[]{TermsFacet.TYPE}; } - @Override public FacetCollector parse(String facetName, XContentParser parser, SearchContext context) throws IOException { + @Override + public FacetCollector parse(String facetName, XContentParser parser, SearchContext context) throws IOException { String field = null; int size = 10; @@ -203,7 +206,8 @@ public class TermsFacetProcessor extends AbstractComponent implements FacetProce return new TermsStringFacetCollector(facetName, field, size, comparatorType, allTerms, context, excluded, pattern, scriptLang, script, params); } - @Override public Facet reduce(String name, List facets) { + @Override + public Facet reduce(String name, List facets) { InternalTermsFacet first = (InternalTermsFacet) facets.get(0); return first.reduce(name, facets); } diff --git a/src/main/java/org/elasticsearch/search/facet/terms/bytes/InternalByteTermsFacet.java b/src/main/java/org/elasticsearch/search/facet/terms/bytes/InternalByteTermsFacet.java index 7e69a10b428..f2a0c153688 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/bytes/InternalByteTermsFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/bytes/InternalByteTermsFacet.java @@ -19,13 +19,13 @@ package org.elasticsearch.search.facet.terms.bytes; +import com.google.common.collect.ImmutableList; +import gnu.trove.iterator.TByteIntIterator; +import gnu.trove.map.hash.TByteIntHashMap; import org.elasticsearch.common.CacheRecycler; import org.elasticsearch.common.collect.BoundedTreeSet; -import org.elasticsearch.common.collect.ImmutableList; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.trove.iterator.TByteIntIterator; -import org.elasticsearch.common.trove.map.hash.TByteIntHashMap; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilderString; import org.elasticsearch.search.facet.Facet; @@ -39,7 +39,7 @@ import java.util.Iterator; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class InternalByteTermsFacet extends InternalTermsFacet { @@ -50,12 +50,14 @@ public class InternalByteTermsFacet extends InternalTermsFacet { } static Stream STREAM = new Stream() { - @Override public Facet readFacet(String type, StreamInput in) throws IOException { + @Override + public Facet readFacet(String type, StreamInput in) throws IOException { return readTermsFacet(in); } }; - @Override public String streamType() { + @Override + public String streamType() { return STREAM_TYPE; } @@ -77,11 +79,13 @@ public class InternalByteTermsFacet extends InternalTermsFacet { return term(); } - @Override public Number termAsNumber() { + @Override + public Number termAsNumber() { return term; } - @Override public Number getTermAsNumber() { + @Override + public Number getTermAsNumber() { return termAsNumber(); } @@ -93,7 +97,8 @@ public class InternalByteTermsFacet extends InternalTermsFacet { return count(); } - @Override public int compareTo(Entry o) { + @Override + public int compareTo(Entry o) { byte anotherVal = ((ByteEntry) o).term; int i = term - anotherVal; if (i == 0) { @@ -129,39 +134,48 @@ public class InternalByteTermsFacet extends InternalTermsFacet { this.total = total; } - @Override public String name() { + @Override + public String name() { return this.name; } - @Override public String getName() { + @Override + public String getName() { return this.name; } - @Override public String type() { + @Override + public String type() { return TYPE; } - @Override public String getType() { + @Override + public String getType() { return type(); } - @Override public long missingCount() { + @Override + public long missingCount() { return this.missing; } - @Override public long getMissingCount() { + @Override + public long getMissingCount() { return missingCount(); } - @Override public long totalCount() { + @Override + public long totalCount() { return this.total; } - @Override public long getTotalCount() { + @Override + public long getTotalCount() { return totalCount(); } - @Override public long otherCount() { + @Override + public long otherCount() { long other = total; for (Entry entry : entries) { other -= entry.count(); @@ -169,28 +183,34 @@ public class InternalByteTermsFacet extends InternalTermsFacet { return other; } - @Override public long getOtherCount() { + @Override + public long getOtherCount() { return otherCount(); } - @Override public List entries() { + @Override + public List entries() { if (!(entries instanceof List)) { entries = ImmutableList.copyOf(entries); } return (List) entries; } - @Override public List getEntries() { + @Override + public List getEntries() { return entries(); } - @SuppressWarnings({"unchecked"}) @Override public Iterator iterator() { + @SuppressWarnings({"unchecked"}) + @Override + public Iterator iterator() { return (Iterator) entries.iterator(); } - @Override public Facet reduce(String name, List facets) { + @Override + public Facet reduce(String name, List facets) { if (facets.size() == 1) { return facets.get(0); } @@ -232,7 +252,8 @@ public class InternalByteTermsFacet extends InternalTermsFacet { static final XContentBuilderString COUNT = new XContentBuilderString("count"); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(name); builder.field(Fields._TYPE, TermsFacet.TYPE); builder.field(Fields.MISSING, missing); @@ -256,7 +277,8 @@ public class InternalByteTermsFacet extends InternalTermsFacet { return facet; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { name = in.readUTF(); comparatorType = ComparatorType.fromId(in.readByte()); requiredSize = in.readVInt(); @@ -270,7 +292,8 @@ public class InternalByteTermsFacet extends InternalTermsFacet { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(name); out.writeByte(comparatorType.id()); diff --git a/src/main/java/org/elasticsearch/search/facet/terms/bytes/TermsByteFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/terms/bytes/TermsByteFacetCollector.java index 6ce07869e99..984dc9c3263 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/bytes/TermsByteFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/bytes/TermsByteFacetCollector.java @@ -19,16 +19,16 @@ package org.elasticsearch.search.facet.terms.bytes; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import gnu.trove.iterator.TByteIntIterator; +import gnu.trove.map.hash.TByteIntHashMap; +import gnu.trove.set.hash.TByteHashSet; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.Scorer; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.CacheRecycler; import org.elasticsearch.common.collect.BoundedTreeSet; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.trove.iterator.TByteIntIterator; -import org.elasticsearch.common.trove.map.hash.TByteIntHashMap; -import org.elasticsearch.common.trove.set.hash.TByteHashSet; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.bytes.ByteFieldData; @@ -47,7 +47,7 @@ import java.util.Map; import java.util.Set; /** - * @author kimchy (shay.banon) + * */ public class TermsByteFacetCollector extends AbstractFacetCollector { @@ -118,24 +118,28 @@ public class TermsByteFacetCollector extends AbstractFacetCollector { } } - @Override public void setScorer(Scorer scorer) throws IOException { + @Override + public void setScorer(Scorer scorer) throws IOException { if (script != null) { script.setScorer(scorer); } } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { fieldData = (ByteFieldData) fieldDataCache.cache(fieldDataType, reader, indexFieldName); if (script != null) { script.setNextReader(reader); } } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { fieldData.forEachValueInDoc(doc, aggregator); } - @Override public Facet facet() { + @Override + public Facet facet() { TByteIntHashMap facets = aggregator.facets(); if (facets.isEmpty()) { CacheRecycler.pushByteIntMap(facets); @@ -184,7 +188,8 @@ public class TermsByteFacetCollector extends AbstractFacetCollector { this.script = script; } - @Override public void onValue(int docId, byte value) { + @Override + public void onValue(int docId, byte value) { if (excluded != null && excluded.contains(value)) { return; } @@ -218,16 +223,19 @@ public class TermsByteFacetCollector extends AbstractFacetCollector { this.facets = facets; } - @Override public void onValue(byte value) { + @Override + public void onValue(byte value) { facets.putIfAbsent(value, 0); } - @Override public void onValue(int docId, byte value) { + @Override + public void onValue(int docId, byte value) { facets.adjustOrPutValue(value, 1, 1); total++; } - @Override public void onMissing(int docID) { + @Override + public void onMissing(int docID) { missing++; } diff --git a/src/main/java/org/elasticsearch/search/facet/terms/bytes/TermsByteOrdinalsFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/terms/bytes/TermsByteOrdinalsFacetCollector.java index 7e4a84a23bf..30db6a5d015 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/bytes/TermsByteOrdinalsFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/bytes/TermsByteOrdinalsFacetCollector.java @@ -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.search.facet.terms.bytes; +import com.google.common.collect.ImmutableSet; +import gnu.trove.set.hash.TByteHashSet; import org.apache.lucene.index.IndexReader; import org.apache.lucene.util.PriorityQueue; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.CacheRecycler; import org.elasticsearch.common.collect.BoundedTreeSet; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.trove.set.hash.TByteHashSet; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldData; import org.elasticsearch.index.field.data.FieldDataType; @@ -43,7 +43,7 @@ import java.util.Arrays; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class TermsByteOrdinalsFacetCollector extends AbstractFacetCollector { @@ -116,7 +116,8 @@ public class TermsByteOrdinalsFacetCollector extends AbstractFacetCollector { this.aggregators = new ArrayList(context.searcher().subReaders().length); } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { if (current != null) { missing += current.counts[0]; total += current.total - current.counts[0]; @@ -128,11 +129,13 @@ public class TermsByteOrdinalsFacetCollector extends AbstractFacetCollector { current = new ReaderAggregator(fieldData); } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { fieldData.forEachOrdinalInDoc(doc, current); } - @Override public Facet facet() { + @Override + public Facet facet() { if (current != null) { missing += current.counts[0]; total += current.total - current.counts[0]; @@ -235,7 +238,8 @@ public class TermsByteOrdinalsFacetCollector extends AbstractFacetCollector { this.counts = CacheRecycler.popIntArray(fieldData.values().length); } - @Override public void onOrdinal(int docId, int ordinal) { + @Override + public void onOrdinal(int docId, int ordinal) { counts[ordinal]++; total++; } @@ -255,7 +259,8 @@ public class TermsByteOrdinalsFacetCollector extends AbstractFacetCollector { initialize(size); } - @Override protected boolean lessThan(ReaderAggregator a, ReaderAggregator b) { + @Override + protected boolean lessThan(ReaderAggregator a, ReaderAggregator b) { return a.current < b.current; } } diff --git a/src/main/java/org/elasticsearch/search/facet/terms/doubles/InternalDoubleTermsFacet.java b/src/main/java/org/elasticsearch/search/facet/terms/doubles/InternalDoubleTermsFacet.java index 57b598c61ff..85dbbdcd36c 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/doubles/InternalDoubleTermsFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/doubles/InternalDoubleTermsFacet.java @@ -19,13 +19,13 @@ package org.elasticsearch.search.facet.terms.doubles; +import com.google.common.collect.ImmutableList; +import gnu.trove.iterator.TDoubleIntIterator; +import gnu.trove.map.hash.TDoubleIntHashMap; import org.elasticsearch.common.CacheRecycler; import org.elasticsearch.common.collect.BoundedTreeSet; -import org.elasticsearch.common.collect.ImmutableList; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.trove.iterator.TDoubleIntIterator; -import org.elasticsearch.common.trove.map.hash.TDoubleIntHashMap; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilderString; import org.elasticsearch.search.facet.Facet; @@ -39,7 +39,7 @@ import java.util.Iterator; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class InternalDoubleTermsFacet extends InternalTermsFacet { @@ -50,12 +50,14 @@ public class InternalDoubleTermsFacet extends InternalTermsFacet { } static Stream STREAM = new Stream() { - @Override public Facet readFacet(String type, StreamInput in) throws IOException { + @Override + public Facet readFacet(String type, StreamInput in) throws IOException { return readTermsFacet(in); } }; - @Override public String streamType() { + @Override + public String streamType() { return STREAM_TYPE; } @@ -77,11 +79,13 @@ public class InternalDoubleTermsFacet extends InternalTermsFacet { return term(); } - @Override public Number termAsNumber() { + @Override + public Number termAsNumber() { return term; } - @Override public Number getTermAsNumber() { + @Override + public Number getTermAsNumber() { return termAsNumber(); } @@ -93,7 +97,8 @@ public class InternalDoubleTermsFacet extends InternalTermsFacet { return count(); } - @Override public int compareTo(Entry o) { + @Override + public int compareTo(Entry o) { double anotherVal = ((DoubleEntry) o).term; if (term < anotherVal) { return -1; @@ -132,54 +137,67 @@ public class InternalDoubleTermsFacet extends InternalTermsFacet { this.total = total; } - @Override public String name() { + @Override + public String name() { return this.name; } - @Override public String getName() { + @Override + public String getName() { return this.name; } - @Override public String type() { + @Override + public String type() { return TYPE; } - @Override public String getType() { + @Override + public String getType() { return type(); } - @Override public List entries() { + @Override + public List entries() { if (!(entries instanceof List)) { entries = ImmutableList.copyOf(entries); } return (List) entries; } - @Override public List getEntries() { + @Override + public List getEntries() { return entries(); } - @SuppressWarnings({"unchecked"}) @Override public Iterator iterator() { + @SuppressWarnings({"unchecked"}) + @Override + public Iterator iterator() { return (Iterator) entries.iterator(); } - @Override public long missingCount() { + @Override + public long missingCount() { return this.missing; } - @Override public long getMissingCount() { + @Override + public long getMissingCount() { return missingCount(); } - @Override public long totalCount() { + @Override + public long totalCount() { return this.total; } - @Override public long getTotalCount() { + @Override + public long getTotalCount() { return totalCount(); } - @Override public long otherCount() { + @Override + public long otherCount() { long other = total; for (Entry entry : entries) { other -= entry.count(); @@ -187,11 +205,13 @@ public class InternalDoubleTermsFacet extends InternalTermsFacet { return other; } - @Override public long getOtherCount() { + @Override + public long getOtherCount() { return otherCount(); } - @Override public Facet reduce(String name, List facets) { + @Override + public Facet reduce(String name, List facets) { if (facets.size() == 1) { return facets.get(0); } @@ -232,7 +252,8 @@ public class InternalDoubleTermsFacet extends InternalTermsFacet { static final XContentBuilderString COUNT = new XContentBuilderString("count"); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(name); builder.field(Fields._TYPE, TermsFacet.TYPE); builder.field(Fields.MISSING, missing); @@ -256,7 +277,8 @@ public class InternalDoubleTermsFacet extends InternalTermsFacet { return facet; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { name = in.readUTF(); comparatorType = ComparatorType.fromId(in.readByte()); requiredSize = in.readVInt(); @@ -270,7 +292,8 @@ public class InternalDoubleTermsFacet extends InternalTermsFacet { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(name); out.writeByte(comparatorType.id()); out.writeVInt(requiredSize); diff --git a/src/main/java/org/elasticsearch/search/facet/terms/doubles/TermsDoubleFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/terms/doubles/TermsDoubleFacetCollector.java index 1cecb98ac71..f792476e378 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/doubles/TermsDoubleFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/doubles/TermsDoubleFacetCollector.java @@ -19,16 +19,16 @@ package org.elasticsearch.search.facet.terms.doubles; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import gnu.trove.iterator.TDoubleIntIterator; +import gnu.trove.map.hash.TDoubleIntHashMap; +import gnu.trove.set.hash.TDoubleHashSet; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.Scorer; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.CacheRecycler; import org.elasticsearch.common.collect.BoundedTreeSet; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.trove.iterator.TDoubleIntIterator; -import org.elasticsearch.common.trove.map.hash.TDoubleIntHashMap; -import org.elasticsearch.common.trove.set.hash.TDoubleHashSet; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.doubles.DoubleFieldData; @@ -47,7 +47,7 @@ import java.util.Map; import java.util.Set; /** - * @author kimchy (shay.banon) + * */ public class TermsDoubleFacetCollector extends AbstractFacetCollector { @@ -117,24 +117,28 @@ public class TermsDoubleFacetCollector extends AbstractFacetCollector { } } - @Override public void setScorer(Scorer scorer) throws IOException { + @Override + public void setScorer(Scorer scorer) throws IOException { if (script != null) { script.setScorer(scorer); } } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { fieldData = (DoubleFieldData) fieldDataCache.cache(fieldDataType, reader, indexFieldName); if (script != null) { script.setNextReader(reader); } } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { fieldData.forEachValueInDoc(doc, aggregator); } - @Override public Facet facet() { + @Override + public Facet facet() { TDoubleIntHashMap facets = aggregator.facets(); if (facets.isEmpty()) { CacheRecycler.pushDoubleIntMap(facets); @@ -183,7 +187,8 @@ public class TermsDoubleFacetCollector extends AbstractFacetCollector { } } - @Override public void onValue(int docId, double value) { + @Override + public void onValue(int docId, double value) { if (excluded != null && excluded.contains(value)) { return; } @@ -217,16 +222,19 @@ public class TermsDoubleFacetCollector extends AbstractFacetCollector { this.facets = facets; } - @Override public void onValue(double value) { + @Override + public void onValue(double value) { facets.putIfAbsent(value, 0); } - @Override public void onValue(int docId, double value) { + @Override + public void onValue(int docId, double value) { facets.adjustOrPutValue(value, 1, 1); total++; } - @Override public void onMissing(int docId) { + @Override + public void onMissing(int docId) { missing++; } diff --git a/src/main/java/org/elasticsearch/search/facet/terms/doubles/TermsDoubleOrdinalsFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/terms/doubles/TermsDoubleOrdinalsFacetCollector.java index 1c06a543ead..e45f8d4c5b4 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/doubles/TermsDoubleOrdinalsFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/doubles/TermsDoubleOrdinalsFacetCollector.java @@ -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.search.facet.terms.doubles; +import com.google.common.collect.ImmutableSet; +import gnu.trove.set.hash.TDoubleHashSet; import org.apache.lucene.index.IndexReader; import org.apache.lucene.util.PriorityQueue; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.CacheRecycler; import org.elasticsearch.common.collect.BoundedTreeSet; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.trove.set.hash.TDoubleHashSet; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldData; import org.elasticsearch.index.field.data.FieldDataType; @@ -43,7 +43,7 @@ import java.util.Arrays; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class TermsDoubleOrdinalsFacetCollector extends AbstractFacetCollector { @@ -115,7 +115,8 @@ public class TermsDoubleOrdinalsFacetCollector extends AbstractFacetCollector { this.aggregators = new ArrayList(context.searcher().subReaders().length); } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { if (current != null) { missing += current.counts[0]; total += current.total - current.counts[0]; @@ -127,11 +128,13 @@ public class TermsDoubleOrdinalsFacetCollector extends AbstractFacetCollector { current = new ReaderAggregator(fieldData); } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { fieldData.forEachOrdinalInDoc(doc, current); } - @Override public Facet facet() { + @Override + public Facet facet() { if (current != null) { missing += current.counts[0]; total += current.total - current.counts[0]; @@ -234,7 +237,8 @@ public class TermsDoubleOrdinalsFacetCollector extends AbstractFacetCollector { this.counts = CacheRecycler.popIntArray(fieldData.values().length); } - @Override public void onOrdinal(int docId, int ordinal) { + @Override + public void onOrdinal(int docId, int ordinal) { counts[ordinal]++; total++; } @@ -254,7 +258,8 @@ public class TermsDoubleOrdinalsFacetCollector extends AbstractFacetCollector { initialize(size); } - @Override protected boolean lessThan(ReaderAggregator a, ReaderAggregator b) { + @Override + protected boolean lessThan(ReaderAggregator a, ReaderAggregator b) { return a.current < b.current; } } diff --git a/src/main/java/org/elasticsearch/search/facet/terms/floats/InternalFloatTermsFacet.java b/src/main/java/org/elasticsearch/search/facet/terms/floats/InternalFloatTermsFacet.java index a0ce55bdfdb..a511a29a713 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/floats/InternalFloatTermsFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/floats/InternalFloatTermsFacet.java @@ -19,13 +19,13 @@ package org.elasticsearch.search.facet.terms.floats; +import com.google.common.collect.ImmutableList; +import gnu.trove.iterator.TFloatIntIterator; +import gnu.trove.map.hash.TFloatIntHashMap; import org.elasticsearch.common.CacheRecycler; import org.elasticsearch.common.collect.BoundedTreeSet; -import org.elasticsearch.common.collect.ImmutableList; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.trove.iterator.TFloatIntIterator; -import org.elasticsearch.common.trove.map.hash.TFloatIntHashMap; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilderString; import org.elasticsearch.search.facet.Facet; @@ -39,7 +39,7 @@ import java.util.Iterator; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class InternalFloatTermsFacet extends InternalTermsFacet { @@ -50,12 +50,14 @@ public class InternalFloatTermsFacet extends InternalTermsFacet { } static Stream STREAM = new Stream() { - @Override public Facet readFacet(String type, StreamInput in) throws IOException { + @Override + public Facet readFacet(String type, StreamInput in) throws IOException { return readTermsFacet(in); } }; - @Override public String streamType() { + @Override + public String streamType() { return STREAM_TYPE; } @@ -77,11 +79,13 @@ public class InternalFloatTermsFacet extends InternalTermsFacet { return term(); } - @Override public Number termAsNumber() { + @Override + public Number termAsNumber() { return term; } - @Override public Number getTermAsNumber() { + @Override + public Number getTermAsNumber() { return termAsNumber(); } @@ -93,7 +97,8 @@ public class InternalFloatTermsFacet extends InternalTermsFacet { return count(); } - @Override public int compareTo(Entry o) { + @Override + public int compareTo(Entry o) { float anotherVal = ((FloatEntry) o).term; if (term < anotherVal) { return -1; @@ -132,54 +137,67 @@ public class InternalFloatTermsFacet extends InternalTermsFacet { this.total = total; } - @Override public String name() { + @Override + public String name() { return this.name; } - @Override public String getName() { + @Override + public String getName() { return this.name; } - @Override public String type() { + @Override + public String type() { return TYPE; } - @Override public String getType() { + @Override + public String getType() { return type(); } - @Override public List entries() { + @Override + public List entries() { if (!(entries instanceof List)) { entries = ImmutableList.copyOf(entries); } return (List) entries; } - @Override public List getEntries() { + @Override + public List getEntries() { return entries(); } - @SuppressWarnings({"unchecked"}) @Override public Iterator iterator() { + @SuppressWarnings({"unchecked"}) + @Override + public Iterator iterator() { return (Iterator) entries.iterator(); } - @Override public long missingCount() { + @Override + public long missingCount() { return this.missing; } - @Override public long getMissingCount() { + @Override + public long getMissingCount() { return missingCount(); } - @Override public long totalCount() { + @Override + public long totalCount() { return this.total; } - @Override public long getTotalCount() { + @Override + public long getTotalCount() { return totalCount(); } - @Override public long otherCount() { + @Override + public long otherCount() { long other = total; for (Entry entry : entries) { other -= entry.count(); @@ -187,11 +205,13 @@ public class InternalFloatTermsFacet extends InternalTermsFacet { return other; } - @Override public long getOtherCount() { + @Override + public long getOtherCount() { return otherCount(); } - @Override public Facet reduce(String name, List facets) { + @Override + public Facet reduce(String name, List facets) { if (facets.size() == 1) { return facets.get(0); } @@ -232,7 +252,8 @@ public class InternalFloatTermsFacet extends InternalTermsFacet { static final XContentBuilderString COUNT = new XContentBuilderString("count"); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(name); builder.field(Fields._TYPE, TermsFacet.TYPE); builder.field(Fields.MISSING, missing); @@ -256,7 +277,8 @@ public class InternalFloatTermsFacet extends InternalTermsFacet { return facet; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { name = in.readUTF(); comparatorType = ComparatorType.fromId(in.readByte()); requiredSize = in.readVInt(); @@ -270,7 +292,8 @@ public class InternalFloatTermsFacet extends InternalTermsFacet { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(name); out.writeByte(comparatorType.id()); out.writeVInt(requiredSize); diff --git a/src/main/java/org/elasticsearch/search/facet/terms/floats/TermsFloatFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/terms/floats/TermsFloatFacetCollector.java index 92146b4b5a5..aa70de892a6 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/floats/TermsFloatFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/floats/TermsFloatFacetCollector.java @@ -19,16 +19,16 @@ package org.elasticsearch.search.facet.terms.floats; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import gnu.trove.iterator.TFloatIntIterator; +import gnu.trove.map.hash.TFloatIntHashMap; +import gnu.trove.set.hash.TFloatHashSet; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.Scorer; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.CacheRecycler; import org.elasticsearch.common.collect.BoundedTreeSet; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.trove.iterator.TFloatIntIterator; -import org.elasticsearch.common.trove.map.hash.TFloatIntHashMap; -import org.elasticsearch.common.trove.set.hash.TFloatHashSet; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.floats.FloatFieldData; @@ -47,7 +47,7 @@ import java.util.Map; import java.util.Set; /** - * @author kimchy (shay.banon) + * */ public class TermsFloatFacetCollector extends AbstractFacetCollector { @@ -117,24 +117,28 @@ public class TermsFloatFacetCollector extends AbstractFacetCollector { } } - @Override public void setScorer(Scorer scorer) throws IOException { + @Override + public void setScorer(Scorer scorer) throws IOException { if (script != null) { script.setScorer(scorer); } } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { fieldData = (FloatFieldData) fieldDataCache.cache(fieldDataType, reader, indexFieldName); if (script != null) { script.setNextReader(reader); } } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { fieldData.forEachValueInDoc(doc, aggregator); } - @Override public Facet facet() { + @Override + public Facet facet() { TFloatIntHashMap facets = aggregator.facets(); if (facets.isEmpty()) { CacheRecycler.pushFloatIntMap(facets); @@ -183,7 +187,8 @@ public class TermsFloatFacetCollector extends AbstractFacetCollector { this.script = script; } - @Override public void onValue(int docId, float value) { + @Override + public void onValue(int docId, float value) { if (excluded != null && excluded.contains(value)) { return; } @@ -217,16 +222,19 @@ public class TermsFloatFacetCollector extends AbstractFacetCollector { this.facets = facets; } - @Override public void onValue(float value) { + @Override + public void onValue(float value) { facets.putIfAbsent(value, 0); } - @Override public void onValue(int docId, float value) { + @Override + public void onValue(int docId, float value) { facets.adjustOrPutValue(value, 1, 1); total++; } - @Override public void onMissing(int docId) { + @Override + public void onMissing(int docId) { missing++; } diff --git a/src/main/java/org/elasticsearch/search/facet/terms/floats/TermsFloatOrdinalsFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/terms/floats/TermsFloatOrdinalsFacetCollector.java index 257c90665c3..0faa900303d 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/floats/TermsFloatOrdinalsFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/floats/TermsFloatOrdinalsFacetCollector.java @@ -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.search.facet.terms.floats; +import com.google.common.collect.ImmutableSet; +import gnu.trove.set.hash.TFloatHashSet; import org.apache.lucene.index.IndexReader; import org.apache.lucene.util.PriorityQueue; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.CacheRecycler; import org.elasticsearch.common.collect.BoundedTreeSet; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.trove.set.hash.TFloatHashSet; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldData; import org.elasticsearch.index.field.data.FieldDataType; @@ -43,7 +43,7 @@ import java.util.Arrays; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class TermsFloatOrdinalsFacetCollector extends AbstractFacetCollector { @@ -115,7 +115,8 @@ public class TermsFloatOrdinalsFacetCollector extends AbstractFacetCollector { this.aggregators = new ArrayList(context.searcher().subReaders().length); } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { if (current != null) { missing += current.counts[0]; total += current.total - current.counts[0]; @@ -127,11 +128,13 @@ public class TermsFloatOrdinalsFacetCollector extends AbstractFacetCollector { current = new ReaderAggregator(fieldData); } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { fieldData.forEachOrdinalInDoc(doc, current); } - @Override public Facet facet() { + @Override + public Facet facet() { if (current != null) { missing += current.counts[0]; total += current.total - current.counts[0]; @@ -234,7 +237,8 @@ public class TermsFloatOrdinalsFacetCollector extends AbstractFacetCollector { this.counts = CacheRecycler.popIntArray(fieldData.values().length); } - @Override public void onOrdinal(int docId, int ordinal) { + @Override + public void onOrdinal(int docId, int ordinal) { counts[ordinal]++; total++; } @@ -254,7 +258,8 @@ public class TermsFloatOrdinalsFacetCollector extends AbstractFacetCollector { initialize(size); } - @Override protected boolean lessThan(ReaderAggregator a, ReaderAggregator b) { + @Override + protected boolean lessThan(ReaderAggregator a, ReaderAggregator b) { return a.current < b.current; } } diff --git a/src/main/java/org/elasticsearch/search/facet/terms/index/IndexNameFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/terms/index/IndexNameFacetCollector.java index 20011d1f91b..53cc4a6fc6a 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/index/IndexNameFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/index/IndexNameFacetCollector.java @@ -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.search.facet.terms.index; +import com.google.common.collect.Sets; import org.apache.lucene.index.IndexReader; -import org.elasticsearch.common.collect.Sets; import org.elasticsearch.search.facet.AbstractFacetCollector; import org.elasticsearch.search.facet.Facet; import org.elasticsearch.search.facet.terms.TermsFacet; @@ -29,7 +29,7 @@ import org.elasticsearch.search.facet.terms.strings.InternalStringTermsFacet; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class IndexNameFacetCollector extends AbstractFacetCollector { @@ -48,14 +48,17 @@ public class IndexNameFacetCollector extends AbstractFacetCollector { this.size = size; } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { count++; } - @Override public Facet facet() { + @Override + public Facet facet() { return new InternalStringTermsFacet(facetName, comparatorType, size, Sets.newHashSet(new InternalStringTermsFacet.StringEntry(indexName, count)), 0, count); } } diff --git a/src/main/java/org/elasticsearch/search/facet/terms/ints/InternalIntTermsFacet.java b/src/main/java/org/elasticsearch/search/facet/terms/ints/InternalIntTermsFacet.java index cbcb8f5c4cc..032153fbb09 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/ints/InternalIntTermsFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/ints/InternalIntTermsFacet.java @@ -19,13 +19,13 @@ package org.elasticsearch.search.facet.terms.ints; +import com.google.common.collect.ImmutableList; +import gnu.trove.iterator.TIntIntIterator; +import gnu.trove.map.hash.TIntIntHashMap; import org.elasticsearch.common.CacheRecycler; import org.elasticsearch.common.collect.BoundedTreeSet; -import org.elasticsearch.common.collect.ImmutableList; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.trove.iterator.TIntIntIterator; -import org.elasticsearch.common.trove.map.hash.TIntIntHashMap; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilderString; import org.elasticsearch.search.facet.Facet; @@ -39,7 +39,7 @@ import java.util.Iterator; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class InternalIntTermsFacet extends InternalTermsFacet { @@ -50,12 +50,14 @@ public class InternalIntTermsFacet extends InternalTermsFacet { } static Stream STREAM = new Stream() { - @Override public Facet readFacet(String type, StreamInput in) throws IOException { + @Override + public Facet readFacet(String type, StreamInput in) throws IOException { return readTermsFacet(in); } }; - @Override public String streamType() { + @Override + public String streamType() { return STREAM_TYPE; } @@ -77,11 +79,13 @@ public class InternalIntTermsFacet extends InternalTermsFacet { return term(); } - @Override public Number termAsNumber() { + @Override + public Number termAsNumber() { return term; } - @Override public Number getTermAsNumber() { + @Override + public Number getTermAsNumber() { return termAsNumber(); } @@ -93,7 +97,8 @@ public class InternalIntTermsFacet extends InternalTermsFacet { return count(); } - @Override public int compareTo(Entry o) { + @Override + public int compareTo(Entry o) { int anotherVal = ((IntEntry) o).term; int i = term - anotherVal; if (i == 0) { @@ -129,54 +134,67 @@ public class InternalIntTermsFacet extends InternalTermsFacet { this.total = total; } - @Override public String name() { + @Override + public String name() { return this.name; } - @Override public String getName() { + @Override + public String getName() { return this.name; } - @Override public String type() { + @Override + public String type() { return TYPE; } - @Override public String getType() { + @Override + public String getType() { return type(); } - @Override public List entries() { + @Override + public List entries() { if (!(entries instanceof List)) { entries = ImmutableList.copyOf(entries); } return (List) entries; } - @Override public List getEntries() { + @Override + public List getEntries() { return entries(); } - @SuppressWarnings({"unchecked"}) @Override public Iterator iterator() { + @SuppressWarnings({"unchecked"}) + @Override + public Iterator iterator() { return (Iterator) entries.iterator(); } - @Override public long missingCount() { + @Override + public long missingCount() { return this.missing; } - @Override public long getMissingCount() { + @Override + public long getMissingCount() { return missingCount(); } - @Override public long totalCount() { + @Override + public long totalCount() { return this.total; } - @Override public long getTotalCount() { + @Override + public long getTotalCount() { return totalCount(); } - @Override public long otherCount() { + @Override + public long otherCount() { long other = total; for (Entry entry : entries) { other -= entry.count(); @@ -184,11 +202,13 @@ public class InternalIntTermsFacet extends InternalTermsFacet { return other; } - @Override public long getOtherCount() { + @Override + public long getOtherCount() { return otherCount(); } - @Override public Facet reduce(String name, List facets) { + @Override + public Facet reduce(String name, List facets) { if (facets.size() == 1) { return facets.get(0); } @@ -229,7 +249,8 @@ public class InternalIntTermsFacet extends InternalTermsFacet { static final XContentBuilderString COUNT = new XContentBuilderString("count"); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(name); builder.field(Fields._TYPE, TermsFacet.TYPE); builder.field(Fields.MISSING, missing); @@ -253,7 +274,8 @@ public class InternalIntTermsFacet extends InternalTermsFacet { return facet; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { name = in.readUTF(); comparatorType = ComparatorType.fromId(in.readByte()); requiredSize = in.readVInt(); @@ -267,7 +289,8 @@ public class InternalIntTermsFacet extends InternalTermsFacet { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(name); out.writeByte(comparatorType.id()); out.writeVInt(requiredSize); diff --git a/src/main/java/org/elasticsearch/search/facet/terms/ints/TermsIntFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/terms/ints/TermsIntFacetCollector.java index c01f323c6b4..ba50da000ab 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/ints/TermsIntFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/ints/TermsIntFacetCollector.java @@ -19,16 +19,16 @@ package org.elasticsearch.search.facet.terms.ints; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import gnu.trove.iterator.TIntIntIterator; +import gnu.trove.map.hash.TIntIntHashMap; +import gnu.trove.set.hash.TIntHashSet; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.Scorer; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.CacheRecycler; import org.elasticsearch.common.collect.BoundedTreeSet; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.trove.iterator.TIntIntIterator; -import org.elasticsearch.common.trove.map.hash.TIntIntHashMap; -import org.elasticsearch.common.trove.set.hash.TIntHashSet; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.ints.IntFieldData; @@ -47,7 +47,7 @@ import java.util.Map; import java.util.Set; /** - * @author kimchy (shay.banon) + * */ public class TermsIntFacetCollector extends AbstractFacetCollector { @@ -117,24 +117,28 @@ public class TermsIntFacetCollector extends AbstractFacetCollector { } } - @Override public void setScorer(Scorer scorer) throws IOException { + @Override + public void setScorer(Scorer scorer) throws IOException { if (script != null) { script.setScorer(scorer); } } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { fieldData = (IntFieldData) fieldDataCache.cache(fieldDataType, reader, indexFieldName); if (script != null) { script.setNextReader(reader); } } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { fieldData.forEachValueInDoc(doc, aggregator); } - @Override public Facet facet() { + @Override + public Facet facet() { TIntIntHashMap facets = aggregator.facets(); if (facets.isEmpty()) { CacheRecycler.pushIntIntMap(facets); @@ -183,7 +187,8 @@ public class TermsIntFacetCollector extends AbstractFacetCollector { this.script = script; } - @Override public void onValue(int docId, int value) { + @Override + public void onValue(int docId, int value) { if (excluded != null && excluded.contains(value)) { return; } @@ -217,16 +222,19 @@ public class TermsIntFacetCollector extends AbstractFacetCollector { this.facets = facets; } - @Override public void onValue(int value) { + @Override + public void onValue(int value) { facets.putIfAbsent(value, 0); } - @Override public void onValue(int docId, int value) { + @Override + public void onValue(int docId, int value) { facets.adjustOrPutValue(value, 1, 1); total++; } - @Override public void onMissing(int docId) { + @Override + public void onMissing(int docId) { missing++; } diff --git a/src/main/java/org/elasticsearch/search/facet/terms/ints/TermsIntOrdinalsFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/terms/ints/TermsIntOrdinalsFacetCollector.java index a05a506e6e1..dee299527c6 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/ints/TermsIntOrdinalsFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/ints/TermsIntOrdinalsFacetCollector.java @@ -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.search.facet.terms.ints; +import com.google.common.collect.ImmutableSet; +import gnu.trove.set.hash.TIntHashSet; import org.apache.lucene.index.IndexReader; import org.apache.lucene.util.PriorityQueue; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.CacheRecycler; import org.elasticsearch.common.collect.BoundedTreeSet; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.trove.set.hash.TIntHashSet; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldData; import org.elasticsearch.index.field.data.FieldDataType; @@ -43,7 +43,7 @@ import java.util.Arrays; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class TermsIntOrdinalsFacetCollector extends AbstractFacetCollector { @@ -115,7 +115,8 @@ public class TermsIntOrdinalsFacetCollector extends AbstractFacetCollector { this.aggregators = new ArrayList(context.searcher().subReaders().length); } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { if (current != null) { missing += current.counts[0]; total += current.total - current.counts[0]; @@ -127,11 +128,13 @@ public class TermsIntOrdinalsFacetCollector extends AbstractFacetCollector { current = new ReaderAggregator(fieldData); } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { fieldData.forEachOrdinalInDoc(doc, current); } - @Override public Facet facet() { + @Override + public Facet facet() { if (current != null) { missing += current.counts[0]; total += current.total - current.counts[0]; @@ -234,7 +237,8 @@ public class TermsIntOrdinalsFacetCollector extends AbstractFacetCollector { this.counts = CacheRecycler.popIntArray(fieldData.values().length); } - @Override public void onOrdinal(int docId, int ordinal) { + @Override + public void onOrdinal(int docId, int ordinal) { counts[ordinal]++; total++; } @@ -254,7 +258,8 @@ public class TermsIntOrdinalsFacetCollector extends AbstractFacetCollector { initialize(size); } - @Override protected boolean lessThan(ReaderAggregator a, ReaderAggregator b) { + @Override + protected boolean lessThan(ReaderAggregator a, ReaderAggregator b) { return a.current < b.current; } } diff --git a/src/main/java/org/elasticsearch/search/facet/terms/ip/InternalIpTermsFacet.java b/src/main/java/org/elasticsearch/search/facet/terms/ip/InternalIpTermsFacet.java index 2d94cf67ba1..009bcf8b26e 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/ip/InternalIpTermsFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/ip/InternalIpTermsFacet.java @@ -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.search.facet.terms.ip; +import com.google.common.collect.ImmutableList; +import gnu.trove.iterator.TLongIntIterator; +import gnu.trove.map.hash.TLongIntHashMap; import org.elasticsearch.common.CacheRecycler; import org.elasticsearch.common.collect.BoundedTreeSet; -import org.elasticsearch.common.collect.ImmutableList; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.trove.iterator.TLongIntIterator; -import org.elasticsearch.common.trove.map.hash.TLongIntHashMap; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilderString; import org.elasticsearch.index.mapper.ip.IpFieldMapper; @@ -40,7 +40,7 @@ import java.util.Iterator; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class InternalIpTermsFacet extends InternalTermsFacet { @@ -51,12 +51,14 @@ public class InternalIpTermsFacet extends InternalTermsFacet { } static Stream STREAM = new Stream() { - @Override public Facet readFacet(String type, StreamInput in) throws IOException { + @Override + public Facet readFacet(String type, StreamInput in) throws IOException { return readTermsFacet(in); } }; - @Override public String streamType() { + @Override + public String streamType() { return STREAM_TYPE; } @@ -78,11 +80,13 @@ public class InternalIpTermsFacet extends InternalTermsFacet { return term(); } - @Override public Number termAsNumber() { + @Override + public Number termAsNumber() { return term; } - @Override public Number getTermAsNumber() { + @Override + public Number getTermAsNumber() { return termAsNumber(); } @@ -94,7 +98,8 @@ public class InternalIpTermsFacet extends InternalTermsFacet { return count(); } - @Override public int compareTo(Entry o) { + @Override + public int compareTo(Entry o) { long anotherVal = ((LongEntry) o).term; if (term < anotherVal) { return -1; @@ -133,55 +138,68 @@ public class InternalIpTermsFacet extends InternalTermsFacet { this.total = total; } - @Override public String name() { + @Override + public String name() { return this.name; } - @Override public String getName() { + @Override + public String getName() { return this.name; } - @Override public String type() { + @Override + public String type() { return TYPE; } - @Override public String getType() { + @Override + public String getType() { return type(); } - @Override public List entries() { + @Override + public List entries() { if (!(entries instanceof List)) { entries = ImmutableList.copyOf(entries); } return (List) entries; } - @Override public List getEntries() { + @Override + public List getEntries() { return entries(); } - @SuppressWarnings({"unchecked"}) @Override public Iterator iterator() { + @SuppressWarnings({"unchecked"}) + @Override + public Iterator iterator() { return (Iterator) entries.iterator(); } - @Override public long missingCount() { + @Override + public long missingCount() { return this.missing; } - @Override public long getMissingCount() { + @Override + public long getMissingCount() { return missingCount(); } - @Override public long totalCount() { + @Override + public long totalCount() { return this.total; } - @Override public long getTotalCount() { + @Override + public long getTotalCount() { return totalCount(); } - @Override public long otherCount() { + @Override + public long otherCount() { long other = total; for (Entry entry : entries) { other -= entry.count(); @@ -189,11 +207,13 @@ public class InternalIpTermsFacet extends InternalTermsFacet { return other; } - @Override public long getOtherCount() { + @Override + public long getOtherCount() { return otherCount(); } - @Override public Facet reduce(String name, List facets) { + @Override + public Facet reduce(String name, List facets) { if (facets.size() == 1) { return facets.get(0); } @@ -234,7 +254,8 @@ public class InternalIpTermsFacet extends InternalTermsFacet { static final XContentBuilderString COUNT = new XContentBuilderString("count"); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(name); builder.field(Fields._TYPE, TermsFacet.TYPE); builder.field(Fields.MISSING, missing); @@ -258,7 +279,8 @@ public class InternalIpTermsFacet extends InternalTermsFacet { return facet; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { name = in.readUTF(); comparatorType = ComparatorType.fromId(in.readByte()); requiredSize = in.readVInt(); @@ -272,7 +294,8 @@ public class InternalIpTermsFacet extends InternalTermsFacet { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(name); out.writeByte(comparatorType.id()); out.writeVInt(requiredSize); diff --git a/src/main/java/org/elasticsearch/search/facet/terms/ip/TermsIpFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/terms/ip/TermsIpFacetCollector.java index 4485b38e10c..4e790029620 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/ip/TermsIpFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/ip/TermsIpFacetCollector.java @@ -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,14 +19,14 @@ package org.elasticsearch.search.facet.terms.ip; +import com.google.common.collect.ImmutableList; +import gnu.trove.iterator.TLongIntIterator; +import gnu.trove.map.hash.TLongIntHashMap; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.Scorer; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.CacheRecycler; import org.elasticsearch.common.collect.BoundedTreeSet; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.trove.iterator.TLongIntIterator; -import org.elasticsearch.common.trove.map.hash.TLongIntHashMap; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.longs.LongFieldData; @@ -44,7 +44,7 @@ import java.util.Arrays; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class TermsIpFacetCollector extends AbstractFacetCollector { @@ -114,24 +114,28 @@ public class TermsIpFacetCollector extends AbstractFacetCollector { } } - @Override public void setScorer(Scorer scorer) throws IOException { + @Override + public void setScorer(Scorer scorer) throws IOException { if (script != null) { script.setScorer(scorer); } } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { fieldData = (LongFieldData) fieldDataCache.cache(fieldDataType, reader, indexFieldName); if (script != null) { script.setNextReader(reader); } } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { fieldData.forEachValueInDoc(doc, aggregator); } - @Override public Facet facet() { + @Override + public Facet facet() { TLongIntHashMap facets = aggregator.facets(); if (facets.isEmpty()) { CacheRecycler.pushLongIntMap(facets); @@ -170,7 +174,8 @@ public class TermsIpFacetCollector extends AbstractFacetCollector { this.script = script; } - @Override public void onValue(int docId, long value) { + @Override + public void onValue(int docId, long value) { if (script != null) { script.setNextDocId(docId); script.setNextVar("term", value); @@ -201,16 +206,19 @@ public class TermsIpFacetCollector extends AbstractFacetCollector { this.facets = facets; } - @Override public void onValue(long value) { + @Override + public void onValue(long value) { facets.putIfAbsent(value, 0); } - @Override public void onValue(int docId, long value) { + @Override + public void onValue(int docId, long value) { facets.adjustOrPutValue(value, 1, 1); total++; } - @Override public void onMissing(int docId) { + @Override + public void onMissing(int docId) { missing++; } diff --git a/src/main/java/org/elasticsearch/search/facet/terms/ip/TermsIpOrdinalsFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/terms/ip/TermsIpOrdinalsFacetCollector.java index 62bad935a6b..8b22d6742b1 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/ip/TermsIpOrdinalsFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/ip/TermsIpOrdinalsFacetCollector.java @@ -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.search.facet.terms.ip; +import com.google.common.collect.ImmutableSet; +import gnu.trove.set.hash.TLongHashSet; import org.apache.lucene.index.IndexReader; import org.apache.lucene.util.PriorityQueue; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.CacheRecycler; import org.elasticsearch.common.collect.BoundedTreeSet; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.trove.set.hash.TLongHashSet; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldData; import org.elasticsearch.index.field.data.FieldDataType; @@ -43,7 +43,7 @@ import java.util.Arrays; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class TermsIpOrdinalsFacetCollector extends AbstractFacetCollector { @@ -115,7 +115,8 @@ public class TermsIpOrdinalsFacetCollector extends AbstractFacetCollector { this.aggregators = new ArrayList(context.searcher().subReaders().length); } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { if (current != null) { missing += current.counts[0]; total += current.total - current.counts[0]; @@ -127,11 +128,13 @@ public class TermsIpOrdinalsFacetCollector extends AbstractFacetCollector { current = new ReaderAggregator(fieldData); } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { fieldData.forEachOrdinalInDoc(doc, current); } - @Override public Facet facet() { + @Override + public Facet facet() { if (current != null) { missing += current.counts[0]; total += current.total - current.counts[0]; @@ -234,7 +237,8 @@ public class TermsIpOrdinalsFacetCollector extends AbstractFacetCollector { this.counts = CacheRecycler.popIntArray(fieldData.values().length); } - @Override public void onOrdinal(int docId, int ordinal) { + @Override + public void onOrdinal(int docId, int ordinal) { counts[ordinal]++; total++; } @@ -254,7 +258,8 @@ public class TermsIpOrdinalsFacetCollector extends AbstractFacetCollector { initialize(size); } - @Override protected boolean lessThan(ReaderAggregator a, ReaderAggregator b) { + @Override + protected boolean lessThan(ReaderAggregator a, ReaderAggregator b) { return a.current < b.current; } } diff --git a/src/main/java/org/elasticsearch/search/facet/terms/longs/InternalLongTermsFacet.java b/src/main/java/org/elasticsearch/search/facet/terms/longs/InternalLongTermsFacet.java index 5b87f731aa5..2a910ce53a1 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/longs/InternalLongTermsFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/longs/InternalLongTermsFacet.java @@ -19,13 +19,13 @@ package org.elasticsearch.search.facet.terms.longs; +import com.google.common.collect.ImmutableList; +import gnu.trove.iterator.TLongIntIterator; +import gnu.trove.map.hash.TLongIntHashMap; import org.elasticsearch.common.CacheRecycler; import org.elasticsearch.common.collect.BoundedTreeSet; -import org.elasticsearch.common.collect.ImmutableList; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.trove.iterator.TLongIntIterator; -import org.elasticsearch.common.trove.map.hash.TLongIntHashMap; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilderString; import org.elasticsearch.search.facet.Facet; @@ -39,7 +39,7 @@ import java.util.Iterator; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class InternalLongTermsFacet extends InternalTermsFacet { @@ -50,12 +50,14 @@ public class InternalLongTermsFacet extends InternalTermsFacet { } static Stream STREAM = new Stream() { - @Override public Facet readFacet(String type, StreamInput in) throws IOException { + @Override + public Facet readFacet(String type, StreamInput in) throws IOException { return readTermsFacet(in); } }; - @Override public String streamType() { + @Override + public String streamType() { return STREAM_TYPE; } @@ -77,11 +79,13 @@ public class InternalLongTermsFacet extends InternalTermsFacet { return term(); } - @Override public Number termAsNumber() { + @Override + public Number termAsNumber() { return term; } - @Override public Number getTermAsNumber() { + @Override + public Number getTermAsNumber() { return termAsNumber(); } @@ -93,7 +97,8 @@ public class InternalLongTermsFacet extends InternalTermsFacet { return count(); } - @Override public int compareTo(Entry o) { + @Override + public int compareTo(Entry o) { long anotherVal = ((LongEntry) o).term; if (term < anotherVal) { return -1; @@ -132,54 +137,67 @@ public class InternalLongTermsFacet extends InternalTermsFacet { this.total = total; } - @Override public String name() { + @Override + public String name() { return this.name; } - @Override public String getName() { + @Override + public String getName() { return this.name; } - @Override public String type() { + @Override + public String type() { return TYPE; } - @Override public String getType() { + @Override + public String getType() { return type(); } - @Override public List entries() { + @Override + public List entries() { if (!(entries instanceof List)) { entries = ImmutableList.copyOf(entries); } return (List) entries; } - @Override public List getEntries() { + @Override + public List getEntries() { return entries(); } - @SuppressWarnings({"unchecked"}) @Override public Iterator iterator() { + @SuppressWarnings({"unchecked"}) + @Override + public Iterator iterator() { return (Iterator) entries.iterator(); } - @Override public long missingCount() { + @Override + public long missingCount() { return this.missing; } - @Override public long getMissingCount() { + @Override + public long getMissingCount() { return missingCount(); } - @Override public long totalCount() { + @Override + public long totalCount() { return this.total; } - @Override public long getTotalCount() { + @Override + public long getTotalCount() { return totalCount(); } - @Override public long otherCount() { + @Override + public long otherCount() { long other = total; for (Entry entry : entries) { other -= entry.count(); @@ -187,11 +205,13 @@ public class InternalLongTermsFacet extends InternalTermsFacet { return other; } - @Override public long getOtherCount() { + @Override + public long getOtherCount() { return otherCount(); } - @Override public Facet reduce(String name, List facets) { + @Override + public Facet reduce(String name, List facets) { if (facets.size() == 1) { return facets.get(0); } @@ -232,7 +252,8 @@ public class InternalLongTermsFacet extends InternalTermsFacet { static final XContentBuilderString COUNT = new XContentBuilderString("count"); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(name); builder.field(Fields._TYPE, TermsFacet.TYPE); builder.field(Fields.MISSING, missing); @@ -256,7 +277,8 @@ public class InternalLongTermsFacet extends InternalTermsFacet { return facet; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { name = in.readUTF(); comparatorType = ComparatorType.fromId(in.readByte()); requiredSize = in.readVInt(); @@ -270,7 +292,8 @@ public class InternalLongTermsFacet extends InternalTermsFacet { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(name); out.writeByte(comparatorType.id()); out.writeVInt(requiredSize); diff --git a/src/main/java/org/elasticsearch/search/facet/terms/longs/TermsLongFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/terms/longs/TermsLongFacetCollector.java index 034285d64ed..edeef683725 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/longs/TermsLongFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/longs/TermsLongFacetCollector.java @@ -19,17 +19,17 @@ package org.elasticsearch.search.facet.terms.longs; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import gnu.trove.iterator.TLongIntIterator; +import gnu.trove.map.hash.TLongIntHashMap; +import gnu.trove.set.hash.TLongHashSet; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.Scorer; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.CacheRecycler; import org.elasticsearch.common.collect.BoundedTreeSet; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.ImmutableSet; import org.elasticsearch.common.thread.ThreadLocals; -import org.elasticsearch.common.trove.iterator.TLongIntIterator; -import org.elasticsearch.common.trove.map.hash.TLongIntHashMap; -import org.elasticsearch.common.trove.set.hash.TLongHashSet; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.longs.LongFieldData; @@ -43,19 +43,16 @@ import org.elasticsearch.search.facet.terms.support.EntryPriorityQueue; import org.elasticsearch.search.internal.SearchContext; import java.io.IOException; -import java.util.ArrayDeque; -import java.util.Arrays; -import java.util.Deque; -import java.util.Map; -import java.util.Set; +import java.util.*; /** - * @author kimchy (shay.banon) + * */ public class TermsLongFacetCollector extends AbstractFacetCollector { static ThreadLocal>> cache = new ThreadLocal>>() { - @Override protected ThreadLocals.CleanableValue> initialValue() { + @Override + protected ThreadLocals.CleanableValue> initialValue() { return new ThreadLocals.CleanableValue>(new ArrayDeque()); } }; @@ -127,24 +124,28 @@ public class TermsLongFacetCollector extends AbstractFacetCollector { } } - @Override public void setScorer(Scorer scorer) throws IOException { + @Override + public void setScorer(Scorer scorer) throws IOException { if (script != null) { script.setScorer(scorer); } } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { fieldData = (LongFieldData) fieldDataCache.cache(fieldDataType, reader, indexFieldName); if (script != null) { script.setNextReader(reader); } } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { fieldData.forEachValueInDoc(doc, aggregator); } - @Override public Facet facet() { + @Override + public Facet facet() { TLongIntHashMap facets = aggregator.facets(); if (facets.isEmpty()) { CacheRecycler.pushLongIntMap(facets); @@ -193,7 +194,8 @@ public class TermsLongFacetCollector extends AbstractFacetCollector { } } - @Override public void onValue(int docId, long value) { + @Override + public void onValue(int docId, long value) { if (excluded != null && excluded.contains(value)) { return; } @@ -227,16 +229,19 @@ public class TermsLongFacetCollector extends AbstractFacetCollector { this.facets = facets; } - @Override public void onValue(long value) { + @Override + public void onValue(long value) { facets.putIfAbsent(value, 0); } - @Override public void onValue(int docId, long value) { + @Override + public void onValue(int docId, long value) { facets.adjustOrPutValue(value, 1, 1); total++; } - @Override public void onMissing(int docId) { + @Override + public void onMissing(int docId) { missing++; } diff --git a/src/main/java/org/elasticsearch/search/facet/terms/longs/TermsLongOrdinalsFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/terms/longs/TermsLongOrdinalsFacetCollector.java index 2eb47a1e1e4..4e93666d7e4 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/longs/TermsLongOrdinalsFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/longs/TermsLongOrdinalsFacetCollector.java @@ -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.search.facet.terms.longs; +import com.google.common.collect.ImmutableSet; +import gnu.trove.set.hash.TLongHashSet; import org.apache.lucene.index.IndexReader; import org.apache.lucene.util.PriorityQueue; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.CacheRecycler; import org.elasticsearch.common.collect.BoundedTreeSet; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.trove.set.hash.TLongHashSet; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldData; import org.elasticsearch.index.field.data.FieldDataType; @@ -43,7 +43,7 @@ import java.util.Arrays; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class TermsLongOrdinalsFacetCollector extends AbstractFacetCollector { @@ -115,7 +115,8 @@ public class TermsLongOrdinalsFacetCollector extends AbstractFacetCollector { this.aggregators = new ArrayList(context.searcher().subReaders().length); } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { if (current != null) { missing += current.counts[0]; total += current.total - current.counts[0]; @@ -127,11 +128,13 @@ public class TermsLongOrdinalsFacetCollector extends AbstractFacetCollector { current = new ReaderAggregator(fieldData); } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { fieldData.forEachOrdinalInDoc(doc, current); } - @Override public Facet facet() { + @Override + public Facet facet() { if (current != null) { missing += current.counts[0]; total += current.total - current.counts[0]; @@ -234,7 +237,8 @@ public class TermsLongOrdinalsFacetCollector extends AbstractFacetCollector { this.counts = CacheRecycler.popIntArray(fieldData.values().length); } - @Override public void onOrdinal(int docId, int ordinal) { + @Override + public void onOrdinal(int docId, int ordinal) { counts[ordinal]++; total++; } @@ -254,7 +258,8 @@ public class TermsLongOrdinalsFacetCollector extends AbstractFacetCollector { initialize(size); } - @Override protected boolean lessThan(ReaderAggregator a, ReaderAggregator b) { + @Override + protected boolean lessThan(ReaderAggregator a, ReaderAggregator b) { return a.current < b.current; } } diff --git a/src/main/java/org/elasticsearch/search/facet/terms/shorts/InternalShortTermsFacet.java b/src/main/java/org/elasticsearch/search/facet/terms/shorts/InternalShortTermsFacet.java index 94c35dd08c0..c6e71503e9e 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/shorts/InternalShortTermsFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/shorts/InternalShortTermsFacet.java @@ -19,13 +19,13 @@ package org.elasticsearch.search.facet.terms.shorts; +import com.google.common.collect.ImmutableList; +import gnu.trove.iterator.TShortIntIterator; +import gnu.trove.map.hash.TShortIntHashMap; import org.elasticsearch.common.CacheRecycler; import org.elasticsearch.common.collect.BoundedTreeSet; -import org.elasticsearch.common.collect.ImmutableList; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.trove.iterator.TShortIntIterator; -import org.elasticsearch.common.trove.map.hash.TShortIntHashMap; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilderString; import org.elasticsearch.search.facet.Facet; @@ -39,7 +39,7 @@ import java.util.Iterator; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class InternalShortTermsFacet extends InternalTermsFacet { @@ -50,12 +50,14 @@ public class InternalShortTermsFacet extends InternalTermsFacet { } static Stream STREAM = new Stream() { - @Override public Facet readFacet(String type, StreamInput in) throws IOException { + @Override + public Facet readFacet(String type, StreamInput in) throws IOException { return readTermsFacet(in); } }; - @Override public String streamType() { + @Override + public String streamType() { return STREAM_TYPE; } @@ -77,11 +79,13 @@ public class InternalShortTermsFacet extends InternalTermsFacet { return term(); } - @Override public Number termAsNumber() { + @Override + public Number termAsNumber() { return term; } - @Override public Number getTermAsNumber() { + @Override + public Number getTermAsNumber() { return termAsNumber(); } @@ -93,7 +97,8 @@ public class InternalShortTermsFacet extends InternalTermsFacet { return count(); } - @Override public int compareTo(Entry o) { + @Override + public int compareTo(Entry o) { short anotherVal = ((ShortEntry) o).term; int i = term - anotherVal; if (i == 0) { @@ -129,54 +134,67 @@ public class InternalShortTermsFacet extends InternalTermsFacet { this.total = total; } - @Override public String name() { + @Override + public String name() { return this.name; } - @Override public String getName() { + @Override + public String getName() { return this.name; } - @Override public String type() { + @Override + public String type() { return TYPE; } - @Override public String getType() { + @Override + public String getType() { return type(); } - @Override public List entries() { + @Override + public List entries() { if (!(entries instanceof List)) { entries = ImmutableList.copyOf(entries); } return (List) entries; } - @Override public List getEntries() { + @Override + public List getEntries() { return entries(); } - @SuppressWarnings({"unchecked"}) @Override public Iterator iterator() { + @SuppressWarnings({"unchecked"}) + @Override + public Iterator iterator() { return (Iterator) entries.iterator(); } - @Override public long missingCount() { + @Override + public long missingCount() { return this.missing; } - @Override public long getMissingCount() { + @Override + public long getMissingCount() { return missingCount(); } - @Override public long totalCount() { + @Override + public long totalCount() { return this.total; } - @Override public long getTotalCount() { + @Override + public long getTotalCount() { return totalCount(); } - @Override public long otherCount() { + @Override + public long otherCount() { long other = total; for (Entry entry : entries) { other -= entry.count(); @@ -184,11 +202,13 @@ public class InternalShortTermsFacet extends InternalTermsFacet { return other; } - @Override public long getOtherCount() { + @Override + public long getOtherCount() { return otherCount(); } - @Override public Facet reduce(String name, List facets) { + @Override + public Facet reduce(String name, List facets) { if (facets.size() == 1) { return facets.get(0); } @@ -229,7 +249,8 @@ public class InternalShortTermsFacet extends InternalTermsFacet { static final XContentBuilderString COUNT = new XContentBuilderString("count"); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(name); builder.field(Fields._TYPE, TermsFacet.TYPE); builder.field(Fields.MISSING, missing); @@ -253,7 +274,8 @@ public class InternalShortTermsFacet extends InternalTermsFacet { return facet; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { name = in.readUTF(); comparatorType = ComparatorType.fromId(in.readByte()); requiredSize = in.readVInt(); @@ -267,7 +289,8 @@ public class InternalShortTermsFacet extends InternalTermsFacet { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(name); out.writeByte(comparatorType.id()); out.writeVInt(requiredSize); diff --git a/src/main/java/org/elasticsearch/search/facet/terms/shorts/TermsShortFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/terms/shorts/TermsShortFacetCollector.java index 6a9eea648b5..a94eccc6eaa 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/shorts/TermsShortFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/shorts/TermsShortFacetCollector.java @@ -19,16 +19,16 @@ package org.elasticsearch.search.facet.terms.shorts; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import gnu.trove.iterator.TShortIntIterator; +import gnu.trove.map.hash.TShortIntHashMap; +import gnu.trove.set.hash.TShortHashSet; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.Scorer; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.CacheRecycler; import org.elasticsearch.common.collect.BoundedTreeSet; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.trove.iterator.TShortIntIterator; -import org.elasticsearch.common.trove.map.hash.TShortIntHashMap; -import org.elasticsearch.common.trove.set.hash.TShortHashSet; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.shorts.ShortFieldData; @@ -47,7 +47,7 @@ import java.util.Map; import java.util.Set; /** - * @author kimchy (shay.banon) + * */ public class TermsShortFacetCollector extends AbstractFacetCollector { @@ -117,24 +117,28 @@ public class TermsShortFacetCollector extends AbstractFacetCollector { } } - @Override public void setScorer(Scorer scorer) throws IOException { + @Override + public void setScorer(Scorer scorer) throws IOException { if (script != null) { script.setScorer(scorer); } } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { fieldData = (ShortFieldData) fieldDataCache.cache(fieldDataType, reader, indexFieldName); if (script != null) { script.setNextReader(reader); } } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { fieldData.forEachValueInDoc(doc, aggregator); } - @Override public Facet facet() { + @Override + public Facet facet() { TShortIntHashMap facets = aggregator.facets(); if (facets.isEmpty()) { CacheRecycler.pushShortIntMap(facets); @@ -183,7 +187,8 @@ public class TermsShortFacetCollector extends AbstractFacetCollector { this.script = script; } - @Override public void onValue(int docId, short value) { + @Override + public void onValue(int docId, short value) { if (excluded != null && excluded.contains(value)) { return; } @@ -218,16 +223,19 @@ public class TermsShortFacetCollector extends AbstractFacetCollector { this.facets = facets; } - @Override public void onValue(short value) { + @Override + public void onValue(short value) { facets.putIfAbsent(value, 0); } - @Override public void onValue(int docId, short value) { + @Override + public void onValue(int docId, short value) { facets.adjustOrPutValue(value, 1, 1); total++; } - @Override public void onMissing(int docId) { + @Override + public void onMissing(int docId) { missing++; } diff --git a/src/main/java/org/elasticsearch/search/facet/terms/shorts/TermsShortOrdinalsFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/terms/shorts/TermsShortOrdinalsFacetCollector.java index 1f185fdba8d..a3ded3a8b0d 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/shorts/TermsShortOrdinalsFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/shorts/TermsShortOrdinalsFacetCollector.java @@ -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.search.facet.terms.shorts; +import com.google.common.collect.ImmutableSet; +import gnu.trove.set.hash.TShortHashSet; import org.apache.lucene.index.IndexReader; import org.apache.lucene.util.PriorityQueue; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.CacheRecycler; import org.elasticsearch.common.collect.BoundedTreeSet; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.trove.set.hash.TShortHashSet; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldData; import org.elasticsearch.index.field.data.FieldDataType; @@ -43,7 +43,7 @@ import java.util.Arrays; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class TermsShortOrdinalsFacetCollector extends AbstractFacetCollector { @@ -115,7 +115,8 @@ public class TermsShortOrdinalsFacetCollector extends AbstractFacetCollector { this.aggregators = new ArrayList(context.searcher().subReaders().length); } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { if (current != null) { missing += current.counts[0]; total += current.total - current.counts[0]; @@ -127,11 +128,13 @@ public class TermsShortOrdinalsFacetCollector extends AbstractFacetCollector { current = new ReaderAggregator(fieldData); } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { fieldData.forEachOrdinalInDoc(doc, current); } - @Override public Facet facet() { + @Override + public Facet facet() { if (current != null) { missing += current.counts[0]; total += current.total - current.counts[0]; @@ -234,7 +237,8 @@ public class TermsShortOrdinalsFacetCollector extends AbstractFacetCollector { this.counts = CacheRecycler.popIntArray(fieldData.values().length); } - @Override public void onOrdinal(int docId, int ordinal) { + @Override + public void onOrdinal(int docId, int ordinal) { counts[ordinal]++; total++; } @@ -254,7 +258,8 @@ public class TermsShortOrdinalsFacetCollector extends AbstractFacetCollector { initialize(size); } - @Override protected boolean lessThan(ReaderAggregator a, ReaderAggregator b) { + @Override + protected boolean lessThan(ReaderAggregator a, ReaderAggregator b) { return a.current < b.current; } } diff --git a/src/main/java/org/elasticsearch/search/facet/terms/strings/FieldsTermsStringFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/terms/strings/FieldsTermsStringFacetCollector.java index c4f41286ed5..47e140a2644 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/strings/FieldsTermsStringFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/strings/FieldsTermsStringFacetCollector.java @@ -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,14 +19,14 @@ package org.elasticsearch.search.facet.terms.strings; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import gnu.trove.iterator.TObjectIntIterator; +import gnu.trove.map.hash.TObjectIntHashMap; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.Scorer; import org.elasticsearch.common.CacheRecycler; import org.elasticsearch.common.collect.BoundedTreeSet; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.trove.iterator.TObjectIntIterator; -import org.elasticsearch.common.trove.map.hash.TObjectIntHashMap; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldData; import org.elasticsearch.index.field.data.FieldDataType; @@ -45,7 +45,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; /** - * @author kimchy (shay.banon) + * */ public class FieldsTermsStringFacetCollector extends AbstractFacetCollector { @@ -117,13 +117,15 @@ public class FieldsTermsStringFacetCollector extends AbstractFacetCollector { } } - @Override public void setScorer(Scorer scorer) throws IOException { + @Override + public void setScorer(Scorer scorer) throws IOException { if (script != null) { script.setScorer(scorer); } } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { for (int i = 0; i < indexFieldsNames.length; i++) { fieldsData[i] = fieldDataCache.cache(fieldsDataType[i], reader, indexFieldsNames[i]); } @@ -132,13 +134,15 @@ public class FieldsTermsStringFacetCollector extends AbstractFacetCollector { } } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { for (FieldData fieldData : fieldsData) { fieldData.forEachValueInDoc(doc, aggregator); } } - @Override public Facet facet() { + @Override + public Facet facet() { TObjectIntHashMap facets = aggregator.facets(); if (facets.isEmpty()) { CacheRecycler.pushObjectIntMap(facets); @@ -183,7 +187,8 @@ public class FieldsTermsStringFacetCollector extends AbstractFacetCollector { this.script = script; } - @Override public void onValue(int docId, String value) { + @Override + public void onValue(int docId, String value) { if (excluded != null && excluded.contains(value)) { return; } @@ -220,16 +225,19 @@ public class FieldsTermsStringFacetCollector extends AbstractFacetCollector { this.facets = facets; } - @Override public void onValue(String value) { + @Override + public void onValue(String value) { facets.putIfAbsent(value, 0); } - @Override public void onValue(int docId, String value) { + @Override + public void onValue(int docId, String value) { facets.adjustOrPutValue(value, 1, 1); total++; } - @Override public void onMissing(int docId) { + @Override + public void onMissing(int docId) { missing++; } diff --git a/src/main/java/org/elasticsearch/search/facet/terms/strings/InternalStringTermsFacet.java b/src/main/java/org/elasticsearch/search/facet/terms/strings/InternalStringTermsFacet.java index 8199d00c2db..f8d168e35f5 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/strings/InternalStringTermsFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/strings/InternalStringTermsFacet.java @@ -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.search.facet.terms.strings; +import com.google.common.collect.ImmutableList; +import gnu.trove.iterator.TObjectIntIterator; +import gnu.trove.map.hash.TObjectIntHashMap; import org.elasticsearch.common.CacheRecycler; import org.elasticsearch.common.collect.BoundedTreeSet; -import org.elasticsearch.common.collect.ImmutableList; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.trove.iterator.TObjectIntIterator; -import org.elasticsearch.common.trove.map.hash.TObjectIntHashMap; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilderString; import org.elasticsearch.search.facet.Facet; @@ -39,7 +39,7 @@ import java.util.Iterator; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class InternalStringTermsFacet extends InternalTermsFacet { @@ -50,12 +50,14 @@ public class InternalStringTermsFacet extends InternalTermsFacet { } static Stream STREAM = new Stream() { - @Override public Facet readFacet(String type, StreamInput in) throws IOException { + @Override + public Facet readFacet(String type, StreamInput in) throws IOException { return readTermsFacet(in); } }; - @Override public String streamType() { + @Override + public String streamType() { return STREAM_TYPE; } @@ -77,11 +79,13 @@ public class InternalStringTermsFacet extends InternalTermsFacet { return term; } - @Override public Number termAsNumber() { + @Override + public Number termAsNumber() { return Double.parseDouble(term); } - @Override public Number getTermAsNumber() { + @Override + public Number getTermAsNumber() { return termAsNumber(); } @@ -93,7 +97,8 @@ public class InternalStringTermsFacet extends InternalTermsFacet { return count(); } - @Override public int compareTo(Entry o) { + @Override + public int compareTo(Entry o) { int i = term.compareTo(o.term()); if (i == 0) { i = count - o.count(); @@ -129,54 +134,67 @@ public class InternalStringTermsFacet extends InternalTermsFacet { this.total = total; } - @Override public String name() { + @Override + public String name() { return this.name; } - @Override public String getName() { + @Override + public String getName() { return this.name; } - @Override public String type() { + @Override + public String type() { return TYPE; } - @Override public String getType() { + @Override + public String getType() { return type(); } - @Override public List entries() { + @Override + public List entries() { if (!(entries instanceof List)) { entries = ImmutableList.copyOf(entries); } return (List) entries; } - @Override public List getEntries() { + @Override + public List getEntries() { return entries(); } - @SuppressWarnings({"unchecked"}) @Override public Iterator iterator() { + @SuppressWarnings({"unchecked"}) + @Override + public Iterator iterator() { return (Iterator) entries.iterator(); } - @Override public long missingCount() { + @Override + public long missingCount() { return this.missing; } - @Override public long getMissingCount() { + @Override + public long getMissingCount() { return missingCount(); } - @Override public long totalCount() { + @Override + public long totalCount() { return this.total; } - @Override public long getTotalCount() { + @Override + public long getTotalCount() { return totalCount(); } - @Override public long otherCount() { + @Override + public long otherCount() { long other = total; for (Entry entry : entries) { other -= entry.count(); @@ -184,11 +202,13 @@ public class InternalStringTermsFacet extends InternalTermsFacet { return other; } - @Override public long getOtherCount() { + @Override + public long getOtherCount() { return otherCount(); } - @Override public Facet reduce(String name, List facets) { + @Override + public Facet reduce(String name, List facets) { if (facets.size() == 1) { return facets.get(0); } @@ -229,7 +249,8 @@ public class InternalStringTermsFacet extends InternalTermsFacet { static final XContentBuilderString COUNT = new XContentBuilderString("count"); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(name); builder.field(Fields._TYPE, TermsFacet.TYPE); builder.field(Fields.MISSING, missing); @@ -253,7 +274,8 @@ public class InternalStringTermsFacet extends InternalTermsFacet { return facet; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { name = in.readUTF(); comparatorType = ComparatorType.fromId(in.readByte()); requiredSize = in.readVInt(); @@ -267,7 +289,8 @@ public class InternalStringTermsFacet extends InternalTermsFacet { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(name); out.writeByte(comparatorType.id()); out.writeVInt(requiredSize); diff --git a/src/main/java/org/elasticsearch/search/facet/terms/strings/ScriptTermsStringFieldFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/terms/strings/ScriptTermsStringFieldFacetCollector.java index 6c943f41b74..eeca203135e 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/strings/ScriptTermsStringFieldFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/strings/ScriptTermsStringFieldFacetCollector.java @@ -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,14 +19,14 @@ package org.elasticsearch.search.facet.terms.strings; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import gnu.trove.iterator.TObjectIntIterator; +import gnu.trove.map.hash.TObjectIntHashMap; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.Scorer; import org.elasticsearch.common.CacheRecycler; import org.elasticsearch.common.collect.BoundedTreeSet; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.ImmutableSet; -import org.elasticsearch.common.trove.iterator.TObjectIntIterator; -import org.elasticsearch.common.trove.map.hash.TObjectIntHashMap; import org.elasticsearch.script.SearchScript; import org.elasticsearch.search.facet.AbstractFacetCollector; import org.elasticsearch.search.facet.Facet; @@ -40,7 +40,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; /** - * @author kimchy (shay.banon) + * */ public class ScriptTermsStringFieldFacetCollector extends AbstractFacetCollector { @@ -75,15 +75,18 @@ public class ScriptTermsStringFieldFacetCollector extends AbstractFacetCollector this.facets = CacheRecycler.popObjectIntMap(); } - @Override public void setScorer(Scorer scorer) throws IOException { + @Override + public void setScorer(Scorer scorer) throws IOException { script.setScorer(scorer); } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { script.setNextReader(reader); } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { script.setNextDocId(doc); Object o = script.run(); if (o == null) { @@ -137,7 +140,8 @@ public class ScriptTermsStringFieldFacetCollector extends AbstractFacetCollector return true; } - @Override public Facet facet() { + @Override + public Facet facet() { if (facets.isEmpty()) { CacheRecycler.pushObjectIntMap(facets); return new InternalStringTermsFacet(facetName, comparatorType, size, ImmutableList.of(), missing, total); diff --git a/src/main/java/org/elasticsearch/search/facet/terms/strings/TermsStringFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/terms/strings/TermsStringFacetCollector.java index de8540054c3..681a68e43a9 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/strings/TermsStringFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/strings/TermsStringFacetCollector.java @@ -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,15 +19,15 @@ package org.elasticsearch.search.facet.terms.strings; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import gnu.trove.iterator.TObjectIntIterator; +import gnu.trove.map.hash.TObjectIntHashMap; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.Scorer; import org.elasticsearch.common.CacheRecycler; import org.elasticsearch.common.collect.BoundedTreeSet; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.ImmutableSet; import org.elasticsearch.common.thread.ThreadLocals; -import org.elasticsearch.common.trove.iterator.TObjectIntIterator; -import org.elasticsearch.common.trove.map.hash.TObjectIntHashMap; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldData; import org.elasticsearch.index.field.data.FieldDataType; @@ -49,12 +49,13 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; /** - * @author kimchy (shay.banon) + * */ public class TermsStringFacetCollector extends AbstractFacetCollector { static ThreadLocal>>> cache = new ThreadLocal>>>() { - @Override protected ThreadLocals.CleanableValue>> initialValue() { + @Override + protected ThreadLocals.CleanableValue>> initialValue() { return new ThreadLocals.CleanableValue>>(new ArrayDeque>()); } }; @@ -124,24 +125,28 @@ public class TermsStringFacetCollector extends AbstractFacetCollector { } } - @Override public void setScorer(Scorer scorer) throws IOException { + @Override + public void setScorer(Scorer scorer) throws IOException { if (script != null) { script.setScorer(scorer); } } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { fieldData = fieldDataCache.cache(fieldDataType, reader, indexFieldName); if (script != null) { script.setNextReader(reader); } } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { fieldData.forEachValueInDoc(doc, aggregator); } - @Override public Facet facet() { + @Override + public Facet facet() { TObjectIntHashMap facets = aggregator.facets(); if (facets.isEmpty()) { CacheRecycler.pushObjectIntMap(facets); @@ -186,7 +191,8 @@ public class TermsStringFacetCollector extends AbstractFacetCollector { this.script = script; } - @Override public void onValue(int docId, String value) { + @Override + public void onValue(int docId, String value) { if (excluded != null && excluded.contains(value)) { return; } @@ -223,16 +229,19 @@ public class TermsStringFacetCollector extends AbstractFacetCollector { this.facets = facets; } - @Override public void onValue(String value) { + @Override + public void onValue(String value) { facets.putIfAbsent(value, 0); } - @Override public void onValue(int docId, String value) { + @Override + public void onValue(int docId, String value) { facets.adjustOrPutValue(value, 1, 1); total++; } - @Override public void onMissing(int docId) { + @Override + public void onMissing(int docId) { missing++; } diff --git a/src/main/java/org/elasticsearch/search/facet/terms/strings/TermsStringOrdinalsFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/terms/strings/TermsStringOrdinalsFacetCollector.java index 66c23f9da28..41e0ffbd50b 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/strings/TermsStringOrdinalsFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/strings/TermsStringOrdinalsFacetCollector.java @@ -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.elasticsearch.search.facet.terms.strings; +import com.google.common.collect.ImmutableSet; import org.apache.lucene.index.IndexReader; import org.apache.lucene.util.PriorityQueue; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.CacheRecycler; import org.elasticsearch.common.collect.BoundedTreeSet; -import org.elasticsearch.common.collect.ImmutableSet; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldData; import org.elasticsearch.index.field.data.FieldDataType; @@ -44,7 +44,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; /** - * @author kimchy (shay.banon) + * */ public class TermsStringOrdinalsFacetCollector extends AbstractFacetCollector { @@ -116,7 +116,8 @@ public class TermsStringOrdinalsFacetCollector extends AbstractFacetCollector { this.aggregators = new ArrayList(context.searcher().subReaders().length); } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { if (current != null) { missing += current.counts[0]; total += current.total - current.counts[0]; @@ -128,11 +129,13 @@ public class TermsStringOrdinalsFacetCollector extends AbstractFacetCollector { current = new ReaderAggregator(fieldData); } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { fieldData.forEachOrdinalInDoc(doc, current); } - @Override public Facet facet() { + @Override + public Facet facet() { if (current != null) { missing += current.counts[0]; total += current.total - current.counts[0]; @@ -244,7 +247,8 @@ public class TermsStringOrdinalsFacetCollector extends AbstractFacetCollector { this.counts = CacheRecycler.popIntArray(fieldData.values().length); } - @Override public void onOrdinal(int docId, int ordinal) { + @Override + public void onOrdinal(int docId, int ordinal) { counts[ordinal]++; total++; } @@ -264,7 +268,8 @@ public class TermsStringOrdinalsFacetCollector extends AbstractFacetCollector { initialize(size); } - @Override protected boolean lessThan(ReaderAggregator a, ReaderAggregator b) { + @Override + protected boolean lessThan(ReaderAggregator a, ReaderAggregator b) { return a.current.compareTo(b.current) < 0; } } diff --git a/src/main/java/org/elasticsearch/search/facet/terms/support/EntryPriorityQueue.java b/src/main/java/org/elasticsearch/search/facet/terms/support/EntryPriorityQueue.java index fd94c34fe2a..65295118896 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/support/EntryPriorityQueue.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/support/EntryPriorityQueue.java @@ -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,8 @@ public class EntryPriorityQueue extends PriorityQueue { this.comparator = comparator; } - @Override protected boolean lessThan(TermsFacet.Entry a, TermsFacet.Entry b) { + @Override + protected boolean lessThan(TermsFacet.Entry a, TermsFacet.Entry b) { return comparator.compare(a, b) > 0; // reverse, since we reverse again when adding to a list } } diff --git a/src/main/java/org/elasticsearch/search/facet/termsstats/InternalTermsStatsFacet.java b/src/main/java/org/elasticsearch/search/facet/termsstats/InternalTermsStatsFacet.java index 7f0d739bfe1..bab83d0c136 100644 --- a/src/main/java/org/elasticsearch/search/facet/termsstats/InternalTermsStatsFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/termsstats/InternalTermsStatsFacet.java @@ -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 diff --git a/src/main/java/org/elasticsearch/search/facet/termsstats/TermsStatsFacet.java b/src/main/java/org/elasticsearch/search/facet/termsstats/TermsStatsFacet.java index ef269a04ec5..ad171c5d6d1 100644 --- a/src/main/java/org/elasticsearch/search/facet/termsstats/TermsStatsFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/termsstats/TermsStatsFacet.java @@ -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 @@ -59,7 +59,8 @@ public interface TermsStatsFacet extends Facet, Iterable */ COUNT((byte) 0, new Comparator() { - @Override public int compare(Entry o1, Entry o2) { + @Override + public int compare(Entry o1, Entry o2) { // push nulls to the end if (o1 == null) { return 1; @@ -82,7 +83,8 @@ public interface TermsStatsFacet extends Facet, Iterable */ REVERSE_COUNT((byte) 1, new Comparator() { - @Override public int compare(Entry o1, Entry o2) { + @Override + public int compare(Entry o1, Entry o2) { // push nulls to the end if (o1 == null) { return 1; @@ -98,7 +100,8 @@ public interface TermsStatsFacet extends Facet, Iterable */ TERM((byte) 2, new Comparator() { - @Override public int compare(Entry o1, Entry o2) { + @Override + public int compare(Entry o1, Entry o2) { // push nulls to the end if (o1 == null) { return 1; @@ -118,7 +121,8 @@ public interface TermsStatsFacet extends Facet, Iterable */ REVERSE_TERM((byte) 3, new Comparator() { - @Override public int compare(Entry o1, Entry o2) { + @Override + public int compare(Entry o1, Entry o2) { // push nulls to the end if (o1 == null) { return 1; @@ -131,7 +135,8 @@ public interface TermsStatsFacet extends Facet, Iterable }), TOTAL((byte) 4, new Comparator() { - @Override public int compare(Entry o1, Entry o2) { + @Override + public int compare(Entry o1, Entry o2) { // push nulls to the end if (o1 == null) { return 1; @@ -150,7 +155,8 @@ public interface TermsStatsFacet extends Facet, Iterable }), REVERSE_TOTAL((byte) 5, new Comparator() { - @Override public int compare(Entry o1, Entry o2) { + @Override + public int compare(Entry o1, Entry o2) { // push nulls to the end if (o1 == null) { return 1; @@ -163,7 +169,8 @@ public interface TermsStatsFacet extends Facet, Iterable }), MIN((byte) 6, new Comparator() { - @Override public int compare(Entry o1, Entry o2) { + @Override + public int compare(Entry o1, Entry o2) { // push nulls to the end if (o1 == null) { return 1; @@ -181,7 +188,8 @@ public interface TermsStatsFacet extends Facet, Iterable } }), REVERSE_MIN((byte) 7, new Comparator() { - @Override public int compare(Entry o1, Entry o2) { + @Override + public int compare(Entry o1, Entry o2) { // push nulls to the end if (o1 == null) { return 1; @@ -193,7 +201,8 @@ public interface TermsStatsFacet extends Facet, Iterable } }), MAX((byte) 8, new Comparator() { - @Override public int compare(Entry o1, Entry o2) { + @Override + public int compare(Entry o1, Entry o2) { // push nulls to the end if (o1 == null) { return 1; @@ -211,7 +220,8 @@ public interface TermsStatsFacet extends Facet, Iterable } }), REVERSE_MAX((byte) 9, new Comparator() { - @Override public int compare(Entry o1, Entry o2) { + @Override + public int compare(Entry o1, Entry o2) { // push nulls to the end if (o1 == null) { return 1; diff --git a/src/main/java/org/elasticsearch/search/facet/termsstats/TermsStatsFacetBuilder.java b/src/main/java/org/elasticsearch/search/facet/termsstats/TermsStatsFacetBuilder.java index 80880d8513f..18a9b187fa7 100644 --- a/src/main/java/org/elasticsearch/search/facet/termsstats/TermsStatsFacetBuilder.java +++ b/src/main/java/org/elasticsearch/search/facet/termsstats/TermsStatsFacetBuilder.java @@ -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,7 +19,7 @@ package org.elasticsearch.search.facet.termsstats; -import org.elasticsearch.common.collect.Maps; +import com.google.common.collect.Maps; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.search.builder.SearchSourceBuilderException; import org.elasticsearch.search.facet.AbstractFacetBuilder; @@ -113,7 +113,8 @@ public class TermsStatsFacetBuilder extends AbstractFacetBuilder { return this; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { if (keyField == null) { throw new SearchSourceBuilderException("key field must be set on terms facet for facet [" + name + "]"); } diff --git a/src/main/java/org/elasticsearch/search/facet/termsstats/TermsStatsFacetProcessor.java b/src/main/java/org/elasticsearch/search/facet/termsstats/TermsStatsFacetProcessor.java index 0809eb2ff15..9b9de255471 100644 --- a/src/main/java/org/elasticsearch/search/facet/termsstats/TermsStatsFacetProcessor.java +++ b/src/main/java/org/elasticsearch/search/facet/termsstats/TermsStatsFacetProcessor.java @@ -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 @@ -40,16 +40,19 @@ import java.util.Map; public class TermsStatsFacetProcessor extends AbstractComponent implements FacetProcessor { - @Inject public TermsStatsFacetProcessor(Settings settings) { + @Inject + public TermsStatsFacetProcessor(Settings settings) { super(settings); InternalTermsStatsFacet.registerStreams(); } - @Override public String[] types() { + @Override + public String[] types() { return new String[]{TermsStatsFacet.TYPE, "termsStats"}; } - @Override public FacetCollector parse(String facetName, XContentParser parser, SearchContext context) throws IOException { + @Override + public FacetCollector parse(String facetName, XContentParser parser, SearchContext context) throws IOException { String keyField = null; String valueField = null; int size = 10; @@ -119,7 +122,8 @@ public class TermsStatsFacetProcessor extends AbstractComponent implements Facet return new TermsStatsStringFacetCollector(facetName, keyField, valueField, size, comparatorType, context, scriptLang, script, params); } - @Override public Facet reduce(String name, List facets) { + @Override + public Facet reduce(String name, List facets) { InternalTermsStatsFacet first = (InternalTermsStatsFacet) facets.get(0); return first.reduce(name, facets); } diff --git a/src/main/java/org/elasticsearch/search/facet/termsstats/doubles/InternalTermsStatsDoubleFacet.java b/src/main/java/org/elasticsearch/search/facet/termsstats/doubles/InternalTermsStatsDoubleFacet.java index ec626773522..fe065ab224c 100644 --- a/src/main/java/org/elasticsearch/search/facet/termsstats/doubles/InternalTermsStatsDoubleFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/termsstats/doubles/InternalTermsStatsDoubleFacet.java @@ -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,24 +19,18 @@ package org.elasticsearch.search.facet.termsstats.doubles; +import com.google.common.collect.ImmutableList; +import gnu.trove.ExtTDoubleObjectHashMap; import org.elasticsearch.common.CacheRecycler; -import org.elasticsearch.common.collect.ImmutableList; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.trove.ExtTDoubleObjectHashMap; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilderString; import org.elasticsearch.search.facet.Facet; import org.elasticsearch.search.facet.termsstats.InternalTermsStatsFacet; import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; +import java.util.*; public class InternalTermsStatsDoubleFacet extends InternalTermsStatsFacet { @@ -47,12 +41,14 @@ public class InternalTermsStatsDoubleFacet extends InternalTermsStatsFacet { } static Stream STREAM = new Stream() { - @Override public Facet readFacet(String type, StreamInput in) throws IOException { + @Override + public Facet readFacet(String type, StreamInput in) throws IOException { return readTermsStatsFacet(in); } }; - @Override public String streamType() { + @Override + public String streamType() { return STREAM_TYPE; } @@ -77,74 +73,91 @@ public class InternalTermsStatsDoubleFacet extends InternalTermsStatsFacet { this.max = max; } - @Override public String term() { + @Override + public String term() { return Double.toString(term); } - @Override public String getTerm() { + @Override + public String getTerm() { return term(); } - @Override public Number termAsNumber() { + @Override + public Number termAsNumber() { return term; } - @Override public Number getTermAsNumber() { + @Override + public Number getTermAsNumber() { return termAsNumber(); } - @Override public long count() { + @Override + public long count() { return count; } - @Override public long getCount() { + @Override + public long getCount() { return count(); } - @Override public long totalCount() { + @Override + public long totalCount() { return this.totalCount; } - @Override public long getTotalCount() { + @Override + public long getTotalCount() { return this.totalCount; } - @Override public double min() { + @Override + public double min() { return this.min; } - @Override public double getMin() { + @Override + public double getMin() { return min(); } - @Override public double max() { + @Override + public double max() { return max; } - @Override public double getMax() { + @Override + public double getMax() { return max(); } - @Override public double total() { + @Override + public double total() { return total; } - @Override public double getTotal() { + @Override + public double getTotal() { return total(); } - @Override public double mean() { + @Override + public double mean() { if (totalCount == 0) { return 0; } return total / totalCount; } - @Override public double getMean() { + @Override + public double getMean() { return mean(); } - @Override public int compareTo(Entry o) { + @Override + public int compareTo(Entry o) { DoubleEntry other = (DoubleEntry) o; return (term < other.term ? -1 : (term == other.term ? 0 : 1)); } @@ -168,23 +181,28 @@ public class InternalTermsStatsDoubleFacet extends InternalTermsStatsFacet { this.missing = missing; } - @Override public String name() { + @Override + public String name() { return this.name; } - @Override public String getName() { + @Override + public String getName() { return this.name; } - @Override public String type() { + @Override + public String type() { return TYPE; } - @Override public String getType() { + @Override + public String getType() { return type(); } - @Override public List entries() { + @Override + public List entries() { if (!(entries instanceof List)) { entries = ImmutableList.copyOf(entries); } @@ -198,23 +216,29 @@ public class InternalTermsStatsDoubleFacet extends InternalTermsStatsFacet { return (List) entries; } - @Override public List getEntries() { + @Override + public List getEntries() { return entries(); } - @SuppressWarnings({"unchecked"}) @Override public Iterator iterator() { + @SuppressWarnings({"unchecked"}) + @Override + public Iterator iterator() { return (Iterator) entries.iterator(); } - @Override public long missingCount() { + @Override + public long missingCount() { return this.missing; } - @Override public long getMissingCount() { + @Override + public long getMissingCount() { return missingCount(); } - @Override public Facet reduce(String name, List facets) { + @Override + public Facet reduce(String name, List facets) { if (facets.size() == 1) { if (requiredSize == 0) { // we need to sort it here! @@ -286,7 +310,8 @@ public class InternalTermsStatsDoubleFacet extends InternalTermsStatsFacet { static final XContentBuilderString MEAN = new XContentBuilderString("mean"); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(name); builder.field(Fields._TYPE, InternalTermsStatsFacet.TYPE); builder.field(Fields.MISSING, missing); @@ -313,7 +338,8 @@ public class InternalTermsStatsDoubleFacet extends InternalTermsStatsFacet { return facet; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { name = in.readUTF(); comparatorType = ComparatorType.fromId(in.readByte()); requiredSize = in.readVInt(); @@ -326,7 +352,8 @@ public class InternalTermsStatsDoubleFacet extends InternalTermsStatsFacet { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(name); out.writeByte(comparatorType.id()); out.writeVInt(requiredSize); diff --git a/src/main/java/org/elasticsearch/search/facet/termsstats/doubles/TermsStatsDoubleFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/termsstats/doubles/TermsStatsDoubleFacetCollector.java index 9b79d505ce7..0df7fa31e95 100644 --- a/src/main/java/org/elasticsearch/search/facet/termsstats/doubles/TermsStatsDoubleFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/termsstats/doubles/TermsStatsDoubleFacetCollector.java @@ -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.search.facet.termsstats.doubles; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; +import gnu.trove.ExtTDoubleObjectHashMap; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.Scorer; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.CacheRecycler; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.trove.ExtTDoubleObjectHashMap; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.NumericFieldData; @@ -105,13 +105,15 @@ public class TermsStatsDoubleFacetCollector extends AbstractFacetCollector { } } - @Override public void setScorer(Scorer scorer) throws IOException { + @Override + public void setScorer(Scorer scorer) throws IOException { if (script != null) { script.setScorer(scorer); } } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { keyFieldData = (NumericFieldData) fieldDataCache.cache(keyFieldDataType, reader, keyFieldName); if (script != null) { script.setNextReader(reader); @@ -120,11 +122,13 @@ public class TermsStatsDoubleFacetCollector extends AbstractFacetCollector { } } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { keyFieldData.forEachValueInDoc(doc, aggregator); } - @Override public Facet facet() { + @Override + public Facet facet() { if (aggregator.entries.isEmpty()) { return new InternalTermsStatsDoubleFacet(facetName, comparatorType, size, ImmutableList.of(), aggregator.missing); } @@ -158,7 +162,8 @@ public class TermsStatsDoubleFacetCollector extends AbstractFacetCollector { final ValueAggregator valueAggregator = new ValueAggregator(); - @Override public void onValue(int docId, double value) { + @Override + public void onValue(int docId, double value) { InternalTermsStatsDoubleFacet.DoubleEntry doubleEntry = entries.get(value); if (doubleEntry == null) { doubleEntry = new InternalTermsStatsDoubleFacet.DoubleEntry(value, 0, 0, 0, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY); @@ -169,7 +174,8 @@ public class TermsStatsDoubleFacetCollector extends AbstractFacetCollector { valueFieldData.forEachValueInDoc(docId, valueAggregator); } - @Override public void onMissing(int docId) { + @Override + public void onMissing(int docId) { missing++; } @@ -177,7 +183,8 @@ public class TermsStatsDoubleFacetCollector extends AbstractFacetCollector { InternalTermsStatsDoubleFacet.DoubleEntry doubleEntry; - @Override public void onValue(int docId, double value) { + @Override + public void onValue(int docId, double value) { if (value < doubleEntry.min) { doubleEntry.min = value; } @@ -198,7 +205,8 @@ public class TermsStatsDoubleFacetCollector extends AbstractFacetCollector { this.script = script; } - @Override public void onValue(int docId, double value) { + @Override + public void onValue(int docId, double value) { InternalTermsStatsDoubleFacet.DoubleEntry doubleEntry = entries.get(value); if (doubleEntry == null) { doubleEntry = new InternalTermsStatsDoubleFacet.DoubleEntry(value, 1, 0, 0, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY); diff --git a/src/main/java/org/elasticsearch/search/facet/termsstats/longs/InternalTermsStatsLongFacet.java b/src/main/java/org/elasticsearch/search/facet/termsstats/longs/InternalTermsStatsLongFacet.java index 12d245109db..4e83251510a 100644 --- a/src/main/java/org/elasticsearch/search/facet/termsstats/longs/InternalTermsStatsLongFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/termsstats/longs/InternalTermsStatsLongFacet.java @@ -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,24 +19,18 @@ package org.elasticsearch.search.facet.termsstats.longs; +import com.google.common.collect.ImmutableList; +import gnu.trove.ExtTLongObjectHashMap; import org.elasticsearch.common.CacheRecycler; -import org.elasticsearch.common.collect.ImmutableList; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.trove.ExtTLongObjectHashMap; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilderString; import org.elasticsearch.search.facet.Facet; import org.elasticsearch.search.facet.termsstats.InternalTermsStatsFacet; import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; +import java.util.*; public class InternalTermsStatsLongFacet extends InternalTermsStatsFacet { @@ -47,12 +41,14 @@ public class InternalTermsStatsLongFacet extends InternalTermsStatsFacet { } static Stream STREAM = new Stream() { - @Override public Facet readFacet(String type, StreamInput in) throws IOException { + @Override + public Facet readFacet(String type, StreamInput in) throws IOException { return readTermsStatsFacet(in); } }; - @Override public String streamType() { + @Override + public String streamType() { return STREAM_TYPE; } @@ -76,74 +72,91 @@ public class InternalTermsStatsLongFacet extends InternalTermsStatsFacet { this.max = max; } - @Override public String term() { + @Override + public String term() { return Long.toString(term); } - @Override public String getTerm() { + @Override + public String getTerm() { return term(); } - @Override public Number termAsNumber() { + @Override + public Number termAsNumber() { return term; } - @Override public Number getTermAsNumber() { + @Override + public Number getTermAsNumber() { return termAsNumber(); } - @Override public long count() { + @Override + public long count() { return count; } - @Override public long getCount() { + @Override + public long getCount() { return count(); } - @Override public long totalCount() { + @Override + public long totalCount() { return this.totalCount; } - @Override public long getTotalCount() { + @Override + public long getTotalCount() { return this.totalCount; } - @Override public double min() { + @Override + public double min() { return this.min; } - @Override public double getMin() { + @Override + public double getMin() { return min(); } - @Override public double max() { + @Override + public double max() { return max; } - @Override public double getMax() { + @Override + public double getMax() { return max(); } - @Override public double total() { + @Override + public double total() { return total; } - @Override public double getTotal() { + @Override + public double getTotal() { return total(); } - @Override public double mean() { + @Override + public double mean() { if (totalCount == 0) { return 0; } return total / totalCount; } - @Override public double getMean() { + @Override + public double getMean() { return mean(); } - @Override public int compareTo(Entry o) { + @Override + public int compareTo(Entry o) { LongEntry other = (LongEntry) o; return (term < other.term ? -1 : (term == other.term ? 0 : 1)); } @@ -167,23 +180,28 @@ public class InternalTermsStatsLongFacet extends InternalTermsStatsFacet { this.missing = missing; } - @Override public String name() { + @Override + public String name() { return this.name; } - @Override public String getName() { + @Override + public String getName() { return this.name; } - @Override public String type() { + @Override + public String type() { return TYPE; } - @Override public String getType() { + @Override + public String getType() { return type(); } - @Override public List entries() { + @Override + public List entries() { if (!(entries instanceof List)) { entries = ImmutableList.copyOf(entries); } @@ -197,23 +215,29 @@ public class InternalTermsStatsLongFacet extends InternalTermsStatsFacet { return (List) entries; } - @Override public List getEntries() { + @Override + public List getEntries() { return entries(); } - @SuppressWarnings({"unchecked"}) @Override public Iterator iterator() { + @SuppressWarnings({"unchecked"}) + @Override + public Iterator iterator() { return (Iterator) entries.iterator(); } - @Override public long missingCount() { + @Override + public long missingCount() { return this.missing; } - @Override public long getMissingCount() { + @Override + public long getMissingCount() { return missingCount(); } - @Override public Facet reduce(String name, List facets) { + @Override + public Facet reduce(String name, List facets) { if (facets.size() == 1) { if (requiredSize == 0) { // we need to sort it here! @@ -285,7 +309,8 @@ public class InternalTermsStatsLongFacet extends InternalTermsStatsFacet { static final XContentBuilderString MEAN = new XContentBuilderString("mean"); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(name); builder.field(Fields._TYPE, InternalTermsStatsFacet.TYPE); builder.field(Fields.MISSING, missing); @@ -312,7 +337,8 @@ public class InternalTermsStatsLongFacet extends InternalTermsStatsFacet { return facet; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { name = in.readUTF(); comparatorType = ComparatorType.fromId(in.readByte()); requiredSize = in.readVInt(); @@ -325,7 +351,8 @@ public class InternalTermsStatsLongFacet extends InternalTermsStatsFacet { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(name); out.writeByte(comparatorType.id()); out.writeVInt(requiredSize); diff --git a/src/main/java/org/elasticsearch/search/facet/termsstats/longs/TermsStatsLongFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/termsstats/longs/TermsStatsLongFacetCollector.java index 347a5511a99..a6097882210 100644 --- a/src/main/java/org/elasticsearch/search/facet/termsstats/longs/TermsStatsLongFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/termsstats/longs/TermsStatsLongFacetCollector.java @@ -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.search.facet.termsstats.longs; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; +import gnu.trove.ExtTLongObjectHashMap; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.Scorer; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.CacheRecycler; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.trove.ExtTLongObjectHashMap; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.NumericFieldData; @@ -106,13 +106,15 @@ public class TermsStatsLongFacetCollector extends AbstractFacetCollector { } } - @Override public void setScorer(Scorer scorer) throws IOException { + @Override + public void setScorer(Scorer scorer) throws IOException { if (script != null) { script.setScorer(scorer); } } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { keyFieldData = (NumericFieldData) fieldDataCache.cache(keyFieldDataType, reader, keyFieldName); if (script != null) { script.setNextReader(reader); @@ -121,11 +123,13 @@ public class TermsStatsLongFacetCollector extends AbstractFacetCollector { } } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { keyFieldData.forEachValueInDoc(doc, aggregator); } - @Override public Facet facet() { + @Override + public Facet facet() { if (aggregator.entries.isEmpty()) { return new InternalTermsStatsLongFacet(facetName, comparatorType, size, ImmutableList.of(), aggregator.missing); } @@ -161,7 +165,8 @@ public class TermsStatsLongFacetCollector extends AbstractFacetCollector { final ValueAggregator valueAggregator = new ValueAggregator(); - @Override public void onValue(int docId, long value) { + @Override + public void onValue(int docId, long value) { InternalTermsStatsLongFacet.LongEntry longEntry = entries.get(value); if (longEntry == null) { longEntry = new InternalTermsStatsLongFacet.LongEntry(value, 0, 0, 0, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY); @@ -172,7 +177,8 @@ public class TermsStatsLongFacetCollector extends AbstractFacetCollector { valueFieldData.forEachValueInDoc(docId, valueAggregator); } - @Override public void onMissing(int docId) { + @Override + public void onMissing(int docId) { missing++; } @@ -180,7 +186,8 @@ public class TermsStatsLongFacetCollector extends AbstractFacetCollector { InternalTermsStatsLongFacet.LongEntry longEntry; - @Override public void onValue(int docId, double value) { + @Override + public void onValue(int docId, double value) { if (value < longEntry.min) { longEntry.min = value; } @@ -201,7 +208,8 @@ public class TermsStatsLongFacetCollector extends AbstractFacetCollector { this.script = script; } - @Override public void onValue(int docId, long value) { + @Override + public void onValue(int docId, long value) { InternalTermsStatsLongFacet.LongEntry longEntry = entries.get(value); if (longEntry == null) { longEntry = new InternalTermsStatsLongFacet.LongEntry(value, 1, 0, 0, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY); diff --git a/src/main/java/org/elasticsearch/search/facet/termsstats/strings/InternalTermsStatsStringFacet.java b/src/main/java/org/elasticsearch/search/facet/termsstats/strings/InternalTermsStatsStringFacet.java index 262fb2b9398..fd690291460 100644 --- a/src/main/java/org/elasticsearch/search/facet/termsstats/strings/InternalTermsStatsStringFacet.java +++ b/src/main/java/org/elasticsearch/search/facet/termsstats/strings/InternalTermsStatsStringFacet.java @@ -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,24 +19,18 @@ package org.elasticsearch.search.facet.termsstats.strings; +import com.google.common.collect.ImmutableList; +import gnu.trove.ExtTHashMap; import org.elasticsearch.common.CacheRecycler; -import org.elasticsearch.common.collect.ImmutableList; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.trove.ExtTHashMap; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilderString; import org.elasticsearch.search.facet.Facet; import org.elasticsearch.search.facet.termsstats.InternalTermsStatsFacet; import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; +import java.util.*; public class InternalTermsStatsStringFacet extends InternalTermsStatsFacet { @@ -47,12 +41,14 @@ public class InternalTermsStatsStringFacet extends InternalTermsStatsFacet { } static Stream STREAM = new Stream() { - @Override public Facet readFacet(String type, StreamInput in) throws IOException { + @Override + public Facet readFacet(String type, StreamInput in) throws IOException { return readTermsStatsFacet(in); } }; - @Override public String streamType() { + @Override + public String streamType() { return STREAM_TYPE; } @@ -77,74 +73,91 @@ public class InternalTermsStatsStringFacet extends InternalTermsStatsFacet { this.max = max; } - @Override public String term() { + @Override + public String term() { return term; } - @Override public String getTerm() { + @Override + public String getTerm() { return term(); } - @Override public Number termAsNumber() { + @Override + public Number termAsNumber() { return Double.parseDouble(term); } - @Override public Number getTermAsNumber() { + @Override + public Number getTermAsNumber() { return termAsNumber(); } - @Override public long count() { + @Override + public long count() { return count; } - @Override public long getCount() { + @Override + public long getCount() { return count(); } - @Override public long totalCount() { + @Override + public long totalCount() { return this.totalCount; } - @Override public long getTotalCount() { + @Override + public long getTotalCount() { return this.totalCount; } - @Override public double min() { + @Override + public double min() { return this.min; } - @Override public double getMin() { + @Override + public double getMin() { return min(); } - @Override public double max() { + @Override + public double max() { return this.max; } - @Override public double getMax() { + @Override + public double getMax() { return max(); } - @Override public double total() { + @Override + public double total() { return total; } - @Override public double getTotal() { + @Override + public double getTotal() { return total(); } - @Override public double mean() { + @Override + public double mean() { if (totalCount == 0) { return 0; } return total / totalCount; } - @Override public double getMean() { + @Override + public double getMean() { return mean(); } - @Override public int compareTo(Entry o) { + @Override + public int compareTo(Entry o) { return term.compareTo(o.term()); } } @@ -167,23 +180,28 @@ public class InternalTermsStatsStringFacet extends InternalTermsStatsFacet { this.missing = missing; } - @Override public String name() { + @Override + public String name() { return this.name; } - @Override public String getName() { + @Override + public String getName() { return this.name; } - @Override public String type() { + @Override + public String type() { return TYPE; } - @Override public String getType() { + @Override + public String getType() { return type(); } - @Override public List entries() { + @Override + public List entries() { if (!(entries instanceof List)) { entries = ImmutableList.copyOf(entries); } @@ -197,23 +215,29 @@ public class InternalTermsStatsStringFacet extends InternalTermsStatsFacet { return (List) entries; } - @Override public List getEntries() { + @Override + public List getEntries() { return entries(); } - @SuppressWarnings({"unchecked"}) @Override public Iterator iterator() { + @SuppressWarnings({"unchecked"}) + @Override + public Iterator iterator() { return (Iterator) entries.iterator(); } - @Override public long missingCount() { + @Override + public long missingCount() { return this.missing; } - @Override public long getMissingCount() { + @Override + public long getMissingCount() { return missingCount(); } - @Override public Facet reduce(String name, List facets) { + @Override + public Facet reduce(String name, List facets) { if (facets.size() == 1) { if (requiredSize == 0) { // we need to sort it here! @@ -284,7 +308,8 @@ public class InternalTermsStatsStringFacet extends InternalTermsStatsFacet { static final XContentBuilderString MEAN = new XContentBuilderString("mean"); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(name); builder.field(Fields._TYPE, InternalTermsStatsFacet.TYPE); builder.field(Fields.MISSING, missing); @@ -311,7 +336,8 @@ public class InternalTermsStatsStringFacet extends InternalTermsStatsFacet { return facet; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { name = in.readUTF(); comparatorType = ComparatorType.fromId(in.readByte()); requiredSize = in.readVInt(); @@ -324,7 +350,8 @@ public class InternalTermsStatsStringFacet extends InternalTermsStatsFacet { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(name); out.writeByte(comparatorType.id()); out.writeVInt(requiredSize); diff --git a/src/main/java/org/elasticsearch/search/facet/termsstats/strings/TermsStatsStringFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/termsstats/strings/TermsStatsStringFacetCollector.java index 5f6176b64f6..21a52e7f292 100644 --- a/src/main/java/org/elasticsearch/search/facet/termsstats/strings/TermsStatsStringFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/termsstats/strings/TermsStatsStringFacetCollector.java @@ -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.search.facet.termsstats.strings; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; +import gnu.trove.ExtTHashMap; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.Scorer; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.CacheRecycler; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.trove.ExtTHashMap; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldData; import org.elasticsearch.index.field.data.FieldDataType; @@ -106,13 +106,15 @@ public class TermsStatsStringFacetCollector extends AbstractFacetCollector { } } - @Override public void setScorer(Scorer scorer) throws IOException { + @Override + public void setScorer(Scorer scorer) throws IOException { if (script != null) { script.setScorer(scorer); } } - @Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { + @Override + protected void doSetNextReader(IndexReader reader, int docBase) throws IOException { keyFieldData = fieldDataCache.cache(keyFieldDataType, reader, keyFieldName); if (script != null) { script.setNextReader(reader); @@ -121,11 +123,13 @@ public class TermsStatsStringFacetCollector extends AbstractFacetCollector { } } - @Override protected void doCollect(int doc) throws IOException { + @Override + protected void doCollect(int doc) throws IOException { keyFieldData.forEachValueInDoc(doc, aggregator); } - @Override public Facet facet() { + @Override + public Facet facet() { if (aggregator.entries.isEmpty()) { return new InternalTermsStatsStringFacet(facetName, comparatorType, size, ImmutableList.of(), aggregator.missing); } @@ -160,7 +164,8 @@ public class TermsStatsStringFacetCollector extends AbstractFacetCollector { ValueAggregator valueAggregator = new ValueAggregator(); - @Override public void onValue(int docId, String value) { + @Override + public void onValue(int docId, String value) { InternalTermsStatsStringFacet.StringEntry stringEntry = entries.get(value); if (stringEntry == null) { stringEntry = new InternalTermsStatsStringFacet.StringEntry(value, 0, 0, 0, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY); @@ -171,7 +176,8 @@ public class TermsStatsStringFacetCollector extends AbstractFacetCollector { valueFieldData.forEachValueInDoc(docId, valueAggregator); } - @Override public void onMissing(int docId) { + @Override + public void onMissing(int docId) { missing++; } @@ -179,7 +185,8 @@ public class TermsStatsStringFacetCollector extends AbstractFacetCollector { InternalTermsStatsStringFacet.StringEntry stringEntry; - @Override public void onValue(int docId, double value) { + @Override + public void onValue(int docId, double value) { if (value < stringEntry.min) { stringEntry.min = value; } @@ -199,7 +206,8 @@ public class TermsStatsStringFacetCollector extends AbstractFacetCollector { this.script = script; } - @Override public void onValue(int docId, String value) { + @Override + public void onValue(int docId, String value) { InternalTermsStatsStringFacet.StringEntry stringEntry = entries.get(value); if (stringEntry == null) { stringEntry = new InternalTermsStatsStringFacet.StringEntry(value, 1, 0, 0, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY); diff --git a/src/main/java/org/elasticsearch/search/fetch/FetchPhase.java b/src/main/java/org/elasticsearch/search/fetch/FetchPhase.java index e090a923bd6..ca0c1af3e08 100644 --- a/src/main/java/org/elasticsearch/search/fetch/FetchPhase.java +++ b/src/main/java/org/elasticsearch/search/fetch/FetchPhase.java @@ -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,11 +19,11 @@ package org.elasticsearch.search.fetch; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Lists; import org.apache.lucene.document.Document; import org.apache.lucene.document.Fieldable; import org.apache.lucene.index.IndexReader; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.lucene.document.ResetFieldSelector; import org.elasticsearch.index.Index; @@ -58,18 +58,20 @@ import java.util.List; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class FetchPhase implements SearchPhase { private final FetchSubPhase[] fetchSubPhases; - @Inject public FetchPhase(HighlightPhase highlightPhase, ScriptFieldsFetchSubPhase scriptFieldsPhase, - MatchedFiltersFetchSubPhase matchFiltersPhase, ExplainFetchSubPhase explainPhase, VersionFetchSubPhase versionPhase) { + @Inject + public FetchPhase(HighlightPhase highlightPhase, ScriptFieldsFetchSubPhase scriptFieldsPhase, + MatchedFiltersFetchSubPhase matchFiltersPhase, ExplainFetchSubPhase explainPhase, VersionFetchSubPhase versionPhase) { this.fetchSubPhases = new FetchSubPhase[]{scriptFieldsPhase, matchFiltersPhase, explainPhase, highlightPhase, versionPhase}; } - @Override public Map parseElements() { + @Override + public Map parseElements() { ImmutableMap.Builder parseElements = ImmutableMap.builder(); parseElements.put("fields", new FieldsParseElement()); for (FetchSubPhase fetchSubPhase : fetchSubPhases) { @@ -78,7 +80,8 @@ public class FetchPhase implements SearchPhase { return parseElements.build(); } - @Override public void preProcess(SearchContext context) { + @Override + public void preProcess(SearchContext context) { } public void execute(SearchContext context) { diff --git a/src/main/java/org/elasticsearch/search/fetch/FetchPhaseExecutionException.java b/src/main/java/org/elasticsearch/search/fetch/FetchPhaseExecutionException.java index 82f06191fca..e9deec51a0b 100644 --- a/src/main/java/org/elasticsearch/search/fetch/FetchPhaseExecutionException.java +++ b/src/main/java/org/elasticsearch/search/fetch/FetchPhaseExecutionException.java @@ -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.search.SearchContextException; import org.elasticsearch.search.internal.SearchContext; /** - * @author kimchy (Shay Banon) + * */ public class FetchPhaseExecutionException extends SearchContextException { diff --git a/src/main/java/org/elasticsearch/search/fetch/FetchSearchRequest.java b/src/main/java/org/elasticsearch/search/fetch/FetchSearchRequest.java index 75c90225c34..ecc153d9f64 100644 --- a/src/main/java/org/elasticsearch/search/fetch/FetchSearchRequest.java +++ b/src/main/java/org/elasticsearch/search/fetch/FetchSearchRequest.java @@ -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,15 +19,15 @@ package org.elasticsearch.search.fetch; +import gnu.trove.ExtTIntArrayList; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Streamable; -import org.elasticsearch.common.trove.ExtTIntArrayList; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class FetchSearchRequest implements Streamable { @@ -64,7 +64,8 @@ public class FetchSearchRequest implements Streamable { return size; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { id = in.readLong(); size = in.readVInt(); docIds = new int[size]; @@ -73,7 +74,8 @@ public class FetchSearchRequest implements Streamable { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeLong(id); out.writeVInt(size); for (int i = 0; i < size; i++) { diff --git a/src/main/java/org/elasticsearch/search/fetch/FetchSearchResult.java b/src/main/java/org/elasticsearch/search/fetch/FetchSearchResult.java index 9113daa4001..f3bed30383d 100644 --- a/src/main/java/org/elasticsearch/search/fetch/FetchSearchResult.java +++ b/src/main/java/org/elasticsearch/search/fetch/FetchSearchResult.java @@ -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,10 +27,10 @@ import org.elasticsearch.search.internal.InternalSearchHits; import java.io.IOException; -import static org.elasticsearch.search.internal.InternalSearchHits.*; +import static org.elasticsearch.search.internal.InternalSearchHits.StreamContext; /** - * @author kimchy (shay.banon) + * */ public class FetchSearchResult implements Streamable, FetchSearchResultProvider { @@ -52,7 +52,8 @@ public class FetchSearchResult implements Streamable, FetchSearchResultProvider this.shardTarget = shardTarget; } - @Override public FetchSearchResult fetchResult() { + @Override + public FetchSearchResult fetchResult() { return this; } @@ -64,7 +65,8 @@ public class FetchSearchResult implements Streamable, FetchSearchResultProvider return this.shardTarget; } - @Override public void shardTarget(SearchShardTarget shardTarget) { + @Override + public void shardTarget(SearchShardTarget shardTarget) { this.shardTarget = shardTarget; } @@ -91,12 +93,14 @@ public class FetchSearchResult implements Streamable, FetchSearchResultProvider return result; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { id = in.readLong(); hits = InternalSearchHits.readSearchHits(in, InternalSearchHits.streamContext().streamShardTarget(StreamContext.ShardTargetType.NO_STREAM)); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeLong(id); hits.writeTo(out, InternalSearchHits.streamContext().streamShardTarget(StreamContext.ShardTargetType.NO_STREAM)); } diff --git a/src/main/java/org/elasticsearch/search/fetch/FetchSearchResultProvider.java b/src/main/java/org/elasticsearch/search/fetch/FetchSearchResultProvider.java index 96492053073..d58ba5d1350 100644 --- a/src/main/java/org/elasticsearch/search/fetch/FetchSearchResultProvider.java +++ b/src/main/java/org/elasticsearch/search/fetch/FetchSearchResultProvider.java @@ -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.search.fetch; import org.elasticsearch.search.SearchPhaseResult; /** - * @author kimchy (Shay Banon) + * */ public interface FetchSearchResultProvider extends SearchPhaseResult { diff --git a/src/main/java/org/elasticsearch/search/fetch/FetchSubPhase.java b/src/main/java/org/elasticsearch/search/fetch/FetchSubPhase.java index ca9f18c1218..d47da76e698 100644 --- a/src/main/java/org/elasticsearch/search/fetch/FetchSubPhase.java +++ b/src/main/java/org/elasticsearch/search/fetch/FetchSubPhase.java @@ -19,10 +19,10 @@ package org.elasticsearch.search.fetch; +import com.google.common.collect.Maps; import org.apache.lucene.document.Document; import org.apache.lucene.index.IndexReader; import org.elasticsearch.ElasticSearchException; -import org.elasticsearch.common.collect.Maps; import org.elasticsearch.search.SearchParseElement; import org.elasticsearch.search.internal.InternalSearchHit; import org.elasticsearch.search.internal.SearchContext; @@ -30,7 +30,7 @@ import org.elasticsearch.search.internal.SearchContext; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public interface FetchSubPhase { diff --git a/src/main/java/org/elasticsearch/search/fetch/FieldsParseElement.java b/src/main/java/org/elasticsearch/search/fetch/FieldsParseElement.java index 3dec32bc98b..7c0c1e52534 100644 --- a/src/main/java/org/elasticsearch/search/fetch/FieldsParseElement.java +++ b/src/main/java/org/elasticsearch/search/fetch/FieldsParseElement.java @@ -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,11 +26,12 @@ import org.elasticsearch.search.fetch.script.ScriptFieldsContext; import org.elasticsearch.search.internal.SearchContext; /** - * @author kimchy (shay.banon) + * */ public class FieldsParseElement implements SearchParseElement { - @Override public void parse(XContentParser parser, SearchContext context) throws Exception { + @Override + public void parse(XContentParser parser, SearchContext context) throws Exception { XContentParser.Token token = parser.currentToken(); if (token == XContentParser.Token.START_ARRAY) { boolean added = false; diff --git a/src/main/java/org/elasticsearch/search/fetch/QueryFetchSearchResult.java b/src/main/java/org/elasticsearch/search/fetch/QueryFetchSearchResult.java index c29ffe982f4..dec5a4dd2be 100644 --- a/src/main/java/org/elasticsearch/search/fetch/QueryFetchSearchResult.java +++ b/src/main/java/org/elasticsearch/search/fetch/QueryFetchSearchResult.java @@ -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,11 @@ import org.elasticsearch.search.query.QuerySearchResultProvider; import java.io.IOException; -import static org.elasticsearch.search.fetch.FetchSearchResult.*; -import static org.elasticsearch.search.query.QuerySearchResult.*; +import static org.elasticsearch.search.fetch.FetchSearchResult.readFetchSearchResult; +import static org.elasticsearch.search.query.QuerySearchResult.readQuerySearchResult; /** - * @author kimchy (shay.banon) + * */ public class QueryFetchSearchResult implements Streamable, QuerySearchResultProvider, FetchSearchResultProvider { @@ -57,12 +57,14 @@ public class QueryFetchSearchResult implements Streamable, QuerySearchResultProv return queryResult.shardTarget(); } - @Override public void shardTarget(SearchShardTarget shardTarget) { + @Override + public void shardTarget(SearchShardTarget shardTarget) { queryResult.shardTarget(shardTarget); fetchResult.shardTarget(shardTarget); } - @Override public boolean includeFetch() { + @Override + public boolean includeFetch() { return true; } @@ -80,12 +82,14 @@ public class QueryFetchSearchResult implements Streamable, QuerySearchResultProv return result; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { queryResult = readQuerySearchResult(in); fetchResult = readFetchSearchResult(in); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { queryResult.writeTo(out); fetchResult.writeTo(out); } diff --git a/src/main/java/org/elasticsearch/search/fetch/ScrollQueryFetchSearchResult.java b/src/main/java/org/elasticsearch/search/fetch/ScrollQueryFetchSearchResult.java index 3eacaec8a94..7efad49a640 100644 --- a/src/main/java/org/elasticsearch/search/fetch/ScrollQueryFetchSearchResult.java +++ b/src/main/java/org/elasticsearch/search/fetch/ScrollQueryFetchSearchResult.java @@ -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,11 +26,11 @@ import org.elasticsearch.search.SearchShardTarget; import java.io.IOException; -import static org.elasticsearch.search.SearchShardTarget.*; -import static org.elasticsearch.search.fetch.QueryFetchSearchResult.*; +import static org.elasticsearch.search.SearchShardTarget.readSearchShardTarget; +import static org.elasticsearch.search.fetch.QueryFetchSearchResult.readQueryFetchSearchResult; /** - * @author kimchy (shay.banon) + * */ public class ScrollQueryFetchSearchResult implements Streamable { @@ -54,13 +54,15 @@ public class ScrollQueryFetchSearchResult implements Streamable { return shardTarget; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { shardTarget = readSearchShardTarget(in); result = readQueryFetchSearchResult(in); result.shardTarget(shardTarget); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { shardTarget.writeTo(out); result.writeTo(out); } diff --git a/src/main/java/org/elasticsearch/search/fetch/explain/ExplainFetchSubPhase.java b/src/main/java/org/elasticsearch/search/fetch/explain/ExplainFetchSubPhase.java index 396e10c7354..244f05e601e 100644 --- a/src/main/java/org/elasticsearch/search/fetch/explain/ExplainFetchSubPhase.java +++ b/src/main/java/org/elasticsearch/search/fetch/explain/ExplainFetchSubPhase.java @@ -19,8 +19,8 @@ package org.elasticsearch.search.fetch.explain; +import com.google.common.collect.ImmutableMap; import org.elasticsearch.ElasticSearchException; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.search.SearchParseElement; import org.elasticsearch.search.fetch.FetchPhaseExecutionException; import org.elasticsearch.search.fetch.FetchSubPhase; @@ -31,26 +31,31 @@ import java.io.IOException; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class ExplainFetchSubPhase implements FetchSubPhase { - @Override public Map parseElements() { + @Override + public Map parseElements() { return ImmutableMap.of("explain", new ExplainParseElement()); } - @Override public boolean hitsExecutionNeeded(SearchContext context) { + @Override + public boolean hitsExecutionNeeded(SearchContext context) { return false; } - @Override public void hitsExecute(SearchContext context, InternalSearchHit[] hits) throws ElasticSearchException { + @Override + public void hitsExecute(SearchContext context, InternalSearchHit[] hits) throws ElasticSearchException { } - @Override public boolean hitExecutionNeeded(SearchContext context) { + @Override + public boolean hitExecutionNeeded(SearchContext context) { return context.explain(); } - @Override public void hitExecute(SearchContext context, HitContext hitContext) throws ElasticSearchException { + @Override + public void hitExecute(SearchContext context, HitContext hitContext) throws ElasticSearchException { try { // we use the top level doc id, since we work with the top level searcher hitContext.hit().explanation(context.searcher().explain(context.query(), hitContext.hit().docId())); diff --git a/src/main/java/org/elasticsearch/search/fetch/explain/ExplainParseElement.java b/src/main/java/org/elasticsearch/search/fetch/explain/ExplainParseElement.java index 44da110eeef..8fda83b4621 100644 --- a/src/main/java/org/elasticsearch/search/fetch/explain/ExplainParseElement.java +++ b/src/main/java/org/elasticsearch/search/fetch/explain/ExplainParseElement.java @@ -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,11 +24,12 @@ import org.elasticsearch.search.SearchParseElement; import org.elasticsearch.search.internal.SearchContext; /** - * @author kimchy (shay.banon) + * */ public class ExplainParseElement implements SearchParseElement { - @Override public void parse(XContentParser parser, SearchContext context) throws Exception { + @Override + public void parse(XContentParser parser, SearchContext context) throws Exception { XContentParser.Token token = parser.currentToken(); if (token.isValue()) { context.explain(parser.booleanValue()); diff --git a/src/main/java/org/elasticsearch/search/fetch/matchedfilters/MatchedFiltersFetchSubPhase.java b/src/main/java/org/elasticsearch/search/fetch/matchedfilters/MatchedFiltersFetchSubPhase.java index 452337809c4..0bb4a4e8a56 100644 --- a/src/main/java/org/elasticsearch/search/fetch/matchedfilters/MatchedFiltersFetchSubPhase.java +++ b/src/main/java/org/elasticsearch/search/fetch/matchedfilters/MatchedFiltersFetchSubPhase.java @@ -19,11 +19,11 @@ package org.elasticsearch.search.fetch.matchedfilters; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Lists; import org.apache.lucene.search.DocIdSet; import org.apache.lucene.search.Filter; import org.elasticsearch.ElasticSearchException; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.lucene.docset.DocSet; import org.elasticsearch.common.lucene.docset.DocSets; import org.elasticsearch.search.SearchParseElement; @@ -36,26 +36,31 @@ import java.util.List; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class MatchedFiltersFetchSubPhase implements FetchSubPhase { - @Override public Map parseElements() { + @Override + public Map parseElements() { return ImmutableMap.of(); } - @Override public boolean hitsExecutionNeeded(SearchContext context) { + @Override + public boolean hitsExecutionNeeded(SearchContext context) { return false; } - @Override public void hitsExecute(SearchContext context, InternalSearchHit[] hits) throws ElasticSearchException { + @Override + public void hitsExecute(SearchContext context, InternalSearchHit[] hits) throws ElasticSearchException { } - @Override public boolean hitExecutionNeeded(SearchContext context) { + @Override + public boolean hitExecutionNeeded(SearchContext context) { return !context.parsedQuery().namedFilters().isEmpty(); } - @Override public void hitExecute(SearchContext context, HitContext hitContext) throws ElasticSearchException { + @Override + public void hitExecute(SearchContext context, HitContext hitContext) throws ElasticSearchException { List matchedFilters = Lists.newArrayListWithCapacity(2); for (Map.Entry entry : context.parsedQuery().namedFilters().entrySet()) { String name = entry.getKey(); diff --git a/src/main/java/org/elasticsearch/search/fetch/script/ScriptFieldsContext.java b/src/main/java/org/elasticsearch/search/fetch/script/ScriptFieldsContext.java index 5fc596e220a..c5027e89e30 100644 --- a/src/main/java/org/elasticsearch/search/fetch/script/ScriptFieldsContext.java +++ b/src/main/java/org/elasticsearch/search/fetch/script/ScriptFieldsContext.java @@ -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.search.fetch.script; -import org.elasticsearch.common.collect.Lists; +import com.google.common.collect.Lists; import org.elasticsearch.script.SearchScript; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class ScriptFieldsContext { diff --git a/src/main/java/org/elasticsearch/search/fetch/script/ScriptFieldsFetchSubPhase.java b/src/main/java/org/elasticsearch/search/fetch/script/ScriptFieldsFetchSubPhase.java index 7ca09ed4fd9..ee48b32575a 100644 --- a/src/main/java/org/elasticsearch/search/fetch/script/ScriptFieldsFetchSubPhase.java +++ b/src/main/java/org/elasticsearch/search/fetch/script/ScriptFieldsFetchSubPhase.java @@ -19,8 +19,8 @@ package org.elasticsearch.search.fetch.script; +import com.google.common.collect.ImmutableMap; import org.elasticsearch.ElasticSearchException; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.search.SearchHitField; import org.elasticsearch.search.SearchParseElement; @@ -34,32 +34,38 @@ import java.util.HashMap; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class ScriptFieldsFetchSubPhase implements FetchSubPhase { - @Inject public ScriptFieldsFetchSubPhase() { + @Inject + public ScriptFieldsFetchSubPhase() { } - @Override public Map parseElements() { + @Override + public Map parseElements() { ImmutableMap.Builder parseElements = ImmutableMap.builder(); parseElements.put("script_fields", new ScriptFieldsParseElement()) .put("scriptFields", new ScriptFieldsParseElement()); return parseElements.build(); } - @Override public boolean hitsExecutionNeeded(SearchContext context) { + @Override + public boolean hitsExecutionNeeded(SearchContext context) { return false; } - @Override public void hitsExecute(SearchContext context, InternalSearchHit[] hits) throws ElasticSearchException { + @Override + public void hitsExecute(SearchContext context, InternalSearchHit[] hits) throws ElasticSearchException { } - @Override public boolean hitExecutionNeeded(SearchContext context) { + @Override + public boolean hitExecutionNeeded(SearchContext context) { return context.hasScriptFields(); } - @Override public void hitExecute(SearchContext context, HitContext hitContext) throws ElasticSearchException { + @Override + public void hitExecute(SearchContext context, HitContext hitContext) throws ElasticSearchException { for (ScriptFieldsContext.ScriptField scriptField : context.scriptFields().fields()) { scriptField.script().setNextReader(hitContext.reader()); scriptField.script().setNextDocId(hitContext.docId()); diff --git a/src/main/java/org/elasticsearch/search/fetch/script/ScriptFieldsParseElement.java b/src/main/java/org/elasticsearch/search/fetch/script/ScriptFieldsParseElement.java index 1684f34faa4..54f8ba3bb67 100644 --- a/src/main/java/org/elasticsearch/search/fetch/script/ScriptFieldsParseElement.java +++ b/src/main/java/org/elasticsearch/search/fetch/script/ScriptFieldsParseElement.java @@ -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,11 +38,12 @@ import java.util.Map; * } * * - * @author kimchy (shay.banon) + * */ public class ScriptFieldsParseElement implements SearchParseElement { - @Override public void parse(XContentParser parser, SearchContext context) throws Exception { + @Override + public void parse(XContentParser parser, SearchContext context) throws Exception { XContentParser.Token token; String currentFieldName = null; while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { diff --git a/src/main/java/org/elasticsearch/search/fetch/version/VersionFetchSubPhase.java b/src/main/java/org/elasticsearch/search/fetch/version/VersionFetchSubPhase.java index bbb42ca4d33..f5342822739 100644 --- a/src/main/java/org/elasticsearch/search/fetch/version/VersionFetchSubPhase.java +++ b/src/main/java/org/elasticsearch/search/fetch/version/VersionFetchSubPhase.java @@ -19,8 +19,8 @@ package org.elasticsearch.search.fetch.version; +import com.google.common.collect.ImmutableMap; import org.elasticsearch.ElasticSearchException; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.lucene.uid.UidField; import org.elasticsearch.index.mapper.internal.UidFieldMapper; import org.elasticsearch.search.SearchParseElement; @@ -31,26 +31,31 @@ import org.elasticsearch.search.internal.SearchContext; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class VersionFetchSubPhase implements FetchSubPhase { - @Override public Map parseElements() { + @Override + public Map parseElements() { return ImmutableMap.of("version", new VersionParseElement()); } - @Override public boolean hitsExecutionNeeded(SearchContext context) { + @Override + public boolean hitsExecutionNeeded(SearchContext context) { return false; } - @Override public void hitsExecute(SearchContext context, InternalSearchHit[] hits) throws ElasticSearchException { + @Override + public void hitsExecute(SearchContext context, InternalSearchHit[] hits) throws ElasticSearchException { } - @Override public boolean hitExecutionNeeded(SearchContext context) { + @Override + public boolean hitExecutionNeeded(SearchContext context) { return context.version(); } - @Override public void hitExecute(SearchContext context, HitContext hitContext) throws ElasticSearchException { + @Override + public void hitExecute(SearchContext context, HitContext hitContext) throws ElasticSearchException { // it might make sense to cache the TermDocs on a shared fetch context and just skip here) // it is going to mean we work on the high level multi reader and not the lower level reader as is // the case below... diff --git a/src/main/java/org/elasticsearch/search/fetch/version/VersionParseElement.java b/src/main/java/org/elasticsearch/search/fetch/version/VersionParseElement.java index 368a39a3c40..d00f404c72d 100644 --- a/src/main/java/org/elasticsearch/search/fetch/version/VersionParseElement.java +++ b/src/main/java/org/elasticsearch/search/fetch/version/VersionParseElement.java @@ -24,11 +24,12 @@ import org.elasticsearch.search.SearchParseElement; import org.elasticsearch.search.internal.SearchContext; /** - * @author kimchy (shay.banon) + * */ public class VersionParseElement implements SearchParseElement { - @Override public void parse(XContentParser parser, SearchContext context) throws Exception { + @Override + public void parse(XContentParser parser, SearchContext context) throws Exception { XContentParser.Token token = parser.currentToken(); if (token.isValue()) { context.version(parser.booleanValue()); diff --git a/src/main/java/org/elasticsearch/search/highlight/HighlightBuilder.java b/src/main/java/org/elasticsearch/search/highlight/HighlightBuilder.java index 730e9b279d2..96689e8ab09 100644 --- a/src/main/java/org/elasticsearch/search/highlight/HighlightBuilder.java +++ b/src/main/java/org/elasticsearch/search/highlight/HighlightBuilder.java @@ -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,12 +25,12 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; import java.util.List; -import static org.elasticsearch.common.collect.Lists.*; +import static com.google.common.collect.Lists.newArrayList; /** * A builder for search highlighting. * - * @author kimchy (shay.banon) + * * @see org.elasticsearch.search.builder.SearchSourceBuilder#highlight() */ public class HighlightBuilder implements ToXContent { @@ -62,7 +62,6 @@ public class HighlightBuilder implements ToXContent { } - /** * Adds a field to be highlighted with a provided fragment size (in characters), and * default number of fragments of 5. @@ -96,8 +95,7 @@ public class HighlightBuilder implements ToXContent { } - - /** + /** * Adds a field to be highlighted with a provided fragment size (in characters), and * a provided (maximum) number of fragments. * @@ -138,6 +136,7 @@ public class HighlightBuilder implements ToXContent { this.encoder = encoder; return this; } + /** * Explicitly set the pre tags that will be used for highlighting. */ @@ -164,7 +163,8 @@ public class HighlightBuilder implements ToXContent { return this; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject("highlight"); if (tagsSchema != null) { builder.field("tags_schema", tagsSchema); diff --git a/src/main/java/org/elasticsearch/search/highlight/HighlightField.java b/src/main/java/org/elasticsearch/search/highlight/HighlightField.java index 74d1e403be3..0bac4f8bb11 100644 --- a/src/main/java/org/elasticsearch/search/highlight/HighlightField.java +++ b/src/main/java/org/elasticsearch/search/highlight/HighlightField.java @@ -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.Arrays; /** * A field highlighted with its highlighted fragments. * - * @author kimchy (shay.banon) + * */ public class HighlightField implements Streamable { @@ -74,7 +74,8 @@ public class HighlightField implements Streamable { return fragments(); } - @Override public String toString() { + @Override + public String toString() { return "[" + name + "], fragments[" + Arrays.toString(fragments) + "]"; } @@ -84,7 +85,8 @@ public class HighlightField implements Streamable { return field; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { name = in.readUTF(); if (in.readBoolean()) { int size = in.readVInt(); @@ -99,7 +101,8 @@ public class HighlightField implements Streamable { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(name); if (fragments == null) { out.writeBoolean(false); diff --git a/src/main/java/org/elasticsearch/search/highlight/HighlightPhase.java b/src/main/java/org/elasticsearch/search/highlight/HighlightPhase.java index 8ffd5251995..9c34a11949b 100644 --- a/src/main/java/org/elasticsearch/search/highlight/HighlightPhase.java +++ b/src/main/java/org/elasticsearch/search/highlight/HighlightPhase.java @@ -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,8 @@ package org.elasticsearch.search.highlight; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.document.Document; @@ -27,18 +29,9 @@ import org.apache.lucene.document.Fieldable; import org.apache.lucene.search.ConstantScoreQuery; import org.apache.lucene.search.Query; import org.apache.lucene.search.highlight.*; -import org.apache.lucene.search.vectorhighlight.CustomFieldQuery; -import org.apache.lucene.search.vectorhighlight.FastVectorHighlighter; -import org.apache.lucene.search.vectorhighlight.FieldQuery; -import org.apache.lucene.search.vectorhighlight.FragListBuilder; -import org.apache.lucene.search.vectorhighlight.FragmentsBuilder; -import org.apache.lucene.search.vectorhighlight.ScoreOrderFragmentsBuilder; -import org.apache.lucene.search.vectorhighlight.SimpleFragListBuilder; -import org.apache.lucene.search.vectorhighlight.SimpleFragmentsBuilder; -import org.apache.lucene.search.vectorhighlight.SingleFragListBuilder; +import org.apache.lucene.search.highlight.Formatter; +import org.apache.lucene.search.vectorhighlight.*; import org.elasticsearch.ElasticSearchException; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.Maps; import org.elasticsearch.common.io.FastStringReader; import org.elasticsearch.common.lucene.document.SingleFieldSelector; import org.elasticsearch.common.lucene.search.function.FiltersFunctionScoreQuery; @@ -55,16 +48,12 @@ import org.elasticsearch.search.internal.InternalSearchHit; import org.elasticsearch.search.internal.SearchContext; import org.elasticsearch.search.lookup.SearchLookup; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.Map; +import java.util.*; -import static org.elasticsearch.common.collect.Maps.*; +import static com.google.common.collect.Maps.newHashMap; /** - * @author kimchy (shay.banon) + * */ public class HighlightPhase implements FetchSubPhase { @@ -73,22 +62,27 @@ public class HighlightPhase implements FetchSubPhase { public static Encoder HTML = new SimpleHTMLEncoder(); } - @Override public Map parseElements() { + @Override + public Map parseElements() { return ImmutableMap.of("highlight", new HighlighterParseElement()); } - @Override public boolean hitsExecutionNeeded(SearchContext context) { + @Override + public boolean hitsExecutionNeeded(SearchContext context) { return false; } - @Override public void hitsExecute(SearchContext context, InternalSearchHit[] hits) throws ElasticSearchException { + @Override + public void hitsExecute(SearchContext context, InternalSearchHit[] hits) throws ElasticSearchException { } - @Override public boolean hitExecutionNeeded(SearchContext context) { + @Override + public boolean hitExecutionNeeded(SearchContext context) { return context.highlight() != null; } - @Override public void hitExecute(SearchContext context, HitContext hitContext) throws ElasticSearchException { + @Override + public void hitExecute(SearchContext context, HitContext hitContext) throws ElasticSearchException { // we use a cache to cache heavy things, mainly the rewrite in FieldQuery for FVH Map cache = (Map) hitContext.cache().get("highlight"); if (cache == null) { diff --git a/src/main/java/org/elasticsearch/search/highlight/HighlighterParseElement.java b/src/main/java/org/elasticsearch/search/highlight/HighlighterParseElement.java index 1dda17f4e6f..f3aab1dd815 100644 --- a/src/main/java/org/elasticsearch/search/highlight/HighlighterParseElement.java +++ b/src/main/java/org/elasticsearch/search/highlight/HighlighterParseElement.java @@ -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,7 +19,7 @@ package org.elasticsearch.search.highlight; -import org.elasticsearch.common.collect.Lists; +import com.google.common.collect.Lists; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.search.SearchParseElement; import org.elasticsearch.search.SearchParseException; @@ -27,7 +27,7 @@ import org.elasticsearch.search.internal.SearchContext; import java.util.List; -import static org.elasticsearch.common.collect.Lists.*; +import static com.google.common.collect.Lists.newArrayList; /** *

    @@ -46,7 +46,7 @@ import static org.elasticsearch.common.collect.Lists.*;
      * }
      * 
    * - * @author kimchy (shay.banon) + * */ public class HighlighterParseElement implements SearchParseElement { @@ -61,7 +61,8 @@ public class HighlighterParseElement implements SearchParseElement { }; private static final String[] STYLED_POST_TAGS = {""}; - @Override public void parse(XContentParser parser, SearchContext context) throws Exception { + @Override + public void parse(XContentParser parser, SearchContext context) throws Exception { XContentParser.Token token; String topLevelFieldName = null; List fields = newArrayList(); diff --git a/src/main/java/org/elasticsearch/search/highlight/SearchContextHighlight.java b/src/main/java/org/elasticsearch/search/highlight/SearchContextHighlight.java index 7717196073a..8a58ea281c2 100644 --- a/src/main/java/org/elasticsearch/search/highlight/SearchContextHighlight.java +++ b/src/main/java/org/elasticsearch/search/highlight/SearchContextHighlight.java @@ -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,10 @@ package org.elasticsearch.search.highlight; -import org.elasticsearch.common.io.stream.StreamInput; - import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class SearchContextHighlight { @@ -90,15 +88,15 @@ public class SearchContextHighlight { this.fragmentOffset = fragmentOffset; } - public String encoder(){ + public String encoder() { return encoder; } - public void encoder(String encoder){ + public void encoder(String encoder) { this.encoder = encoder; - } + } - public String[] preTags() { + public String[] preTags() { return preTags; } diff --git a/src/main/java/org/elasticsearch/search/highlight/vectorhighlight/SourceScoreOrderFragmentsBuilder.java b/src/main/java/org/elasticsearch/search/highlight/vectorhighlight/SourceScoreOrderFragmentsBuilder.java index 65cbb22312f..dd5639fdb7a 100644 --- a/src/main/java/org/elasticsearch/search/highlight/vectorhighlight/SourceScoreOrderFragmentsBuilder.java +++ b/src/main/java/org/elasticsearch/search/highlight/vectorhighlight/SourceScoreOrderFragmentsBuilder.java @@ -30,7 +30,7 @@ import java.io.IOException; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class SourceScoreOrderFragmentsBuilder extends ScoreOrderFragmentsBuilder { @@ -45,7 +45,8 @@ public class SourceScoreOrderFragmentsBuilder extends ScoreOrderFragmentsBuilder this.searchContext = searchContext; } - @Override protected Field[] getFields(IndexReader reader, int docId, String fieldName) throws IOException { + @Override + protected Field[] getFields(IndexReader reader, int docId, String fieldName) throws IOException { // we know its low level reader, and matching docId, since that's how we call the highlighter with SearchLookup lookup = searchContext.lookup(); lookup.setNextReader(reader); diff --git a/src/main/java/org/elasticsearch/search/highlight/vectorhighlight/SourceSimpleFragmentsBuilder.java b/src/main/java/org/elasticsearch/search/highlight/vectorhighlight/SourceSimpleFragmentsBuilder.java index 819883ab37c..26894ed0c1e 100644 --- a/src/main/java/org/elasticsearch/search/highlight/vectorhighlight/SourceSimpleFragmentsBuilder.java +++ b/src/main/java/org/elasticsearch/search/highlight/vectorhighlight/SourceSimpleFragmentsBuilder.java @@ -30,7 +30,7 @@ import java.io.IOException; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class SourceSimpleFragmentsBuilder extends SimpleFragmentsBuilder { @@ -47,7 +47,8 @@ public class SourceSimpleFragmentsBuilder extends SimpleFragmentsBuilder { public static final Field[] EMPTY_FIELDS = new Field[0]; - @Override protected Field[] getFields(IndexReader reader, int docId, String fieldName) throws IOException { + @Override + protected Field[] getFields(IndexReader reader, int docId, String fieldName) throws IOException { // we know its low level reader, and matching docId, since that's how we call the highlighter with SearchLookup lookup = searchContext.lookup(); lookup.setNextReader(reader); diff --git a/src/main/java/org/elasticsearch/search/internal/ContextIndexSearcher.java b/src/main/java/org/elasticsearch/search/internal/ContextIndexSearcher.java index e4dd9fdc74b..7f19148d2cb 100644 --- a/src/main/java/org/elasticsearch/search/internal/ContextIndexSearcher.java +++ b/src/main/java/org/elasticsearch/search/internal/ContextIndexSearcher.java @@ -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,19 +19,12 @@ package org.elasticsearch.search.internal; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import org.apache.lucene.index.ExtendedIndexSearcher; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.search.Collector; -import org.apache.lucene.search.Filter; -import org.apache.lucene.search.Query; -import org.apache.lucene.search.Sort; -import org.apache.lucene.search.TimeLimitingCollector; -import org.apache.lucene.search.TopFieldCollector; -import org.apache.lucene.search.TopFieldDocs; -import org.apache.lucene.search.Weight; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.Lists; -import org.elasticsearch.common.collect.Maps; +import org.apache.lucene.search.*; import org.elasticsearch.common.lucene.MinimumScoreCollector; import org.elasticsearch.common.lucene.MultiCollector; import org.elasticsearch.common.lucene.search.AndFilter; @@ -44,7 +37,7 @@ import java.util.List; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class ContextIndexSearcher extends ExtendedIndexSearcher { @@ -116,7 +109,8 @@ public class ContextIndexSearcher extends ExtendedIndexSearcher { this.processingScope = Scopes.NA; } - @Override public Query rewrite(Query original) throws IOException { + @Override + public Query rewrite(Query original) throws IOException { if (original == searchContext.query() || original == searchContext.parsedQuery().query()) { // optimize in case its the top level search query and we already rewrote it... if (searchContext.queryRewritten()) { @@ -130,7 +124,8 @@ public class ContextIndexSearcher extends ExtendedIndexSearcher { } } - @Override public Weight createNormalizedWeight(Query query) throws IOException { + @Override + public Weight createNormalizedWeight(Query query) throws IOException { // if its the main query, use we have dfs data, only then do it if (dfSource != null && (query == searchContext.query() || query == searchContext.parsedQuery().query())) { return dfSource.createNormalizedWeight(query); @@ -140,8 +135,9 @@ public class ContextIndexSearcher extends ExtendedIndexSearcher { // override from the Searcher to allow to control if scores will be tracked or not // LUCENE MONITOR - We override the logic here to apply our own flags for track scores - @Override public TopFieldDocs search(Weight weight, Filter filter, int nDocs, - Sort sort, boolean fillFields) throws IOException { + @Override + public TopFieldDocs search(Weight weight, Filter filter, int nDocs, + Sort sort, boolean fillFields) throws IOException { int limit = reader.maxDoc(); if (limit == 0) { limit = 1; @@ -154,7 +150,8 @@ public class ContextIndexSearcher extends ExtendedIndexSearcher { return (TopFieldDocs) collector.topDocs(); } - @Override public void search(Weight weight, Filter filter, Collector collector) throws IOException { + @Override + public void search(Weight weight, Filter filter, Collector collector) throws IOException { if (searchContext.parsedFilter() != null && Scopes.MAIN.equals(processingScope)) { // this will only get applied to the actual search collector and not // to any scoped collectors, also, it will only be applied to the main collector diff --git a/src/main/java/org/elasticsearch/search/internal/InternalScrollSearchRequest.java b/src/main/java/org/elasticsearch/search/internal/InternalScrollSearchRequest.java index 5326aaf891b..4eb97cdb6a9 100644 --- a/src/main/java/org/elasticsearch/search/internal/InternalScrollSearchRequest.java +++ b/src/main/java/org/elasticsearch/search/internal/InternalScrollSearchRequest.java @@ -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,10 +26,10 @@ import org.elasticsearch.search.Scroll; import java.io.IOException; -import static org.elasticsearch.search.Scroll.*; +import static org.elasticsearch.search.Scroll.readScroll; /** - * @author kimchy (Shay Banon) + * */ public class InternalScrollSearchRequest implements Streamable { @@ -57,14 +57,16 @@ public class InternalScrollSearchRequest implements Streamable { return this; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { id = in.readLong(); if (in.readBoolean()) { scroll = readScroll(in); } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeLong(id); if (scroll == null) { out.writeBoolean(false); diff --git a/src/main/java/org/elasticsearch/search/internal/InternalSearchHit.java b/src/main/java/org/elasticsearch/search/internal/InternalSearchHit.java index 33b763d9649..543695211b3 100644 --- a/src/main/java/org/elasticsearch/search/internal/InternalSearchHit.java +++ b/src/main/java/org/elasticsearch/search/internal/InternalSearchHit.java @@ -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.elasticsearch.search.internal; +import com.google.common.collect.ImmutableMap; import org.apache.lucene.search.Explanation; import org.elasticsearch.ElasticSearchParseException; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Strings; import org.elasticsearch.common.Unicode; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.compress.lzf.LZF; import org.elasticsearch.common.compress.lzf.LZFDecoder; import org.elasticsearch.common.io.stream.StreamInput; @@ -43,13 +43,14 @@ import java.io.IOException; import java.util.Iterator; import java.util.Map; -import static org.elasticsearch.common.lucene.Lucene.*; -import static org.elasticsearch.search.SearchShardTarget.*; -import static org.elasticsearch.search.highlight.HighlightField.*; -import static org.elasticsearch.search.internal.InternalSearchHitField.*; +import static org.elasticsearch.common.lucene.Lucene.readExplanation; +import static org.elasticsearch.common.lucene.Lucene.writeExplanation; +import static org.elasticsearch.search.SearchShardTarget.readSearchShardTarget; +import static org.elasticsearch.search.highlight.HighlightField.readHighlightField; +import static org.elasticsearch.search.internal.InternalSearchHitField.readSearchHitField; /** - * @author kimchy (shay.banon) + * */ public class InternalSearchHit implements SearchHit { @@ -77,7 +78,8 @@ public class InternalSearchHit implements SearchHit { private Explanation explanation; - @Nullable private SearchShardTarget shard; + @Nullable + private SearchShardTarget shard; private Map sourceAsMap; @@ -105,11 +107,13 @@ public class InternalSearchHit implements SearchHit { this.score = score; } - @Override public float score() { + @Override + public float score() { return this.score; } - @Override public float getScore() { + @Override + public float getScore() { return score(); } @@ -117,39 +121,48 @@ public class InternalSearchHit implements SearchHit { this.version = version; } - @Override public long version() { + @Override + public long version() { return this.version; } - @Override public long getVersion() { + @Override + public long getVersion() { return this.version; } - @Override public String index() { + @Override + public String index() { return shard.index(); } - @Override public String getIndex() { + @Override + public String getIndex() { return index(); } - @Override public String id() { + @Override + public String id() { return id; } - @Override public String getId() { + @Override + public String getId() { return id(); } - @Override public String type() { + @Override + public String type() { return type; } - @Override public String getType() { + @Override + public String getType() { return type(); } - @Override public byte[] source() { + @Override + public byte[] source() { if (source == null) { return null; } @@ -163,15 +176,18 @@ public class InternalSearchHit implements SearchHit { return this.source; } - @Override public boolean isSourceEmpty() { + @Override + public boolean isSourceEmpty() { return source == null; } - @Override public Map getSource() { + @Override + public Map getSource() { return sourceAsMap(); } - @Override public String sourceAsString() { + @Override + public String sourceAsString() { if (source == null) { return null; } @@ -179,7 +195,8 @@ public class InternalSearchHit implements SearchHit { } @SuppressWarnings({"unchecked"}) - @Override public Map sourceAsMap() throws ElasticSearchParseException { + @Override + public Map sourceAsMap() throws ElasticSearchParseException { if (source == null) { return null; } @@ -202,15 +219,18 @@ public class InternalSearchHit implements SearchHit { } } - @Override public Iterator iterator() { + @Override + public Iterator iterator() { return fields.values().iterator(); } - @Override public SearchHitField field(String fieldName) { + @Override + public SearchHitField field(String fieldName) { return fields().get(fieldName); } - @Override public Map fields() { + @Override + public Map fields() { if (fields == null) { return ImmutableMap.of(); } @@ -222,7 +242,8 @@ public class InternalSearchHit implements SearchHit { return this.fields; } - @Override public Map getFields() { + @Override + public Map getFields() { return fields(); } @@ -234,14 +255,16 @@ public class InternalSearchHit implements SearchHit { return highlightFields; } - @Override public Map highlightFields() { + @Override + public Map highlightFields() { if (highlightFields == null) { return ImmutableMap.of(); } return this.highlightFields; } - @Override public Map getHighlightFields() { + @Override + public Map getHighlightFields() { return highlightFields(); } @@ -253,19 +276,23 @@ public class InternalSearchHit implements SearchHit { this.sortValues = sortValues; } - @Override public Object[] sortValues() { + @Override + public Object[] sortValues() { return sortValues; } - @Override public Object[] getSortValues() { + @Override + public Object[] getSortValues() { return sortValues(); } - @Override public Explanation explanation() { + @Override + public Explanation explanation() { return explanation; } - @Override public Explanation getExplanation() { + @Override + public Explanation getExplanation() { return explanation(); } @@ -273,11 +300,13 @@ public class InternalSearchHit implements SearchHit { this.explanation = explanation; } - @Override public SearchShardTarget shard() { + @Override + public SearchShardTarget shard() { return shard; } - @Override public SearchShardTarget getShard() { + @Override + public SearchShardTarget getShard() { return shard(); } @@ -293,7 +322,8 @@ public class InternalSearchHit implements SearchHit { return this.matchedFilters; } - @Override public String[] getMatchedFilters() { + @Override + public String[] getMatchedFilters() { return this.matchedFilters; } @@ -313,7 +343,8 @@ public class InternalSearchHit implements SearchHit { static final XContentBuilderString DETAILS = new XContentBuilderString("details"); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); if (explanation() != null) { builder.field("_shard", shard.shardId()); @@ -411,7 +442,8 @@ public class InternalSearchHit implements SearchHit { return hit; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { readFrom(in, InternalSearchHits.streamContext().streamShardTarget(InternalSearchHits.StreamContext.ShardTargetType.STREAM)); } @@ -544,7 +576,8 @@ public class InternalSearchHit implements SearchHit { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { writeTo(out, InternalSearchHits.streamContext().streamShardTarget(InternalSearchHits.StreamContext.ShardTargetType.STREAM)); } diff --git a/src/main/java/org/elasticsearch/search/internal/InternalSearchHitField.java b/src/main/java/org/elasticsearch/search/internal/InternalSearchHitField.java index af89fe9b3f6..20bd5fd2cec 100644 --- a/src/main/java/org/elasticsearch/search/internal/InternalSearchHitField.java +++ b/src/main/java/org/elasticsearch/search/internal/InternalSearchHitField.java @@ -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.Iterator; import java.util.List; /** - * @author kimchy (Shay Banon) + * */ public class InternalSearchHitField implements SearchHitField { @@ -51,18 +51,21 @@ public class InternalSearchHitField implements SearchHitField { return name; } - @Override public String getName() { + @Override + public String getName() { return name(); } - @Override public Object value() { + @Override + public Object value() { if (values == null || values.isEmpty()) { return null; } return values.get(0); } - @Override public Object getValue() { + @Override + public Object getValue() { return value(); } @@ -70,12 +73,14 @@ public class InternalSearchHitField implements SearchHitField { return values; } - @Override public List getValues() { + @Override + public List getValues() { return values(); } - @Override public Iterator iterator() { + @Override + public Iterator iterator() { return values.iterator(); } @@ -85,7 +90,8 @@ public class InternalSearchHitField implements SearchHitField { return result; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { name = in.readUTF(); int size = in.readVInt(); values = new ArrayList(size); @@ -94,7 +100,8 @@ public class InternalSearchHitField implements SearchHitField { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(name); out.writeVInt(values.size()); for (Object value : values) { diff --git a/src/main/java/org/elasticsearch/search/internal/InternalSearchHits.java b/src/main/java/org/elasticsearch/search/internal/InternalSearchHits.java index de66daa6fb7..d7acede5405 100644 --- a/src/main/java/org/elasticsearch/search/internal/InternalSearchHits.java +++ b/src/main/java/org/elasticsearch/search/internal/InternalSearchHits.java @@ -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,11 +19,11 @@ package org.elasticsearch.search.internal; -import org.elasticsearch.common.collect.Iterators; +import com.google.common.collect.Iterators; +import gnu.trove.map.hash.TIntObjectHashMap; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.thread.ThreadLocals; -import org.elasticsearch.common.trove.map.hash.TIntObjectHashMap; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilderString; import org.elasticsearch.search.SearchHit; @@ -35,11 +35,11 @@ import java.util.IdentityHashMap; import java.util.Iterator; import java.util.Map; -import static org.elasticsearch.search.SearchShardTarget.*; -import static org.elasticsearch.search.internal.InternalSearchHit.*; +import static org.elasticsearch.search.SearchShardTarget.readSearchShardTarget; +import static org.elasticsearch.search.internal.InternalSearchHit.readSearchHit; /** - * @author kimchy (shay.banon) + * */ public class InternalSearchHits implements SearchHits { @@ -81,7 +81,8 @@ public class InternalSearchHits implements SearchHits { } private static final ThreadLocal> cache = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { + @Override + protected ThreadLocals.CleanableValue initialValue() { return new ThreadLocals.CleanableValue(new StreamContext()); } }; @@ -119,15 +120,18 @@ public class InternalSearchHits implements SearchHits { return totalHits; } - @Override public long getTotalHits() { + @Override + public long getTotalHits() { return totalHits(); } - @Override public float maxScore() { + @Override + public float maxScore() { return this.maxScore; } - @Override public float getMaxScore() { + @Override + public float getMaxScore() { return maxScore(); } @@ -135,15 +139,18 @@ public class InternalSearchHits implements SearchHits { return this.hits; } - @Override public SearchHit getAt(int position) { + @Override + public SearchHit getAt(int position) { return hits[position]; } - @Override public SearchHit[] getHits() { + @Override + public SearchHit[] getHits() { return hits(); } - @Override public Iterator iterator() { + @Override + public Iterator iterator() { return Iterators.forArray(hits()); } @@ -157,7 +164,8 @@ public class InternalSearchHits implements SearchHits { static final XContentBuilderString MAX_SCORE = new XContentBuilderString("max_score"); } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(Fields.HITS); builder.field(Fields.TOTAL, totalHits); if (Float.isNaN(maxScore)) { @@ -187,7 +195,8 @@ public class InternalSearchHits implements SearchHits { return hits; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { readFrom(in, streamContext().streamShardTarget(StreamContext.ShardTargetType.LOOKUP)); } @@ -213,7 +222,8 @@ public class InternalSearchHits implements SearchHits { } } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { writeTo(out, streamContext().streamShardTarget(StreamContext.ShardTargetType.LOOKUP)); } diff --git a/src/main/java/org/elasticsearch/search/internal/InternalSearchRequest.java b/src/main/java/org/elasticsearch/search/internal/InternalSearchRequest.java index 430e1ee5726..20f6013d930 100644 --- a/src/main/java/org/elasticsearch/search/internal/InternalSearchRequest.java +++ b/src/main/java/org/elasticsearch/search/internal/InternalSearchRequest.java @@ -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,8 +31,8 @@ import org.elasticsearch.search.Scroll; import java.io.IOException; -import static org.elasticsearch.common.unit.TimeValue.*; -import static org.elasticsearch.search.Scroll.*; +import static org.elasticsearch.common.unit.TimeValue.readTimeValue; +import static org.elasticsearch.search.Scroll.readScroll; /** * Source structure: @@ -51,7 +51,7 @@ import static org.elasticsearch.search.Scroll.*; * } * * - * @author kimchy (shay.banon) + * */ public class InternalSearchRequest implements Streamable { @@ -196,7 +196,8 @@ public class InternalSearchRequest implements Streamable { this.types = types; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { index = in.readUTF(); shardId = in.readVInt(); searchType = SearchType.fromId(in.readByte()); @@ -242,7 +243,8 @@ public class InternalSearchRequest implements Streamable { nowInMillis = in.readVLong(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(index); out.writeVInt(shardId); out.writeByte(searchType.id()); diff --git a/src/main/java/org/elasticsearch/search/internal/InternalSearchResponse.java b/src/main/java/org/elasticsearch/search/internal/InternalSearchResponse.java index aaf476150fb..75c705a0e56 100644 --- a/src/main/java/org/elasticsearch/search/internal/InternalSearchResponse.java +++ b/src/main/java/org/elasticsearch/search/internal/InternalSearchResponse.java @@ -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,10 +30,10 @@ import org.elasticsearch.search.facet.InternalFacets; import java.io.IOException; -import static org.elasticsearch.search.internal.InternalSearchHits.*; +import static org.elasticsearch.search.internal.InternalSearchHits.readSearchHits; /** - * @author kimchy (shay.banon) + * */ public class InternalSearchResponse implements Streamable, ToXContent { @@ -66,7 +66,8 @@ public class InternalSearchResponse implements Streamable, ToXContent { return facets; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { hits.toXContent(builder, params); if (facets != null) { facets.toXContent(builder, params); @@ -80,7 +81,8 @@ public class InternalSearchResponse implements Streamable, ToXContent { return response; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { hits = readSearchHits(in); if (in.readBoolean()) { facets = InternalFacets.readFacets(in); @@ -88,7 +90,8 @@ public class InternalSearchResponse implements Streamable, ToXContent { timedOut = in.readBoolean(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { hits.writeTo(out); if (facets == null) { out.writeBoolean(false); diff --git a/src/main/java/org/elasticsearch/search/internal/ScopePhase.java b/src/main/java/org/elasticsearch/search/internal/ScopePhase.java index f8c4337f460..b690f01c102 100644 --- a/src/main/java/org/elasticsearch/search/internal/ScopePhase.java +++ b/src/main/java/org/elasticsearch/search/internal/ScopePhase.java @@ -24,7 +24,7 @@ import org.apache.lucene.search.Query; import org.apache.lucene.search.TopDocs; /** - * @author kimchy (shay.banon) + * */ public interface ScopePhase { diff --git a/src/main/java/org/elasticsearch/search/internal/SearchContext.java b/src/main/java/org/elasticsearch/search/internal/SearchContext.java index c55bab45115..cd55ab5bba6 100644 --- a/src/main/java/org/elasticsearch/search/internal/SearchContext.java +++ b/src/main/java/org/elasticsearch/search/internal/SearchContext.java @@ -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,14 +19,14 @@ package org.elasticsearch.search.internal; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; import org.apache.lucene.search.Filter; import org.apache.lucene.search.Query; import org.apache.lucene.search.Sort; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.action.search.SearchType; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.lease.Releasable; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.index.analysis.AnalysisService; @@ -61,7 +61,7 @@ import java.util.List; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class SearchContext implements Releasable { @@ -177,7 +177,8 @@ public class SearchContext implements Releasable { this.searcher = new ContextIndexSearcher(this, engineSearcher); } - @Override public boolean release() throws ElasticSearchException { + @Override + public boolean release() throws ElasticSearchException { // clear and scope phase we have if (scopePhases != null) { for (ScopePhase scopePhase : scopePhases) { @@ -441,7 +442,8 @@ public class SearchContext implements Releasable { this.explain = explain; } - @Nullable public List groupStats() { + @Nullable + public List groupStats() { return this.groupStats; } diff --git a/src/main/java/org/elasticsearch/search/lookup/DocLookup.java b/src/main/java/org/elasticsearch/search/lookup/DocLookup.java index 75e6aaefb72..fb5fa9066ea 100644 --- a/src/main/java/org/elasticsearch/search/lookup/DocLookup.java +++ b/src/main/java/org/elasticsearch/search/lookup/DocLookup.java @@ -19,11 +19,11 @@ package org.elasticsearch.search.lookup; +import com.google.common.collect.Maps; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.Scorer; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.ElasticSearchIllegalArgumentException; -import org.elasticsearch.common.collect.Maps; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.DocFieldData; import org.elasticsearch.index.field.data.FieldData; @@ -37,7 +37,7 @@ import java.util.Map; import java.util.Set; /** - * @author kimchy (shay.banon) + * */ public class DocLookup implements Map { @@ -91,7 +91,8 @@ public class DocLookup implements Map { return scorer.score(); } - @Override public Object get(Object key) { + @Override + public Object get(Object key) { // assume its a string... String fieldName = key.toString(); FieldData fieldData = localCacheFieldData.get(fieldName); diff --git a/src/main/java/org/elasticsearch/search/lookup/FieldLookup.java b/src/main/java/org/elasticsearch/search/lookup/FieldLookup.java index 7952c637856..165497c45f1 100644 --- a/src/main/java/org/elasticsearch/search/lookup/FieldLookup.java +++ b/src/main/java/org/elasticsearch/search/lookup/FieldLookup.java @@ -27,7 +27,7 @@ import java.util.ArrayList; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class FieldLookup { diff --git a/src/main/java/org/elasticsearch/search/lookup/FieldsLookup.java b/src/main/java/org/elasticsearch/search/lookup/FieldsLookup.java index 337c8b9cc4b..d556c330c3a 100644 --- a/src/main/java/org/elasticsearch/search/lookup/FieldsLookup.java +++ b/src/main/java/org/elasticsearch/search/lookup/FieldsLookup.java @@ -19,10 +19,10 @@ package org.elasticsearch.search.lookup; +import com.google.common.collect.Maps; import org.apache.lucene.index.IndexReader; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.ElasticSearchParseException; -import org.elasticsearch.common.collect.Maps; import org.elasticsearch.common.lucene.document.SingleFieldSelector; import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.MapperService; @@ -33,7 +33,7 @@ import java.util.Map; import java.util.Set; /** - * @author kimchy (shay.banon) + * */ public class FieldsLookup implements Map { @@ -69,11 +69,13 @@ public class FieldsLookup implements Map { } - @Override public Object get(Object key) { + @Override + public Object get(Object key) { return loadFieldData(key.toString()); } - @Override public boolean containsKey(Object key) { + @Override + public boolean containsKey(Object key) { try { loadFieldData(key.toString()); return true; @@ -82,43 +84,53 @@ public class FieldsLookup implements Map { } } - @Override public int size() { + @Override + public int size() { throw new UnsupportedOperationException(); } - @Override public boolean isEmpty() { + @Override + public boolean isEmpty() { throw new UnsupportedOperationException(); } - @Override public Set keySet() { + @Override + public Set keySet() { throw new UnsupportedOperationException(); } - @Override public Collection values() { + @Override + public Collection values() { throw new UnsupportedOperationException(); } - @Override public Set entrySet() { + @Override + public Set entrySet() { throw new UnsupportedOperationException(); } - @Override public Object put(Object key, Object value) { + @Override + public Object put(Object key, Object value) { throw new UnsupportedOperationException(); } - @Override public Object remove(Object key) { + @Override + public Object remove(Object key) { throw new UnsupportedOperationException(); } - @Override public void clear() { + @Override + public void clear() { throw new UnsupportedOperationException(); } - @Override public void putAll(Map m) { + @Override + public void putAll(Map m) { throw new UnsupportedOperationException(); } - @Override public boolean containsValue(Object value) { + @Override + public boolean containsValue(Object value) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/org/elasticsearch/search/lookup/SearchLookup.java b/src/main/java/org/elasticsearch/search/lookup/SearchLookup.java index 15757b17d03..2c07e507f40 100644 --- a/src/main/java/org/elasticsearch/search/lookup/SearchLookup.java +++ b/src/main/java/org/elasticsearch/search/lookup/SearchLookup.java @@ -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,14 +19,14 @@ package org.elasticsearch.search.lookup; +import com.google.common.collect.ImmutableMap; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.Scorer; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.mapper.MapperService; /** - * @author kimchy (shay.banon) + * */ public class SearchLookup { diff --git a/src/main/java/org/elasticsearch/search/lookup/SourceLookup.java b/src/main/java/org/elasticsearch/search/lookup/SourceLookup.java index e61ec5bc915..7047c06f432 100644 --- a/src/main/java/org/elasticsearch/search/lookup/SourceLookup.java +++ b/src/main/java/org/elasticsearch/search/lookup/SourceLookup.java @@ -19,11 +19,11 @@ package org.elasticsearch.search.lookup; +import com.google.common.collect.ImmutableMap; import org.apache.lucene.document.Document; import org.apache.lucene.document.Fieldable; import org.apache.lucene.index.IndexReader; import org.elasticsearch.ElasticSearchParseException; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.support.XContentMapValues; @@ -36,7 +36,7 @@ import java.util.Map; import java.util.Set; /** - * @author kimchy (shay.banon) + * */ // TODO: If we are processing it in the per hit fetch phase, we cna initialize it with a source if it was loaded.. public class SourceLookup implements Map { @@ -111,51 +111,63 @@ public class SourceLookup implements Map { return XContentMapValues.extractValue(path, loadSourceIfNeeded()); } - @Override public Object get(Object key) { + @Override + public Object get(Object key) { return loadSourceIfNeeded().get(key); } - @Override public int size() { + @Override + public int size() { return loadSourceIfNeeded().size(); } - @Override public boolean isEmpty() { + @Override + public boolean isEmpty() { return loadSourceIfNeeded().isEmpty(); } - @Override public boolean containsKey(Object key) { + @Override + public boolean containsKey(Object key) { return loadSourceIfNeeded().containsKey(key); } - @Override public boolean containsValue(Object value) { + @Override + public boolean containsValue(Object value) { return loadSourceIfNeeded().containsValue(value); } - @Override public Set keySet() { + @Override + public Set keySet() { return loadSourceIfNeeded().keySet(); } - @Override public Collection values() { + @Override + public Collection values() { return loadSourceIfNeeded().values(); } - @Override public Set entrySet() { + @Override + public Set entrySet() { return loadSourceIfNeeded().entrySet(); } - @Override public Object put(Object key, Object value) { + @Override + public Object put(Object key, Object value) { throw new UnsupportedOperationException(); } - @Override public Object remove(Object key) { + @Override + public Object remove(Object key) { throw new UnsupportedOperationException(); } - @Override public void putAll(Map m) { + @Override + public void putAll(Map m) { throw new UnsupportedOperationException(); } - @Override public void clear() { + @Override + public void clear() { throw new UnsupportedOperationException(); } } diff --git a/src/main/java/org/elasticsearch/search/query/FilterBinaryParseElement.java b/src/main/java/org/elasticsearch/search/query/FilterBinaryParseElement.java index d3a59358d7d..5f0bac94ce1 100644 --- a/src/main/java/org/elasticsearch/search/query/FilterBinaryParseElement.java +++ b/src/main/java/org/elasticsearch/search/query/FilterBinaryParseElement.java @@ -25,11 +25,12 @@ import org.elasticsearch.search.SearchParseElement; import org.elasticsearch.search.internal.SearchContext; /** - * @author kimchy (shay.banon) + * */ public class FilterBinaryParseElement implements SearchParseElement { - @Override public void parse(XContentParser parser, SearchContext context) throws Exception { + @Override + public void parse(XContentParser parser, SearchContext context) throws Exception { byte[] filterSource = parser.binaryValue(); XContentParser fSourceParser = XContentFactory.xContent(filterSource).createParser(filterSource); try { diff --git a/src/main/java/org/elasticsearch/search/query/FilterParseElement.java b/src/main/java/org/elasticsearch/search/query/FilterParseElement.java index 0121e1e0521..64b0948ec3d 100644 --- a/src/main/java/org/elasticsearch/search/query/FilterParseElement.java +++ b/src/main/java/org/elasticsearch/search/query/FilterParseElement.java @@ -24,11 +24,12 @@ import org.elasticsearch.search.SearchParseElement; import org.elasticsearch.search.internal.SearchContext; /** - * @author kimchy (shay.banon) + * */ public class FilterParseElement implements SearchParseElement { - @Override public void parse(XContentParser parser, SearchContext context) throws Exception { + @Override + public void parse(XContentParser parser, SearchContext context) throws Exception { context.parsedFilter(context.queryParserService().parseInnerFilter(parser)); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/search/query/FromParseElement.java b/src/main/java/org/elasticsearch/search/query/FromParseElement.java index 3324417f7c6..5debdd3b25d 100644 --- a/src/main/java/org/elasticsearch/search/query/FromParseElement.java +++ b/src/main/java/org/elasticsearch/search/query/FromParseElement.java @@ -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,11 +25,12 @@ import org.elasticsearch.search.SearchParseException; import org.elasticsearch.search.internal.SearchContext; /** - * @author kimchy (shay.banon) + * */ public class FromParseElement implements SearchParseElement { - @Override public void parse(XContentParser parser, SearchContext context) throws Exception { + @Override + public void parse(XContentParser parser, SearchContext context) throws Exception { XContentParser.Token token = parser.currentToken(); if (token.isValue()) { int from = parser.intValue(); diff --git a/src/main/java/org/elasticsearch/search/query/IndicesBoostParseElement.java b/src/main/java/org/elasticsearch/search/query/IndicesBoostParseElement.java index f55d343c260..6749f9f9c11 100644 --- a/src/main/java/org/elasticsearch/search/query/IndicesBoostParseElement.java +++ b/src/main/java/org/elasticsearch/search/query/IndicesBoostParseElement.java @@ -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,11 +33,12 @@ import org.elasticsearch.search.internal.SearchContext; * } * * - * @author kimchy (shay.banon) + * */ public class IndicesBoostParseElement implements SearchParseElement { - @Override public void parse(XContentParser parser, SearchContext context) throws Exception { + @Override + public void parse(XContentParser parser, SearchContext context) throws Exception { XContentParser.Token token; while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { if (token == XContentParser.Token.FIELD_NAME) { diff --git a/src/main/java/org/elasticsearch/search/query/MinScoreParseElement.java b/src/main/java/org/elasticsearch/search/query/MinScoreParseElement.java index 0465441d743..3dd538e78c4 100644 --- a/src/main/java/org/elasticsearch/search/query/MinScoreParseElement.java +++ b/src/main/java/org/elasticsearch/search/query/MinScoreParseElement.java @@ -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,11 +24,12 @@ import org.elasticsearch.search.SearchParseElement; import org.elasticsearch.search.internal.SearchContext; /** - * @author kimchy (shay.banon) + * */ public class MinScoreParseElement implements SearchParseElement { - @Override public void parse(XContentParser parser, SearchContext context) throws Exception { + @Override + public void parse(XContentParser parser, SearchContext context) throws Exception { XContentParser.Token token = parser.currentToken(); if (token.isValue()) { context.minimumScore(parser.floatValue()); diff --git a/src/main/java/org/elasticsearch/search/query/QueryBinaryParseElement.java b/src/main/java/org/elasticsearch/search/query/QueryBinaryParseElement.java index a5f16e630c3..20ee56fac29 100644 --- a/src/main/java/org/elasticsearch/search/query/QueryBinaryParseElement.java +++ b/src/main/java/org/elasticsearch/search/query/QueryBinaryParseElement.java @@ -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,11 +25,12 @@ import org.elasticsearch.search.SearchParseElement; import org.elasticsearch.search.internal.SearchContext; /** - * @author kimchy (shay.banon) + * */ public class QueryBinaryParseElement implements SearchParseElement { - @Override public void parse(XContentParser parser, SearchContext context) throws Exception { + @Override + public void parse(XContentParser parser, SearchContext context) throws Exception { byte[] querySource = parser.binaryValue(); XContentParser qSourceParser = XContentFactory.xContent(querySource).createParser(querySource); try { diff --git a/src/main/java/org/elasticsearch/search/query/QueryParseElement.java b/src/main/java/org/elasticsearch/search/query/QueryParseElement.java index 20e91188b41..a7950b743bb 100644 --- a/src/main/java/org/elasticsearch/search/query/QueryParseElement.java +++ b/src/main/java/org/elasticsearch/search/query/QueryParseElement.java @@ -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,11 +24,12 @@ import org.elasticsearch.search.SearchParseElement; import org.elasticsearch.search.internal.SearchContext; /** - * @author kimchy (shay.banon) + * */ public class QueryParseElement implements SearchParseElement { - @Override public void parse(XContentParser parser, SearchContext context) throws Exception { + @Override + public void parse(XContentParser parser, SearchContext context) throws Exception { context.parsedQuery(context.queryParserService().parse(parser)); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/search/query/QueryPhase.java b/src/main/java/org/elasticsearch/search/query/QueryPhase.java index ea6c937deb2..04d6b8aaa80 100644 --- a/src/main/java/org/elasticsearch/search/query/QueryPhase.java +++ b/src/main/java/org/elasticsearch/search/query/QueryPhase.java @@ -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,17 +19,10 @@ package org.elasticsearch.search.query; +import com.google.common.collect.ImmutableMap; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.search.Collector; -import org.apache.lucene.search.Filter; -import org.apache.lucene.search.FilteredQuery; -import org.apache.lucene.search.Query; -import org.apache.lucene.search.ScoreDoc; -import org.apache.lucene.search.Scorer; -import org.apache.lucene.search.SortField; -import org.apache.lucene.search.TopDocs; +import org.apache.lucene.search.*; import org.elasticsearch.action.search.SearchType; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.lucene.search.function.BoostScoreFunction; import org.elasticsearch.common.lucene.search.function.FunctionScoreQuery; @@ -48,17 +41,19 @@ import java.util.ArrayList; import java.util.Map; /** - * @author kimchy (Shay Banon) + * */ public class QueryPhase implements SearchPhase { private final FacetPhase facetPhase; - @Inject public QueryPhase(FacetPhase facetPhase) { + @Inject + public QueryPhase(FacetPhase facetPhase) { this.facetPhase = facetPhase; } - @Override public Map parseElements() { + @Override + public Map parseElements() { ImmutableMap.Builder parseElements = ImmutableMap.builder(); parseElements.put("from", new FromParseElement()).put("size", new SizeParseElement()) .put("indices_boost", new IndicesBoostParseElement()) @@ -78,7 +73,8 @@ public class QueryPhase implements SearchPhase { return parseElements.build(); } - @Override public void preProcess(SearchContext context) { + @Override + public void preProcess(SearchContext context) { if (context.query() == null) { context.parsedQuery(ParsedQuery.MATCH_ALL_PARSED_QUERY); } @@ -230,17 +226,21 @@ public class QueryPhase implements SearchPhase { private int totalHits = 0; - @Override public void setScorer(Scorer scorer) throws IOException { + @Override + public void setScorer(Scorer scorer) throws IOException { } - @Override public void collect(int doc) throws IOException { + @Override + public void collect(int doc) throws IOException { totalHits++; } - @Override public void setNextReader(IndexReader reader, int docBase) throws IOException { + @Override + public void setNextReader(IndexReader reader, int docBase) throws IOException { } - @Override public boolean acceptsDocsOutOfOrder() { + @Override + public boolean acceptsDocsOutOfOrder() { return true; } @@ -278,11 +278,13 @@ public class QueryPhase implements SearchPhase { return new TopDocs(docs.size(), docs.toArray(new ScoreDoc[docs.size()]), 0f); } - @Override public void setScorer(Scorer scorer) throws IOException { + @Override + public void setScorer(Scorer scorer) throws IOException { this.scorer = scorer; } - @Override public void collect(int doc) throws IOException { + @Override + public void collect(int doc) throws IOException { if (counter >= from) { docs.add(new ScoreDoc(docBase + doc, trackScores ? scorer.score() : 0f)); } @@ -292,18 +294,21 @@ public class QueryPhase implements SearchPhase { } } - @Override public void setNextReader(IndexReader reader, int docBase) throws IOException { + @Override + public void setNextReader(IndexReader reader, int docBase) throws IOException { this.docBase = docBase; } - @Override public boolean acceptsDocsOutOfOrder() { + @Override + public boolean acceptsDocsOutOfOrder() { return true; } public static final RuntimeException StopCollectingException = new StopCollectingException(); static class StopCollectingException extends RuntimeException { - @Override public Throwable fillInStackTrace() { + @Override + public Throwable fillInStackTrace() { return null; } } diff --git a/src/main/java/org/elasticsearch/search/query/QueryPhaseExecutionException.java b/src/main/java/org/elasticsearch/search/query/QueryPhaseExecutionException.java index c3f8cc3faff..097e7f3d93e 100644 --- a/src/main/java/org/elasticsearch/search/query/QueryPhaseExecutionException.java +++ b/src/main/java/org/elasticsearch/search/query/QueryPhaseExecutionException.java @@ -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.search.SearchContextException; import org.elasticsearch.search.internal.SearchContext; /** - * @author kimchy (Shay Banon) + * */ public class QueryPhaseExecutionException extends SearchContextException { diff --git a/src/main/java/org/elasticsearch/search/query/QuerySearchRequest.java b/src/main/java/org/elasticsearch/search/query/QuerySearchRequest.java index 0869a881bac..f5f1cd050d0 100644 --- a/src/main/java/org/elasticsearch/search/query/QuerySearchRequest.java +++ b/src/main/java/org/elasticsearch/search/query/QuerySearchRequest.java @@ -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,10 +26,10 @@ import org.elasticsearch.search.dfs.AggregatedDfs; import java.io.IOException; -import static org.elasticsearch.search.dfs.AggregatedDfs.*; +import static org.elasticsearch.search.dfs.AggregatedDfs.readAggregatedDfs; /** - * @author kimchy (Shay Banon) + * */ public class QuerySearchRequest implements Streamable { @@ -53,12 +53,14 @@ public class QuerySearchRequest implements Streamable { return dfs; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { id = in.readLong(); dfs = readAggregatedDfs(in); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeLong(id); dfs.writeTo(out); } diff --git a/src/main/java/org/elasticsearch/search/query/QuerySearchResult.java b/src/main/java/org/elasticsearch/search/query/QuerySearchResult.java index beafe107789..8a574ef3aaf 100644 --- a/src/main/java/org/elasticsearch/search/query/QuerySearchResult.java +++ b/src/main/java/org/elasticsearch/search/query/QuerySearchResult.java @@ -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,11 @@ import org.elasticsearch.search.facet.InternalFacets; import java.io.IOException; -import static org.elasticsearch.common.lucene.Lucene.*; +import static org.elasticsearch.common.lucene.Lucene.readTopDocs; +import static org.elasticsearch.common.lucene.Lucene.writeTopDocs; /** - * @author kimchy (shay.banon) + * */ public class QuerySearchResult implements Streamable, QuerySearchResultProvider { @@ -59,11 +60,13 @@ public class QuerySearchResult implements Streamable, QuerySearchResultProvider this.shardTarget = shardTarget; } - @Override public boolean includeFetch() { + @Override + public boolean includeFetch() { return false; } - @Override public QuerySearchResult queryResult() { + @Override + public QuerySearchResult queryResult() { return this; } @@ -75,7 +78,8 @@ public class QuerySearchResult implements Streamable, QuerySearchResultProvider return shardTarget; } - @Override public void shardTarget(SearchShardTarget shardTarget) { + @Override + public void shardTarget(SearchShardTarget shardTarget) { this.shardTarget = shardTarget; } @@ -127,7 +131,8 @@ public class QuerySearchResult implements Streamable, QuerySearchResultProvider return result; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { id = in.readLong(); // shardTarget = readSearchShardTarget(in); from = in.readVInt(); @@ -139,7 +144,8 @@ public class QuerySearchResult implements Streamable, QuerySearchResultProvider searchTimedOut = in.readBoolean(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeLong(id); // shardTarget.writeTo(out); out.writeVInt(from); diff --git a/src/main/java/org/elasticsearch/search/query/QuerySearchResultProvider.java b/src/main/java/org/elasticsearch/search/query/QuerySearchResultProvider.java index 98431e0c373..606a8a8c61c 100644 --- a/src/main/java/org/elasticsearch/search/query/QuerySearchResultProvider.java +++ b/src/main/java/org/elasticsearch/search/query/QuerySearchResultProvider.java @@ -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.search.query; import org.elasticsearch.search.SearchPhaseResult; /** - * @author kimchy (Shay Banon) + * */ public interface QuerySearchResultProvider extends SearchPhaseResult { diff --git a/src/main/java/org/elasticsearch/search/query/ScrollQuerySearchResult.java b/src/main/java/org/elasticsearch/search/query/ScrollQuerySearchResult.java index 0ddea482e35..c73880612d3 100644 --- a/src/main/java/org/elasticsearch/search/query/ScrollQuerySearchResult.java +++ b/src/main/java/org/elasticsearch/search/query/ScrollQuerySearchResult.java @@ -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,11 +26,11 @@ import org.elasticsearch.search.SearchShardTarget; import java.io.IOException; -import static org.elasticsearch.search.SearchShardTarget.*; -import static org.elasticsearch.search.query.QuerySearchResult.*; +import static org.elasticsearch.search.SearchShardTarget.readSearchShardTarget; +import static org.elasticsearch.search.query.QuerySearchResult.readQuerySearchResult; /** - * @author kimchy (shay.banon) + * */ public class ScrollQuerySearchResult implements Streamable { @@ -54,13 +54,15 @@ public class ScrollQuerySearchResult implements Streamable { return shardTarget; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { shardTarget = readSearchShardTarget(in); queryResult = readQuerySearchResult(in); queryResult.shardTarget(shardTarget); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { shardTarget.writeTo(out); queryResult.writeTo(out); } diff --git a/src/main/java/org/elasticsearch/search/query/SizeParseElement.java b/src/main/java/org/elasticsearch/search/query/SizeParseElement.java index bd6433dc1cf..04c4d481332 100644 --- a/src/main/java/org/elasticsearch/search/query/SizeParseElement.java +++ b/src/main/java/org/elasticsearch/search/query/SizeParseElement.java @@ -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,11 +25,12 @@ import org.elasticsearch.search.SearchParseException; import org.elasticsearch.search.internal.SearchContext; /** - * @author kimchy (shay.banon) + * */ public class SizeParseElement implements SearchParseElement { - @Override public void parse(XContentParser parser, SearchContext context) throws Exception { + @Override + public void parse(XContentParser parser, SearchContext context) throws Exception { XContentParser.Token token = parser.currentToken(); if (token.isValue()) { int size = parser.intValue(); diff --git a/src/main/java/org/elasticsearch/search/sort/FieldSortBuilder.java b/src/main/java/org/elasticsearch/search/sort/FieldSortBuilder.java index 8ca9d706d47..de0a8faccae 100644 --- a/src/main/java/org/elasticsearch/search/sort/FieldSortBuilder.java +++ b/src/main/java/org/elasticsearch/search/sort/FieldSortBuilder.java @@ -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.IOException; /** * A sort builder to sort based on a document field. * - * @author kimchy (shay.banon) + * */ public class FieldSortBuilder extends SortBuilder { @@ -48,7 +48,8 @@ public class FieldSortBuilder extends SortBuilder { /** * The order of sorting. Defaults to {@link SortOrder#ASC}. */ - @Override public FieldSortBuilder order(SortOrder order) { + @Override + public FieldSortBuilder order(SortOrder order) { this.order = order; return this; } @@ -57,12 +58,14 @@ public class FieldSortBuilder extends SortBuilder { * Sets the value when a field is missing in a doc. Can also be set to _last or * _first to sort missing last or first respectively. */ - @Override public FieldSortBuilder missing(Object missing) { + @Override + public FieldSortBuilder missing(Object missing) { this.missing = missing; return this; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(fieldName); if (order != null) { builder.field("order", order.toString()); diff --git a/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortBuilder.java b/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortBuilder.java index 352f5c2bb06..55475c58f66 100644 --- a/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortBuilder.java +++ b/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortBuilder.java @@ -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; /** * A geo distance based sorting on a geo point like field. * - * @author kimchy (shay.banon) + * */ public class GeoDistanceSortBuilder extends SortBuilder { @@ -90,7 +90,8 @@ public class GeoDistanceSortBuilder extends SortBuilder { /** * The order of sorting. Defaults to {@link SortOrder#ASC}. */ - @Override public GeoDistanceSortBuilder order(SortOrder order) { + @Override + public GeoDistanceSortBuilder order(SortOrder order) { this.order = order; return this; } @@ -98,11 +99,13 @@ public class GeoDistanceSortBuilder extends SortBuilder { /** * Not relevant. */ - @Override public SortBuilder missing(Object missing) { + @Override + public SortBuilder missing(Object missing) { return this; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject("_geo_distance"); if (geohash != null) { diff --git a/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortParser.java b/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortParser.java index 1bbd7270643..c4e7b892f65 100644 --- a/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortParser.java +++ b/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortParser.java @@ -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,15 +30,17 @@ import org.elasticsearch.index.search.geo.GeoUtils; import org.elasticsearch.search.internal.SearchContext; /** - * @author kimchy (shay.banon) + * */ public class GeoDistanceSortParser implements SortParser { - @Override public String[] names() { + @Override + public String[] names() { return new String[]{"_geo_distance", "_geoDistance"}; } - @Override public SortField parse(XContentParser parser, SearchContext context) throws Exception { + @Override + public SortField parse(XContentParser parser, SearchContext context) throws Exception { String fieldName = null; double lat = Double.NaN; double lon = Double.NaN; diff --git a/src/main/java/org/elasticsearch/search/sort/ScoreSortBuilder.java b/src/main/java/org/elasticsearch/search/sort/ScoreSortBuilder.java index f1861626c12..3d81780e143 100644 --- a/src/main/java/org/elasticsearch/search/sort/ScoreSortBuilder.java +++ b/src/main/java/org/elasticsearch/search/sort/ScoreSortBuilder.java @@ -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.IOException; /** * A sort builder allowing to sort by score. * - * @author kimchy (shay.banon) + * */ public class ScoreSortBuilder extends SortBuilder { @@ -35,16 +35,19 @@ public class ScoreSortBuilder extends SortBuilder { /** * The order of sort scoring. By default, its {@link SortOrder#DESC}. */ - @Override public ScoreSortBuilder order(SortOrder order) { + @Override + public ScoreSortBuilder order(SortOrder order) { this.order = order; return this; } - @Override public SortBuilder missing(Object missing) { + @Override + public SortBuilder missing(Object missing) { return this; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject("_score"); if (order == SortOrder.ASC) { builder.field("reverse", true); diff --git a/src/main/java/org/elasticsearch/search/sort/ScriptSortBuilder.java b/src/main/java/org/elasticsearch/search/sort/ScriptSortBuilder.java index c887d2d0702..ef96fc8c339 100644 --- a/src/main/java/org/elasticsearch/search/sort/ScriptSortBuilder.java +++ b/src/main/java/org/elasticsearch/search/sort/ScriptSortBuilder.java @@ -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,7 +19,7 @@ package org.elasticsearch.search.sort; -import org.elasticsearch.common.collect.Maps; +import com.google.common.collect.Maps; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; @@ -28,7 +28,7 @@ import java.util.Map; /** * Script sort builder allows to sort based on a custom script expression. * - * @author kimchy (shay.banon) + * */ public class ScriptSortBuilder extends SortBuilder { @@ -70,7 +70,8 @@ public class ScriptSortBuilder extends SortBuilder { /** * Sets the sort order. */ - @Override public ScriptSortBuilder order(SortOrder order) { + @Override + public ScriptSortBuilder order(SortOrder order) { this.order = order; return this; } @@ -78,7 +79,8 @@ public class ScriptSortBuilder extends SortBuilder { /** * Not really relevant. */ - @Override public SortBuilder missing(Object missing) { + @Override + public SortBuilder missing(Object missing) { return this; } @@ -90,7 +92,8 @@ public class ScriptSortBuilder extends SortBuilder { return this; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject("_script"); builder.field("script", script); builder.field("type", type); diff --git a/src/main/java/org/elasticsearch/search/sort/ScriptSortParser.java b/src/main/java/org/elasticsearch/search/sort/ScriptSortParser.java index d3cb7ebe66c..b909a0fdd39 100644 --- a/src/main/java/org/elasticsearch/search/sort/ScriptSortParser.java +++ b/src/main/java/org/elasticsearch/search/sort/ScriptSortParser.java @@ -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,15 +31,17 @@ import org.elasticsearch.search.internal.SearchContext; import java.util.Map; /** - * @author kimchy (shay.banon) + * */ public class ScriptSortParser implements SortParser { - @Override public String[] names() { + @Override + public String[] names() { return new String[]{"_script"}; } - @Override public SortField parse(XContentParser parser, SearchContext context) throws Exception { + @Override + public SortField parse(XContentParser parser, SearchContext context) throws Exception { String script = null; String scriptLang = null; String type = null; diff --git a/src/main/java/org/elasticsearch/search/sort/SortBuilder.java b/src/main/java/org/elasticsearch/search/sort/SortBuilder.java index f193615a3ff..ff963fcad0c 100644 --- a/src/main/java/org/elasticsearch/search/sort/SortBuilder.java +++ b/src/main/java/org/elasticsearch/search/sort/SortBuilder.java @@ -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.search.sort; import org.elasticsearch.common.xcontent.ToXContent; /** - * @author kimchy (shay.banon) + * */ public abstract class SortBuilder implements ToXContent { diff --git a/src/main/java/org/elasticsearch/search/sort/SortBuilders.java b/src/main/java/org/elasticsearch/search/sort/SortBuilders.java index ed7b6103f5f..7afc5872d92 100644 --- a/src/main/java/org/elasticsearch/search/sort/SortBuilders.java +++ b/src/main/java/org/elasticsearch/search/sort/SortBuilders.java @@ -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.search.sort; /** * A set of static factory methods for {@link SortBuilder}s. * - * @author kimchy (shay.banon) + * */ public class SortBuilders { diff --git a/src/main/java/org/elasticsearch/search/sort/SortOrder.java b/src/main/java/org/elasticsearch/search/sort/SortOrder.java index 757f0fbc939..42142fcc13c 100644 --- a/src/main/java/org/elasticsearch/search/sort/SortOrder.java +++ b/src/main/java/org/elasticsearch/search/sort/SortOrder.java @@ -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,14 +22,15 @@ package org.elasticsearch.search.sort; /** * A sorting order. * - * @author kimchy (shay.banon) + * */ public enum SortOrder { /** * Ascending order. */ ASC { - @Override public String toString() { + @Override + public String toString() { return "asc"; } }, @@ -37,7 +38,8 @@ public enum SortOrder { * Descending order. */ DESC { - @Override public String toString() { + @Override + public String toString() { return "desc"; } } diff --git a/src/main/java/org/elasticsearch/search/sort/SortParseElement.java b/src/main/java/org/elasticsearch/search/sort/SortParseElement.java index dfb29b2028d..ec809692ae9 100644 --- a/src/main/java/org/elasticsearch/search/sort/SortParseElement.java +++ b/src/main/java/org/elasticsearch/search/sort/SortParseElement.java @@ -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,11 +19,11 @@ package org.elasticsearch.search.sort; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Lists; import org.apache.lucene.search.Sort; import org.apache.lucene.search.SortField; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.search.SearchParseElement; @@ -33,7 +33,7 @@ import org.elasticsearch.search.internal.SearchContext; import java.util.List; /** - * @author kimchy (shay.banon) + * */ public class SortParseElement implements SearchParseElement { @@ -60,7 +60,8 @@ public class SortParseElement implements SearchParseElement { } } - @Override public void parse(XContentParser parser, SearchContext context) throws Exception { + @Override + public void parse(XContentParser parser, SearchContext context) throws Exception { XContentParser.Token token = parser.currentToken(); List sortFields = Lists.newArrayListWithCapacity(2); if (token == XContentParser.Token.START_ARRAY) { diff --git a/src/main/java/org/elasticsearch/search/sort/SortParser.java b/src/main/java/org/elasticsearch/search/sort/SortParser.java index 402cd1d3e40..0f6b6b8eefb 100644 --- a/src/main/java/org/elasticsearch/search/sort/SortParser.java +++ b/src/main/java/org/elasticsearch/search/sort/SortParser.java @@ -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.common.xcontent.XContentParser; import org.elasticsearch.search.internal.SearchContext; /** - * @author kimchy (shay.banon) + * */ public interface SortParser { diff --git a/src/main/java/org/elasticsearch/search/sort/TrackScoresParseElement.java b/src/main/java/org/elasticsearch/search/sort/TrackScoresParseElement.java index 1c086d1bb80..d9169e450db 100644 --- a/src/main/java/org/elasticsearch/search/sort/TrackScoresParseElement.java +++ b/src/main/java/org/elasticsearch/search/sort/TrackScoresParseElement.java @@ -24,11 +24,12 @@ import org.elasticsearch.search.SearchParseElement; import org.elasticsearch.search.internal.SearchContext; /** - * @author kimchy (shay.banon) + * */ public class TrackScoresParseElement implements SearchParseElement { - @Override public void parse(XContentParser parser, SearchContext context) throws Exception { + @Override + public void parse(XContentParser parser, SearchContext context) throws Exception { XContentParser.Token token = parser.currentToken(); if (token.isValue()) { context.trackScores(parser.booleanValue()); diff --git a/src/main/java/org/elasticsearch/threadpool/ThreadPool.java b/src/main/java/org/elasticsearch/threadpool/ThreadPool.java index 048b4e6b44c..feb065d9116 100644 --- a/src/main/java/org/elasticsearch/threadpool/ThreadPool.java +++ b/src/main/java/org/elasticsearch/threadpool/ThreadPool.java @@ -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,12 @@ package org.elasticsearch.threadpool; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; +import com.google.common.util.concurrent.MoreExecutors; +import jsr166y.LinkedTransferQueue; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.Maps; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.io.FileSystemUtils; @@ -32,17 +34,16 @@ import org.elasticsearch.common.unit.SizeValue; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.concurrent.DynamicExecutors; import org.elasticsearch.common.util.concurrent.EsExecutors; -import org.elasticsearch.common.util.concurrent.MoreExecutors; -import org.elasticsearch.common.util.concurrent.jsr166y.LinkedTransferQueue; import java.util.Map; import java.util.concurrent.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.elasticsearch.common.unit.TimeValue.*; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.elasticsearch.common.unit.TimeValue.timeValueMinutes; +import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; /** - * @author kimchy (shay.banon) + * */ public class ThreadPool extends AbstractComponent { @@ -67,7 +68,8 @@ public class ThreadPool extends AbstractComponent { this(ImmutableSettings.Builder.EMPTY_SETTINGS); } - @Inject public ThreadPool(Settings settings) { + @Inject + public ThreadPool(Settings settings) { super(settings); Map groupSettings = settings.getGroups("threadpool"); @@ -213,7 +215,8 @@ public class ThreadPool extends AbstractComponent { this.runnable = runnable; } - @Override public void run() { + @Override + public void run() { try { runnable.run(); } catch (Exception e) { @@ -221,15 +224,18 @@ public class ThreadPool extends AbstractComponent { } } - @Override public int hashCode() { + @Override + public int hashCode() { return runnable.hashCode(); } - @Override public boolean equals(Object obj) { + @Override + public boolean equals(Object obj) { return runnable.equals(obj); } - @Override public String toString() { + @Override + public String toString() { return "[threaded] " + runnable.toString(); } } @@ -245,19 +251,23 @@ public class ThreadPool extends AbstractComponent { this.executor = executor; } - @Override public void run() { + @Override + public void run() { executor.execute(runnable); } - @Override public int hashCode() { + @Override + public int hashCode() { return runnable.hashCode(); } - @Override public boolean equals(Object obj) { + @Override + public boolean equals(Object obj) { return runnable.equals(obj); } - @Override public String toString() { + @Override + public String toString() { return "[threaded] " + runnable.toString(); } } @@ -280,7 +290,8 @@ public class ThreadPool extends AbstractComponent { return this.estimatedTimeInMillis; } - @Override public void run() { + @Override + public void run() { while (running) { estimatedTimeInMillis = System.currentTimeMillis(); try { diff --git a/src/main/java/org/elasticsearch/threadpool/ThreadPoolModule.java b/src/main/java/org/elasticsearch/threadpool/ThreadPoolModule.java index e9746982606..aadec3f618d 100644 --- a/src/main/java/org/elasticsearch/threadpool/ThreadPoolModule.java +++ b/src/main/java/org/elasticsearch/threadpool/ThreadPoolModule.java @@ -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.inject.AbstractModule; import org.elasticsearch.common.settings.Settings; /** - * @author kimchy (shay.banon) + * */ public class ThreadPoolModule extends AbstractModule { @@ -33,7 +33,8 @@ public class ThreadPoolModule extends AbstractModule { this.settings = settings; } - @Override protected void configure() { + @Override + protected void configure() { bind(ThreadPool.class).asEagerSingleton(); } } diff --git a/src/main/java/org/elasticsearch/transport/ActionNotFoundTransportException.java b/src/main/java/org/elasticsearch/transport/ActionNotFoundTransportException.java index a4c2fa0c2f4..98dcf9a885c 100644 --- a/src/main/java/org/elasticsearch/transport/ActionNotFoundTransportException.java +++ b/src/main/java/org/elasticsearch/transport/ActionNotFoundTransportException.java @@ -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.transport; /** * An exception indicating that a transport action was not found. * - * @author kimchy (shay.banon) + * */ public class ActionNotFoundTransportException extends TransportException { diff --git a/src/main/java/org/elasticsearch/transport/ActionTransportException.java b/src/main/java/org/elasticsearch/transport/ActionTransportException.java index 0722e4c2019..7fc154e5f0e 100644 --- a/src/main/java/org/elasticsearch/transport/ActionTransportException.java +++ b/src/main/java/org/elasticsearch/transport/ActionTransportException.java @@ -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.common.transport.TransportAddress; /** * An action invocation failure. * - * @author kimchy (shay.banon) + * */ public class ActionTransportException extends TransportException { diff --git a/src/main/java/org/elasticsearch/transport/ActionTransportRequestHandler.java b/src/main/java/org/elasticsearch/transport/ActionTransportRequestHandler.java index a1d3c1b5799..e04fed1d40a 100644 --- a/src/main/java/org/elasticsearch/transport/ActionTransportRequestHandler.java +++ b/src/main/java/org/elasticsearch/transport/ActionTransportRequestHandler.java @@ -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.transport; import org.elasticsearch.common.io.stream.Streamable; /** - * @author kimchy (Shay Banon) + * */ public interface ActionTransportRequestHandler extends TransportRequestHandler { diff --git a/src/main/java/org/elasticsearch/transport/BaseTransportRequestHandler.java b/src/main/java/org/elasticsearch/transport/BaseTransportRequestHandler.java index 9278eebac11..296b78012fc 100644 --- a/src/main/java/org/elasticsearch/transport/BaseTransportRequestHandler.java +++ b/src/main/java/org/elasticsearch/transport/BaseTransportRequestHandler.java @@ -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.common.io.stream.Streamable; /** * A simple based class that always spawns. * - * @author kimchy (Shay Banon) + * */ public abstract class BaseTransportRequestHandler implements TransportRequestHandler { diff --git a/src/main/java/org/elasticsearch/transport/BaseTransportResponseHandler.java b/src/main/java/org/elasticsearch/transport/BaseTransportResponseHandler.java index 97c2f5b2b43..41c676d7e83 100644 --- a/src/main/java/org/elasticsearch/transport/BaseTransportResponseHandler.java +++ b/src/main/java/org/elasticsearch/transport/BaseTransportResponseHandler.java @@ -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.common.io.stream.Streamable; /** * A simple based class that always spawns. * - * @author kimchy (Shay Banon) + * */ public abstract class BaseTransportResponseHandler implements TransportResponseHandler { diff --git a/src/main/java/org/elasticsearch/transport/BindTransportException.java b/src/main/java/org/elasticsearch/transport/BindTransportException.java index 9f5dc05e0da..5debde6314e 100644 --- a/src/main/java/org/elasticsearch/transport/BindTransportException.java +++ b/src/main/java/org/elasticsearch/transport/BindTransportException.java @@ -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.transport; /** - * @author kimchy (Shay Banon) + * */ public class BindTransportException extends TransportException { diff --git a/src/main/java/org/elasticsearch/transport/ConnectTransportException.java b/src/main/java/org/elasticsearch/transport/ConnectTransportException.java index 9c72e0b37ef..d84980d4bc0 100644 --- a/src/main/java/org/elasticsearch/transport/ConnectTransportException.java +++ b/src/main/java/org/elasticsearch/transport/ConnectTransportException.java @@ -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.transport; import org.elasticsearch.cluster.node.DiscoveryNode; /** - * @author kimchy (shay.banon) + * */ public class ConnectTransportException extends ActionTransportException { diff --git a/src/main/java/org/elasticsearch/transport/FailedCommunicationException.java b/src/main/java/org/elasticsearch/transport/FailedCommunicationException.java index fe2c5e9108c..028acb21b4c 100644 --- a/src/main/java/org/elasticsearch/transport/FailedCommunicationException.java +++ b/src/main/java/org/elasticsearch/transport/FailedCommunicationException.java @@ -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.transport; /** - * @author kimchy (Shay Banon) + * */ public class FailedCommunicationException extends TransportException { diff --git a/src/main/java/org/elasticsearch/transport/FutureTransportResponseHandler.java b/src/main/java/org/elasticsearch/transport/FutureTransportResponseHandler.java index ad1ffebea4f..ffd8d7d20a7 100644 --- a/src/main/java/org/elasticsearch/transport/FutureTransportResponseHandler.java +++ b/src/main/java/org/elasticsearch/transport/FutureTransportResponseHandler.java @@ -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,17 +25,20 @@ import org.elasticsearch.threadpool.ThreadPool; /** * A response handler to be used when all interaction will be done through the {@link TransportFuture}. * - * @author kimchy (Shay Banon) + * */ public abstract class FutureTransportResponseHandler extends BaseTransportResponseHandler { - @Override public void handleResponse(T response) { + @Override + public void handleResponse(T response) { } - @Override public void handleException(TransportException exp) { + @Override + public void handleException(TransportException exp) { } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } } diff --git a/src/main/java/org/elasticsearch/transport/NodeDisconnectedException.java b/src/main/java/org/elasticsearch/transport/NodeDisconnectedException.java index cf3627b4ab7..574cdb3331d 100644 --- a/src/main/java/org/elasticsearch/transport/NodeDisconnectedException.java +++ b/src/main/java/org/elasticsearch/transport/NodeDisconnectedException.java @@ -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.transport; import org.elasticsearch.cluster.node.DiscoveryNode; /** - * @author kimchy (shay.banon) + * */ public class NodeDisconnectedException extends ConnectTransportException { @@ -32,7 +32,8 @@ public class NodeDisconnectedException extends ConnectTransportException { // stack trace is meaningless... - @Override public Throwable fillInStackTrace() { + @Override + public Throwable fillInStackTrace() { return null; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/transport/NodeNotConnectedException.java b/src/main/java/org/elasticsearch/transport/NodeNotConnectedException.java index a958bb8f54b..3be67d77531 100644 --- a/src/main/java/org/elasticsearch/transport/NodeNotConnectedException.java +++ b/src/main/java/org/elasticsearch/transport/NodeNotConnectedException.java @@ -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.cluster.node.DiscoveryNode; /** * An exception indicating that a message is sent to a node that is not connected. * - * @author kimchy (shay.banon) + * */ public class NodeNotConnectedException extends ConnectTransportException { diff --git a/src/main/java/org/elasticsearch/transport/NotSerializableTransportException.java b/src/main/java/org/elasticsearch/transport/NotSerializableTransportException.java index 3ca65ddef5b..41baa3b56c7 100644 --- a/src/main/java/org/elasticsearch/transport/NotSerializableTransportException.java +++ b/src/main/java/org/elasticsearch/transport/NotSerializableTransportException.java @@ -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.transport; /** - * @author kimchy (Shay Banon) + * */ public class NotSerializableTransportException extends TransportException { @@ -28,7 +28,8 @@ public class NotSerializableTransportException extends TransportException { super(buildMessage(t)); } - @Override public Throwable fillInStackTrace() { + @Override + public Throwable fillInStackTrace() { return null; } diff --git a/src/main/java/org/elasticsearch/transport/PlainTransportFuture.java b/src/main/java/org/elasticsearch/transport/PlainTransportFuture.java index 7c9ac8b5608..2432f50ffd9 100644 --- a/src/main/java/org/elasticsearch/transport/PlainTransportFuture.java +++ b/src/main/java/org/elasticsearch/transport/PlainTransportFuture.java @@ -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,18 @@ package org.elasticsearch.transport; +import com.google.common.util.concurrent.AbstractFuture; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.ElasticSearchInterruptedException; import org.elasticsearch.ElasticSearchTimeoutException; import org.elasticsearch.common.io.stream.Streamable; -import org.elasticsearch.common.util.concurrent.AbstractFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; /** - * @author kimchy (shay.banon) + * */ public class PlainTransportFuture extends AbstractFuture implements TransportFuture, TransportResponseHandler { @@ -40,7 +40,8 @@ public class PlainTransportFuture extends AbstractFuture extends AbstractFuture extends AbstractFuture { diff --git a/src/main/java/org/elasticsearch/transport/TransportChannel.java b/src/main/java/org/elasticsearch/transport/TransportChannel.java index dae9a9624eb..355eb98804d 100644 --- a/src/main/java/org/elasticsearch/transport/TransportChannel.java +++ b/src/main/java/org/elasticsearch/transport/TransportChannel.java @@ -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.IOException; /** * A transport channel allows to send a response to a request on the channel. * - * @author kimchy (shay.banon) + * */ public interface TransportChannel { diff --git a/src/main/java/org/elasticsearch/transport/TransportConnectionListener.java b/src/main/java/org/elasticsearch/transport/TransportConnectionListener.java index 371457b0e0a..86fa4ea2030 100644 --- a/src/main/java/org/elasticsearch/transport/TransportConnectionListener.java +++ b/src/main/java/org/elasticsearch/transport/TransportConnectionListener.java @@ -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.transport; import org.elasticsearch.cluster.node.DiscoveryNode; /** - * @author kimchy (shay.banon) + * */ public interface TransportConnectionListener { diff --git a/src/main/java/org/elasticsearch/transport/TransportException.java b/src/main/java/org/elasticsearch/transport/TransportException.java index eac11a8ee6d..87d80d450cd 100644 --- a/src/main/java/org/elasticsearch/transport/TransportException.java +++ b/src/main/java/org/elasticsearch/transport/TransportException.java @@ -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.transport; import org.elasticsearch.ElasticSearchException; /** - * @author kimchy (shay.banon) + * */ public class TransportException extends ElasticSearchException { diff --git a/src/main/java/org/elasticsearch/transport/TransportFuture.java b/src/main/java/org/elasticsearch/transport/TransportFuture.java index f92ba2f5b72..b2bc236a45f 100644 --- a/src/main/java/org/elasticsearch/transport/TransportFuture.java +++ b/src/main/java/org/elasticsearch/transport/TransportFuture.java @@ -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.concurrent.Future; import java.util.concurrent.TimeUnit; /** - * @author kimchy (Shay Banon) + * */ public interface TransportFuture extends Future { diff --git a/src/main/java/org/elasticsearch/transport/TransportInfo.java b/src/main/java/org/elasticsearch/transport/TransportInfo.java index fdf0e5133da..e5aa6a1f1e5 100644 --- a/src/main/java/org/elasticsearch/transport/TransportInfo.java +++ b/src/main/java/org/elasticsearch/transport/TransportInfo.java @@ -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.io.IOException; import java.io.Serializable; /** - * @author kimchy (shay.banon) + * */ public class TransportInfo implements Streamable, Serializable, ToXContent { @@ -43,7 +43,8 @@ public class TransportInfo implements Streamable, Serializable, ToXContent { this.address = address; } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject("transport"); builder.field("bound_address", address.boundAddress().toString()); builder.field("publish_address", address.publishAddress().toString()); @@ -57,11 +58,13 @@ public class TransportInfo implements Streamable, Serializable, ToXContent { return info; } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { address = BoundTransportAddress.readBoundTransportAddress(in); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { address.writeTo(out); } diff --git a/src/main/java/org/elasticsearch/transport/TransportModule.java b/src/main/java/org/elasticsearch/transport/TransportModule.java index 8a42f475fa0..776c57347b1 100644 --- a/src/main/java/org/elasticsearch/transport/TransportModule.java +++ b/src/main/java/org/elasticsearch/transport/TransportModule.java @@ -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,7 +19,7 @@ package org.elasticsearch.transport; -import org.elasticsearch.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.inject.Modules; @@ -29,7 +29,7 @@ import org.elasticsearch.transport.local.LocalTransportModule; import org.elasticsearch.transport.netty.NettyTransportModule; /** - * @author kimchy (shay.banon) + * */ public class TransportModule extends AbstractModule implements SpawnModules { @@ -39,7 +39,8 @@ public class TransportModule extends AbstractModule implements SpawnModules { this.settings = settings; } - @Override public Iterable spawnModules() { + @Override + public Iterable spawnModules() { Class defaultTransportModule; if (settings.getAsBoolean("node.local", false)) { defaultTransportModule = LocalTransportModule.class; @@ -49,7 +50,8 @@ public class TransportModule extends AbstractModule implements SpawnModules { return ImmutableList.of(Modules.createModule(settings.getAsClass("transport.type", defaultTransportModule, "org.elasticsearch.transport.", "TransportModule"), settings)); } - @Override protected void configure() { + @Override + protected void configure() { bind(TransportService.class).asEagerSingleton(); bind(TransportServiceManagement.class).asEagerSingleton(); } diff --git a/src/main/java/org/elasticsearch/transport/TransportRequestHandler.java b/src/main/java/org/elasticsearch/transport/TransportRequestHandler.java index d07e0019e34..9986c065e63 100644 --- a/src/main/java/org/elasticsearch/transport/TransportRequestHandler.java +++ b/src/main/java/org/elasticsearch/transport/TransportRequestHandler.java @@ -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.transport; import org.elasticsearch.common.io.stream.Streamable; /** - * @author kimchy (Shay Banon) + * */ public interface TransportRequestHandler { diff --git a/src/main/java/org/elasticsearch/transport/TransportRequestOptions.java b/src/main/java/org/elasticsearch/transport/TransportRequestOptions.java index c51e8f746dd..ff6ba76e8d8 100644 --- a/src/main/java/org/elasticsearch/transport/TransportRequestOptions.java +++ b/src/main/java/org/elasticsearch/transport/TransportRequestOptions.java @@ -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.transport; import org.elasticsearch.common.unit.TimeValue; /** - * @author kimchy (shay.banon) + * */ public class TransportRequestOptions { diff --git a/src/main/java/org/elasticsearch/transport/TransportResponseHandler.java b/src/main/java/org/elasticsearch/transport/TransportResponseHandler.java index a8e71f62bd5..d40bf0e2751 100644 --- a/src/main/java/org/elasticsearch/transport/TransportResponseHandler.java +++ b/src/main/java/org/elasticsearch/transport/TransportResponseHandler.java @@ -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.transport; import org.elasticsearch.common.io.stream.Streamable; /** - * @author kimchy (Shay Banon) + * */ public interface TransportResponseHandler { diff --git a/src/main/java/org/elasticsearch/transport/TransportResponseOptions.java b/src/main/java/org/elasticsearch/transport/TransportResponseOptions.java index 501b2dcc966..deac0c83413 100644 --- a/src/main/java/org/elasticsearch/transport/TransportResponseOptions.java +++ b/src/main/java/org/elasticsearch/transport/TransportResponseOptions.java @@ -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.transport; /** - * @author kimchy (shay.banon) + * */ public class TransportResponseOptions { diff --git a/src/main/java/org/elasticsearch/transport/TransportSerializationException.java b/src/main/java/org/elasticsearch/transport/TransportSerializationException.java index 897c66c4ce3..9542a8e2c93 100644 --- a/src/main/java/org/elasticsearch/transport/TransportSerializationException.java +++ b/src/main/java/org/elasticsearch/transport/TransportSerializationException.java @@ -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.transport; /** - * @author kimchy (Shay Banon) + * */ public class TransportSerializationException extends TransportException { diff --git a/src/main/java/org/elasticsearch/transport/TransportService.java b/src/main/java/org/elasticsearch/transport/TransportService.java index 92390bd1654..9c00052d356 100644 --- a/src/main/java/org/elasticsearch/transport/TransportService.java +++ b/src/main/java/org/elasticsearch/transport/TransportService.java @@ -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.transport; +import com.google.common.collect.ImmutableMap; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.cluster.node.DiscoveryNode; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.collect.MapBuilder; import org.elasticsearch.common.component.AbstractLifecycleComponent; import org.elasticsearch.common.inject.Inject; @@ -41,10 +41,10 @@ import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.atomic.AtomicLong; -import static org.elasticsearch.common.settings.ImmutableSettings.Builder.*; +import static org.elasticsearch.common.settings.ImmutableSettings.Builder.EMPTY_SETTINGS; /** - * @author kimchy (shay.banon) + * */ public class TransportService extends AbstractLifecycleComponent { @@ -76,13 +76,15 @@ public class TransportService extends AbstractLifecycleComponenttrue to indicate that a {@link ConnectTransportException} should be thrown when * sending a message (otherwise, it will be passed to the response handler). Defaults to false. - * + *

    *

    This is useful when logic based on connect failure is needed without having to wrap the handler, * for example, in case of retries across several nodes. */ @@ -195,7 +199,8 @@ public class TransportService extends AbstractLifecycleComponent { @@ -36,17 +36,21 @@ public class VoidTransportResponseHandler implements TransportResponseHandler implements Transport { @@ -71,26 +65,31 @@ public class LocalTransport extends AbstractLifecycleComponent implem this(ImmutableSettings.Builder.EMPTY_SETTINGS, threadPool); } - @Inject public LocalTransport(Settings settings, ThreadPool threadPool) { + @Inject + public LocalTransport(Settings settings, ThreadPool threadPool) { super(settings); this.threadPool = threadPool; } - @Override public TransportAddress[] addressesFromString(String address) { + @Override + public TransportAddress[] addressesFromString(String address) { return new TransportAddress[]{new LocalTransportAddress(address)}; } - @Override public boolean addressSupported(Class address) { + @Override + public boolean addressSupported(Class address) { return LocalTransportAddress.class.equals(address); } - @Override protected void doStart() throws ElasticSearchException { + @Override + protected void doStart() throws ElasticSearchException { localAddress = new LocalTransportAddress(Long.toString(transportAddressIdGenerator.incrementAndGet())); transports.put(localAddress, this); boundAddress = new BoundTransportAddress(localAddress, localAddress); } - @Override protected void doStop() throws ElasticSearchException { + @Override + protected void doStop() throws ElasticSearchException { transports.remove(localAddress); // now, go over all the transports connected to me, and raise disconnected event for (final LocalTransport targetTransport : transports.values()) { @@ -102,26 +101,32 @@ public class LocalTransport extends AbstractLifecycleComponent implem } } - @Override protected void doClose() throws ElasticSearchException { + @Override + protected void doClose() throws ElasticSearchException { } - @Override public void transportServiceAdapter(TransportServiceAdapter transportServiceAdapter) { + @Override + public void transportServiceAdapter(TransportServiceAdapter transportServiceAdapter) { this.transportServiceAdapter = transportServiceAdapter; } - @Override public BoundTransportAddress boundAddress() { + @Override + public BoundTransportAddress boundAddress() { return boundAddress; } - @Override public boolean nodeConnected(DiscoveryNode node) { + @Override + public boolean nodeConnected(DiscoveryNode node) { return connectedNodes.containsKey(node); } - @Override public void connectToNodeLight(DiscoveryNode node) throws ConnectTransportException { + @Override + public void connectToNodeLight(DiscoveryNode node) throws ConnectTransportException { connectToNode(node); } - @Override public void connectToNode(DiscoveryNode node) throws ConnectTransportException { + @Override + public void connectToNode(DiscoveryNode node) throws ConnectTransportException { synchronized (this) { if (connectedNodes.containsKey(node)) { return; @@ -135,7 +140,8 @@ public class LocalTransport extends AbstractLifecycleComponent implem } } - @Override public void disconnectFromNode(DiscoveryNode node) { + @Override + public void disconnectFromNode(DiscoveryNode node) { synchronized (this) { LocalTransport removed = connectedNodes.remove(node); if (removed != null) { @@ -144,11 +150,13 @@ public class LocalTransport extends AbstractLifecycleComponent implem } } - @Override public long serverOpen() { + @Override + public long serverOpen() { return 0; } - @Override public void sendRequest(final DiscoveryNode node, final long requestId, final String action, final Streamable message, TransportRequestOptions options) throws IOException, TransportException { + @Override + public void sendRequest(final DiscoveryNode node, final long requestId, final String action, final Streamable message, TransportRequestOptions options) throws IOException, TransportException { CachedStreamOutput.Entry cachedEntry = CachedStreamOutput.popEntry(); try { HandlesStreamOutput stream = cachedEntry.cachedHandlesBytes(); @@ -171,7 +179,8 @@ public class LocalTransport extends AbstractLifecycleComponent implem transportServiceAdapter.sent(data.length); threadPool.cached().execute(new Runnable() { - @Override public void run() { + @Override + public void run() { targetTransport.messageReceived(data, action, LocalTransport.this, requestId); } }); @@ -250,7 +259,9 @@ public class LocalTransport extends AbstractLifecycleComponent implem return; } threadPool.executor(handler.executor()).execute(new Runnable() { - @SuppressWarnings({"unchecked"}) @Override public void run() { + @SuppressWarnings({"unchecked"}) + @Override + public void run() { try { handler.handleResponse(streamable); } catch (Exception e) { diff --git a/src/main/java/org/elasticsearch/transport/local/LocalTransportChannel.java b/src/main/java/org/elasticsearch/transport/local/LocalTransportChannel.java index b41802c360b..5536e8940cf 100644 --- a/src/main/java/org/elasticsearch/transport/local/LocalTransportChannel.java +++ b/src/main/java/org/elasticsearch/transport/local/LocalTransportChannel.java @@ -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,7 +34,7 @@ import java.io.IOException; import java.io.NotSerializableException; /** - * @author kimchy (shay.banon) + * */ public class LocalTransportChannel implements TransportChannel { @@ -54,15 +54,18 @@ public class LocalTransportChannel implements TransportChannel { this.requestId = requestId; } - @Override public String action() { + @Override + public String action() { return action; } - @Override public void sendResponse(Streamable message) throws IOException { + @Override + public void sendResponse(Streamable message) throws IOException { sendResponse(message, TransportResponseOptions.EMPTY); } - @Override public void sendResponse(Streamable message, TransportResponseOptions options) throws IOException { + @Override + public void sendResponse(Streamable message, TransportResponseOptions options) throws IOException { CachedStreamOutput.Entry cachedEntry = CachedStreamOutput.popEntry(); try { HandlesStreamOutput stream = cachedEntry.cachedHandlesBytes(); @@ -73,7 +76,8 @@ public class LocalTransportChannel implements TransportChannel { message.writeTo(stream); final byte[] data = cachedEntry.bytes().copiedByteArray(); targetTransport.threadPool().cached().execute(new Runnable() { - @Override public void run() { + @Override + public void run() { targetTransport.messageReceived(data, action, sourceTransport, null); } }); @@ -82,7 +86,8 @@ public class LocalTransportChannel implements TransportChannel { } } - @Override public void sendResponse(Throwable error) throws IOException { + @Override + public void sendResponse(Throwable error) throws IOException { CachedStreamOutput.Entry cachedEntry = CachedStreamOutput.popEntry(); try { BytesStreamOutput stream; @@ -103,7 +108,8 @@ public class LocalTransportChannel implements TransportChannel { } final byte[] data = stream.copiedByteArray(); targetTransport.threadPool().cached().execute(new Runnable() { - @Override public void run() { + @Override + public void run() { targetTransport.messageReceived(data, action, sourceTransport, null); } }); diff --git a/src/main/java/org/elasticsearch/transport/local/LocalTransportManagement.java b/src/main/java/org/elasticsearch/transport/local/LocalTransportManagement.java index 9b35f284567..ceb43f539b4 100644 --- a/src/main/java/org/elasticsearch/transport/local/LocalTransportManagement.java +++ b/src/main/java/org/elasticsearch/transport/local/LocalTransportManagement.java @@ -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,14 +24,15 @@ import org.elasticsearch.jmx.MBean; import org.elasticsearch.transport.Transport; /** - * @author kimchy (Shay Banon) + * */ @MBean(objectName = "service=transport,transportType=local", description = "Local Transport") public class LocalTransportManagement { private final LocalTransport transport; - @Inject public LocalTransportManagement(Transport transport) { + @Inject + public LocalTransportManagement(Transport transport) { this.transport = (LocalTransport) transport; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/transport/local/LocalTransportModule.java b/src/main/java/org/elasticsearch/transport/local/LocalTransportModule.java index 2249d1de7ef..79653821401 100644 --- a/src/main/java/org/elasticsearch/transport/local/LocalTransportModule.java +++ b/src/main/java/org/elasticsearch/transport/local/LocalTransportModule.java @@ -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,11 +23,12 @@ import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.transport.Transport; /** - * @author kimchy (Shay Banon) + * */ public class LocalTransportModule extends AbstractModule { - @Override protected void configure() { + @Override + protected void configure() { bind(LocalTransport.class).asEagerSingleton(); bind(Transport.class).to(LocalTransport.class).asEagerSingleton(); bind(LocalTransportManagement.class).asEagerSingleton(); diff --git a/src/main/java/org/elasticsearch/transport/netty/ChannelBufferStreamInput.java b/src/main/java/org/elasticsearch/transport/netty/ChannelBufferStreamInput.java index 5abbc863658..f32d4a70183 100644 --- a/src/main/java/org/elasticsearch/transport/netty/ChannelBufferStreamInput.java +++ b/src/main/java/org/elasticsearch/transport/netty/ChannelBufferStreamInput.java @@ -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,15 +20,15 @@ package org.elasticsearch.transport.netty; import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.netty.buffer.ChannelBuffer; +import org.jboss.netty.buffer.ChannelBuffer; import java.io.EOFException; import java.io.IOException; /** - * A Netty {@link org.elasticsearch.common.netty.buffer.ChannelBuffer} based {@link org.elasticsearch.common.io.stream.StreamInput}. + * A Netty {@link org.jboss.netty.buffer.ChannelBuffer} based {@link org.elasticsearch.common.io.stream.StreamInput}. + * * - * @author kimchy (shay.banon) */ public class ChannelBufferStreamInput extends StreamInput { @@ -53,19 +53,23 @@ public class ChannelBufferStreamInput extends StreamInput { return buffer.readerIndex() - startIndex; } - @Override public int available() throws IOException { + @Override + public int available() throws IOException { return endIndex - buffer.readerIndex(); } - @Override public void mark(int readlimit) { + @Override + public void mark(int readlimit) { buffer.markReaderIndex(); } - @Override public boolean markSupported() { + @Override + public boolean markSupported() { return true; } - @Override public int read() throws IOException { + @Override + public int read() throws IOException { if (available() == 0) { return -1; } @@ -87,7 +91,8 @@ public class ChannelBufferStreamInput extends StreamInput { return len; } - @Override public void reset() throws IOException { + @Override + public void reset() throws IOException { buffer.resetReaderIndex(); } @@ -107,21 +112,24 @@ public class ChannelBufferStreamInput extends StreamInput { } - @Override public byte readByte() throws IOException { + @Override + public byte readByte() throws IOException { if (available() == 0) { throw new EOFException(); } return buffer.readByte(); } - @Override public void readBytes(byte[] b, int offset, int len) throws IOException { + @Override + public void readBytes(byte[] b, int offset, int len) throws IOException { int read = read(b, offset, len); if (read < len) { throw new EOFException(); } } - @Override public void close() throws IOException { + @Override + public void close() throws IOException { // nothing to do here } } diff --git a/src/main/java/org/elasticsearch/transport/netty/MessageChannelHandler.java b/src/main/java/org/elasticsearch/transport/netty/MessageChannelHandler.java index 92a80322aba..71ebf872a72 100644 --- a/src/main/java/org/elasticsearch/transport/netty/MessageChannelHandler.java +++ b/src/main/java/org/elasticsearch/transport/netty/MessageChannelHandler.java @@ -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,24 +25,12 @@ import org.elasticsearch.common.io.stream.HandlesStreamInput; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.Streamable; import org.elasticsearch.common.logging.ESLogger; -import org.elasticsearch.common.netty.buffer.ChannelBuffer; -import org.elasticsearch.common.netty.buffer.ChannelBuffers; -import org.elasticsearch.common.netty.channel.Channel; -import org.elasticsearch.common.netty.channel.ChannelHandlerContext; -import org.elasticsearch.common.netty.channel.ChannelStateEvent; -import org.elasticsearch.common.netty.channel.ExceptionEvent; -import org.elasticsearch.common.netty.channel.MessageEvent; -import org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler; -import org.elasticsearch.common.netty.channel.WriteCompletionEvent; import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.transport.ActionNotFoundTransportException; -import org.elasticsearch.transport.RemoteTransportException; -import org.elasticsearch.transport.ResponseHandlerFailureTransportException; -import org.elasticsearch.transport.TransportRequestHandler; -import org.elasticsearch.transport.TransportResponseHandler; -import org.elasticsearch.transport.TransportSerializationException; -import org.elasticsearch.transport.TransportServiceAdapter; +import org.elasticsearch.transport.*; import org.elasticsearch.transport.support.TransportStreams; +import org.jboss.netty.buffer.ChannelBuffer; +import org.jboss.netty.buffer.ChannelBuffers; +import org.jboss.netty.channel.*; import java.io.IOException; import java.io.StreamCorruptedException; @@ -72,7 +60,8 @@ public class MessageChannelHandler extends SimpleChannelUpstreamHandler { this.logger = logger; } - @Override public void writeComplete(ChannelHandlerContext ctx, WriteCompletionEvent e) throws Exception { + @Override + public void writeComplete(ChannelHandlerContext ctx, WriteCompletionEvent e) throws Exception { transportServiceAdapter.sent(e.getWrittenAmount()); super.writeComplete(ctx, e); } @@ -81,7 +70,8 @@ public class MessageChannelHandler extends SimpleChannelUpstreamHandler { // to guess the size of the cumulation buffer to allocate // Also strange, is that the FrameDecoder always allocated a cumulation, even if the input bufer is enough // so we don't allocate a cumulation buffer unless we really need to here (need to post this to the mailing list) - @Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { + @Override + public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { Object m = e.getMessage(); if (!(m instanceof ChannelBuffer)) { @@ -278,7 +268,8 @@ public class MessageChannelHandler extends SimpleChannelUpstreamHandler { handler.handleException(rtx); } else { threadPool.executor(handler.executor()).execute(new Runnable() { - @Override public void run() { + @Override + public void run() { try { handler.handleException(rtx); } catch (Exception e) { @@ -317,7 +308,8 @@ public class MessageChannelHandler extends SimpleChannelUpstreamHandler { return action; } - @Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { + @Override + public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { transport.exceptionCaught(ctx, e); } @@ -331,7 +323,9 @@ public class MessageChannelHandler extends SimpleChannelUpstreamHandler { this.streamable = streamable; } - @SuppressWarnings({"unchecked"}) @Override public void run() { + @SuppressWarnings({"unchecked"}) + @Override + public void run() { try { handler.handleResponse(streamable); } catch (Exception e) { @@ -353,7 +347,9 @@ public class MessageChannelHandler extends SimpleChannelUpstreamHandler { this.action = action; } - @SuppressWarnings({"unchecked"}) @Override public void run() { + @SuppressWarnings({"unchecked"}) + @Override + public void run() { try { handler.messageReceived(streamable, transportChannel); } catch (Throwable e) { diff --git a/src/main/java/org/elasticsearch/transport/netty/NettyInternalESLogger.java b/src/main/java/org/elasticsearch/transport/netty/NettyInternalESLogger.java index f6c849f9a8d..7132d98168d 100644 --- a/src/main/java/org/elasticsearch/transport/netty/NettyInternalESLogger.java +++ b/src/main/java/org/elasticsearch/transport/netty/NettyInternalESLogger.java @@ -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,10 +20,10 @@ package org.elasticsearch.transport.netty; import org.elasticsearch.common.logging.ESLogger; -import org.elasticsearch.common.netty.logging.AbstractInternalLogger; +import org.jboss.netty.logging.AbstractInternalLogger; /** - * @author kimchy (shay.banon) + * */ public class NettyInternalESLogger extends AbstractInternalLogger { @@ -33,51 +33,63 @@ public class NettyInternalESLogger extends AbstractInternalLogger { this.logger = logger; } - @Override public boolean isDebugEnabled() { + @Override + public boolean isDebugEnabled() { return logger.isDebugEnabled(); } - @Override public boolean isInfoEnabled() { + @Override + public boolean isInfoEnabled() { return logger.isInfoEnabled(); } - @Override public boolean isWarnEnabled() { + @Override + public boolean isWarnEnabled() { return logger.isWarnEnabled(); } - @Override public boolean isErrorEnabled() { + @Override + public boolean isErrorEnabled() { return logger.isErrorEnabled(); } - @Override public void debug(String msg) { + @Override + public void debug(String msg) { logger.debug(msg); } - @Override public void debug(String msg, Throwable cause) { + @Override + public void debug(String msg, Throwable cause) { logger.debug(msg, cause); } - @Override public void info(String msg) { + @Override + public void info(String msg) { logger.info(msg); } - @Override public void info(String msg, Throwable cause) { + @Override + public void info(String msg, Throwable cause) { logger.info(msg, cause); } - @Override public void warn(String msg) { + @Override + public void warn(String msg) { logger.warn(msg); } - @Override public void warn(String msg, Throwable cause) { + @Override + public void warn(String msg, Throwable cause) { logger.warn(msg, cause); } - @Override public void error(String msg) { + @Override + public void error(String msg) { logger.error(msg); } - @Override public void error(String msg, Throwable cause) { + @Override + public void error(String msg, Throwable cause) { logger.error(msg, cause); } } diff --git a/src/main/java/org/elasticsearch/transport/netty/NettyInternalESLoggerFactory.java b/src/main/java/org/elasticsearch/transport/netty/NettyInternalESLoggerFactory.java index a7f69ac332a..95a574ba7ca 100644 --- a/src/main/java/org/elasticsearch/transport/netty/NettyInternalESLoggerFactory.java +++ b/src/main/java/org/elasticsearch/transport/netty/NettyInternalESLoggerFactory.java @@ -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,15 +20,16 @@ package org.elasticsearch.transport.netty; import org.elasticsearch.common.logging.Loggers; -import org.elasticsearch.common.netty.logging.InternalLogger; -import org.elasticsearch.common.netty.logging.InternalLoggerFactory; +import org.jboss.netty.logging.InternalLogger; +import org.jboss.netty.logging.InternalLoggerFactory; /** - * @author kimchy (shay.banon) + * */ public class NettyInternalESLoggerFactory extends InternalLoggerFactory { - @Override public InternalLogger newInstance(String name) { + @Override + public InternalLogger newInstance(String name) { return new NettyInternalESLogger(Loggers.getLogger(name)); } } diff --git a/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java b/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java index 7a8e9bbc9b9..d6efbc287be 100644 --- a/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java +++ b/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java @@ -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,35 +19,17 @@ package org.elasticsearch.transport.netty; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.ElasticSearchIllegalStateException; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.component.AbstractLifecycleComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.io.stream.CachedStreamOutput; import org.elasticsearch.common.io.stream.Streamable; import org.elasticsearch.common.netty.OpenChannelsHandler; -import org.elasticsearch.common.netty.bootstrap.ClientBootstrap; -import org.elasticsearch.common.netty.bootstrap.ServerBootstrap; -import org.elasticsearch.common.netty.buffer.ChannelBuffer; -import org.elasticsearch.common.netty.buffer.ChannelBuffers; -import org.elasticsearch.common.netty.channel.Channel; -import org.elasticsearch.common.netty.channel.ChannelFuture; -import org.elasticsearch.common.netty.channel.ChannelFutureListener; -import org.elasticsearch.common.netty.channel.ChannelHandlerContext; -import org.elasticsearch.common.netty.channel.ChannelPipeline; -import org.elasticsearch.common.netty.channel.ChannelPipelineFactory; -import org.elasticsearch.common.netty.channel.Channels; -import org.elasticsearch.common.netty.channel.ExceptionEvent; -import org.elasticsearch.common.netty.channel.socket.nio.NioClientSocketChannelFactory; -import org.elasticsearch.common.netty.channel.socket.nio.NioServerSocketChannelFactory; -import org.elasticsearch.common.netty.channel.socket.oio.OioClientSocketChannelFactory; -import org.elasticsearch.common.netty.channel.socket.oio.OioServerSocketChannelFactory; -import org.elasticsearch.common.netty.logging.InternalLogger; -import org.elasticsearch.common.netty.logging.InternalLoggerFactory; import org.elasticsearch.common.network.NetworkService; import org.elasticsearch.common.network.NetworkUtils; import org.elasticsearch.common.settings.Settings; @@ -58,24 +40,25 @@ import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.transport.BindTransportException; -import org.elasticsearch.transport.ConnectTransportException; -import org.elasticsearch.transport.NodeNotConnectedException; -import org.elasticsearch.transport.Transport; -import org.elasticsearch.transport.TransportException; -import org.elasticsearch.transport.TransportRequestOptions; -import org.elasticsearch.transport.TransportServiceAdapter; +import org.elasticsearch.transport.*; import org.elasticsearch.transport.support.TransportStreams; +import org.jboss.netty.bootstrap.ClientBootstrap; +import org.jboss.netty.bootstrap.ServerBootstrap; +import org.jboss.netty.buffer.ChannelBuffer; +import org.jboss.netty.buffer.ChannelBuffers; +import org.jboss.netty.channel.*; +import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory; +import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory; +import org.jboss.netty.channel.socket.oio.OioClientSocketChannelFactory; +import org.jboss.netty.channel.socket.oio.OioServerSocketChannelFactory; +import org.jboss.netty.logging.InternalLogger; +import org.jboss.netty.logging.InternalLoggerFactory; import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.SocketAddress; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executors; @@ -84,24 +67,26 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import static org.elasticsearch.common.network.NetworkService.TcpSettings.*; -import static org.elasticsearch.common.settings.ImmutableSettings.Builder.*; -import static org.elasticsearch.common.transport.NetworkExceptionHelper.*; -import static org.elasticsearch.common.util.concurrent.ConcurrentCollections.*; -import static org.elasticsearch.common.util.concurrent.EsExecutors.*; +import static org.elasticsearch.common.settings.ImmutableSettings.Builder.EMPTY_SETTINGS; +import static org.elasticsearch.common.transport.NetworkExceptionHelper.isCloseConnectionException; +import static org.elasticsearch.common.transport.NetworkExceptionHelper.isConnectException; +import static org.elasticsearch.common.util.concurrent.ConcurrentCollections.newConcurrentMap; +import static org.elasticsearch.common.util.concurrent.EsExecutors.daemonThreadFactory; /** * There are 3 types of connections per node, low/med/high. Low if for batch oriented APIs (like recovery or * batch) with high payload that will cause regular request. (like search or single index) to take * longer. Med is for the typical search / single doc index. And High is for ping type requests (like FD). * - * @author kimchy (shay.banon) + * */ public class NettyTransport extends AbstractLifecycleComponent implements Transport { static { InternalLoggerFactory.setDefaultFactory(new NettyInternalESLoggerFactory() { - @Override public InternalLogger newInstance(String name) { - return super.newInstance(name.replace("org.elasticsearch.common.netty.", "netty.").replace("org.jboss.netty.", "netty.")); + @Override + public InternalLogger newInstance(String name) { + return super.newInstance(name.replace("org.jboss.netty.", "netty.").replace("org.jboss.netty.", "netty.")); } }); } @@ -164,7 +149,8 @@ public class NettyTransport extends AbstractLifecycleComponent implem this(settings, threadPool, new NetworkService(settings)); } - @Inject public NettyTransport(Settings settings, ThreadPool threadPool, NetworkService networkService) { + @Inject + public NettyTransport(Settings settings, ThreadPool threadPool, NetworkService networkService) { super(settings); this.threadPool = threadPool; this.networkService = networkService; @@ -194,7 +180,8 @@ public class NettyTransport extends AbstractLifecycleComponent implem return this.settings; } - @Override public void transportServiceAdapter(TransportServiceAdapter service) { + @Override + public void transportServiceAdapter(TransportServiceAdapter service) { this.transportServiceAdapter = service; } @@ -206,7 +193,8 @@ public class NettyTransport extends AbstractLifecycleComponent implem return threadPool; } - @Override protected void doStart() throws ElasticSearchException { + @Override + protected void doStart() throws ElasticSearchException { if (blockingClient) { clientBootstrap = new ClientBootstrap(new OioClientSocketChannelFactory(Executors.newCachedThreadPool(daemonThreadFactory(settings, "transport_client_worker")))); } else { @@ -216,7 +204,8 @@ public class NettyTransport extends AbstractLifecycleComponent implem workerCount)); } ChannelPipelineFactory clientPipelineFactory = new ChannelPipelineFactory() { - @Override public ChannelPipeline getPipeline() throws Exception { + @Override + public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = Channels.pipeline(); pipeline.addLast("dispatcher", new MessageChannelHandler(NettyTransport.this, logger)); return pipeline; @@ -257,7 +246,8 @@ public class NettyTransport extends AbstractLifecycleComponent implem workerCount)); } ChannelPipelineFactory serverPipelineFactory = new ChannelPipelineFactory() { - @Override public ChannelPipeline getPipeline() throws Exception { + @Override + public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = Channels.pipeline(); pipeline.addLast("openChannels", serverOpenChannels); pipeline.addLast("dispatcher", new MessageChannelHandler(NettyTransport.this, logger)); @@ -294,7 +284,8 @@ public class NettyTransport extends AbstractLifecycleComponent implem PortsRange portsRange = new PortsRange(port); final AtomicReference lastException = new AtomicReference(); boolean success = portsRange.iterate(new PortsRange.PortCallback() { - @Override public boolean onPortNumber(int portNumber) { + @Override + public boolean onPortNumber(int portNumber) { try { serverChannel = serverBootstrap.bind(new InetSocketAddress(hostAddress, portNumber)); } catch (Exception e) { @@ -320,11 +311,13 @@ public class NettyTransport extends AbstractLifecycleComponent implem this.boundAddress = new BoundTransportAddress(new InetSocketTransportAddress(boundAddress), new InetSocketTransportAddress(publishAddress)); } - @Override protected void doStop() throws ElasticSearchException { + @Override + protected void doStop() throws ElasticSearchException { final CountDownLatch latch = new CountDownLatch(1); // make sure we run it on another thread than a possible IO handler thread threadPool.cached().execute(new Runnable() { - @Override public void run() { + @Override + public void run() { try { for (Iterator it = connectedNodes.values().iterator(); it.hasNext(); ) { NodeChannels nodeChannels = it.next(); @@ -373,10 +366,12 @@ public class NettyTransport extends AbstractLifecycleComponent implem } } - @Override protected void doClose() throws ElasticSearchException { + @Override + protected void doClose() throws ElasticSearchException { } - @Override public TransportAddress[] addressesFromString(String address) throws Exception { + @Override + public TransportAddress[] addressesFromString(String address) throws Exception { int index = address.indexOf('['); if (index != -1) { String host = address.substring(0, index); @@ -406,11 +401,13 @@ public class NettyTransport extends AbstractLifecycleComponent implem } } - @Override public boolean addressSupported(Class address) { + @Override + public boolean addressSupported(Class address) { return InetSocketTransportAddress.class.equals(address); } - @Override public BoundTransportAddress boundAddress() { + @Override + public BoundTransportAddress boundAddress() { return this.boundAddress; } @@ -439,12 +436,14 @@ public class NettyTransport extends AbstractLifecycleComponent implem return new InetSocketTransportAddress((InetSocketAddress) socketAddress); } - @Override public long serverOpen() { + @Override + public long serverOpen() { OpenChannelsHandler channels = serverOpenChannels; return channels == null ? 0 : channels.numberOfOpenChannels(); } - @Override public void sendRequest(final DiscoveryNode node, final long requestId, final String action, final Streamable message, TransportRequestOptions options) throws IOException, TransportException { + @Override + public void sendRequest(final DiscoveryNode node, final long requestId, final String action, final Streamable message, TransportRequestOptions options) throws IOException, TransportException { Channel targetChannel = nodeChannel(node, options); if (compress) { @@ -470,15 +469,18 @@ public class NettyTransport extends AbstractLifecycleComponent implem // }); } - @Override public boolean nodeConnected(DiscoveryNode node) { + @Override + public boolean nodeConnected(DiscoveryNode node) { return connectedNodes.containsKey(node); } - @Override public void connectToNodeLight(DiscoveryNode node) throws ConnectTransportException { + @Override + public void connectToNodeLight(DiscoveryNode node) throws ConnectTransportException { connectToNode(node, true); } - @Override public void connectToNode(DiscoveryNode node) { + @Override + public void connectToNode(DiscoveryNode node) { connectToNode(node, false); } @@ -618,7 +620,8 @@ public class NettyTransport extends AbstractLifecycleComponent implem } } - @Override public void disconnectFromNode(DiscoveryNode node) { + @Override + public void disconnectFromNode(DiscoveryNode node) { NodeChannels nodeChannels = connectedNodes.remove(node); if (nodeChannels != null) { try { @@ -646,7 +649,8 @@ public class NettyTransport extends AbstractLifecycleComponent implem this.node = node; } - @Override public void operationComplete(ChannelFuture future) throws Exception { + @Override + public void operationComplete(ChannelFuture future) throws Exception { disconnectFromNode(node); } } @@ -720,7 +724,8 @@ public class NettyTransport extends AbstractLifecycleComponent implem this.cachedEntry = cachedEntry; } - @Override public void operationComplete(ChannelFuture channelFuture) throws Exception { + @Override + public void operationComplete(ChannelFuture channelFuture) throws Exception { CachedStreamOutput.pushEntry(cachedEntry); } } diff --git a/src/main/java/org/elasticsearch/transport/netty/NettyTransportChannel.java b/src/main/java/org/elasticsearch/transport/netty/NettyTransportChannel.java index ec5801d02a7..8bcb5b8ec6c 100644 --- a/src/main/java/org/elasticsearch/transport/netty/NettyTransportChannel.java +++ b/src/main/java/org/elasticsearch/transport/netty/NettyTransportChannel.java @@ -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,21 +23,21 @@ import org.elasticsearch.common.io.ThrowableObjectOutputStream; import org.elasticsearch.common.io.stream.BytesStreamOutput; import org.elasticsearch.common.io.stream.CachedStreamOutput; import org.elasticsearch.common.io.stream.Streamable; -import org.elasticsearch.common.netty.buffer.ChannelBuffer; -import org.elasticsearch.common.netty.buffer.ChannelBuffers; -import org.elasticsearch.common.netty.channel.Channel; -import org.elasticsearch.common.netty.channel.ChannelFuture; import org.elasticsearch.transport.NotSerializableTransportException; import org.elasticsearch.transport.RemoteTransportException; import org.elasticsearch.transport.TransportChannel; import org.elasticsearch.transport.TransportResponseOptions; import org.elasticsearch.transport.support.TransportStreams; +import org.jboss.netty.buffer.ChannelBuffer; +import org.jboss.netty.buffer.ChannelBuffers; +import org.jboss.netty.channel.Channel; +import org.jboss.netty.channel.ChannelFuture; import java.io.IOException; import java.io.NotSerializableException; /** - * @author kimchy (shay.banon) + * */ public class NettyTransportChannel implements TransportChannel { @@ -58,15 +58,18 @@ public class NettyTransportChannel implements TransportChannel { this.requestId = requestId; } - @Override public String action() { + @Override + public String action() { return this.action; } - @Override public void sendResponse(Streamable message) throws IOException { + @Override + public void sendResponse(Streamable message) throws IOException { sendResponse(message, TransportResponseOptions.EMPTY); } - @Override public void sendResponse(Streamable message, TransportResponseOptions options) throws IOException { + @Override + public void sendResponse(Streamable message, TransportResponseOptions options) throws IOException { if (transport.compress) { options.withCompress(true); } @@ -77,7 +80,8 @@ public class NettyTransportChannel implements TransportChannel { future.addListener(new NettyTransport.CacheFutureListener(cachedEntry)); } - @Override public void sendResponse(Throwable error) throws IOException { + @Override + public void sendResponse(Throwable error) throws IOException { CachedStreamOutput.Entry cachedEntry = CachedStreamOutput.popEntry(); BytesStreamOutput stream; try { diff --git a/src/main/java/org/elasticsearch/transport/netty/NettyTransportManagement.java b/src/main/java/org/elasticsearch/transport/netty/NettyTransportManagement.java index 33e974e9fc3..e8230547b9d 100644 --- a/src/main/java/org/elasticsearch/transport/netty/NettyTransportManagement.java +++ b/src/main/java/org/elasticsearch/transport/netty/NettyTransportManagement.java @@ -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,14 +25,15 @@ import org.elasticsearch.jmx.ManagedAttribute; import org.elasticsearch.transport.Transport; /** - * @author kimchy (Shay Banon) + * */ @MBean(objectName = "service=transport,transportType=netty", description = "Netty Transport") public class NettyTransportManagement { private final NettyTransport transport; - @Inject public NettyTransportManagement(Transport transport) { + @Inject + public NettyTransportManagement(Transport transport) { this.transport = (NettyTransport) transport; } diff --git a/src/main/java/org/elasticsearch/transport/netty/NettyTransportModule.java b/src/main/java/org/elasticsearch/transport/netty/NettyTransportModule.java index 83550e90786..b0dcf421417 100644 --- a/src/main/java/org/elasticsearch/transport/netty/NettyTransportModule.java +++ b/src/main/java/org/elasticsearch/transport/netty/NettyTransportModule.java @@ -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,11 +23,12 @@ import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.transport.Transport; /** - * @author kimchy (Shay Banon) + * */ public class NettyTransportModule extends AbstractModule { - @Override protected void configure() { + @Override + protected void configure() { bind(NettyTransport.class).asEagerSingleton(); bind(Transport.class).to(NettyTransport.class).asEagerSingleton(); bind(NettyTransportManagement.class).asEagerSingleton(); diff --git a/src/main/java/org/elasticsearch/transport/support/TransportStreams.java b/src/main/java/org/elasticsearch/transport/support/TransportStreams.java index 9927037f924..2d1cf54e70d 100644 --- a/src/main/java/org/elasticsearch/transport/support/TransportStreams.java +++ b/src/main/java/org/elasticsearch/transport/support/TransportStreams.java @@ -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.transport.TransportResponseOptions; import java.io.IOException; /** - * @author kimchy (shay.banon) + * */ public class TransportStreams { diff --git a/src/test/java/org/apache/lucene/analysis/miscellaneous/TruncateTokenFilterTests.java b/src/test/java/org/apache/lucene/analysis/miscellaneous/TruncateTokenFilterTests.java index 87dfa970644..b87e9cdaa8e 100644 --- a/src/test/java/org/apache/lucene/analysis/miscellaneous/TruncateTokenFilterTests.java +++ b/src/test/java/org/apache/lucene/analysis/miscellaneous/TruncateTokenFilterTests.java @@ -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,11 +19,7 @@ package org.apache.lucene.analysis.miscellaneous; -import org.apache.lucene.analysis.Analyzer; -import org.apache.lucene.analysis.ReusableAnalyzerBase; -import org.apache.lucene.analysis.TokenStream; -import org.apache.lucene.analysis.Tokenizer; -import org.apache.lucene.analysis.WhitespaceTokenizer; +import org.apache.lucene.analysis.*; import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; import org.elasticsearch.common.lucene.Lucene; import org.testng.annotations.Test; @@ -32,15 +28,16 @@ import java.io.IOException; import java.io.Reader; import java.io.StringReader; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** */ @Test public class TruncateTokenFilterTests { - @Test public void simpleTest() throws IOException { + @Test + public void simpleTest() throws IOException { Analyzer analyzer = new ReusableAnalyzerBase() { @Override protected TokenStreamComponents createComponents(String fieldName, diff --git a/src/test/java/org/apache/lucene/analysis/miscellaneous/UniqueTokenFilterTests.java b/src/test/java/org/apache/lucene/analysis/miscellaneous/UniqueTokenFilterTests.java index 0bdbf26aee9..3b9dd3f92c4 100644 --- a/src/test/java/org/apache/lucene/analysis/miscellaneous/UniqueTokenFilterTests.java +++ b/src/test/java/org/apache/lucene/analysis/miscellaneous/UniqueTokenFilterTests.java @@ -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,11 +19,7 @@ package org.apache.lucene.analysis.miscellaneous; -import org.apache.lucene.analysis.Analyzer; -import org.apache.lucene.analysis.ReusableAnalyzerBase; -import org.apache.lucene.analysis.TokenStream; -import org.apache.lucene.analysis.Tokenizer; -import org.apache.lucene.analysis.WhitespaceTokenizer; +import org.apache.lucene.analysis.*; import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; import org.elasticsearch.common.lucene.Lucene; import org.testng.annotations.Test; @@ -32,15 +28,16 @@ import java.io.IOException; import java.io.Reader; import java.io.StringReader; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** */ @Test public class UniqueTokenFilterTests { - @Test public void simpleTest() throws IOException { + @Test + public void simpleTest() throws IOException { Analyzer analyzer = new ReusableAnalyzerBase() { @Override protected TokenStreamComponents createComponents(String fieldName, diff --git a/src/test/java/org/apache/lucene/index/memory/CustomMemoryIndexTests.java b/src/test/java/org/apache/lucene/index/memory/CustomMemoryIndexTests.java index 1917b73675f..914ed8be7ea 100644 --- a/src/test/java/org/apache/lucene/index/memory/CustomMemoryIndexTests.java +++ b/src/test/java/org/apache/lucene/index/memory/CustomMemoryIndexTests.java @@ -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,12 +25,13 @@ import org.apache.lucene.search.TermQuery; import org.elasticsearch.common.lucene.Lucene; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; public class CustomMemoryIndexTests { - @Test public void testSameFieldSeveralTimes() throws Exception { + @Test + public void testSameFieldSeveralTimes() throws Exception { CustomMemoryIndex memoryIndex = new CustomMemoryIndex(); memoryIndex.addField("field1", "value1", Lucene.KEYWORD_ANALYZER); memoryIndex.addField("field1", "value2", Lucene.KEYWORD_ANALYZER); diff --git a/src/test/java/org/elasticsearch/benchmark/checksum/ChecksumBenchmarkTest.java b/src/test/java/org/elasticsearch/benchmark/checksum/ChecksumBenchmarkTest.java index 162d8ca7368..75654eae8cc 100644 --- a/src/test/java/org/elasticsearch/benchmark/checksum/ChecksumBenchmarkTest.java +++ b/src/test/java/org/elasticsearch/benchmark/checksum/ChecksumBenchmarkTest.java @@ -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.util.zip.Adler32; import java.util.zip.CRC32; /** - * @author kimchy (shay.banon) + * */ public class ChecksumBenchmarkTest { diff --git a/src/test/java/org/elasticsearch/benchmark/common/lucene/uidscan/LuceneUidScanBenchmark.java b/src/test/java/org/elasticsearch/benchmark/common/lucene/uidscan/LuceneUidScanBenchmark.java index a6f73e548d6..b6ac579ea9c 100644 --- a/src/test/java/org/elasticsearch/benchmark/common/lucene/uidscan/LuceneUidScanBenchmark.java +++ b/src/test/java/org/elasticsearch/benchmark/common/lucene/uidscan/LuceneUidScanBenchmark.java @@ -19,6 +19,7 @@ package org.elasticsearch.benchmark.common.lucene.uidscan; +import jsr166y.ThreadLocalRandom; import org.apache.lucene.document.Document; import org.apache.lucene.index.*; import org.apache.lucene.store.FSDirectory; @@ -27,13 +28,12 @@ import org.elasticsearch.common.StopWatch; import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.common.lucene.uid.UidField; import org.elasticsearch.common.unit.SizeValue; -import org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom; import java.io.File; import java.util.concurrent.CountDownLatch; /** - * @author kimchy (shay.banon) + * */ public class LuceneUidScanBenchmark { @@ -63,7 +63,8 @@ public class LuceneUidScanBenchmark { Thread[] threads = new Thread[NUMBER_OF_THREADS]; for (int i = 0; i < threads.length; i++) { threads[i] = new Thread(new Runnable() { - @Override public void run() { + @Override + public void run() { try { for (long i = 0; i < SCAN_COUNT; i++) { long id = startUid + (Math.abs(ThreadLocalRandom.current().nextInt()) % INDEX_COUNT); diff --git a/src/test/java/org/elasticsearch/benchmark/common/lucene/versioned/VersionedMapBenchmark.java b/src/test/java/org/elasticsearch/benchmark/common/lucene/versioned/VersionedMapBenchmark.java index f1f88f93590..65c2127ffa1 100644 --- a/src/test/java/org/elasticsearch/benchmark/common/lucene/versioned/VersionedMapBenchmark.java +++ b/src/test/java/org/elasticsearch/benchmark/common/lucene/versioned/VersionedMapBenchmark.java @@ -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,10 +30,10 @@ import java.lang.management.ManagementFactory; import java.util.concurrent.CountDownLatch; import java.util.concurrent.CyclicBarrier; -import static java.util.concurrent.TimeUnit.*; +import static java.util.concurrent.TimeUnit.MILLISECONDS; /** - * @author kimchy (Shay Banon) + * */ public class VersionedMapBenchmark { @@ -131,7 +131,8 @@ public class VersionedMapBenchmark { } private class ReaderThread implements Runnable { - @Override public void run() { + @Override + public void run() { try { barrier1.await(); barrier2.await(); @@ -146,7 +147,8 @@ public class VersionedMapBenchmark { } private class WriterThread implements Runnable { - @Override public void run() { + @Override + public void run() { try { barrier1.await(); barrier2.await(); diff --git a/src/test/java/org/elasticsearch/benchmark/counter/SimpleCounterBenchmark.java b/src/test/java/org/elasticsearch/benchmark/counter/SimpleCounterBenchmark.java index 266b65404b7..9b363876159 100644 --- a/src/test/java/org/elasticsearch/benchmark/counter/SimpleCounterBenchmark.java +++ b/src/test/java/org/elasticsearch/benchmark/counter/SimpleCounterBenchmark.java @@ -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.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicLong; /** - * @author kimchy (Shay Banon) + * */ public class SimpleCounterBenchmark { @@ -46,7 +46,8 @@ public class SimpleCounterBenchmark { Thread[] threads = new Thread[NUMBER_OF_THREADS]; for (int i = 0; i < threads.length; i++) { threads[i] = new Thread(new Runnable() { - @Override public void run() { + @Override + public void run() { for (long i = 0; i < NUMBER_OF_ITERATIONS; i++) { counter.incrementAndGet(); } diff --git a/src/test/java/org/elasticsearch/benchmark/fs/FsAppendBenchmark.java b/src/test/java/org/elasticsearch/benchmark/fs/FsAppendBenchmark.java index 27f58646797..81e86528b21 100644 --- a/src/test/java/org/elasticsearch/benchmark/fs/FsAppendBenchmark.java +++ b/src/test/java/org/elasticsearch/benchmark/fs/FsAppendBenchmark.java @@ -29,7 +29,7 @@ import java.nio.channels.FileChannel; import java.util.Random; /** - * @author kimchy (shay.banon) + * */ public class FsAppendBenchmark { diff --git a/src/test/java/org/elasticsearch/benchmark/get/SimpleGetActionBenchmark.java b/src/test/java/org/elasticsearch/benchmark/get/SimpleGetActionBenchmark.java index 485a4f67c12..90132be208b 100644 --- a/src/test/java/org/elasticsearch/benchmark/get/SimpleGetActionBenchmark.java +++ b/src/test/java/org/elasticsearch/benchmark/get/SimpleGetActionBenchmark.java @@ -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 diff --git a/src/test/java/org/elasticsearch/benchmark/percolator/EmbeddedPercolatorBenchmarkTest.java b/src/test/java/org/elasticsearch/benchmark/percolator/EmbeddedPercolatorBenchmarkTest.java index 233818b2828..033135133d8 100644 --- a/src/test/java/org/elasticsearch/benchmark/percolator/EmbeddedPercolatorBenchmarkTest.java +++ b/src/test/java/org/elasticsearch/benchmark/percolator/EmbeddedPercolatorBenchmarkTest.java @@ -44,10 +44,10 @@ import org.elasticsearch.threadpool.ThreadPoolModule; import java.util.concurrent.CountDownLatch; -import static org.elasticsearch.index.query.QueryBuilders.*; +import static org.elasticsearch.index.query.QueryBuilders.termQuery; /** - * @author kimchy (shay.banon) + * */ public class EmbeddedPercolatorBenchmarkTest { @@ -74,7 +74,8 @@ public class EmbeddedPercolatorBenchmarkTest { new IndexQueryParserModule(settings), new IndexNameModule(index), new AbstractModule() { - @Override protected void configure() { + @Override + protected void configure() { bind(PercolatorExecutor.class).asEagerSingleton(); } } @@ -109,7 +110,8 @@ public class EmbeddedPercolatorBenchmarkTest { Thread[] threads = new Thread[NUMBER_OF_THREADS]; for (int i = 0; i < threads.length; i++) { threads[i] = new Thread(new Runnable() { - @Override public void run() { + @Override + public void run() { for (long i = 0; i < NUMBER_OF_ITERATIONS; i++) { PercolatorExecutor.Response percolate = percolatorExecutor.percolate(new PercolatorExecutor.SourceRequest("type1", source)); } diff --git a/src/test/java/org/elasticsearch/benchmark/percolator/SinglePercolatorStressBenchmark.java b/src/test/java/org/elasticsearch/benchmark/percolator/SinglePercolatorStressBenchmark.java index 184653b9fc5..857c5322857 100644 --- a/src/test/java/org/elasticsearch/benchmark/percolator/SinglePercolatorStressBenchmark.java +++ b/src/test/java/org/elasticsearch/benchmark/percolator/SinglePercolatorStressBenchmark.java @@ -29,15 +29,16 @@ import org.elasticsearch.node.Node; import java.io.IOException; import java.util.concurrent.TimeUnit; -import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.cluster.metadata.IndexMetaData.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.elasticsearch.common.xcontent.XContentFactory.*; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.elasticsearch.node.NodeBuilder.*; +import static org.elasticsearch.client.Requests.createIndexRequest; +import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS; +import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import static org.elasticsearch.index.query.QueryBuilders.termQuery; +import static org.elasticsearch.node.NodeBuilder.nodeBuilder; /** - * @author kimchy (shay.banon) + * */ public class SinglePercolatorStressBenchmark { diff --git a/src/test/java/org/elasticsearch/benchmark/search/child/ChildSearchBenchmark.java b/src/test/java/org/elasticsearch/benchmark/search/child/ChildSearchBenchmark.java index ff487188b2f..4935e00adbf 100644 --- a/src/test/java/org/elasticsearch/benchmark/search/child/ChildSearchBenchmark.java +++ b/src/test/java/org/elasticsearch/benchmark/search/child/ChildSearchBenchmark.java @@ -35,15 +35,16 @@ import org.elasticsearch.node.Node; import java.io.IOException; import java.util.Arrays; -import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.cluster.metadata.IndexMetaData.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.elasticsearch.common.xcontent.XContentFactory.*; +import static org.elasticsearch.client.Requests.createIndexRequest; +import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS; +import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.elasticsearch.node.NodeBuilder.*; +import static org.elasticsearch.node.NodeBuilder.nodeBuilder; /** - * @author kimchy (shay.banon) + * */ public class ChildSearchBenchmark { diff --git a/src/test/java/org/elasticsearch/benchmark/search/facet/HistogramFacetSearchBenchmark.java b/src/test/java/org/elasticsearch/benchmark/search/facet/HistogramFacetSearchBenchmark.java index a00ee73dfb2..d2b33a59474 100644 --- a/src/test/java/org/elasticsearch/benchmark/search/facet/HistogramFacetSearchBenchmark.java +++ b/src/test/java/org/elasticsearch/benchmark/search/facet/HistogramFacetSearchBenchmark.java @@ -33,16 +33,18 @@ import org.elasticsearch.node.Node; import java.util.Date; -import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.cluster.metadata.IndexMetaData.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.elasticsearch.common.xcontent.XContentFactory.*; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.elasticsearch.node.NodeBuilder.*; -import static org.elasticsearch.search.facet.FacetBuilders.*; +import static org.elasticsearch.client.Requests.createIndexRequest; +import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS; +import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; +import static org.elasticsearch.node.NodeBuilder.nodeBuilder; +import static org.elasticsearch.search.facet.FacetBuilders.dateHistogramFacet; +import static org.elasticsearch.search.facet.FacetBuilders.histogramFacet; /** - * @author kimchy (shay.banon) + * */ public class HistogramFacetSearchBenchmark { diff --git a/src/test/java/org/elasticsearch/benchmark/search/facet/QueryFilterFacetSearchBenchmark.java b/src/test/java/org/elasticsearch/benchmark/search/facet/QueryFilterFacetSearchBenchmark.java index 0cb52975c5b..34397a4f290 100644 --- a/src/test/java/org/elasticsearch/benchmark/search/facet/QueryFilterFacetSearchBenchmark.java +++ b/src/test/java/org/elasticsearch/benchmark/search/facet/QueryFilterFacetSearchBenchmark.java @@ -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.benchmark.search.facet; +import jsr166y.ThreadLocalRandom; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.bulk.BulkResponse; import org.elasticsearch.action.search.SearchResponse; @@ -29,17 +30,18 @@ import org.elasticsearch.client.action.bulk.BulkRequestBuilder; import org.elasticsearch.common.StopWatch; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.SizeValue; -import org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.node.Node; import org.elasticsearch.search.facet.FacetBuilders; -import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.cluster.metadata.IndexMetaData.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.elasticsearch.common.xcontent.XContentFactory.*; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.elasticsearch.node.NodeBuilder.*; +import static org.elasticsearch.client.Requests.createIndexRequest; +import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS; +import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; +import static org.elasticsearch.index.query.QueryBuilders.termQuery; +import static org.elasticsearch.node.NodeBuilder.nodeBuilder; public class QueryFilterFacetSearchBenchmark { diff --git a/src/test/java/org/elasticsearch/benchmark/search/facet/TermsFacetSearchBenchmark.java b/src/test/java/org/elasticsearch/benchmark/search/facet/TermsFacetSearchBenchmark.java index f5bbeeff910..3fab24656d3 100644 --- a/src/test/java/org/elasticsearch/benchmark/search/facet/TermsFacetSearchBenchmark.java +++ b/src/test/java/org/elasticsearch/benchmark/search/facet/TermsFacetSearchBenchmark.java @@ -19,6 +19,8 @@ package org.elasticsearch.benchmark.search.facet; +import com.google.common.collect.Lists; +import jsr166y.ThreadLocalRandom; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.bulk.BulkResponse; import org.elasticsearch.action.search.SearchResponse; @@ -28,26 +30,26 @@ import org.elasticsearch.client.Requests; import org.elasticsearch.client.action.bulk.BulkRequestBuilder; import org.elasticsearch.common.RandomStringGenerator; import org.elasticsearch.common.StopWatch; -import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.SizeValue; import org.elasticsearch.common.unit.TimeValue; -import org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.node.Node; import java.util.List; -import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.cluster.metadata.IndexMetaData.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.elasticsearch.common.xcontent.XContentFactory.*; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.elasticsearch.node.NodeBuilder.*; -import static org.elasticsearch.search.facet.FacetBuilders.*; +import static org.elasticsearch.client.Requests.createIndexRequest; +import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS; +import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; +import static org.elasticsearch.node.NodeBuilder.nodeBuilder; +import static org.elasticsearch.search.facet.FacetBuilders.termsFacet; +import static org.elasticsearch.search.facet.FacetBuilders.termsStatsFacet; /** - * @author kimchy (shay.banon) + * */ public class TermsFacetSearchBenchmark { diff --git a/src/test/java/org/elasticsearch/benchmark/search/geo/GeoDistanceSearchBenchmark.java b/src/test/java/org/elasticsearch/benchmark/search/geo/GeoDistanceSearchBenchmark.java index 71d74f9e24f..c3885369556 100644 --- a/src/test/java/org/elasticsearch/benchmark/search/geo/GeoDistanceSearchBenchmark.java +++ b/src/test/java/org/elasticsearch/benchmark/search/geo/GeoDistanceSearchBenchmark.java @@ -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,9 +30,10 @@ import org.elasticsearch.index.search.geo.GeoDistance; import org.elasticsearch.node.Node; import org.elasticsearch.node.NodeBuilder; -import static org.elasticsearch.common.xcontent.XContentFactory.*; -import static org.elasticsearch.index.query.FilterBuilders.*; -import static org.elasticsearch.index.query.QueryBuilders.*; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import static org.elasticsearch.index.query.FilterBuilders.geoDistanceFilter; +import static org.elasticsearch.index.query.QueryBuilders.filteredQuery; +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; /** */ diff --git a/src/test/java/org/elasticsearch/benchmark/stress/NodesStressTest.java b/src/test/java/org/elasticsearch/benchmark/stress/NodesStressTest.java index 72aff201bf1..d9fd39ed52a 100644 --- a/src/test/java/org/elasticsearch/benchmark/stress/NodesStressTest.java +++ b/src/test/java/org/elasticsearch/benchmark/stress/NodesStressTest.java @@ -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,17 +33,19 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.CyclicBarrier; import java.util.concurrent.atomic.AtomicLong; -import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.cluster.metadata.IndexMetaData.*; -import static org.elasticsearch.common.settings.ImmutableSettings.Builder.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.elasticsearch.index.query.FilterBuilders.*; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.elasticsearch.node.NodeBuilder.*; -import static org.elasticsearch.search.builder.SearchSourceBuilder.*; +import static org.elasticsearch.client.Requests.searchRequest; +import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS; +import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; +import static org.elasticsearch.common.settings.ImmutableSettings.Builder.EMPTY_SETTINGS; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.elasticsearch.index.query.FilterBuilders.queryFilter; +import static org.elasticsearch.index.query.QueryBuilders.constantScoreQuery; +import static org.elasticsearch.index.query.QueryBuilders.termQuery; +import static org.elasticsearch.node.NodeBuilder.nodeBuilder; +import static org.elasticsearch.search.builder.SearchSourceBuilder.searchSource; /** - * @author kimchy (shay.banon) + * */ public class NodesStressTest { @@ -197,7 +199,8 @@ public class NodesStressTest { this.id = id; } - @Override public void run() { + @Override + public void run() { try { barrier1.await(); barrier2.await(); @@ -236,7 +239,8 @@ public class NodesStressTest { return this; } - @Override public void run() { + @Override + public void run() { try { barrier1.await(); barrier2.await(); diff --git a/src/test/java/org/elasticsearch/benchmark/stress/SingleThreadBulkStress.java b/src/test/java/org/elasticsearch/benchmark/stress/SingleThreadBulkStress.java index d0eb02ea891..5303955fa89 100644 --- a/src/test/java/org/elasticsearch/benchmark/stress/SingleThreadBulkStress.java +++ b/src/test/java/org/elasticsearch/benchmark/stress/SingleThreadBulkStress.java @@ -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,14 +34,15 @@ import java.io.IOException; import java.util.Random; import java.util.concurrent.TimeUnit; -import static org.elasticsearch.cluster.metadata.IndexMetaData.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.elasticsearch.common.xcontent.XContentFactory.*; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.elasticsearch.node.NodeBuilder.*; +import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS; +import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; +import static org.elasticsearch.node.NodeBuilder.nodeBuilder; /** - * @author kimchy (shay.banon) + * */ public class SingleThreadBulkStress { diff --git a/src/test/java/org/elasticsearch/benchmark/stress/SingleThreadIndexingStress.java b/src/test/java/org/elasticsearch/benchmark/stress/SingleThreadIndexingStress.java index d8cf30a2ee8..9bca4ab76cf 100644 --- a/src/test/java/org/elasticsearch/benchmark/stress/SingleThreadIndexingStress.java +++ b/src/test/java/org/elasticsearch/benchmark/stress/SingleThreadIndexingStress.java @@ -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,15 +28,16 @@ import org.elasticsearch.node.Node; import java.io.IOException; import java.util.concurrent.TimeUnit; -import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.cluster.metadata.IndexMetaData.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.elasticsearch.common.xcontent.XContentFactory.*; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.elasticsearch.node.NodeBuilder.*; +import static org.elasticsearch.client.Requests.createIndexRequest; +import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS; +import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; +import static org.elasticsearch.node.NodeBuilder.nodeBuilder; /** - * @author kimchy (shay.banon) + * */ public class SingleThreadIndexingStress { diff --git a/src/test/java/org/elasticsearch/benchmark/time/SimpleTimeBenchmark.java b/src/test/java/org/elasticsearch/benchmark/time/SimpleTimeBenchmark.java index 75112aaeb0a..c05b6fbbb22 100644 --- a/src/test/java/org/elasticsearch/benchmark/time/SimpleTimeBenchmark.java +++ b/src/test/java/org/elasticsearch/benchmark/time/SimpleTimeBenchmark.java @@ -24,7 +24,7 @@ import org.elasticsearch.common.StopWatch; import java.util.concurrent.CountDownLatch; /** - * @author kimchy (Shay Banon) + * */ public class SimpleTimeBenchmark { @@ -45,7 +45,8 @@ public class SimpleTimeBenchmark { Thread[] threads = new Thread[NUMBER_OF_THREADS]; for (int i = 0; i < threads.length; i++) { threads[i] = new Thread(new Runnable() { - @Override public void run() { + @Override + public void run() { if (USE_NANO_TIME) { for (long i = 0; i < NUMBER_OF_ITERATIONS; i++) { System.nanoTime(); diff --git a/src/test/java/org/elasticsearch/benchmark/transport/BenchmarkMessage.java b/src/test/java/org/elasticsearch/benchmark/transport/BenchmarkMessage.java index 53b76e244b9..dca7e8b3ccf 100644 --- a/src/test/java/org/elasticsearch/benchmark/transport/BenchmarkMessage.java +++ b/src/test/java/org/elasticsearch/benchmark/transport/BenchmarkMessage.java @@ -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 BenchmarkMessage implements Streamable { @@ -42,13 +42,15 @@ public class BenchmarkMessage implements Streamable { public BenchmarkMessage() { } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { id = in.readLong(); payload = new byte[in.readVInt()]; in.readFully(payload); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeLong(id); out.writeVInt(payload.length); out.writeBytes(payload); diff --git a/src/test/java/org/elasticsearch/benchmark/transport/BenchmarkNettyLargeMessages.java b/src/test/java/org/elasticsearch/benchmark/transport/BenchmarkNettyLargeMessages.java index 6eb59325be9..60e874e8099 100644 --- a/src/test/java/org/elasticsearch/benchmark/transport/BenchmarkNettyLargeMessages.java +++ b/src/test/java/org/elasticsearch/benchmark/transport/BenchmarkNettyLargeMessages.java @@ -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,10 +32,10 @@ import org.elasticsearch.transport.netty.NettyTransport; import java.util.concurrent.CountDownLatch; -import static org.elasticsearch.transport.TransportRequestOptions.*; +import static org.elasticsearch.transport.TransportRequestOptions.options; /** - * @author kimchy (shay.banon) + * */ public class BenchmarkNettyLargeMessages { @@ -60,15 +60,18 @@ public class BenchmarkNettyLargeMessages { transportServiceClient.connectToNode(smallNode); transportServiceServer.registerHandler("benchmark", new BaseTransportRequestHandler() { - @Override public BenchmarkMessage newInstance() { + @Override + public BenchmarkMessage newInstance() { return new BenchmarkMessage(); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.CACHED; } - @Override public void messageReceived(BenchmarkMessage request, TransportChannel channel) throws Exception { + @Override + public void messageReceived(BenchmarkMessage request, TransportChannel channel) throws Exception { channel.sendResponse(request); } }); @@ -76,22 +79,27 @@ public class BenchmarkNettyLargeMessages { final CountDownLatch latch = new CountDownLatch(NUMBER_OF_CLIENTS); for (int i = 0; i < NUMBER_OF_CLIENTS; i++) { new Thread(new Runnable() { - @Override public void run() { + @Override + public void run() { for (int i = 0; i < NUMBER_OF_ITERATIONS; i++) { BenchmarkMessage message = new BenchmarkMessage(1, payload); transportServiceClient.submitRequest(bigNode, "benchmark", message, options().withLowType(), new BaseTransportResponseHandler() { - @Override public BenchmarkMessage newInstance() { + @Override + public BenchmarkMessage newInstance() { return new BenchmarkMessage(); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } - @Override public void handleResponse(BenchmarkMessage response) { + @Override + public void handleResponse(BenchmarkMessage response) { } - @Override public void handleException(TransportException exp) { + @Override + public void handleException(TransportException exp) { exp.printStackTrace(); } }).txGet(); @@ -102,23 +110,28 @@ public class BenchmarkNettyLargeMessages { } new Thread(new Runnable() { - @Override public void run() { + @Override + public void run() { for (int i = 0; i < NUMBER_OF_ITERATIONS; i++) { BenchmarkMessage message = new BenchmarkMessage(2, Bytes.EMPTY_ARRAY); long start = System.currentTimeMillis(); transportServiceClient.submitRequest(smallNode, "benchmark", message, options().withHighType(), new BaseTransportResponseHandler() { - @Override public BenchmarkMessage newInstance() { + @Override + public BenchmarkMessage newInstance() { return new BenchmarkMessage(); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } - @Override public void handleResponse(BenchmarkMessage response) { + @Override + public void handleResponse(BenchmarkMessage response) { } - @Override public void handleException(TransportException exp) { + @Override + public void handleException(TransportException exp) { exp.printStackTrace(); } }).txGet(); diff --git a/src/test/java/org/elasticsearch/benchmark/transport/TransportBenchmark.java b/src/test/java/org/elasticsearch/benchmark/transport/TransportBenchmark.java index c32ffcdc633..157ab8bbd37 100644 --- a/src/test/java/org/elasticsearch/benchmark/transport/TransportBenchmark.java +++ b/src/test/java/org/elasticsearch/benchmark/transport/TransportBenchmark.java @@ -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 @@ -40,12 +40,14 @@ public class TransportBenchmark { static enum Type { LOCAL { - @Override public Transport newTransport(Settings settings, ThreadPool threadPool) { + @Override + public Transport newTransport(Settings settings, ThreadPool threadPool) { return new LocalTransport(settings, threadPool); } }, NETTY { - @Override public Transport newTransport(Settings settings, ThreadPool threadPool) { + @Override + public Transport newTransport(Settings settings, ThreadPool threadPool) { return new NettyTransport(settings, threadPool); } }; @@ -76,15 +78,18 @@ public class TransportBenchmark { final DiscoveryNode node = new DiscoveryNode("server", serverTransportService.boundAddress().publishAddress()); serverTransportService.registerHandler("benchmark", new BaseTransportRequestHandler() { - @Override public BenchmarkMessage newInstance() { + @Override + public BenchmarkMessage newInstance() { return new BenchmarkMessage(); } - @Override public String executor() { + @Override + public String executor() { return executor; } - @Override public void messageReceived(BenchmarkMessage request, TransportChannel channel) throws Exception { + @Override + public void messageReceived(BenchmarkMessage request, TransportChannel channel) throws Exception { channel.sendResponse(request); } }); @@ -94,18 +99,22 @@ public class TransportBenchmark { for (int i = 0; i < 10000; i++) { BenchmarkMessage message = new BenchmarkMessage(1, payload); clientTransportService.submitRequest(node, "benchmark", message, new BaseTransportResponseHandler() { - @Override public BenchmarkMessage newInstance() { + @Override + public BenchmarkMessage newInstance() { return new BenchmarkMessage(); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.SAME; } - @Override public void handleResponse(BenchmarkMessage response) { + @Override + public void handleResponse(BenchmarkMessage response) { } - @Override public void handleException(TransportException exp) { + @Override + public void handleException(TransportException exp) { exp.printStackTrace(); } }).txGet(); @@ -116,27 +125,32 @@ public class TransportBenchmark { final CountDownLatch latch = new CountDownLatch(NUMBER_OF_CLIENTS * NUMBER_OF_ITERATIONS); for (int i = 0; i < NUMBER_OF_CLIENTS; i++) { clients[i] = new Thread(new Runnable() { - @Override public void run() { + @Override + public void run() { for (int j = 0; j < NUMBER_OF_ITERATIONS; j++) { final long id = idGenerator.incrementAndGet(); BenchmarkMessage message = new BenchmarkMessage(id, payload); BaseTransportResponseHandler handler = new BaseTransportResponseHandler() { - @Override public BenchmarkMessage newInstance() { + @Override + public BenchmarkMessage newInstance() { return new BenchmarkMessage(); } - @Override public String executor() { + @Override + public String executor() { return executor; } - @Override public void handleResponse(BenchmarkMessage response) { + @Override + public void handleResponse(BenchmarkMessage response) { if (response.id != id) { System.out.println("NO ID MATCH [" + response.id + "] and [" + id + "]"); } latch.countDown(); } - @Override public void handleException(TransportException exp) { + @Override + public void handleException(TransportException exp) { exp.printStackTrace(); latch.countDown(); } diff --git a/src/test/java/org/elasticsearch/benchmark/transport/netty/NettyEchoBenchmark.java b/src/test/java/org/elasticsearch/benchmark/transport/netty/NettyEchoBenchmark.java index 3702bb90212..894bdc6e0fb 100644 --- a/src/test/java/org/elasticsearch/benchmark/transport/netty/NettyEchoBenchmark.java +++ b/src/test/java/org/elasticsearch/benchmark/transport/netty/NettyEchoBenchmark.java @@ -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.benchmark.transport.netty; -import org.elasticsearch.common.netty.bootstrap.ClientBootstrap; -import org.elasticsearch.common.netty.bootstrap.ServerBootstrap; -import org.elasticsearch.common.netty.buffer.ChannelBuffer; -import org.elasticsearch.common.netty.buffer.ChannelBuffers; -import org.elasticsearch.common.netty.channel.*; -import org.elasticsearch.common.netty.channel.socket.nio.NioClientSocketChannelFactory; -import org.elasticsearch.common.netty.channel.socket.nio.NioServerSocketChannelFactory; +import org.jboss.netty.bootstrap.ClientBootstrap; +import org.jboss.netty.bootstrap.ServerBootstrap; +import org.jboss.netty.buffer.ChannelBuffer; +import org.jboss.netty.buffer.ChannelBuffers; +import org.jboss.netty.channel.*; +import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory; +import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory; import java.net.InetSocketAddress; import java.util.concurrent.CountDownLatch; diff --git a/src/test/java/org/elasticsearch/benchmark/trove/StringMapAdjustOrPutBenchmark.java b/src/test/java/org/elasticsearch/benchmark/trove/StringMapAdjustOrPutBenchmark.java index 4f0b17fc155..12b30617a3b 100644 --- a/src/test/java/org/elasticsearch/benchmark/trove/StringMapAdjustOrPutBenchmark.java +++ b/src/test/java/org/elasticsearch/benchmark/trove/StringMapAdjustOrPutBenchmark.java @@ -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,17 +19,17 @@ package org.elasticsearch.benchmark.trove; +import gnu.trove.StringIdentityHashingStrategy; +import gnu.trove.map.custom_hash.TObjectIntCustomHashMap; +import gnu.trove.map.hash.THashMap; +import gnu.trove.map.hash.TIntIntHashMap; +import gnu.trove.map.hash.TIntObjectHashMap; +import gnu.trove.map.hash.TObjectIntHashMap; +import gnu.trove.strategy.IdentityHashingStrategy; +import jsr166y.ThreadLocalRandom; import org.elasticsearch.common.RandomStringGenerator; import org.elasticsearch.common.StopWatch; -import org.elasticsearch.common.trove.StringIdentityHashingStrategy; -import org.elasticsearch.common.trove.map.custom_hash.TObjectIntCustomHashMap; -import org.elasticsearch.common.trove.map.hash.THashMap; -import org.elasticsearch.common.trove.map.hash.TIntIntHashMap; -import org.elasticsearch.common.trove.map.hash.TIntObjectHashMap; -import org.elasticsearch.common.trove.map.hash.TObjectIntHashMap; -import org.elasticsearch.common.trove.strategy.IdentityHashingStrategy; import org.elasticsearch.common.unit.SizeValue; -import org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom; import java.util.HashMap; import java.util.IdentityHashMap; diff --git a/src/test/java/org/elasticsearch/benchmark/uuid/SimpleUuidBenchmark.java b/src/test/java/org/elasticsearch/benchmark/uuid/SimpleUuidBenchmark.java index 4b3f8c0e005..9be9684e9d2 100644 --- a/src/test/java/org/elasticsearch/benchmark/uuid/SimpleUuidBenchmark.java +++ b/src/test/java/org/elasticsearch/benchmark/uuid/SimpleUuidBenchmark.java @@ -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.UUID; import java.util.concurrent.CountDownLatch; /** - * @author kimchy (Shay Banon) + * */ public class SimpleUuidBenchmark { @@ -45,7 +45,8 @@ public class SimpleUuidBenchmark { Thread[] threads = new Thread[NUMBER_OF_THREADS]; for (int i = 0; i < threads.length; i++) { threads[i] = new Thread(new Runnable() { - @Override public void run() { + @Override + public void run() { for (long i = 0; i < NUMBER_OF_ITERATIONS; i++) { UUID.randomUUID().toString(); } diff --git a/src/test/java/org/elasticsearch/common/settings/loader/test-settings.json b/src/test/java/org/elasticsearch/common/settings/loader/test-settings.json deleted file mode 100644 index e64b882a98e..00000000000 --- a/src/test/java/org/elasticsearch/common/settings/loader/test-settings.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - test1 : { - value1 : "value1", - test2 : { - value2 : "value2", - value3 : 2 - }, - test3 : ["test3-1", "test3-2"] - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/analysis/synonyms/synonyms.json b/src/test/java/org/elasticsearch/index/analysis/synonyms/synonyms.json deleted file mode 100644 index 88d1f51bc79..00000000000 --- a/src/test/java/org/elasticsearch/index/analysis/synonyms/synonyms.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "index" : { - "analysis" : { - "analyzer" : { - "synonymAnalyzer" : { - "tokenizer" : "standard", - "filter" : [ "synonym" ] - }, - "synonymAnalyzer_file" : { - "tokenizer" : "standard", - "filter" : [ "synonym_file" ] - }, - "synonymAnalyzerWordnet" : { - "tokenizer" : "standard", - "filter" : [ "synonymWordnet" ] - }, - "synonymAnalyzerWordnet_file" : { - "tokenizer" : "standard", - "filter" : [ "synonymWordnet_file" ] - } - }, - "filter" : { - "synonym" : { - "type" : "synonym", - "synonyms" : [ - "kimchy => shay", - "dude => elasticsearch", - "abides => man!" - ] - }, - "synonym_file" : { - "type" : "synonym", - "synonyms_path" : "org/elasticsearch/index/analysis/synonyms/synonyms.txt" - }, - "synonymWordnet" : { - "type" : "synonym", - "format" : "wordnet", - "synonyms" : [ - "s(100000001,1,'abstain',v,1,0).", - "s(100000001,2,'refrain',v,1,0).", - "s(100000001,3,'desist',v,1,0)." - ] - }, - "synonymWordnet_file" : { - "type" : "synonym", - "format" : "wordnet", - "synonyms_path" : "org/elasticsearch/index/analysis/synonyms/synonyms_wordnet.txt" - } - } - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/analysis/test1.json b/src/test/java/org/elasticsearch/index/analysis/test1.json deleted file mode 100644 index deeef1c70c7..00000000000 --- a/src/test/java/org/elasticsearch/index/analysis/test1.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "index" : { - "analysis" : { - "tokenizer" : { - "standard" : { - "type" : "standard" - } - }, - "char_filter" : { - "my_html" : { - "type" : "html_strip", - "escaped_tags" : ["xxx", "yyy"], - "read_ahead" : 1024 - }, - "my_mapping" : { - "type" : "mapping", - "mappings" : ["ph=>f", "qu=>q"] - } - }, - "filter" : { - "stop" : { - "type" : "stop", - "stopwords" : ["test-stop"] - }, - "stop2" : { - "type" : "stop", - "stopwords" : ["stop2-1", "stop2-2"] - }, - "metaphone" : { - "type" : "phonetic", - "encoder" : "metaphone" - }, - "my" : { - "type" : "org.elasticsearch.index.analysis.filter1.MyFilterTokenFilterFactory" - }, - "dict_dec" : { - "type" : "dictionary_decompounder", - "word_list" : ["donau", "dampf", "schiff", "spargel", "creme", "suppe"] - } - }, - "analyzer" : { - "standard" : { - "alias" : "alias1,alias2", - "type" : "standard", - "stopwords" : ["test1", "test2", "test3"] - }, - "custom1" : { - "alias" : ["alias4", "alias5"], - "tokenizer" : "standard", - "filter" : ["stop", "stop2"] - }, - "custom2" : { - "tokenizer" : "standard", - "char_filter" : ["html_strip", "my_html"] - }, - "custom3" : { - "tokenizer" : "standard", - "filter" : ["metaphone"] - }, - "custom4" : { - "tokenizer" : "standard", - "filter" : ["my"] - }, - "custom5" : { - "tokenizer" : "standard", - "char_filter" : ["my_mapping"] - }, - "czechAnalyzerWithStemmer" : { - "tokenizer" : "standard", - "filter" : ["standard", "lowercase", "stop", "czech_stem"] - }, - "decompoundingAnalyzer" : { - "tokenizer" : "standard", - "filter" : ["dict_dec"] - } - } - } - } -} diff --git a/src/test/java/org/elasticsearch/index/mapper/all/mapping.json b/src/test/java/org/elasticsearch/index/mapper/all/mapping.json deleted file mode 100644 index 73c4f2f6d3d..00000000000 --- a/src/test/java/org/elasticsearch/index/mapper/all/mapping.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "person" : { - "_all" : { - "enabled" : true - }, - "properties" : { - "name" : { - "type" : "object", - "dynamic" : false, - "properties" : { - "first" : { - "type" : "string", - "store" : "yes", - "include_in_all" : false - }, - "last" : { - "type" : "string", - "index" : "not_analyzed" - } - } - }, - "address" : { - "type" : "object", - "include_in_all" : false, - "properties" : { - "first" : { - "properties" : { - "location" : { - "type" : "string", - "store" : "yes", - "index_name" : "firstLocation" - } - } - }, - "last" : { - "properties" : { - "location" : { - "type" : "string", - "include_in_all" : true - } - } - } - } - }, - "simple1" : { - "type" : "long", - "include_in_all" : true - }, - "simple2" : { - "type" : "long", - "include_in_all" : false - } - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/mapper/all/store-mapping.json b/src/test/java/org/elasticsearch/index/mapper/all/store-mapping.json deleted file mode 100644 index 989d0026f7b..00000000000 --- a/src/test/java/org/elasticsearch/index/mapper/all/store-mapping.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "person" : { - "_all" : { - "enabled" : true, - "store" : "yes" - }, - "properties" : { - "name" : { - "type" : "object", - "dynamic" : false, - "properties" : { - "first" : { - "type" : "string", - "store" : "yes", - "include_in_all" : false - }, - "last" : { - "type" : "string", - "index" : "not_analyzed" - } - } - }, - "address" : { - "type" : "object", - "include_in_all" : false, - "properties" : { - "first" : { - "properties" : { - "location" : { - "type" : "string", - "store" : "yes", - "index_name" : "firstLocation" - } - } - }, - "last" : { - "properties" : { - "location" : { - "type" : "string" - } - } - } - } - }, - "simple1" : { - "type" : "long", - "include_in_all" : true - }, - "simple2" : { - "type" : "long", - "include_in_all" : false - } - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/mapper/all/test1.json b/src/test/java/org/elasticsearch/index/mapper/all/test1.json deleted file mode 100644 index 378b8a2df4a..00000000000 --- a/src/test/java/org/elasticsearch/index/mapper/all/test1.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "person" : { - "_boost" : 3.7, - "_id" : "1", - "name" : { - "first" : "shay", - "last" : "banon" - }, - "address" : { - "first" : { - "location" : "first location" - }, - "last" : { - "location" : "last location" - } - }, - "simple1" : 1, - "simple2" : 2 - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/genericstore/test-data.json b/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/genericstore/test-data.json deleted file mode 100644 index a72b32d6799..00000000000 --- a/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/genericstore/test-data.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "_id" : "1", - "name" : "some name", - "age" : 1 -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/genericstore/test-mapping.json b/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/genericstore/test-mapping.json deleted file mode 100644 index 94a3d1a7cdf..00000000000 --- a/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/genericstore/test-mapping.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "person" : { - "dynamic_templates" : [ - { - "template_1" : { - "match" : "*", - "mapping" : { - "store" : "yes" - } - } - } - ] - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/pathmatch/test-data.json b/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/pathmatch/test-data.json deleted file mode 100644 index 096992d519f..00000000000 --- a/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/pathmatch/test-data.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "_id" : "1", - "name" : "top_level", - "obj1" : { - "name" : "obj1_level", - "obj2" : { - "name" : "obj2_level" - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/pathmatch/test-mapping.json b/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/pathmatch/test-mapping.json deleted file mode 100644 index b791b421243..00000000000 --- a/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/pathmatch/test-mapping.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "person" : { - "dynamic_templates" : [ - { - "template_1" : { - "path_match" : "obj1.obj2.*", - "mapping" : { - "store" : "no" - } - } - }, - { - "template_2" : { - "path_match" : "obj1.*", - "mapping" : { - "store" : "yes" - } - } - } - ] - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/simple/test-data.json b/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/simple/test-data.json deleted file mode 100644 index 5864c59cccf..00000000000 --- a/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/simple/test-data.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "_id" : "1", - "name" : "some name", - "age" : 1, - "multi1" : "multi 1", - "multi2" : "multi 2" -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/simple/test-mapping.json b/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/simple/test-mapping.json deleted file mode 100644 index 65511907d92..00000000000 --- a/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/simple/test-mapping.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "person" : { - "dynamic_templates" : [ - { - "tempalte_1" : { - "match" : "multi*", - "mapping" : { - "type" : "multi_field", - "fields" : { - "{name}" : { - "type": "{dynamic_type}", - "index" : "analyzed", - "store" : "yes" - }, - "org" : { - "type": "{dynamic_type}", - "index" : "not_analyzed", - "store" : "yes" - } - } - } - } - }, - { - "template_2" : { - "match" : "*", - "match_mapping_type" : "string", - "mapping" : { - "type" : "string", - "index" : "not_analyzed" - } - } - } - ] - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/mapper/merge/stage1.json b/src/test/java/org/elasticsearch/index/mapper/merge/stage1.json deleted file mode 100644 index 89b952ca9d0..00000000000 --- a/src/test/java/org/elasticsearch/index/mapper/merge/stage1.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "person" : { - "properties" : { - "name" : { - "type" : "string" - } - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/mapper/merge/stage2.json b/src/test/java/org/elasticsearch/index/mapper/merge/stage2.json deleted file mode 100644 index 989382b2312..00000000000 --- a/src/test/java/org/elasticsearch/index/mapper/merge/stage2.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "person" : { - "properties" : { - "name" : { - "type" : "string" - }, - "age" : { - "type" : "integer" - }, - "obj1" : { - "properties" : { - "prop1" : { - "type" : "string" - } - } - } - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/mapper/multifield/merge/test-data.json b/src/test/java/org/elasticsearch/index/mapper/multifield/merge/test-data.json deleted file mode 100644 index fc7324eda84..00000000000 --- a/src/test/java/org/elasticsearch/index/mapper/multifield/merge/test-data.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - _id : 1, - name : "some name" -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/mapper/multifield/merge/test-mapping1.json b/src/test/java/org/elasticsearch/index/mapper/multifield/merge/test-mapping1.json deleted file mode 100644 index 6cb370ec795..00000000000 --- a/src/test/java/org/elasticsearch/index/mapper/multifield/merge/test-mapping1.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - person : { - properties : { - "name" : { - type: "string", - index : "analyzed", - store : "yes" - } - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/mapper/multifield/merge/test-mapping2.json b/src/test/java/org/elasticsearch/index/mapper/multifield/merge/test-mapping2.json deleted file mode 100644 index beb4ffd7682..00000000000 --- a/src/test/java/org/elasticsearch/index/mapper/multifield/merge/test-mapping2.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - person : { - properties : { - "name" : { - type : "multi_field", - "fields" : { - "name" : { - type: "string", - index : "analyzed", - store : "yes" - }, - "indexed" : { - type: "string", - index : "analyzed" - }, - "not_indexed" : { - type: "string", - index : "no", - store : "yes" - } - } - } - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/mapper/multifield/merge/test-mapping3.json b/src/test/java/org/elasticsearch/index/mapper/multifield/merge/test-mapping3.json deleted file mode 100644 index ae87f840674..00000000000 --- a/src/test/java/org/elasticsearch/index/mapper/multifield/merge/test-mapping3.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - person : { - properties : { - "name" : { - type : "multi_field", - "fields" : { - "name" : { - type: "string", - index : "analyzed", - store : "yes" - }, - "indexed" : { - type: "string", - index : "analyzed" - }, - "not_indexed" : { - type: "string", - index : "no", - store : "yes" - }, - "not_indexed2" : { - type: "string", - index : "no", - store : "yes" - } - } - } - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/mapper/multifield/merge/test-mapping4.json b/src/test/java/org/elasticsearch/index/mapper/multifield/merge/test-mapping4.json deleted file mode 100644 index b98804db862..00000000000 --- a/src/test/java/org/elasticsearch/index/mapper/multifield/merge/test-mapping4.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - person : { - properties : { - "name" : { - type : "multi_field", - "fields" : { - "not_indexed3" : { - type: "string", - index : "no", - store : "yes" - } - } - } - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/mapper/multifield/test-data.json b/src/test/java/org/elasticsearch/index/mapper/multifield/test-data.json deleted file mode 100644 index e3d73279543..00000000000 --- a/src/test/java/org/elasticsearch/index/mapper/multifield/test-data.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "_id" : 1, - "name" : "some name", - "object1" : { - "multi1" : "2010-01-01" - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/mapper/multifield/test-mapping.json b/src/test/java/org/elasticsearch/index/mapper/multifield/test-mapping.json deleted file mode 100644 index fc5bcdaf59d..00000000000 --- a/src/test/java/org/elasticsearch/index/mapper/multifield/test-mapping.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "person" : { - "properties" : { - "name" : { - "type" : "multi_field", - "fields" : { - "name" : { - "type": "string", - "index" : "analyzed", - "store" : "yes" - }, - "indexed" : { - "type": "string", - "index" : "analyzed" - }, - "not_indexed" : { - "type": "string", - "index" : "no", - "store" : "yes" - } - } - }, - "object1" : { - "properties" : { - "multi1" : { - "type" : "multi_field", - "fields" : { - "multi1" : { - "type": "date" - }, - "string" : { - "type": "string", - "index" : "not_analyzed" - } - } - } - } - } - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/mapper/path/test-mapping.json b/src/test/java/org/elasticsearch/index/mapper/path/test-mapping.json deleted file mode 100644 index 0f7da102c86..00000000000 --- a/src/test/java/org/elasticsearch/index/mapper/path/test-mapping.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "person" : { - "properties" : { - "name1" : { - "type" : "object", - "path" : "just_name", - "properties" : { - "first1" : { - "type" : "string" - }, - "last1" : { - "type" : "string", - "index_name" : "i_last_1" - } - } - }, - "name2" : { - "type" : "object", - "path" : "full", - "properties" : { - "first2" : { - "type" : "string" - }, - "last2" : { - "type" : "string", - "index_name" : "i_last_2" - } - } - } - } - } -} diff --git a/src/test/java/org/elasticsearch/index/mapper/simple/test-mapping.json b/src/test/java/org/elasticsearch/index/mapper/simple/test-mapping.json deleted file mode 100644 index 2ca8b4762c0..00000000000 --- a/src/test/java/org/elasticsearch/index/mapper/simple/test-mapping.json +++ /dev/null @@ -1,98 +0,0 @@ -{ - person : { - "_meta" : { - "param1" : "value1" - }, - date_formats : ["yyyy-MM-dd", "dd-MM-yyyy"], - dynamic : false, - enabled : true, - _id : { - name : "_id", - index_name : "_id" - }, - _source : { - name : "_source" - }, - _type : { - name : "_type" - }, - _boost : { - name : "_boost", - null_value : 2.0 - }, - properties : { - name : { - type : "object", - dynamic : false, - properties : { - first : { - type : "string", - store : "yes" - }, - last : { - type : "string", - index : "not_analyzed" - } - } - }, - address : { - type : "object", - properties : { - first : { - properties : { - location : { - type : "string", - store : "yes", - index_name : "firstLocation" - } - } - }, - last : { - properties : { - location : { - type : "string" - } - } - } - } - }, - age : { - type : "integer", - null_value : 0 - }, - birthdate : { - type : "date", - format : "yyyy-MM-dd" - }, - nerd : { - type : "boolean" - }, - dogs : { - type : "string", - index_name : "dog" - }, - complex : { - type : "object", - properties : { - value1 : { - type : "string" - }, - value2 : { - type : "string" - } - } - }, - complex2 : { - type : "object", - properties : { - value1 : { - type : "string" - }, - value2 : { - type : "string" - } - } - } - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/mapper/simple/test1-notype-noid.json b/src/test/java/org/elasticsearch/index/mapper/simple/test1-notype-noid.json deleted file mode 100644 index 09e3e463e98..00000000000 --- a/src/test/java/org/elasticsearch/index/mapper/simple/test1-notype-noid.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - _boost : 3.7, - name : { - first : "shay", - last : "banon" - }, - address : { - first : { - location : "first location" - }, - last : { - location : "last location" - } - }, - age : 32, - birthDate : "1977-11-15", - nerd : true, - dogs : ["buck", "mia"], - complex : [ - { - value1 : "value1" - }, - { - value2 : "value2" - } - ], - complex2 : [ - [ - { - value1 : "value1" - } - ], - [ - { - value2 : "value2" - } - ] - ], - nullValue : null -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/mapper/simple/test1-notype.json b/src/test/java/org/elasticsearch/index/mapper/simple/test1-notype.json deleted file mode 100644 index f566f4992e3..00000000000 --- a/src/test/java/org/elasticsearch/index/mapper/simple/test1-notype.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - _boost : 3.7, - _id : "1", - name : { - first : "shay", - last : "banon" - }, - address : { - first : { - location : "first location" - }, - last : { - location : "last location" - } - }, - age : 32, - birthDate : "1977-11-15", - nerd : true, - dogs : ["buck", "mia"], - complex : [ - { - value1 : "value1" - }, - { - value2 : "value2" - } - ], - complex2 : [ - [ - { - value1 : "value1" - } - ], - [ - { - value2 : "value2" - } - ] - ], - nullValue : null -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/mapper/simple/test1.json b/src/test/java/org/elasticsearch/index/mapper/simple/test1.json deleted file mode 100644 index 181d61cfa24..00000000000 --- a/src/test/java/org/elasticsearch/index/mapper/simple/test1.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - person : { - _boost : 3.7, - _id : "1", - name : { - first : "shay", - last : "banon" - }, - address : { - first : { - location : "first location" - }, - last : { - location : "last location" - } - }, - age : 32, - birthDate : "1977-11-15", - nerd : true, - dogs : ["buck", "mia"], - complex : [ - { - value1 : "value1" - }, - { - value2 : "value2" - } - ], - complex2 : [ - [ - { - value1 : "value1" - } - ], - [ - { - value2 : "value2" - } - ] - ], - nullValue : null - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/and-filter-named.json b/src/test/java/org/elasticsearch/index/query/and-filter-named.json deleted file mode 100644 index 06f5f55620d..00000000000 --- a/src/test/java/org/elasticsearch/index/query/and-filter-named.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "filtered" : { - "query" : { - "term" : { - "name.first" : "shay" - } - }, - "filter" : { - "and" : { - "filters" : [ - { - "term" : { - "name.first" : "shay1" - } - }, - { - "term" : { - "name.first" : "shay4" - } - } - ], - "_name" : "test" - } - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/and-filter.json b/src/test/java/org/elasticsearch/index/query/and-filter.json deleted file mode 100644 index 0f4e51af925..00000000000 --- a/src/test/java/org/elasticsearch/index/query/and-filter.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "filtered" : { - "query" : { - "term" : { - "name.first" : "shay" - } - }, - "filter" : { - "and" : { - "filters" : [ - { - "term" : { - "name.first" : "shay1" - } - }, - { - "term" : { - "name.first" : "shay4" - } - } - ] - } - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/and-filter2.json b/src/test/java/org/elasticsearch/index/query/and-filter2.json deleted file mode 100644 index f3acaadc902..00000000000 --- a/src/test/java/org/elasticsearch/index/query/and-filter2.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "filtered" : { - "query" : { - "term" : { - "name.first" : "shay" - } - }, - "filter" : { - "and" : [ - { - "term" : { - "name.first" : "shay1" - } - }, - { - "term" : { - "name.first" : "shay4" - } - } - ] - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/bool-filter.json b/src/test/java/org/elasticsearch/index/query/bool-filter.json deleted file mode 100644 index 779aa16d3ab..00000000000 --- a/src/test/java/org/elasticsearch/index/query/bool-filter.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - filtered : { - query : { - term : { - "name.first" : "shay" - } - }, - filter : { - bool : { - must : [ - { - term : { - "name.first" : "shay1" - } - }, - { - term : { - "name.first" : "shay4" - } - } - ], - must_not: { - term : { - "name.first" : "shay2" - } - }, - should: { - term : { - "name.first" : "shay3" - } - } - } - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/bool.json b/src/test/java/org/elasticsearch/index/query/bool.json deleted file mode 100644 index 0e56943d4ed..00000000000 --- a/src/test/java/org/elasticsearch/index/query/bool.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - bool : { - must : [ - { - query_string : { - default_field : "content", - query : "test1" - } - }, - { - query_string : { - default_field : "content", - query : "test4" - } - } - ], - must_not: { - query_string : { - default_field : "content", - query : "test2" - } - }, - should: { - query_string : { - default_field : "content", - query : "test3" - } - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/boosting-query.json b/src/test/java/org/elasticsearch/index/query/boosting-query.json deleted file mode 100644 index b22347debcb..00000000000 --- a/src/test/java/org/elasticsearch/index/query/boosting-query.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "boosting" : { - "positive" : { - "term" : { - "field1" : "value1" - } - }, - "negative" : { - "term" : { - "field2" : "value2" - } - }, - "negative_boost" : 0.2 - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/constantScore-query.json b/src/test/java/org/elasticsearch/index/query/constantScore-query.json deleted file mode 100644 index 842fee2cf85..00000000000 --- a/src/test/java/org/elasticsearch/index/query/constantScore-query.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - constant_score : { - filter : { - term : { - "name.last" : "banon" - } - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/custom-boost-factor-query.json b/src/test/java/org/elasticsearch/index/query/custom-boost-factor-query.json deleted file mode 100644 index aa57ad8921b..00000000000 --- a/src/test/java/org/elasticsearch/index/query/custom-boost-factor-query.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "custom_boost_factor" : { - "query" : { - "term" : { - "name.last" : "banon" - } - }, - "boost_factor" : 1.3 - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/custom_score1.json b/src/test/java/org/elasticsearch/index/query/custom_score1.json deleted file mode 100644 index a55d476878c..00000000000 --- a/src/test/java/org/elasticsearch/index/query/custom_score1.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "custom_score" : { - "query" : { - "term" : { - "name.last" : "banon" - } - }, - "script" : "score * doc['name.first']" - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/data.json b/src/test/java/org/elasticsearch/index/query/data.json deleted file mode 100644 index ef71f522114..00000000000 --- a/src/test/java/org/elasticsearch/index/query/data.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - person : { - _boost : 3.7, - _id : "1", - name : { - first : "shay", - last : "banon" - }, - address : { - first : { - location : "first location" - }, - last : { - location : "last location" - } - }, - age : 32, - birthDate : "1977-11-15", - nerd : true, - dogs : ["buck", "mia"], - complex : [ - { - value1 : "value1" - }, - { - value2 : "value2" - } - ], - complex2 : [ - [ - { - value1 : "value1" - } - ], - [ - { - value2 : "value2" - } - ] - ], - nullValue : null, - "location" : { - "lat" : 1.1, - "lon" : 1.2 - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/disMax.json b/src/test/java/org/elasticsearch/index/query/disMax.json deleted file mode 100644 index ca56aaef2a3..00000000000 --- a/src/test/java/org/elasticsearch/index/query/disMax.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - dis_max : { - tie_breaker: 0.7, - boost: 1.2, - queries : [ - { - term : { - "name.first" : "first" - } - }, - { - term : { - "name.last" : "last" - } - } - ] - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/disMax2.json b/src/test/java/org/elasticsearch/index/query/disMax2.json deleted file mode 100644 index 6325f15ae7e..00000000000 --- a/src/test/java/org/elasticsearch/index/query/disMax2.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "dis_max" : { - "queries" : [ - { - "prefix" : { - "name.first" : { - "value" : "sh", - "boost" : 1.2 - } - } - } - ] - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/field1.json b/src/test/java/org/elasticsearch/index/query/field1.json deleted file mode 100644 index 15e6c3b08b9..00000000000 --- a/src/test/java/org/elasticsearch/index/query/field1.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "field" : { - "age" : 34 - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/field2.json b/src/test/java/org/elasticsearch/index/query/field2.json deleted file mode 100644 index 76a2859fcea..00000000000 --- a/src/test/java/org/elasticsearch/index/query/field2.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - field : { - "name.first" : "something else" - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/field3.json b/src/test/java/org/elasticsearch/index/query/field3.json deleted file mode 100644 index bfca58dbfb0..00000000000 --- a/src/test/java/org/elasticsearch/index/query/field3.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - field : { - age : { - query : 34, - boost : 2.0, - enable_position_increments : false - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/filtered-query.json b/src/test/java/org/elasticsearch/index/query/filtered-query.json deleted file mode 100644 index 67dc879d239..00000000000 --- a/src/test/java/org/elasticsearch/index/query/filtered-query.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - filtered : { - query : { - term : { - "name.first" : "shay" - } - }, - filter : { - term : { - "name.last" : "banon" - } - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/filtered-query2.json b/src/test/java/org/elasticsearch/index/query/filtered-query2.json deleted file mode 100644 index f0eaefc342b..00000000000 --- a/src/test/java/org/elasticsearch/index/query/filtered-query2.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - filtered : { - filter : { - term : { - "name.last" : "banon" - } - }, - query : { - term : { - "name.first" : "shay" - } - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/filtered-query3.json b/src/test/java/org/elasticsearch/index/query/filtered-query3.json deleted file mode 100644 index f841255a761..00000000000 --- a/src/test/java/org/elasticsearch/index/query/filtered-query3.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - filtered : { - filter : { - range : { - age : { - from : "23", - to : "54", - include_lower : true, - include_upper: false - } - } - }, - query : { - term : { - "name.first" : "shay" - } - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/filtered-query4.json b/src/test/java/org/elasticsearch/index/query/filtered-query4.json deleted file mode 100644 index 65a9186c94b..00000000000 --- a/src/test/java/org/elasticsearch/index/query/filtered-query4.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - filtered : { - query : { - wildcard : { - "name.first" : { - wildcard : "sh*", - boost : 1.1 - } - } - }, - filter : { - term : { - "name.last" : "banon" - } - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/fquery-filter.json b/src/test/java/org/elasticsearch/index/query/fquery-filter.json deleted file mode 100644 index c04fd403dc7..00000000000 --- a/src/test/java/org/elasticsearch/index/query/fquery-filter.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "filtered" : { - "query" : { - "term" : { - "name.first" : "shay" - } - }, - "filter" : { - "fquery" : { - "query" : { - "term" : { - "name.last" : "banon" - } - }, - "_name" : "test" - } - } - } -} diff --git a/src/test/java/org/elasticsearch/index/query/fuzzy-with-fields.json b/src/test/java/org/elasticsearch/index/query/fuzzy-with-fields.json deleted file mode 100644 index e6523a60519..00000000000 --- a/src/test/java/org/elasticsearch/index/query/fuzzy-with-fields.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "fuzzy" : { - "name.first" : { - "value" : "sh", - "min_similarity" : 0.1, - "prefix_length" : 1, - "boost" : 2.0 - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/fuzzy-with-fields2.json b/src/test/java/org/elasticsearch/index/query/fuzzy-with-fields2.json deleted file mode 100644 index 44037719201..00000000000 --- a/src/test/java/org/elasticsearch/index/query/fuzzy-with-fields2.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "fuzzy" : { - "age" : { - "value" : 12, - "min_similarity" : 5, - "boost" : 2.0 - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/fuzzy.json b/src/test/java/org/elasticsearch/index/query/fuzzy.json deleted file mode 100644 index 04323184c34..00000000000 --- a/src/test/java/org/elasticsearch/index/query/fuzzy.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "fuzzy" : { - "name.first" : "sh" - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/fuzzyLikeThis.json b/src/test/java/org/elasticsearch/index/query/fuzzyLikeThis.json deleted file mode 100644 index 614d6f0e763..00000000000 --- a/src/test/java/org/elasticsearch/index/query/fuzzyLikeThis.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - fuzzy_like_this : { - fields : ["name.first", "name.last"], - like_text : "something", - max_query_terms : 12 - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/fuzzyLikeThisField.json b/src/test/java/org/elasticsearch/index/query/fuzzyLikeThisField.json deleted file mode 100644 index a431c44d4cf..00000000000 --- a/src/test/java/org/elasticsearch/index/query/fuzzyLikeThisField.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - fuzzy_like_this_field : { - "name.first" : { - like_text : "something", - max_query_terms : 12 - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/geo_boundingbox-named.json b/src/test/java/org/elasticsearch/index/query/geo_boundingbox-named.json deleted file mode 100644 index 845d41235e3..00000000000 --- a/src/test/java/org/elasticsearch/index/query/geo_boundingbox-named.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "filtered" : { - "query" : { - "match_all" : {} - }, - "filter" : { - "geo_bounding_box" : { - "location" : { - "top_left" : [-70, 40], - "bottom_right" : [-80, 30] - }, - "_name" : "test" - } - } - } -} diff --git a/src/test/java/org/elasticsearch/index/query/geo_boundingbox1.json b/src/test/java/org/elasticsearch/index/query/geo_boundingbox1.json deleted file mode 100644 index 688225855c0..00000000000 --- a/src/test/java/org/elasticsearch/index/query/geo_boundingbox1.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "filtered" : { - "query" : { - "match_all" : {} - }, - "filter" : { - "geo_bounding_box" : { - "location" : { - "top_left" : [-70, 40], - "bottom_right" : [-80, 30] - } - } - } - } -} diff --git a/src/test/java/org/elasticsearch/index/query/geo_boundingbox2.json b/src/test/java/org/elasticsearch/index/query/geo_boundingbox2.json deleted file mode 100644 index 4cd168dd42d..00000000000 --- a/src/test/java/org/elasticsearch/index/query/geo_boundingbox2.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "filtered" : { - "query" : { - "match_all" : {} - }, - "filter" : { - "geo_bounding_box" : { - "location" : { - "top_left" : { - "lat" : 40, - "lon" : -70 - }, - "bottom_right" : { - "lat" : 30, - "lon" : -80 - } - } - } - } - } -} diff --git a/src/test/java/org/elasticsearch/index/query/geo_boundingbox3.json b/src/test/java/org/elasticsearch/index/query/geo_boundingbox3.json deleted file mode 100644 index c8f2dc8ba64..00000000000 --- a/src/test/java/org/elasticsearch/index/query/geo_boundingbox3.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "filtered" : { - "query" : { - "match_all" : {} - }, - "filter" : { - "geo_bounding_box" : { - "location" : { - "top_left" : "40, -70", - "bottom_right" : "30, -80" - } - } - } - } -} diff --git a/src/test/java/org/elasticsearch/index/query/geo_boundingbox4.json b/src/test/java/org/elasticsearch/index/query/geo_boundingbox4.json deleted file mode 100644 index 6a13d2a9fc0..00000000000 --- a/src/test/java/org/elasticsearch/index/query/geo_boundingbox4.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "filtered" : { - "query" : { - "match_all" : {} - }, - "filter" : { - "geo_bounding_box" : { - "location" : { - "top_left" : "drn5x1g8cu2y", - "bottom_right" : "30, -80" - } - } - } - } -} diff --git a/src/test/java/org/elasticsearch/index/query/geo_distance-named.json b/src/test/java/org/elasticsearch/index/query/geo_distance-named.json deleted file mode 100644 index 24ad527e86c..00000000000 --- a/src/test/java/org/elasticsearch/index/query/geo_distance-named.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "filtered" : { - "query" : { - "match_all" : {} - }, - "filter" : { - "geo_distance" : { - "distance" : "12mi", - "location" : { - "lat" : 40, - "lon" : -70 - }, - "_name" : "test" - } - } - } -} diff --git a/src/test/java/org/elasticsearch/index/query/geo_distance1.json b/src/test/java/org/elasticsearch/index/query/geo_distance1.json deleted file mode 100644 index 02406a78b71..00000000000 --- a/src/test/java/org/elasticsearch/index/query/geo_distance1.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "filtered" : { - "query" : { - "match_all" : {} - }, - "filter" : { - "geo_distance" : { - "distance" : "12mi", - "location" : { - "lat" : 40, - "lon" : -70 - } - } - } - } -} diff --git a/src/test/java/org/elasticsearch/index/query/geo_distance10.json b/src/test/java/org/elasticsearch/index/query/geo_distance10.json deleted file mode 100644 index e2f2643c17e..00000000000 --- a/src/test/java/org/elasticsearch/index/query/geo_distance10.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "filtered" : { - "query" : { - "match_all" : {} - }, - "filter" : { - "geo_distance" : { - "distance" : 19.312128, - "unit": "km", - "location" : { - "lat" : 40, - "lon" : -70 - } - } - } - } -} diff --git a/src/test/java/org/elasticsearch/index/query/geo_distance11.json b/src/test/java/org/elasticsearch/index/query/geo_distance11.json deleted file mode 100644 index 1ced101be1c..00000000000 --- a/src/test/java/org/elasticsearch/index/query/geo_distance11.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "filtered" : { - "query" : { - "match_all" : {} - }, - "filter" : { - "geo_distance" : { - "distance" : "19.312128km", - "location" : { - "lat" : 40, - "lon" : -70 - } - } - } - } -} diff --git a/src/test/java/org/elasticsearch/index/query/geo_distance12.json b/src/test/java/org/elasticsearch/index/query/geo_distance12.json deleted file mode 100644 index 68adbf6713a..00000000000 --- a/src/test/java/org/elasticsearch/index/query/geo_distance12.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "filtered" : { - "query" : { - "match_all" : {} - }, - "filter" : { - "geo_distance" : { - "distance" : "12mi", - "unit": "km", - "location" : { - "lat" : 40, - "lon" : -70 - } - } - } - } -} diff --git a/src/test/java/org/elasticsearch/index/query/geo_distance2.json b/src/test/java/org/elasticsearch/index/query/geo_distance2.json deleted file mode 100644 index 33cbfb537ac..00000000000 --- a/src/test/java/org/elasticsearch/index/query/geo_distance2.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "filtered" : { - "query" : { - "match_all" : {} - }, - "filter" : { - "geo_distance" : { - "distance" : "12mi", - "location" : [-70, 40] - } - } - } -} diff --git a/src/test/java/org/elasticsearch/index/query/geo_distance3.json b/src/test/java/org/elasticsearch/index/query/geo_distance3.json deleted file mode 100644 index 7687b16a367..00000000000 --- a/src/test/java/org/elasticsearch/index/query/geo_distance3.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "filtered" : { - "query" : { - "match_all" : {} - }, - "filter" : { - "geo_distance" : { - "distance" : "12mi", - "location" : "40, -70" - } - } - } -} diff --git a/src/test/java/org/elasticsearch/index/query/geo_distance4.json b/src/test/java/org/elasticsearch/index/query/geo_distance4.json deleted file mode 100644 index eaf8d81a9b7..00000000000 --- a/src/test/java/org/elasticsearch/index/query/geo_distance4.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "filtered" : { - "query" : { - "match_all" : {} - }, - "filter" : { - "geo_distance" : { - "distance" : "12mi", - "location" : "drn5x1g8cu2y" - } - } - } -} diff --git a/src/test/java/org/elasticsearch/index/query/geo_distance5.json b/src/test/java/org/elasticsearch/index/query/geo_distance5.json deleted file mode 100644 index 8815f456cc9..00000000000 --- a/src/test/java/org/elasticsearch/index/query/geo_distance5.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "filtered" : { - "query" : { - "match_all" : {} - }, - "filter" : { - "geo_distance" : { - "distance" : 12, - "unit": "mi", - "location" : { - "lat" : 40, - "lon" : -70 - } - } - } - } -} diff --git a/src/test/java/org/elasticsearch/index/query/geo_distance6.json b/src/test/java/org/elasticsearch/index/query/geo_distance6.json deleted file mode 100644 index eb8802a519d..00000000000 --- a/src/test/java/org/elasticsearch/index/query/geo_distance6.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "filtered" : { - "query" : { - "match_all" : {} - }, - "filter" : { - "geo_distance" : { - "distance" : "12", - "unit": "mi", - "location" : { - "lat" : 40, - "lon" : -70 - } - } - } - } -} diff --git a/src/test/java/org/elasticsearch/index/query/geo_distance7.json b/src/test/java/org/elasticsearch/index/query/geo_distance7.json deleted file mode 100644 index c1e33054b23..00000000000 --- a/src/test/java/org/elasticsearch/index/query/geo_distance7.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "filtered" : { - "query" : { - "match_all" : {} - }, - "filter" : { - "geo_distance" : { - "distance" : "19.312128", - "location" : { - "lat" : 40, - "lon" : -70 - } - } - } - } -} diff --git a/src/test/java/org/elasticsearch/index/query/geo_distance8.json b/src/test/java/org/elasticsearch/index/query/geo_distance8.json deleted file mode 100644 index 94c858656bd..00000000000 --- a/src/test/java/org/elasticsearch/index/query/geo_distance8.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "filtered" : { - "query" : { - "match_all" : {} - }, - "filter" : { - "geo_distance" : { - "distance" : 19.312128, - "location" : { - "lat" : 40, - "lon" : -70 - } - } - } - } -} diff --git a/src/test/java/org/elasticsearch/index/query/geo_distance9.json b/src/test/java/org/elasticsearch/index/query/geo_distance9.json deleted file mode 100644 index ff1a1798008..00000000000 --- a/src/test/java/org/elasticsearch/index/query/geo_distance9.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "filtered" : { - "query" : { - "match_all" : {} - }, - "filter" : { - "geo_distance" : { - "distance" : "19.312128", - "unit": "km", - "location" : { - "lat" : 40, - "lon" : -70 - } - } - } - } -} diff --git a/src/test/java/org/elasticsearch/index/query/geo_polygon-named.json b/src/test/java/org/elasticsearch/index/query/geo_polygon-named.json deleted file mode 100644 index e6e3d0957c2..00000000000 --- a/src/test/java/org/elasticsearch/index/query/geo_polygon-named.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "filtered" : { - "query" : { - "match_all" : {} - }, - "filter" : { - "geo_polygon" : { - "location" : { - "points" : [ - [-70, 40], - [-80, 30], - [-90, 20] - ] - }, - "_name" : "test" - } - } - } -} diff --git a/src/test/java/org/elasticsearch/index/query/geo_polygon2.json b/src/test/java/org/elasticsearch/index/query/geo_polygon2.json deleted file mode 100644 index 55568193b9d..00000000000 --- a/src/test/java/org/elasticsearch/index/query/geo_polygon2.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "filtered" : { - "query" : { - "match_all" : {} - }, - "filter" : { - "geo_polygon" : { - "location" : { - "points" : [ - { - "lat" : 40, - "lon" : -70 - }, - { - "lat" : 30, - "lon" : -80 - }, - { - "lat" : 20, - "lon" : -90 - } - ] - } - } - } - } -} diff --git a/src/test/java/org/elasticsearch/index/query/limit-filter.json b/src/test/java/org/elasticsearch/index/query/limit-filter.json deleted file mode 100644 index 240cf5cd856..00000000000 --- a/src/test/java/org/elasticsearch/index/query/limit-filter.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "filtered" : { - "filter" : { - "limit" : { - "value" : 2 - } - }, - "query" : { - "term" : { - "name.first" : "shay" - } - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/mapping.json b/src/test/java/org/elasticsearch/index/query/mapping.json deleted file mode 100644 index 97d0edd7abe..00000000000 --- a/src/test/java/org/elasticsearch/index/query/mapping.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "person" : { - "properties" : { - "location" : { - "type" : "geo_point" - } - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/matchAll.json b/src/test/java/org/elasticsearch/index/query/matchAll.json deleted file mode 100644 index 0bc79b95b55..00000000000 --- a/src/test/java/org/elasticsearch/index/query/matchAll.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - match_all : { - boost : 1.2 - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/mlt.json b/src/test/java/org/elasticsearch/index/query/mlt.json deleted file mode 100644 index 4c6e2a042e6..00000000000 --- a/src/test/java/org/elasticsearch/index/query/mlt.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - more_like_this : { - fields : ["name.first", "name.last"], - like_text : "something", - min_term_freq : 1, - max_query_terms : 12 - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/mltField.json b/src/test/java/org/elasticsearch/index/query/mltField.json deleted file mode 100644 index f9d931edc0f..00000000000 --- a/src/test/java/org/elasticsearch/index/query/mltField.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - more_like_this_field : { - "name.first" : { - like_text : "something", - min_term_freq : 1, - max_query_terms : 12 - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/not-filter.json b/src/test/java/org/elasticsearch/index/query/not-filter.json deleted file mode 100644 index 4156cafb730..00000000000 --- a/src/test/java/org/elasticsearch/index/query/not-filter.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "filtered" : { - "query" : { - "term" : { - "name.first" : "shay" - } - }, - "filter" : { - "not" : { - "filter" : { - "term" : { - "name.first" : "shay1" - } - } - } - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/not-filter2.json b/src/test/java/org/elasticsearch/index/query/not-filter2.json deleted file mode 100644 index 226961689ff..00000000000 --- a/src/test/java/org/elasticsearch/index/query/not-filter2.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "filtered" : { - "query" : { - "term" : { - "name.first" : "shay" - } - }, - "filter" : { - "not" : { - "term" : { - "name.first" : "shay1" - } - } - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/not-filter3.json b/src/test/java/org/elasticsearch/index/query/not-filter3.json deleted file mode 100644 index 2b0947a48f6..00000000000 --- a/src/test/java/org/elasticsearch/index/query/not-filter3.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "filtered" : { - "filter" : { - "not" : { - "term" : { - "name.first" : "shay1" - } - } - }, - "query" : { - "term" : { - "name.first" : "shay" - } - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/numeric_range-filter.json b/src/test/java/org/elasticsearch/index/query/numeric_range-filter.json deleted file mode 100644 index 68a0e820a39..00000000000 --- a/src/test/java/org/elasticsearch/index/query/numeric_range-filter.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "filtered" : { - "query" : { - "term" : { - "name.first" : "shay" - } - }, - "filter" : { - "numeric_range" : { - "age" : { - "from" : "23", - "to" : "54", - "include_lower" : true, - "include_upper": false - } - } - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/or-filter.json b/src/test/java/org/elasticsearch/index/query/or-filter.json deleted file mode 100644 index 8c6ece1f350..00000000000 --- a/src/test/java/org/elasticsearch/index/query/or-filter.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "filtered" : { - "query" : { - "term" : { - "name.first" : "shay" - } - }, - "filter" : { - "or" : { - "filters" : [ - { - "term" : { - "name.first" : "shay1" - } - }, - { - "term" : { - "name.first" : "shay4" - } - } - ] - } - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/or-filter2.json b/src/test/java/org/elasticsearch/index/query/or-filter2.json deleted file mode 100644 index 1c0799bdb69..00000000000 --- a/src/test/java/org/elasticsearch/index/query/or-filter2.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "filtered" : { - "query" : { - "term" : { - "name.first" : "shay" - } - }, - "filter" : { - "or" : [ - { - "term" : { - "name.first" : "shay1" - } - }, - { - "term" : { - "name.first" : "shay4" - } - } - ] - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/prefix-boost.json b/src/test/java/org/elasticsearch/index/query/prefix-boost.json deleted file mode 100644 index 0e5e09d7c4d..00000000000 --- a/src/test/java/org/elasticsearch/index/query/prefix-boost.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "prefix" : { - "name.first" : { - "value" : "sh", - "boost" : 1.2 - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/prefix-filter-named.json b/src/test/java/org/elasticsearch/index/query/prefix-filter-named.json deleted file mode 100644 index 6f0465bf11d..00000000000 --- a/src/test/java/org/elasticsearch/index/query/prefix-filter-named.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "filtered" : { - "query" : { - "term" : { - "name.first" : "shay" - } - }, - "filter" : { - "prefix" : { - "name.first" : "sh", - "_name" : "test" - } - } - } -} diff --git a/src/test/java/org/elasticsearch/index/query/prefix-filter.json b/src/test/java/org/elasticsearch/index/query/prefix-filter.json deleted file mode 100644 index a8f46d48cc4..00000000000 --- a/src/test/java/org/elasticsearch/index/query/prefix-filter.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "filtered" : { - "query" : { - "term" : { - "name.first" : "shay" - } - }, - "filter" : { - "prefix" : { - "name.first" : "sh" - } - } - } -} diff --git a/src/test/java/org/elasticsearch/index/query/prefix-with-boost.json b/src/test/java/org/elasticsearch/index/query/prefix-with-boost.json deleted file mode 100644 index 962d0988161..00000000000 --- a/src/test/java/org/elasticsearch/index/query/prefix-with-boost.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - prefix : { - "name.first" : { - prefix : "sh", - boost : 2.0 - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/prefix.json b/src/test/java/org/elasticsearch/index/query/prefix.json deleted file mode 100644 index d17c976d6df..00000000000 --- a/src/test/java/org/elasticsearch/index/query/prefix.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - prefix : { - "name.first" : "sh" - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/query-fields-match.json b/src/test/java/org/elasticsearch/index/query/query-fields-match.json deleted file mode 100644 index 0805cb4d10a..00000000000 --- a/src/test/java/org/elasticsearch/index/query/query-fields-match.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - query_string : { - fields : ["name.*"], - use_dis_max : false, - query: "test" - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/query-fields1.json b/src/test/java/org/elasticsearch/index/query/query-fields1.json deleted file mode 100644 index c268b1fa906..00000000000 --- a/src/test/java/org/elasticsearch/index/query/query-fields1.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - query_string : { - fields : ["content", "name"], - use_dis_max : false, - query: "test" - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/query-fields2.json b/src/test/java/org/elasticsearch/index/query/query-fields2.json deleted file mode 100644 index ca4b3d33dd5..00000000000 --- a/src/test/java/org/elasticsearch/index/query/query-fields2.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - query_string : { - fields : ["content", "name"], - use_dis_max : true, - query: "test" - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/query-fields3.json b/src/test/java/org/elasticsearch/index/query/query-fields3.json deleted file mode 100644 index 33c79b4aa15..00000000000 --- a/src/test/java/org/elasticsearch/index/query/query-fields3.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - query_string : { - fields : ["content^2.2", "name"], - use_dis_max : true, - query: "test" - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/query-filter.json b/src/test/java/org/elasticsearch/index/query/query-filter.json deleted file mode 100644 index 4ceaabb7bca..00000000000 --- a/src/test/java/org/elasticsearch/index/query/query-filter.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - filtered : { - query : { - term : { - "name.first" : "shay" - } - }, - filter : { - query : { - term : { - "name.last" : "banon" - } - } - } - } -} diff --git a/src/test/java/org/elasticsearch/index/query/query.json b/src/test/java/org/elasticsearch/index/query/query.json deleted file mode 100644 index b7802351e95..00000000000 --- a/src/test/java/org/elasticsearch/index/query/query.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - query_string : { - default_field : "content", - phrase_slop : 1, - query: "test" - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/query2.json b/src/test/java/org/elasticsearch/index/query/query2.json deleted file mode 100644 index 35bb3249e2e..00000000000 --- a/src/test/java/org/elasticsearch/index/query/query2.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - query_string : { - default_field : "age", - query: "12~0.2" - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/range-filter-named.json b/src/test/java/org/elasticsearch/index/query/range-filter-named.json deleted file mode 100644 index 3c990bf896f..00000000000 --- a/src/test/java/org/elasticsearch/index/query/range-filter-named.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "filtered" : { - "query" : { - "term" : { - "name.first" : "shay" - } - }, - "filter" : { - "range" : { - "age" : { - "from" : "23", - "to" : "54", - "include_lower" : true, - "include_upper": false - }, - "_name" : "test" - } - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/range-filter.json b/src/test/java/org/elasticsearch/index/query/range-filter.json deleted file mode 100644 index a926b093475..00000000000 --- a/src/test/java/org/elasticsearch/index/query/range-filter.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - filtered : { - query : { - term : { - "name.first" : "shay" - } - }, - filter : { - range : { - age : { - from : "23", - to : "54", - include_lower : true, - include_upper: false - } - } - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/range.json b/src/test/java/org/elasticsearch/index/query/range.json deleted file mode 100644 index 3c98d1352fb..00000000000 --- a/src/test/java/org/elasticsearch/index/query/range.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - range : { - age : { - from : "23", - to : "54", - include_lower : true, - include_upper: false - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/range2.json b/src/test/java/org/elasticsearch/index/query/range2.json deleted file mode 100644 index cf3c47bad4a..00000000000 --- a/src/test/java/org/elasticsearch/index/query/range2.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - range : { - age : { - gte : "23", - lt : "54" - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/spanFirst.json b/src/test/java/org/elasticsearch/index/query/spanFirst.json deleted file mode 100644 index a4f9532a41a..00000000000 --- a/src/test/java/org/elasticsearch/index/query/spanFirst.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - span_first : { - match : { - span_term : { - age : 34 - } - }, - end : 12 - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/spanNear.json b/src/test/java/org/elasticsearch/index/query/spanNear.json deleted file mode 100644 index 643fc443f88..00000000000 --- a/src/test/java/org/elasticsearch/index/query/spanNear.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - span_near : { - clauses : [ - { - span_term : { - age : 34 - } - }, - { - span_term : { - age : 35 - } - }, - { - span_term : { - age : 36 - } - } - ], - slop : 12, - in_order : false, - collect_payloads : false - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/spanNot.json b/src/test/java/org/elasticsearch/index/query/spanNot.json deleted file mode 100644 index 0fe035ddda8..00000000000 --- a/src/test/java/org/elasticsearch/index/query/spanNot.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - span_not : { - include : { - span_term : { - age : 34 - } - }, - exclude : { - span_term : { - age : 35 - } - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/spanOr.json b/src/test/java/org/elasticsearch/index/query/spanOr.json deleted file mode 100644 index 74c90ebc632..00000000000 --- a/src/test/java/org/elasticsearch/index/query/spanOr.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - span_or : { - clauses : [ - { - span_term : { - age : 34 - } - }, - { - span_term : { - age : 35 - } - }, - { - span_term : { - age : 36 - } - } - ] - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/spanOr2.json b/src/test/java/org/elasticsearch/index/query/spanOr2.json deleted file mode 100644 index e323898ace5..00000000000 --- a/src/test/java/org/elasticsearch/index/query/spanOr2.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "span_or" : { - "clauses" : [ - { - "span_term" : { - "age" : { - "value" : 34, - "boost" : 1.0 - } - } - }, - { - "span_term" : { - "age" : { - "value" : 35, - "boost" : 1.0 - } - } - }, - { - "span_term" : { - "age" : { - "value" : 36, - "boost" : 1.0 - } - } - } - ] - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/spanTerm.json b/src/test/java/org/elasticsearch/index/query/spanTerm.json deleted file mode 100644 index e99a6e01466..00000000000 --- a/src/test/java/org/elasticsearch/index/query/spanTerm.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - span_term : { - age : 34 - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/term-filter-named.json b/src/test/java/org/elasticsearch/index/query/term-filter-named.json deleted file mode 100644 index 1fc5a08040d..00000000000 --- a/src/test/java/org/elasticsearch/index/query/term-filter-named.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "filtered" : { - "query" : { - "term" : { - "name.first" : "shay" - } - }, - "filter" : { - "term" : { - "name.last" : "banon", - "_name" : "test" - } - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/term-filter.json b/src/test/java/org/elasticsearch/index/query/term-filter.json deleted file mode 100644 index 9db44a6db1e..00000000000 --- a/src/test/java/org/elasticsearch/index/query/term-filter.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "filtered" : { - "query" : { - "term" : { - "name.first" : "shay" - } - }, - "filter" : { - "term" : { - "name.last" : "banon" - } - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/term-with-boost.json b/src/test/java/org/elasticsearch/index/query/term-with-boost.json deleted file mode 100644 index 9b4ea06f753..00000000000 --- a/src/test/java/org/elasticsearch/index/query/term-with-boost.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - term : { - age : { - value : 34, - boost : 2.0 - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/term.json b/src/test/java/org/elasticsearch/index/query/term.json deleted file mode 100644 index 6e00ffca49c..00000000000 --- a/src/test/java/org/elasticsearch/index/query/term.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - term : { - age : 34 - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/terms-filter-named.json b/src/test/java/org/elasticsearch/index/query/terms-filter-named.json deleted file mode 100644 index ffc687a3673..00000000000 --- a/src/test/java/org/elasticsearch/index/query/terms-filter-named.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "filtered" : { - "query" : { - "term" : { - "name.first" : "shay" - } - }, - "filter" : { - "terms" : { - "name.last" : ["banon", "kimchy"], - "_name" : "test" - } - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/terms-filter.json b/src/test/java/org/elasticsearch/index/query/terms-filter.json deleted file mode 100644 index 59279e7975c..00000000000 --- a/src/test/java/org/elasticsearch/index/query/terms-filter.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "filtered" : { - "query" : { - "term" : { - "name.first" : "shay" - } - }, - "filter" : { - "terms" : { - "name.last" : ["banon", "kimchy"] - } - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/terms-query.json b/src/test/java/org/elasticsearch/index/query/terms-query.json deleted file mode 100644 index bcb11ebda55..00000000000 --- a/src/test/java/org/elasticsearch/index/query/terms-query.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "terms" : { - "name.first" : ["shay", "test"] - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/text1.json b/src/test/java/org/elasticsearch/index/query/text1.json deleted file mode 100644 index 92902998f29..00000000000 --- a/src/test/java/org/elasticsearch/index/query/text1.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "text" : { - "name.first" : "aaa bbb" - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/text2.json b/src/test/java/org/elasticsearch/index/query/text2.json deleted file mode 100644 index 641b6665324..00000000000 --- a/src/test/java/org/elasticsearch/index/query/text2.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "text" : { - "name.first" : { - "query" : "aaa bbb", - "boost" : 1.5 - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/text3.json b/src/test/java/org/elasticsearch/index/query/text3.json deleted file mode 100644 index cd40e0cf078..00000000000 --- a/src/test/java/org/elasticsearch/index/query/text3.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "text" : { - "name.first" : { - "query" : "aaa bbb", - "type" : "phrase" - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/text4.json b/src/test/java/org/elasticsearch/index/query/text4.json deleted file mode 100644 index 76309f37f85..00000000000 --- a/src/test/java/org/elasticsearch/index/query/text4.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "text" : { - "name.first" : { - "query" : "aaa bbb", - "type" : "phrase_prefix" - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/text4_2.json b/src/test/java/org/elasticsearch/index/query/text4_2.json deleted file mode 100644 index 56ed5ee37ec..00000000000 --- a/src/test/java/org/elasticsearch/index/query/text4_2.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "text_phrase_prefix" : { - "name.first" : { - "query" : "aaa bbb" - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/wildcard-boost.json b/src/test/java/org/elasticsearch/index/query/wildcard-boost.json deleted file mode 100644 index ba8a7c20800..00000000000 --- a/src/test/java/org/elasticsearch/index/query/wildcard-boost.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "wildcard" : { - "name.first" : { - "value" : "sh*", - "boost" : 1.2 - } - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/wildcard.json b/src/test/java/org/elasticsearch/index/query/wildcard.json deleted file mode 100644 index de587144348..00000000000 --- a/src/test/java/org/elasticsearch/index/query/wildcard.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - wildcard : { - "name.first" : "sh*" - } -} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/integration/AbstractNodesTests.java b/src/test/java/org/elasticsearch/test/integration/AbstractNodesTests.java index 0956cebbe71..ab1bb576d90 100644 --- a/src/test/java/org/elasticsearch/test/integration/AbstractNodesTests.java +++ b/src/test/java/org/elasticsearch/test/integration/AbstractNodesTests.java @@ -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.node.Node; import java.util.Map; -import static org.elasticsearch.common.collect.Maps.*; -import static org.elasticsearch.common.settings.ImmutableSettings.Builder.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.elasticsearch.node.NodeBuilder.*; +import static com.google.common.collect.Maps.newHashMap; +import static org.elasticsearch.common.settings.ImmutableSettings.Builder.EMPTY_SETTINGS; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.elasticsearch.node.NodeBuilder.nodeBuilder; public abstract class AbstractNodesTests { diff --git a/src/test/java/org/elasticsearch/test/integration/aliases/IndexAliasesTests.java b/src/test/java/org/elasticsearch/test/integration/aliases/IndexAliasesTests.java index a5370b7af96..9190b81fa39 100644 --- a/src/test/java/org/elasticsearch/test/integration/aliases/IndexAliasesTests.java +++ b/src/test/java/org/elasticsearch/test/integration/aliases/IndexAliasesTests.java @@ -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 @@ -46,15 +46,15 @@ import java.util.Set; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import static com.google.common.collect.Sets.newHashSet; import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.common.collect.Sets.*; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; -import static org.elasticsearch.index.query.FilterBuilders.*; -import static org.hamcrest.MatcherAssert.*; +import static org.elasticsearch.index.query.FilterBuilders.termFilter; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** - * @author kimchy (shay.banon) + * */ @Test public class IndexAliasesTests extends AbstractNodesTests { @@ -65,7 +65,8 @@ public class IndexAliasesTests extends AbstractNodesTests { protected Random random = new Random(); - @BeforeClass public void startNodes() { + @BeforeClass + public void startNodes() { startNode("server1"); startNode("server2"); client1 = getClient1(); @@ -73,7 +74,8 @@ public class IndexAliasesTests extends AbstractNodesTests { clients = new Client[]{client1, client2}; } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { client1.close(); client2.close(); closeAllNodes(); @@ -91,7 +93,8 @@ public class IndexAliasesTests extends AbstractNodesTests { return clients[random.nextInt(clients.length)]; } - @Test public void testAliases() throws Exception { + @Test + public void testAliases() throws Exception { // delete all indices client1.admin().indices().prepareDelete().execute().actionGet(); @@ -137,7 +140,8 @@ public class IndexAliasesTests extends AbstractNodesTests { assertThat(indexResponse.index(), equalTo("test_x")); } - @Test public void testFailedFilter() throws Exception { + @Test + public void testFailedFilter() throws Exception { // delete all indices client1.admin().indices().prepareDelete().execute().actionGet(); @@ -159,7 +163,8 @@ public class IndexAliasesTests extends AbstractNodesTests { } } - @Test public void testFilteringAliases() throws Exception { + @Test + public void testFilteringAliases() throws Exception { // delete all indices client1.admin().indices().prepareDelete().execute().actionGet(); @@ -184,7 +189,8 @@ public class IndexAliasesTests extends AbstractNodesTests { } - @Test public void testSearchingFilteringAliasesSingleIndex() throws Exception { + @Test + public void testSearchingFilteringAliasesSingleIndex() throws Exception { // delete all indices client1.admin().indices().prepareDelete().execute().actionGet(); @@ -233,7 +239,8 @@ public class IndexAliasesTests extends AbstractNodesTests { assertHits(searchResponse.hits(), "1", "2", "3", "4"); } - @Test public void testSearchingFilteringAliasesTwoIndices() throws Exception { + @Test + public void testSearchingFilteringAliasesTwoIndices() throws Exception { // delete all indices client1.admin().indices().prepareDelete().execute().actionGet(); @@ -303,7 +310,8 @@ public class IndexAliasesTests extends AbstractNodesTests { assertThat(client1.prepareCount("foos", "aliasToTests").setQuery(QueryBuilders.termQuery("name", "something")).execute().actionGet().count(), equalTo(2L)); } - @Test public void testSearchingFilteringAliasesMultipleIndices() throws Exception { + @Test + public void testSearchingFilteringAliasesMultipleIndices() throws Exception { // delete all indices client1.admin().indices().prepareDelete().execute().actionGet(); @@ -371,7 +379,8 @@ public class IndexAliasesTests extends AbstractNodesTests { } - @Test public void testDeletingByQueryFilteringAliases() throws Exception { + @Test + public void testDeletingByQueryFilteringAliases() throws Exception { // delete all indices client1.admin().indices().prepareDelete().execute().actionGet(); @@ -439,7 +448,8 @@ public class IndexAliasesTests extends AbstractNodesTests { assertHits(searchResponse.hits(), "4"); } - @Test public void testWaitForAliasCreationMultipleShards() throws Exception { + @Test + public void testWaitForAliasCreationMultipleShards() throws Exception { // delete all indices client1.admin().indices().prepareDelete().execute().actionGet(); @@ -459,7 +469,8 @@ public class IndexAliasesTests extends AbstractNodesTests { } - @Test public void testWaitForAliasCreationSingleShard() throws Exception { + @Test + public void testWaitForAliasCreationSingleShard() throws Exception { // delete all indices client1.admin().indices().prepareDelete().execute().actionGet(); @@ -478,7 +489,8 @@ public class IndexAliasesTests extends AbstractNodesTests { } } - @Test public void testWaitForAliasSimultaneousUpdate() throws Exception { + @Test + public void testWaitForAliasSimultaneousUpdate() throws Exception { final int aliasCount = 10; // delete all indices client1.admin().indices().prepareDelete().execute().actionGet(); @@ -496,7 +508,8 @@ public class IndexAliasesTests extends AbstractNodesTests { for (int i = 0; i < aliasCount; i++) { final String aliasName = "alias" + i; executor.submit(new Runnable() { - @Override public void run() { + @Override + public void run() { assertThat(client1.admin().indices().prepareAliases().addAlias("test", aliasName).execute().actionGet().acknowledged(), equalTo(true)); client2.index(indexRequest(aliasName).type("type1").id("1").source(source("1", "test")).refresh(true)).actionGet(); } @@ -506,7 +519,8 @@ public class IndexAliasesTests extends AbstractNodesTests { } - @Test public void testWaitForAliasTimeout() throws Exception { + @Test + public void testWaitForAliasTimeout() throws Exception { client1.admin().indices().prepareDelete().execute().actionGet(); logger.info("--> creating index [test]"); @@ -527,7 +541,8 @@ public class IndexAliasesTests extends AbstractNodesTests { } - @Test public void testSameAlias() throws Exception { + @Test + public void testSameAlias() throws Exception { client1.admin().indices().prepareDelete().execute().actionGet(); logger.info("--> creating index [test]"); diff --git a/src/test/java/org/elasticsearch/test/integration/broadcast/BroadcastActionsTests.java b/src/test/java/org/elasticsearch/test/integration/broadcast/BroadcastActionsTests.java index ae376dcb6f8..358aade8967 100644 --- a/src/test/java/org/elasticsearch/test/integration/broadcast/BroadcastActionsTests.java +++ b/src/test/java/org/elasticsearch/test/integration/broadcast/BroadcastActionsTests.java @@ -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,20 +36,23 @@ import org.testng.annotations.Test; import java.io.IOException; import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.index.query.QueryBuilders.termQuery; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class BroadcastActionsTests extends AbstractNodesTests { - @AfterMethod public void closeServers() { + @AfterMethod + public void closeServers() { closeAllNodes(); } - @Test public void testBroadcastOperations() throws IOException { + @Test + public void testBroadcastOperations() throws IOException { startNode("server1"); client("server1").admin().indices().prepareCreate("test").execute().actionGet(5000); diff --git a/src/test/java/org/elasticsearch/test/integration/client/transport/ClientTransportTwoNodesSearchTests.java b/src/test/java/org/elasticsearch/test/integration/client/transport/ClientTransportTwoNodesSearchTests.java index f35c3341cd4..c1897035b4a 100644 --- a/src/test/java/org/elasticsearch/test/integration/client/transport/ClientTransportTwoNodesSearchTests.java +++ b/src/test/java/org/elasticsearch/test/integration/client/transport/ClientTransportTwoNodesSearchTests.java @@ -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,11 +29,12 @@ import org.elasticsearch.test.integration.search.basic.TransportTwoNodesSearchTe import org.elasticsearch.transport.TransportService; /** - * @author kimchy (shay.banon) + * */ public class ClientTransportTwoNodesSearchTests extends TransportTwoNodesSearchTests { - @Override protected Client getClient() { + @Override + protected Client getClient() { TransportAddress server1Address = ((InternalNode) node("server1")).injector().getInstance(TransportService.class).boundAddress().publishAddress(); TransportClient client = new TransportClient(ImmutableSettings .settingsBuilder() diff --git a/src/test/java/org/elasticsearch/test/integration/client/transport/DiscoveryTransportClientTests.java b/src/test/java/org/elasticsearch/test/integration/client/transport/DiscoveryTransportClientTests.java index b210866c79a..202969df818 100644 --- a/src/test/java/org/elasticsearch/test/integration/client/transport/DiscoveryTransportClientTests.java +++ b/src/test/java/org/elasticsearch/test/integration/client/transport/DiscoveryTransportClientTests.java @@ -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,16 +25,18 @@ import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.test.integration.AbstractNodesTests; import org.testng.annotations.AfterMethod; -import static org.elasticsearch.client.Requests.*; +import static org.elasticsearch.client.Requests.createIndexRequest; +import static org.elasticsearch.client.Requests.pingSingleRequest; /** - * @author kimchy (Shay Banon) + * */ public class DiscoveryTransportClientTests extends AbstractNodesTests { private TransportClient client; - @AfterMethod public void closeServers() { + @AfterMethod + public void closeServers() { if (client != null) { client.close(); } diff --git a/src/test/java/org/elasticsearch/test/integration/client/transport/TransportClientDocumentActionsTests.java b/src/test/java/org/elasticsearch/test/integration/client/transport/TransportClientDocumentActionsTests.java index 11d6b9c0d31..bed87ea860e 100644 --- a/src/test/java/org/elasticsearch/test/integration/client/transport/TransportClientDocumentActionsTests.java +++ b/src/test/java/org/elasticsearch/test/integration/client/transport/TransportClientDocumentActionsTests.java @@ -27,14 +27,15 @@ import org.elasticsearch.node.internal.InternalNode; import org.elasticsearch.test.integration.document.DocumentActionsTests; import org.elasticsearch.transport.TransportService; -import static org.elasticsearch.common.settings.ImmutableSettings.*; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; /** - * @author kimchy (shay.banon) + * */ public class TransportClientDocumentActionsTests extends DocumentActionsTests { - @Override protected Client getClient1() { + @Override + protected Client getClient1() { TransportAddress server1Address = ((InternalNode) node("server1")).injector().getInstance(TransportService.class).boundAddress().publishAddress(); TransportClient client = new TransportClient(settingsBuilder() .put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress().getHostName()) @@ -43,7 +44,8 @@ public class TransportClientDocumentActionsTests extends DocumentActionsTests { return client; } - @Override protected Client getClient2() { + @Override + protected Client getClient2() { TransportAddress server2Address = ((InternalNode) node("server2")).injector().getInstance(TransportService.class).boundAddress().publishAddress(); TransportClient client = new TransportClient(settingsBuilder() .put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress().getHostName()) diff --git a/src/test/java/org/elasticsearch/test/integration/client/transport/TransportClientMoreLikeThisActionTests.java b/src/test/java/org/elasticsearch/test/integration/client/transport/TransportClientMoreLikeThisActionTests.java index 120877e3295..a81140983ab 100644 --- a/src/test/java/org/elasticsearch/test/integration/client/transport/TransportClientMoreLikeThisActionTests.java +++ b/src/test/java/org/elasticsearch/test/integration/client/transport/TransportClientMoreLikeThisActionTests.java @@ -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,14 +27,15 @@ import org.elasticsearch.node.internal.InternalNode; import org.elasticsearch.test.integration.document.MoreLikeThisActionTests; import org.elasticsearch.transport.TransportService; -import static org.elasticsearch.common.settings.ImmutableSettings.*; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; /** - * @author kimchy (shay.banon) + * */ public class TransportClientMoreLikeThisActionTests extends MoreLikeThisActionTests { - @Override protected Client getClient1() { + @Override + protected Client getClient1() { TransportAddress server1Address = ((InternalNode) node("server1")).injector().getInstance(TransportService.class).boundAddress().publishAddress(); TransportClient client = new TransportClient(settingsBuilder() .put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress().getHostName()) @@ -43,7 +44,8 @@ public class TransportClientMoreLikeThisActionTests extends MoreLikeThisActionTe return client; } - @Override protected Client getClient2() { + @Override + protected Client getClient2() { TransportAddress server1Address = ((InternalNode) node("server2")).injector().getInstance(TransportService.class).boundAddress().publishAddress(); TransportClient client = new TransportClient(settingsBuilder() .put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress().getHostName()) diff --git a/src/test/java/org/elasticsearch/test/integration/client/transport/TransportClientSniffDocumentActionsTests.java b/src/test/java/org/elasticsearch/test/integration/client/transport/TransportClientSniffDocumentActionsTests.java index b88ed6bba80..0afba385fdb 100644 --- a/src/test/java/org/elasticsearch/test/integration/client/transport/TransportClientSniffDocumentActionsTests.java +++ b/src/test/java/org/elasticsearch/test/integration/client/transport/TransportClientSniffDocumentActionsTests.java @@ -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,14 +27,15 @@ import org.elasticsearch.node.internal.InternalNode; import org.elasticsearch.test.integration.document.DocumentActionsTests; import org.elasticsearch.transport.TransportService; -import static org.elasticsearch.common.settings.ImmutableSettings.*; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; /** - * @author kimchy (shay.banon) + * */ public class TransportClientSniffDocumentActionsTests extends DocumentActionsTests { - @Override protected Client getClient1() { + @Override + protected Client getClient1() { TransportAddress server1Address = ((InternalNode) node("server1")).injector().getInstance(TransportService.class).boundAddress().publishAddress(); TransportClient client = new TransportClient(settingsBuilder() .put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress().getHostName()) @@ -43,7 +44,8 @@ public class TransportClientSniffDocumentActionsTests extends DocumentActionsTes return client; } - @Override protected Client getClient2() { + @Override + protected Client getClient2() { TransportAddress server2Address = ((InternalNode) node("server2")).injector().getInstance(TransportService.class).boundAddress().publishAddress(); TransportClient client = new TransportClient(settingsBuilder() .put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress().getHostName()) diff --git a/src/test/java/org/elasticsearch/test/integration/cluster/AbstractZenNodesTests.java b/src/test/java/org/elasticsearch/test/integration/cluster/AbstractZenNodesTests.java index ed611b8586b..8be12f1564f 100644 --- a/src/test/java/org/elasticsearch/test/integration/cluster/AbstractZenNodesTests.java +++ b/src/test/java/org/elasticsearch/test/integration/cluster/AbstractZenNodesTests.java @@ -22,14 +22,15 @@ package org.elasticsearch.test.integration.cluster; import org.elasticsearch.test.integration.AbstractNodesTests; import org.testng.annotations.BeforeClass; -import static org.elasticsearch.common.settings.ImmutableSettings.*; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; /** * */ public class AbstractZenNodesTests extends AbstractNodesTests { - @BeforeClass public void setUpZenDiscoSettings() { + @BeforeClass + public void setUpZenDiscoSettings() { // we force zen discovery here since it has specific handling for specific master / data nodes // and disconnections putDefaultSettings(settingsBuilder().put("discovery.type", "zen")); diff --git a/src/test/java/org/elasticsearch/test/integration/cluster/ClusterHealthTests.java b/src/test/java/org/elasticsearch/test/integration/cluster/ClusterHealthTests.java index 1a3995d3240..806358cfc3b 100644 --- a/src/test/java/org/elasticsearch/test/integration/cluster/ClusterHealthTests.java +++ b/src/test/java/org/elasticsearch/test/integration/cluster/ClusterHealthTests.java @@ -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,18 @@ import org.elasticsearch.test.integration.AbstractNodesTests; import org.testng.annotations.AfterMethod; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; public class ClusterHealthTests extends AbstractNodesTests { - @AfterMethod public void closeNodes() { + @AfterMethod + public void closeNodes() { closeAllNodes(); } - @Test public void testHealth() { + @Test + public void testHealth() { Node node1 = startNode("node1"); logger.info("--> running cluster health on an index that does not exists"); ClusterHealthResponse healthResponse = node1.client().admin().cluster().prepareHealth("test").setWaitForYellowStatus().setTimeout("1s").execute().actionGet(); diff --git a/src/test/java/org/elasticsearch/test/integration/cluster/MinimumMasterNodesTests.java b/src/test/java/org/elasticsearch/test/integration/cluster/MinimumMasterNodesTests.java index 873d4a72065..3fe1a7484d8 100644 --- a/src/test/java/org/elasticsearch/test/integration/cluster/MinimumMasterNodesTests.java +++ b/src/test/java/org/elasticsearch/test/integration/cluster/MinimumMasterNodesTests.java @@ -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,11 +19,11 @@ package org.elasticsearch.test.integration.cluster; +import com.google.common.collect.Sets; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.node.DiscoveryNode; -import org.elasticsearch.common.collect.Sets; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.discovery.Discovery; import org.elasticsearch.env.NodeEnvironment; @@ -36,15 +36,16 @@ import org.testng.annotations.Test; import java.util.LinkedList; import java.util.Set; -import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.client.Requests.clusterHealthRequest; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; @Test public class MinimumMasterNodesTests extends AbstractZenNodesTests { - @AfterMethod public void cleanAndCloseNodes() throws Exception { + @AfterMethod + public void cleanAndCloseNodes() throws Exception { for (int i = 0; i < 10; i++) { if (node("node" + i) != null) { node("node" + i).stop(); @@ -57,7 +58,8 @@ public class MinimumMasterNodesTests extends AbstractZenNodesTests { closeAllNodes(); } - @Test public void simpleMinimumMasterNodes() throws Exception { + @Test + public void simpleMinimumMasterNodes() throws Exception { logger.info("--> cleaning nodes"); buildNode("node1", settingsBuilder().put("gateway.type", "local")); buildNode("node2", settingsBuilder().put("gateway.type", "local")); @@ -181,7 +183,8 @@ public class MinimumMasterNodesTests extends AbstractZenNodesTests { } } - @Test public void multipleNodesShutdownNonMasterNodes() throws Exception { + @Test + public void multipleNodesShutdownNonMasterNodes() throws Exception { logger.info("--> cleaning nodes"); buildNode("node1", settingsBuilder().put("gateway.type", "local")); buildNode("node2", settingsBuilder().put("gateway.type", "local")); diff --git a/src/test/java/org/elasticsearch/test/integration/cluster/SimpleDataNodesTests.java b/src/test/java/org/elasticsearch/test/integration/cluster/SimpleDataNodesTests.java index c2412c12b06..d6e1f5748b2 100644 --- a/src/test/java/org/elasticsearch/test/integration/cluster/SimpleDataNodesTests.java +++ b/src/test/java/org/elasticsearch/test/integration/cluster/SimpleDataNodesTests.java @@ -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,22 +26,24 @@ import org.elasticsearch.test.integration.AbstractNodesTests; import org.testng.annotations.AfterMethod; import org.testng.annotations.Test; -import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.elasticsearch.common.unit.TimeValue.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.client.Requests.createIndexRequest; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class SimpleDataNodesTests extends AbstractNodesTests { - @AfterMethod public void closeNodes() { + @AfterMethod + public void closeNodes() { closeAllNodes(); } - @Test public void testDataNodes() throws Exception { + @Test + public void testDataNodes() throws Exception { startNode("nonData1", settingsBuilder().put("node.data", false).build()); client("nonData1").admin().indices().create(createIndexRequest("test")).actionGet(); try { diff --git a/src/test/java/org/elasticsearch/test/integration/cluster/SpecificMasterNodesTests.java b/src/test/java/org/elasticsearch/test/integration/cluster/SpecificMasterNodesTests.java index 2afc44245d0..4c8aee51edc 100644 --- a/src/test/java/org/elasticsearch/test/integration/cluster/SpecificMasterNodesTests.java +++ b/src/test/java/org/elasticsearch/test/integration/cluster/SpecificMasterNodesTests.java @@ -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,20 +23,23 @@ import org.elasticsearch.discovery.MasterNotDiscoveredException; import org.testng.annotations.AfterMethod; import org.testng.annotations.Test; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.nullValue; /** - * @author kimchy (shay.banon) + * */ public class SpecificMasterNodesTests extends AbstractZenNodesTests { - @AfterMethod public void closeNodes() { + @AfterMethod + public void closeNodes() { closeAllNodes(); } - @Test public void simpleOnlyMasterNodeElection() { + @Test + public void simpleOnlyMasterNodeElection() { logger.info("--> start data node / non master node"); startNode("data1", settingsBuilder().put("node.data", true).put("node.master", false).put("discovery.initial_state_timeout", "1s")); try { @@ -70,7 +73,8 @@ public class SpecificMasterNodesTests extends AbstractZenNodesTests { closeNode("master1"); } - @Test public void electOnlyBetweenMasterNodes() { + @Test + public void electOnlyBetweenMasterNodes() { logger.info("--> start data node / non master node"); startNode("data1", settingsBuilder().put("node.data", true).put("node.master", false).put("discovery.initial_state_timeout", "1s")); try { diff --git a/src/test/java/org/elasticsearch/test/integration/cluster/allocation/AwarenessAllocationTests.java b/src/test/java/org/elasticsearch/test/integration/cluster/allocation/AwarenessAllocationTests.java index ca911c0010f..2eb87b9855f 100644 --- a/src/test/java/org/elasticsearch/test/integration/cluster/allocation/AwarenessAllocationTests.java +++ b/src/test/java/org/elasticsearch/test/integration/cluster/allocation/AwarenessAllocationTests.java @@ -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.test.integration.cluster.allocation; +import gnu.trove.map.hash.TObjectIntHashMap; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.routing.IndexRoutingTable; @@ -28,13 +29,12 @@ import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.trove.map.hash.TObjectIntHashMap; import org.elasticsearch.test.integration.AbstractNodesTests; import org.testng.annotations.AfterMethod; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** */ @@ -43,11 +43,13 @@ public class AwarenessAllocationTests extends AbstractNodesTests { private final ESLogger logger = Loggers.getLogger(AwarenessAllocationTests.class); - @AfterMethod public void cleanAndCloseNodes() throws Exception { + @AfterMethod + public void cleanAndCloseNodes() throws Exception { closeAllNodes(); } - @Test public void testSimpleAwareness() throws Exception { + @Test + public void testSimpleAwareness() throws Exception { Settings commonSettings = ImmutableSettings.settingsBuilder() .put("cluster.routing.schedule", "10ms") .put("cluster.routing.allocation.awareness.attributes", "rack_id") diff --git a/src/test/java/org/elasticsearch/test/integration/cluster/allocation/FilteringAllocationTests.java b/src/test/java/org/elasticsearch/test/integration/cluster/allocation/FilteringAllocationTests.java index 1efc14aa966..705054fc99f 100644 --- a/src/test/java/org/elasticsearch/test/integration/cluster/allocation/FilteringAllocationTests.java +++ b/src/test/java/org/elasticsearch/test/integration/cluster/allocation/FilteringAllocationTests.java @@ -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,9 +31,9 @@ import org.elasticsearch.test.integration.AbstractNodesTests; import org.testng.annotations.AfterMethod; import org.testng.annotations.Test; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** */ @@ -41,11 +41,13 @@ public class FilteringAllocationTests extends AbstractNodesTests { private final ESLogger logger = Loggers.getLogger(FilteringAllocationTests.class); - @AfterMethod public void cleanAndCloseNodes() throws Exception { + @AfterMethod + public void cleanAndCloseNodes() throws Exception { closeAllNodes(); } - @Test public void testDecommissionNodeNoReplicas() throws Exception { + @Test + public void testDecommissionNodeNoReplicas() throws Exception { logger.info("--> starting 2 nodes"); startNode("node1"); startNode("node2"); diff --git a/src/test/java/org/elasticsearch/test/integration/consistencylevel/WriteConsistencyLevelTests.java b/src/test/java/org/elasticsearch/test/integration/consistencylevel/WriteConsistencyLevelTests.java index 3bd9a6f2a2d..afcd15f4088 100644 --- a/src/test/java/org/elasticsearch/test/integration/consistencylevel/WriteConsistencyLevelTests.java +++ b/src/test/java/org/elasticsearch/test/integration/consistencylevel/WriteConsistencyLevelTests.java @@ -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,20 +28,23 @@ import org.elasticsearch.test.integration.AbstractNodesTests; import org.testng.annotations.AfterMethod; import org.testng.annotations.Test; -import static org.elasticsearch.common.unit.TimeValue.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.unit.TimeValue.timeValueMillis; +import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class WriteConsistencyLevelTests extends AbstractNodesTests { - @AfterMethod public void closeNodes() { + @AfterMethod + public void closeNodes() { closeAllNodes(); } - @Test public void testWriteConsistencyLevelReplication2() throws Exception { + @Test + public void testWriteConsistencyLevelReplication2() throws Exception { startNode("node1"); client("node1").admin().indices().prepareCreate("test").setSettings(ImmutableSettings.settingsBuilder().put("number_of_shards", 1).put("number_of_replicas", 2)).execute().actionGet(); diff --git a/src/test/java/org/elasticsearch/test/integration/discovery/DiscoveryTests.java b/src/test/java/org/elasticsearch/test/integration/discovery/DiscoveryTests.java index fb1ac1165d4..112222e9573 100644 --- a/src/test/java/org/elasticsearch/test/integration/discovery/DiscoveryTests.java +++ b/src/test/java/org/elasticsearch/test/integration/discovery/DiscoveryTests.java @@ -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,17 +26,19 @@ import org.elasticsearch.test.integration.AbstractNodesTests; import org.testng.annotations.AfterClass; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; @Test public class DiscoveryTests extends AbstractNodesTests { - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { closeAllNodes(); } - @Test public void testUnicastDiscovery() { + @Test + public void testUnicastDiscovery() { Settings settings = ImmutableSettings.settingsBuilder() .put("discovery.zen.multicast.enabled", false) .put("discovery.zen.unicast.hosts", "localhost") diff --git a/src/test/java/org/elasticsearch/test/integration/document/AliasedIndexDocumentActionsTests.java b/src/test/java/org/elasticsearch/test/integration/document/AliasedIndexDocumentActionsTests.java index a0d52c7efa5..1091f4bc3a5 100644 --- a/src/test/java/org/elasticsearch/test/integration/document/AliasedIndexDocumentActionsTests.java +++ b/src/test/java/org/elasticsearch/test/integration/document/AliasedIndexDocumentActionsTests.java @@ -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,11 +19,11 @@ package org.elasticsearch.test.integration.document; -import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; +import static org.elasticsearch.client.Requests.createIndexRequest; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; /** - * @author kimchy (shay.banon) + * */ public class AliasedIndexDocumentActionsTests extends DocumentActionsTests { @@ -38,7 +38,8 @@ public class AliasedIndexDocumentActionsTests extends DocumentActionsTests { client1.admin().indices().create(createIndexRequest("test1").settings(settingsBuilder().putArray("index.aliases", "test"))).actionGet(); } - @Override protected String getConcreteIndexName() { + @Override + protected String getConcreteIndexName() { return "test1"; } } \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/integration/document/DocumentActionsTests.java b/src/test/java/org/elasticsearch/test/integration/document/DocumentActionsTests.java index 9ac8832e935..a81dc19f5a0 100644 --- a/src/test/java/org/elasticsearch/test/integration/document/DocumentActionsTests.java +++ b/src/test/java/org/elasticsearch/test/integration/document/DocumentActionsTests.java @@ -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 @@ -47,19 +47,21 @@ import java.io.IOException; import java.util.Map; import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.index.query.QueryBuilders.termQuery; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.nullValue; /** - * @author kimchy (shay.banon) + * */ public class DocumentActionsTests extends AbstractNodesTests { protected Client client1; protected Client client2; - @BeforeClass public void startNodes() { + @BeforeClass + public void startNodes() { startNode("server1"); startNode("server2"); client1 = getClient1(); @@ -89,7 +91,8 @@ public class DocumentActionsTests extends AbstractNodesTests { return "test"; } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { client1.close(); client2.close(); closeAllNodes(); @@ -103,7 +106,8 @@ public class DocumentActionsTests extends AbstractNodesTests { return client("server2"); } - @Test public void testIndexActions() throws Exception { + @Test + public void testIndexActions() throws Exception { createIndex(); logger.info("Running Cluster Health"); ClusterHealthResponse clusterHealth = client1.admin().cluster().health(clusterHealthRequest().waitForGreenStatus()).actionGet(); @@ -257,7 +261,8 @@ public class DocumentActionsTests extends AbstractNodesTests { } } - @Test public void testBulk() throws Exception { + @Test + public void testBulk() throws Exception { createIndex(); logger.info("-> running Cluster Health"); ClusterHealthResponse clusterHealth = client1.admin().cluster().health(clusterHealthRequest().waitForGreenStatus()).actionGet(); diff --git a/src/test/java/org/elasticsearch/test/integration/document/GetActionTests.java b/src/test/java/org/elasticsearch/test/integration/document/GetActionTests.java index 1afa3151ba6..874066135a2 100644 --- a/src/test/java/org/elasticsearch/test/integration/document/GetActionTests.java +++ b/src/test/java/org/elasticsearch/test/integration/document/GetActionTests.java @@ -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,27 +33,31 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.common.xcontent.XContentFactory.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.client.Requests.clusterHealthRequest; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.nullValue; public class GetActionTests extends AbstractNodesTests { protected Client client; - @BeforeClass public void startNodes() { + @BeforeClass + public void startNodes() { startNode("node1"); startNode("node2"); client = client("node1"); } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { client.close(); closeAllNodes(); } - @Test public void simpleGetTests() { + @Test + public void simpleGetTests() { client.admin().indices().prepareDelete().execute().actionGet(); client.admin().indices().prepareCreate("test").setSettings(ImmutableSettings.settingsBuilder().put("index.refresh_interval", -1)).execute().actionGet(); @@ -142,7 +146,8 @@ public class GetActionTests extends AbstractNodesTests { assertThat(response.exists(), equalTo(false)); } - @Test public void simpleMultiGetTests() throws Exception { + @Test + public void simpleMultiGetTests() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -193,7 +198,8 @@ public class GetActionTests extends AbstractNodesTests { assertThat(response.responses()[0].response().field("field").values().get(0).toString(), equalTo("value1")); } - @Test public void realtimeGetWithCompress() throws Exception { + @Test + public void realtimeGetWithCompress() throws Exception { client.admin().indices().prepareDelete().execute().actionGet(); client.admin().indices().prepareCreate("test").setSettings(ImmutableSettings.settingsBuilder().put("index.refresh_interval", -1)) diff --git a/src/test/java/org/elasticsearch/test/integration/document/LocalDocumentActionsTests.java b/src/test/java/org/elasticsearch/test/integration/document/LocalDocumentActionsTests.java index 3530f6a45f1..ac14ad31c70 100644 --- a/src/test/java/org/elasticsearch/test/integration/document/LocalDocumentActionsTests.java +++ b/src/test/java/org/elasticsearch/test/integration/document/LocalDocumentActionsTests.java @@ -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.test.integration.document; /** - * @author kimchy (Shay Banon) + * */ public class LocalDocumentActionsTests extends DocumentActionsTests { } diff --git a/src/test/java/org/elasticsearch/test/integration/document/MoreLikeThisActionTests.java b/src/test/java/org/elasticsearch/test/integration/document/MoreLikeThisActionTests.java index 6b758786faf..64950fd5c5b 100644 --- a/src/test/java/org/elasticsearch/test/integration/document/MoreLikeThisActionTests.java +++ b/src/test/java/org/elasticsearch/test/integration/document/MoreLikeThisActionTests.java @@ -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,27 +29,29 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.common.xcontent.XContentFactory.*; -import static org.elasticsearch.index.query.FilterBuilders.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import static org.elasticsearch.index.query.FilterBuilders.termFilter; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class MoreLikeThisActionTests extends AbstractNodesTests { private Client client1; private Client client2; - @BeforeMethod public void startServers() { + @BeforeMethod + public void startServers() { startNode("server1"); startNode("server2"); client1 = getClient1(); client2 = getClient2(); } - @AfterMethod public void closeServers() { + @AfterMethod + public void closeServers() { client1.close(); client2.close(); closeAllNodes(); @@ -63,7 +65,8 @@ public class MoreLikeThisActionTests extends AbstractNodesTests { return client("server2"); } - @Test public void testSimpleMoreLikeThis() throws Exception { + @Test + public void testSimpleMoreLikeThis() throws Exception { logger.info("Creating index test"); client1.admin().indices().create(createIndexRequest("test")).actionGet(); @@ -86,7 +89,8 @@ public class MoreLikeThisActionTests extends AbstractNodesTests { } - @Test public void testMoreLikeThisWithAliases() throws Exception { + @Test + public void testMoreLikeThisWithAliases() throws Exception { logger.info("Creating index test"); client1.admin().indices().create(createIndexRequest("test")).actionGet(); diff --git a/src/test/java/org/elasticsearch/test/integration/gateway/fs/AbstractSimpleIndexGatewayTests.java b/src/test/java/org/elasticsearch/test/integration/gateway/fs/AbstractSimpleIndexGatewayTests.java index a75ce07e12d..23c9d0d512d 100644 --- a/src/test/java/org/elasticsearch/test/integration/gateway/fs/AbstractSimpleIndexGatewayTests.java +++ b/src/test/java/org/elasticsearch/test/integration/gateway/fs/AbstractSimpleIndexGatewayTests.java @@ -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,30 +39,33 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.hamcrest.MatcherAssert.*; +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** - * @author kimchy (shay.banon) + * */ public abstract class AbstractSimpleIndexGatewayTests extends AbstractNodesTests { - @AfterMethod public void closeNodes() throws Exception { + @AfterMethod + public void closeNodes() throws Exception { node("server1").stop(); // since we store (by default) the index snapshot under the gateway, resetting it will reset the index data as well ((InternalNode) node("server1")).injector().getInstance(Gateway.class).reset(); closeAllNodes(); } - @BeforeMethod public void buildNode1() throws Exception { + @BeforeMethod + public void buildNode1() throws Exception { buildNode("server1"); // since we store (by default) the index snapshot under the gateway, resetting it will reset the index data as well ((InternalNode) node("server1")).injector().getInstance(Gateway.class).reset(); closeAllNodes(); } - @Test public void testSnapshotOperations() throws Exception { + @Test + public void testSnapshotOperations() throws Exception { startNode("server1"); // get the environment, so we can clear the work dir when needed @@ -219,11 +222,13 @@ public abstract class AbstractSimpleIndexGatewayTests extends AbstractNodesTests client("server1").admin().indices().delete(deleteIndexRequest("test")).actionGet(); } - @Test public void testLoadWithFullRecovery() { + @Test + public void testLoadWithFullRecovery() { testLoad(true); } - @Test public void testLoadWithReuseRecovery() { + @Test + public void testLoadWithReuseRecovery() { testLoad(false); } diff --git a/src/test/java/org/elasticsearch/test/integration/gateway/fs/BlobStoreSmallBufferSizeFsIndexGatewayTests.java b/src/test/java/org/elasticsearch/test/integration/gateway/fs/BlobStoreSmallBufferSizeFsIndexGatewayTests.java index 27770228b53..587f10b37e8 100644 --- a/src/test/java/org/elasticsearch/test/integration/gateway/fs/BlobStoreSmallBufferSizeFsIndexGatewayTests.java +++ b/src/test/java/org/elasticsearch/test/integration/gateway/fs/BlobStoreSmallBufferSizeFsIndexGatewayTests.java @@ -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.test.integration.gateway.fs; /** - * @author kimchy (shay.banon) + * */ public class BlobStoreSmallBufferSizeFsIndexGatewayTests extends AbstractSimpleIndexGatewayTests { diff --git a/src/test/java/org/elasticsearch/test/integration/gateway/fs/ChunkFsIndexGatewayTests.java b/src/test/java/org/elasticsearch/test/integration/gateway/fs/ChunkFsIndexGatewayTests.java index 63a823c1e91..1ab81240b66 100644 --- a/src/test/java/org/elasticsearch/test/integration/gateway/fs/ChunkFsIndexGatewayTests.java +++ b/src/test/java/org/elasticsearch/test/integration/gateway/fs/ChunkFsIndexGatewayTests.java @@ -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.test.integration.gateway.fs; /** - * @author kimchy (shay.banon) + * */ public class ChunkFsIndexGatewayTests extends AbstractSimpleIndexGatewayTests { diff --git a/src/test/java/org/elasticsearch/test/integration/gateway/fs/FsMetaDataGatewayTests.java b/src/test/java/org/elasticsearch/test/integration/gateway/fs/FsMetaDataGatewayTests.java index 2a6c8ee68d9..04f7b2a04d9 100644 --- a/src/test/java/org/elasticsearch/test/integration/gateway/fs/FsMetaDataGatewayTests.java +++ b/src/test/java/org/elasticsearch/test/integration/gateway/fs/FsMetaDataGatewayTests.java @@ -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,30 +29,34 @@ import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import static org.elasticsearch.client.Requests.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.client.Requests.clusterHealthRequest; +import static org.elasticsearch.client.Requests.createIndexRequest; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class FsMetaDataGatewayTests extends AbstractNodesTests { - @AfterMethod void closeNodes() throws Exception { + @AfterMethod + void closeNodes() throws Exception { node("server1").stop(); // since we store (by default) the index snapshot under the gateway, resetting it will reset the index data as well ((InternalNode) node("server1")).injector().getInstance(Gateway.class).reset(); closeAllNodes(); } - @BeforeMethod void buildNodeToReset() throws Exception { + @BeforeMethod + void buildNodeToReset() throws Exception { buildNode("server1"); // since we store (by default) the index snapshot under the gateway, resetting it will reset the index data as well ((InternalNode) node("server1")).injector().getInstance(Gateway.class).reset(); closeAllNodes(); } - @Test public void testIndexActions() throws Exception { + @Test + public void testIndexActions() throws Exception { startNode("server1"); logger.info("Running Cluster Health (waiting for node to startup properly)"); diff --git a/src/test/java/org/elasticsearch/test/integration/gateway/fs/SimpleFsIndexGatewayTests.java b/src/test/java/org/elasticsearch/test/integration/gateway/fs/SimpleFsIndexGatewayTests.java index 9e8ce8ebdfb..b8bc8e35ddf 100644 --- a/src/test/java/org/elasticsearch/test/integration/gateway/fs/SimpleFsIndexGatewayTests.java +++ b/src/test/java/org/elasticsearch/test/integration/gateway/fs/SimpleFsIndexGatewayTests.java @@ -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.test.integration.gateway.fs; /** - * @author kimchy (shay.banon) + * */ public class SimpleFsIndexGatewayTests extends AbstractSimpleIndexGatewayTests { diff --git a/src/test/java/org/elasticsearch/test/integration/gateway/fs/SimpleFsIndexInRamIndexGatewayTests.java b/src/test/java/org/elasticsearch/test/integration/gateway/fs/SimpleFsIndexInRamIndexGatewayTests.java index 57b9054e215..84b816a8861 100644 --- a/src/test/java/org/elasticsearch/test/integration/gateway/fs/SimpleFsIndexInRamIndexGatewayTests.java +++ b/src/test/java/org/elasticsearch/test/integration/gateway/fs/SimpleFsIndexInRamIndexGatewayTests.java @@ -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,11 +20,12 @@ package org.elasticsearch.test.integration.gateway.fs; /** - * @author kimchy (shay.banon) + * */ public class SimpleFsIndexInRamIndexGatewayTests extends AbstractSimpleIndexGatewayTests { - @Override protected boolean isPersistentStorage() { + @Override + protected boolean isPersistentStorage() { return false; } } \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/integration/gateway/local/LocalGatewayIndexStateTests.java b/src/test/java/org/elasticsearch/test/integration/gateway/local/LocalGatewayIndexStateTests.java index d6f34c7d5b3..fd7bc286562 100644 --- a/src/test/java/org/elasticsearch/test/integration/gateway/local/LocalGatewayIndexStateTests.java +++ b/src/test/java/org/elasticsearch/test/integration/gateway/local/LocalGatewayIndexStateTests.java @@ -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,19 +37,21 @@ import org.elasticsearch.test.integration.AbstractNodesTests; import org.testng.annotations.AfterMethod; import org.testng.annotations.Test; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.nullValue; /** - * @author kimchy (shay.banon) + * */ public class LocalGatewayIndexStateTests extends AbstractNodesTests { private final ESLogger logger = Loggers.getLogger(LocalGatewayIndexStateTests.class); - @AfterMethod public void cleanAndCloseNodes() throws Exception { + @AfterMethod + public void cleanAndCloseNodes() throws Exception { for (int i = 0; i < 10; i++) { if (node("node" + i) != null) { node("node" + i).stop(); @@ -62,7 +64,8 @@ public class LocalGatewayIndexStateTests extends AbstractNodesTests { closeAllNodes(); } - @Test public void testMappingMetaDataParsed() throws Exception { + @Test + public void testMappingMetaDataParsed() throws Exception { logger.info("--> cleaning nodes"); buildNode("node1", settingsBuilder().put("gateway.type", "local")); buildNode("node2", settingsBuilder().put("gateway.type", "local")); @@ -107,7 +110,8 @@ public class LocalGatewayIndexStateTests extends AbstractNodesTests { assertThat(mappingMd.routing().required(), equalTo(true)); } - @Test public void testSimpleOpenClose() throws Exception { + @Test + public void testSimpleOpenClose() throws Exception { logger.info("--> cleaning nodes"); buildNode("node1", settingsBuilder().put("gateway.type", "local").build()); buildNode("node2", settingsBuilder().put("gateway.type", "local").build()); @@ -226,7 +230,8 @@ public class LocalGatewayIndexStateTests extends AbstractNodesTests { client("node1").prepareIndex("test", "type1", "2").setSource("field1", "value1").execute().actionGet(); } - @Test public void testJustMasterNode() throws Exception { + @Test + public void testJustMasterNode() throws Exception { logger.info("--> cleaning nodes"); buildNode("node1", settingsBuilder().put("gateway.type", "local").build()); buildNode("node2", settingsBuilder().put("gateway.type", "local").build()); @@ -253,7 +258,8 @@ public class LocalGatewayIndexStateTests extends AbstractNodesTests { assertThat(clusterStateResponse.state().metaData().hasIndex("test"), equalTo(true)); } - @Test public void testJustMasterNodeAndJustDataNode() throws Exception { + @Test + public void testJustMasterNodeAndJustDataNode() throws Exception { logger.info("--> cleaning nodes"); buildNode("node1", settingsBuilder().put("gateway.type", "local").build()); buildNode("node2", settingsBuilder().put("gateway.type", "local").build()); @@ -273,7 +279,8 @@ public class LocalGatewayIndexStateTests extends AbstractNodesTests { client("node1").prepareIndex("test", "type1").setSource("field1", "value1").setTimeout("100ms").execute().actionGet(); } - @Test public void testTwoNodesSingleDoc() throws Exception { + @Test + public void testTwoNodesSingleDoc() throws Exception { logger.info("--> cleaning nodes"); buildNode("node1", settingsBuilder().put("gateway.type", "local").build()); buildNode("node2", settingsBuilder().put("gateway.type", "local").build()); diff --git a/src/test/java/org/elasticsearch/test/integration/gateway/local/QuorumLocalGatewayTests.java b/src/test/java/org/elasticsearch/test/integration/gateway/local/QuorumLocalGatewayTests.java index 252aecc37c8..ca568feb289 100644 --- a/src/test/java/org/elasticsearch/test/integration/gateway/local/QuorumLocalGatewayTests.java +++ b/src/test/java/org/elasticsearch/test/integration/gateway/local/QuorumLocalGatewayTests.java @@ -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,19 +29,20 @@ import org.elasticsearch.test.integration.AbstractNodesTests; import org.testng.annotations.AfterMethod; import org.testng.annotations.Test; -import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.elasticsearch.common.xcontent.XContentFactory.*; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.client.Requests.clusterHealthRequest; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class QuorumLocalGatewayTests extends AbstractNodesTests { - @AfterMethod public void cleanAndCloseNodes() throws Exception { + @AfterMethod + public void cleanAndCloseNodes() throws Exception { for (int i = 0; i < 10; i++) { if (node("node" + i) != null) { node("node" + i).stop(); @@ -52,7 +53,8 @@ public class QuorumLocalGatewayTests extends AbstractNodesTests { closeAllNodes(); } - @Test public void testChangeInitialShardsRecovery() throws Exception { + @Test + public void testChangeInitialShardsRecovery() throws Exception { // clean three nodes logger.info("--> cleaning nodes"); buildNode("node1", settingsBuilder().put("gateway.type", "local").build()); @@ -108,7 +110,8 @@ public class QuorumLocalGatewayTests extends AbstractNodesTests { } } - @Test public void testQuorumRecovery() throws Exception { + @Test + public void testQuorumRecovery() throws Exception { // clean three nodes logger.info("--> cleaning nodes"); buildNode("node1", settingsBuilder().put("gateway.type", "local").build()); diff --git a/src/test/java/org/elasticsearch/test/integration/gateway/local/SimpleRecoveryLocalGatewayTests.java b/src/test/java/org/elasticsearch/test/integration/gateway/local/SimpleRecoveryLocalGatewayTests.java index 426bae30924..fcd3124eeff 100644 --- a/src/test/java/org/elasticsearch/test/integration/gateway/local/SimpleRecoveryLocalGatewayTests.java +++ b/src/test/java/org/elasticsearch/test/integration/gateway/local/SimpleRecoveryLocalGatewayTests.java @@ -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,19 +33,22 @@ import org.elasticsearch.test.integration.AbstractNodesTests; import org.testng.annotations.AfterMethod; import org.testng.annotations.Test; -import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.elasticsearch.common.xcontent.XContentFactory.*; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.client.Requests.clusterHealthRequest; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; +import static org.elasticsearch.index.query.QueryBuilders.termQuery; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.greaterThan; /** - * @author kimchy (shay.banon) + * */ public class SimpleRecoveryLocalGatewayTests extends AbstractNodesTests { - @AfterMethod public void cleanAndCloseNodes() throws Exception { + @AfterMethod + public void cleanAndCloseNodes() throws Exception { for (int i = 0; i < 10; i++) { if (node("node" + i) != null) { node("node" + i).stop(); @@ -56,7 +59,8 @@ public class SimpleRecoveryLocalGatewayTests extends AbstractNodesTests { closeAllNodes(); } - @Test public void testX() throws Exception { + @Test + public void testX() throws Exception { buildNode("node1", settingsBuilder().put("gateway.type", "local").build()); cleanAndCloseNodes(); @@ -103,7 +107,8 @@ public class SimpleRecoveryLocalGatewayTests extends AbstractNodesTests { assertThat(node1.client().prepareCount().setQuery(termQuery("appAccountIds", 179)).execute().actionGet().count(), equalTo(2l)); } - @Test public void testSingleNodeNoFlush() throws Exception { + @Test + public void testSingleNodeNoFlush() throws Exception { buildNode("node1", settingsBuilder().put("gateway.type", "local").build()); cleanAndCloseNodes(); @@ -155,7 +160,8 @@ public class SimpleRecoveryLocalGatewayTests extends AbstractNodesTests { } - @Test public void testSingleNodeWithFlush() throws Exception { + @Test + public void testSingleNodeWithFlush() throws Exception { buildNode("node1", settingsBuilder().put("gateway.type", "local").build()); cleanAndCloseNodes(); @@ -194,7 +200,8 @@ public class SimpleRecoveryLocalGatewayTests extends AbstractNodesTests { } } - @Test public void testTwoNodeFirstNodeCleared() throws Exception { + @Test + public void testTwoNodeFirstNodeCleared() throws Exception { // clean two nodes buildNode("node1", settingsBuilder().put("gateway.type", "local").build()); buildNode("node2", settingsBuilder().put("gateway.type", "local").build()); @@ -240,7 +247,8 @@ public class SimpleRecoveryLocalGatewayTests extends AbstractNodesTests { } } - @Test public void testLatestVersionLoaded() throws Exception { + @Test + public void testLatestVersionLoaded() throws Exception { // clean two nodes buildNode("node1", settingsBuilder().put("gateway.type", "local").build()); buildNode("node2", settingsBuilder().put("gateway.type", "local").build()); @@ -293,7 +301,8 @@ public class SimpleRecoveryLocalGatewayTests extends AbstractNodesTests { } } - @Test public void testReusePeerRecovery() throws Exception { + @Test + public void testReusePeerRecovery() throws Exception { buildNode("node1", settingsBuilder().put("gateway.type", "local").build()); buildNode("node2", settingsBuilder().put("gateway.type", "local").build()); buildNode("node3", settingsBuilder().put("gateway.type", "local").build()); @@ -367,7 +376,8 @@ public class SimpleRecoveryLocalGatewayTests extends AbstractNodesTests { } } - @Test public void testRecoveryDifferentNodeOrderStartup() throws Exception { + @Test + public void testRecoveryDifferentNodeOrderStartup() throws Exception { // we need different data paths so we make sure we start the second node fresh buildNode("node1", settingsBuilder().put("gateway.type", "local").put("path.data", "data/data1").build()); buildNode("node2", settingsBuilder().put("gateway.type", "local").put("path.data", "data/data2").build()); diff --git a/src/test/java/org/elasticsearch/test/integration/gateway/none/RecoverAfterNodesTests.java b/src/test/java/org/elasticsearch/test/integration/gateway/none/RecoverAfterNodesTests.java index 53bc2ac0cb2..77fad18b553 100644 --- a/src/test/java/org/elasticsearch/test/integration/gateway/none/RecoverAfterNodesTests.java +++ b/src/test/java/org/elasticsearch/test/integration/gateway/none/RecoverAfterNodesTests.java @@ -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,20 +25,23 @@ import org.elasticsearch.test.integration.AbstractNodesTests; import org.testng.annotations.AfterMethod; import org.testng.annotations.Test; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.hasItem; /** - * @author kimchy (shay.banon) + * */ public class RecoverAfterNodesTests extends AbstractNodesTests { - @AfterMethod public void closeNodes() { + @AfterMethod + public void closeNodes() { closeAllNodes(); } - @Test public void testRecoverAfterNodes() { + @Test + public void testRecoverAfterNodes() { logger.info("--> start node (1)"); startNode("node1", settingsBuilder().put("gateway.recover_after_nodes", 3)); assertThat(client("node1").admin().cluster().prepareState().setLocal(true).execute().actionGet() @@ -68,7 +71,8 @@ public class RecoverAfterNodesTests extends AbstractNodesTests { equalTo(true)); } - @Test public void testRecoverAfterMasterNodes() throws Exception { + @Test + public void testRecoverAfterMasterNodes() throws Exception { logger.info("--> start master_node (1)"); startNode("master1", settingsBuilder().put("gateway.recover_after_master_nodes", 2).put("node.data", false).put("node.master", true)); assertThat(client("master1").admin().cluster().prepareState().setLocal(true).execute().actionGet() @@ -113,7 +117,8 @@ public class RecoverAfterNodesTests extends AbstractNodesTests { equalTo(true)); } - @Test public void testRecoverAfterDataNodes() { + @Test + public void testRecoverAfterDataNodes() { logger.info("--> start master_node (1)"); startNode("master1", settingsBuilder().put("gateway.recover_after_data_nodes", 2).put("node.data", false).put("node.master", true)); assertThat(client("master1").admin().cluster().prepareState().setLocal(true).execute().actionGet() diff --git a/src/test/java/org/elasticsearch/test/integration/indexlifecycle/IndexLifecycleActionTests.java b/src/test/java/org/elasticsearch/test/integration/indexlifecycle/IndexLifecycleActionTests.java index e53961161f0..f959bd370bd 100644 --- a/src/test/java/org/elasticsearch/test/integration/indexlifecycle/IndexLifecycleActionTests.java +++ b/src/test/java/org/elasticsearch/test/integration/indexlifecycle/IndexLifecycleActionTests.java @@ -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,24 +35,27 @@ import org.testng.annotations.AfterMethod; import org.testng.annotations.Test; import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.cluster.metadata.IndexMetaData.*; -import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.hamcrest.MatcherAssert.*; +import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS; +import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; +import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** - * @author kimchy (shay.banon) + * */ public class IndexLifecycleActionTests extends AbstractNodesTests { private final ESLogger logger = Loggers.getLogger(IndexLifecycleActionTests.class); - @AfterMethod public void closeNodes() { + @AfterMethod + public void closeNodes() { closeAllNodes(); } - @Test public void testIndexLifecycleActionsWith11Shards1Backup() throws Exception { + @Test + public void testIndexLifecycleActionsWith11Shards1Backup() throws Exception { Settings settings = settingsBuilder() .put(SETTING_NUMBER_OF_SHARDS, 11) .put(SETTING_NUMBER_OF_REPLICAS, 1) @@ -183,7 +186,8 @@ public class IndexLifecycleActionTests extends AbstractNodesTests { assertThat(routingNodeEntry3, nullValue()); } - @Test public void testIndexLifecycleActionsWith11Shards0Backup() throws Exception { + @Test + public void testIndexLifecycleActionsWith11Shards0Backup() throws Exception { Settings settings = settingsBuilder() .put(SETTING_NUMBER_OF_SHARDS, 11) @@ -315,7 +319,8 @@ public class IndexLifecycleActionTests extends AbstractNodesTests { assertThat(routingNodeEntry3, nullValue()); } - @Test public void testTwoIndicesCreation() throws Exception { + @Test + public void testTwoIndicesCreation() throws Exception { Settings settings = settingsBuilder() .put(SETTING_NUMBER_OF_SHARDS, 11) diff --git a/src/test/java/org/elasticsearch/test/integration/indices/analyze/AnalyzeActionTests.java b/src/test/java/org/elasticsearch/test/integration/indices/analyze/AnalyzeActionTests.java index f0a559b99ab..9b540b326e2 100644 --- a/src/test/java/org/elasticsearch/test/integration/indices/analyze/AnalyzeActionTests.java +++ b/src/test/java/org/elasticsearch/test/integration/indices/analyze/AnalyzeActionTests.java @@ -27,23 +27,25 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class AnalyzeActionTests extends AbstractNodesTests { private Client client; - @BeforeClass public void createNodes() throws Exception { + @BeforeClass + public void createNodes() throws Exception { startNode("server1"); startNode("server2"); client = getClient(); } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { client.close(); closeAllNodes(); } @@ -52,7 +54,8 @@ public class AnalyzeActionTests extends AbstractNodesTests { return client("server1"); } - @Test public void simpleAnalyzerTests() throws Exception { + @Test + public void simpleAnalyzerTests() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -72,7 +75,8 @@ public class AnalyzeActionTests extends AbstractNodesTests { } } - @Test public void analyzerWithFieldOrTypeTests() throws Exception { + @Test + public void analyzerWithFieldOrTypeTests() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { diff --git a/src/test/java/org/elasticsearch/test/integration/indices/mapping/SimpleDeleteMappingTests.java b/src/test/java/org/elasticsearch/test/integration/indices/mapping/SimpleDeleteMappingTests.java index 5511959aca6..5a58b9c60de 100644 --- a/src/test/java/org/elasticsearch/test/integration/indices/mapping/SimpleDeleteMappingTests.java +++ b/src/test/java/org/elasticsearch/test/integration/indices/mapping/SimpleDeleteMappingTests.java @@ -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,21 +27,22 @@ import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.common.xcontent.XContentFactory.*; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.client.Requests.createIndexRequest; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class SimpleDeleteMappingTests extends AbstractNodesTests { protected Client client1; protected Client client2; - @BeforeMethod public void startNodes() { + @BeforeMethod + public void startNodes() { startNode("node1"); startNode("node2"); client1 = getClient1(); @@ -55,7 +56,8 @@ public class SimpleDeleteMappingTests extends AbstractNodesTests { client1.admin().indices().create(createIndexRequest("test")).actionGet(); } - @AfterMethod public void closeNodes() { + @AfterMethod + public void closeNodes() { client1.close(); client2.close(); closeAllNodes(); @@ -69,7 +71,8 @@ public class SimpleDeleteMappingTests extends AbstractNodesTests { return client("node2"); } - @Test public void simpleDeleteMapping() throws Exception { + @Test + public void simpleDeleteMapping() throws Exception { for (int i = 0; i < 10; i++) { client1.prepareIndex("test", "type1", Integer.toString(i)).setSource(jsonBuilder().startObject() .field("value", "test" + i) diff --git a/src/test/java/org/elasticsearch/test/integration/indices/settings/UpdateNumberOfReplicasTests.java b/src/test/java/org/elasticsearch/test/integration/indices/settings/UpdateNumberOfReplicasTests.java index 2cbdd6f589e..3add8675da4 100644 --- a/src/test/java/org/elasticsearch/test/integration/indices/settings/UpdateNumberOfReplicasTests.java +++ b/src/test/java/org/elasticsearch/test/integration/indices/settings/UpdateNumberOfReplicasTests.java @@ -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,22 +28,23 @@ import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.elasticsearch.common.xcontent.XContentFactory.*; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.client.Requests.createIndexRequest; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class UpdateNumberOfReplicasTests extends AbstractNodesTests { protected Client client1; protected Client client2; - @BeforeMethod public void startNodes() { + @BeforeMethod + public void startNodes() { startNode("node1"); startNode("node2"); client1 = getClient1(); @@ -51,7 +52,8 @@ public class UpdateNumberOfReplicasTests extends AbstractNodesTests { } - @AfterMethod public void closeNodes() { + @AfterMethod + public void closeNodes() { client1.close(); client2.close(); closeAllNodes(); @@ -65,7 +67,8 @@ public class UpdateNumberOfReplicasTests extends AbstractNodesTests { return client("node2"); } - @Test public void simpleUpdateNumberOfReplicasTests() throws Exception { + @Test + public void simpleUpdateNumberOfReplicasTests() throws Exception { logger.info("Creating index test"); client1.admin().indices().create(createIndexRequest("test")).actionGet(); @@ -142,7 +145,8 @@ public class UpdateNumberOfReplicasTests extends AbstractNodesTests { } } - @Test public void testAutoExpandNumberOfReplicas0ToData() { + @Test + public void testAutoExpandNumberOfReplicas0ToData() { logger.info("--> creating index test with auto expand replicas"); client1.admin().indices().prepareCreate("test").setSettings(settingsBuilder().put("number_of_shards", 2).put("auto_expand_replicas", "0-all")).execute().actionGet(); @@ -192,7 +196,8 @@ public class UpdateNumberOfReplicasTests extends AbstractNodesTests { assertThat(clusterHealth.indices().get("test").activeShards(), equalTo(2)); } - @Test public void testAutoExpandNumberReplicas1ToData() { + @Test + public void testAutoExpandNumberReplicas1ToData() { logger.info("--> creating index test with auto expand replicas"); client1.admin().indices().prepareCreate("test").setSettings(settingsBuilder().put("number_of_shards", 2).put("auto_expand_replicas", "1-all")).execute().actionGet(); @@ -242,7 +247,8 @@ public class UpdateNumberOfReplicasTests extends AbstractNodesTests { assertThat(clusterHealth.indices().get("test").activeShards(), equalTo(2)); } - @Test public void testAutoExpandNumberReplicas2() { + @Test + public void testAutoExpandNumberReplicas2() { logger.info("--> add another node"); startNode("node3"); logger.info("--> creating index test with auto expand replicas set to 0-2"); diff --git a/src/test/java/org/elasticsearch/test/integration/indices/settings/UpdateSettingsTests.java b/src/test/java/org/elasticsearch/test/integration/indices/settings/UpdateSettingsTests.java index 52124ba6f9f..e43c586d5af 100644 --- a/src/test/java/org/elasticsearch/test/integration/indices/settings/UpdateSettingsTests.java +++ b/src/test/java/org/elasticsearch/test/integration/indices/settings/UpdateSettingsTests.java @@ -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,20 +26,24 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.nullValue; public class UpdateSettingsTests extends AbstractNodesTests { - @BeforeClass public void startNodes() { + @BeforeClass + public void startNodes() { startNode("node1"); } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { closeAllNodes(); } - @Test public void testOpenCloseUpdateSettings() throws Exception { + @Test + public void testOpenCloseUpdateSettings() throws Exception { try { client("node1").admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { diff --git a/src/test/java/org/elasticsearch/test/integration/indices/state/SimpleIndexStateTests.java b/src/test/java/org/elasticsearch/test/integration/indices/state/SimpleIndexStateTests.java index 350773f36ce..6b67dbaebb7 100644 --- a/src/test/java/org/elasticsearch/test/integration/indices/state/SimpleIndexStateTests.java +++ b/src/test/java/org/elasticsearch/test/integration/indices/state/SimpleIndexStateTests.java @@ -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,21 +31,24 @@ import org.elasticsearch.test.integration.AbstractNodesTests; import org.testng.annotations.AfterMethod; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.nullValue; /** - * @author kimchy (shay.banon) + * */ public class SimpleIndexStateTests extends AbstractNodesTests { private final ESLogger logger = Loggers.getLogger(SimpleIndexStateTests.class); - @AfterMethod public void closeNodes() { + @AfterMethod + public void closeNodes() { closeAllNodes(); } - @Test public void testSimpleOpenClose() { + @Test + public void testSimpleOpenClose() { logger.info("--> starting two nodes...."); startNode("node1"); startNode("node2"); diff --git a/src/test/java/org/elasticsearch/test/integration/indices/stats/SimpleIndexStatsTests.java b/src/test/java/org/elasticsearch/test/integration/indices/stats/SimpleIndexStatsTests.java index dc317e9b217..2153df9246d 100644 --- a/src/test/java/org/elasticsearch/test/integration/indices/stats/SimpleIndexStatsTests.java +++ b/src/test/java/org/elasticsearch/test/integration/indices/stats/SimpleIndexStatsTests.java @@ -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,23 +28,25 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** - * @author kimchy (shay.banon) + * */ public class SimpleIndexStatsTests extends AbstractNodesTests { private Client client; - @BeforeClass public void createNodes() throws Exception { + @BeforeClass + public void createNodes() throws Exception { startNode("node1"); startNode("node2"); client = getClient(); } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { client.close(); closeAllNodes(); } @@ -53,7 +55,8 @@ public class SimpleIndexStatsTests extends AbstractNodesTests { return client("node2"); } - @Test public void simpleStats() throws Exception { + @Test + public void simpleStats() throws Exception { // rely on 1 replica for this tests client.admin().indices().prepareCreate("test1").execute().actionGet(); client.admin().indices().prepareCreate("test2").execute().actionGet(); diff --git a/src/test/java/org/elasticsearch/test/integration/indices/store/IndicesStoreTests.java b/src/test/java/org/elasticsearch/test/integration/indices/store/IndicesStoreTests.java index 7a46104c97c..c0fc1832795 100644 --- a/src/test/java/org/elasticsearch/test/integration/indices/store/IndicesStoreTests.java +++ b/src/test/java/org/elasticsearch/test/integration/indices/store/IndicesStoreTests.java @@ -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,19 +31,21 @@ import org.testng.annotations.Test; import java.io.File; -import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.client.Requests.clusterHealthRequest; +import static org.elasticsearch.client.Requests.createIndexRequest; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author imotov + * */ public class IndicesStoreTests extends AbstractNodesTests { protected Client client1; - @BeforeClass public void startNodes() { + @BeforeClass + public void startNodes() { // The default (none) gateway cleans the shards on closing putDefaultSettings(settingsBuilder().put("gateway.type", "local")); startNode("server1"); @@ -51,7 +53,8 @@ public class IndicesStoreTests extends AbstractNodesTests { client1 = getClient1(); } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { client1.close(); closeAllNodes(); } diff --git a/src/test/java/org/elasticsearch/test/integration/indices/template/SimpleIndexTemplateTests.java b/src/test/java/org/elasticsearch/test/integration/indices/template/SimpleIndexTemplateTests.java index 20de13a0b23..4e4e9631a5a 100644 --- a/src/test/java/org/elasticsearch/test/integration/indices/template/SimpleIndexTemplateTests.java +++ b/src/test/java/org/elasticsearch/test/integration/indices/template/SimpleIndexTemplateTests.java @@ -29,24 +29,26 @@ import org.testng.annotations.Test; import java.util.Arrays; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.index.query.QueryBuilders.termQuery; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class SimpleIndexTemplateTests extends AbstractNodesTests { private Client client; - @BeforeClass public void createNodes() throws Exception { + @BeforeClass + public void createNodes() throws Exception { startNode("node1"); startNode("node2"); client = getClient(); } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { client.close(); closeAllNodes(); } @@ -55,7 +57,8 @@ public class SimpleIndexTemplateTests extends AbstractNodesTests { return client("node2"); } - @Test public void simpleIndexTemplateTests() throws Exception { + @Test + public void simpleIndexTemplateTests() throws Exception { clean(); client.admin().indices().preparePutTemplate("template_1") diff --git a/src/test/java/org/elasticsearch/test/integration/nested/SimpleNestedTests.java b/src/test/java/org/elasticsearch/test/integration/nested/SimpleNestedTests.java index ba8828e87a1..d3a0c76cdd8 100644 --- a/src/test/java/org/elasticsearch/test/integration/nested/SimpleNestedTests.java +++ b/src/test/java/org/elasticsearch/test/integration/nested/SimpleNestedTests.java @@ -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,29 +35,32 @@ import org.testng.annotations.Test; import java.util.Arrays; -import static org.elasticsearch.common.xcontent.XContentFactory.*; -import static org.elasticsearch.index.query.FilterBuilders.*; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import static org.elasticsearch.index.query.FilterBuilders.nestedFilter; import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; @Test public class SimpleNestedTests extends AbstractNodesTests { private Client client; - @BeforeClass public void createNodes() throws Exception { + @BeforeClass + public void createNodes() throws Exception { startNode("node1"); startNode("node2"); client = client("node1"); } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { client.close(); closeAllNodes(); } - @Test public void simpleNested() throws Exception { + @Test + public void simpleNested() throws Exception { client.admin().indices().prepareDelete().execute().actionGet(); client.admin().indices().prepareCreate("test") @@ -175,7 +178,8 @@ public class SimpleNestedTests extends AbstractNodesTests { assertThat(searchResponse.hits().totalHits(), equalTo(1l)); } - @Test public void multiNested() throws Exception { + @Test + public void multiNested() throws Exception { client.admin().indices().prepareDelete().execute().actionGet(); client.admin().indices().prepareCreate("test") @@ -249,11 +253,13 @@ public class SimpleNestedTests extends AbstractNodesTests { assertThat(searchResponse.hits().totalHits(), equalTo(0l)); } - @Test public void testFacetsSingleShard() throws Exception { + @Test + public void testFacetsSingleShard() throws Exception { testFacets(1); } - @Test public void testFacetsMultiShards() throws Exception { + @Test + public void testFacetsMultiShards() throws Exception { testFacets(3); } diff --git a/src/test/java/org/elasticsearch/test/integration/nodesinfo/SimpleNodesInfoTests.java b/src/test/java/org/elasticsearch/test/integration/nodesinfo/SimpleNodesInfoTests.java index 90fd6d7ed32..cc25385e8db 100644 --- a/src/test/java/org/elasticsearch/test/integration/nodesinfo/SimpleNodesInfoTests.java +++ b/src/test/java/org/elasticsearch/test/integration/nodesinfo/SimpleNodesInfoTests.java @@ -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,20 +26,23 @@ import org.elasticsearch.test.integration.AbstractNodesTests; import org.testng.annotations.AfterMethod; import org.testng.annotations.Test; -import static org.elasticsearch.client.Requests.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.client.Requests.nodesInfoRequest; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.notNullValue; /** - * @author kimchy (shay.banon) + * */ public class SimpleNodesInfoTests extends AbstractNodesTests { - @AfterMethod public void closeNodes() { + @AfterMethod + public void closeNodes() { closeAllNodes(); } - @Test public void testNodesInfos() { + @Test + public void testNodesInfos() { startNode("server1"); startNode("server2"); String server1NodeId = ((InternalNode) node("server1")).injector().getInstance(ClusterService.class).state().nodes().localNodeId(); diff --git a/src/test/java/org/elasticsearch/test/integration/percolator/RecoveryPercolatorTests.java b/src/test/java/org/elasticsearch/test/integration/percolator/RecoveryPercolatorTests.java index c62d7c77d27..81bcb5286a8 100644 --- a/src/test/java/org/elasticsearch/test/integration/percolator/RecoveryPercolatorTests.java +++ b/src/test/java/org/elasticsearch/test/integration/percolator/RecoveryPercolatorTests.java @@ -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,17 +30,19 @@ import org.elasticsearch.test.integration.AbstractNodesTests; import org.testng.annotations.AfterMethod; import org.testng.annotations.Test; -import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.elasticsearch.common.xcontent.XContentFactory.*; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.client.Requests.clusterHealthRequest; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; +import static org.elasticsearch.index.query.QueryBuilders.termQuery; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; @Test public class RecoveryPercolatorTests extends AbstractNodesTests { - @AfterMethod public void cleanAndCloseNodes() throws Exception { + @AfterMethod + public void cleanAndCloseNodes() throws Exception { for (int i = 0; i < 10; i++) { if (node("node" + i) != null) { node("node" + i).stop(); @@ -53,7 +55,8 @@ public class RecoveryPercolatorTests extends AbstractNodesTests { closeAllNodes(); } - @Test public void testRestartNodePercolator1() throws Exception { + @Test + public void testRestartNodePercolator1() throws Exception { logger.info("--> cleaning nodes"); buildNode("node1", settingsBuilder().put("gateway.type", "local")); cleanAndCloseNodes(); @@ -98,7 +101,8 @@ public class RecoveryPercolatorTests extends AbstractNodesTests { assertThat(percolate.matches().size(), equalTo(1)); } - @Test public void testRestartNodePercolator2() throws Exception { + @Test + public void testRestartNodePercolator2() throws Exception { logger.info("--> cleaning nodes"); buildNode("node1", settingsBuilder().put("gateway.type", "local")); cleanAndCloseNodes(); diff --git a/src/test/java/org/elasticsearch/test/integration/percolator/SimplePercolatorTests.java b/src/test/java/org/elasticsearch/test/integration/percolator/SimplePercolatorTests.java index 5c022a137e8..be720b5693b 100644 --- a/src/test/java/org/elasticsearch/test/integration/percolator/SimplePercolatorTests.java +++ b/src/test/java/org/elasticsearch/test/integration/percolator/SimplePercolatorTests.java @@ -30,26 +30,30 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.elasticsearch.common.xcontent.XContentFactory.*; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; +import static org.elasticsearch.index.query.QueryBuilders.termQuery; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.hasItem; /** - * @author kimchy (shay.banon) + * */ public class SimplePercolatorTests extends AbstractNodesTests { private Client client; - @BeforeClass public void createNodes() throws Exception { + @BeforeClass + public void createNodes() throws Exception { startNode("node1"); startNode("node2"); client = getClient(); } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { client.close(); closeAllNodes(); } @@ -58,7 +62,8 @@ public class SimplePercolatorTests extends AbstractNodesTests { return client("node1"); } - @Test public void percolateOnRecreatedIndex() throws Exception { + @Test + public void percolateOnRecreatedIndex() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -97,7 +102,8 @@ public class SimplePercolatorTests extends AbstractNodesTests { .execute().actionGet(); } - @Test public void registerPercolatorAndThenCreateAnIndex() throws Exception { + @Test + public void registerPercolatorAndThenCreateAnIndex() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -136,7 +142,8 @@ public class SimplePercolatorTests extends AbstractNodesTests { assertThat(percolate.matches().size(), equalTo(1)); } - @Test public void createIndexAndThenRegisterPercolator() throws Exception { + @Test + public void createIndexAndThenRegisterPercolator() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -188,7 +195,8 @@ public class SimplePercolatorTests extends AbstractNodesTests { assertThat(client.prepareCount("_percolator").setQuery(matchAllQuery()).execute().actionGet().count(), equalTo(0l)); } - @Test public void percolateOnIndexOperation() throws Exception { + @Test + public void percolateOnIndexOperation() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -248,7 +256,8 @@ public class SimplePercolatorTests extends AbstractNodesTests { } } - @Test public void multiplePercolators() throws Exception { + @Test + public void multiplePercolators() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -298,7 +307,8 @@ public class SimplePercolatorTests extends AbstractNodesTests { } - @Test public void dynamicAddingRemovingQueries() throws Exception { + @Test + public void dynamicAddingRemovingQueries() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { diff --git a/src/test/java/org/elasticsearch/test/integration/ping/PingActionTests.java b/src/test/java/org/elasticsearch/test/integration/ping/PingActionTests.java index 83eaac76950..3f15ad37209 100644 --- a/src/test/java/org/elasticsearch/test/integration/ping/PingActionTests.java +++ b/src/test/java/org/elasticsearch/test/integration/ping/PingActionTests.java @@ -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,26 +32,29 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import static org.elasticsearch.client.Requests.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class PingActionTests extends AbstractNodesTests { private final ESLogger logger = Loggers.getLogger(PingActionTests.class); - @BeforeMethod public void startNodes() { + @BeforeMethod + public void startNodes() { startNode("server1"); startNode("server2"); } - @AfterMethod public void closeNodes() { + @AfterMethod + public void closeNodes() { closeAllNodes(); } - @Test public void testPingActions() throws Exception { + @Test + public void testPingActions() throws Exception { logger.info("Creating index [test1]"); client("server1").admin().indices().create(createIndexRequest("test1")).actionGet(); logger.info("Creating index [test2]"); diff --git a/src/test/java/org/elasticsearch/test/integration/recovery/FullRollingRestartTests.java b/src/test/java/org/elasticsearch/test/integration/recovery/FullRollingRestartTests.java index 1a59c9bd037..d0ec755f4de 100644 --- a/src/test/java/org/elasticsearch/test/integration/recovery/FullRollingRestartTests.java +++ b/src/test/java/org/elasticsearch/test/integration/recovery/FullRollingRestartTests.java @@ -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,20 +24,22 @@ import org.elasticsearch.test.integration.AbstractNodesTests; import org.testng.annotations.AfterMethod; import org.testng.annotations.Test; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class FullRollingRestartTests extends AbstractNodesTests { - @AfterMethod public void shutdownNodes() { + @AfterMethod + public void shutdownNodes() { closeAllNodes(); } - @Test public void testFullRollingRestart() throws Exception { + @Test + public void testFullRollingRestart() throws Exception { startNode("node1"); client("node1").admin().indices().prepareCreate("test").execute().actionGet(); diff --git a/src/test/java/org/elasticsearch/test/integration/recovery/RecoveryWhileUnderLoadTests.java b/src/test/java/org/elasticsearch/test/integration/recovery/RecoveryWhileUnderLoadTests.java index 5f1951d0eee..aa9c510be29 100644 --- a/src/test/java/org/elasticsearch/test/integration/recovery/RecoveryWhileUnderLoadTests.java +++ b/src/test/java/org/elasticsearch/test/integration/recovery/RecoveryWhileUnderLoadTests.java @@ -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,22 +30,24 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class RecoveryWhileUnderLoadTests extends AbstractNodesTests { private final ESLogger logger = Loggers.getLogger(RecoveryWhileUnderLoadTests.class); - @AfterMethod public void shutdownNodes() { + @AfterMethod + public void shutdownNodes() { closeAllNodes(); } - @Test public void recoverWhileUnderLoadAllocateBackupsTest() throws Exception { + @Test + public void recoverWhileUnderLoadAllocateBackupsTest() throws Exception { logger.info("--> starting [node1] ..."); startNode("node1"); @@ -62,7 +64,8 @@ public class RecoveryWhileUnderLoadTests extends AbstractNodesTests { for (int i = 0; i < writers.length; i++) { final int indexerId = i; writers[i] = new Thread() { - @Override public void run() { + @Override + public void run() { try { logger.info("**** starting indexing thread {}", indexerId); while (!stop.get()) { @@ -132,7 +135,8 @@ public class RecoveryWhileUnderLoadTests extends AbstractNodesTests { } } - @Test public void recoverWhileUnderLoadAllocateBackupsRelocatePrimariesTest() throws Exception { + @Test + public void recoverWhileUnderLoadAllocateBackupsRelocatePrimariesTest() throws Exception { logger.info("--> starting [node1] ..."); startNode("node1"); @@ -148,7 +152,8 @@ public class RecoveryWhileUnderLoadTests extends AbstractNodesTests { for (int i = 0; i < writers.length; i++) { final int indexerId = i; writers[i] = new Thread() { - @Override public void run() { + @Override + public void run() { try { logger.info("**** starting indexing thread {}", indexerId); while (!stop.get()) { @@ -221,7 +226,8 @@ public class RecoveryWhileUnderLoadTests extends AbstractNodesTests { } } - @Test public void recoverWhileUnderLoadWithNodeShutdown() throws Exception { + @Test + public void recoverWhileUnderLoadWithNodeShutdown() throws Exception { logger.info("--> starting [node1] ..."); startNode("node1"); logger.info("--> starting [node2] ..."); @@ -239,7 +245,8 @@ public class RecoveryWhileUnderLoadTests extends AbstractNodesTests { for (int i = 0; i < writers.length; i++) { final int indexerId = i; writers[i] = new Thread() { - @Override public void run() { + @Override + public void run() { try { logger.info("**** starting indexing thread {}", indexerId); while (!stop.get()) { diff --git a/src/test/java/org/elasticsearch/test/integration/recovery/SimpleRecoveryTests.java b/src/test/java/org/elasticsearch/test/integration/recovery/SimpleRecoveryTests.java index 56f486de714..5fac76ed698 100644 --- a/src/test/java/org/elasticsearch/test/integration/recovery/SimpleRecoveryTests.java +++ b/src/test/java/org/elasticsearch/test/integration/recovery/SimpleRecoveryTests.java @@ -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,15 +31,16 @@ import org.testng.annotations.AfterMethod; import org.testng.annotations.Test; import static org.elasticsearch.client.Requests.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class SimpleRecoveryTests extends AbstractNodesTests { - @AfterMethod public void closeNodes() { + @AfterMethod + public void closeNodes() { closeAllNodes(); } @@ -47,7 +48,8 @@ public class SimpleRecoveryTests extends AbstractNodesTests { return ImmutableSettings.Builder.EMPTY_SETTINGS; } - @Test public void testSimpleRecovery() throws Exception { + @Test + public void testSimpleRecovery() throws Exception { startNode("server1", recoverySettings()); client("server1").admin().indices().create(createIndexRequest("test")).actionGet(5000); diff --git a/src/test/java/org/elasticsearch/test/integration/recovery/SmallFileChunkSizeRecoveryTests.java b/src/test/java/org/elasticsearch/test/integration/recovery/SmallFileChunkSizeRecoveryTests.java index 6835de7b2f1..f01f7cde4b6 100644 --- a/src/test/java/org/elasticsearch/test/integration/recovery/SmallFileChunkSizeRecoveryTests.java +++ b/src/test/java/org/elasticsearch/test/integration/recovery/SmallFileChunkSizeRecoveryTests.java @@ -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,11 +23,12 @@ import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; /** - * @author kimchy (shay.banon) + * */ public class SmallFileChunkSizeRecoveryTests extends SimpleRecoveryTests { - @Override protected Settings recoverySettings() { + @Override + protected Settings recoverySettings() { return ImmutableSettings.settingsBuilder().put("index.shard.recovery.file_chunk_size", "3b").build(); } } diff --git a/src/test/java/org/elasticsearch/test/integration/recovery/SmallTranslogOpsRecoveryTests.java b/src/test/java/org/elasticsearch/test/integration/recovery/SmallTranslogOpsRecoveryTests.java index 44aa9386080..87d6b0436bc 100644 --- a/src/test/java/org/elasticsearch/test/integration/recovery/SmallTranslogOpsRecoveryTests.java +++ b/src/test/java/org/elasticsearch/test/integration/recovery/SmallTranslogOpsRecoveryTests.java @@ -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,11 +23,12 @@ import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; /** - * @author kimchy (shay.banon) + * */ public class SmallTranslogOpsRecoveryTests extends SimpleRecoveryTests { - @Override protected Settings recoverySettings() { + @Override + protected Settings recoverySettings() { return ImmutableSettings.settingsBuilder().put("index.shard.recovery.translog_ops", 1).build(); } } diff --git a/src/test/java/org/elasticsearch/test/integration/recovery/SmallTranslogSizeRecoveryTests.java b/src/test/java/org/elasticsearch/test/integration/recovery/SmallTranslogSizeRecoveryTests.java index 8f2aaf54557..a5340959f98 100644 --- a/src/test/java/org/elasticsearch/test/integration/recovery/SmallTranslogSizeRecoveryTests.java +++ b/src/test/java/org/elasticsearch/test/integration/recovery/SmallTranslogSizeRecoveryTests.java @@ -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,11 +23,12 @@ import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; /** - * @author kimchy (shay.banon) + * */ public class SmallTranslogSizeRecoveryTests extends SimpleRecoveryTests { - @Override protected Settings recoverySettings() { + @Override + protected Settings recoverySettings() { return ImmutableSettings.settingsBuilder().put("index.shard.recovery.translog_size", "3b").build(); } } diff --git a/src/test/java/org/elasticsearch/test/integration/routing/AliasResolveRoutingTests.java b/src/test/java/org/elasticsearch/test/integration/routing/AliasResolveRoutingTests.java index a0b2b637140..08125be49ea 100644 --- a/src/test/java/org/elasticsearch/test/integration/routing/AliasResolveRoutingTests.java +++ b/src/test/java/org/elasticsearch/test/integration/routing/AliasResolveRoutingTests.java @@ -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,28 +31,31 @@ import org.testng.annotations.Test; import java.util.Map; import java.util.Set; -import static org.elasticsearch.cluster.metadata.AliasAction.*; -import static org.elasticsearch.common.collect.Maps.*; -import static org.elasticsearch.common.collect.Sets.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static com.google.common.collect.Maps.newHashMap; +import static com.google.common.collect.Sets.newHashSet; +import static org.elasticsearch.cluster.metadata.AliasAction.newAddAliasAction; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.nullValue; /** - * @author imotov + * */ public class AliasResolveRoutingTests extends AbstractNodesTests { private Client client; private ClusterService clusterService; - @BeforeClass public void createNodes() throws Exception { + @BeforeClass + public void createNodes() throws Exception { startNode("node1"); startNode("node2"); client = getClient(); clusterService = ((InternalNode) node("node1")).injector().getInstance(ClusterService.class); } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { client.close(); closeAllNodes(); } @@ -61,7 +64,8 @@ public class AliasResolveRoutingTests extends AbstractNodesTests { return client("node1"); } - @Test public void testResolveIndexRouting() throws Exception { + @Test + public void testResolveIndexRouting() throws Exception { try { client.admin().indices().prepareDelete("test1").execute().actionGet(); client.admin().indices().prepareDelete("test2").execute().actionGet(); @@ -106,7 +110,8 @@ public class AliasResolveRoutingTests extends AbstractNodesTests { } - @Test public void testResolveSearchRouting() throws Exception { + @Test + public void testResolveSearchRouting() throws Exception { try { client.admin().indices().prepareDelete("test1").execute().actionGet(); client.admin().indices().prepareDelete("test2").execute().actionGet(); diff --git a/src/test/java/org/elasticsearch/test/integration/routing/AliasRoutingTests.java b/src/test/java/org/elasticsearch/test/integration/routing/AliasRoutingTests.java index a967df7856b..52fb28ddced 100644 --- a/src/test/java/org/elasticsearch/test/integration/routing/AliasRoutingTests.java +++ b/src/test/java/org/elasticsearch/test/integration/routing/AliasRoutingTests.java @@ -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,24 +31,27 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import static org.elasticsearch.cluster.metadata.AliasAction.newAddAliasAction; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.instanceOf; /** - * @author imotov + * */ public class AliasRoutingTests extends AbstractNodesTests { private Client client; - @BeforeClass public void createNodes() throws Exception { + @BeforeClass + public void createNodes() throws Exception { startNode("node1"); startNode("node2"); client = getClient(); } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { client.close(); closeAllNodes(); } @@ -57,7 +60,8 @@ public class AliasRoutingTests extends AbstractNodesTests { return client("node1"); } - @Test public void testAliasCrudRouting() throws Exception { + @Test + public void testAliasCrudRouting() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -131,7 +135,8 @@ public class AliasRoutingTests extends AbstractNodesTests { } } - @Test public void testAliasSearchRouting() throws Exception { + @Test + public void testAliasSearchRouting() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -233,7 +238,8 @@ public class AliasRoutingTests extends AbstractNodesTests { } - @Test public void testAliasSearchRoutingWithTwoIndices() throws Exception { + @Test + public void testAliasSearchRoutingWithTwoIndices() throws Exception { try { client.admin().indices().prepareDelete("test-a").execute().actionGet(); client.admin().indices().prepareDelete("test-b").execute().actionGet(); @@ -296,7 +302,8 @@ public class AliasRoutingTests extends AbstractNodesTests { } } - @Test public void testRequiredRoutingMappingWithAlias() throws Exception { + @Test + public void testRequiredRoutingMappingWithAlias() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -344,7 +351,8 @@ public class AliasRoutingTests extends AbstractNodesTests { } } - @Test public void testIndexingAliasesOverTime() throws Exception { + @Test + public void testIndexingAliasesOverTime() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { diff --git a/src/test/java/org/elasticsearch/test/integration/routing/SimpleRoutingTests.java b/src/test/java/org/elasticsearch/test/integration/routing/SimpleRoutingTests.java index 7df8cb273ea..ed27a2c9213 100644 --- a/src/test/java/org/elasticsearch/test/integration/routing/SimpleRoutingTests.java +++ b/src/test/java/org/elasticsearch/test/integration/routing/SimpleRoutingTests.java @@ -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,24 +31,27 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.instanceOf; /** - * @author kimchy (shay.banon) + * */ public class SimpleRoutingTests extends AbstractNodesTests { private Client client; - @BeforeClass public void createNodes() throws Exception { + @BeforeClass + public void createNodes() throws Exception { startNode("node1"); startNode("node2"); client = getClient(); } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { client.close(); closeAllNodes(); } @@ -57,7 +60,8 @@ public class SimpleRoutingTests extends AbstractNodesTests { return client("node1"); } - @Test public void testSimpleCrudRouting() throws Exception { + @Test + public void testSimpleCrudRouting() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -119,7 +123,8 @@ public class SimpleRoutingTests extends AbstractNodesTests { } } - @Test public void testSimpleSearchRouting() { + @Test + public void testSimpleSearchRouting() { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -190,7 +195,8 @@ public class SimpleRoutingTests extends AbstractNodesTests { } } - @Test public void testRequiredRoutingMapping() throws Exception { + @Test + public void testRequiredRoutingMapping() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -238,7 +244,8 @@ public class SimpleRoutingTests extends AbstractNodesTests { } } - @Test public void testRequiredRoutingWithPathMapping() throws Exception { + @Test + public void testRequiredRoutingWithPathMapping() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -273,7 +280,8 @@ public class SimpleRoutingTests extends AbstractNodesTests { } } - @Test public void testRequiredRoutingWithPathMappingBulk() throws Exception { + @Test + public void testRequiredRoutingWithPathMappingBulk() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -301,7 +309,8 @@ public class SimpleRoutingTests extends AbstractNodesTests { } } - @Test public void testRequiredRoutingWithPathNumericType() throws Exception { + @Test + public void testRequiredRoutingWithPathNumericType() throws Exception { client.admin().indices().prepareDelete().execute().actionGet(); client.admin().indices().prepareCreate("test") diff --git a/src/test/java/org/elasticsearch/test/integration/search/basic/SearchWhileCreatingIndexTests.java b/src/test/java/org/elasticsearch/test/integration/search/basic/SearchWhileCreatingIndexTests.java index 2bd0a796214..471c1b44ae0 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/basic/SearchWhileCreatingIndexTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/basic/SearchWhileCreatingIndexTests.java @@ -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,14 @@ import org.elasticsearch.test.integration.AbstractNodesTests; import org.testng.annotations.AfterMethod; import org.testng.annotations.Test; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; public class SearchWhileCreatingIndexTests extends AbstractNodesTests { - @AfterMethod public void closeAll() { + @AfterMethod + public void closeAll() { closeAllNodes(); } @@ -40,7 +41,8 @@ public class SearchWhileCreatingIndexTests extends AbstractNodesTests { * This test basically verifies that search with a single shard active (cause we indexed to it) and other * shards possibly not active at all (cause they haven't allocated) will still work. */ - @Test public void searchWhileCreatingIndex() { + @Test + public void searchWhileCreatingIndex() { Node node = startNode("node1"); try { diff --git a/src/test/java/org/elasticsearch/test/integration/search/basic/TransportSearchFailuresTests.java b/src/test/java/org/elasticsearch/test/integration/search/basic/TransportSearchFailuresTests.java index 0b27fe03a2d..ddf58097f71 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/basic/TransportSearchFailuresTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/basic/TransportSearchFailuresTests.java @@ -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,21 +37,24 @@ import org.testng.annotations.Test; import java.io.IOException; import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.elasticsearch.common.xcontent.XContentFactory.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.instanceOf; /** - * @author kimchy (shay.banon) + * */ public class TransportSearchFailuresTests extends AbstractNodesTests { - @AfterMethod public void closeNodes() { + @AfterMethod + public void closeNodes() { closeAllNodes(); } - @Test public void testFailedSearchWithWrongQuery() throws Exception { + @Test + public void testFailedSearchWithWrongQuery() throws Exception { logger.info("Start Testing failed search with wrong query"); startNode("server1"); client("server1").admin().indices().create(createIndexRequest("test") diff --git a/src/test/java/org/elasticsearch/test/integration/search/basic/TransportTwoNodesSearchTests.java b/src/test/java/org/elasticsearch/test/integration/search/basic/TransportTwoNodesSearchTests.java index cfe01c05917..561a14d14f3 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/basic/TransportTwoNodesSearchTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/basic/TransportTwoNodesSearchTests.java @@ -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.test.integration.search.basic; +import com.google.common.collect.Sets; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.action.search.SearchPhaseExecutionException; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.client.Client; import org.elasticsearch.client.Requests; import org.elasticsearch.common.Unicode; -import org.elasticsearch.common.collect.Sets; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.search.Scroll; import org.elasticsearch.search.SearchHit; @@ -44,16 +44,17 @@ import java.util.Set; import static org.elasticsearch.action.search.SearchType.*; import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.elasticsearch.common.unit.TimeValue.*; -import static org.elasticsearch.common.xcontent.XContentFactory.*; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.elasticsearch.search.builder.SearchSourceBuilder.*; -import static org.hamcrest.MatcherAssert.*; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.elasticsearch.common.unit.TimeValue.timeValueMinutes; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; +import static org.elasticsearch.index.query.QueryBuilders.termQuery; +import static org.elasticsearch.search.builder.SearchSourceBuilder.searchSource; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** - * @author kimchy (shay.banon) + * */ public class TransportTwoNodesSearchTests extends AbstractNodesTests { @@ -61,7 +62,8 @@ public class TransportTwoNodesSearchTests extends AbstractNodesTests { private Set fullExpectedIds = Sets.newHashSet(); - @BeforeClass public void createNodes() throws Exception { + @BeforeClass + public void createNodes() throws Exception { startNode("server1"); startNode("server2"); client = getClient(); @@ -79,7 +81,8 @@ public class TransportTwoNodesSearchTests extends AbstractNodesTests { client.admin().indices().refresh(refreshRequest("test")).actionGet(); } - @AfterClass public void closeServers() { + @AfterClass + public void closeServers() { client.close(); closeAllNodes(); } @@ -88,7 +91,8 @@ public class TransportTwoNodesSearchTests extends AbstractNodesTests { return client("server1"); } - @Test public void testDfsQueryThenFetch() throws Exception { + @Test + public void testDfsQueryThenFetch() throws Exception { SearchSourceBuilder source = searchSource() .query(termQuery("multi", "test")) .from(0).size(60).explain(true); @@ -116,7 +120,8 @@ public class TransportTwoNodesSearchTests extends AbstractNodesTests { } } - @Test public void testDfsQueryThenFetchWithSort() throws Exception { + @Test + public void testDfsQueryThenFetchWithSort() throws Exception { SearchSourceBuilder source = searchSource() .query(termQuery("multi", "test")) .from(0).size(60).explain(true).sort("age", SortOrder.ASC); @@ -142,7 +147,8 @@ public class TransportTwoNodesSearchTests extends AbstractNodesTests { } } - @Test public void testQueryThenFetch() throws Exception { + @Test + public void testQueryThenFetch() throws Exception { SearchSourceBuilder source = searchSource() .query(termQuery("multi", "test")) .sort("nid", SortOrder.DESC) // we have to sort here to have some ordering with dist scoring @@ -169,7 +175,8 @@ public class TransportTwoNodesSearchTests extends AbstractNodesTests { } } - @Test public void testQueryThenFetchWithFrom() throws Exception { + @Test + public void testQueryThenFetchWithFrom() throws Exception { SearchSourceBuilder source = searchSource() .query(matchAllQuery()) .explain(true); @@ -195,7 +202,8 @@ public class TransportTwoNodesSearchTests extends AbstractNodesTests { assertThat(collectedIds, equalTo(fullExpectedIds)); } - @Test public void testQueryThenFetchWithSort() throws Exception { + @Test + public void testQueryThenFetchWithSort() throws Exception { SearchSourceBuilder source = searchSource() .query(termQuery("multi", "test")) .from(0).size(60).explain(true).sort("age", SortOrder.ASC); @@ -221,7 +229,8 @@ public class TransportTwoNodesSearchTests extends AbstractNodesTests { } } - @Test public void testQueryAndFetch() throws Exception { + @Test + public void testQueryAndFetch() throws Exception { SearchSourceBuilder source = searchSource() .query(termQuery("multi", "test")) .from(0).size(20).explain(true); @@ -257,7 +266,8 @@ public class TransportTwoNodesSearchTests extends AbstractNodesTests { assertThat("make sure we got all [" + expectedIds + "]", expectedIds.size(), equalTo(0)); } - @Test public void testDfsQueryAndFetch() throws Exception { + @Test + public void testDfsQueryAndFetch() throws Exception { SearchSourceBuilder source = searchSource() .query(termQuery("multi", "test")) .from(0).size(20).explain(true); @@ -294,7 +304,8 @@ public class TransportTwoNodesSearchTests extends AbstractNodesTests { assertThat("make sure we got all [" + expectedIds + "]", expectedIds.size(), equalTo(0)); } - @Test public void testSimpleFacets() throws Exception { + @Test + public void testSimpleFacets() throws Exception { SearchSourceBuilder sourceBuilder = searchSource() .query(termQuery("multi", "test")) .from(0).size(20).explain(true) @@ -309,12 +320,14 @@ public class TransportTwoNodesSearchTests extends AbstractNodesTests { assertThat(searchResponse.facets().facet(QueryFacet.class, "all").count(), equalTo(100l)); } - @Test public void testSimpleFacetsTwice() throws Exception { + @Test + public void testSimpleFacetsTwice() throws Exception { testSimpleFacets(); testSimpleFacets(); } - @Test public void testFailedSearchWithWrongQuery() throws Exception { + @Test + public void testFailedSearchWithWrongQuery() throws Exception { logger.info("Start Testing failed search with wrong query"); try { SearchResponse searchResponse = client.search(searchRequest("test").source(Unicode.fromStringAsBytes("{ xxx }"))).actionGet(); @@ -329,7 +342,8 @@ public class TransportTwoNodesSearchTests extends AbstractNodesTests { logger.info("Done Testing failed search"); } - @Test public void testFailedSearchWithWrongFrom() throws Exception { + @Test + public void testFailedSearchWithWrongFrom() throws Exception { logger.info("Start Testing failed search with wrong from"); SearchSourceBuilder source = searchSource() .query(termQuery("multi", "test")) diff --git a/src/test/java/org/elasticsearch/test/integration/search/child/SimpleChildQuerySearchTests.java b/src/test/java/org/elasticsearch/test/integration/search/child/SimpleChildQuerySearchTests.java index 084f9368771..1be2d03f09e 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/child/SimpleChildQuerySearchTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/child/SimpleChildQuerySearchTests.java @@ -33,26 +33,28 @@ import org.testng.annotations.Test; import java.util.Arrays; -import static org.elasticsearch.index.query.FilterBuilders.*; +import static org.elasticsearch.index.query.FilterBuilders.hasChildFilter; import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.elasticsearch.search.facet.FacetBuilders.*; -import static org.hamcrest.MatcherAssert.*; +import static org.elasticsearch.search.facet.FacetBuilders.termsFacet; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** - * @author kimchy (shay.banon) + * */ public class SimpleChildQuerySearchTests extends AbstractNodesTests { private Client client; - @BeforeClass public void createNodes() throws Exception { + @BeforeClass + public void createNodes() throws Exception { startNode("node1"); startNode("node2"); client = getClient(); } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { client.close(); closeAllNodes(); } @@ -61,7 +63,8 @@ public class SimpleChildQuerySearchTests extends AbstractNodesTests { return client("node1"); } - @Test public void simpleChildQuery() throws Exception { + @Test + public void simpleChildQuery() throws Exception { client.admin().indices().prepareDelete().execute().actionGet(); client.admin().indices().prepareCreate("test").setSettings(ImmutableSettings.settingsBuilder().put("index.number_of_shards", 1)).execute().actionGet(); @@ -210,7 +213,8 @@ public class SimpleChildQuerySearchTests extends AbstractNodesTests { assertThat(searchResponse.hits().getAt(1).id(), anyOf(equalTo("p2"), equalTo("p1"))); } - @Test public void simpleChildQueryWithFlush() throws Exception { + @Test + public void simpleChildQueryWithFlush() throws Exception { client.admin().indices().prepareDelete().execute().actionGet(); client.admin().indices().prepareCreate("test").setSettings(ImmutableSettings.settingsBuilder().put("index.number_of_shards", 1)).execute().actionGet(); @@ -304,7 +308,8 @@ public class SimpleChildQuerySearchTests extends AbstractNodesTests { assertThat(searchResponse.hits().getAt(1).id(), anyOf(equalTo("p2"), equalTo("p1"))); } - @Test public void simpleChildQueryWithFlushAnd3Shards() throws Exception { + @Test + public void simpleChildQueryWithFlushAnd3Shards() throws Exception { client.admin().indices().prepareDelete().execute().actionGet(); client.admin().indices().prepareCreate("test").setSettings(ImmutableSettings.settingsBuilder().put("index.number_of_shards", 3)).execute().actionGet(); @@ -398,7 +403,8 @@ public class SimpleChildQuerySearchTests extends AbstractNodesTests { assertThat(searchResponse.hits().getAt(1).id(), anyOf(equalTo("p2"), equalTo("p1"))); } - @Test public void testScopedFacet() throws Exception { + @Test + public void testScopedFacet() throws Exception { client.admin().indices().prepareDelete().execute().actionGet(); client.admin().indices().prepareCreate("test").setSettings(ImmutableSettings.settingsBuilder().put("index.number_of_shards", 1)).execute().actionGet(); @@ -436,7 +442,8 @@ public class SimpleChildQuerySearchTests extends AbstractNodesTests { assertThat(termsFacet.entries().get(1).count(), equalTo(1)); } - @Test public void testDeletedParent() throws Exception { + @Test + public void testDeletedParent() throws Exception { client.admin().indices().prepareDelete().execute().actionGet(); client.admin().indices().prepareCreate("test").setSettings(ImmutableSettings.settingsBuilder().put("index.number_of_shards", 1)).execute().actionGet(); @@ -496,7 +503,8 @@ public class SimpleChildQuerySearchTests extends AbstractNodesTests { assertThat(searchResponse.hits().getAt(0).sourceAsString(), containsString("\"p_value1_updated\"")); } - @Test public void testDfsSearchType() throws Exception { + @Test + public void testDfsSearchType() throws Exception { client.admin().indices().prepareDelete().execute().actionGet(); client.admin().indices().prepareCreate("test").setSettings(ImmutableSettings.settingsBuilder().put("index.number_of_shards", 2)).execute().actionGet(); diff --git a/src/test/java/org/elasticsearch/test/integration/search/compress/SearchSourceCompressTests.java b/src/test/java/org/elasticsearch/test/integration/search/compress/SearchSourceCompressTests.java index b0938ddd99e..63a14852fbd 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/compress/SearchSourceCompressTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/compress/SearchSourceCompressTests.java @@ -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,23 +32,25 @@ import org.testng.annotations.Test; import java.io.IOException; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class SearchSourceCompressTests extends AbstractNodesTests { private Client client; - @BeforeClass public void createNodes() throws Exception { + @BeforeClass + public void createNodes() throws Exception { startNode("node1"); startNode("node2"); client = getClient(); } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { client.close(); closeAllNodes(); } @@ -57,15 +59,18 @@ public class SearchSourceCompressTests extends AbstractNodesTests { return client("node1"); } - @Test public void testSourceFieldCompressed() throws IOException { + @Test + public void testSourceFieldCompressed() throws IOException { verifySource(true); } - @Test public void testSourceFieldPlainExplicit() throws IOException { + @Test + public void testSourceFieldPlainExplicit() throws IOException { verifySource(false); } - @Test public void testSourceFieldPlain() throws IOException { + @Test + public void testSourceFieldPlain() throws IOException { verifySource(null); } diff --git a/src/test/java/org/elasticsearch/test/integration/search/customscore/CustomScoreSearchTests.java b/src/test/java/org/elasticsearch/test/integration/search/customscore/CustomScoreSearchTests.java index fbfd96e4e2e..8992e3ad4bc 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/customscore/CustomScoreSearchTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/customscore/CustomScoreSearchTests.java @@ -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,27 +30,30 @@ import org.testng.annotations.Test; import java.util.Arrays; import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.common.xcontent.XContentFactory.*; -import static org.elasticsearch.index.query.FilterBuilders.*; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import static org.elasticsearch.index.query.FilterBuilders.termFilter; import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.elasticsearch.search.builder.SearchSourceBuilder.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.search.builder.SearchSourceBuilder.searchSource; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.anyOf; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ @Test public class CustomScoreSearchTests extends AbstractNodesTests { private Client client; - @BeforeMethod public void createNodes() throws Exception { + @BeforeMethod + public void createNodes() throws Exception { startNode("server1"); client = getClient(); } - @AfterMethod public void closeNodes() { + @AfterMethod + public void closeNodes() { client.close(); closeAllNodes(); } @@ -59,7 +62,8 @@ public class CustomScoreSearchTests extends AbstractNodesTests { return client("server1"); } - @Test public void testCustomScriptBoost() throws Exception { + @Test + public void testCustomScriptBoost() throws Exception { client.admin().indices().prepareDelete().execute().actionGet(); client.admin().indices().create(createIndexRequest("test")).actionGet(); @@ -145,7 +149,8 @@ public class CustomScoreSearchTests extends AbstractNodesTests { assertThat(response.hits().getAt(1).id(), equalTo("2")); } - @Test public void testCustomFiltersScore() throws Exception { + @Test + public void testCustomFiltersScore() throws Exception { client.admin().indices().prepareDelete().execute().actionGet(); client.prepareIndex("test", "type", "1").setSource("field", "value1", "color", "red").execute().actionGet(); diff --git a/src/test/java/org/elasticsearch/test/integration/search/embedded/SingleShardEmbeddedSearchTests.java b/src/test/java/org/elasticsearch/test/integration/search/embedded/SingleShardEmbeddedSearchTests.java index e19d51c6b96..2a6c7a33926 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/embedded/SingleShardEmbeddedSearchTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/embedded/SingleShardEmbeddedSearchTests.java @@ -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.elasticsearch.test.integration.search.embedded; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import gnu.trove.ExtTIntArrayList; import org.elasticsearch.action.search.SearchType; import org.elasticsearch.client.Client; -import org.elasticsearch.common.collect.Maps; -import org.elasticsearch.common.collect.Sets; -import org.elasticsearch.common.trove.ExtTIntArrayList; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.node.internal.InternalNode; -import org.elasticsearch.search.Scroll; -import org.elasticsearch.search.SearchContextMissingException; -import org.elasticsearch.search.SearchHit; -import org.elasticsearch.search.SearchService; -import org.elasticsearch.search.SearchShardTarget; +import org.elasticsearch.search.*; import org.elasticsearch.search.builder.SearchSourceBuilder; import org.elasticsearch.search.controller.SearchPhaseController; import org.elasticsearch.search.controller.ShardDoc; @@ -53,16 +49,18 @@ import org.testng.annotations.Test; import java.util.Map; import java.util.Set; -import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.common.collect.Lists.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.elasticsearch.search.builder.SearchSourceBuilder.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static com.google.common.collect.Lists.newArrayList; +import static org.elasticsearch.client.Requests.indexRequest; +import static org.elasticsearch.client.Requests.refreshRequest; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; +import static org.elasticsearch.index.query.QueryBuilders.termQuery; +import static org.elasticsearch.search.builder.SearchSourceBuilder.searchSource; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class SingleShardEmbeddedSearchTests extends AbstractNodesTests { @@ -76,7 +74,8 @@ public class SingleShardEmbeddedSearchTests extends AbstractNodesTests { return true; } - @BeforeClass public void createNodeAndInitWithData() throws Exception { + @BeforeClass + public void createNodeAndInitWithData() throws Exception { putDefaultSettings(settingsBuilder().put("search.controller.optimize_single_shard", optimizeSingleShard())); startNode("server1"); client = client("server1"); @@ -96,15 +95,18 @@ public class SingleShardEmbeddedSearchTests extends AbstractNodesTests { searchPhaseController = ((InternalNode) node("server1")).injector().getInstance(SearchPhaseController.class); } - @AfterClass public void closeNode() { + @AfterClass + public void closeNode() { closeAllNodes(); } - @Test public void verifyOptimizeSingleShardSetting() { + @Test + public void verifyOptimizeSingleShardSetting() { assertThat(searchPhaseController.optimizeSingleShard(), equalTo(optimizeSingleShard())); } - @Test public void testDirectDfs() throws Exception { + @Test + public void testDirectDfs() throws Exception { DfsSearchResult dfsResult = searchService.executeDfsPhase(searchRequest(searchSource().query(termQuery("name", "test1")), SearchType.DFS_QUERY_THEN_FETCH)); assertThat(dfsResult.terms().length, equalTo(1)); @@ -114,12 +116,14 @@ public class SingleShardEmbeddedSearchTests extends AbstractNodesTests { assertThat(dfsResult.freqs()[0], equalTo(1)); } - @Test public void testDirectQuery() throws Exception { + @Test + public void testDirectQuery() throws Exception { QuerySearchResult queryResult = searchService.executeQueryPhase(searchRequest(searchSource().query(termQuery("name", "test1")), SearchType.QUERY_THEN_FETCH)); assertThat(queryResult.topDocs().totalHits, equalTo(1)); } - @Test public void testDirectFetch() throws Exception { + @Test + public void testDirectFetch() throws Exception { QueryFetchSearchResult queryFetchResult = searchService.executeFetchPhase(searchRequest(searchSource().query(termQuery("name", "test1")), SearchType.QUERY_AND_FETCH)); assertThat(queryFetchResult.queryResult().topDocs().totalHits, equalTo(1)); assertThat(queryFetchResult.fetchResult().hits().hits().length, equalTo(1)); @@ -128,7 +132,8 @@ public class SingleShardEmbeddedSearchTests extends AbstractNodesTests { assertThat(queryFetchResult.fetchResult().hits().hits()[0].type(), equalTo("type1")); } - @Test public void testScan() throws Exception { + @Test + public void testScan() throws Exception { Scroll scroll = new Scroll(TimeValue.timeValueMillis(500)); QuerySearchResult scanResult = searchService.executeScan(searchRequest(searchSource().query(matchAllQuery()).size(2), SearchType.SCAN).scroll(scroll)); assertThat(scanResult.queryResult().topDocs().totalHits, equalTo(5)); @@ -166,7 +171,8 @@ public class SingleShardEmbeddedSearchTests extends AbstractNodesTests { } } - @Test public void testQueryThenFetch() throws Exception { + @Test + public void testQueryThenFetch() throws Exception { QuerySearchResult queryResult = searchService.executeQueryPhase(searchRequest(searchSource().query(termQuery("name", "test1")), SearchType.QUERY_THEN_FETCH)); assertThat(queryResult.topDocs().totalHits, equalTo(1)); @@ -181,7 +187,8 @@ public class SingleShardEmbeddedSearchTests extends AbstractNodesTests { assertThat(fetchResult.hits().hits()[0].type(), equalTo("type1")); } - @Test public void testQueryThenFetchIterateWithFrom() throws Exception { + @Test + public void testQueryThenFetchIterateWithFrom() throws Exception { QuerySearchResult queryResult = searchService.executeQueryPhase(searchRequest(searchSource().query(matchAllQuery()).from(0).size(2), SearchType.QUERY_THEN_FETCH)); assertThat(queryResult.topDocs().totalHits, equalTo(5)); @@ -233,7 +240,8 @@ public class SingleShardEmbeddedSearchTests extends AbstractNodesTests { assertThat(idsLoaded, equalTo(expectedIds)); } - @Test public void testQueryThenFetchIterateWithFromSortedByAge() throws Exception { + @Test + public void testQueryThenFetchIterateWithFromSortedByAge() throws Exception { QuerySearchResult queryResult = searchService.executeQueryPhase(searchRequest(searchSource().query(matchAllQuery()).from(0).size(2).sort("age", SortOrder.DESC), SearchType.QUERY_THEN_FETCH)); assertThat(queryResult.topDocs().totalHits, equalTo(5)); @@ -285,7 +293,8 @@ public class SingleShardEmbeddedSearchTests extends AbstractNodesTests { assertThat(idsLoaded, equalTo(expectedIds)); } - @Test public void testQueryAndFetch() throws Exception { + @Test + public void testQueryAndFetch() throws Exception { QueryFetchSearchResult result = searchService.executeFetchPhase(searchRequest(searchSource().query(termQuery("name", "test1")), SearchType.QUERY_AND_FETCH)); FetchSearchResult fetchResult = result.fetchResult(); assertThat(fetchResult.hits().hits()[0].sourceAsString(), equalTo(source("1", "test1", 1))); @@ -293,7 +302,8 @@ public class SingleShardEmbeddedSearchTests extends AbstractNodesTests { assertThat(fetchResult.hits().hits()[0].type(), equalTo("type1")); } - @Test public void testQueryAndFetchIterateWithFrom() throws Exception { + @Test + public void testQueryAndFetchIterateWithFrom() throws Exception { QueryFetchSearchResult result = searchService.executeFetchPhase(searchRequest(searchSource().query(matchAllQuery()).from(0).size(2).sort("age", SortOrder.DESC), SearchType.QUERY_AND_FETCH)); assertThat(result.queryResult().topDocs().totalHits, equalTo(5)); @@ -337,7 +347,8 @@ public class SingleShardEmbeddedSearchTests extends AbstractNodesTests { assertThat(idsLoaded, equalTo(expectedIds)); } - @Test public void testDfsQueryThenFetch() throws Exception { + @Test + public void testDfsQueryThenFetch() throws Exception { DfsSearchResult dfsResult = searchService.executeDfsPhase(searchRequest(searchSource().query(termQuery("name", "test1")), SearchType.DFS_QUERY_THEN_FETCH)); AggregatedDfs dfs = searchPhaseController.aggregateDfs(newArrayList(dfsResult)); @@ -355,7 +366,8 @@ public class SingleShardEmbeddedSearchTests extends AbstractNodesTests { assertThat(fetchResult.hits().hits()[0].type(), equalTo("type1")); } - @Test public void testQueryFetchKeepAliveTimeout() throws Exception { + @Test + public void testQueryFetchKeepAliveTimeout() throws Exception { QuerySearchResult queryResult = searchService.executeQueryPhase(searchRequest(searchSource().query(termQuery("name", "test1")), SearchType.QUERY_THEN_FETCH).scroll(new Scroll(TimeValue.timeValueMillis(10)))); assertThat(queryResult.topDocs().totalHits, equalTo(1)); diff --git a/src/test/java/org/elasticsearch/test/integration/search/embedded/SingleShardNoOptimizationEmbeddedSearchTests.java b/src/test/java/org/elasticsearch/test/integration/search/embedded/SingleShardNoOptimizationEmbeddedSearchTests.java index c0e2b371e54..51e64d623b9 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/embedded/SingleShardNoOptimizationEmbeddedSearchTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/embedded/SingleShardNoOptimizationEmbeddedSearchTests.java @@ -21,7 +21,8 @@ package org.elasticsearch.test.integration.search.embedded; public class SingleShardNoOptimizationEmbeddedSearchTests extends SingleShardEmbeddedSearchTests { - @Override protected boolean optimizeSingleShard() { + @Override + protected boolean optimizeSingleShard() { return false; } } \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/integration/search/embedded/ThreeShardsEmbeddedSearchTests.java b/src/test/java/org/elasticsearch/test/integration/search/embedded/ThreeShardsEmbeddedSearchTests.java index 2954eff40c8..79270e4028c 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/embedded/ThreeShardsEmbeddedSearchTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/embedded/ThreeShardsEmbeddedSearchTests.java @@ -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,22 +19,18 @@ package org.elasticsearch.test.integration.search.embedded; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Sets; +import gnu.trove.ExtTIntArrayList; import org.elasticsearch.action.search.SearchType; import org.elasticsearch.client.Client; import org.elasticsearch.client.Requests; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.routing.ShardIterator; import org.elasticsearch.cluster.routing.ShardRouting; -import org.elasticsearch.common.collect.ImmutableMap; -import org.elasticsearch.common.collect.Sets; -import org.elasticsearch.common.trove.ExtTIntArrayList; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.node.internal.InternalNode; -import org.elasticsearch.search.Scroll; -import org.elasticsearch.search.SearchHit; -import org.elasticsearch.search.SearchHits; -import org.elasticsearch.search.SearchService; -import org.elasticsearch.search.SearchShardTarget; +import org.elasticsearch.search.*; import org.elasticsearch.search.builder.SearchSourceBuilder; import org.elasticsearch.search.controller.SearchPhaseController; import org.elasticsearch.search.controller.ShardDoc; @@ -62,18 +58,20 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; -import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.common.collect.Lists.*; -import static org.elasticsearch.common.collect.Maps.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.elasticsearch.common.unit.TimeValue.*; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.elasticsearch.search.builder.SearchSourceBuilder.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static com.google.common.collect.Lists.newArrayList; +import static com.google.common.collect.Maps.newHashMap; +import static org.elasticsearch.client.Requests.indexRequest; +import static org.elasticsearch.client.Requests.refreshRequest; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.elasticsearch.common.unit.TimeValue.timeValueMinutes; +import static org.elasticsearch.index.query.QueryBuilders.termQuery; +import static org.elasticsearch.search.builder.SearchSourceBuilder.searchSource; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.notNullValue; /** - * @author kimchy (shay.banon) + * */ public class ThreeShardsEmbeddedSearchTests extends AbstractNodesTests { @@ -83,7 +81,8 @@ public class ThreeShardsEmbeddedSearchTests extends AbstractNodesTests { private SearchPhaseController searchPhaseController; - @BeforeClass public void createNodeAndInitWithData() throws Exception { + @BeforeClass + public void createNodeAndInitWithData() throws Exception { startNode("server1"); startNode("server2"); @@ -108,11 +107,13 @@ public class ThreeShardsEmbeddedSearchTests extends AbstractNodesTests { searchPhaseController = ((InternalNode) node("server1")).injector().getInstance(SearchPhaseController.class); } - @AfterClass public void closeServers() { + @AfterClass + public void closeServers() { closeAllNodes(); } - @Test public void testDfsQueryThenFetch() throws Exception { + @Test + public void testDfsQueryThenFetch() throws Exception { SearchSourceBuilder sourceBuilder = searchSource() .query(termQuery("multi", "test")) .from(0).size(60).explain(true).indexBoost("test", 1.0f).indexBoost("test2", 2.0f); @@ -180,7 +181,8 @@ public class ThreeShardsEmbeddedSearchTests extends AbstractNodesTests { } } - @Test public void testDfsQueryThenFetchWithSort() throws Exception { + @Test + public void testDfsQueryThenFetchWithSort() throws Exception { SearchSourceBuilder sourceBuilder = searchSource() .query(termQuery("multi", "test")) .from(0).size(60).explain(true).sort("age", SortOrder.ASC); @@ -269,7 +271,8 @@ public class ThreeShardsEmbeddedSearchTests extends AbstractNodesTests { assertThat(hits.hits().length, equalTo(0)); } - @Test public void testQueryAndFetch() { + @Test + public void testQueryAndFetch() { SearchSourceBuilder sourceBuilder = searchSource() .query(termQuery("multi", "test")) .from(0).size(20).explain(true); @@ -324,7 +327,8 @@ public class ThreeShardsEmbeddedSearchTests extends AbstractNodesTests { assertThat("make sure we got all [" + expectedIds + "]", expectedIds.size(), equalTo(0)); } - @Test public void testSimpleFacets() { + @Test + public void testSimpleFacets() { SearchSourceBuilder sourceBuilder = searchSource() .query(termQuery("multi", "test")) .from(0).size(20).explain(true).sort("age", SortOrder.ASC) @@ -358,7 +362,8 @@ public class ThreeShardsEmbeddedSearchTests extends AbstractNodesTests { assertThat(searchResponse.facets().facet(QueryFacet.class, "all").count(), equalTo(100l)); } - @Test public void testSimpleFacetsTwice() { + @Test + public void testSimpleFacetsTwice() { testSimpleFacets(); testSimpleFacets(); } diff --git a/src/test/java/org/elasticsearch/test/integration/search/embedded/ThreeShardsUnbalancedShardsEmbeddedSearchTests.java b/src/test/java/org/elasticsearch/test/integration/search/embedded/ThreeShardsUnbalancedShardsEmbeddedSearchTests.java index c1b56d9914f..427cc1ecd25 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/embedded/ThreeShardsUnbalancedShardsEmbeddedSearchTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/embedded/ThreeShardsUnbalancedShardsEmbeddedSearchTests.java @@ -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,8 @@ package org.elasticsearch.test.integration.search.embedded; +import com.google.common.collect.ImmutableMap; +import gnu.trove.ExtTIntArrayList; import org.elasticsearch.action.search.SearchType; import org.elasticsearch.client.Client; import org.elasticsearch.client.Requests; @@ -28,20 +30,14 @@ import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.cluster.routing.allocation.decider.AwarenessAllocationDecider; import org.elasticsearch.cluster.routing.operation.OperationRouting; import org.elasticsearch.cluster.routing.operation.plain.PlainOperationRouting; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.trove.ExtTIntArrayList; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.node.internal.InternalNode; import org.elasticsearch.node.settings.NodeSettingsService; -import org.elasticsearch.search.Scroll; -import org.elasticsearch.search.SearchHit; -import org.elasticsearch.search.SearchHits; -import org.elasticsearch.search.SearchService; -import org.elasticsearch.search.SearchShardTarget; +import org.elasticsearch.search.*; import org.elasticsearch.search.builder.SearchSourceBuilder; import org.elasticsearch.search.controller.SearchPhaseController; import org.elasticsearch.search.controller.ShardDoc; @@ -67,19 +63,20 @@ import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; -import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.common.collect.Lists.*; -import static org.elasticsearch.common.collect.Maps.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.elasticsearch.common.unit.TimeValue.*; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.elasticsearch.search.builder.SearchSourceBuilder.*; -import static org.elasticsearch.search.facet.FacetBuilders.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static com.google.common.collect.Lists.newArrayList; +import static com.google.common.collect.Maps.newHashMap; +import static org.elasticsearch.client.Requests.indexRequest; +import static org.elasticsearch.client.Requests.refreshRequest; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.elasticsearch.common.unit.TimeValue.timeValueMinutes; +import static org.elasticsearch.index.query.QueryBuilders.termQuery; +import static org.elasticsearch.search.builder.SearchSourceBuilder.searchSource; +import static org.elasticsearch.search.facet.FacetBuilders.queryFacet; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class ThreeShardsUnbalancedShardsEmbeddedSearchTests extends AbstractNodesTests { @@ -89,7 +86,8 @@ public class ThreeShardsUnbalancedShardsEmbeddedSearchTests extends AbstractNode private SearchPhaseController searchPhaseController; - @BeforeClass public void createNodeAndInitWithData() throws Exception { + @BeforeClass + public void createNodeAndInitWithData() throws Exception { ImmutableSettings.Builder nodeSettings = ImmutableSettings.settingsBuilder() .put("cluster.routing.operation.type", "org.elasticsearch.test.integration.search.embedded.ThreeShardsUnbalancedShardsEmbeddedSearchTests$UnevenOperationRoutingModule"); startNode("server1", nodeSettings); @@ -118,11 +116,13 @@ public class ThreeShardsUnbalancedShardsEmbeddedSearchTests extends AbstractNode searchPhaseController = ((InternalNode) node("server1")).injector().getInstance(SearchPhaseController.class); } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { closeAllNodes(); } - @Test public void testDfsQueryFetch() throws Exception { + @Test + public void testDfsQueryFetch() throws Exception { SearchSourceBuilder sourceBuilder = searchSource() .query(termQuery("multi", "test")) .from(0).size(60).explain(true); @@ -189,7 +189,8 @@ public class ThreeShardsUnbalancedShardsEmbeddedSearchTests extends AbstractNode } } - @Test public void testDfsQueryFetchWithSort() throws Exception { + @Test + public void testDfsQueryFetchWithSort() throws Exception { SearchSourceBuilder sourceBuilder = searchSource() .query(termQuery("multi", "test")) .from(0).size(60).explain(true).sort("age", SortOrder.ASC); @@ -278,7 +279,8 @@ public class ThreeShardsUnbalancedShardsEmbeddedSearchTests extends AbstractNode assertThat(hits.hits().length, equalTo(0)); } - @Test public void testQueryFetchInOneGo() { + @Test + public void testQueryFetchInOneGo() { SearchSourceBuilder sourceBuilder = searchSource() .query(termQuery("multi", "test")) .from(0).size(20).explain(true); @@ -332,7 +334,8 @@ public class ThreeShardsUnbalancedShardsEmbeddedSearchTests extends AbstractNode // } } - @Test public void testSimpleFacets() { + @Test + public void testSimpleFacets() { SearchSourceBuilder sourceBuilder = searchSource() .query(termQuery("multi", "test")) .from(0).size(20).explain(true).sort("age", SortOrder.ASC) @@ -366,7 +369,8 @@ public class ThreeShardsUnbalancedShardsEmbeddedSearchTests extends AbstractNode assertThat(searchResponse.facets().facet(QueryFacet.class, "all").count(), equalTo(100l)); } - @Test public void testSimpleFacetsTwice() { + @Test + public void testSimpleFacetsTwice() { testSimpleFacets(); testSimpleFacets(); } @@ -388,7 +392,8 @@ public class ThreeShardsUnbalancedShardsEmbeddedSearchTests extends AbstractNode } public static class UnevenOperationRoutingModule extends AbstractModule { - @Override protected void configure() { + @Override + protected void configure() { bind(OperationRouting.class).to(UnevenOperationRoutingStrategy.class).asEagerSingleton(); } } @@ -400,11 +405,13 @@ public class ThreeShardsUnbalancedShardsEmbeddedSearchTests extends AbstractNode */ public static class UnevenOperationRoutingStrategy extends PlainOperationRouting { - @Inject public UnevenOperationRoutingStrategy(Settings settings) { - super(settings, null, new AwarenessAllocationDecider(Builder.EMPTY_SETTINGS, new NodeSettingsService(Builder.EMPTY_SETTINGS))); + @Inject + public UnevenOperationRoutingStrategy(Settings settings) { + super(settings, null, new AwarenessAllocationDecider(ImmutableSettings.Builder.EMPTY_SETTINGS, new NodeSettingsService(ImmutableSettings.Builder.EMPTY_SETTINGS))); } - @Override protected int hash(String routing) { + @Override + protected int hash(String routing) { long lId = Long.parseLong(routing); if (lId < 60) { return 0; @@ -415,7 +422,8 @@ public class ThreeShardsUnbalancedShardsEmbeddedSearchTests extends AbstractNode return 2; } - @Override protected int hash(String type, String id) { + @Override + protected int hash(String type, String id) { long lId = Long.parseLong(id); if (lId < 60) { return 0; diff --git a/src/test/java/org/elasticsearch/test/integration/search/facet/SimpleFacetsMultiShardMultiNodeTests.java b/src/test/java/org/elasticsearch/test/integration/search/facet/SimpleFacetsMultiShardMultiNodeTests.java index ce8c4437acc..a443d157178 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/facet/SimpleFacetsMultiShardMultiNodeTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/facet/SimpleFacetsMultiShardMultiNodeTests.java @@ -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,13 @@ import org.testng.annotations.Test; @Test public class SimpleFacetsMultiShardMultiNodeTests extends SimpleFacetsTests { - @Override protected int numberOfShards() { + @Override + protected int numberOfShards() { return 3; } - @Override protected int numberOfNodes() { + @Override + protected int numberOfNodes() { return 2; } } \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/integration/search/facet/SimpleFacetsMultiShardTests.java b/src/test/java/org/elasticsearch/test/integration/search/facet/SimpleFacetsMultiShardTests.java index 511ea5b5744..d797cc49a99 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/facet/SimpleFacetsMultiShardTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/facet/SimpleFacetsMultiShardTests.java @@ -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,8 @@ import org.testng.annotations.Test; @Test public class SimpleFacetsMultiShardTests extends SimpleFacetsTests { - @Override protected int numberOfShards() { + @Override + protected int numberOfShards() { return 3; } } \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/integration/search/facet/SimpleFacetsTests.java b/src/test/java/org/elasticsearch/test/integration/search/facet/SimpleFacetsTests.java index 0e85747ed42..c2a89ab490d 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/facet/SimpleFacetsTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/facet/SimpleFacetsTests.java @@ -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,8 +23,6 @@ import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchType; import org.elasticsearch.action.search.ShardSearchFailure; import org.elasticsearch.client.Client; -import org.elasticsearch.common.joda.time.DateTimeZone; -import org.elasticsearch.common.joda.time.format.ISODateTimeFormat; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; @@ -43,27 +41,30 @@ import org.elasticsearch.search.facet.terms.longs.InternalLongTermsFacet; import org.elasticsearch.search.facet.terms.shorts.InternalShortTermsFacet; import org.elasticsearch.search.facet.termsstats.TermsStatsFacet; import org.elasticsearch.test.integration.AbstractNodesTests; +import org.joda.time.DateTimeZone; +import org.joda.time.format.ISODateTimeFormat; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import java.util.concurrent.TimeUnit; -import static org.elasticsearch.common.xcontent.XContentFactory.*; -import static org.elasticsearch.index.query.FilterBuilders.*; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import static org.elasticsearch.index.query.FilterBuilders.termFilter; import static org.elasticsearch.index.query.QueryBuilders.*; import static org.elasticsearch.search.facet.FacetBuilders.*; -import static org.hamcrest.MatcherAssert.*; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** - * @author kimchy (shay.banon) + * */ public class SimpleFacetsTests extends AbstractNodesTests { private Client client; - @BeforeClass public void createNodes() throws Exception { + @BeforeClass + public void createNodes() throws Exception { Settings settings = ImmutableSettings.settingsBuilder().put("index.number_of_shards", numberOfShards()).put("index.number_of_replicas", 0).build(); for (int i = 0; i < numberOfNodes(); i++) { startNode("node" + i, settings); @@ -83,7 +84,8 @@ public class SimpleFacetsTests extends AbstractNodesTests { return 5; } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { client.close(); closeAllNodes(); } @@ -139,7 +141,8 @@ public class SimpleFacetsTests extends AbstractNodesTests { } } - @Test public void testSearchFilter() throws Exception { + @Test + public void testSearchFilter() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -193,7 +196,8 @@ public class SimpleFacetsTests extends AbstractNodesTests { } } - @Test public void testFacetsWithSize0() throws Exception { + @Test + public void testFacetsWithSize0() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -254,7 +258,8 @@ public class SimpleFacetsTests extends AbstractNodesTests { } } - @Test public void testTermsIndexFacet() throws Exception { + @Test + public void testTermsIndexFacet() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); client.admin().indices().prepareDelete("test1").execute().actionGet(); @@ -305,7 +310,8 @@ public class SimpleFacetsTests extends AbstractNodesTests { } } - @Test public void testFilterFacets() throws Exception { + @Test + public void testFilterFacets() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -341,7 +347,8 @@ public class SimpleFacetsTests extends AbstractNodesTests { } } - @Test public void testTermsFacetsMissing() throws Exception { + @Test + public void testTermsFacetsMissing() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -384,11 +391,13 @@ public class SimpleFacetsTests extends AbstractNodesTests { } } - @Test public void testTermsFacetsNoHint() throws Exception { + @Test + public void testTermsFacetsNoHint() throws Exception { testTermsFacets(null); } - @Test public void testTermsFacetsMapHint() throws Exception { + @Test + public void testTermsFacetsMapHint() throws Exception { testTermsFacets("map"); } @@ -757,7 +766,8 @@ public class SimpleFacetsTests extends AbstractNodesTests { } } - @Test public void testTermFacetWithEqualTermDistribution() throws Exception { + @Test + public void testTermFacetWithEqualTermDistribution() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -803,7 +813,8 @@ public class SimpleFacetsTests extends AbstractNodesTests { } } - @Test public void testStatsFacets() throws Exception { + @Test + public void testStatsFacets() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -901,7 +912,8 @@ public class SimpleFacetsTests extends AbstractNodesTests { } } - @Test public void testHistoFacetEdge() throws Exception { + @Test + public void testHistoFacetEdge() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -946,7 +958,8 @@ public class SimpleFacetsTests extends AbstractNodesTests { } } - @Test public void testHistoFacets() throws Exception { + @Test + public void testHistoFacets() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -1192,7 +1205,8 @@ public class SimpleFacetsTests extends AbstractNodesTests { } } - @Test public void testRangeFacets() throws Exception { + @Test + public void testRangeFacets() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -1351,7 +1365,8 @@ public class SimpleFacetsTests extends AbstractNodesTests { } } - @Test public void testDateHistoFacets() throws Exception { + @Test + public void testDateHistoFacets() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -1446,7 +1461,8 @@ public class SimpleFacetsTests extends AbstractNodesTests { } } - @Test public void testTermsStatsFacets() throws Exception { + @Test + public void testTermsStatsFacets() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -1629,7 +1645,8 @@ public class SimpleFacetsTests extends AbstractNodesTests { } } - @Test public void testNumericTermsStatsFacets() throws Exception { + @Test + public void testNumericTermsStatsFacets() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -1701,7 +1718,8 @@ public class SimpleFacetsTests extends AbstractNodesTests { } } - @Test public void testTermsStatsFacets2() throws Exception { + @Test + public void testTermsStatsFacets2() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -1737,7 +1755,8 @@ public class SimpleFacetsTests extends AbstractNodesTests { } } - @Test public void testQueryFacet() throws Exception { + @Test + public void testQueryFacet() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { diff --git a/src/test/java/org/elasticsearch/test/integration/search/fields/SearchFieldsTests.java b/src/test/java/org/elasticsearch/test/integration/search/fields/SearchFieldsTests.java index 2357496b4b4..948ab4694f7 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/fields/SearchFieldsTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/fields/SearchFieldsTests.java @@ -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,25 +27,27 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static org.elasticsearch.common.xcontent.XContentFactory.*; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class SearchFieldsTests extends AbstractNodesTests { private Client client; - @BeforeClass public void createNodes() throws Exception { + @BeforeClass + public void createNodes() throws Exception { startNode("server1"); startNode("server2"); client = getClient(); } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { client.close(); closeAllNodes(); } @@ -54,7 +56,8 @@ public class SearchFieldsTests extends AbstractNodesTests { return client("server1"); } - @Test public void testStoredFields() throws Exception { + @Test + public void testStoredFields() throws Exception { client.admin().indices().prepareCreate("test").execute().actionGet(); client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet(); diff --git a/src/test/java/org/elasticsearch/test/integration/search/geo/GeoBoundingBoxTests.java b/src/test/java/org/elasticsearch/test/integration/search/geo/GeoBoundingBoxTests.java index f26a7692e86..3f89176f08c 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/geo/GeoBoundingBoxTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/geo/GeoBoundingBoxTests.java @@ -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,27 +28,30 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.elasticsearch.common.xcontent.XContentFactory.*; -import static org.elasticsearch.index.query.FilterBuilders.*; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import static org.elasticsearch.index.query.FilterBuilders.geoBoundingBoxFilter; import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.anyOf; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class GeoBoundingBoxTests extends AbstractNodesTests { private Client client; - @BeforeClass public void createNodes() throws Exception { + @BeforeClass + public void createNodes() throws Exception { startNode("server1"); startNode("server2"); client = getClient(); } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { client.close(); closeAllNodes(); } @@ -57,7 +60,8 @@ public class GeoBoundingBoxTests extends AbstractNodesTests { return client("server1"); } - @Test public void simpleBoundingBoxTest() throws Exception { + @Test + public void simpleBoundingBoxTest() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -131,7 +135,8 @@ public class GeoBoundingBoxTests extends AbstractNodesTests { } } - @Test public void limitsBoundingBoxTest() throws Exception { + @Test + public void limitsBoundingBoxTest() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -238,7 +243,8 @@ public class GeoBoundingBoxTests extends AbstractNodesTests { assertThat(searchResponse.hits().getAt(0).id(), equalTo("9")); } - @Test public void limit2BoundingBoxTest() throws Exception { + @Test + public void limit2BoundingBoxTest() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { diff --git a/src/test/java/org/elasticsearch/test/integration/search/geo/GeoDistanceFacetTests.java b/src/test/java/org/elasticsearch/test/integration/search/geo/GeoDistanceFacetTests.java index 3a1af169464..a766c361373 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/geo/GeoDistanceFacetTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/geo/GeoDistanceFacetTests.java @@ -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,26 +31,28 @@ import org.testng.annotations.Test; import java.util.Arrays; -import static org.elasticsearch.common.xcontent.XContentFactory.*; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.elasticsearch.search.facet.FacetBuilders.*; -import static org.hamcrest.MatcherAssert.*; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; +import static org.elasticsearch.search.facet.FacetBuilders.geoDistanceFacet; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** - * @author kimchy (shay.banon) + * */ public class GeoDistanceFacetTests extends AbstractNodesTests { private Client client; - @BeforeClass public void createNodes() throws Exception { + @BeforeClass + public void createNodes() throws Exception { startNode("server1"); startNode("server2"); client = getClient(); } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { client.close(); closeAllNodes(); } @@ -59,7 +61,8 @@ public class GeoDistanceFacetTests extends AbstractNodesTests { return client("server1"); } - @Test public void simpleGeoFacetTests() throws Exception { + @Test + public void simpleGeoFacetTests() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -220,7 +223,8 @@ public class GeoDistanceFacetTests extends AbstractNodesTests { assertThat(facet.entries().get(3).total(), closeTo(24, 0.00001)); } - @Test public void multiLocationGeoDistanceTest() throws Exception { + @Test + public void multiLocationGeoDistanceTest() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { diff --git a/src/test/java/org/elasticsearch/test/integration/search/geo/GeoDistanceTests.java b/src/test/java/org/elasticsearch/test/integration/search/geo/GeoDistanceTests.java index 9700255ceec..b1e89ddbd72 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/geo/GeoDistanceTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/geo/GeoDistanceTests.java @@ -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,11 +31,14 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static org.elasticsearch.common.xcontent.XContentFactory.*; -import static org.elasticsearch.index.query.FilterBuilders.*; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import static org.elasticsearch.index.query.FilterBuilders.geoDistanceFilter; +import static org.elasticsearch.index.query.FilterBuilders.geoDistanceRangeFilter; +import static org.elasticsearch.index.query.QueryBuilders.filteredQuery; +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.anyOf; +import static org.hamcrest.Matchers.equalTo; /** */ @@ -43,13 +46,15 @@ public class GeoDistanceTests extends AbstractNodesTests { private Client client; - @BeforeClass public void createNodes() throws Exception { + @BeforeClass + public void createNodes() throws Exception { startNode("server1"); startNode("server2"); client = getClient(); } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { client.close(); closeAllNodes(); } @@ -58,7 +63,8 @@ public class GeoDistanceTests extends AbstractNodesTests { return client("server1"); } - @Test public void simpleDistanceTests() throws Exception { + @Test + public void simpleDistanceTests() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { diff --git a/src/test/java/org/elasticsearch/test/integration/search/highlight/HighlighterSearchTests.java b/src/test/java/org/elasticsearch/test/integration/search/highlight/HighlighterSearchTests.java index 1ceb589e9e3..b5cb867bffe 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/highlight/HighlighterSearchTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/highlight/HighlighterSearchTests.java @@ -37,29 +37,33 @@ import org.testng.annotations.Test; import java.io.IOException; import java.util.Arrays; -import static org.elasticsearch.action.search.SearchType.*; -import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.common.unit.TimeValue.*; -import static org.elasticsearch.common.xcontent.XContentFactory.*; +import static org.elasticsearch.action.search.SearchType.QUERY_THEN_FETCH; +import static org.elasticsearch.client.Requests.searchRequest; +import static org.elasticsearch.common.unit.TimeValue.timeValueMinutes; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.elasticsearch.search.builder.SearchSourceBuilder.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.search.builder.SearchSourceBuilder.highlight; +import static org.elasticsearch.search.builder.SearchSourceBuilder.searchSource; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.instanceOf; /** - * @author kimchy (shay.banon) + * */ public class HighlighterSearchTests extends AbstractNodesTests { private Client client; - @BeforeClass public void createNodes() throws Exception { + @BeforeClass + public void createNodes() throws Exception { startNode("server1"); startNode("server2"); client = getClient(); } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { client.close(); closeAllNodes(); } @@ -68,7 +72,8 @@ public class HighlighterSearchTests extends AbstractNodesTests { return client("server1"); } - @Test public void testSourceLookupHighlightingUsingPlainHighlighter() throws Exception { + @Test + public void testSourceLookupHighlightingUsingPlainHighlighter() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -121,7 +126,8 @@ public class HighlighterSearchTests extends AbstractNodesTests { } } - @Test public void testSourceLookupHighlightingUsingFastVectorHighlighter() throws Exception { + @Test + public void testSourceLookupHighlightingUsingFastVectorHighlighter() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -174,7 +180,8 @@ public class HighlighterSearchTests extends AbstractNodesTests { } } - @Test public void testPlainHighlighter() throws Exception { + @Test + public void testPlainHighlighter() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (IndexMissingException e) { @@ -236,7 +243,8 @@ public class HighlighterSearchTests extends AbstractNodesTests { assertThat(searchResponse.hits().getAt(0).highlightFields().get("field2").fragments()[0], equalTo("The quick brown fox jumps over the lazy dog")); } - @Test public void testFastVectorHighlighter() throws Exception { + @Test + public void testFastVectorHighlighter() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (IndexMissingException e) { @@ -302,7 +310,8 @@ public class HighlighterSearchTests extends AbstractNodesTests { assertThat(searchResponse.hits().getAt(0).highlightFields().get("field2").fragments()[0], equalTo("The quick brown fox jumps over the lazy dog ")); } - @Test public void testFastVectorHighlighterManyDocs() throws Exception { + @Test + public void testFastVectorHighlighterManyDocs() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (ElasticSearchException e) { @@ -374,7 +383,8 @@ public class HighlighterSearchTests extends AbstractNodesTests { .endObject().endObject(); } - @Test public void testSameContent() throws Exception { + @Test + public void testSameContent() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -407,7 +417,8 @@ public class HighlighterSearchTests extends AbstractNodesTests { } } - @Test public void testFastVectorHighlighterOffsetParameter() throws Exception { + @Test + public void testFastVectorHighlighterOffsetParameter() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -441,7 +452,8 @@ public class HighlighterSearchTests extends AbstractNodesTests { } } - @Test public void testEscapeHtml() throws Exception { + @Test + public void testEscapeHtml() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); @@ -477,7 +489,8 @@ public class HighlighterSearchTests extends AbstractNodesTests { } } - @Test public void testEscapeHtml_vector() throws Exception { + @Test + public void testEscapeHtml_vector() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); diff --git a/src/test/java/org/elasticsearch/test/integration/search/indicesboost/SimpleIndicesBoostSearchTests.java b/src/test/java/org/elasticsearch/test/integration/search/indicesboost/SimpleIndicesBoostSearchTests.java index 3f527f25b18..9fabec3f095 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/indicesboost/SimpleIndicesBoostSearchTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/indicesboost/SimpleIndicesBoostSearchTests.java @@ -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,26 +28,28 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.common.xcontent.XContentFactory.*; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.elasticsearch.search.builder.SearchSourceBuilder.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import static org.elasticsearch.index.query.QueryBuilders.termQuery; +import static org.elasticsearch.search.builder.SearchSourceBuilder.searchSource; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ @Test public class SimpleIndicesBoostSearchTests extends AbstractNodesTests { private Client client; - @BeforeMethod public void createNodes() throws Exception { + @BeforeMethod + public void createNodes() throws Exception { startNode("server1"); client = getClient(); } - @AfterMethod public void closeNodes() { + @AfterMethod + public void closeNodes() { client.close(); closeAllNodes(); } diff --git a/src/test/java/org/elasticsearch/test/integration/search/matchedfilters/MatchedFiltersTests.java b/src/test/java/org/elasticsearch/test/integration/search/matchedfilters/MatchedFiltersTests.java index 2f938c27242..58624fb00b4 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/matchedfilters/MatchedFiltersTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/matchedfilters/MatchedFiltersTests.java @@ -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,26 +27,31 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static org.elasticsearch.common.xcontent.XContentFactory.*; -import static org.elasticsearch.index.query.FilterBuilders.*; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import static org.elasticsearch.index.query.FilterBuilders.orFilter; +import static org.elasticsearch.index.query.FilterBuilders.rangeFilter; +import static org.elasticsearch.index.query.QueryBuilders.filteredQuery; +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.hasItemInArray; /** - * @author kimchy (shay.banon) + * */ public class MatchedFiltersTests extends AbstractNodesTests { private Client client; - @BeforeClass public void createNodes() throws Exception { + @BeforeClass + public void createNodes() throws Exception { startNode("server1"); startNode("server2"); client = getClient(); } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { client.close(); closeAllNodes(); } @@ -55,7 +60,8 @@ public class MatchedFiltersTests extends AbstractNodesTests { return client("server1"); } - @Test public void simpleMatchedFilter() throws Exception { + @Test + public void simpleMatchedFilter() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { diff --git a/src/test/java/org/elasticsearch/test/integration/search/preference/SearchPreferenceTests.java b/src/test/java/org/elasticsearch/test/integration/search/preference/SearchPreferenceTests.java index 291c5a422f3..4bb147d15d1 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/preference/SearchPreferenceTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/preference/SearchPreferenceTests.java @@ -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,24 +27,27 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.not; @Test public class SearchPreferenceTests extends AbstractNodesTests { private Client client; - @BeforeClass public void createNodes() throws Exception { + @BeforeClass + public void createNodes() throws Exception { Settings settings = settingsBuilder().put("number_of_shards", 3).put("number_of_replicas", 1).build(); startNode("server1", settings); startNode("server2", settings); client = getClient(); } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { client.close(); closeAllNodes(); } @@ -53,7 +56,8 @@ public class SearchPreferenceTests extends AbstractNodesTests { return client("server1"); } - @Test public void noPreferenceRandom() throws Exception { + @Test + public void noPreferenceRandom() throws Exception { client.admin().indices().prepareDelete().execute().actionGet(); client.admin().indices().prepareCreate("test").setSettings(settingsBuilder().put("number_of_shards", 1).put("number_of_replicas", 1)).execute().actionGet(); @@ -71,7 +75,8 @@ public class SearchPreferenceTests extends AbstractNodesTests { assertThat(firstNodeId, not(equalTo(secondNodeId))); } - @Test public void simplePreferenceTests() throws Exception { + @Test + public void simplePreferenceTests() throws Exception { client.admin().indices().prepareDelete().execute().actionGet(); client.admin().indices().prepareCreate("test").execute().actionGet(); diff --git a/src/test/java/org/elasticsearch/test/integration/search/query/SimpleQueryTests.java b/src/test/java/org/elasticsearch/test/integration/search/query/SimpleQueryTests.java index 2a4a55fd9cf..8367edaeb88 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/query/SimpleQueryTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/query/SimpleQueryTests.java @@ -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,25 +32,28 @@ import org.testng.annotations.Test; import java.util.Arrays; -import static org.elasticsearch.common.xcontent.XContentFactory.*; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.FilterBuilders.*; import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.anyOf; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class SimpleQueryTests extends AbstractNodesTests { private Client client; - @BeforeClass public void createNodes() throws Exception { + @BeforeClass + public void createNodes() throws Exception { startNode("node1"); client = getClient(); } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { client.close(); closeAllNodes(); } @@ -59,7 +62,8 @@ public class SimpleQueryTests extends AbstractNodesTests { return client("node1"); } - @Test public void passQueryAsStringTest() throws Exception { + @Test + public void passQueryAsStringTest() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -74,7 +78,8 @@ public class SimpleQueryTests extends AbstractNodesTests { assertThat(searchResponse.hits().totalHits(), equalTo(1l)); } - @Test public void queryStringAnalyzedWildcard() throws Exception { + @Test + public void queryStringAnalyzedWildcard() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -103,11 +108,13 @@ public class SimpleQueryTests extends AbstractNodesTests { assertThat(searchResponse.hits().totalHits(), equalTo(1l)); } - @Test public void typeFilterTypeIndexedTests() throws Exception { + @Test + public void typeFilterTypeIndexedTests() throws Exception { typeFilterTests("not_analyzed"); } - @Test public void typeFilterTypeNotIndexedTests() throws Exception { + @Test + public void typeFilterTypeNotIndexedTests() throws Exception { typeFilterTests("no"); } @@ -146,11 +153,13 @@ public class SimpleQueryTests extends AbstractNodesTests { assertThat(client.prepareCount().setTypes("type1", "type2").setQuery(matchAllQuery()).execute().actionGet().count(), equalTo(5l)); } - @Test public void idsFilterTestsIdIndexed() throws Exception { + @Test + public void idsFilterTestsIdIndexed() throws Exception { idsFilterTests("not_analyzed"); } - @Test public void idsFilterTestsIdNotIndexed() throws Exception { + @Test + public void idsFilterTestsIdNotIndexed() throws Exception { idsFilterTests("no"); } @@ -200,7 +209,8 @@ public class SimpleQueryTests extends AbstractNodesTests { assertThat(searchResponse.hits().totalHits(), equalTo(0l)); } - @Test public void testLimitFilter() throws Exception { + @Test + public void testLimitFilter() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -220,7 +230,8 @@ public class SimpleQueryTests extends AbstractNodesTests { assertThat(searchResponse.hits().totalHits(), equalTo(2l)); } - @Test public void filterExistsMissingTests() throws Exception { + @Test + public void filterExistsMissingTests() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -282,7 +293,8 @@ public class SimpleQueryTests extends AbstractNodesTests { assertThat(searchResponse.hits().getAt(1).id(), anyOf(equalTo("3"), equalTo("4"))); } - @Test public void passQueryAsJSONStringTest() throws Exception { + @Test + public void passQueryAsJSONStringTest() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -306,7 +318,8 @@ public class SimpleQueryTests extends AbstractNodesTests { } - @Test public void testFiltersWithCustomCacheKey() throws Exception { + @Test + public void testFiltersWithCustomCacheKey() throws Exception { client.admin().indices().prepareDelete().execute().actionGet(); client.prepareIndex("test", "type1", "1").setSource("field1", "value1").execute().actionGet(); diff --git a/src/test/java/org/elasticsearch/test/integration/search/scan/SearchScanScrollingTests.java b/src/test/java/org/elasticsearch/test/integration/search/scan/SearchScanScrollingTests.java index 1f1b19f8096..024376bffd1 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/scan/SearchScanScrollingTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/scan/SearchScanScrollingTests.java @@ -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.test.integration.search.scan; +import com.google.common.collect.Sets; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchType; import org.elasticsearch.client.Client; -import org.elasticsearch.common.collect.Sets; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.search.SearchHit; @@ -33,21 +33,23 @@ import org.testng.annotations.Test; import java.util.Set; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; public class SearchScanScrollingTests extends AbstractNodesTests { private Client client; - @BeforeClass public void createNodes() throws Exception { + @BeforeClass + public void createNodes() throws Exception { startNode("node1"); startNode("node2"); client = getClient(); } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { client.close(); closeAllNodes(); } @@ -56,111 +58,138 @@ public class SearchScanScrollingTests extends AbstractNodesTests { return client("node1"); } - @Test public void shard1docs100size3() throws Exception { + @Test + public void shard1docs100size3() throws Exception { testScroll(1, 100, 3); } - @Test public void shard1docs100size7() throws Exception { + @Test + public void shard1docs100size7() throws Exception { testScroll(1, 100, 7); } - @Test public void shard1docs100size13() throws Exception { + @Test + public void shard1docs100size13() throws Exception { testScroll(1, 100, 13); } - @Test public void shard1docs100size24() throws Exception { + @Test + public void shard1docs100size24() throws Exception { testScroll(1, 100, 24); } - @Test public void shard1docs100size45() throws Exception { + @Test + public void shard1docs100size45() throws Exception { testScroll(1, 100, 45); } - @Test public void shard1docs100size63() throws Exception { + @Test + public void shard1docs100size63() throws Exception { testScroll(1, 100, 63); } - @Test public void shard1docs100size89() throws Exception { + @Test + public void shard1docs100size89() throws Exception { testScroll(1, 100, 89); } - @Test public void shard1docs100size99() throws Exception { + @Test + public void shard1docs100size99() throws Exception { testScroll(1, 100, 99); } - @Test public void shard1docs100size100() throws Exception { + @Test + public void shard1docs100size100() throws Exception { testScroll(1, 100, 100); } - @Test public void shard1docs100size101() throws Exception { + @Test + public void shard1docs100size101() throws Exception { testScroll(1, 100, 101); } - @Test public void shard1docs100size120() throws Exception { + @Test + public void shard1docs100size120() throws Exception { testScroll(1, 100, 120); } - @Test public void shard3docs100size3() throws Exception { + @Test + public void shard3docs100size3() throws Exception { testScroll(3, 100, 3); } - @Test public void shard3docs100size7() throws Exception { + @Test + public void shard3docs100size7() throws Exception { testScroll(3, 100, 7); } - @Test public void shard3docs100size13() throws Exception { + @Test + public void shard3docs100size13() throws Exception { testScroll(3, 100, 13); } - @Test public void shard3docs100size24() throws Exception { + @Test + public void shard3docs100size24() throws Exception { testScroll(3, 100, 24); } - @Test public void shard3docs100size45() throws Exception { + @Test + public void shard3docs100size45() throws Exception { testScroll(3, 100, 45); } - @Test public void shard3docs100size63() throws Exception { + @Test + public void shard3docs100size63() throws Exception { testScroll(3, 100, 63); } - @Test public void shard3docs100size89() throws Exception { + @Test + public void shard3docs100size89() throws Exception { testScroll(3, 100, 89); } - @Test public void shard3docs100size120() throws Exception { + @Test + public void shard3docs100size120() throws Exception { testScroll(3, 100, 120); } - @Test public void shard3docs100size3Unbalanced() throws Exception { + @Test + public void shard3docs100size3Unbalanced() throws Exception { testScroll(3, 100, 3, true); } - @Test public void shard3docs100size7Unbalanced() throws Exception { + @Test + public void shard3docs100size7Unbalanced() throws Exception { testScroll(3, 100, 7, true); } - @Test public void shard3docs100size13Unbalanced() throws Exception { + @Test + public void shard3docs100size13Unbalanced() throws Exception { testScroll(3, 100, 13, true); } - @Test public void shard3docs100size24Unbalanced() throws Exception { + @Test + public void shard3docs100size24Unbalanced() throws Exception { testScroll(3, 100, 24, true); } - @Test public void shard3docs100size45Unbalanced() throws Exception { + @Test + public void shard3docs100size45Unbalanced() throws Exception { testScroll(3, 100, 45, true); } - @Test public void shard3docs100size63Unbalanced() throws Exception { + @Test + public void shard3docs100size63Unbalanced() throws Exception { testScroll(3, 100, 63, true); } - @Test public void shard3docs100size89Unbalanced() throws Exception { + @Test + public void shard3docs100size89Unbalanced() throws Exception { testScroll(3, 100, 89, true); } - @Test public void shard3docs100size120Unbalanced() throws Exception { + @Test + public void shard3docs100size120Unbalanced() throws Exception { testScroll(3, 100, 120); } diff --git a/src/test/java/org/elasticsearch/test/integration/search/scan/SearchScanTests.java b/src/test/java/org/elasticsearch/test/integration/search/scan/SearchScanTests.java index 38af66b3547..eee377a157b 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/scan/SearchScanTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/scan/SearchScanTests.java @@ -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.test.integration.search.scan; +import com.google.common.collect.Sets; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchType; import org.elasticsearch.client.Client; -import org.elasticsearch.common.collect.Sets; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.search.SearchHit; @@ -33,22 +33,24 @@ import org.testng.annotations.Test; import java.util.Set; -import static org.elasticsearch.common.xcontent.XContentFactory.*; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import static org.elasticsearch.index.query.QueryBuilders.termQuery; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; public class SearchScanTests extends AbstractNodesTests { private Client client; - @BeforeClass public void createNodes() throws Exception { + @BeforeClass + public void createNodes() throws Exception { startNode("node1"); startNode("node2"); client = getClient(); } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { client.close(); closeAllNodes(); } @@ -57,7 +59,8 @@ public class SearchScanTests extends AbstractNodesTests { return client("node1"); } - @Test public void testNarrowingQuery() throws Exception { + @Test + public void testNarrowingQuery() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { diff --git a/src/test/java/org/elasticsearch/test/integration/search/scriptfield/ScriptFieldSearchTests.java b/src/test/java/org/elasticsearch/test/integration/search/scriptfield/ScriptFieldSearchTests.java index 56f1bb15847..5cfb51bc4f4 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/scriptfield/ScriptFieldSearchTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/scriptfield/ScriptFieldSearchTests.java @@ -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,28 +33,30 @@ import java.util.Arrays; import java.util.List; import java.util.Map; -import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.elasticsearch.common.xcontent.XContentFactory.*; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.client.Requests.refreshRequest; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ @Test public class ScriptFieldSearchTests extends AbstractNodesTests { private Client client; - @BeforeClass public void createNodes() throws Exception { + @BeforeClass + public void createNodes() throws Exception { startNode("server1", settingsBuilder().put("number_of_shards", 1).put("number_of_replicas", 0)); startNode("client1", settingsBuilder().put("node.client", true).build()); client = getClient(); } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { client.close(); closeNode("client1"); closeAllNodes(); @@ -64,7 +66,8 @@ public class ScriptFieldSearchTests extends AbstractNodesTests { return client("client1"); } - @Test public void testDocAndFields() throws Exception { + @Test + public void testDocAndFields() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -134,7 +137,8 @@ public class ScriptFieldSearchTests extends AbstractNodesTests { assertThat((Double) response.hits().getAt(2).fields().get("sNum1").values().get(0), equalTo(6.0)); } - @Test public void testScriptFieldUsingSource() throws Exception { + @Test + public void testScriptFieldUsingSource() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { diff --git a/src/test/java/org/elasticsearch/test/integration/search/scriptfilter/ScriptFilterSearchTests.java b/src/test/java/org/elasticsearch/test/integration/search/scriptfilter/ScriptFilterSearchTests.java index 65093b35bea..c2b9646e751 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/scriptfilter/ScriptFilterSearchTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/scriptfilter/ScriptFilterSearchTests.java @@ -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,27 +27,30 @@ import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import static org.elasticsearch.client.Requests.*; -import static org.elasticsearch.common.xcontent.XContentFactory.*; -import static org.elasticsearch.index.query.FilterBuilders.*; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.client.Requests.refreshRequest; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import static org.elasticsearch.index.query.FilterBuilders.scriptFilter; +import static org.elasticsearch.index.query.QueryBuilders.filteredQuery; +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ @Test public class ScriptFilterSearchTests extends AbstractNodesTests { private Client client; - @BeforeMethod public void createNodes() throws Exception { + @BeforeMethod + public void createNodes() throws Exception { startNode("server1"); client = getClient(); } - @AfterMethod public void closeNodes() { + @AfterMethod + public void closeNodes() { client.close(); closeAllNodes(); } diff --git a/src/test/java/org/elasticsearch/test/integration/search/scroll/SearchScrollTests.java b/src/test/java/org/elasticsearch/test/integration/search/scroll/SearchScrollTests.java index f77d1c1368c..d3e609d06a4 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/scroll/SearchScrollTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/scroll/SearchScrollTests.java @@ -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,25 +33,27 @@ import org.testng.annotations.Test; import java.util.Map; -import static org.elasticsearch.common.xcontent.XContentFactory.*; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class SearchScrollTests extends AbstractNodesTests { private Client client; - @BeforeClass public void createNodes() throws Exception { + @BeforeClass + public void createNodes() throws Exception { startNode("node1"); startNode("node2"); client = getClient(); } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { client.close(); closeAllNodes(); } @@ -60,7 +62,8 @@ public class SearchScrollTests extends AbstractNodesTests { return client("node1"); } - @Test public void testSimpleScrollQueryThenFetch() throws Exception { + @Test + public void testSimpleScrollQueryThenFetch() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -113,7 +116,8 @@ public class SearchScrollTests extends AbstractNodesTests { } } - @Test public void testSimpleScrollQueryThenFetchSmallSizeUnevenDistribution() throws Exception { + @Test + public void testSimpleScrollQueryThenFetchSmallSizeUnevenDistribution() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -187,7 +191,8 @@ public class SearchScrollTests extends AbstractNodesTests { } } - @Test public void testScrollAndUpdateIndex() throws Exception { + @Test + public void testScrollAndUpdateIndex() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { diff --git a/src/test/java/org/elasticsearch/test/integration/search/simple/SimpleSearchTests.java b/src/test/java/org/elasticsearch/test/integration/search/simple/SimpleSearchTests.java index 0321d15f8c2..4fea1082220 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/simple/SimpleSearchTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/simple/SimpleSearchTests.java @@ -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,20 +29,23 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.index.query.QueryBuilders.boolQuery; +import static org.elasticsearch.index.query.QueryBuilders.rangeQuery; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; public class SimpleSearchTests extends AbstractNodesTests { private Client client; - @BeforeClass public void createNodes() throws Exception { + @BeforeClass + public void createNodes() throws Exception { startNode("node1"); client = getClient(); } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { client.close(); closeAllNodes(); } @@ -51,7 +54,8 @@ public class SimpleSearchTests extends AbstractNodesTests { return client("node1"); } - @Test public void simpleIpTests() throws Exception { + @Test + public void simpleIpTests() throws Exception { client.admin().indices().prepareDelete().execute().actionGet(); client.admin().indices().prepareCreate("test").setSettings(ImmutableSettings.settingsBuilder().put("number_of_shards", 1)).execute().actionGet(); @@ -72,7 +76,8 @@ public class SimpleSearchTests extends AbstractNodesTests { assertThat(search.hits().totalHits(), equalTo(1l)); } - @Test public void simpleIdTests() { + @Test + public void simpleIdTests() { client.admin().indices().prepareDelete().execute().actionGet(); client.admin().indices().prepareCreate("test").setSettings(ImmutableSettings.settingsBuilder().put("number_of_shards", 1)).execute().actionGet(); @@ -85,7 +90,8 @@ public class SimpleSearchTests extends AbstractNodesTests { assertThat(searchResponse.hits().totalHits(), equalTo(1l)); } - @Test public void simpleDateRangeWithUpperInclusiveEnabledTests() throws Exception { + @Test + public void simpleDateRangeWithUpperInclusiveEnabledTests() throws Exception { client.admin().indices().prepareDelete().execute().actionGet(); client.admin().indices().prepareCreate("test").setSettings(ImmutableSettings.settingsBuilder()).execute().actionGet(); client.prepareIndex("test", "type1", "1").setSource("field", "2010-01-05T02:00").execute().actionGet(); @@ -99,7 +105,8 @@ public class SimpleSearchTests extends AbstractNodesTests { assertThat(searchResponse.hits().totalHits(), equalTo(1l)); } - @Test public void simpleDateRangeWithUpperInclusiveDisabledTests() throws Exception { + @Test + public void simpleDateRangeWithUpperInclusiveDisabledTests() throws Exception { client.admin().indices().prepareDelete().execute().actionGet(); client.admin().indices().prepareCreate("test").setSettings(ImmutableSettings.settingsBuilder().put("index.mapping.date.parse_upper_inclusive", false)).execute().actionGet(); client.prepareIndex("test", "type1", "1").setSource("field", "2010-01-05T02:00").execute().actionGet(); diff --git a/src/test/java/org/elasticsearch/test/integration/search/sort/SimpleSortTests.java b/src/test/java/org/elasticsearch/test/integration/search/sort/SimpleSortTests.java index 8bc68550a8d..2f99775cbc6 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/sort/SimpleSortTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/sort/SimpleSortTests.java @@ -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,27 +36,29 @@ import org.testng.annotations.Test; import java.util.Arrays; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.elasticsearch.common.xcontent.XContentFactory.*; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.hamcrest.MatcherAssert.*; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** - * @author kimchy (shay.banon) + * */ public class SimpleSortTests extends AbstractNodesTests { private Client client; - @BeforeClass public void createNodes() throws Exception { + @BeforeClass + public void createNodes() throws Exception { Settings settings = settingsBuilder().put("number_of_shards", 3).put("number_of_replicas", 0).build(); startNode("server1", settings); startNode("server2", settings); client = getClient(); } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { client.close(); closeAllNodes(); } @@ -65,7 +67,8 @@ public class SimpleSortTests extends AbstractNodesTests { return client("server1"); } - @Test public void testTrackScores() throws Exception { + @Test + public void testTrackScores() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -113,7 +116,8 @@ public class SimpleSortTests extends AbstractNodesTests { } } - @Test public void testScoreSortDirection() throws Exception { + @Test + public void testScoreSortDirection() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -148,15 +152,18 @@ public class SimpleSortTests extends AbstractNodesTests { assertThat(searchResponse.hits().getAt(0).getId(), equalTo("1")); } - @Test public void testSimpleSortsSingleShard() throws Exception { + @Test + public void testSimpleSortsSingleShard() throws Exception { testSimpleSorts(1); } - @Test public void testSimpleSortsTwoShards() throws Exception { + @Test + public void testSimpleSortsTwoShards() throws Exception { testSimpleSorts(2); } - @Test public void testSimpleSortsThreeShards() throws Exception { + @Test + public void testSimpleSortsThreeShards() throws Exception { testSimpleSorts(3); } @@ -416,7 +423,8 @@ public class SimpleSortTests extends AbstractNodesTests { assertThat(searchResponse.toString(), not(containsString("error"))); } - @Test public void testDocumentsWithNullValue() throws Exception { + @Test + public void testDocumentsWithNullValue() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { @@ -494,7 +502,8 @@ public class SimpleSortTests extends AbstractNodesTests { assertThat((String) searchResponse.hits().getAt(0).field("id").value(), equalTo("2")); } - @Test public void testSortMissing() throws Exception { + @Test + public void testSortMissing() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (Exception e) { diff --git a/src/test/java/org/elasticsearch/test/integration/search/stats/SearchStatsTests.java b/src/test/java/org/elasticsearch/test/integration/search/stats/SearchStatsTests.java index 05905f6820a..da57dfc2de7 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/stats/SearchStatsTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/stats/SearchStatsTests.java @@ -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,8 +29,8 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.hamcrest.MatcherAssert.*; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** @@ -39,14 +39,16 @@ public class SearchStatsTests extends AbstractNodesTests { private Client client; - @BeforeClass public void createNodes() throws Exception { + @BeforeClass + public void createNodes() throws Exception { Settings settings = settingsBuilder().put("number_of_shards", 3).put("number_of_replicas", 0).build(); startNode("server1", settings); startNode("server2", settings); client = getClient(); } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { client.close(); closeAllNodes(); } @@ -55,7 +57,8 @@ public class SearchStatsTests extends AbstractNodesTests { return client("server1"); } - @Test public void testSimpleStats() throws Exception { + @Test + public void testSimpleStats() throws Exception { client.admin().indices().prepareDelete().execute().actionGet(); for (int i = 0; i < 500; i++) { diff --git a/src/test/java/org/elasticsearch/test/integration/timestamp/SimpleTimestampTests.java b/src/test/java/org/elasticsearch/test/integration/timestamp/SimpleTimestampTests.java index 1609f3aeba1..aa39a8d56bc 100644 --- a/src/test/java/org/elasticsearch/test/integration/timestamp/SimpleTimestampTests.java +++ b/src/test/java/org/elasticsearch/test/integration/timestamp/SimpleTimestampTests.java @@ -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.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** @@ -36,13 +36,15 @@ public class SimpleTimestampTests extends AbstractNodesTests { private Client client; - @BeforeClass public void createNodes() throws Exception { + @BeforeClass + public void createNodes() throws Exception { startNode("node1"); startNode("node2"); client = getClient(); } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { client.close(); closeAllNodes(); } @@ -51,7 +53,8 @@ public class SimpleTimestampTests extends AbstractNodesTests { return client("node1"); } - @Test public void testSimpleTimestamp() throws Exception { + @Test + public void testSimpleTimestamp() throws Exception { client.admin().indices().prepareDelete().execute().actionGet(); client.admin().indices().prepareCreate("test") diff --git a/src/test/java/org/elasticsearch/test/integration/ttl/SimpleTTLTests.java b/src/test/java/org/elasticsearch/test/integration/ttl/SimpleTTLTests.java index d10730be6cf..89f4ab78fe1 100644 --- a/src/test/java/org/elasticsearch/test/integration/ttl/SimpleTTLTests.java +++ b/src/test/java/org/elasticsearch/test/integration/ttl/SimpleTTLTests.java @@ -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,8 +28,8 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.hamcrest.MatcherAssert.*; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; public class SimpleTTLTests extends AbstractNodesTests { @@ -37,14 +37,16 @@ public class SimpleTTLTests extends AbstractNodesTests { static private final long purgeInterval = 200; private Client client; - @BeforeClass public void createNodes() throws Exception { + @BeforeClass + public void createNodes() throws Exception { Settings settings = settingsBuilder().put("indices.ttl.interval", purgeInterval).build(); startNode("node1", settings); startNode("node2", settings); client = getClient(); } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { client.close(); closeAllNodes(); } @@ -53,7 +55,8 @@ public class SimpleTTLTests extends AbstractNodesTests { return client("node1"); } - @Test public void testSimpleTTL() throws Exception { + @Test + public void testSimpleTTL() throws Exception { client.admin().indices().prepareDelete().execute().actionGet(); client.admin().indices().prepareCreate("test") diff --git a/src/test/java/org/elasticsearch/test/integration/versioning/ConcurrentDocumentOperationTests.java b/src/test/java/org/elasticsearch/test/integration/versioning/ConcurrentDocumentOperationTests.java index a2268e3b3d6..f154cf5dfe5 100644 --- a/src/test/java/org/elasticsearch/test/integration/versioning/ConcurrentDocumentOperationTests.java +++ b/src/test/java/org/elasticsearch/test/integration/versioning/ConcurrentDocumentOperationTests.java @@ -11,21 +11,24 @@ import java.util.Map; import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicReference; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.nullValue; /** - * @author kimchy (shay.banon) + * */ @Test public class ConcurrentDocumentOperationTests extends AbstractNodesTests { - @AfterMethod public void closeNodes() { + @AfterMethod + public void closeNodes() { closeAllNodes(); } - @Test public void concurrentOperationOnSameDocTest() throws Exception { + @Test + public void concurrentOperationOnSameDocTest() throws Exception { // start 5 nodes Node[] nodes = new Node[5]; for (int i = 0; i < nodes.length; i++) { @@ -43,11 +46,13 @@ public class ConcurrentDocumentOperationTests extends AbstractNodesTests { final CountDownLatch latch = new CountDownLatch(numberOfUpdates); for (int i = 0; i < numberOfUpdates; i++) { nodes[0].client().prepareIndex("test", "type1", "1").setSource("field1", i).execute(new ActionListener() { - @Override public void onResponse(IndexResponse response) { + @Override + public void onResponse(IndexResponse response) { latch.countDown(); } - @Override public void onFailure(Throwable e) { + @Override + public void onFailure(Throwable e) { e.printStackTrace(); failure.set(e); latch.countDown(); diff --git a/src/test/java/org/elasticsearch/test/integration/versioning/SimpleVersioningTests.java b/src/test/java/org/elasticsearch/test/integration/versioning/SimpleVersioningTests.java index 6ee70fd43c7..75569909153 100644 --- a/src/test/java/org/elasticsearch/test/integration/versioning/SimpleVersioningTests.java +++ b/src/test/java/org/elasticsearch/test/integration/versioning/SimpleVersioningTests.java @@ -35,19 +35,21 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.instanceOf; /** - * @author kimchy (shay.banon) + * */ public class SimpleVersioningTests extends AbstractNodesTests { private Client client; private Client client2; - @BeforeClass public void createNodes() throws Exception { + @BeforeClass + public void createNodes() throws Exception { // make sure we use bloom filters here! Settings settings = ImmutableSettings.settingsBuilder().put("index.engine.robin.async_load_bloom", false).build(); startNode("server1", settings); @@ -56,12 +58,14 @@ public class SimpleVersioningTests extends AbstractNodesTests { client2 = client("server2"); } - @AfterClass public void closeNodes() { + @AfterClass + public void closeNodes() { client.close(); closeAllNodes(); } - @Test public void testExternalVersioningInitialDelete() throws Exception { + @Test + public void testExternalVersioningInitialDelete() throws Exception { client.admin().indices().prepareDelete().execute().actionGet(); client.admin().indices().prepareCreate("test").execute().actionGet(); @@ -79,7 +83,8 @@ public class SimpleVersioningTests extends AbstractNodesTests { client.prepareIndex("test", "type", "1").setSource("field1", "value1_1").setVersion(18).setVersionType(VersionType.EXTERNAL).execute().actionGet(); } - @Test public void testExternalVersioning() throws Exception { + @Test + public void testExternalVersioning() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (IndexMissingException e) { @@ -120,7 +125,8 @@ public class SimpleVersioningTests extends AbstractNodesTests { assertThat(deleteResponse.version(), equalTo(18l)); } - @Test public void testSimpleVersioning() throws Exception { + @Test + public void testSimpleVersioning() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (IndexMissingException e) { @@ -203,7 +209,8 @@ public class SimpleVersioningTests extends AbstractNodesTests { assertThat(deleteResponse.version(), equalTo(4l)); } - @Test public void testSimpleVersioningWithFlush() throws Exception { + @Test + public void testSimpleVersioningWithFlush() throws Exception { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (IndexMissingException e) { @@ -269,7 +276,8 @@ public class SimpleVersioningTests extends AbstractNodesTests { } } - @Test public void testVersioningWithBulk() { + @Test + public void testVersioningWithBulk() { try { client.admin().indices().prepareDelete("test").execute().actionGet(); } catch (IndexMissingException e) { diff --git a/src/test/java/org/elasticsearch/test/stress/client/ClientFailover.java b/src/test/java/org/elasticsearch/test/stress/client/ClientFailover.java index 98acf5686f2..4b0c9909448 100644 --- a/src/test/java/org/elasticsearch/test/stress/client/ClientFailover.java +++ b/src/test/java/org/elasticsearch/test/stress/client/ClientFailover.java @@ -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 @@ -48,7 +48,8 @@ public class ClientFailover { final AtomicLong indexed = new AtomicLong(); final CountDownLatch latch = new CountDownLatch(1); Thread indexer = new Thread(new Runnable() { - @Override public void run() { + @Override + public void run() { while (!done.get()) { try { client.prepareIndex("test", "type").setSource("field", "value").execute().actionGet(); diff --git a/src/test/java/org/elasticsearch/test/stress/fullrestart/FullRestartStressTest.java b/src/test/java/org/elasticsearch/test/stress/fullrestart/FullRestartStressTest.java index df91339c1c6..2a1d7783d45 100644 --- a/src/test/java/org/elasticsearch/test/stress/fullrestart/FullRestartStressTest.java +++ b/src/test/java/org/elasticsearch/test/stress/fullrestart/FullRestartStressTest.java @@ -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.test.stress.fullrestart; +import jsr166y.ThreadLocalRandom; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.count.CountResponse; import org.elasticsearch.action.search.SearchResponse; @@ -31,7 +32,6 @@ import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; -import org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.env.NodeEnvironment; @@ -42,10 +42,10 @@ import org.elasticsearch.node.internal.InternalNode; import java.io.File; import java.util.concurrent.atomic.AtomicLong; -import static org.elasticsearch.index.query.QueryBuilders.*; +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; /** - * @author kimchy (shay.banon) + * */ public class FullRestartStressTest { diff --git a/src/test/java/org/elasticsearch/test/stress/gcbehavior/FilterCacheGcStress.java b/src/test/java/org/elasticsearch/test/stress/gcbehavior/FilterCacheGcStress.java index e6790fa1202..29c47cb40e2 100644 --- a/src/test/java/org/elasticsearch/test/stress/gcbehavior/FilterCacheGcStress.java +++ b/src/test/java/org/elasticsearch/test/stress/gcbehavior/FilterCacheGcStress.java @@ -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,8 +27,9 @@ import org.elasticsearch.node.NodeBuilder; import java.util.concurrent.atomic.AtomicBoolean; -import static org.elasticsearch.index.query.FilterBuilders.*; -import static org.elasticsearch.index.query.QueryBuilders.*; +import static org.elasticsearch.index.query.FilterBuilders.rangeFilter; +import static org.elasticsearch.index.query.QueryBuilders.filteredQuery; +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; public class FilterCacheGcStress { @@ -47,7 +48,8 @@ public class FilterCacheGcStress { final AtomicBoolean stop = new AtomicBoolean(); Thread indexingThread = new Thread() { - @Override public void run() { + @Override + public void run() { while (!stop.get()) { client.prepareIndex("test", "type1").setSource("field", System.currentTimeMillis()).execute().actionGet(); } @@ -56,7 +58,8 @@ public class FilterCacheGcStress { indexingThread.start(); Thread searchThread = new Thread() { - @Override public void run() { + @Override + public void run() { while (!stop.get()) { client.prepareSearch() .setQuery(filteredQuery(matchAllQuery(), rangeFilter("field").from(System.currentTimeMillis() - 1000000))) diff --git a/src/test/java/org/elasticsearch/test/stress/get/GetStressTest.java b/src/test/java/org/elasticsearch/test/stress/get/GetStressTest.java index 4220a57f20f..0717afb22b4 100644 --- a/src/test/java/org/elasticsearch/test/stress/get/GetStressTest.java +++ b/src/test/java/org/elasticsearch/test/stress/get/GetStressTest.java @@ -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,11 +19,11 @@ package org.elasticsearch.test.stress.get; +import jsr166y.ThreadLocalRandom; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; -import org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom; import org.elasticsearch.node.Node; import org.elasticsearch.node.NodeBuilder; @@ -61,7 +61,8 @@ public class GetStressTest { Thread[] threads = new Thread[NUMBER_OF_THREADS]; for (int i = 0; i < threads.length; i++) { threads[i] = new Thread(new Runnable() { - @Override public void run() { + @Override + public void run() { ThreadLocalRandom random = ThreadLocalRandom.current(); while (!done.get()) { String id = String.valueOf(idGenerator.incrementAndGet()); diff --git a/src/test/java/org/elasticsearch/test/stress/get/MGetStress1.java b/src/test/java/org/elasticsearch/test/stress/get/MGetStress1.java index f7262f66d9e..e4f5114927b 100644 --- a/src/test/java/org/elasticsearch/test/stress/get/MGetStress1.java +++ b/src/test/java/org/elasticsearch/test/stress/get/MGetStress1.java @@ -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.elasticsearch.test.stress.get; +import com.google.common.collect.Sets; +import jsr166y.ThreadLocalRandom; import org.elasticsearch.action.get.MultiGetItemResponse; import org.elasticsearch.action.get.MultiGetResponse; import org.elasticsearch.client.Client; -import org.elasticsearch.common.collect.Sets; import org.elasticsearch.common.unit.TimeValue; -import org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom; import org.elasticsearch.node.Node; import org.elasticsearch.node.NodeBuilder; @@ -55,7 +55,8 @@ public class MGetStress1 { final AtomicBoolean done = new AtomicBoolean(); // start indexer Thread indexer = new Thread(new Runnable() { - @Override public void run() { + @Override + public void run() { while (!done.get()) { client.prepareIndex("test", "type", Integer.toString(ThreadLocalRandom.current().nextInt(NUMBER_OF_DOCS))) .setSource("field", "value").execute().actionGet(); @@ -67,7 +68,8 @@ public class MGetStress1 { // start the mget one Thread mget = new Thread(new Runnable() { - @Override public void run() { + @Override + public void run() { while (!done.get()) { Set ids = Sets.newHashSet(); for (int i = 0; i < MGET_BATCH; i++) { diff --git a/src/test/java/org/elasticsearch/test/stress/indexing/BulkIndexingStressTest.java b/src/test/java/org/elasticsearch/test/stress/indexing/BulkIndexingStressTest.java index 4cec041feba..c36f0412bfc 100644 --- a/src/test/java/org/elasticsearch/test/stress/indexing/BulkIndexingStressTest.java +++ b/src/test/java/org/elasticsearch/test/stress/indexing/BulkIndexingStressTest.java @@ -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.elasticsearch.test.stress.indexing; +import jsr166y.ThreadLocalRandom; import org.elasticsearch.client.Client; import org.elasticsearch.client.Requests; import org.elasticsearch.client.action.bulk.BulkRequestBuilder; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom; import org.elasticsearch.node.Node; import org.elasticsearch.node.NodeBuilder; diff --git a/src/test/java/org/elasticsearch/test/stress/indexing/ConcurrentIndexingVersioningTest.java b/src/test/java/org/elasticsearch/test/stress/indexing/ConcurrentIndexingVersioningTest.java index 1dd4b4422bf..150f18127ff 100644 --- a/src/test/java/org/elasticsearch/test/stress/indexing/ConcurrentIndexingVersioningTest.java +++ b/src/test/java/org/elasticsearch/test/stress/indexing/ConcurrentIndexingVersioningTest.java @@ -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,18 @@ package org.elasticsearch.test.stress.indexing; +import jsr166y.ThreadLocalRandom; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.SizeValue; -import org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.node.Node; import java.util.concurrent.CountDownLatch; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.elasticsearch.node.NodeBuilder.*; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.elasticsearch.node.NodeBuilder.nodeBuilder; /** * Checks that index operation does not create duplicate documents. @@ -56,7 +56,8 @@ public class ConcurrentIndexingVersioningTest { Thread[] threads = new Thread[NUMBER_OF_THREADS]; for (int i = 0; i < threads.length; i++) { threads[i] = new Thread() { - @Override public void run() { + @Override + public void run() { try { for (long i = 0; i < NUMBER_OF_ITERATIONS; i++) { if ((i % DELETE_EVERY) == 0) { diff --git a/src/test/java/org/elasticsearch/test/stress/leaks/GenericStatsLeak.java b/src/test/java/org/elasticsearch/test/stress/leaks/GenericStatsLeak.java index a49257b1b7e..968c1299c09 100644 --- a/src/test/java/org/elasticsearch/test/stress/leaks/GenericStatsLeak.java +++ b/src/test/java/org/elasticsearch/test/stress/leaks/GenericStatsLeak.java @@ -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 diff --git a/src/test/java/org/elasticsearch/test/stress/leaks/JvmStatsLeak.java b/src/test/java/org/elasticsearch/test/stress/leaks/JvmStatsLeak.java index 1c2e5838440..860ccf86e30 100644 --- a/src/test/java/org/elasticsearch/test/stress/leaks/JvmStatsLeak.java +++ b/src/test/java/org/elasticsearch/test/stress/leaks/JvmStatsLeak.java @@ -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 diff --git a/src/test/java/org/elasticsearch/test/stress/manyindices/ManyIndicesRemoteStressTest.java b/src/test/java/org/elasticsearch/test/stress/manyindices/ManyIndicesRemoteStressTest.java index 90d867681d0..b92c9605f60 100644 --- a/src/test/java/org/elasticsearch/test/stress/manyindices/ManyIndicesRemoteStressTest.java +++ b/src/test/java/org/elasticsearch/test/stress/manyindices/ManyIndicesRemoteStressTest.java @@ -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,7 +31,7 @@ import org.elasticsearch.node.NodeBuilder; import java.util.Date; /** - * @author kimchy (shay.banon) + * */ public class ManyIndicesRemoteStressTest { diff --git a/src/test/java/org/elasticsearch/test/stress/manyindices/ManyIndicesStressTest.java b/src/test/java/org/elasticsearch/test/stress/manyindices/ManyIndicesStressTest.java index e7e10290320..5916647e10d 100644 --- a/src/test/java/org/elasticsearch/test/stress/manyindices/ManyIndicesStressTest.java +++ b/src/test/java/org/elasticsearch/test/stress/manyindices/ManyIndicesStressTest.java @@ -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,10 +30,10 @@ import org.elasticsearch.node.NodeBuilder; import java.util.Date; -import static org.elasticsearch.index.query.QueryBuilders.*; +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; /** - * @author kimchy (shay.banon) + * */ public class ManyIndicesStressTest { diff --git a/src/test/java/org/elasticsearch/test/stress/manyindices/ManyNodesManyIndicesRecoveryStressTest.java b/src/test/java/org/elasticsearch/test/stress/manyindices/ManyNodesManyIndicesRecoveryStressTest.java index d748090e880..0b3d4a4aac5 100644 --- a/src/test/java/org/elasticsearch/test/stress/manyindices/ManyNodesManyIndicesRecoveryStressTest.java +++ b/src/test/java/org/elasticsearch/test/stress/manyindices/ManyNodesManyIndicesRecoveryStressTest.java @@ -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.test.stress.manyindices; +import com.google.common.collect.Lists; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.count.CountResponse; import org.elasticsearch.client.Client; -import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.query.QueryBuilders; diff --git a/src/test/java/org/elasticsearch/test/stress/refresh/RefreshStressTest1.java b/src/test/java/org/elasticsearch/test/stress/refresh/RefreshStressTest1.java index 3801f681d7e..169e5f49779 100644 --- a/src/test/java/org/elasticsearch/test/stress/refresh/RefreshStressTest1.java +++ b/src/test/java/org/elasticsearch/test/stress/refresh/RefreshStressTest1.java @@ -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 diff --git a/src/test/java/org/elasticsearch/test/stress/rollingrestart/RollingRestartStressTest.java b/src/test/java/org/elasticsearch/test/stress/rollingrestart/RollingRestartStressTest.java index 0b888accf3c..d922dce9996 100644 --- a/src/test/java/org/elasticsearch/test/stress/rollingrestart/RollingRestartStressTest.java +++ b/src/test/java/org/elasticsearch/test/stress/rollingrestart/RollingRestartStressTest.java @@ -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.test.stress.rollingrestart; +import jsr166y.ThreadLocalRandom; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.indices.status.IndexShardStatus; import org.elasticsearch.action.admin.indices.status.IndicesStatusResponse; @@ -34,7 +35,6 @@ import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; -import org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.env.NodeEnvironment; @@ -47,11 +47,11 @@ import java.io.File; import java.util.Arrays; import java.util.concurrent.atomic.AtomicLong; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.elasticsearch.index.query.QueryBuilders.*; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; /** - * @author kimchy (shay.banon) + * */ public class RollingRestartStressTest { @@ -293,7 +293,8 @@ public class RollingRestartStressTest { volatile boolean closed = false; - @Override public void run() { + @Override + public void run() { while (true) { if (close) { closed = true; diff --git a/src/test/java/org/elasticsearch/test/stress/search1/ParentChildStressTest.java b/src/test/java/org/elasticsearch/test/stress/search1/ParentChildStressTest.java index d211cc2e742..536e760a717 100644 --- a/src/test/java/org/elasticsearch/test/stress/search1/ParentChildStressTest.java +++ b/src/test/java/org/elasticsearch/test/stress/search1/ParentChildStressTest.java @@ -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 @@ -107,7 +107,7 @@ public class ParentChildStressTest { /** * Execute a search based on a JSON String in QueryDSL format. - * + *

    * Throws a RuntimeException if there are any shard failures to * elevate the visibility of the problem. */ @@ -158,7 +158,7 @@ public class ParentChildStressTest { /** * Perform the has_child query for the doc. - * + *

    * Since it might take time to get indexed, it * loops until it finds the doc. */ @@ -194,9 +194,9 @@ public class ParentChildStressTest { * search for the doc * delete the doc * repeat the above until shard failure. - * + *

    * Eventually fails with: - * + *

    * [shard [[74wz0lrXRSmSOsJOqgPvlw][acme][1]], reason [RemoteTransportException * [[Kismet][inet[/10.10.30.52:9300]][search/phase/query]]; nested: * QueryPhaseExecutionException[[acme][1]: diff --git a/src/test/java/org/elasticsearch/test/stress/search1/Search1StressTest.java b/src/test/java/org/elasticsearch/test/stress/search1/Search1StressTest.java index 03576016783..15beece477a 100644 --- a/src/test/java/org/elasticsearch/test/stress/search1/Search1StressTest.java +++ b/src/test/java/org/elasticsearch/test/stress/search1/Search1StressTest.java @@ -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.test.stress.search1; +import jsr166y.ThreadLocalRandom; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchType; import org.elasticsearch.client.action.search.SearchRequestBuilder; @@ -28,7 +29,6 @@ import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.SizeValue; import org.elasticsearch.common.unit.TimeValue; -import org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.node.Node; @@ -39,10 +39,10 @@ import org.elasticsearch.search.sort.SortOrder; import java.util.Arrays; import java.util.concurrent.atomic.AtomicLong; -import static org.elasticsearch.index.query.QueryBuilders.*; +import static org.elasticsearch.index.query.QueryBuilders.termQuery; /** - * @author kimchy (shay.banon) + * */ public class Search1StressTest { @@ -165,7 +165,8 @@ public class Search1StressTest { volatile boolean closed = false; - @Override public void run() { + @Override + public void run() { while (true) { if (close) { closed = true; @@ -222,7 +223,8 @@ public class Search1StressTest { volatile boolean closed = false; - @Override public void run() { + @Override + public void run() { while (true) { if (close) { closed = true; @@ -243,7 +245,8 @@ public class Search1StressTest { volatile boolean closed = false; - @Override public void run() { + @Override + public void run() { while (true) { if (close) { closed = true; @@ -264,7 +267,8 @@ public class Search1StressTest { volatile boolean closed = false; - @Override public void run() { + @Override + public void run() { while (true) { if (close) { closed = true; diff --git a/src/test/java/org/elasticsearch/ElasticSearchExceptionTests.java b/src/test/java/org/elasticsearch/test/unit/ElasticSearchExceptionTests.java similarity index 83% rename from src/test/java/org/elasticsearch/ElasticSearchExceptionTests.java rename to src/test/java/org/elasticsearch/test/unit/ElasticSearchExceptionTests.java index ee406a8815a..b2bacfb7f00 100644 --- a/src/test/java/org/elasticsearch/ElasticSearchExceptionTests.java +++ b/src/test/java/org/elasticsearch/test/unit/ElasticSearchExceptionTests.java @@ -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 @@ -17,21 +17,23 @@ * under the License. */ -package org.elasticsearch; +package org.elasticsearch.test.unit; +import org.elasticsearch.ElasticSearchException; import org.elasticsearch.index.Index; import org.elasticsearch.indices.IndexMissingException; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.transport.RemoteTransportException; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; @Test public class ElasticSearchExceptionTests { - @Test public void testStatus() { + @Test + public void testStatus() { ElasticSearchException exception = new ElasticSearchException("test"); assertThat(exception.status(), equalTo(RestStatus.INTERNAL_SERVER_ERROR)); diff --git a/src/test/java/org/elasticsearch/VersionTests.java b/src/test/java/org/elasticsearch/test/unit/VersionTests.java similarity index 82% rename from src/test/java/org/elasticsearch/VersionTests.java rename to src/test/java/org/elasticsearch/test/unit/VersionTests.java index 8a449291db8..4b8cf4a6048 100644 --- a/src/test/java/org/elasticsearch/VersionTests.java +++ b/src/test/java/org/elasticsearch/test/unit/VersionTests.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch; +package org.elasticsearch.test.unit; public class VersionTests { diff --git a/src/test/java/org/elasticsearch/action/bulk/BulkActionTests.java b/src/test/java/org/elasticsearch/test/unit/action/bulk/BulkActionTests.java similarity index 67% rename from src/test/java/org/elasticsearch/action/bulk/BulkActionTests.java rename to src/test/java/org/elasticsearch/test/unit/action/bulk/BulkActionTests.java index b98253cbdeb..fa536e8ac32 100644 --- a/src/test/java/org/elasticsearch/action/bulk/BulkActionTests.java +++ b/src/test/java/org/elasticsearch/test/unit/action/bulk/BulkActionTests.java @@ -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 @@ -17,25 +17,28 @@ * under the License. */ -package org.elasticsearch.action.bulk; +package org.elasticsearch.test.unit.action.bulk; +import org.elasticsearch.action.bulk.BulkRequest; import org.testng.annotations.Test; -import static org.elasticsearch.common.io.Streams.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.io.Streams.copyToStringFromClasspath; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; public class BulkActionTests { - @Test public void testSimpleBulk1() throws Exception { - String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk.json"); + @Test + public void testSimpleBulk1() throws Exception { + String bulkAction = copyToStringFromClasspath("/org/elasticsearch/test/unit/action/bulk/simple-bulk.json"); BulkRequest bulkRequest = new BulkRequest(); bulkRequest.add(bulkAction.getBytes(), 0, bulkAction.length(), true, null, null); assertThat(bulkRequest.numberOfActions(), equalTo(3)); } - @Test public void testSimpleBulk2() throws Exception { - String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk2.json"); + @Test + public void testSimpleBulk2() throws Exception { + String bulkAction = copyToStringFromClasspath("/org/elasticsearch/test/unit/action/bulk/simple-bulk2.json"); BulkRequest bulkRequest = new BulkRequest(); bulkRequest.add(bulkAction.getBytes(), 0, bulkAction.length(), true, null, null); assertThat(bulkRequest.numberOfActions(), equalTo(3)); diff --git a/src/test/java/org/elasticsearch/action/bulk/simple-bulk.json b/src/test/java/org/elasticsearch/test/unit/action/bulk/simple-bulk.json similarity index 73% rename from src/test/java/org/elasticsearch/action/bulk/simple-bulk.json rename to src/test/java/org/elasticsearch/test/unit/action/bulk/simple-bulk.json index b6f1b76ddf9..cf764771875 100644 --- a/src/test/java/org/elasticsearch/action/bulk/simple-bulk.json +++ b/src/test/java/org/elasticsearch/test/unit/action/bulk/simple-bulk.json @@ -1,4 +1,4 @@ -{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" } } +{ "index":{"_index":"test","_type":"type1","_id":"1"} } { "field1" : "value1" } { "delete" : { "_index" : "test", "_type" : "type1", "_id" : "2" } } { "create" : { "_index" : "test", "_type" : "type1", "_id" : "3" } } diff --git a/src/test/java/org/elasticsearch/action/bulk/simple-bulk2.json b/src/test/java/org/elasticsearch/test/unit/action/bulk/simple-bulk2.json similarity index 85% rename from src/test/java/org/elasticsearch/action/bulk/simple-bulk2.json rename to src/test/java/org/elasticsearch/test/unit/action/bulk/simple-bulk2.json index ccb621d4488..7cd4f9932d9 100644 --- a/src/test/java/org/elasticsearch/action/bulk/simple-bulk2.json +++ b/src/test/java/org/elasticsearch/test/unit/action/bulk/simple-bulk2.json @@ -1,4 +1,4 @@ -{ "index" : { } } +{ "index":{ } } { "field1" : "value1" } { "delete" : { "_id" : "2" } } { "create" : { "_id" : "3" } } diff --git a/src/test/java/org/elasticsearch/cluster/metadata/MappingMetaDataParserTests.java b/src/test/java/org/elasticsearch/test/unit/cluster/metadata/MappingMetaDataParserTests.java similarity index 91% rename from src/test/java/org/elasticsearch/cluster/metadata/MappingMetaDataParserTests.java rename to src/test/java/org/elasticsearch/test/unit/cluster/metadata/MappingMetaDataParserTests.java index f1028c57885..b8c0717d712 100644 --- a/src/test/java/org/elasticsearch/cluster/metadata/MappingMetaDataParserTests.java +++ b/src/test/java/org/elasticsearch/test/unit/cluster/metadata/MappingMetaDataParserTests.java @@ -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 @@ -17,20 +17,23 @@ * under the License. */ -package org.elasticsearch.cluster.metadata; +package org.elasticsearch.test.unit.cluster.metadata; +import org.elasticsearch.cluster.metadata.MappingMetaData; import org.elasticsearch.common.compress.CompressedString; import org.elasticsearch.common.xcontent.XContentFactory; import org.testng.annotations.Test; -import static org.elasticsearch.common.xcontent.XContentFactory.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.nullValue; @Test public class MappingMetaDataParserTests { - @Test public void testParseIdAlone() throws Exception { + @Test + public void testParseIdAlone() throws Exception { MappingMetaData md = new MappingMetaData("type1", new CompressedString(""), new MappingMetaData.Id("id"), new MappingMetaData.Routing(true, "routing"), @@ -47,7 +50,8 @@ public class MappingMetaDataParserTests { assertThat(parseContext.timestampResolved(), equalTo(false)); } - @Test public void testParseRoutingAlone() throws Exception { + @Test + public void testParseRoutingAlone() throws Exception { MappingMetaData md = new MappingMetaData("type1", new CompressedString(""), new MappingMetaData.Id("id"), new MappingMetaData.Routing(true, "routing"), @@ -64,7 +68,8 @@ public class MappingMetaDataParserTests { assertThat(parseContext.timestampResolved(), equalTo(false)); } - @Test public void testParseTimestampAlone() throws Exception { + @Test + public void testParseTimestampAlone() throws Exception { MappingMetaData md = new MappingMetaData("type1", new CompressedString(""), new MappingMetaData.Id("id"), new MappingMetaData.Routing(true, "routing"), @@ -81,7 +86,8 @@ public class MappingMetaDataParserTests { assertThat(parseContext.timestampResolved(), equalTo(true)); } - @Test public void testParseIdAndRoutingAndTimestamp() throws Exception { + @Test + public void testParseIdAndRoutingAndTimestamp() throws Exception { MappingMetaData md = new MappingMetaData("type1", new CompressedString(""), new MappingMetaData.Id("id"), new MappingMetaData.Routing(true, "routing"), @@ -95,7 +101,8 @@ public class MappingMetaDataParserTests { assertThat(parseContext.timestamp(), equalTo("1")); } - @Test public void testParseIdAndRoutingAndTimestampWithPath() throws Exception { + @Test + public void testParseIdAndRoutingAndTimestampWithPath() throws Exception { MappingMetaData md = new MappingMetaData("type1", new CompressedString(""), new MappingMetaData.Id("obj1.id"), new MappingMetaData.Routing(true, "obj1.routing"), @@ -112,7 +119,8 @@ public class MappingMetaDataParserTests { assertThat(parseContext.timestamp(), equalTo("1")); } - @Test public void testParseIdWithPath() throws Exception { + @Test + public void testParseIdWithPath() throws Exception { MappingMetaData md = new MappingMetaData("type1", new CompressedString(""), new MappingMetaData.Id("obj1.id"), new MappingMetaData.Routing(true, "obj1.routing"), @@ -132,7 +140,8 @@ public class MappingMetaDataParserTests { assertThat(parseContext.timestampResolved(), equalTo(false)); } - @Test public void testParseRoutingWithPath() throws Exception { + @Test + public void testParseRoutingWithPath() throws Exception { MappingMetaData md = new MappingMetaData("type1", new CompressedString(""), new MappingMetaData.Id("obj1.id"), new MappingMetaData.Routing(true, "obj1.routing"), @@ -152,7 +161,8 @@ public class MappingMetaDataParserTests { assertThat(parseContext.timestampResolved(), equalTo(false)); } - @Test public void testParseTimestampWithPath() throws Exception { + @Test + public void testParseTimestampWithPath() throws Exception { MappingMetaData md = new MappingMetaData("type1", new CompressedString(""), new MappingMetaData.Id("obj1.id"), new MappingMetaData.Routing(true, "obj1.routing"), @@ -172,7 +182,8 @@ public class MappingMetaDataParserTests { assertThat(parseContext.timestampResolved(), equalTo(true)); } - @Test public void testParseIdAndRoutingAndTimestampWithinSamePath() throws Exception { + @Test + public void testParseIdAndRoutingAndTimestampWithinSamePath() throws Exception { MappingMetaData md = new MappingMetaData("type1", new CompressedString(""), new MappingMetaData.Id("obj1.id"), new MappingMetaData.Routing(true, "obj1.routing"), @@ -189,7 +200,8 @@ public class MappingMetaDataParserTests { assertThat(parseContext.timestamp(), equalTo("1")); } - @Test public void testParseIdAndRoutingAndTimestampWithinSamePathAndMoreLevels() throws Exception { + @Test + public void testParseIdAndRoutingAndTimestampWithinSamePathAndMoreLevels() throws Exception { MappingMetaData md = new MappingMetaData("type1", new CompressedString(""), new MappingMetaData.Id("obj1.obj0.id"), new MappingMetaData.Routing(true, "obj1.obj2.routing"), @@ -217,7 +229,8 @@ public class MappingMetaDataParserTests { } - @Test public void testParseIdAndRoutingAndTimestampWithSameRepeatedObject() throws Exception { + @Test + public void testParseIdAndRoutingAndTimestampWithSameRepeatedObject() throws Exception { MappingMetaData md = new MappingMetaData("type1", new CompressedString(""), new MappingMetaData.Id("obj1.id"), new MappingMetaData.Routing(true, "obj1.routing"), @@ -236,7 +249,8 @@ public class MappingMetaDataParserTests { } // - @Test public void testParseIdRoutingTimestampWithRepeatedField() throws Exception { + @Test + public void testParseIdRoutingTimestampWithRepeatedField() throws Exception { MappingMetaData md = new MappingMetaData("type1", new CompressedString(""), new MappingMetaData.Id("field1"), new MappingMetaData.Routing(true, "field1.field1"), @@ -258,7 +272,8 @@ public class MappingMetaDataParserTests { assertThat(parseContext.timestamp(), equalTo("foo")); } - @Test public void testParseNoIdRoutingWithRepeatedFieldAndObject() throws Exception { + @Test + public void testParseNoIdRoutingWithRepeatedFieldAndObject() throws Exception { MappingMetaData md = new MappingMetaData("type1", new CompressedString(""), new MappingMetaData.Id("id"), new MappingMetaData.Routing(true, "field1.field1.field2"), @@ -280,7 +295,8 @@ public class MappingMetaDataParserTests { assertThat(parseContext.timestamp(), equalTo("foo")); } - @Test public void testParseRoutingWithRepeatedFieldAndValidRouting() throws Exception { + @Test + public void testParseRoutingWithRepeatedFieldAndValidRouting() throws Exception { MappingMetaData md = new MappingMetaData("type1", new CompressedString(""), new MappingMetaData.Id(null), new MappingMetaData.Routing(true, "field1.field2"), diff --git a/src/test/java/org/elasticsearch/cluster/metadata/ToAndFromJsonMetaDataTests.java b/src/test/java/org/elasticsearch/test/unit/cluster/metadata/ToAndFromJsonMetaDataTests.java similarity index 94% rename from src/test/java/org/elasticsearch/cluster/metadata/ToAndFromJsonMetaDataTests.java rename to src/test/java/org/elasticsearch/test/unit/cluster/metadata/ToAndFromJsonMetaDataTests.java index dd908c84097..5f94529bcda 100644 --- a/src/test/java/org/elasticsearch/cluster/metadata/ToAndFromJsonMetaDataTests.java +++ b/src/test/java/org/elasticsearch/test/unit/cluster/metadata/ToAndFromJsonMetaDataTests.java @@ -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 @@ -17,8 +17,10 @@ * under the License. */ -package org.elasticsearch.cluster.metadata; +package org.elasticsearch.test.unit.cluster.metadata; +import org.elasticsearch.cluster.metadata.IndexMetaData; +import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentType; import org.testng.annotations.Test; @@ -26,14 +28,15 @@ import org.testng.annotations.Test; import java.io.IOException; import static org.elasticsearch.cluster.metadata.AliasMetaData.newAliasMetaDataBuilder; -import static org.elasticsearch.cluster.metadata.IndexMetaData.*; -import static org.elasticsearch.cluster.metadata.MetaData.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder; +import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.nullValue; /** - * @author kimchy (shay.banon) + * */ @Test public class ToAndFromJsonMetaDataTests { diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/AwarenessAllocationTests.java b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/AwarenessAllocationTests.java similarity index 96% rename from src/test/java/org/elasticsearch/cluster/routing/allocation/AwarenessAllocationTests.java rename to src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/AwarenessAllocationTests.java index 56304c42301..c2842400257 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/AwarenessAllocationTests.java +++ b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/AwarenessAllocationTests.java @@ -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 @@ -17,26 +17,28 @@ * under the License. */ -package org.elasticsearch.cluster.routing.allocation; +package org.elasticsearch.test.unit.cluster.routing.allocation; +import com.google.common.collect.ImmutableMap; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.routing.RoutingTable; import org.elasticsearch.cluster.routing.ShardRoutingState; -import org.elasticsearch.common.collect.ImmutableMap; +import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.testng.annotations.Test; -import static org.elasticsearch.cluster.ClusterState.*; -import static org.elasticsearch.cluster.metadata.IndexMetaData.*; -import static org.elasticsearch.cluster.metadata.MetaData.*; -import static org.elasticsearch.cluster.node.DiscoveryNodes.*; -import static org.elasticsearch.cluster.routing.RoutingBuilders.*; +import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; +import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder; +import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; +import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; +import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable; +import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.hamcrest.MatcherAssert.*; +import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** @@ -46,7 +48,8 @@ public class AwarenessAllocationTests { private final ESLogger logger = Loggers.getLogger(AwarenessAllocationTests.class); - @Test public void moveShardOnceNewNodeWithAttributeAdded1() { + @Test + public void moveShardOnceNewNodeWithAttributeAdded1() { AllocationService strategy = new AllocationService(settingsBuilder() .put("cluster.routing.allocation.concurrent_recoveries", 10) .put("cluster.routing.allocation.allow_rebalance", "always") @@ -114,7 +117,8 @@ public class AwarenessAllocationTests { assertThat(clusterState.routingNodes().shardsWithState(STARTED).size(), equalTo(2)); } - @Test public void moveShardOnceNewNodeWithAttributeAdded2() { + @Test + public void moveShardOnceNewNodeWithAttributeAdded2() { AllocationService strategy = new AllocationService(settingsBuilder() .put("cluster.routing.allocation.concurrent_recoveries", 10) .put("cluster.routing.allocation.allow_rebalance", "always") @@ -183,7 +187,8 @@ public class AwarenessAllocationTests { assertThat(clusterState.routingNodes().shardsWithState(STARTED).size(), equalTo(2)); } - @Test public void moveShardOnceNewNodeWithAttributeAdded3() { + @Test + public void moveShardOnceNewNodeWithAttributeAdded3() { AllocationService strategy = new AllocationService(settingsBuilder() .put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_initial_primaries_recoveries", 10) @@ -266,7 +271,8 @@ public class AwarenessAllocationTests { assertThat(strategy.reroute(clusterState).routingTable(), sameInstance(clusterState.routingTable())); } - @Test public void moveShardOnceNewNodeWithAttributeAdded4() { + @Test + public void moveShardOnceNewNodeWithAttributeAdded4() { AllocationService strategy = new AllocationService(settingsBuilder() .put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_initial_primaries_recoveries", 10) @@ -351,7 +357,8 @@ public class AwarenessAllocationTests { assertThat(strategy.reroute(clusterState).routingTable(), sameInstance(clusterState.routingTable())); } - @Test public void moveShardOnceNewNodeWithAttributeAdded5() { + @Test + public void moveShardOnceNewNodeWithAttributeAdded5() { AllocationService strategy = new AllocationService(settingsBuilder() .put("cluster.routing.allocation.concurrent_recoveries", 10) .put("cluster.routing.allocation.allow_rebalance", "always") @@ -429,7 +436,8 @@ public class AwarenessAllocationTests { assertThat(strategy.reroute(clusterState).routingTable(), sameInstance(clusterState.routingTable())); } - @Test public void moveShardOnceNewNodeWithAttributeAdded6() { + @Test + public void moveShardOnceNewNodeWithAttributeAdded6() { AllocationService strategy = new AllocationService(settingsBuilder() .put("cluster.routing.allocation.concurrent_recoveries", 10) .put("cluster.routing.allocation.allow_rebalance", "always") @@ -509,7 +517,8 @@ public class AwarenessAllocationTests { assertThat(strategy.reroute(clusterState).routingTable(), sameInstance(clusterState.routingTable())); } - @Test public void fullAwareness1() { + @Test + public void fullAwareness1() { AllocationService strategy = new AllocationService(settingsBuilder() .put("cluster.routing.allocation.concurrent_recoveries", 10) .put("cluster.routing.allocation.allow_rebalance", "always") @@ -576,7 +585,8 @@ public class AwarenessAllocationTests { assertThat(clusterState.routingNodes().shardsWithState(STARTED).size(), equalTo(2)); } - @Test public void fullAwareness2() { + @Test + public void fullAwareness2() { AllocationService strategy = new AllocationService(settingsBuilder() .put("cluster.routing.allocation.concurrent_recoveries", 10) .put("cluster.routing.allocation.allow_rebalance", "always") @@ -644,7 +654,8 @@ public class AwarenessAllocationTests { assertThat(clusterState.routingNodes().shardsWithState(STARTED).size(), equalTo(2)); } - @Test public void fullAwareness3() { + @Test + public void fullAwareness3() { AllocationService strategy = new AllocationService(settingsBuilder() .put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_initial_primaries_recoveries", 10) diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/ClusterRebalanceRoutingTests.java b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/ClusterRebalanceRoutingTests.java similarity index 96% rename from src/test/java/org/elasticsearch/cluster/routing/allocation/ClusterRebalanceRoutingTests.java rename to src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/ClusterRebalanceRoutingTests.java index 289f93ac0e1..bd760774827 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/ClusterRebalanceRoutingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/ClusterRebalanceRoutingTests.java @@ -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 @@ -17,34 +17,38 @@ * under the License. */ -package org.elasticsearch.cluster.routing.allocation; +package org.elasticsearch.test.unit.cluster.routing.allocation; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.routing.RoutingNodes; import org.elasticsearch.cluster.routing.RoutingTable; +import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllocationDecider; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.testng.annotations.Test; -import static org.elasticsearch.cluster.ClusterState.*; -import static org.elasticsearch.cluster.metadata.IndexMetaData.*; -import static org.elasticsearch.cluster.metadata.MetaData.*; -import static org.elasticsearch.cluster.node.DiscoveryNodes.*; -import static org.elasticsearch.cluster.routing.RoutingBuilders.*; +import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; +import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder; +import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; +import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; +import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable; +import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.nullValue; @Test public class ClusterRebalanceRoutingTests { private final ESLogger logger = Loggers.getLogger(ClusterRebalanceRoutingTests.class); - @Test public void testAlways() { + @Test + public void testAlways() { AllocationService strategy = new AllocationService(settingsBuilder().put("cluster.routing.allocation.allow_rebalance", ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString()).build()); MetaData metaData = newMetaDataBuilder() @@ -129,7 +133,8 @@ public class ClusterRebalanceRoutingTests { } - @Test public void testClusterPrimariesActive1() { + @Test + public void testClusterPrimariesActive1() { AllocationService strategy = new AllocationService(settingsBuilder().put("cluster.routing.allocation.allow_rebalance", ClusterRebalanceAllocationDecider.ClusterRebalanceType.INDICES_PRIMARIES_ACTIVE.toString()).build()); MetaData metaData = newMetaDataBuilder() @@ -232,7 +237,8 @@ public class ClusterRebalanceRoutingTests { assertThat(routingNodes.node("node3").shards().get(0).shardId().index().name(), equalTo("test1")); } - @Test public void testClusterPrimariesActive2() { + @Test + public void testClusterPrimariesActive2() { AllocationService strategy = new AllocationService(settingsBuilder().put("cluster.routing.allocation.allow_rebalance", ClusterRebalanceAllocationDecider.ClusterRebalanceType.INDICES_PRIMARIES_ACTIVE.toString()).build()); MetaData metaData = newMetaDataBuilder() @@ -315,7 +321,8 @@ public class ClusterRebalanceRoutingTests { assertThat(routingNodes.node("node3"), nullValue()); } - @Test public void testClusterAllActive1() { + @Test + public void testClusterAllActive1() { AllocationService strategy = new AllocationService(settingsBuilder().put("cluster.routing.allocation.allow_rebalance", ClusterRebalanceAllocationDecider.ClusterRebalanceType.INDICES_ALL_ACTIVE.toString()).build()); MetaData metaData = newMetaDataBuilder() @@ -437,7 +444,8 @@ public class ClusterRebalanceRoutingTests { assertThat(routingNodes.node("node3").shards().get(0).shardId().index().name(), equalTo("test1")); } - @Test public void testClusterAllActive2() { + @Test + public void testClusterAllActive2() { AllocationService strategy = new AllocationService(settingsBuilder().put("cluster.routing.allocation.allow_rebalance", ClusterRebalanceAllocationDecider.ClusterRebalanceType.INDICES_ALL_ACTIVE.toString()).build()); MetaData metaData = newMetaDataBuilder() @@ -520,7 +528,8 @@ public class ClusterRebalanceRoutingTests { assertThat(routingNodes.node("node3"), nullValue()); } - @Test public void testClusterAllActive3() { + @Test + public void testClusterAllActive3() { AllocationService strategy = new AllocationService(settingsBuilder().put("cluster.routing.allocation.allow_rebalance", ClusterRebalanceAllocationDecider.ClusterRebalanceType.INDICES_ALL_ACTIVE.toString()).build()); MetaData metaData = newMetaDataBuilder() diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/ConcurrentRebalanceRoutingTests.java b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/ConcurrentRebalanceRoutingTests.java similarity index 89% rename from src/test/java/org/elasticsearch/cluster/routing/allocation/ConcurrentRebalanceRoutingTests.java rename to src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/ConcurrentRebalanceRoutingTests.java index a075d5576e9..82a94298264 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/ConcurrentRebalanceRoutingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/ConcurrentRebalanceRoutingTests.java @@ -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 @@ -17,33 +17,37 @@ * under the License. */ -package org.elasticsearch.cluster.routing.allocation; +package org.elasticsearch.test.unit.cluster.routing.allocation; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.routing.RoutingNodes; import org.elasticsearch.cluster.routing.RoutingTable; +import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.testng.annotations.Test; -import static org.elasticsearch.cluster.ClusterState.*; -import static org.elasticsearch.cluster.metadata.IndexMetaData.*; -import static org.elasticsearch.cluster.metadata.MetaData.*; -import static org.elasticsearch.cluster.node.DiscoveryNodes.*; -import static org.elasticsearch.cluster.routing.RoutingBuilders.*; +import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; +import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder; +import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; +import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; +import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable; +import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.nullValue; @Test public class ConcurrentRebalanceRoutingTests { private final ESLogger logger = Loggers.getLogger(ConcurrentRebalanceRoutingTests.class); - @Test public void testClusterConcurrentRebalance() { + @Test + public void testClusterConcurrentRebalance() { AllocationService strategy = new AllocationService(settingsBuilder() .put("cluster.routing.allocation.concurrent_recoveries", 10) .put("cluster.routing.allocation.allow_rebalance", "always") diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/DisableAllocationTests.java b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/DisableAllocationTests.java similarity index 80% rename from src/test/java/org/elasticsearch/cluster/routing/allocation/DisableAllocationTests.java rename to src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/DisableAllocationTests.java index 18ed1c0a936..45005d380f9 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/DisableAllocationTests.java +++ b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/DisableAllocationTests.java @@ -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 @@ -17,25 +17,27 @@ * under the License. */ -package org.elasticsearch.cluster.routing.allocation; +package org.elasticsearch.test.unit.cluster.routing.allocation; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.routing.RoutingTable; +import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.testng.annotations.Test; -import static org.elasticsearch.cluster.ClusterState.*; -import static org.elasticsearch.cluster.metadata.IndexMetaData.*; -import static org.elasticsearch.cluster.metadata.MetaData.*; -import static org.elasticsearch.cluster.node.DiscoveryNodes.*; -import static org.elasticsearch.cluster.routing.RoutingBuilders.*; -import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; +import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder; +import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; +import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; +import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable; +import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; +import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; +import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** */ @@ -44,7 +46,8 @@ public class DisableAllocationTests { private final ESLogger logger = Loggers.getLogger(DisableAllocationTests.class); - @Test public void testDisableAllocation() { + @Test + public void testDisableAllocation() { AllocationService strategy = new AllocationService(settingsBuilder() .put("cluster.routing.allocation.disable_allocation", true) .build()); @@ -72,7 +75,8 @@ public class DisableAllocationTests { } - @Test public void testDisableReplicaAllocation() { + @Test + public void testDisableReplicaAllocation() { AllocationService strategy = new AllocationService(settingsBuilder() .put("cluster.routing.allocation.disable_replica_allocation", true) .build()); diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/ElectReplicaAsPrimaryDuringRelocationTests.java b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/ElectReplicaAsPrimaryDuringRelocationTests.java similarity index 83% rename from src/test/java/org/elasticsearch/cluster/routing/allocation/ElectReplicaAsPrimaryDuringRelocationTests.java rename to src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/ElectReplicaAsPrimaryDuringRelocationTests.java index b5bd0711857..ea9597e8d9d 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/ElectReplicaAsPrimaryDuringRelocationTests.java +++ b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/ElectReplicaAsPrimaryDuringRelocationTests.java @@ -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 @@ -17,36 +17,41 @@ * under the License. */ -package org.elasticsearch.cluster.routing.allocation; +package org.elasticsearch.test.unit.cluster.routing.allocation; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.routing.IndexShardRoutingTable; import org.elasticsearch.cluster.routing.RoutingNodes; import org.elasticsearch.cluster.routing.RoutingTable; +import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.testng.annotations.Test; -import static org.elasticsearch.cluster.ClusterState.*; -import static org.elasticsearch.cluster.metadata.IndexMetaData.*; -import static org.elasticsearch.cluster.metadata.MetaData.*; -import static org.elasticsearch.cluster.node.DiscoveryNodes.*; -import static org.elasticsearch.cluster.routing.RoutingBuilders.*; -import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; +import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder; +import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; +import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; +import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable; +import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; +import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; +import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; +import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.notNullValue; /** - * @author kimchy (shay.banon) + * */ public class ElectReplicaAsPrimaryDuringRelocationTests { private final ESLogger logger = Loggers.getLogger(ElectReplicaAsPrimaryDuringRelocationTests.class); - @Test public void testElectReplicaAsPrimaryDuringRelocation() { + @Test + public void testElectReplicaAsPrimaryDuringRelocation() { AllocationService strategy = new AllocationService(settingsBuilder().put("cluster.routing.allocation.concurrent_recoveries", 10).build()); logger.info("Building initial routing table"); diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/FailedNodeRoutingTests.java b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/FailedNodeRoutingTests.java similarity index 84% rename from src/test/java/org/elasticsearch/cluster/routing/allocation/FailedNodeRoutingTests.java rename to src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/FailedNodeRoutingTests.java index bbdef0290e2..c397b527453 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/FailedNodeRoutingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/FailedNodeRoutingTests.java @@ -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 @@ -17,34 +17,38 @@ * under the License. */ -package org.elasticsearch.cluster.routing.allocation; +package org.elasticsearch.test.unit.cluster.routing.allocation; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.routing.RoutingNode; import org.elasticsearch.cluster.routing.RoutingNodes; import org.elasticsearch.cluster.routing.RoutingTable; +import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllocationDecider; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.testng.annotations.Test; -import static org.elasticsearch.cluster.ClusterState.*; -import static org.elasticsearch.cluster.metadata.IndexMetaData.*; -import static org.elasticsearch.cluster.metadata.MetaData.*; -import static org.elasticsearch.cluster.node.DiscoveryNodes.*; -import static org.elasticsearch.cluster.routing.RoutingBuilders.*; -import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; +import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder; +import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; +import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; +import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable; +import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; +import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; +import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; +import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; public class FailedNodeRoutingTests { private final ESLogger logger = Loggers.getLogger(FailedNodeRoutingTests.class); - @Test public void simpleFailedNodeTest() { + @Test + public void simpleFailedNodeTest() { AllocationService strategy = new AllocationService(settingsBuilder().put("cluster.routing.allocation.allow_rebalance", ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString()).build()); MetaData metaData = newMetaDataBuilder() @@ -60,7 +64,7 @@ public class FailedNodeRoutingTests { ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build(); logger.info("start 4 nodes"); - clusterState = newClusterStateBuilder().state(clusterState).nodes(newNodesBuilder().put(newNode("node1")).put(newNode("node2")).put(newNode("node3")).put(newNode("node4"))).build(); + clusterState = newClusterStateBuilder().state(clusterState).nodes(newNodesBuilder().put(RoutingAllocationTests.newNode("node1")).put(RoutingAllocationTests.newNode("node2")).put(RoutingAllocationTests.newNode("node3")).put(RoutingAllocationTests.newNode("node4"))).build(); RoutingTable prevRoutingTable = routingTable; routingTable = strategy.reroute(clusterState).routingTable(); clusterState = newClusterStateBuilder().state(clusterState).routingTable(routingTable).build(); @@ -103,7 +107,8 @@ public class FailedNodeRoutingTests { } } - @Test public void simpleFailedNodeTestNoReassign() { + @Test + public void simpleFailedNodeTestNoReassign() { AllocationService strategy = new AllocationService(settingsBuilder().put("cluster.routing.allocation.allow_rebalance", ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString()).build()); MetaData metaData = newMetaDataBuilder() @@ -119,7 +124,7 @@ public class FailedNodeRoutingTests { ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build(); logger.info("start 4 nodes"); - clusterState = newClusterStateBuilder().state(clusterState).nodes(newNodesBuilder().put(newNode("node1")).put(newNode("node2")).put(newNode("node3")).put(newNode("node4"))).build(); + clusterState = newClusterStateBuilder().state(clusterState).nodes(newNodesBuilder().put(RoutingAllocationTests.newNode("node1")).put(RoutingAllocationTests.newNode("node2")).put(RoutingAllocationTests.newNode("node3")).put(RoutingAllocationTests.newNode("node4"))).build(); RoutingTable prevRoutingTable = routingTable; routingTable = strategy.reroute(clusterState).routingTable(); clusterState = newClusterStateBuilder().state(clusterState).routingTable(routingTable).build(); diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/FailedShardsRoutingTests.java b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/FailedShardsRoutingTests.java similarity index 94% rename from src/test/java/org/elasticsearch/cluster/routing/allocation/FailedShardsRoutingTests.java rename to src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/FailedShardsRoutingTests.java index bae094ac335..64e90f7ddd2 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/FailedShardsRoutingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/FailedShardsRoutingTests.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.cluster.routing.allocation; +package org.elasticsearch.test.unit.cluster.routing.allocation; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.MetaData; @@ -25,30 +25,33 @@ import org.elasticsearch.cluster.routing.ImmutableShardRouting; import org.elasticsearch.cluster.routing.RoutingNodes; import org.elasticsearch.cluster.routing.RoutingTable; import org.elasticsearch.cluster.routing.ShardRouting; +import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.testng.annotations.Test; -import static org.elasticsearch.cluster.ClusterState.*; -import static org.elasticsearch.cluster.metadata.IndexMetaData.*; -import static org.elasticsearch.cluster.metadata.MetaData.*; -import static org.elasticsearch.cluster.node.DiscoveryNodes.*; -import static org.elasticsearch.cluster.routing.RoutingBuilders.*; +import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; +import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder; +import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; +import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; +import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable; +import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.hamcrest.MatcherAssert.*; +import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** - * @author kimchy (shay.banon) + * */ @Test public class FailedShardsRoutingTests { private final ESLogger logger = Loggers.getLogger(FailedShardsRoutingTests.class); - @Test public void failPrimaryStartedCheckReplicaElected() { + @Test + public void failPrimaryStartedCheckReplicaElected() { AllocationService strategy = new AllocationService(settingsBuilder() .put("cluster.routing.allocation.concurrent_recoveries", 10) .put("cluster.routing.allocation.allow_rebalance", "always") @@ -128,7 +131,8 @@ public class FailedShardsRoutingTests { assertThat(strategy.applyFailedShard(clusterState, shardToFail).changed(), equalTo(false)); } - @Test public void firstAllocationFailureSingleNode() { + @Test + public void firstAllocationFailureSingleNode() { AllocationService strategy = new AllocationService(settingsBuilder() .put("cluster.routing.allocation.concurrent_recoveries", 10) .put("cluster.routing.allocation.allow_rebalance", "always") @@ -184,7 +188,8 @@ public class FailedShardsRoutingTests { assertThat(strategy.applyFailedShard(clusterState, new ImmutableShardRouting("test", 0, "node1", true, INITIALIZING, 0)).changed(), equalTo(false)); } - @Test public void firstAllocationFailureTwoNodes() { + @Test + public void firstAllocationFailureTwoNodes() { AllocationService strategy = new AllocationService(settingsBuilder() .put("cluster.routing.allocation.concurrent_recoveries", 10) .put("cluster.routing.allocation.allow_rebalance", "always") @@ -240,7 +245,8 @@ public class FailedShardsRoutingTests { assertThat(strategy.applyFailedShard(clusterState, new ImmutableShardRouting("test", 0, "node1", true, INITIALIZING, 0)).changed(), equalTo(false)); } - @Test public void rebalanceFailure() { + @Test + public void rebalanceFailure() { AllocationService strategy = new AllocationService(settingsBuilder() .put("cluster.routing.allocation.concurrent_recoveries", 10) .put("cluster.routing.allocation.allow_rebalance", "always") diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/FilterRoutingTests.java b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/FilterRoutingTests.java similarity index 89% rename from src/test/java/org/elasticsearch/cluster/routing/allocation/FilterRoutingTests.java rename to src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/FilterRoutingTests.java index 756164bf6c5..d247d16c8a0 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/FilterRoutingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/FilterRoutingTests.java @@ -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 @@ -17,14 +17,15 @@ * under the License. */ -package org.elasticsearch.cluster.routing.allocation; +package org.elasticsearch.test.unit.cluster.routing.allocation; +import com.google.common.collect.ImmutableMap; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.routing.MutableShardRouting; import org.elasticsearch.cluster.routing.RoutingTable; import org.elasticsearch.cluster.routing.ShardRoutingState; -import org.elasticsearch.common.collect.ImmutableMap; +import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.hamcrest.Matchers; @@ -32,16 +33,17 @@ import org.testng.annotations.Test; import java.util.List; -import static org.elasticsearch.cluster.ClusterState.*; -import static org.elasticsearch.cluster.metadata.IndexMetaData.*; -import static org.elasticsearch.cluster.metadata.MetaData.*; -import static org.elasticsearch.cluster.node.DiscoveryNodes.*; -import static org.elasticsearch.cluster.routing.RoutingBuilders.*; -import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; +import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder; +import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; +import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; +import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable; +import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; +import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; +import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** */ @@ -50,7 +52,8 @@ public class FilterRoutingTests { private final ESLogger logger = Loggers.getLogger(FilterRoutingTests.class); - @Test public void testClusterFilters() { + @Test + public void testClusterFilters() { AllocationService strategy = new AllocationService(settingsBuilder() .put("cluster.routing.allocation.include.tag1", "value1,value2") .put("cluster.routing.allocation.exclude.tag1", "value3,value4") @@ -95,7 +98,8 @@ public class FilterRoutingTests { } } - @Test public void testIndexFilters() { + @Test + public void testIndexFilters() { AllocationService strategy = new AllocationService(settingsBuilder() .build()); diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/PrimaryElectionRoutingTests.java b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/PrimaryElectionRoutingTests.java similarity index 79% rename from src/test/java/org/elasticsearch/cluster/routing/allocation/PrimaryElectionRoutingTests.java rename to src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/PrimaryElectionRoutingTests.java index 76a66a696be..7b84e412367 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/PrimaryElectionRoutingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/PrimaryElectionRoutingTests.java @@ -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 @@ -17,35 +17,40 @@ * under the License. */ -package org.elasticsearch.cluster.routing.allocation; +package org.elasticsearch.test.unit.cluster.routing.allocation; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.routing.RoutingNodes; import org.elasticsearch.cluster.routing.RoutingTable; +import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.testng.annotations.Test; -import static org.elasticsearch.cluster.ClusterState.*; -import static org.elasticsearch.cluster.metadata.IndexMetaData.*; -import static org.elasticsearch.cluster.metadata.MetaData.*; -import static org.elasticsearch.cluster.node.DiscoveryNodes.*; -import static org.elasticsearch.cluster.routing.RoutingBuilders.*; -import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; +import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder; +import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; +import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; +import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable; +import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; +import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; +import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; +import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.nullValue; /** - * @author kimchy (shay.banon) + * */ public class PrimaryElectionRoutingTests { private final ESLogger logger = Loggers.getLogger(PrimaryElectionRoutingTests.class); - @Test public void testBackupElectionToPrimaryWhenPrimaryCanBeAllocatedToAnotherNode() { + @Test + public void testBackupElectionToPrimaryWhenPrimaryCanBeAllocatedToAnotherNode() { AllocationService strategy = new AllocationService(settingsBuilder().put("cluster.routing.allocation.concurrent_recoveries", 10).build()); logger.info("Building initial routing table"); diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/PrimaryNotRelocatedWhileBeingRecoveredTests.java b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/PrimaryNotRelocatedWhileBeingRecoveredTests.java similarity index 79% rename from src/test/java/org/elasticsearch/cluster/routing/allocation/PrimaryNotRelocatedWhileBeingRecoveredTests.java rename to src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/PrimaryNotRelocatedWhileBeingRecoveredTests.java index a2b6da7dadf..794ac62d20e 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/PrimaryNotRelocatedWhileBeingRecoveredTests.java +++ b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/PrimaryNotRelocatedWhileBeingRecoveredTests.java @@ -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 @@ -17,36 +17,40 @@ * under the License. */ -package org.elasticsearch.cluster.routing.allocation; +package org.elasticsearch.test.unit.cluster.routing.allocation; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.routing.RoutingNodes; import org.elasticsearch.cluster.routing.RoutingTable; +import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.testng.annotations.Test; -import static org.elasticsearch.cluster.ClusterState.*; -import static org.elasticsearch.cluster.metadata.IndexMetaData.*; -import static org.elasticsearch.cluster.metadata.MetaData.*; -import static org.elasticsearch.cluster.node.DiscoveryNodes.*; -import static org.elasticsearch.cluster.routing.RoutingBuilders.*; -import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; +import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder; +import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; +import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; +import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable; +import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; +import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; +import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; +import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class PrimaryNotRelocatedWhileBeingRecoveredTests { private final ESLogger logger = Loggers.getLogger(PrimaryNotRelocatedWhileBeingRecoveredTests.class); - @Test public void testPrimaryNotRelocatedWhileBeingRecoveredFrom() { + @Test + public void testPrimaryNotRelocatedWhileBeingRecoveredFrom() { AllocationService strategy = new AllocationService(settingsBuilder() .put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_initial_primaries_recoveries", 10) diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/RebalanceAfterActiveTests.java b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/RebalanceAfterActiveTests.java similarity index 88% rename from src/test/java/org/elasticsearch/cluster/routing/allocation/RebalanceAfterActiveTests.java rename to src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/RebalanceAfterActiveTests.java index c9d26a0714e..ca994e1f471 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/RebalanceAfterActiveTests.java +++ b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/RebalanceAfterActiveTests.java @@ -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 @@ -17,36 +17,40 @@ * under the License. */ -package org.elasticsearch.cluster.routing.allocation; +package org.elasticsearch.test.unit.cluster.routing.allocation; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.routing.RoutingNode; import org.elasticsearch.cluster.routing.RoutingNodes; import org.elasticsearch.cluster.routing.RoutingTable; +import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.testng.annotations.Test; -import static org.elasticsearch.cluster.ClusterState.*; -import static org.elasticsearch.cluster.metadata.IndexMetaData.*; -import static org.elasticsearch.cluster.metadata.MetaData.*; -import static org.elasticsearch.cluster.node.DiscoveryNodes.*; -import static org.elasticsearch.cluster.routing.RoutingBuilders.*; +import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; +import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder; +import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; +import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; +import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable; +import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.nullValue; /** - * @author kimchy (shay.banon) + * */ public class RebalanceAfterActiveTests { private final ESLogger logger = Loggers.getLogger(RebalanceAfterActiveTests.class); - @Test public void testRebalanceOnlyAfterAllShardsAreActive() { + @Test + public void testRebalanceOnlyAfterAllShardsAreActive() { AllocationService strategy = new AllocationService(settingsBuilder() .put("cluster.routing.allocation.concurrent_recoveries", 10) .put("cluster.routing.allocation.allow_rebalance", "always") diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/ReplicaAllocatedAfterPrimaryTests.java b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/ReplicaAllocatedAfterPrimaryTests.java similarity index 83% rename from src/test/java/org/elasticsearch/cluster/routing/allocation/ReplicaAllocatedAfterPrimaryTests.java rename to src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/ReplicaAllocatedAfterPrimaryTests.java index d48f8a3e135..1c1f8734f0d 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/ReplicaAllocatedAfterPrimaryTests.java +++ b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/ReplicaAllocatedAfterPrimaryTests.java @@ -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 @@ -17,35 +17,39 @@ * under the License. */ -package org.elasticsearch.cluster.routing.allocation; +package org.elasticsearch.test.unit.cluster.routing.allocation; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.routing.RoutingNodes; import org.elasticsearch.cluster.routing.RoutingTable; +import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.testng.annotations.Test; -import static org.elasticsearch.cluster.ClusterState.*; -import static org.elasticsearch.cluster.metadata.IndexMetaData.*; -import static org.elasticsearch.cluster.metadata.MetaData.*; -import static org.elasticsearch.cluster.node.DiscoveryNodes.*; -import static org.elasticsearch.cluster.routing.RoutingBuilders.*; +import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; +import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder; +import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; +import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; +import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable; +import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.nullValue; /** - * @author kimchy (shay.banon) + * */ public class ReplicaAllocatedAfterPrimaryTests { private final ESLogger logger = Loggers.getLogger(ReplicaAllocatedAfterPrimaryTests.class); - @Test public void testBackupIsAllocatedAfterPrimary() { + @Test + public void testBackupIsAllocatedAfterPrimary() { AllocationService strategy = new AllocationService(settingsBuilder().put("cluster.routing.allocation.concurrent_recoveries", 10).build()); logger.info("Building initial routing table"); diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/RoutingAllocationTests.java b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/RoutingAllocationTests.java similarity index 86% rename from src/test/java/org/elasticsearch/cluster/routing/allocation/RoutingAllocationTests.java rename to src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/RoutingAllocationTests.java index 314df22ba72..dbb8cd31225 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/RoutingAllocationTests.java +++ b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/RoutingAllocationTests.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.cluster.routing.allocation; +package org.elasticsearch.test.unit.cluster.routing.allocation; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.transport.DummyTransportAddress; diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardVersioningTests.java b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/ShardVersioningTests.java similarity index 85% rename from src/test/java/org/elasticsearch/cluster/routing/allocation/ShardVersioningTests.java rename to src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/ShardVersioningTests.java index b9b4ae89d01..3d4b3230f87 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardVersioningTests.java +++ b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/ShardVersioningTests.java @@ -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 @@ -17,34 +17,37 @@ * under the License. */ -package org.elasticsearch.cluster.routing.allocation; +package org.elasticsearch.test.unit.cluster.routing.allocation; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.routing.RoutingNodes; import org.elasticsearch.cluster.routing.RoutingTable; +import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllocationDecider; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.testng.annotations.Test; -import static org.elasticsearch.cluster.ClusterState.*; -import static org.elasticsearch.cluster.metadata.IndexMetaData.*; -import static org.elasticsearch.cluster.metadata.MetaData.*; -import static org.elasticsearch.cluster.node.DiscoveryNodes.*; -import static org.elasticsearch.cluster.routing.RoutingBuilders.*; +import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; +import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder; +import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; +import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; +import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable; +import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; @Test public class ShardVersioningTests { private final ESLogger logger = Loggers.getLogger(ShardVersioningTests.class); - @Test public void simple() { + @Test + public void simple() { AllocationService strategy = new AllocationService(settingsBuilder().put("cluster.routing.allocation.allow_rebalance", ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString()).build()); MetaData metaData = newMetaDataBuilder() diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/SingleShardNoReplicasRoutingTests.java b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/SingleShardNoReplicasRoutingTests.java similarity index 92% rename from src/test/java/org/elasticsearch/cluster/routing/allocation/SingleShardNoReplicasRoutingTests.java rename to src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/SingleShardNoReplicasRoutingTests.java index d9e0583b936..68382848324 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/SingleShardNoReplicasRoutingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/SingleShardNoReplicasRoutingTests.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.cluster.routing.allocation; +package org.elasticsearch.test.unit.cluster.routing.allocation; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.MetaData; @@ -27,6 +27,7 @@ import org.elasticsearch.cluster.routing.MutableShardRouting; import org.elasticsearch.cluster.routing.RoutingNode; import org.elasticsearch.cluster.routing.RoutingNodes; import org.elasticsearch.cluster.routing.RoutingTable; +import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.testng.annotations.Test; @@ -34,27 +35,29 @@ import org.testng.annotations.Test; import java.util.List; import java.util.Set; -import static org.elasticsearch.cluster.ClusterState.*; -import static org.elasticsearch.cluster.metadata.IndexMetaData.*; -import static org.elasticsearch.cluster.metadata.MetaData.*; -import static org.elasticsearch.cluster.node.DiscoveryNodes.*; -import static org.elasticsearch.cluster.routing.RoutingBuilders.*; +import static com.google.common.collect.Lists.newArrayList; +import static com.google.common.collect.Sets.newHashSet; +import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; +import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder; +import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; +import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; +import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable; +import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.*; -import static org.elasticsearch.common.collect.Lists.*; -import static org.elasticsearch.common.collect.Sets.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.hamcrest.MatcherAssert.*; +import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** - * @author kimchy (shay.banon) + * */ public class SingleShardNoReplicasRoutingTests { private final ESLogger logger = Loggers.getLogger(SingleShardNoReplicasRoutingTests.class); - @Test public void testSingleIndexStartedShard() { + @Test + public void testSingleIndexStartedShard() { AllocationService strategy = new AllocationService(settingsBuilder().put("cluster.routing.allocation.concurrent_recoveries", 10).build()); logger.info("Building initial routing table"); @@ -76,7 +79,7 @@ public class SingleShardNoReplicasRoutingTests { assertThat(routingTable.index("test").shard(0).shards().get(0).currentNodeId(), nullValue()); logger.info("Adding one node and performing rerouting"); - clusterState = newClusterStateBuilder().state(clusterState).nodes(newNodesBuilder().put(newNode("node1"))).build(); + clusterState = newClusterStateBuilder().state(clusterState).nodes(newNodesBuilder().put(RoutingAllocationTests.newNode("node1"))).build(); RoutingTable prevRoutingTable = routingTable; routingTable = strategy.reroute(clusterState).routingTable(); clusterState = newClusterStateBuilder().state(clusterState).routingTable(routingTable).build(); @@ -108,7 +111,7 @@ public class SingleShardNoReplicasRoutingTests { assertThat(routingTable.index("test").shard(0).shards().get(0).currentNodeId(), equalTo("node1")); logger.info("Starting another node and making sure nothing changed"); - clusterState = newClusterStateBuilder().state(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes()).put(newNode("node2"))).build(); + clusterState = newClusterStateBuilder().state(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes()).put(RoutingAllocationTests.newNode("node2"))).build(); prevRoutingTable = routingTable; routingTable = strategy.reroute(clusterState).routingTable(); clusterState = newClusterStateBuilder().state(clusterState).routingTable(routingTable).build(); @@ -135,7 +138,7 @@ public class SingleShardNoReplicasRoutingTests { assertThat(routingTable.index("test").shard(0).shards().get(0).currentNodeId(), equalTo("node2")); logger.info("Start another node, make sure that things remain the same (shard is in node2 and initializing)"); - clusterState = newClusterStateBuilder().state(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes()).put(newNode("node3"))).build(); + clusterState = newClusterStateBuilder().state(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes()).put(RoutingAllocationTests.newNode("node3"))).build(); prevRoutingTable = routingTable; routingTable = strategy.reroute(clusterState).routingTable(); clusterState = newClusterStateBuilder().state(clusterState).routingTable(routingTable).build(); @@ -155,7 +158,8 @@ public class SingleShardNoReplicasRoutingTests { assertThat(routingTable.index("test").shard(0).shards().get(0).currentNodeId(), equalTo("node2")); } - @Test public void testSingleIndexShardFailed() { + @Test + public void testSingleIndexShardFailed() { AllocationService strategy = new AllocationService(settingsBuilder().put("cluster.routing.allocation.concurrent_recoveries", 10).build()); logger.info("Building initial routing table"); @@ -177,7 +181,7 @@ public class SingleShardNoReplicasRoutingTests { assertThat(routingTable.index("test").shard(0).shards().get(0).currentNodeId(), nullValue()); logger.info("Adding one node and rerouting"); - clusterState = newClusterStateBuilder().state(clusterState).nodes(newNodesBuilder().put(newNode("node1"))).build(); + clusterState = newClusterStateBuilder().state(clusterState).nodes(newNodesBuilder().put(RoutingAllocationTests.newNode("node1"))).build(); RoutingTable prevRoutingTable = routingTable; routingTable = strategy.reroute(clusterState).routingTable(); clusterState = newClusterStateBuilder().state(clusterState).routingTable(routingTable).build(); @@ -204,7 +208,8 @@ public class SingleShardNoReplicasRoutingTests { assertThat(routingTable.index("test").shard(0).shards().get(0).currentNodeId(), nullValue()); } - @Test public void testMultiIndexEvenDistribution() { + @Test + public void testMultiIndexEvenDistribution() { AllocationService strategy = new AllocationService(settingsBuilder() .put("cluster.routing.allocation.concurrent_recoveries", 10) .put("cluster.routing.allocation.allow_rebalance", "always") @@ -240,7 +245,7 @@ public class SingleShardNoReplicasRoutingTests { DiscoveryNodes.Builder nodesBuilder = newNodesBuilder(); List nodes = newArrayList(); for (int i = 0; i < (numberOfIndices / 2); i++) { - nodesBuilder.put(newNode("node" + i)); + nodesBuilder.put(RoutingAllocationTests.newNode("node" + i)); } RoutingTable prevRoutingTable = routingTable; clusterState = newClusterStateBuilder().state(clusterState).nodes(nodesBuilder).build(); @@ -278,7 +283,7 @@ public class SingleShardNoReplicasRoutingTests { logger.info("Adding additional " + (numberOfIndices / 2) + " nodes, nothing should change"); nodesBuilder = newNodesBuilder().putAll(clusterState.nodes()); for (int i = (numberOfIndices / 2); i < numberOfIndices; i++) { - nodesBuilder.put(newNode("node" + i)); + nodesBuilder.put(RoutingAllocationTests.newNode("node" + i)); } prevRoutingTable = routingTable; clusterState = newClusterStateBuilder().state(clusterState).nodes(nodesBuilder).build(); @@ -316,7 +321,8 @@ public class SingleShardNoReplicasRoutingTests { assertThat(numberOfStartedShards, equalTo(25)); } - @Test public void testMultiIndexUnevenNodes() { + @Test + public void testMultiIndexUnevenNodes() { AllocationService strategy = new AllocationService(settingsBuilder() .put("cluster.routing.allocation.concurrent_recoveries", 10) .put("cluster.routing.allocation.allow_rebalance", "always") @@ -344,7 +350,7 @@ public class SingleShardNoReplicasRoutingTests { logger.info("Starting 3 nodes and rerouting"); clusterState = newClusterStateBuilder().state(clusterState) - .nodes(newNodesBuilder().put(newNode("node1")).put(newNode("node2")).put(newNode("node3"))) + .nodes(newNodesBuilder().put(RoutingAllocationTests.newNode("node1")).put(RoutingAllocationTests.newNode("node2")).put(RoutingAllocationTests.newNode("node3"))) .build(); RoutingTable prevRoutingTable = routingTable; routingTable = strategy.reroute(clusterState).routingTable(); @@ -365,7 +371,7 @@ public class SingleShardNoReplicasRoutingTests { logger.info("Start two more nodes, things should remain the same"); clusterState = newClusterStateBuilder().state(clusterState) - .nodes(newNodesBuilder().putAll(clusterState.nodes()).put(newNode("node4")).put(newNode("node5"))) + .nodes(newNodesBuilder().putAll(clusterState.nodes()).put(RoutingAllocationTests.newNode("node4")).put(RoutingAllocationTests.newNode("node5"))) .build(); clusterState = newClusterStateBuilder().state(clusterState).routingTable(routingTable).build(); diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/SingleShardOneReplicaRoutingTests.java b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/SingleShardOneReplicaRoutingTests.java similarity index 90% rename from src/test/java/org/elasticsearch/cluster/routing/allocation/SingleShardOneReplicaRoutingTests.java rename to src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/SingleShardOneReplicaRoutingTests.java index 0093a3929f8..eb37719c016 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/SingleShardOneReplicaRoutingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/SingleShardOneReplicaRoutingTests.java @@ -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 @@ -17,35 +17,39 @@ * under the License. */ -package org.elasticsearch.cluster.routing.allocation; +package org.elasticsearch.test.unit.cluster.routing.allocation; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.routing.RoutingNodes; import org.elasticsearch.cluster.routing.RoutingTable; +import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.testng.annotations.Test; -import static org.elasticsearch.cluster.ClusterState.*; -import static org.elasticsearch.cluster.metadata.IndexMetaData.*; -import static org.elasticsearch.cluster.metadata.MetaData.*; -import static org.elasticsearch.cluster.node.DiscoveryNodes.*; -import static org.elasticsearch.cluster.routing.RoutingBuilders.*; +import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; +import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder; +import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; +import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; +import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable; +import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.nullValue; /** - * @author kimchy (shay.banon) + * */ public class SingleShardOneReplicaRoutingTests { private final ESLogger logger = Loggers.getLogger(SingleShardOneReplicaRoutingTests.class); - @Test public void testSingleIndexFirstStartPrimaryThenBackups() { + @Test + public void testSingleIndexFirstStartPrimaryThenBackups() { AllocationService strategy = new AllocationService(settingsBuilder().put("cluster.routing.allocation.concurrent_recoveries", 10).build()); logger.info("Building initial routing table"); diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/TenShardsOneReplicaRoutingTests.java b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/TenShardsOneReplicaRoutingTests.java similarity index 91% rename from src/test/java/org/elasticsearch/cluster/routing/allocation/TenShardsOneReplicaRoutingTests.java rename to src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/TenShardsOneReplicaRoutingTests.java index 5e4aefc7e1c..bce14c62b18 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/TenShardsOneReplicaRoutingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/TenShardsOneReplicaRoutingTests.java @@ -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 @@ -17,35 +17,38 @@ * under the License. */ -package org.elasticsearch.cluster.routing.allocation; +package org.elasticsearch.test.unit.cluster.routing.allocation; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.routing.RoutingNodes; import org.elasticsearch.cluster.routing.RoutingTable; +import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.testng.annotations.Test; -import static org.elasticsearch.cluster.ClusterState.*; -import static org.elasticsearch.cluster.metadata.IndexMetaData.*; -import static org.elasticsearch.cluster.metadata.MetaData.*; -import static org.elasticsearch.cluster.node.DiscoveryNodes.*; -import static org.elasticsearch.cluster.routing.RoutingBuilders.*; +import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; +import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder; +import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; +import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; +import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable; +import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.hamcrest.MatcherAssert.*; +import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** - * @author kimchy (shay.banon) + * */ public class TenShardsOneReplicaRoutingTests { private final ESLogger logger = Loggers.getLogger(TenShardsOneReplicaRoutingTests.class); - @Test public void testSingleIndexFirstStartPrimaryThenBackups() { + @Test + public void testSingleIndexFirstStartPrimaryThenBackups() { AllocationService strategy = new AllocationService(settingsBuilder() .put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_initial_primaries_recoveries", 10) diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/ThrottlingAllocationTests.java b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/ThrottlingAllocationTests.java similarity index 87% rename from src/test/java/org/elasticsearch/cluster/routing/allocation/ThrottlingAllocationTests.java rename to src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/ThrottlingAllocationTests.java index d91cc6b11f1..27b4dc2c5b8 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/ThrottlingAllocationTests.java +++ b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/ThrottlingAllocationTests.java @@ -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 @@ -17,34 +17,37 @@ * under the License. */ -package org.elasticsearch.cluster.routing.allocation; +package org.elasticsearch.test.unit.cluster.routing.allocation; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.routing.RoutingTable; +import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.testng.annotations.Test; -import static org.elasticsearch.cluster.ClusterState.*; -import static org.elasticsearch.cluster.metadata.IndexMetaData.*; -import static org.elasticsearch.cluster.metadata.MetaData.*; -import static org.elasticsearch.cluster.node.DiscoveryNodes.*; -import static org.elasticsearch.cluster.routing.RoutingBuilders.*; +import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; +import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder; +import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; +import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; +import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable; +import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class ThrottlingAllocationTests { private final ESLogger logger = Loggers.getLogger(ThrottlingAllocationTests.class); - @Test public void testPrimaryRecoveryThrottling() { + @Test + public void testPrimaryRecoveryThrottling() { AllocationService strategy = new AllocationService(settingsBuilder() .put("cluster.routing.allocation.node_concurrent_recoveries", 3) .put("cluster.routing.allocation.node_initial_primaries_recoveries", 3) @@ -63,7 +66,7 @@ public class ThrottlingAllocationTests { ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build(); logger.info("start one node, do reroute, only 3 should initialize"); - clusterState = newClusterStateBuilder().state(clusterState).nodes(newNodesBuilder().put(newNode("node1"))).build(); + clusterState = newClusterStateBuilder().state(clusterState).nodes(newNodesBuilder().put(RoutingAllocationTests.newNode("node1"))).build(); routingTable = strategy.reroute(clusterState).routingTable(); clusterState = newClusterStateBuilder().state(clusterState).routingTable(routingTable).build(); @@ -104,7 +107,8 @@ public class ThrottlingAllocationTests { assertThat(routingTable.shardsWithState(UNASSIGNED).size(), equalTo(10)); } - @Test public void testReplicaAndPrimaryRecoveryThrottling() { + @Test + public void testReplicaAndPrimaryRecoveryThrottling() { AllocationService strategy = new AllocationService(settingsBuilder() .put("cluster.routing.allocation.concurrent_recoveries", 3) .put("cluster.routing.allocation.node_initial_primaries_recoveries", 3) @@ -123,7 +127,7 @@ public class ThrottlingAllocationTests { ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build(); logger.info("start one node, do reroute, only 3 should initialize"); - clusterState = newClusterStateBuilder().state(clusterState).nodes(newNodesBuilder().put(newNode("node1"))).build(); + clusterState = newClusterStateBuilder().state(clusterState).nodes(newNodesBuilder().put(RoutingAllocationTests.newNode("node1"))).build(); routingTable = strategy.reroute(clusterState).routingTable(); clusterState = newClusterStateBuilder().state(clusterState).routingTable(routingTable).build(); @@ -148,7 +152,7 @@ public class ThrottlingAllocationTests { assertThat(routingTable.shardsWithState(UNASSIGNED).size(), equalTo(5)); logger.info("start another node, replicas should start being allocated"); - clusterState = newClusterStateBuilder().state(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes()).put(newNode("node2"))).build(); + clusterState = newClusterStateBuilder().state(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes()).put(RoutingAllocationTests.newNode("node2"))).build(); routingTable = strategy.reroute(clusterState).routingTable(); clusterState = newClusterStateBuilder().state(clusterState).routingTable(routingTable).build(); diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/UpdateNumberOfReplicasTests.java b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/UpdateNumberOfReplicasTests.java similarity index 92% rename from src/test/java/org/elasticsearch/cluster/routing/allocation/UpdateNumberOfReplicasTests.java rename to src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/UpdateNumberOfReplicasTests.java index eaf3bd87ca9..9aab5b9304f 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/UpdateNumberOfReplicasTests.java +++ b/src/test/java/org/elasticsearch/test/unit/cluster/routing/allocation/UpdateNumberOfReplicasTests.java @@ -1,32 +1,35 @@ -package org.elasticsearch.cluster.routing.allocation; +package org.elasticsearch.test.unit.cluster.routing.allocation; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.routing.RoutingNodes; import org.elasticsearch.cluster.routing.RoutingTable; +import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.testng.annotations.Test; -import static org.elasticsearch.cluster.ClusterState.*; -import static org.elasticsearch.cluster.metadata.IndexMetaData.*; -import static org.elasticsearch.cluster.metadata.MetaData.*; -import static org.elasticsearch.cluster.node.DiscoveryNodes.*; -import static org.elasticsearch.cluster.routing.RoutingBuilders.*; +import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; +import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder; +import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; +import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; +import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable; +import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.hamcrest.MatcherAssert.*; +import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** - * @author kimchy (shay.banon) + * */ public class UpdateNumberOfReplicasTests { private final ESLogger logger = Loggers.getLogger(UpdateNumberOfReplicasTests.class); - @Test public void testUpdateNumberOfReplicas() { + @Test + public void testUpdateNumberOfReplicas() { AllocationService strategy = new AllocationService(settingsBuilder().put("cluster.routing.allocation.concurrent_recoveries", 10).build()); logger.info("Building initial routing table"); diff --git a/src/test/java/org/elasticsearch/cluster/serialization/ClusterSerializationTests.java b/src/test/java/org/elasticsearch/test/unit/cluster/serialization/ClusterSerializationTests.java similarity index 82% rename from src/test/java/org/elasticsearch/cluster/serialization/ClusterSerializationTests.java rename to src/test/java/org/elasticsearch/test/unit/cluster/serialization/ClusterSerializationTests.java index 30535619e33..8d8fda75987 100644 --- a/src/test/java/org/elasticsearch/cluster/serialization/ClusterSerializationTests.java +++ b/src/test/java/org/elasticsearch/test/unit/cluster/serialization/ClusterSerializationTests.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.cluster.serialization; +package org.elasticsearch.test.unit.cluster.serialization; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.MetaData; @@ -30,19 +30,21 @@ import org.elasticsearch.common.io.stream.BytesStreamOutput; import org.elasticsearch.common.transport.DummyTransportAddress; import org.testng.annotations.Test; -import static org.elasticsearch.cluster.ClusterState.*; -import static org.elasticsearch.cluster.metadata.IndexMetaData.*; -import static org.elasticsearch.cluster.metadata.MetaData.*; -import static org.elasticsearch.cluster.routing.RoutingBuilders.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; +import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder; +import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; +import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable; +import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (Shay Banon) + * */ public class ClusterSerializationTests { - @Test public void testClusterStateSerialization() throws Exception { + @Test + public void testClusterStateSerialization() throws Exception { MetaData metaData = newMetaDataBuilder() .put(newIndexMetaDataBuilder("test").numberOfShards(10).numberOfReplicas(1)) .build(); @@ -64,7 +66,8 @@ public class ClusterSerializationTests { } - @Test public void testRoutingTableSerialization() throws Exception { + @Test + public void testRoutingTableSerialization() throws Exception { MetaData metaData = newMetaDataBuilder() .put(newIndexMetaDataBuilder("test").numberOfShards(10).numberOfReplicas(1)) .build(); diff --git a/src/test/java/org/elasticsearch/cluster/structure/RoutingIteratorTests.java b/src/test/java/org/elasticsearch/test/unit/cluster/structure/RoutingIteratorTests.java similarity index 91% rename from src/test/java/org/elasticsearch/cluster/structure/RoutingIteratorTests.java rename to src/test/java/org/elasticsearch/test/unit/cluster/structure/RoutingIteratorTests.java index 146599633d5..ff546d6e981 100644 --- a/src/test/java/org/elasticsearch/cluster/structure/RoutingIteratorTests.java +++ b/src/test/java/org/elasticsearch/test/unit/cluster/structure/RoutingIteratorTests.java @@ -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 @@ -17,8 +17,10 @@ * under the License. */ -package org.elasticsearch.cluster.structure; +package org.elasticsearch.test.unit.cluster.structure; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.routing.PlainShardIterator; @@ -26,26 +28,27 @@ import org.elasticsearch.cluster.routing.RoutingTable; import org.elasticsearch.cluster.routing.ShardIterator; import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.cluster.routing.allocation.AllocationService; -import org.elasticsearch.common.collect.ImmutableList; -import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.index.shard.ShardId; +import org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests; import org.testng.annotations.Test; -import static org.elasticsearch.cluster.ClusterState.*; -import static org.elasticsearch.cluster.metadata.IndexMetaData.*; -import static org.elasticsearch.cluster.metadata.MetaData.*; -import static org.elasticsearch.cluster.node.DiscoveryNodes.*; -import static org.elasticsearch.cluster.routing.RoutingBuilders.*; -import static org.elasticsearch.cluster.routing.ShardRoutingState.*; -import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.*; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.hamcrest.MatcherAssert.*; +import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; +import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder; +import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder; +import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder; +import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTable; +import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable; +import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; +import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; @Test public class RoutingIteratorTests { - @Test public void testEmptyIterator() { + @Test + public void testEmptyIterator() { ShardIterator shardIterator = new PlainShardIterator(new ShardId("test1", 0), ImmutableList.of(), 0); assertThat(shardIterator.remaining(), equalTo(0)); assertThat(shardIterator.firstOrNull(), nullValue()); @@ -83,7 +86,8 @@ public class RoutingIteratorTests { assertThat(shardIterator.remaining(), equalTo(0)); } - @Test public void testIterator1() { + @Test + public void testIterator1() { MetaData metaData = newMetaDataBuilder() .put(newIndexMetaDataBuilder("test1").numberOfShards(1).numberOfReplicas(2)) .build(); @@ -116,7 +120,8 @@ public class RoutingIteratorTests { assertThat(shardIterator.remaining(), equalTo(0)); } - @Test public void testIterator2() { + @Test + public void testIterator2() { MetaData metaData = newMetaDataBuilder() .put(newIndexMetaDataBuilder("test1").numberOfShards(1).numberOfReplicas(1)) .put(newIndexMetaDataBuilder("test2").numberOfShards(1).numberOfReplicas(1)) @@ -218,7 +223,8 @@ public class RoutingIteratorTests { assertThat(shardRouting10, sameInstance(shardRouting6)); } - @Test public void testRandomRouting() { + @Test + public void testRandomRouting() { MetaData metaData = newMetaDataBuilder() .put(newIndexMetaDataBuilder("test1").numberOfShards(1).numberOfReplicas(1)) .put(newIndexMetaDataBuilder("test2").numberOfShards(1).numberOfReplicas(1)) @@ -245,7 +251,8 @@ public class RoutingIteratorTests { assertThat(shardRouting1, sameInstance(shardRouting3)); } - @Test public void testAttributePreferenceRouting() { + @Test + public void testAttributePreferenceRouting() { AllocationService strategy = new AllocationService(settingsBuilder() .put("cluster.routing.allocation.concurrent_recoveries", 10) .put("cluster.routing.allocation.allow_rebalance", "always") @@ -263,8 +270,8 @@ public class RoutingIteratorTests { ClusterState clusterState = newClusterStateBuilder().metaData(metaData).routingTable(routingTable).build(); clusterState = newClusterStateBuilder().state(clusterState).nodes(newNodesBuilder() - .put(newNode("node1", ImmutableMap.of("rack_id", "rack_1", "zone", "zone1"))) - .put(newNode("node2", ImmutableMap.of("rack_id", "rack_2", "zone", "zone2"))) + .put(RoutingAllocationTests.newNode("node1", ImmutableMap.of("rack_id", "rack_1", "zone", "zone1"))) + .put(RoutingAllocationTests.newNode("node2", ImmutableMap.of("rack_id", "rack_2", "zone", "zone2"))) .localNodeId("node1") ).build(); routingTable = strategy.reroute(clusterState).routingTable(); diff --git a/src/test/java/org/elasticsearch/common/bloom/BoomFilterTests.java b/src/test/java/org/elasticsearch/test/unit/common/bloom/BoomFilterTests.java similarity index 80% rename from src/test/java/org/elasticsearch/common/bloom/BoomFilterTests.java rename to src/test/java/org/elasticsearch/test/unit/common/bloom/BoomFilterTests.java index 18a50466a3e..a5f6b359f3b 100644 --- a/src/test/java/org/elasticsearch/common/bloom/BoomFilterTests.java +++ b/src/test/java/org/elasticsearch/test/unit/common/bloom/BoomFilterTests.java @@ -17,23 +17,26 @@ * under the License. */ -package org.elasticsearch.common.bloom; +package org.elasticsearch.test.unit.common.bloom; -import org.elasticsearch.common.base.Charsets; +import com.google.common.base.Charsets; +import org.elasticsearch.common.bloom.BloomFilter; +import org.elasticsearch.common.bloom.BloomFilterFactory; import org.testng.annotations.Test; import java.nio.ByteBuffer; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ @Test public class BoomFilterTests { - @Test public void testSimpleOps() { + @Test + public void testSimpleOps() { BloomFilter filter = BloomFilterFactory.getFilter(10, 15); filter.add(wrap("1")); assertThat(filter.isPresent(wrap("1")), equalTo(true)); diff --git a/src/test/java/org/elasticsearch/common/compress/CompressedStringTests.java b/src/test/java/org/elasticsearch/test/unit/common/compress/CompressedStringTests.java similarity index 75% rename from src/test/java/org/elasticsearch/common/compress/CompressedStringTests.java rename to src/test/java/org/elasticsearch/test/unit/common/compress/CompressedStringTests.java index 363ae17d16a..7cbfea4aaf0 100644 --- a/src/test/java/org/elasticsearch/common/compress/CompressedStringTests.java +++ b/src/test/java/org/elasticsearch/test/unit/common/compress/CompressedStringTests.java @@ -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 @@ -17,21 +17,24 @@ * under the License. */ -package org.elasticsearch.common.compress; +package org.elasticsearch.test.unit.common.compress; +import org.elasticsearch.common.compress.CompressedString; import org.testng.annotations.Test; import java.io.IOException; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.not; /** - * @author kimchy (shay.banon) + * */ public class CompressedStringTests { - @Test public void simpleTests() throws IOException { + @Test + public void simpleTests() throws IOException { String str = "this is a simple string"; CompressedString cstr = new CompressedString(str); assertThat(cstr.string(), equalTo(str)); diff --git a/src/test/java/org/elasticsearch/common/io/StreamsTests.java b/src/test/java/org/elasticsearch/test/unit/common/io/StreamsTests.java similarity index 76% rename from src/test/java/org/elasticsearch/common/io/StreamsTests.java rename to src/test/java/org/elasticsearch/test/unit/common/io/StreamsTests.java index 3de7beb8a5c..864820b31ae 100644 --- a/src/test/java/org/elasticsearch/common/io/StreamsTests.java +++ b/src/test/java/org/elasticsearch/test/unit/common/io/StreamsTests.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.common.io; +package org.elasticsearch.test.unit.common.io; import org.testng.annotations.Test; @@ -25,17 +25,18 @@ import java.io.*; import java.util.Arrays; import static org.elasticsearch.common.io.Streams.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * Unit tests for {@link Streams}. + * Unit tests for {@link org.elasticsearch.common.io.Streams}. + * * - * @author kimchy (Shay Banon) */ public class StreamsTests { - @Test public void testCopyFromInputStream() throws IOException { + @Test + public void testCopyFromInputStream() throws IOException { byte[] content = "content".getBytes(); ByteArrayInputStream in = new ByteArrayInputStream(content); ByteArrayOutputStream out = new ByteArrayOutputStream(content.length); @@ -45,21 +46,24 @@ public class StreamsTests { assertThat(Arrays.equals(content, out.toByteArray()), equalTo(true)); } - @Test public void testCopyFromByteArray() throws IOException { + @Test + public void testCopyFromByteArray() throws IOException { byte[] content = "content".getBytes(); ByteArrayOutputStream out = new ByteArrayOutputStream(content.length); copy(content, out); assertThat(Arrays.equals(content, out.toByteArray()), equalTo(true)); } - @Test public void testCopyToByteArray() throws IOException { + @Test + public void testCopyToByteArray() throws IOException { byte[] content = "content".getBytes(); ByteArrayInputStream in = new ByteArrayInputStream(content); byte[] result = copyToByteArray(in); assertThat(Arrays.equals(content, result), equalTo(true)); } - @Test public void testCopyFromReader() throws IOException { + @Test + public void testCopyFromReader() throws IOException { String content = "content"; StringReader in = new StringReader(content); StringWriter out = new StringWriter(); @@ -68,14 +72,16 @@ public class StreamsTests { assertThat(out.toString(), equalTo(content)); } - @Test public void testCopyFromString() throws IOException { + @Test + public void testCopyFromString() throws IOException { String content = "content"; StringWriter out = new StringWriter(); copy(content, out); assertThat(out.toString(), equalTo(content)); } - @Test public void testCopyToString() throws IOException { + @Test + public void testCopyToString() throws IOException { String content = "content"; StringReader in = new StringReader(content); String result = copyToString(in); diff --git a/src/test/java/org/elasticsearch/common/io/streams/BytesStreamsTests.java b/src/test/java/org/elasticsearch/test/unit/common/io/streams/BytesStreamsTests.java similarity index 84% rename from src/test/java/org/elasticsearch/common/io/streams/BytesStreamsTests.java rename to src/test/java/org/elasticsearch/test/unit/common/io/streams/BytesStreamsTests.java index 9d960ab4109..9222b328750 100644 --- a/src/test/java/org/elasticsearch/common/io/streams/BytesStreamsTests.java +++ b/src/test/java/org/elasticsearch/test/unit/common/io/streams/BytesStreamsTests.java @@ -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 @@ -17,23 +17,25 @@ * under the License. */ -package org.elasticsearch.common.io.streams; +package org.elasticsearch.test.unit.common.io.streams; import org.elasticsearch.common.io.stream.BytesStreamInput; import org.elasticsearch.common.io.stream.BytesStreamOutput; import org.elasticsearch.common.io.stream.CachedStreamOutput; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.closeTo; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ @Test public class BytesStreamsTests { - @Test public void testSimpleStreams() throws Exception { + @Test + public void testSimpleStreams() throws Exception { BytesStreamOutput out = CachedStreamOutput.popEntry().cachedBytes(); out.writeBoolean(false); out.writeByte((byte) 1); diff --git a/src/test/java/org/elasticsearch/common/io/streams/HandlesStreamsTests.java b/src/test/java/org/elasticsearch/test/unit/common/io/streams/HandlesStreamsTests.java similarity index 85% rename from src/test/java/org/elasticsearch/common/io/streams/HandlesStreamsTests.java rename to src/test/java/org/elasticsearch/test/unit/common/io/streams/HandlesStreamsTests.java index ad3add72790..f7b33789936 100644 --- a/src/test/java/org/elasticsearch/common/io/streams/HandlesStreamsTests.java +++ b/src/test/java/org/elasticsearch/test/unit/common/io/streams/HandlesStreamsTests.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.common.io.streams; +package org.elasticsearch.test.unit.common.io.streams; import org.elasticsearch.common.io.stream.BytesStreamInput; import org.elasticsearch.common.io.stream.BytesStreamOutput; @@ -25,16 +25,17 @@ import org.elasticsearch.common.io.stream.HandlesStreamInput; import org.elasticsearch.common.io.stream.HandlesStreamOutput; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ @Test public class HandlesStreamsTests { - @Test public void testSharedUTFHandles() throws Exception { + @Test + public void testSharedUTFHandles() throws Exception { BytesStreamOutput bytesOut = new BytesStreamOutput(); HandlesStreamOutput out = new HandlesStreamOutput(bytesOut, 5); String lowerThresholdValue = "test"; diff --git a/src/test/java/org/elasticsearch/common/lucene/all/SimpleAllTests.java b/src/test/java/org/elasticsearch/test/unit/common/lucene/all/SimpleAllTests.java similarity index 92% rename from src/test/java/org/elasticsearch/common/lucene/all/SimpleAllTests.java rename to src/test/java/org/elasticsearch/test/unit/common/lucene/all/SimpleAllTests.java index ad4862f94b0..ff4ade9d346 100644 --- a/src/test/java/org/elasticsearch/common/lucene/all/SimpleAllTests.java +++ b/src/test/java/org/elasticsearch/test/unit/common/lucene/all/SimpleAllTests.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.common.lucene.all; +package org.elasticsearch.test.unit.common.lucene.all; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; @@ -30,20 +30,24 @@ import org.apache.lucene.search.TopDocs; import org.apache.lucene.store.Directory; import org.apache.lucene.store.RAMDirectory; import org.elasticsearch.common.lucene.Lucene; +import org.elasticsearch.common.lucene.all.AllEntries; +import org.elasticsearch.common.lucene.all.AllTermQuery; +import org.elasticsearch.common.lucene.all.AllTokenStream; import org.testng.annotations.Test; import java.io.IOException; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ @Test public class SimpleAllTests { - @Test public void testAllEntriesRead() throws Exception { + @Test + public void testAllEntriesRead() throws Exception { AllEntries allEntries = new AllEntries(); allEntries.addText("field1", "something", 1.0f); allEntries.addText("field2", "else", 1.0f); @@ -68,7 +72,8 @@ public class SimpleAllTests { return sb.toString(); } - @Test public void testSimpleAllNoBoost() throws Exception { + @Test + public void testSimpleAllNoBoost() throws Exception { Directory dir = new RAMDirectory(); IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER)); @@ -110,7 +115,8 @@ public class SimpleAllTests { indexWriter.close(); } - @Test public void testSimpleAllWithBoost() throws Exception { + @Test + public void testSimpleAllWithBoost() throws Exception { Directory dir = new RAMDirectory(); IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER)); @@ -153,7 +159,8 @@ public class SimpleAllTests { indexWriter.close(); } - @Test public void testMultipleTokensAllNoBoost() throws Exception { + @Test + public void testMultipleTokensAllNoBoost() throws Exception { Directory dir = new RAMDirectory(); IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER)); @@ -205,7 +212,8 @@ public class SimpleAllTests { indexWriter.close(); } - @Test public void testMultipleTokensAllWithBoost() throws Exception { + @Test + public void testMultipleTokensAllWithBoost() throws Exception { Directory dir = new RAMDirectory(); IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER)); diff --git a/src/test/java/org/elasticsearch/common/lucene/search/MatchAllDocsFilterTests.java b/src/test/java/org/elasticsearch/test/unit/common/lucene/search/MatchAllDocsFilterTests.java similarity index 78% rename from src/test/java/org/elasticsearch/common/lucene/search/MatchAllDocsFilterTests.java rename to src/test/java/org/elasticsearch/test/unit/common/lucene/search/MatchAllDocsFilterTests.java index cc4b4561f9b..653ff74c222 100644 --- a/src/test/java/org/elasticsearch/common/lucene/search/MatchAllDocsFilterTests.java +++ b/src/test/java/org/elasticsearch/test/unit/common/lucene/search/MatchAllDocsFilterTests.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.common.lucene.search; +package org.elasticsearch.test.unit.common.lucene.search; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexWriter; @@ -27,18 +27,21 @@ import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.store.Directory; import org.apache.lucene.store.RAMDirectory; import org.elasticsearch.common.lucene.Lucene; +import org.elasticsearch.common.lucene.search.Queries; import org.testng.annotations.Test; -import static org.elasticsearch.common.lucene.DocumentBuilder.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.lucene.DocumentBuilder.doc; +import static org.elasticsearch.common.lucene.DocumentBuilder.field; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class MatchAllDocsFilterTests { - @Test public void testMatchAllDocsFilter() throws Exception { + @Test + public void testMatchAllDocsFilter() throws Exception { Directory dir = new RAMDirectory(); IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER)); diff --git a/src/test/java/org/elasticsearch/common/lucene/search/MoreLikeThisQueryTests.java b/src/test/java/org/elasticsearch/test/unit/common/lucene/search/MoreLikeThisQueryTests.java similarity index 79% rename from src/test/java/org/elasticsearch/common/lucene/search/MoreLikeThisQueryTests.java rename to src/test/java/org/elasticsearch/test/unit/common/lucene/search/MoreLikeThisQueryTests.java index 3d3dba6d7b2..2d3be20896d 100644 --- a/src/test/java/org/elasticsearch/common/lucene/search/MoreLikeThisQueryTests.java +++ b/src/test/java/org/elasticsearch/test/unit/common/lucene/search/MoreLikeThisQueryTests.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.common.lucene.search; +package org.elasticsearch.test.unit.common.lucene.search; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexWriter; @@ -26,19 +26,22 @@ import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.store.Directory; import org.apache.lucene.store.RAMDirectory; import org.elasticsearch.common.lucene.Lucene; +import org.elasticsearch.common.lucene.search.MoreLikeThisQuery; import org.testng.annotations.Test; -import static org.elasticsearch.common.lucene.DocumentBuilder.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.lucene.DocumentBuilder.doc; +import static org.elasticsearch.common.lucene.DocumentBuilder.field; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ @Test public class MoreLikeThisQueryTests { - @Test public void testSimple() throws Exception { + @Test + public void testSimple() throws Exception { Directory dir = new RAMDirectory(); IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER)); indexWriter.commit(); diff --git a/src/test/java/org/elasticsearch/common/lucene/search/MultiPhrasePrefixQueryTests.java b/src/test/java/org/elasticsearch/test/unit/common/lucene/search/MultiPhrasePrefixQueryTests.java similarity index 85% rename from src/test/java/org/elasticsearch/common/lucene/search/MultiPhrasePrefixQueryTests.java rename to src/test/java/org/elasticsearch/test/unit/common/lucene/search/MultiPhrasePrefixQueryTests.java index e30595deed9..00433d581cb 100644 --- a/src/test/java/org/elasticsearch/common/lucene/search/MultiPhrasePrefixQueryTests.java +++ b/src/test/java/org/elasticsearch/test/unit/common/lucene/search/MultiPhrasePrefixQueryTests.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.common.lucene.search; +package org.elasticsearch.test.unit.common.lucene.search; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; @@ -28,15 +28,17 @@ import org.apache.lucene.index.Term; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.store.RAMDirectory; import org.elasticsearch.common.lucene.Lucene; +import org.elasticsearch.common.lucene.search.MultiPhrasePrefixQuery; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; @Test public class MultiPhrasePrefixQueryTests { - @Test public void simpleTests() throws Exception { + @Test + public void simpleTests() throws Exception { IndexWriter writer = new IndexWriter(new RAMDirectory(), new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER)); Document doc = new Document(); doc.add(new Field("field", "aaa bbb ccc ddd", Field.Store.NO, Field.Index.ANALYZED)); diff --git a/src/test/java/org/elasticsearch/common/lucene/store/InputStreamIndexInputTests.java b/src/test/java/org/elasticsearch/test/unit/common/lucene/store/InputStreamIndexInputTests.java similarity index 91% rename from src/test/java/org/elasticsearch/common/lucene/store/InputStreamIndexInputTests.java rename to src/test/java/org/elasticsearch/test/unit/common/lucene/store/InputStreamIndexInputTests.java index c4131f743b2..e88b542e141 100644 --- a/src/test/java/org/elasticsearch/common/lucene/store/InputStreamIndexInputTests.java +++ b/src/test/java/org/elasticsearch/test/unit/common/lucene/store/InputStreamIndexInputTests.java @@ -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 @@ -17,24 +17,27 @@ * under the License. */ -package org.elasticsearch.common.lucene.store; +package org.elasticsearch.test.unit.common.lucene.store; import org.apache.lucene.store.IndexInput; import org.apache.lucene.store.IndexOutput; import org.apache.lucene.store.RAMDirectory; +import org.elasticsearch.common.lucene.store.InputStreamIndexInput; import org.testng.annotations.Test; import java.io.IOException; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.lessThan; /** - * @author kimchy (shay.banon) + * */ public class InputStreamIndexInputTests { - @Test public void testSingleReadSingleByteLimit() throws IOException { + @Test + public void testSingleReadSingleByteLimit() throws IOException { RAMDirectory dir = new RAMDirectory(); IndexOutput output = dir.createOutput("test"); for (int i = 0; i < 3; i++) { @@ -70,7 +73,8 @@ public class InputStreamIndexInputTests { assertThat(is.read(), equalTo(-1)); } - @Test public void testReadMultiSingleByteLimit1() throws IOException { + @Test + public void testReadMultiSingleByteLimit1() throws IOException { RAMDirectory dir = new RAMDirectory(); IndexOutput output = dir.createOutput("test"); for (int i = 0; i < 3; i++) { @@ -108,7 +112,8 @@ public class InputStreamIndexInputTests { assertThat(is.read(read), equalTo(-1)); } - @Test public void testSingleReadTwoBytesLimit() throws IOException { + @Test + public void testSingleReadTwoBytesLimit() throws IOException { RAMDirectory dir = new RAMDirectory(); IndexOutput output = dir.createOutput("test"); for (int i = 0; i < 3; i++) { @@ -149,7 +154,8 @@ public class InputStreamIndexInputTests { assertThat(is.read(), equalTo(-1)); } - @Test public void testReadMultiTwoBytesLimit1() throws IOException { + @Test + public void testReadMultiTwoBytesLimit1() throws IOException { RAMDirectory dir = new RAMDirectory(); IndexOutput output = dir.createOutput("test"); for (int i = 0; i < 3; i++) { @@ -192,7 +198,8 @@ public class InputStreamIndexInputTests { assertThat(is.read(read), equalTo(-1)); } - @Test public void testReadMultiFourBytesLimit() throws IOException { + @Test + public void testReadMultiFourBytesLimit() throws IOException { RAMDirectory dir = new RAMDirectory(); IndexOutput output = dir.createOutput("test"); for (int i = 0; i < 3; i++) { diff --git a/src/test/java/org/elasticsearch/common/lucene/uid/UidFieldTests.java b/src/test/java/org/elasticsearch/test/unit/common/lucene/uid/UidFieldTests.java similarity index 87% rename from src/test/java/org/elasticsearch/common/lucene/uid/UidFieldTests.java rename to src/test/java/org/elasticsearch/test/unit/common/lucene/uid/UidFieldTests.java index 16c92a782a4..e406abfaf3f 100644 --- a/src/test/java/org/elasticsearch/common/lucene/uid/UidFieldTests.java +++ b/src/test/java/org/elasticsearch/test/unit/common/lucene/uid/UidFieldTests.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.common.lucene.uid; +package org.elasticsearch.test.unit.common.lucene.uid; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; @@ -27,21 +27,25 @@ import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.index.Term; import org.apache.lucene.store.RAMDirectory; import org.elasticsearch.common.lucene.Lucene; +import org.elasticsearch.common.lucene.uid.UidField; +import org.hamcrest.MatcherAssert; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.nullValue; /** - * @author kimchy (shay.banon) + * */ public class UidFieldTests { - @Test public void testUidField() throws Exception { + @Test + public void testUidField() throws Exception { IndexWriter writer = new IndexWriter(new RAMDirectory(), new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER)); IndexReader reader = IndexReader.open(writer, true); - assertThat(UidField.loadVersion(reader, new Term("_uid", "1")), equalTo(-1l)); + MatcherAssert.assertThat(UidField.loadVersion(reader, new Term("_uid", "1")), equalTo(-1l)); Document doc = new Document(); doc.add(new Field("_uid", "1", Field.Store.YES, Field.Index.NOT_ANALYZED)); diff --git a/src/test/java/org/elasticsearch/common/lucene/versioned/AbstractVersionedMapTests.java b/src/test/java/org/elasticsearch/test/unit/common/lucene/versioned/AbstractVersionedMapTests.java similarity index 82% rename from src/test/java/org/elasticsearch/common/lucene/versioned/AbstractVersionedMapTests.java rename to src/test/java/org/elasticsearch/test/unit/common/lucene/versioned/AbstractVersionedMapTests.java index 99cf3e25664..05522b7b83c 100644 --- a/src/test/java/org/elasticsearch/common/lucene/versioned/AbstractVersionedMapTests.java +++ b/src/test/java/org/elasticsearch/test/unit/common/lucene/versioned/AbstractVersionedMapTests.java @@ -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 @@ -17,21 +17,23 @@ * under the License. */ -package org.elasticsearch.common.lucene.versioned; +package org.elasticsearch.test.unit.common.lucene.versioned; +import org.elasticsearch.common.lucene.versioned.VersionedMap; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (Shay Banon) + * */ public abstract class AbstractVersionedMapTests { protected abstract VersionedMap create(); - @Test public void testSimple() { + @Test + public void testSimple() { VersionedMap versionedMap = create(); assertThat(true, equalTo(versionedMap.beforeVersion(1, 1))); diff --git a/src/test/java/org/elasticsearch/common/lucene/versioned/NativeVersionedMapTests.java b/src/test/java/org/elasticsearch/test/unit/common/lucene/versioned/NativeVersionedMapTests.java similarity index 69% rename from src/test/java/org/elasticsearch/common/lucene/versioned/NativeVersionedMapTests.java rename to src/test/java/org/elasticsearch/test/unit/common/lucene/versioned/NativeVersionedMapTests.java index 61b2ffdcd3e..fd01e09c5b3 100644 --- a/src/test/java/org/elasticsearch/common/lucene/versioned/NativeVersionedMapTests.java +++ b/src/test/java/org/elasticsearch/test/unit/common/lucene/versioned/NativeVersionedMapTests.java @@ -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 @@ -17,14 +17,18 @@ * under the License. */ -package org.elasticsearch.common.lucene.versioned; +package org.elasticsearch.test.unit.common.lucene.versioned; + +import org.elasticsearch.common.lucene.versioned.NativeVersionedMap; +import org.elasticsearch.common.lucene.versioned.VersionedMap; /** - * @author kimchy (Shay Banon) + * */ public class NativeVersionedMapTests extends AbstractVersionedMapTests { - @Override protected VersionedMap create() { + @Override + protected VersionedMap create() { return new NativeVersionedMap(); } } \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/common/lucene/versioned/NonBlockingVersionedMapTests.java b/src/test/java/org/elasticsearch/test/unit/common/lucene/versioned/NonBlockingVersionedMapTests.java similarity index 69% rename from src/test/java/org/elasticsearch/common/lucene/versioned/NonBlockingVersionedMapTests.java rename to src/test/java/org/elasticsearch/test/unit/common/lucene/versioned/NonBlockingVersionedMapTests.java index d8713bb37ea..fb09a2a5a17 100644 --- a/src/test/java/org/elasticsearch/common/lucene/versioned/NonBlockingVersionedMapTests.java +++ b/src/test/java/org/elasticsearch/test/unit/common/lucene/versioned/NonBlockingVersionedMapTests.java @@ -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 @@ -17,14 +17,18 @@ * under the License. */ -package org.elasticsearch.common.lucene.versioned; +package org.elasticsearch.test.unit.common.lucene.versioned; + +import org.elasticsearch.common.lucene.versioned.ConcurrentVersionedMapLong; +import org.elasticsearch.common.lucene.versioned.VersionedMap; /** - * @author kimchy (Shay Banon) + * */ public class NonBlockingVersionedMapTests extends AbstractVersionedMapTests { - @Override protected VersionedMap create() { + @Override + protected VersionedMap create() { return new ConcurrentVersionedMapLong(); } } diff --git a/src/test/java/org/elasticsearch/common/lucene/versioned/VersionedIndexReaderTests.java b/src/test/java/org/elasticsearch/test/unit/common/lucene/versioned/VersionedIndexReaderTests.java similarity index 83% rename from src/test/java/org/elasticsearch/common/lucene/versioned/VersionedIndexReaderTests.java rename to src/test/java/org/elasticsearch/test/unit/common/lucene/versioned/VersionedIndexReaderTests.java index caa42d09020..829cbdaef5a 100644 --- a/src/test/java/org/elasticsearch/common/lucene/versioned/VersionedIndexReaderTests.java +++ b/src/test/java/org/elasticsearch/test/unit/common/lucene/versioned/VersionedIndexReaderTests.java @@ -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 @@ -17,26 +17,26 @@ * under the License. */ -package org.elasticsearch.common.lucene.versioned; +package org.elasticsearch.test.unit.common.lucene.versioned; import org.apache.lucene.document.Document; -import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.IndexWriter; -import org.apache.lucene.index.IndexWriterConfig; -import org.apache.lucene.index.Term; -import org.apache.lucene.index.TermDocs; +import org.apache.lucene.index.*; import org.apache.lucene.store.RAMDirectory; import org.elasticsearch.common.lucene.Lucene; +import org.elasticsearch.common.lucene.versioned.ConcurrentVersionedMapLong; +import org.elasticsearch.common.lucene.versioned.VersionedIndexReader; +import org.elasticsearch.common.lucene.versioned.VersionedMap; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static org.elasticsearch.common.lucene.DocumentBuilder.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.lucene.DocumentBuilder.doc; +import static org.elasticsearch.common.lucene.DocumentBuilder.field; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (Shay Banon) + * */ public class VersionedIndexReaderTests { @@ -45,7 +45,8 @@ public class VersionedIndexReaderTests { private IndexWriter indexWriter; private VersionedMap versionedMap; - @BeforeClass public void setUp() throws Exception { + @BeforeClass + public void setUp() throws Exception { versionedMap = new ConcurrentVersionedMapLong(); dir = new RAMDirectory(); indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER)); @@ -57,13 +58,15 @@ public class VersionedIndexReaderTests { indexReader = IndexReader.open(dir, true); } - @AfterClass public void tearDown() throws Exception { + @AfterClass + public void tearDown() throws Exception { indexWriter.close(); indexReader.close(); dir.close(); } - @Test public void verifyExpected() throws Exception { + @Test + public void verifyExpected() throws Exception { TermDocs termDocs; Document doc = indexReader.document(0); @@ -91,7 +94,8 @@ public class VersionedIndexReaderTests { assertThat(termDocs.next(), equalTo(false)); } - @Test public void testSimple() throws Exception { + @Test + public void testSimple() throws Exception { TermDocs termDocs; // open a versioned index reader in version 0 VersionedIndexReader versionedIndexReader = new VersionedIndexReader(indexReader, 0, versionedMap); diff --git a/src/test/java/org/elasticsearch/common/path/PathTrieTests.java b/src/test/java/org/elasticsearch/test/unit/common/path/PathTrieTests.java similarity index 83% rename from src/test/java/org/elasticsearch/common/path/PathTrieTests.java rename to src/test/java/org/elasticsearch/test/unit/common/path/PathTrieTests.java index f4f8365b077..249762c19b2 100644 --- a/src/test/java/org/elasticsearch/common/path/PathTrieTests.java +++ b/src/test/java/org/elasticsearch/test/unit/common/path/PathTrieTests.java @@ -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 @@ -17,22 +17,25 @@ * under the License. */ -package org.elasticsearch.common.path; +package org.elasticsearch.test.unit.common.path; +import org.elasticsearch.common.path.PathTrie; import org.testng.annotations.Test; import java.util.Map; -import static org.elasticsearch.common.collect.Maps.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static com.google.common.collect.Maps.newHashMap; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.nullValue; /** - * @author kimchy (Shay Banon) + * */ public class PathTrieTests { - @Test public void testPath() { + @Test + public void testPath() { PathTrie trie = new PathTrie(); trie.insert("/a/b/c", "walla"); trie.insert("a/d/g", "kuku"); @@ -59,13 +62,15 @@ public class PathTrieTests { assertThat(params.get("docId"), equalTo("12")); } - @Test public void testEmptyPath() { + @Test + public void testEmptyPath() { PathTrie trie = new PathTrie(); trie.insert("/", "walla"); assertThat(trie.retrieve(""), equalTo("walla")); } - @Test public void testDifferentNamesOnDifferentPath() { + @Test + public void testDifferentNamesOnDifferentPath() { PathTrie trie = new PathTrie(); trie.insert("/a/{type}", "test1"); trie.insert("/b/{name}", "test2"); @@ -79,7 +84,8 @@ public class PathTrieTests { assertThat(params.get("name"), equalTo("testX")); } - @Test public void testSameNameOnDifferentPath() { + @Test + public void testSameNameOnDifferentPath() { PathTrie trie = new PathTrie(); trie.insert("/a/c/{name}", "test1"); trie.insert("/b/{name}", "test2"); diff --git a/src/test/java/org/elasticsearch/common/settings/ImmutableSettingsTests.java b/src/test/java/org/elasticsearch/test/unit/common/settings/ImmutableSettingsTests.java similarity index 61% rename from src/test/java/org/elasticsearch/common/settings/ImmutableSettingsTests.java rename to src/test/java/org/elasticsearch/test/unit/common/settings/ImmutableSettingsTests.java index babf79c114a..516ab5e057d 100644 --- a/src/test/java/org/elasticsearch/common/settings/ImmutableSettingsTests.java +++ b/src/test/java/org/elasticsearch/test/unit/common/settings/ImmutableSettingsTests.java @@ -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 @@ -17,45 +17,48 @@ * under the License. */ -package org.elasticsearch.common.settings; +package org.elasticsearch.test.unit.common.settings; -import org.elasticsearch.common.settings.foo.FooTest; +import org.elasticsearch.common.settings.NoClassSettingsException; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.test.unit.common.settings.bar.BarTest; +import org.elasticsearch.test.unit.common.settings.foo.FooTest; import org.testng.annotations.Test; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author imotov */ public class ImmutableSettingsTests { - @Test public void testGetAsClass() { + @Test + public void testGetAsClass() { Settings settings = settingsBuilder() .put("test.class", "bar") - .put("test.class.package", "org.elasticsearch.common.settings.bar") + .put("test.class.package", "org.elasticsearch.test.unit.common.settings.bar") .build(); // Assert that defaultClazz is loaded if setting is not specified - assertThat(settings.getAsClass("no.settings", FooTest.class, "org.elasticsearch.common.settings.", "Test").getName(), - equalTo("org.elasticsearch.common.settings.foo.FooTest")); + assertThat(settings.getAsClass("no.settings", FooTest.class, "org.elasticsearch.test.unit.common.settings.", "Test").getName(), + equalTo(FooTest.class.getName())); // Assert that correct class is loaded if setting contain name without package - assertThat(settings.getAsClass("test.class", FooTest.class, "org.elasticsearch.common.settings.", "Test").getName(), - equalTo("org.elasticsearch.common.settings.bar.BarTest")); + assertThat(settings.getAsClass("test.class", FooTest.class, "org.elasticsearch.test.unit.common.settings.", "Test").getName(), + equalTo(BarTest.class.getName())); // Assert that class cannot be loaded if wrong packagePrefix is specified try { - settings.getAsClass("test.class", FooTest.class, "com.example.elasticsearch.common.settings.", "Test"); + settings.getAsClass("test.class", FooTest.class, "com.example.elasticsearch.test.unit..common.settings.", "Test"); assertThat("Class with wrong package name shouldn't be loaded", false); } catch (NoClassSettingsException ex) { // Ignore } // Assert that package name in settings is getting correctly applied - assertThat(settings.getAsClass("test.class.package", FooTest.class, "com.example.elasticsearch.common.settings.", "Test").getName(), - equalTo("org.elasticsearch.common.settings.bar.BarTest")); + assertThat(settings.getAsClass("test.class.package", FooTest.class, "com.example.elasticsearch.test.unit.common.settings.", "Test").getName(), + equalTo(BarTest.class.getName())); } diff --git a/src/test/java/org/elasticsearch/common/settings/bar/BarTest.java b/src/test/java/org/elasticsearch/test/unit/common/settings/bar/BarTest.java similarity index 79% rename from src/test/java/org/elasticsearch/common/settings/bar/BarTest.java rename to src/test/java/org/elasticsearch/test/unit/common/settings/bar/BarTest.java index c578e1bf7cf..7807a467029 100644 --- a/src/test/java/org/elasticsearch/common/settings/bar/BarTest.java +++ b/src/test/java/org/elasticsearch/test/unit/common/settings/bar/BarTest.java @@ -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 @@ -17,10 +17,10 @@ * under the License. */ -package org.elasticsearch.common.settings.bar; +package org.elasticsearch.test.unit.common.settings.bar; /** - * @author imotov + * */ public class BarTest { } diff --git a/src/test/java/org/elasticsearch/common/settings/foo/FooTest.java b/src/test/java/org/elasticsearch/test/unit/common/settings/foo/FooTest.java similarity index 79% rename from src/test/java/org/elasticsearch/common/settings/foo/FooTest.java rename to src/test/java/org/elasticsearch/test/unit/common/settings/foo/FooTest.java index 0b44bec1b60..af6bd3eb008 100644 --- a/src/test/java/org/elasticsearch/common/settings/foo/FooTest.java +++ b/src/test/java/org/elasticsearch/test/unit/common/settings/foo/FooTest.java @@ -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 @@ -17,10 +17,10 @@ * under the License. */ -package org.elasticsearch.common.settings.foo; +package org.elasticsearch.test.unit.common.settings.foo; /** - * @author imotov + * */ public class FooTest { } diff --git a/src/test/java/org/elasticsearch/common/settings/loader/JsonSettingsLoaderTests.java b/src/test/java/org/elasticsearch/test/unit/common/settings/loader/JsonSettingsLoaderTests.java similarity index 77% rename from src/test/java/org/elasticsearch/common/settings/loader/JsonSettingsLoaderTests.java rename to src/test/java/org/elasticsearch/test/unit/common/settings/loader/JsonSettingsLoaderTests.java index d729545c0ff..6127913073e 100644 --- a/src/test/java/org/elasticsearch/common/settings/loader/JsonSettingsLoaderTests.java +++ b/src/test/java/org/elasticsearch/test/unit/common/settings/loader/JsonSettingsLoaderTests.java @@ -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 @@ -17,23 +17,24 @@ * under the License. */ -package org.elasticsearch.common.settings.loader; +package org.elasticsearch.test.unit.common.settings.loader; import org.elasticsearch.common.settings.Settings; import org.testng.annotations.Test; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (Shay Banon) + * */ public class JsonSettingsLoaderTests { - @Test public void testSimpleJsonSettings() throws Exception { + @Test + public void testSimpleJsonSettings() throws Exception { Settings settings = settingsBuilder() - .loadFromClasspath("org/elasticsearch/common/settings/loader/test-settings.json") + .loadFromClasspath("org/elasticsearch/test/unit/common/settings/loader/test-settings.json") .build(); assertThat(settings.get("test1.value1"), equalTo("value1")); diff --git a/src/test/java/org/elasticsearch/common/settings/loader/YamlSettingsLoaderTests.java b/src/test/java/org/elasticsearch/test/unit/common/settings/loader/YamlSettingsLoaderTests.java similarity index 77% rename from src/test/java/org/elasticsearch/common/settings/loader/YamlSettingsLoaderTests.java rename to src/test/java/org/elasticsearch/test/unit/common/settings/loader/YamlSettingsLoaderTests.java index b456e8917a0..2b1e6ef045c 100644 --- a/src/test/java/org/elasticsearch/common/settings/loader/YamlSettingsLoaderTests.java +++ b/src/test/java/org/elasticsearch/test/unit/common/settings/loader/YamlSettingsLoaderTests.java @@ -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 @@ -17,23 +17,24 @@ * under the License. */ -package org.elasticsearch.common.settings.loader; +package org.elasticsearch.test.unit.common.settings.loader; import org.elasticsearch.common.settings.Settings; import org.testng.annotations.Test; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (Shay Banon) + * */ public class YamlSettingsLoaderTests { - @Test public void testSimpleYamlSettings() throws Exception { + @Test + public void testSimpleYamlSettings() throws Exception { Settings settings = settingsBuilder() - .loadFromClasspath("org/elasticsearch/common/settings/loader/test-settings.yml") + .loadFromClasspath("org/elasticsearch/test/unit/common/settings/loader/test-settings.yml") .build(); assertThat(settings.get("test1.value1"), equalTo("value1")); diff --git a/src/test/java/org/elasticsearch/test/unit/common/settings/loader/test-settings.json b/src/test/java/org/elasticsearch/test/unit/common/settings/loader/test-settings.json new file mode 100644 index 00000000000..7190648d597 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/common/settings/loader/test-settings.json @@ -0,0 +1,10 @@ +{ + test1:{ + value1:"value1", + test2:{ + value2:"value2", + value3:2 + }, + test3:["test3-1", "test3-2"] + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/common/settings/loader/test-settings.yml b/src/test/java/org/elasticsearch/test/unit/common/settings/loader/test-settings.yml similarity index 100% rename from src/test/java/org/elasticsearch/common/settings/loader/test-settings.yml rename to src/test/java/org/elasticsearch/test/unit/common/settings/loader/test-settings.yml diff --git a/src/test/java/org/elasticsearch/common/unit/ByteSizeUnitTests.java b/src/test/java/org/elasticsearch/test/unit/common/unit/ByteSizeUnitTests.java similarity index 80% rename from src/test/java/org/elasticsearch/common/unit/ByteSizeUnitTests.java rename to src/test/java/org/elasticsearch/test/unit/common/unit/ByteSizeUnitTests.java index 7bc5961c0ae..e791d540b71 100644 --- a/src/test/java/org/elasticsearch/common/unit/ByteSizeUnitTests.java +++ b/src/test/java/org/elasticsearch/test/unit/common/unit/ByteSizeUnitTests.java @@ -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 @@ -17,41 +17,45 @@ * under the License. */ -package org.elasticsearch.common.unit; +package org.elasticsearch.test.unit.common.unit; import org.testng.annotations.Test; import static org.elasticsearch.common.unit.ByteSizeUnit.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (Shay Banon) + * */ public class ByteSizeUnitTests { - @Test public void testBytes() { + @Test + public void testBytes() { assertThat(BYTES.toBytes(1), equalTo(1l)); assertThat(BYTES.toKB(1024), equalTo(1l)); assertThat(BYTES.toMB(1024 * 1024), equalTo(1l)); assertThat(BYTES.toGB(1024 * 1024 * 1024), equalTo(1l)); } - @Test public void testKB() { + @Test + public void testKB() { assertThat(KB.toBytes(1), equalTo(1024l)); assertThat(KB.toKB(1), equalTo(1l)); assertThat(KB.toMB(1024), equalTo(1l)); assertThat(KB.toGB(1024 * 1024), equalTo(1l)); } - @Test public void testMB() { + @Test + public void testMB() { assertThat(MB.toBytes(1), equalTo(1024l * 1024)); assertThat(MB.toKB(1), equalTo(1024l)); assertThat(MB.toMB(1), equalTo(1l)); assertThat(MB.toGB(1024), equalTo(1l)); } - @Test public void testGB() { + @Test + public void testGB() { assertThat(GB.toBytes(1), equalTo(1024l * 1024 * 1024)); assertThat(GB.toKB(1), equalTo(1024l * 1024)); assertThat(GB.toMB(1), equalTo(1024l)); diff --git a/src/test/java/org/elasticsearch/common/unit/ByteSizeValueTests.java b/src/test/java/org/elasticsearch/test/unit/common/unit/ByteSizeValueTests.java similarity index 71% rename from src/test/java/org/elasticsearch/common/unit/ByteSizeValueTests.java rename to src/test/java/org/elasticsearch/test/unit/common/unit/ByteSizeValueTests.java index 3e9bb57c620..20388898db2 100644 --- a/src/test/java/org/elasticsearch/common/unit/ByteSizeValueTests.java +++ b/src/test/java/org/elasticsearch/test/unit/common/unit/ByteSizeValueTests.java @@ -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 @@ -17,30 +17,37 @@ * under the License. */ -package org.elasticsearch.common.unit; +package org.elasticsearch.test.unit.common.unit; +import org.elasticsearch.common.unit.ByteSizeUnit; +import org.elasticsearch.common.unit.ByteSizeValue; +import org.hamcrest.MatcherAssert; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; /** - * @author kimchy (Shay Banon) + * */ public class ByteSizeValueTests { - @Test public void testActual() { - assertThat(new ByteSizeValue(4, ByteSizeUnit.GB).bytes(), equalTo(4294967296l)); + @Test + public void testActual() { + MatcherAssert.assertThat(new ByteSizeValue(4, ByteSizeUnit.GB).bytes(), equalTo(4294967296l)); } - @Test public void testSimple() { + @Test + public void testSimple() { assertThat(ByteSizeUnit.BYTES.toBytes(10), is(new ByteSizeValue(10, ByteSizeUnit.BYTES).bytes())); assertThat(ByteSizeUnit.KB.toKB(10), is(new ByteSizeValue(10, ByteSizeUnit.KB).kb())); assertThat(ByteSizeUnit.MB.toMB(10), is(new ByteSizeValue(10, ByteSizeUnit.MB).mb())); assertThat(ByteSizeUnit.GB.toGB(10), is(new ByteSizeValue(10, ByteSizeUnit.GB).gb())); } - @Test public void testToString() { + @Test + public void testToString() { assertThat("10b", is(new ByteSizeValue(10, ByteSizeUnit.BYTES).toString())); assertThat("1.5kb", is(new ByteSizeValue((long) (1024 * 1.5), ByteSizeUnit.BYTES).toString())); assertThat("1.5mb", is(new ByteSizeValue((long) (1024 * 1.5), ByteSizeUnit.KB).toString())); diff --git a/src/test/java/org/elasticsearch/common/unit/DistanceUnitTests.java b/src/test/java/org/elasticsearch/test/unit/common/unit/DistanceUnitTests.java similarity index 67% rename from src/test/java/org/elasticsearch/common/unit/DistanceUnitTests.java rename to src/test/java/org/elasticsearch/test/unit/common/unit/DistanceUnitTests.java index 689d6a327cc..11bd6aff354 100644 --- a/src/test/java/org/elasticsearch/common/unit/DistanceUnitTests.java +++ b/src/test/java/org/elasticsearch/test/unit/common/unit/DistanceUnitTests.java @@ -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 @@ -17,21 +17,24 @@ * under the License. */ -package org.elasticsearch.common.unit; +package org.elasticsearch.test.unit.common.unit; +import org.elasticsearch.common.unit.DistanceUnit; +import org.hamcrest.MatcherAssert; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.closeTo; /** - * @author kimchy (shay.banon) + * */ @Test public class DistanceUnitTests { - @Test void testSimpleDistanceUnit() { - assertThat(DistanceUnit.MILES.toKilometers(10), closeTo(16.09344, 0.001)); + @Test + void testSimpleDistanceUnit() { + MatcherAssert.assertThat(DistanceUnit.MILES.toKilometers(10), closeTo(16.09344, 0.001)); assertThat(DistanceUnit.MILES.toMiles(10), closeTo(10, 0.001)); assertThat(DistanceUnit.KILOMETERS.toMiles(10), closeTo(6.21371192, 0.001)); assertThat(DistanceUnit.KILOMETERS.toKilometers(10), closeTo(10, 0.001)); diff --git a/src/test/java/org/elasticsearch/common/unit/TimeValueTests.java b/src/test/java/org/elasticsearch/test/unit/common/unit/TimeValueTests.java similarity index 81% rename from src/test/java/org/elasticsearch/common/unit/TimeValueTests.java rename to src/test/java/org/elasticsearch/test/unit/common/unit/TimeValueTests.java index f8cc8374772..74eba8b3bc5 100644 --- a/src/test/java/org/elasticsearch/common/unit/TimeValueTests.java +++ b/src/test/java/org/elasticsearch/test/unit/common/unit/TimeValueTests.java @@ -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 @@ -17,22 +17,25 @@ * under the License. */ -package org.elasticsearch.common.unit; +package org.elasticsearch.test.unit.common.unit; -import org.elasticsearch.common.joda.time.PeriodType; +import org.elasticsearch.common.unit.TimeValue; +import org.joda.time.PeriodType; import org.testng.annotations.Test; import java.util.concurrent.TimeUnit; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.lessThan; /** - * @author kimchy (shay.banon) + * */ public class TimeValueTests { - @Test public void testSimple() { + @Test + public void testSimple() { assertThat(TimeUnit.MILLISECONDS.toMillis(10), equalTo(new TimeValue(10, TimeUnit.MILLISECONDS).millis())); assertThat(TimeUnit.MICROSECONDS.toMicros(10), equalTo(new TimeValue(10, TimeUnit.MICROSECONDS).micros())); assertThat(TimeUnit.SECONDS.toSeconds(10), equalTo(new TimeValue(10, TimeUnit.SECONDS).seconds())); @@ -41,7 +44,8 @@ public class TimeValueTests { assertThat(TimeUnit.DAYS.toDays(10), equalTo(new TimeValue(10, TimeUnit.DAYS).days())); } - @Test public void testToString() { + @Test + public void testToString() { assertThat("10ms", equalTo(new TimeValue(10, TimeUnit.MILLISECONDS).toString())); assertThat("1.5s", equalTo(new TimeValue(1533, TimeUnit.MILLISECONDS).toString())); assertThat("1.5m", equalTo(new TimeValue(90, TimeUnit.SECONDS).toString())); @@ -50,14 +54,16 @@ public class TimeValueTests { assertThat("1000d", equalTo(new TimeValue(1000, TimeUnit.DAYS).toString())); } - @Test public void testFormat() { + @Test + public void testFormat() { assertThat(new TimeValue(1025, TimeUnit.MILLISECONDS).format(PeriodType.dayTime()), equalTo("1 second and 25 milliseconds")); assertThat(new TimeValue(1, TimeUnit.MINUTES).format(PeriodType.dayTime()), equalTo("1 minute")); assertThat(new TimeValue(65, TimeUnit.MINUTES).format(PeriodType.dayTime()), equalTo("1 hour and 5 minutes")); assertThat(new TimeValue(24 * 600 + 85, TimeUnit.MINUTES).format(PeriodType.dayTime()), equalTo("241 hours and 25 minutes")); } - @Test public void testMinusOne() { + @Test + public void testMinusOne() { assertThat(new TimeValue(-1).nanos(), lessThan(0l)); } } diff --git a/src/test/java/org/elasticsearch/common/util/concurrent/BlockingThreadPoolTest.java b/src/test/java/org/elasticsearch/test/unit/common/util/concurrent/BlockingThreadPoolTest.java similarity index 84% rename from src/test/java/org/elasticsearch/common/util/concurrent/BlockingThreadPoolTest.java rename to src/test/java/org/elasticsearch/test/unit/common/util/concurrent/BlockingThreadPoolTest.java index ec55790bcef..fa30161ee38 100644 --- a/src/test/java/org/elasticsearch/common/util/concurrent/BlockingThreadPoolTest.java +++ b/src/test/java/org/elasticsearch/test/unit/common/util/concurrent/BlockingThreadPoolTest.java @@ -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 @@ -17,24 +17,27 @@ * under the License. */ -package org.elasticsearch.common.util.concurrent; +package org.elasticsearch.test.unit.common.util.concurrent; +import org.elasticsearch.common.util.concurrent.ThreadBarrier; +import org.elasticsearch.common.util.concurrent.TransferThreadPoolExecutor; import org.testng.annotations.Test; import java.util.concurrent.Executors; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.TimeUnit; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ @Test(enabled = false) public class BlockingThreadPoolTest { - @Test public void testBlocking() throws Exception { + @Test + public void testBlocking() throws Exception { final int min = 2; final int max = 4; final long waitTime = 1000; //1 second @@ -50,8 +53,7 @@ public class BlockingThreadPoolTest { try { barrier.await(); barrier.await(); - } - catch (Throwable e) { + } catch (Throwable e) { barrier.reset(e); } } diff --git a/src/test/java/org/elasticsearch/common/util/concurrent/ScalingThreadPoolTest.java b/src/test/java/org/elasticsearch/test/unit/common/util/concurrent/ScalingThreadPoolTest.java similarity index 89% rename from src/test/java/org/elasticsearch/common/util/concurrent/ScalingThreadPoolTest.java rename to src/test/java/org/elasticsearch/test/unit/common/util/concurrent/ScalingThreadPoolTest.java index 1fdb6a4e5a1..89b6c318eff 100644 --- a/src/test/java/org/elasticsearch/common/util/concurrent/ScalingThreadPoolTest.java +++ b/src/test/java/org/elasticsearch/test/unit/common/util/concurrent/ScalingThreadPoolTest.java @@ -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 @@ -17,24 +17,27 @@ * under the License. */ -package org.elasticsearch.common.util.concurrent; +package org.elasticsearch.test.unit.common.util.concurrent; +import org.elasticsearch.common.util.concurrent.ThreadBarrier; +import org.elasticsearch.common.util.concurrent.TransferThreadPoolExecutor; import org.testng.annotations.Test; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import static org.hamcrest.MatcherAssert.*; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** - * @author kimchy (shay.banon) + * */ @Test(enabled = false) public class ScalingThreadPoolTest { - @Test public void testScaleUp() throws Exception { + @Test + public void testScaleUp() throws Exception { final int min = 2; final int max = 4; final ThreadBarrier barrier = new ThreadBarrier(max + 1); @@ -50,8 +53,7 @@ public class ScalingThreadPoolTest { try { barrier.await(); barrier.await(); - } - catch (Throwable e) { + } catch (Throwable e) { barrier.reset(e); } } @@ -69,7 +71,8 @@ public class ScalingThreadPoolTest { pool.shutdown(); } - @Test public void testScaleDown() throws Exception { + @Test + public void testScaleDown() throws Exception { final int min = 2; final int max = 4; final ThreadBarrier barrier = new ThreadBarrier(max + 1); @@ -85,8 +88,7 @@ public class ScalingThreadPoolTest { try { barrier.await(); barrier.await(); - } - catch (Throwable e) { + } catch (Throwable e) { barrier.reset(e); } } @@ -112,7 +114,8 @@ public class ScalingThreadPoolTest { } - @Test public void testScaleAbove() throws Exception { + @Test + public void testScaleAbove() throws Exception { final int min = 2; final int max = 4; final int ntasks = 16; @@ -133,8 +136,7 @@ public class ScalingThreadPoolTest { if (id < max) { barrier.await(); } - } - catch (Throwable e) { + } catch (Throwable e) { barrier.reset(e); } } diff --git a/src/test/java/org/elasticsearch/common/util/concurrent/resource/AbstractAcquirableResourceTests.java b/src/test/java/org/elasticsearch/test/unit/common/util/concurrent/resource/AbstractAcquirableResourceTests.java similarity index 82% rename from src/test/java/org/elasticsearch/common/util/concurrent/resource/AbstractAcquirableResourceTests.java rename to src/test/java/org/elasticsearch/test/unit/common/util/concurrent/resource/AbstractAcquirableResourceTests.java index ee80f356c20..712f9d164aa 100644 --- a/src/test/java/org/elasticsearch/common/util/concurrent/resource/AbstractAcquirableResourceTests.java +++ b/src/test/java/org/elasticsearch/test/unit/common/util/concurrent/resource/AbstractAcquirableResourceTests.java @@ -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 @@ -17,28 +17,30 @@ * under the License. */ -package org.elasticsearch.common.util.concurrent.resource; +package org.elasticsearch.test.unit.common.util.concurrent.resource; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.common.StopWatch; import org.elasticsearch.common.lease.Releasable; +import org.elasticsearch.common.util.concurrent.resource.AcquirableResource; import org.testng.annotations.Test; import java.util.ArrayList; import java.util.List; import java.util.concurrent.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy + * */ public abstract class AbstractAcquirableResourceTests { protected abstract AcquirableResource createInstance(T resource); - @Test public void testSimple() throws Exception { + @Test + public void testSimple() throws Exception { ExecutorService executorService = Executors.newCachedThreadPool(); final AcquirableResource acquirableResource = createInstance(new Resource()); @@ -53,7 +55,8 @@ public abstract class AbstractAcquirableResourceTests { for (int i = 0; i < cycles; i++) { results.add(executorService.submit(new Callable() { - @Override public Object call() throws Exception { + @Override + public Object call() throws Exception { barrier1.await(); barrier2.await(); for (int j = 0; j < operationsWithinCycle; j++) { @@ -63,7 +66,8 @@ public abstract class AbstractAcquirableResourceTests { } })); results.add(executorService.submit(new Callable() { - @Override public Object call() throws Exception { + @Override + public Object call() throws Exception { barrier1.await(); barrier2.await(); for (int j = 0; j < operationsWithinCycle; j++) { @@ -96,7 +100,8 @@ public abstract class AbstractAcquirableResourceTests { private volatile boolean released = false; - @Override public boolean release() throws ElasticSearchException { + @Override + public boolean release() throws ElasticSearchException { released = true; return true; } diff --git a/src/test/java/org/elasticsearch/common/util/concurrent/resource/BlockingAcquirableResourceTests.java b/src/test/java/org/elasticsearch/test/unit/common/util/concurrent/resource/BlockingAcquirableResourceTests.java similarity index 66% rename from src/test/java/org/elasticsearch/common/util/concurrent/resource/BlockingAcquirableResourceTests.java rename to src/test/java/org/elasticsearch/test/unit/common/util/concurrent/resource/BlockingAcquirableResourceTests.java index 99466e6a63c..b97718c7a32 100644 --- a/src/test/java/org/elasticsearch/common/util/concurrent/resource/BlockingAcquirableResourceTests.java +++ b/src/test/java/org/elasticsearch/test/unit/common/util/concurrent/resource/BlockingAcquirableResourceTests.java @@ -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 @@ -17,16 +17,19 @@ * under the License. */ -package org.elasticsearch.common.util.concurrent.resource; +package org.elasticsearch.test.unit.common.util.concurrent.resource; import org.elasticsearch.common.lease.Releasable; +import org.elasticsearch.common.util.concurrent.resource.AcquirableResource; +import org.elasticsearch.common.util.concurrent.resource.BlockingAcquirableResource; /** - * @author kimchy + * */ public class BlockingAcquirableResourceTests extends AbstractAcquirableResourceTests { - @Override protected AcquirableResource createInstance(T resource) { + @Override + protected AcquirableResource createInstance(T resource) { return new BlockingAcquirableResource(resource); } } diff --git a/src/test/java/org/elasticsearch/common/util/concurrent/resource/NonBlockingAcquirableResourceTests.java b/src/test/java/org/elasticsearch/test/unit/common/util/concurrent/resource/NonBlockingAcquirableResourceTests.java similarity index 66% rename from src/test/java/org/elasticsearch/common/util/concurrent/resource/NonBlockingAcquirableResourceTests.java rename to src/test/java/org/elasticsearch/test/unit/common/util/concurrent/resource/NonBlockingAcquirableResourceTests.java index c09a6ca6c9d..b83bfeab2c0 100644 --- a/src/test/java/org/elasticsearch/common/util/concurrent/resource/NonBlockingAcquirableResourceTests.java +++ b/src/test/java/org/elasticsearch/test/unit/common/util/concurrent/resource/NonBlockingAcquirableResourceTests.java @@ -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 @@ -17,16 +17,19 @@ * under the License. */ -package org.elasticsearch.common.util.concurrent.resource; +package org.elasticsearch.test.unit.common.util.concurrent.resource; import org.elasticsearch.common.lease.Releasable; +import org.elasticsearch.common.util.concurrent.resource.AcquirableResource; +import org.elasticsearch.common.util.concurrent.resource.NonBlockingAcquirableResource; /** - * @author kimchy + * */ public class NonBlockingAcquirableResourceTests extends AbstractAcquirableResourceTests { - @Override protected AcquirableResource createInstance(T resource) { + @Override + protected AcquirableResource createInstance(T resource) { return new NonBlockingAcquirableResource(resource); } } \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/common/xcontent/builder/BuilderRawFieldTests.java b/src/test/java/org/elasticsearch/test/unit/common/xcontent/builder/BuilderRawFieldTests.java similarity index 87% rename from src/test/java/org/elasticsearch/common/xcontent/builder/BuilderRawFieldTests.java rename to src/test/java/org/elasticsearch/test/unit/common/xcontent/builder/BuilderRawFieldTests.java index 2007849002e..6dc8e5d720a 100644 --- a/src/test/java/org/elasticsearch/common/xcontent/builder/BuilderRawFieldTests.java +++ b/src/test/java/org/elasticsearch/test/unit/common/xcontent/builder/BuilderRawFieldTests.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.common.xcontent.builder; +package org.elasticsearch.test.unit.common.xcontent.builder; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; @@ -27,19 +27,21 @@ import org.testng.annotations.Test; import java.io.IOException; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class BuilderRawFieldTests { - @Test public void testJsonRawField() throws IOException { + @Test + public void testJsonRawField() throws IOException { testRawField(XContentType.JSON); } - @Test public void testSmileRawField() throws IOException { + @Test + public void testSmileRawField() throws IOException { testRawField(XContentType.SMILE); } diff --git a/src/test/java/org/elasticsearch/common/xcontent/builder/XContentBuilderTests.java b/src/test/java/org/elasticsearch/test/unit/common/xcontent/builder/XContentBuilderTests.java similarity index 82% rename from src/test/java/org/elasticsearch/common/xcontent/builder/XContentBuilderTests.java rename to src/test/java/org/elasticsearch/test/unit/common/xcontent/builder/XContentBuilderTests.java index cd6c5c63314..f9b14efbb3f 100644 --- a/src/test/java/org/elasticsearch/common/xcontent/builder/XContentBuilderTests.java +++ b/src/test/java/org/elasticsearch/test/unit/common/xcontent/builder/XContentBuilderTests.java @@ -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 @@ -17,9 +17,9 @@ * under the License. */ -package org.elasticsearch.common.xcontent.builder; +package org.elasticsearch.test.unit.common.xcontent.builder; -import org.elasticsearch.common.collect.Lists; +import com.google.common.collect.Lists; import org.elasticsearch.common.io.FastByteArrayOutputStream; import org.elasticsearch.common.io.FastCharArrayWriter; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -28,17 +28,19 @@ import org.elasticsearch.common.xcontent.XContentGenerator; import org.elasticsearch.common.xcontent.XContentType; import org.testng.annotations.Test; -import static org.elasticsearch.common.xcontent.XContentBuilder.FieldCaseConversion.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.xcontent.XContentBuilder.FieldCaseConversion.CAMELCASE; +import static org.elasticsearch.common.xcontent.XContentBuilder.FieldCaseConversion.UNDERSCORE; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ @Test public class XContentBuilderTests { - @Test public void verifyReuseJsonGenerator() throws Exception { + @Test + public void verifyReuseJsonGenerator() throws Exception { FastCharArrayWriter writer = new FastCharArrayWriter(); XContentGenerator generator = XContentFactory.xContent(XContentType.JSON).createGenerator(writer); generator.writeStartObject(); @@ -58,7 +60,8 @@ public class XContentBuilderTests { assertThat(writer.toStringTrim(), equalTo("{\"test\":\"value\"}")); } - @Test public void testSimpleGenerator() throws Exception { + @Test + public void testSimpleGenerator() throws Exception { XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); builder.startObject().field("test", "value").endObject(); assertThat(builder.string(), equalTo("{\"test\":\"value\"}")); @@ -68,13 +71,15 @@ public class XContentBuilderTests { assertThat(builder.string(), equalTo("{\"test\":\"value\"}")); } - @Test public void testOverloadedList() throws Exception { + @Test + public void testOverloadedList() throws Exception { XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); builder.startObject().field("test", Lists.newArrayList("1", "2")).endObject(); assertThat(builder.string(), equalTo("{\"test\":[\"1\",\"2\"]}")); } - @Test public void testWritingBinaryToStream() throws Exception { + @Test + public void testWritingBinaryToStream() throws Exception { FastByteArrayOutputStream bos = new FastByteArrayOutputStream(); XContentGenerator gen = XContentFactory.xContent(XContentType.JSON).createGenerator(bos); @@ -91,7 +96,8 @@ public class XContentBuilderTests { System.out.println("DATA: " + sData); } - @Test public void testFieldCaseConversion() throws Exception { + @Test + public void testFieldCaseConversion() throws Exception { XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON).fieldCaseConversion(CAMELCASE); builder.startObject().field("test_name", "value").endObject(); assertThat(builder.string(), equalTo("{\"testName\":\"value\"}")); diff --git a/src/test/java/org/elasticsearch/common/xcontent/smile/JsonVsSmileTests.java b/src/test/java/org/elasticsearch/test/unit/common/xcontent/smile/JsonVsSmileTests.java similarity index 90% rename from src/test/java/org/elasticsearch/common/xcontent/smile/JsonVsSmileTests.java rename to src/test/java/org/elasticsearch/test/unit/common/xcontent/smile/JsonVsSmileTests.java index bbb21654b82..c4faaf6ed8d 100644 --- a/src/test/java/org/elasticsearch/common/xcontent/smile/JsonVsSmileTests.java +++ b/src/test/java/org/elasticsearch/test/unit/common/xcontent/smile/JsonVsSmileTests.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.common.xcontent.smile; +package org.elasticsearch.test.unit.common.xcontent.smile; import org.elasticsearch.common.io.FastByteArrayOutputStream; import org.elasticsearch.common.xcontent.XContentFactory; @@ -28,11 +28,12 @@ import org.testng.annotations.Test; import java.io.IOException; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.nullValue; /** - * @author kimchy (shay.banon) + * */ public class JsonVsSmileTests { @@ -45,7 +46,8 @@ public class JsonVsSmileTests { // gen.writeEndObject(); // } - @Test public void compareParsingTokens() throws IOException { + @Test + public void compareParsingTokens() throws IOException { FastByteArrayOutputStream xsonOs = new FastByteArrayOutputStream(); XContentGenerator xsonGen = XContentFactory.xContent(XContentType.SMILE).createGenerator(xsonOs); diff --git a/src/test/java/org/elasticsearch/common/xcontent/support/XContentMapValuesTests.java b/src/test/java/org/elasticsearch/test/unit/common/xcontent/support/XContentMapValuesTests.java similarity index 93% rename from src/test/java/org/elasticsearch/common/xcontent/support/XContentMapValuesTests.java rename to src/test/java/org/elasticsearch/test/unit/common/xcontent/support/XContentMapValuesTests.java index 529b27c4cfb..48d65d6b6e2 100644 --- a/src/test/java/org/elasticsearch/common/xcontent/support/XContentMapValuesTests.java +++ b/src/test/java/org/elasticsearch/test/unit/common/xcontent/support/XContentMapValuesTests.java @@ -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 @@ -17,18 +17,19 @@ * under the License. */ -package org.elasticsearch.common.xcontent.support; +package org.elasticsearch.test.unit.common.xcontent.support; import org.elasticsearch.common.Strings; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentType; +import org.elasticsearch.common.xcontent.support.XContentMapValues; import org.testng.annotations.Test; import java.util.List; import java.util.Map; -import static org.hamcrest.MatcherAssert.*; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** @@ -36,7 +37,8 @@ import static org.hamcrest.Matchers.*; @Test public class XContentMapValuesTests { - @Test public void testFilter() throws Exception { + @Test + public void testFilter() throws Exception { XContentBuilder builder = XContentFactory.jsonBuilder().startObject() .field("test1", "value1") .field("test2", "value2") @@ -80,7 +82,9 @@ public class XContentMapValuesTests { assertThat(filter.containsKey("path1"), equalTo(false)); } - @SuppressWarnings({"unchecked"}) @Test public void testExtractValue() throws Exception { + @SuppressWarnings({"unchecked"}) + @Test + public void testExtractValue() throws Exception { XContentBuilder builder = XContentFactory.jsonBuilder().startObject() .field("test", "value") .endObject(); diff --git a/src/test/java/org/elasticsearch/deps/jackson/JacksonLocationTests.java b/src/test/java/org/elasticsearch/test/unit/deps/jackson/JacksonLocationTests.java similarity index 87% rename from src/test/java/org/elasticsearch/deps/jackson/JacksonLocationTests.java rename to src/test/java/org/elasticsearch/test/unit/deps/jackson/JacksonLocationTests.java index 9fb92487ae6..d75c9aa93a2 100644 --- a/src/test/java/org/elasticsearch/deps/jackson/JacksonLocationTests.java +++ b/src/test/java/org/elasticsearch/test/unit/deps/jackson/JacksonLocationTests.java @@ -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 @@ -17,23 +17,24 @@ * under the License. */ -package org.elasticsearch.deps.jackson; +package org.elasticsearch.test.unit.deps.jackson; +import org.codehaus.jackson.*; import org.elasticsearch.common.io.FastByteArrayOutputStream; -import org.elasticsearch.common.jackson.*; import org.testng.annotations.Test; import java.io.IOException; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class JacksonLocationTests { - @Test public void testLocationExtraction() throws IOException { + @Test + public void testLocationExtraction() throws IOException { // { // "index" : "test", // "source" : { diff --git a/src/test/java/org/elasticsearch/deps/joda/SimpleJodaTests.java b/src/test/java/org/elasticsearch/test/unit/deps/joda/SimpleJodaTests.java similarity index 87% rename from src/test/java/org/elasticsearch/deps/joda/SimpleJodaTests.java rename to src/test/java/org/elasticsearch/test/unit/deps/joda/SimpleJodaTests.java index 759df94eea9..4fbb7c840be 100644 --- a/src/test/java/org/elasticsearch/deps/joda/SimpleJodaTests.java +++ b/src/test/java/org/elasticsearch/test/unit/deps/joda/SimpleJodaTests.java @@ -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 @@ -17,31 +17,28 @@ * under the License. */ -package org.elasticsearch.deps.joda; +package org.elasticsearch.test.unit.deps.joda; import org.elasticsearch.common.joda.FormatDateTimeFormatter; import org.elasticsearch.common.joda.Joda; -import org.elasticsearch.common.joda.time.DateTimeZone; -import org.elasticsearch.common.joda.time.MutableDateTime; -import org.elasticsearch.common.joda.time.format.DateTimeFormat; -import org.elasticsearch.common.joda.time.format.DateTimeFormatter; -import org.elasticsearch.common.joda.time.format.DateTimeFormatterBuilder; -import org.elasticsearch.common.joda.time.format.DateTimeParser; -import org.elasticsearch.common.joda.time.format.ISODateTimeFormat; import org.elasticsearch.common.unit.TimeValue; +import org.joda.time.DateTimeZone; +import org.joda.time.MutableDateTime; +import org.joda.time.format.*; import org.testng.annotations.Test; import java.util.Date; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (Shay Banon) + * */ public class SimpleJodaTests { - @Test public void testMultiParsers() { + @Test + public void testMultiParsers() { DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder(); DateTimeParser[] parsers = new DateTimeParser[3]; parsers[0] = DateTimeFormat.forPattern("MM/dd/yyyy").withZone(DateTimeZone.UTC).getParser(); @@ -54,14 +51,16 @@ public class SimpleJodaTests { formatter.parseMillis("2009-11-15 14:12:12"); } - @Test public void testIsoDateFormatDateTimeNoMillisUTC() { + @Test + public void testIsoDateFormatDateTimeNoMillisUTC() { DateTimeFormatter formatter = ISODateTimeFormat.dateTimeNoMillis().withZone(DateTimeZone.UTC); long millis = formatter.parseMillis("1970-01-01T00:00:00Z"); assertThat(millis, equalTo(0l)); } - @Test public void testUpperBound() { + @Test + public void testUpperBound() { MutableDateTime dateTime = new MutableDateTime(3000, 12, 31, 23, 59, 59, 999, DateTimeZone.UTC); DateTimeFormatter formatter = ISODateTimeFormat.dateOptionalTimeParser().withZone(DateTimeZone.UTC); @@ -71,7 +70,8 @@ public class SimpleJodaTests { assertThat(dateTime.toString(), equalTo("2000-01-01T23:59:59.999Z")); } - @Test public void testIsoDateFormatDateOptionalTimeUTC() { + @Test + public void testIsoDateFormatDateOptionalTimeUTC() { DateTimeFormatter formatter = ISODateTimeFormat.dateOptionalTimeParser().withZone(DateTimeZone.UTC); long millis = formatter.parseMillis("1970-01-01T00:00:00Z"); assertThat(millis, equalTo(0l)); @@ -101,7 +101,8 @@ public class SimpleJodaTests { assertThat(millis, equalTo(TimeValue.timeValueHours(2).millis())); } - @Test public void testIsoVsCustom() { + @Test + public void testIsoVsCustom() { DateTimeFormatter formatter = ISODateTimeFormat.dateOptionalTimeParser().withZone(DateTimeZone.UTC); long millis = formatter.parseMillis("1970-01-01T00:00:00"); assertThat(millis, equalTo(0l)); @@ -115,14 +116,16 @@ public class SimpleJodaTests { assertThat(millis, equalTo(0l)); } - @Test public void testWriteAndParse() { + @Test + public void testWriteAndParse() { DateTimeFormatter dateTimeWriter = ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC); DateTimeFormatter formatter = ISODateTimeFormat.dateOptionalTimeParser().withZone(DateTimeZone.UTC); Date date = new Date(); assertThat(formatter.parseMillis(dateTimeWriter.print(date.getTime())), equalTo(date.getTime())); } - @Test public void testSlashInFormat() { + @Test + public void testSlashInFormat() { FormatDateTimeFormatter formatter = Joda.forPattern("MM/yyyy"); formatter.parser().parseMillis("01/2001"); @@ -138,7 +141,8 @@ public class SimpleJodaTests { } } - @Test public void testMultipleFormats() { + @Test + public void testMultipleFormats() { FormatDateTimeFormatter formatter = Joda.forPattern("yyyy/MM/dd HH:mm:ss||yyyy/MM/dd"); long millis = formatter.parser().parseMillis("1970/01/01 00:00:00"); millis = formatter.parser().parseMillis("1970/01/01"); @@ -147,7 +151,8 @@ public class SimpleJodaTests { System.out.println(formatter.printer().print(millis)); } - @Test public void testRounding() { + @Test + public void testRounding() { long TIME = utcTimeInMillis("2009-02-03T01:01:01"); MutableDateTime time = new MutableDateTime(DateTimeZone.UTC); time.setMillis(TIME); @@ -158,7 +163,8 @@ public class SimpleJodaTests { assertThat(time.dayOfMonth().roundFloor().toString(), equalTo("2009-02-03T00:00:00.000Z")); } - @Test public void testRoundingSetOnTime() { + @Test + public void testRoundingSetOnTime() { MutableDateTime time = new MutableDateTime(DateTimeZone.UTC); time.setRounding(time.getChronology().monthOfYear(), MutableDateTime.ROUND_FLOOR); time.setMillis(utcTimeInMillis("2009-02-03T01:01:01")); @@ -186,7 +192,8 @@ public class SimpleJodaTests { assertThat(time.getMillis(), equalTo(utcTimeInMillis("2011-05-02T00:00:00.000Z"))); } - @Test public void testRoundingWithTimeZone() { + @Test + public void testRoundingWithTimeZone() { MutableDateTime time = new MutableDateTime(DateTimeZone.UTC); time.setZone(DateTimeZone.forOffsetHours(-2)); time.setRounding(time.getChronology().dayOfMonth(), MutableDateTime.ROUND_FLOOR); diff --git a/src/test/java/org/elasticsearch/deps/lucene/LuceneFieldCacheTests.java b/src/test/java/org/elasticsearch/test/unit/deps/lucene/LuceneFieldCacheTests.java similarity index 85% rename from src/test/java/org/elasticsearch/deps/lucene/LuceneFieldCacheTests.java rename to src/test/java/org/elasticsearch/test/unit/deps/lucene/LuceneFieldCacheTests.java index 6c93f254662..210385aa30b 100644 --- a/src/test/java/org/elasticsearch/deps/lucene/LuceneFieldCacheTests.java +++ b/src/test/java/org/elasticsearch/test/unit/deps/lucene/LuceneFieldCacheTests.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.deps.lucene; +package org.elasticsearch.test.unit.deps.lucene; import org.apache.lucene.document.Document; import org.apache.lucene.document.NumericField; @@ -30,11 +30,11 @@ import org.apache.lucene.store.RAMDirectory; import org.elasticsearch.common.lucene.Lucene; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ @Test public class LuceneFieldCacheTests { @@ -43,7 +43,8 @@ public class LuceneFieldCacheTests { * A test that verifies that when using FieldCache for a field that has been added twice (under the same name) * to the document, returns the last one. */ - @Test public void testTwoFieldSameNameNumericFieldCache() throws Exception { + @Test + public void testTwoFieldSameNameNumericFieldCache() throws Exception { Directory dir = new RAMDirectory(); IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER)); diff --git a/src/test/java/org/elasticsearch/deps/lucene/SimpleLuceneTests.java b/src/test/java/org/elasticsearch/test/unit/deps/lucene/SimpleLuceneTests.java similarity index 82% rename from src/test/java/org/elasticsearch/deps/lucene/SimpleLuceneTests.java rename to src/test/java/org/elasticsearch/test/unit/deps/lucene/SimpleLuceneTests.java index ad46b2d7e5f..2210a48c8ba 100644 --- a/src/test/java/org/elasticsearch/deps/lucene/SimpleLuceneTests.java +++ b/src/test/java/org/elasticsearch/test/unit/deps/lucene/SimpleLuceneTests.java @@ -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 @@ -17,29 +17,11 @@ * under the License. */ -package org.elasticsearch.deps.lucene; +package org.elasticsearch.test.unit.deps.lucene; -import org.apache.lucene.document.Document; -import org.apache.lucene.document.Field; -import org.apache.lucene.document.FieldSelector; -import org.apache.lucene.document.FieldSelectorResult; -import org.apache.lucene.document.Fieldable; -import org.apache.lucene.document.NumericField; -import org.apache.lucene.index.FieldInfo; -import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.IndexWriter; -import org.apache.lucene.index.IndexWriterConfig; -import org.apache.lucene.index.Term; -import org.apache.lucene.index.TermDocs; -import org.apache.lucene.index.TermEnum; -import org.apache.lucene.search.FieldDoc; -import org.apache.lucene.search.IndexSearcher; -import org.apache.lucene.search.MatchAllDocsQuery; -import org.apache.lucene.search.Sort; -import org.apache.lucene.search.SortField; -import org.apache.lucene.search.TermQuery; -import org.apache.lucene.search.TopDocs; -import org.apache.lucene.search.TopFieldDocs; +import org.apache.lucene.document.*; +import org.apache.lucene.index.*; +import org.apache.lucene.search.*; import org.apache.lucene.store.Directory; import org.apache.lucene.store.RAMDirectory; import org.apache.lucene.util.NumericUtils; @@ -49,16 +31,18 @@ import org.testng.annotations.Test; import java.io.IOException; import java.util.ArrayList; -import static org.elasticsearch.common.lucene.DocumentBuilder.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.lucene.DocumentBuilder.doc; +import static org.elasticsearch.common.lucene.DocumentBuilder.field; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy + * */ public class SimpleLuceneTests { - @Test public void testSortValues() throws Exception { + @Test + public void testSortValues() throws Exception { Directory dir = new RAMDirectory(); IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER)); for (int i = 0; i < 10; i++) { @@ -73,7 +57,8 @@ public class SimpleLuceneTests { } } - @Test public void testAddDocAfterPrepareCommit() throws Exception { + @Test + public void testAddDocAfterPrepareCommit() throws Exception { Directory dir = new RAMDirectory(); IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER)); indexWriter.addDocument(doc() @@ -92,7 +77,8 @@ public class SimpleLuceneTests { assertThat(reader.numDocs(), equalTo(2)); } - @Test public void testSimpleNumericOps() throws Exception { + @Test + public void testSimpleNumericOps() throws Exception { Directory dir = new RAMDirectory(); IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER)); @@ -118,7 +104,8 @@ public class SimpleLuceneTests { * of the field. This means that heavily accessed fields that use field selector should be added * first (with load and break). */ - @Test public void testOrdering() throws Exception { + @Test + public void testOrdering() throws Exception { Directory dir = new RAMDirectory(); IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER)); @@ -131,7 +118,8 @@ public class SimpleLuceneTests { TopDocs topDocs = searcher.search(new TermQuery(new Term("_id", "1")), 1); final ArrayList fieldsOrder = new ArrayList(); Document doc = searcher.doc(topDocs.scoreDocs[0].doc, new FieldSelector() { - @Override public FieldSelectorResult accept(String fieldName) { + @Override + public FieldSelectorResult accept(String fieldName) { fieldsOrder.add(fieldName); return FieldSelectorResult.LOAD; } @@ -144,7 +132,8 @@ public class SimpleLuceneTests { indexWriter.close(); } - @Test public void testBoost() throws Exception { + @Test + public void testBoost() throws Exception { Directory dir = new RAMDirectory(); IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER)); @@ -174,7 +163,8 @@ public class SimpleLuceneTests { indexWriter.close(); } - @Test public void testNRTSearchOnClosedWriter() throws Exception { + @Test + public void testNRTSearchOnClosedWriter() throws Exception { Directory dir = new RAMDirectory(); IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER)); IndexReader reader = IndexReader.open(indexWriter, true); @@ -196,7 +186,8 @@ public class SimpleLuceneTests { * A test just to verify that term freqs are not stored for numeric fields. int1 is not storing termFreq * and int2 does. */ - @Test public void testNumericTermDocsFreqs() throws Exception { + @Test + public void testNumericTermDocsFreqs() throws Exception { Directory dir = new RAMDirectory(); IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER)); diff --git a/src/test/java/org/elasticsearch/deps/lucene/VectorHighlighterTests.java b/src/test/java/org/elasticsearch/test/unit/deps/lucene/VectorHighlighterTests.java similarity index 88% rename from src/test/java/org/elasticsearch/deps/lucene/VectorHighlighterTests.java rename to src/test/java/org/elasticsearch/test/unit/deps/lucene/VectorHighlighterTests.java index bb44203d2b3..08039790693 100644 --- a/src/test/java/org/elasticsearch/deps/lucene/VectorHighlighterTests.java +++ b/src/test/java/org/elasticsearch/test/unit/deps/lucene/VectorHighlighterTests.java @@ -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 @@ -17,18 +17,14 @@ * under the License. */ -package org.elasticsearch.deps.lucene; +package org.elasticsearch.test.unit.deps.lucene; import org.apache.lucene.document.Field; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.index.Term; -import org.apache.lucene.search.IndexSearcher; -import org.apache.lucene.search.PrefixQuery; -import org.apache.lucene.search.Query; -import org.apache.lucene.search.TermQuery; -import org.apache.lucene.search.TopDocs; +import org.apache.lucene.search.*; import org.apache.lucene.search.vectorhighlight.CustomFieldQuery; import org.apache.lucene.search.vectorhighlight.FastVectorHighlighter; import org.apache.lucene.store.Directory; @@ -36,17 +32,19 @@ import org.apache.lucene.store.RAMDirectory; import org.elasticsearch.common.lucene.Lucene; import org.testng.annotations.Test; -import static org.elasticsearch.common.lucene.DocumentBuilder.*; -import static org.hamcrest.MatcherAssert.*; +import static org.elasticsearch.common.lucene.DocumentBuilder.doc; +import static org.elasticsearch.common.lucene.DocumentBuilder.field; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** - * @author kimchy (shay.banon) + * */ @Test public class VectorHighlighterTests { - @Test public void testVectorHighlighter() throws Exception { + @Test + public void testVectorHighlighter() throws Exception { Directory dir = new RAMDirectory(); IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER)); @@ -65,7 +63,8 @@ public class VectorHighlighterTests { System.out.println(fragment); } - @Test public void testVectorHighlighterPrefixQuery() throws Exception { + @Test + public void testVectorHighlighterPrefixQuery() throws Exception { Directory dir = new RAMDirectory(); IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER)); @@ -103,7 +102,8 @@ public class VectorHighlighterTests { System.out.println(fragment); } - @Test public void testVectorHighlighterNoStore() throws Exception { + @Test + public void testVectorHighlighterNoStore() throws Exception { Directory dir = new RAMDirectory(); IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER)); @@ -121,7 +121,8 @@ public class VectorHighlighterTests { assertThat(fragment, nullValue()); } - @Test public void testVectorHighlighterNoTermVector() throws Exception { + @Test + public void testVectorHighlighterNoTermVector() throws Exception { Directory dir = new RAMDirectory(); IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER)); diff --git a/src/test/java/org/elasticsearch/discovery/zen/ping/multicast/MulticastZenPingTests.java b/src/test/java/org/elasticsearch/test/unit/discovery/zen/ping/multicast/MulticastZenPingTests.java similarity index 84% rename from src/test/java/org/elasticsearch/discovery/zen/ping/multicast/MulticastZenPingTests.java rename to src/test/java/org/elasticsearch/test/unit/discovery/zen/ping/multicast/MulticastZenPingTests.java index 28b5aff28f0..9c2cce4476d 100644 --- a/src/test/java/org/elasticsearch/discovery/zen/ping/multicast/MulticastZenPingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/discovery/zen/ping/multicast/MulticastZenPingTests.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.discovery.zen.ping.multicast; +package org.elasticsearch.test.unit.discovery.zen.ping.multicast; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.node.DiscoveryNode; @@ -25,21 +25,23 @@ import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.discovery.zen.DiscoveryNodesProvider; import org.elasticsearch.discovery.zen.ping.ZenPing; +import org.elasticsearch.discovery.zen.ping.multicast.MulticastZenPing; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import org.elasticsearch.transport.local.LocalTransport; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ @Test public class MulticastZenPingTests { - @Test public void testSimplePings() { + @Test + public void testSimplePings() { ThreadPool threadPool = new ThreadPool(); ClusterName clusterName = new ClusterName("test"); final TransportService transportServiceA = new TransportService(new LocalTransport(threadPool), threadPool).start(); @@ -50,7 +52,8 @@ public class MulticastZenPingTests { MulticastZenPing zenPingA = new MulticastZenPing(threadPool, transportServiceA, clusterName); zenPingA.setNodesProvider(new DiscoveryNodesProvider() { - @Override public DiscoveryNodes nodes() { + @Override + public DiscoveryNodes nodes() { return DiscoveryNodes.newNodesBuilder().put(nodeA).localNodeId("A").build(); } }); @@ -58,7 +61,8 @@ public class MulticastZenPingTests { MulticastZenPing zenPingB = new MulticastZenPing(threadPool, transportServiceB, clusterName); zenPingB.setNodesProvider(new DiscoveryNodesProvider() { - @Override public DiscoveryNodes nodes() { + @Override + public DiscoveryNodes nodes() { return DiscoveryNodes.newNodesBuilder().put(nodeB).localNodeId("B").build(); } }); diff --git a/src/test/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPingTests.java b/src/test/java/org/elasticsearch/test/unit/discovery/zen/ping/unicast/UnicastZenPingTests.java similarity index 87% rename from src/test/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPingTests.java rename to src/test/java/org/elasticsearch/test/unit/discovery/zen/ping/unicast/UnicastZenPingTests.java index 6961eba6e20..eedf50d39d0 100644 --- a/src/test/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/discovery/zen/ping/unicast/UnicastZenPingTests.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.discovery.zen.ping.unicast; +package org.elasticsearch.test.unit.discovery.zen.ping.unicast; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.node.DiscoveryNode; @@ -28,20 +28,22 @@ import org.elasticsearch.common.transport.InetSocketTransportAddress; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.discovery.zen.DiscoveryNodesProvider; import org.elasticsearch.discovery.zen.ping.ZenPing; +import org.elasticsearch.discovery.zen.ping.unicast.UnicastZenPing; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import org.elasticsearch.transport.netty.NettyTransport; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class UnicastZenPingTests { - @Test public void testSimplePings() { + @Test + public void testSimplePings() { ThreadPool threadPool = new ThreadPool(); ClusterName clusterName = new ClusterName("test"); NettyTransport transportA = new NettyTransport(threadPool); @@ -63,7 +65,8 @@ public class UnicastZenPingTests { UnicastZenPing zenPingA = new UnicastZenPing(hostsSettings, threadPool, transportServiceA, clusterName); zenPingA.setNodesProvider(new DiscoveryNodesProvider() { - @Override public DiscoveryNodes nodes() { + @Override + public DiscoveryNodes nodes() { return DiscoveryNodes.newNodesBuilder().put(nodeA).localNodeId("A").build(); } }); @@ -71,7 +74,8 @@ public class UnicastZenPingTests { UnicastZenPing zenPingB = new UnicastZenPing(hostsSettings, threadPool, transportServiceB, clusterName); zenPingB.setNodesProvider(new DiscoveryNodesProvider() { - @Override public DiscoveryNodes nodes() { + @Override + public DiscoveryNodes nodes() { return DiscoveryNodes.newNodesBuilder().put(nodeB).localNodeId("B").build(); } }); diff --git a/src/test/java/org/elasticsearch/index/aliases/IndexAliasesServiceTests.java b/src/test/java/org/elasticsearch/test/unit/index/aliases/IndexAliasesServiceTests.java similarity index 88% rename from src/test/java/org/elasticsearch/index/aliases/IndexAliasesServiceTests.java rename to src/test/java/org/elasticsearch/test/unit/index/aliases/IndexAliasesServiceTests.java index f069569db3e..9b9245e1703 100644 --- a/src/test/java/org/elasticsearch/index/aliases/IndexAliasesServiceTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/aliases/IndexAliasesServiceTests.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.aliases; +package org.elasticsearch.test.unit.index.aliases; import org.elasticsearch.common.compress.CompressedString; import org.elasticsearch.common.inject.Injector; @@ -29,6 +29,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexNameModule; +import org.elasticsearch.index.aliases.IndexAliasesService; import org.elasticsearch.index.analysis.AnalysisModule; import org.elasticsearch.index.cache.IndexCacheModule; import org.elasticsearch.index.engine.IndexEngineModule; @@ -43,12 +44,13 @@ import org.testng.annotations.Test; import java.io.IOException; -import static org.elasticsearch.index.query.FilterBuilders.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.index.query.FilterBuilders.termFilter; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.nullValue; /** - * @author imotov + * */ public class IndexAliasesServiceTests { public static IndexAliasesService newIndexAliasesService() { @@ -77,7 +79,8 @@ public class IndexAliasesServiceTests { return new CompressedString(builder.string()); } - @Test public void testFilteringAliases() throws Exception { + @Test + public void testFilteringAliases() throws Exception { IndexAliasesService indexAliasesService = newIndexAliasesService(); indexAliasesService.add("cats", filter(termFilter("animal", "cat"))); indexAliasesService.add("dogs", filter(termFilter("animal", "dog"))); @@ -100,7 +103,8 @@ public class IndexAliasesServiceTests { assertThat(indexAliasesService.aliasFilter("dogs", "cats").toString(), equalTo("BooleanFilter( FilterCacheFilterWrapper(animal:canine) FilterCacheFilterWrapper(animal:feline))")); } - @Test public void testAliasFilters() throws Exception { + @Test + public void testAliasFilters() throws Exception { IndexAliasesService indexAliasesService = newIndexAliasesService(); indexAliasesService.add("cats", filter(termFilter("animal", "cat"))); indexAliasesService.add("dogs", filter(termFilter("animal", "dog"))); @@ -115,7 +119,8 @@ public class IndexAliasesServiceTests { assertThat(indexAliasesService.aliasFilter("dogs", "cats").toString(), equalTo("BooleanFilter( FilterCacheFilterWrapper(animal:canine) FilterCacheFilterWrapper(animal:feline))")); } - @Test(expectedExceptions = InvalidAliasNameException.class) public void testRemovedAliasFilter() throws Exception { + @Test(expectedExceptions = InvalidAliasNameException.class) + public void testRemovedAliasFilter() throws Exception { IndexAliasesService indexAliasesService = newIndexAliasesService(); indexAliasesService.add("cats", filter(termFilter("animal", "cat"))); indexAliasesService.remove("cats"); @@ -123,7 +128,8 @@ public class IndexAliasesServiceTests { } - @Test(expectedExceptions = InvalidAliasNameException.class) public void testUnknownAliasFilter() throws Exception { + @Test(expectedExceptions = InvalidAliasNameException.class) + public void testUnknownAliasFilter() throws Exception { IndexAliasesService indexAliasesService = newIndexAliasesService(); indexAliasesService.add("cats", filter(termFilter("animal", "cat"))); indexAliasesService.add("dogs", filter(termFilter("animal", "dog"))); diff --git a/src/test/java/org/elasticsearch/index/analysis/AnalysisModuleTests.java b/src/test/java/org/elasticsearch/test/unit/index/analysis/AnalysisModuleTests.java similarity index 90% rename from src/test/java/org/elasticsearch/index/analysis/AnalysisModuleTests.java rename to src/test/java/org/elasticsearch/test/unit/index/analysis/AnalysisModuleTests.java index c13bd844bd1..a74d39f5825 100644 --- a/src/test/java/org/elasticsearch/index/analysis/AnalysisModuleTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/analysis/AnalysisModuleTests.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.analysis; +package org.elasticsearch.test.unit.index.analysis; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.standard.StandardAnalyzer; @@ -31,7 +31,8 @@ import org.elasticsearch.env.Environment; import org.elasticsearch.env.EnvironmentModule; import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexNameModule; -import org.elasticsearch.index.analysis.filter1.MyFilterTokenFilterFactory; +import org.elasticsearch.index.analysis.*; +import org.elasticsearch.test.unit.index.analysis.filter1.MyFilterTokenFilterFactory; import org.elasticsearch.index.analysis.phonetic.PhoneticTokenFilterFactory; import org.elasticsearch.index.settings.IndexSettingsModule; import org.elasticsearch.indices.analysis.IndicesAnalysisModule; @@ -44,22 +45,25 @@ import java.io.File; import java.io.FileWriter; import java.util.Set; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.instanceOf; /** - * @author kimchy (shay.banon) + * */ public class AnalysisModuleTests { - @Test public void testSimpleConfigurationJson() { - Settings settings = settingsBuilder().loadFromClasspath("org/elasticsearch/index/analysis/test1.json").build(); + @Test + public void testSimpleConfigurationJson() { + Settings settings = settingsBuilder().loadFromClasspath("org/elasticsearch/test/unit/index/analysis/test1.json").build(); testSimpleConfiguration(settings); } - @Test public void testSimpleConfigurationYaml() { - Settings settings = settingsBuilder().loadFromClasspath("org/elasticsearch/index/analysis/test1.yml").build(); + @Test + public void testSimpleConfigurationYaml() { + Settings settings = settingsBuilder().loadFromClasspath("org/elasticsearch/test/unit/index/analysis/test1.yml").build(); testSimpleConfiguration(settings); } @@ -138,7 +142,8 @@ public class AnalysisModuleTests { // MatcherAssert.assertThat(wordList, hasItems("donau", "dampf", "schiff", "spargel", "creme", "suppe")); } - @Test public void testWordListPath() throws Exception { + @Test + public void testWordListPath() throws Exception { Environment env = new Environment(ImmutableSettings.Builder.EMPTY_SETTINGS); String[] words = new String[]{"donau", "dampf", "schiff", "spargel", "creme", "suppe"}; diff --git a/src/test/java/org/elasticsearch/index/analysis/CompoundAnalysisTests.java b/src/test/java/org/elasticsearch/test/unit/index/analysis/CompoundAnalysisTests.java similarity index 88% rename from src/test/java/org/elasticsearch/index/analysis/CompoundAnalysisTests.java rename to src/test/java/org/elasticsearch/test/unit/index/analysis/CompoundAnalysisTests.java index 4dec33a7e55..61ed2179a4d 100644 --- a/src/test/java/org/elasticsearch/index/analysis/CompoundAnalysisTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/analysis/CompoundAnalysisTests.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.analysis; +package org.elasticsearch.test.unit.index.analysis; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.TokenStream; @@ -32,6 +32,9 @@ import org.elasticsearch.env.Environment; import org.elasticsearch.env.EnvironmentModule; import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexNameModule; +import org.elasticsearch.index.analysis.AnalysisModule; +import org.elasticsearch.index.analysis.AnalysisService; +import org.elasticsearch.index.analysis.TokenFilterFactory; import org.elasticsearch.index.analysis.compound.DictionaryCompoundWordTokenFilterFactory; import org.elasticsearch.index.settings.IndexSettingsModule; import org.elasticsearch.indices.analysis.IndicesAnalysisModule; @@ -43,15 +46,15 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; -import static org.elasticsearch.common.settings.ImmutableSettings.*; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.hamcrest.Matchers.*; /** - * @author Edward Dale (scompt@scompt.com) */ public class CompoundAnalysisTests { - @Test public void testDefaultsCompoundAnalysis() throws Exception { + @Test + public void testDefaultsCompoundAnalysis() throws Exception { Index index = new Index("test"); Settings settings = getJsonSettings(); Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings), new EnvironmentModule(new Environment(settings)), new IndicesAnalysisModule()).createInjector(); @@ -67,7 +70,8 @@ public class CompoundAnalysisTests { MatcherAssert.assertThat(filterFactory, instanceOf(DictionaryCompoundWordTokenFilterFactory.class)); } - @Test public void testDictionaryDecompounder() throws Exception { + @Test + public void testDictionaryDecompounder() throws Exception { Settings[] settingsArr = new Settings[]{getJsonSettings(), getYamlSettings()}; for (Settings settings : settingsArr) { List terms = analyze(settings, "decompoundingAnalyzer", "donaudampfschiff spargelcremesuppe"); @@ -105,10 +109,10 @@ public class CompoundAnalysisTests { } private Settings getJsonSettings() { - return settingsBuilder().loadFromClasspath("org/elasticsearch/index/analysis/test1.json").build(); + return settingsBuilder().loadFromClasspath("org/elasticsearch/test/unit/index/analysis/test1.json").build(); } private Settings getYamlSettings() { - return settingsBuilder().loadFromClasspath("org/elasticsearch/index/analysis/test1.yml").build(); + return settingsBuilder().loadFromClasspath("org/elasticsearch/test/unit/index/analysis/test1.yml").build(); } } diff --git a/src/test/java/org/elasticsearch/index/analysis/filter1/MyFilterTokenFilterFactory.java b/src/test/java/org/elasticsearch/test/unit/index/analysis/filter1/MyFilterTokenFilterFactory.java similarity index 86% rename from src/test/java/org/elasticsearch/index/analysis/filter1/MyFilterTokenFilterFactory.java rename to src/test/java/org/elasticsearch/test/unit/index/analysis/filter1/MyFilterTokenFilterFactory.java index 1f8adf0a0e1..cb3ed833823 100644 --- a/src/test/java/org/elasticsearch/index/analysis/filter1/MyFilterTokenFilterFactory.java +++ b/src/test/java/org/elasticsearch/test/unit/index/analysis/filter1/MyFilterTokenFilterFactory.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.analysis.filter1; +package org.elasticsearch.test.unit.index.analysis.filter1; import org.apache.lucene.analysis.StopAnalyzer; import org.apache.lucene.analysis.StopFilter; @@ -31,11 +31,13 @@ import org.elasticsearch.index.settings.IndexSettings; public class MyFilterTokenFilterFactory extends AbstractTokenFilterFactory { - @Inject public MyFilterTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, String name) { + @Inject + public MyFilterTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, String name) { super(index, indexSettings, name, ImmutableSettings.Builder.EMPTY_SETTINGS); } - @Override public TokenStream create(TokenStream tokenStream) { + @Override + public TokenStream create(TokenStream tokenStream) { return new StopFilter(version, tokenStream, StopAnalyzer.ENGLISH_STOP_WORDS_SET); } } \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/analysis/synonyms/SynonymsAnalysisTest.java b/src/test/java/org/elasticsearch/test/unit/index/analysis/synonyms/SynonymsAnalysisTest.java similarity index 91% rename from src/test/java/org/elasticsearch/index/analysis/synonyms/SynonymsAnalysisTest.java rename to src/test/java/org/elasticsearch/test/unit/index/analysis/synonyms/SynonymsAnalysisTest.java index 712deb1d5e4..db9a1b3b827 100644 --- a/src/test/java/org/elasticsearch/index/analysis/synonyms/SynonymsAnalysisTest.java +++ b/src/test/java/org/elasticsearch/test/unit/index/analysis/synonyms/SynonymsAnalysisTest.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.analysis.synonyms; +package org.elasticsearch.test.unit.index.analysis.synonyms; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.TokenStream; @@ -45,19 +45,19 @@ import org.testng.annotations.Test; import java.io.IOException; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.Matchers.equalTo; /** - * @author Lukas Vlcek */ public class SynonymsAnalysisTest { protected final ESLogger logger = Loggers.getLogger(getClass()); private AnalysisService analysisService; - @Test public void testSynonymsAnalysis() throws IOException { + @Test + public void testSynonymsAnalysis() throws IOException { - Settings settings = settingsBuilder().loadFromClasspath("org/elasticsearch/index/analysis/synonyms/synonyms.json").build(); + Settings settings = settingsBuilder().loadFromClasspath("org/elasticsearch/test/unit/index/analysis/synonyms/synonyms.json").build(); Index index = new Index("test"); diff --git a/src/test/java/org/elasticsearch/test/unit/index/analysis/synonyms/synonyms.json b/src/test/java/org/elasticsearch/test/unit/index/analysis/synonyms/synonyms.json new file mode 100644 index 00000000000..df24eade6d0 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/analysis/synonyms/synonyms.json @@ -0,0 +1,52 @@ +{ + "index":{ + "analysis":{ + "analyzer":{ + "synonymAnalyzer":{ + "tokenizer":"standard", + "filter":[ "synonym" ] + }, + "synonymAnalyzer_file":{ + "tokenizer":"standard", + "filter":[ "synonym_file" ] + }, + "synonymAnalyzerWordnet":{ + "tokenizer":"standard", + "filter":[ "synonymWordnet" ] + }, + "synonymAnalyzerWordnet_file":{ + "tokenizer":"standard", + "filter":[ "synonymWordnet_file" ] + } + }, + "filter":{ + "synonym":{ + "type":"synonym", + "synonyms":[ + "kimchy => shay", + "dude => elasticsearch", + "abides => man!" + ] + }, + "synonym_file":{ + "type":"synonym", + "synonyms_path":"org/elasticsearch/test/unit/index/analysis/synonyms/synonyms.txt" + }, + "synonymWordnet":{ + "type":"synonym", + "format":"wordnet", + "synonyms":[ + "s(100000001,1,'abstain',v,1,0).", + "s(100000001,2,'refrain',v,1,0).", + "s(100000001,3,'desist',v,1,0)." + ] + }, + "synonymWordnet_file":{ + "type":"synonym", + "format":"wordnet", + "synonyms_path":"org/elasticsearch/test/unit/index/analysis/synonyms/synonyms_wordnet.txt" + } + } + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/analysis/synonyms/synonyms.txt b/src/test/java/org/elasticsearch/test/unit/index/analysis/synonyms/synonyms.txt similarity index 100% rename from src/test/java/org/elasticsearch/index/analysis/synonyms/synonyms.txt rename to src/test/java/org/elasticsearch/test/unit/index/analysis/synonyms/synonyms.txt diff --git a/src/test/java/org/elasticsearch/index/analysis/synonyms/synonyms_wordnet.txt b/src/test/java/org/elasticsearch/test/unit/index/analysis/synonyms/synonyms_wordnet.txt similarity index 100% rename from src/test/java/org/elasticsearch/index/analysis/synonyms/synonyms_wordnet.txt rename to src/test/java/org/elasticsearch/test/unit/index/analysis/synonyms/synonyms_wordnet.txt diff --git a/src/test/java/org/elasticsearch/test/unit/index/analysis/test1.json b/src/test/java/org/elasticsearch/test/unit/index/analysis/test1.json new file mode 100644 index 00000000000..6b7a8ec67d7 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/analysis/test1.json @@ -0,0 +1,79 @@ +{ + "index":{ + "analysis":{ + "tokenizer":{ + "standard":{ + "type":"standard" + } + }, + "char_filter":{ + "my_html":{ + "type":"html_strip", + "escaped_tags":["xxx", "yyy"], + "read_ahead":1024 + }, + "my_mapping":{ + "type":"mapping", + "mappings":["ph=>f", "qu=>q"] + } + }, + "filter":{ + "stop":{ + "type":"stop", + "stopwords":["test-stop"] + }, + "stop2":{ + "type":"stop", + "stopwords":["stop2-1", "stop2-2"] + }, + "metaphone":{ + "type":"phonetic", + "encoder":"metaphone" + }, + "my":{ + "type":"org.elasticsearch.test.unit.index.analysis.filter1.MyFilterTokenFilterFactory" + }, + "dict_dec":{ + "type":"dictionary_decompounder", + "word_list":["donau", "dampf", "schiff", "spargel", "creme", "suppe"] + } + }, + "analyzer":{ + "standard":{ + "alias":"alias1,alias2", + "type":"standard", + "stopwords":["test1", "test2", "test3"] + }, + "custom1":{ + "alias":["alias4", "alias5"], + "tokenizer":"standard", + "filter":["stop", "stop2"] + }, + "custom2":{ + "tokenizer":"standard", + "char_filter":["html_strip", "my_html"] + }, + "custom3":{ + "tokenizer":"standard", + "filter":["metaphone"] + }, + "custom4":{ + "tokenizer":"standard", + "filter":["my"] + }, + "custom5":{ + "tokenizer":"standard", + "char_filter":["my_mapping"] + }, + "czechAnalyzerWithStemmer":{ + "tokenizer":"standard", + "filter":["standard", "lowercase", "stop", "czech_stem"] + }, + "decompoundingAnalyzer":{ + "tokenizer":"standard", + "filter":["dict_dec"] + } + } + } + } +} diff --git a/src/test/java/org/elasticsearch/index/analysis/test1.yml b/src/test/java/org/elasticsearch/test/unit/index/analysis/test1.yml similarity index 93% rename from src/test/java/org/elasticsearch/index/analysis/test1.yml rename to src/test/java/org/elasticsearch/test/unit/index/analysis/test1.yml index de94e810a11..f6c1bc0b0b7 100644 --- a/src/test/java/org/elasticsearch/index/analysis/test1.yml +++ b/src/test/java/org/elasticsearch/test/unit/index/analysis/test1.yml @@ -22,7 +22,7 @@ index : type : phonetic encoder : metaphone my : - type : org.elasticsearch.index.analysis.filter1.MyFilterTokenFilterFactory + type : org.elasticsearch.test.unit.index.analysis.filter1.MyFilterTokenFilterFactory dict_dec : type : dictionary_decompounder word_list : [donau, dampf, schiff, spargel, creme, suppe] diff --git a/src/test/java/org/elasticsearch/index/cache/filter/FilterCacheTests.java b/src/test/java/org/elasticsearch/test/unit/index/cache/filter/FilterCacheTests.java similarity index 82% rename from src/test/java/org/elasticsearch/index/cache/filter/FilterCacheTests.java rename to src/test/java/org/elasticsearch/test/unit/index/cache/filter/FilterCacheTests.java index c673f18fb1a..ffdd05098ff 100644 --- a/src/test/java/org/elasticsearch/index/cache/filter/FilterCacheTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/cache/filter/FilterCacheTests.java @@ -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 @@ -17,23 +17,19 @@ * under the License. */ -package org.elasticsearch.index.cache.filter; +package org.elasticsearch.test.unit.index.cache.filter; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.index.Term; -import org.apache.lucene.search.ConstantScoreQuery; -import org.apache.lucene.search.DeletionAwareConstantScoreQuery; -import org.apache.lucene.search.Filter; -import org.apache.lucene.search.FilteredQuery; -import org.apache.lucene.search.IndexSearcher; -import org.apache.lucene.search.MatchAllDocsQuery; +import org.apache.lucene.search.*; import org.apache.lucene.store.Directory; import org.apache.lucene.store.RAMDirectory; import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.common.lucene.search.TermFilter; import org.elasticsearch.index.Index; +import org.elasticsearch.index.cache.filter.FilterCache; import org.elasticsearch.index.cache.filter.none.NoneFilterCache; import org.elasticsearch.index.cache.filter.soft.SoftFilterCache; import org.elasticsearch.index.cache.filter.weak.WeakFilterCache; @@ -42,26 +38,30 @@ import org.testng.annotations.Test; import java.io.IOException; -import static org.elasticsearch.common.lucene.DocumentBuilder.*; -import static org.elasticsearch.common.settings.ImmutableSettings.Builder.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.lucene.DocumentBuilder.doc; +import static org.elasticsearch.common.lucene.DocumentBuilder.field; +import static org.elasticsearch.common.settings.ImmutableSettings.Builder.EMPTY_SETTINGS; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class FilterCacheTests { - @Test public void testNoCache() throws Exception { + @Test + public void testNoCache() throws Exception { verifyCache(new NoneFilterCache(new Index("test"), EMPTY_SETTINGS)); } - @Test public void testSoftCache() throws Exception { + @Test + public void testSoftCache() throws Exception { verifyCache(new SoftFilterCache(new Index("test"), EMPTY_SETTINGS, new IndexSettingsService(new Index("test"), EMPTY_SETTINGS))); } - @Test public void testWeakCache() throws Exception { + @Test + public void testWeakCache() throws Exception { verifyCache(new WeakFilterCache(new Index("test"), EMPTY_SETTINGS, new IndexSettingsService(new Index("test"), EMPTY_SETTINGS))); } diff --git a/src/test/java/org/elasticsearch/index/deletionpolicy/SnapshotDeletionPolicyTests.java b/src/test/java/org/elasticsearch/test/unit/index/deletionpolicy/SnapshotDeletionPolicyTests.java similarity index 83% rename from src/test/java/org/elasticsearch/index/deletionpolicy/SnapshotDeletionPolicyTests.java rename to src/test/java/org/elasticsearch/test/unit/index/deletionpolicy/SnapshotDeletionPolicyTests.java index 60f64f7d0d6..f0957eb9ae2 100644 --- a/src/test/java/org/elasticsearch/index/deletionpolicy/SnapshotDeletionPolicyTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/deletionpolicy/SnapshotDeletionPolicyTests.java @@ -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 @@ -17,27 +17,32 @@ * under the License. */ -package org.elasticsearch.index.deletionpolicy; +package org.elasticsearch.test.unit.index.deletionpolicy; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.store.RAMDirectory; import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.index.Index; +import org.elasticsearch.index.deletionpolicy.KeepOnlyLastDeletionPolicy; +import org.elasticsearch.index.deletionpolicy.SnapshotDeletionPolicy; +import org.elasticsearch.index.deletionpolicy.SnapshotIndexCommit; +import org.elasticsearch.index.deletionpolicy.SnapshotIndexCommits; import org.elasticsearch.index.shard.ShardId; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static org.apache.lucene.index.IndexReader.*; -import static org.elasticsearch.common.lucene.DocumentBuilder.*; -import static org.elasticsearch.common.settings.ImmutableSettings.Builder.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.apache.lucene.index.IndexReader.listCommits; +import static org.elasticsearch.common.lucene.DocumentBuilder.doc; +import static org.elasticsearch.common.lucene.DocumentBuilder.field; +import static org.elasticsearch.common.settings.ImmutableSettings.Builder.EMPTY_SETTINGS; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * A set of tests for {@link SnapshotDeletionPolicy}. + * A set of tests for {@link org.elasticsearch.index.deletionpolicy.SnapshotDeletionPolicy}. + * * - * @author kimchy (Shay Banon) */ public class SnapshotDeletionPolicyTests { @@ -47,18 +52,21 @@ public class SnapshotDeletionPolicyTests { private SnapshotDeletionPolicy deletionPolicy; private IndexWriter indexWriter; - @BeforeClass public void setUp() throws Exception { + @BeforeClass + public void setUp() throws Exception { dir = new RAMDirectory(); deletionPolicy = new SnapshotDeletionPolicy(new KeepOnlyLastDeletionPolicy(shardId, EMPTY_SETTINGS)); indexWriter = new IndexWriter(dir, Lucene.STANDARD_ANALYZER, true, deletionPolicy, IndexWriter.MaxFieldLength.UNLIMITED); } - @AfterClass public void tearDown() throws Exception { + @AfterClass + public void tearDown() throws Exception { indexWriter.close(); dir.close(); } - @Test public void testSimpleSnapshot() throws Exception { + @Test + public void testSimpleSnapshot() throws Exception { // add a document and commit, resulting in one commit point indexWriter.addDocument(doc().add(field("test", "1")).build()); indexWriter.commit(); @@ -83,7 +91,8 @@ public class SnapshotDeletionPolicyTests { assertThat(listCommits(dir).size(), equalTo(1)); } - @Test public void testMultiSnapshot() throws Exception { + @Test + public void testMultiSnapshot() throws Exception { // add a document and commit, resulting in one commit point indexWriter.addDocument(doc().add(field("test", "1")).build()); indexWriter.commit(); @@ -111,7 +120,8 @@ public class SnapshotDeletionPolicyTests { assertThat(listCommits(dir).size(), equalTo(1)); } - @Test public void testMultiReleaseException() throws Exception { + @Test + public void testMultiReleaseException() throws Exception { // add a document and commit, resulting in one commit point indexWriter.addDocument(doc().add(field("test", "1")).build()); indexWriter.commit(); @@ -123,7 +133,8 @@ public class SnapshotDeletionPolicyTests { assertThat(snapshot.release(), equalTo(false)); } - @Test public void testSimpleSnapshots() throws Exception { + @Test + public void testSimpleSnapshots() throws Exception { // add a document and commit, resulting in one commit point indexWriter.addDocument(doc().add(field("test", "1")).build()); indexWriter.commit(); diff --git a/src/test/java/org/elasticsearch/index/deletionpolicy/SnapshotIndexCommitExistsMatcher.java b/src/test/java/org/elasticsearch/test/unit/index/deletionpolicy/SnapshotIndexCommitExistsMatcher.java similarity index 78% rename from src/test/java/org/elasticsearch/index/deletionpolicy/SnapshotIndexCommitExistsMatcher.java rename to src/test/java/org/elasticsearch/test/unit/index/deletionpolicy/SnapshotIndexCommitExistsMatcher.java index 09625730a7d..faef66556b3 100644 --- a/src/test/java/org/elasticsearch/index/deletionpolicy/SnapshotIndexCommitExistsMatcher.java +++ b/src/test/java/org/elasticsearch/test/unit/index/deletionpolicy/SnapshotIndexCommitExistsMatcher.java @@ -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 @@ -17,8 +17,9 @@ * under the License. */ -package org.elasticsearch.index.deletionpolicy; +package org.elasticsearch.test.unit.index.deletionpolicy; +import org.elasticsearch.index.deletionpolicy.SnapshotIndexCommit; import org.hamcrest.Description; import org.hamcrest.Matcher; import org.hamcrest.TypeSafeMatcher; @@ -26,11 +27,12 @@ import org.hamcrest.TypeSafeMatcher; import java.io.IOException; /** - * @author kimchy (Shay Banon) + * */ public class SnapshotIndexCommitExistsMatcher extends TypeSafeMatcher { - @Override public boolean matchesSafely(SnapshotIndexCommit snapshotIndexCommit) { + @Override + public boolean matchesSafely(SnapshotIndexCommit snapshotIndexCommit) { for (String fileName : snapshotIndexCommit.getFiles()) { try { if (!snapshotIndexCommit.getDirectory().fileExists(fileName)) { @@ -43,7 +45,8 @@ public class SnapshotIndexCommitExistsMatcher extends TypeSafeMatcher segments = engine.segments(); assertThat(segments.isEmpty(), equalTo(true)); @@ -196,9 +201,10 @@ public abstract class AbstractSimpleEngineTests { assertThat(segments.get(1).deletedDocs(), equalTo(0)); } - @Test public void testSimpleOperations() throws Exception { + @Test + public void testSimpleOperations() throws Exception { Engine.Searcher searchResult = engine.searcher(); - assertThat(searchResult, engineSearcherTotalHits(0)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(0)); searchResult.release(); // create a document @@ -207,8 +213,8 @@ public abstract class AbstractSimpleEngineTests { // its not there... searchResult = engine.searcher(); - assertThat(searchResult, engineSearcherTotalHits(0)); - assertThat(searchResult, engineSearcherTotalHits(new TermQuery(new Term("value", "test")), 0)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(0)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(new TermQuery(new Term("value", "test")), 0)); searchResult.release(); // but, we can still get it (in realtime) @@ -226,8 +232,8 @@ public abstract class AbstractSimpleEngineTests { // now its there... searchResult = engine.searcher(); - assertThat(searchResult, engineSearcherTotalHits(1)); - assertThat(searchResult, engineSearcherTotalHits(new TermQuery(new Term("value", "test")), 1)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(1)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(new TermQuery(new Term("value", "test")), 1)); searchResult.release(); // also in non realtime @@ -241,9 +247,9 @@ public abstract class AbstractSimpleEngineTests { // its not updated yet... searchResult = engine.searcher(); - assertThat(searchResult, engineSearcherTotalHits(1)); - assertThat(searchResult, engineSearcherTotalHits(new TermQuery(new Term("value", "test")), 1)); - assertThat(searchResult, engineSearcherTotalHits(new TermQuery(new Term("value", "test1")), 0)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(1)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(new TermQuery(new Term("value", "test")), 1)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(new TermQuery(new Term("value", "test1")), 0)); searchResult.release(); // but, we can still get it (in realtime) @@ -256,9 +262,9 @@ public abstract class AbstractSimpleEngineTests { engine.refresh(new Engine.Refresh(true)); searchResult = engine.searcher(); - assertThat(searchResult, engineSearcherTotalHits(1)); - assertThat(searchResult, engineSearcherTotalHits(new TermQuery(new Term("value", "test")), 0)); - assertThat(searchResult, engineSearcherTotalHits(new TermQuery(new Term("value", "test1")), 1)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(1)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(new TermQuery(new Term("value", "test")), 0)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(new TermQuery(new Term("value", "test1")), 1)); searchResult.release(); // now delete @@ -266,9 +272,9 @@ public abstract class AbstractSimpleEngineTests { // its not deleted yet searchResult = engine.searcher(); - assertThat(searchResult, engineSearcherTotalHits(1)); - assertThat(searchResult, engineSearcherTotalHits(new TermQuery(new Term("value", "test")), 0)); - assertThat(searchResult, engineSearcherTotalHits(new TermQuery(new Term("value", "test1")), 1)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(1)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(new TermQuery(new Term("value", "test")), 0)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(new TermQuery(new Term("value", "test1")), 1)); searchResult.release(); // but, get should not see it (in realtime) @@ -279,9 +285,9 @@ public abstract class AbstractSimpleEngineTests { engine.refresh(new Engine.Refresh(true)); searchResult = engine.searcher(); - assertThat(searchResult, engineSearcherTotalHits(0)); - assertThat(searchResult, engineSearcherTotalHits(new TermQuery(new Term("value", "test")), 0)); - assertThat(searchResult, engineSearcherTotalHits(new TermQuery(new Term("value", "test1")), 0)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(0)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(new TermQuery(new Term("value", "test")), 0)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(new TermQuery(new Term("value", "test1")), 0)); searchResult.release(); // add it back @@ -290,9 +296,9 @@ public abstract class AbstractSimpleEngineTests { // its not there... searchResult = engine.searcher(); - assertThat(searchResult, engineSearcherTotalHits(0)); - assertThat(searchResult, engineSearcherTotalHits(new TermQuery(new Term("value", "test")), 0)); - assertThat(searchResult, engineSearcherTotalHits(new TermQuery(new Term("value", "test1")), 0)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(0)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(new TermQuery(new Term("value", "test")), 0)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(new TermQuery(new Term("value", "test1")), 0)); searchResult.release(); // refresh and it should be there @@ -300,9 +306,9 @@ public abstract class AbstractSimpleEngineTests { // now its there... searchResult = engine.searcher(); - assertThat(searchResult, engineSearcherTotalHits(1)); - assertThat(searchResult, engineSearcherTotalHits(new TermQuery(new Term("value", "test")), 1)); - assertThat(searchResult, engineSearcherTotalHits(new TermQuery(new Term("value", "test1")), 0)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(1)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(new TermQuery(new Term("value", "test")), 1)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(new TermQuery(new Term("value", "test1")), 0)); searchResult.release(); // now flush @@ -322,26 +328,27 @@ public abstract class AbstractSimpleEngineTests { // its not updated yet... searchResult = engine.searcher(); - assertThat(searchResult, engineSearcherTotalHits(1)); - assertThat(searchResult, engineSearcherTotalHits(new TermQuery(new Term("value", "test")), 1)); - assertThat(searchResult, engineSearcherTotalHits(new TermQuery(new Term("value", "test1")), 0)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(1)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(new TermQuery(new Term("value", "test")), 1)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(new TermQuery(new Term("value", "test1")), 0)); searchResult.release(); // refresh and it should be updated engine.refresh(new Engine.Refresh(true)); searchResult = engine.searcher(); - assertThat(searchResult, engineSearcherTotalHits(1)); - assertThat(searchResult, engineSearcherTotalHits(new TermQuery(new Term("value", "test")), 0)); - assertThat(searchResult, engineSearcherTotalHits(new TermQuery(new Term("value", "test1")), 1)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(1)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(new TermQuery(new Term("value", "test")), 0)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(new TermQuery(new Term("value", "test1")), 1)); searchResult.release(); engine.close(); } - @Test public void testSearchResultRelease() throws Exception { + @Test + public void testSearchResultRelease() throws Exception { Engine.Searcher searchResult = engine.searcher(); - assertThat(searchResult, engineSearcherTotalHits(0)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(0)); searchResult.release(); // create a document @@ -350,8 +357,8 @@ public abstract class AbstractSimpleEngineTests { // its not there... searchResult = engine.searcher(); - assertThat(searchResult, engineSearcherTotalHits(0)); - assertThat(searchResult, engineSearcherTotalHits(new TermQuery(new Term("value", "test")), 0)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(0)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(new TermQuery(new Term("value", "test")), 0)); searchResult.release(); // refresh and it should be there @@ -359,24 +366,25 @@ public abstract class AbstractSimpleEngineTests { // now its there... searchResult = engine.searcher(); - assertThat(searchResult, engineSearcherTotalHits(1)); - assertThat(searchResult, engineSearcherTotalHits(new TermQuery(new Term("value", "test")), 1)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(1)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(new TermQuery(new Term("value", "test")), 1)); // don't release the search result yet... // delete, refresh and do a new search, it should not be there engine.delete(new Engine.Delete("test", "1", newUid("1"))); engine.refresh(new Engine.Refresh(true)); Engine.Searcher updateSearchResult = engine.searcher(); - assertThat(updateSearchResult, engineSearcherTotalHits(0)); + MatcherAssert.assertThat(updateSearchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(0)); updateSearchResult.release(); // the non release search result should not see the deleted yet... - assertThat(searchResult, engineSearcherTotalHits(1)); - assertThat(searchResult, engineSearcherTotalHits(new TermQuery(new Term("value", "test")), 1)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(1)); + MatcherAssert.assertThat(searchResult, EngineSearcherTotalHitsMatcher.engineSearcherTotalHits(new TermQuery(new Term("value", "test")), 1)); searchResult.release(); } - @Test public void testSimpleSnapshot() throws Exception { + @Test + public void testSimpleSnapshot() throws Exception { // create a document ParsedDocument doc1 = new ParsedDocument("1", "1", "test", null, -1, -1, doc().add(uidField("1")).add(field("value", "test")).build(), Lucene.STANDARD_ANALYZER, B_1, false); engine.create(new Engine.Create(null, newUid("1"), doc1)); @@ -384,15 +392,17 @@ public abstract class AbstractSimpleEngineTests { final ExecutorService executorService = Executors.newCachedThreadPool(); engine.snapshot(new Engine.SnapshotHandler() { - @Override public Void snapshot(final SnapshotIndexCommit snapshotIndexCommit1, final Translog.Snapshot translogSnapshot1) { - assertThat(snapshotIndexCommit1, snapshotIndexCommitExists()); + @Override + public Void snapshot(final SnapshotIndexCommit snapshotIndexCommit1, final Translog.Snapshot translogSnapshot1) { + MatcherAssert.assertThat(snapshotIndexCommit1, SnapshotIndexCommitExistsMatcher.snapshotIndexCommitExists()); assertThat(translogSnapshot1.hasNext(), equalTo(true)); Translog.Create create1 = (Translog.Create) translogSnapshot1.next(); assertThat(create1.source(), equalTo(B_1)); assertThat(translogSnapshot1.hasNext(), equalTo(false)); Future future = executorService.submit(new Callable() { - @Override public Object call() throws Exception { + @Override + public Object call() throws Exception { engine.flush(new Engine.Flush()); ParsedDocument doc2 = new ParsedDocument("2", "2", "test", null, -1, -1, doc().add(uidField("2")).add(field("value", "test")).build(), Lucene.STANDARD_ANALYZER, B_2, false); engine.create(new Engine.Create(null, newUid("2"), doc2)); @@ -410,12 +420,13 @@ public abstract class AbstractSimpleEngineTests { assertThat(e.getMessage(), false, equalTo(true)); } - assertThat(snapshotIndexCommit1, snapshotIndexCommitExists()); + MatcherAssert.assertThat(snapshotIndexCommit1, SnapshotIndexCommitExistsMatcher.snapshotIndexCommitExists()); engine.snapshot(new Engine.SnapshotHandler() { - @Override public Void snapshot(SnapshotIndexCommit snapshotIndexCommit2, Translog.Snapshot translogSnapshot2) throws EngineException { - assertThat(snapshotIndexCommit1, snapshotIndexCommitExists()); - assertThat(snapshotIndexCommit2, snapshotIndexCommitExists()); + @Override + public Void snapshot(SnapshotIndexCommit snapshotIndexCommit2, Translog.Snapshot translogSnapshot2) throws EngineException { + MatcherAssert.assertThat(snapshotIndexCommit1, SnapshotIndexCommitExistsMatcher.snapshotIndexCommitExists()); + MatcherAssert.assertThat(snapshotIndexCommit2, SnapshotIndexCommitExistsMatcher.snapshotIndexCommitExists()); assertThat(snapshotIndexCommit2.getSegmentsFileName(), not(equalTo(snapshotIndexCommit1.getSegmentsFileName()))); assertThat(translogSnapshot2.hasNext(), equalTo(true)); Translog.Create create3 = (Translog.Create) translogSnapshot2.next(); @@ -431,13 +442,15 @@ public abstract class AbstractSimpleEngineTests { engine.close(); } - @Test public void testSimpleRecover() throws Exception { + @Test + public void testSimpleRecover() throws Exception { ParsedDocument doc = new ParsedDocument("1", "1", "test", null, -1, -1, doc().add(uidField("1")).add(field("value", "test")).build(), Lucene.STANDARD_ANALYZER, B_1, false); engine.create(new Engine.Create(null, newUid("1"), doc)); engine.flush(new Engine.Flush()); engine.recover(new Engine.RecoveryHandler() { - @Override public void phase1(SnapshotIndexCommit snapshot) throws EngineException { + @Override + public void phase1(SnapshotIndexCommit snapshot) throws EngineException { try { engine.flush(new Engine.Flush()); assertThat("flush is not allowed in phase 3", false, equalTo(true)); @@ -446,8 +459,9 @@ public abstract class AbstractSimpleEngineTests { } } - @Override public void phase2(Translog.Snapshot snapshot) throws EngineException { - assertThat(snapshot, translogSize(0)); + @Override + public void phase2(Translog.Snapshot snapshot) throws EngineException { + MatcherAssert.assertThat(snapshot, TranslogSizeMatcher.translogSize(0)); try { engine.flush(new Engine.Flush()); assertThat("flush is not allowed in phase 3", false, equalTo(true)); @@ -456,8 +470,9 @@ public abstract class AbstractSimpleEngineTests { } } - @Override public void phase3(Translog.Snapshot snapshot) throws EngineException { - assertThat(snapshot, translogSize(0)); + @Override + public void phase3(Translog.Snapshot snapshot) throws EngineException { + MatcherAssert.assertThat(snapshot, TranslogSizeMatcher.translogSize(0)); try { // we can do this here since we are on the same thread engine.flush(new Engine.Flush()); @@ -472,7 +487,8 @@ public abstract class AbstractSimpleEngineTests { engine.close(); } - @Test public void testRecoverWithOperationsBetweenPhase1AndPhase2() throws Exception { + @Test + public void testRecoverWithOperationsBetweenPhase1AndPhase2() throws Exception { ParsedDocument doc1 = new ParsedDocument("1", "1", "test", null, -1, -1, doc().add(uidField("1")).add(field("value", "test")).build(), Lucene.STANDARD_ANALYZER, B_1, false); engine.create(new Engine.Create(null, newUid("1"), doc1)); engine.flush(new Engine.Flush()); @@ -480,18 +496,21 @@ public abstract class AbstractSimpleEngineTests { engine.create(new Engine.Create(null, newUid("2"), doc2)); engine.recover(new Engine.RecoveryHandler() { - @Override public void phase1(SnapshotIndexCommit snapshot) throws EngineException { + @Override + public void phase1(SnapshotIndexCommit snapshot) throws EngineException { } - @Override public void phase2(Translog.Snapshot snapshot) throws EngineException { + @Override + public void phase2(Translog.Snapshot snapshot) throws EngineException { assertThat(snapshot.hasNext(), equalTo(true)); Translog.Create create = (Translog.Create) snapshot.next(); assertThat(create.source(), equalTo(B_2)); assertThat(snapshot.hasNext(), equalTo(false)); } - @Override public void phase3(Translog.Snapshot snapshot) throws EngineException { - assertThat(snapshot, translogSize(0)); + @Override + public void phase3(Translog.Snapshot snapshot) throws EngineException { + MatcherAssert.assertThat(snapshot, TranslogSizeMatcher.translogSize(0)); } }); @@ -499,7 +518,8 @@ public abstract class AbstractSimpleEngineTests { engine.close(); } - @Test public void testRecoverWithOperationsBetweenPhase1AndPhase2AndPhase3() throws Exception { + @Test + public void testRecoverWithOperationsBetweenPhase1AndPhase2AndPhase3() throws Exception { ParsedDocument doc1 = new ParsedDocument("1", "1", "test", null, -1, -1, doc().add(uidField("1")).add(field("value", "test")).build(), Lucene.STANDARD_ANALYZER, B_1, false); engine.create(new Engine.Create(null, newUid("1"), doc1)); engine.flush(new Engine.Flush()); @@ -507,10 +527,12 @@ public abstract class AbstractSimpleEngineTests { engine.create(new Engine.Create(null, newUid("2"), doc2)); engine.recover(new Engine.RecoveryHandler() { - @Override public void phase1(SnapshotIndexCommit snapshot) throws EngineException { + @Override + public void phase1(SnapshotIndexCommit snapshot) throws EngineException { } - @Override public void phase2(Translog.Snapshot snapshot) throws EngineException { + @Override + public void phase2(Translog.Snapshot snapshot) throws EngineException { assertThat(snapshot.hasNext(), equalTo(true)); Translog.Create create = (Translog.Create) snapshot.next(); assertThat(snapshot.hasNext(), equalTo(false)); @@ -521,7 +543,8 @@ public abstract class AbstractSimpleEngineTests { engine.create(new Engine.Create(null, newUid("3"), doc3)); } - @Override public void phase3(Translog.Snapshot snapshot) throws EngineException { + @Override + public void phase3(Translog.Snapshot snapshot) throws EngineException { assertThat(snapshot.hasNext(), equalTo(true)); Translog.Create create = (Translog.Create) snapshot.next(); assertThat(snapshot.hasNext(), equalTo(false)); @@ -533,7 +556,8 @@ public abstract class AbstractSimpleEngineTests { engine.close(); } - @Test public void testVersioningNewCreate() { + @Test + public void testVersioningNewCreate() { ParsedDocument doc = new ParsedDocument("1", "1", "test", null, -1, -1, doc().add(uidField("1")).build(), Lucene.STANDARD_ANALYZER, B_1, false); Engine.Create create = new Engine.Create(null, newUid("1"), doc); engine.create(create); @@ -544,7 +568,8 @@ public abstract class AbstractSimpleEngineTests { assertThat(create.version(), equalTo(1l)); } - @Test public void testExternalVersioningNewCreate() { + @Test + public void testExternalVersioningNewCreate() { ParsedDocument doc = new ParsedDocument("1", "1", "test", null, -1, -1, doc().add(uidField("1")).build(), Lucene.STANDARD_ANALYZER, B_1, false); Engine.Create create = new Engine.Create(null, newUid("1"), doc).versionType(VersionType.EXTERNAL).version(12); engine.create(create); @@ -555,7 +580,8 @@ public abstract class AbstractSimpleEngineTests { assertThat(create.version(), equalTo(12l)); } - @Test public void testVersioningNewIndex() { + @Test + public void testVersioningNewIndex() { ParsedDocument doc = new ParsedDocument("1", "1", "test", null, -1, -1, doc().add(uidField("1")).build(), Lucene.STANDARD_ANALYZER, B_1, false); Engine.Index index = new Engine.Index(null, newUid("1"), doc); engine.index(index); @@ -566,7 +592,8 @@ public abstract class AbstractSimpleEngineTests { assertThat(index.version(), equalTo(1l)); } - @Test public void testExternalVersioningNewIndex() { + @Test + public void testExternalVersioningNewIndex() { ParsedDocument doc = new ParsedDocument("1", "1", "test", null, -1, -1, doc().add(uidField("1")).build(), Lucene.STANDARD_ANALYZER, B_1, false); Engine.Index index = new Engine.Index(null, newUid("1"), doc).versionType(VersionType.EXTERNAL).version(12); engine.index(index); @@ -577,7 +604,8 @@ public abstract class AbstractSimpleEngineTests { assertThat(index.version(), equalTo(12l)); } - @Test public void testVersioningIndexConflict() { + @Test + public void testVersioningIndexConflict() { ParsedDocument doc = new ParsedDocument("1", "1", "test", null, -1, -1, doc().add(uidField("1")).build(), Lucene.STANDARD_ANALYZER, B_1, false); Engine.Index index = new Engine.Index(null, newUid("1"), doc); engine.index(index); @@ -605,7 +633,8 @@ public abstract class AbstractSimpleEngineTests { } } - @Test public void testExternalVersioningIndexConflict() { + @Test + public void testExternalVersioningIndexConflict() { ParsedDocument doc = new ParsedDocument("1", "1", "test", null, -1, -1, doc().add(uidField("1")).build(), Lucene.STANDARD_ANALYZER, B_1, false); Engine.Index index = new Engine.Index(null, newUid("1"), doc).versionType(VersionType.EXTERNAL).version(12); engine.index(index); @@ -624,7 +653,8 @@ public abstract class AbstractSimpleEngineTests { } } - @Test public void testVersioningIndexConflictWithFlush() { + @Test + public void testVersioningIndexConflictWithFlush() { ParsedDocument doc = new ParsedDocument("1", "1", "test", null, -1, -1, doc().add(uidField("1")).build(), Lucene.STANDARD_ANALYZER, B_1, false); Engine.Index index = new Engine.Index(null, newUid("1"), doc); engine.index(index); @@ -654,7 +684,8 @@ public abstract class AbstractSimpleEngineTests { } } - @Test public void testExternalVersioningIndexConflictWithFlush() { + @Test + public void testExternalVersioningIndexConflictWithFlush() { ParsedDocument doc = new ParsedDocument("1", "1", "test", null, -1, -1, doc().add(uidField("1")).build(), Lucene.STANDARD_ANALYZER, B_1, false); Engine.Index index = new Engine.Index(null, newUid("1"), doc).versionType(VersionType.EXTERNAL).version(12); engine.index(index); @@ -675,7 +706,8 @@ public abstract class AbstractSimpleEngineTests { } } - @Test public void testVersioningDeleteConflict() { + @Test + public void testVersioningDeleteConflict() { ParsedDocument doc = new ParsedDocument("1", "1", "test", null, -1, -1, doc().add(uidField("1")).build(), Lucene.STANDARD_ANALYZER, B_1, false); Engine.Index index = new Engine.Index(null, newUid("1"), doc); engine.index(index); @@ -725,7 +757,8 @@ public abstract class AbstractSimpleEngineTests { } } - @Test public void testVersioningDeleteConflictWithFlush() { + @Test + public void testVersioningDeleteConflictWithFlush() { ParsedDocument doc = new ParsedDocument("1", "1", "test", null, -1, -1, doc().add(uidField("1")).build(), Lucene.STANDARD_ANALYZER, B_1, false); Engine.Index index = new Engine.Index(null, newUid("1"), doc); engine.index(index); @@ -781,7 +814,8 @@ public abstract class AbstractSimpleEngineTests { } } - @Test public void testVersioningCreateExistsException() { + @Test + public void testVersioningCreateExistsException() { ParsedDocument doc = new ParsedDocument("1", "1", "test", null, -1, -1, doc().add(uidField("1")).build(), Lucene.STANDARD_ANALYZER, B_1, false); Engine.Create create = new Engine.Create(null, newUid("1"), doc); engine.create(create); @@ -796,7 +830,8 @@ public abstract class AbstractSimpleEngineTests { } } - @Test public void testVersioningCreateExistsExceptionWithFlush() { + @Test + public void testVersioningCreateExistsExceptionWithFlush() { ParsedDocument doc = new ParsedDocument("1", "1", "test", null, -1, -1, doc().add(uidField("1")).build(), Lucene.STANDARD_ANALYZER, B_1, false); Engine.Create create = new Engine.Create(null, newUid("1"), doc); engine.create(create); @@ -813,7 +848,8 @@ public abstract class AbstractSimpleEngineTests { } } - @Test public void testVersioningReplicaConflict1() { + @Test + public void testVersioningReplicaConflict1() { ParsedDocument doc = new ParsedDocument("1", "1", "test", null, -1, -1, doc().add(uidField("1")).build(), Lucene.STANDARD_ANALYZER, B_1, false); Engine.Index index = new Engine.Index(null, newUid("1"), doc); engine.index(index); @@ -847,7 +883,8 @@ public abstract class AbstractSimpleEngineTests { } } - @Test public void testVersioningReplicaConflict2() { + @Test + public void testVersioningReplicaConflict2() { ParsedDocument doc = new ParsedDocument("1", "1", "test", null, -1, -1, doc().add(uidField("1")).build(), Lucene.STANDARD_ANALYZER, B_1, false); Engine.Index index = new Engine.Index(null, newUid("1"), doc); engine.index(index); diff --git a/src/test/java/org/elasticsearch/index/engine/EngineSearcherTotalHitsMatcher.java b/src/test/java/org/elasticsearch/test/unit/index/engine/EngineSearcherTotalHitsMatcher.java similarity index 84% rename from src/test/java/org/elasticsearch/index/engine/EngineSearcherTotalHitsMatcher.java rename to src/test/java/org/elasticsearch/test/unit/index/engine/EngineSearcherTotalHitsMatcher.java index 4ea071a1478..b669ed250d4 100644 --- a/src/test/java/org/elasticsearch/index/engine/EngineSearcherTotalHitsMatcher.java +++ b/src/test/java/org/elasticsearch/test/unit/index/engine/EngineSearcherTotalHitsMatcher.java @@ -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 @@ -17,11 +17,12 @@ * under the License. */ -package org.elasticsearch.index.engine; +package org.elasticsearch.test.unit.index.engine; import org.apache.lucene.search.Query; import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.common.lucene.search.Queries; +import org.elasticsearch.index.engine.Engine; import org.hamcrest.Description; import org.hamcrest.Matcher; import org.hamcrest.TypeSafeMatcher; @@ -29,7 +30,7 @@ import org.hamcrest.TypeSafeMatcher; import java.io.IOException; /** - * @author kimchy + * */ public final class EngineSearcherTotalHitsMatcher extends TypeSafeMatcher { @@ -42,7 +43,8 @@ public final class EngineSearcherTotalHitsMatcher extends TypeSafeMatcher values = new ArrayList(); sFieldData.forEachValue(new DoubleFieldData.ValueProc() { - @Override public void onValue(double value) { + @Override + public void onValue(double value) { values.add(value); } }); @@ -149,7 +152,8 @@ public class DoubleFieldDataTests { // check order is correct values.clear(); mFieldData.forEachValue(new DoubleFieldData.ValueProc() { - @Override public void onValue(double value) { + @Override + public void onValue(double value) { values.add(value); } }); diff --git a/src/test/java/org/elasticsearch/index/field/data/floats/FloatFieldDataTests.java b/src/test/java/org/elasticsearch/test/unit/index/field/data/floats/FloatFieldDataTests.java similarity index 90% rename from src/test/java/org/elasticsearch/index/field/data/floats/FloatFieldDataTests.java rename to src/test/java/org/elasticsearch/test/unit/index/field/data/floats/FloatFieldDataTests.java index 02b13b13aa0..93cfc3ee1f0 100644 --- a/src/test/java/org/elasticsearch/index/field/data/floats/FloatFieldDataTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/field/data/floats/FloatFieldDataTests.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.field.data.floats; +package org.elasticsearch.test.unit.index.field.data.floats; import org.apache.lucene.document.NumericField; import org.apache.lucene.index.IndexReader; @@ -26,20 +26,22 @@ import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.store.Directory; import org.apache.lucene.store.RAMDirectory; import org.elasticsearch.common.lucene.Lucene; +import org.elasticsearch.index.field.data.floats.FloatFieldData; import org.testng.annotations.Test; import java.util.ArrayList; -import static org.elasticsearch.common.lucene.DocumentBuilder.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.lucene.DocumentBuilder.doc; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (Shay Banon) + * */ public class FloatFieldDataTests { - @Test public void intFieldDataTests() throws Exception { + @Test + public void intFieldDataTests() throws Exception { Directory dir = new RAMDirectory(); IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER)); @@ -106,7 +108,8 @@ public class FloatFieldDataTests { // check order is correct final ArrayList values = new ArrayList(); sFieldData.forEachValue(new FloatFieldData.ValueProc() { - @Override public void onValue(float value) { + @Override + public void onValue(float value) { values.add(value); } }); @@ -149,7 +152,8 @@ public class FloatFieldDataTests { // check order is correct values.clear(); mFieldData.forEachValue(new FloatFieldData.ValueProc() { - @Override public void onValue(float value) { + @Override + public void onValue(float value) { values.add(value); } }); diff --git a/src/test/java/org/elasticsearch/index/field/data/ints/IntFieldDataTests.java b/src/test/java/org/elasticsearch/test/unit/index/field/data/ints/IntFieldDataTests.java similarity index 90% rename from src/test/java/org/elasticsearch/index/field/data/ints/IntFieldDataTests.java rename to src/test/java/org/elasticsearch/test/unit/index/field/data/ints/IntFieldDataTests.java index e40adf1e6a5..ba565918a6c 100644 --- a/src/test/java/org/elasticsearch/index/field/data/ints/IntFieldDataTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/field/data/ints/IntFieldDataTests.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.field.data.ints; +package org.elasticsearch.test.unit.index.field.data.ints; import org.apache.lucene.document.NumericField; import org.apache.lucene.index.IndexReader; @@ -26,20 +26,22 @@ import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.store.Directory; import org.apache.lucene.store.RAMDirectory; import org.elasticsearch.common.lucene.Lucene; +import org.elasticsearch.index.field.data.ints.IntFieldData; import org.testng.annotations.Test; import java.util.ArrayList; -import static org.elasticsearch.common.lucene.DocumentBuilder.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.lucene.DocumentBuilder.doc; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (Shay Banon) + * */ public class IntFieldDataTests { - @Test public void intFieldDataTests() throws Exception { + @Test + public void intFieldDataTests() throws Exception { Directory dir = new RAMDirectory(); IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER)); @@ -106,7 +108,8 @@ public class IntFieldDataTests { // check order is correct final ArrayList values = new ArrayList(); sFieldData.forEachValue(new IntFieldData.ValueProc() { - @Override public void onValue(int value) { + @Override + public void onValue(int value) { values.add(value); } }); @@ -142,7 +145,8 @@ public class IntFieldDataTests { // check order is correct values.clear(); mFieldData.forEachValue(new IntFieldData.ValueProc() { - @Override public void onValue(int value) { + @Override + public void onValue(int value) { values.add(value); } }); diff --git a/src/test/java/org/elasticsearch/index/field/data/longs/LongFieldDataTests.java b/src/test/java/org/elasticsearch/test/unit/index/field/data/longs/LongFieldDataTests.java similarity index 90% rename from src/test/java/org/elasticsearch/index/field/data/longs/LongFieldDataTests.java rename to src/test/java/org/elasticsearch/test/unit/index/field/data/longs/LongFieldDataTests.java index 03367f5e2f5..c1fa6d85bed 100644 --- a/src/test/java/org/elasticsearch/index/field/data/longs/LongFieldDataTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/field/data/longs/LongFieldDataTests.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.field.data.longs; +package org.elasticsearch.test.unit.index.field.data.longs; import org.apache.lucene.document.NumericField; import org.apache.lucene.index.IndexReader; @@ -26,20 +26,22 @@ import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.store.Directory; import org.apache.lucene.store.RAMDirectory; import org.elasticsearch.common.lucene.Lucene; +import org.elasticsearch.index.field.data.longs.LongFieldData; import org.testng.annotations.Test; import java.util.ArrayList; -import static org.elasticsearch.common.lucene.DocumentBuilder.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.lucene.DocumentBuilder.doc; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (Shay Banon) + * */ public class LongFieldDataTests { - @Test public void intFieldDataTests() throws Exception { + @Test + public void intFieldDataTests() throws Exception { Directory dir = new RAMDirectory(); IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER)); @@ -109,7 +111,8 @@ public class LongFieldDataTests { // check order is correct final ArrayList values = new ArrayList(); sFieldData.forEachValue(new LongFieldData.ValueProc() { - @Override public void onValue(long value) { + @Override + public void onValue(long value) { values.add(value); } }); @@ -149,7 +152,8 @@ public class LongFieldDataTests { // check order is correct values.clear(); mFieldData.forEachValue(new LongFieldData.ValueProc() { - @Override public void onValue(long value) { + @Override + public void onValue(long value) { values.add(value); } }); diff --git a/src/test/java/org/elasticsearch/index/field/data/shorts/ShortFieldDataTests.java b/src/test/java/org/elasticsearch/test/unit/index/field/data/shorts/ShortFieldDataTests.java similarity index 90% rename from src/test/java/org/elasticsearch/index/field/data/shorts/ShortFieldDataTests.java rename to src/test/java/org/elasticsearch/test/unit/index/field/data/shorts/ShortFieldDataTests.java index 6906994b4d6..8c89da6c95c 100644 --- a/src/test/java/org/elasticsearch/index/field/data/shorts/ShortFieldDataTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/field/data/shorts/ShortFieldDataTests.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.field.data.shorts; +package org.elasticsearch.test.unit.index.field.data.shorts; import org.apache.lucene.document.NumericField; import org.apache.lucene.index.IndexReader; @@ -26,20 +26,22 @@ import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.store.Directory; import org.apache.lucene.store.RAMDirectory; import org.elasticsearch.common.lucene.Lucene; +import org.elasticsearch.index.field.data.shorts.ShortFieldData; import org.testng.annotations.Test; import java.util.ArrayList; -import static org.elasticsearch.common.lucene.DocumentBuilder.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.lucene.DocumentBuilder.doc; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (Shay Banon) + * */ public class ShortFieldDataTests { - @Test public void intFieldDataTests() throws Exception { + @Test + public void intFieldDataTests() throws Exception { Directory dir = new RAMDirectory(); IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER)); @@ -107,7 +109,8 @@ public class ShortFieldDataTests { // check order is correct final ArrayList values = new ArrayList(); sFieldData.forEachValue(new ShortFieldData.ValueProc() { - @Override public void onValue(short value) { + @Override + public void onValue(short value) { values.add(value); } }); @@ -147,7 +150,8 @@ public class ShortFieldDataTests { // check order is correct values.clear(); mFieldData.forEachValue(new ShortFieldData.ValueProc() { - @Override public void onValue(short value) { + @Override + public void onValue(short value) { values.add(value); } }); diff --git a/src/test/java/org/elasticsearch/index/field/data/strings/StringFieldDataTests.java b/src/test/java/org/elasticsearch/test/unit/index/field/data/strings/StringFieldDataTests.java similarity index 88% rename from src/test/java/org/elasticsearch/index/field/data/strings/StringFieldDataTests.java rename to src/test/java/org/elasticsearch/test/unit/index/field/data/strings/StringFieldDataTests.java index 44b069d73b1..c216b4f945f 100644 --- a/src/test/java/org/elasticsearch/index/field/data/strings/StringFieldDataTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/field/data/strings/StringFieldDataTests.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.field.data.strings; +package org.elasticsearch.test.unit.index.field.data.strings; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexWriter; @@ -26,20 +26,23 @@ import org.apache.lucene.store.Directory; import org.apache.lucene.store.RAMDirectory; import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.index.field.data.FieldData; +import org.elasticsearch.index.field.data.strings.StringFieldData; import org.testng.annotations.Test; import java.util.ArrayList; -import static org.elasticsearch.common.lucene.DocumentBuilder.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.lucene.DocumentBuilder.doc; +import static org.elasticsearch.common.lucene.DocumentBuilder.field; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (Shay Banon) + * */ public class StringFieldDataTests { - @Test public void stringFieldDataTests() throws Exception { + @Test + public void stringFieldDataTests() throws Exception { Directory dir = new RAMDirectory(); IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER)); @@ -100,7 +103,8 @@ public class StringFieldDataTests { // check order is correct final ArrayList values = new ArrayList(); sFieldData.forEachValue(new FieldData.StringValueProc() { - @Override public void onValue(String value) { + @Override + public void onValue(String value) { values.add(value); } }); @@ -134,7 +138,8 @@ public class StringFieldDataTests { values.clear(); mFieldData.forEachValue(new FieldData.StringValueProc() { - @Override public void onValue(String value) { + @Override + public void onValue(String value) { values.add(value); } }); diff --git a/src/test/java/org/elasticsearch/index/gateway/CommitPointsTests.java b/src/test/java/org/elasticsearch/test/unit/index/gateway/CommitPointsTests.java similarity index 85% rename from src/test/java/org/elasticsearch/index/gateway/CommitPointsTests.java rename to src/test/java/org/elasticsearch/test/unit/index/gateway/CommitPointsTests.java index 59623fcf298..d87528cb3dc 100644 --- a/src/test/java/org/elasticsearch/index/gateway/CommitPointsTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/gateway/CommitPointsTests.java @@ -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 @@ -17,26 +17,30 @@ * under the License. */ -package org.elasticsearch.index.gateway; +package org.elasticsearch.test.unit.index.gateway; -import org.elasticsearch.common.collect.Lists; +import com.google.common.collect.Lists; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; +import org.elasticsearch.index.gateway.CommitPoint; +import org.elasticsearch.index.gateway.CommitPoints; import org.testng.annotations.Test; import java.util.ArrayList; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.nullValue; /** - * @author kimchy (shay.banon) + * */ public class CommitPointsTests { private final ESLogger logger = Loggers.getLogger(CommitPointsTests.class); - @Test public void testCommitPointXContent() throws Exception { + @Test + public void testCommitPointXContent() throws Exception { ArrayList indexFiles = Lists.newArrayList(); indexFiles.add(new CommitPoint.FileInfo("file1", "file1_p", 100, "ck1")); indexFiles.add(new CommitPoint.FileInfo("file2", "file2_p", 200, "ck2")); diff --git a/src/test/java/org/elasticsearch/index/mapper/MapperTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/MapperTests.java similarity index 89% rename from src/test/java/org/elasticsearch/index/mapper/MapperTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/MapperTests.java index d6d3934583d..bd642ef69c4 100644 --- a/src/test/java/org/elasticsearch/index/mapper/MapperTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/MapperTests.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.mapper; +package org.elasticsearch.test.unit.index.mapper; import org.elasticsearch.common.inject.Injector; import org.elasticsearch.common.inject.ModulesBuilder; @@ -29,12 +29,14 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexNameModule; import org.elasticsearch.index.analysis.AnalysisModule; import org.elasticsearch.index.analysis.AnalysisService; +import org.elasticsearch.index.mapper.DocumentMapperParser; +import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.settings.IndexSettingsModule; import org.elasticsearch.indices.analysis.IndicesAnalysisModule; import org.elasticsearch.indices.analysis.IndicesAnalysisService; /** - * @author kimchy (shay.banon) + * */ public class MapperTests { diff --git a/src/test/java/org/elasticsearch/index/mapper/all/SimpleAllMapperTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/all/SimpleAllMapperTests.java similarity index 78% rename from src/test/java/org/elasticsearch/index/mapper/all/SimpleAllMapperTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/all/SimpleAllMapperTests.java index 5a85b6ff144..ea7d2793b49 100644 --- a/src/test/java/org/elasticsearch/index/mapper/all/SimpleAllMapperTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/all/SimpleAllMapperTests.java @@ -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 @@ -17,30 +17,32 @@ * under the License. */ -package org.elasticsearch.index.mapper.all; +package org.elasticsearch.test.unit.index.mapper.all; import org.apache.lucene.document.Document; import org.elasticsearch.common.lucene.all.AllEntries; import org.elasticsearch.common.lucene.all.AllField; import org.elasticsearch.common.lucene.all.AllTokenStream; import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.mapper.MapperTests; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.testng.annotations.Test; -import static org.elasticsearch.common.io.Streams.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.io.Streams.copyToBytesFromClasspath; +import static org.elasticsearch.common.io.Streams.copyToStringFromClasspath; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ @Test public class SimpleAllMapperTests { - @Test public void testSimpleAllMappers() throws Exception { - String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/all/mapping.json"); + @Test + public void testSimpleAllMappers() throws Exception { + String mapping = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/mapper/all/mapping.json"); DocumentMapper docMapper = MapperTests.newParser().parse(mapping); - byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/all/test1.json"); + byte[] json = copyToBytesFromClasspath("/org/elasticsearch/test/unit/index/mapper/all/test1.json"); Document doc = docMapper.parse(json).rootDoc(); AllField field = (AllField) doc.getFieldable("_all"); AllEntries allEntries = ((AllTokenStream) field.tokenStreamValue()).allEntries(); @@ -50,14 +52,15 @@ public class SimpleAllMapperTests { assertThat(allEntries.fields().contains("simple1"), equalTo(true)); } - @Test public void testSimpleAllMappersWithReparse() throws Exception { - String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/all/mapping.json"); + @Test + public void testSimpleAllMappersWithReparse() throws Exception { + String mapping = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/mapper/all/mapping.json"); DocumentMapper docMapper = MapperTests.newParser().parse(mapping); String builtMapping = docMapper.mappingSource().string(); // System.out.println(builtMapping); // reparse it DocumentMapper builtDocMapper = MapperTests.newParser().parse(builtMapping); - byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/all/test1.json"); + byte[] json = copyToBytesFromClasspath("/org/elasticsearch/test/unit/index/mapper/all/test1.json"); Document doc = builtDocMapper.parse(json).rootDoc(); AllField field = (AllField) doc.getFieldable("_all"); @@ -68,10 +71,11 @@ public class SimpleAllMapperTests { assertThat(allEntries.fields().contains("simple1"), equalTo(true)); } - @Test public void testSimpleAllMappersWithStore() throws Exception { - String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/all/store-mapping.json"); + @Test + public void testSimpleAllMappersWithStore() throws Exception { + String mapping = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/mapper/all/store-mapping.json"); DocumentMapper docMapper = MapperTests.newParser().parse(mapping); - byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/all/test1.json"); + byte[] json = copyToBytesFromClasspath("/org/elasticsearch/test/unit/index/mapper/all/test1.json"); Document doc = docMapper.parse(json).rootDoc(); AllField field = (AllField) doc.getFieldable("_all"); AllEntries allEntries = ((AllTokenStream) field.tokenStreamValue()).allEntries(); @@ -83,14 +87,15 @@ public class SimpleAllMapperTests { assertThat(text, equalTo(allEntries.buildText())); } - @Test public void testSimpleAllMappersWithReparseWithStore() throws Exception { - String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/all/store-mapping.json"); + @Test + public void testSimpleAllMappersWithReparseWithStore() throws Exception { + String mapping = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/mapper/all/store-mapping.json"); DocumentMapper docMapper = MapperTests.newParser().parse(mapping); String builtMapping = docMapper.mappingSource().string(); System.out.println(builtMapping); // reparse it DocumentMapper builtDocMapper = MapperTests.newParser().parse(builtMapping); - byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/all/test1.json"); + byte[] json = copyToBytesFromClasspath("/org/elasticsearch/test/unit/index/mapper/all/test1.json"); Document doc = builtDocMapper.parse(json).rootDoc(); AllField field = (AllField) doc.getFieldable("_all"); diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/all/mapping.json b/src/test/java/org/elasticsearch/test/unit/index/mapper/all/mapping.json new file mode 100644 index 00000000000..ecbf315e73a --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/all/mapping.json @@ -0,0 +1,55 @@ +{ + "person":{ + "_all":{ + "enabled":true + }, + "properties":{ + "name":{ + "type":"object", + "dynamic":false, + "properties":{ + "first":{ + "type":"string", + "store":"yes", + "include_in_all":false + }, + "last":{ + "type":"string", + "index":"not_analyzed" + } + } + }, + "address":{ + "type":"object", + "include_in_all":false, + "properties":{ + "first":{ + "properties":{ + "location":{ + "type":"string", + "store":"yes", + "index_name":"firstLocation" + } + } + }, + "last":{ + "properties":{ + "location":{ + "type":"string", + "include_in_all":true + } + } + } + } + }, + "simple1":{ + "type":"long", + "include_in_all":true + }, + "simple2":{ + "type":"long", + "include_in_all":false + } + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/all/store-mapping.json b/src/test/java/org/elasticsearch/test/unit/index/mapper/all/store-mapping.json new file mode 100644 index 00000000000..45ca9fa7043 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/all/store-mapping.json @@ -0,0 +1,55 @@ +{ + "person":{ + "_all":{ + "enabled":true, + "store":"yes" + }, + "properties":{ + "name":{ + "type":"object", + "dynamic":false, + "properties":{ + "first":{ + "type":"string", + "store":"yes", + "include_in_all":false + }, + "last":{ + "type":"string", + "index":"not_analyzed" + } + } + }, + "address":{ + "type":"object", + "include_in_all":false, + "properties":{ + "first":{ + "properties":{ + "location":{ + "type":"string", + "store":"yes", + "index_name":"firstLocation" + } + } + }, + "last":{ + "properties":{ + "location":{ + "type":"string" + } + } + } + } + }, + "simple1":{ + "type":"long", + "include_in_all":true + }, + "simple2":{ + "type":"long", + "include_in_all":false + } + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/all/test1.json b/src/test/java/org/elasticsearch/test/unit/index/mapper/all/test1.json new file mode 100644 index 00000000000..c3e72dfa9a8 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/all/test1.json @@ -0,0 +1,20 @@ +{ + "person":{ + "_boost":3.7, + "_id":"1", + "name":{ + "first":"shay", + "last":"banon" + }, + "address":{ + "first":{ + "location":"first location" + }, + "last":{ + "location":"last location" + } + }, + "simple1":1, + "simple2":2 + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/mapper/analyzer/AnalyzerMapperTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/analyzer/AnalyzerMapperTests.java similarity index 92% rename from src/test/java/org/elasticsearch/index/mapper/analyzer/AnalyzerMapperTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/analyzer/AnalyzerMapperTests.java index 04b521b17e5..38f9d6ee49d 100644 --- a/src/test/java/org/elasticsearch/index/mapper/analyzer/AnalyzerMapperTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/analyzer/AnalyzerMapperTests.java @@ -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 @@ -17,25 +17,27 @@ * under the License. */ -package org.elasticsearch.index.mapper.analyzer; +package org.elasticsearch.test.unit.index.mapper.analyzer; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.analysis.FieldNameAnalyzer; import org.elasticsearch.index.analysis.NamedAnalyzer; import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.mapper.MapperTests; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.elasticsearch.index.mapper.ParsedDocument; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.nullValue; /** - * @author kimchy (shay.banon) + * */ public class AnalyzerMapperTests { - @Test public void testAnalyzerMapping() throws Exception { + @Test + public void testAnalyzerMapping() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("_analyzer").field("path", "field_analyzer").endObject() .startObject("properties") @@ -74,7 +76,8 @@ public class AnalyzerMapperTests { } - @Test public void testAnalyzerMappingExplicit() throws Exception { + @Test + public void testAnalyzerMappingExplicit() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("_analyzer").field("path", "field_analyzer").endObject() .startObject("properties") @@ -113,7 +116,8 @@ public class AnalyzerMapperTests { assertThat(((NamedAnalyzer) analyzer.analyzers().get("field2")).name(), equalTo("simple")); } - @Test public void testAnalyzerMappingNotIndexedNorStored() throws Exception { + @Test + public void testAnalyzerMappingNotIndexedNorStored() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("_analyzer").field("path", "field_analyzer").endObject() .startObject("properties") diff --git a/src/test/java/org/elasticsearch/index/mapper/boost/BoostMappingTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/boost/BoostMappingTests.java similarity index 82% rename from src/test/java/org/elasticsearch/index/mapper/boost/BoostMappingTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/boost/BoostMappingTests.java index 29391280eb5..ff981278e87 100644 --- a/src/test/java/org/elasticsearch/index/mapper/boost/BoostMappingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/boost/BoostMappingTests.java @@ -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 @@ -17,23 +17,24 @@ * under the License. */ -package org.elasticsearch.index.mapper.boost; +package org.elasticsearch.test.unit.index.mapper.boost; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.mapper.MapperTests; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.elasticsearch.index.mapper.ParsedDocument; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** */ @Test public class BoostMappingTests { - @Test public void testDefaultMapping() throws Exception { + @Test + public void testDefaultMapping() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string(); DocumentMapper mapper = MapperTests.newParser().parse(mapping); @@ -44,7 +45,8 @@ public class BoostMappingTests { assertThat(doc.rootDoc().getBoost(), equalTo(2.0f)); } - @Test public void testCustomName() throws Exception { + @Test + public void testCustomName() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("_boost").field("name", "custom_boost").endObject() .endObject().endObject().string(); diff --git a/src/test/java/org/elasticsearch/index/mapper/boost/CustomBoostMappingTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/boost/CustomBoostMappingTests.java similarity index 89% rename from src/test/java/org/elasticsearch/index/mapper/boost/CustomBoostMappingTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/boost/CustomBoostMappingTests.java index 386d749b847..7842dc1af1c 100644 --- a/src/test/java/org/elasticsearch/index/mapper/boost/CustomBoostMappingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/boost/CustomBoostMappingTests.java @@ -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 @@ -17,21 +17,22 @@ * under the License. */ -package org.elasticsearch.index.mapper.boost; +package org.elasticsearch.test.unit.index.mapper.boost; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.mapper.MapperTests; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.elasticsearch.index.mapper.ParsedDocument; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; @Test public class CustomBoostMappingTests { - @Test public void testCustomBoostValues() throws Exception { + @Test + public void testCustomBoostValues() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties") .startObject("s_field").field("type", "string").endObject() .startObject("l_field").field("type", "long").endObject() diff --git a/src/test/java/org/elasticsearch/index/mapper/camelcase/CamelCaseFieldNameTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/camelcase/CamelCaseFieldNameTests.java similarity index 80% rename from src/test/java/org/elasticsearch/index/mapper/camelcase/CamelCaseFieldNameTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/camelcase/CamelCaseFieldNameTests.java index 0c5f00191c2..10793154878 100644 --- a/src/test/java/org/elasticsearch/index/mapper/camelcase/CamelCaseFieldNameTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/camelcase/CamelCaseFieldNameTests.java @@ -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 @@ -17,23 +17,25 @@ * under the License. */ -package org.elasticsearch.index.mapper.camelcase; +package org.elasticsearch.test.unit.index.mapper.camelcase; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.mapper.MapperTests; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.elasticsearch.index.mapper.ParsedDocument; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.nullValue; /** - * @author kimchy (shay.banon) + * */ public class CamelCaseFieldNameTests { - @Test public void testCamelCaseFieldNameStaysAsIs() throws Exception { + @Test + public void testCamelCaseFieldNameStaysAsIs() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .endObject().endObject().string(); diff --git a/src/test/java/org/elasticsearch/index/mapper/compound/CompoundTypesTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/compound/CompoundTypesTests.java similarity index 86% rename from src/test/java/org/elasticsearch/index/mapper/compound/CompoundTypesTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/compound/CompoundTypesTests.java index 14d8fcba133..d760a2f6969 100644 --- a/src/test/java/org/elasticsearch/index/mapper/compound/CompoundTypesTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/compound/CompoundTypesTests.java @@ -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 @@ -17,21 +17,23 @@ * under the License. */ -package org.elasticsearch.index.mapper.compound; +package org.elasticsearch.test.unit.index.mapper.compound; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.mapper.MapperTests; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.elasticsearch.index.mapper.ParsedDocument; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.closeTo; +import static org.hamcrest.Matchers.equalTo; @Test public class CompoundTypesTests { - @Test public void testStringType() throws Exception { + @Test + public void testStringType() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("properties") .startObject("field1").field("type", "string").endObject() diff --git a/src/test/java/org/elasticsearch/index/mapper/date/SimpleDateMappingTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/date/SimpleDateMappingTests.java similarity index 89% rename from src/test/java/org/elasticsearch/index/mapper/date/SimpleDateMappingTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/date/SimpleDateMappingTests.java index 1bae0b32012..8dbbfcb8061 100644 --- a/src/test/java/org/elasticsearch/index/mapper/date/SimpleDateMappingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/date/SimpleDateMappingTests.java @@ -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 @@ -17,23 +17,24 @@ * under the License. */ -package org.elasticsearch.index.mapper.date; +package org.elasticsearch.test.unit.index.mapper.date; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.FieldMapper; -import org.elasticsearch.index.mapper.MapperTests; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.elasticsearch.index.mapper.ParsedDocument; import org.elasticsearch.index.mapper.core.DateFieldMapper; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; @Test public class SimpleDateMappingTests { - @Test public void testAutomaticDateParser() throws Exception { + @Test + public void testAutomaticDateParser() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("properties").endObject() .endObject().endObject().string(); @@ -59,7 +60,8 @@ public class SimpleDateMappingTests { // assertThat(fieldMapper, instanceOf(DateFieldMapper.class)); } - @Test public void testTimestampAsDate() throws Exception { + @Test + public void testTimestampAsDate() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("properties").startObject("date_field").field("type", "date").endObject().endObject() .endObject().endObject().string(); @@ -76,7 +78,8 @@ public class SimpleDateMappingTests { assertThat(doc.rootDoc().getFieldable("date_field").tokenStreamValue(), notNullValue()); } - @Test public void testDateDetection() throws Exception { + @Test + public void testDateDetection() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .field("date_detection", false) .startObject("properties").startObject("date_field").field("type", "date").endObject().endObject() diff --git a/src/test/java/org/elasticsearch/index/mapper/dynamic/DynamicMappingTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamic/DynamicMappingTests.java similarity index 89% rename from src/test/java/org/elasticsearch/index/mapper/dynamic/DynamicMappingTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/dynamic/DynamicMappingTests.java index e65cb96e1fd..6f1914a16de 100644 --- a/src/test/java/org/elasticsearch/index/mapper/dynamic/DynamicMappingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamic/DynamicMappingTests.java @@ -17,24 +17,26 @@ * under the License. */ -package org.elasticsearch.index.mapper.dynamic; +package org.elasticsearch.test.unit.index.mapper.dynamic; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.mapper.MapperTests; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.elasticsearch.index.mapper.ParsedDocument; import org.elasticsearch.index.mapper.StrictDynamicMappingException; import org.testng.annotations.Test; import java.io.IOException; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.nullValue; @Test public class DynamicMappingTests { - @Test public void testDynamicTrue() throws IOException { + @Test + public void testDynamicTrue() throws IOException { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .field("dynamic", "true") .startObject("properties") @@ -54,7 +56,8 @@ public class DynamicMappingTests { assertThat(doc.rootDoc().get("field2"), equalTo("value2")); } - @Test public void testDynamicFalse() throws IOException { + @Test + public void testDynamicFalse() throws IOException { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .field("dynamic", "false") .startObject("properties") @@ -75,7 +78,8 @@ public class DynamicMappingTests { } - @Test public void testDynamicStrict() throws IOException { + @Test + public void testDynamicStrict() throws IOException { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .field("dynamic", "strict") .startObject("properties") @@ -97,7 +101,8 @@ public class DynamicMappingTests { } } - @Test public void testDynamicFalseWithInnerObjectButDynamicSetOnRoot() throws IOException { + @Test + public void testDynamicFalseWithInnerObjectButDynamicSetOnRoot() throws IOException { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .field("dynamic", "false") .startObject("properties") @@ -120,7 +125,8 @@ public class DynamicMappingTests { assertThat(doc.rootDoc().get("obj1.field2"), nullValue()); } - @Test public void testDynamicStrictWithInnerObjectButDynamicSetOnRoot() throws IOException { + @Test + public void testDynamicStrictWithInnerObjectButDynamicSetOnRoot() throws IOException { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .field("dynamic", "strict") .startObject("properties") diff --git a/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/genericstore/GenericStoreDynamicTemplateTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/genericstore/GenericStoreDynamicTemplateTests.java similarity index 73% rename from src/test/java/org/elasticsearch/index/mapper/dynamictemplate/genericstore/GenericStoreDynamicTemplateTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/genericstore/GenericStoreDynamicTemplateTests.java index bbfbcd7f185..ac8ad138b8e 100644 --- a/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/genericstore/GenericStoreDynamicTemplateTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/genericstore/GenericStoreDynamicTemplateTests.java @@ -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 @@ -17,28 +17,30 @@ * under the License. */ -package org.elasticsearch.index.mapper.dynamictemplate.genericstore; +package org.elasticsearch.test.unit.index.mapper.dynamictemplate.genericstore; import org.apache.lucene.document.Document; import org.apache.lucene.document.Fieldable; import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.FieldMappers; -import org.elasticsearch.index.mapper.MapperTests; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.testng.annotations.Test; -import static org.elasticsearch.common.io.Streams.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.io.Streams.copyToBytesFromClasspath; +import static org.elasticsearch.common.io.Streams.copyToStringFromClasspath; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class GenericStoreDynamicTemplateTests { - @Test public void testSimple() throws Exception { - String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/dynamictemplate/genericstore/test-mapping.json"); + @Test + public void testSimple() throws Exception { + String mapping = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/mapper/dynamictemplate/genericstore/test-mapping.json"); DocumentMapper docMapper = MapperTests.newParser().parse(mapping); - byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/dynamictemplate/genericstore/test-data.json"); + byte[] json = copyToBytesFromClasspath("/org/elasticsearch/test/unit/index/mapper/dynamictemplate/genericstore/test-data.json"); Document doc = docMapper.parse(json).rootDoc(); Fieldable f = doc.getFieldable("name"); diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/genericstore/test-data.json b/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/genericstore/test-data.json new file mode 100644 index 00000000000..75b8a0ec912 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/genericstore/test-data.json @@ -0,0 +1,5 @@ +{ + "_id":"1", + "name":"some name", + "age":1 +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/genericstore/test-mapping.json b/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/genericstore/test-mapping.json new file mode 100644 index 00000000000..d99067c2b52 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/genericstore/test-mapping.json @@ -0,0 +1,14 @@ +{ + "person":{ + "dynamic_templates":[ + { + "template_1":{ + "match":"*", + "mapping":{ + "store":"yes" + } + } + } + ] + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/pathmatch/PathMatchDynamicTempalteTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/pathmatch/PathMatchDynamicTempalteTests.java similarity index 76% rename from src/test/java/org/elasticsearch/index/mapper/dynamictemplate/pathmatch/PathMatchDynamicTempalteTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/pathmatch/PathMatchDynamicTempalteTests.java index a90380b9404..48652cdc3b0 100644 --- a/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/pathmatch/PathMatchDynamicTempalteTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/pathmatch/PathMatchDynamicTempalteTests.java @@ -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 @@ -17,28 +17,30 @@ * under the License. */ -package org.elasticsearch.index.mapper.dynamictemplate.pathmatch; +package org.elasticsearch.test.unit.index.mapper.dynamictemplate.pathmatch; import org.apache.lucene.document.Document; import org.apache.lucene.document.Fieldable; import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.FieldMappers; -import org.elasticsearch.index.mapper.MapperTests; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.testng.annotations.Test; -import static org.elasticsearch.common.io.Streams.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.io.Streams.copyToBytesFromClasspath; +import static org.elasticsearch.common.io.Streams.copyToStringFromClasspath; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class PathMatchDynamicTempalteTests { - @Test public void testSimple() throws Exception { - String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/dynamictemplate/pathmatch/test-mapping.json"); + @Test + public void testSimple() throws Exception { + String mapping = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/mapper/dynamictemplate/pathmatch/test-mapping.json"); DocumentMapper docMapper = MapperTests.newParser().parse(mapping); - byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/dynamictemplate/pathmatch/test-data.json"); + byte[] json = copyToBytesFromClasspath("/org/elasticsearch/test/unit/index/mapper/dynamictemplate/pathmatch/test-data.json"); Document doc = docMapper.parse(json).rootDoc(); Fieldable f = doc.getFieldable("name"); diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/pathmatch/test-data.json b/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/pathmatch/test-data.json new file mode 100644 index 00000000000..2d3a2f7cc72 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/pathmatch/test-data.json @@ -0,0 +1,10 @@ +{ + "_id":"1", + "name":"top_level", + "obj1":{ + "name":"obj1_level", + "obj2":{ + "name":"obj2_level" + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/pathmatch/test-mapping.json b/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/pathmatch/test-mapping.json new file mode 100644 index 00000000000..3806d844ed8 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/pathmatch/test-mapping.json @@ -0,0 +1,22 @@ +{ + "person":{ + "dynamic_templates":[ + { + "template_1":{ + "path_match":"obj1.obj2.*", + "mapping":{ + "store":"no" + } + } + }, + { + "template_2":{ + "path_match":"obj1.*", + "mapping":{ + "store":"yes" + } + } + } + ] + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/simple/SimpleDynamicTemplatesTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/simple/SimpleDynamicTemplatesTests.java similarity index 85% rename from src/test/java/org/elasticsearch/index/mapper/dynamictemplate/simple/SimpleDynamicTemplatesTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/simple/SimpleDynamicTemplatesTests.java index 49e327e06b9..a84a3d7d55b 100644 --- a/src/test/java/org/elasticsearch/index/mapper/dynamictemplate/simple/SimpleDynamicTemplatesTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/simple/SimpleDynamicTemplatesTests.java @@ -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 @@ -17,28 +17,30 @@ * under the License. */ -package org.elasticsearch.index.mapper.dynamictemplate.simple; +package org.elasticsearch.test.unit.index.mapper.dynamictemplate.simple; import org.apache.lucene.document.Document; import org.apache.lucene.document.Fieldable; import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.FieldMappers; -import org.elasticsearch.index.mapper.MapperTests; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.testng.annotations.Test; -import static org.elasticsearch.common.io.Streams.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.io.Streams.copyToBytesFromClasspath; +import static org.elasticsearch.common.io.Streams.copyToStringFromClasspath; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class SimpleDynamicTemplatesTests { - @Test public void testSimple() throws Exception { - String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/dynamictemplate/simple/test-mapping.json"); + @Test + public void testSimple() throws Exception { + String mapping = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/mapper/dynamictemplate/simple/test-mapping.json"); DocumentMapper docMapper = MapperTests.newParser().parse(mapping); - byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/dynamictemplate/simple/test-data.json"); + byte[] json = copyToBytesFromClasspath("/org/elasticsearch/test/unit/index/mapper/dynamictemplate/simple/test-data.json"); Document doc = docMapper.parse(json).rootDoc(); Fieldable f = doc.getFieldable("name"); @@ -87,13 +89,14 @@ public class SimpleDynamicTemplatesTests { assertThat(fieldMappers.mappers().size(), equalTo(1)); } - @Test public void testSimpleWithXContentTraverse() throws Exception { - String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/dynamictemplate/simple/test-mapping.json"); + @Test + public void testSimpleWithXContentTraverse() throws Exception { + String mapping = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/mapper/dynamictemplate/simple/test-mapping.json"); DocumentMapper docMapper = MapperTests.newParser().parse(mapping); docMapper.refreshSource(); docMapper = MapperTests.newParser().parse(docMapper.mappingSource().string()); - byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/dynamictemplate/simple/test-data.json"); + byte[] json = copyToBytesFromClasspath("/org/elasticsearch/test/unit/index/mapper/dynamictemplate/simple/test-data.json"); Document doc = docMapper.parse(json).rootDoc(); Fieldable f = doc.getFieldable("name"); diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/simple/test-data.json b/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/simple/test-data.json new file mode 100644 index 00000000000..5682d1d1360 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/simple/test-data.json @@ -0,0 +1,7 @@ +{ + "_id":"1", + "name":"some name", + "age":1, + "multi1":"multi 1", + "multi2":"multi 2" +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/simple/test-mapping.json b/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/simple/test-mapping.json new file mode 100644 index 00000000000..fa0293c89f7 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/simple/test-mapping.json @@ -0,0 +1,36 @@ +{ + "person":{ + "dynamic_templates":[ + { + "tempalte_1":{ + "match":"multi*", + "mapping":{ + "type":"multi_field", + "fields":{ + "{name}":{ + "type":"{dynamic_type}", + "index":"analyzed", + "store":"yes" + }, + "org":{ + "type":"{dynamic_type}", + "index":"not_analyzed", + "store":"yes" + } + } + } + } + }, + { + "template_2":{ + "match":"*", + "match_mapping_type":"string", + "mapping":{ + "type":"string", + "index":"not_analyzed" + } + } + } + ] + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/mapper/geopoint/GeohashMappingGeoPointTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/geopoint/GeohashMappingGeoPointTests.java similarity index 89% rename from src/test/java/org/elasticsearch/index/mapper/geopoint/GeohashMappingGeoPointTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/geopoint/GeohashMappingGeoPointTests.java index 5e55223ddb8..c4661249cbc 100644 --- a/src/test/java/org/elasticsearch/index/mapper/geopoint/GeohashMappingGeoPointTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/geopoint/GeohashMappingGeoPointTests.java @@ -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 @@ -17,11 +17,11 @@ * under the License. */ -package org.elasticsearch.index.mapper.geopoint; +package org.elasticsearch.test.unit.index.mapper.geopoint; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.mapper.MapperTests; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.elasticsearch.index.mapper.ParsedDocument; import org.elasticsearch.index.search.geo.GeoHashUtils; import org.hamcrest.MatcherAssert; @@ -30,11 +30,12 @@ import org.testng.annotations.Test; import static org.hamcrest.Matchers.*; /** - * @author kimchy (shay.banon) + * */ public class GeohashMappingGeoPointTests { - @Test public void testLatLonValues() throws Exception { + @Test + public void testLatLonValues() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", false).endObject().endObject() .endObject().endObject().string(); @@ -52,7 +53,8 @@ public class GeohashMappingGeoPointTests { MatcherAssert.assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3")); } - @Test public void testLatLonInOneValue() throws Exception { + @Test + public void testLatLonInOneValue() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", false).endObject().endObject() .endObject().endObject().string(); @@ -70,7 +72,8 @@ public class GeohashMappingGeoPointTests { MatcherAssert.assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3")); } - @Test public void testGeoHashValue() throws Exception { + @Test + public void testGeoHashValue() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("properties").startObject("point").field("type", "geo_point").field("geohash", true).endObject().endObject() .endObject().endObject().string(); diff --git a/src/test/java/org/elasticsearch/index/mapper/geopoint/LatLonAndGeohashMappingGeoPointTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/geopoint/LatLonAndGeohashMappingGeoPointTests.java similarity index 86% rename from src/test/java/org/elasticsearch/index/mapper/geopoint/LatLonAndGeohashMappingGeoPointTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/geopoint/LatLonAndGeohashMappingGeoPointTests.java index f56d587b814..d381598d5da 100644 --- a/src/test/java/org/elasticsearch/index/mapper/geopoint/LatLonAndGeohashMappingGeoPointTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/geopoint/LatLonAndGeohashMappingGeoPointTests.java @@ -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 @@ -17,24 +17,26 @@ * under the License. */ -package org.elasticsearch.index.mapper.geopoint; +package org.elasticsearch.test.unit.index.mapper.geopoint; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.mapper.MapperTests; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.elasticsearch.index.mapper.ParsedDocument; import org.elasticsearch.index.search.geo.GeoHashUtils; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.notNullValue; /** - * @author kimchy (shay.banon) + * */ public class LatLonAndGeohashMappingGeoPointTests { - @Test public void testLatLonValues() throws Exception { + @Test + public void testLatLonValues() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", true).field("geohash", true).endObject().endObject() .endObject().endObject().string(); @@ -52,7 +54,8 @@ public class LatLonAndGeohashMappingGeoPointTests { assertThat(doc.rootDoc().get("point.geohash"), equalTo(GeoHashUtils.encode(1.2, 1.3))); } - @Test public void testLatLonInOneValue() throws Exception { + @Test + public void testLatLonInOneValue() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", true).field("geohash", true).endObject().endObject() .endObject().endObject().string(); @@ -70,7 +73,8 @@ public class LatLonAndGeohashMappingGeoPointTests { assertThat(doc.rootDoc().get("point.geohash"), equalTo(GeoHashUtils.encode(1.2, 1.3))); } - @Test public void testGeoHashValue() throws Exception { + @Test + public void testGeoHashValue() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", true).field("geohash", true).endObject().endObject() .endObject().endObject().string(); diff --git a/src/test/java/org/elasticsearch/index/mapper/geopoint/LatLonMappingGeoPointTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/geopoint/LatLonMappingGeoPointTests.java similarity index 93% rename from src/test/java/org/elasticsearch/index/mapper/geopoint/LatLonMappingGeoPointTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/geopoint/LatLonMappingGeoPointTests.java index 653bf94102c..05a819d14af 100644 --- a/src/test/java/org/elasticsearch/index/mapper/geopoint/LatLonMappingGeoPointTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/geopoint/LatLonMappingGeoPointTests.java @@ -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 @@ -17,26 +17,27 @@ * under the License. */ -package org.elasticsearch.index.mapper.geopoint; +package org.elasticsearch.test.unit.index.mapper.geopoint; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.Numbers; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.mapper.MapperTests; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.elasticsearch.index.mapper.ParsedDocument; import org.elasticsearch.index.search.geo.GeoHashUtils; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** - * @author kimchy (shay.banon) + * */ public class LatLonMappingGeoPointTests { - @Test public void testNormalizeLatLonValuesDefault() throws Exception { + @Test + public void testNormalizeLatLonValuesDefault() throws Exception { // default to normalize String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("properties").startObject("point").field("type", "geo_point").endObject().endObject() @@ -69,7 +70,8 @@ public class LatLonMappingGeoPointTests { assertThat(doc.rootDoc().get("point"), equalTo("1.0,1.0")); } - @Test public void testValidateLatLonValues() throws Exception { + @Test + public void testValidateLatLonValues() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", true).field("normalize", false).field("validate", true).endObject().endObject() .endObject().endObject().string(); @@ -129,7 +131,8 @@ public class LatLonMappingGeoPointTests { } - @Test public void testNoValidateLatLonValues() throws Exception { + @Test + public void testNoValidateLatLonValues() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", true).field("normalize", false).field("validate", false).endObject().endObject() .endObject().endObject().string(); @@ -168,7 +171,8 @@ public class LatLonMappingGeoPointTests { .copiedBytes()); } - @Test public void testLatLonValues() throws Exception { + @Test + public void testLatLonValues() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", true).endObject().endObject() .endObject().endObject().string(); @@ -189,7 +193,8 @@ public class LatLonMappingGeoPointTests { assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3")); } - @Test public void testLatLonValuesStored() throws Exception { + @Test + public void testLatLonValuesStored() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", true).field("store", "yes").endObject().endObject() .endObject().endObject().string(); @@ -210,7 +215,8 @@ public class LatLonMappingGeoPointTests { assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3")); } - @Test public void testArrayLatLonValues() throws Exception { + @Test + public void testArrayLatLonValues() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", true).field("store", "yes").endObject().endObject() .endObject().endObject().string(); @@ -236,7 +242,8 @@ public class LatLonMappingGeoPointTests { assertThat(doc.rootDoc().getFieldables("point")[1].stringValue(), equalTo("1.4,1.5")); } - @Test public void testLatLonInOneValue() throws Exception { + @Test + public void testLatLonInOneValue() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", true).endObject().endObject() .endObject().endObject().string(); @@ -254,7 +261,8 @@ public class LatLonMappingGeoPointTests { assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3")); } - @Test public void testLatLonInOneValueStored() throws Exception { + @Test + public void testLatLonInOneValueStored() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", true).field("store", "yes").endObject().endObject() .endObject().endObject().string(); @@ -274,7 +282,8 @@ public class LatLonMappingGeoPointTests { assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3")); } - @Test public void testLatLonInOneValueArray() throws Exception { + @Test + public void testLatLonInOneValueArray() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", true).field("store", "yes").endObject().endObject() .endObject().endObject().string(); @@ -300,7 +309,8 @@ public class LatLonMappingGeoPointTests { assertThat(doc.rootDoc().getFieldables("point")[1].stringValue(), equalTo("1.4,1.5")); } - @Test public void testGeoHashValue() throws Exception { + @Test + public void testGeoHashValue() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", true).endObject().endObject() .endObject().endObject().string(); @@ -318,7 +328,8 @@ public class LatLonMappingGeoPointTests { assertThat(doc.rootDoc().get("point"), notNullValue()); } - @Test public void testLonLatArray() throws Exception { + @Test + public void testLonLatArray() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", true).endObject().endObject() .endObject().endObject().string(); @@ -338,7 +349,8 @@ public class LatLonMappingGeoPointTests { assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3")); } - @Test public void testLonLatArrayStored() throws Exception { + @Test + public void testLonLatArrayStored() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", true).field("store", "yes").endObject().endObject() .endObject().endObject().string(); @@ -358,7 +370,8 @@ public class LatLonMappingGeoPointTests { assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3")); } - @Test public void testLonLatArrayArrayStored() throws Exception { + @Test + public void testLonLatArrayArrayStored() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", true).field("store", "yes").endObject().endObject() .endObject().endObject().string(); diff --git a/src/test/java/org/elasticsearch/index/mapper/id/IdMappingTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/id/IdMappingTests.java similarity index 90% rename from src/test/java/org/elasticsearch/index/mapper/id/IdMappingTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/id/IdMappingTests.java index 7f40cadd45c..2c4ce3795a7 100644 --- a/src/test/java/org/elasticsearch/index/mapper/id/IdMappingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/id/IdMappingTests.java @@ -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 @@ -17,20 +17,20 @@ * under the License. */ -package org.elasticsearch.index.mapper.id; +package org.elasticsearch.test.unit.index.mapper.id; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MapperTests; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.elasticsearch.index.mapper.ParsedDocument; import org.elasticsearch.index.mapper.internal.IdFieldMapper; import org.elasticsearch.index.mapper.internal.UidFieldMapper; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** @@ -38,7 +38,8 @@ import static org.hamcrest.Matchers.*; @Test public class IdMappingTests { - @Test public void simpleIdTests() throws Exception { + @Test + public void simpleIdTests() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .endObject().endObject().string(); DocumentMapper docMapper = MapperTests.newParser().parse(mapping); @@ -70,7 +71,8 @@ public class IdMappingTests { assertThat(doc.rootDoc().get(IdFieldMapper.NAME), nullValue()); } - @Test public void testIdIndexed() throws Exception { + @Test + public void testIdIndexed() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("_id").field("index", "not_analyzed").endObject() .endObject().endObject().string(); @@ -94,7 +96,8 @@ public class IdMappingTests { assertThat(doc.rootDoc().get(IdFieldMapper.NAME), notNullValue()); } - @Test public void testIdPath() throws Exception { + @Test + public void testIdPath() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("_id").field("path", "my_path").endObject() .endObject().endObject().string(); diff --git a/src/test/java/org/elasticsearch/index/mapper/index/IndexTypeMapperTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/index/IndexTypeMapperTests.java similarity index 87% rename from src/test/java/org/elasticsearch/index/mapper/index/IndexTypeMapperTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/index/IndexTypeMapperTests.java index da8c958df09..c3428888f74 100644 --- a/src/test/java/org/elasticsearch/index/mapper/index/IndexTypeMapperTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/index/IndexTypeMapperTests.java @@ -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 @@ -17,25 +17,26 @@ * under the License. */ -package org.elasticsearch.index.mapper.index; +package org.elasticsearch.test.unit.index.mapper.index; import org.apache.lucene.document.Field; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.mapper.MapperTests; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.elasticsearch.index.mapper.ParsedDocument; import org.elasticsearch.index.mapper.internal.IndexFieldMapper; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** - * @author kimchy (shay.banon) + * */ public class IndexTypeMapperTests { - @Test public void simpleIndexMapperTests() throws Exception { + @Test + public void simpleIndexMapperTests() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("_index").field("enabled", true).field("store", "yes").endObject() .endObject().endObject().string(); @@ -55,7 +56,8 @@ public class IndexTypeMapperTests { assertThat(doc.rootDoc().get("field"), equalTo("value")); } - @Test public void explicitDisabledIndexMapperTests() throws Exception { + @Test + public void explicitDisabledIndexMapperTests() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("_index").field("enabled", false).field("store", "yes").endObject() .endObject().endObject().string(); @@ -74,7 +76,8 @@ public class IndexTypeMapperTests { assertThat(doc.rootDoc().get("field"), equalTo("value")); } - @Test public void defaultDisabledIndexMapperTests() throws Exception { + @Test + public void defaultDisabledIndexMapperTests() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .endObject().endObject().string(); DocumentMapper docMapper = MapperTests.newParser().parse(mapping); diff --git a/src/test/java/org/elasticsearch/index/mapper/ip/SimpleIpMappingTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/ip/SimpleIpMappingTests.java similarity index 90% rename from src/test/java/org/elasticsearch/index/mapper/ip/SimpleIpMappingTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/ip/SimpleIpMappingTests.java index 54104c4c28b..cab2a875c92 100644 --- a/src/test/java/org/elasticsearch/index/mapper/ip/SimpleIpMappingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/ip/SimpleIpMappingTests.java @@ -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 @@ -17,10 +17,10 @@ * under the License. */ -package org.elasticsearch.index.mapper.ip; +package org.elasticsearch.test.unit.index.mapper.ip; /** - * @author kimchy (shay.banon) + * */ public class SimpleIpMappingTests { diff --git a/src/test/java/org/elasticsearch/index/mapper/lucene/DoubleIndexingDocTest.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/lucene/DoubleIndexingDocTest.java similarity index 90% rename from src/test/java/org/elasticsearch/index/mapper/lucene/DoubleIndexingDocTest.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/lucene/DoubleIndexingDocTest.java index 4812b6c4f6d..4395a7d3012 100644 --- a/src/test/java/org/elasticsearch/index/mapper/lucene/DoubleIndexingDocTest.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/lucene/DoubleIndexingDocTest.java @@ -1,4 +1,4 @@ -package org.elasticsearch.index.mapper.lucene; +package org.elasticsearch.test.unit.index.mapper.lucene; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexWriter; @@ -9,20 +9,21 @@ import org.apache.lucene.store.RAMDirectory; import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.mapper.MapperTests; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.elasticsearch.index.mapper.ParsedDocument; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ @Test public class DoubleIndexingDocTest { - @Test public void testDoubleIndexingSameDoc() throws Exception { + @Test + public void testDoubleIndexingSameDoc() throws Exception { IndexWriter writer = new IndexWriter(new RAMDirectory(), new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER)); String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") diff --git a/src/test/java/org/elasticsearch/index/mapper/merge/Test1MergeMapperTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/merge/Test1MergeMapperTests.java similarity index 78% rename from src/test/java/org/elasticsearch/index/mapper/merge/Test1MergeMapperTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/merge/Test1MergeMapperTests.java index 2ae28e91017..8c0908c2070 100644 --- a/src/test/java/org/elasticsearch/index/mapper/merge/Test1MergeMapperTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/merge/Test1MergeMapperTests.java @@ -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 @@ -17,27 +17,28 @@ * under the License. */ -package org.elasticsearch.index.mapper.merge; +package org.elasticsearch.test.unit.index.mapper.merge; import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.mapper.MapperTests; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.testng.annotations.Test; -import static org.elasticsearch.common.io.Streams.*; -import static org.elasticsearch.index.mapper.DocumentMapper.MergeFlags.*; -import static org.hamcrest.MatcherAssert.*; +import static org.elasticsearch.common.io.Streams.copyToStringFromClasspath; +import static org.elasticsearch.index.mapper.DocumentMapper.MergeFlags.mergeFlags; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** - * @author kimchy (shay.banon) + * */ @Test public class Test1MergeMapperTests { - @Test public void test1Merge() throws Exception { - String stage1Mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/merge/stage1.json"); + @Test + public void test1Merge() throws Exception { + String stage1Mapping = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/mapper/merge/stage1.json"); DocumentMapper stage1 = MapperTests.newParser().parse(stage1Mapping); - String stage2Mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/merge/stage2.json"); + String stage2Mapping = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/mapper/merge/stage2.json"); DocumentMapper stage2 = MapperTests.newParser().parse(stage2Mapping); DocumentMapper.MergeResult mergeResult = stage1.merge(stage2, mergeFlags().simulate(true)); diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/merge/stage1.json b/src/test/java/org/elasticsearch/test/unit/index/mapper/merge/stage1.json new file mode 100644 index 00000000000..1c963d73b68 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/merge/stage1.json @@ -0,0 +1,9 @@ +{ + "person":{ + "properties":{ + "name":{ + "type":"string" + } + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/merge/stage2.json b/src/test/java/org/elasticsearch/test/unit/index/mapper/merge/stage2.json new file mode 100644 index 00000000000..a7b93df9bfa --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/merge/stage2.json @@ -0,0 +1,19 @@ +{ + "person":{ + "properties":{ + "name":{ + "type":"string" + }, + "age":{ + "type":"integer" + }, + "obj1":{ + "properties":{ + "prop1":{ + "type":"string" + } + } + } + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/mapper/multifield/MultiFieldTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/MultiFieldTests.java similarity index 83% rename from src/test/java/org/elasticsearch/index/mapper/multifield/MultiFieldTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/MultiFieldTests.java index 3621d60fff8..0e7b56d1c3c 100644 --- a/src/test/java/org/elasticsearch/index/mapper/multifield/MultiFieldTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/MultiFieldTests.java @@ -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 @@ -17,31 +17,33 @@ * under the License. */ -package org.elasticsearch.index.mapper.multifield; +package org.elasticsearch.test.unit.index.mapper.multifield; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.document.Fieldable; import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.DocumentMapperParser; -import org.elasticsearch.index.mapper.MapperTests; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.testng.annotations.Test; -import static org.elasticsearch.common.io.Streams.*; +import static org.elasticsearch.common.io.Streams.copyToBytesFromClasspath; +import static org.elasticsearch.common.io.Streams.copyToStringFromClasspath; import static org.elasticsearch.index.mapper.MapperBuilders.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ @Test public class MultiFieldTests { - @Test public void testMultiField() throws Exception { - String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multifield/test-mapping.json"); + @Test + public void testMultiField() throws Exception { + String mapping = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/mapper/multifield/test-mapping.json"); DocumentMapper docMapper = MapperTests.newParser().parse(mapping); - byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/multifield/test-data.json"); + byte[] json = copyToBytesFromClasspath("/org/elasticsearch/test/unit/index/mapper/multifield/test-data.json"); Document doc = docMapper.parse(json).rootDoc(); Fieldable f = doc.getFieldable("name"); @@ -70,7 +72,8 @@ public class MultiFieldTests { assertThat(f.stringValue(), equalTo("2010-01-01")); } - @Test public void testBuildThenParse() throws Exception { + @Test + public void testBuildThenParse() throws Exception { DocumentMapperParser mapperParser = MapperTests.newParser(); DocumentMapper builderDocMapper = doc("test", rootObject("person").add( @@ -87,7 +90,7 @@ public class MultiFieldTests { DocumentMapper docMapper = mapperParser.parse(builtMapping); - byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/multifield/test-data.json"); + byte[] json = copyToBytesFromClasspath("/org/elasticsearch/test/unit/index/mapper/multifield/test-data.json"); Document doc = docMapper.parse(json).rootDoc(); Fieldable f = doc.getFieldable("name"); diff --git a/src/test/java/org/elasticsearch/index/mapper/multifield/merge/JavaMultiFieldMergeTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/merge/JavaMultiFieldMergeTests.java similarity index 83% rename from src/test/java/org/elasticsearch/index/mapper/multifield/merge/JavaMultiFieldMergeTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/merge/JavaMultiFieldMergeTests.java index f328ba7e90c..dd3b362a715 100644 --- a/src/test/java/org/elasticsearch/index/mapper/multifield/merge/JavaMultiFieldMergeTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/merge/JavaMultiFieldMergeTests.java @@ -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 @@ -17,30 +17,32 @@ * under the License. */ -package org.elasticsearch.index.mapper.multifield.merge; +package org.elasticsearch.test.unit.index.mapper.multifield.merge; import org.apache.lucene.document.Document; import org.apache.lucene.document.Fieldable; import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.DocumentMapperParser; -import org.elasticsearch.index.mapper.MapperTests; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.testng.annotations.Test; import java.util.Arrays; -import static org.elasticsearch.common.io.Streams.*; -import static org.elasticsearch.index.mapper.DocumentMapper.MergeFlags.*; -import static org.hamcrest.MatcherAssert.*; +import static org.elasticsearch.common.io.Streams.copyToBytesFromClasspath; +import static org.elasticsearch.common.io.Streams.copyToStringFromClasspath; +import static org.elasticsearch.index.mapper.DocumentMapper.MergeFlags.mergeFlags; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** - * @author kimchy (shay.banon) + * */ @Test public class JavaMultiFieldMergeTests { - @Test public void testMergeMultiField() throws Exception { - String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multifield/merge/test-mapping1.json"); + @Test + public void testMergeMultiField() throws Exception { + String mapping = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/mapper/multifield/merge/test-mapping1.json"); DocumentMapperParser parser = MapperTests.newParser(); DocumentMapper docMapper = parser.parse(mapping); @@ -48,7 +50,7 @@ public class JavaMultiFieldMergeTests { assertThat(docMapper.mappers().fullName("name").mapper().indexed(), equalTo(true)); assertThat(docMapper.mappers().fullName("name.indexed"), nullValue()); - byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/multifield/merge/test-data.json"); + byte[] json = copyToBytesFromClasspath("/org/elasticsearch/test/unit/index/mapper/multifield/merge/test-data.json"); Document doc = docMapper.parse(json).rootDoc(); Fieldable f = doc.getFieldable("name"); assertThat(f, notNullValue()); @@ -56,7 +58,7 @@ public class JavaMultiFieldMergeTests { assertThat(f, nullValue()); - mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multifield/merge/test-mapping2.json"); + mapping = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/mapper/multifield/merge/test-mapping2.json"); DocumentMapper docMapper2 = parser.parse(mapping); DocumentMapper.MergeResult mergeResult = docMapper.merge(docMapper2, mergeFlags().simulate(true)); @@ -72,14 +74,14 @@ public class JavaMultiFieldMergeTests { assertThat(docMapper.mappers().fullName("name.not_indexed2"), nullValue()); assertThat(docMapper.mappers().fullName("name.not_indexed3"), nullValue()); - json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/multifield/merge/test-data.json"); + json = copyToBytesFromClasspath("/org/elasticsearch/test/unit/index/mapper/multifield/merge/test-data.json"); doc = docMapper.parse(json).rootDoc(); f = doc.getFieldable("name"); assertThat(f, notNullValue()); f = doc.getFieldable("name.indexed"); assertThat(f, notNullValue()); - mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multifield/merge/test-mapping3.json"); + mapping = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/mapper/multifield/merge/test-mapping3.json"); DocumentMapper docMapper3 = parser.parse(mapping); mergeResult = docMapper.merge(docMapper3, mergeFlags().simulate(true)); @@ -96,7 +98,7 @@ public class JavaMultiFieldMergeTests { assertThat(docMapper.mappers().fullName("name.not_indexed3"), nullValue()); - mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multifield/merge/test-mapping4.json"); + mapping = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/mapper/multifield/merge/test-mapping4.json"); DocumentMapper docMapper4 = parser.parse(mapping); mergeResult = docMapper.merge(docMapper4, mergeFlags().simulate(true)); diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/merge/test-data.json b/src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/merge/test-data.json new file mode 100644 index 00000000000..c539fcc885d --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/merge/test-data.json @@ -0,0 +1,4 @@ +{ + _id:1, + name:"some name" +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/merge/test-mapping1.json b/src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/merge/test-mapping1.json new file mode 100644 index 00000000000..61f08af57e2 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/merge/test-mapping1.json @@ -0,0 +1,11 @@ +{ + person:{ + properties:{ + "name":{ + type:"string", + index:"analyzed", + store:"yes" + } + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/merge/test-mapping2.json b/src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/merge/test-mapping2.json new file mode 100644 index 00000000000..6206592afcb --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/merge/test-mapping2.json @@ -0,0 +1,25 @@ +{ + person:{ + properties:{ + "name":{ + type:"multi_field", + "fields":{ + "name":{ + type:"string", + index:"analyzed", + store:"yes" + }, + "indexed":{ + type:"string", + index:"analyzed" + }, + "not_indexed":{ + type:"string", + index:"no", + store:"yes" + } + } + } + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/merge/test-mapping3.json b/src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/merge/test-mapping3.json new file mode 100644 index 00000000000..4a8fbf66ced --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/merge/test-mapping3.json @@ -0,0 +1,30 @@ +{ + person:{ + properties:{ + "name":{ + type:"multi_field", + "fields":{ + "name":{ + type:"string", + index:"analyzed", + store:"yes" + }, + "indexed":{ + type:"string", + index:"analyzed" + }, + "not_indexed":{ + type:"string", + index:"no", + store:"yes" + }, + "not_indexed2":{ + type:"string", + index:"no", + store:"yes" + } + } + } + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/merge/test-mapping4.json b/src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/merge/test-mapping4.json new file mode 100644 index 00000000000..9b309789f50 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/merge/test-mapping4.json @@ -0,0 +1,16 @@ +{ + person:{ + properties:{ + "name":{ + type:"multi_field", + "fields":{ + "not_indexed3":{ + type:"string", + index:"no", + store:"yes" + } + } + } + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/test-data.json b/src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/test-data.json new file mode 100644 index 00000000000..e0f22340b0f --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/test-data.json @@ -0,0 +1,7 @@ +{ + "_id":1, + "name":"some name", + "object1":{ + "multi1":"2010-01-01" + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/test-mapping.json b/src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/test-mapping.json new file mode 100644 index 00000000000..3ebf7a86bad --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/test-mapping.json @@ -0,0 +1,41 @@ +{ + "person":{ + "properties":{ + "name":{ + "type":"multi_field", + "fields":{ + "name":{ + "type":"string", + "index":"analyzed", + "store":"yes" + }, + "indexed":{ + "type":"string", + "index":"analyzed" + }, + "not_indexed":{ + "type":"string", + "index":"no", + "store":"yes" + } + } + }, + "object1":{ + "properties":{ + "multi1":{ + "type":"multi_field", + "fields":{ + "multi1":{ + "type":"date" + }, + "string":{ + "type":"string", + "index":"not_analyzed" + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/mapper/nested/NestedMappingTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/nested/NestedMappingTests.java similarity index 95% rename from src/test/java/org/elasticsearch/index/mapper/nested/NestedMappingTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/nested/NestedMappingTests.java index 624fe3c7367..e5e4a704def 100644 --- a/src/test/java/org/elasticsearch/index/mapper/nested/NestedMappingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/nested/NestedMappingTests.java @@ -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 @@ -17,23 +17,25 @@ * under the License. */ -package org.elasticsearch.index.mapper.nested; +package org.elasticsearch.test.unit.index.mapper.nested; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.mapper.MapperTests; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.elasticsearch.index.mapper.ParsedDocument; import org.elasticsearch.index.mapper.internal.TypeFieldMapper; import org.elasticsearch.index.mapper.object.ObjectMapper; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.nullValue; @Test public class NestedMappingTests { - @Test public void emptyNested() throws Exception { + @Test + public void emptyNested() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties") .startObject("nested1").field("type", "nested").endObject() .endObject().endObject().endObject().string(); @@ -59,7 +61,8 @@ public class NestedMappingTests { assertThat(doc.docs().size(), equalTo(1)); } - @Test public void singleNested() throws Exception { + @Test + public void singleNested() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties") .startObject("nested1").field("type", "nested").endObject() .endObject().endObject().endObject().string(); @@ -106,7 +109,8 @@ public class NestedMappingTests { assertThat(doc.docs().get(2).get("field"), equalTo("value")); } - @Test public void multiNested() throws Exception { + @Test + public void multiNested() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties") .startObject("nested1").field("type", "nested").startObject("properties") .startObject("nested2").field("type", "nested") @@ -157,7 +161,8 @@ public class NestedMappingTests { assertThat(doc.docs().get(6).get("nested1.nested2.field2"), nullValue()); } - @Test public void multiObjectAndNested1() throws Exception { + @Test + public void multiObjectAndNested1() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties") .startObject("nested1").field("type", "nested").startObject("properties") .startObject("nested2").field("type", "nested").field("include_in_parent", true) @@ -208,7 +213,8 @@ public class NestedMappingTests { assertThat(doc.docs().get(6).get("nested1.nested2.field2"), nullValue()); } - @Test public void multiObjectAndNested2() throws Exception { + @Test + public void multiObjectAndNested2() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties") .startObject("nested1").field("type", "nested").field("include_in_parent", true).startObject("properties") .startObject("nested2").field("type", "nested").field("include_in_parent", true) @@ -259,7 +265,8 @@ public class NestedMappingTests { assertThat(doc.docs().get(6).getFieldables("nested1.nested2.field2").length, equalTo(4)); } - @Test public void multiRootAndNested1() throws Exception { + @Test + public void multiRootAndNested1() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties") .startObject("nested1").field("type", "nested").startObject("properties") .startObject("nested2").field("type", "nested").field("include_in_root", true) diff --git a/src/test/java/org/elasticsearch/index/mapper/numeric/SimpleNumericTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/numeric/SimpleNumericTests.java similarity index 89% rename from src/test/java/org/elasticsearch/index/mapper/numeric/SimpleNumericTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/numeric/SimpleNumericTests.java index 83c64b72ec7..7d538639af2 100644 --- a/src/test/java/org/elasticsearch/index/mapper/numeric/SimpleNumericTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/numeric/SimpleNumericTests.java @@ -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 @@ -17,20 +17,20 @@ * under the License. */ -package org.elasticsearch.index.mapper.numeric; +package org.elasticsearch.test.unit.index.mapper.numeric; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.FieldMapper; -import org.elasticsearch.index.mapper.MapperTests; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.elasticsearch.index.mapper.ParsedDocument; import org.elasticsearch.index.mapper.core.DoubleFieldMapper; import org.elasticsearch.index.mapper.core.LongFieldMapper; import org.elasticsearch.index.mapper.core.StringFieldMapper; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.instanceOf; /** */ diff --git a/src/test/java/org/elasticsearch/index/mapper/object/NullValueObjectMappingTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/object/NullValueObjectMappingTests.java similarity index 85% rename from src/test/java/org/elasticsearch/index/mapper/object/NullValueObjectMappingTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/object/NullValueObjectMappingTests.java index 5b53dbc5df9..b5c94c4890d 100644 --- a/src/test/java/org/elasticsearch/index/mapper/object/NullValueObjectMappingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/object/NullValueObjectMappingTests.java @@ -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 @@ -17,25 +17,26 @@ * under the License. */ -package org.elasticsearch.index.mapper.object; +package org.elasticsearch.test.unit.index.mapper.object; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.mapper.MapperTests; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.elasticsearch.index.mapper.ParsedDocument; import org.testng.annotations.Test; import java.io.IOException; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class NullValueObjectMappingTests { - @Test public void testNullValueObject() throws IOException { + @Test + public void testNullValueObject() throws IOException { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("properties").startObject("obj1").field("type", "object").endObject().endObject() .endObject().endObject().string(); diff --git a/src/test/java/org/elasticsearch/index/mapper/overridetype/OverrideTypeMappingTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/overridetype/OverrideTypeMappingTests.java similarity index 78% rename from src/test/java/org/elasticsearch/index/mapper/overridetype/OverrideTypeMappingTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/overridetype/OverrideTypeMappingTests.java index 14e78a5e395..7fd971a2088 100644 --- a/src/test/java/org/elasticsearch/index/mapper/overridetype/OverrideTypeMappingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/overridetype/OverrideTypeMappingTests.java @@ -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 @@ -17,22 +17,23 @@ * under the License. */ -package org.elasticsearch.index.mapper.overridetype; +package org.elasticsearch.test.unit.index.mapper.overridetype; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.mapper.MapperTests; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class OverrideTypeMappingTests { - @Test public void testOverrideType() throws Exception { + @Test + public void testOverrideType() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("_source").field("enabled", false).endObject() .endObject().endObject().string(); diff --git a/src/test/java/org/elasticsearch/index/mapper/parent/ParentMappingTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/parent/ParentMappingTests.java similarity index 84% rename from src/test/java/org/elasticsearch/index/mapper/parent/ParentMappingTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/parent/ParentMappingTests.java index 25be48f2ca9..8e6f3e82080 100644 --- a/src/test/java/org/elasticsearch/index/mapper/parent/ParentMappingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/parent/ParentMappingTests.java @@ -17,25 +17,23 @@ * under the License. */ -package org.elasticsearch.index.mapper.parent; +package org.elasticsearch.test.unit.index.mapper.parent; import org.elasticsearch.common.xcontent.XContentFactory; -import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.mapper.MapperTests; -import org.elasticsearch.index.mapper.ParsedDocument; -import org.elasticsearch.index.mapper.SourceToParse; -import org.elasticsearch.index.mapper.Uid; +import org.elasticsearch.index.mapper.*; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class ParentMappingTests { - @Test public void parentNotMapped() throws Exception { + @Test + public void parentNotMapped() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .endObject().endObject().string(); DocumentMapper docMapper = MapperTests.newParser().parse(mapping); @@ -52,7 +50,8 @@ public class ParentMappingTests { assertThat(doc.rootDoc().get("_parent"), equalTo("1122")); } - @Test public void parentSetInDocNotExternally() throws Exception { + @Test + public void parentSetInDocNotExternally() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("_parent").field("type", "p_type").endObject() .endObject().endObject().string(); @@ -64,12 +63,13 @@ public class ParentMappingTests { .field("x_field", "x_value") .endObject() .copiedBytes()).type("type").id("1")); - + assertThat(doc.parent(), equalTo("1122")); assertThat(doc.rootDoc().get("_parent"), equalTo(Uid.createUid("p_type", "1122"))); } - @Test public void parentNotSetInDocSetExternally() throws Exception { + @Test + public void parentNotSetInDocSetExternally() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("_parent").field("type", "p_type").endObject() .endObject().endObject().string(); @@ -84,7 +84,8 @@ public class ParentMappingTests { assertThat(doc.rootDoc().get("_parent"), equalTo(Uid.createUid("p_type", "1122"))); } - @Test public void parentSetInDocSetExternally() throws Exception { + @Test + public void parentSetInDocSetExternally() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("_parent").field("type", "p_type").endObject() .endObject().endObject().string(); diff --git a/src/test/java/org/elasticsearch/index/mapper/path/PathMapperTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/path/PathMapperTests.java similarity index 83% rename from src/test/java/org/elasticsearch/index/mapper/path/PathMapperTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/path/PathMapperTests.java index 1fdd327e914..afa206c6053 100644 --- a/src/test/java/org/elasticsearch/index/mapper/path/PathMapperTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/path/PathMapperTests.java @@ -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 @@ -17,25 +17,27 @@ * under the License. */ -package org.elasticsearch.index.mapper.path; +package org.elasticsearch.test.unit.index.mapper.path; import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.mapper.MapperTests; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.testng.annotations.Test; import java.io.IOException; -import static org.elasticsearch.common.io.Streams.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.io.Streams.copyToStringFromClasspath; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.notNullValue; +import static org.hamcrest.Matchers.nullValue; /** - * @author kimchy (shay.banon) + * */ public class PathMapperTests { - @Test public void testPathMapping() throws IOException { - String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/path/test-mapping.json"); + @Test + public void testPathMapping() throws IOException { + String mapping = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/mapper/path/test-mapping.json"); DocumentMapper docMapper = MapperTests.newParser().parse(mapping); assertThat(docMapper.mappers().indexName("first1"), notNullValue()); diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/path/test-mapping.json b/src/test/java/org/elasticsearch/test/unit/index/mapper/path/test-mapping.json new file mode 100644 index 00000000000..200a45107d3 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/path/test-mapping.json @@ -0,0 +1,32 @@ +{ + "person":{ + "properties":{ + "name1":{ + "type":"object", + "path":"just_name", + "properties":{ + "first1":{ + "type":"string" + }, + "last1":{ + "type":"string", + "index_name":"i_last_1" + } + } + }, + "name2":{ + "type":"object", + "path":"full", + "properties":{ + "first2":{ + "type":"string" + }, + "last2":{ + "type":"string", + "index_name":"i_last_2" + } + } + } + } + } +} diff --git a/src/test/java/org/elasticsearch/index/mapper/routing/RoutingTypeMapperTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/routing/RoutingTypeMapperTests.java similarity index 80% rename from src/test/java/org/elasticsearch/index/mapper/routing/RoutingTypeMapperTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/routing/RoutingTypeMapperTests.java index deea3ca6cc5..09beabdabce 100644 --- a/src/test/java/org/elasticsearch/index/mapper/routing/RoutingTypeMapperTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/routing/RoutingTypeMapperTests.java @@ -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 @@ -17,24 +17,25 @@ * under the License. */ -package org.elasticsearch.index.mapper.routing; +package org.elasticsearch.test.unit.index.mapper.routing; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.mapper.MapperTests; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.elasticsearch.index.mapper.ParsedDocument; import org.elasticsearch.index.mapper.SourceToParse; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class RoutingTypeMapperTests { - @Test public void simpleRoutingMapperTests() throws Exception { + @Test + public void simpleRoutingMapperTests() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .endObject().endObject().string(); DocumentMapper docMapper = MapperTests.newParser().parse(mapping); diff --git a/src/test/java/org/elasticsearch/index/mapper/simple/SimpleMapperTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/simple/SimpleMapperTests.java similarity index 78% rename from src/test/java/org/elasticsearch/index/mapper/simple/SimpleMapperTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/simple/SimpleMapperTests.java index d0bf65e3596..6dc1bbc2b96 100644 --- a/src/test/java/org/elasticsearch/index/mapper/simple/SimpleMapperTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/simple/SimpleMapperTests.java @@ -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 @@ -17,35 +17,38 @@ * under the License. */ -package org.elasticsearch.index.mapper.simple; +package org.elasticsearch.test.unit.index.mapper.simple; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.DocumentMapperParser; -import org.elasticsearch.index.mapper.MapperTests; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.elasticsearch.index.mapper.Uid; import org.testng.annotations.Test; -import static org.apache.lucene.document.Field.Store.*; -import static org.elasticsearch.common.io.Streams.*; +import static org.apache.lucene.document.Field.Store.YES; +import static org.elasticsearch.common.io.Streams.copyToBytesFromClasspath; +import static org.elasticsearch.common.io.Streams.copyToStringFromClasspath; import static org.elasticsearch.index.mapper.MapperBuilders.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.closeTo; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy + * */ public class SimpleMapperTests { - @Test public void testSimpleMapper() throws Exception { + @Test + public void testSimpleMapper() throws Exception { DocumentMapperParser mapperParser = MapperTests.newParser(); DocumentMapper docMapper = doc("test", rootObject("person") .add(object("name").add(stringField("first").store(YES).index(Field.Index.NO))) ).build(mapperParser); - byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/simple/test1.json"); + byte[] json = copyToBytesFromClasspath("/org/elasticsearch/test/unit/index/mapper/simple/test1.json"); Document doc = docMapper.parse("person", "1", json).rootDoc(); assertThat((double) doc.getBoost(), closeTo(3.7, 0.01)); @@ -58,14 +61,15 @@ public class SimpleMapperTests { // System.out.println("Json: " + docMapper.sourceMapper().value(doc)); } - @Test public void testParseToJsonAndParse() throws Exception { - String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/simple/test-mapping.json"); + @Test + public void testParseToJsonAndParse() throws Exception { + String mapping = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/mapper/simple/test-mapping.json"); DocumentMapper docMapper = MapperTests.newParser().parse(mapping); String builtMapping = docMapper.mappingSource().string(); // System.out.println(builtMapping); // reparse it DocumentMapper builtDocMapper = MapperTests.newParser().parse(builtMapping); - byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/simple/test1.json"); + byte[] json = copyToBytesFromClasspath("/org/elasticsearch/test/unit/index/mapper/simple/test1.json"); Document doc = builtDocMapper.parse(json).rootDoc(); assertThat(doc.get(docMapper.uidMapper().names().indexName()), equalTo(Uid.createUid("person", "1"))); assertThat((double) doc.getBoost(), closeTo(3.7, 0.01)); @@ -74,13 +78,14 @@ public class SimpleMapperTests { // System.out.println("Json: " + docMapper.sourceMapper().value(doc)); } - @Test public void testSimpleParser() throws Exception { - String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/simple/test-mapping.json"); + @Test + public void testSimpleParser() throws Exception { + String mapping = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/mapper/simple/test-mapping.json"); DocumentMapper docMapper = MapperTests.newParser().parse(mapping); assertThat((String) docMapper.meta().get("param1"), equalTo("value1")); - byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/simple/test1.json"); + byte[] json = copyToBytesFromClasspath("/org/elasticsearch/test/unit/index/mapper/simple/test1.json"); Document doc = docMapper.parse(json).rootDoc(); assertThat(doc.get(docMapper.uidMapper().names().indexName()), equalTo(Uid.createUid("person", "1"))); assertThat((double) doc.getBoost(), closeTo(3.7, 0.01)); @@ -89,10 +94,11 @@ public class SimpleMapperTests { // System.out.println("Json: " + docMapper.sourceMapper().value(doc)); } - @Test public void testSimpleParserNoTypeNoId() throws Exception { - String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/simple/test-mapping.json"); + @Test + public void testSimpleParserNoTypeNoId() throws Exception { + String mapping = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/mapper/simple/test-mapping.json"); DocumentMapper docMapper = MapperTests.newParser().parse(mapping); - byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/simple/test1-notype-noid.json"); + byte[] json = copyToBytesFromClasspath("/org/elasticsearch/test/unit/index/mapper/simple/test1-notype-noid.json"); Document doc = docMapper.parse("person", "1", json).rootDoc(); assertThat(doc.get(docMapper.uidMapper().names().indexName()), equalTo(Uid.createUid("person", "1"))); assertThat((double) doc.getBoost(), closeTo(3.7, 0.01)); @@ -101,8 +107,9 @@ public class SimpleMapperTests { // System.out.println("Json: " + docMapper.sourceMapper().value(doc)); } - @Test public void testAttributes() throws Exception { - String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/simple/test-mapping.json"); + @Test + public void testAttributes() throws Exception { + String mapping = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/mapper/simple/test-mapping.json"); DocumentMapper docMapper = MapperTests.newParser().parse(mapping); assertThat((String) docMapper.meta().get("param1"), equalTo("value1")); diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/simple/test-mapping.json b/src/test/java/org/elasticsearch/test/unit/index/mapper/simple/test-mapping.json new file mode 100644 index 00000000000..d45d55704a1 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/simple/test-mapping.json @@ -0,0 +1,98 @@ +{ + person:{ + "_meta":{ + "param1":"value1" + }, + date_formats:["yyyy-MM-dd", "dd-MM-yyyy"], + dynamic:false, + enabled:true, + _id:{ + name:"_id", + index_name:"_id" + }, + _source:{ + name:"_source" + }, + _type:{ + name:"_type" + }, + _boost:{ + name:"_boost", + null_value:2.0 + }, + properties:{ + name:{ + type:"object", + dynamic:false, + properties:{ + first:{ + type:"string", + store:"yes" + }, + last:{ + type:"string", + index:"not_analyzed" + } + } + }, + address:{ + type:"object", + properties:{ + first:{ + properties:{ + location:{ + type:"string", + store:"yes", + index_name:"firstLocation" + } + } + }, + last:{ + properties:{ + location:{ + type:"string" + } + } + } + } + }, + age:{ + type:"integer", + null_value:0 + }, + birthdate:{ + type:"date", + format:"yyyy-MM-dd" + }, + nerd:{ + type:"boolean" + }, + dogs:{ + type:"string", + index_name:"dog" + }, + complex:{ + type:"object", + properties:{ + value1:{ + type:"string" + }, + value2:{ + type:"string" + } + } + }, + complex2:{ + type:"object", + properties:{ + value1:{ + type:"string" + }, + value2:{ + type:"string" + } + } + } + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/simple/test1-notype-noid.json b/src/test/java/org/elasticsearch/test/unit/index/mapper/simple/test1-notype-noid.json new file mode 100644 index 00000000000..745617a5000 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/simple/test1-notype-noid.json @@ -0,0 +1,40 @@ +{ + _boost:3.7, + name:{ + first:"shay", + last:"banon" + }, + address:{ + first:{ + location:"first location" + }, + last:{ + location:"last location" + } + }, + age:32, + birthDate:"1977-11-15", + nerd:true, + dogs:["buck", "mia"], + complex:[ + { + value1:"value1" + }, + { + value2:"value2" + } + ], + complex2:[ + [ + { + value1:"value1" + } + ], + [ + { + value2:"value2" + } + ] + ], + nullValue:null +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/simple/test1-notype.json b/src/test/java/org/elasticsearch/test/unit/index/mapper/simple/test1-notype.json new file mode 100644 index 00000000000..7f38d0d3343 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/simple/test1-notype.json @@ -0,0 +1,41 @@ +{ + _boost:3.7, + _id:"1", + name:{ + first:"shay", + last:"banon" + }, + address:{ + first:{ + location:"first location" + }, + last:{ + location:"last location" + } + }, + age:32, + birthDate:"1977-11-15", + nerd:true, + dogs:["buck", "mia"], + complex:[ + { + value1:"value1" + }, + { + value2:"value2" + } + ], + complex2:[ + [ + { + value1:"value1" + } + ], + [ + { + value2:"value2" + } + ] + ], + nullValue:null +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/simple/test1.json b/src/test/java/org/elasticsearch/test/unit/index/mapper/simple/test1.json new file mode 100644 index 00000000000..0d678692999 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/simple/test1.json @@ -0,0 +1,43 @@ +{ + person:{ + _boost:3.7, + _id:"1", + name:{ + first:"shay", + last:"banon" + }, + address:{ + first:{ + location:"first location" + }, + last:{ + location:"last location" + } + }, + age:32, + birthDate:"1977-11-15", + nerd:true, + dogs:["buck", "mia"], + complex:[ + { + value1:"value1" + }, + { + value2:"value2" + } + ], + complex2:[ + [ + { + value1:"value1" + } + ], + [ + { + value2:"value2" + } + ] + ], + nullValue:null + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/mapper/size/SizeMappingTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/size/SizeMappingTests.java similarity index 87% rename from src/test/java/org/elasticsearch/index/mapper/size/SizeMappingTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/size/SizeMappingTests.java index 5f194e0a97d..e024e7086fc 100644 --- a/src/test/java/org/elasticsearch/index/mapper/size/SizeMappingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/size/SizeMappingTests.java @@ -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 @@ -17,22 +17,23 @@ * under the License. */ -package org.elasticsearch.index.mapper.size; +package org.elasticsearch.test.unit.index.mapper.size; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.mapper.MapperTests; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.elasticsearch.index.mapper.ParsedDocument; import org.elasticsearch.index.mapper.SourceToParse; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; @Test public class SizeMappingTests { - @Test public void testSizeEnabled() throws Exception { + @Test + public void testSizeEnabled() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("_size").field("enabled", true).endObject() .endObject().endObject().string(); @@ -49,7 +50,8 @@ public class SizeMappingTests { assertThat(doc.rootDoc().getFieldable("_size").tokenStreamValue(), notNullValue()); } - @Test public void testSizeEnabledAndStored() throws Exception { + @Test + public void testSizeEnabledAndStored() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("_size").field("enabled", true).field("store", "yes").endObject() .endObject().endObject().string(); @@ -66,7 +68,8 @@ public class SizeMappingTests { assertThat(doc.rootDoc().getFieldable("_size").tokenStreamValue(), notNullValue()); } - @Test public void testSizeDisabled() throws Exception { + @Test + public void testSizeDisabled() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("_size").field("enabled", false).endObject() .endObject().endObject().string(); @@ -82,7 +85,8 @@ public class SizeMappingTests { assertThat(doc.rootDoc().getFieldable("_size"), nullValue()); } - @Test public void testSizeNotSet() throws Exception { + @Test + public void testSizeNotSet() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .endObject().endObject().string(); DocumentMapper docMapper = MapperTests.newParser().parse(mapping); diff --git a/src/test/java/org/elasticsearch/index/mapper/source/CompressSourceMappingTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/source/CompressSourceMappingTests.java similarity index 86% rename from src/test/java/org/elasticsearch/index/mapper/source/CompressSourceMappingTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/source/CompressSourceMappingTests.java index cbd4a6cdcca..9cfb8d934af 100644 --- a/src/test/java/org/elasticsearch/index/mapper/source/CompressSourceMappingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/source/CompressSourceMappingTests.java @@ -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 @@ -17,24 +17,25 @@ * under the License. */ -package org.elasticsearch.index.mapper.source; +package org.elasticsearch.test.unit.index.mapper.source; import org.elasticsearch.common.compress.lzf.LZF; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.mapper.MapperTests; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.elasticsearch.index.mapper.ParsedDocument; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class CompressSourceMappingTests { - @Test public void testCompressDisabled() throws Exception { + @Test + public void testCompressDisabled() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("_source").field("compress", false).endObject() .endObject().endObject().string(); @@ -49,7 +50,8 @@ public class CompressSourceMappingTests { assertThat(LZF.isCompressed(doc.rootDoc().getBinaryValue("_source")), equalTo(false)); } - @Test public void testCompressEnabled() throws Exception { + @Test + public void testCompressEnabled() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("_source").field("compress", true).endObject() .endObject().endObject().string(); @@ -64,7 +66,8 @@ public class CompressSourceMappingTests { assertThat(LZF.isCompressed(doc.rootDoc().getBinaryValue("_source")), equalTo(true)); } - @Test public void testCompressThreshold() throws Exception { + @Test + public void testCompressThreshold() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("_source").field("compress_threshold", "200b").endObject() .endObject().endObject().string(); diff --git a/src/test/java/org/elasticsearch/index/mapper/source/DefaultSourceMappingTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/source/DefaultSourceMappingTests.java similarity index 83% rename from src/test/java/org/elasticsearch/index/mapper/source/DefaultSourceMappingTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/source/DefaultSourceMappingTests.java index 591b40d900f..364b79946d9 100644 --- a/src/test/java/org/elasticsearch/index/mapper/source/DefaultSourceMappingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/source/DefaultSourceMappingTests.java @@ -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 @@ -17,29 +17,27 @@ * under the License. */ -package org.elasticsearch.index.mapper.source; +package org.elasticsearch.test.unit.index.mapper.source; import org.apache.lucene.document.Fieldable; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentType; -import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MapperService; -import org.elasticsearch.index.mapper.MapperTests; -import org.elasticsearch.index.mapper.ParsedDocument; +import org.elasticsearch.index.mapper.*; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.testng.annotations.Test; import java.util.Map; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class DefaultSourceMappingTests { - @Test public void testIncludeExclude() throws Exception { + @Test + public void testIncludeExclude() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("_source").field("includes", new String[]{"path1*"}).endObject() .endObject().endObject().string(); @@ -57,7 +55,8 @@ public class DefaultSourceMappingTests { assertThat(sourceAsMap.containsKey("path2"), equalTo(false)); } - @Test public void testDefaultMappingAndNoMapping() throws Exception { + @Test + public void testDefaultMappingAndNoMapping() throws Exception { String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject(MapperService.DEFAULT_MAPPING) .startObject("_source").field("enabled", false).endObject() .endObject().endObject().string(); @@ -76,7 +75,8 @@ public class DefaultSourceMappingTests { } } - @Test public void testDefaultMappingAndWithMappingOverride() throws Exception { + @Test + public void testDefaultMappingAndWithMappingOverride() throws Exception { String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject(MapperService.DEFAULT_MAPPING) .startObject("_source").field("enabled", false).endObject() .endObject().endObject().string(); @@ -90,7 +90,8 @@ public class DefaultSourceMappingTests { assertThat(mapper.sourceMapper().enabled(), equalTo(true)); } - @Test public void testDefaultMappingAndNoMappingWithMapperService() throws Exception { + @Test + public void testDefaultMappingAndNoMappingWithMapperService() throws Exception { String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject(MapperService.DEFAULT_MAPPING) .startObject("_source").field("enabled", false).endObject() .endObject().endObject().string(); @@ -103,7 +104,8 @@ public class DefaultSourceMappingTests { assertThat(mapper.sourceMapper().enabled(), equalTo(false)); } - @Test public void testDefaultMappingAndWithMappingOverrideWithMapperService() throws Exception { + @Test + public void testDefaultMappingAndWithMappingOverrideWithMapperService() throws Exception { String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject(MapperService.DEFAULT_MAPPING) .startObject("_source").field("enabled", false).endObject() .endObject().endObject().string(); diff --git a/src/test/java/org/elasticsearch/index/mapper/timestamp/TimestampMappingTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/timestamp/TimestampMappingTests.java similarity index 87% rename from src/test/java/org/elasticsearch/index/mapper/timestamp/TimestampMappingTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/timestamp/TimestampMappingTests.java index 3bd5fc00aad..b26460ec3c7 100644 --- a/src/test/java/org/elasticsearch/index/mapper/timestamp/TimestampMappingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/timestamp/TimestampMappingTests.java @@ -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 @@ -17,26 +17,27 @@ * under the License. */ -package org.elasticsearch.index.mapper.timestamp; +package org.elasticsearch.test.unit.index.mapper.timestamp; import org.apache.lucene.document.Field; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.mapper.MapperTests; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.elasticsearch.index.mapper.ParsedDocument; import org.elasticsearch.index.mapper.SourceToParse; import org.elasticsearch.index.mapper.internal.TimestampFieldMapper; import org.testng.annotations.Test; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.notNullValue; /** - * @author paikan (benjamin.deveze) */ public class TimestampMappingTests { - @Test public void testSimpleDisabled() throws Exception { + @Test + public void testSimpleDisabled() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().string(); DocumentMapper docMapper = MapperTests.newParser().parse(mapping); byte[] source = XContentFactory.jsonBuilder() @@ -49,7 +50,8 @@ public class TimestampMappingTests { assertThat(doc.rootDoc().getFieldable("_timestamp"), equalTo(null)); } - @Test public void testEnabled() throws Exception { + @Test + public void testEnabled() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("_timestamp").field("enabled", "yes").field("store", "yes").endObject() .endObject().endObject().string(); @@ -66,7 +68,8 @@ public class TimestampMappingTests { assertThat(doc.rootDoc().getFieldable("_timestamp").tokenStreamValue(), notNullValue()); } - @Test public void testDefaultValues() throws Exception { + @Test + public void testDefaultValues() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().string(); DocumentMapper docMapper = MapperTests.newParser().parse(mapping); assertThat(docMapper.timestampFieldMapper().enabled(), equalTo(TimestampFieldMapper.Defaults.ENABLED)); @@ -77,7 +80,8 @@ public class TimestampMappingTests { } - @Test public void testSetValues() throws Exception { + @Test + public void testSetValues() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("_timestamp") .field("enabled", "yes").field("store", "yes").field("index", "no") diff --git a/src/test/java/org/elasticsearch/index/mapper/ttl/TTLMappingTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/ttl/TTLMappingTests.java similarity index 89% rename from src/test/java/org/elasticsearch/index/mapper/ttl/TTLMappingTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/ttl/TTLMappingTests.java index 1f561bad437..e3c02f628f0 100644 --- a/src/test/java/org/elasticsearch/index/mapper/ttl/TTLMappingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/ttl/TTLMappingTests.java @@ -18,22 +18,24 @@ * under the License. */ -package org.elasticsearch.index.mapper.ttl; +package org.elasticsearch.test.unit.index.mapper.ttl; import org.apache.lucene.document.Field; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.mapper.MapperTests; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.elasticsearch.index.mapper.ParsedDocument; import org.elasticsearch.index.mapper.SourceToParse; import org.elasticsearch.index.mapper.internal.TTLFieldMapper; import org.testng.annotations.Test; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.notNullValue; public class TTLMappingTests { - @Test public void testSimpleDisabled() throws Exception { + @Test + public void testSimpleDisabled() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().string(); DocumentMapper docMapper = MapperTests.newParser().parse(mapping); byte[] source = XContentFactory.jsonBuilder() @@ -46,7 +48,8 @@ public class TTLMappingTests { assertThat(doc.rootDoc().getFieldable("_ttl"), equalTo(null)); } - @Test public void testEnabled() throws Exception { + @Test + public void testEnabled() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("_ttl").field("enabled", "yes").endObject() .endObject().endObject().string(); @@ -63,7 +66,8 @@ public class TTLMappingTests { assertThat(doc.rootDoc().getFieldable("_ttl").tokenStreamValue(), notNullValue()); } - @Test public void testDefaultValues() throws Exception { + @Test + public void testDefaultValues() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().string(); DocumentMapper docMapper = MapperTests.newParser().parse(mapping); assertThat(docMapper.TTLFieldMapper().enabled(), equalTo(TTLFieldMapper.Defaults.ENABLED)); @@ -72,7 +76,8 @@ public class TTLMappingTests { } - @Test public void testSetValues() throws Exception { + @Test + public void testSetValues() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("_ttl") .field("enabled", "yes").field("store", "no").field("index", "no") diff --git a/src/test/java/org/elasticsearch/index/mapper/typelevels/ParseDocumentTypeLevelsTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/typelevels/ParseDocumentTypeLevelsTests.java similarity index 89% rename from src/test/java/org/elasticsearch/index/mapper/typelevels/ParseDocumentTypeLevelsTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/typelevels/ParseDocumentTypeLevelsTests.java index de71b678bac..7b7ef94a2f9 100644 --- a/src/test/java/org/elasticsearch/index/mapper/typelevels/ParseDocumentTypeLevelsTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/typelevels/ParseDocumentTypeLevelsTests.java @@ -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 @@ -17,23 +17,25 @@ * under the License. */ -package org.elasticsearch.index.mapper.typelevels; +package org.elasticsearch.test.unit.index.mapper.typelevels; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.mapper.MapperTests; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.elasticsearch.index.mapper.ParsedDocument; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.nullValue; /** - * @author kimchy (shay.banon) + * */ public class ParseDocumentTypeLevelsTests { - @Test public void testNoLevel() throws Exception { + @Test + public void testNoLevel() throws Exception { String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string(); DocumentMapper defaultMapper = MapperTests.newParser().parse(defaultMapping); @@ -51,7 +53,8 @@ public class ParseDocumentTypeLevelsTests { assertThat(doc.rootDoc().get("inner.inner_field"), equalTo("inner_value")); } - @Test public void testTypeLevel() throws Exception { + @Test + public void testTypeLevel() throws Exception { String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string(); DocumentMapper defaultMapper = MapperTests.newParser().parse(defaultMapping); @@ -69,7 +72,8 @@ public class ParseDocumentTypeLevelsTests { assertThat(doc.rootDoc().get("inner.inner_field"), equalTo("inner_value")); } - @Test public void testNoLevelWithFieldTypeAsValue() throws Exception { + @Test + public void testNoLevelWithFieldTypeAsValue() throws Exception { String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string(); DocumentMapper defaultMapper = MapperTests.newParser().parse(defaultMapping); @@ -89,7 +93,8 @@ public class ParseDocumentTypeLevelsTests { assertThat(doc.rootDoc().get("inner.inner_field"), equalTo("inner_value")); } - @Test public void testTypeLevelWithFieldTypeAsValue() throws Exception { + @Test + public void testTypeLevelWithFieldTypeAsValue() throws Exception { String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string(); DocumentMapper defaultMapper = MapperTests.newParser().parse(defaultMapping); @@ -109,7 +114,8 @@ public class ParseDocumentTypeLevelsTests { assertThat(doc.rootDoc().get("inner.inner_field"), equalTo("inner_value")); } - @Test public void testNoLevelWithFieldTypeAsObject() throws Exception { + @Test + public void testNoLevelWithFieldTypeAsObject() throws Exception { String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string(); DocumentMapper defaultMapper = MapperTests.newParser().parse(defaultMapping); @@ -129,7 +135,8 @@ public class ParseDocumentTypeLevelsTests { assertThat(doc.rootDoc().get("test2"), nullValue()); } - @Test public void testTypeLevelWithFieldTypeAsObject() throws Exception { + @Test + public void testTypeLevelWithFieldTypeAsObject() throws Exception { String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string(); DocumentMapper defaultMapper = MapperTests.newParser().parse(defaultMapping); @@ -149,7 +156,8 @@ public class ParseDocumentTypeLevelsTests { assertThat(doc.rootDoc().get("inner.inner_field"), equalTo("inner_value")); } - @Test public void testNoLevelWithFieldTypeAsValueNotFirst() throws Exception { + @Test + public void testNoLevelWithFieldTypeAsValueNotFirst() throws Exception { String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string(); DocumentMapper defaultMapper = MapperTests.newParser().parse(defaultMapping); @@ -169,7 +177,8 @@ public class ParseDocumentTypeLevelsTests { assertThat(doc.rootDoc().get("inner.inner_field"), equalTo("inner_value")); } - @Test public void testTypeLevelWithFieldTypeAsValueNotFirst() throws Exception { + @Test + public void testTypeLevelWithFieldTypeAsValueNotFirst() throws Exception { String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string(); DocumentMapper defaultMapper = MapperTests.newParser().parse(defaultMapping); @@ -189,7 +198,8 @@ public class ParseDocumentTypeLevelsTests { assertThat(doc.rootDoc().get("inner.inner_field"), equalTo("inner_value")); } - @Test public void testNoLevelWithFieldTypeAsObjectNotFirst() throws Exception { + @Test + public void testNoLevelWithFieldTypeAsObjectNotFirst() throws Exception { String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string(); DocumentMapper defaultMapper = MapperTests.newParser().parse(defaultMapping); @@ -210,7 +220,8 @@ public class ParseDocumentTypeLevelsTests { assertThat(doc.rootDoc().get("inner.inner_field"), equalTo("inner_value")); } - @Test public void testTypeLevelWithFieldTypeAsObjectNotFirst() throws Exception { + @Test + public void testTypeLevelWithFieldTypeAsObjectNotFirst() throws Exception { String defaultMapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string(); DocumentMapper defaultMapper = MapperTests.newParser().parse(defaultMapping); diff --git a/src/test/java/org/elasticsearch/index/mapper/typelevels/ParseMappingTypeLevelTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/typelevels/ParseMappingTypeLevelTests.java similarity index 78% rename from src/test/java/org/elasticsearch/index/mapper/typelevels/ParseMappingTypeLevelTests.java rename to src/test/java/org/elasticsearch/test/unit/index/mapper/typelevels/ParseMappingTypeLevelTests.java index 193dbddf26c..090556f6413 100644 --- a/src/test/java/org/elasticsearch/index/mapper/typelevels/ParseMappingTypeLevelTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/typelevels/ParseMappingTypeLevelTests.java @@ -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 @@ -17,22 +17,23 @@ * under the License. */ -package org.elasticsearch.index.mapper.typelevels; +package org.elasticsearch.test.unit.index.mapper.typelevels; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.mapper.MapperTests; +import org.elasticsearch.test.unit.index.mapper.MapperTests; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class ParseMappingTypeLevelTests { - @Test public void testTypeLevel() throws Exception { + @Test + public void testTypeLevel() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("_source").field("enabled", false).endObject() .endObject().endObject().string(); diff --git a/src/test/java/org/elasticsearch/index/percolator/PercolatorExecutorTests.java b/src/test/java/org/elasticsearch/test/unit/index/percolator/PercolatorExecutorTests.java similarity index 91% rename from src/test/java/org/elasticsearch/index/percolator/PercolatorExecutorTests.java rename to src/test/java/org/elasticsearch/test/unit/index/percolator/PercolatorExecutorTests.java index 652e3d1b68d..cbc275db815 100644 --- a/src/test/java/org/elasticsearch/index/percolator/PercolatorExecutorTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/percolator/PercolatorExecutorTests.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.percolator; +package org.elasticsearch.test.unit.index.percolator; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.Injector; @@ -33,6 +33,7 @@ import org.elasticsearch.index.analysis.AnalysisModule; import org.elasticsearch.index.cache.IndexCacheModule; import org.elasticsearch.index.engine.IndexEngineModule; import org.elasticsearch.index.mapper.MapperServiceModule; +import org.elasticsearch.index.percolator.PercolatorExecutor; import org.elasticsearch.index.query.IndexQueryParserModule; import org.elasticsearch.index.settings.IndexSettingsModule; import org.elasticsearch.index.similarity.SimilarityModule; @@ -42,19 +43,20 @@ import org.elasticsearch.threadpool.ThreadPoolModule; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.hamcrest.MatcherAssert.*; +import static org.elasticsearch.index.query.QueryBuilders.termQuery; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** - * @author kimchy (shay.banon) + * */ @Test public class PercolatorExecutorTests { private PercolatorExecutor percolatorExecutor; - @BeforeClass public void buildPercolatorService() { + @BeforeClass + public void buildPercolatorService() { Settings settings = ImmutableSettings.settingsBuilder() .put("index.cache.filter.type", "none") .build(); @@ -73,7 +75,8 @@ public class PercolatorExecutorTests { new IndexQueryParserModule(settings), new IndexNameModule(index), new AbstractModule() { - @Override protected void configure() { + @Override + protected void configure() { bind(PercolatorExecutor.class).asEagerSingleton(); } } @@ -82,7 +85,8 @@ public class PercolatorExecutorTests { percolatorExecutor = injector.getInstance(PercolatorExecutor.class); } - @Test public void testSimplePercolator() throws Exception { + @Test + public void testSimplePercolator() throws Exception { // introduce the doc XContentBuilder doc = XContentFactory.jsonBuilder().startObject().startObject("doc") .field("field1", 1) diff --git a/src/test/java/org/elasticsearch/index/query/SimpleIndexQueryParserTests.java b/src/test/java/org/elasticsearch/test/unit/index/query/SimpleIndexQueryParserTests.java similarity index 86% rename from src/test/java/org/elasticsearch/index/query/SimpleIndexQueryParserTests.java rename to src/test/java/org/elasticsearch/test/unit/index/query/SimpleIndexQueryParserTests.java index a13ebb5c759..ec90f20f5c0 100644 --- a/src/test/java/org/elasticsearch/index/query/SimpleIndexQueryParserTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/query/SimpleIndexQueryParserTests.java @@ -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 @@ -17,27 +17,15 @@ * under the License. */ -package org.elasticsearch.index.query; +package org.elasticsearch.test.unit.index.query; import org.apache.lucene.index.Term; import org.apache.lucene.search.*; -import org.apache.lucene.search.spans.SpanFirstQuery; -import org.apache.lucene.search.spans.SpanNearQuery; -import org.apache.lucene.search.spans.SpanNotQuery; -import org.apache.lucene.search.spans.SpanOrQuery; -import org.apache.lucene.search.spans.SpanTermQuery; +import org.apache.lucene.search.spans.*; import org.apache.lucene.util.NumericUtils; import org.elasticsearch.common.inject.Injector; import org.elasticsearch.common.inject.ModulesBuilder; -import org.elasticsearch.common.lucene.search.AndFilter; -import org.elasticsearch.common.lucene.search.LimitFilter; -import org.elasticsearch.common.lucene.search.MoreLikeThisQuery; -import org.elasticsearch.common.lucene.search.MultiPhrasePrefixQuery; -import org.elasticsearch.common.lucene.search.NotFilter; -import org.elasticsearch.common.lucene.search.OrFilter; -import org.elasticsearch.common.lucene.search.Queries; -import org.elasticsearch.common.lucene.search.TermFilter; -import org.elasticsearch.common.lucene.search.XBooleanFilter; +import org.elasticsearch.common.lucene.search.*; import org.elasticsearch.common.lucene.search.function.BoostScoreFunction; import org.elasticsearch.common.lucene.search.function.FunctionScoreQuery; import org.elasticsearch.common.settings.ImmutableSettings; @@ -50,6 +38,9 @@ import org.elasticsearch.index.cache.IndexCacheModule; import org.elasticsearch.index.engine.IndexEngineModule; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.MapperServiceModule; +import org.elasticsearch.index.query.IndexQueryParserModule; +import org.elasticsearch.index.query.IndexQueryParserService; +import org.elasticsearch.index.query.ParsedQuery; import org.elasticsearch.index.search.NumericRangeFieldDataFilter; import org.elasticsearch.index.search.geo.GeoDistanceFilter; import org.elasticsearch.index.search.geo.GeoPolygonFilter; @@ -66,21 +57,23 @@ import java.io.IOException; import java.lang.reflect.Field; import java.util.List; -import static org.elasticsearch.common.io.Streams.*; +import static org.elasticsearch.common.io.Streams.copyToBytesFromClasspath; +import static org.elasticsearch.common.io.Streams.copyToStringFromClasspath; import static org.elasticsearch.index.query.FilterBuilders.*; import static org.elasticsearch.index.query.QueryBuilders.*; -import static org.hamcrest.MatcherAssert.*; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** - * @author kimchy (shay.banon) + * */ @Test public class SimpleIndexQueryParserTests { private IndexQueryParserService queryParser; - @BeforeClass public void setupQueryParser() throws IOException { + @BeforeClass + public void setupQueryParser() throws IOException { Settings settings = ImmutableSettings.settingsBuilder() .put("index.cache.filter.type", "none") .build(); @@ -100,9 +93,9 @@ public class SimpleIndexQueryParserTests { new IndexNameModule(index) ).createInjector(); - String mapping = copyToStringFromClasspath("/org/elasticsearch/index/query/mapping.json"); + String mapping = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/mapping.json"); injector.getInstance(MapperService.class).add("person", mapping); - injector.getInstance(MapperService.class).documentMapper("person").parse(copyToBytesFromClasspath("/org/elasticsearch/index/query/data.json")); + injector.getInstance(MapperService.class).documentMapper("person").parse(copyToBytesFromClasspath("/org/elasticsearch/test/unit/index/query/data.json")); this.queryParser = injector.getInstance(IndexQueryParserService.class); } @@ -110,7 +103,8 @@ public class SimpleIndexQueryParserTests { return this.queryParser; } - @Test public void testQueryStringBuilder() throws Exception { + @Test + public void testQueryStringBuilder() throws Exception { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(queryString("test").defaultField("content").phraseSlop(1)).query(); @@ -119,16 +113,18 @@ public class SimpleIndexQueryParserTests { assertThat(termQuery.getTerm(), equalTo(new Term("content", "test"))); } - @Test public void testQueryString() throws Exception { + @Test + public void testQueryString() throws Exception { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/query.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/query.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(TermQuery.class)); TermQuery termQuery = (TermQuery) parsedQuery; assertThat(termQuery.getTerm(), equalTo(new Term("content", "test"))); } - @Test public void testQueryStringFields1Builder() throws Exception { + @Test + public void testQueryStringFields1Builder() throws Exception { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(queryString("test").field("content").field("name").useDisMax(false)).query(); assertThat(parsedQuery, instanceOf(BooleanQuery.class)); @@ -138,9 +134,10 @@ public class SimpleIndexQueryParserTests { assertThat(((TermQuery) bQuery.clauses().get(1).getQuery()).getTerm(), equalTo(new Term("name", "test"))); } - @Test public void testQueryStringFields1() throws Exception { + @Test + public void testQueryStringFields1() throws Exception { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/query-fields1.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/query-fields1.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(BooleanQuery.class)); BooleanQuery bQuery = (BooleanQuery) parsedQuery; @@ -149,9 +146,10 @@ public class SimpleIndexQueryParserTests { assertThat(((TermQuery) bQuery.clauses().get(1).getQuery()).getTerm(), equalTo(new Term("name", "test"))); } - @Test public void testQueryStringFieldsMatch() throws Exception { + @Test + public void testQueryStringFieldsMatch() throws Exception { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/query-fields-match.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/query-fields-match.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(BooleanQuery.class)); BooleanQuery bQuery = (BooleanQuery) parsedQuery; @@ -160,7 +158,8 @@ public class SimpleIndexQueryParserTests { assertThat(((TermQuery) bQuery.clauses().get(1).getQuery()).getTerm(), equalTo(new Term("name.last", "test"))); } - @Test public void testQueryStringFields2Builder() throws Exception { + @Test + public void testQueryStringFields2Builder() throws Exception { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(queryString("test").field("content").field("name").useDisMax(true)).query(); assertThat(parsedQuery, instanceOf(DisjunctionMaxQuery.class)); @@ -170,9 +169,10 @@ public class SimpleIndexQueryParserTests { assertThat(((TermQuery) disjuncts.get(1)).getTerm(), equalTo(new Term("name", "test"))); } - @Test public void testQueryStringFields2() throws Exception { + @Test + public void testQueryStringFields2() throws Exception { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/query-fields2.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/query-fields2.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(DisjunctionMaxQuery.class)); DisjunctionMaxQuery disMaxQuery = (DisjunctionMaxQuery) parsedQuery; @@ -181,7 +181,8 @@ public class SimpleIndexQueryParserTests { assertThat(((TermQuery) disjuncts.get(1)).getTerm(), equalTo(new Term("name", "test"))); } - @Test public void testQueryStringFields3Builder() throws Exception { + @Test + public void testQueryStringFields3Builder() throws Exception { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(queryString("test").field("content", 2.2f).field("name").useDisMax(true)).query(); assertThat(parsedQuery, instanceOf(DisjunctionMaxQuery.class)); @@ -193,9 +194,10 @@ public class SimpleIndexQueryParserTests { assertThat((double) disjuncts.get(1).getBoost(), closeTo(1, 0.01)); } - @Test public void testQueryStringFields3() throws Exception { + @Test + public void testQueryStringFields3() throws Exception { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/query-fields3.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/query-fields3.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(DisjunctionMaxQuery.class)); DisjunctionMaxQuery disMaxQuery = (DisjunctionMaxQuery) parsedQuery; @@ -206,7 +208,8 @@ public class SimpleIndexQueryParserTests { assertThat((double) disjuncts.get(1).getBoost(), closeTo(1, 0.01)); } - @Test public void testMatchAllBuilder() throws Exception { + @Test + public void testMatchAllBuilder() throws Exception { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(matchAllQuery().boost(1.2f)).query(); assertThat(parsedQuery, instanceOf(MatchAllDocsQuery.class)); @@ -214,16 +217,18 @@ public class SimpleIndexQueryParserTests { assertThat((double) matchAllDocsQuery.getBoost(), closeTo(1.2, 0.01)); } - @Test public void testMatchAll() throws Exception { + @Test + public void testMatchAll() throws Exception { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/matchAll.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/matchAll.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(MatchAllDocsQuery.class)); MatchAllDocsQuery matchAllDocsQuery = (MatchAllDocsQuery) parsedQuery; assertThat((double) matchAllDocsQuery.getBoost(), closeTo(1.2, 0.01)); } - @Test public void testDisMaxBuilder() throws Exception { + @Test + public void testDisMaxBuilder() throws Exception { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(disMaxQuery().boost(1.2f).tieBreaker(0.7f).add(termQuery("name.first", "first")).add(termQuery("name.last", "last"))).query(); assertThat(parsedQuery, instanceOf(DisjunctionMaxQuery.class)); @@ -242,9 +247,10 @@ public class SimpleIndexQueryParserTests { assertThat(((TermQuery) secondsQ).getTerm(), equalTo(new Term("name.last", "last"))); } - @Test public void testDisMax() throws Exception { + @Test + public void testDisMax() throws Exception { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/disMax.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/disMax.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(DisjunctionMaxQuery.class)); DisjunctionMaxQuery disjunctionMaxQuery = (DisjunctionMaxQuery) parsedQuery; @@ -262,9 +268,10 @@ public class SimpleIndexQueryParserTests { assertThat(((TermQuery) secondsQ).getTerm(), equalTo(new Term("name.last", "last"))); } - @Test public void testDisMax2() throws Exception { + @Test + public void testDisMax2() throws Exception { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/disMax2.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/disMax2.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(DisjunctionMaxQuery.class)); DisjunctionMaxQuery disjunctionMaxQuery = (DisjunctionMaxQuery) parsedQuery; @@ -278,7 +285,8 @@ public class SimpleIndexQueryParserTests { assertThat((double) firstQ.getBoost(), closeTo(1.2, 0.00001)); } - @Test public void testTermQueryBuilder() throws IOException { + @Test + public void testTermQueryBuilder() throws IOException { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(termQuery("age", 34).buildAsBytes()).query(); assertThat(parsedQuery, instanceOf(NumericRangeQuery.class)); @@ -289,9 +297,10 @@ public class SimpleIndexQueryParserTests { assertThat(fieldQuery.includesMin(), equalTo(true)); } - @Test public void testTermQuery() throws IOException { + @Test + public void testTermQuery() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/term.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/term.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(NumericRangeQuery.class)); NumericRangeQuery fieldQuery = (NumericRangeQuery) parsedQuery; @@ -301,7 +310,8 @@ public class SimpleIndexQueryParserTests { assertThat(fieldQuery.includesMin(), equalTo(true)); } - @Test public void testFuzzyQueryBuilder() throws IOException { + @Test + public void testFuzzyQueryBuilder() throws IOException { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(fuzzyQuery("name.first", "sh").buildAsBytes()).query(); assertThat(parsedQuery, instanceOf(FuzzyQuery.class)); @@ -309,16 +319,18 @@ public class SimpleIndexQueryParserTests { assertThat(fuzzyQuery.getTerm(), equalTo(new Term("name.first", "sh"))); } - @Test public void testFuzzyQuery() throws IOException { + @Test + public void testFuzzyQuery() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/fuzzy.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/fuzzy.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(FuzzyQuery.class)); FuzzyQuery fuzzyQuery = (FuzzyQuery) parsedQuery; assertThat(fuzzyQuery.getTerm(), equalTo(new Term("name.first", "sh"))); } - @Test public void testFuzzyQueryWithFieldsBuilder() throws IOException { + @Test + public void testFuzzyQueryWithFieldsBuilder() throws IOException { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(fuzzyQuery("name.first", "sh").minSimilarity(0.1f).prefixLength(1).boost(2.0f).buildAsBytes()).query(); assertThat(parsedQuery, instanceOf(FuzzyQuery.class)); @@ -329,9 +341,10 @@ public class SimpleIndexQueryParserTests { assertThat(fuzzyQuery.getBoost(), equalTo(2.0f)); } - @Test public void testFuzzyQueryWithFields() throws IOException { + @Test + public void testFuzzyQueryWithFields() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/fuzzy-with-fields.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/fuzzy-with-fields.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(FuzzyQuery.class)); FuzzyQuery fuzzyQuery = (FuzzyQuery) parsedQuery; @@ -341,9 +354,10 @@ public class SimpleIndexQueryParserTests { assertThat(fuzzyQuery.getBoost(), equalTo(2.0f)); } - @Test public void testFuzzyQueryWithFields2() throws IOException { + @Test + public void testFuzzyQueryWithFields2() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/fuzzy-with-fields2.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/fuzzy-with-fields2.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(NumericRangeQuery.class)); NumericRangeQuery fuzzyQuery = (NumericRangeQuery) parsedQuery; @@ -351,7 +365,8 @@ public class SimpleIndexQueryParserTests { assertThat(fuzzyQuery.getMax().longValue(), equalTo(17l)); } - @Test public void testFieldQueryBuilder1() throws IOException { + @Test + public void testFieldQueryBuilder1() throws IOException { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(fieldQuery("age", 34).buildAsBytes()).query(); assertThat(parsedQuery, instanceOf(NumericRangeQuery.class)); @@ -362,9 +377,10 @@ public class SimpleIndexQueryParserTests { assertThat(fieldQuery.includesMin(), equalTo(true)); } - @Test public void testFieldQuery1() throws IOException { + @Test + public void testFieldQuery1() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/field1.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/field1.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(NumericRangeQuery.class)); NumericRangeQuery fieldQuery = (NumericRangeQuery) parsedQuery; @@ -374,9 +390,10 @@ public class SimpleIndexQueryParserTests { assertThat(fieldQuery.includesMin(), equalTo(true)); } - @Test public void testFieldQuery2() throws IOException { + @Test + public void testFieldQuery2() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/field2.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/field2.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(BooleanQuery.class)); BooleanQuery bQuery = (BooleanQuery) parsedQuery; @@ -387,9 +404,10 @@ public class SimpleIndexQueryParserTests { assertThat(((TermQuery) bQuery.getClauses()[1].getQuery()).getTerm().text(), equalTo("else")); } - @Test public void testFieldQuery3() throws IOException { + @Test + public void testFieldQuery3() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/field3.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/field3.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat((double) parsedQuery.getBoost(), closeTo(2.0, 0.01)); assertThat(parsedQuery, instanceOf(NumericRangeQuery.class)); @@ -400,9 +418,10 @@ public class SimpleIndexQueryParserTests { assertThat(fieldQuery.includesMin(), equalTo(true)); } - @Test public void testTextQuery1() throws IOException { + @Test + public void testTextQuery1() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/text1.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/text1.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(BooleanQuery.class)); BooleanQuery booleanQuery = (BooleanQuery) parsedQuery; @@ -411,9 +430,10 @@ public class SimpleIndexQueryParserTests { assertThat(((TermQuery) booleanQuery.getClauses()[1].getQuery()).getTerm(), equalTo(new Term("name.first", "bbb"))); } - @Test public void testTextQuery2() throws IOException { + @Test + public void testTextQuery2() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/text2.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/text2.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(BooleanQuery.class)); BooleanQuery booleanQuery = (BooleanQuery) parsedQuery; @@ -422,9 +442,10 @@ public class SimpleIndexQueryParserTests { assertThat(((TermQuery) booleanQuery.getClauses()[1].getQuery()).getTerm(), equalTo(new Term("name.first", "bbb"))); } - @Test public void testTextQuery3() throws IOException { + @Test + public void testTextQuery3() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/text3.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/text3.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(PhraseQuery.class)); PhraseQuery phraseQuery = (PhraseQuery) parsedQuery; @@ -432,9 +453,10 @@ public class SimpleIndexQueryParserTests { assertThat(phraseQuery.getTerms()[1], equalTo(new Term("name.first", "bbb"))); } - @Test public void testTextQuery4() throws IOException { + @Test + public void testTextQuery4() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/text4.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/text4.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(MultiPhrasePrefixQuery.class)); MultiPhrasePrefixQuery phraseQuery = (MultiPhrasePrefixQuery) parsedQuery; @@ -442,9 +464,10 @@ public class SimpleIndexQueryParserTests { assertThat(phraseQuery.getTermArrays().get(1)[0], equalTo(new Term("name.first", "bbb"))); } - @Test public void testTextQuery4_2() throws IOException { + @Test + public void testTextQuery4_2() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/text4_2.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/text4_2.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(MultiPhrasePrefixQuery.class)); MultiPhrasePrefixQuery phraseQuery = (MultiPhrasePrefixQuery) parsedQuery; @@ -452,7 +475,8 @@ public class SimpleIndexQueryParserTests { assertThat(phraseQuery.getTermArrays().get(1)[0], equalTo(new Term("name.first", "bbb"))); } - @Test public void testTermWithBoostQueryBuilder() throws IOException { + @Test + public void testTermWithBoostQueryBuilder() throws IOException { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(termQuery("age", 34).boost(2.0f)).query(); assertThat(parsedQuery, instanceOf(NumericRangeQuery.class)); @@ -464,9 +488,10 @@ public class SimpleIndexQueryParserTests { assertThat((double) fieldQuery.getBoost(), closeTo(2.0, 0.01)); } - @Test public void testTermWithBoostQuery() throws IOException { + @Test + public void testTermWithBoostQuery() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/term-with-boost.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/term-with-boost.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(NumericRangeQuery.class)); NumericRangeQuery fieldQuery = (NumericRangeQuery) parsedQuery; @@ -477,7 +502,8 @@ public class SimpleIndexQueryParserTests { assertThat((double) fieldQuery.getBoost(), closeTo(2.0, 0.01)); } - @Test public void testPrefixQueryBuilder() throws IOException { + @Test + public void testPrefixQueryBuilder() throws IOException { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(prefixQuery("name.first", "sh")).query(); assertThat(parsedQuery, instanceOf(PrefixQuery.class)); @@ -486,9 +512,10 @@ public class SimpleIndexQueryParserTests { assertThat(prefixQuery.getPrefix(), equalTo(new Term("name.first", "sh"))); } - @Test public void testPrefixQuery() throws IOException { + @Test + public void testPrefixQuery() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/prefix.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/prefix.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(PrefixQuery.class)); PrefixQuery prefixQuery = (PrefixQuery) parsedQuery; @@ -496,9 +523,10 @@ public class SimpleIndexQueryParserTests { assertThat(prefixQuery.getPrefix(), equalTo(new Term("name.first", "sh"))); } - @Test public void testPrefixBoostQuery() throws IOException { + @Test + public void testPrefixBoostQuery() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/prefix-boost.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/prefix-boost.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(PrefixQuery.class)); PrefixQuery prefixQuery = (PrefixQuery) parsedQuery; @@ -507,7 +535,8 @@ public class SimpleIndexQueryParserTests { assertThat((double) prefixQuery.getBoost(), closeTo(1.2, 0.00001)); } - @Test public void testPrefixFilteredQueryBuilder() throws IOException { + @Test + public void testPrefixFilteredQueryBuilder() throws IOException { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(filteredQuery(termQuery("name.first", "shay"), prefixFilter("name.first", "sh"))).query(); assertThat(parsedQuery, instanceOf(FilteredQuery.class)); @@ -516,9 +545,10 @@ public class SimpleIndexQueryParserTests { assertThat(prefixFilter.getPrefix(), equalTo(new Term("name.first", "sh"))); } - @Test public void testPrefixFilteredQuery() throws IOException { + @Test + public void testPrefixFilteredQuery() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/prefix-filter.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/prefix-filter.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(FilteredQuery.class)); FilteredQuery filteredQuery = (FilteredQuery) parsedQuery; @@ -526,9 +556,10 @@ public class SimpleIndexQueryParserTests { assertThat(prefixFilter.getPrefix(), equalTo(new Term("name.first", "sh"))); } - @Test public void testPrefixNamedFilteredQuery() throws IOException { + @Test + public void testPrefixNamedFilteredQuery() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/prefix-filter-named.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/prefix-filter-named.json"); ParsedQuery parsedQuery = queryParser.parse(query); assertThat(parsedQuery.namedFilters().containsKey("test"), equalTo(true)); assertThat(parsedQuery.query(), instanceOf(FilteredQuery.class)); @@ -537,7 +568,8 @@ public class SimpleIndexQueryParserTests { assertThat(prefixFilter.getPrefix(), equalTo(new Term("name.first", "sh"))); } - @Test public void testPrefixQueryBoostQueryBuilder() throws IOException { + @Test + public void testPrefixQueryBoostQueryBuilder() throws IOException { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(prefixQuery("name.first", "sh").boost(2.0f)).query(); assertThat(parsedQuery, instanceOf(PrefixQuery.class)); @@ -546,9 +578,10 @@ public class SimpleIndexQueryParserTests { assertThat((double) prefixQuery.getBoost(), closeTo(2.0, 0.01)); } - @Test public void testPrefixQueryBoostQuery() throws IOException { + @Test + public void testPrefixQueryBoostQuery() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/prefix-with-boost.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/prefix-with-boost.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(PrefixQuery.class)); PrefixQuery prefixQuery = (PrefixQuery) parsedQuery; @@ -556,7 +589,8 @@ public class SimpleIndexQueryParserTests { assertThat((double) prefixQuery.getBoost(), closeTo(2.0, 0.01)); } - @Test public void testWildcardQueryBuilder() throws IOException { + @Test + public void testWildcardQueryBuilder() throws IOException { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(wildcardQuery("name.first", "sh*")).query(); assertThat(parsedQuery, instanceOf(WildcardQuery.class)); @@ -564,18 +598,20 @@ public class SimpleIndexQueryParserTests { assertThat(wildcardQuery.getTerm(), equalTo(new Term("name.first", "sh*"))); } - @Test public void testWildcardQuery() throws IOException { + @Test + public void testWildcardQuery() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/wildcard.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/wildcard.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(WildcardQuery.class)); WildcardQuery wildcardQuery = (WildcardQuery) parsedQuery; assertThat(wildcardQuery.getTerm(), equalTo(new Term("name.first", "sh*"))); } - @Test public void testWildcardBoostQuery() throws IOException { + @Test + public void testWildcardBoostQuery() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/wildcard-boost.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/wildcard-boost.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(WildcardQuery.class)); WildcardQuery wildcardQuery = (WildcardQuery) parsedQuery; @@ -583,7 +619,8 @@ public class SimpleIndexQueryParserTests { assertThat((double) wildcardQuery.getBoost(), closeTo(1.2, 0.00001)); } - @Test public void testRangeQueryBuilder() throws IOException { + @Test + public void testRangeQueryBuilder() throws IOException { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(rangeQuery("age").from(23).to(54).includeLower(true).includeUpper(false)).query(); // since age is automatically registered in data, we encode it as numeric @@ -596,9 +633,10 @@ public class SimpleIndexQueryParserTests { assertThat(rangeQuery.includesMax(), equalTo(false)); } - @Test public void testRangeQuery() throws IOException { + @Test + public void testRangeQuery() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/range.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/range.json"); Query parsedQuery = queryParser.parse(query).query(); // since age is automatically registered in data, we encode it as numeric assertThat(parsedQuery, instanceOf(NumericRangeQuery.class)); @@ -610,9 +648,10 @@ public class SimpleIndexQueryParserTests { assertThat(rangeQuery.includesMax(), equalTo(false)); } - @Test public void testRange2Query() throws IOException { + @Test + public void testRange2Query() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/range2.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/range2.json"); Query parsedQuery = queryParser.parse(query).query(); // since age is automatically registered in data, we encode it as numeric assertThat(parsedQuery, instanceOf(NumericRangeQuery.class)); @@ -624,7 +663,8 @@ public class SimpleIndexQueryParserTests { assertThat(rangeQuery.includesMax(), equalTo(false)); } - @Test public void testRangeFilteredQueryBuilder() throws IOException { + @Test + public void testRangeFilteredQueryBuilder() throws IOException { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(filteredQuery(termQuery("name.first", "shay"), rangeFilter("age").from(23).to(54).includeLower(true).includeUpper(false))).query(); // since age is automatically registered in data, we encode it as numeric @@ -639,9 +679,10 @@ public class SimpleIndexQueryParserTests { assertThat(rangeFilter.includesMax(), equalTo(false)); } - @Test public void testRangeFilteredQuery() throws IOException { + @Test + public void testRangeFilteredQuery() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/range-filter.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/range-filter.json"); Query parsedQuery = queryParser.parse(query).query(); // since age is automatically registered in data, we encode it as numeric assertThat(parsedQuery, instanceOf(FilteredQuery.class)); @@ -655,9 +696,10 @@ public class SimpleIndexQueryParserTests { assertThat(rangeFilter.includesMax(), equalTo(false)); } - @Test public void testRangeNamedFilteredQuery() throws IOException { + @Test + public void testRangeNamedFilteredQuery() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/range-filter-named.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/range-filter-named.json"); ParsedQuery parsedQuery = queryParser.parse(query); assertThat(parsedQuery.namedFilters().containsKey("test"), equalTo(true)); assertThat(parsedQuery.query(), instanceOf(FilteredQuery.class)); @@ -671,7 +713,8 @@ public class SimpleIndexQueryParserTests { assertThat(rangeFilter.includesMax(), equalTo(false)); } - @Test public void testNumericRangeFilteredQueryBuilder() throws IOException { + @Test + public void testNumericRangeFilteredQueryBuilder() throws IOException { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(filteredQuery(termQuery("name.first", "shay"), numericRangeFilter("age").from(23).to(54).includeLower(true).includeUpper(false))).query(); assertThat(parsedQuery, instanceOf(FilteredQuery.class)); @@ -685,9 +728,10 @@ public class SimpleIndexQueryParserTests { assertThat(rangeFilter.isIncludeUpper(), equalTo(false)); } - @Test public void testNumericRangeFilteredQuery() throws IOException { + @Test + public void testNumericRangeFilteredQuery() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/numeric_range-filter.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/numeric_range-filter.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(FilteredQuery.class)); Filter filter = ((FilteredQuery) parsedQuery).getFilter(); @@ -700,9 +744,10 @@ public class SimpleIndexQueryParserTests { assertThat(rangeFilter.isIncludeUpper(), equalTo(false)); } - @Test public void testBoolFilteredQuery() throws IOException { + @Test + public void testBoolFilteredQuery() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/bool-filter.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/bool-filter.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(FilteredQuery.class)); FilteredQuery filteredQuery = (FilteredQuery) parsedQuery; @@ -711,7 +756,8 @@ public class SimpleIndexQueryParserTests { // TODO get the content and test } - @Test public void testAndFilteredQueryBuilder() throws IOException { + @Test + public void testAndFilteredQueryBuilder() throws IOException { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(filteredQuery(matchAllQuery(), andFilter(termFilter("name.first", "shay1"), termFilter("name.first", "shay4")))).query(); assertThat(parsedQuery, instanceOf(DeletionAwareConstantScoreQuery.class)); @@ -723,9 +769,10 @@ public class SimpleIndexQueryParserTests { assertThat(((TermFilter) andFilter.filters().get(1)).getTerm(), equalTo(new Term("name.first", "shay4"))); } - @Test public void testAndFilteredQuery() throws IOException { + @Test + public void testAndFilteredQuery() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/and-filter.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/and-filter.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(FilteredQuery.class)); FilteredQuery filteredQuery = (FilteredQuery) parsedQuery; @@ -736,9 +783,10 @@ public class SimpleIndexQueryParserTests { assertThat(((TermFilter) andFilter.filters().get(1)).getTerm(), equalTo(new Term("name.first", "shay4"))); } - @Test public void testAndNamedFilteredQuery() throws IOException { + @Test + public void testAndNamedFilteredQuery() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/and-filter-named.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/and-filter-named.json"); ParsedQuery parsedQuery = queryParser.parse(query); assertThat(parsedQuery.namedFilters().containsKey("test"), equalTo(true)); assertThat(parsedQuery.query(), instanceOf(FilteredQuery.class)); @@ -750,9 +798,10 @@ public class SimpleIndexQueryParserTests { assertThat(((TermFilter) andFilter.filters().get(1)).getTerm(), equalTo(new Term("name.first", "shay4"))); } - @Test public void testAndFilteredQuery2() throws IOException { + @Test + public void testAndFilteredQuery2() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/and-filter2.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/and-filter2.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(FilteredQuery.class)); FilteredQuery filteredQuery = (FilteredQuery) parsedQuery; @@ -763,7 +812,8 @@ public class SimpleIndexQueryParserTests { assertThat(((TermFilter) andFilter.filters().get(1)).getTerm(), equalTo(new Term("name.first", "shay4"))); } - @Test public void testOrFilteredQueryBuilder() throws IOException { + @Test + public void testOrFilteredQueryBuilder() throws IOException { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(filteredQuery(matchAllQuery(), orFilter(termFilter("name.first", "shay1"), termFilter("name.first", "shay4")))).query(); assertThat(parsedQuery, instanceOf(DeletionAwareConstantScoreQuery.class)); @@ -775,9 +825,10 @@ public class SimpleIndexQueryParserTests { assertThat(((TermFilter) andFilter.filters().get(1)).getTerm(), equalTo(new Term("name.first", "shay4"))); } - @Test public void testOrFilteredQuery() throws IOException { + @Test + public void testOrFilteredQuery() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/or-filter.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/or-filter.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(FilteredQuery.class)); FilteredQuery filteredQuery = (FilteredQuery) parsedQuery; @@ -788,9 +839,10 @@ public class SimpleIndexQueryParserTests { assertThat(((TermFilter) orFilter.filters().get(1)).getTerm(), equalTo(new Term("name.first", "shay4"))); } - @Test public void testOrFilteredQuery2() throws IOException { + @Test + public void testOrFilteredQuery2() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/or-filter2.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/or-filter2.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(FilteredQuery.class)); FilteredQuery filteredQuery = (FilteredQuery) parsedQuery; @@ -801,7 +853,8 @@ public class SimpleIndexQueryParserTests { assertThat(((TermFilter) orFilter.filters().get(1)).getTerm(), equalTo(new Term("name.first", "shay4"))); } - @Test public void testNotFilteredQueryBuilder() throws IOException { + @Test + public void testNotFilteredQueryBuilder() throws IOException { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(filteredQuery(matchAllQuery(), notFilter(termFilter("name.first", "shay1")))).query(); assertThat(parsedQuery, instanceOf(DeletionAwareConstantScoreQuery.class)); @@ -811,9 +864,10 @@ public class SimpleIndexQueryParserTests { assertThat(((TermFilter) notFilter.filter()).getTerm(), equalTo(new Term("name.first", "shay1"))); } - @Test public void testNotFilteredQuery() throws IOException { + @Test + public void testNotFilteredQuery() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/not-filter.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/not-filter.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(FilteredQuery.class)); FilteredQuery filteredQuery = (FilteredQuery) parsedQuery; @@ -823,9 +877,10 @@ public class SimpleIndexQueryParserTests { assertThat(((TermFilter) notFilter.filter()).getTerm(), equalTo(new Term("name.first", "shay1"))); } - @Test public void testNotFilteredQuery2() throws IOException { + @Test + public void testNotFilteredQuery2() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/not-filter2.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/not-filter2.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(FilteredQuery.class)); FilteredQuery filteredQuery = (FilteredQuery) parsedQuery; @@ -835,9 +890,10 @@ public class SimpleIndexQueryParserTests { assertThat(((TermFilter) notFilter.filter()).getTerm(), equalTo(new Term("name.first", "shay1"))); } - @Test public void testNotFilteredQuery3() throws IOException { + @Test + public void testNotFilteredQuery3() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/not-filter3.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/not-filter3.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(FilteredQuery.class)); FilteredQuery filteredQuery = (FilteredQuery) parsedQuery; @@ -847,22 +903,25 @@ public class SimpleIndexQueryParserTests { assertThat(((TermFilter) notFilter.filter()).getTerm(), equalTo(new Term("name.first", "shay1"))); } - @Test public void testBoostingQueryBuilder() throws IOException { + @Test + public void testBoostingQueryBuilder() throws IOException { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(boostingQuery().positive(termQuery("field1", "value1")).negative(termQuery("field1", "value2")).negativeBoost(0.2f)).query(); assertThat(parsedQuery, instanceOf(BoostingQuery.class)); } - @Test public void testBoostingQuery() throws IOException { + @Test + public void testBoostingQuery() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/boosting-query.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/boosting-query.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(BoostingQuery.class)); } - @Test public void testQueryStringFuzzyNumeric() throws IOException { + @Test + public void testQueryStringFuzzyNumeric() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/query2.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/query2.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(NumericRangeQuery.class)); NumericRangeQuery fuzzyQuery = (NumericRangeQuery) parsedQuery; @@ -870,7 +929,8 @@ public class SimpleIndexQueryParserTests { assertThat(fuzzyQuery.getMax().longValue(), equalTo(12l)); } - @Test public void testBoolQueryBuilder() throws IOException { + @Test + public void testBoolQueryBuilder() throws IOException { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(boolQuery().must(termQuery("content", "test1")).must(termQuery("content", "test4")).mustNot(termQuery("content", "test2")).should(termQuery("content", "test3"))).query(); assertThat(parsedQuery, instanceOf(BooleanQuery.class)); @@ -893,9 +953,10 @@ public class SimpleIndexQueryParserTests { } - @Test public void testBoolQuery() throws IOException { + @Test + public void testBoolQuery() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/bool.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/bool.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(BooleanQuery.class)); BooleanQuery booleanQuery = (BooleanQuery) parsedQuery; @@ -916,9 +977,10 @@ public class SimpleIndexQueryParserTests { assertThat(clauses[3].getOccur(), equalTo(BooleanClause.Occur.SHOULD)); } - @Test public void testTermsQuery() throws IOException { + @Test + public void testTermsQuery() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/terms-query.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/terms-query.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(BooleanQuery.class)); BooleanQuery booleanQuery = (BooleanQuery) parsedQuery; @@ -933,7 +995,8 @@ public class SimpleIndexQueryParserTests { assertThat(clauses[1].getOccur(), equalTo(BooleanClause.Occur.SHOULD)); } - @Test public void testFilteredQueryBuilder() throws IOException { + @Test + public void testFilteredQueryBuilder() throws IOException { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(filteredQuery(termQuery("name.first", "shay"), termFilter("name.last", "banon"))).query(); assertThat(parsedQuery, instanceOf(FilteredQuery.class)); @@ -942,9 +1005,10 @@ public class SimpleIndexQueryParserTests { assertThat(((TermFilter) filteredQuery.getFilter()).getTerm(), equalTo(new Term("name.last", "banon"))); } - @Test public void testFilteredQuery() throws IOException { + @Test + public void testFilteredQuery() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/filtered-query.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/filtered-query.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(FilteredQuery.class)); FilteredQuery filteredQuery = (FilteredQuery) parsedQuery; @@ -952,9 +1016,10 @@ public class SimpleIndexQueryParserTests { assertThat(((TermFilter) filteredQuery.getFilter()).getTerm(), equalTo(new Term("name.last", "banon"))); } - @Test public void testFilteredQuery2() throws IOException { + @Test + public void testFilteredQuery2() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/filtered-query2.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/filtered-query2.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(FilteredQuery.class)); FilteredQuery filteredQuery = (FilteredQuery) parsedQuery; @@ -962,9 +1027,10 @@ public class SimpleIndexQueryParserTests { assertThat(((TermFilter) filteredQuery.getFilter()).getTerm(), equalTo(new Term("name.last", "banon"))); } - @Test public void testFilteredQuery3() throws IOException { + @Test + public void testFilteredQuery3() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/filtered-query3.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/filtered-query3.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(FilteredQuery.class)); FilteredQuery filteredQuery = (FilteredQuery) parsedQuery; @@ -978,9 +1044,10 @@ public class SimpleIndexQueryParserTests { assertThat(rangeFilter.getMax().intValue(), equalTo(54)); } - @Test public void testFilteredQuery4() throws IOException { + @Test + public void testFilteredQuery4() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/filtered-query4.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/filtered-query4.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(FilteredQuery.class)); FilteredQuery filteredQuery = (FilteredQuery) parsedQuery; @@ -991,9 +1058,10 @@ public class SimpleIndexQueryParserTests { assertThat(((TermFilter) filteredQuery.getFilter()).getTerm(), equalTo(new Term("name.last", "banon"))); } - @Test public void testLimitFilter() throws Exception { + @Test + public void testLimitFilter() throws Exception { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/limit-filter.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/limit-filter.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(FilteredQuery.class)); FilteredQuery filteredQuery = (FilteredQuery) parsedQuery; @@ -1004,9 +1072,10 @@ public class SimpleIndexQueryParserTests { assertThat(((TermQuery) filteredQuery.getQuery()).getTerm(), equalTo(new Term("name.first", "shay"))); } - @Test public void testTermFilterQuery() throws Exception { + @Test + public void testTermFilterQuery() throws Exception { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/term-filter.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/term-filter.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(FilteredQuery.class)); FilteredQuery filteredQuery = (FilteredQuery) parsedQuery; @@ -1016,9 +1085,10 @@ public class SimpleIndexQueryParserTests { assertThat(termFilter.getTerm().text(), equalTo("banon")); } - @Test public void testTermNamedFilterQuery() throws Exception { + @Test + public void testTermNamedFilterQuery() throws Exception { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/term-filter-named.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/term-filter-named.json"); ParsedQuery parsedQuery = queryParser.parse(query); assertThat(parsedQuery.namedFilters().containsKey("test"), equalTo(true)); assertThat(parsedQuery.query(), instanceOf(FilteredQuery.class)); @@ -1029,7 +1099,8 @@ public class SimpleIndexQueryParserTests { assertThat(termFilter.getTerm().text(), equalTo("banon")); } - @Test public void testTermsFilterQueryBuilder() throws Exception { + @Test + public void testTermsFilterQueryBuilder() throws Exception { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(filteredQuery(termQuery("name.first", "shay"), termsFilter("name.last", "banon", "kimchy"))).query(); assertThat(parsedQuery, instanceOf(FilteredQuery.class)); @@ -1041,9 +1112,10 @@ public class SimpleIndexQueryParserTests { } - @Test public void testTermsFilterQuery() throws Exception { + @Test + public void testTermsFilterQuery() throws Exception { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/terms-filter.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/terms-filter.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(FilteredQuery.class)); FilteredQuery filteredQuery = (FilteredQuery) parsedQuery; @@ -1053,9 +1125,10 @@ public class SimpleIndexQueryParserTests { assertThat(termsFilter.getTerms().iterator().next().text(), equalTo("banon")); } - @Test public void testTermsWithNameFilterQuery() throws Exception { + @Test + public void testTermsWithNameFilterQuery() throws Exception { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/terms-filter-named.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/terms-filter-named.json"); ParsedQuery parsedQuery = queryParser.parse(query); assertThat(parsedQuery.namedFilters().containsKey("test"), equalTo(true)); assertThat(parsedQuery.query(), instanceOf(FilteredQuery.class)); @@ -1066,7 +1139,8 @@ public class SimpleIndexQueryParserTests { assertThat(termsFilter.getTerms().iterator().next().text(), equalTo("banon")); } - @Test public void testConstantScoreQueryBuilder() throws IOException { + @Test + public void testConstantScoreQueryBuilder() throws IOException { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(constantScoreQuery(termFilter("name.last", "banon"))).query(); assertThat(parsedQuery, instanceOf(DeletionAwareConstantScoreQuery.class)); @@ -1074,9 +1148,10 @@ public class SimpleIndexQueryParserTests { assertThat(((TermFilter) constantScoreQuery.getFilter()).getTerm(), equalTo(new Term("name.last", "banon"))); } - @Test public void testConstantScoreQuery() throws IOException { + @Test + public void testConstantScoreQuery() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/constantScore-query.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/constantScore-query.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(DeletionAwareConstantScoreQuery.class)); DeletionAwareConstantScoreQuery constantScoreQuery = (DeletionAwareConstantScoreQuery) parsedQuery; @@ -1094,7 +1169,8 @@ public class SimpleIndexQueryParserTests { // assertThat(functionScoreQuery.getFunction(), instanceOf(CustomScoreQueryParser.ScriptScoreFunction.class)); // } - @Test public void testCustomBoostFactorQueryBuilder() throws IOException { + @Test + public void testCustomBoostFactorQueryBuilder() throws IOException { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(customBoostFactorQuery(termQuery("name.last", "banon")).boostFactor(1.3f)).query(); assertThat(parsedQuery, instanceOf(FunctionScoreQuery.class)); @@ -1104,9 +1180,10 @@ public class SimpleIndexQueryParserTests { } - @Test public void testCustomBoostFactorQuery() throws IOException { + @Test + public void testCustomBoostFactorQuery() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/custom-boost-factor-query.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/custom-boost-factor-query.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(FunctionScoreQuery.class)); FunctionScoreQuery functionScoreQuery = (FunctionScoreQuery) parsedQuery; @@ -1114,7 +1191,8 @@ public class SimpleIndexQueryParserTests { assertThat((double) ((BoostScoreFunction) functionScoreQuery.getFunction()).getBoost(), closeTo(1.3, 0.001)); } - @Test public void testSpanTermQueryBuilder() throws IOException { + @Test + public void testSpanTermQueryBuilder() throws IOException { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(spanTermQuery("age", 34)).query(); assertThat(parsedQuery, instanceOf(SpanTermQuery.class)); @@ -1123,9 +1201,10 @@ public class SimpleIndexQueryParserTests { assertThat(termQuery.getTerm(), equalTo(new Term("age", NumericUtils.longToPrefixCoded(34)))); } - @Test public void testSpanTermQuery() throws IOException { + @Test + public void testSpanTermQuery() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/spanTerm.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/spanTerm.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(SpanTermQuery.class)); SpanTermQuery termQuery = (SpanTermQuery) parsedQuery; @@ -1133,7 +1212,8 @@ public class SimpleIndexQueryParserTests { assertThat(termQuery.getTerm(), equalTo(new Term("age", NumericUtils.longToPrefixCoded(34)))); } - @Test public void testSpanNotQueryBuilder() throws IOException { + @Test + public void testSpanNotQueryBuilder() throws IOException { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(spanNotQuery().include(spanTermQuery("age", 34)).exclude(spanTermQuery("age", 35))).query(); assertThat(parsedQuery, instanceOf(SpanNotQuery.class)); @@ -1143,9 +1223,10 @@ public class SimpleIndexQueryParserTests { assertThat(((SpanTermQuery) spanNotQuery.getExclude()).getTerm(), equalTo(new Term("age", NumericUtils.longToPrefixCoded(35)))); } - @Test public void testSpanNotQuery() throws IOException { + @Test + public void testSpanNotQuery() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/spanNot.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/spanNot.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(SpanNotQuery.class)); SpanNotQuery spanNotQuery = (SpanNotQuery) parsedQuery; @@ -1154,7 +1235,8 @@ public class SimpleIndexQueryParserTests { assertThat(((SpanTermQuery) spanNotQuery.getExclude()).getTerm(), equalTo(new Term("age", NumericUtils.longToPrefixCoded(35)))); } - @Test public void testSpanFirstQueryBuilder() throws IOException { + @Test + public void testSpanFirstQueryBuilder() throws IOException { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(spanFirstQuery(spanTermQuery("age", 34), 12)).query(); assertThat(parsedQuery, instanceOf(SpanFirstQuery.class)); @@ -1164,9 +1246,10 @@ public class SimpleIndexQueryParserTests { assertThat(spanFirstQuery.getEnd(), equalTo(12)); } - @Test public void testSpanFirstQuery() throws IOException { + @Test + public void testSpanFirstQuery() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/spanFirst.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/spanFirst.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(SpanFirstQuery.class)); SpanFirstQuery spanFirstQuery = (SpanFirstQuery) parsedQuery; @@ -1175,7 +1258,8 @@ public class SimpleIndexQueryParserTests { assertThat(spanFirstQuery.getEnd(), equalTo(12)); } - @Test public void testSpanNearQueryBuilder() throws IOException { + @Test + public void testSpanNearQueryBuilder() throws IOException { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(spanNearQuery().clause(spanTermQuery("age", 34)).clause(spanTermQuery("age", 35)).clause(spanTermQuery("age", 36)).slop(12).inOrder(false).collectPayloads(false)).query(); assertThat(parsedQuery, instanceOf(SpanNearQuery.class)); @@ -1187,9 +1271,10 @@ public class SimpleIndexQueryParserTests { assertThat(spanNearQuery.isInOrder(), equalTo(false)); } - @Test public void testSpanNearQuery() throws IOException { + @Test + public void testSpanNearQuery() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/spanNear.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/spanNear.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(SpanNearQuery.class)); SpanNearQuery spanNearQuery = (SpanNearQuery) parsedQuery; @@ -1200,7 +1285,8 @@ public class SimpleIndexQueryParserTests { assertThat(spanNearQuery.isInOrder(), equalTo(false)); } - @Test public void testSpanOrQueryBuilder() throws IOException { + @Test + public void testSpanOrQueryBuilder() throws IOException { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(spanOrQuery().clause(spanTermQuery("age", 34)).clause(spanTermQuery("age", 35)).clause(spanTermQuery("age", 36))).query(); assertThat(parsedQuery, instanceOf(SpanOrQuery.class)); @@ -1211,9 +1297,10 @@ public class SimpleIndexQueryParserTests { assertThat(((SpanTermQuery) spanOrQuery.getClauses()[2]).getTerm(), equalTo(new Term("age", NumericUtils.longToPrefixCoded(36)))); } - @Test public void testSpanOrQuery() throws IOException { + @Test + public void testSpanOrQuery() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/spanOr.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/spanOr.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(SpanOrQuery.class)); SpanOrQuery spanOrQuery = (SpanOrQuery) parsedQuery; @@ -1223,9 +1310,10 @@ public class SimpleIndexQueryParserTests { assertThat(((SpanTermQuery) spanOrQuery.getClauses()[2]).getTerm(), equalTo(new Term("age", NumericUtils.longToPrefixCoded(36)))); } - @Test public void testSpanOrQuery2() throws IOException { + @Test + public void testSpanOrQuery2() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/spanOr2.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/spanOr2.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(SpanOrQuery.class)); SpanOrQuery spanOrQuery = (SpanOrQuery) parsedQuery; @@ -1235,7 +1323,8 @@ public class SimpleIndexQueryParserTests { assertThat(((SpanTermQuery) spanOrQuery.getClauses()[2]).getTerm(), equalTo(new Term("age", NumericUtils.longToPrefixCoded(36)))); } - @Test public void testQueryFilterBuilder() throws Exception { + @Test + public void testQueryFilterBuilder() throws Exception { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(filteredQuery(termQuery("name.first", "shay"), queryFilter(termQuery("name.last", "banon")))).query(); assertThat(parsedQuery, instanceOf(FilteredQuery.class)); @@ -1248,9 +1337,10 @@ public class SimpleIndexQueryParserTests { assertThat(((TermQuery) wrappedQuery).getTerm(), equalTo(new Term("name.last", "banon"))); } - @Test public void testQueryFilter() throws Exception { + @Test + public void testQueryFilter() throws Exception { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/query-filter.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/query-filter.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(FilteredQuery.class)); FilteredQuery filteredQuery = (FilteredQuery) parsedQuery; @@ -1262,9 +1352,10 @@ public class SimpleIndexQueryParserTests { assertThat(((TermQuery) wrappedQuery).getTerm(), equalTo(new Term("name.last", "banon"))); } - @Test public void testFQueryFilter() throws Exception { + @Test + public void testFQueryFilter() throws Exception { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/fquery-filter.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/fquery-filter.json"); ParsedQuery parsedQuery = queryParser.parse(query); assertThat(parsedQuery.namedFilters().containsKey("test"), equalTo(true)); assertThat(parsedQuery.query(), instanceOf(FilteredQuery.class)); @@ -1277,7 +1368,8 @@ public class SimpleIndexQueryParserTests { assertThat(((TermQuery) wrappedQuery).getTerm(), equalTo(new Term("name.last", "banon"))); } - @Test public void testMoreLikeThisBuilder() throws Exception { + @Test + public void testMoreLikeThisBuilder() throws Exception { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(moreLikeThisQuery("name.first", "name.last").likeText("something").minTermFreq(1).maxQueryTerms(12)).query(); assertThat(parsedQuery, instanceOf(MoreLikeThisQuery.class)); @@ -1288,9 +1380,10 @@ public class SimpleIndexQueryParserTests { assertThat(mltQuery.getMaxQueryTerms(), equalTo(12)); } - @Test public void testMoreLikeThis() throws Exception { + @Test + public void testMoreLikeThis() throws Exception { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/mlt.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/mlt.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(MoreLikeThisQuery.class)); MoreLikeThisQuery mltQuery = (MoreLikeThisQuery) parsedQuery; @@ -1301,37 +1394,42 @@ public class SimpleIndexQueryParserTests { assertThat(mltQuery.getMaxQueryTerms(), equalTo(12)); } - @Test public void testFuzzyLikeThisBuilder() throws Exception { + @Test + public void testFuzzyLikeThisBuilder() throws Exception { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(fuzzyLikeThisQuery("name.first", "name.last").likeText("something").maxQueryTerms(12)).query(); assertThat(parsedQuery, instanceOf(FuzzyLikeThisQuery.class)); // FuzzyLikeThisQuery fuzzyLikeThisQuery = (FuzzyLikeThisQuery) parsedQuery; } - @Test public void testFuzzyLikeThis() throws Exception { + @Test + public void testFuzzyLikeThis() throws Exception { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/fuzzyLikeThis.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/fuzzyLikeThis.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(FuzzyLikeThisQuery.class)); // FuzzyLikeThisQuery fuzzyLikeThisQuery = (FuzzyLikeThisQuery) parsedQuery; } - @Test public void testFuzzyLikeFieldThisBuilder() throws Exception { + @Test + public void testFuzzyLikeFieldThisBuilder() throws Exception { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(fuzzyLikeThisFieldQuery("name.first").likeText("something").maxQueryTerms(12)).query(); assertThat(parsedQuery, instanceOf(FuzzyLikeThisQuery.class)); // FuzzyLikeThisQuery fuzzyLikeThisQuery = (FuzzyLikeThisQuery) parsedQuery; } - @Test public void testFuzzyLikeThisField() throws Exception { + @Test + public void testFuzzyLikeThisField() throws Exception { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/fuzzyLikeThisField.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/fuzzyLikeThisField.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(FuzzyLikeThisQuery.class)); // FuzzyLikeThisQuery fuzzyLikeThisQuery = (FuzzyLikeThisQuery) parsedQuery; } - @Test public void testMoreLikeThisFieldBuilder() throws Exception { + @Test + public void testMoreLikeThisFieldBuilder() throws Exception { IndexQueryParserService queryParser = queryParser(); Query parsedQuery = queryParser.parse(moreLikeThisFieldQuery("name.first").likeText("something").minTermFreq(1).maxQueryTerms(12)).query(); assertThat(parsedQuery, instanceOf(MoreLikeThisQuery.class)); @@ -1342,9 +1440,10 @@ public class SimpleIndexQueryParserTests { assertThat(mltQuery.getMaxQueryTerms(), equalTo(12)); } - @Test public void testMoreLikeThisField() throws Exception { + @Test + public void testMoreLikeThisField() throws Exception { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/mltField.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/mltField.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(MoreLikeThisQuery.class)); MoreLikeThisQuery mltQuery = (MoreLikeThisQuery) parsedQuery; @@ -1354,9 +1453,10 @@ public class SimpleIndexQueryParserTests { assertThat(mltQuery.getMaxQueryTerms(), equalTo(12)); } - @Test public void testGeoDistanceFilterNamed() throws IOException { + @Test + public void testGeoDistanceFilterNamed() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_distance-named.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/geo_distance-named.json"); ParsedQuery parsedQuery = queryParser.parse(query); assertThat(parsedQuery.namedFilters().containsKey("test"), equalTo(true)); assertThat(parsedQuery.query(), instanceOf(DeletionAwareConstantScoreQuery.class)); @@ -1368,9 +1468,10 @@ public class SimpleIndexQueryParserTests { assertThat(filter.distance(), closeTo(12, 0.00001)); } - @Test public void testGeoDistanceFilter1() throws IOException { + @Test + public void testGeoDistanceFilter1() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_distance1.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/geo_distance1.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(DeletionAwareConstantScoreQuery.class)); DeletionAwareConstantScoreQuery constantScoreQuery = (DeletionAwareConstantScoreQuery) parsedQuery; @@ -1381,9 +1482,10 @@ public class SimpleIndexQueryParserTests { assertThat(filter.distance(), closeTo(12, 0.00001)); } - @Test public void testGeoDistanceFilter2() throws IOException { + @Test + public void testGeoDistanceFilter2() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_distance2.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/geo_distance2.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(DeletionAwareConstantScoreQuery.class)); DeletionAwareConstantScoreQuery constantScoreQuery = (DeletionAwareConstantScoreQuery) parsedQuery; @@ -1394,9 +1496,10 @@ public class SimpleIndexQueryParserTests { assertThat(filter.distance(), closeTo(12, 0.00001)); } - @Test public void testGeoDistanceFilter3() throws IOException { + @Test + public void testGeoDistanceFilter3() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_distance3.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/geo_distance3.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(DeletionAwareConstantScoreQuery.class)); DeletionAwareConstantScoreQuery constantScoreQuery = (DeletionAwareConstantScoreQuery) parsedQuery; @@ -1407,9 +1510,10 @@ public class SimpleIndexQueryParserTests { assertThat(filter.distance(), closeTo(12, 0.00001)); } - @Test public void testGeoDistanceFilter4() throws IOException { + @Test + public void testGeoDistanceFilter4() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_distance4.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/geo_distance4.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(DeletionAwareConstantScoreQuery.class)); DeletionAwareConstantScoreQuery constantScoreQuery = (DeletionAwareConstantScoreQuery) parsedQuery; @@ -1420,9 +1524,10 @@ public class SimpleIndexQueryParserTests { assertThat(filter.distance(), closeTo(12, 0.00001)); } - @Test public void testGeoDistanceFilter5() throws IOException { + @Test + public void testGeoDistanceFilter5() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_distance5.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/geo_distance5.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(DeletionAwareConstantScoreQuery.class)); DeletionAwareConstantScoreQuery constantScoreQuery = (DeletionAwareConstantScoreQuery) parsedQuery; @@ -1433,9 +1538,10 @@ public class SimpleIndexQueryParserTests { assertThat(filter.distance(), closeTo(12, 0.00001)); } - @Test public void testGeoDistanceFilter6() throws IOException { + @Test + public void testGeoDistanceFilter6() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_distance6.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/geo_distance6.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(DeletionAwareConstantScoreQuery.class)); DeletionAwareConstantScoreQuery constantScoreQuery = (DeletionAwareConstantScoreQuery) parsedQuery; @@ -1446,9 +1552,10 @@ public class SimpleIndexQueryParserTests { assertThat(filter.distance(), closeTo(12, 0.00001)); } - @Test public void testGeoDistanceFilter7() throws IOException { + @Test + public void testGeoDistanceFilter7() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_distance7.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/geo_distance7.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(DeletionAwareConstantScoreQuery.class)); DeletionAwareConstantScoreQuery constantScoreQuery = (DeletionAwareConstantScoreQuery) parsedQuery; @@ -1459,9 +1566,10 @@ public class SimpleIndexQueryParserTests { assertThat(filter.distance(), closeTo(12, 0.00001)); } - @Test public void testGeoDistanceFilter8() throws IOException { + @Test + public void testGeoDistanceFilter8() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_distance8.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/geo_distance8.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(DeletionAwareConstantScoreQuery.class)); DeletionAwareConstantScoreQuery constantScoreQuery = (DeletionAwareConstantScoreQuery) parsedQuery; @@ -1472,9 +1580,10 @@ public class SimpleIndexQueryParserTests { assertThat(filter.distance(), closeTo(12, 0.00001)); } - @Test public void testGeoDistanceFilter9() throws IOException { + @Test + public void testGeoDistanceFilter9() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_distance9.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/geo_distance9.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(DeletionAwareConstantScoreQuery.class)); DeletionAwareConstantScoreQuery constantScoreQuery = (DeletionAwareConstantScoreQuery) parsedQuery; @@ -1485,9 +1594,10 @@ public class SimpleIndexQueryParserTests { assertThat(filter.distance(), closeTo(12, 0.00001)); } - @Test public void testGeoDistanceFilter10() throws IOException { + @Test + public void testGeoDistanceFilter10() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_distance10.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/geo_distance10.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(DeletionAwareConstantScoreQuery.class)); DeletionAwareConstantScoreQuery constantScoreQuery = (DeletionAwareConstantScoreQuery) parsedQuery; @@ -1498,9 +1608,10 @@ public class SimpleIndexQueryParserTests { assertThat(filter.distance(), closeTo(12, 0.00001)); } - @Test public void testGeoDistanceFilter11() throws IOException { + @Test + public void testGeoDistanceFilter11() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_distance11.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/geo_distance11.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(DeletionAwareConstantScoreQuery.class)); DeletionAwareConstantScoreQuery constantScoreQuery = (DeletionAwareConstantScoreQuery) parsedQuery; @@ -1511,9 +1622,10 @@ public class SimpleIndexQueryParserTests { assertThat(filter.distance(), closeTo(12, 0.00001)); } - @Test public void testGeoDistanceFilter12() throws IOException { + @Test + public void testGeoDistanceFilter12() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_distance12.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/geo_distance12.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(DeletionAwareConstantScoreQuery.class)); DeletionAwareConstantScoreQuery constantScoreQuery = (DeletionAwareConstantScoreQuery) parsedQuery; @@ -1524,9 +1636,10 @@ public class SimpleIndexQueryParserTests { assertThat(filter.distance(), closeTo(12, 0.00001)); } - @Test public void testGeoBoundingBoxFilterNamed() throws IOException { + @Test + public void testGeoBoundingBoxFilterNamed() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_boundingbox-named.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/geo_boundingbox-named.json"); ParsedQuery parsedQuery = queryParser.parse(query); assertThat(parsedQuery.query(), instanceOf(DeletionAwareConstantScoreQuery.class)); assertThat(parsedQuery.namedFilters().containsKey("test"), equalTo(true)); @@ -1540,9 +1653,10 @@ public class SimpleIndexQueryParserTests { } - @Test public void testGeoBoundingBoxFilter1() throws IOException { + @Test + public void testGeoBoundingBoxFilter1() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_boundingbox1.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/geo_boundingbox1.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(DeletionAwareConstantScoreQuery.class)); DeletionAwareConstantScoreQuery constantScoreQuery = (DeletionAwareConstantScoreQuery) parsedQuery; @@ -1554,9 +1668,10 @@ public class SimpleIndexQueryParserTests { assertThat(filter.bottomRight().lon, closeTo(-80, 0.00001)); } - @Test public void testGeoBoundingBoxFilter2() throws IOException { + @Test + public void testGeoBoundingBoxFilter2() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_boundingbox2.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/geo_boundingbox2.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(DeletionAwareConstantScoreQuery.class)); DeletionAwareConstantScoreQuery constantScoreQuery = (DeletionAwareConstantScoreQuery) parsedQuery; @@ -1568,9 +1683,10 @@ public class SimpleIndexQueryParserTests { assertThat(filter.bottomRight().lon, closeTo(-80, 0.00001)); } - @Test public void testGeoBoundingBoxFilter3() throws IOException { + @Test + public void testGeoBoundingBoxFilter3() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_boundingbox3.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/geo_boundingbox3.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(DeletionAwareConstantScoreQuery.class)); DeletionAwareConstantScoreQuery constantScoreQuery = (DeletionAwareConstantScoreQuery) parsedQuery; @@ -1582,9 +1698,10 @@ public class SimpleIndexQueryParserTests { assertThat(filter.bottomRight().lon, closeTo(-80, 0.00001)); } - @Test public void testGeoBoundingBoxFilter4() throws IOException { + @Test + public void testGeoBoundingBoxFilter4() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_boundingbox4.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/geo_boundingbox4.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(DeletionAwareConstantScoreQuery.class)); DeletionAwareConstantScoreQuery constantScoreQuery = (DeletionAwareConstantScoreQuery) parsedQuery; @@ -1596,9 +1713,10 @@ public class SimpleIndexQueryParserTests { assertThat(filter.bottomRight().lon, closeTo(-80, 0.00001)); } - @Test public void testGeoPolygonNamedFilter() throws IOException { + @Test + public void testGeoPolygonNamedFilter() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_polygon-named.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/geo_polygon-named.json"); ParsedQuery parsedQuery = queryParser.parse(query); assertThat(parsedQuery.namedFilters().containsKey("test"), equalTo(true)); assertThat(parsedQuery.query(), instanceOf(DeletionAwareConstantScoreQuery.class)); @@ -1614,9 +1732,10 @@ public class SimpleIndexQueryParserTests { assertThat(filter.points()[2].lon, closeTo(-90, 0.00001)); } - @Test public void testGeoPolygonFilter1() throws IOException { + @Test + public void testGeoPolygonFilter1() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_polygon1.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/geo_polygon1.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(DeletionAwareConstantScoreQuery.class)); DeletionAwareConstantScoreQuery constantScoreQuery = (DeletionAwareConstantScoreQuery) parsedQuery; @@ -1631,9 +1750,10 @@ public class SimpleIndexQueryParserTests { assertThat(filter.points()[2].lon, closeTo(-90, 0.00001)); } - @Test public void testGeoPolygonFilter2() throws IOException { + @Test + public void testGeoPolygonFilter2() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_polygon2.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/geo_polygon2.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(DeletionAwareConstantScoreQuery.class)); DeletionAwareConstantScoreQuery constantScoreQuery = (DeletionAwareConstantScoreQuery) parsedQuery; @@ -1648,9 +1768,10 @@ public class SimpleIndexQueryParserTests { assertThat(filter.points()[2].lon, closeTo(-90, 0.00001)); } - @Test public void testGeoPolygonFilter3() throws IOException { + @Test + public void testGeoPolygonFilter3() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_polygon3.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/geo_polygon3.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(DeletionAwareConstantScoreQuery.class)); DeletionAwareConstantScoreQuery constantScoreQuery = (DeletionAwareConstantScoreQuery) parsedQuery; @@ -1665,9 +1786,10 @@ public class SimpleIndexQueryParserTests { assertThat(filter.points()[2].lon, closeTo(-90, 0.00001)); } - @Test public void testGeoPolygonFilter4() throws IOException { + @Test + public void testGeoPolygonFilter4() throws IOException { IndexQueryParserService queryParser = queryParser(); - String query = copyToStringFromClasspath("/org/elasticsearch/index/query/geo_polygon4.json"); + String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/geo_polygon4.json"); Query parsedQuery = queryParser.parse(query).query(); assertThat(parsedQuery, instanceOf(DeletionAwareConstantScoreQuery.class)); DeletionAwareConstantScoreQuery constantScoreQuery = (DeletionAwareConstantScoreQuery) parsedQuery; diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/and-filter-named.json b/src/test/java/org/elasticsearch/test/unit/index/query/and-filter-named.json new file mode 100644 index 00000000000..605a1936e84 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/and-filter-named.json @@ -0,0 +1,26 @@ +{ + "filtered":{ + "query":{ + "term":{ + "name.first":"shay" + } + }, + "filter":{ + "and":{ + "filters":[ + { + "term":{ + "name.first":"shay1" + } + }, + { + "term":{ + "name.first":"shay4" + } + } + ], + "_name":"test" + } + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/and-filter.json b/src/test/java/org/elasticsearch/test/unit/index/query/and-filter.json new file mode 100644 index 00000000000..752add1a28a --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/and-filter.json @@ -0,0 +1,25 @@ +{ + "filtered":{ + "query":{ + "term":{ + "name.first":"shay" + } + }, + "filter":{ + "and":{ + "filters":[ + { + "term":{ + "name.first":"shay1" + } + }, + { + "term":{ + "name.first":"shay4" + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/and-filter2.json b/src/test/java/org/elasticsearch/test/unit/index/query/and-filter2.json new file mode 100644 index 00000000000..580b8e95b9b --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/and-filter2.json @@ -0,0 +1,23 @@ +{ + "filtered":{ + "query":{ + "term":{ + "name.first":"shay" + } + }, + "filter":{ + "and":[ + { + "term":{ + "name.first":"shay1" + } + }, + { + "term":{ + "name.first":"shay4" + } + } + ] + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/bool-filter.json b/src/test/java/org/elasticsearch/test/unit/index/query/bool-filter.json new file mode 100644 index 00000000000..484e517fd47 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/bool-filter.json @@ -0,0 +1,35 @@ +{ + filtered:{ + query:{ + term:{ + "name.first":"shay" + } + }, + filter:{ + bool:{ + must:[ + { + term:{ + "name.first":"shay1" + } + }, + { + term:{ + "name.first":"shay4" + } + } + ], + must_not:{ + term:{ + "name.first":"shay2" + } + }, + should:{ + term:{ + "name.first":"shay3" + } + } + } + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/bool.json b/src/test/java/org/elasticsearch/test/unit/index/query/bool.json new file mode 100644 index 00000000000..1619fcf48c8 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/bool.json @@ -0,0 +1,30 @@ +{ + bool:{ + must:[ + { + query_string:{ + default_field:"content", + query:"test1" + } + }, + { + query_string:{ + default_field:"content", + query:"test4" + } + } + ], + must_not:{ + query_string:{ + default_field:"content", + query:"test2" + } + }, + should:{ + query_string:{ + default_field:"content", + query:"test3" + } + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/boosting-query.json b/src/test/java/org/elasticsearch/test/unit/index/query/boosting-query.json new file mode 100644 index 00000000000..87b6e6d158c --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/boosting-query.json @@ -0,0 +1,15 @@ +{ + "boosting":{ + "positive":{ + "term":{ + "field1":"value1" + } + }, + "negative":{ + "term":{ + "field2":"value2" + } + }, + "negative_boost":0.2 + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/constantScore-query.json b/src/test/java/org/elasticsearch/test/unit/index/query/constantScore-query.json new file mode 100644 index 00000000000..bf59bc5b472 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/constantScore-query.json @@ -0,0 +1,9 @@ +{ + constant_score:{ + filter:{ + term:{ + "name.last":"banon" + } + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/custom-boost-factor-query.json b/src/test/java/org/elasticsearch/test/unit/index/query/custom-boost-factor-query.json new file mode 100644 index 00000000000..6f829212fc9 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/custom-boost-factor-query.json @@ -0,0 +1,10 @@ +{ + "custom_boost_factor":{ + "query":{ + "term":{ + "name.last":"banon" + } + }, + "boost_factor":1.3 + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/custom_score1.json b/src/test/java/org/elasticsearch/test/unit/index/query/custom_score1.json new file mode 100644 index 00000000000..6d7dcac1e61 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/custom_score1.json @@ -0,0 +1,10 @@ +{ + "custom_score":{ + "query":{ + "term":{ + "name.last":"banon" + } + }, + "script":"score * doc['name.first']" + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/data.json b/src/test/java/org/elasticsearch/test/unit/index/query/data.json new file mode 100644 index 00000000000..ef942d9c55d --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/data.json @@ -0,0 +1,47 @@ +{ + person:{ + _boost:3.7, + _id:"1", + name:{ + first:"shay", + last:"banon" + }, + address:{ + first:{ + location:"first location" + }, + last:{ + location:"last location" + } + }, + age:32, + birthDate:"1977-11-15", + nerd:true, + dogs:["buck", "mia"], + complex:[ + { + value1:"value1" + }, + { + value2:"value2" + } + ], + complex2:[ + [ + { + value1:"value1" + } + ], + [ + { + value2:"value2" + } + ] + ], + nullValue:null, + "location":{ + "lat":1.1, + "lon":1.2 + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/disMax.json b/src/test/java/org/elasticsearch/test/unit/index/query/disMax.json new file mode 100644 index 00000000000..99da2df0251 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/disMax.json @@ -0,0 +1,18 @@ +{ + dis_max:{ + tie_breaker:0.7, + boost:1.2, + queries:[ + { + term:{ + "name.first":"first" + } + }, + { + term:{ + "name.last":"last" + } + } + ] + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/disMax2.json b/src/test/java/org/elasticsearch/test/unit/index/query/disMax2.json new file mode 100644 index 00000000000..ea92d6498f4 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/disMax2.json @@ -0,0 +1,14 @@ +{ + "dis_max":{ + "queries":[ + { + "prefix":{ + "name.first":{ + "value":"sh", + "boost":1.2 + } + } + } + ] + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/field1.json b/src/test/java/org/elasticsearch/test/unit/index/query/field1.json new file mode 100644 index 00000000000..4fab5eeab44 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/field1.json @@ -0,0 +1,5 @@ +{ + "field":{ + "age":34 + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/field2.json b/src/test/java/org/elasticsearch/test/unit/index/query/field2.json new file mode 100644 index 00000000000..de78420b9e1 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/field2.json @@ -0,0 +1,5 @@ +{ + field:{ + "name.first":"something else" + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/field3.json b/src/test/java/org/elasticsearch/test/unit/index/query/field3.json new file mode 100644 index 00000000000..61e349f7b7f --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/field3.json @@ -0,0 +1,9 @@ +{ + field:{ + age:{ + query:34, + boost:2.0, + enable_position_increments:false + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/filtered-query.json b/src/test/java/org/elasticsearch/test/unit/index/query/filtered-query.json new file mode 100644 index 00000000000..8eea99a135a --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/filtered-query.json @@ -0,0 +1,14 @@ +{ + filtered:{ + query:{ + term:{ + "name.first":"shay" + } + }, + filter:{ + term:{ + "name.last":"banon" + } + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/filtered-query2.json b/src/test/java/org/elasticsearch/test/unit/index/query/filtered-query2.json new file mode 100644 index 00000000000..b23faf4e74a --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/filtered-query2.json @@ -0,0 +1,14 @@ +{ + filtered:{ + filter:{ + term:{ + "name.last":"banon" + } + }, + query:{ + term:{ + "name.first":"shay" + } + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/filtered-query3.json b/src/test/java/org/elasticsearch/test/unit/index/query/filtered-query3.json new file mode 100644 index 00000000000..4a9db4909ab --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/filtered-query3.json @@ -0,0 +1,19 @@ +{ + filtered:{ + filter:{ + range:{ + age:{ + from:"23", + to:"54", + include_lower:true, + include_upper:false + } + } + }, + query:{ + term:{ + "name.first":"shay" + } + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/filtered-query4.json b/src/test/java/org/elasticsearch/test/unit/index/query/filtered-query4.json new file mode 100644 index 00000000000..8c10013f1e4 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/filtered-query4.json @@ -0,0 +1,17 @@ +{ + filtered:{ + query:{ + wildcard:{ + "name.first":{ + wildcard:"sh*", + boost:1.1 + } + } + }, + filter:{ + term:{ + "name.last":"banon" + } + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/fquery-filter.json b/src/test/java/org/elasticsearch/test/unit/index/query/fquery-filter.json new file mode 100644 index 00000000000..60153347747 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/fquery-filter.json @@ -0,0 +1,19 @@ +{ + "filtered":{ + "query":{ + "term":{ + "name.first":"shay" + } + }, + "filter":{ + "fquery":{ + "query":{ + "term":{ + "name.last":"banon" + } + }, + "_name":"test" + } + } + } +} diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/fuzzy-with-fields.json b/src/test/java/org/elasticsearch/test/unit/index/query/fuzzy-with-fields.json new file mode 100644 index 00000000000..6ef343ac454 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/fuzzy-with-fields.json @@ -0,0 +1,10 @@ +{ + "fuzzy":{ + "name.first":{ + "value":"sh", + "min_similarity":0.1, + "prefix_length":1, + "boost":2.0 + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/fuzzy-with-fields2.json b/src/test/java/org/elasticsearch/test/unit/index/query/fuzzy-with-fields2.json new file mode 100644 index 00000000000..371070f66c2 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/fuzzy-with-fields2.json @@ -0,0 +1,9 @@ +{ + "fuzzy":{ + "age":{ + "value":12, + "min_similarity":5, + "boost":2.0 + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/fuzzy.json b/src/test/java/org/elasticsearch/test/unit/index/query/fuzzy.json new file mode 100644 index 00000000000..27d8deebe5a --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/fuzzy.json @@ -0,0 +1,5 @@ +{ + "fuzzy":{ + "name.first":"sh" + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/fuzzyLikeThis.json b/src/test/java/org/elasticsearch/test/unit/index/query/fuzzyLikeThis.json new file mode 100644 index 00000000000..ccd30a98953 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/fuzzyLikeThis.json @@ -0,0 +1,7 @@ +{ + fuzzy_like_this:{ + fields:["name.first", "name.last"], + like_text:"something", + max_query_terms:12 + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/fuzzyLikeThisField.json b/src/test/java/org/elasticsearch/test/unit/index/query/fuzzyLikeThisField.json new file mode 100644 index 00000000000..114ebe5ffda --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/fuzzyLikeThisField.json @@ -0,0 +1,8 @@ +{ + fuzzy_like_this_field:{ + "name.first":{ + like_text:"something", + max_query_terms:12 + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/geo_boundingbox-named.json b/src/test/java/org/elasticsearch/test/unit/index/query/geo_boundingbox-named.json new file mode 100644 index 00000000000..6db6d5aed00 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/geo_boundingbox-named.json @@ -0,0 +1,16 @@ +{ + "filtered":{ + "query":{ + "match_all":{} + }, + "filter":{ + "geo_bounding_box":{ + "location":{ + "top_left":[-70, 40], + "bottom_right":[-80, 30] + }, + "_name":"test" + } + } + } +} diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/geo_boundingbox1.json b/src/test/java/org/elasticsearch/test/unit/index/query/geo_boundingbox1.json new file mode 100644 index 00000000000..8d04915a8a7 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/geo_boundingbox1.json @@ -0,0 +1,15 @@ +{ + "filtered":{ + "query":{ + "match_all":{} + }, + "filter":{ + "geo_bounding_box":{ + "location":{ + "top_left":[-70, 40], + "bottom_right":[-80, 30] + } + } + } + } +} diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/geo_boundingbox2.json b/src/test/java/org/elasticsearch/test/unit/index/query/geo_boundingbox2.json new file mode 100644 index 00000000000..63216544427 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/geo_boundingbox2.json @@ -0,0 +1,21 @@ +{ + "filtered":{ + "query":{ + "match_all":{} + }, + "filter":{ + "geo_bounding_box":{ + "location":{ + "top_left":{ + "lat":40, + "lon":-70 + }, + "bottom_right":{ + "lat":30, + "lon":-80 + } + } + } + } + } +} diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/geo_boundingbox3.json b/src/test/java/org/elasticsearch/test/unit/index/query/geo_boundingbox3.json new file mode 100644 index 00000000000..08999604c7c --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/geo_boundingbox3.json @@ -0,0 +1,15 @@ +{ + "filtered":{ + "query":{ + "match_all":{} + }, + "filter":{ + "geo_bounding_box":{ + "location":{ + "top_left":"40, -70", + "bottom_right":"30, -80" + } + } + } + } +} diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/geo_boundingbox4.json b/src/test/java/org/elasticsearch/test/unit/index/query/geo_boundingbox4.json new file mode 100644 index 00000000000..170a02d3551 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/geo_boundingbox4.json @@ -0,0 +1,15 @@ +{ + "filtered":{ + "query":{ + "match_all":{} + }, + "filter":{ + "geo_bounding_box":{ + "location":{ + "top_left":"drn5x1g8cu2y", + "bottom_right":"30, -80" + } + } + } + } +} diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance-named.json b/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance-named.json new file mode 100644 index 00000000000..a3e0be95492 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance-named.json @@ -0,0 +1,17 @@ +{ + "filtered":{ + "query":{ + "match_all":{} + }, + "filter":{ + "geo_distance":{ + "distance":"12mi", + "location":{ + "lat":40, + "lon":-70 + }, + "_name":"test" + } + } + } +} diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance1.json b/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance1.json new file mode 100644 index 00000000000..cf3b0ab3985 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance1.json @@ -0,0 +1,16 @@ +{ + "filtered":{ + "query":{ + "match_all":{} + }, + "filter":{ + "geo_distance":{ + "distance":"12mi", + "location":{ + "lat":40, + "lon":-70 + } + } + } + } +} diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance10.json b/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance10.json new file mode 100644 index 00000000000..067b39e3411 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance10.json @@ -0,0 +1,17 @@ +{ + "filtered":{ + "query":{ + "match_all":{} + }, + "filter":{ + "geo_distance":{ + "distance":19.312128, + "unit":"km", + "location":{ + "lat":40, + "lon":-70 + } + } + } + } +} diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance11.json b/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance11.json new file mode 100644 index 00000000000..008d5b5b08c --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance11.json @@ -0,0 +1,16 @@ +{ + "filtered":{ + "query":{ + "match_all":{} + }, + "filter":{ + "geo_distance":{ + "distance":"19.312128km", + "location":{ + "lat":40, + "lon":-70 + } + } + } + } +} diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance12.json b/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance12.json new file mode 100644 index 00000000000..8769223d90f --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance12.json @@ -0,0 +1,17 @@ +{ + "filtered":{ + "query":{ + "match_all":{} + }, + "filter":{ + "geo_distance":{ + "distance":"12mi", + "unit":"km", + "location":{ + "lat":40, + "lon":-70 + } + } + } + } +} diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance2.json b/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance2.json new file mode 100644 index 00000000000..32838672cae --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance2.json @@ -0,0 +1,13 @@ +{ + "filtered":{ + "query":{ + "match_all":{} + }, + "filter":{ + "geo_distance":{ + "distance":"12mi", + "location":[-70, 40] + } + } + } +} diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance3.json b/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance3.json new file mode 100644 index 00000000000..193f234fd08 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance3.json @@ -0,0 +1,13 @@ +{ + "filtered":{ + "query":{ + "match_all":{} + }, + "filter":{ + "geo_distance":{ + "distance":"12mi", + "location":"40, -70" + } + } + } +} diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance4.json b/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance4.json new file mode 100644 index 00000000000..56a74095ff7 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance4.json @@ -0,0 +1,13 @@ +{ + "filtered":{ + "query":{ + "match_all":{} + }, + "filter":{ + "geo_distance":{ + "distance":"12mi", + "location":"drn5x1g8cu2y" + } + } + } +} diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance5.json b/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance5.json new file mode 100644 index 00000000000..bea9a3df8a1 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance5.json @@ -0,0 +1,17 @@ +{ + "filtered":{ + "query":{ + "match_all":{} + }, + "filter":{ + "geo_distance":{ + "distance":12, + "unit":"mi", + "location":{ + "lat":40, + "lon":-70 + } + } + } + } +} diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance6.json b/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance6.json new file mode 100644 index 00000000000..4afa128b028 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance6.json @@ -0,0 +1,17 @@ +{ + "filtered":{ + "query":{ + "match_all":{} + }, + "filter":{ + "geo_distance":{ + "distance":"12", + "unit":"mi", + "location":{ + "lat":40, + "lon":-70 + } + } + } + } +} diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance7.json b/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance7.json new file mode 100644 index 00000000000..7fcf8bd0743 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance7.json @@ -0,0 +1,16 @@ +{ + "filtered":{ + "query":{ + "match_all":{} + }, + "filter":{ + "geo_distance":{ + "distance":"19.312128", + "location":{ + "lat":40, + "lon":-70 + } + } + } + } +} diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance8.json b/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance8.json new file mode 100644 index 00000000000..3bafd163ad8 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance8.json @@ -0,0 +1,16 @@ +{ + "filtered":{ + "query":{ + "match_all":{} + }, + "filter":{ + "geo_distance":{ + "distance":19.312128, + "location":{ + "lat":40, + "lon":-70 + } + } + } + } +} diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance9.json b/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance9.json new file mode 100644 index 00000000000..e6c8f120603 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/geo_distance9.json @@ -0,0 +1,17 @@ +{ + "filtered":{ + "query":{ + "match_all":{} + }, + "filter":{ + "geo_distance":{ + "distance":"19.312128", + "unit":"km", + "location":{ + "lat":40, + "lon":-70 + } + } + } + } +} diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/geo_polygon-named.json b/src/test/java/org/elasticsearch/test/unit/index/query/geo_polygon-named.json new file mode 100644 index 00000000000..91256c14d0d --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/geo_polygon-named.json @@ -0,0 +1,19 @@ +{ + "filtered":{ + "query":{ + "match_all":{} + }, + "filter":{ + "geo_polygon":{ + "location":{ + "points":[ + [-70, 40], + [-80, 30], + [-90, 20] + ] + }, + "_name":"test" + } + } + } +} diff --git a/src/test/java/org/elasticsearch/index/query/geo_polygon1.json b/src/test/java/org/elasticsearch/test/unit/index/query/geo_polygon1.json similarity index 50% rename from src/test/java/org/elasticsearch/index/query/geo_polygon1.json rename to src/test/java/org/elasticsearch/test/unit/index/query/geo_polygon1.json index f25bd1fd85d..99ac329b9e9 100644 --- a/src/test/java/org/elasticsearch/index/query/geo_polygon1.json +++ b/src/test/java/org/elasticsearch/test/unit/index/query/geo_polygon1.json @@ -1,12 +1,12 @@ { - "filtered" : { - "query" : { - "match_all" : {} + "filtered":{ + "query":{ + "match_all":{} }, - "filter" : { - "geo_polygon" : { - "location" : { - "points" : [ + "filter":{ + "geo_polygon":{ + "location":{ + "points":[ [-70, 40], [-80, 30], [-90, 20] diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/geo_polygon2.json b/src/test/java/org/elasticsearch/test/unit/index/query/geo_polygon2.json new file mode 100644 index 00000000000..588b22f882e --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/geo_polygon2.json @@ -0,0 +1,27 @@ +{ + "filtered":{ + "query":{ + "match_all":{} + }, + "filter":{ + "geo_polygon":{ + "location":{ + "points":[ + { + "lat":40, + "lon":-70 + }, + { + "lat":30, + "lon":-80 + }, + { + "lat":20, + "lon":-90 + } + ] + } + } + } + } +} diff --git a/src/test/java/org/elasticsearch/index/query/geo_polygon3.json b/src/test/java/org/elasticsearch/test/unit/index/query/geo_polygon3.json similarity index 50% rename from src/test/java/org/elasticsearch/index/query/geo_polygon3.json rename to src/test/java/org/elasticsearch/test/unit/index/query/geo_polygon3.json index 5f7c0236ed9..d6d905b865b 100644 --- a/src/test/java/org/elasticsearch/index/query/geo_polygon3.json +++ b/src/test/java/org/elasticsearch/test/unit/index/query/geo_polygon3.json @@ -1,12 +1,12 @@ { - "filtered" : { - "query" : { - "match_all" : {} + "filtered":{ + "query":{ + "match_all":{} }, - "filter" : { - "geo_polygon" : { - "location" : { - "points" : [ + "filter":{ + "geo_polygon":{ + "location":{ + "points":[ "40, -70", "30, -80", "20, -90" diff --git a/src/test/java/org/elasticsearch/index/query/geo_polygon4.json b/src/test/java/org/elasticsearch/test/unit/index/query/geo_polygon4.json similarity index 51% rename from src/test/java/org/elasticsearch/index/query/geo_polygon4.json rename to src/test/java/org/elasticsearch/test/unit/index/query/geo_polygon4.json index 174b2da3a7d..ae9608d21ca 100644 --- a/src/test/java/org/elasticsearch/index/query/geo_polygon4.json +++ b/src/test/java/org/elasticsearch/test/unit/index/query/geo_polygon4.json @@ -1,12 +1,12 @@ { - "filtered" : { - "query" : { - "match_all" : {} + "filtered":{ + "query":{ + "match_all":{} }, - "filter" : { - "geo_polygon" : { - "location" : { - "points" : [ + "filter":{ + "geo_polygon":{ + "location":{ + "points":[ "drn5x1g8cu2y", "30, -80", "20, -90" diff --git a/src/test/java/org/elasticsearch/index/query/guice/IndexQueryParserModuleTests.java b/src/test/java/org/elasticsearch/test/unit/index/query/guice/IndexQueryParserModuleTests.java similarity index 90% rename from src/test/java/org/elasticsearch/index/query/guice/IndexQueryParserModuleTests.java rename to src/test/java/org/elasticsearch/test/unit/index/query/guice/IndexQueryParserModuleTests.java index 0c850463b9a..a1a3dcc5e68 100644 --- a/src/test/java/org/elasticsearch/index/query/guice/IndexQueryParserModuleTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/query/guice/IndexQueryParserModuleTests.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.query.guice; +package org.elasticsearch.test.unit.index.query.guice; import org.elasticsearch.common.inject.Injector; import org.elasticsearch.common.inject.ModulesBuilder; @@ -37,16 +37,17 @@ import org.elasticsearch.script.ScriptModule; import org.elasticsearch.threadpool.ThreadPoolModule; import org.testng.annotations.Test; -import static org.elasticsearch.common.settings.ImmutableSettings.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class IndexQueryParserModuleTests { - @Test public void testCustomInjection() { + @Test + public void testCustomInjection() { Settings settings = settingsBuilder() .put("index.queryparser.query.my.type", MyJsonQueryParser.class) .put("index.queryparser.query.my.param1", "value1") diff --git a/src/test/java/org/elasticsearch/index/query/guice/MyJsonFilterParser.java b/src/test/java/org/elasticsearch/test/unit/index/query/guice/MyJsonFilterParser.java similarity index 77% rename from src/test/java/org/elasticsearch/index/query/guice/MyJsonFilterParser.java rename to src/test/java/org/elasticsearch/test/unit/index/query/guice/MyJsonFilterParser.java index 82e5853ae41..3dc8fb5929f 100644 --- a/src/test/java/org/elasticsearch/index/query/guice/MyJsonFilterParser.java +++ b/src/test/java/org/elasticsearch/test/unit/index/query/guice/MyJsonFilterParser.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.query.guice; +package org.elasticsearch.test.unit.index.query.guice; import org.apache.lucene.search.Filter; import org.elasticsearch.common.inject.Inject; @@ -33,7 +33,7 @@ import org.elasticsearch.index.settings.IndexSettings; import java.io.IOException; /** - * @author kimchy (Shay Banon) + * */ public class MyJsonFilterParser extends AbstractIndexComponent implements FilterParser { @@ -41,17 +41,20 @@ public class MyJsonFilterParser extends AbstractIndexComponent implements Filter private final Settings settings; - @Inject public MyJsonFilterParser(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public MyJsonFilterParser(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings); this.name = name; this.settings = settings; } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{this.name}; } - @Override public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { return null; } diff --git a/src/test/java/org/elasticsearch/index/query/guice/MyJsonQueryParser.java b/src/test/java/org/elasticsearch/test/unit/index/query/guice/MyJsonQueryParser.java similarity index 77% rename from src/test/java/org/elasticsearch/index/query/guice/MyJsonQueryParser.java rename to src/test/java/org/elasticsearch/test/unit/index/query/guice/MyJsonQueryParser.java index 22d4923e189..71304a12eef 100644 --- a/src/test/java/org/elasticsearch/index/query/guice/MyJsonQueryParser.java +++ b/src/test/java/org/elasticsearch/test/unit/index/query/guice/MyJsonQueryParser.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.query.guice; +package org.elasticsearch.test.unit.index.query.guice; import org.apache.lucene.search.Query; import org.elasticsearch.common.inject.Inject; @@ -33,7 +33,7 @@ import org.elasticsearch.index.settings.IndexSettings; import java.io.IOException; /** - * @author kimchy (Shay Banon) + * */ public class MyJsonQueryParser extends AbstractIndexComponent implements QueryParser { @@ -41,17 +41,20 @@ public class MyJsonQueryParser extends AbstractIndexComponent implements QueryPa private final Settings settings; - @Inject public MyJsonQueryParser(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public MyJsonQueryParser(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings); this.name = name; this.settings = settings; } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{this.name}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { return null; } diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/limit-filter.json b/src/test/java/org/elasticsearch/test/unit/index/query/limit-filter.json new file mode 100644 index 00000000000..549f33178d7 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/limit-filter.json @@ -0,0 +1,14 @@ +{ + "filtered":{ + "filter":{ + "limit":{ + "value":2 + } + }, + "query":{ + "term":{ + "name.first":"shay" + } + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/mapping.json b/src/test/java/org/elasticsearch/test/unit/index/query/mapping.json new file mode 100644 index 00000000000..8d21cc4409f --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/mapping.json @@ -0,0 +1,9 @@ +{ + "person":{ + "properties":{ + "location":{ + "type":"geo_point" + } + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/matchAll.json b/src/test/java/org/elasticsearch/test/unit/index/query/matchAll.json new file mode 100644 index 00000000000..33256469508 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/matchAll.json @@ -0,0 +1,5 @@ +{ + match_all:{ + boost:1.2 + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/mlt.json b/src/test/java/org/elasticsearch/test/unit/index/query/mlt.json new file mode 100644 index 00000000000..3f45bb4bdda --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/mlt.json @@ -0,0 +1,8 @@ +{ + more_like_this:{ + fields:["name.first", "name.last"], + like_text:"something", + min_term_freq:1, + max_query_terms:12 + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/mltField.json b/src/test/java/org/elasticsearch/test/unit/index/query/mltField.json new file mode 100644 index 00000000000..9f9eb591206 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/mltField.json @@ -0,0 +1,9 @@ +{ + more_like_this_field:{ + "name.first":{ + like_text:"something", + min_term_freq:1, + max_query_terms:12 + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/not-filter.json b/src/test/java/org/elasticsearch/test/unit/index/query/not-filter.json new file mode 100644 index 00000000000..42c48d806eb --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/not-filter.json @@ -0,0 +1,18 @@ +{ + "filtered":{ + "query":{ + "term":{ + "name.first":"shay" + } + }, + "filter":{ + "not":{ + "filter":{ + "term":{ + "name.first":"shay1" + } + } + } + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/not-filter2.json b/src/test/java/org/elasticsearch/test/unit/index/query/not-filter2.json new file mode 100644 index 00000000000..6defaff7cdc --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/not-filter2.json @@ -0,0 +1,16 @@ +{ + "filtered":{ + "query":{ + "term":{ + "name.first":"shay" + } + }, + "filter":{ + "not":{ + "term":{ + "name.first":"shay1" + } + } + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/not-filter3.json b/src/test/java/org/elasticsearch/test/unit/index/query/not-filter3.json new file mode 100644 index 00000000000..ab613357cbc --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/not-filter3.json @@ -0,0 +1,16 @@ +{ + "filtered":{ + "filter":{ + "not":{ + "term":{ + "name.first":"shay1" + } + } + }, + "query":{ + "term":{ + "name.first":"shay" + } + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/numeric_range-filter.json b/src/test/java/org/elasticsearch/test/unit/index/query/numeric_range-filter.json new file mode 100644 index 00000000000..fbae8ae322a --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/numeric_range-filter.json @@ -0,0 +1,19 @@ +{ + "filtered":{ + "query":{ + "term":{ + "name.first":"shay" + } + }, + "filter":{ + "numeric_range":{ + "age":{ + "from":"23", + "to":"54", + "include_lower":true, + "include_upper":false + } + } + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/or-filter.json b/src/test/java/org/elasticsearch/test/unit/index/query/or-filter.json new file mode 100644 index 00000000000..b1e73face7e --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/or-filter.json @@ -0,0 +1,25 @@ +{ + "filtered":{ + "query":{ + "term":{ + "name.first":"shay" + } + }, + "filter":{ + "or":{ + "filters":[ + { + "term":{ + "name.first":"shay1" + } + }, + { + "term":{ + "name.first":"shay4" + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/or-filter2.json b/src/test/java/org/elasticsearch/test/unit/index/query/or-filter2.json new file mode 100644 index 00000000000..2c15e9a0828 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/or-filter2.json @@ -0,0 +1,23 @@ +{ + "filtered":{ + "query":{ + "term":{ + "name.first":"shay" + } + }, + "filter":{ + "or":[ + { + "term":{ + "name.first":"shay1" + } + }, + { + "term":{ + "name.first":"shay4" + } + } + ] + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/query/plugin/IndexQueryParserPlugin2Tests.java b/src/test/java/org/elasticsearch/test/unit/index/query/plugin/IndexQueryParserPlugin2Tests.java similarity index 90% rename from src/test/java/org/elasticsearch/index/query/plugin/IndexQueryParserPlugin2Tests.java rename to src/test/java/org/elasticsearch/test/unit/index/query/plugin/IndexQueryParserPlugin2Tests.java index 6b8b89d1f75..fe8fe652603 100644 --- a/src/test/java/org/elasticsearch/index/query/plugin/IndexQueryParserPlugin2Tests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/query/plugin/IndexQueryParserPlugin2Tests.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.query.plugin; +package org.elasticsearch.test.unit.index.query.plugin; import org.elasticsearch.common.inject.Injector; import org.elasticsearch.common.inject.ModulesBuilder; @@ -38,15 +38,16 @@ import org.elasticsearch.script.ScriptModule; import org.elasticsearch.threadpool.ThreadPoolModule; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class IndexQueryParserPlugin2Tests { - @Test public void testCustomInjection() { + @Test + public void testCustomInjection() { Settings settings = ImmutableSettings.Builder.EMPTY_SETTINGS; IndexQueryParserModule queryParserModule = new IndexQueryParserModule(settings); diff --git a/src/test/java/org/elasticsearch/index/query/plugin/IndexQueryParserPluginTests.java b/src/test/java/org/elasticsearch/test/unit/index/query/plugin/IndexQueryParserPluginTests.java similarity index 85% rename from src/test/java/org/elasticsearch/index/query/plugin/IndexQueryParserPluginTests.java rename to src/test/java/org/elasticsearch/test/unit/index/query/plugin/IndexQueryParserPluginTests.java index b888755c021..9601590eff8 100644 --- a/src/test/java/org/elasticsearch/index/query/plugin/IndexQueryParserPluginTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/query/plugin/IndexQueryParserPluginTests.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.query.plugin; +package org.elasticsearch.test.unit.index.query.plugin; import org.elasticsearch.common.inject.Injector; import org.elasticsearch.common.inject.ModulesBuilder; @@ -38,24 +38,27 @@ import org.elasticsearch.script.ScriptModule; import org.elasticsearch.threadpool.ThreadPoolModule; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ public class IndexQueryParserPluginTests { - @Test public void testCustomInjection() { + @Test + public void testCustomInjection() { Settings settings = ImmutableSettings.Builder.EMPTY_SETTINGS; IndexQueryParserModule queryParserModule = new IndexQueryParserModule(settings); queryParserModule.addProcessor(new IndexQueryParserModule.QueryParsersProcessor() { - @Override public void processXContentQueryParsers(XContentQueryParsersBindings bindings) { + @Override + public void processXContentQueryParsers(XContentQueryParsersBindings bindings) { bindings.processXContentQueryParser("my", PluginJsonQueryParser.class); } - @Override public void processXContentFilterParsers(XContentFilterParsersBindings bindings) { + @Override + public void processXContentFilterParsers(XContentFilterParsersBindings bindings) { bindings.processXContentQueryFilter("my", PluginJsonFilterParser.class); } }); diff --git a/src/test/java/org/elasticsearch/index/query/plugin/PluginJsonFilterParser.java b/src/test/java/org/elasticsearch/test/unit/index/query/plugin/PluginJsonFilterParser.java similarity index 77% rename from src/test/java/org/elasticsearch/index/query/plugin/PluginJsonFilterParser.java rename to src/test/java/org/elasticsearch/test/unit/index/query/plugin/PluginJsonFilterParser.java index 1f4ff63da60..9552e2aa870 100644 --- a/src/test/java/org/elasticsearch/index/query/plugin/PluginJsonFilterParser.java +++ b/src/test/java/org/elasticsearch/test/unit/index/query/plugin/PluginJsonFilterParser.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.query.plugin; +package org.elasticsearch.test.unit.index.query.plugin; import org.apache.lucene.search.Filter; import org.elasticsearch.common.inject.Inject; @@ -33,7 +33,7 @@ import org.elasticsearch.index.settings.IndexSettings; import java.io.IOException; /** - * @author kimchy (Shay Banon) + * */ public class PluginJsonFilterParser extends AbstractIndexComponent implements FilterParser { @@ -41,17 +41,20 @@ public class PluginJsonFilterParser extends AbstractIndexComponent implements Fi private final Settings settings; - @Inject public PluginJsonFilterParser(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public PluginJsonFilterParser(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings); this.name = name; this.settings = settings; } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{this.name}; } - @Override public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Filter parse(QueryParseContext parseContext) throws IOException, QueryParsingException { return null; } diff --git a/src/test/java/org/elasticsearch/index/query/plugin/PluginJsonQueryParser.java b/src/test/java/org/elasticsearch/test/unit/index/query/plugin/PluginJsonQueryParser.java similarity index 77% rename from src/test/java/org/elasticsearch/index/query/plugin/PluginJsonQueryParser.java rename to src/test/java/org/elasticsearch/test/unit/index/query/plugin/PluginJsonQueryParser.java index cc32e77db5a..857ee22cd22 100644 --- a/src/test/java/org/elasticsearch/index/query/plugin/PluginJsonQueryParser.java +++ b/src/test/java/org/elasticsearch/test/unit/index/query/plugin/PluginJsonQueryParser.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.query.plugin; +package org.elasticsearch.test.unit.index.query.plugin; import org.apache.lucene.search.Query; import org.elasticsearch.common.inject.Inject; @@ -33,7 +33,7 @@ import org.elasticsearch.index.settings.IndexSettings; import java.io.IOException; /** - * @author kimchy (Shay Banon) + * */ public class PluginJsonQueryParser extends AbstractIndexComponent implements QueryParser { @@ -41,17 +41,20 @@ public class PluginJsonQueryParser extends AbstractIndexComponent implements Que private final Settings settings; - @Inject public PluginJsonQueryParser(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { + @Inject + public PluginJsonQueryParser(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings); this.name = name; this.settings = settings; } - @Override public String[] names() { + @Override + public String[] names() { return new String[]{this.name}; } - @Override public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { + @Override + public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { return null; } diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/prefix-boost.json b/src/test/java/org/elasticsearch/test/unit/index/query/prefix-boost.json new file mode 100644 index 00000000000..4da623ac49f --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/prefix-boost.json @@ -0,0 +1,8 @@ +{ + "prefix":{ + "name.first":{ + "value":"sh", + "boost":1.2 + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/prefix-filter-named.json b/src/test/java/org/elasticsearch/test/unit/index/query/prefix-filter-named.json new file mode 100644 index 00000000000..de0170118ed --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/prefix-filter-named.json @@ -0,0 +1,15 @@ +{ + "filtered":{ + "query":{ + "term":{ + "name.first":"shay" + } + }, + "filter":{ + "prefix":{ + "name.first":"sh", + "_name":"test" + } + } + } +} diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/prefix-filter.json b/src/test/java/org/elasticsearch/test/unit/index/query/prefix-filter.json new file mode 100644 index 00000000000..1f2e42e8e97 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/prefix-filter.json @@ -0,0 +1,14 @@ +{ + "filtered":{ + "query":{ + "term":{ + "name.first":"shay" + } + }, + "filter":{ + "prefix":{ + "name.first":"sh" + } + } + } +} diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/prefix-with-boost.json b/src/test/java/org/elasticsearch/test/unit/index/query/prefix-with-boost.json new file mode 100644 index 00000000000..83e56cb4d5e --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/prefix-with-boost.json @@ -0,0 +1,8 @@ +{ + prefix:{ + "name.first":{ + prefix:"sh", + boost:2.0 + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/prefix.json b/src/test/java/org/elasticsearch/test/unit/index/query/prefix.json new file mode 100644 index 00000000000..49f5261d1d9 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/prefix.json @@ -0,0 +1,5 @@ +{ + prefix:{ + "name.first":"sh" + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/query-fields-match.json b/src/test/java/org/elasticsearch/test/unit/index/query/query-fields-match.json new file mode 100644 index 00000000000..c15cdf3c6d1 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/query-fields-match.json @@ -0,0 +1,7 @@ +{ + query_string:{ + fields:["name.*"], + use_dis_max:false, + query:"test" + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/query-fields1.json b/src/test/java/org/elasticsearch/test/unit/index/query/query-fields1.json new file mode 100644 index 00000000000..84abcaafc05 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/query-fields1.json @@ -0,0 +1,7 @@ +{ + query_string:{ + fields:["content", "name"], + use_dis_max:false, + query:"test" + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/query-fields2.json b/src/test/java/org/elasticsearch/test/unit/index/query/query-fields2.json new file mode 100644 index 00000000000..ab39c8773dd --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/query-fields2.json @@ -0,0 +1,7 @@ +{ + query_string:{ + fields:["content", "name"], + use_dis_max:true, + query:"test" + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/query-fields3.json b/src/test/java/org/elasticsearch/test/unit/index/query/query-fields3.json new file mode 100644 index 00000000000..8114c1b3b86 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/query-fields3.json @@ -0,0 +1,7 @@ +{ + query_string:{ + fields:["content^2.2", "name"], + use_dis_max:true, + query:"test" + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/query-filter.json b/src/test/java/org/elasticsearch/test/unit/index/query/query-filter.json new file mode 100644 index 00000000000..dee136d24c6 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/query-filter.json @@ -0,0 +1,16 @@ +{ + filtered:{ + query:{ + term:{ + "name.first":"shay" + } + }, + filter:{ + query:{ + term:{ + "name.last":"banon" + } + } + } + } +} diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/query.json b/src/test/java/org/elasticsearch/test/unit/index/query/query.json new file mode 100644 index 00000000000..f07a0d8a59a --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/query.json @@ -0,0 +1,7 @@ +{ + query_string:{ + default_field:"content", + phrase_slop:1, + query:"test" + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/query2.json b/src/test/java/org/elasticsearch/test/unit/index/query/query2.json new file mode 100644 index 00000000000..410e05cd808 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/query2.json @@ -0,0 +1,6 @@ +{ + query_string:{ + default_field:"age", + query:"12~0.2" + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/range-filter-named.json b/src/test/java/org/elasticsearch/test/unit/index/query/range-filter-named.json new file mode 100644 index 00000000000..1b50177a522 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/range-filter-named.json @@ -0,0 +1,20 @@ +{ + "filtered":{ + "query":{ + "term":{ + "name.first":"shay" + } + }, + "filter":{ + "range":{ + "age":{ + "from":"23", + "to":"54", + "include_lower":true, + "include_upper":false + }, + "_name":"test" + } + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/range-filter.json b/src/test/java/org/elasticsearch/test/unit/index/query/range-filter.json new file mode 100644 index 00000000000..3842e0be346 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/range-filter.json @@ -0,0 +1,19 @@ +{ + filtered:{ + query:{ + term:{ + "name.first":"shay" + } + }, + filter:{ + range:{ + age:{ + from:"23", + to:"54", + include_lower:true, + include_upper:false + } + } + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/range.json b/src/test/java/org/elasticsearch/test/unit/index/query/range.json new file mode 100644 index 00000000000..cc2363fc22b --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/range.json @@ -0,0 +1,10 @@ +{ + range:{ + age:{ + from:"23", + to:"54", + include_lower:true, + include_upper:false + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/range2.json b/src/test/java/org/elasticsearch/test/unit/index/query/range2.json new file mode 100644 index 00000000000..c116b3c0a33 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/range2.json @@ -0,0 +1,8 @@ +{ + range:{ + age:{ + gte:"23", + lt:"54" + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/spanFirst.json b/src/test/java/org/elasticsearch/test/unit/index/query/spanFirst.json new file mode 100644 index 00000000000..9972c769137 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/spanFirst.json @@ -0,0 +1,10 @@ +{ + span_first:{ + match:{ + span_term:{ + age:34 + } + }, + end:12 + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/spanNear.json b/src/test/java/org/elasticsearch/test/unit/index/query/spanNear.json new file mode 100644 index 00000000000..ce17063978a --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/spanNear.json @@ -0,0 +1,24 @@ +{ + span_near:{ + clauses:[ + { + span_term:{ + age:34 + } + }, + { + span_term:{ + age:35 + } + }, + { + span_term:{ + age:36 + } + } + ], + slop:12, + in_order:false, + collect_payloads:false + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/spanNot.json b/src/test/java/org/elasticsearch/test/unit/index/query/spanNot.json new file mode 100644 index 00000000000..c90de330df7 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/spanNot.json @@ -0,0 +1,14 @@ +{ + span_not:{ + include:{ + span_term:{ + age:34 + } + }, + exclude:{ + span_term:{ + age:35 + } + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/spanOr.json b/src/test/java/org/elasticsearch/test/unit/index/query/spanOr.json new file mode 100644 index 00000000000..06c52628e5f --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/spanOr.json @@ -0,0 +1,21 @@ +{ + span_or:{ + clauses:[ + { + span_term:{ + age:34 + } + }, + { + span_term:{ + age:35 + } + }, + { + span_term:{ + age:36 + } + } + ] + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/spanOr2.json b/src/test/java/org/elasticsearch/test/unit/index/query/spanOr2.json new file mode 100644 index 00000000000..b64ce1cae3f --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/spanOr2.json @@ -0,0 +1,30 @@ +{ + "span_or":{ + "clauses":[ + { + "span_term":{ + "age":{ + "value":34, + "boost":1.0 + } + } + }, + { + "span_term":{ + "age":{ + "value":35, + "boost":1.0 + } + } + }, + { + "span_term":{ + "age":{ + "value":36, + "boost":1.0 + } + } + } + ] + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/spanTerm.json b/src/test/java/org/elasticsearch/test/unit/index/query/spanTerm.json new file mode 100644 index 00000000000..0186593ff58 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/spanTerm.json @@ -0,0 +1,5 @@ +{ + span_term:{ + age:34 + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/term-filter-named.json b/src/test/java/org/elasticsearch/test/unit/index/query/term-filter-named.json new file mode 100644 index 00000000000..c23b7b382e9 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/term-filter-named.json @@ -0,0 +1,15 @@ +{ + "filtered":{ + "query":{ + "term":{ + "name.first":"shay" + } + }, + "filter":{ + "term":{ + "name.last":"banon", + "_name":"test" + } + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/term-filter.json b/src/test/java/org/elasticsearch/test/unit/index/query/term-filter.json new file mode 100644 index 00000000000..11d2bfdd8da --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/term-filter.json @@ -0,0 +1,14 @@ +{ + "filtered":{ + "query":{ + "term":{ + "name.first":"shay" + } + }, + "filter":{ + "term":{ + "name.last":"banon" + } + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/term-with-boost.json b/src/test/java/org/elasticsearch/test/unit/index/query/term-with-boost.json new file mode 100644 index 00000000000..5f33cd55ea3 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/term-with-boost.json @@ -0,0 +1,8 @@ +{ + term:{ + age:{ + value:34, + boost:2.0 + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/term.json b/src/test/java/org/elasticsearch/test/unit/index/query/term.json new file mode 100644 index 00000000000..378cf42f04c --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/term.json @@ -0,0 +1,5 @@ +{ + term:{ + age:34 + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/terms-filter-named.json b/src/test/java/org/elasticsearch/test/unit/index/query/terms-filter-named.json new file mode 100644 index 00000000000..2cb8c7aab1a --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/terms-filter-named.json @@ -0,0 +1,15 @@ +{ + "filtered":{ + "query":{ + "term":{ + "name.first":"shay" + } + }, + "filter":{ + "terms":{ + "name.last":["banon", "kimchy"], + "_name":"test" + } + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/terms-filter.json b/src/test/java/org/elasticsearch/test/unit/index/query/terms-filter.json new file mode 100644 index 00000000000..04a8d26f41d --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/terms-filter.json @@ -0,0 +1,14 @@ +{ + "filtered":{ + "query":{ + "term":{ + "name.first":"shay" + } + }, + "filter":{ + "terms":{ + "name.last":["banon", "kimchy"] + } + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/terms-query.json b/src/test/java/org/elasticsearch/test/unit/index/query/terms-query.json new file mode 100644 index 00000000000..a3e0d084ad2 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/terms-query.json @@ -0,0 +1,5 @@ +{ + "terms":{ + "name.first":["shay", "test"] + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/text1.json b/src/test/java/org/elasticsearch/test/unit/index/query/text1.json new file mode 100644 index 00000000000..454cd4d3a60 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/text1.json @@ -0,0 +1,5 @@ +{ + "text":{ + "name.first":"aaa bbb" + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/text2.json b/src/test/java/org/elasticsearch/test/unit/index/query/text2.json new file mode 100644 index 00000000000..36517c4ce19 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/text2.json @@ -0,0 +1,8 @@ +{ + "text":{ + "name.first":{ + "query":"aaa bbb", + "boost":1.5 + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/text3.json b/src/test/java/org/elasticsearch/test/unit/index/query/text3.json new file mode 100644 index 00000000000..ebead81547e --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/text3.json @@ -0,0 +1,8 @@ +{ + "text":{ + "name.first":{ + "query":"aaa bbb", + "type":"phrase" + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/text4.json b/src/test/java/org/elasticsearch/test/unit/index/query/text4.json new file mode 100644 index 00000000000..f95fc9caeaf --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/text4.json @@ -0,0 +1,8 @@ +{ + "text":{ + "name.first":{ + "query":"aaa bbb", + "type":"phrase_prefix" + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/text4_2.json b/src/test/java/org/elasticsearch/test/unit/index/query/text4_2.json new file mode 100644 index 00000000000..ae947e400f0 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/text4_2.json @@ -0,0 +1,7 @@ +{ + "text_phrase_prefix":{ + "name.first":{ + "query":"aaa bbb" + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/wildcard-boost.json b/src/test/java/org/elasticsearch/test/unit/index/query/wildcard-boost.json new file mode 100644 index 00000000000..53c8d82a8d4 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/wildcard-boost.json @@ -0,0 +1,8 @@ +{ + "wildcard":{ + "name.first":{ + "value":"sh*", + "boost":1.2 + } + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/wildcard.json b/src/test/java/org/elasticsearch/test/unit/index/query/wildcard.json new file mode 100644 index 00000000000..c8ed85262bd --- /dev/null +++ b/src/test/java/org/elasticsearch/test/unit/index/query/wildcard.json @@ -0,0 +1,5 @@ +{ + wildcard:{ + "name.first":"sh*" + } +} \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/index/search/geo/GeoDistanceTests.java b/src/test/java/org/elasticsearch/test/unit/index/search/geo/GeoDistanceTests.java similarity index 84% rename from src/test/java/org/elasticsearch/index/search/geo/GeoDistanceTests.java rename to src/test/java/org/elasticsearch/test/unit/index/search/geo/GeoDistanceTests.java index 511940a8cf6..3783357c3fe 100644 --- a/src/test/java/org/elasticsearch/index/search/geo/GeoDistanceTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/search/geo/GeoDistanceTests.java @@ -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 @@ -17,20 +17,22 @@ * under the License. */ -package org.elasticsearch.index.search.geo; +package org.elasticsearch.test.unit.index.search.geo; import org.elasticsearch.common.unit.DistanceUnit; +import org.elasticsearch.index.search.geo.GeoDistance; import org.testng.annotations.Test; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** */ @Test public class GeoDistanceTests { - @Test public void testDistanceCheck() { + @Test + public void testDistanceCheck() { // Note, is within is an approximation, so, even though 0.52 is outside 50mi, we still get "true" GeoDistance.DistanceBoundingCheck check = GeoDistance.distanceBoundingCheck(0, 0, 50, DistanceUnit.MILES); //System.out.println("Dist: " + GeoDistance.ARC.calculate(0, 0, 0.5, 0.5, DistanceUnit.MILES)); diff --git a/src/test/java/org/elasticsearch/index/search/geo/GeoHashUtilsTests.java b/src/test/java/org/elasticsearch/test/unit/index/search/geo/GeoHashUtilsTests.java similarity index 91% rename from src/test/java/org/elasticsearch/index/search/geo/GeoHashUtilsTests.java rename to src/test/java/org/elasticsearch/test/unit/index/search/geo/GeoHashUtilsTests.java index 880c9f7e914..41920b03947 100644 --- a/src/test/java/org/elasticsearch/index/search/geo/GeoHashUtilsTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/search/geo/GeoHashUtilsTests.java @@ -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 @@ -17,14 +17,15 @@ * under the License. */ -package org.elasticsearch.index.search.geo; +package org.elasticsearch.test.unit.index.search.geo; +import org.elasticsearch.index.search.geo.GeoHashUtils; import org.testng.annotations.Test; -import static org.testng.Assert.*; +import static org.testng.Assert.assertEquals; /** - * @author kimchy (shay.banon) + * */ public class GeoHashUtilsTests { diff --git a/src/test/java/org/elasticsearch/index/store/memory/SimpleByteBufferStoreTests.java b/src/test/java/org/elasticsearch/test/unit/index/store/memory/SimpleByteBufferStoreTests.java similarity index 88% rename from src/test/java/org/elasticsearch/index/store/memory/SimpleByteBufferStoreTests.java rename to src/test/java/org/elasticsearch/test/unit/index/store/memory/SimpleByteBufferStoreTests.java index cb63de52286..88ef0f53989 100644 --- a/src/test/java/org/elasticsearch/index/store/memory/SimpleByteBufferStoreTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/store/memory/SimpleByteBufferStoreTests.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.store.memory; +package org.elasticsearch.test.unit.index.store.memory; import org.apache.lucene.store.IndexInput; import org.apache.lucene.store.IndexOutput; @@ -29,15 +29,16 @@ import org.testng.annotations.Test; import java.io.IOException; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy + * */ public class SimpleByteBufferStoreTests { - @Test public void test1BufferNoCache() throws Exception { + @Test + public void test1BufferNoCache() throws Exception { ByteBufferCache cache = new ByteBufferCache(1, 0, true); ByteBufferDirectory dir = new ByteBufferDirectory(cache); insertData(dir, 1); @@ -46,7 +47,8 @@ public class SimpleByteBufferStoreTests { cache.close(); } - @Test public void test1Buffer() throws Exception { + @Test + public void test1Buffer() throws Exception { ByteBufferCache cache = new ByteBufferCache(1, 10, true); ByteBufferDirectory dir = new ByteBufferDirectory(cache); insertData(dir, 1); @@ -55,7 +57,8 @@ public class SimpleByteBufferStoreTests { cache.close(); } - @Test public void test3Buffer() throws Exception { + @Test + public void test3Buffer() throws Exception { ByteBufferCache cache = new ByteBufferCache(3, 10, true); ByteBufferDirectory dir = new ByteBufferDirectory(cache); insertData(dir, 3); @@ -64,7 +67,8 @@ public class SimpleByteBufferStoreTests { cache.close(); } - @Test public void test10Buffer() throws Exception { + @Test + public void test10Buffer() throws Exception { ByteBufferCache cache = new ByteBufferCache(10, 20, true); ByteBufferDirectory dir = new ByteBufferDirectory(cache); insertData(dir, 10); @@ -73,7 +77,8 @@ public class SimpleByteBufferStoreTests { cache.close(); } - @Test public void test15Buffer() throws Exception { + @Test + public void test15Buffer() throws Exception { ByteBufferCache cache = new ByteBufferCache(15, 30, true); ByteBufferDirectory dir = new ByteBufferDirectory(cache); insertData(dir, 15); @@ -82,7 +87,8 @@ public class SimpleByteBufferStoreTests { cache.close(); } - @Test public void test40Buffer() throws Exception { + @Test + public void test40Buffer() throws Exception { ByteBufferCache cache = new ByteBufferCache(40, 80, true); ByteBufferDirectory dir = new ByteBufferDirectory(cache); insertData(dir, 40); @@ -91,7 +97,8 @@ public class SimpleByteBufferStoreTests { cache.close(); } - @Test public void testSimpleLocking() throws Exception { + @Test + public void testSimpleLocking() throws Exception { ByteBufferCache cache = new ByteBufferCache(40, 80, true); ByteBufferDirectory dir = new ByteBufferDirectory(cache); diff --git a/src/test/java/org/elasticsearch/index/translog/AbstractSimpleTranslogTests.java b/src/test/java/org/elasticsearch/test/unit/index/translog/AbstractSimpleTranslogTests.java similarity index 75% rename from src/test/java/org/elasticsearch/index/translog/AbstractSimpleTranslogTests.java rename to src/test/java/org/elasticsearch/test/unit/index/translog/AbstractSimpleTranslogTests.java index cd9d6dcc9e3..e36ac7aec50 100644 --- a/src/test/java/org/elasticsearch/index/translog/AbstractSimpleTranslogTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/translog/AbstractSimpleTranslogTests.java @@ -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 @@ -17,22 +17,23 @@ * under the License. */ -package org.elasticsearch.index.translog; +package org.elasticsearch.test.unit.index.translog; import org.apache.lucene.index.Term; import org.elasticsearch.index.Index; import org.elasticsearch.index.shard.ShardId; +import org.elasticsearch.index.translog.Translog; +import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import static org.elasticsearch.index.translog.TranslogSizeMatcher.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (Shay Banon) + * */ public abstract class AbstractSimpleTranslogTests { @@ -40,75 +41,79 @@ public abstract class AbstractSimpleTranslogTests { protected Translog translog; - @BeforeMethod public void setUp() { + @BeforeMethod + public void setUp() { translog = create(); translog.newTranslog(1); } - @AfterMethod public void tearDown() { + @AfterMethod + public void tearDown() { translog.close(true); } protected abstract Translog create(); - @Test public void testTransientTranslog() { + @Test + public void testTransientTranslog() { Translog.Snapshot snapshot = translog.snapshot(); - assertThat(snapshot, translogSize(0)); + MatcherAssert.assertThat(snapshot, TranslogSizeMatcher.translogSize(0)); snapshot.release(); translog.add(new Translog.Create("test", "1", new byte[]{1})); snapshot = translog.snapshot(); - assertThat(snapshot, translogSize(1)); + MatcherAssert.assertThat(snapshot, TranslogSizeMatcher.translogSize(1)); assertThat(snapshot.estimatedTotalOperations(), equalTo(1)); snapshot.release(); translog.newTransientTranslog(2); snapshot = translog.snapshot(); - assertThat(snapshot, translogSize(1)); + MatcherAssert.assertThat(snapshot, TranslogSizeMatcher.translogSize(1)); assertThat(snapshot.estimatedTotalOperations(), equalTo(1)); snapshot.release(); translog.add(new Translog.Index("test", "2", new byte[]{2})); snapshot = translog.snapshot(); - assertThat(snapshot, translogSize(2)); + MatcherAssert.assertThat(snapshot, TranslogSizeMatcher.translogSize(2)); assertThat(snapshot.estimatedTotalOperations(), equalTo(2)); snapshot.release(); translog.makeTransientCurrent(); snapshot = translog.snapshot(); - assertThat(snapshot, translogSize(1)); // now its one, since it only includes "2" + MatcherAssert.assertThat(snapshot, TranslogSizeMatcher.translogSize(1)); // now its one, since it only includes "2" assertThat(snapshot.estimatedTotalOperations(), equalTo(1)); snapshot.release(); } - @Test public void testSimpleOperations() { + @Test + public void testSimpleOperations() { Translog.Snapshot snapshot = translog.snapshot(); - assertThat(snapshot, translogSize(0)); + MatcherAssert.assertThat(snapshot, TranslogSizeMatcher.translogSize(0)); snapshot.release(); translog.add(new Translog.Create("test", "1", new byte[]{1})); snapshot = translog.snapshot(); - assertThat(snapshot, translogSize(1)); + MatcherAssert.assertThat(snapshot, TranslogSizeMatcher.translogSize(1)); assertThat(snapshot.estimatedTotalOperations(), equalTo(1)); snapshot.release(); translog.add(new Translog.Index("test", "2", new byte[]{2})); snapshot = translog.snapshot(); - assertThat(snapshot, translogSize(2)); + MatcherAssert.assertThat(snapshot, TranslogSizeMatcher.translogSize(2)); assertThat(snapshot.estimatedTotalOperations(), equalTo(2)); snapshot.release(); translog.add(new Translog.Delete(newUid("3"))); snapshot = translog.snapshot(); - assertThat(snapshot, translogSize(3)); + MatcherAssert.assertThat(snapshot, TranslogSizeMatcher.translogSize(3)); assertThat(snapshot.estimatedTotalOperations(), equalTo(3)); snapshot.release(); translog.add(new Translog.DeleteByQuery(new byte[]{4}, null)); snapshot = translog.snapshot(); - assertThat(snapshot, translogSize(4)); + MatcherAssert.assertThat(snapshot, TranslogSizeMatcher.translogSize(4)); assertThat(snapshot.estimatedTotalOperations(), equalTo(4)); snapshot.release(); @@ -139,19 +144,20 @@ public abstract class AbstractSimpleTranslogTests { assertThat(translog.currentId(), Matchers.not(equalTo(firstId))); snapshot = translog.snapshot(); - assertThat(snapshot, translogSize(0)); + MatcherAssert.assertThat(snapshot, TranslogSizeMatcher.translogSize(0)); assertThat(snapshot.estimatedTotalOperations(), equalTo(0)); snapshot.release(); } - @Test public void testSnapshot() { + @Test + public void testSnapshot() { Translog.Snapshot snapshot = translog.snapshot(); - assertThat(snapshot, translogSize(0)); + MatcherAssert.assertThat(snapshot, TranslogSizeMatcher.translogSize(0)); snapshot.release(); translog.add(new Translog.Create("test", "1", new byte[]{1})); snapshot = translog.snapshot(); - assertThat(snapshot, translogSize(1)); + MatcherAssert.assertThat(snapshot, TranslogSizeMatcher.translogSize(1)); assertThat(snapshot.estimatedTotalOperations(), equalTo(1)); snapshot.release(); @@ -164,12 +170,12 @@ public abstract class AbstractSimpleTranslogTests { Translog.Snapshot snapshot1 = translog.snapshot(); // we use the translogSize to also navigate to the last position on this snapshot // so snapshot(Snapshot) will work properly - assertThat(snapshot1, translogSize(1)); + MatcherAssert.assertThat(snapshot1, TranslogSizeMatcher.translogSize(1)); assertThat(snapshot1.estimatedTotalOperations(), equalTo(1)); translog.add(new Translog.Index("test", "2", new byte[]{2})); snapshot = translog.snapshot(snapshot1); - assertThat(snapshot, translogSize(1)); + MatcherAssert.assertThat(snapshot, TranslogSizeMatcher.translogSize(1)); assertThat(snapshot.estimatedTotalOperations(), equalTo(2)); snapshot.release(); @@ -183,9 +189,10 @@ public abstract class AbstractSimpleTranslogTests { snapshot1.release(); } - @Test public void testSnapshotWithNewTranslog() { + @Test + public void testSnapshotWithNewTranslog() { Translog.Snapshot snapshot = translog.snapshot(); - assertThat(snapshot, translogSize(0)); + MatcherAssert.assertThat(snapshot, TranslogSizeMatcher.translogSize(0)); snapshot.release(); translog.add(new Translog.Create("test", "1", new byte[]{1})); @@ -198,7 +205,7 @@ public abstract class AbstractSimpleTranslogTests { translog.add(new Translog.Index("test", "3", new byte[]{3})); snapshot = translog.snapshot(actualSnapshot); - assertThat(snapshot, translogSize(1)); + MatcherAssert.assertThat(snapshot, TranslogSizeMatcher.translogSize(1)); snapshot.release(); snapshot = translog.snapshot(actualSnapshot); @@ -211,21 +218,22 @@ public abstract class AbstractSimpleTranslogTests { snapshot.release(); } - @Test public void testSnapshotWithSeekForward() { + @Test + public void testSnapshotWithSeekForward() { Translog.Snapshot snapshot = translog.snapshot(); - assertThat(snapshot, translogSize(0)); + MatcherAssert.assertThat(snapshot, TranslogSizeMatcher.translogSize(0)); snapshot.release(); translog.add(new Translog.Create("test", "1", new byte[]{1})); snapshot = translog.snapshot(); - assertThat(snapshot, translogSize(1)); + MatcherAssert.assertThat(snapshot, TranslogSizeMatcher.translogSize(1)); long lastPosition = snapshot.position(); snapshot.release(); translog.add(new Translog.Create("test", "2", new byte[]{1})); snapshot = translog.snapshot(); snapshot.seekForward(lastPosition); - assertThat(snapshot, translogSize(1)); + MatcherAssert.assertThat(snapshot, TranslogSizeMatcher.translogSize(1)); snapshot.release(); snapshot = translog.snapshot(); diff --git a/src/test/java/org/elasticsearch/index/translog/TranslogSizeMatcher.java b/src/test/java/org/elasticsearch/test/unit/index/translog/TranslogSizeMatcher.java similarity index 78% rename from src/test/java/org/elasticsearch/index/translog/TranslogSizeMatcher.java rename to src/test/java/org/elasticsearch/test/unit/index/translog/TranslogSizeMatcher.java index 30205d76758..6276d28729d 100644 --- a/src/test/java/org/elasticsearch/index/translog/TranslogSizeMatcher.java +++ b/src/test/java/org/elasticsearch/test/unit/index/translog/TranslogSizeMatcher.java @@ -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 @@ -17,14 +17,15 @@ * under the License. */ -package org.elasticsearch.index.translog; +package org.elasticsearch.test.unit.index.translog; +import org.elasticsearch.index.translog.Translog; import org.hamcrest.Description; import org.hamcrest.Matcher; import org.hamcrest.TypeSafeMatcher; /** - * @author kimchy (Shay Banon) + * */ public class TranslogSizeMatcher extends TypeSafeMatcher { @@ -34,7 +35,8 @@ public class TranslogSizeMatcher extends TypeSafeMatcher { this.size = size; } - @Override public boolean matchesSafely(Translog.Snapshot snapshot) { + @Override + public boolean matchesSafely(Translog.Snapshot snapshot) { int count = 0; while (snapshot.hasNext()) { snapshot.next(); @@ -43,7 +45,8 @@ public class TranslogSizeMatcher extends TypeSafeMatcher { return size == count; } - @Override public void describeTo(Description description) { + @Override + public void describeTo(Description description) { description.appendText("a translog with size ").appendValue(size); } diff --git a/src/test/java/org/elasticsearch/index/translog/fs/FsChannelSimpleTranslogTests.java b/src/test/java/org/elasticsearch/test/unit/index/translog/fs/FsChannelSimpleTranslogTests.java similarity index 73% rename from src/test/java/org/elasticsearch/index/translog/fs/FsChannelSimpleTranslogTests.java rename to src/test/java/org/elasticsearch/test/unit/index/translog/fs/FsChannelSimpleTranslogTests.java index 80b743f3c72..cada35c8d19 100644 --- a/src/test/java/org/elasticsearch/index/translog/fs/FsChannelSimpleTranslogTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/translog/fs/FsChannelSimpleTranslogTests.java @@ -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 @@ -17,27 +17,30 @@ * under the License. */ -package org.elasticsearch.index.translog.fs; +package org.elasticsearch.test.unit.index.translog.fs; import org.elasticsearch.common.io.FileSystemUtils; -import org.elasticsearch.index.translog.AbstractSimpleTranslogTests; +import org.elasticsearch.test.unit.index.translog.AbstractSimpleTranslogTests; import org.elasticsearch.index.translog.Translog; +import org.elasticsearch.index.translog.fs.FsTranslog; import org.testng.annotations.AfterClass; import java.io.File; -import static org.elasticsearch.common.settings.ImmutableSettings.Builder.*; +import static org.elasticsearch.common.settings.ImmutableSettings.Builder.EMPTY_SETTINGS; /** - * @author kimchy (shay.banon) + * */ public class FsChannelSimpleTranslogTests extends AbstractSimpleTranslogTests { - @Override protected Translog create() { + @Override + protected Translog create() { return new FsTranslog(shardId, EMPTY_SETTINGS, new File("work/fs-translog")); } - @AfterClass public void cleanup() { + @AfterClass + public void cleanup() { FileSystemUtils.deleteRecursively(new File("work/fs-translog"), true); } } diff --git a/src/test/java/org/elasticsearch/rest/util/RestUtilsTests.java b/src/test/java/org/elasticsearch/test/unit/rest/util/RestUtilsTests.java similarity index 92% rename from src/test/java/org/elasticsearch/rest/util/RestUtilsTests.java rename to src/test/java/org/elasticsearch/test/unit/rest/util/RestUtilsTests.java index 84414b93a12..3fa38a6e3f8 100644 --- a/src/test/java/org/elasticsearch/rest/util/RestUtilsTests.java +++ b/src/test/java/org/elasticsearch/test/unit/rest/util/RestUtilsTests.java @@ -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 @@ -17,19 +17,19 @@ * under the License. */ -package org.elasticsearch.rest.util; +package org.elasticsearch.test.unit.rest.util; import org.elasticsearch.rest.support.RestUtils; import org.testng.annotations.Test; import java.util.Map; -import static org.elasticsearch.common.collect.Maps.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static com.google.common.collect.Maps.newHashMap; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; /** - * @author kimchy (shay.banon) + * */ @Test public class RestUtilsTests { diff --git a/src/test/java/org/elasticsearch/script/NativeScriptTests.java b/src/test/java/org/elasticsearch/test/unit/script/NativeScriptTests.java similarity index 79% rename from src/test/java/org/elasticsearch/script/NativeScriptTests.java rename to src/test/java/org/elasticsearch/test/unit/script/NativeScriptTests.java index bf0fbaa85a9..3fe61c3ae28 100644 --- a/src/test/java/org/elasticsearch/script/NativeScriptTests.java +++ b/src/test/java/org/elasticsearch/test/unit/script/NativeScriptTests.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.script; +package org.elasticsearch.test.unit.script; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.inject.Injector; @@ -25,16 +25,18 @@ import org.elasticsearch.common.inject.ModulesBuilder; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.SettingsModule; +import org.elasticsearch.script.*; import org.testng.annotations.Test; import java.util.Map; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; public class NativeScriptTests { - @Test public void testNativeScript() { + @Test + public void testNativeScript() { Settings settings = ImmutableSettings.settingsBuilder() .put("script.native.my.type", MyNativeScriptFactory.class.getName()) .build(); @@ -49,13 +51,15 @@ public class NativeScriptTests { } static class MyNativeScriptFactory implements NativeScriptFactory { - @Override public ExecutableScript newScript(@Nullable Map params) { + @Override + public ExecutableScript newScript(@Nullable Map params) { return new MyScript(); } } static class MyScript extends AbstractExecutableScript { - @Override public Object run() { + @Override + public Object run() { return "test"; } } diff --git a/src/test/java/org/elasticsearch/transport/AbstractSimpleTransportTests.java b/src/test/java/org/elasticsearch/test/unit/transport/AbstractSimpleTransportTests.java similarity index 58% rename from src/test/java/org/elasticsearch/transport/AbstractSimpleTransportTests.java rename to src/test/java/org/elasticsearch/test/unit/transport/AbstractSimpleTransportTests.java index 942b1ee297b..d120dad5e8a 100644 --- a/src/test/java/org/elasticsearch/transport/AbstractSimpleTransportTests.java +++ b/src/test/java/org/elasticsearch/test/unit/transport/AbstractSimpleTransportTests.java @@ -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 @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.transport; +package org.elasticsearch.test.unit.transport; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.io.stream.StreamInput; @@ -26,6 +26,7 @@ import org.elasticsearch.common.io.stream.Streamable; import org.elasticsearch.common.io.stream.VoidStreamable; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.threadpool.ThreadPool; +import org.elasticsearch.transport.*; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -34,12 +35,12 @@ import java.io.IOException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import static org.elasticsearch.transport.TransportRequestOptions.*; -import static org.hamcrest.MatcherAssert.*; +import static org.elasticsearch.transport.TransportRequestOptions.options; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** - * @author kimchy (shay.banon) + * */ public abstract class AbstractSimpleTransportTests { @@ -50,14 +51,16 @@ public abstract class AbstractSimpleTransportTests { protected DiscoveryNode serviceANode; protected DiscoveryNode serviceBNode; - @BeforeMethod public void setUp() { + @BeforeMethod + public void setUp() { threadPool = new ThreadPool(); build(); serviceA.connectToNode(serviceBNode); serviceB.connectToNode(serviceANode); } - @AfterMethod public void tearDown() { + @AfterMethod + public void tearDown() { serviceA.close(); serviceB.close(); @@ -66,17 +69,21 @@ public abstract class AbstractSimpleTransportTests { protected abstract void build(); - @Test public void testHelloWorld() { + @Test + public void testHelloWorld() { serviceA.registerHandler("sayHello", new BaseTransportRequestHandler() { - @Override public StringMessage newInstance() { + @Override + public StringMessage newInstance() { return new StringMessage(); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.CACHED; } - @Override public void messageReceived(StringMessage request, TransportChannel channel) { + @Override + public void messageReceived(StringMessage request, TransportChannel channel) { assertThat("moshe", equalTo(request.message)); try { channel.sendResponse(new StringMessage("hello " + request.message)); @@ -89,23 +96,27 @@ public abstract class AbstractSimpleTransportTests { TransportFuture res = serviceB.submitRequest(serviceANode, "sayHello", new StringMessage("moshe"), new BaseTransportResponseHandler() { - @Override public StringMessage newInstance() { - return new StringMessage(); - } + @Override + public StringMessage newInstance() { + return new StringMessage(); + } - @Override public String executor() { - return ThreadPool.Names.CACHED; - } + @Override + public String executor() { + return ThreadPool.Names.CACHED; + } - @Override public void handleResponse(StringMessage response) { - assertThat("hello moshe", equalTo(response.message)); - } + @Override + public void handleResponse(StringMessage response) { + assertThat("hello moshe", equalTo(response.message)); + } - @Override public void handleException(TransportException exp) { - exp.printStackTrace(); - assertThat("got exception instead of a response: " + exp.getMessage(), false, equalTo(true)); - } - }); + @Override + public void handleException(TransportException exp) { + exp.printStackTrace(); + assertThat("got exception instead of a response: " + exp.getMessage(), false, equalTo(true)); + } + }); try { StringMessage message = res.get(); @@ -117,17 +128,21 @@ public abstract class AbstractSimpleTransportTests { serviceA.removeHandler("sayHello"); } - @Test public void testVoidMessageCompressed() { + @Test + public void testVoidMessageCompressed() { serviceA.registerHandler("sayHello", new BaseTransportRequestHandler() { - @Override public VoidStreamable newInstance() { + @Override + public VoidStreamable newInstance() { return VoidStreamable.INSTANCE; } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.CACHED; } - @Override public void messageReceived(VoidStreamable request, TransportChannel channel) { + @Override + public void messageReceived(VoidStreamable request, TransportChannel channel) { try { channel.sendResponse(VoidStreamable.INSTANCE, TransportResponseOptions.options().withCompress(true)); } catch (IOException e) { @@ -139,22 +154,26 @@ public abstract class AbstractSimpleTransportTests { TransportFuture res = serviceB.submitRequest(serviceANode, "sayHello", VoidStreamable.INSTANCE, TransportRequestOptions.options().withCompress(true), new BaseTransportResponseHandler() { - @Override public VoidStreamable newInstance() { - return VoidStreamable.INSTANCE; - } + @Override + public VoidStreamable newInstance() { + return VoidStreamable.INSTANCE; + } - @Override public String executor() { - return ThreadPool.Names.CACHED; - } + @Override + public String executor() { + return ThreadPool.Names.CACHED; + } - @Override public void handleResponse(VoidStreamable response) { - } + @Override + public void handleResponse(VoidStreamable response) { + } - @Override public void handleException(TransportException exp) { - exp.printStackTrace(); - assertThat("got exception instead of a response: " + exp.getMessage(), false, equalTo(true)); - } - }); + @Override + public void handleException(TransportException exp) { + exp.printStackTrace(); + assertThat("got exception instead of a response: " + exp.getMessage(), false, equalTo(true)); + } + }); try { VoidStreamable message = res.get(); @@ -166,17 +185,21 @@ public abstract class AbstractSimpleTransportTests { serviceA.removeHandler("sayHello"); } - @Test public void testHelloWorldCompressed() { + @Test + public void testHelloWorldCompressed() { serviceA.registerHandler("sayHello", new BaseTransportRequestHandler() { - @Override public StringMessage newInstance() { + @Override + public StringMessage newInstance() { return new StringMessage(); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.CACHED; } - @Override public void messageReceived(StringMessage request, TransportChannel channel) { + @Override + public void messageReceived(StringMessage request, TransportChannel channel) { assertThat("moshe", equalTo(request.message)); try { channel.sendResponse(new StringMessage("hello " + request.message), TransportResponseOptions.options().withCompress(true)); @@ -189,23 +212,27 @@ public abstract class AbstractSimpleTransportTests { TransportFuture res = serviceB.submitRequest(serviceANode, "sayHello", new StringMessage("moshe"), TransportRequestOptions.options().withCompress(true), new BaseTransportResponseHandler() { - @Override public StringMessage newInstance() { - return new StringMessage(); - } + @Override + public StringMessage newInstance() { + return new StringMessage(); + } - @Override public String executor() { - return ThreadPool.Names.CACHED; - } + @Override + public String executor() { + return ThreadPool.Names.CACHED; + } - @Override public void handleResponse(StringMessage response) { - assertThat("hello moshe", equalTo(response.message)); - } + @Override + public void handleResponse(StringMessage response) { + assertThat("hello moshe", equalTo(response.message)); + } - @Override public void handleException(TransportException exp) { - exp.printStackTrace(); - assertThat("got exception instead of a response: " + exp.getMessage(), false, equalTo(true)); - } - }); + @Override + public void handleException(TransportException exp) { + exp.printStackTrace(); + assertThat("got exception instead of a response: " + exp.getMessage(), false, equalTo(true)); + } + }); try { StringMessage message = res.get(); @@ -217,17 +244,21 @@ public abstract class AbstractSimpleTransportTests { serviceA.removeHandler("sayHello"); } - @Test public void testErrorMessage() { + @Test + public void testErrorMessage() { serviceA.registerHandler("sayHelloException", new BaseTransportRequestHandler() { - @Override public StringMessage newInstance() { + @Override + public StringMessage newInstance() { return new StringMessage(); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.CACHED; } - @Override public void messageReceived(StringMessage request, TransportChannel channel) throws Exception { + @Override + public void messageReceived(StringMessage request, TransportChannel channel) throws Exception { assertThat("moshe", equalTo(request.message)); throw new RuntimeException("bad message !!!"); } @@ -235,22 +266,26 @@ public abstract class AbstractSimpleTransportTests { TransportFuture res = serviceB.submitRequest(serviceANode, "sayHelloException", new StringMessage("moshe"), new BaseTransportResponseHandler() { - @Override public StringMessage newInstance() { - return new StringMessage(); - } + @Override + public StringMessage newInstance() { + return new StringMessage(); + } - @Override public String executor() { - return ThreadPool.Names.CACHED; - } + @Override + public String executor() { + return ThreadPool.Names.CACHED; + } - @Override public void handleResponse(StringMessage response) { - assertThat("got response instead of exception", false, equalTo(true)); - } + @Override + public void handleResponse(StringMessage response) { + assertThat("got response instead of exception", false, equalTo(true)); + } - @Override public void handleException(TransportException exp) { - assertThat("bad message !!!", equalTo(exp.getCause().getMessage())); - } - }); + @Override + public void handleException(TransportException exp) { + assertThat("bad message !!!", equalTo(exp.getCause().getMessage())); + } + }); try { res.txGet(); @@ -266,11 +301,13 @@ public abstract class AbstractSimpleTransportTests { public void testDisconnectListener() throws Exception { final CountDownLatch latch = new CountDownLatch(1); TransportConnectionListener disconnectListener = new TransportConnectionListener() { - @Override public void onNodeConnected(DiscoveryNode node) { + @Override + public void onNodeConnected(DiscoveryNode node) { throw new RuntimeException("Should not be called"); } - @Override public void onNodeDisconnected(DiscoveryNode node) { + @Override + public void onNodeDisconnected(DiscoveryNode node) { latch.countDown(); } }; @@ -279,17 +316,21 @@ public abstract class AbstractSimpleTransportTests { assertThat(latch.await(5, TimeUnit.SECONDS), equalTo(true)); } - @Test public void testTimeoutSendExceptionWithNeverSendingBackResponse() throws Exception { + @Test + public void testTimeoutSendExceptionWithNeverSendingBackResponse() throws Exception { serviceA.registerHandler("sayHelloTimeoutNoResponse", new BaseTransportRequestHandler() { - @Override public StringMessage newInstance() { + @Override + public StringMessage newInstance() { return new StringMessage(); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.CACHED; } - @Override public void messageReceived(StringMessage request, TransportChannel channel) { + @Override + public void messageReceived(StringMessage request, TransportChannel channel) { assertThat("moshe", equalTo(request.message)); // don't send back a response // try { @@ -303,22 +344,26 @@ public abstract class AbstractSimpleTransportTests { TransportFuture res = serviceB.submitRequest(serviceANode, "sayHelloTimeoutNoResponse", new StringMessage("moshe"), options().withTimeout(100), new BaseTransportResponseHandler() { - @Override public StringMessage newInstance() { - return new StringMessage(); - } + @Override + public StringMessage newInstance() { + return new StringMessage(); + } - @Override public String executor() { - return ThreadPool.Names.CACHED; - } + @Override + public String executor() { + return ThreadPool.Names.CACHED; + } - @Override public void handleResponse(StringMessage response) { - assertThat("got response instead of exception", false, equalTo(true)); - } + @Override + public void handleResponse(StringMessage response) { + assertThat("got response instead of exception", false, equalTo(true)); + } - @Override public void handleException(TransportException exp) { - assertThat(exp, instanceOf(ReceiveTimeoutTransportException.class)); - } - }); + @Override + public void handleException(TransportException exp) { + assertThat(exp, instanceOf(ReceiveTimeoutTransportException.class)); + } + }); try { StringMessage message = res.txGet(); @@ -330,17 +375,21 @@ public abstract class AbstractSimpleTransportTests { serviceA.removeHandler("sayHelloTimeoutNoResponse"); } - @Test public void testTimeoutSendExceptionWithDelayedResponse() throws Exception { + @Test + public void testTimeoutSendExceptionWithDelayedResponse() throws Exception { serviceA.registerHandler("sayHelloTimeoutDelayedResponse", new BaseTransportRequestHandler() { - @Override public StringMessage newInstance() { + @Override + public StringMessage newInstance() { return new StringMessage(); } - @Override public String executor() { + @Override + public String executor() { return ThreadPool.Names.CACHED; } - @Override public void messageReceived(StringMessage request, TransportChannel channel) { + @Override + public void messageReceived(StringMessage request, TransportChannel channel) { TimeValue sleep = TimeValue.parseTimeValue(request.message, null); try { Thread.sleep(sleep.millis()); @@ -358,22 +407,26 @@ public abstract class AbstractSimpleTransportTests { TransportFuture res = serviceB.submitRequest(serviceANode, "sayHelloTimeoutDelayedResponse", new StringMessage("300ms"), options().withTimeout(100), new BaseTransportResponseHandler() { - @Override public StringMessage newInstance() { - return new StringMessage(); - } + @Override + public StringMessage newInstance() { + return new StringMessage(); + } - @Override public String executor() { - return ThreadPool.Names.CACHED; - } + @Override + public String executor() { + return ThreadPool.Names.CACHED; + } - @Override public void handleResponse(StringMessage response) { - assertThat("got response instead of exception", false, equalTo(true)); - } + @Override + public void handleResponse(StringMessage response) { + assertThat("got response instead of exception", false, equalTo(true)); + } - @Override public void handleException(TransportException exp) { - assertThat(exp, instanceOf(ReceiveTimeoutTransportException.class)); - } - }); + @Override + public void handleException(TransportException exp) { + assertThat(exp, instanceOf(ReceiveTimeoutTransportException.class)); + } + }); try { StringMessage message = res.txGet(); @@ -390,23 +443,27 @@ public abstract class AbstractSimpleTransportTests { // now, try and send another request, this times, with a short timeout res = serviceB.submitRequest(serviceANode, "sayHelloTimeoutDelayedResponse", new StringMessage(counter + "ms"), options().withTimeout(100), new BaseTransportResponseHandler() { - @Override public StringMessage newInstance() { - return new StringMessage(); - } + @Override + public StringMessage newInstance() { + return new StringMessage(); + } - @Override public String executor() { - return ThreadPool.Names.CACHED; - } + @Override + public String executor() { + return ThreadPool.Names.CACHED; + } - @Override public void handleResponse(StringMessage response) { - assertThat("hello " + counter + "ms", equalTo(response.message)); - } + @Override + public void handleResponse(StringMessage response) { + assertThat("hello " + counter + "ms", equalTo(response.message)); + } - @Override public void handleException(TransportException exp) { - exp.printStackTrace(); - assertThat("got exception instead of a response for " + counter + ": " + exp.getDetailedMessage(), false, equalTo(true)); - } - }); + @Override + public void handleException(TransportException exp) { + exp.printStackTrace(); + assertThat("got exception instead of a response for " + counter + ": " + exp.getDetailedMessage(), false, equalTo(true)); + } + }); StringMessage message = res.txGet(); assertThat(message.message, equalTo("hello " + counter + "ms")); @@ -426,11 +483,13 @@ public abstract class AbstractSimpleTransportTests { private StringMessage() { } - @Override public void readFrom(StreamInput in) throws IOException { + @Override + public void readFrom(StreamInput in) throws IOException { message = in.readUTF(); } - @Override public void writeTo(StreamOutput out) throws IOException { + @Override + public void writeTo(StreamOutput out) throws IOException { out.writeUTF(message); } } diff --git a/src/test/java/org/elasticsearch/transport/local/SimpleLocalTransportTests.java b/src/test/java/org/elasticsearch/test/unit/transport/local/SimpleLocalTransportTests.java similarity index 78% rename from src/test/java/org/elasticsearch/transport/local/SimpleLocalTransportTests.java rename to src/test/java/org/elasticsearch/test/unit/transport/local/SimpleLocalTransportTests.java index 569619f78f5..0374c9bed3b 100644 --- a/src/test/java/org/elasticsearch/transport/local/SimpleLocalTransportTests.java +++ b/src/test/java/org/elasticsearch/test/unit/transport/local/SimpleLocalTransportTests.java @@ -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 @@ -17,17 +17,19 @@ * under the License. */ -package org.elasticsearch.transport.local; +package org.elasticsearch.test.unit.transport.local; import org.elasticsearch.cluster.node.DiscoveryNode; -import org.elasticsearch.transport.AbstractSimpleTransportTests; +import org.elasticsearch.test.unit.transport.AbstractSimpleTransportTests; import org.elasticsearch.transport.TransportService; +import org.elasticsearch.transport.local.LocalTransport; import org.testng.annotations.Test; @Test public class SimpleLocalTransportTests extends AbstractSimpleTransportTests { - @Override protected void build() { + @Override + protected void build() { serviceA = new TransportService(new LocalTransport(threadPool), threadPool).start(); serviceANode = new DiscoveryNode("A", serviceA.boundAddress().publishAddress()); diff --git a/src/test/java/org/elasticsearch/transport/netty/SimpleNettyTransportTests.java b/src/test/java/org/elasticsearch/test/unit/transport/netty/SimpleNettyTransportTests.java similarity index 80% rename from src/test/java/org/elasticsearch/transport/netty/SimpleNettyTransportTests.java rename to src/test/java/org/elasticsearch/test/unit/transport/netty/SimpleNettyTransportTests.java index df6cb99db28..abe6212dbb8 100644 --- a/src/test/java/org/elasticsearch/transport/netty/SimpleNettyTransportTests.java +++ b/src/test/java/org/elasticsearch/test/unit/transport/netty/SimpleNettyTransportTests.java @@ -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 @@ -17,21 +17,23 @@ * under the License. */ -package org.elasticsearch.transport.netty; +package org.elasticsearch.test.unit.transport.netty; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.transport.InetSocketTransportAddress; -import org.elasticsearch.transport.AbstractSimpleTransportTests; +import org.elasticsearch.test.unit.transport.AbstractSimpleTransportTests; import org.elasticsearch.transport.ConnectTransportException; import org.elasticsearch.transport.TransportService; +import org.elasticsearch.transport.netty.NettyTransport; import org.testng.annotations.Test; -import static org.elasticsearch.common.settings.ImmutableSettings.*; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; @Test public class SimpleNettyTransportTests extends AbstractSimpleTransportTests { - @Override protected void build() { + @Override + protected void build() { serviceA = new TransportService(settingsBuilder().put("name", "A").build(), new NettyTransport(settingsBuilder().put("name", "A").build(), threadPool), threadPool).start(); serviceANode = new DiscoveryNode("A", serviceA.boundAddress().publishAddress()); @@ -39,15 +41,18 @@ public class SimpleNettyTransportTests extends AbstractSimpleTransportTests { serviceBNode = new DiscoveryNode("B", serviceB.boundAddress().publishAddress()); } - @Override public void testHelloWorld() { + @Override + public void testHelloWorld() { super.testHelloWorld(); //To change body of overridden methods use File | Settings | File Templates. } - @Override public void testVoidMessageCompressed() { + @Override + public void testVoidMessageCompressed() { super.testVoidMessageCompressed(); //To change body of overridden methods use File | Settings | File Templates. } - @Test public void testConnectException() { + @Test + public void testConnectException() { try { serviceA.connectToNode(new DiscoveryNode("C", new InetSocketTransportAddress("localhost", 9876))); assert false; diff --git a/src/test/java/org/elasticsearch/util/StopWatchTests.java b/src/test/java/org/elasticsearch/util/StopWatchTests.java deleted file mode 100644 index 872ba91e3e8..00000000000 --- a/src/test/java/org/elasticsearch/util/StopWatchTests.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Licensed to Elastic Search 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 - * file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.util; - -import org.elasticsearch.common.StopWatch; -import org.testng.annotations.Test; - -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; - -/** - * Test for {@link StopWatch}. - * - * @author kimchy (Shay Banon) - */ -public class StopWatchTests { - - /** - * Are timings off in JUnit? - */ - @Test public void testValidUsage() throws Exception { - StopWatch sw = new StopWatch(); - long int1 = 166L; - long int2 = 45L; - String name1 = "Task 1"; - String name2 = "Task 2"; - - long fudgeFactor = 5L; - assertThat(sw.isRunning(), equalTo(false)); - sw.start(name1); - Thread.sleep(int1); - assertThat(sw.isRunning(), equalTo(true)); - sw.stop(); - - // TODO are timings off in JUnit? Why do these assertions sometimes fail - // under both Ant and Eclipse? - - //assertTrue("Unexpected timing " + sw.getTotalTime(), sw.getTotalTime() >= int1); - //assertTrue("Unexpected timing " + sw.getTotalTime(), sw.getTotalTime() <= int1 + fudgeFactor); - sw.start(name2); - Thread.sleep(int2); - sw.stop(); - //assertTrue("Unexpected timing " + sw.getTotalTime(), sw.getTotalTime() >= int1 + int2); - //assertTrue("Unexpected timing " + sw.getTotalTime(), sw.getTotalTime() <= int1 + int2 + fudgeFactor); - - assertThat(sw.taskCount(), equalTo(2)); - String pp = sw.prettyPrint(); - assertThat(pp.indexOf(name1) != -1, equalTo(true)); - assertThat(pp.indexOf(name2) != -1, equalTo(true)); - - StopWatch.TaskInfo[] tasks = sw.taskInfo(); - assertThat(tasks.length, equalTo(2)); - assertThat(tasks[0].getTaskName(), equalTo(name1)); - assertThat(tasks[1].getTaskName(), equalTo(name2)); - sw.toString(); - } - - @Test public void testValidUsageNotKeepingTaskList() throws Exception { - StopWatch sw = new StopWatch().keepTaskList(false); - long int1 = 166L; - long int2 = 45L; - String name1 = "Task 1"; - String name2 = "Task 2"; - - long fudgeFactor = 5L; - assertThat(sw.isRunning(), equalTo(false)); - sw.start(name1); - Thread.sleep(int1); - assertThat(sw.isRunning(), equalTo(true)); - sw.stop(); - - // TODO are timings off in JUnit? Why do these assertions sometimes fail - // under both Ant and Eclipse? - - //assertTrue("Unexpected timing " + sw.getTotalTime(), sw.getTotalTime() >= int1); - //assertTrue("Unexpected timing " + sw.getTotalTime(), sw.getTotalTime() <= int1 + fudgeFactor); - sw.start(name2); - Thread.sleep(int2); - sw.stop(); - //assertTrue("Unexpected timing " + sw.getTotalTime(), sw.getTotalTime() >= int1 + int2); - //assertTrue("Unexpected timing " + sw.getTotalTime(), sw.getTotalTime() <= int1 + int2 + fudgeFactor); - - assertThat(sw.taskCount(), equalTo(2)); - String pp = sw.prettyPrint(); - assertThat(pp.indexOf("kept"), not(equalTo(-1))); - sw.toString(); - - try { - sw.taskInfo(); - assertThat(false, equalTo(true)); - } catch (UnsupportedOperationException ex) { - // Ok - } - } - - @Test public void testFailureToStartBeforeGettingTimings() { - StopWatch sw = new StopWatch(); - try { - sw.lastTaskTime(); - assertThat("Can't get last interval if no tests run", false, equalTo(true)); - } catch (IllegalStateException ex) { - // Ok - } - } - - @Test public void testFailureToStartBeforeStop() { - StopWatch sw = new StopWatch(); - try { - sw.stop(); - assertThat("Can't stop without starting", false, equalTo(true)); - } catch (IllegalStateException ex) { - // Ok - } - } - - @Test public void testRejectsStartTwice() { - StopWatch sw = new StopWatch(); - try { - sw.start(""); - sw.stop(); - sw.start(""); - assertThat(sw.isRunning(), equalTo(true)); - sw.start(""); - assertThat("Can't start twice", false, equalTo(true)); - } catch (IllegalStateException ex) { - // Ok - } - } -} diff --git a/src/test/java/org/elasticsearch/util/StringsTests.java b/src/test/java/org/elasticsearch/util/StringsTests.java deleted file mode 100644 index a35a97814c3..00000000000 --- a/src/test/java/org/elasticsearch/util/StringsTests.java +++ /dev/null @@ -1,618 +0,0 @@ -/* - * Licensed to Elastic Search 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 - * file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.util; - -import org.testng.annotations.Test; - -import static org.elasticsearch.common.Strings.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; - -/** - * Tests for {@link org.elasticsearch.common.Strings}. - * - * @author kimchy (Shay Banon) - */ -public class StringsTests { - - @Test public void testCamelCase() { - assertThat(toCamelCase("test_value"), equalTo("testValue")); - String testValue = "testValue"; - assertThat(toCamelCase(testValue), equalTo(testValue)); - assertThat(toCamelCase(testValue), sameInstance(testValue)); - } - - @Test public void testUnderscoreCase() { - assertThat(toUnderscoreCase("testValue"), equalTo("test_value")); - String testValue = "test_value"; - assertThat(toUnderscoreCase(testValue), equalTo(testValue)); - assertThat(toUnderscoreCase(testValue), sameInstance(testValue)); - - assertThat(toUnderscoreCase("Name"), equalTo("name")); - } - -// @Test public void testHasTextBlank() throws Exception { -// String blank = " "; -// assertEquals(false, Strings.hasText(blank)); -// } -// -// @Test public void testHasTextNullEmpty() throws Exception { -// assertEquals(false, Strings.hasText(null)); -// assertEquals(false, Strings.hasText("")); -// } -// -// @Test public void testHasTextValid() throws Exception { -// assertEquals(true, Strings.hasText("t")); -// } -// -// @Test public void testContainsWhitespace() throws Exception { -// assertFalse(Strings.containsWhitespace(null)); -// assertFalse(Strings.containsWhitespace("")); -// assertFalse(Strings.containsWhitespace("a")); -// assertFalse(Strings.containsWhitespace("abc")); -// assertTrue(Strings.containsWhitespace(" ")); -// assertTrue(Strings.containsWhitespace(" a")); -// assertTrue(Strings.containsWhitespace("abc ")); -// assertTrue(Strings.containsWhitespace("a b")); -// assertTrue(Strings.containsWhitespace("a b")); -// } -// -// @Test public void testTrimWhitespace() throws Exception { -// assertEquals(null, Strings.trimWhitespace(null)); -// assertEquals("", Strings.trimWhitespace("")); -// assertEquals("", Strings.trimWhitespace(" ")); -// assertEquals("", Strings.trimWhitespace("\t")); -// assertEquals("a", Strings.trimWhitespace(" a")); -// assertEquals("a", Strings.trimWhitespace("a ")); -// assertEquals("a", Strings.trimWhitespace(" a ")); -// assertEquals("a b", Strings.trimWhitespace(" a b ")); -// assertEquals("a b c", Strings.trimWhitespace(" a b c ")); -// } -// -// @Test public void testTrimAllWhitespace() throws Exception { -// assertEquals("", Strings.trimAllWhitespace("")); -// assertEquals("", Strings.trimAllWhitespace(" ")); -// assertEquals("", Strings.trimAllWhitespace("\t")); -// assertEquals("a", Strings.trimAllWhitespace(" a")); -// assertEquals("a", Strings.trimAllWhitespace("a ")); -// assertEquals("a", Strings.trimAllWhitespace(" a ")); -// assertEquals("ab", Strings.trimAllWhitespace(" a b ")); -// assertEquals("abc", Strings.trimAllWhitespace(" a b c ")); -// } -// -// @Test public void testTrimLeadingWhitespace() throws Exception { -// assertEquals(null, Strings.trimLeadingWhitespace(null)); -// assertEquals("", Strings.trimLeadingWhitespace("")); -// assertEquals("", Strings.trimLeadingWhitespace(" ")); -// assertEquals("", Strings.trimLeadingWhitespace("\t")); -// assertEquals("a", Strings.trimLeadingWhitespace(" a")); -// assertEquals("a ", Strings.trimLeadingWhitespace("a ")); -// assertEquals("a ", Strings.trimLeadingWhitespace(" a ")); -// assertEquals("a b ", Strings.trimLeadingWhitespace(" a b ")); -// assertEquals("a b c ", Strings.trimLeadingWhitespace(" a b c ")); -// } -// -// @Test public void testTrimTrailingWhitespace() throws Exception { -// assertEquals(null, Strings.trimTrailingWhitespace(null)); -// assertEquals("", Strings.trimTrailingWhitespace("")); -// assertEquals("", Strings.trimTrailingWhitespace(" ")); -// assertEquals("", Strings.trimTrailingWhitespace("\t")); -// assertEquals("a", Strings.trimTrailingWhitespace("a ")); -// assertEquals(" a", Strings.trimTrailingWhitespace(" a")); -// assertEquals(" a", Strings.trimTrailingWhitespace(" a ")); -// assertEquals(" a b", Strings.trimTrailingWhitespace(" a b ")); -// assertEquals(" a b c", Strings.trimTrailingWhitespace(" a b c ")); -// } -// -// @Test public void testTrimLeadingCharacter() throws Exception { -// assertEquals(null, Strings.trimLeadingCharacter(null, ' ')); -// assertEquals("", Strings.trimLeadingCharacter("", ' ')); -// assertEquals("", Strings.trimLeadingCharacter(" ", ' ')); -// assertEquals("\t", Strings.trimLeadingCharacter("\t", ' ')); -// assertEquals("a", Strings.trimLeadingCharacter(" a", ' ')); -// assertEquals("a ", Strings.trimLeadingCharacter("a ", ' ')); -// assertEquals("a ", Strings.trimLeadingCharacter(" a ", ' ')); -// assertEquals("a b ", Strings.trimLeadingCharacter(" a b ", ' ')); -// assertEquals("a b c ", Strings.trimLeadingCharacter(" a b c ", ' ')); -// } -// -// @Test public void testTrimTrailingCharacter() throws Exception { -// assertEquals(null, Strings.trimTrailingCharacter(null, ' ')); -// assertEquals("", Strings.trimTrailingCharacter("", ' ')); -// assertEquals("", Strings.trimTrailingCharacter(" ", ' ')); -// assertEquals("\t", Strings.trimTrailingCharacter("\t", ' ')); -// assertEquals("a", Strings.trimTrailingCharacter("a ", ' ')); -// assertEquals(" a", Strings.trimTrailingCharacter(" a", ' ')); -// assertEquals(" a", Strings.trimTrailingCharacter(" a ", ' ')); -// assertEquals(" a b", Strings.trimTrailingCharacter(" a b ", ' ')); -// assertEquals(" a b c", Strings.trimTrailingCharacter(" a b c ", ' ')); -// } -// -// @Test public void testCountOccurrencesOf() { -// assertTrue("nullx2 = 0", -// Strings.countOccurrencesOf(null, null) == 0); -// assertTrue("null string = 0", -// Strings.countOccurrencesOf("s", null) == 0); -// assertTrue("null substring = 0", -// Strings.countOccurrencesOf(null, "s") == 0); -// String s = "erowoiueoiur"; -// assertTrue("not found = 0", -// Strings.countOccurrencesOf(s, "WERWER") == 0); -// assertTrue("not found char = 0", -// Strings.countOccurrencesOf(s, "x") == 0); -// assertTrue("not found ws = 0", -// Strings.countOccurrencesOf(s, " ") == 0); -// assertTrue("not found empty string = 0", -// Strings.countOccurrencesOf(s, "") == 0); -// assertTrue("found char=2", Strings.countOccurrencesOf(s, "e") == 2); -// assertTrue("found substring=2", -// Strings.countOccurrencesOf(s, "oi") == 2); -// assertTrue("found substring=2", -// Strings.countOccurrencesOf(s, "oiu") == 2); -// assertTrue("found substring=3", -// Strings.countOccurrencesOf(s, "oiur") == 1); -// assertTrue("test last", Strings.countOccurrencesOf(s, "r") == 2); -// } -// -// @Test public void testReplace() throws Exception { -// String inString = "a6AazAaa77abaa"; -// String oldPattern = "aa"; -// String newPattern = "foo"; -// -// // Simple replace -// String s = Strings.replace(inString, oldPattern, newPattern); -// assertTrue("Replace 1 worked", s.equals("a6AazAfoo77abfoo")); -// -// // Non match: no change -// s = Strings.replace(inString, "qwoeiruqopwieurpoqwieur", newPattern); -// assertTrue("Replace non matched is equal", s.equals(inString)); -// -// // Null new pattern: should ignore -// s = Strings.replace(inString, oldPattern, null); -// assertTrue("Replace non matched is equal", s.equals(inString)); -// -// // Null old pattern: should ignore -// s = Strings.replace(inString, null, newPattern); -// assertTrue("Replace non matched is equal", s.equals(inString)); -// } -// -// @Test public void testDelete() throws Exception { -// String inString = "The quick brown fox jumped over the lazy dog"; -// -// String noThe = Strings.delete(inString, "the"); -// assertTrue("Result has no the [" + noThe + "]", -// noThe.equals("The quick brown fox jumped over lazy dog")); -// -// String nohe = Strings.delete(inString, "he"); -// assertTrue("Result has no he [" + nohe + "]", -// nohe.equals("T quick brown fox jumped over t lazy dog")); -// -// String nosp = Strings.delete(inString, " "); -// assertTrue("Result has no spaces", -// nosp.equals("Thequickbrownfoxjumpedoverthelazydog")); -// -// String killEnd = Strings.delete(inString, "dog"); -// assertTrue("Result has no dog", -// killEnd.equals("The quick brown fox jumped over the lazy ")); -// -// String mismatch = Strings.delete(inString, "dxxcxcxog"); -// assertTrue("Result is unchanged", mismatch.equals(inString)); -// -// String nochange = Strings.delete(inString, ""); -// assertTrue("Result is unchanged", nochange.equals(inString)); -// } -// -// @Test public void testDeleteAny() throws Exception { -// String inString = "Able was I ere I saw Elba"; -// -// String res = Strings.deleteAny(inString, "I"); -// assertTrue("Result has no Is [" + res + "]", res.equals("Able was ere saw Elba")); -// -// res = Strings.deleteAny(inString, "AeEba!"); -// assertTrue("Result has no Is [" + res + "]", res.equals("l ws I r I sw l")); -// -// String mismatch = Strings.deleteAny(inString, "#@$#$^"); -// assertTrue("Result is unchanged", mismatch.equals(inString)); -// -// String whitespace = "This is\n\n\n \t a messagy string with whitespace\n"; -// assertTrue("Has CR", whitespace.indexOf("\n") != -1); -// assertTrue("Has tab", whitespace.indexOf("\t") != -1); -// assertTrue("Has sp", whitespace.indexOf(" ") != -1); -// String cleaned = Strings.deleteAny(whitespace, "\n\t "); -// assertTrue("Has no CR", cleaned.indexOf("\n") == -1); -// assertTrue("Has no tab", cleaned.indexOf("\t") == -1); -// assertTrue("Has no sp", cleaned.indexOf(" ") == -1); -// assertTrue("Still has chars", cleaned.length() > 10); -// } -// -// -// @Test public void testQuote() { -// assertEquals("'myString'", Strings.quote("myString")); -// assertEquals("''", Strings.quote("")); -// assertNull(Strings.quote(null)); -// } -// -// @Test public void testQuoteIfString() { -// assertEquals("'myString'", Strings.quoteIfString("myString")); -// assertEquals("''", Strings.quoteIfString("")); -// assertEquals(5, Strings.quoteIfString(5)); -// assertNull(Strings.quoteIfString(null)); -// } -// -// @Test public void testUnqualify() { -// String qualified = "i.am.not.unqualified"; -// assertEquals("unqualified", Strings.unqualify(qualified)); -// } -// -// @Test public void testCapitalize() { -// String capitalized = "i am not capitalized"; -// assertEquals("I am not capitalized", Strings.capitalize(capitalized)); -// } -// -// @Test public void testUncapitalize() { -// String capitalized = "I am capitalized"; -// assertEquals("i am capitalized", Strings.uncapitalize(capitalized)); -// } -// -// @Test public void testGetFilename() { -// assertEquals(null, Strings.getFilename(null)); -// assertEquals("", Strings.getFilename("")); -// assertEquals("myfile", Strings.getFilename("myfile")); -// assertEquals("myfile", Strings.getFilename("mypath/myfile")); -// assertEquals("myfile.", Strings.getFilename("myfile.")); -// assertEquals("myfile.", Strings.getFilename("mypath/myfile.")); -// assertEquals("myfile.txt", Strings.getFilename("myfile.txt")); -// assertEquals("myfile.txt", Strings.getFilename("mypath/myfile.txt")); -// } -// -// @Test public void testGetFilenameExtension() { -// assertEquals(null, Strings.getFilenameExtension(null)); -// assertEquals(null, Strings.getFilenameExtension("")); -// assertEquals(null, Strings.getFilenameExtension("myfile")); -// assertEquals(null, Strings.getFilenameExtension("myPath/myfile")); -// assertEquals("", Strings.getFilenameExtension("myfile.")); -// assertEquals("", Strings.getFilenameExtension("myPath/myfile.")); -// assertEquals("txt", Strings.getFilenameExtension("myfile.txt")); -// assertEquals("txt", Strings.getFilenameExtension("mypath/myfile.txt")); -// } -// -// @Test public void testStripFilenameExtension() { -// assertEquals(null, Strings.stripFilenameExtension(null)); -// assertEquals("", Strings.stripFilenameExtension("")); -// assertEquals("myfile", Strings.stripFilenameExtension("myfile")); -// assertEquals("mypath/myfile", Strings.stripFilenameExtension("mypath/myfile")); -// assertEquals("myfile", Strings.stripFilenameExtension("myfile.")); -// assertEquals("mypath/myfile", Strings.stripFilenameExtension("mypath/myfile.")); -// assertEquals("myfile", Strings.stripFilenameExtension("myfile.txt")); -// assertEquals("mypath/myfile", Strings.stripFilenameExtension("mypath/myfile.txt")); -// } -// -// @Test public void testCleanPath() { -// assertEquals("mypath/myfile", Strings.cleanPath("mypath/myfile")); -// assertEquals("mypath/myfile", Strings.cleanPath("mypath\\myfile")); -// assertEquals("mypath/myfile", Strings.cleanPath("mypath/../mypath/myfile")); -// assertEquals("mypath/myfile", Strings.cleanPath("mypath/myfile/../../mypath/myfile")); -// assertEquals("../mypath/myfile", Strings.cleanPath("../mypath/myfile")); -// assertEquals("../mypath/myfile", Strings.cleanPath("../mypath/../mypath/myfile")); -// assertEquals("../mypath/myfile", Strings.cleanPath("mypath/../../mypath/myfile")); -// assertEquals("/../mypath/myfile", Strings.cleanPath("/../mypath/myfile")); -// } -// -// @Test public void testPathEquals() { -// assertTrue("Must be true for the same strings", -// Strings.pathEquals("/dummy1/dummy2/dummy3", -// "/dummy1/dummy2/dummy3")); -// assertTrue("Must be true for the same win strings", -// Strings.pathEquals("C:\\dummy1\\dummy2\\dummy3", -// "C:\\dummy1\\dummy2\\dummy3")); -// assertTrue("Must be true for one top path on 1", -// Strings.pathEquals("/dummy1/bin/../dummy2/dummy3", -// "/dummy1/dummy2/dummy3")); -// assertTrue("Must be true for one win top path on 2", -// Strings.pathEquals("C:\\dummy1\\dummy2\\dummy3", -// "C:\\dummy1\\bin\\..\\dummy2\\dummy3")); -// assertTrue("Must be true for two top paths on 1", -// Strings.pathEquals("/dummy1/bin/../dummy2/bin/../dummy3", -// "/dummy1/dummy2/dummy3")); -// assertTrue("Must be true for two win top paths on 2", -// Strings.pathEquals("C:\\dummy1\\dummy2\\dummy3", -// "C:\\dummy1\\bin\\..\\dummy2\\bin\\..\\dummy3")); -// assertTrue("Must be true for double top paths on 1", -// Strings.pathEquals("/dummy1/bin/tmp/../../dummy2/dummy3", -// "/dummy1/dummy2/dummy3")); -// assertTrue("Must be true for double top paths on 2 with similarity", -// Strings.pathEquals("/dummy1/dummy2/dummy3", -// "/dummy1/dum/dum/../../dummy2/dummy3")); -// assertTrue("Must be true for current paths", -// Strings.pathEquals("./dummy1/dummy2/dummy3", -// "dummy1/dum/./dum/../../dummy2/dummy3")); -// assertFalse("Must be false for relative/absolute paths", -// Strings.pathEquals("./dummy1/dummy2/dummy3", -// "/dummy1/dum/./dum/../../dummy2/dummy3")); -// assertFalse("Must be false for different strings", -// Strings.pathEquals("/dummy1/dummy2/dummy3", -// "/dummy1/dummy4/dummy3")); -// assertFalse("Must be false for one false path on 1", -// Strings.pathEquals("/dummy1/bin/tmp/../dummy2/dummy3", -// "/dummy1/dummy2/dummy3")); -// assertFalse("Must be false for one false win top path on 2", -// Strings.pathEquals("C:\\dummy1\\dummy2\\dummy3", -// "C:\\dummy1\\bin\\tmp\\..\\dummy2\\dummy3")); -// assertFalse("Must be false for top path on 1 + difference", -// Strings.pathEquals("/dummy1/bin/../dummy2/dummy3", -// "/dummy1/dummy2/dummy4")); -// } -// -// @Test public void testConcatenateStringArrays() { -// String[] input1 = new String[]{"myString2"}; -// String[] input2 = new String[]{"myString1", "myString2"}; -// String[] result = Strings.concatenateStringArrays(input1, input2); -// assertEquals(3, result.length); -// assertEquals("myString2", result[0]); -// assertEquals("myString1", result[1]); -// assertEquals("myString2", result[2]); -// -// assertArrayEquals(input1, Strings.concatenateStringArrays(input1, null)); -// assertArrayEquals(input2, Strings.concatenateStringArrays(null, input2)); -// assertNull(Strings.concatenateStringArrays(null, null)); -// } -// -// @Test public void testMergeStringArrays() { -// String[] input1 = new String[]{"myString2"}; -// String[] input2 = new String[]{"myString1", "myString2"}; -// String[] result = Strings.mergeStringArrays(input1, input2); -// assertEquals(2, result.length); -// assertEquals("myString2", result[0]); -// assertEquals("myString1", result[1]); -// -// assertArrayEquals(input1, Strings.mergeStringArrays(input1, null)); -// assertArrayEquals(input2, Strings.mergeStringArrays(null, input2)); -// assertNull(Strings.mergeStringArrays(null, null)); -// } -// -// @Test public void testSortStringArray() { -// String[] input = new String[]{"myString2"}; -// input = Strings.addStringToArray(input, "myString1"); -// assertEquals("myString2", input[0]); -// assertEquals("myString1", input[1]); -// -// Strings.sortStringArray(input); -// assertEquals("myString1", input[0]); -// assertEquals("myString2", input[1]); -// } -// -// @Test public void testRemoveDuplicateStrings() { -// String[] input = new String[]{"myString2", "myString1", "myString2"}; -// input = Strings.removeDuplicateStrings(input); -// assertEquals("myString1", input[0]); -// assertEquals("myString2", input[1]); -// } -// -// @Test public void testSplitArrayElementsIntoProperties() { -// String[] input = new String[]{"key1=value1 ", "key2 =\"value2\""}; -// Properties result = Strings.splitArrayElementsIntoProperties(input, "="); -// assertEquals("value1", result.getProperty("key1")); -// assertEquals("\"value2\"", result.getProperty("key2")); -// } -// -// @Test public void testSplitArrayElementsIntoPropertiesAndDeletedChars() { -// String[] input = new String[]{"key1=value1 ", "key2 =\"value2\""}; -// Properties result = Strings.splitArrayElementsIntoProperties(input, "=", "\""); -// assertEquals("value1", result.getProperty("key1")); -// assertEquals("value2", result.getProperty("key2")); -// } -// -// @Test public void testTokenizeToStringArray() { -// String[] sa = Strings.tokenizeToStringArray("a,b , ,c", ","); -// assertEquals(3, sa.length); -// assertTrue("components are correct", -// sa[0].equals("a") && sa[1].equals("b") && sa[2].equals("c")); -// } -// -// @Test public void testTokenizeToStringArrayWithNotIgnoreEmptyTokens() { -// String[] sa = Strings.tokenizeToStringArray("a,b , ,c", ",", true, false); -// assertEquals(4, sa.length); -// assertTrue("components are correct", -// sa[0].equals("a") && sa[1].equals("b") && sa[2].equals("") && sa[3].equals("c")); -// } -// -// @Test public void testTokenizeToStringArrayWithNotTrimTokens() { -// String[] sa = Strings.tokenizeToStringArray("a,b ,c", ",", false, true); -// assertEquals(3, sa.length); -// assertTrue("components are correct", -// sa[0].equals("a") && sa[1].equals("b ") && sa[2].equals("c")); -// } -// -// @Test public void testCommaDelimitedListToStringArrayWithNullProducesEmptyArray() { -// String[] sa = Strings.commaDelimitedListToStringArray(null); -// assertTrue("String array isn't null with null input", sa != null); -// assertTrue("String array length == 0 with null input", sa.length == 0); -// } -// -// @Test public void testCommaDelimitedListToStringArrayWithEmptyStringProducesEmptyArray() { -// String[] sa = Strings.commaDelimitedListToStringArray(""); -// assertTrue("String array isn't null with null input", sa != null); -// assertTrue("String array length == 0 with null input", sa.length == 0); -// } -// -// private void testStringArrayReverseTransformationMatches(String[] sa) { -// String[] reverse = -// Strings.commaDelimitedListToStringArray(Strings.arrayToCommaDelimitedString(sa)); -// assertEquals("Reverse transformation is equal", -// Arrays.asList(sa), -// Arrays.asList(reverse)); -// } -// -// @Test public void testDelimitedListToStringArrayWithComma() { -// String[] sa = Strings.delimitedListToStringArray("a,b", ","); -// assertEquals(2, sa.length); -// assertEquals("a", sa[0]); -// assertEquals("b", sa[1]); -// } -// -// @Test public void testDelimitedListToStringArrayWithSemicolon() { -// String[] sa = Strings.delimitedListToStringArray("a;b", ";"); -// assertEquals(2, sa.length); -// assertEquals("a", sa[0]); -// assertEquals("b", sa[1]); -// } -// -// @Test public void testDelimitedListToStringArrayWithEmptyString() { -// String[] sa = Strings.delimitedListToStringArray("a,b", ""); -// assertEquals(3, sa.length); -// assertEquals("a", sa[0]); -// assertEquals(",", sa[1]); -// assertEquals("b", sa[2]); -// } -// -// @Test public void testDelimitedListToStringArrayWithNullDelimiter() { -// String[] sa = Strings.delimitedListToStringArray("a,b", null); -// assertEquals(1, sa.length); -// assertEquals("a,b", sa[0]); -// } -// -// @Test public void testCommaDelimitedListToStringArrayMatchWords() { -// // Could read these from files -// String[] sa = new String[]{"foo", "bar", "big"}; -// doTestCommaDelimitedListToStringArrayLegalMatch(sa); -// testStringArrayReverseTransformationMatches(sa); -// -// sa = new String[]{"a", "b", "c"}; -// doTestCommaDelimitedListToStringArrayLegalMatch(sa); -// testStringArrayReverseTransformationMatches(sa); -// -// // Test same words -// sa = new String[]{"AA", "AA", "AA", "AA", "AA"}; -// doTestCommaDelimitedListToStringArrayLegalMatch(sa); -// testStringArrayReverseTransformationMatches(sa); -// } -// -// @Test public void testCommaDelimitedListToStringArraySingleString() { -// // Could read these from files -// String s = "woeirqupoiewuropqiewuorpqiwueopriquwopeiurqopwieur"; -// String[] sa = Strings.commaDelimitedListToStringArray(s); -// assertTrue("Found one String with no delimiters", sa.length == 1); -// assertTrue("Single array entry matches input String with no delimiters", -// sa[0].equals(s)); -// } -// -// @Test public void testCommaDelimitedListToStringArrayWithOtherPunctuation() { -// // Could read these from files -// String[] sa = new String[]{"xcvwert4456346&*.", "///", ".!", ".", ";"}; -// doTestCommaDelimitedListToStringArrayLegalMatch(sa); -// } -// -// /** -// * We expect to see the empty Strings in the output. -// */ -// @Test public void testCommaDelimitedListToStringArrayEmptyStrings() { -// // Could read these from files -// String[] sa = Strings.commaDelimitedListToStringArray("a,,b"); -// assertEquals("a,,b produces array length 3", 3, sa.length); -// assertTrue("components are correct", -// sa[0].equals("a") && sa[1].equals("") && sa[2].equals("b")); -// -// sa = new String[]{"", "", "a", ""}; -// doTestCommaDelimitedListToStringArrayLegalMatch(sa); -// } -// -// private void doTestCommaDelimitedListToStringArrayLegalMatch(String[] components) { -// StringBuffer sbuf = new StringBuffer(); -// for (int i = 0; i < components.length; i++) { -// if (i != 0) { -// sbuf.append(","); -// } -// sbuf.append(components[i]); -// } -// String[] sa = Strings.commaDelimitedListToStringArray(sbuf.toString()); -// assertTrue("String array isn't null with legal match", sa != null); -// assertEquals("String array length is correct with legal match", components.length, sa.length); -// assertTrue("Output equals input", Arrays.equals(sa, components)); -// } -// -// @Test public void testEndsWithIgnoreCase() { -// String suffix = "fOo"; -// assertTrue(Strings.endsWithIgnoreCase("foo", suffix)); -// assertTrue(Strings.endsWithIgnoreCase("Foo", suffix)); -// assertTrue(Strings.endsWithIgnoreCase("barfoo", suffix)); -// assertTrue(Strings.endsWithIgnoreCase("barbarfoo", suffix)); -// assertTrue(Strings.endsWithIgnoreCase("barFoo", suffix)); -// assertTrue(Strings.endsWithIgnoreCase("barBarFoo", suffix)); -// assertTrue(Strings.endsWithIgnoreCase("barfoO", suffix)); -// assertTrue(Strings.endsWithIgnoreCase("barFOO", suffix)); -// assertTrue(Strings.endsWithIgnoreCase("barfOo", suffix)); -// assertFalse(Strings.endsWithIgnoreCase(null, suffix)); -// assertFalse(Strings.endsWithIgnoreCase("barfOo", null)); -// assertFalse(Strings.endsWithIgnoreCase("b", suffix)); -// } -// -// @Test public void testParseLocaleStringSunnyDay() throws Exception { -// Locale expectedLocale = Locale.UK; -// Locale locale = Strings.parseLocaleString(expectedLocale.toString()); -// assertNotNull("When given a bona-fide Locale string, must not return null.", locale); -// assertEquals(expectedLocale, locale); -// } -// -// @Test public void testParseLocaleStringWithMalformedLocaleString() throws Exception { -// Locale locale = Strings.parseLocaleString("_banjo_on_my_knee"); -// assertNotNull("When given a malformed Locale string, must not return null.", locale); -// } -// -// @Test public void testParseLocaleStringWithEmptyLocaleStringYieldsNullLocale() throws Exception { -// Locale locale = Strings.parseLocaleString(""); -// assertNull("When given an empty Locale string, must return null.", locale); -// } -// -// @Test public void testParseLocaleWithMultiValuedVariant() throws Exception { -// final String variant = "proper_northern"; -// final String localeString = "en_GB_" + variant; -// Locale locale = Strings.parseLocaleString(localeString); -// assertEquals("Multi-valued variant portion of the Locale not extracted correctly.", variant, locale.getVariant()); -// } -// -// @Test public void testParseLocaleWithMultiValuedVariantUsingSpacesAsSeparators() throws Exception { -// final String variant = "proper northern"; -// final String localeString = "en GB " + variant; -// Locale locale = Strings.parseLocaleString(localeString); -// assertEquals("Multi-valued variant portion of the Locale not extracted correctly.", variant, locale.getVariant()); -// } -// -// @Test public void testParseLocaleWithMultiValuedVariantUsingMixtureOfUnderscoresAndSpacesAsSeparators() throws Exception { -// final String variant = "proper northern"; -// final String localeString = "en_GB_" + variant; -// Locale locale = Strings.parseLocaleString(localeString); -// assertEquals("Multi-valued variant portion of the Locale not extracted correctly.", variant, locale.getVariant()); -// } -// -// @Test public void testParseLocaleWithMultiValuedVariantUsingSpacesAsSeparatorsWithLotsOfLeadingWhitespace() throws Exception { -// final String variant = "proper northern"; -// final String localeString = "en GB " + variant; // lots of whitespace -// Locale locale = Strings.parseLocaleString(localeString); -// assertEquals("Multi-valued variant portion of the Locale not extracted correctly.", variant, locale.getVariant()); -// } -// -// @Test public void testParseLocaleWithMultiValuedVariantUsingUnderscoresAsSeparatorsWithLotsOfLeadingWhitespace() throws Exception { -// final String variant = "proper_northern"; -// final String localeString = "en_GB_____" + variant; // lots of underscores -// Locale locale = Strings.parseLocaleString(localeString); -// assertEquals("Multi-valued variant portion of the Locale not extracted correctly.", variant, locale.getVariant()); -// } - -} diff --git a/src/test/java/org/elasticsearch/util/ThreadLocalsTests.java b/src/test/java/org/elasticsearch/util/ThreadLocalsTests.java deleted file mode 100644 index 85b145526dc..00000000000 --- a/src/test/java/org/elasticsearch/util/ThreadLocalsTests.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to Elastic Search 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 - * file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.util; - -import org.elasticsearch.common.thread.ThreadLocals; -import org.testng.annotations.Test; - -import java.util.concurrent.atomic.AtomicInteger; - -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; - -/** - * @author kimchy (shay.banon) - */ -@Test -public class ThreadLocalsTests { - - private static final ThreadLocal> local = new ThreadLocal>() { - @Override protected ThreadLocals.CleanableValue initialValue() { - return new ThreadLocals.CleanableValue(new AtomicInteger()); - } - }; - - @Test public void testCleanThreadLocals() { - assertThat(local.get().get().get(), equalTo(0)); - local.get().get().incrementAndGet(); - assertThat(local.get().get().get(), equalTo(1)); - ThreadLocals.clearReferencesThreadLocals(); - // Disabled for now, for some reason, it fails on gradle...! -// assertThat(local.get().get().get(), equalTo(0)); -// ThreadLocals.clearReferencesThreadLocals(); - } -} diff --git a/src/test/java/org/elasticsearch/util/guice/InjectorsTests.java b/src/test/java/org/elasticsearch/util/guice/InjectorsTests.java deleted file mode 100644 index 406df704a85..00000000000 --- a/src/test/java/org/elasticsearch/util/guice/InjectorsTests.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to Elastic Search 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 - * file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.util.guice; - -import org.elasticsearch.common.inject.*; -import org.elasticsearch.common.inject.matcher.Matchers; -import org.testng.annotations.Test; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.*; -import static java.lang.annotation.RetentionPolicy.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; - -/** - * @author kimchy (Shay Banon) - */ -public class InjectorsTests { - - @Test public void testMatchers() throws Exception { - Injector injector = Guice.createInjector(new MyModule()); - - assertThat(Injectors.getInstancesOf(injector, A.class).size(), equalTo(2)); - assertThat(Injectors.getInstancesOf(injector, B.class).size(), equalTo(1)); - assertThat(Injectors.getInstancesOf(injector, C.class).size(), equalTo(1)); - - assertThat(Injectors.getInstancesOf(injector, - Matchers.subclassesOf(C.class).and(Matchers.annotatedWith(Blue.class))).size(), equalTo(1)); - } - - public static class MyModule extends AbstractModule { - protected void configure() { - bind(C.class); - bind(B.class); - } - } - - public static class A { - public String name = "A"; - } - - public static class B extends A { - public B() { - name = "B"; - } - } - - @Blue - public static class C extends A { - public C() { - name = "C"; - } - } - - @Target({METHOD, CONSTRUCTOR, FIELD, TYPE}) - @Retention(RUNTIME) - @Documented - @BindingAnnotation - public @interface Blue { - } -} diff --git a/src/test/resources/log4j.properties b/src/test/resources/log4j.properties new file mode 100644 index 00000000000..497c97f9959 --- /dev/null +++ b/src/test/resources/log4j.properties @@ -0,0 +1,5 @@ +log4j.rootLogger=INFO, out + +log4j.appender.out=org.apache.log4j.ConsoleAppender +log4j.appender.out.layout=org.apache.log4j.PatternLayout +log4j.appender.out.layout.conversionPattern=[%d{ISO8601}][%-5p][%-25c] %m%n