|
85 | 85 | * The hosts that are part of the cluster need to be provided at creation time, but can also be replaced later
|
86 | 86 | * by calling {@link #setNodes(Collection)}.
|
87 | 87 | * <p>
|
88 |
| - * The method {@link #performRequest(String, String, Map, HttpEntity, Header...)} allows to send a request to the cluster. When |
| 88 | + * The method {@link #performRequest(Request)} allows to send a request to the cluster. When |
89 | 89 | * sending a request, a host gets selected out of the provided ones in a round-robin fashion. Failing hosts are marked dead and
|
90 | 90 | * retried after a certain amount of time (minimum 1 minute, maximum 30 minutes), depending on how many times they previously
|
91 | 91 | * failed (the more failures, the later they will be retried). In case of failures all of the alive nodes (or dead nodes that
|
@@ -145,17 +145,6 @@ public static RestClientBuilder builder(HttpHost... hosts) {
|
145 | 145 | return new RestClientBuilder(hostsToNodes(hosts));
|
146 | 146 | }
|
147 | 147 |
|
148 |
| - /** |
149 |
| - * Replaces the hosts with which the client communicates. |
150 |
| - * |
151 |
| - * @deprecated prefer {@link #setNodes(Collection)} because it allows you |
152 |
| - * to set metadata for use with {@link NodeSelector}s |
153 |
| - */ |
154 |
| - @Deprecated |
155 |
| - public void setHosts(HttpHost... hosts) { |
156 |
| - setNodes(hostsToNodes(hosts)); |
157 |
| - } |
158 |
| - |
159 | 148 | /**
|
160 | 149 | * Replaces the nodes with which the client communicates.
|
161 | 150 | */
|
@@ -251,234 +240,6 @@ public void performRequestAsync(Request request, ResponseListener responseListen
|
251 | 240 | }
|
252 | 241 | }
|
253 | 242 |
|
254 |
| - /** |
255 |
| - * Sends a request to the Elasticsearch cluster that the client points to and waits for the corresponding response |
256 |
| - * to be returned. Shortcut to {@link #performRequest(String, String, Map, HttpEntity, Header...)} but without parameters |
257 |
| - * and request body. |
258 |
| - * |
259 |
| - * @param method the http method |
260 |
| - * @param endpoint the path of the request (without host and port) |
261 |
| - * @param headers the optional request headers |
262 |
| - * @return the response returned by Elasticsearch |
263 |
| - * @throws IOException in case of a problem or the connection was aborted |
264 |
| - * @throws ClientProtocolException in case of an http protocol error |
265 |
| - * @throws ResponseException in case Elasticsearch responded with a status code that indicated an error |
266 |
| - * @deprecated prefer {@link #performRequest(Request)} |
267 |
| - */ |
268 |
| - @Deprecated |
269 |
| - public Response performRequest(String method, String endpoint, Header... headers) throws IOException { |
270 |
| - Request request = new Request(method, endpoint); |
271 |
| - addHeaders(request, headers); |
272 |
| - return performRequest(request); |
273 |
| - } |
274 |
| - |
275 |
| - /** |
276 |
| - * Sends a request to the Elasticsearch cluster that the client points to and waits for the corresponding response |
277 |
| - * to be returned. Shortcut to {@link #performRequest(String, String, Map, HttpEntity, Header...)} but without request body. |
278 |
| - * |
279 |
| - * @param method the http method |
280 |
| - * @param endpoint the path of the request (without host and port) |
281 |
| - * @param params the query_string parameters |
282 |
| - * @param headers the optional request headers |
283 |
| - * @return the response returned by Elasticsearch |
284 |
| - * @throws IOException in case of a problem or the connection was aborted |
285 |
| - * @throws ClientProtocolException in case of an http protocol error |
286 |
| - * @throws ResponseException in case Elasticsearch responded with a status code that indicated an error |
287 |
| - * @deprecated prefer {@link #performRequest(Request)} |
288 |
| - */ |
289 |
| - @Deprecated |
290 |
| - public Response performRequest(String method, String endpoint, Map<String, String> params, Header... headers) throws IOException { |
291 |
| - Request request = new Request(method, endpoint); |
292 |
| - addParameters(request, params); |
293 |
| - addHeaders(request, headers); |
294 |
| - return performRequest(request); |
295 |
| - } |
296 |
| - |
297 |
| - /** |
298 |
| - * Sends a request to the Elasticsearch cluster that the client points to and waits for the corresponding response |
299 |
| - * to be returned. Shortcut to {@link #performRequest(String, String, Map, HttpEntity, HttpAsyncResponseConsumerFactory, Header...)} |
300 |
| - * which doesn't require specifying an {@link HttpAsyncResponseConsumerFactory} instance, |
301 |
| - * {@link HttpAsyncResponseConsumerFactory} will be used to create the needed instances of {@link HttpAsyncResponseConsumer}. |
302 |
| - * |
303 |
| - * @param method the http method |
304 |
| - * @param endpoint the path of the request (without host and port) |
305 |
| - * @param params the query_string parameters |
306 |
| - * @param entity the body of the request, null if not applicable |
307 |
| - * @param headers the optional request headers |
308 |
| - * @return the response returned by Elasticsearch |
309 |
| - * @throws IOException in case of a problem or the connection was aborted |
310 |
| - * @throws ClientProtocolException in case of an http protocol error |
311 |
| - * @throws ResponseException in case Elasticsearch responded with a status code that indicated an error |
312 |
| - * @deprecated prefer {@link #performRequest(Request)} |
313 |
| - */ |
314 |
| - @Deprecated |
315 |
| - public Response performRequest(String method, String endpoint, Map<String, String> params, |
316 |
| - HttpEntity entity, Header... headers) throws IOException { |
317 |
| - Request request = new Request(method, endpoint); |
318 |
| - addParameters(request, params); |
319 |
| - request.setEntity(entity); |
320 |
| - addHeaders(request, headers); |
321 |
| - return performRequest(request); |
322 |
| - } |
323 |
| - |
324 |
| - /** |
325 |
| - * Sends a request to the Elasticsearch cluster that the client points to. Blocks until the request is completed and returns |
326 |
| - * its response or fails by throwing an exception. Selects a host out of the provided ones in a round-robin fashion. Failing hosts |
327 |
| - * are marked dead and retried after a certain amount of time (minimum 1 minute, maximum 30 minutes), depending on how many times |
328 |
| - * they previously failed (the more failures, the later they will be retried). In case of failures all of the alive nodes (or dead |
329 |
| - * nodes that deserve a retry) are retried until one responds or none of them does, in which case an {@link IOException} will be thrown. |
330 |
| - * |
331 |
| - * This method works by performing an asynchronous call and waiting |
332 |
| - * for the result. If the asynchronous call throws an exception we wrap |
333 |
| - * it and rethrow it so that the stack trace attached to the exception |
334 |
| - * contains the call site. While we attempt to preserve the original |
335 |
| - * exception this isn't always possible and likely haven't covered all of |
336 |
| - * the cases. You can get the original exception from |
337 |
| - * {@link Exception#getCause()}. |
338 |
| - * |
339 |
| - * @param method the http method |
340 |
| - * @param endpoint the path of the request (without host and port) |
341 |
| - * @param params the query_string parameters |
342 |
| - * @param entity the body of the request, null if not applicable |
343 |
| - * @param httpAsyncResponseConsumerFactory the {@link HttpAsyncResponseConsumerFactory} used to create one |
344 |
| - * {@link HttpAsyncResponseConsumer} callback per retry. Controls how the response body gets streamed from a non-blocking HTTP |
345 |
| - * connection on the client side. |
346 |
| - * @param headers the optional request headers |
347 |
| - * @return the response returned by Elasticsearch |
348 |
| - * @throws IOException in case of a problem or the connection was aborted |
349 |
| - * @throws ClientProtocolException in case of an http protocol error |
350 |
| - * @throws ResponseException in case Elasticsearch responded with a status code that indicated an error |
351 |
| - * @deprecated prefer {@link #performRequest(Request)} |
352 |
| - */ |
353 |
| - @Deprecated |
354 |
| - public Response performRequest(String method, String endpoint, Map<String, String> params, |
355 |
| - HttpEntity entity, HttpAsyncResponseConsumerFactory httpAsyncResponseConsumerFactory, |
356 |
| - Header... headers) throws IOException { |
357 |
| - Request request = new Request(method, endpoint); |
358 |
| - addParameters(request, params); |
359 |
| - request.setEntity(entity); |
360 |
| - setOptions(request, httpAsyncResponseConsumerFactory, headers); |
361 |
| - return performRequest(request); |
362 |
| - } |
363 |
| - |
364 |
| - /** |
365 |
| - * Sends a request to the Elasticsearch cluster that the client points to. Doesn't wait for the response, instead |
366 |
| - * the provided {@link ResponseListener} will be notified upon completion or failure. Shortcut to |
367 |
| - * {@link #performRequestAsync(String, String, Map, HttpEntity, ResponseListener, Header...)} but without parameters and request body. |
368 |
| - * |
369 |
| - * @param method the http method |
370 |
| - * @param endpoint the path of the request (without host and port) |
371 |
| - * @param responseListener the {@link ResponseListener} to notify when the request is completed or fails |
372 |
| - * @param headers the optional request headers |
373 |
| - * @deprecated prefer {@link #performRequestAsync(Request, ResponseListener)} |
374 |
| - */ |
375 |
| - @Deprecated |
376 |
| - public void performRequestAsync(String method, String endpoint, ResponseListener responseListener, Header... headers) { |
377 |
| - Request request; |
378 |
| - try { |
379 |
| - request = new Request(method, endpoint); |
380 |
| - addHeaders(request, headers); |
381 |
| - } catch (Exception e) { |
382 |
| - responseListener.onFailure(e); |
383 |
| - return; |
384 |
| - } |
385 |
| - performRequestAsync(request, responseListener); |
386 |
| - } |
387 |
| - |
388 |
| - /** |
389 |
| - * Sends a request to the Elasticsearch cluster that the client points to. Doesn't wait for the response, instead |
390 |
| - * the provided {@link ResponseListener} will be notified upon completion or failure. Shortcut to |
391 |
| - * {@link #performRequestAsync(String, String, Map, HttpEntity, ResponseListener, Header...)} but without request body. |
392 |
| - * |
393 |
| - * @param method the http method |
394 |
| - * @param endpoint the path of the request (without host and port) |
395 |
| - * @param params the query_string parameters |
396 |
| - * @param responseListener the {@link ResponseListener} to notify when the request is completed or fails |
397 |
| - * @param headers the optional request headers |
398 |
| - * @deprecated prefer {@link #performRequestAsync(Request, ResponseListener)} |
399 |
| - */ |
400 |
| - @Deprecated |
401 |
| - public void performRequestAsync(String method, String endpoint, Map<String, String> params, |
402 |
| - ResponseListener responseListener, Header... headers) { |
403 |
| - Request request; |
404 |
| - try { |
405 |
| - request = new Request(method, endpoint); |
406 |
| - addParameters(request, params); |
407 |
| - addHeaders(request, headers); |
408 |
| - } catch (Exception e) { |
409 |
| - responseListener.onFailure(e); |
410 |
| - return; |
411 |
| - } |
412 |
| - performRequestAsync(request, responseListener); |
413 |
| - } |
414 |
| - |
415 |
| - /** |
416 |
| - * Sends a request to the Elasticsearch cluster that the client points to. Doesn't wait for the response, instead |
417 |
| - * the provided {@link ResponseListener} will be notified upon completion or failure. |
418 |
| - * Shortcut to {@link #performRequestAsync(String, String, Map, HttpEntity, HttpAsyncResponseConsumerFactory, ResponseListener, |
419 |
| - * Header...)} which doesn't require specifying an {@link HttpAsyncResponseConsumerFactory} instance, |
420 |
| - * {@link HttpAsyncResponseConsumerFactory} will be used to create the needed instances of {@link HttpAsyncResponseConsumer}. |
421 |
| - * |
422 |
| - * @param method the http method |
423 |
| - * @param endpoint the path of the request (without host and port) |
424 |
| - * @param params the query_string parameters |
425 |
| - * @param entity the body of the request, null if not applicable |
426 |
| - * @param responseListener the {@link ResponseListener} to notify when the request is completed or fails |
427 |
| - * @param headers the optional request headers |
428 |
| - * @deprecated prefer {@link #performRequestAsync(Request, ResponseListener)} |
429 |
| - */ |
430 |
| - @Deprecated |
431 |
| - public void performRequestAsync(String method, String endpoint, Map<String, String> params, |
432 |
| - HttpEntity entity, ResponseListener responseListener, Header... headers) { |
433 |
| - Request request; |
434 |
| - try { |
435 |
| - request = new Request(method, endpoint); |
436 |
| - addParameters(request, params); |
437 |
| - request.setEntity(entity); |
438 |
| - addHeaders(request, headers); |
439 |
| - } catch (Exception e) { |
440 |
| - responseListener.onFailure(e); |
441 |
| - return; |
442 |
| - } |
443 |
| - performRequestAsync(request, responseListener); |
444 |
| - } |
445 |
| - |
446 |
| - /** |
447 |
| - * Sends a request to the Elasticsearch cluster that the client points to. The request is executed asynchronously |
448 |
| - * and the provided {@link ResponseListener} gets notified upon request completion or failure. |
449 |
| - * Selects a host out of the provided ones in a round-robin fashion. Failing hosts are marked dead and retried after a certain |
450 |
| - * amount of time (minimum 1 minute, maximum 30 minutes), depending on how many times they previously failed (the more failures, |
451 |
| - * the later they will be retried). In case of failures all of the alive nodes (or dead nodes that deserve a retry) are retried |
452 |
| - * until one responds or none of them does, in which case an {@link IOException} will be thrown. |
453 |
| - * |
454 |
| - * @param method the http method |
455 |
| - * @param endpoint the path of the request (without host and port) |
456 |
| - * @param params the query_string parameters |
457 |
| - * @param entity the body of the request, null if not applicable |
458 |
| - * @param httpAsyncResponseConsumerFactory the {@link HttpAsyncResponseConsumerFactory} used to create one |
459 |
| - * {@link HttpAsyncResponseConsumer} callback per retry. Controls how the response body gets streamed from a non-blocking HTTP |
460 |
| - * connection on the client side. |
461 |
| - * @param responseListener the {@link ResponseListener} to notify when the request is completed or fails |
462 |
| - * @param headers the optional request headers |
463 |
| - * @deprecated prefer {@link #performRequestAsync(Request, ResponseListener)} |
464 |
| - */ |
465 |
| - @Deprecated |
466 |
| - public void performRequestAsync(String method, String endpoint, Map<String, String> params, |
467 |
| - HttpEntity entity, HttpAsyncResponseConsumerFactory httpAsyncResponseConsumerFactory, |
468 |
| - ResponseListener responseListener, Header... headers) { |
469 |
| - Request request; |
470 |
| - try { |
471 |
| - request = new Request(method, endpoint); |
472 |
| - addParameters(request, params); |
473 |
| - request.setEntity(entity); |
474 |
| - setOptions(request, httpAsyncResponseConsumerFactory, headers); |
475 |
| - } catch (Exception e) { |
476 |
| - responseListener.onFailure(e); |
477 |
| - return; |
478 |
| - } |
479 |
| - performRequestAsync(request, responseListener); |
480 |
| - } |
481 |
| - |
482 | 243 | void performRequestAsyncNoCatch(Request request, ResponseListener listener) throws IOException {
|
483 | 244 | Map<String, String> requestParams = new HashMap<>(request.getParameters());
|
484 | 245 | //ignore is a special parameter supported by the clients, shouldn't be sent to es
|
@@ -1035,42 +796,4 @@ public void remove() {
|
1035 | 796 | itr.remove();
|
1036 | 797 | }
|
1037 | 798 | }
|
1038 |
| - |
1039 |
| - /** |
1040 |
| - * Add all headers from the provided varargs argument to a {@link Request}. This only exists |
1041 |
| - * to support methods that exist for backwards compatibility. |
1042 |
| - */ |
1043 |
| - @Deprecated |
1044 |
| - private static void addHeaders(Request request, Header... headers) { |
1045 |
| - setOptions(request, RequestOptions.DEFAULT.getHttpAsyncResponseConsumerFactory(), headers); |
1046 |
| - } |
1047 |
| - |
1048 |
| - /** |
1049 |
| - * Add all headers from the provided varargs argument to a {@link Request}. This only exists |
1050 |
| - * to support methods that exist for backwards compatibility. |
1051 |
| - */ |
1052 |
| - @Deprecated |
1053 |
| - private static void setOptions(Request request, HttpAsyncResponseConsumerFactory httpAsyncResponseConsumerFactory, |
1054 |
| - Header... headers) { |
1055 |
| - Objects.requireNonNull(headers, "headers cannot be null"); |
1056 |
| - RequestOptions.Builder options = request.getOptions().toBuilder(); |
1057 |
| - for (Header header : headers) { |
1058 |
| - Objects.requireNonNull(header, "header cannot be null"); |
1059 |
| - options.addHeader(header.getName(), header.getValue()); |
1060 |
| - } |
1061 |
| - options.setHttpAsyncResponseConsumerFactory(httpAsyncResponseConsumerFactory); |
1062 |
| - request.setOptions(options); |
1063 |
| - } |
1064 |
| - |
1065 |
| - /** |
1066 |
| - * Add all parameters from a map to a {@link Request}. This only exists |
1067 |
| - * to support methods that exist for backwards compatibility. |
1068 |
| - */ |
1069 |
| - @Deprecated |
1070 |
| - private static void addParameters(Request request, Map<String, String> parameters) { |
1071 |
| - Objects.requireNonNull(parameters, "parameters cannot be null"); |
1072 |
| - for (Map.Entry<String, String> entry : parameters.entrySet()) { |
1073 |
| - request.addParameter(entry.getKey(), entry.getValue()); |
1074 |
| - } |
1075 |
| - } |
1076 | 799 | }
|
0 commit comments