Commit Graph

2110 Commits

Author SHA1 Message Date
jaymode ec4307f080 properly bind ClassSet extensions as singletons
The ExtensionPoint.ClassSet binds adds the extension classes to a a Multibinder and binds
the classes and calls the asEagerSingleton method on the multibinder. This does not actually
create a singleton. Instead we first bind the class as a singleton and add then add the class
to the multibinder.

Closes #14194
2015-10-21 15:01:24 -04:00
javanna 75cedca0da Remove search exists api
Closes #13682
Closes #13911
2015-10-21 17:39:32 +02:00
Adrien Grand fd592c6d76 Remove Lucene.isEmpty(DocIdSet).
After the Filter ban, this method is not used anymore.
2015-10-21 15:34:32 +02:00
Simon Willnauer 3ba4dfa3a6 Merge pull request #14206 from s1monw/refactor_shard_failure_listener
Refactor ShardFailure listener infrastructure
2015-10-21 13:40:56 +02:00
Adrien Grand f4e9f69f68 Merge pull request #14082 from jpountz/remove/uninverted_numeric_fielddata
Remove "uninverted" and "binary" fielddata support for numeric and boolean fields.
2015-10-21 13:03:15 +02:00
Adrien Grand 76231c89da Remove "uninverted" and "binary" fielddata support for numeric and boolean fields.
Numeric and boolean fields have doc values enabled by default as of
elasticsearch 2.0. This commit removes support for uninverted/in-memory
fielddata, as well as numeric fields encoded in binary doc values which was
the way that elasticsearch stored doc values in a Lucene index before the
1.4 release.

As a consequence, you will only be able to sort and aggregate on numeric and
boolean fields in Elasticsearch 3.0 if doc values have not been switched off.
2015-10-21 12:15:40 +02:00
javanna eaffa975e5 Restore support for escaped '/' as part of document id
With #13691 we introduced some custom logic to make sure that date math expressions like <logstash-{now/D}> don't get broken up into two where the slash appears in the expression. That said the only correct way to provide such a date math expression as part of the uri would be to properly escape the '/' instead. This fix also introduced a regression, as it would make sure that unescaped '/' are handled only in the case of date math expressions, but it removed support for properly escaped slashes anywhere else. The solution is to keep supporting escaped slashes only and require client libraries to properly escape them.

This commit reverts 93ad696 and makes sure that our REST tests runner supports escaping of path parts, which was more involving than expected as each single part of the path needs to be properly escaped. I am not too happy with the current solution but it's the best I could do for now, maybe not that concerning anyway given that it's just test code. I do find uri encoding quite frustrating in java.

Relates to #13691
Relates to #13665

Closes #14177
Closes #14216
2015-10-21 10:49:02 +02:00
Simon Willnauer cba210c439 apply review comments 2015-10-21 09:34:25 +02:00
Lee Hinman b3646f9bfc Merge remote-tracking branch 'dakrone/use-the-force-luke' 2015-10-20 21:13:18 -06:00
Nik Everett 2cc97a0d3e Remove and ban @Test
There are three ways `@Test` was used. Way one:

```java
@Test
public void flubTheBlort() {
```

This way was always replaced with:

```java
public void testFlubTheBlort() {
```

Or, maybe with a better method name if I was feeling generous.

Way two:

```java
@Test(throws=IllegalArgumentException.class)
public void testFoo() {
    methodThatThrows();
}
```

This way of using `@Test` is actually pretty OK, but to get the tools to ban
`@Test` entirely it can't be used. Instead:

```java
public void testFoo() {
    try {
        methodThatThrows();
        fail("Expected IllegalArgumentException");
    } catch (IllegalArgumentException e ) {
        assertThat(e.getMessage(), containsString("something"));
    }
}
```

This is longer but tests more than the old ways and is much more precise.
Compare:

```java
@Test(throws=IllegalArgumentException.class)
public void testFoo() {
    some();
    copy();
    and();
    pasted();
    methodThatThrows();
    code();  // <---- This was left here by mistake and is never called
}
```

to:

