Commit Graph

153 Commits

Author SHA1 Message Date
Jim Ferenczi 1764ec56b3 Fixed naming inconsistency for fields/stored_fields in the APIs (#20166)
This change replaces the fields parameter with stored_fields when it makes sense.
This is dictated by the renaming we made in #18943 for the search API.

The following list of endpoint has been changed to use `stored_fields` instead of `fields`:
* get
* mget
* explain

The documentation and the rest API spec has been updated to cope with the changes for the following APIs:
* delete_by_query
* get
* mget
* explain

The `fields` parameter has been deprecated for the following APIs (it is replaced by _source filtering):
* update: the fields are extracted from the _source directly.
* bulk: the fields parameter is used but fields are extracted from the source directly so it is allowed to have non-stored fields.

Some APIs still have the `fields` parameter for various reasons:
* cat.fielddata: the fields paramaters relates to the fielddata fields that should be printed.
* indices.clear_cache: used to indicate which fielddata fields should be cleared.
* indices.get_field_mapping: used to filter fields in the mapping.
* indices.stats: get stats on fields (stored or not stored).
* termvectors: fields are retrieved from the stored fields if possible and extracted from the _source otherwise.
* mtermvectors:
* nodes.stats: the fields parameter is used to concatenate completion_fields and fielddata_fields so it's not related to stored_fields at all.

Fixes #20155
2016-09-13 20:54:41 +02:00
Jason Tedor e166459bbe Merge branch 'master' into log4j2
* master:
  Increase visibility of deprecation logger
  Skip transport client plugin installed on JDK 9
  Explicitly disable Netty key set replacement
  percolator: Fail indexing percolator queries containing either a has_child or has_parent query.
  Make it possible for Ingest Processors to access AnalysisRegistry
  Allow RestClient to send array-based headers
  Silence rest util tests until the bogusness can be simplified
  Remove unknown HttpContext-based test as it fails unpredictably on different JVMs
  Tests: Improve rest suite names and generated test names for docs tests
  Add support for a RestClient base path
2016-08-31 10:59:27 -04:00
Jason Tedor 6f8a047942 Skip transport client plugin installed on JDK 9
This commit adds an assumption to
PreBuiltTransportClientTests#testPluginInstalled on JDK 9. The
underlying issue is that Netty attempts to access sun.nio.ch but this
package is not exported from java.base on JDK 9. This throws an uncaught
InaccessibleObjectException causing the test to fail. This assumption
can be removed when Netty 4.1.6 is released as it will include a fix for
this scenario.

Relates #20251
2016-08-31 09:46:27 -04:00
Chris Earle b8f4c92d41 Allow RestClient to send array-based headers
This enables the RestClient to send array-based (multi-valued) header values, rather than only sending whatever happened to be the _last_ value of the header.
2016-08-30 18:02:07 -04:00
Chris Earle c05d5f9257 Remove unknown HttpContext-based test as it fails unpredictably on different JVMs 2016-08-30 17:18:01 -04:00
Chris Earle 335c020cd7 Add support for a RestClient base path
This enables simple support for proxies (beyond proxy host and proxy port, which is done via the RequestConfig)) to provide a base path in front of all requests performed by the RestClient.
2016-08-30 13:46:45 -04:00
Jason Tedor 7da0cdec42 Introduce Log4j 2
This commit introduces Log4j 2 to the stack.
2016-08-30 13:31:24 -04:00
Chris Earle bd0b06440e Add "Async" to the end of each Async RestClient method
This makes it much harder to accidentally miss the Response.
2016-08-26 10:51:33 -04:00
Daniel Mitterdorfer 4460998ff8 Remove obsolete NoopSearchRequestBuilder#setNoStoredFields() 2016-08-26 09:58:53 +02:00
Daniel Mitterdorfer 7b81c4ca59 Add client-benchmark-noop-api-plugin to stress clients even more in benchmarks (#20103) 2016-08-26 09:05:47 +02:00
Chris Earle e171d0e0a8 Un-final Core REST Client classes
This removes final from the RestClient, Response, and Sniffer classes so that outside code can mock them. Their constructors are already package private, so there's not much that can go wrong.
2016-08-25 16:02:04 -04:00
Jason Tedor a62740bbd2 Avoid early initializing Netty
Today when we load the Netty plugins, we indirectly cause several Netty
classes to initialize. This is because we attempt to load some classes
by name, and loading these classes is done in a way that triggers a long
chain of class initializers within Netty. We should not do this, this
can lead to log messages before the logger is loader, and it leads to
initialization in cases when the classes would never be needed (for
example, Netty 3 class initialization is never needed if Netty 4 is
used, and vice versa). This commit avoids this early initialization of
these classes by removing the need for the early loading.

Relates #19819
2016-08-05 14:58:33 -04:00
Tanguy Leroux 841d5a210e Update to Jackson 2.8.1
This commit updates Jackson to the 2.8.1 version, which is more strict when it comes to build objects. It also adds the snakeyaml dependency that was previously shaded in jackson libs.

It also closes #18076
2016-08-05 12:26:06 +02:00
Colin Goodheart-Smithe f1110f6f2a fix import statements 2016-08-04 16:45:05 +01:00
Colin Goodheart-Smithe f273981f37 Added failure message to test 2016-08-04 16:28:12 +01:00
Jason Tedor 785624e96b Restore interrupted status on when closing client
When closing a transport client that depends on Netty 4, interrupted
exceptions can be thrown while shutting down some Netty threads. This
commit refactors the handling of these exceptions to finish shutting
down and then just restore the interrupted status.
2016-08-04 11:22:13 -04:00
Jason Tedor 2936810c63 Setting exists equals false instead of not exists
This commit rewrites a boolean expression to check for equality with
false instead of negating the existence check.
2016-08-04 10:03:08 -04:00
Jason Tedor c08557d033 Wait for Netty 4 threads to terminate on close
Today if the PreBuiltTransportClient is using Netty 4 transport, on
shutdown some Netty 4 threads could linger. This commit causes the
client to wait for these threads to shutdown upon termination.
2016-08-04 09:48:38 -04:00
Colin Goodheart-Smithe b0730bb214 Fix PreBuiltTransportClientTests to run and pass
This change does three things:

1. Makes PreBuiltTransportClientTests run since it was silently
failing on a missing dependency
2. Makes PreBuiltTransportClientTests pass
3. Removes the http.type and transport.type from being set in the
transport clients additional settings since these are set to `netty4` by
default anyway.
2016-08-04 14:15:28 +01:00
Jason Tedor 227463c356 Default transport and HTTP to Netty 4
This commit sets the default transport and HTTP implementation to use
transport-netty4.

Relates #19563
2016-08-02 12:19:19 -04:00
Daniel Mitterdorfer b99a482992 Improve client benchmark (#19736)
* Allow to run client benchmark as an uberjar
* Busy wait to avoid accidental skew on low target throughput rates
* Trigger and wait for full GC to happen between trials
* Add missing SuppressForbidden to allow System.gc in client benchmark
2016-08-02 14:17:51 +02:00
Ryan Ernst 05edb0367d Add client jars pom generation, and make transport client depend on
transport client plugin jars
2016-07-29 07:41:39 -07:00
javanna 1ea8f865d6 Add response body to ResponseException error message
Consuming the response body to make it part of the exception message means that it may not be readable anymore later, depending on whether the entity is repeatable or not. Turns out that the response body tells a lot about the error itself, and considering that we don't expect bodies to be incredibly big for errors, we can wrap the entity into a BufferedHttpEntity to make it repeatable.

Closes #19622
2016-07-28 14:44:20 +02:00
Luca Cavanna 8a51cfb5b3 Simplify Sniffer initialization and automatically create the default HostsSniffer (#19599)
Simplify Sniffer initialization and automatically create the default HostsSniffer

Take Sniffer.Builder out to its own top level class. Remove HostsSniffer.Builder and let SnifferBuilder create the default HostsSniffer. This simplifies the Sniffer initialization as the HostsSniffer is not mandatory anymore. It can still be specified though in case the configuration needs to be changed or a different impl has to be used. Also make HostsSniffer an interface.
2016-07-26 17:28:37 +02:00
Daniel Mitterdorfer c33f85bc37 Add client benchmark
With this commit we add a benchmark for the new REST client and the
existing transport client.

Closes #19281
2016-07-26 11:01:22 +02:00
Jason Tedor 2d1b0587dd Introduce Netty 4
This commit adds transport-netty4, a transport and HTTP implementation
based on Netty 4.

Relates #19526
2016-07-22 22:26:35 -04:00
javanna 061ea1bd8c [TEST] move assertions outside of listener in testAsyncRequests for clearer test failures 2016-07-22 22:19:59 +02:00
javanna c9c7af791c update nextHost method javadocs 2016-07-22 21:42:42 +02:00
javanna 46cb3f36ff fix concurrency bug when getting the host for a given request
It can happen that the list of healthy hosts is empty, then we get one from the blacklist. but some other operation might have sneaked in and emptied the blacklist in the meantime, so we have to retry till we manage to get some host, either from the healthy list or from the blacklist.
2016-07-22 21:35:43 +02:00
javanna e6054a931e add async request unit test 2016-07-22 19:01:56 +02:00
javanna 4e8ee1f0ab add some javadocs to clarify internal listeners behaviour 2016-07-22 17:44:50 +02:00
javanna 835d8cecdc [TEST] add unit tests for internal TrackingFailureListener
Any provided listener will always be wrapped into FailureTrackingListener to handle retries
2016-07-22 17:31:11 +02:00
javanna a6a685b0f6 make Response class final 2016-07-22 16:36:14 +02:00
javanna a579866b42 rename mayRetry to isRetryStatus 2016-07-22 15:49:39 +02:00
javanna 37e075a506 Make SyncResponseListener safer
Throw explicit IllegalStateException in unexpected situations, like where both response and exception are set, or when both are unset. Add unit test for SyncResponseListener.
2016-07-22 15:48:15 +02:00
javanna 175c327e17 validate bufferLimit is positive in HeapBufferedAsyncResponseConsumer 2016-07-21 13:59:28 +02:00
javanna 59ccc88c73 rename mustRetry method to mayRetry 2016-07-20 16:24:57 +02:00
javanna fccfe7dcb8 RestClient javadocs adjustments 2016-07-20 16:24:29 +02:00
javanna 569d7b3ecc notify the listener if the request gets cancelled 2016-07-20 15:24:14 +02:00
javanna a9b5c5adbe restore throws IOException clause on all performRequest sync methods
We throw IOException, which is the exception that is going to be thrown in 99% of the cases. A more generic exception can happen, and if it is a runtime one we just let it bubble up as is, otherwise we wrap it into runtime one so that we don't require to catch Exception everywhere, which seems odd.

Also adjusted javadocs for all performRequest methods
2016-07-19 15:18:05 +02:00
javanna 8eccdff9ad add HeapBufferedAsyncResponseConsumer with configurable max buffer size
We keep the default async client behaviour like in BasicAsyncResponseConsumer, but we lower the maximum size of the buffer from Integer.MAX_VALUE (2GB) to 10 MB. This way users will realize they are buffering big responses in heap hence they'll know they have to do something about it, either write their own response consumer or increase the buffer size limit by providing their manually creeted instance of HeapBufferedAsyncResponseConsumer (constructor accept a bufferLimit int argument).
2016-07-19 15:17:12 +02:00
javanna 1bb33cf572 Remove RestClient#JSON_CONTENT_TYPE constant, already available in ContentType class 2016-07-19 15:17:12 +02:00
javanna f2ab597c84 Build: use license mapping for http* and commons-*
This way we reduce the number of LICENSE and NOTICE files with same content for client.rest and client.sniffer projects.
2016-07-19 15:16:45 +02:00
javanna 69309fb834 [TEST] remove one too many SuppressWarnings 2016-07-19 15:16:45 +02:00
javanna 06caea6b80 move RestClient#builder method on top for more visibility 2016-07-19 15:16:45 +02:00
javanna a3f9721751 replace till with until in RestClient javadocs 2016-07-19 15:16:45 +02:00
javanna b6b92c64c0 update Response javadocs 2016-07-19 15:16:45 +02:00
javanna 283090e2ae add check for null hosts in RestClientBuilder, so it fails early
Also delayed call to HttpAsyncClient#start so that if something goes wrong while creating the RestClient, the http client threads don't linger. In fact, if the constructor fails it is not possible to call close against the RestClient.
2016-07-19 15:16:45 +02:00
javanna e5006ed7b5 Rest Client: have RestClientBuilder callback also return the same type as their argument
HttpClientConfigCallback#customizeHttpClient now also returns the HttpClientBuilder so it can be completely replaced
RequestConfigCallback#customizeRequestConfig now also returns the HttpClientBuilder so it can be completely replaced
2016-07-19 15:16:45 +02:00
javanna e27203534a Rest Client: improve listener naming 2016-07-19 15:16:45 +02:00