Commit Graph

633 Commits

Author SHA1 Message Date
javanna eae914ae8e Replace rest test client with low level RestClient
We still have a wrapper called RestTestClient that is very specific to Rest tests, as well as RestTestResponse etc. but all the low level bits around http connections etc. are now handled by RestClient.
2016-06-03 16:01:07 +02:00
javanna 325b723930 [TEST] add rest client test dependency and replace usage of HttpRequestBuilder with RestClient in integration tests 2016-06-03 16:01:07 +02:00
javanna 6d3f6c7faf support missing OPTIONS method, it is supported in elasticsearch core 2016-06-03 16:01:07 +02:00
javanna 9a38d81bec Expose whole ElasticsearchResponse within ElasticsearchResponseException
The only small problem is that the response gets closed straightaway and its body read immediately into a string. Should be ok to load it all into memory eagerly though in case of errors. Otherwise it becomes cumbersome to have an exception implement Closeable...
2016-06-03 16:01:07 +02:00
javanna 16ab491016 add getFirstHeader method to ElasticsearchResponse 2016-06-03 16:01:07 +02:00
javanna 1d06916b07 adapt params argument, they can only be Strings in performRequest method 2016-06-03 16:01:07 +02:00
javanna 2735897b36 use versions from versions.properties 2016-06-03 16:01:07 +02:00
javanna 2d7a781195 fix usage of deprecated apis 2016-06-03 16:01:07 +02:00
javanna c0a72c1686 add support for headers: default ones and per request 2016-06-03 16:01:07 +02:00
javanna 85a7721185 simplify Connection class
The connection class can be greatly simplified now that we don't ping anymore. Pings required a special initial state (UNKNOWN) for connections, to indicate that they require pinging although they are not dead. At this point we don't need the State enum anymore, as connections can only be dead or alive based on the number of failed attempts. markResurrected is also not needed, as it was again a way to make pings required. RestClient can simply pick a dead connection now and use it, no need to change its state when picking the connection.
2016-06-03 16:01:07 +02:00
javanna cdffc3d15b remove notion of connection pool, turn around dependency between RestClient and Sniffer
RestClient exposes a setNodes method, which Sniffer can call to update its nodes.
2016-06-03 16:01:07 +02:00
javanna b38ef345e2 remove streams leftover
Given that we don't use streams anymore, we can check straightaway if the connection iterator is empty before returning it and resurrect a connection when needed directly in the connection pool, no lastResortConnection method required.
2016-06-03 16:01:07 +02:00
javanna 599dad560c remove streams and java 8 only api, build with source and target 1.7 2016-06-03 16:01:07 +02:00
javanna 9569ebc262 add builders for simple creation of RestClient and SniffingConnectionPool instances
We have quite some constructor parameters and some defaults should be applied, builders help simplifying creation of objects for users.
2016-06-03 16:01:07 +02:00
javanna e040d2fc77 remove ConnectionPool interface 2016-06-03 16:01:07 +02:00
javanna 17a21f0272 add curl format trace logging for requests and responses 2016-06-03 16:01:07 +02:00
javanna e7fe397c39 add missing parentheses 2016-06-03 16:01:07 +02:00
javanna 530ad227a2 prevent unclosed response entities in ElasticsearchResponseException, eagerly read response string in case of error status code 2016-06-03 16:01:07 +02:00
javanna e77ab87926 return the response as part of ElasticsearchResponseException 2016-06-03 16:01:07 +02:00
javanna e85ed3eb52 remove pinging from static connection pool, can be replaced by a low connect timeout on each request 2016-06-03 16:01:07 +02:00
javanna d7c41764f2 add some javadocs to connection pool classes 2016-06-03 16:01:07 +02:00
javanna 9ffdea9515 remove Scheme enum 2016-06-03 16:01:07 +02:00
javanna bd29dc1572 Remove Transport class, move all of it within RestClient class 2016-06-03 16:01:07 +02:00
javanna 062a21678c merge Connection and StatefulConnection into one class, remove generic type from Transport 2016-06-03 16:01:07 +02:00
javanna a472544ab4 move sniff related stuff to sniff package 2016-06-03 16:01:07 +02:00
javanna ce663e9703 get rid of connection selector predicate 2016-06-03 16:01:07 +02:00
javanna f6a5a0a4ad get rid of Node abstraction 2016-06-03 16:01:07 +02:00
javanna 94cf8437d0 get rid of retry timeout exception 2016-06-03 16:01:07 +02:00
javanna 25892351e7 remove Verb enum 2016-06-03 16:01:07 +02:00
javanna 6ae8be55bd Introduce notion of Transport, Connection and ConnectionPool
There are two implementations of connection pool, a static one that allows to enable/disable pings, and a sniffing one that sniffs nodes from the nodes info api.

Transport retrieves a stream of connections from the connection for each request and calls onSuccess or onFailure depending on the result of the request.

Transport also supports a max retry timeout to control the timeout for the request retries overall.
2016-06-03 16:01:07 +02:00
javanna 5970723945 clarify why jarhell and dependency license check are disabled, add okhttp mockwebserver dependency
Also enable forbiddenApisTest (will fail till we get rid of the sun http web server in RestClientTests that will be replaced with mockwebserver)
2016-06-03 16:01:07 +02:00
javanna c9c33a7719 Fix checkstyle issues, setup thirdPartyAudit checks and enable forbiddenApisMain 2016-06-03 16:01:07 +02:00
Simon Willnauer 3efbe95ca4 RestClient prototype 2016-06-03 16:01:07 +02:00