```java
@Test(throws=IllegalArgumentException.class)
public void testFoo() {
    some();
    copy();
    and();
    pasted();
    try {
        methodThatThrows();
        fail("Expected IllegalArgumentException");
    } catch (IllegalArgumentException e ) {
        assertThat(e.getMessage(), containsString("something"));
    }
}
```

The final use of test is:

```java
@Test(timeout=1000)
public void testFoo() {
    methodThatWasSlow();
}
```

This is the most insidious use of `@Test` because its tempting but tragically
flawed. Its flaws are:
1. Hard and fast timeouts can look like they are asserting that something is
faster and even do an ok job of it when you compare the timings on the same
machine but as soon as you take them to another machine they start to be
invalid. On a slow VM both the new and old methods fail. On a super-fast
machine the slower and faster ways succeed.
2. Tests often contain slow `assert` calls so the performance of tests isn't
sure to predict the performance of non-test code.
3. These timeouts are rude to debuggers because the test just drops out from
under it after the timeout.

Confusingly, timeouts are useful in tests because it'd be rude for a broken
test to cause CI to abort the whole build after it hits a global timeout. But
those timeouts should be very very long "backstop" timeouts and aren't useful
assertions about speed.

For all its flaws `@Test(timeout=1000)` doesn't have a good replacement __in__
__tests__. Nightly benchmarks like http://benchmarks.elasticsearch.org/ are
useful here because they run on the same machine but they aren't quick to check
and it takes lots of time to figure out the regressions. Sometimes its useful
to compare dueling implementations but that requires keeping both
implementations around. All and all we don't have a satisfactory answer to the
question "what do you replace `@Test(timeout=1000)`" with. So we handle each
occurrence on a case by case basis.

For files with `@Test` this also:
1. Removes excess blank lines. They don't help anything.
2. Removes underscores from method names. Those would fail any code style
checks we ever care to run and don't add to readability. Since I did this manually
I didn't do it consistently.
3. Make sure all test method names start with `test`. Some used to end in `Test` or start
with `verify` or `check` and they were picked up using the annotation. Without the
annotation they always need to start with `test`.
4. Organizes imports using the rules we generate for Eclipse. For the most part
this just removes `*` imports which is a win all on its own. It was "required"
to quickly remove `@Test`.
5. Removes unneeded casts. This is just a setting I have enabled in Eclipse and
forgot to turn off before I did this work. It probably isn't hurting anything.
6. Removes trailing whitespace. Again, another Eclipse setting I forgot to turn
off that doesn't hurt anything. Hopefully.
7. Swaps some tests override superclass tests to make them empty with
`assumeTrue` so that the reasoning for the skips is logged in the test run and
it doesn't "look like" that thing is being tested when it isn't.
8. Adds an oxford comma to an error message.

The total test count doesn't change. I know. I counted.
```bash
git checkout master && mvn clean && mvn install | tee with_test
git no_test_annotation master && mvn clean && mvn install | tee not_test
grep 'Tests summary' with_test > with_test_summary
grep 'Tests summary' not_test > not_test_summary
diff with_test_summary not_test_summary
```

These differ somewhat because some tests are skipped based on the random seed.
The total shouldn't differ. But it does!
```
1c1
< [INFO] Tests summary: 564 suites (1 ignored), 3171 tests, 31 ignored (31 assumptions)
---
> [INFO] Tests summary: 564 suites (1 ignored), 3167 tests, 17 ignored (17 assumptions)
```

These are the core unit tests. So we dig further:
```bash
cat with_test | perl -pe 's/\n// if /^Suite/;s/.*\n// if /IGNOR/;s/.*\n// if /Assumption #/;s/.*\n// if /HEARTBEAT/;s/Completed .+?,//' | grep Suite > with_test_suites
cat not_test | perl -pe 's/\n// if /^Suite/;s/.*\n// if /IGNOR/;s/.*\n// if /Assumption #/;s/.*\n// if /HEARTBEAT/;s/Completed .+?,//' | grep Suite > not_test_suites
diff <(sort with_test_suites) <(sort not_test_suites)
```

The four tests with lower test numbers are all extend `AbstractQueryTestCase`
and all have a method that looks like this:

```java
@Override
public void testToQuery() throws IOException {
    assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
    super.testToQuery();
}
```

