diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/ClusterClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/ClusterClient.java index 1e25a40b0084a..b3075a2fddbd5 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/ClusterClient.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/ClusterClient.java @@ -19,7 +19,6 @@ package org.elasticsearch.client; -import org.apache.http.Header; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; @@ -59,20 +58,6 @@ public ClusterUpdateSettingsResponse putSettings(ClusterUpdateSettingsRequest cl options, ClusterUpdateSettingsResponse::fromXContent, emptySet()); } - /** - * Updates cluster wide specific settings using the Cluster Update Settings API. - *

- * See Cluster Update Settings - * API on elastic.co - * @deprecated Prefer {@link #putSettings(ClusterUpdateSettingsRequest, RequestOptions)} - */ - @Deprecated - public ClusterUpdateSettingsResponse putSettings(ClusterUpdateSettingsRequest clusterUpdateSettingsRequest, Header... headers) - throws IOException { - return restHighLevelClient.performRequestAndParseEntity(clusterUpdateSettingsRequest, RequestConverters::clusterPutSettings, - ClusterUpdateSettingsResponse::fromXContent, emptySet(), headers); - } - /** * Asynchronously updates cluster wide specific settings using the Cluster Update Settings API. * See Cluster Update Settings @@ -86,19 +71,6 @@ public void putSettingsAsync(ClusterUpdateSettingsRequest clusterUpdateSettingsR restHighLevelClient.performRequestAsyncAndParseEntity(clusterUpdateSettingsRequest, RequestConverters::clusterPutSettings, options, ClusterUpdateSettingsResponse::fromXContent, listener, emptySet()); } - /** - * Asynchronously updates cluster wide specific settings using the Cluster Update Settings API. - *

- * See Cluster Update Settings - * API on elastic.co - * @deprecated Prefer {@link #putSettingsAsync(ClusterUpdateSettingsRequest, RequestOptions, ActionListener)} - */ - @Deprecated - public void putSettingsAsync(ClusterUpdateSettingsRequest clusterUpdateSettingsRequest, - ActionListener listener, Header... headers) { - restHighLevelClient.performRequestAsyncAndParseEntity(clusterUpdateSettingsRequest, RequestConverters::clusterPutSettings, - ClusterUpdateSettingsResponse::fromXContent, listener, emptySet(), headers); - } /** * Get cluster health using the Cluster Health API. diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java index 5d0376efce5f6..5f85b18091d72 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java @@ -19,7 +19,6 @@ package org.elasticsearch.client; -import org.apache.http.Header; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; @@ -92,19 +91,6 @@ public DeleteIndexResponse delete(DeleteIndexRequest deleteIndexRequest, Request DeleteIndexResponse::fromXContent, emptySet()); } - /** - * Deletes an index using the Delete Index API. - *

- * See - * Delete Index API on elastic.co - * @deprecated Prefer {@link #delete(DeleteIndexRequest, RequestOptions)} - */ - @Deprecated - public DeleteIndexResponse delete(DeleteIndexRequest deleteIndexRequest, Header... headers) throws IOException { - return restHighLevelClient.performRequestAndParseEntity(deleteIndexRequest, RequestConverters::deleteIndex, - DeleteIndexResponse::fromXContent, emptySet(), headers); - } - /** * Asynchronously deletes an index using the Delete Index API. * See @@ -118,19 +104,6 @@ public void deleteAsync(DeleteIndexRequest deleteIndexRequest, RequestOptions op DeleteIndexResponse::fromXContent, listener, emptySet()); } - /** - * Asynchronously deletes an index using the Delete Index API. - *

- * See - * Delete Index API on elastic.co - * @deprecated Prefer {@link #deleteAsync(DeleteIndexRequest, RequestOptions, ActionListener)} - */ - @Deprecated - public void deleteAsync(DeleteIndexRequest deleteIndexRequest, ActionListener listener, Header... headers) { - restHighLevelClient.performRequestAsyncAndParseEntity(deleteIndexRequest, RequestConverters::deleteIndex, - DeleteIndexResponse::fromXContent, listener, emptySet(), headers); - } - /** * Creates an index using the Create Index API. * See @@ -145,19 +118,6 @@ public CreateIndexResponse create(CreateIndexRequest createIndexRequest, Request CreateIndexResponse::fromXContent, emptySet()); } - /** - * Creates an index using the Create Index API. - *

- * See - * Create Index API on elastic.co - * @deprecated Prefer {@link #create(CreateIndexRequest, RequestOptions)} - */ - @Deprecated - public CreateIndexResponse create(CreateIndexRequest createIndexRequest, Header... headers) throws IOException { - return restHighLevelClient.performRequestAndParseEntity(createIndexRequest, RequestConverters::createIndex, - CreateIndexResponse::fromXContent, emptySet(), headers); - } - /** * Asynchronously creates an index using the Create Index API. * See @@ -171,19 +131,6 @@ public void createAsync(CreateIndexRequest createIndexRequest, RequestOptions op CreateIndexResponse::fromXContent, listener, emptySet()); } - /** - * Asynchronously creates an index using the Create Index API. - *

- * See - * Create Index API on elastic.co - * @deprecated Prefer {@link #createAsync(CreateIndexRequest, RequestOptions, ActionListener)} - */ - @Deprecated - public void createAsync(CreateIndexRequest createIndexRequest, ActionListener listener, Header... headers) { - restHighLevelClient.performRequestAsyncAndParseEntity(createIndexRequest, RequestConverters::createIndex, - CreateIndexResponse::fromXContent, listener, emptySet(), headers); - } - /** * Updates the mappings on an index using the Put Mapping API. * See @@ -198,19 +145,6 @@ public PutMappingResponse putMapping(PutMappingRequest putMappingRequest, Reques PutMappingResponse::fromXContent, emptySet()); } - /** - * Updates the mappings on an index using the Put Mapping API. - *

- * See - * Put Mapping API on elastic.co - * @deprecated Prefer {@link #putMapping(PutMappingRequest, RequestOptions)} - */ - @Deprecated - public PutMappingResponse putMapping(PutMappingRequest putMappingRequest, Header... headers) throws IOException { - return restHighLevelClient.performRequestAndParseEntity(putMappingRequest, RequestConverters::putMapping, - PutMappingResponse::fromXContent, emptySet(), headers); - } - /** * Asynchronously updates the mappings on an index using the Put Mapping API. * See @@ -224,20 +158,6 @@ public void putMappingAsync(PutMappingRequest putMappingRequest, RequestOptions PutMappingResponse::fromXContent, listener, emptySet()); } - /** - * Asynchronously updates the mappings on an index using the Put Mapping API. - *

- * See - * Put Mapping API on elastic.co - * @deprecated Prefer {@link #putMappingAsync(PutMappingRequest, RequestOptions, ActionListener)} - */ - @Deprecated - public void putMappingAsync(PutMappingRequest putMappingRequest, ActionListener listener, - Header... headers) { - restHighLevelClient.performRequestAsyncAndParseEntity(putMappingRequest, RequestConverters::putMapping, - PutMappingResponse::fromXContent, listener, emptySet(), headers); - } - /** * Retrieves the mappings on an index or indices using the Get Mapping API. * See @@ -280,20 +200,6 @@ public IndicesAliasesResponse updateAliases(IndicesAliasesRequest indicesAliases IndicesAliasesResponse::fromXContent, emptySet()); } - /** - * Updates aliases using the Index Aliases API. - *

- * See - * Index Aliases API on elastic.co - * @deprecated {@link #updateAliases(IndicesAliasesRequest, RequestOptions)} - */ - @Deprecated - public IndicesAliasesResponse updateAliases(IndicesAliasesRequest indicesAliasesRequest, Header... headers) throws IOException { - return restHighLevelClient.performRequestAndParseEntity(indicesAliasesRequest, RequestConverters::updateAliases, - IndicesAliasesResponse::fromXContent, emptySet(), headers); - } - /** * Asynchronously updates aliases using the Index Aliases API. * See @@ -308,21 +214,6 @@ public void updateAliasesAsync(IndicesAliasesRequest indicesAliasesRequest, Requ IndicesAliasesResponse::fromXContent, listener, emptySet()); } - /** - * Asynchronously updates aliases using the Index Aliases API. - *

- * See - * Index Aliases API on elastic.co - * @deprecated Prefer {@link #updateAliasesAsync(IndicesAliasesRequest, RequestOptions, ActionListener)} - */ - @Deprecated - public void updateAliasesAsync(IndicesAliasesRequest indicesAliasesRequest, ActionListener listener, - Header... headers) { - restHighLevelClient.performRequestAsyncAndParseEntity(indicesAliasesRequest, RequestConverters::updateAliases, - IndicesAliasesResponse::fromXContent, listener, emptySet(), headers); - } - /** * Opens an index using the Open Index API. * See @@ -337,19 +228,6 @@ public OpenIndexResponse open(OpenIndexRequest openIndexRequest, RequestOptions OpenIndexResponse::fromXContent, emptySet()); } - /** - * Opens an index using the Open Index API. - *

- * See - * Open Index API on elastic.co - * @deprecated Prefer {@link #open(OpenIndexRequest, RequestOptions)} - */ - @Deprecated - public OpenIndexResponse open(OpenIndexRequest openIndexRequest, Header... headers) throws IOException { - return restHighLevelClient.performRequestAndParseEntity(openIndexRequest, RequestConverters::openIndex, - OpenIndexResponse::fromXContent, emptySet(), headers); - } - /** * Asynchronously opens an index using the Open Index API. * See @@ -363,19 +241,6 @@ public void openAsync(OpenIndexRequest openIndexRequest, RequestOptions options, OpenIndexResponse::fromXContent, listener, emptySet()); } - /** - * Asynchronously opens an index using the Open Index API. - *

- * See - * Open Index API on elastic.co - * @deprecated Prefer {@link #openAsync(OpenIndexRequest, RequestOptions, ActionListener)} - */ - @Deprecated - public void openAsync(OpenIndexRequest openIndexRequest, ActionListener listener, Header... headers) { - restHighLevelClient.performRequestAsyncAndParseEntity(openIndexRequest, RequestConverters::openIndex, - OpenIndexResponse::fromXContent, listener, emptySet(), headers); - } - /** * Closes an index using the Close Index API. * See @@ -390,19 +255,6 @@ public CloseIndexResponse close(CloseIndexRequest closeIndexRequest, RequestOpti CloseIndexResponse::fromXContent, emptySet()); } - /** - * Closes an index using the Close Index API. - *

- * See - * Close Index API on elastic.co - * @deprecated Prefer {@link #close(CloseIndexRequest, RequestOptions)} - */ - @Deprecated - public CloseIndexResponse close(CloseIndexRequest closeIndexRequest, Header... headers) throws IOException { - return restHighLevelClient.performRequestAndParseEntity(closeIndexRequest, RequestConverters::closeIndex, - CloseIndexResponse::fromXContent, emptySet(), headers); - } - /** * Asynchronously closes an index using the Close Index API. * See @@ -417,19 +269,6 @@ public void closeAsync(CloseIndexRequest closeIndexRequest, RequestOptions optio } - /** - * Asynchronously closes an index using the Close Index API. - *

- * See - * Close Index API on elastic.co - * @deprecated Prefer {@link #closeAsync(CloseIndexRequest, RequestOptions, ActionListener)} - */ - @Deprecated - public void closeAsync(CloseIndexRequest closeIndexRequest, ActionListener listener, Header... headers) { - restHighLevelClient.performRequestAsyncAndParseEntity(closeIndexRequest, RequestConverters::closeIndex, - CloseIndexResponse::fromXContent, listener, emptySet(), headers); - } - /** * Checks if one or more aliases exist using the Aliases Exist API. * See @@ -444,19 +283,6 @@ public boolean existsAlias(GetAliasesRequest getAliasesRequest, RequestOptions o RestHighLevelClient::convertExistsResponse, emptySet()); } - /** - * Checks if one or more aliases exist using the Aliases Exist API. - *

- * See - * Indices Aliases API on elastic.co - * @deprecated Prefer {@link #existsAlias(GetAliasesRequest, RequestOptions)} - */ - @Deprecated - public boolean existsAlias(GetAliasesRequest getAliasesRequest, Header... headers) throws IOException { - return restHighLevelClient.performRequest(getAliasesRequest, RequestConverters::existsAlias, - RestHighLevelClient::convertExistsResponse, emptySet(), headers); - } - /** * Asynchronously checks if one or more aliases exist using the Aliases Exist API. * See @@ -470,19 +296,6 @@ public void existsAliasAsync(GetAliasesRequest getAliasesRequest, RequestOptions RestHighLevelClient::convertExistsResponse, listener, emptySet()); } - /** - * Asynchronously checks if one or more aliases exist using the Aliases Exist API. - *

- * See - * Indices Aliases API on elastic.co - * @deprecated Prefer {@link #existsAliasAsync(GetAliasesRequest, RequestOptions, ActionListener)} - */ - @Deprecated - public void existsAliasAsync(GetAliasesRequest getAliasesRequest, ActionListener listener, Header... headers) { - restHighLevelClient.performRequestAsync(getAliasesRequest, RequestConverters::existsAlias, - RestHighLevelClient::convertExistsResponse, listener, emptySet(), headers); - } - /** * Refresh one or more indices using the Refresh API. * See Refresh API on elastic.co @@ -496,18 +309,6 @@ public RefreshResponse refresh(RefreshRequest refreshRequest, RequestOptions opt RefreshResponse::fromXContent, emptySet()); } - /** - * Refresh one or more indices using the Refresh API. - *

- * See Refresh API on elastic.co - * @deprecated Prefer {@link #refresh(RefreshRequest, RequestOptions)} - */ - @Deprecated - public RefreshResponse refresh(RefreshRequest refreshRequest, Header... headers) throws IOException { - return restHighLevelClient.performRequestAndParseEntity(refreshRequest, RequestConverters::refresh, RefreshResponse::fromXContent, - emptySet(), headers); - } - /** * Asynchronously refresh one or more indices using the Refresh API. * See Refresh API on elastic.co @@ -520,18 +321,6 @@ public void refreshAsync(RefreshRequest refreshRequest, RequestOptions options, RefreshResponse::fromXContent, listener, emptySet()); } - /** - * Asynchronously refresh one or more indices using the Refresh API. - *

- * See Refresh API on elastic.co - * @deprecated Prefer {@link #refreshAsync(RefreshRequest, RequestOptions, ActionListener)} - */ - @Deprecated - public void refreshAsync(RefreshRequest refreshRequest, ActionListener listener, Header... headers) { - restHighLevelClient.performRequestAsyncAndParseEntity(refreshRequest, RequestConverters::refresh, RefreshResponse::fromXContent, - listener, emptySet(), headers); - } - /** * Flush one or more indices using the Flush API. * See Flush API on elastic.co @@ -545,18 +334,6 @@ public FlushResponse flush(FlushRequest flushRequest, RequestOptions options) th FlushResponse::fromXContent, emptySet()); } - /** - * Flush one or more indices using the Flush API. - *

- * See Flush API on elastic.co - * @deprecated Prefer {@link #flush(FlushRequest, RequestOptions)} - */ - @Deprecated - public FlushResponse flush(FlushRequest flushRequest, Header... headers) throws IOException { - return restHighLevelClient.performRequestAndParseEntity(flushRequest, RequestConverters::flush, FlushResponse::fromXContent, - emptySet(), headers); - } - /** * Asynchronously flush one or more indices using the Flush API. * See Flush API on elastic.co @@ -569,18 +346,6 @@ public void flushAsync(FlushRequest flushRequest, RequestOptions options, Action FlushResponse::fromXContent, listener, emptySet()); } - /** - * Asynchronously flush one or more indices using the Flush API. - *

- * See Flush API on elastic.co - * @deprecated Prefer {@link #flushAsync(FlushRequest, RequestOptions, ActionListener)} - */ - @Deprecated - public void flushAsync(FlushRequest flushRequest, ActionListener listener, Header... headers) { - restHighLevelClient.performRequestAsyncAndParseEntity(flushRequest, RequestConverters::flush, FlushResponse::fromXContent, - listener, emptySet(), headers); - } - /** * Initiate a synced flush manually using the synced flush API. * See @@ -651,19 +416,6 @@ public ForceMergeResponse forceMerge(ForceMergeRequest forceMergeRequest, Reques ForceMergeResponse::fromXContent, emptySet()); } - /** - * Force merge one or more indices using the Force Merge API. - *

- * See - * Force Merge API on elastic.co - * @deprecated Prefer {@link #forceMerge(ForceMergeRequest, RequestOptions)} - */ - @Deprecated - public ForceMergeResponse forceMerge(ForceMergeRequest forceMergeRequest, Header... headers) throws IOException { - return restHighLevelClient.performRequestAndParseEntity(forceMergeRequest, RequestConverters::forceMerge, - ForceMergeResponse::fromXContent, emptySet(), headers); - } - /** * Asynchronously force merge one or more indices using the Force Merge API. * See @@ -677,19 +429,6 @@ public void forceMergeAsync(ForceMergeRequest forceMergeRequest, RequestOptions ForceMergeResponse::fromXContent, listener, emptySet()); } - /** - * Asynchronously force merge one or more indices using the Force Merge API. - *

- * See - * Force Merge API on elastic.co - * @deprecated Prefer {@link #forceMergeAsync(ForceMergeRequest, RequestOptions, ActionListener)} - */ - @Deprecated - public void forceMergeAsync(ForceMergeRequest forceMergeRequest, ActionListener listener, Header... headers) { - restHighLevelClient.performRequestAsyncAndParseEntity(forceMergeRequest, RequestConverters::forceMerge, - ForceMergeResponse::fromXContent, listener, emptySet(), headers); - } - /** * Clears the cache of one or more indices using the Clear Cache API. * See @@ -705,19 +444,6 @@ public ClearIndicesCacheResponse clearCache(ClearIndicesCacheRequest clearIndice ClearIndicesCacheResponse::fromXContent, emptySet()); } - /** - * Clears the cache of one or more indices using the Clear Cache API. - *

- * See - * Clear Cache API on elastic.co - * @deprecated Prefer {@link #clearCache(ClearIndicesCacheRequest, RequestOptions)} - */ - @Deprecated - public ClearIndicesCacheResponse clearCache(ClearIndicesCacheRequest clearIndicesCacheRequest, Header... headers) throws IOException { - return restHighLevelClient.performRequestAndParseEntity(clearIndicesCacheRequest, RequestConverters::clearCache, - ClearIndicesCacheResponse::fromXContent, emptySet(), headers); - } - /** * Asynchronously clears the cache of one or more indices using the Clear Cache API. * See @@ -732,20 +458,6 @@ public void clearCacheAsync(ClearIndicesCacheRequest clearIndicesCacheRequest, R ClearIndicesCacheResponse::fromXContent, listener, emptySet()); } - /** - * Asynchronously clears the cache of one or more indices using the Clear Cache API. - *

- * See - * Clear Cache API on elastic.co - * @deprecated Prefer {@link #clearCacheAsync(ClearIndicesCacheRequest, RequestOptions, ActionListener)} - */ - @Deprecated - public void clearCacheAsync(ClearIndicesCacheRequest clearIndicesCacheRequest, ActionListener listener, - Header... headers) { - restHighLevelClient.performRequestAsyncAndParseEntity(clearIndicesCacheRequest, RequestConverters::clearCache, - ClearIndicesCacheResponse::fromXContent, listener, emptySet(), headers); - } - /** * Checks if the index (indices) exists or not. * See @@ -765,24 +477,6 @@ public boolean exists(GetIndexRequest request, RequestOptions options) throws IO ); } - /** - * Checks if the index (indices) exists or not. - *

- * See - * Indices Exists API on elastic.co - * @deprecated Prefer {@link #exists(GetIndexRequest, RequestOptions)} - */ - @Deprecated - public boolean exists(GetIndexRequest request, Header... headers) throws IOException { - return restHighLevelClient.performRequest( - request, - RequestConverters::indicesExist, - RestHighLevelClient::convertExistsResponse, - Collections.emptySet(), - headers - ); - } - /** * Asynchronously checks if the index (indices) exists or not. * See @@ -802,25 +496,6 @@ public void existsAsync(GetIndexRequest request, RequestOptions options, ActionL ); } - /** - * Asynchronously checks if the index (indices) exists or not. - *

- * See - * Indices Exists API on elastic.co - * @deprecated Prefer {@link #existsAsync(GetIndexRequest, RequestOptions, ActionListener)} - */ - @Deprecated - public void existsAsync(GetIndexRequest request, ActionListener listener, Header... headers) { - restHighLevelClient.performRequestAsync( - request, - RequestConverters::indicesExist, - RestHighLevelClient::convertExistsResponse, - listener, - Collections.emptySet(), - headers - ); - } - /** * Shrinks an index using the Shrink Index API. * See @@ -835,19 +510,6 @@ public ResizeResponse shrink(ResizeRequest resizeRequest, RequestOptions options ResizeResponse::fromXContent, emptySet()); } - /** - * Shrinks an index using the Shrink Index API. - *

- * See - * Shrink Index API on elastic.co - * @deprecated Prefer {@link #shrink(ResizeRequest, RequestOptions)} - */ - @Deprecated - public ResizeResponse shrink(ResizeRequest resizeRequest, Header... headers) throws IOException { - return restHighLevelClient.performRequestAndParseEntity(resizeRequest, RequestConverters::shrink, ResizeResponse::fromXContent, - emptySet(), headers); - } - /** * Asynchronously shrinks an index using the Shrink index API. * See @@ -861,19 +523,6 @@ public void shrinkAsync(ResizeRequest resizeRequest, RequestOptions options, Act ResizeResponse::fromXContent, listener, emptySet()); } - /** - * Asynchronously shrinks an index using the Shrink index API. - *

- * See - * Shrink Index API on elastic.co - * @deprecated Prefer {@link #shrinkAsync(ResizeRequest, RequestOptions, ActionListener)} - */ - @Deprecated - public void shrinkAsync(ResizeRequest resizeRequest, ActionListener listener, Header... headers) { - restHighLevelClient.performRequestAsyncAndParseEntity(resizeRequest, RequestConverters::shrink, ResizeResponse::fromXContent, - listener, emptySet(), headers); - } - /** * Splits an index using the Split Index API. * See @@ -888,19 +537,6 @@ public ResizeResponse split(ResizeRequest resizeRequest, RequestOptions options) ResizeResponse::fromXContent, emptySet()); } - /** - * Splits an index using the Split Index API. - *

- * See - * Split Index API on elastic.co - * @deprecated {@link #split(ResizeRequest, RequestOptions)} - */ - @Deprecated - public ResizeResponse split(ResizeRequest resizeRequest, Header... headers) throws IOException { - return restHighLevelClient.performRequestAndParseEntity(resizeRequest, RequestConverters::split, ResizeResponse::fromXContent, - emptySet(), headers); - } - /** * Asynchronously splits an index using the Split Index API. * See @@ -914,19 +550,6 @@ public void splitAsync(ResizeRequest resizeRequest, RequestOptions options, Acti ResizeResponse::fromXContent, listener, emptySet()); } - /** - * Asynchronously splits an index using the Split Index API. - *

- * See - * Split Index API on elastic.co - * @deprecated Prefer {@link #splitAsync(ResizeRequest, RequestOptions, ActionListener)} - */ - @Deprecated - public void splitAsync(ResizeRequest resizeRequest, ActionListener listener, Header... headers) { - restHighLevelClient.performRequestAsyncAndParseEntity(resizeRequest, RequestConverters::split, ResizeResponse::fromXContent, - listener, emptySet(), headers); - } - /** * Rolls over an index using the Rollover Index API. * See @@ -941,19 +564,6 @@ public RolloverResponse rollover(RolloverRequest rolloverRequest, RequestOptions RolloverResponse::fromXContent, emptySet()); } - /** - * Rolls over an index using the Rollover Index API. - *

- * See - * Rollover Index API on elastic.co - * @deprecated Prefer {@link #rollover(RolloverRequest, RequestOptions)} - */ - @Deprecated - public RolloverResponse rollover(RolloverRequest rolloverRequest, Header... headers) throws IOException { - return restHighLevelClient.performRequestAndParseEntity(rolloverRequest, RequestConverters::rollover, - RolloverResponse::fromXContent, emptySet(), headers); - } - /** * Asynchronously rolls over an index using the Rollover Index API. * See @@ -967,19 +577,6 @@ public void rolloverAsync(RolloverRequest rolloverRequest, RequestOptions option RolloverResponse::fromXContent, listener, emptySet()); } - /** - * Asynchronously rolls over an index using the Rollover Index API. - *

- * See - * Rollover Index API on elastic.co - * @deprecated Prefer {@link #rolloverAsync(RolloverRequest, RequestOptions, ActionListener)} - */ - @Deprecated - public void rolloverAsync(RolloverRequest rolloverRequest, ActionListener listener, Header... headers) { - restHighLevelClient.performRequestAsyncAndParseEntity(rolloverRequest, RequestConverters::rollover, RolloverResponse::fromXContent, - listener, emptySet(), headers); - } - /** * Gets one or more aliases using the Get Index Aliases API. * See Indices Aliases API on @@ -1021,19 +618,6 @@ public UpdateSettingsResponse putSettings(UpdateSettingsRequest updateSettingsRe UpdateSettingsResponse::fromXContent, emptySet()); } - /** - * Updates specific index level settings using the Update Indices Settings API. - *

- * See Update Indices Settings - * API on elastic.co - * @deprecated Prefer {@link #putSettings(UpdateSettingsRequest, RequestOptions)} - */ - @Deprecated - public UpdateSettingsResponse putSettings(UpdateSettingsRequest updateSettingsRequest, Header... headers) throws IOException { - return restHighLevelClient.performRequestAndParseEntity(updateSettingsRequest, RequestConverters::indexPutSettings, - UpdateSettingsResponse::fromXContent, emptySet(), headers); - } - /** * Asynchronously updates specific index level settings using the Update Indices Settings API. * See Update Indices Settings @@ -1048,20 +632,6 @@ public void putSettingsAsync(UpdateSettingsRequest updateSettingsRequest, Reques UpdateSettingsResponse::fromXContent, listener, emptySet()); } - /** - * Asynchronously updates specific index level settings using the Update Indices Settings API. - *

- * See Update Indices Settings - * API on elastic.co - * @deprecated Prefer {@link #putSettingsAsync(UpdateSettingsRequest, RequestOptions, ActionListener)} - */ - @Deprecated - public void putSettingsAsync(UpdateSettingsRequest updateSettingsRequest, ActionListener listener, - Header... headers) { - restHighLevelClient.performRequestAsyncAndParseEntity(updateSettingsRequest, RequestConverters::indexPutSettings, - UpdateSettingsResponse::fromXContent, listener, emptySet(), headers); - } - /** * Puts an index template using the Index Templates API. * See Index Templates API diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java index 0084ce0f90d74..536b85925a4ba 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java @@ -296,17 +296,6 @@ public final BulkResponse bulk(BulkRequest bulkRequest, RequestOptions options) return performRequestAndParseEntity(bulkRequest, RequestConverters::bulk, options, BulkResponse::fromXContent, emptySet()); } - /** - * Executes a bulk request using the Bulk API. - * - * See Bulk API on elastic.co - * @deprecated Prefer {@link #bulk(BulkRequest, RequestOptions)} - */ - @Deprecated - public final BulkResponse bulk(BulkRequest bulkRequest, Header... headers) throws IOException { - return performRequestAndParseEntity(bulkRequest, RequestConverters::bulk, BulkResponse::fromXContent, emptySet(), headers); - } - /** * Asynchronously executes a bulk request using the Bulk API. * See Bulk API on elastic.co @@ -318,17 +307,6 @@ public final void bulkAsync(BulkRequest bulkRequest, RequestOptions options, Act performRequestAsyncAndParseEntity(bulkRequest, RequestConverters::bulk, options, BulkResponse::fromXContent, listener, emptySet()); } - /** - * Asynchronously executes a bulk request using the Bulk API. - * - * See Bulk API on elastic.co - * @deprecated Prefer {@link #bulkAsync(BulkRequest, RequestOptions, ActionListener)} - */ - @Deprecated - public final void bulkAsync(BulkRequest bulkRequest, ActionListener listener, Header... headers) { - performRequestAsyncAndParseEntity(bulkRequest, RequestConverters::bulk, BulkResponse::fromXContent, listener, emptySet(), headers); - } - /** * Pings the remote Elasticsearch cluster and returns true if the ping succeeded, false otherwise * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized @@ -340,16 +318,6 @@ public final boolean ping(RequestOptions options) throws IOException { emptySet()); } - /** - * Pings the remote Elasticsearch cluster and returns true if the ping succeeded, false otherwise - * @deprecated Prefer {@link #ping(RequestOptions)} - */ - @Deprecated - public final boolean ping(Header... headers) throws IOException { - return performRequest(new MainRequest(), (request) -> RequestConverters.ping(), RestHighLevelClient::convertExistsResponse, - emptySet(), headers); - } - /** * Get the cluster info otherwise provided when sending an HTTP request to '/' * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized @@ -361,16 +329,6 @@ public final MainResponse info(RequestOptions options) throws IOException { MainResponse::fromXContent, emptySet()); } - /** - * Get the cluster info otherwise provided when sending an HTTP request to port 9200 - * @deprecated Prefer {@link #info(RequestOptions)} - */ - @Deprecated - public final MainResponse info(Header... headers) throws IOException { - return performRequestAndParseEntity(new MainRequest(), (request) -> RequestConverters.info(), - MainResponse::fromXContent, emptySet(), headers); - } - /** * Retrieves a document by id using the Get API. * See Get API on elastic.co @@ -383,17 +341,6 @@ public final GetResponse get(GetRequest getRequest, RequestOptions options) thro return performRequestAndParseEntity(getRequest, RequestConverters::get, options, GetResponse::fromXContent, singleton(404)); } - /** - * Retrieves a document by id using the Get API. - * - * See Get API on elastic.co - * @deprecated Prefer {@link #get(GetRequest, RequestOptions)} - */ - @Deprecated - public final GetResponse get(GetRequest getRequest, Header... headers) throws IOException { - return performRequestAndParseEntity(getRequest, RequestConverters::get, GetResponse::fromXContent, singleton(404), headers); - } - /** * Asynchronously retrieves a document by id using the Get API. * See Get API on elastic.co @@ -406,18 +353,6 @@ public final void getAsync(GetRequest getRequest, RequestOptions options, Action singleton(404)); } - /** - * Asynchronously retrieves a document by id using the Get API. - * - * See Get API on elastic.co - * @deprecated Prefer {@link #getAsync(GetRequest, RequestOptions, ActionListener)} - */ - @Deprecated - public final void getAsync(GetRequest getRequest, ActionListener listener, Header... headers) { - performRequestAsyncAndParseEntity(getRequest, RequestConverters::get, GetResponse::fromXContent, listener, - singleton(404), headers); - } - /** * Retrieves multiple documents by id using the Multi Get API. * See Multi Get API on elastic.co @@ -431,18 +366,6 @@ public final MultiGetResponse multiGet(MultiGetRequest multiGetRequest, RequestO singleton(404)); } - /** - * Retrieves multiple documents by id using the Multi Get API. - * - * See Multi Get API on elastic.co - * @deprecated Prefer {@link #multiGet(MultiGetRequest, RequestOptions)} - */ - @Deprecated - public final MultiGetResponse multiGet(MultiGetRequest multiGetRequest, Header... headers) throws IOException { - return performRequestAndParseEntity(multiGetRequest, RequestConverters::multiGet, MultiGetResponse::fromXContent, - singleton(404), headers); - } - /** * Asynchronously retrieves multiple documents by id using the Multi Get API. * See Multi Get API on elastic.co @@ -455,18 +378,6 @@ public final void multiGetAsync(MultiGetRequest multiGetRequest, RequestOptions singleton(404)); } - /** - * Asynchronously retrieves multiple documents by id using the Multi Get API. - * - * See Multi Get API on elastic.co - * @deprecated Prefer {@link #multiGetAsync(MultiGetRequest, RequestOptions, ActionListener)} - */ - @Deprecated - public final void multiGetAsync(MultiGetRequest multiGetRequest, ActionListener listener, Header... headers) { - performRequestAsyncAndParseEntity(multiGetRequest, RequestConverters::multiGet, MultiGetResponse::fromXContent, listener, - singleton(404), headers); - } - /** * Checks for the existence of a document. Returns true if it exists, false otherwise. * See Get API on elastic.co @@ -479,17 +390,6 @@ public final boolean exists(GetRequest getRequest, RequestOptions options) throw return performRequest(getRequest, RequestConverters::exists, options, RestHighLevelClient::convertExistsResponse, emptySet()); } - /** - * Checks for the existence of a document. Returns true if it exists, false otherwise. - * - * See Get API on elastic.co - * @deprecated Prefer {@link #exists(GetRequest, RequestOptions)} - */ - @Deprecated - public final boolean exists(GetRequest getRequest, Header... headers) throws IOException { - return performRequest(getRequest, RequestConverters::exists, RestHighLevelClient::convertExistsResponse, emptySet(), headers); - } - /** * Asynchronously checks for the existence of a document. Returns true if it exists, false otherwise. * See Get API on elastic.co @@ -502,18 +402,6 @@ public final void existsAsync(GetRequest getRequest, RequestOptions options, Act emptySet()); } - /** - * Asynchronously checks for the existence of a document. Returns true if it exists, false otherwise. - * - * See Get API on elastic.co - * @deprecated Prefer {@link #existsAsync(GetRequest, RequestOptions, ActionListener)} - */ - @Deprecated - public final void existsAsync(GetRequest getRequest, ActionListener listener, Header... headers) { - performRequestAsync(getRequest, RequestConverters::exists, RestHighLevelClient::convertExistsResponse, listener, - emptySet(), headers); - } - /** * Index a document using the Index API. * See Index API on elastic.co @@ -526,17 +414,6 @@ public final IndexResponse index(IndexRequest indexRequest, RequestOptions optio return performRequestAndParseEntity(indexRequest, RequestConverters::index, options, IndexResponse::fromXContent, emptySet()); } - /** - * Index a document using the Index API. - * - * See Index API on elastic.co - * @deprecated Prefer {@link #index(IndexRequest, RequestOptions)} - */ - @Deprecated - public final IndexResponse index(IndexRequest indexRequest, Header... headers) throws IOException { - return performRequestAndParseEntity(indexRequest, RequestConverters::index, IndexResponse::fromXContent, emptySet(), headers); - } - /** * Asynchronously index a document using the Index API. * See Index API on elastic.co @@ -549,18 +426,6 @@ public final void indexAsync(IndexRequest indexRequest, RequestOptions options, emptySet()); } - /** - * Asynchronously index a document using the Index API. - * - * See Index API on elastic.co - * @deprecated Prefer {@link #indexAsync(IndexRequest, RequestOptions, ActionListener)} - */ - @Deprecated - public final void indexAsync(IndexRequest indexRequest, ActionListener listener, Header... headers) { - performRequestAsyncAndParseEntity(indexRequest, RequestConverters::index, IndexResponse::fromXContent, listener, - emptySet(), headers); - } - /** * Updates a document using the Update API. * See Update API on elastic.co @@ -573,17 +438,6 @@ public final UpdateResponse update(UpdateRequest updateRequest, RequestOptions o return performRequestAndParseEntity(updateRequest, RequestConverters::update, options, UpdateResponse::fromXContent, emptySet()); } - /** - * Updates a document using the Update API. - *

- * See Update API on elastic.co - * @deprecated Prefer {@link #update(UpdateRequest, RequestOptions)} - */ - @Deprecated - public final UpdateResponse update(UpdateRequest updateRequest, Header... headers) throws IOException { - return performRequestAndParseEntity(updateRequest, RequestConverters::update, UpdateResponse::fromXContent, emptySet(), headers); - } - /** * Asynchronously updates a document using the Update API. * See Update API on elastic.co @@ -596,18 +450,6 @@ public final void updateAsync(UpdateRequest updateRequest, RequestOptions option emptySet()); } - /** - * Asynchronously updates a document using the Update API. - *

- * See Update API on elastic.co - * @deprecated Prefer {@link #updateAsync(UpdateRequest, RequestOptions, ActionListener)} - */ - @Deprecated - public final void updateAsync(UpdateRequest updateRequest, ActionListener listener, Header... headers) { - performRequestAsyncAndParseEntity(updateRequest, RequestConverters::update, UpdateResponse::fromXContent, listener, - emptySet(), headers); - } - /** * Deletes a document by id using the Delete API. * See Delete API on elastic.co @@ -621,18 +463,6 @@ public final DeleteResponse delete(DeleteRequest deleteRequest, RequestOptions o singleton(404)); } - /** - * Deletes a document by id using the Delete API. - * - * See Delete API on elastic.co - * @deprecated Prefer {@link #delete(DeleteRequest, RequestOptions)} - */ - @Deprecated - public final DeleteResponse delete(DeleteRequest deleteRequest, Header... headers) throws IOException { - return performRequestAndParseEntity(deleteRequest, RequestConverters::delete, DeleteResponse::fromXContent, - singleton(404), headers); - } - /** * Asynchronously deletes a document by id using the Delete API. * See Delete API on elastic.co @@ -645,18 +475,6 @@ public final void deleteAsync(DeleteRequest deleteRequest, RequestOptions option Collections.singleton(404)); } - /** - * Asynchronously deletes a document by id using the Delete API. - * - * See Delete API on elastic.co - * @deprecated Prefer {@link #deleteAsync(DeleteRequest, RequestOptions, ActionListener)} - */ - @Deprecated - public final void deleteAsync(DeleteRequest deleteRequest, ActionListener listener, Header... headers) { - performRequestAsyncAndParseEntity(deleteRequest, RequestConverters::delete, DeleteResponse::fromXContent, listener, - Collections.singleton(404), headers); - } - /** * Executes a search request using the Search API. * See Search API on elastic.co @@ -669,17 +487,6 @@ public final SearchResponse search(SearchRequest searchRequest, RequestOptions o return performRequestAndParseEntity(searchRequest, RequestConverters::search, options, SearchResponse::fromXContent, emptySet()); } - /** - * Executes a search using the Search API. - * - * See Search API on elastic.co - * @deprecated Prefer {@link #search(SearchRequest, RequestOptions)} - */ - @Deprecated - public final SearchResponse search(SearchRequest searchRequest, Header... headers) throws IOException { - return performRequestAndParseEntity(searchRequest, RequestConverters::search, SearchResponse::fromXContent, emptySet(), headers); - } - /** * Asynchronously executes a search using the Search API. * See Search API on elastic.co @@ -692,18 +499,6 @@ public final void searchAsync(SearchRequest searchRequest, RequestOptions option emptySet()); } - /** - * Asynchronously executes a search using the Search API. - * - * See Search API on elastic.co - * @deprecated Prefer {@link #searchAsync(SearchRequest, RequestOptions, ActionListener)} - */ - @Deprecated - public final void searchAsync(SearchRequest searchRequest, ActionListener listener, Header... headers) { - performRequestAsyncAndParseEntity(searchRequest, RequestConverters::search, SearchResponse::fromXContent, listener, - emptySet(), headers); - } - /** * Executes a multi search using the msearch API. * See Multi search API on @@ -718,19 +513,6 @@ public final MultiSearchResponse multiSearch(MultiSearchRequest multiSearchReque emptySet()); } - /** - * Executes a multi search using the msearch API. - * - * See Multi search API on - * elastic.co - * @deprecated Prefer {@link #multiSearch(MultiSearchRequest, RequestOptions)} - */ - @Deprecated - public final MultiSearchResponse multiSearch(MultiSearchRequest multiSearchRequest, Header... headers) throws IOException { - return performRequestAndParseEntity(multiSearchRequest, RequestConverters::multiSearch, MultiSearchResponse::fromXContext, - emptySet(), headers); - } - /** * Asynchronously executes a multi search using the msearch API. * See Multi search API on @@ -745,19 +527,6 @@ public final void multiSearchAsync(MultiSearchRequest searchRequest, RequestOpti listener, emptySet()); } - /** - * Asynchronously executes a multi search using the msearch API. - * - * See Multi search API on - * elastic.co - * @deprecated Prefer {@link #multiSearchAsync(MultiSearchRequest, RequestOptions, ActionListener)} - */ - @Deprecated - public final void multiSearchAsync(MultiSearchRequest searchRequest, ActionListener listener, Header... headers) { - performRequestAsyncAndParseEntity(searchRequest, RequestConverters::multiSearch, MultiSearchResponse::fromXContext, listener, - emptySet(), headers); - } - /** * Executes a search using the Search Scroll API. * See Search Scroll @@ -772,19 +541,6 @@ public final SearchResponse searchScroll(SearchScrollRequest searchScrollRequest emptySet()); } - /** - * Executes a search using the Search Scroll API. - * - * See Search Scroll - * API on elastic.co - * @deprecated Prefer {@link #searchScroll(SearchScrollRequest, RequestOptions)} - */ - @Deprecated - public final SearchResponse searchScroll(SearchScrollRequest searchScrollRequest, Header... headers) throws IOException { - return performRequestAndParseEntity(searchScrollRequest, RequestConverters::searchScroll, SearchResponse::fromXContent, - emptySet(), headers); - } - /** * Asynchronously executes a search using the Search Scroll API. * See Search Scroll @@ -799,20 +555,6 @@ public final void searchScrollAsync(SearchScrollRequest searchScrollRequest, Req listener, emptySet()); } - /** - * Asynchronously executes a search using the Search Scroll API. - * - * See Search Scroll - * API on elastic.co - * @deprecated Prefer {@link #searchScrollAsync(SearchScrollRequest, RequestOptions, ActionListener)} - */ - @Deprecated - public final void searchScrollAsync(SearchScrollRequest searchScrollRequest, - ActionListener listener, Header... headers) { - performRequestAsyncAndParseEntity(searchScrollRequest, RequestConverters::searchScroll, SearchResponse::fromXContent, - listener, emptySet(), headers); - } - /** * Clears one or more scroll ids using the Clear Scroll API. * See @@ -827,19 +569,6 @@ public final ClearScrollResponse clearScroll(ClearScrollRequest clearScrollReque emptySet()); } - /** - * Clears one or more scroll ids using the Clear Scroll API. - * - * See - * Clear Scroll API on elastic.co - * @deprecated Prefer {@link #clearScroll(ClearScrollRequest, RequestOptions)} - */ - @Deprecated - public final ClearScrollResponse clearScroll(ClearScrollRequest clearScrollRequest, Header... headers) throws IOException { - return performRequestAndParseEntity(clearScrollRequest, RequestConverters::clearScroll, ClearScrollResponse::fromXContent, - emptySet(), headers); - } - /** * Asynchronously clears one or more scroll ids using the Clear Scroll API. * See @@ -854,20 +583,6 @@ public final void clearScrollAsync(ClearScrollRequest clearScrollRequest, Reques listener, emptySet()); } - /** - * Asynchronously clears one or more scroll ids using the Clear Scroll API. - * - * See - * Clear Scroll API on elastic.co - * @deprecated Prefer {@link #clearScrollAsync(ClearScrollRequest, RequestOptions, ActionListener)} - */ - @Deprecated - public final void clearScrollAsync(ClearScrollRequest clearScrollRequest, - ActionListener listener, Header... headers) { - performRequestAsyncAndParseEntity(clearScrollRequest, RequestConverters::clearScroll, ClearScrollResponse::fromXContent, - listener, emptySet(), headers); - } - /** * Executes a request using the Search Template API. * See Search Template API @@ -909,19 +624,6 @@ public final RankEvalResponse rankEval(RankEvalRequest rankEvalRequest, RequestO emptySet()); } - /** - * Executes a request using the Ranking Evaluation API. - * - * See Ranking Evaluation API - * on elastic.co - * @deprecated Prefer {@link #rankEval(RankEvalRequest, RequestOptions)} - */ - @Deprecated - public final RankEvalResponse rankEval(RankEvalRequest rankEvalRequest, Header... headers) throws IOException { - return performRequestAndParseEntity(rankEvalRequest, RequestConverters::rankEval, RankEvalResponse::fromXContent, - emptySet(), headers); - } - /** * Asynchronously executes a request using the Ranking Evaluation API. * See Ranking Evaluation API @@ -935,19 +637,6 @@ public final void rankEvalAsync(RankEvalRequest rankEvalRequest, RequestOptions emptySet()); } - /** - * Asynchronously executes a request using the Ranking Evaluation API. - * - * See Ranking Evaluation API - * on elastic.co - * @deprecated Prefer {@link #rankEvalAsync(RankEvalRequest, RequestOptions, ActionListener)} - */ - @Deprecated - public final void rankEvalAsync(RankEvalRequest rankEvalRequest, ActionListener listener, Header... headers) { - performRequestAsyncAndParseEntity(rankEvalRequest, RequestConverters::rankEval, RankEvalResponse::fromXContent, listener, - emptySet(), headers); - } - /** * Executes a request using the Field Capabilities API. * See Field Capabilities API @@ -977,14 +666,6 @@ public final void fieldCapsAsync(FieldCapabilitiesRequest fieldCapabilitiesReque FieldCapabilitiesResponse::fromXContent, listener, emptySet()); } - @Deprecated - protected final Resp performRequestAndParseEntity(Req request, - CheckedFunction requestConverter, - CheckedFunction entityParser, - Set ignores, Header... headers) throws IOException { - return performRequest(request, requestConverter, (response) -> parseEntity(response.getEntity(), entityParser), ignores, headers); - } - protected final Resp performRequestAndParseEntity(Req request, CheckedFunction requestConverter, RequestOptions options, @@ -994,14 +675,6 @@ protected final Resp performRequestAndParseEnt response -> parseEntity(response.getEntity(), entityParser), ignores); } - @Deprecated - protected final Resp performRequest(Req request, - CheckedFunction requestConverter, - CheckedFunction responseConverter, - Set ignores, Header... headers) throws IOException { - return performRequest(request, requestConverter, optionsForHeaders(headers), responseConverter, ignores); - } - protected final Resp performRequest(Req request, CheckedFunction requestConverter, RequestOptions options, @@ -1038,15 +711,6 @@ protected final Resp performRequest(Req reques } } - @Deprecated - protected final void performRequestAsyncAndParseEntity(Req request, - CheckedFunction requestConverter, - CheckedFunction entityParser, - ActionListener listener, Set ignores, Header... headers) { - performRequestAsync(request, requestConverter, (response) -> parseEntity(response.getEntity(), entityParser), - listener, ignores, headers); - } - protected final void performRequestAsyncAndParseEntity(Req request, CheckedFunction requestConverter, RequestOptions options, @@ -1056,14 +720,6 @@ protected final void performRequestAsyncAndPar response -> parseEntity(response.getEntity(), entityParser), listener, ignores); } - @Deprecated - protected final void performRequestAsync(Req request, - CheckedFunction requestConverter, - CheckedFunction responseConverter, - ActionListener listener, Set ignores, Header... headers) { - performRequestAsync(request, requestConverter, optionsForHeaders(headers), responseConverter, listener, ignores); - } - protected final void performRequestAsync(Req request, CheckedFunction requestConverter, RequestOptions options, diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/TasksClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/TasksClient.java index f8f03d7f7d288..ebba636b8fa05 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/TasksClient.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/TasksClient.java @@ -84,7 +84,7 @@ public CancelTasksResponse cancel(CancelTasksRequest cancelTasksRequest, Request cancelTasksRequest, RequestConverters::cancelTasks, options, - parser -> CancelTasksResponse.fromXContent(parser), + CancelTasksResponse::fromXContent, emptySet() ); } @@ -103,7 +103,7 @@ public void cancelAsync(CancelTasksRequest cancelTasksRequest, RequestOptions op cancelTasksRequest, RequestConverters::cancelTasks, options, - parser -> CancelTasksResponse.fromXContent(parser), + CancelTasksResponse::fromXContent, listener, emptySet() ); diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorIT.java index d41c47177f968..7605b1c715c74 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorIT.java @@ -56,7 +56,8 @@ public class BulkProcessorIT extends ESRestHighLevelClientTestCase { private static BulkProcessor.Builder initBulkProcessorBuilder(BulkProcessor.Listener listener) { - return BulkProcessor.builder(highLevelClient()::bulkAsync, listener); + return BulkProcessor.builder( + (request, bulkListener) -> highLevelClient().bulkAsync(request, RequestOptions.DEFAULT, bulkListener), listener); } public void testThatBulkProcessorCountIsCorrect() throws Exception { diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorRetryIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorRetryIT.java index fe6aa6b1017ee..c20998eeb5826 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorRetryIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorRetryIT.java @@ -48,7 +48,8 @@ public class BulkProcessorRetryIT extends ESRestHighLevelClientTestCase { private static final String TYPE_NAME = "type"; private static BulkProcessor.Builder initBulkProcessorBuilder(BulkProcessor.Listener listener) { - return BulkProcessor.builder(highLevelClient()::bulkAsync, listener); + return BulkProcessor.builder( + (request, bulkListener) -> highLevelClient().bulkAsync(request, RequestOptions.DEFAULT, bulkListener), listener); } public void testBulkRejectionLoadWithoutBackoff() throws Exception { diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/ClusterClientIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/ClusterClientIT.java index 7cf9fca07c30d..2ae6f9dc186ef 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/ClusterClientIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/ClusterClientIT.java @@ -63,7 +63,6 @@ public void testClusterPutSettings() throws IOException { setRequest.persistentSettings(map); ClusterUpdateSettingsResponse setResponse = execute(setRequest, highLevelClient().cluster()::putSettings, - highLevelClient().cluster()::putSettingsAsync, highLevelClient().cluster()::putSettings, highLevelClient().cluster()::putSettingsAsync); assertAcked(setResponse); @@ -86,7 +85,6 @@ public void testClusterPutSettings() throws IOException { resetRequest.persistentSettings("{\"" + persistentSettingKey + "\": null }", XContentType.JSON); ClusterUpdateSettingsResponse resetResponse = execute(resetRequest, highLevelClient().cluster()::putSettings, - highLevelClient().cluster()::putSettingsAsync, highLevelClient().cluster()::putSettings, highLevelClient().cluster()::putSettingsAsync); assertThat(resetResponse.getTransientSettings().get(transientSettingKey), equalTo(null)); @@ -108,7 +106,6 @@ public void testClusterUpdateSettingNonExistent() { clusterUpdateSettingsRequest.transientSettings(Settings.builder().put(setting, value).build()); ElasticsearchException exception = expectThrows(ElasticsearchException.class, () -> execute(clusterUpdateSettingsRequest, - highLevelClient().cluster()::putSettings, highLevelClient().cluster()::putSettingsAsync, highLevelClient().cluster()::putSettings, highLevelClient().cluster()::putSettingsAsync)); assertThat(exception.status(), equalTo(RestStatus.BAD_REQUEST)); assertThat(exception.getMessage(), equalTo( diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java index 81c894f242fe4..9de4c22611c3b 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java @@ -74,8 +74,7 @@ public void testDelete() throws IOException { if (randomBoolean()) { deleteRequest.version(1L); } - DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync, - highLevelClient()::delete, highLevelClient()::deleteAsync); + DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync); assertEquals("index", deleteResponse.getIndex()); assertEquals("type", deleteResponse.getType()); assertEquals(docId, deleteResponse.getId()); @@ -85,8 +84,7 @@ public void testDelete() throws IOException { // Testing non existing document String docId = "does_not_exist"; DeleteRequest deleteRequest = new DeleteRequest("index", "type", docId); - DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync, - highLevelClient()::delete, highLevelClient()::deleteAsync); + DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync); assertEquals("index", deleteResponse.getIndex()); assertEquals("type", deleteResponse.getType()); assertEquals(docId, deleteResponse.getId()); @@ -99,8 +97,7 @@ public void testDelete() throws IOException { new IndexRequest("index", "type", docId).source(Collections.singletonMap("foo", "bar")), RequestOptions.DEFAULT); DeleteRequest deleteRequest = new DeleteRequest("index", "type", docId).version(2); ElasticsearchException exception = expectThrows(ElasticsearchException.class, - () -> execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync, - highLevelClient()::delete, highLevelClient()::deleteAsync)); + () -> execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync)); assertEquals(RestStatus.CONFLICT, exception.status()); assertEquals("Elasticsearch exception [type=version_conflict_engine_exception, reason=[type][" + docId + "]: " + "version conflict, current version [1] is different than the one provided [2]]", exception.getMessage()); @@ -113,8 +110,7 @@ public void testDelete() throws IOException { new IndexRequest("index", "type", docId).source(Collections.singletonMap("foo", "bar")) .versionType(VersionType.EXTERNAL).version(12), RequestOptions.DEFAULT); DeleteRequest deleteRequest = new DeleteRequest("index", "type", docId).versionType(VersionType.EXTERNAL).version(13); - DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync, - highLevelClient()::delete, highLevelClient()::deleteAsync); + DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync); assertEquals("index", deleteResponse.getIndex()); assertEquals("type", deleteResponse.getType()); assertEquals(docId, deleteResponse.getId()); @@ -128,8 +124,7 @@ public void testDelete() throws IOException { .versionType(VersionType.EXTERNAL).version(12), RequestOptions.DEFAULT); ElasticsearchStatusException exception = expectThrows(ElasticsearchStatusException.class, () -> { DeleteRequest deleteRequest = new DeleteRequest("index", "type", docId).versionType(VersionType.EXTERNAL).version(10); - execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync, - highLevelClient()::delete, highLevelClient()::deleteAsync); + execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync); }); assertEquals(RestStatus.CONFLICT, exception.status()); assertEquals("Elasticsearch exception [type=version_conflict_engine_exception, reason=[type][" + @@ -142,8 +137,7 @@ public void testDelete() throws IOException { highLevelClient().index(new IndexRequest("index", "type", docId).source(Collections.singletonMap("foo", "bar")).routing("foo"), RequestOptions.DEFAULT); DeleteRequest deleteRequest = new DeleteRequest("index", "type", docId).routing("foo"); - DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync, - highLevelClient()::delete, highLevelClient()::deleteAsync); + DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync); assertEquals("index", deleteResponse.getIndex()); assertEquals("type", deleteResponse.getType()); assertEquals(docId, deleteResponse.getId()); @@ -154,8 +148,7 @@ public void testDelete() throws IOException { public void testExists() throws IOException { { GetRequest getRequest = new GetRequest("index", "type", "id"); - assertFalse(execute(getRequest, highLevelClient()::exists, highLevelClient()::existsAsync, - highLevelClient()::exists, highLevelClient()::existsAsync)); + assertFalse(execute(getRequest, highLevelClient()::exists, highLevelClient()::existsAsync)); } IndexRequest index = new IndexRequest("index", "type", "id"); index.source("{\"field1\":\"value1\",\"field2\":\"value2\"}", XContentType.JSON); @@ -163,18 +156,15 @@ public void testExists() throws IOException { highLevelClient().index(index, RequestOptions.DEFAULT); { GetRequest getRequest = new GetRequest("index", "type", "id"); - assertTrue(execute(getRequest, highLevelClient()::exists, highLevelClient()::existsAsync, - highLevelClient()::exists, highLevelClient()::existsAsync)); + assertTrue(execute(getRequest, highLevelClient()::exists, highLevelClient()::existsAsync)); } { GetRequest getRequest = new GetRequest("index", "type", "does_not_exist"); - assertFalse(execute(getRequest, highLevelClient()::exists, highLevelClient()::existsAsync, - highLevelClient()::exists, highLevelClient()::existsAsync)); + assertFalse(execute(getRequest, highLevelClient()::exists, highLevelClient()::existsAsync)); } { GetRequest getRequest = new GetRequest("index", "type", "does_not_exist").version(1); - assertFalse(execute(getRequest, highLevelClient()::exists, highLevelClient()::existsAsync, - highLevelClient()::exists, highLevelClient()::existsAsync)); + assertFalse(execute(getRequest, highLevelClient()::exists, highLevelClient()::existsAsync)); } } @@ -182,8 +172,7 @@ public void testGet() throws IOException { { GetRequest getRequest = new GetRequest("index", "type", "id"); ElasticsearchException exception = expectThrows(ElasticsearchException.class, - () -> execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync, - highLevelClient()::get, highLevelClient()::getAsync)); + () -> execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync)); assertEquals(RestStatus.NOT_FOUND, exception.status()); assertEquals("Elasticsearch exception [type=index_not_found_exception, reason=no such index]", exception.getMessage()); assertEquals("index", exception.getMetadata("es.index").get(0)); @@ -196,8 +185,7 @@ public void testGet() throws IOException { { GetRequest getRequest = new GetRequest("index", "type", "id").version(2); ElasticsearchException exception = expectThrows(ElasticsearchException.class, - () -> execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync, - highLevelClient()::get, highLevelClient()::getAsync)); + () -> execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync)); assertEquals(RestStatus.CONFLICT, exception.status()); assertEquals("Elasticsearch exception [type=version_conflict_engine_exception, " + "reason=[type][id]: " + "version conflict, current version [1] is different than the one provided [2]]", exception.getMessage()); @@ -208,8 +196,7 @@ public void testGet() throws IOException { if (randomBoolean()) { getRequest.version(1L); } - GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync, - highLevelClient()::get, highLevelClient()::getAsync); + GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync); assertEquals("index", getResponse.getIndex()); assertEquals("type", getResponse.getType()); assertEquals("id", getResponse.getId()); @@ -220,8 +207,7 @@ public void testGet() throws IOException { } { GetRequest getRequest = new GetRequest("index", "type", "does_not_exist"); - GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync, - highLevelClient()::get, highLevelClient()::getAsync); + GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync); assertEquals("index", getResponse.getIndex()); assertEquals("type", getResponse.getType()); assertEquals("does_not_exist", getResponse.getId()); @@ -233,8 +219,7 @@ public void testGet() throws IOException { { GetRequest getRequest = new GetRequest("index", "type", "id"); getRequest.fetchSourceContext(new FetchSourceContext(false, Strings.EMPTY_ARRAY, Strings.EMPTY_ARRAY)); - GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync, - highLevelClient()::get, highLevelClient()::getAsync); + GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync); assertEquals("index", getResponse.getIndex()); assertEquals("type", getResponse.getType()); assertEquals("id", getResponse.getId()); @@ -250,8 +235,7 @@ public void testGet() throws IOException { } else { getRequest.fetchSourceContext(new FetchSourceContext(true, Strings.EMPTY_ARRAY, new String[]{"field2"})); } - GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync, - highLevelClient()::get, highLevelClient()::getAsync); + GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync); assertEquals("index", getResponse.getIndex()); assertEquals("type", getResponse.getType()); assertEquals("id", getResponse.getId()); @@ -269,8 +253,7 @@ public void testMultiGet() throws IOException { MultiGetRequest multiGetRequest = new MultiGetRequest(); multiGetRequest.add("index", "type", "id1"); multiGetRequest.add("index", "type", "id2"); - MultiGetResponse response = execute(multiGetRequest, highLevelClient()::multiGet, highLevelClient()::multiGetAsync, - highLevelClient()::multiGet, highLevelClient()::multiGetAsync); + MultiGetResponse response = execute(multiGetRequest, highLevelClient()::multiGet, highLevelClient()::multiGetAsync); assertEquals(2, response.getResponses().length); assertTrue(response.getResponses()[0].isFailed()); @@ -302,8 +285,7 @@ public void testMultiGet() throws IOException { MultiGetRequest multiGetRequest = new MultiGetRequest(); multiGetRequest.add("index", "type", "id1"); multiGetRequest.add("index", "type", "id2"); - MultiGetResponse response = execute(multiGetRequest, highLevelClient()::multiGet, highLevelClient()::multiGetAsync, - highLevelClient()::multiGet, highLevelClient()::multiGetAsync); + MultiGetResponse response = execute(multiGetRequest, highLevelClient()::multiGet, highLevelClient()::multiGetAsync); assertEquals(2, response.getResponses().length); assertFalse(response.getResponses()[0].isFailed()); @@ -328,8 +310,7 @@ public void testIndex() throws IOException { IndexRequest indexRequest = new IndexRequest("index", "type"); indexRequest.source(XContentBuilder.builder(xContentType.xContent()).startObject().field("test", "test").endObject()); - IndexResponse indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync, - highLevelClient()::index, highLevelClient()::indexAsync); + IndexResponse indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync); assertEquals(RestStatus.CREATED, indexResponse.status()); assertEquals(DocWriteResponse.Result.CREATED, indexResponse.getResult()); assertEquals("index", indexResponse.getIndex()); @@ -350,8 +331,7 @@ public void testIndex() throws IOException { IndexRequest indexRequest = new IndexRequest("index", "type", "id"); indexRequest.source(XContentBuilder.builder(xContentType.xContent()).startObject().field("version", 1).endObject()); - IndexResponse indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync, - highLevelClient()::index, highLevelClient()::indexAsync); + IndexResponse indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync); assertEquals(RestStatus.CREATED, indexResponse.status()); assertEquals("index", indexResponse.getIndex()); assertEquals("type", indexResponse.getType()); @@ -361,8 +341,7 @@ public void testIndex() throws IOException { indexRequest = new IndexRequest("index", "type", "id"); indexRequest.source(XContentBuilder.builder(xContentType.xContent()).startObject().field("version", 2).endObject()); - indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync, - highLevelClient()::index, highLevelClient()::indexAsync); + indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync); assertEquals(RestStatus.OK, indexResponse.status()); assertEquals("index", indexResponse.getIndex()); assertEquals("type", indexResponse.getType()); @@ -374,8 +353,7 @@ public void testIndex() throws IOException { wrongRequest.source(XContentBuilder.builder(xContentType.xContent()).startObject().field("field", "test").endObject()); wrongRequest.version(5L); - execute(wrongRequest, highLevelClient()::index, highLevelClient()::indexAsync, - highLevelClient()::index, highLevelClient()::indexAsync); + execute(wrongRequest, highLevelClient()::index, highLevelClient()::indexAsync); }); assertEquals(RestStatus.CONFLICT, exception.status()); assertEquals("Elasticsearch exception [type=version_conflict_engine_exception, reason=[type][id]: " + @@ -388,8 +366,7 @@ public void testIndex() throws IOException { indexRequest.source(XContentBuilder.builder(xContentType.xContent()).startObject().field("field", "test").endObject()); indexRequest.setPipeline("missing"); - execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync, - highLevelClient()::index, highLevelClient()::indexAsync); + execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync); }); assertEquals(RestStatus.BAD_REQUEST, exception.status()); @@ -402,8 +379,7 @@ public void testIndex() throws IOException { indexRequest.version(12L); indexRequest.versionType(VersionType.EXTERNAL); - IndexResponse indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync, - highLevelClient()::index, highLevelClient()::indexAsync); + IndexResponse indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync); assertEquals(RestStatus.CREATED, indexResponse.status()); assertEquals("index", indexResponse.getIndex()); assertEquals("type", indexResponse.getType()); @@ -415,16 +391,14 @@ public void testIndex() throws IOException { indexRequest.source(XContentBuilder.builder(xContentType.xContent()).startObject().field("field", "test").endObject()); indexRequest.opType(DocWriteRequest.OpType.CREATE); - IndexResponse indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync, - highLevelClient()::index, highLevelClient()::indexAsync); + IndexResponse indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync); assertEquals(RestStatus.CREATED, indexResponse.status()); assertEquals("index", indexResponse.getIndex()); assertEquals("type", indexResponse.getType()); assertEquals("with_create_op_type", indexResponse.getId()); ElasticsearchStatusException exception = expectThrows(ElasticsearchStatusException.class, () -> { - execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync, - highLevelClient()::index, highLevelClient()::indexAsync); + execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync); }); assertEquals(RestStatus.CONFLICT, exception.status()); @@ -439,8 +413,7 @@ public void testUpdate() throws IOException { updateRequest.doc(singletonMap("field", "value"), randomFrom(XContentType.values())); ElasticsearchStatusException exception = expectThrows(ElasticsearchStatusException.class, () -> - execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync, - highLevelClient()::update, highLevelClient()::updateAsync)); + execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync)); assertEquals(RestStatus.NOT_FOUND, exception.status()); assertEquals("Elasticsearch exception [type=document_missing_exception, reason=[type][does_not_exist]: document missing]", exception.getMessage()); @@ -463,8 +436,7 @@ public void testUpdate() throws IOException { updateRequestConflict.version(indexResponse.getVersion()); ElasticsearchStatusException exception = expectThrows(ElasticsearchStatusException.class, () -> - execute(updateRequestConflict, highLevelClient()::update, highLevelClient()::updateAsync, - highLevelClient()::update, highLevelClient()::updateAsync)); + execute(updateRequestConflict, highLevelClient()::update, highLevelClient()::updateAsync)); assertEquals(RestStatus.CONFLICT, exception.status()); assertEquals("Elasticsearch exception [type=version_conflict_engine_exception, reason=[type][id]: version conflict, " + "current version [2] is different than the one provided [1]]", exception.getMessage()); @@ -480,8 +452,7 @@ public void testUpdate() throws IOException { updateRequest.script(script); updateRequest.fetchSource(true); - UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync, - highLevelClient()::update, highLevelClient()::updateAsync); + UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync); assertEquals(RestStatus.OK, updateResponse.status()); assertEquals(DocWriteResponse.Result.UPDATED, updateResponse.getResult()); assertEquals(2L, updateResponse.getVersion()); @@ -501,8 +472,7 @@ public void testUpdate() throws IOException { updateRequest.doc(singletonMap("field_2", "two"), randomFrom(XContentType.values())); updateRequest.fetchSource("field_*", "field_3"); - UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync, - highLevelClient()::update, highLevelClient()::updateAsync); + UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync); assertEquals(RestStatus.OK, updateResponse.status()); assertEquals(DocWriteResponse.Result.UPDATED, updateResponse.getResult()); assertEquals(13L, updateResponse.getVersion()); @@ -523,8 +493,7 @@ public void testUpdate() throws IOException { UpdateRequest updateRequest = new UpdateRequest("index", "type", "noop"); updateRequest.doc(singletonMap("field", "value"), randomFrom(XContentType.values())); - UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync, - highLevelClient()::update, highLevelClient()::updateAsync); + UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync); assertEquals(RestStatus.OK, updateResponse.status()); assertEquals(DocWriteResponse.Result.NOOP, updateResponse.getResult()); assertEquals(1L, updateResponse.getVersion()); @@ -542,8 +511,7 @@ public void testUpdate() throws IOException { updateRequest.doc(singletonMap("doc_status", "updated")); updateRequest.fetchSource(true); - UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync, - highLevelClient()::update, highLevelClient()::updateAsync); + UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync); assertEquals(RestStatus.CREATED, updateResponse.status()); assertEquals("index", updateResponse.getIndex()); assertEquals("type", updateResponse.getType()); @@ -558,8 +526,7 @@ public void testUpdate() throws IOException { updateRequest.fetchSource(true); updateRequest.docAsUpsert(true); - UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync, - highLevelClient()::update, highLevelClient()::updateAsync); + UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync); assertEquals(RestStatus.CREATED, updateResponse.status()); assertEquals("index", updateResponse.getIndex()); assertEquals("type", updateResponse.getType()); @@ -575,8 +542,7 @@ public void testUpdate() throws IOException { updateRequest.scriptedUpsert(true); updateRequest.upsert(singletonMap("level", "A")); - UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync, - highLevelClient()::update, highLevelClient()::updateAsync); + UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync); assertEquals(RestStatus.CREATED, updateResponse.status()); assertEquals("index", updateResponse.getIndex()); assertEquals("type", updateResponse.getType()); @@ -591,8 +557,7 @@ public void testUpdate() throws IOException { UpdateRequest updateRequest = new UpdateRequest("index", "type", "id"); updateRequest.doc(new IndexRequest().source(Collections.singletonMap("field", "doc"), XContentType.JSON)); updateRequest.upsert(new IndexRequest().source(Collections.singletonMap("field", "upsert"), XContentType.YAML)); - execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync, - highLevelClient()::update, highLevelClient()::updateAsync); + execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync); }); assertEquals("Update request cannot have different content types for doc [JSON] and upsert [YAML] documents", exception.getMessage()); @@ -651,8 +616,7 @@ public void testBulk() throws IOException { } } - BulkResponse bulkResponse = execute(bulkRequest, highLevelClient()::bulk, highLevelClient()::bulkAsync, - highLevelClient()::bulk, highLevelClient()::bulkAsync); + BulkResponse bulkResponse = execute(bulkRequest, highLevelClient()::bulk, highLevelClient()::bulkAsync); assertEquals(RestStatus.OK, bulkResponse.status()); assertTrue(bulkResponse.getTook().getMillis() > 0); assertEquals(nbItems, bulkResponse.getItems().length); @@ -688,10 +652,8 @@ public void afterBulk(long executionId, BulkRequest request, Throwable failure) } }; - // Pull the client to a variable to work around https://bugs.eclipse.org/bugs/show_bug.cgi?id=514884 - RestHighLevelClient hlClient = highLevelClient(); - - try (BulkProcessor processor = BulkProcessor.builder(hlClient::bulkAsync, listener) + try (BulkProcessor processor = BulkProcessor.builder( + (request, bulkListener) -> highLevelClient().bulkAsync(request, RequestOptions.DEFAULT, bulkListener), listener) .setConcurrentRequests(0) .setBulkSize(new ByteSizeValue(5, ByteSizeUnit.GB)) .setBulkActions(nbItems + 1) diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/ESRestHighLevelClientTestCase.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/ESRestHighLevelClientTestCase.java index 14fe0e01d31f9..4ad39f547584b 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/ESRestHighLevelClientTestCase.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/ESRestHighLevelClientTestCase.java @@ -19,7 +19,6 @@ package org.elasticsearch.client; -import org.apache.http.Header; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ingest.PutPipelineRequest; import org.elasticsearch.action.support.PlainActionFuture; @@ -80,43 +79,6 @@ protected interface AsyncMethod { void execute(Request request, RequestOptions options, ActionListener listener); } - /** - * Executes the provided request using either the sync method or its async variant, both provided as functions - */ - @Deprecated - protected static Resp execute(Req request, SyncMethod syncMethod, AsyncMethod asyncMethod, - SyncMethodWithHeaders syncMethodWithHeaders, - AsyncMethodWithHeaders asyncMethodWithHeaders) throws IOException { - switch(randomIntBetween(0, 3)) { - case 0: - return syncMethod.execute(request, RequestOptions.DEFAULT); - case 1: - PlainActionFuture future = PlainActionFuture.newFuture(); - asyncMethod.execute(request, RequestOptions.DEFAULT, future); - return future.actionGet(); - case 2: - return syncMethodWithHeaders.execute(request); - case 3: - PlainActionFuture futureWithHeaders = PlainActionFuture.newFuture(); - asyncMethodWithHeaders.execute(request, futureWithHeaders); - return futureWithHeaders.actionGet(); - default: - throw new UnsupportedOperationException(); - } - } - - @Deprecated - @FunctionalInterface - protected interface SyncMethodWithHeaders { - Response execute(Request request, Header... headers) throws IOException; - } - - @Deprecated - @FunctionalInterface - protected interface AsyncMethodWithHeaders { - void execute(Request request, ActionListener listener, Header... headers); - } - private static class HighLevelClient extends RestHighLevelClient { private HighLevelClient(RestClient restClient) { super(restClient, (client) -> {}, Collections.emptyList()); diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java index 9b54938ede4d6..82ac161f5afe0 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java @@ -117,8 +117,6 @@ public void testIndicesExists() throws IOException { boolean response = execute( request, highLevelClient().indices()::exists, - highLevelClient().indices()::existsAsync, - highLevelClient().indices()::exists, highLevelClient().indices()::existsAsync ); assertTrue(response); @@ -134,8 +132,6 @@ public void testIndicesExists() throws IOException { boolean response = execute( request, highLevelClient().indices()::exists, - highLevelClient().indices()::existsAsync, - highLevelClient().indices()::exists, highLevelClient().indices()::existsAsync ); assertFalse(response); @@ -154,8 +150,6 @@ public void testIndicesExists() throws IOException { boolean response = execute( request, highLevelClient().indices()::exists, - highLevelClient().indices()::existsAsync, - highLevelClient().indices()::exists, highLevelClient().indices()::existsAsync ); assertFalse(response); @@ -173,8 +167,7 @@ public void testCreateIndex() throws IOException { CreateIndexRequest createIndexRequest = new CreateIndexRequest(indexName); CreateIndexResponse createIndexResponse = - execute(createIndexRequest, highLevelClient().indices()::create, highLevelClient().indices()::createAsync, - highLevelClient().indices()::create, highLevelClient().indices()::createAsync); + execute(createIndexRequest, highLevelClient().indices()::create, highLevelClient().indices()::createAsync); assertTrue(createIndexResponse.isAcknowledged()); assertTrue(indexExists(indexName)); @@ -202,8 +195,7 @@ public void testCreateIndex() throws IOException { createIndexRequest.mapping("type_name", mappingBuilder); CreateIndexResponse createIndexResponse = - execute(createIndexRequest, highLevelClient().indices()::create, highLevelClient().indices()::createAsync, - highLevelClient().indices()::create, highLevelClient().indices()::createAsync); + execute(createIndexRequest, highLevelClient().indices()::create, highLevelClient().indices()::createAsync); assertTrue(createIndexResponse.isAcknowledged()); Map getIndexResponse = getAsMap(indexName); @@ -338,8 +330,7 @@ public void testPutMapping() throws IOException { putMappingRequest.source(mappingBuilder); PutMappingResponse putMappingResponse = - execute(putMappingRequest, highLevelClient().indices()::putMapping, highLevelClient().indices()::putMappingAsync, - highLevelClient().indices()::putMapping, highLevelClient().indices()::putMappingAsync); + execute(putMappingRequest, highLevelClient().indices()::putMapping, highLevelClient().indices()::putMappingAsync); assertTrue(putMappingResponse.isAcknowledged()); Map getIndexResponse = getAsMap(indexName); @@ -390,8 +381,7 @@ public void testDeleteIndex() throws IOException { DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(indexName); DeleteIndexResponse deleteIndexResponse = - execute(deleteIndexRequest, highLevelClient().indices()::delete, highLevelClient().indices()::deleteAsync, - highLevelClient().indices()::delete, highLevelClient().indices()::deleteAsync); + execute(deleteIndexRequest, highLevelClient().indices()::delete, highLevelClient().indices()::deleteAsync); assertTrue(deleteIndexResponse.isAcknowledged()); assertFalse(indexExists(indexName)); @@ -404,8 +394,7 @@ public void testDeleteIndex() throws IOException { DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(nonExistentIndex); ElasticsearchException exception = expectThrows(ElasticsearchException.class, - () -> execute(deleteIndexRequest, highLevelClient().indices()::delete, highLevelClient().indices()::deleteAsync, - highLevelClient().indices()::delete, highLevelClient().indices()::deleteAsync)); + () -> execute(deleteIndexRequest, highLevelClient().indices()::delete, highLevelClient().indices()::deleteAsync)); assertEquals(RestStatus.NOT_FOUND, exception.status()); } } @@ -424,7 +413,6 @@ public void testUpdateAliases() throws IOException { addAction.routing("routing").searchRouting("search_routing").filter("{\"term\":{\"year\":2016}}"); aliasesAddRequest.addAliasAction(addAction); IndicesAliasesResponse aliasesAddResponse = execute(aliasesAddRequest, highLevelClient().indices()::updateAliases, - highLevelClient().indices()::updateAliasesAsync, highLevelClient().indices()::updateAliases, highLevelClient().indices()::updateAliasesAsync); assertTrue(aliasesAddResponse.isAcknowledged()); assertThat(aliasExists(alias), equalTo(true)); @@ -443,7 +431,6 @@ public void testUpdateAliases() throws IOException { AliasActions removeAction = new AliasActions(AliasActions.Type.REMOVE).index(index).alias(alias); aliasesAddRemoveRequest.addAliasAction(removeAction); IndicesAliasesResponse aliasesAddRemoveResponse = execute(aliasesAddRemoveRequest, highLevelClient().indices()::updateAliases, - highLevelClient().indices()::updateAliasesAsync, highLevelClient().indices()::updateAliases, highLevelClient().indices()::updateAliasesAsync); assertTrue(aliasesAddRemoveResponse.isAcknowledged()); assertThat(aliasExists(alias), equalTo(false)); @@ -455,7 +442,6 @@ public void testUpdateAliases() throws IOException { AliasActions removeIndexAction = new AliasActions(AliasActions.Type.REMOVE_INDEX).index(index); aliasesRemoveIndexRequest.addAliasAction(removeIndexAction); IndicesAliasesResponse aliasesRemoveIndexResponse = execute(aliasesRemoveIndexRequest, highLevelClient().indices()::updateAliases, - highLevelClient().indices()::updateAliasesAsync, highLevelClient().indices()::updateAliases, highLevelClient().indices()::updateAliasesAsync); assertTrue(aliasesRemoveIndexResponse.isAcknowledged()); assertThat(aliasExists(alias), equalTo(false)); @@ -473,9 +459,7 @@ public void testAliasesNonExistentIndex() throws IOException { IndicesAliasesRequest nonExistentIndexRequest = new IndicesAliasesRequest(); nonExistentIndexRequest.addAliasAction(new AliasActions(AliasActions.Type.ADD).index(nonExistentIndex).alias(alias)); ElasticsearchException exception = expectThrows(ElasticsearchException.class, () -> execute(nonExistentIndexRequest, - highLevelClient().indices()::updateAliases, highLevelClient().indices()::updateAliasesAsync, - highLevelClient().indices()::updateAliases, - highLevelClient().indices()::updateAliasesAsync)); + highLevelClient().indices()::updateAliases, highLevelClient().indices()::updateAliasesAsync)); assertThat(exception.status(), equalTo(RestStatus.NOT_FOUND)); assertThat(exception.getMessage(), equalTo("Elasticsearch exception [type=index_not_found_exception, reason=no such index]")); assertThat(exception.getMetadata("es.index"), hasItem(nonExistentIndex)); @@ -485,8 +469,7 @@ public void testAliasesNonExistentIndex() throws IOException { mixedRequest.addAliasAction(new AliasActions(AliasActions.Type.ADD).indices(index).aliases(alias)); mixedRequest.addAliasAction(new AliasActions(AliasActions.Type.REMOVE).indices(nonExistentIndex).alias(alias)); exception = expectThrows(ElasticsearchStatusException.class, - () -> execute(mixedRequest, highLevelClient().indices()::updateAliases, highLevelClient().indices()::updateAliasesAsync, - highLevelClient().indices()::updateAliases, highLevelClient().indices()::updateAliasesAsync)); + () -> execute(mixedRequest, highLevelClient().indices()::updateAliases, highLevelClient().indices()::updateAliasesAsync)); assertThat(exception.status(), equalTo(RestStatus.NOT_FOUND)); assertThat(exception.getMessage(), equalTo("Elasticsearch exception [type=index_not_found_exception, reason=no such index]")); assertThat(exception.getMetadata("es.index"), hasItem(nonExistentIndex)); @@ -498,7 +481,6 @@ public void testAliasesNonExistentIndex() throws IOException { removeIndexRequest.addAliasAction(new AliasActions(AliasActions.Type.ADD).index(nonExistentIndex).alias(alias)); removeIndexRequest.addAliasAction(new AliasActions(AliasActions.Type.REMOVE_INDEX).indices(nonExistentIndex)); exception = expectThrows(ElasticsearchException.class, () -> execute(removeIndexRequest, highLevelClient().indices()::updateAliases, - highLevelClient().indices()::updateAliasesAsync, highLevelClient().indices()::updateAliases, highLevelClient().indices()::updateAliasesAsync)); assertThat(exception.status(), equalTo(RestStatus.NOT_FOUND)); assertThat(exception.getMessage(), equalTo("Elasticsearch exception [type=index_not_found_exception, reason=no such index]")); @@ -519,7 +501,6 @@ public void testOpenExistingIndex() throws IOException { OpenIndexRequest openIndexRequest = new OpenIndexRequest(index); OpenIndexResponse openIndexResponse = execute(openIndexRequest, highLevelClient().indices()::open, - highLevelClient().indices()::openAsync, highLevelClient().indices()::open, highLevelClient().indices()::openAsync); assertTrue(openIndexResponse.isAcknowledged()); @@ -533,22 +514,19 @@ public void testOpenNonExistentIndex() throws IOException { OpenIndexRequest openIndexRequest = new OpenIndexRequest(nonExistentIndex); ElasticsearchException exception = expectThrows(ElasticsearchException.class, - () -> execute(openIndexRequest, highLevelClient().indices()::open, highLevelClient().indices()::openAsync, - highLevelClient().indices()::open, highLevelClient().indices()::openAsync)); + () -> execute(openIndexRequest, highLevelClient().indices()::open, highLevelClient().indices()::openAsync)); assertEquals(RestStatus.NOT_FOUND, exception.status()); OpenIndexRequest lenientOpenIndexRequest = new OpenIndexRequest(nonExistentIndex); lenientOpenIndexRequest.indicesOptions(IndicesOptions.lenientExpandOpen()); OpenIndexResponse lenientOpenIndexResponse = execute(lenientOpenIndexRequest, highLevelClient().indices()::open, - highLevelClient().indices()::openAsync, highLevelClient().indices()::open, highLevelClient().indices()::openAsync); assertThat(lenientOpenIndexResponse.isAcknowledged(), equalTo(true)); OpenIndexRequest strictOpenIndexRequest = new OpenIndexRequest(nonExistentIndex); strictOpenIndexRequest.indicesOptions(IndicesOptions.strictExpandOpen()); ElasticsearchException strictException = expectThrows(ElasticsearchException.class, - () -> execute(openIndexRequest, highLevelClient().indices()::open, highLevelClient().indices()::openAsync, - highLevelClient().indices()::open, highLevelClient().indices()::openAsync)); + () -> execute(openIndexRequest, highLevelClient().indices()::open, highLevelClient().indices()::openAsync)); assertEquals(RestStatus.NOT_FOUND, strictException.status()); } @@ -560,7 +538,6 @@ public void testCloseExistingIndex() throws IOException { CloseIndexRequest closeIndexRequest = new CloseIndexRequest(index); CloseIndexResponse closeIndexResponse = execute(closeIndexRequest, highLevelClient().indices()::close, - highLevelClient().indices()::closeAsync, highLevelClient().indices()::close, highLevelClient().indices()::closeAsync); assertTrue(closeIndexResponse.isAcknowledged()); @@ -576,8 +553,7 @@ public void testCloseNonExistentIndex() throws IOException { CloseIndexRequest closeIndexRequest = new CloseIndexRequest(nonExistentIndex); ElasticsearchException exception = expectThrows(ElasticsearchException.class, - () -> execute(closeIndexRequest, highLevelClient().indices()::close, highLevelClient().indices()::closeAsync, - highLevelClient().indices()::close, highLevelClient().indices()::closeAsync)); + () -> execute(closeIndexRequest, highLevelClient().indices()::close, highLevelClient().indices()::closeAsync)); assertEquals(RestStatus.NOT_FOUND, exception.status()); } @@ -591,8 +567,7 @@ public void testRefresh() throws IOException { createIndex(index, settings); RefreshRequest refreshRequest = new RefreshRequest(index); RefreshResponse refreshResponse = - execute(refreshRequest, highLevelClient().indices()::refresh, highLevelClient().indices()::refreshAsync, - highLevelClient().indices()::refresh, highLevelClient().indices()::refreshAsync); + execute(refreshRequest, highLevelClient().indices()::refresh, highLevelClient().indices()::refreshAsync); assertThat(refreshResponse.getTotalShards(), equalTo(1)); assertThat(refreshResponse.getSuccessfulShards(), equalTo(1)); assertThat(refreshResponse.getFailedShards(), equalTo(0)); @@ -603,8 +578,7 @@ public void testRefresh() throws IOException { assertFalse(indexExists(nonExistentIndex)); RefreshRequest refreshRequest = new RefreshRequest(nonExistentIndex); ElasticsearchException exception = expectThrows(ElasticsearchException.class, - () -> execute(refreshRequest, highLevelClient().indices()::refresh, highLevelClient().indices()::refreshAsync, - highLevelClient().indices()::refresh, highLevelClient().indices()::refreshAsync)); + () -> execute(refreshRequest, highLevelClient().indices()::refresh, highLevelClient().indices()::refreshAsync)); assertEquals(RestStatus.NOT_FOUND, exception.status()); } } @@ -619,8 +593,7 @@ public void testFlush() throws IOException { createIndex(index, settings); FlushRequest flushRequest = new FlushRequest(index); FlushResponse flushResponse = - execute(flushRequest, highLevelClient().indices()::flush, highLevelClient().indices()::flushAsync, - highLevelClient().indices()::flush, highLevelClient().indices()::flushAsync); + execute(flushRequest, highLevelClient().indices()::flush, highLevelClient().indices()::flushAsync); assertThat(flushResponse.getTotalShards(), equalTo(1)); assertThat(flushResponse.getSuccessfulShards(), equalTo(1)); assertThat(flushResponse.getFailedShards(), equalTo(0)); @@ -631,8 +604,7 @@ public void testFlush() throws IOException { assertFalse(indexExists(nonExistentIndex)); FlushRequest flushRequest = new FlushRequest(nonExistentIndex); ElasticsearchException exception = expectThrows(ElasticsearchException.class, - () -> execute(flushRequest, highLevelClient().indices()::flush, highLevelClient().indices()::flushAsync, - highLevelClient().indices()::flush, highLevelClient().indices()::flushAsync)); + () -> execute(flushRequest, highLevelClient().indices()::flush, highLevelClient().indices()::flushAsync)); assertEquals(RestStatus.NOT_FOUND, exception.status()); } } @@ -680,8 +652,7 @@ public void testClearCache() throws IOException { createIndex(index, settings); ClearIndicesCacheRequest clearCacheRequest = new ClearIndicesCacheRequest(index); ClearIndicesCacheResponse clearCacheResponse = - execute(clearCacheRequest, highLevelClient().indices()::clearCache, highLevelClient().indices()::clearCacheAsync, - highLevelClient().indices()::clearCache, highLevelClient().indices()::clearCacheAsync); + execute(clearCacheRequest, highLevelClient().indices()::clearCache, highLevelClient().indices()::clearCacheAsync); assertThat(clearCacheResponse.getTotalShards(), equalTo(1)); assertThat(clearCacheResponse.getSuccessfulShards(), equalTo(1)); assertThat(clearCacheResponse.getFailedShards(), equalTo(0)); @@ -692,8 +663,8 @@ public void testClearCache() throws IOException { assertFalse(indexExists(nonExistentIndex)); ClearIndicesCacheRequest clearCacheRequest = new ClearIndicesCacheRequest(nonExistentIndex); ElasticsearchException exception = expectThrows(ElasticsearchException.class, - () -> execute(clearCacheRequest, highLevelClient().indices()::clearCache, highLevelClient().indices()::clearCacheAsync, - highLevelClient().indices()::clearCache, highLevelClient().indices()::clearCacheAsync)); + () -> execute(clearCacheRequest, highLevelClient().indices()::clearCache, + highLevelClient().indices()::clearCacheAsync)); assertEquals(RestStatus.NOT_FOUND, exception.status()); } } @@ -708,8 +679,7 @@ public void testForceMerge() throws IOException { createIndex(index, settings); ForceMergeRequest forceMergeRequest = new ForceMergeRequest(index); ForceMergeResponse forceMergeResponse = - execute(forceMergeRequest, highLevelClient().indices()::forceMerge, highLevelClient().indices()::forceMergeAsync, - highLevelClient().indices()::forceMerge, highLevelClient().indices()::forceMergeAsync); + execute(forceMergeRequest, highLevelClient().indices()::forceMerge, highLevelClient().indices()::forceMergeAsync); assertThat(forceMergeResponse.getTotalShards(), equalTo(1)); assertThat(forceMergeResponse.getSuccessfulShards(), equalTo(1)); assertThat(forceMergeResponse.getFailedShards(), equalTo(0)); @@ -720,30 +690,25 @@ public void testForceMerge() throws IOException { assertFalse(indexExists(nonExistentIndex)); ForceMergeRequest forceMergeRequest = new ForceMergeRequest(nonExistentIndex); ElasticsearchException exception = expectThrows(ElasticsearchException.class, - () -> execute(forceMergeRequest, highLevelClient().indices()::forceMerge, highLevelClient().indices()::forceMergeAsync, - highLevelClient().indices()::forceMerge, highLevelClient().indices()::forceMergeAsync)); + () -> execute(forceMergeRequest, highLevelClient().indices()::forceMerge, highLevelClient().indices()::forceMergeAsync)); assertEquals(RestStatus.NOT_FOUND, exception.status()); } } public void testExistsAlias() throws IOException { GetAliasesRequest getAliasesRequest = new GetAliasesRequest("alias"); - assertFalse(execute(getAliasesRequest, highLevelClient().indices()::existsAlias, highLevelClient().indices()::existsAliasAsync, - highLevelClient().indices()::existsAlias, highLevelClient().indices()::existsAliasAsync)); + assertFalse(execute(getAliasesRequest, highLevelClient().indices()::existsAlias, highLevelClient().indices()::existsAliasAsync)); createIndex("index", Settings.EMPTY); client().performRequest(HttpPut.METHOD_NAME, "/index/_alias/alias"); - assertTrue(execute(getAliasesRequest, highLevelClient().indices()::existsAlias, highLevelClient().indices()::existsAliasAsync, - highLevelClient().indices()::existsAlias, highLevelClient().indices()::existsAliasAsync)); + assertTrue(execute(getAliasesRequest, highLevelClient().indices()::existsAlias, highLevelClient().indices()::existsAliasAsync)); GetAliasesRequest getAliasesRequest2 = new GetAliasesRequest(); getAliasesRequest2.aliases("alias"); getAliasesRequest2.indices("index"); - assertTrue(execute(getAliasesRequest2, highLevelClient().indices()::existsAlias, highLevelClient().indices()::existsAliasAsync, - highLevelClient().indices()::existsAlias, highLevelClient().indices()::existsAliasAsync)); + assertTrue(execute(getAliasesRequest2, highLevelClient().indices()::existsAlias, highLevelClient().indices()::existsAliasAsync)); getAliasesRequest2.indices("does_not_exist"); - assertFalse(execute(getAliasesRequest2, highLevelClient().indices()::existsAlias, highLevelClient().indices()::existsAliasAsync, - highLevelClient().indices()::existsAlias, highLevelClient().indices()::existsAliasAsync)); + assertFalse(execute(getAliasesRequest2, highLevelClient().indices()::existsAlias, highLevelClient().indices()::existsAliasAsync)); } @SuppressWarnings("unchecked") @@ -764,7 +729,7 @@ public void testShrink() throws IOException { .build(); resizeRequest.setTargetIndex(new CreateIndexRequest("target").settings(targetSettings).alias(new Alias("alias"))); ResizeResponse resizeResponse = execute(resizeRequest, highLevelClient().indices()::shrink, - highLevelClient().indices()::shrinkAsync, highLevelClient().indices()::shrink, highLevelClient().indices()::shrinkAsync); + highLevelClient().indices()::shrinkAsync); assertTrue(resizeResponse.isAcknowledged()); assertTrue(resizeResponse.isShardsAcknowledged()); Map getIndexResponse = getAsMap("target"); @@ -786,8 +751,7 @@ public void testSplit() throws IOException { resizeRequest.setResizeType(ResizeType.SPLIT); Settings targetSettings = Settings.builder().put("index.number_of_shards", 4).put("index.number_of_replicas", 0).build(); resizeRequest.setTargetIndex(new CreateIndexRequest("target").settings(targetSettings).alias(new Alias("alias"))); - ResizeResponse resizeResponse = execute(resizeRequest, highLevelClient().indices()::split, highLevelClient().indices()::splitAsync, - highLevelClient().indices()::split, highLevelClient().indices()::splitAsync); + ResizeResponse resizeResponse = execute(resizeRequest, highLevelClient().indices()::split, highLevelClient().indices()::splitAsync); assertTrue(resizeResponse.isAcknowledged()); assertTrue(resizeResponse.isShardsAcknowledged()); Map getIndexResponse = getAsMap("target"); @@ -806,7 +770,6 @@ public void testRollover() throws IOException { { RolloverResponse rolloverResponse = execute(rolloverRequest, highLevelClient().indices()::rollover, - highLevelClient().indices()::rolloverAsync, highLevelClient().indices()::rollover, highLevelClient().indices()::rolloverAsync); assertFalse(rolloverResponse.isRolledOver()); assertFalse(rolloverResponse.isDryRun()); @@ -826,7 +789,6 @@ public void testRollover() throws IOException { rolloverRequest.addMaxIndexAgeCondition(new TimeValue(1)); rolloverRequest.dryRun(true); RolloverResponse rolloverResponse = execute(rolloverRequest, highLevelClient().indices()::rollover, - highLevelClient().indices()::rolloverAsync, highLevelClient().indices()::rollover, highLevelClient().indices()::rolloverAsync); assertFalse(rolloverResponse.isRolledOver()); assertTrue(rolloverResponse.isDryRun()); @@ -841,7 +803,6 @@ public void testRollover() throws IOException { rolloverRequest.dryRun(false); rolloverRequest.addMaxIndexSizeCondition(new ByteSizeValue(1, ByteSizeUnit.MB)); RolloverResponse rolloverResponse = execute(rolloverRequest, highLevelClient().indices()::rollover, - highLevelClient().indices()::rolloverAsync, highLevelClient().indices()::rollover, highLevelClient().indices()::rolloverAsync); assertTrue(rolloverResponse.isRolledOver()); assertFalse(rolloverResponse.isDryRun()); @@ -1067,7 +1028,6 @@ public void testIndexPutSettings() throws IOException { UpdateSettingsRequest dynamicSettingRequest = new UpdateSettingsRequest(); dynamicSettingRequest.settings(Settings.builder().put(dynamicSettingKey, dynamicSettingValue).build()); UpdateSettingsResponse response = execute(dynamicSettingRequest, highLevelClient().indices()::putSettings, - highLevelClient().indices()::putSettingsAsync, highLevelClient().indices()::putSettings, highLevelClient().indices()::putSettingsAsync); assertTrue(response.isAcknowledged()); @@ -1078,7 +1038,6 @@ public void testIndexPutSettings() throws IOException { UpdateSettingsRequest staticSettingRequest = new UpdateSettingsRequest(); staticSettingRequest.settings(Settings.builder().put(staticSettingKey, staticSettingValue).build()); ElasticsearchException exception = expectThrows(ElasticsearchException.class, () -> execute(staticSettingRequest, - highLevelClient().indices()::putSettings, highLevelClient().indices()::putSettingsAsync, highLevelClient().indices()::putSettings, highLevelClient().indices()::putSettingsAsync)); assertThat(exception.getMessage(), startsWith("Elasticsearch exception [type=illegal_argument_exception, " @@ -1089,7 +1048,6 @@ public void testIndexPutSettings() throws IOException { closeIndex(index); response = execute(staticSettingRequest, highLevelClient().indices()::putSettings, - highLevelClient().indices()::putSettingsAsync, highLevelClient().indices()::putSettings, highLevelClient().indices()::putSettingsAsync); assertTrue(response.isAcknowledged()); openIndex(index); @@ -1100,7 +1058,6 @@ public void testIndexPutSettings() throws IOException { UpdateSettingsRequest unmodifiableSettingRequest = new UpdateSettingsRequest(); unmodifiableSettingRequest.settings(Settings.builder().put(unmodifiableSettingKey, unmodifiableSettingValue).build()); exception = expectThrows(ElasticsearchException.class, () -> execute(unmodifiableSettingRequest, - highLevelClient().indices()::putSettings, highLevelClient().indices()::putSettingsAsync, highLevelClient().indices()::putSettings, highLevelClient().indices()::putSettingsAsync)); assertThat(exception.getMessage(), startsWith( "Elasticsearch exception [type=illegal_argument_exception, " @@ -1128,14 +1085,12 @@ public void testIndexPutSettingNonExistent() throws IOException { indexUpdateSettingsRequest.settings(Settings.builder().put(setting, value).build()); ElasticsearchException exception = expectThrows(ElasticsearchException.class, () -> execute(indexUpdateSettingsRequest, - highLevelClient().indices()::putSettings, highLevelClient().indices()::putSettingsAsync, highLevelClient().indices()::putSettings, highLevelClient().indices()::putSettingsAsync)); assertEquals(RestStatus.NOT_FOUND, exception.status()); assertThat(exception.getMessage(), equalTo("Elasticsearch exception [type=index_not_found_exception, reason=no such index]")); createIndex(index, Settings.EMPTY); exception = expectThrows(ElasticsearchException.class, () -> execute(indexUpdateSettingsRequest, - highLevelClient().indices()::putSettings, highLevelClient().indices()::putSettingsAsync, highLevelClient().indices()::putSettings, highLevelClient().indices()::putSettingsAsync)); assertThat(exception.status(), equalTo(RestStatus.BAD_REQUEST)); assertThat(exception.getMessage(), equalTo( diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/RankEvalIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/RankEvalIT.java index 1e12f3f5e62f6..a7a452484e023 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/RankEvalIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/RankEvalIT.java @@ -82,8 +82,7 @@ public void testRankEvalRequest() throws IOException { RankEvalSpec spec = new RankEvalSpec(specifications, metric); RankEvalRequest rankEvalRequest = new RankEvalRequest(spec, new String[] { "index", "index2" }); - RankEvalResponse response = execute(rankEvalRequest, highLevelClient()::rankEval, highLevelClient()::rankEvalAsync, - highLevelClient()::rankEval, highLevelClient()::rankEvalAsync); + RankEvalResponse response = execute(rankEvalRequest, highLevelClient()::rankEval, highLevelClient()::rankEvalAsync); // the expected Prec@ for the first query is 5/7 and the expected Prec@ for the second is 1/7, divided by 2 to get the average double expectedPrecision = (1.0 / 7.0 + 5.0 / 7.0) / 2.0; assertEquals(expectedPrecision, response.getEvaluationResult(), Double.MIN_VALUE); @@ -117,8 +116,7 @@ public void testRankEvalRequest() throws IOException { // now try this when test2 is closed client().performRequest("POST", "index2/_close", Collections.emptyMap()); rankEvalRequest.indicesOptions(IndicesOptions.fromParameters(null, "true", null, SearchRequest.DEFAULT_INDICES_OPTIONS)); - response = execute(rankEvalRequest, highLevelClient()::rankEval, highLevelClient()::rankEvalAsync, - highLevelClient()::rankEval, highLevelClient()::rankEvalAsync); + response = execute(rankEvalRequest, highLevelClient()::rankEval, highLevelClient()::rankEvalAsync); } private static List createRelevant(String indexName, String... docs) { diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java index 9084a547c162d..49a84146dc8f4 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java @@ -188,12 +188,12 @@ public ActionRequestValidationException validate() { { ActionRequestValidationException actualException = expectThrows(ActionRequestValidationException.class, - () -> restHighLevelClient.performRequest(request, null, null, null)); + () -> restHighLevelClient.performRequest(request, null, RequestOptions.DEFAULT, null, null)); assertSame(validationException, actualException); } { TrackingActionListener trackingActionListener = new TrackingActionListener(); - restHighLevelClient.performRequestAsync(request, null, null, trackingActionListener, null); + restHighLevelClient.performRequestAsync(request, null, RequestOptions.DEFAULT, null, trackingActionListener, null); assertSame(validationException, trackingActionListener.exception.get()); } } @@ -307,13 +307,13 @@ public void testPerformRequestOnSuccess() throws IOException { Response mockResponse = new Response(REQUEST_LINE, new HttpHost("localhost", 9200), httpResponse); when(restClient.performRequest(any(Request.class))).thenReturn(mockResponse); { - Integer result = restHighLevelClient.performRequest(mainRequest, requestConverter, + Integer result = restHighLevelClient.performRequest(mainRequest, requestConverter, RequestOptions.DEFAULT, response -> response.getStatusLine().getStatusCode(), Collections.emptySet()); assertEquals(restStatus.getStatus(), result.intValue()); } { IOException ioe = expectThrows(IOException.class, () -> restHighLevelClient.performRequest(mainRequest, - requestConverter, response -> {throw new IllegalStateException();}, Collections.emptySet())); + requestConverter, RequestOptions.DEFAULT, response -> {throw new IllegalStateException();}, Collections.emptySet())); assertEquals("Unable to parse response body for Response{requestLine=GET / http/1.1, host=http://localhost:9200, " + "response=http/1.1 " + restStatus.getStatus() + " " + restStatus.name() + "}", ioe.getMessage()); } @@ -328,7 +328,7 @@ public void testPerformRequestOnResponseExceptionWithoutEntity() throws IOExcept ResponseException responseException = new ResponseException(mockResponse); when(restClient.performRequest(any(Request.class))).thenThrow(responseException); ElasticsearchException elasticsearchException = expectThrows(ElasticsearchException.class, - () -> restHighLevelClient.performRequest(mainRequest, requestConverter, + () -> restHighLevelClient.performRequest(mainRequest, requestConverter, RequestOptions.DEFAULT, response -> response.getStatusLine().getStatusCode(), Collections.emptySet())); assertEquals(responseException.getMessage(), elasticsearchException.getMessage()); assertEquals(restStatus, elasticsearchException.status()); @@ -346,7 +346,7 @@ public void testPerformRequestOnResponseExceptionWithEntity() throws IOException ResponseException responseException = new ResponseException(mockResponse); when(restClient.performRequest(any(Request.class))).thenThrow(responseException); ElasticsearchException elasticsearchException = expectThrows(ElasticsearchException.class, - () -> restHighLevelClient.performRequest(mainRequest, requestConverter, + () -> restHighLevelClient.performRequest(mainRequest, requestConverter, RequestOptions.DEFAULT, response -> response.getStatusLine().getStatusCode(), Collections.emptySet())); assertEquals("Elasticsearch exception [type=exception, reason=test error message]", elasticsearchException.getMessage()); assertEquals(restStatus, elasticsearchException.status()); @@ -363,7 +363,7 @@ public void testPerformRequestOnResponseExceptionWithBrokenEntity() throws IOExc ResponseException responseException = new ResponseException(mockResponse); when(restClient.performRequest(any(Request.class))).thenThrow(responseException); ElasticsearchException elasticsearchException = expectThrows(ElasticsearchException.class, - () -> restHighLevelClient.performRequest(mainRequest, requestConverter, + () -> restHighLevelClient.performRequest(mainRequest, requestConverter, RequestOptions.DEFAULT, response -> response.getStatusLine().getStatusCode(), Collections.emptySet())); assertEquals("Unable to parse response body", elasticsearchException.getMessage()); assertEquals(restStatus, elasticsearchException.status()); @@ -381,7 +381,7 @@ public void testPerformRequestOnResponseExceptionWithBrokenEntity2() throws IOEx ResponseException responseException = new ResponseException(mockResponse); when(restClient.performRequest(any(Request.class))).thenThrow(responseException); ElasticsearchException elasticsearchException = expectThrows(ElasticsearchException.class, - () -> restHighLevelClient.performRequest(mainRequest, requestConverter, + () -> restHighLevelClient.performRequest(mainRequest, requestConverter, RequestOptions.DEFAULT, response -> response.getStatusLine().getStatusCode(), Collections.emptySet())); assertEquals("Unable to parse response body", elasticsearchException.getMessage()); assertEquals(restStatus, elasticsearchException.status()); @@ -397,7 +397,7 @@ public void testPerformRequestOnResponseExceptionWithIgnores() throws IOExceptio ResponseException responseException = new ResponseException(mockResponse); when(restClient.performRequest(any(Request.class))).thenThrow(responseException); //although we got an exception, we turn it into a successful response because the status code was provided among ignores - assertEquals(Integer.valueOf(404), restHighLevelClient.performRequest(mainRequest, requestConverter, + assertEquals(Integer.valueOf(404), restHighLevelClient.performRequest(mainRequest, requestConverter, RequestOptions.DEFAULT, response -> response.getStatusLine().getStatusCode(), Collections.singleton(404))); } @@ -409,7 +409,7 @@ public void testPerformRequestOnResponseExceptionWithIgnoresErrorNoBody() throws ResponseException responseException = new ResponseException(mockResponse); when(restClient.performRequest(any(Request.class))).thenThrow(responseException); ElasticsearchException elasticsearchException = expectThrows(ElasticsearchException.class, - () -> restHighLevelClient.performRequest(mainRequest, requestConverter, + () -> restHighLevelClient.performRequest(mainRequest, requestConverter, RequestOptions.DEFAULT, response -> {throw new IllegalStateException();}, Collections.singleton(404))); assertEquals(RestStatus.NOT_FOUND, elasticsearchException.status()); assertSame(responseException, elasticsearchException.getCause()); @@ -426,7 +426,7 @@ public void testPerformRequestOnResponseExceptionWithIgnoresErrorValidBody() thr ResponseException responseException = new ResponseException(mockResponse); when(restClient.performRequest(any(Request.class))).thenThrow(responseException); ElasticsearchException elasticsearchException = expectThrows(ElasticsearchException.class, - () -> restHighLevelClient.performRequest(mainRequest, requestConverter, + () -> restHighLevelClient.performRequest(mainRequest, requestConverter, RequestOptions.DEFAULT, response -> {throw new IllegalStateException();}, Collections.singleton(404))); assertEquals(RestStatus.NOT_FOUND, elasticsearchException.status()); assertSame(responseException, elasticsearchException.getSuppressed()[0]); diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/SearchIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/SearchIT.java index 80d09acf2817d..a87aec7c2cf87 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/SearchIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/SearchIT.java @@ -164,8 +164,7 @@ public void testSearchNoQuery() throws IOException { public void testSearchMatchQuery() throws IOException { SearchRequest searchRequest = new SearchRequest("index"); searchRequest.source(new SearchSourceBuilder().query(new MatchQueryBuilder("num", 10))); - SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync, - highLevelClient()::search, highLevelClient()::searchAsync); + SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync); assertSearchHeader(searchResponse); assertNull(searchResponse.getAggregations()); assertNull(searchResponse.getSuggest()); @@ -191,8 +190,7 @@ public void testSearchWithTermsAgg() throws IOException { searchSourceBuilder.aggregation(new TermsAggregationBuilder("agg1", ValueType.STRING).field("type.keyword")); searchSourceBuilder.size(0); searchRequest.source(searchSourceBuilder); - SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync, - highLevelClient()::search, highLevelClient()::searchAsync); + SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync); assertSearchHeader(searchResponse); assertNull(searchResponse.getSuggest()); assertEquals(Collections.emptyMap(), searchResponse.getProfileResults()); @@ -218,8 +216,7 @@ public void testSearchWithRangeAgg() throws IOException { searchRequest.source(searchSourceBuilder); ElasticsearchStatusException exception = expectThrows(ElasticsearchStatusException.class, - () -> execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync, - highLevelClient()::search, highLevelClient()::searchAsync)); + () -> execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync)); assertEquals(RestStatus.BAD_REQUEST, exception.status()); } @@ -229,8 +226,7 @@ public void testSearchWithRangeAgg() throws IOException { .addRange("first", 0, 30).addRange("second", 31, 200)); searchSourceBuilder.size(0); searchRequest.source(searchSourceBuilder); - SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync, - highLevelClient()::search, highLevelClient()::searchAsync); + SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync); assertSearchHeader(searchResponse); assertNull(searchResponse.getSuggest()); assertEquals(Collections.emptyMap(), searchResponse.getProfileResults()); @@ -261,8 +257,7 @@ public void testSearchWithTermsAndRangeAgg() throws IOException { searchSourceBuilder.aggregation(agg); searchSourceBuilder.size(0); searchRequest.source(searchSourceBuilder); - SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync, - highLevelClient()::search, highLevelClient()::searchAsync); + SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync); assertSearchHeader(searchResponse); assertNull(searchResponse.getSuggest()); assertEquals(Collections.emptyMap(), searchResponse.getProfileResults()); @@ -313,8 +308,7 @@ public void testSearchWithMatrixStats() throws IOException { searchSourceBuilder.aggregation(new MatrixStatsAggregationBuilder("agg1").fields(Arrays.asList("num", "num2"))); searchSourceBuilder.size(0); searchRequest.source(searchSourceBuilder); - SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync, - highLevelClient()::search, highLevelClient()::searchAsync); + SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync); assertSearchHeader(searchResponse); assertNull(searchResponse.getSuggest()); assertEquals(Collections.emptyMap(), searchResponse.getProfileResults()); @@ -403,8 +397,7 @@ public void testSearchWithParentJoin() throws IOException { SearchRequest searchRequest = new SearchRequest(indexName); searchRequest.source(searchSourceBuilder); - SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync, - highLevelClient()::search, highLevelClient()::searchAsync); + SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync); assertSearchHeader(searchResponse); assertNull(searchResponse.getSuggest()); assertEquals(Collections.emptyMap(), searchResponse.getProfileResults()); @@ -444,8 +437,7 @@ public void testSearchWithSuggest() throws IOException { searchSourceBuilder.size(0); searchRequest.source(searchSourceBuilder); - SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync, - highLevelClient()::search, highLevelClient()::searchAsync); + SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync); assertSearchHeader(searchResponse); assertNull(searchResponse.getAggregations()); assertEquals(Collections.emptyMap(), searchResponse.getProfileResults()); @@ -477,8 +469,7 @@ public void testSearchWithWeirdScriptFields() throws Exception { { SearchRequest searchRequest = new SearchRequest("test").source(SearchSourceBuilder.searchSource() .scriptField("result", new Script("null"))); - SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync, - highLevelClient()::search, highLevelClient()::searchAsync); + SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync); SearchHit searchHit = searchResponse.getHits().getAt(0); List values = searchHit.getFields().get("result").getValues(); assertNotNull(values); @@ -488,8 +479,7 @@ public void testSearchWithWeirdScriptFields() throws Exception { { SearchRequest searchRequest = new SearchRequest("test").source(SearchSourceBuilder.searchSource() .scriptField("result", new Script("new HashMap()"))); - SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync, - highLevelClient()::search, highLevelClient()::searchAsync); + SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync); SearchHit searchHit = searchResponse.getHits().getAt(0); List values = searchHit.getFields().get("result").getValues(); assertNotNull(values); @@ -501,8 +491,7 @@ public void testSearchWithWeirdScriptFields() throws Exception { { SearchRequest searchRequest = new SearchRequest("test").source(SearchSourceBuilder.searchSource() .scriptField("result", new Script("new String[]{}"))); - SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync, - highLevelClient()::search, highLevelClient()::searchAsync); + SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync); SearchHit searchHit = searchResponse.getHits().getAt(0); List values = searchHit.getFields().get("result").getValues(); assertNotNull(values); @@ -524,8 +513,7 @@ public void testSearchScroll() throws Exception { SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().size(35).sort("field", SortOrder.ASC); SearchRequest searchRequest = new SearchRequest("test").scroll(TimeValue.timeValueMinutes(2)).source(searchSourceBuilder); - SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync, - highLevelClient()::search, highLevelClient()::searchAsync); + SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync); try { long counter = 0; @@ -537,7 +525,6 @@ public void testSearchScroll() throws Exception { } searchResponse = execute(new SearchScrollRequest(searchResponse.getScrollId()).scroll(TimeValue.timeValueMinutes(2)), - highLevelClient()::searchScroll, highLevelClient()::searchScrollAsync, highLevelClient()::searchScroll, highLevelClient()::searchScrollAsync); assertThat(searchResponse.getHits().getTotalHits(), equalTo(100L)); @@ -547,7 +534,6 @@ public void testSearchScroll() throws Exception { } searchResponse = execute(new SearchScrollRequest(searchResponse.getScrollId()).scroll(TimeValue.timeValueMinutes(2)), - highLevelClient()::searchScroll, highLevelClient()::searchScrollAsync, highLevelClient()::searchScroll, highLevelClient()::searchScrollAsync); assertThat(searchResponse.getHits().getTotalHits(), equalTo(100L)); @@ -559,14 +545,12 @@ public void testSearchScroll() throws Exception { ClearScrollRequest clearScrollRequest = new ClearScrollRequest(); clearScrollRequest.addScrollId(searchResponse.getScrollId()); ClearScrollResponse clearScrollResponse = execute(clearScrollRequest, - highLevelClient()::clearScroll, highLevelClient()::clearScrollAsync, highLevelClient()::clearScroll, highLevelClient()::clearScrollAsync); assertThat(clearScrollResponse.getNumFreed(), greaterThan(0)); assertTrue(clearScrollResponse.isSucceeded()); SearchScrollRequest scrollRequest = new SearchScrollRequest(searchResponse.getScrollId()).scroll(TimeValue.timeValueMinutes(2)); ElasticsearchStatusException exception = expectThrows(ElasticsearchStatusException.class, () -> execute(scrollRequest, - highLevelClient()::searchScroll, highLevelClient()::searchScrollAsync, highLevelClient()::searchScroll, highLevelClient()::searchScrollAsync)); assertEquals(RestStatus.NOT_FOUND, exception.status()); assertThat(exception.getRootCause(), instanceOf(ElasticsearchException.class)); @@ -588,8 +572,7 @@ public void testMultiSearch() throws Exception { multiSearchRequest.add(searchRequest3); MultiSearchResponse multiSearchResponse = - execute(multiSearchRequest, highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync, - highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync); + execute(multiSearchRequest, highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync); assertThat(multiSearchResponse.getTook().millis(), Matchers.greaterThanOrEqualTo(0L)); assertThat(multiSearchResponse.getResponses().length, Matchers.equalTo(3)); @@ -631,8 +614,7 @@ public void testMultiSearch_withAgg() throws Exception { multiSearchRequest.add(searchRequest3); MultiSearchResponse multiSearchResponse = - execute(multiSearchRequest, highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync, - highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync); + execute(multiSearchRequest, highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync); assertThat(multiSearchResponse.getTook().millis(), Matchers.greaterThanOrEqualTo(0L)); assertThat(multiSearchResponse.getResponses().length, Matchers.equalTo(3)); @@ -680,8 +662,7 @@ public void testMultiSearch_withQuery() throws Exception { multiSearchRequest.add(searchRequest3); MultiSearchResponse multiSearchResponse = - execute(multiSearchRequest, highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync, - highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync); + execute(multiSearchRequest, highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync); assertThat(multiSearchResponse.getTook().millis(), Matchers.greaterThanOrEqualTo(0L)); assertThat(multiSearchResponse.getResponses().length, Matchers.equalTo(3)); @@ -744,8 +725,7 @@ public void testMultiSearch_failure() throws Exception { multiSearchRequest.add(searchRequest2); MultiSearchResponse multiSearchResponse = - execute(multiSearchRequest, highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync, - highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync); + execute(multiSearchRequest, highLevelClient()::multiSearch, highLevelClient()::multiSearchAsync); assertThat(multiSearchResponse.getTook().millis(), Matchers.greaterThanOrEqualTo(0L)); assertThat(multiSearchResponse.getResponses().length, Matchers.equalTo(2)); diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/CRUDDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/CRUDDocumentationIT.java index ef92e28a07280..4193685f14bc2 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/CRUDDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/CRUDDocumentationIT.java @@ -746,7 +746,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::bulk-execute-async - client.bulkAsync(request, listener); // <1> + client.bulkAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::bulk-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -995,8 +995,9 @@ public void afterBulk(long executionId, BulkRequest request, Throwable failure) } }; - BulkProcessor bulkProcessor = - BulkProcessor.builder(client::bulkAsync, listener).build(); // <5> + BulkProcessor bulkProcessor = BulkProcessor.builder( + (request, bulkListener) -> client.bulkAsync(request, RequestOptions.DEFAULT, bulkListener), + listener).build(); // <5> // end::bulk-processor-init assertNotNull(bulkProcessor); @@ -1054,7 +1055,8 @@ public void afterBulk(long executionId, BulkRequest request, Throwable failure) // end::bulk-processor-listener // tag::bulk-processor-options - BulkProcessor.Builder builder = BulkProcessor.builder(client::bulkAsync, listener); + BulkProcessor.Builder builder = BulkProcessor.builder( + (request, bulkListener) -> client.bulkAsync(request, RequestOptions.DEFAULT, bulkListener), listener); builder.setBulkActions(500); // <1> builder.setBulkSize(new ByteSizeValue(1L, ByteSizeUnit.MB)); // <2> builder.setConcurrentRequests(0); // <3> @@ -1175,7 +1177,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::multi-get-execute-async - client.multiGetAsync(request, listener); // <1> + client.multiGetAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::multi-get-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java index fffba8e5f3f58..7bd6b16cecc99 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java @@ -576,7 +576,7 @@ public void testGetMapping() throws IOException { RestHighLevelClient client = highLevelClient(); { - CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("twitter")); + CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("twitter"), RequestOptions.DEFAULT); assertTrue(createIndexResponse.isAcknowledged()); PutMappingRequest request = new PutMappingRequest("twitter"); request.type("tweet"); @@ -589,7 +589,7 @@ public void testGetMapping() throws IOException { " }\n" + "}", // <1> XContentType.JSON); - PutMappingResponse putMappingResponse = client.indices().putMapping(request); + PutMappingResponse putMappingResponse = client.indices().putMapping(request, RequestOptions.DEFAULT); assertTrue(putMappingResponse.isAcknowledged()); } @@ -633,7 +633,7 @@ public void testGetMappingAsync() throws Exception { final RestHighLevelClient client = highLevelClient(); { - CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("twitter")); + CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("twitter"), RequestOptions.DEFAULT); assertTrue(createIndexResponse.isAcknowledged()); PutMappingRequest request = new PutMappingRequest("twitter"); request.type("tweet"); @@ -646,7 +646,7 @@ public void testGetMappingAsync() throws Exception { " }\n" + "}", // <1> XContentType.JSON); - PutMappingResponse putMappingResponse = client.indices().putMapping(request); + PutMappingResponse putMappingResponse = client.indices().putMapping(request, RequestOptions.DEFAULT); assertTrue(putMappingResponse.isAcknowledged()); } @@ -1733,7 +1733,8 @@ public void testGetAlias() throws Exception { RestHighLevelClient client = highLevelClient(); { - CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("index").alias(new Alias("alias"))); + CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("index").alias(new Alias("alias")), + RequestOptions.DEFAULT); assertTrue(createIndexResponse.isAcknowledged()); } diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SearchDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SearchDocumentationIT.java index cf6409bab6444..adc0fede1aa78 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SearchDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SearchDocumentationIT.java @@ -628,7 +628,7 @@ public void onFailure(Exception e) { scrollListener = new LatchedActionListener<>(scrollListener, latch); // tag::search-scroll-execute-async - client.searchScrollAsync(scrollRequest, scrollListener); // <1> + client.searchScrollAsync(scrollRequest, RequestOptions.DEFAULT, scrollListener); // <1> // end::search-scroll-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); diff --git a/docs/reference/migration/migrate_7_0.asciidoc b/docs/reference/migration/migrate_7_0.asciidoc index 6f008a275c737..c80b0ae64a371 100644 --- a/docs/reference/migration/migrate_7_0.asciidoc +++ b/docs/reference/migration/migrate_7_0.asciidoc @@ -36,6 +36,7 @@ Elasticsearch 6.x in order to be readable by Elasticsearch 7.x. * <> * <> * <> +* <> include::migrate_7_0/aggregations.asciidoc[] include::migrate_7_0/analysis.asciidoc[] @@ -49,4 +50,5 @@ include::migrate_7_0/api.asciidoc[] include::migrate_7_0/java.asciidoc[] include::migrate_7_0/settings.asciidoc[] include::migrate_7_0/scripting.asciidoc[] -include::migrate_7_0/snapshotstats.asciidoc[] \ No newline at end of file +include::migrate_7_0/snapshotstats.asciidoc[] +include::migrate_7_0/restclient.asciidoc[] \ No newline at end of file diff --git a/docs/reference/migration/migrate_7_0/restclient.asciidoc b/docs/reference/migration/migrate_7_0/restclient.asciidoc new file mode 100644 index 0000000000000..146b0d7338640 --- /dev/null +++ b/docs/reference/migration/migrate_7_0/restclient.asciidoc @@ -0,0 +1,13 @@ +[[breaking_70_restclient_changes]] +=== High-level REST client changes + +==== API methods accepting `Header` argument have been removed + +All API methods accepting headers as a `Header` varargs argument, deprecated +since 6.4, have been removed in favour of the newly introduced methods that +accept instead a `RequestOptions` argument. In case you are not specifying any +header, e.g. `client.index(indexRequest)` becomes +`client.index(indexRequest, RequestOptions.DEFAULT)`. +In case you are specifying headers +e.g. `client.index(indexRequest, new Header("name" "value"))` becomes +`client.index(indexRequest, RequestOptions.DEFAULT.toBuilder().addHeader("name", "value").build());` \ No newline at end of file