Commit Graph

8278 Commits

Author SHA1 Message Date
Boaz Leskes a474a13911 testRerouteRecovery should use assertBusy when checking recovery counters
The test check that the number of outgoing/incoming recoveries of a shard is 0 after recoveries were done. Sadly that is not guaranteed by the current recovery logic as we decrement the counters only when all references to the relevant RecoveryTarget object have been released. This may happen in an async fashion to the recovery completion which causes the test to fail. I looked at options to change the recovery logic to have the recovery counters decrease before the recovery is done *under normally circumstances* but I don't see a clean way to do it. Since it won't give hard guarantees anyway I opted to add assertBusy to the test

Closes #24669
2017-05-16 11:09:52 +02:00
Ryan Ernst d966034298 Scripting: Deprecate index lookup (#24691)
This commit adds a deprecation warning if `_index` is used in scripts.
It is emitted each time a script is invoked, but not per document. There
is no test because constructing a LeafIndexLookup is quite difficult,
but the deprecation warning does show up in IndexLookupIT, there is just
no way to assert warnings in integ tests.

relates #19359
2017-05-16 01:41:29 -07:00
Simon Willnauer f9cfe86320 Make RemoteClusterConnectionTests more robust against cancelable threads aborts
Today we assert hart if failure listeners are invoked more than once. Yet, this
can happen if we cancel the execution since the caller and the handler will get
the exception on the cancelable threads and will notify the listener concurrently
if timinig allows. This commit relaxes the assertion towards handling multiple
invocations with `ExecutionCancelledException`

Closes #24010
Closes #24179
Closes vagnerclementino/elasticsearch/#98
2017-05-16 10:01:17 +02:00
Ryan Ernst 6ce597a378 Scripts: Convert template script engines to return String instead of BytesReference (#24447)
Template script engines (mustache, the only one) currently return a
BytesReference that users must know is utf8 encoded. This commit
modifies all callers and mustache to have the template engine return
String. This is much simpler, and does not require decoding in order to
use (for example, in ingest).
2017-05-15 22:37:31 -07:00
Jack Conradson 43292979fd Add New Security Script Settings (#24637)
Settings are simplified to allowed_types and allowed_contexts.  If a setting is not specified the default is to enable all for that setting.
2017-05-15 13:37:46 -07:00
Igor Motov 243635222a Move ReindexAction class to core (#24684)
This class is also needed for plugins to use reindex functionality.

Relates to #24578
2017-05-15 14:28:59 -04:00
Luca Cavanna 563e7ddc83 Pass over _routing value with more_like_this items to be retrieved (#24679)
When retrieving documents to extract terms from as part of a more like this query, the _routing value can be set, yet it gets lost. That leads to not being able to retrieve the documents, hence more_like_this used to return no matches all the time.

Closes #23699
2017-05-15 18:15:42 +02:00
Luca Cavanna e14ba81ac1 Make ObjectParser support string to boolean conversion (#24668)
We generally accept string values when a boolean is expected. We've been doing that in our parsing code, but we missed that bit when moving parsing code to ObjectParser, which throws an error instead. This commit makes ObjectParser parse also string values into booleans. It throws an error in case the value is not `true` or `false`.

Closes #21802
2017-05-15 18:15:20 +02:00
Tanguy Leroux 5fb04fa603 Merge remote-tracking branch 'origin/master' into feature/client_aggs_parsing 2017-05-15 17:08:26 +02:00
Tanguy Leroux dcb63ab8bc Share XContent rendering code in significant terms aggregations (#24677)
The rendering methods in String and Long Significant String aggregations
 and buckets are very similar. They can be factored out in the
 InternalSignificantTerms class an InternalMappedSignificantTerms class.
2017-05-15 16:52:02 +02:00
Christoph Büscher 60505c9100 Add parsing for InternalFilters aggregation (#24648)
This adds parsing to the InternalFilters aggregation.
2017-05-15 15:26:35 +02:00
Tanguy Leroux 578223f679 Make SignificantTerms.Bucket an interface rather than an abstract class (#24670)
This commit changes SignificantTerms.Bucket so that it is not an
abstract class anymore but an interface. It will be easier for the Java
High Level Rest Client to provide its own implementation of
SignificantTerms and SignificantTerms.Bucket. Also, it is now more
coherent with the others aggregations.
2017-05-15 15:14:07 +02:00
Christoph Büscher 0b688a8733 Small improvement in InternalAggregationTestCase test setup after changes in master (#24675) 2017-05-15 15:06:01 +02:00
Jason Tedor bd5aee8cfa Split disruption test suite
The disruption tests sit in a single test suite which causes these tests
to be single-threaded. We can split this test suite into multiple suites
(logically, of course) enabling them to be run in parallel reducing the
total run time of all integration tests in core. This commit splits the
discovery with service disruptions test suite into three suites
 - master disruptions
 - discovery disruptions
 - cluster disruptions

The last one could probably be better named, it is meant to represent
performing actions in the cluster (indexing, failing a shard, etc.)
while a disruption is taking place.

Relates #24662
2017-05-15 07:47:42 -04:00
Christoph Büscher 42e8d4b761 Merge branch 'master' into feature/client_aggs_parsing
Conflicts:
	core/src/test/java/org/elasticsearch/search/aggregations/bucket/filter/InternalFilterTests.java
	core/src/test/java/org/elasticsearch/search/aggregations/bucket/global/InternalGlobalTests.java
	core/src/test/java/org/elasticsearch/search/aggregations/bucket/missing/InternalMissingTests.java
	core/src/test/java/org/elasticsearch/search/aggregations/bucket/nested/InternalNestedTests.java
	core/src/test/java/org/elasticsearch/search/aggregations/bucket/nested/InternalReverseNestedTests.java
	core/src/test/java/org/elasticsearch/search/aggregations/bucket/sampler/InternalSamplerTests.java
	modules/parent-join/src/test/java/org/elasticsearch/join/aggregations/InternalChildrenTests.java
	test/framework/src/main/java/org/elasticsearch/search/aggregations/InternalSingleBucketAggregationTestCase.java
2017-05-15 12:25:07 +02:00
Christoph Büscher bb59ee51b0 Revert changing the InternalSampler type constant (#24667) 2017-05-15 11:49:47 +02:00
Kunal Kapoor fdb6cd8088 Deprecate use of + in index names (#24585)
Use of '+' in index names is implicit. There is no need to support it. This commit deprecates support for it.

Closes #24515
2017-05-15 11:26:51 +02:00
Koen De Groote f185b69e04 Replace manual copying an array or collection with static methods calls (#24657) 2017-05-15 09:35:48 +02:00
Ryan Ernst 17f8d2debd Settings: Remove support for yaml and json config files (#24664)
This commit removes the deprecated support for .yaml and .json files. If
the files still exist, the node will fail to start, indicating the file
must be converted or renamed.

closes #19391
2017-05-14 17:45:04 -07:00
Ryan Ernst e6535bc771 Settings: Update settings deprecation from yml to yaml (#24663)
This converts the deprecation added for 5.5 from .yml to .yaml. Note
that this deprecation has not been released yet.

relates #19391
2017-05-14 17:40:50 -07:00
Tanguy Leroux b9d2ecc3ea Add parsing methods to Range aggregations (#24583) 2017-05-12 16:52:47 +02:00
Tanguy Leroux f8df2a22e9 SniffNodesSampler should close connection after handling responses (#24632)
With the current implementation, SniffNodesSampler might close the
current connection right after a request is sent but before the response
is correctly handled. This causes to timeouts in the transport client
when the sniffing is activated.

closes #24575
closes #24557
2017-05-12 16:38:50 +02:00
Koen De Groote 878ae8eb3c Size lists in advance when known
When constructing an array list, if we know the size of the list in
advance (because we are adding objects to it derived from another list),
we should size the array list to the appropriate capacity in advance (to
avoid resizing allocations). This commit does this in various places.

Relates #24439
2017-05-12 10:36:13 -04:00
Simon Willnauer e8e2ccdcf5 Call onClose listener in a finally block 2017-05-12 16:32:29 +02:00
Jim Ferenczi 279a18a527 Add parent-join module (#24638)
* Add parent-join module

This change adds a new module named `parent-join`.
The goal of this module is to provide a replacement for the `_parent` field but as a first step this change only moves the `has_child`, `has_parent` queries and the `children` aggregation to this module.
These queries and aggregations are no longer in core but they are deployed by default as a module.

Relates #20257
2017-05-12 15:58:06 +02:00
Tanguy Leroux 29a5694bb7 Add parsing method to GeoHashGrid aggregation (#24589) 2017-05-12 15:44:39 +02:00
Simon Willnauer be2a6ce80b Notify onConnectionClosed rather than onNodeDisconnect to prune transport handlers (#24639)
Today we prune transport handlers in TransportService when a node is disconnected.
This can cause connections to starve in the TransportService if the connection is
opened as a short living connection ie. without sharing the connection to a node
via registering in the transport itself. This change now moves to pruning based
on the connections cache key to ensure we notify handlers as soon as the connection
is closed for all connections not just for registered connections.

Relates to #24632
Relates to #24575
Relates to #24557
2017-05-12 15:40:40 +02:00
Yannick Welsch 04e08f5e49 Simplify Discovery interface (#24608)
- Removes clusterState, getInitialClusterState and getMinimumMasterNodes methods from Discovery interface.
- Sets PingContextProvider in ZenPing constructor
- Renames state in ZenDiscovery to committedState
2017-05-12 14:08:14 +02:00
Christoph Büscher ee1303a9fc Merge branch 'master' into feature/client_aggs_parsing 2017-05-12 11:53:38 +02:00
Christoph Büscher f06467b6a0 [Tests] Add unit tests for InternalFilters (#24624)
Relates to #22278
2017-05-12 11:48:44 +02:00
Christoph Büscher 744b1afcb2 Merge branch 'master' into feature/client_aggs_parsing
Conflicts:
	core/src/test/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalHistogramTests.java
	core/src/test/java/org/elasticsearch/search/aggregations/bucket/terms/DoubleTermsTests.java
	core/src/test/java/org/elasticsearch/search/aggregations/bucket/terms/LongTermsTests.java
	core/src/test/java/org/elasticsearch/search/aggregations/bucket/terms/StringTermsTests.java
2017-05-12 10:55:05 +02:00
Byron Voorbach 70e14d5e3f Fix Source filtering in new field collapsing feature
Update ValueType of FetchSourceContext to OBJECT_ARRAY_BOOLEAN_OR_STRING to be in line with other source_filtering implementations
2017-05-12 09:38:16 +02:00
Koen De Groote 220bd2de6e Make a few class level fields static
This commit converts some final constant instance fields to class
fields.
2017-05-11 22:44:31 -04:00
Ryan Ernst f477a6472d Settings: Deprecate settings in .yml and .json (#24059)
This commit adds a deprecation warning when elasticsearch.yml or
elasticsearch.json is read during startup.

relates #19391
2017-05-11 13:11:18 -07:00
Ryan Ernst c1f1f66509 Scripting: Replace advanced and native scripts with ScriptEngine docs (#24603)
This commit documents how to write a `ScriptEngine` in order to use
expert internal apis, such as using Lucene directly to find index term
statistics. These documents prepare the way to remove both native
scripts and IndexLookup.

The example java code is actually compiled and tested under a new gradle
subproject for example plugins. This change does not yet breakup
jvm-example into the new examples dir, which should be done separately.

relates #19359
relates #19966
2017-05-11 12:15:16 -07:00
Ryan Ernst 17d01550c2 S3 Repository: Add back repository level credentials (#24609)
Specifying s3 access and secret keys inside repository settings are not
secure. However, until there is a way to dynamically update secure
settings, this is the only way to dynamically add repositories with
credentials that are not known at node startup time. This commit adds
back `access_key` and `secret_key` s3 repository settings, but protects
it with a required system property `allow_insecure_settings`.
2017-05-11 12:14:23 -07:00
Simon Willnauer 1155615536 Move DeleteByQuery and Reindex requests into core (#24578)
This allows other plugins to use a client to call the functionality
that is in the core modules without duplicating the logic.
Plugins can now safely send the request and response classes via the
client even if the requests are executed locally. All relevant classes
are loaded by the core classloader such that plugins can share them.

This is re-adds this commit that was revered in 952feb58e4
2017-05-11 20:22:30 +02:00
Jason Tedor 657686cefb Fix runtime class cast exception in TRA
If we fail to acquire the shard lock, need to retry and wait for the new
cluster state, we were sending the wrong kind of request for the replica
action. This commit fixes this issue.
2017-05-11 13:58:03 -04:00
qwerty4030 e7d352b489 Compound order for histogram aggregations. (#22343)
This commit adds support for histogram and date_histogram agg compound order by refactoring and reusing terms agg order code. The major change is that the Terms.Order and Histogram.Order classes have been replaced/refactored into a new class BucketOrder. This is a breaking change for the Java Transport API. For backward compatibility with previous ES versions the (date)histogram compound order will use the first order. Also the _term and _time aggregation order keys have been deprecated; replaced by _key.

Relates to #20003: now that all these aggregations use the same order code, it should be easier to move validation to parse time (as a follow up PR).

Relates to #14771: histogram and date_histogram aggregation order will now be validated at reduce time.

Closes #23613: if a single BucketOrder that is not a tie-breaker is added with the Java Transport API, it will be converted into a CompoundOrder with a tie-breaker.
2017-05-11 18:06:26 +01:00
Simon Willnauer 952feb58e4 Revert "Move DeleteByQuery and Reindex requests into core (#24578)"
This reverts commit 6ea2ae32b8.
2017-05-11 18:26:40 +02:00
Lee Hinman 57fddce8c4 [TEST] Use at least 1ms for FunctionScoreQueryBuilderTests
Previously micros or nanoseconds could be used, which was reduced to 0
milliseconds and `scale` must be higher than 0.
2017-05-11 10:10:55 -06:00
Jason Tedor d9cac191a2 Fix missing active IDs prevent advance test
This commit addresses an issue in the missing active IDs prevent advance
test from the global checkpoint tracker. The assumptions this test was
making about reality were violated when global checkpoints were inlined
(specifically, the component of that change where the tracker's
knowledge of the global checkpoint was updated inline with updates to
the tracker's knowledge of local checkpoints for an allocatio ID). The
point of the test was to ensure that a lagging shard prevents the global
checkpoint from advancing, so this commit rewrites the test with that in
mind.
2017-05-11 11:39:33 -04:00
Simon Willnauer 6ea2ae32b8 Move DeleteByQuery and Reindex requests into core (#24578)
This allows other plugins to use a client to call the functionality
that is in the core modules without duplicating the logic.
Plugins can now safely send the request and response classes via the
client even if the requests are executed locally. All relevant classes
are loaded by the core classloader such that plugins can share them.
2017-05-11 16:20:40 +02:00
Simon Willnauer 8f798f1231 Add up-to-date javadocs on Translog#syncNeeded 2017-05-11 15:28:39 +02:00
Simon Willnauer 64d0d9184d Fix IndexShardIT#testDurableFlagHasEffect to only test if operations have been synced
With global checkpoints we also take into account if a global checkpoint must be fsynced.
Yet, with recent addition of inlining global checkpoints into indexing operations from a
test perspective unnecessary fsyncs might be reported if `Translog#syncNeeded` is checked.
Now the test only check if the last write location triggers an fsync instead.

Closes #24600
2017-05-11 15:13:09 +02:00
Jason Tedor b6cb9a4e8a Fix checkpoints advance test
This commit fixes an issue in the checkpoints advance test. Namely, when
there zero documents indexed, after the global checkpoint is synced, the
global checkpoint will have advanced to the no ops performed. There is a
larger conceptual problem here, namely that the primary does not update
its knowledge of its own local checkpoint upon recovery which causes the
global checkpoint to initially be unassigned and then advance to no ops
performed, but this will be addressed in a follow-up.
2017-05-11 07:25:11 -04:00
Christoph Büscher c4fc8edc03 Add parsing for single bucket aggregations (#24564)
This adds parsing to all implementations of SingleBucketAggregations. They are mostly similar, so they share the common
base class `ParsedSingleBucketAggregation` and the shared base test `InternalSingleBucketAggregationTestCase`.
2017-05-11 11:50:35 +02:00
Martijn van Groningen e5b42bed50
inner_hits: Reuse inner hit query weight
Previously query weight was created for each search hit that needed to compute inner hits,
 with this change the weight of the inner hit query is computed once for all search hits.

Closes #23917
2017-05-11 11:48:13 +02:00
Christoph Büscher 570390ac36 Merge branch 'master' into feature/client_aggs_parsing 2017-05-11 11:20:39 +02:00
Jim Ferenczi e13db1b269 Validates updated settings on closed indices (#24487)
We allow non-dynamic settings to be updated on closed indices but we don't
check if the updated settings can be used to open/create the index.
This can lead to unrecoverable state where the settings are updated but the index
cannot be reopened since the settings are not valid. Trying to update the invalid settings
is also not possible since the update will fail to validate the current settings.
This change adds the validation of the updated settings for closed indices and make sure that the new settings
do not prevent the reopen of the index.

Fixes #23787
2017-05-11 11:06:55 +02:00
Ali Beyad bc223b6aef Removes completed snapshot from cluster state on master change (#24605)
Previously, if a master node updated the cluster state to reflect that a
snapshot is completed, but subsequently failed before processing a
cluster state to remove the snapshot from the cluster state, then the
newly elected master would not know that it needed to clean up the
leftover cluster state.

This commit ensures that the newly elected master sees if there is a
snapshot in the cluster state that is in the completed state but has not
yet been removed from the cluster state.

Closes #24452
2017-05-10 23:08:59 -04:00
Nik Everett 65f2717ab7 Make PreConfiguredTokenFilter harder to misuse (#24572)
There are now three public static method to build instances of
PreConfiguredTokenFilter and the ctor is private. I chose static
methods instead of constructors because those allow us to change
out the implementation returned if we so desire.

Relates to #23658
2017-05-10 22:39:43 -04:00
Jason Tedor 0b089ac084 Refresh at end of concurrent relocate test
We have to do something to force the global checkpoint to be
synchronized to the replicas or the assertions at the end of the test
that they are in sync will trip. Since the last write operation to hit a
replica shard will only carry the penultimate global checkpoint (it will
advance when the replicas respond with their local checkpoint), and a
background sync will not happen until the primary shard falls idle, we
force a sync through a refresh action.
2017-05-10 18:54:22 -04:00
Jack Conradson 349d1bd23e Fixes ScriptServiceTests.testDefaultBehaviourFineGrainedSettings due to
an error with the fine grained settings deprecation.
2017-05-10 15:00:29 -07:00
Ali Beyad 63a408a128 Updates version for get snapshot API with verbose option to 5.5 2017-05-10 17:38:23 -04:00
Jack Conradson 6ac8a1eb85 Deprecate Fine Grain Settings for Scripts (#24573) 2017-05-10 13:09:31 -07:00
Ali Beyad 743217a430 Enhances get snapshots API to allow retrieving repository index only (#24477)
Currently, the get snapshots API (e.g. /_snapshot/{repositoryName}/_all)
provides information about snapshots in the repository, including the
snapshot state, number of shards snapshotted, failures, etc.  In order
to provide information about each snapshot in the repository, the call
must read the snapshot metadata blob (`snap-{snapshot_uuid}.dat`) for
every snapshot.  In cloud-based repositories, this can be expensive,
both from a cost and performance perspective.  Sometimes, all the user
wants is to retrieve all the names/uuids of each snapshot, and the
indices that went into each snapshot, without any of the other status
information about the snapshot.  This minimal information can be
retrieved from the repository index blob (`index-N`) without needing to
read each snapshot metadata blob.

This commit enhances the get snapshots API with an optional `verbose`
parameter.  If `verbose` is set to false on the request, then the get
snapshots API will only retrieve the minimal information about each
snapshot (the name, uuid, and indices in the snapshot), and only read
this information from the repository index blob, thereby giving users
the option to retrieve the snapshots in a repository in a more
cost-effective and efficient manner.

Closes #24288
2017-05-10 15:48:40 -04:00
Jason Tedor fbf532a626 Revert "Add global checkpoint assertion in index shard"
This reverts commit 89b305c09e.
2017-05-10 14:28:07 -04:00
Lee Hinman d2c69701e6 Fix SocketPermission in test framework for alpha2 bump
It was using the wrong version, which can cause errors like

```
  1> java.security.AccessControlException: access denied ("java.net.SocketPermission" "[0:0:0:0:0:0:0:1]:34221" "connect,resolve")
  1> 	at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472) ~[?:1.8.0_111]
  1> 	at java.security.AccessController.checkPermission(AccessController.java:884) ~[?:1.8.0_111]
  1> 	at java.lang.SecurityManager.checkPermission(SecurityManager.java:549) ~[?:1.8.0_111]
  1> 	at java.lang.SecurityManager.checkConnect(SecurityManager.java:1051) ~[?:1.8.0_111]
  1> 	at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:625) ~[?:?]
  1> 	at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processSessionRequests(DefaultConnectingIOReactor.java:273) ~[httpcore-nio-4.4.5.jar:4.4.5]
  1> 	at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvents(DefaultConnectingIOReactor.java:139) ~[httpcore-nio-4.4.5.jar:4.4.5]
  1> 	at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:348) ~[httpcore-nio-4.4.5.jar:4.4.5]
  1> 	at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.execute(PoolingNHttpClientConnectionManager.java:192) ~[httpasyncclient-4.1.2.jar:4.1.2]
1> at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase$1.run(CloseableHttpAsyncClientBase.java:64) ~[httpasyncclient-4.1.2.jar:4.1.2]
```

When running tests
2017-05-10 11:27:57 -06:00
Christoph Büscher ae5919e5df Tests: Fix VersionTests after version bump 2017-05-10 18:18:22 +02:00
javanna 2e602d6641 [TEST] reset subAggregationsSupplier in AggregationsTests to empty sub-aggs once the maxDepth is reached
If we don't do this, although we don't set the subAggsSupplier again, we will reuse the one set in the previous run, hence we can end up in situations where we keep on generating sub aggregations till a StackOverflowError gets thrown.
2017-05-10 17:51:58 +02:00
Christoph Büscher 64ecf4f4bf Bumping version to v6.0.0-alpha2 2017-05-10 17:12:56 +02:00
David Roberts d611ab4855 Avoid race when shutting down controller processes (#24579)
This commit terminates any controller processes plugins might have after
the node has been closed.  This gives the plugins a chance to shut down their
controllers gracefully.

Previously there was a race condition where controller processes could be shut
down gracefully and terminated by two threads running in parallel, leading to
non-deterministic outcomes.

Additionally, controller processes that failed to shut down gracefully were
not forcibly terminated when running as a Windows service; there was a reliance
on the plugin to shut down its controller gracefully in this situation.
This commit also fixes this problem.
2017-05-10 14:59:14 +01:00
Tanguy Leroux 3201e22710 Fix merging conflicts 2017-05-10 14:05:43 +02:00
Tanguy Leroux bf718a686f Merge remote-tracking branch 'origin/master' into feature/client_aggs_parsing
# Conflicts:
#	core/src/test/java/org/elasticsearch/search/aggregations/bucket/terms/InternalTermsTestCase.java
#	core/src/test/java/org/elasticsearch/search/aggregations/metrics/InternalExtendedStatsTests.java
#	core/src/test/java/org/elasticsearch/search/aggregations/metrics/InternalMaxTests.java
#	core/src/test/java/org/elasticsearch/search/aggregations/metrics/InternalStatsTests.java
#	core/src/test/java/org/elasticsearch/search/aggregations/metrics/avg/InternalAvgTests.java
#	core/src/test/java/org/elasticsearch/search/aggregations/metrics/cardinality/InternalCardinalityTests.java
#	core/src/test/java/org/elasticsearch/search/aggregations/metrics/geobounds/InternalGeoBoundsTests.java
#	core/src/test/java/org/elasticsearch/search/aggregations/metrics/geocentroid/InternalGeoCentroidTests.java
#	core/src/test/java/org/elasticsearch/search/aggregations/metrics/min/InternalMinTests.java
#	core/src/test/java/org/elasticsearch/search/aggregations/metrics/percentiles/InternalPercentilesTestCase.java
#	core/src/test/java/org/elasticsearch/search/aggregations/metrics/percentiles/hdr/InternalHDRPercentilesRanksTests.java
#	core/src/test/java/org/elasticsearch/search/aggregations/metrics/percentiles/tdigest/InternalTDigestPercentilesRanksTests.java
#	core/src/test/java/org/elasticsearch/search/aggregations/metrics/sum/InternalSumTests.java
#	core/src/test/java/org/elasticsearch/search/aggregations/metrics/valuecount/InternalValueCountTests.java
#	core/src/test/java/org/elasticsearch/search/aggregations/pipeline/InternalSimpleValueTests.java
#	core/src/test/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/percentile/InternalPercentilesBucketTests.java
#	core/src/test/java/org/elasticsearch/search/aggregations/pipeline/derivative/InternalDerivativeTests.java
#	test/framework/src/main/java/org/elasticsearch/test/InternalAggregationTestCase.java
2017-05-10 13:40:39 +02:00
Tanguy Leroux 3e4406f044 [Test] Fix wrong import 2017-05-10 12:31:28 +02:00
Tanguy Leroux 2fe53be0db [Test] Add unit tests for Range aggregations (#24569)
Related to #22278
2017-05-10 12:22:52 +02:00
Tanguy Leroux 7c97296d77 [Test] Reference Terms aggregations in AggregationsTests 2017-05-10 11:37:20 +02:00
Tanguy Leroux 2178491387 Fix checkstyle violation 2017-05-10 11:34:34 +02:00
Martijn van Groningen 51c74ce547
Added unit tests for InternalMatrixStats.
Also moved InternalAggregationTestCase to test-framework module in order to make use of it from other modules than core.

Relates to #22278
2017-05-10 11:06:18 +02:00
Matt Weber b24326271e Add ICUCollationFieldMapper (#24126)
Adds a new "icu_collation" field type that exposes lucene's
ICUCollationDocValuesField.  ICUCollationDocValuesField is the replacement
for ICUCollationKeyFilter which has been deprecated since Lucene 5.
2017-05-10 10:35:11 +02:00
Tanguy Leroux 3c66ac06ae Add parsing for String/Long/Double Terms aggregations (#24521) 2017-05-10 10:17:25 +02:00
Ryan Ernst 9ca7d28552 Scripting: Remove "service" from ScriptEngine interface name (#24574)
This commit renames ScriptEngineService to ScriptEngine.  It is often
confusing because we have the ScriptService, and then
ScriptEngineService implementations, but the latter are not services as
we see in other places in elasticsearch.
2017-05-10 00:47:33 -07:00
Christoph Büscher 01b976071f Merge branch 'master' into feature/client_aggs_parsing 2017-05-10 09:40:26 +02:00
Ryan Ernst 5242d3aeb0 Fix ids query builder test to use the same logic for matchnodocs as the
builder itself
2017-05-09 16:53:19 -07:00
Ryan Ernst ebd3e5f73f Scripting: Deprecate file script settings (#24555)
File scripts have 2 related settings: the path of file scripts, and
whether they can be dynamically reloaded. This commit deprecates those
settings.

relates #21798
2017-05-09 16:14:57 -07:00
Ryan Ernst 53f6d9412e Fix ids query test when none or ALL type is used
See #24460
2017-05-09 14:52:28 -07:00
Jason Tedor b6906702cc Remove global checkpoint constraint
A constraint on the global checkpoint was inadvertently committed from
the inlining global checkpoint work. Namely, the constraint prevents the
global checkpoint from advancing to no ops performed, a situation that
can occur when shards are started but empty.
2017-05-09 17:17:09 -04:00
javanna 37dc165e7f [TEST] add test to verify that no aggs have been forgotten in AggregationsTests 2017-05-09 21:23:00 +02:00
Jason Tedor 8f873620ee Inline global checkpoints
Today we rely on background syncs to relay the global checkpoint under
the mandate of the primary to its replicas. This means that the global
checkpoint on a replica can lag far behind the primary. The commit moves
to inlining global checkpoints with replication requests. When a
replication operation is performed, the primary will send the latest
global checkpoint inline with the replica requests. This keeps the
replicas closer in-sync with the primary.

However, consider a replication request that is not followed by another
replication request for an indefinite period of time. When the replicas
respond to the primary with their local checkpoint, the primary will
advance its global checkpoint. During this indefinite period of time,
the replicas will not be notified of the advanced global
checkpoint. This necessitates a need for another sync. To achieve this,
we perform a global checkpoint sync when a shard falls idle.

Relates #24513
2017-05-09 15:08:11 -04:00
Luca Cavanna c5bdbecc64 [TEST] Add test for Aggregations#fromXContent (#24524)
AggregationsTests#testFromXContent verifies that parsing of aggregations works by combining multiple aggs at the same level, and also adding sub-aggregations to multi bucket and single bucket aggs, up to a maximum depth of 5.
2017-05-09 21:08:10 +02:00
Nik Everett bb06d8ec4f Allow plugins to build pre-configured token filters (#24223)
This changes the way we register pre-configured token filters so that
plugins can declare them and starts to move all of the pre-configured
token filters out of core. It doesn't finish the job because doing
so would make the change unreviewably large. So this PR includes
a shim that keeps the "old" way of registering pre-configured token
filters around.

The Lowercase token filter is special because there is a "special"
interaction between it and the lowercase tokenizer. I'm not sure
exactly what to do about it so for now I'm leaving it alone with
the intent of figuring out what to do with it in a followup.

This also renames these pre-configured token filters from
"pre-built" to "pre-configured" because that seemed like a more
descriptive name.

This is a part of #23658
2017-05-09 14:50:49 -04:00
Christoph Büscher 1959fd6a1a Merge branch 'master' into feature/client_aggs_parsing 2017-05-09 19:54:36 +02:00
Nik Everett 428390865c Tests: Give stats tests long to wait for listener
This test waited 10 seconds for a refresh listener to appear in
the stats. It turns out that in our NFS testing infrastructure this can
take a lot longer than 10 seconds. The error reported here:
https://elasticsearch-ci.elastic.co/job/elastic+elasticsearch+master+nfs/257/consoleFull
has it taking something like 15 seconds. This bumps the timeout
to a solid minute.

Closes #24417
2017-05-09 13:33:33 -04:00
Jim Ferenczi b6c714ccc8 Fix BWC for query_and_fetch 2017-05-09 18:52:53 +02:00
Jim Ferenczi a404f0aca7 Cleanup BWC for single shard optimization
The BWC layer is needed only for pre 5.3 indices.
2017-05-09 16:54:44 +02:00
Adrien Grand a72eaa8e0f Identify documents by their `_id`. (#24460)
Now that indices have a single type by default, we can move to the next step
and identify documents using their `_id` rather than the `_uid`.

One notable change in this commit is that I made deletions implicitly create
types. This helps with the live version map in the case that documents are
deleted before the first type is introduced. Otherwise there would be no way
to differenciate `DELETE index/foo/1` followed by `PUT index/foo/1` from
`DELETE index/bar/1` followed by `PUT index/foo/1`, even though those are
different if versioning is involved.
2017-05-09 16:33:52 +02:00
Jim Ferenczi 4df636b5ef Fix single shard scroll within a cluster with nodes in version >= 5.3 and <= 5.3 (#24512)
If a node in version >= 5.3 acts as a coordinating node during a scroll request that targets a single shard, the scroll may return the same documents over and over iff the targeted shard is hosted by a node with a version <= 5.3.
The nodes in this version will advance the scroll only if the search_type has been set to `query_and_fetch` though this search type has been removed in 5.3.
This change handles this situation by adding the removed search_type in the request that targets a node in version <= 5.3.
2017-05-09 09:14:17 +02:00
Tal Levy 423b0f5e3d add option for _ingest.timestamp to use new ZonedDateTime (#24030)
Previously, Mustache would call `toString` on the `_ingest.timestamp`
field and return a date format that did not match Elasticsearch's
defaults for date-mapping parsing. The new ZonedDateTime class in Java 8
happens to do format itself in the same way ES is expecting.

This commit adds support for a feature flag that enables the usage of this new date format 
that has more native behavior.

Fixes #23168.

This new fix can be found in the form of a cluster setting called
`ingest.new_date_format`. By default, in 5.x, the existing behavior
will remain the same. One will set this property to `true` in order to
take advantage of this update for ingest-pipeline convenience.
2017-05-08 15:06:39 -07:00
joachimdraeger fec1802e2f Fixes inefficient loading of snapshot repository data (#24510)
This commit fixes inefficient (worst case exponential) loading of 
snapshot repository data when checking for incompatible snapshots,
that was introduced in #22267.  When getting snapshot information,
getRepositoryData() was called on every snapshot, so if there are
a large number of snapshots in the repository and _all snapshots
were requested, the performance degraded exponentially.  This
commit fixes the issue by only calling getRepositoryData once and
using the data from it in all subsequent calls to get snapshot 
information.

Closes #24509
2017-05-08 17:43:01 -04:00
Ryan Ernst bd3717a0f8 Scripting: Deprecate file scripts (#24552)
File scripts will be removed in 6.0. This commit adds a deprecation
warning for 5.5 when the first file script is loaded.
2017-05-08 14:06:45 -07:00
Jason Tedor 0944577ee8 Remove commented code from ESILRTC
This commit removes some commented out code from
ESIndexLevelReplicationTestCase.java that was inadvertently committed.
2017-05-08 16:20:58 -04:00
Jason Tedor 1de5bb8cd5 Ensure test replicas have valid recovery state
When starting a new replication group in an index level replication test
case, a started replica would not have a valid recovery state. This
violates simple assumptions as replicas always have to have recovered
before being started. This commit causes this to be the case that this
assumption is not violated too.
2017-05-08 16:19:47 -04:00
Jason Tedor 89b305c09e Add global checkpoint assertion in index shard
We previously removed this assertion because it could be violated in
races. This commit adds this assertion back with sampling done more
carefully to avoid failures solely due to race conditions.
2017-05-08 13:37:28 -04:00
Jason Tedor bf32b0c59d Improve bootstrap checks error messages
When multiple bootstrap checks fail, it's not clear where one error
message begins and the next error message ends. This commit numbers the
bootstrap check error messages so they are easier to read.

Relates #24548
2017-05-08 12:32:57 -04:00
Lee Hinman 1907c46689 Refactor UpdateHelper into unit-testable pieces
This starts breaking up the `UpdateHelper.prepare` method so that each piece can
be individually unit tested. No actual functionality has changed.

Note however, that I did add a TODO about `ctx.op` leniency, which I'd love to
remove as a separate PR if desired.
2017-05-08 09:00:47 -06:00
Jason Tedor 0ec30eb8e0 Fix cache expire after access
This commit fixes a bug in the cache expire after access
implementation. The bug is this: if you construct a cache with an expire
after access of T, put a key, and then touch the key at some time t > T,
the act of getting the key would update the access time for the entry
before checking if the entry was expired. There are situations in which
expire after access would be honored (e.g., if the cache needs to prune
the LRU list to keep the cache under a certain weight, or a manual
refresh was called) but this behavior is otherwise broken.

Relates #24546
2017-05-08 09:49:14 -04:00
Hendrik Muhs f41ddb3607 Move MockLogAppender to elasticsearch test (#24542)
In order to make MockLogAppender (utility to test logging) available outside
of es-core move MockLogAppender from test core-tests to test framework. As
package names do not change, no need to change clients.
2017-05-08 13:02:27 +02:00
Jason Tedor bbdaf113d4 Remove gap skipping when opening engine
Today when opening the engine we skip gaps in the history, advancing the
local checkpoint until it is equal to the maximum sequence number
contained in the commit. This allows history to advance, but it leaves
gaps. A previous change filled these gaps when recovering from store,
but since we were skipping the gaps while opening the engine, this
change had no effect. This commit removes the gap skipping when opening
the engine allowing the gap filling to do its job.

Relates #24535
2017-05-08 06:38:28 -04:00
Koen De Groote 13c17c75b5 Remove unneeded empty string concatentation
This commit removes concatenation by empty string in places where it
is simply not needed to obtain a string representation.

Relates #24411
2017-05-06 00:28:53 -04:00
Jason Tedor 4027c9da7b TimeValue#parseTimeValue author is bad, feels bad
I stumbled on this code today and I hated it; I wrote it. I did not like
that you could not tell at a glance whether or not the method parameters
were correct. This commit fixes it.

Relates #24522
2017-05-05 18:37:09 -04:00
Tanguy Leroux c7c524dd3f Merge remote-tracking branch 'origin/master' into feature/client_aggs_parsing 2017-05-05 21:54:37 +02:00
Tanguy Leroux 7bd2abe48a Change Terms.Bucket to an interface (#24492)
This commit changes the Terms.Bucket abstract class to an interface, so
that it's easier for the Java High Level Rest Client to provide its own
implementation.

In its current state, the Terms.Bucket abstract class inherits from
InternalMultiBucketAggregation.InternalBucket which forces subclasses to
implement Writeable and exposes a public getProperty() method that relies
on InternalAggregation. This two points make it difficult for the Java
High Level Rest Client to implement the Terms and Terms.Bucket correctly.
This is also different from other MultiBucketsAggregation like Range
which are pure interfaces.

Changing Terms.Bucket to an interface causes a method clashes for the
`getBuckets()` method in InternalTerms. This is because:
 - InternalTerms implements Terms which declared a
 `List<Terms.Bucket> getBuckets()` method
 - InternalTerms extends InternalMultiBucketAggregation which declares a
 `List<? extends InternalBucket> getBuckets()` method
 - both overrides the MultiBucketsAggregation
 `List<? extends Bucket> getBuckets()` method

 There was no clashes before this change because Terms.Bucket extends
 InternalBucket and conformed to both declaration. With Terms.Bucket now
 an interface, the getBuckets() method in the Terms interface is changed
 to avoid method clash. This is a breaking change in the Java API but
 it's a straightforward change and the Terms multi bucket aggregation
 interface is also more coherent with the other Range, Histogram,
 Filters, AdjacencyMatrix etc that all return a `List<? extends Bucket>`.
2017-05-05 20:00:39 +02:00
Nicholas Knize 0c4eb0a029 Add new ip_range field type
This commit adds support for indexing and searching a new ip_range field type. Both IPv4 and IPv6 formats are supported. Tests are updated and docs are added.
2017-05-05 09:43:42 -05:00
Simon Willnauer e3766d2828 Expand cross cluster search indices for search requests to the concrete index or to it's aliases (#24502)
This change will expand the shard level request to the actual concrete index or to the aliases
that expanded to the concrete index to ensure shard level requests won't see wildcard expressions as their original indices
2017-05-05 16:40:04 +02:00
Simon Willnauer 03267e03da Fix NPE if field caps request has a field that exists not in all indices (#24504)
If a field caps request contains a field name that doesn't exist in all indices
the response will be partial and we hide an NPE. The NPE is now fixed but we still
have the problem that we don't pass on errors on the shard level to the user. This will
be fixed in a followup.
2017-05-05 11:56:03 +02:00
Simon Willnauer 6b67e0bf2f Include all aliases including non-filtering in `_search_shards` response (#24489)
`_search_shards`API today only returns aliases names if there is an alias
filter associated with one of them. Now it can be useful to see which aliases
have been expanded for an index given the index expressions. This change also includes non-filtering aliases even without a filtering alias being present.
2017-05-05 09:34:12 +02:00
Yannick Welsch c8712e9531 Limit AllocationService dependency injection hack (#24479)
Changes the scope of the AllocationService dependency injection hack so that it is at least contained to the AllocationService and does not leak into the Discovery world.
2017-05-05 08:39:18 +02:00
Igor Motov 6002b41b5f Add StreamInput.readEnum and StreamOutput.writeEnum (#24475)
Implements the common enum serialization/deserialization pattern for enumeration on the StreamInput/StreamOutput.
2017-05-04 12:22:54 -04:00
Jason Tedor de65f51d34 Simplify file store
Today we go to heroic lengths to workaround bugs in the JDK or around
issues like BSD jails to get information about the underlying file
store. For example, we went to lengths to work around a JDK bug where
the file store returned would incorrectly report whether or not a path
is writable in certain situations in Windows operating
systems. Another bug prevented getting file store information on
Windows on a virtual drive on Windows. We no longer need to work
around these bugs, we could simply try to write to disk and let an I/O
exception arise if we could not write to the disk or take advantage of
the fact that these bugs are fixed in recent releases of the JDK
(e.g., the file store bug is fixed since 8u72). Additionally, we
collected information about all file stores on the system which meant
that if the user had a stale NFS mount, Elasticsearch could hang and
fail on startup if that mount point was not available. Finally, we
collected information through Lucene about whether or not a disk was a
spinning disk versus an SSD, information that we do not need since we
assume SSDs by default. This commit takes into consideration that we
simply do not need this heroic effort, we do not need information
about all file stores, and we do not need information about whether or
not a disk spins to greatly simplfy file store handling.

Relates #24402
2017-05-04 11:19:41 -04:00
Jason Tedor cb46e97a04 Fix reschedule async fsync test
This commit fixes the reschedule async fsync test in index service
tests. This test was passing for the wrong reason. Namely, the test was
trying to set translog durability to async, fire off an indexing
request, and then assert that the translog eventually got fsynced. The
problem here is that in the course of issuing the indexing request, a
mapping update is trigger. The mapping update triggers the index
settings to be refreshed. Since the test did not issue a cluster state
update to change the durability from request to async but instead did
this directly through index service, the mapping update flops the
durability back to async. This means that when the indexing request
executes, an fsync is performed after the request and the assertoin that
an fsync is not needed passes but for the wrong reason (in short: the
test wanted it to pass because an async fsync fired, but instead it
passed because a request async fired). This commit fixes this by going
through the index settings API so that a proper cluster state update is
triggered and so the mapping update does not flop the durability back to
request.
2017-05-04 10:41:20 -04:00
Jason Tedor 50b617f73a Remove global checkpoint assertion in index shard
Due to races, this assertion in index shard can be wrong. This commit
removes that assertion and adjusts the explanatory comment.
2017-05-04 10:33:42 -04:00
Adrien Grand 977016ba25 Do not index `_type` when there is at most one type. (#24363)
This change makes `_type` behave pretty much like `_index` when
`index.mapping.single_type` is true.
2017-05-04 16:29:35 +02:00
Jason Tedor 1fc777b6e3 Change logging level on reroute test
We are still chasing a test failure here and increasing the logging
level stopped the failures. We have a theory as to what is going on so
this commit reduces the logging level to hopefully trigger the failure
again and give us the logging that we need to confirm the theory.
2017-05-04 09:23:19 -04:00
Jim Ferenczi c4002e5ca4 Bump the Lucene version for ES V5_4_1 2017-05-04 14:50:05 +02:00
Simon Willnauer 8356df0846 [TEST] Add a test that alias requests are dense for all indices 2017-05-04 14:29:59 +02:00
Jim Ferenczi 01872f3649 Add version for 5.4.1 and bwc indices for 5.4.0 2017-05-04 13:29:03 +02:00
Simon Willnauer c4eea85713 Use V_5_5_UNRELEASED constant consitently on both request and response 2017-05-04 11:52:07 +02:00
Simon Willnauer 14e57bf9f8 Add cross cluster support to `_field_caps` (#24463)
To support kibana this commit adds an internal optimization
to support the cross cluster syntax for indices on the `_field_caps`
API.

Closes #24334
2017-05-04 11:44:54 +02:00
Adrien Grand d0e71510ad Enforce at most one type. (#24428)
This is a follow-up to #24317, which did the hard work but was merged in such a
way that it exposes the setting while still allowing indices to have multiple
types by default in order to give time to people who test against master to
add this setting to their index settings.
2017-05-04 10:27:50 +02:00
Jason Tedor 4862544934 Increase logging in IndexRecoveryIT#rerouteTest
This test started failing but the logging here is insufficient to
discern what is happening. This commit increases the logging level on
this test until the failure can be understood.
2017-05-03 20:11:41 -04:00
javanna 62c37339b8 Merge branch 'master' into feature/client_aggs_parsing 2017-05-03 22:04:06 +02:00
Igor Motov cacba6bc46 Allow plugins to upgrade templates and index metadata on startup (#24379)
The UpgraderPlugin adds two additional extension points called during cluster upgrade and when old indices are introduced into the cluster state during initial recovery, restore from a snapshot or as a dangling index. One extension point allows plugin to update old templates and another extension points allows to update/check index metadata.
2017-05-03 12:51:41 -04:00
Tim Brooks 855b64b0ee Add non-dispatching listenable action future (#24412)
Currently the only implementation of `ListenableActionFuture` requires
dispatching listener execution to a thread pool. This commit renames
that variant to `DispatchingListenableActionFuture` and converts
`AbstractListenableActionFuture` to be a variant that does not require
dispatching. That class is now named `PlainListenableActionFuture`.
2017-05-03 10:30:54 -05:00
Yannick Welsch 7ecb79a8e1 Remove DiscoveryNodesProvider interface (#24461)
The DiscoveryNodesProvider interface provides an unnecessary abstraction and is just used in conjunction with the existing PingContextProvider interface. This commit removes it.
2017-05-03 16:29:51 +02:00
Luca Cavanna 144f96eaeb Open/Close index api to allow_no_indices by default (#24401)
Open/Close index api have allow_no_indices set to false by default, while delete index has it set to true. The flag controls where a wildcard expression that matches no indices will be ignored or an error will be thrown instead. This commit aligns open/close default behaviour to that of delete index.
2017-05-03 16:22:26 +02:00
Jason Tedor 16af0a9ce2 Remove unnecessary field from UnicastZenPing
This field was only ever used in the constructor, where it was set and
then passed around. As such, there's no need for it to be a field and we
can remove it.
2017-05-03 09:22:24 -04:00
Tanguy Leroux 2ac90b3de9 Add parsing methods for InternalDateHistogram and InternalHistogram (#24213) 2017-05-03 13:27:20 +02:00
Jason Tedor 070963658b Block global checkpoint advances when recovering
After a replica shard finishes recovery, it will be marked as active and
its local checkpoint will be considered in the calculation of the global
checkpoint on the primary. If there were operations in flight during
recovery, when the replica is activated its local checkpoint could be
lagging behind the global checkpoint on the primary. This means that
when the replica shard is activated, we can end up in a situtaion where
a global checkpoint update would want to move the global checkpoint
backwards, violating an invariant of the system. This only arises if a
background global checkpoint sync executes, which today is only a
scheduled operation and might be delayed until the in-flight operations
complete and the replica catches up to the primary. Yet, we are going to
move to inlining global checkpoints which will cause this issue to be
more likely to manifest. Additionally, the global checkpoint on the
replica, which is the local knowledge on the replica updated under the
mandate of the primary, could be higher than the local checkpoint on the
replica, again violating an invariant of the system. This commit
addresses these issues by blocking global checkpoint on the primary when
a replica shard is finalizing recovery. While we have blocked global
checkpoint advancement, recovery on the replica shard will not be
considered complete until its local checkpoint advances to the blocked
global checkpoint.

Relates #24404
2017-05-03 06:48:09 -04:00
Simon Willnauer c99cc8a896 Preserve cluster alias throughout search execution to lookup nodes by cluster and ID (#24438)
today we only lookup nodes by their ID but never by the (clusterAlias, nodeId) tuple.
This could in theory lead to lookups on the wrong cluster if there are 2 clusters
with a node that has the same ID. It's very unlikely to happen but we now can clearly
disambiguate between clusters and their nodes.
2017-05-03 12:03:30 +02:00
javanna 194742b3f4 [TEST] Remove unnecessary usages of ListenableActionFuture 2017-05-03 11:42:06 +02:00
Luca Cavanna 92bfd16c58 Java api: ActionRequestBuilder#execute to return a PlainActionFuture (#24415)
This change makes the request builder code-path same as `Client#execute`. The request builder used to return a `ListenableActionFuture` when calling execute, which allows to associate listeners with the returned future. For async execution though it is recommended to use the `execute` method that accepts an `ActionListener`, like users would do when using `Client#execute`.

Relates to #24412
Relates to #9201
2017-05-03 11:20:53 +02:00
Luca Cavanna fbd793d9e6 Introduce SearchResponseSections base class (#24442)
SearchResponseSections is the common part extracted from InternalSearchResponse that can be shared between high level REST and elasticsearch. The only bits left out are around serialization which is not supported. This way it can accept Aggregations as a constructor argument, without requiring InternalAggregations, as the high level REST client uses its own objects for aggs parsing rather than internal ones.

This change also makes Aggregations implement ToXContent, and Aggregation extend ToXContent. Especially the latter is suboptimal but the best solution that allows to share as much code as possible between core and the client, that doesn't require messing with generics and making the api complicated. Also it doesn't have downsides as all of the current implementations of Aggregation do implement ToXContent already.
2017-05-03 10:45:31 +02:00
Yannick Welsch be19ccef57 Discard stale node responses from async shard fetching (#24434)
Async shard fetching only uses the node id to correlate responses to requests. This can lead to a situation where a response from an earlier request is mistaken as response from a new request when a node is restarted. This commit adds unique round ids to correlate responses to requests.
2017-05-03 09:47:21 +02:00
Jason Tedor 4a578e9c71 Show JVM arguments
We often want the JVM arguments used for a running instance of
Elasticsearch. It sure would be nice if these came as part of the nodes
API, or any API that includes JVM info. This commit causes these
arguments to be displayed.

Relates #24450
2017-05-02 22:25:52 -04:00
Jason Tedor 4289e206ae Log JVM arguments on startup
These can be very useful to have, let's have them at our fingertips in
the logs (in case the JVM dies and we can no longer retrieve them, at
least they are here).

Relates #24451
2017-05-02 21:33:24 -04:00
Nik Everett 732741dd8d Build that java api docs from a test (#24354)
We've had `QueryDSLDocumentationTests` for a while but it had a very
hopeful comment at the top about how we want to make sure that the
example in the query-dsl docs match up with the test but we never
had anything that made *sure* that they did. This changes that!

Now the examples from the query-dsl docs are all built from the
`QueryDSLDocumentationTests`. All except for the percolator example
because that is hard to do as it stands now.

To make this easier this change moves `QueryDSLDocumentationTests`
from core and into the high level rest client. This is useful for
two reasons:
1. We expect the high level rest client to be able to use the builders.
2. The code that builds that docs doesn't check out all of
Elasticsearch. It only checks out certain directories. Since we're
already including snippets from that directory we don't have to
make any changes to that process.

Closes #24320
2017-05-02 13:00:56 -04:00
Simon Willnauer 2f9e9460d4 Move RemoteClusterService into TransportService (#24424)
TransportService and RemoteClusterService are closely coupled already today
and to simplify remote cluster integration down the road it can be a direct
dependency of TransportService. This change moves RemoteClusterService into
TransportService with the goal to make it a hidden implementation detail
of TransportService in followup changes.
2017-05-02 18:09:32 +02:00
Simon Willnauer 691ec68a3c Extract a common base class to allow services to listen to remote cluster config updates (#24367)
RemoteClusterService is an internal service that should not necessarily be exposed
to plugins or other parts of the system. Yet, for cluster name parsing for instance
it is crucial to reuse some code that is used for the RemoteClusterService. This
change extracts a base class that allows to share the settings related code as well
as cluster settings updates to `search.remote.*` to be observed by other services.
2017-05-02 16:02:36 +02:00
Ali Beyad 1435c23df2 Adds check to snapshot repository incompatible-snapshots blob to delete
a pre-existing one before attempting to overwrite it.
2017-05-02 09:56:05 -04:00
javanna 60866da4b7 Merge branch 'master' into feature/client_aggs_parsing 2017-05-02 12:48:30 +02:00
Colin Goodheart-Smithe 7b7cc488da
Fixes checkstyle errors 2017-05-02 11:37:36 +01:00
Winston Ewert c1ba4fdcb4 Allow scripted metric agg to access `_score` (#24295)
* Fixes #24259

Corrects the ScriptedMetricAggregator so that the script can have
access to scores during the map stage.

* Restored original tests. Added seperate test.

As requested, I've restored the non-score dependant tests, and added the
score dependent metric as a seperate test.
2017-05-02 11:24:23 +01:00
Tanguy Leroux ad3c042fc4 [Test] Add unit tests for HDR/TDigest PercentilesAggregators (#24245)
Relates to #22278
2017-05-02 10:55:45 +02:00
David Pilato 186b401fd8 Upgrade to JUnit 4.12 (#23877)
* Upgrade to JUnit 4.12
* Add permission to junit 4.12 and remove junit4-ant specific permission
2017-05-02 09:58:21 +02:00
Ali Beyad 9878aae144 Ensure every repository has an incompatible-snapshots blob (#24403)
In #22267, we introduced the notion of incompatible snapshots in a
repository, and they were stored in a root-level blob named
`incompatible-snapshots`.  If there were no incompatible snapshots in
the repository, then there was no `incompatible-snapshots` blob.

However, this causes a problem for some cloud-based repositories,
because if the blob does not exist, the cloud-based repositories may
attempt to keep retrying the read of a non-existent blob with
expontential backoff until giving up.  This causes performance issues
(and potential timeouts) on snapshot operations because getting the
`incompatible-snapshots` is part of getting the repository data (see
RepositoryData#getRepositoryData()).

This commit fixes the issue by creating an empty
`incompatible-snapshots` blob in the repository if one does not exist.
2017-05-01 15:09:21 -04:00
Nik Everett 8f1fe51f34 Test: more logging for refresh listeners many threads test
This test fails from time to time but doesn't give enough information
for me to figure out what caused the assertion to fail.

Relates to #24418
2017-05-01 14:50:13 -04:00
Luca Cavanna 91fbb0ba28 Move IndicesAliasesRequest#concreteAliases to TransportIndicesAliasesAction (#24400)
This method has to do with how the transport action may or may not resolve wildcards expressions to aliases names. It is only needed in TransportIndicesAliasesAction and for this reason it should be a private method in it rather than part of a request class which is also part of the Java API and later in the high level REST client.
2017-05-01 19:59:06 +02:00
Nik Everett 62712bf653 Test: extra debugging for refresh listeners stats
This test failed in CI but didn't give us enough information to
debug it:
https://elasticsearch-ci.elastic.co/job/elastic+elasticsearch+master+nfs/223/consoleFull

This turns on more debugging and make the test fail more quickly
if something is obviously wrong.
2017-05-01 11:46:55 -04:00
Koen De Groote 0fef5acd01 Cleanup collections construction
This commit cleans up some cases where a list or map was being
constructed, and then an existing collection was copied into the new
collection. The clean is to instead use an appropriate constructor to
directly copy the existing collection in during collection
construction. The advantage of this is that the new collection is sized
appropriately.

Relates #24409
2017-04-30 21:26:51 -04:00
Yannick Welsch 86aab98fde [TEST] Fix race condition in ZenDiscoveryIT.testDiscoveryStats
With #24236, the master now uses the pending queue when publishing to itself. This means that a cluster state update is put into the pending queue,
then sent to the ClusterApplierService to be applied. After it has been applied, it is marked as processed and removed from the pending queue.
ensureGreen is implemented as a cluster health action that waits on certain conditions, which will lead to a cluster state update task to be submitted
on the master. When this task gets to run and the conditions are not satisfied yet, it register a cluster state observer. This observer is registered
on the ClusterApplierService and waits on cluster state change events. ClusterApplierService first notifies the observer and then the discovery
layer. This means that there is a small time frame where ensureGreen can complete and call the node stats to find the pending queue still containing
the last cluster state update.

Closes #24388
2017-04-28 20:42:56 +02:00
Yannick Welsch 9c55bca8fb Fix node failure detection race when updating cluster state
Failure detection should only be updated in ZenDiscovery after the current state has been updated to prevent a race condition
with handleLeaveRequest and handleNodeFailure as those check the current state to determine whether the failure is to be handled by this node.
2017-04-28 19:52:27 +02:00
olcbean 55daf743d7 Open and close index to honour allow_no_indices option (#24222)
Open/close index API when executed providing an index expressions that matched no indices, threw an error even when allow_no_indices was set to true. The APIs should rather honour the option and behave as a no-op in that case.

Closes #24031
2017-04-28 17:41:05 +02:00
Christoph Büscher 4d14143ac6 Add parsing for InternalGeoCentroid (#24371) 2017-04-28 17:08:48 +02:00
Christoph Büscher eb002340d7 Don't render InternalGeoCentroid in static helper method
This was introduced by a previous commit but is not necessary.
2017-04-28 16:55:07 +02:00
Christoph Büscher db07a34718 Merge branch 'master' into feature/client_aggs_parsing 2017-04-28 16:42:55 +02:00
Christoph Büscher 16a7cbe463 Add `count` value to rest output of `geo_centroid` (#24387)
Currently we don't write the count value to the geo_centroid aggregation rest response,
but it is provided via the java api and the count() method in the GeoCentroid interface. 
We should add this parameter to the rest output and also provide it via the getProperty()
method.
2017-04-28 16:25:22 +02:00
Nik Everett e3b7b88756 Fix compilation in Ecipse (#24391)
Eclipse doesn't allow extra semicolons after an import statement:
```
import foo.Bar;;   // <-- syntax error!
```

Here is the Eclipse bug:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=425140
which the Eclipse folks closed as "the spec doesn't allow these
semicolons so why should we?" Which is fair. Here is the bug
against javac for allowing them:
https://bugs.openjdk.java.net/browse/JDK-8027682
which hasn't been touched since 2013 without explanation. There
is, however, a rather educations mailing list thread:
http://mail.openjdk.java.net/pipermail/compiler-dev/2013-August/006956.html

which contains gems like, "In general, it is better/simpler to
change javac to conform to the spec. (Except when it is not.)"

I suspect the reason this hasn't been fixed is:
```
FWIW, if we change javac such that the set of programs accepted by javac
is changed, we have an process (currently Oracle internal) to get
approval for such a change.   So, we would not simply change javac on a
whim to meet the spec; we would at least have other eyes looking at the
behavioral change to determine if it is "acceptable".
```
from http://mail.openjdk.java.net/pipermail/compiler-dev/2013-August/006973.html
2017-04-28 09:52:14 -04:00
Guillaume Le Floch 382a617d34 Handle multiple aliases in _cat/aliases api (#23698)
The alias parameter was documented as a list in our rest-spec, yet only the first value out of a list was getting read and processed. This commit adds support for multiple aliases to _cat/aliases

Closes #23661
2017-04-28 15:21:44 +02:00
Christoph Büscher 0d5cca8feb Fixing checktyle error for modifier order 2017-04-28 14:19:00 +02:00
Kunal Kapoor a5bd2012b6 Added validation for upserd request (#24282)
The version on an update request is a syntactic sugar
for get of a specific version, doc merge and a version
index. This changes it to reject requests with both
upsert and a version.
If the upsert index request is versioned, we also
reject the op.
2017-04-28 08:02:09 -04:00
Christoph Büscher a6c38b8f8a Add parsing for InternalGeoBounds (#24365) 2017-04-28 12:10:16 +02:00
Yannick Welsch a72db191f2 Weaken assertion in ZenDiscovery.publish
The previous commit (35f78d098a) introduced an assertion in ZenDiscovery that was overly restrictive - it could trip when a cluster state that was
successfully published would not be applied locally because a master with a better cluster state came along in the meantime.
2017-04-28 11:33:53 +02:00
Yannick Welsch 35f78d098a Separate publishing from applying cluster states (#24236)
Separates cluster state publishing from applying cluster states:

- ClusterService is split into two classes MasterService and ClusterApplierService. MasterService has the responsibility to calculate cluster state updates for actions that want to change the cluster state (create index, update shard routing table, etc.). ClusterApplierService has the responsibility to apply cluster states that have been successfully published and invokes the cluster state appliers and listeners.
- ClusterApplierService keeps track of the last applied state, but MasterService is stateless and uses the last cluster state that is provided by the discovery module to calculate the next prospective state. The ClusterService class is still kept around, which now just delegates actions to ClusterApplierService and MasterService.
- The discovery implementation is now responsible for managing the last cluster state that is used by the consensus layer and the master service. It also exposes the initial cluster state which is used by the ClusterApplierService. The discovery implementation is also responsible for adding the right cluster-level blocks to the initial state.
- NoneDiscovery has been renamed to TribeDiscovery as it is exclusively used by TribeService. It adds the tribe blocks to the initial state.
- ZenDiscovery is synchronized on state changes to the last cluster state that is used by the consensus layer and the master service, and does not submit cluster state update tasks anymore to make changes to the disco state (except when becoming master).

Control flow for cluster state updates is now as follows:

- State updates are sent to MasterService
- MasterService gets the latest committed cluster state from the discovery implementation and calculates the next cluster state to publish
- MasterService submits the new prospective cluster state to the discovery implementation for publishing
- Discovery implementation publishes cluster states to all nodes and, once the state is committed, asks the ClusterApplierService to apply the newly committed state.
- ClusterApplierService applies state to local node.
2017-04-28 09:34:31 +02:00
Toby McLaughlin e4bb360ae0 Fix typo in node environment exception message
This commit fixes a typo in an exception message when trying to create a
node environment.

Relates #24381
2017-04-28 00:48:52 -04:00
Christoph Büscher 9cb3666f0a Merge branch 'master' into feature/client_aggs_parsing 2017-04-28 00:41:16 +02:00
Zachary Tong 350573290f Agg builder accessibility fixes (#24323)
- Getters for DateHisto `interval` and `offset` should return a
long, not double
- Add getter for the filter in a FilterAgg
- Add getters for subaggs / pipelines in base AggregationBuilder
2017-04-27 16:50:59 -04:00
Ryan Ernst cdcc75dd2a Plugins: Add support for platform specific plugins (#24265)
This commit adds support for plugins having a platform specific variant.
It also adds unit tests for all official and maven urls.
2017-04-27 11:27:29 -07:00
Ali Beyad 2facc42a55 Change snapshot status error to use generic SnapshotException (#24355)
Changes the snapshot status read exception from the (misleading)
IndexShardRestoreFailedException to the generic SnapshotException

Closes #24225
2017-04-27 09:36:26 -04:00
Yannick Welsch 2fa1c9fff1 Provide target allocation id as part of start recovery request (#24333)
This makes it possible for the recovery source to verify that it is talking to the shard it thinks it is talking to.

Closes #24167
2017-04-27 14:45:44 +02:00
Tim Vernum 65f90b25e0 Pass Context to ConstructingObjectParser's function (#24230)
Allow the `Context` to be used in the builder function used within ConstructingObjectParser.
This facilitates scenarios where a constructor argument comes from a URL parameter, or from document id.
2017-04-27 20:26:10 +10:00
Christoph Büscher 93415cdfb4 Add parsing for InternalPercentilesBucket (#24330) 2017-04-27 11:04:57 +02:00
Clinton Gormley 8a8410b5ce Added bwc indices for v2.4.5 2017-04-27 10:30:53 +02:00
Ryan Ernst 4a5c3c5a4a Test: Write node ports file before starting tribe service (#24351)
The tribe service can take a while to initialize, depending on how many cluster it needs to connect to. This change moves writing the ports file used by tests to before the tribe service is started.
2017-04-27 09:59:54 +02:00
Adrien Grand 1be2800120 Only allow one type on 7.0 indices (#24317)
This adds the `index.mapping.single_type` setting, which enforces that indices
have at most one type when it is true. The default value is true for 6.0+ indices
and false for old indices.

Relates #15613
2017-04-27 08:43:20 +02:00
Koen De Groote 7f9d84cb1a The parseObject method in DocumentParse can be void. There is no point in the code that actually expects the return, plus the variable created for it was never actually used. (#24350) 2017-04-26 16:54:23 -06:00
Ali Beyad d387dcfd6c [TEST] fixes NPE in RoutingTableTests 2017-04-26 18:39:26 -04:00
Christoph Büscher b46c39ea2e Fixed another sneaky LineLength violation 2017-04-27 00:02:08 +02:00
Christoph Büscher 1f221154a6 Merge branch 'master' into feature/client_aggs_parsing 2017-04-26 23:09:45 +02:00
Christoph Büscher e2b95f9758 Fix order of static field declarations for parser 2017-04-26 23:07:49 +02:00
Ali Beyad 0e74f5ddb1 [TEST] fixes shard count of source shard index in a restore shrink index
test
2017-04-26 16:34:53 -04:00
Christoph Büscher 774368d2ac Add parsing for InternalStatsBucket and InternalExtendedStatsBucket (#24312) 2017-04-26 22:32:30 +02:00
Nik Everett bc45d10e82 Remove most usages of 1-arg Script ctor (#24325)
The one argument ctor for `Script` creates a script with the
default language but most usages of are for testing and either
don't care about the language or are for use with
`MockScriptEngine`. This replaces most usages of the one argument
ctor on `Script` with calls to `ESTestCase#mockScript` to make
it clear that the tests don't need the default scripting language.

I've also factored out some copy and pasted script generation
code into a single place. I would have had to change that code
to use `mockScript` anyway, so it was easier to perform the
refactor.

Relates to #16314
2017-04-26 16:04:38 -04:00
Luca Cavanna 149629fec6 Cross Cluster Search: propagate original indices per cluster (#24328)
In case of a Cross Cluster Search, the coordinating node should split the original indices per cluster, and send over to each cluster only its own set of original indices, rather than the set taken from the original search request which contains all the indices.

In fact, each remote cluster should not be aware of the indices belonging to other remote clusters.
2017-04-26 21:45:49 +02:00
Yannick Welsch b7bf651738 [TEST] Fix cluster forming in testDynamicUpdateMinimumMasterNodes
This test can run into a split-brain situation as minimum_master_nodes is not properly set. To prevent this, make sure that at least one of the two
master nodes that are initially started has minimum_master_nodes correctly set.
2017-04-26 21:13:27 +02:00
Martijn van Groningen ebe98f9d62
test: don't randomly wrap index reader 2017-04-26 21:07:56 +02:00
Ali Beyad 0e52e3420e Fixes restore of a shrunken index when initial recovery node is gone (#24322)
When an index is shrunk using the shrink APIs, the shrink operation adds
some internal index settings to the shrink index, for example
`index.shrink.source.name|uuid` to denote the source index, as well as
`index.routing.allocation.initial_recovery._id` to denote the node on
which all shards for the source index resided when the shrunken index
was created.  However, this presents a problem when taking a snapshot of
the shrunken index and restoring it to a cluster where the initial
recovery node is not present, or restoring to the same cluster where the
initial recovery node is offline or decomissioned.  The restore
operation fails to allocate the shard in the shrunken index to a node
when the initial recovery node is not present, and a restore type of
recovery will *not* go through the PrimaryShardAllocator, meaning that
it will not have the chance to force allocate the primary to a node in
the cluster.  Rather, restore initiated shard allocation goes through
the BalancedShardAllocator which does not attempt to force allocate a
primary.

This commit fixes the aforementioned problem by not requiring allocation
to occur on the initial recovery node when the recovery type is a
restore of a snapshot.  This commit also ensures that the internal
shrink index settings are recognized and not archived (which can trip an
assertion in the restore scenario).

Closes #24257
2017-04-26 14:48:10 -04:00
Koen De Groote 3187ed73fc Removal of dead code in ScriptedMetricAggregationBuilder (#24346)
This code removes a few lines of dead code from ScriptedMetricAggregationBuilder. 
Just completely dead code, it adds things to a Set that is then not used in any way.
2017-04-26 14:44:03 -04:00
Koen De Groote 4c0eb35c22 Removal of dead code from SnapshotsService (#24347)
This code removes a few lines of dead code from SnapshotsService. 
Looks like a forgotten remnant of a past implementation.
2017-04-26 14:32:35 -04:00
Nik Everett 7c3efb829b Move char filters into analysis-common (#24261)
Another step down the road to dropping the
lucene-analyzers-common dependency from core.

Note that this removes some tests that no longer compile from
core. I played around with adding them to the analysis-common
module where they would compile but we already test these in
the tests generated from the example usage in the documentation.

I'm not super happy with the way that `requriesAnalysisSettings`
works with regards to plugins. I think it'd be fairly bug-prone
for plugin authors to use. But I'm making it visible as is for
now and I'll rethink later.

A part of #23658
2017-04-26 13:25:34 -04:00
Christoph Büscher db1b243343 InternalPercentilesBucket should not rely on ordered percents array (#24336)
Currently InternalPercentilesBucket#percentile() relies on the percent array passed in
to be in sorted order. This changes the aggregation to store an internal lookup table that
is constructed from the percent/percentiles arrays passed in that can be used to look up 
the percentile values.

Closes #24331
2017-04-26 19:15:48 +02:00
Yannick Welsch 91b61ce569 [TEST] Do a reroute with retry_failed after a bridge partition on testAckedIndexing
In case of a bridge partition, shard allocation can fail "index.allocation.max_retries" times if the master is the super-connected node and recovery
source and target are on opposite sides of the bridge. This commit adds a reroute with retry_failed after healing the network partition so that the
ensureGreen check succeeds.
2017-04-26 16:08:16 +02:00
Jay Modi 7f8fe8b81d StreamInput throws exceptions instead of using assertions (#24294)
StreamInput has methods such as readVInt that perform sanity checks on the data using assertions,
which will catch bad data in tests but provide no safety when running as a node without assertions
enabled. The use of assertions also make testing with invalid data difficult since we would need
to handle assertion errors in the code using the stream input and errors like this should not be
something we try to catch. This commit introduces a flag that will throw an IOException instead of
using an assertion.
2017-04-26 07:23:07 -04:00
Martijn van Groningen c17de49a6d
[percolator] Fix memory leak when percolator uses bitset or field data cache.
The percolator doesn't close the IndexReader of the memory index any more.
Prior to 2.x the percolator had its own SearchContext (PercolatorContext) that did this,
but that was removed when the percolator was refactored as part of the 5.0 release.

I think an alternative way to fix this is to let percolator not use the bitset and fielddata caches,
that way we prevent the memory leak.

Closes #24108
2017-04-26 11:08:15 +02:00
Christoph Büscher fede0bab2c Correcting 140 character line length 2017-04-26 11:04:33 +02:00
Koen De Groote 3c845727f8 Replace alternating regex with character classes
This commit replaces two alternating regular expressions (that is,
regular expressions that consist of the form a|b where a and b are
characters) with the equivalent regular expression rewritten as a
character class (that is, [ab]) The reason this is an improvement is
because a|b involves backtracking while [ab] does not.

Relates #24316
2017-04-25 22:15:00 -04:00
Christoph Büscher 0e31a21db2 Add parsing for InternalExtendedStats (#24284) 2017-04-25 23:55:24 +02:00
Guillaume Le Floch 739cb35d1b Allow passing single scrollID in clear scroll API body (#24242)
* Allow single scrollId in string format

Closes #24233
2017-04-25 13:43:21 +02:00
Christoph Büscher 768420db55 Add parsing for InternalStats (#24239) 2017-04-25 13:42:15 +02:00
Koen De Groote 88de33d43d Minor changes to collection creation from enums (#24274)
These changes are mainly cosmetic with minor perf advantages drawn from checkstyle.
2017-04-25 13:13:55 +02:00