It looks like this method was being double counted on master and isn't anymore.

Closes #14028
2015-10-20 17:37:36 -04:00
Yannick Welsch 2ab81eee2d Remove unused method ActionFuture.getRootFailure()
Closes #14214
2015-10-20 22:22:22 +02:00
Christoph Büscher 5d25bc30cd Query DSL: Remove NotQueryBuilder
The NotQueryBuilder has been deprecated on the 2.x branches
and can be removed with the next major version. It can be
replaced by boolean query with added mustNot() clause.

Closes #13761
2015-10-20 19:43:16 +02:00
Jason Tedor 8361d7dbf4 Use built-in method for computing hash code of longs
This commit replaces instances of manually computing a hash code for
primitive longs by XORing the upper bits with the lower bits with a
built-in method for doing the same.
2015-10-20 11:46:58 -04:00
Lee Hinman 9ea4909035 Add Force Merge API, deprecate Optimize API
This adds an API for force merging lucene segments. The `/_optimize` API is now
deprecated and replaced by the `/_forcemerge` API, which has all the same flags
and action, just a different name.
2015-10-20 09:00:24 -06:00
Jason Tedor a0668a3b2b Merge pull request #14210 from jasontedor/remove-cache-concurrency-level-settings
Remove cache concurrency level settings that no longer apply
2015-10-20 10:31:32 -04:00
Adrien Grand 824b7b3845 Merge pull request #14209 from jpountz/fix/ban_filter_apis
Ban oal.search.Filter.
2015-10-20 16:22:28 +02:00
Jason Tedor 18b32f0ba5 Remove cache concurrency level settings that no longer apply
This commit removes some cache concurrency level settings that were
applicable when the cache was backed by the Guava cache implementation,
but no longer apply with the cache implementation completed in #13717.

Relates #7836, relates #13224, relates #13717
2015-10-20 10:15:03 -04:00
Adrien Grand 57310fc451 Ban oal.search.Filter.
Filter has been deprecated in Lucene 5.4 and will be removed in 6.0. We should
stop using this API.
2015-10-20 16:09:46 +02:00
Robert Muir 82eb5d299a check "plugin already installed" before jar hell check.
In the case of a plugin using the deprecated `isolated=false` functionality
this will cause confusion otherwise.

Closes #14205
Closes #14207
2015-10-20 09:59:04 -04:00
Simon Willnauer b772b513e0 Refactor ShardFailure listener infrastructure
Today we leak the notion of an engine outside of the shard abstraction
which is not desirable. This commit refactors the infrastrucutre to use
use already existing interfaces to communicate if a shard has failed and
prevents engine private classes to be implemented on a higher level.
This change is purely cosmentical...
2015-10-20 15:08:26 +02:00
Jason Tedor 1b461a7f9d Remove mistakenly committed build output files
This commit removes some build output files from the
burn_maven_with_fire_branch that appear to have been mistakenly
committed to master in bfb9054a11.
2015-10-20 08:34:51 -04:00
Robert Muir c037a67988 Drop ability to execute on Solaris
This is very simple to do and recommended by `privileges(5)` documentation:
```
Daemons that never need to exec subprocesses should remove the PRIV_PROC_EXEC privilege from their permitted and limit sets.
```

Closes #14200
2015-10-20 08:10:44 -04:00
Simon Willnauer fc38c147de Remove dead code 2015-10-20 13:59:53 +02:00
Isabel Drost-Fromm 4adf7c3d86 Fix the naming check. 2015-10-20 11:17:33 +02:00
Isabel Drost-Fromm 4338ffc8a7 Merge pull request #14189 from MaineC/doc-fix/13800
Updates java query dsl documentation
2015-10-20 10:56:43 +02:00
Isabel Drost-Fromm 5fbf49a0fb Minus 16 calls to getMessage
Adds *Exception(Throwable cause) constructors and calls them where appropriate
thus getting rid of 16 instances of calling getMessage and eliminating the risk
of loosing exception context.

Fixes ElasticsearchTimeoutException along the way (used to discard the
parameter args in the (String message, Object... args) constructor, passes it
up to super now.

Relates to #10021
2015-10-20 09:55:53 +02:00
Isabel Drost-Fromm dac88c0281 Updates java query dsl documentation
Closes #13800
2015-10-20 09:37:36 +02:00
Nicholas Knize 6d3dd727c2 Resync Geopoint hashCode/equals method
Geopoint's equals method was modified to consider two points equal if they are within a threshold. This change was done to accept round-off error introduced from GeoHash encoding methods. This commit removes this trappy leniency from the GeoPoint equals method and instead forces round-off error to be handled at the encoding source.
2015-10-19 14:52:31 -05:00
Jason Tedor 2668bdc42e Rename ShardReplicationTests to TransportReplicationActionTests
This commit renames ShardReplicationTests to
TransportReplicationActionTests. This rename is to reflect the fact
that the tests contained in this test suite are for testing
TransportReplicationAction. This class was previously renamed but the
test suite was not.
2015-10-19 11:14:14 -04:00
Nik Everett 1cb3068737 Make root_cause of field conflicts more obvious
Does so by improving the error message passed to MapperParsingException.

The error messages for mapping conflicts now look like:
```
{
  "error" : {
    "root_cause" : [ {
      "type" : "mapper_parsing_exception",
      "reason" : "Failed to parse mapping [type_one]: Mapper for [text] conflicts with existing mapping in other types:\n[mapper [text] has different [analyzer], mapper [text] is used by multiple types. Set update_all_types to true to update [search_analyzer] across all types., mapper [text] is used by multiple types. Set update_all_types to true to update [search_quote_analyzer] across all types.]"
    } ],
    "type" : "mapper_parsing_exception",
    "reason" : "Failed to parse mapping [type_one]: Mapper for [text] conflicts with existing mapping in other types:\n[mapper [text] has different [analyzer], mapper [text] is used by multiple types. Set update_all_types to true to update [search_analyzer] across all types., mapper [text] is used by multiple types. Set update_all_types to true to update [search_quote_analyzer] across all types.]",
    "caused_by" : {
      "type" : "illegal_argument_exception",
      "reason" : "Mapper for [text] conflicts with existing mapping in other types:\n[mapper [text] has different [analyzer], mapper [text] is used by multiple types. Set update_all_types to true to update [search_analyzer] across all types., mapper [text] is used by multiple types. Set update_all_types to true to update [search_quote_analyzer] across all types.]"
    }
  },
  "status" : 400
}
```

Closes #12839

Change implementation

Rather than make a new exception this improves the error message of the old
exception.
2015-10-19 10:42:55 -04:00
Nik Everett a963385dee Merge pull request #14134 from nik9000/bundle_shard_routing
Bundle TestShardRouting in test jar
2015-10-19 10:00:22 -04:00
javanna a6e7a5f307 Java api: remove the count api
Closes #14166
Closes #13928
2015-10-19 14:40:52 +02:00
Britta Weber 15a63f3ec7 Merge pull request #14089 from brwe/fix-test-access-denied
fix access denied for shard deletion with WindowsFS
2015-10-19 14:25:26 +02:00
Simon Willnauer c5cf5cde8f add several code comments and apply review comments 2015-10-19 13:32:49 +02:00
Simon Willnauer 9487a8e1fd apply review comments 2015-10-19 13:32:49 +02:00
Simon Willnauer b40c1deebe Remove MetaDataSerivce and it's semaphores
MetaDataSerivce tried to protect concurrent index creation/deletion
from resulting in inconsistent indices. This was originally added a
long time ago via #1296 which seems to be caused by several problems
that we fixed already in 2.0 or even in late 1.x version. Indices where
recreated without being deleted and shards where deleted while being used
which is now prevented on several levels. We can safely remove the semaphores
since we are already serializing the events on the cluster state threads.
This commit also fixes some expception handling bugs exposed by the added test
2015-10-19 13:32:49 +02:00
Simon Willnauer 06b1d956f8 Merge pull request #13801 from achow/achow/omit-old-current-stats
Omit current* stats for OldShardStats (closes #13386)
2015-10-19 11:48:02 +02:00
Luca Cavanna 6be72d220f Merge pull request #14007 from synhershko/patch-6
Fix ensureNodesAreAvailable's error message
2015-10-19 10:42:11 +02:00
Boaz Leskes fbe9c49e8f Internal: only have one CORS allow origin setting string
We currently have two, which is confusing when you  read the code (especially if one is used with a null default and the other with '*')

Note: this is not a real bug, just a  clean up. We do the right thing...

Closes #13988
2015-10-18 21:37:50 +02:00
Boaz Leskes de7d3cf752 Gateway: a race condition can prevent the initial cluster state from being recovered
After a full cluster restart, the elected master is tasked with recovery the last known cluster state from disk. To do so, the GatewayService registers it self as a listener to cluster state changes, triggering the recovery if the local node is elected. Sadly the initial post-election cluster state can be missed if it's being processed while the listener is registered (i.e., the listener is too late but the discoveryService.initialStateReceived is not yet set). In this case the cluster state from disk will be recovered with the next change (typically node join).

 In practice this is not a big deal as master election takes at least 3s (by which time the gateway is long started), but it does make some of our tests to fail: http://build-us-00.elastic.co/job/es_core_master_centos/7915/

 To fix this, we submit a cluster state task after the edition of the listener, so we are guaranteed to check things while they are at rest.

 While at it, I removed some left over latch which we don't really wait on anymore.

 Closes #13997
2015-10-18 21:15:07 +02:00
Simon Willnauer c71da4b999 Also catch EngineClosedException when pulling translog from potentially closed engine
When we check the engine if a flush is needed we don't catch EngineClosedException today
but the engine is potentially closed already in which case we can simply return false and don't need
to bubble up the exception.
2015-10-17 20:32:03 +02:00
Jason Tedor 7f12806a7d Fix typo in o.e.c.r.a.d.ConcurrentRebalanceAllocationDecider 2015-10-16 10:06:33 -04:00
javanna a1c1a8b230 Query DSL: don't change state of the bool query while converting to lucene query
We used to change the minimumShouldMatch field of the query depending on the context, the final minimim should match should still be applied based on that, but the original minimumShouldMatch of the query shouldn't change. This was revelead by some recent test failure.

Closes #14153
2015-10-16 14:33:09 +02:00
Adrien Grand 5ae810991c Upgrade to lucene-5.4-snapshot-1708254. 2015-10-16 09:41:36 +02:00
Simon Willnauer cd0084915d Allow parser to move on the START_OBJECT token when parsing search source
Currently we require parser to be right before the sources START_OBJECT
but if we are parsing embedded search sources this won't work since we potentially
moved already on to the START_OBJECT. This commit make this optional such that
both ways work.
2015-10-15 22:28:05 +02:00
Nik Everett 68d708a75f Merge pull request #11398 from Collaborne/bugs/explain-function-script-quotes
Fix the quotes in the explain message for a script score function without parameters
2015-10-15 13:56:21 -04:00
Nik Everett 846c01f42a [test] Bundle TestShardRouting in test jar
Plugins want to use this too.

Closes #14133
2015-10-15 11:54:14 -04:00
Colin Goodheart-Smithe cf3e92ae92 Merge branch 'master' into feature/search-request-refactoring 2015-10-15 13:51:00 +01:00
Colin Goodheart-Smithe ef5fc721e5 reverted non-null searchSourceBuilder in searchRequest for now 2015-10-15 13:49:43 +01:00
Robert Muir c3751801c6 Test that the lucene "unmap hack" is supported.
Closes #14120

Squashed commit of the following:

commit 556b7f5783211bd82a5d9796996e21be87b0404b
Author: Robert Muir <rmuir@apache.org>
Date:   Wed Oct 14 15:16:54 2015 -0400

    Add bugid link

commit b44aac7e9f1a97974938c17e013812ebf4c2fa76
Author: Robert Muir <rmuir@apache.org>
Date:   Wed Oct 14 15:01:41 2015 -0400

    Test that the lucene "unmap hack" is supported.

    We should know if this is not working for any configuration, otherwise resources such as address space, file handles, and even disk space become tied to Java's garbage collector.
2015-10-15 08:47:05 -04:00