Merge branch 'master' into index-lifecycle
This commit is contained in:
commit
9fd4f3f854
|
@ -140,7 +140,7 @@ class PrecommitTasks {
|
|||
configProperties = [
|
||||
suppressions: checkstyleSuppressions
|
||||
]
|
||||
toolVersion = 7.5
|
||||
toolVersion = '8.10.1'
|
||||
}
|
||||
|
||||
project.tasks.withType(Checkstyle) { task ->
|
||||
|
|
|
@ -149,11 +149,11 @@ public class AntFixture extends AntTask implements Fixture {
|
|||
}
|
||||
|
||||
// the process is started (has a pid) and is bound to a network interface
|
||||
// so now wait undil the waitCondition has been met
|
||||
// so now evaluates if the waitCondition is successful
|
||||
// TODO: change this to a loop?
|
||||
boolean success
|
||||
try {
|
||||
success = waitCondition(this, ant) == false
|
||||
success = waitCondition(this, ant)
|
||||
} catch (Exception e) {
|
||||
String msg = "Wait condition caught exception for ${name}"
|
||||
logger.error(msg, e)
|
||||
|
|
|
@ -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 final class ClusterClient {
|
|||
options, ClusterUpdateSettingsResponse::fromXContent, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates cluster wide specific settings using the Cluster Update Settings API.
|
||||
* <p>
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-update-settings.html"> Cluster Update Settings
|
||||
* API on elastic.co</a>
|
||||
* @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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-update-settings.html"> Cluster Update Settings
|
||||
|
@ -86,19 +71,6 @@ public final class ClusterClient {
|
|||
restHighLevelClient.performRequestAsyncAndParseEntity(clusterUpdateSettingsRequest, RequestConverters::clusterPutSettings,
|
||||
options, ClusterUpdateSettingsResponse::fromXContent, listener, emptySet());
|
||||
}
|
||||
/**
|
||||
* Asynchronously updates cluster wide specific settings using the Cluster Update Settings API.
|
||||
* <p>
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-update-settings.html"> Cluster Update Settings
|
||||
* API on elastic.co</a>
|
||||
* @deprecated Prefer {@link #putSettingsAsync(ClusterUpdateSettingsRequest, RequestOptions, ActionListener)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void putSettingsAsync(ClusterUpdateSettingsRequest clusterUpdateSettingsRequest,
|
||||
ActionListener<ClusterUpdateSettingsResponse> listener, Header... headers) {
|
||||
restHighLevelClient.performRequestAsyncAndParseEntity(clusterUpdateSettingsRequest, RequestConverters::clusterPutSettings,
|
||||
ClusterUpdateSettingsResponse::fromXContent, listener, emptySet(), headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cluster health using the Cluster Health API.
|
||||
|
|
|
@ -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 final class IndicesClient {
|
|||
DeleteIndexResponse::fromXContent, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an index using the Delete Index API.
|
||||
* <p>
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-delete-index.html">
|
||||
* Delete Index API on elastic.co</a>
|
||||
* @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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-delete-index.html">
|
||||
|
@ -118,19 +104,6 @@ public final class IndicesClient {
|
|||
DeleteIndexResponse::fromXContent, listener, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously deletes an index using the Delete Index API.
|
||||
* <p>
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-delete-index.html">
|
||||
* Delete Index API on elastic.co</a>
|
||||
* @deprecated Prefer {@link #deleteAsync(DeleteIndexRequest, RequestOptions, ActionListener)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void deleteAsync(DeleteIndexRequest deleteIndexRequest, ActionListener<DeleteIndexResponse> listener, Header... headers) {
|
||||
restHighLevelClient.performRequestAsyncAndParseEntity(deleteIndexRequest, RequestConverters::deleteIndex,
|
||||
DeleteIndexResponse::fromXContent, listener, emptySet(), headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an index using the Create Index API.
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html">
|
||||
|
@ -145,19 +118,6 @@ public final class IndicesClient {
|
|||
CreateIndexResponse::fromXContent, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an index using the Create Index API.
|
||||
* <p>
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html">
|
||||
* Create Index API on elastic.co</a>
|
||||
* @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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html">
|
||||
|
@ -171,19 +131,6 @@ public final class IndicesClient {
|
|||
CreateIndexResponse::fromXContent, listener, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously creates an index using the Create Index API.
|
||||
* <p>
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html">
|
||||
* Create Index API on elastic.co</a>
|
||||
* @deprecated Prefer {@link #createAsync(CreateIndexRequest, RequestOptions, ActionListener)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void createAsync(CreateIndexRequest createIndexRequest, ActionListener<CreateIndexResponse> 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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html">
|
||||
|
@ -198,19 +145,6 @@ public final class IndicesClient {
|
|||
PutMappingResponse::fromXContent, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the mappings on an index using the Put Mapping API.
|
||||
* <p>
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html">
|
||||
* Put Mapping API on elastic.co</a>
|
||||
* @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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html">
|
||||
|
@ -224,20 +158,6 @@ public final class IndicesClient {
|
|||
PutMappingResponse::fromXContent, listener, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously updates the mappings on an index using the Put Mapping API.
|
||||
* <p>
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html">
|
||||
* Put Mapping API on elastic.co</a>
|
||||
* @deprecated Prefer {@link #putMappingAsync(PutMappingRequest, RequestOptions, ActionListener)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void putMappingAsync(PutMappingRequest putMappingRequest, ActionListener<PutMappingResponse> 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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-mapping.html">
|
||||
|
@ -280,20 +200,6 @@ public final class IndicesClient {
|
|||
IndicesAliasesResponse::fromXContent, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates aliases using the Index Aliases API.
|
||||
* <p>
|
||||
* See <a href=
|
||||
* "https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html">
|
||||
* Index Aliases API on elastic.co</a>
|
||||
* @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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html">
|
||||
|
@ -308,21 +214,6 @@ public final class IndicesClient {
|
|||
IndicesAliasesResponse::fromXContent, listener, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously updates aliases using the Index Aliases API.
|
||||
* <p>
|
||||
* See <a href=
|
||||
* "https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html">
|
||||
* Index Aliases API on elastic.co</a>
|
||||
* @deprecated Prefer {@link #updateAliasesAsync(IndicesAliasesRequest, RequestOptions, ActionListener)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void updateAliasesAsync(IndicesAliasesRequest indicesAliasesRequest, ActionListener<IndicesAliasesResponse> listener,
|
||||
Header... headers) {
|
||||
restHighLevelClient.performRequestAsyncAndParseEntity(indicesAliasesRequest, RequestConverters::updateAliases,
|
||||
IndicesAliasesResponse::fromXContent, listener, emptySet(), headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens an index using the Open Index API.
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-open-close.html">
|
||||
|
@ -337,19 +228,6 @@ public final class IndicesClient {
|
|||
OpenIndexResponse::fromXContent, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens an index using the Open Index API.
|
||||
* <p>
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-open-close.html">
|
||||
* Open Index API on elastic.co</a>
|
||||
* @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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-open-close.html">
|
||||
|
@ -363,19 +241,6 @@ public final class IndicesClient {
|
|||
OpenIndexResponse::fromXContent, listener, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously opens an index using the Open Index API.
|
||||
* <p>
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-open-close.html">
|
||||
* Open Index API on elastic.co</a>
|
||||
* @deprecated Prefer {@link #openAsync(OpenIndexRequest, RequestOptions, ActionListener)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void openAsync(OpenIndexRequest openIndexRequest, ActionListener<OpenIndexResponse> listener, Header... headers) {
|
||||
restHighLevelClient.performRequestAsyncAndParseEntity(openIndexRequest, RequestConverters::openIndex,
|
||||
OpenIndexResponse::fromXContent, listener, emptySet(), headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes an index using the Close Index API.
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-open-close.html">
|
||||
|
@ -390,19 +255,6 @@ public final class IndicesClient {
|
|||
CloseIndexResponse::fromXContent, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes an index using the Close Index API.
|
||||
* <p>
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-open-close.html">
|
||||
* Close Index API on elastic.co</a>
|
||||
* @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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-open-close.html">
|
||||
|
@ -417,19 +269,6 @@ public final class IndicesClient {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Asynchronously closes an index using the Close Index API.
|
||||
* <p>
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-open-close.html">
|
||||
* Close Index API on elastic.co</a>
|
||||
* @deprecated Prefer {@link #closeAsync(CloseIndexRequest, RequestOptions, ActionListener)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void closeAsync(CloseIndexRequest closeIndexRequest, ActionListener<CloseIndexResponse> 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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html">
|
||||
|
@ -444,19 +283,6 @@ public final class IndicesClient {
|
|||
RestHighLevelClient::convertExistsResponse, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if one or more aliases exist using the Aliases Exist API.
|
||||
* <p>
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html">
|
||||
* Indices Aliases API on elastic.co</a>
|
||||
* @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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html">
|
||||
|
@ -470,19 +296,6 @@ public final class IndicesClient {
|
|||
RestHighLevelClient::convertExistsResponse, listener, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously checks if one or more aliases exist using the Aliases Exist API.
|
||||
* <p>
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html">
|
||||
* Indices Aliases API on elastic.co</a>
|
||||
* @deprecated Prefer {@link #existsAliasAsync(GetAliasesRequest, RequestOptions, ActionListener)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void existsAliasAsync(GetAliasesRequest getAliasesRequest, ActionListener<Boolean> listener, Header... headers) {
|
||||
restHighLevelClient.performRequestAsync(getAliasesRequest, RequestConverters::existsAlias,
|
||||
RestHighLevelClient::convertExistsResponse, listener, emptySet(), headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh one or more indices using the Refresh API.
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-refresh.html"> Refresh API on elastic.co</a>
|
||||
|
@ -496,18 +309,6 @@ public final class IndicesClient {
|
|||
RefreshResponse::fromXContent, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh one or more indices using the Refresh API.
|
||||
* <p>
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-refresh.html"> Refresh API on elastic.co</a>
|
||||
* @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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-refresh.html"> Refresh API on elastic.co</a>
|
||||
|
@ -520,18 +321,6 @@ public final class IndicesClient {
|
|||
RefreshResponse::fromXContent, listener, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously refresh one or more indices using the Refresh API.
|
||||
* <p>
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-refresh.html"> Refresh API on elastic.co</a>
|
||||
* @deprecated Prefer {@link #refreshAsync(RefreshRequest, RequestOptions, ActionListener)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void refreshAsync(RefreshRequest refreshRequest, ActionListener<RefreshResponse> listener, Header... headers) {
|
||||
restHighLevelClient.performRequestAsyncAndParseEntity(refreshRequest, RequestConverters::refresh, RefreshResponse::fromXContent,
|
||||
listener, emptySet(), headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush one or more indices using the Flush API.
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-flush.html"> Flush API on elastic.co</a>
|
||||
|
@ -545,18 +334,6 @@ public final class IndicesClient {
|
|||
FlushResponse::fromXContent, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush one or more indices using the Flush API.
|
||||
* <p>
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-flush.html"> Flush API on elastic.co</a>
|
||||
* @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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-flush.html"> Flush API on elastic.co</a>
|
||||
|
@ -569,18 +346,6 @@ public final class IndicesClient {
|
|||
FlushResponse::fromXContent, listener, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously flush one or more indices using the Flush API.
|
||||
* <p>
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-flush.html"> Flush API on elastic.co</a>
|
||||
* @deprecated Prefer {@link #flushAsync(FlushRequest, RequestOptions, ActionListener)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void flushAsync(FlushRequest flushRequest, ActionListener<FlushResponse> listener, Header... headers) {
|
||||
restHighLevelClient.performRequestAsyncAndParseEntity(flushRequest, RequestConverters::flush, FlushResponse::fromXContent,
|
||||
listener, emptySet(), headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initiate a synced flush manually using the synced flush API.
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-synced-flush.html">
|
||||
|
@ -651,19 +416,6 @@ public final class IndicesClient {
|
|||
ForceMergeResponse::fromXContent, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Force merge one or more indices using the Force Merge API.
|
||||
* <p>
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-forcemerge.html">
|
||||
* Force Merge API on elastic.co</a>
|
||||
* @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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-forcemerge.html">
|
||||
|
@ -677,19 +429,6 @@ public final class IndicesClient {
|
|||
ForceMergeResponse::fromXContent, listener, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously force merge one or more indices using the Force Merge API.
|
||||
* <p>
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-forcemerge.html">
|
||||
* Force Merge API on elastic.co</a>
|
||||
* @deprecated Prefer {@link #forceMergeAsync(ForceMergeRequest, RequestOptions, ActionListener)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void forceMergeAsync(ForceMergeRequest forceMergeRequest, ActionListener<ForceMergeResponse> 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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-clearcache.html">
|
||||
|
@ -705,19 +444,6 @@ public final class IndicesClient {
|
|||
ClearIndicesCacheResponse::fromXContent, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the cache of one or more indices using the Clear Cache API.
|
||||
* <p>
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-clearcache.html">
|
||||
* Clear Cache API on elastic.co</a>
|
||||
* @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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-clearcache.html">
|
||||
|
@ -732,20 +458,6 @@ public final class IndicesClient {
|
|||
ClearIndicesCacheResponse::fromXContent, listener, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously clears the cache of one or more indices using the Clear Cache API.
|
||||
* <p>
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-clearcache.html">
|
||||
* Clear Cache API on elastic.co</a>
|
||||
* @deprecated Prefer {@link #clearCacheAsync(ClearIndicesCacheRequest, RequestOptions, ActionListener)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void clearCacheAsync(ClearIndicesCacheRequest clearIndicesCacheRequest, ActionListener<ClearIndicesCacheResponse> listener,
|
||||
Header... headers) {
|
||||
restHighLevelClient.performRequestAsyncAndParseEntity(clearIndicesCacheRequest, RequestConverters::clearCache,
|
||||
ClearIndicesCacheResponse::fromXContent, listener, emptySet(), headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the index (indices) exists or not.
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-exists.html">
|
||||
|
@ -765,24 +477,6 @@ public final class IndicesClient {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the index (indices) exists or not.
|
||||
* <p>
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-exists.html">
|
||||
* Indices Exists API on elastic.co</a>
|
||||
* @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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-exists.html">
|
||||
|
@ -802,25 +496,6 @@ public final class IndicesClient {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously checks if the index (indices) exists or not.
|
||||
* <p>
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-exists.html">
|
||||
* Indices Exists API on elastic.co</a>
|
||||
* @deprecated Prefer {@link #existsAsync(GetIndexRequest, RequestOptions, ActionListener)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void existsAsync(GetIndexRequest request, ActionListener<Boolean> listener, Header... headers) {
|
||||
restHighLevelClient.performRequestAsync(
|
||||
request,
|
||||
RequestConverters::indicesExist,
|
||||
RestHighLevelClient::convertExistsResponse,
|
||||
listener,
|
||||
Collections.emptySet(),
|
||||
headers
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shrinks an index using the Shrink Index API.
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-shrink-index.html">
|
||||
|
@ -835,19 +510,6 @@ public final class IndicesClient {
|
|||
ResizeResponse::fromXContent, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Shrinks an index using the Shrink Index API.
|
||||
* <p>
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-shrink-index.html">
|
||||
* Shrink Index API on elastic.co</a>
|
||||
* @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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-shrink-index.html">
|
||||
|
@ -861,19 +523,6 @@ public final class IndicesClient {
|
|||
ResizeResponse::fromXContent, listener, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously shrinks an index using the Shrink index API.
|
||||
* <p>
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-shrink-index.html">
|
||||
* Shrink Index API on elastic.co</a>
|
||||
* @deprecated Prefer {@link #shrinkAsync(ResizeRequest, RequestOptions, ActionListener)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void shrinkAsync(ResizeRequest resizeRequest, ActionListener<ResizeResponse> listener, Header... headers) {
|
||||
restHighLevelClient.performRequestAsyncAndParseEntity(resizeRequest, RequestConverters::shrink, ResizeResponse::fromXContent,
|
||||
listener, emptySet(), headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits an index using the Split Index API.
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-split-index.html">
|
||||
|
@ -888,19 +537,6 @@ public final class IndicesClient {
|
|||
ResizeResponse::fromXContent, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits an index using the Split Index API.
|
||||
* <p>
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-split-index.html">
|
||||
* Split Index API on elastic.co</a>
|
||||
* @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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-split-index.html">
|
||||
|
@ -914,19 +550,6 @@ public final class IndicesClient {
|
|||
ResizeResponse::fromXContent, listener, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously splits an index using the Split Index API.
|
||||
* <p>
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-split-index.html">
|
||||
* Split Index API on elastic.co</a>
|
||||
* @deprecated Prefer {@link #splitAsync(ResizeRequest, RequestOptions, ActionListener)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void splitAsync(ResizeRequest resizeRequest, ActionListener<ResizeResponse> listener, Header... headers) {
|
||||
restHighLevelClient.performRequestAsyncAndParseEntity(resizeRequest, RequestConverters::split, ResizeResponse::fromXContent,
|
||||
listener, emptySet(), headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rolls over an index using the Rollover Index API.
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-rollover-index.html">
|
||||
|
@ -941,19 +564,6 @@ public final class IndicesClient {
|
|||
RolloverResponse::fromXContent, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Rolls over an index using the Rollover Index API.
|
||||
* <p>
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-rollover-index.html">
|
||||
* Rollover Index API on elastic.co</a>
|
||||
* @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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-rollover-index.html">
|
||||
|
@ -967,19 +577,6 @@ public final class IndicesClient {
|
|||
RolloverResponse::fromXContent, listener, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously rolls over an index using the Rollover Index API.
|
||||
* <p>
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-rollover-index.html">
|
||||
* Rollover Index API on elastic.co</a>
|
||||
* @deprecated Prefer {@link #rolloverAsync(RolloverRequest, RequestOptions, ActionListener)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void rolloverAsync(RolloverRequest rolloverRequest, ActionListener<RolloverResponse> 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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html"> Indices Aliases API on
|
||||
|
@ -1021,19 +618,6 @@ public final class IndicesClient {
|
|||
UpdateSettingsResponse::fromXContent, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates specific index level settings using the Update Indices Settings API.
|
||||
* <p>
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html"> Update Indices Settings
|
||||
* API on elastic.co</a>
|
||||
* @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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html"> Update Indices Settings
|
||||
|
@ -1048,20 +632,6 @@ public final class IndicesClient {
|
|||
UpdateSettingsResponse::fromXContent, listener, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously updates specific index level settings using the Update Indices Settings API.
|
||||
* <p>
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html"> Update Indices Settings
|
||||
* API on elastic.co</a>
|
||||
* @deprecated Prefer {@link #putSettingsAsync(UpdateSettingsRequest, RequestOptions, ActionListener)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void putSettingsAsync(UpdateSettingsRequest updateSettingsRequest, ActionListener<UpdateSettingsResponse> listener,
|
||||
Header... headers) {
|
||||
restHighLevelClient.performRequestAsyncAndParseEntity(updateSettingsRequest, RequestConverters::indexPutSettings,
|
||||
UpdateSettingsResponse::fromXContent, listener, emptySet(), headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts an index template using the Index Templates API.
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html"> Index Templates API
|
||||
|
|
|
@ -721,7 +721,7 @@ final class RequestConverters {
|
|||
.withWaitForStatus(healthRequest.waitForStatus())
|
||||
.withWaitForNoRelocatingShards(healthRequest.waitForNoRelocatingShards())
|
||||
.withWaitForNoInitializingShards(healthRequest.waitForNoInitializingShards())
|
||||
.withWaitForActiveShards(healthRequest.waitForActiveShards())
|
||||
.withWaitForActiveShards(healthRequest.waitForActiveShards(), ActiveShardCount.NONE)
|
||||
.withWaitForNodes(healthRequest.waitForNodes())
|
||||
.withWaitForEvents(healthRequest.waitForEvents())
|
||||
.withTimeout(healthRequest.timeout())
|
||||
|
@ -1047,7 +1047,11 @@ final class RequestConverters {
|
|||
}
|
||||
|
||||
Params withWaitForActiveShards(ActiveShardCount activeShardCount) {
|
||||
if (activeShardCount != null && activeShardCount != ActiveShardCount.DEFAULT) {
|
||||
return withWaitForActiveShards(activeShardCount, ActiveShardCount.DEFAULT);
|
||||
}
|
||||
|
||||
Params withWaitForActiveShards(ActiveShardCount activeShardCount, ActiveShardCount defaultActiveShardCount) {
|
||||
if (activeShardCount != null && activeShardCount != defaultActiveShardCount) {
|
||||
return putParam("wait_for_active_shards", activeShardCount.toString().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
return this;
|
||||
|
|
|
@ -296,17 +296,6 @@ public class RestHighLevelClient implements Closeable {
|
|||
return performRequestAndParseEntity(bulkRequest, RequestConverters::bulk, options, BulkResponse::fromXContent, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a bulk request using the Bulk API.
|
||||
*
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html">Bulk API on elastic.co</a>
|
||||
* @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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html">Bulk API on elastic.co</a>
|
||||
|
@ -318,17 +307,6 @@ public class RestHighLevelClient implements Closeable {
|
|||
performRequestAsyncAndParseEntity(bulkRequest, RequestConverters::bulk, options, BulkResponse::fromXContent, listener, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously executes a bulk request using the Bulk API.
|
||||
*
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html">Bulk API on elastic.co</a>
|
||||
* @deprecated Prefer {@link #bulkAsync(BulkRequest, RequestOptions, ActionListener)}
|
||||
*/
|
||||
@Deprecated
|
||||
public final void bulkAsync(BulkRequest bulkRequest, ActionListener<BulkResponse> 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 class RestHighLevelClient implements Closeable {
|
|||
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 class RestHighLevelClient implements Closeable {
|
|||
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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html">Get API on elastic.co</a>
|
||||
|
@ -383,17 +341,6 @@ public class RestHighLevelClient implements Closeable {
|
|||
return performRequestAndParseEntity(getRequest, RequestConverters::get, options, GetResponse::fromXContent, singleton(404));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a document by id using the Get API.
|
||||
*
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html">Get API on elastic.co</a>
|
||||
* @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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html">Get API on elastic.co</a>
|
||||
|
@ -406,18 +353,6 @@ public class RestHighLevelClient implements Closeable {
|
|||
singleton(404));
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously retrieves a document by id using the Get API.
|
||||
*
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html">Get API on elastic.co</a>
|
||||
* @deprecated Prefer {@link #getAsync(GetRequest, RequestOptions, ActionListener)}
|
||||
*/
|
||||
@Deprecated
|
||||
public final void getAsync(GetRequest getRequest, ActionListener<GetResponse> listener, Header... headers) {
|
||||
performRequestAsyncAndParseEntity(getRequest, RequestConverters::get, GetResponse::fromXContent, listener,
|
||||
singleton(404), headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves multiple documents by id using the Multi Get API.
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.html">Multi Get API on elastic.co</a>
|
||||
|
@ -431,18 +366,6 @@ public class RestHighLevelClient implements Closeable {
|
|||
singleton(404));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves multiple documents by id using the Multi Get API.
|
||||
*
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.html">Multi Get API on elastic.co</a>
|
||||
* @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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.html">Multi Get API on elastic.co</a>
|
||||
|
@ -455,18 +378,6 @@ public class RestHighLevelClient implements Closeable {
|
|||
singleton(404));
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously retrieves multiple documents by id using the Multi Get API.
|
||||
*
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.html">Multi Get API on elastic.co</a>
|
||||
* @deprecated Prefer {@link #multiGetAsync(MultiGetRequest, RequestOptions, ActionListener)}
|
||||
*/
|
||||
@Deprecated
|
||||
public final void multiGetAsync(MultiGetRequest multiGetRequest, ActionListener<MultiGetResponse> 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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html">Get API on elastic.co</a>
|
||||
|
@ -479,17 +390,6 @@ public class RestHighLevelClient implements Closeable {
|
|||
return performRequest(getRequest, RequestConverters::exists, options, RestHighLevelClient::convertExistsResponse, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for the existence of a document. Returns true if it exists, false otherwise.
|
||||
*
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html">Get API on elastic.co</a>
|
||||
* @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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html">Get API on elastic.co</a>
|
||||
|
@ -502,18 +402,6 @@ public class RestHighLevelClient implements Closeable {
|
|||
emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously checks for the existence of a document. Returns true if it exists, false otherwise.
|
||||
*
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html">Get API on elastic.co</a>
|
||||
* @deprecated Prefer {@link #existsAsync(GetRequest, RequestOptions, ActionListener)}
|
||||
*/
|
||||
@Deprecated
|
||||
public final void existsAsync(GetRequest getRequest, ActionListener<Boolean> listener, Header... headers) {
|
||||
performRequestAsync(getRequest, RequestConverters::exists, RestHighLevelClient::convertExistsResponse, listener,
|
||||
emptySet(), headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Index a document using the Index API.
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html">Index API on elastic.co</a>
|
||||
|
@ -526,17 +414,6 @@ public class RestHighLevelClient implements Closeable {
|
|||
return performRequestAndParseEntity(indexRequest, RequestConverters::index, options, IndexResponse::fromXContent, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Index a document using the Index API.
|
||||
*
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html">Index API on elastic.co</a>
|
||||
* @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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html">Index API on elastic.co</a>
|
||||
|
@ -549,18 +426,6 @@ public class RestHighLevelClient implements Closeable {
|
|||
emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously index a document using the Index API.
|
||||
*
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html">Index API on elastic.co</a>
|
||||
* @deprecated Prefer {@link #indexAsync(IndexRequest, RequestOptions, ActionListener)}
|
||||
*/
|
||||
@Deprecated
|
||||
public final void indexAsync(IndexRequest indexRequest, ActionListener<IndexResponse> listener, Header... headers) {
|
||||
performRequestAsyncAndParseEntity(indexRequest, RequestConverters::index, IndexResponse::fromXContent, listener,
|
||||
emptySet(), headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a document using the Update API.
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html">Update API on elastic.co</a>
|
||||
|
@ -573,17 +438,6 @@ public class RestHighLevelClient implements Closeable {
|
|||
return performRequestAndParseEntity(updateRequest, RequestConverters::update, options, UpdateResponse::fromXContent, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a document using the Update API.
|
||||
* <p>
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html">Update API on elastic.co</a>
|
||||
* @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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html">Update API on elastic.co</a>
|
||||
|
@ -596,18 +450,6 @@ public class RestHighLevelClient implements Closeable {
|
|||
emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously updates a document using the Update API.
|
||||
* <p>
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html">Update API on elastic.co</a>
|
||||
* @deprecated Prefer {@link #updateAsync(UpdateRequest, RequestOptions, ActionListener)}
|
||||
*/
|
||||
@Deprecated
|
||||
public final void updateAsync(UpdateRequest updateRequest, ActionListener<UpdateResponse> listener, Header... headers) {
|
||||
performRequestAsyncAndParseEntity(updateRequest, RequestConverters::update, UpdateResponse::fromXContent, listener,
|
||||
emptySet(), headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a document by id using the Delete API.
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete.html">Delete API on elastic.co</a>
|
||||
|
@ -621,18 +463,6 @@ public class RestHighLevelClient implements Closeable {
|
|||
singleton(404));
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a document by id using the Delete API.
|
||||
*
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete.html">Delete API on elastic.co</a>
|
||||
* @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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete.html">Delete API on elastic.co</a>
|
||||
|
@ -645,18 +475,6 @@ public class RestHighLevelClient implements Closeable {
|
|||
Collections.singleton(404));
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously deletes a document by id using the Delete API.
|
||||
*
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete.html">Delete API on elastic.co</a>
|
||||
* @deprecated Prefer {@link #deleteAsync(DeleteRequest, RequestOptions, ActionListener)}
|
||||
*/
|
||||
@Deprecated
|
||||
public final void deleteAsync(DeleteRequest deleteRequest, ActionListener<DeleteResponse> listener, Header... headers) {
|
||||
performRequestAsyncAndParseEntity(deleteRequest, RequestConverters::delete, DeleteResponse::fromXContent, listener,
|
||||
Collections.singleton(404), headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a search request using the Search API.
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html">Search API on elastic.co</a>
|
||||
|
@ -669,17 +487,6 @@ public class RestHighLevelClient implements Closeable {
|
|||
return performRequestAndParseEntity(searchRequest, RequestConverters::search, options, SearchResponse::fromXContent, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a search using the Search API.
|
||||
*
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html">Search API on elastic.co</a>
|
||||
* @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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html">Search API on elastic.co</a>
|
||||
|
@ -692,18 +499,6 @@ public class RestHighLevelClient implements Closeable {
|
|||
emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously executes a search using the Search API.
|
||||
*
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html">Search API on elastic.co</a>
|
||||
* @deprecated Prefer {@link #searchAsync(SearchRequest, RequestOptions, ActionListener)}
|
||||
*/
|
||||
@Deprecated
|
||||
public final void searchAsync(SearchRequest searchRequest, ActionListener<SearchResponse> listener, Header... headers) {
|
||||
performRequestAsyncAndParseEntity(searchRequest, RequestConverters::search, SearchResponse::fromXContent, listener,
|
||||
emptySet(), headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a multi search using the msearch API.
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html">Multi search API on
|
||||
|
@ -718,19 +513,6 @@ public class RestHighLevelClient implements Closeable {
|
|||
emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a multi search using the msearch API.
|
||||
*
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html">Multi search API on
|
||||
* elastic.co</a>
|
||||
* @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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html">Multi search API on
|
||||
|
@ -745,19 +527,6 @@ public class RestHighLevelClient implements Closeable {
|
|||
listener, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously executes a multi search using the msearch API.
|
||||
*
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html">Multi search API on
|
||||
* elastic.co</a>
|
||||
* @deprecated Prefer {@link #multiSearchAsync(MultiSearchRequest, RequestOptions, ActionListener)}
|
||||
*/
|
||||
@Deprecated
|
||||
public final void multiSearchAsync(MultiSearchRequest searchRequest, ActionListener<MultiSearchResponse> listener, Header... headers) {
|
||||
performRequestAsyncAndParseEntity(searchRequest, RequestConverters::multiSearch, MultiSearchResponse::fromXContext, listener,
|
||||
emptySet(), headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a search using the Search Scroll API.
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html">Search Scroll
|
||||
|
@ -772,19 +541,6 @@ public class RestHighLevelClient implements Closeable {
|
|||
emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a search using the Search Scroll API.
|
||||
*
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html">Search Scroll
|
||||
* API on elastic.co</a>
|
||||
* @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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html">Search Scroll
|
||||
|
@ -799,20 +555,6 @@ public class RestHighLevelClient implements Closeable {
|
|||
listener, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously executes a search using the Search Scroll API.
|
||||
*
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html">Search Scroll
|
||||
* API on elastic.co</a>
|
||||
* @deprecated Prefer {@link #searchScrollAsync(SearchScrollRequest, RequestOptions, ActionListener)}
|
||||
*/
|
||||
@Deprecated
|
||||
public final void searchScrollAsync(SearchScrollRequest searchScrollRequest,
|
||||
ActionListener<SearchResponse> listener, Header... headers) {
|
||||
performRequestAsyncAndParseEntity(searchScrollRequest, RequestConverters::searchScroll, SearchResponse::fromXContent,
|
||||
listener, emptySet(), headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears one or more scroll ids using the Clear Scroll API.
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html#_clear_scroll_api">
|
||||
|
@ -827,19 +569,6 @@ public class RestHighLevelClient implements Closeable {
|
|||
emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears one or more scroll ids using the Clear Scroll API.
|
||||
*
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html#_clear_scroll_api">
|
||||
* Clear Scroll API on elastic.co</a>
|
||||
* @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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html#_clear_scroll_api">
|
||||
|
@ -854,20 +583,6 @@ public class RestHighLevelClient implements Closeable {
|
|||
listener, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously clears one or more scroll ids using the Clear Scroll API.
|
||||
*
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html#_clear_scroll_api">
|
||||
* Clear Scroll API on elastic.co</a>
|
||||
* @deprecated Prefer {@link #clearScrollAsync(ClearScrollRequest, RequestOptions, ActionListener)}
|
||||
*/
|
||||
@Deprecated
|
||||
public final void clearScrollAsync(ClearScrollRequest clearScrollRequest,
|
||||
ActionListener<ClearScrollResponse> listener, Header... headers) {
|
||||
performRequestAsyncAndParseEntity(clearScrollRequest, RequestConverters::clearScroll, ClearScrollResponse::fromXContent,
|
||||
listener, emptySet(), headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a request using the Search Template API.
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html">Search Template API
|
||||
|
@ -909,19 +624,6 @@ public class RestHighLevelClient implements Closeable {
|
|||
emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a request using the Ranking Evaluation API.
|
||||
*
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-rank-eval.html">Ranking Evaluation API
|
||||
* on elastic.co</a>
|
||||
* @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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-rank-eval.html">Ranking Evaluation API
|
||||
|
@ -935,19 +637,6 @@ public class RestHighLevelClient implements Closeable {
|
|||
emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously executes a request using the Ranking Evaluation API.
|
||||
*
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-rank-eval.html">Ranking Evaluation API
|
||||
* on elastic.co</a>
|
||||
* @deprecated Prefer {@link #rankEvalAsync(RankEvalRequest, RequestOptions, ActionListener)}
|
||||
*/
|
||||
@Deprecated
|
||||
public final void rankEvalAsync(RankEvalRequest rankEvalRequest, ActionListener<RankEvalResponse> listener, Header... headers) {
|
||||
performRequestAsyncAndParseEntity(rankEvalRequest, RequestConverters::rankEval, RankEvalResponse::fromXContent, listener,
|
||||
emptySet(), headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a request using the Field Capabilities API.
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-field-caps.html">Field Capabilities API
|
||||
|
@ -977,14 +666,6 @@ public class RestHighLevelClient implements Closeable {
|
|||
FieldCapabilitiesResponse::fromXContent, listener, emptySet());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected final <Req extends ActionRequest, Resp> Resp performRequestAndParseEntity(Req request,
|
||||
CheckedFunction<Req, Request, IOException> requestConverter,
|
||||
CheckedFunction<XContentParser, Resp, IOException> entityParser,
|
||||
Set<Integer> ignores, Header... headers) throws IOException {
|
||||
return performRequest(request, requestConverter, (response) -> parseEntity(response.getEntity(), entityParser), ignores, headers);
|
||||
}
|
||||
|
||||
protected final <Req extends ActionRequest, Resp> Resp performRequestAndParseEntity(Req request,
|
||||
CheckedFunction<Req, Request, IOException> requestConverter,
|
||||
RequestOptions options,
|
||||
|
@ -994,14 +675,6 @@ public class RestHighLevelClient implements Closeable {
|
|||
response -> parseEntity(response.getEntity(), entityParser), ignores);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected final <Req extends ActionRequest, Resp> Resp performRequest(Req request,
|
||||
CheckedFunction<Req, Request, IOException> requestConverter,
|
||||
CheckedFunction<Response, Resp, IOException> responseConverter,
|
||||
Set<Integer> ignores, Header... headers) throws IOException {
|
||||
return performRequest(request, requestConverter, optionsForHeaders(headers), responseConverter, ignores);
|
||||
}
|
||||
|
||||
protected final <Req extends ActionRequest, Resp> Resp performRequest(Req request,
|
||||
CheckedFunction<Req, Request, IOException> requestConverter,
|
||||
RequestOptions options,
|
||||
|
@ -1038,15 +711,6 @@ public class RestHighLevelClient implements Closeable {
|
|||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected final <Req extends ActionRequest, Resp> void performRequestAsyncAndParseEntity(Req request,
|
||||
CheckedFunction<Req, Request, IOException> requestConverter,
|
||||
CheckedFunction<XContentParser, Resp, IOException> entityParser,
|
||||
ActionListener<Resp> listener, Set<Integer> ignores, Header... headers) {
|
||||
performRequestAsync(request, requestConverter, (response) -> parseEntity(response.getEntity(), entityParser),
|
||||
listener, ignores, headers);
|
||||
}
|
||||
|
||||
protected final <Req extends ActionRequest, Resp> void performRequestAsyncAndParseEntity(Req request,
|
||||
CheckedFunction<Req, Request, IOException> requestConverter,
|
||||
RequestOptions options,
|
||||
|
@ -1056,14 +720,6 @@ public class RestHighLevelClient implements Closeable {
|
|||
response -> parseEntity(response.getEntity(), entityParser), listener, ignores);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected final <Req extends ActionRequest, Resp> void performRequestAsync(Req request,
|
||||
CheckedFunction<Req, Request, IOException> requestConverter,
|
||||
CheckedFunction<Response, Resp, IOException> responseConverter,
|
||||
ActionListener<Resp> listener, Set<Integer> ignores, Header... headers) {
|
||||
performRequestAsync(request, requestConverter, optionsForHeaders(headers), responseConverter, listener, ignores);
|
||||
}
|
||||
|
||||
protected final <Req extends ActionRequest, Resp> void performRequestAsync(Req request,
|
||||
CheckedFunction<Req, Request, IOException> requestConverter,
|
||||
RequestOptions options,
|
||||
|
|
|
@ -84,7 +84,7 @@ public final class TasksClient {
|
|||
cancelTasksRequest,
|
||||
RequestConverters::cancelTasks,
|
||||
options,
|
||||
parser -> CancelTasksResponse.fromXContent(parser),
|
||||
CancelTasksResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ public final class TasksClient {
|
|||
cancelTasksRequest,
|
||||
RequestConverters::cancelTasks,
|
||||
options,
|
||||
parser -> CancelTasksResponse.fromXContent(parser),
|
||||
CancelTasksResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
|
|
|
@ -56,7 +56,8 @@ import static org.hamcrest.Matchers.lessThanOrEqualTo;
|
|||
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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -63,7 +63,6 @@ public class ClusterClientIT extends ESRestHighLevelClientTestCase {
|
|||
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 class ClusterClientIT extends ESRestHighLevelClientTestCase {
|
|||
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 class ClusterClientIT extends ESRestHighLevelClientTestCase {
|
|||
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(
|
||||
|
|
|
@ -74,8 +74,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
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 class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
// 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 class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
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 class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
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 class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
.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 class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
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 class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
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 class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
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 class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
{
|
||||
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 class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
{
|
||||
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 class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
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 class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
}
|
||||
{
|
||||
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 class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
{
|
||||
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 class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
} 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 class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
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 class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
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 class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
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 class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
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 class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
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 class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
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 class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
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 class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
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 class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
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 class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
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 class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
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 class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
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 class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
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 class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
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 class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
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 class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
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 class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
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 class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
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 class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
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 class CrudIT extends ESRestHighLevelClientTestCase {
|
|||
}
|
||||
};
|
||||
|
||||
// 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)
|
||||
|
|
|
@ -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 @@ public abstract class ESRestHighLevelClientTestCase extends ESRestTestCase {
|
|||
void execute(Request request, RequestOptions options, ActionListener<Response> listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the provided request using either the sync method or its async variant, both provided as functions
|
||||
*/
|
||||
@Deprecated
|
||||
protected static <Req, Resp> Resp execute(Req request, SyncMethod<Req, Resp> syncMethod, AsyncMethod<Req, Resp> asyncMethod,
|
||||
SyncMethodWithHeaders<Req, Resp> syncMethodWithHeaders,
|
||||
AsyncMethodWithHeaders<Req, Resp> asyncMethodWithHeaders) throws IOException {
|
||||
switch(randomIntBetween(0, 3)) {
|
||||
case 0:
|
||||
return syncMethod.execute(request, RequestOptions.DEFAULT);
|
||||
case 1:
|
||||
PlainActionFuture<Resp> future = PlainActionFuture.newFuture();
|
||||
asyncMethod.execute(request, RequestOptions.DEFAULT, future);
|
||||
return future.actionGet();
|
||||
case 2:
|
||||
return syncMethodWithHeaders.execute(request);
|
||||
case 3:
|
||||
PlainActionFuture<Resp> futureWithHeaders = PlainActionFuture.newFuture();
|
||||
asyncMethodWithHeaders.execute(request, futureWithHeaders);
|
||||
return futureWithHeaders.actionGet();
|
||||
default:
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@FunctionalInterface
|
||||
protected interface SyncMethodWithHeaders<Request, Response> {
|
||||
Response execute(Request request, Header... headers) throws IOException;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@FunctionalInterface
|
||||
protected interface AsyncMethodWithHeaders<Request, Response> {
|
||||
void execute(Request request, ActionListener<Response> listener, Header... headers);
|
||||
}
|
||||
|
||||
private static class HighLevelClient extends RestHighLevelClient {
|
||||
private HighLevelClient(RestClient restClient) {
|
||||
super(restClient, (client) -> {}, Collections.emptyList());
|
||||
|
|
|
@ -117,8 +117,6 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
boolean response = execute(
|
||||
request,
|
||||
highLevelClient().indices()::exists,
|
||||
highLevelClient().indices()::existsAsync,
|
||||
highLevelClient().indices()::exists,
|
||||
highLevelClient().indices()::existsAsync
|
||||
);
|
||||
assertTrue(response);
|
||||
|
@ -134,8 +132,6 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
boolean response = execute(
|
||||
request,
|
||||
highLevelClient().indices()::exists,
|
||||
highLevelClient().indices()::existsAsync,
|
||||
highLevelClient().indices()::exists,
|
||||
highLevelClient().indices()::existsAsync
|
||||
);
|
||||
assertFalse(response);
|
||||
|
@ -154,8 +150,6 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
boolean response = execute(
|
||||
request,
|
||||
highLevelClient().indices()::exists,
|
||||
highLevelClient().indices()::existsAsync,
|
||||
highLevelClient().indices()::exists,
|
||||
highLevelClient().indices()::existsAsync
|
||||
);
|
||||
assertFalse(response);
|
||||
|
@ -173,8 +167,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
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 class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
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<String, Object> getIndexResponse = getAsMap(indexName);
|
||||
|
@ -338,8 +330,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
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<String, Object> getIndexResponse = getAsMap(indexName);
|
||||
|
@ -390,8 +381,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
|
||||
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 class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
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 class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
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 class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
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 class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
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 class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
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 class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
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 class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
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 class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
|
||||
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 class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
|
||||
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 class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
|
||||
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 class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
|
||||
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 class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
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 class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
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 class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
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 class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
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 class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
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 class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
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 class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
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 class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
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 class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
.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<String, Object> getIndexResponse = getAsMap("target");
|
||||
|
@ -786,8 +751,7 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
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<String, Object> getIndexResponse = getAsMap("target");
|
||||
|
@ -806,7 +770,6 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
|
||||
{
|
||||
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 class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
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 class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
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 class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
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 class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
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 class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
|
||||
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 class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
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 class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
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(
|
||||
|
|
|
@ -82,8 +82,7 @@ public class RankEvalIT extends ESRestHighLevelClientTestCase {
|
|||
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 class RankEvalIT extends ESRestHighLevelClientTestCase {
|
|||
// 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<RatedDocument> createRelevant(String indexName, String... docs) {
|
||||
|
|
|
@ -1562,7 +1562,7 @@ public class RequestConvertersTests extends ESTestCase {
|
|||
default:
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
setRandomWaitForActiveShards(healthRequest::waitForActiveShards, expectedParams, "0");
|
||||
setRandomWaitForActiveShards(healthRequest::waitForActiveShards, ActiveShardCount.NONE, expectedParams);
|
||||
if (randomBoolean()) {
|
||||
ClusterHealthRequest.Level level = randomFrom(ClusterHealthRequest.Level.values());
|
||||
healthRequest.level(level);
|
||||
|
@ -2187,23 +2187,24 @@ public class RequestConvertersTests extends ESTestCase {
|
|||
}
|
||||
|
||||
private static void setRandomWaitForActiveShards(Consumer<ActiveShardCount> setter, Map<String, String> expectedParams) {
|
||||
setRandomWaitForActiveShards(setter, expectedParams, null);
|
||||
setRandomWaitForActiveShards(setter, ActiveShardCount.DEFAULT, expectedParams);
|
||||
}
|
||||
|
||||
private static void setRandomWaitForActiveShards(Consumer<ActiveShardCount> setter,Map<String, String> expectedParams,
|
||||
String defaultValue) {
|
||||
private static void setRandomWaitForActiveShards(Consumer<ActiveShardCount> setter, ActiveShardCount defaultActiveShardCount,
|
||||
Map<String, String> expectedParams) {
|
||||
if (randomBoolean()) {
|
||||
int waitForActiveShardsInt = randomIntBetween(-1, 5);
|
||||
String waitForActiveShardsString;
|
||||
int waitForActiveShards = randomIntBetween(-1, 5);
|
||||
if (waitForActiveShards == -1) {
|
||||
if (waitForActiveShardsInt == -1) {
|
||||
waitForActiveShardsString = "all";
|
||||
} else {
|
||||
waitForActiveShardsString = String.valueOf(waitForActiveShards);
|
||||
waitForActiveShardsString = String.valueOf(waitForActiveShardsInt);
|
||||
}
|
||||
ActiveShardCount activeShardCount = ActiveShardCount.parseString(waitForActiveShardsString);
|
||||
setter.accept(activeShardCount);
|
||||
if (defaultActiveShardCount.equals(activeShardCount) == false) {
|
||||
expectedParams.put("wait_for_active_shards", waitForActiveShardsString);
|
||||
}
|
||||
setter.accept(ActiveShardCount.parseString(waitForActiveShardsString));
|
||||
expectedParams.put("wait_for_active_shards", waitForActiveShardsString);
|
||||
} else if (defaultValue != null) {
|
||||
expectedParams.put("wait_for_active_shards", defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -188,12 +188,12 @@ public class RestHighLevelClientTests extends ESTestCase {
|
|||
|
||||
{
|
||||
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 class RestHighLevelClientTests extends ESTestCase {
|
|||
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 class RestHighLevelClientTests extends ESTestCase {
|
|||
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 class RestHighLevelClientTests extends ESTestCase {
|
|||
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 class RestHighLevelClientTests extends ESTestCase {
|
|||
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 class RestHighLevelClientTests extends ESTestCase {
|
|||
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 class RestHighLevelClientTests extends ESTestCase {
|
|||
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 class RestHighLevelClientTests extends ESTestCase {
|
|||
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 class RestHighLevelClientTests extends ESTestCase {
|
|||
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]);
|
||||
|
|
|
@ -164,8 +164,7 @@ public class SearchIT extends ESRestHighLevelClientTestCase {
|
|||
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 class SearchIT extends ESRestHighLevelClientTestCase {
|
|||
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 class SearchIT extends ESRestHighLevelClientTestCase {
|
|||
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 class SearchIT extends ESRestHighLevelClientTestCase {
|
|||
.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 class SearchIT extends ESRestHighLevelClientTestCase {
|
|||
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 class SearchIT extends ESRestHighLevelClientTestCase {
|
|||
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 class SearchIT extends ESRestHighLevelClientTestCase {
|
|||
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 class SearchIT extends ESRestHighLevelClientTestCase {
|
|||
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 class SearchIT extends ESRestHighLevelClientTestCase {
|
|||
{
|
||||
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<Object> values = searchHit.getFields().get("result").getValues();
|
||||
assertNotNull(values);
|
||||
|
@ -488,8 +479,7 @@ public class SearchIT extends ESRestHighLevelClientTestCase {
|
|||
{
|
||||
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<Object> values = searchHit.getFields().get("result").getValues();
|
||||
assertNotNull(values);
|
||||
|
@ -501,8 +491,7 @@ public class SearchIT extends ESRestHighLevelClientTestCase {
|
|||
{
|
||||
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<Object> values = searchHit.getFields().get("result").getValues();
|
||||
assertNotNull(values);
|
||||
|
@ -524,8 +513,7 @@ public class SearchIT extends ESRestHighLevelClientTestCase {
|
|||
|
||||
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 class SearchIT extends ESRestHighLevelClientTestCase {
|
|||
}
|
||||
|
||||
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 class SearchIT extends ESRestHighLevelClientTestCase {
|
|||
}
|
||||
|
||||
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 class SearchIT extends ESRestHighLevelClientTestCase {
|
|||
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 class SearchIT extends ESRestHighLevelClientTestCase {
|
|||
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 class SearchIT extends ESRestHighLevelClientTestCase {
|
|||
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 class SearchIT extends ESRestHighLevelClientTestCase {
|
|||
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 class SearchIT extends ESRestHighLevelClientTestCase {
|
|||
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));
|
||||
|
||||
|
|
|
@ -746,7 +746,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
|
|||
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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
|
|||
}
|
||||
};
|
||||
|
||||
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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
|
|||
// 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 class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
|
|||
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));
|
||||
|
|
|
@ -576,7 +576,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
|
|||
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 class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
|
|||
" }\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 class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
|
|||
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 class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
|
|||
" }\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 class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
|
|||
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());
|
||||
}
|
||||
|
||||
|
|
|
@ -628,7 +628,7 @@ public class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
|
|||
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));
|
||||
|
|
|
@ -23,6 +23,7 @@ import joptsimple.OptionSet;
|
|||
import joptsimple.OptionSpec;
|
||||
import org.apache.lucene.search.spell.LevensteinDistance;
|
||||
import org.apache.lucene.util.CollectionUtil;
|
||||
import org.bouncycastle.bcpg.ArmoredInputStream;
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||
import org.bouncycastle.openpgp.PGPException;
|
||||
import org.bouncycastle.openpgp.PGPPublicKey;
|
||||
|
@ -47,7 +48,6 @@ import org.elasticsearch.core.internal.io.IOUtils;
|
|||
import org.elasticsearch.env.Environment;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
@ -74,7 +74,6 @@ import java.security.MessageDigest;
|
|||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
@ -543,8 +542,8 @@ class InstallPluginCommand extends EnvironmentAwareCommand {
|
|||
InputStream fin = pluginZipInputStream(zip);
|
||||
// sin is a URL stream to the signature corresponding to the downloaded plugin zip
|
||||
InputStream sin = urlOpenStream(ascUrl);
|
||||
// pin is a input stream to the public key in ASCII-Armor format (RFC4880); the Armor data is in RFC2045 format
|
||||
InputStream pin = getPublicKey()) {
|
||||
// ain is a input stream to the public key in ASCII-Armor format (RFC4880)
|
||||
InputStream ain = new ArmoredInputStream(getPublicKey())) {
|
||||
final JcaPGPObjectFactory factory = new JcaPGPObjectFactory(PGPUtil.getDecoderStream(sin));
|
||||
final PGPSignature signature = ((PGPSignatureList) factory.nextObject()).get(0);
|
||||
|
||||
|
@ -555,18 +554,6 @@ class InstallPluginCommand extends EnvironmentAwareCommand {
|
|||
}
|
||||
|
||||
// compute the signature of the downloaded plugin zip
|
||||
final List<String> lines =
|
||||
new BufferedReader(new InputStreamReader(pin, StandardCharsets.UTF_8)).lines().collect(Collectors.toList());
|
||||
// skip armor headers and possible blank line
|
||||
int index = 1;
|
||||
for (; index < lines.size(); index++) {
|
||||
if (lines.get(index).matches(".*: .*") == false && lines.get(index).matches("\\s*") == false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
final byte[] armoredData =
|
||||
lines.subList(index, lines.size() - 1).stream().collect(Collectors.joining("\n")).getBytes(StandardCharsets.UTF_8);
|
||||
final InputStream ain = Base64.getMimeDecoder().wrap(new ByteArrayInputStream(armoredData));
|
||||
final PGPPublicKeyRingCollection collection = new PGPPublicKeyRingCollection(ain, new JcaKeyFingerprintCalculator());
|
||||
final PGPPublicKey key = collection.getPublicKey(signature.getKeyID());
|
||||
signature.init(new JcaPGPContentVerifierBuilderProvider().setProvider(new BouncyCastleProvider()), key);
|
||||
|
|
|
@ -23,7 +23,6 @@ import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
|
|||
import com.google.common.jimfs.Configuration;
|
||||
import com.google.common.jimfs.Jimfs;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.util.LuceneTestCase.AwaitsFix;
|
||||
import org.bouncycastle.bcpg.ArmoredOutputStream;
|
||||
import org.bouncycastle.bcpg.BCPGOutputStream;
|
||||
import org.bouncycastle.bcpg.HashAlgorithmTags;
|
||||
|
@ -116,7 +115,6 @@ import static org.hamcrest.Matchers.hasToString;
|
|||
import static org.hamcrest.Matchers.not;
|
||||
|
||||
@LuceneTestCase.SuppressFileSystems("*")
|
||||
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/30900")
|
||||
public class InstallPluginCommandTests extends ESTestCase {
|
||||
|
||||
private InstallPluginCommand skipJarHellCommand;
|
||||
|
|
|
@ -36,6 +36,7 @@ Elasticsearch 6.x in order to be readable by Elasticsearch 7.x.
|
|||
* <<breaking_70_settings_changes>>
|
||||
* <<breaking_70_scripting_changes>>
|
||||
* <<breaking_70_snapshotstats_changes>>
|
||||
* <<breaking_70_restclient_changes>>
|
||||
|
||||
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[]
|
||||
include::migrate_7_0/snapshotstats.asciidoc[]
|
||||
include::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());`
|
|
@ -247,108 +247,31 @@ public class CommonAnalysisPlugin extends Plugin implements AnalysisPlugin {
|
|||
@Override
|
||||
public List<PreBuiltAnalyzerProviderFactory> getPreBuiltAnalyzerProviderFactories() {
|
||||
List<PreBuiltAnalyzerProviderFactory> analyzers = new ArrayList<>();
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("standard_html_strip", CachingStrategy.LUCENE, version -> {
|
||||
Analyzer a = new StandardHtmlStripAnalyzer(CharArraySet.EMPTY_SET);
|
||||
a.setVersion(version.luceneVersion);
|
||||
return a;
|
||||
}));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("pattern", CachingStrategy.ELASTICSEARCH, version -> {
|
||||
Analyzer a = new PatternAnalyzer(Regex.compile("\\W+" /*PatternAnalyzer.NON_WORD_PATTERN*/, null), true,
|
||||
CharArraySet.EMPTY_SET);
|
||||
a.setVersion(version.luceneVersion);
|
||||
return a;
|
||||
}));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("snowball", CachingStrategy.LUCENE, version -> {
|
||||
Analyzer a = new SnowballAnalyzer("English", StopAnalyzer.ENGLISH_STOP_WORDS_SET);
|
||||
a.setVersion(version.luceneVersion);
|
||||
return a;
|
||||
}));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("arabic", CachingStrategy.LUCENE, version -> {
|
||||
Analyzer a = new ArabicAnalyzer();
|
||||
a.setVersion(version.luceneVersion);
|
||||
return a;
|
||||
}));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("armenian", CachingStrategy.LUCENE, version -> {
|
||||
Analyzer a = new ArmenianAnalyzer();
|
||||
a.setVersion(version.luceneVersion);
|
||||
return a;
|
||||
}));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("basque", CachingStrategy.LUCENE, version -> {
|
||||
Analyzer a = new BasqueAnalyzer();
|
||||
a.setVersion(version.luceneVersion);
|
||||
return a;
|
||||
}));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("bengali", CachingStrategy.LUCENE, version -> {
|
||||
Analyzer a = new BengaliAnalyzer();
|
||||
a.setVersion(version.luceneVersion);
|
||||
return a;
|
||||
}));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("brazilian", CachingStrategy.LUCENE, version -> {
|
||||
Analyzer a = new BrazilianAnalyzer();
|
||||
a.setVersion(version.luceneVersion);
|
||||
return a;
|
||||
}));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("bulgarian", CachingStrategy.LUCENE, version -> {
|
||||
Analyzer a = new BulgarianAnalyzer();
|
||||
a.setVersion(version.luceneVersion);
|
||||
return a;
|
||||
}));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("catalan", CachingStrategy.LUCENE, version -> {
|
||||
Analyzer a = new CatalanAnalyzer();
|
||||
a.setVersion(version.luceneVersion);
|
||||
return a;
|
||||
}));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("chinese", CachingStrategy.LUCENE, version -> {
|
||||
// only for old indices, best effort
|
||||
Analyzer a = new StandardAnalyzer();
|
||||
a.setVersion(version.luceneVersion);
|
||||
return a;
|
||||
}));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("cjk", CachingStrategy.LUCENE, version -> {
|
||||
Analyzer a = new CJKAnalyzer();
|
||||
a.setVersion(version.luceneVersion);
|
||||
return a;
|
||||
}));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("czech", CachingStrategy.LUCENE, version -> {
|
||||
Analyzer a = new CzechAnalyzer();
|
||||
a.setVersion(version.luceneVersion);
|
||||
return a;
|
||||
}));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("danish", CachingStrategy.LUCENE, version -> {
|
||||
Analyzer a = new DanishAnalyzer();
|
||||
a.setVersion(version.luceneVersion);
|
||||
return a;
|
||||
}));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("dutch", CachingStrategy.LUCENE, version -> {
|
||||
Analyzer a = new DutchAnalyzer();
|
||||
a.setVersion(version.luceneVersion);
|
||||
return a;
|
||||
}));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("english", CachingStrategy.LUCENE, version -> {
|
||||
Analyzer a = new EnglishAnalyzer();
|
||||
a.setVersion(version.luceneVersion);
|
||||
return a;
|
||||
}));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("finnish", CachingStrategy.LUCENE, version -> {
|
||||
Analyzer a = new FinnishAnalyzer();
|
||||
a.setVersion(version.luceneVersion);
|
||||
return a;
|
||||
}));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("french", CachingStrategy.LUCENE, version -> {
|
||||
Analyzer a = new FrenchAnalyzer();
|
||||
a.setVersion(version.luceneVersion);
|
||||
return a;
|
||||
}));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("galician", CachingStrategy.LUCENE, version -> {
|
||||
Analyzer a = new GalicianAnalyzer();
|
||||
a.setVersion(version.luceneVersion);
|
||||
return a;
|
||||
}));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("german", CachingStrategy.LUCENE, version -> {
|
||||
Analyzer a = new GermanAnalyzer();
|
||||
a.setVersion(version.luceneVersion);
|
||||
return a;
|
||||
}));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("standard_html_strip", CachingStrategy.LUCENE,
|
||||
() -> new StandardHtmlStripAnalyzer(CharArraySet.EMPTY_SET)));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("pattern", CachingStrategy.ELASTICSEARCH,
|
||||
() -> new PatternAnalyzer(Regex.compile("\\W+" /*PatternAnalyzer.NON_WORD_PATTERN*/, null), true,
|
||||
CharArraySet.EMPTY_SET)));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("snowball", CachingStrategy.LUCENE,
|
||||
() -> new SnowballAnalyzer("English", StopAnalyzer.ENGLISH_STOP_WORDS_SET)));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("arabic", CachingStrategy.LUCENE, ArabicAnalyzer::new));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("armenian", CachingStrategy.LUCENE, ArmenianAnalyzer::new));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("basque", CachingStrategy.LUCENE, BasqueAnalyzer::new));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("bengali", CachingStrategy.LUCENE, BengaliAnalyzer::new));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("brazilian", CachingStrategy.LUCENE, BrazilianAnalyzer::new));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("bulgarian", CachingStrategy.LUCENE, BulgarianAnalyzer::new));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("catalan", CachingStrategy.LUCENE, CatalanAnalyzer::new));
|
||||
// chinese analyzer: only for old indices, best effort
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("chinese", CachingStrategy.LUCENE, StandardAnalyzer::new));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("cjk", CachingStrategy.LUCENE, CJKAnalyzer::new));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("czech", CachingStrategy.LUCENE, CzechAnalyzer::new));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("danish", CachingStrategy.LUCENE, DanishAnalyzer::new));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("dutch", CachingStrategy.LUCENE, DutchAnalyzer::new));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("english", CachingStrategy.LUCENE, EnglishAnalyzer::new));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("finnish", CachingStrategy.LUCENE, FinnishAnalyzer::new));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("french", CachingStrategy.LUCENE, FrenchAnalyzer::new));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("galician", CachingStrategy.LUCENE, GalicianAnalyzer::new));
|
||||
analyzers.add(new PreBuiltAnalyzerProviderFactory("german", CachingStrategy.LUCENE, GermanAnalyzer::new));
|
||||
return analyzers;
|
||||
}
|
||||
|
||||
|
|
|
@ -121,6 +121,11 @@ if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
|||
baseDir,
|
||||
unzip.temporaryDir,
|
||||
version == '090'
|
||||
waitCondition = { fixture, ant ->
|
||||
// the fixture writes the ports file when Elasticsearch's HTTP service
|
||||
// is ready, so we can just wait for the file to exist
|
||||
return fixture.portsFile.exists()
|
||||
}
|
||||
}
|
||||
integTest.dependsOn fixture
|
||||
integTestRunner {
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
package org.elasticsearch.index.reindex;
|
||||
|
||||
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
|
||||
import org.apache.lucene.util.SetOnce;
|
||||
import org.elasticsearch.ElasticsearchSecurityException;
|
||||
import org.elasticsearch.ElasticsearchStatusException;
|
||||
|
@ -42,7 +41,6 @@ import org.elasticsearch.common.util.concurrent.ThreadContext;
|
|||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.env.NodeEnvironment;
|
||||
import org.elasticsearch.index.reindex.test.ObjectCleanerThreadThreadFilter;
|
||||
import org.elasticsearch.plugins.ActionPlugin;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
|
@ -66,7 +64,6 @@ import static java.util.Collections.singletonMap;
|
|||
import static org.elasticsearch.index.reindex.ReindexTestCase.matcher;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
|
||||
@ThreadLeakFilters(filters = {ObjectCleanerThreadThreadFilter.class})
|
||||
public class ReindexFromRemoteWithAuthTests extends ESSingleNodeTestCase {
|
||||
private TransportAddress address;
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
package org.elasticsearch.index.reindex;
|
||||
|
||||
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
|
||||
import org.elasticsearch.action.ActionFuture;
|
||||
import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
|
||||
import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse;
|
||||
|
@ -33,7 +32,6 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.transport.TransportAddress;
|
||||
import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.index.reindex.test.ObjectCleanerThreadThreadFilter;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
|
@ -57,7 +55,6 @@ import static org.hamcrest.Matchers.hasSize;
|
|||
* Integration test for retry behavior. Useful because retrying relies on the way that the
|
||||
* rest of Elasticsearch throws exceptions and unit tests won't verify that.
|
||||
*/
|
||||
@ThreadLeakFilters(filters = {ObjectCleanerThreadThreadFilter.class})
|
||||
public class RetryTests extends ESIntegTestCase {
|
||||
|
||||
private static final int DOC_COUNT = 20;
|
||||
|
|
|
@ -39,6 +39,7 @@ import java.nio.file.StandardCopyOption;
|
|||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static java.util.Collections.emptyMap;
|
||||
import static java.util.Collections.singleton;
|
||||
import static java.util.Collections.singletonMap;
|
||||
|
@ -67,7 +68,6 @@ public class URLFixture {
|
|||
writeFile(workingDirectory, "ports", addressAndPort);
|
||||
|
||||
// Exposes the repository over HTTP
|
||||
final String url = "http://" + addressAndPort;
|
||||
httpServer.createContext("/", new ResponseHandler(dir(args[1])));
|
||||
httpServer.start();
|
||||
|
||||
|
@ -110,7 +110,13 @@ public class URLFixture {
|
|||
@Override
|
||||
public void handle(HttpExchange exchange) throws IOException {
|
||||
Response response;
|
||||
if ("GET".equalsIgnoreCase(exchange.getRequestMethod())) {
|
||||
|
||||
final String userAgent = exchange.getRequestHeaders().getFirst("User-Agent");
|
||||
if (userAgent != null && userAgent.startsWith("Apache Ant")) {
|
||||
// This is a request made by the AntFixture, just reply "OK"
|
||||
response = new Response(RestStatus.OK, emptyMap(), "text/plain; charset=utf-8", "OK".getBytes(UTF_8));
|
||||
|
||||
} else if ("GET".equalsIgnoreCase(exchange.getRequestMethod())) {
|
||||
String path = exchange.getRequestURI().toString();
|
||||
if (path.length() > 0 && path.charAt(0) == '/') {
|
||||
path = path.substring(1);
|
||||
|
@ -125,13 +131,13 @@ public class URLFixture {
|
|||
Map<String, String> headers = singletonMap("Content-Length", String.valueOf(content.length));
|
||||
response = new Response(RestStatus.OK, headers, "application/octet-stream", content);
|
||||
} else {
|
||||
response = new Response(RestStatus.NOT_FOUND, emptyMap(), "text/plain", new byte[0]);
|
||||
response = new Response(RestStatus.NOT_FOUND, emptyMap(), "text/plain; charset=utf-8", new byte[0]);
|
||||
}
|
||||
} else {
|
||||
response = new Response(RestStatus.FORBIDDEN, emptyMap(), "text/plain", new byte[0]);
|
||||
response = new Response(RestStatus.FORBIDDEN, emptyMap(), "text/plain; charset=utf-8", new byte[0]);
|
||||
}
|
||||
} else {
|
||||
response = new Response(RestStatus.INTERNAL_SERVER_ERROR, emptyMap(), "text/plain",
|
||||
response = new Response(RestStatus.INTERNAL_SERVER_ERROR, emptyMap(), "text/plain; charset=utf-8",
|
||||
"Unsupported HTTP method".getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
exchange.sendResponseHeaders(response.status.getStatus(), response.body.length);
|
||||
|
|
|
@ -34,13 +34,13 @@ compileTestJava.options.compilerArgs << "-Xlint:-cast,-deprecation,-rawtypes,-tr
|
|||
|
||||
dependencies {
|
||||
// network stack
|
||||
compile "io.netty:netty-buffer:4.1.25.Final"
|
||||
compile "io.netty:netty-codec:4.1.25.Final"
|
||||
compile "io.netty:netty-codec-http:4.1.25.Final"
|
||||
compile "io.netty:netty-common:4.1.25.Final"
|
||||
compile "io.netty:netty-handler:4.1.25.Final"
|
||||
compile "io.netty:netty-resolver:4.1.25.Final"
|
||||
compile "io.netty:netty-transport:4.1.25.Final"
|
||||
compile "io.netty:netty-buffer:4.1.16.Final"
|
||||
compile "io.netty:netty-codec:4.1.16.Final"
|
||||
compile "io.netty:netty-codec-http:4.1.16.Final"
|
||||
compile "io.netty:netty-common:4.1.16.Final"
|
||||
compile "io.netty:netty-handler:4.1.16.Final"
|
||||
compile "io.netty:netty-resolver:4.1.16.Final"
|
||||
compile "io.netty:netty-transport:4.1.16.Final"
|
||||
}
|
||||
|
||||
dependencyLicenses {
|
||||
|
@ -161,6 +161,6 @@ thirdPartyAudit.excludes = [
|
|||
|
||||
'org.conscrypt.AllocatedBuffer',
|
||||
'org.conscrypt.BufferAllocator',
|
||||
'org.conscrypt.Conscrypt',
|
||||
'org.conscrypt.Conscrypt$Engines',
|
||||
'org.conscrypt.HandshakeListener'
|
||||
]
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
63b5fa95c74785e16f2c30ce268bc222e35c8cb5
|
|
@ -1 +0,0 @@
|
|||
f366d0cc87b158ca064d27507127e3cc4eb2f089
|
|
@ -0,0 +1 @@
|
|||
d84a1f21768b7309c2954521cf5a1f46c2309eb1
|
|
@ -1 +0,0 @@
|
|||
3e465c75bead40d06b5b9c0612b37cf77c548887
|
|
@ -0,0 +1 @@
|
|||
d64312378b438dfdad84267c599a053327c6f02a
|
|
@ -1 +0,0 @@
|
|||
70888d3f2a829541378f68503ddd52c3193df35a
|
|
@ -0,0 +1 @@
|
|||
177a6b30cca92f6f5f9873c9befd681377a4c328
|
|
@ -1 +0,0 @@
|
|||
e17d5c05c101fe14536ce3fb34b36c54e04791f6
|
|
@ -0,0 +1 @@
|
|||
fec0e63e7dd7f4eeef7ea8dc47a1ff32dfc7ebc2
|
|
@ -1 +0,0 @@
|
|||
ecdfb8fe93a8b75db3ea8746d3437eed845c24bd
|
|
@ -0,0 +1 @@
|
|||
f6eb553b53fb3a90a8ac1170697093fed82eae28
|
|
@ -1 +0,0 @@
|
|||
dc0965d00746b782b33f419b005cbc130973030d
|
|
@ -0,0 +1 @@
|
|||
3c8ee2c4d4a1cbb947a5c184c7aeb2204260958b
|
|
@ -1 +0,0 @@
|
|||
19a6f1f649894b6705aa9d8cbcced188dff133b0
|
|
@ -22,7 +22,7 @@ package org.elasticsearch.http.netty4;
|
|||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import io.netty.handler.codec.http.LastHttpContent;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.elasticsearch.common.collect.Tuple;
|
||||
import org.elasticsearch.http.HttpPipelinedRequest;
|
||||
|
@ -53,17 +53,14 @@ public class Netty4HttpPipeliningHandler extends ChannelDuplexHandler {
|
|||
|
||||
@Override
|
||||
public void channelRead(final ChannelHandlerContext ctx, final Object msg) {
|
||||
if (msg instanceof LastHttpContent) {
|
||||
HttpPipelinedRequest<LastHttpContent> pipelinedRequest = aggregator.read(((LastHttpContent) msg));
|
||||
ctx.fireChannelRead(pipelinedRequest);
|
||||
} else {
|
||||
ctx.fireChannelRead(msg);
|
||||
}
|
||||
assert msg instanceof FullHttpRequest : "Invalid message type: " + msg.getClass();
|
||||
HttpPipelinedRequest<FullHttpRequest> pipelinedRequest = aggregator.read(((FullHttpRequest) msg));
|
||||
ctx.fireChannelRead(pipelinedRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final ChannelHandlerContext ctx, final Object msg, final ChannelPromise promise) {
|
||||
assert msg instanceof Netty4HttpResponse : "Message must be type: " + Netty4HttpResponse.class;
|
||||
assert msg instanceof Netty4HttpResponse : "Invalid message type: " + msg.getClass();;
|
||||
Netty4HttpResponse response = (Netty4HttpResponse) msg;
|
||||
boolean success = false;
|
||||
try {
|
||||
|
|
|
@ -21,8 +21,6 @@ grant codeBase "${codebase.netty-common}" {
|
|||
// for reading the system-wide configuration for the backlog of established sockets
|
||||
permission java.io.FilePermission "/proc/sys/net/core/somaxconn", "read";
|
||||
|
||||
permission java.lang.RuntimePermission "setContextClassLoader";
|
||||
|
||||
// netty makes and accepts socket connections
|
||||
permission java.net.SocketPermission "*", "accept,connect";
|
||||
};
|
||||
|
|
|
@ -16,21 +16,19 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.elasticsearch;
|
||||
|
||||
package org.elasticsearch.test;
|
||||
|
||||
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
|
||||
import org.elasticsearch.common.network.NetworkModule;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.elasticsearch.transport.Netty4Plugin;
|
||||
import org.elasticsearch.transport.netty4.Netty4Transport;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
@ThreadLeakFilters(filters = {ObjectCleanerThreadThreadFilter.class})
|
||||
public abstract class Netty4IntegTestCase extends ESIntegTestCase {
|
||||
public abstract class ESNetty4IntegTestCase extends ESIntegTestCase {
|
||||
|
||||
@Override
|
||||
protected boolean ignoreExternalCluster() {
|
|
@ -20,7 +20,6 @@
|
|||
package org.elasticsearch.http.netty4;
|
||||
|
||||
import io.netty.handler.codec.http.FullHttpResponse;
|
||||
import org.elasticsearch.test.Netty4TestCase;
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.common.network.NetworkService;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -34,6 +33,7 @@ import org.elasticsearch.rest.BytesRestResponse;
|
|||
import org.elasticsearch.rest.RestChannel;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.threadpool.TestThreadPool;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.junit.After;
|
||||
|
@ -48,7 +48,7 @@ import static org.hamcrest.Matchers.containsString;
|
|||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
|
||||
public class Netty4BadRequestTests extends Netty4TestCase {
|
||||
public class Netty4BadRequestTests extends ESTestCase {
|
||||
|
||||
private NetworkService networkService;
|
||||
private MockBigArrays bigArrays;
|
||||
|
|
|
@ -41,7 +41,6 @@ import io.netty.handler.codec.http.HttpResponse;
|
|||
import io.netty.handler.codec.http.HttpVersion;
|
||||
import io.netty.util.Attribute;
|
||||
import io.netty.util.AttributeKey;
|
||||
import org.elasticsearch.test.Netty4TestCase;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.bytes.ReleasablePagedBytesReference;
|
||||
import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
||||
|
@ -65,6 +64,7 @@ import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
|
|||
import org.elasticsearch.rest.BytesRestResponse;
|
||||
import org.elasticsearch.rest.RestResponse;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.threadpool.TestThreadPool;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.netty4.Netty4Utils;
|
||||
|
@ -90,7 +90,7 @@ import static org.hamcrest.Matchers.not;
|
|||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
|
||||
public class Netty4HttpChannelTests extends Netty4TestCase {
|
||||
public class Netty4HttpChannelTests extends ESTestCase {
|
||||
|
||||
private NetworkService networkService;
|
||||
private ThreadPool threadPool;
|
||||
|
|
|
@ -36,9 +36,9 @@ import io.netty.handler.codec.http.HttpRequest;
|
|||
import io.netty.handler.codec.http.HttpVersion;
|
||||
import io.netty.handler.codec.http.LastHttpContent;
|
||||
import io.netty.handler.codec.http.QueryStringDecoder;
|
||||
import org.elasticsearch.test.Netty4TestCase;
|
||||
import org.elasticsearch.common.Randomness;
|
||||
import org.elasticsearch.http.HttpPipelinedRequest;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.junit.After;
|
||||
|
||||
import java.nio.channels.ClosedChannelException;
|
||||
|
@ -61,7 +61,7 @@ import static io.netty.handler.codec.http.HttpResponseStatus.OK;
|
|||
import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1;
|
||||
import static org.hamcrest.core.Is.is;
|
||||
|
||||
public class Netty4HttpPipeliningHandlerTests extends Netty4TestCase {
|
||||
public class Netty4HttpPipeliningHandlerTests extends ESTestCase {
|
||||
|
||||
private final ExecutorService handlerService = Executors.newFixedThreadPool(randomIntBetween(4, 8));
|
||||
private final ExecutorService eventLoopService = Executors.newFixedThreadPool(1);
|
||||
|
@ -148,38 +148,6 @@ public class Netty4HttpPipeliningHandlerTests extends Netty4TestCase {
|
|||
assertTrue(embeddedChannel.isOpen());
|
||||
}
|
||||
|
||||
public void testThatPipeliningWorksWithChunkedRequests() throws InterruptedException {
|
||||
final int numberOfRequests = randomIntBetween(2, 128);
|
||||
final EmbeddedChannel embeddedChannel =
|
||||
new EmbeddedChannel(
|
||||
new AggregateUrisAndHeadersHandler(),
|
||||
new Netty4HttpPipeliningHandler(logger, numberOfRequests),
|
||||
new WorkEmulatorHandler());
|
||||
|
||||
for (int i = 0; i < numberOfRequests; i++) {
|
||||
final DefaultHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/" + i);
|
||||
embeddedChannel.writeInbound(request);
|
||||
embeddedChannel.writeInbound(LastHttpContent.EMPTY_LAST_CONTENT);
|
||||
}
|
||||
|
||||
final List<CountDownLatch> latches = new ArrayList<>();
|
||||
for (int i = numberOfRequests - 1; i >= 0; i--) {
|
||||
latches.add(finishRequest(Integer.toString(i)));
|
||||
}
|
||||
|
||||
for (final CountDownLatch latch : latches) {
|
||||
latch.await();
|
||||
}
|
||||
|
||||
embeddedChannel.flush();
|
||||
|
||||
for (int i = 0; i < numberOfRequests; i++) {
|
||||
assertReadHttpMessageHasContent(embeddedChannel, Integer.toString(i));
|
||||
}
|
||||
|
||||
assertTrue(embeddedChannel.isOpen());
|
||||
}
|
||||
|
||||
public void testThatPipeliningClosesConnectionWithTooManyEvents() throws InterruptedException {
|
||||
final int numberOfRequests = randomIntBetween(2, 128);
|
||||
final EmbeddedChannel embeddedChannel = new EmbeddedChannel(new Netty4HttpPipeliningHandler(logger, numberOfRequests),
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package org.elasticsearch.http.netty4;
|
||||
|
||||
import io.netty.handler.codec.http.FullHttpResponse;
|
||||
import org.elasticsearch.test.Netty4IntegTestCase;
|
||||
import org.elasticsearch.ESNetty4IntegTestCase;
|
||||
import org.elasticsearch.common.collect.Tuple;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.TransportAddress;
|
||||
|
@ -45,7 +45,7 @@ import static org.hamcrest.Matchers.hasSize;
|
|||
* a single node "cluster". We also force test infrastructure to use the node client instead of the transport client for the same reason.
|
||||
*/
|
||||
@ClusterScope(scope = Scope.TEST, supportsDedicatedMasters = false, numClientNodes = 0, numDataNodes = 1, transportClientRatio = 0)
|
||||
public class Netty4HttpRequestSizeLimitIT extends Netty4IntegTestCase {
|
||||
public class Netty4HttpRequestSizeLimitIT extends ESNetty4IntegTestCase {
|
||||
|
||||
private static final ByteSizeValue LIMIT = new ByteSizeValue(2, ByteSizeUnit.KB);
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ import io.netty.handler.codec.http.FullHttpResponse;
|
|||
import io.netty.handler.codec.http.HttpHeaderNames;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.handler.codec.http.HttpVersion;
|
||||
import org.elasticsearch.test.Netty4TestCase;
|
||||
import org.elasticsearch.common.network.NetworkService;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.TransportAddress;
|
||||
|
@ -43,6 +42,7 @@ import org.elasticsearch.http.HttpPipelinedRequest;
|
|||
import org.elasticsearch.http.HttpServerTransport;
|
||||
import org.elasticsearch.http.NullDispatcher;
|
||||
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.threadpool.TestThreadPool;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.junit.After;
|
||||
|
@ -61,7 +61,7 @@ import static org.hamcrest.Matchers.contains;
|
|||
/**
|
||||
* This test just tests, if he pipelining works in general with out any connection the Elasticsearch handler
|
||||
*/
|
||||
public class Netty4HttpServerPipeliningTests extends Netty4TestCase {
|
||||
public class Netty4HttpServerPipeliningTests extends ESTestCase {
|
||||
private NetworkService networkService;
|
||||
private ThreadPool threadPool;
|
||||
private MockBigArrays bigArrays;
|
||||
|
|
|
@ -38,7 +38,6 @@ import io.netty.handler.codec.http.HttpMethod;
|
|||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.handler.codec.http.HttpUtil;
|
||||
import io.netty.handler.codec.http.HttpVersion;
|
||||
import org.elasticsearch.test.Netty4TestCase;
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.bytes.BytesArray;
|
||||
|
@ -60,6 +59,7 @@ import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
|
|||
import org.elasticsearch.rest.BytesRestResponse;
|
||||
import org.elasticsearch.rest.RestChannel;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.threadpool.TestThreadPool;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.junit.After;
|
||||
|
@ -94,7 +94,7 @@ import static org.hamcrest.Matchers.is;
|
|||
/**
|
||||
* Tests for the {@link Netty4HttpServerTransport} class.
|
||||
*/
|
||||
public class Netty4HttpServerTransportTests extends Netty4TestCase {
|
||||
public class Netty4HttpServerTransportTests extends ESTestCase {
|
||||
|
||||
private NetworkService networkService;
|
||||
private ThreadPool threadPool;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package org.elasticsearch.http.netty4;
|
||||
|
||||
import io.netty.handler.codec.http.FullHttpResponse;
|
||||
import org.elasticsearch.test.Netty4IntegTestCase;
|
||||
import org.elasticsearch.ESNetty4IntegTestCase;
|
||||
import org.elasticsearch.common.transport.TransportAddress;
|
||||
import org.elasticsearch.http.HttpServerTransport;
|
||||
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
||||
|
@ -33,7 +33,7 @@ import static org.hamcrest.Matchers.hasSize;
|
|||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
@ClusterScope(scope = Scope.TEST, supportsDedicatedMasters = false, numDataNodes = 1)
|
||||
public class Netty4PipeliningIT extends Netty4IntegTestCase {
|
||||
public class Netty4PipeliningIT extends ESNetty4IntegTestCase {
|
||||
|
||||
@Override
|
||||
protected boolean addMockHttpTransport() {
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.test;
|
||||
|
||||
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
|
||||
|
||||
@ThreadLeakFilters(filters = {ObjectCleanerThreadThreadFilter.class})
|
||||
public abstract class Netty4TestCase extends ESTestCase {
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.test;
|
||||
|
||||
import com.carrotsearch.randomizedtesting.ThreadFilter;
|
||||
|
||||
/**
|
||||
* The Netty object cleaner thread is not closeable and it does not terminate in a timely manner. This means that thread leak control in
|
||||
* tests will fail test suites when the object cleaner thread has not terminated. Since there is not a reliable way to terminate this thread
|
||||
* we instead filter it out of thread leak control.
|
||||
*/
|
||||
public class ObjectCleanerThreadThreadFilter implements ThreadFilter {
|
||||
|
||||
@Override
|
||||
public boolean reject(final Thread t) {
|
||||
// TODO: replace with constant from Netty when https://github.com/netty/netty/pull/8014 is integrated
|
||||
return "ObjectCleanerThread".equals(t.getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -18,18 +18,15 @@
|
|||
*/
|
||||
package org.elasticsearch.transport.netty4;
|
||||
|
||||
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.elasticsearch.test.ObjectCleanerThreadThreadFilter;
|
||||
import org.elasticsearch.common.bytes.AbstractBytesReferenceTestCase;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.io.stream.ReleasableBytesStreamOutput;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@ThreadLeakFilters(filters = {ObjectCleanerThreadThreadFilter.class})
|
||||
public class ByteBufBytesReferenceTests extends AbstractBytesReferenceTestCase {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package org.elasticsearch.transport.netty4;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.elasticsearch.test.Netty4IntegTestCase;
|
||||
import org.elasticsearch.ESNetty4IntegTestCase;
|
||||
import org.elasticsearch.action.admin.cluster.node.hotthreads.NodesHotThreadsRequest;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
|
@ -29,7 +29,7 @@ import org.elasticsearch.test.junit.annotations.TestLogging;
|
|||
|
||||
@ESIntegTestCase.ClusterScope(numDataNodes = 2)
|
||||
@TestLogging(value = "org.elasticsearch.transport.netty4.ESLoggingHandler:trace")
|
||||
public class ESLoggingHandlerIT extends Netty4IntegTestCase {
|
||||
public class ESLoggingHandlerIT extends ESNetty4IntegTestCase {
|
||||
|
||||
private MockLogAppender appender;
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.elasticsearch.transport.netty4;
|
||||
|
||||
import org.elasticsearch.test.Netty4TestCase;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
|
||||
import org.elasticsearch.common.lease.Releasables;
|
||||
|
@ -27,6 +26,7 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.util.BigArrays;
|
||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.test.transport.MockTransportService;
|
||||
import org.elasticsearch.threadpool.TestThreadPool;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
|
@ -47,7 +47,7 @@ import java.util.Collections;
|
|||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
|
||||
public class Netty4ScheduledPingTests extends Netty4TestCase {
|
||||
public class Netty4ScheduledPingTests extends ESTestCase {
|
||||
public void testScheduledPing() throws Exception {
|
||||
ThreadPool threadPool = new TestThreadPool(getClass().getName());
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
package org.elasticsearch.transport.netty4;
|
||||
|
||||
import org.elasticsearch.test.Netty4TestCase;
|
||||
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
|
||||
import org.elasticsearch.common.network.NetworkService;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -29,6 +28,7 @@ import org.elasticsearch.common.util.MockBigArrays;
|
|||
import org.elasticsearch.common.util.MockPageCacheRecycler;
|
||||
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
|
||||
import org.elasticsearch.mocksocket.MockSocket;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TcpTransport;
|
||||
import org.junit.After;
|
||||
|
@ -47,7 +47,7 @@ import static org.hamcrest.Matchers.is;
|
|||
* This test checks, if a HTTP look-alike request (starting with a HTTP method and a space)
|
||||
* actually returns text response instead of just dropping the connection
|
||||
*/
|
||||
public class Netty4SizeHeaderFrameDecoderTests extends Netty4TestCase {
|
||||
public class Netty4SizeHeaderFrameDecoderTests extends ESTestCase {
|
||||
|
||||
private final Settings settings = Settings.builder()
|
||||
.put("node.name", "NettySizeHeaderFrameDecoderTests")
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
package org.elasticsearch.transport.netty4;
|
||||
|
||||
import org.elasticsearch.test.Netty4IntegTestCase;
|
||||
import org.elasticsearch.ESNetty4IntegTestCase;
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
||||
|
@ -54,7 +54,7 @@ import static org.hamcrest.Matchers.containsString;
|
|||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
@ClusterScope(scope = Scope.TEST, supportsDedicatedMasters = false, numDataNodes = 1)
|
||||
public class Netty4TransportIT extends Netty4IntegTestCase {
|
||||
public class Netty4TransportIT extends ESNetty4IntegTestCase {
|
||||
// static so we can use it in anonymous classes
|
||||
private static String channelProfileName = null;
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
package org.elasticsearch.transport.netty4;
|
||||
|
||||
import org.elasticsearch.test.Netty4IntegTestCase;
|
||||
import org.elasticsearch.ESNetty4IntegTestCase;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
||||
import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
|
||||
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
|
||||
|
@ -48,7 +48,7 @@ import static org.hamcrest.Matchers.is;
|
|||
import static org.hamcrest.Matchers.lessThanOrEqualTo;
|
||||
|
||||
@ClusterScope(scope = Scope.SUITE, supportsDedicatedMasters = false, numDataNodes = 1, numClientNodes = 0)
|
||||
public class Netty4TransportMultiPortIntegrationIT extends Netty4IntegTestCase {
|
||||
public class Netty4TransportMultiPortIntegrationIT extends ESNetty4IntegTestCase {
|
||||
|
||||
private static int randomPort = -1;
|
||||
private static String randomPortRange;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
package org.elasticsearch.transport.netty4;
|
||||
|
||||
import org.elasticsearch.test.Netty4IntegTestCase;
|
||||
import org.elasticsearch.ESNetty4IntegTestCase;
|
||||
import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
|
||||
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
|
||||
import org.elasticsearch.common.network.NetworkModule;
|
||||
|
@ -41,7 +41,7 @@ import static org.hamcrest.Matchers.instanceOf;
|
|||
* different ports on ipv4 and ipv6.
|
||||
*/
|
||||
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0)
|
||||
public class Netty4TransportPublishAddressIT extends Netty4IntegTestCase {
|
||||
public class Netty4TransportPublishAddressIT extends ESNetty4IntegTestCase {
|
||||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
return Settings.builder()
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.elasticsearch.transport.netty4;
|
||||
|
||||
import org.elasticsearch.test.Netty4TestCase;
|
||||
import org.elasticsearch.common.component.Lifecycle;
|
||||
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
|
||||
import org.elasticsearch.common.network.NetworkService;
|
||||
|
@ -28,6 +27,7 @@ import org.elasticsearch.common.util.BigArrays;
|
|||
import org.elasticsearch.common.util.MockBigArrays;
|
||||
import org.elasticsearch.common.util.MockPageCacheRecycler;
|
||||
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.threadpool.TestThreadPool;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TcpTransport;
|
||||
|
@ -37,7 +37,7 @@ import java.util.Collections;
|
|||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
public class NettyTransportMultiPortTests extends Netty4TestCase {
|
||||
public class NettyTransportMultiPortTests extends ESTestCase {
|
||||
|
||||
private String host;
|
||||
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
|
||||
package org.elasticsearch.transport.netty4;
|
||||
|
||||
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
|
||||
import org.elasticsearch.test.ObjectCleanerThreadThreadFilter;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
|
||||
|
@ -51,7 +49,6 @@ import static java.util.Collections.emptyMap;
|
|||
import static java.util.Collections.emptySet;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
|
||||
@ThreadLeakFilters(filters = {ObjectCleanerThreadThreadFilter.class})
|
||||
public class SimpleNetty4TransportTests extends AbstractSimpleTransportTestCase {
|
||||
|
||||
public static MockTransportService nettyFromThreadPool(Settings settings, ThreadPool threadPool, final Version version,
|
||||
|
|
|
@ -23,25 +23,41 @@ import org.elasticsearch.mocksocket.MockSocket;
|
|||
import org.elasticsearch.test.ESTestCase;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Objects;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.hamcrest.Matchers.hasItems;
|
||||
|
||||
public class ExampleFixtureIT extends ESTestCase {
|
||||
|
||||
public void testExample() throws Exception {
|
||||
final String stringAddress = Objects.requireNonNull(System.getProperty("external.address"));
|
||||
final URL url = new URL("http://" + stringAddress);
|
||||
final String externalAddress = System.getProperty("external.address");
|
||||
assertNotNull("External address must not be null", externalAddress);
|
||||
|
||||
final URL url = new URL("http://" + externalAddress);
|
||||
final InetAddress address = InetAddress.getByName(url.getHost());
|
||||
try (
|
||||
Socket socket = new MockSocket(address, url.getPort());
|
||||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(), StandardCharsets.UTF_8));
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_8))
|
||||
) {
|
||||
assertEquals("TEST", reader.readLine());
|
||||
writer.write("GET / HTTP/1.1\r\n");
|
||||
writer.write("Host: elastic.co\r\n\r\n");
|
||||
writer.flush();
|
||||
|
||||
final List<String> lines = new ArrayList<>();
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
lines.add(line);
|
||||
}
|
||||
assertThat(lines, hasItems("HTTP/1.1 200 OK", "TEST"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@ import com.sun.net.httpserver.HttpServer;
|
|||
import org.elasticsearch.common.SuppressForbidden;
|
||||
import org.elasticsearch.common.io.Streams;
|
||||
import org.elasticsearch.mocksocket.MockHttpServer;
|
||||
import org.elasticsearch.repositories.azure.AzureStorageTestServer.Response;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -39,6 +41,8 @@ import java.nio.file.StandardCopyOption;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static java.util.Collections.emptyMap;
|
||||
import static java.util.Collections.singleton;
|
||||
import static java.util.Collections.singletonList;
|
||||
|
||||
|
@ -121,7 +125,16 @@ public class AzureStorageFixture {
|
|||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
Streams.copy(exchange.getRequestBody(), out);
|
||||
|
||||
final AzureStorageTestServer.Response response = server.handle(method, path, query, headers, out.toByteArray());
|
||||
Response response = null;
|
||||
|
||||
final String userAgent = exchange.getRequestHeaders().getFirst("User-Agent");
|
||||
if (userAgent != null && userAgent.startsWith("Apache Ant")) {
|
||||
// This is a request made by the AntFixture, just reply "OK"
|
||||
response = new Response(RestStatus.OK, emptyMap(), "text/plain; charset=utf-8", "OK".getBytes(UTF_8));
|
||||
} else {
|
||||
// Otherwise simulate a S3 response
|
||||
response = server.handle(method, path, query, headers, out.toByteArray());
|
||||
}
|
||||
|
||||
Map<String, List<String>> responseHeaders = exchange.getResponseHeaders();
|
||||
responseHeaders.put("Content-Type", singletonList(response.contentType));
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.elasticsearch.common.SuppressForbidden;
|
|||
import org.elasticsearch.core.internal.io.Streams;
|
||||
import org.elasticsearch.mocksocket.MockHttpServer;
|
||||
import org.elasticsearch.repositories.gcs.GoogleCloudStorageTestServer.Response;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -40,6 +41,8 @@ import java.nio.file.StandardCopyOption;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static java.util.Collections.emptyMap;
|
||||
import static java.util.Collections.singleton;
|
||||
import static java.util.Collections.singletonList;
|
||||
|
||||
|
@ -123,7 +126,16 @@ public class GoogleCloudStorageFixture {
|
|||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
Streams.copy(exchange.getRequestBody(), out);
|
||||
|
||||
final Response storageResponse = storageServer.handle(method, path, query, headers, out.toByteArray());
|
||||
Response storageResponse = null;
|
||||
|
||||
final String userAgent = exchange.getRequestHeaders().getFirst("User-Agent");
|
||||
if (userAgent != null && userAgent.startsWith("Apache Ant")) {
|
||||
// This is a request made by the AntFixture, just reply "OK"
|
||||
storageResponse = new Response(RestStatus.OK, emptyMap(), "text/plain; charset=utf-8", "OK".getBytes(UTF_8));
|
||||
} else {
|
||||
// Otherwise simulate a S3 response
|
||||
storageResponse = storageServer.handle(method, path, query, headers, out.toByteArray());
|
||||
}
|
||||
|
||||
Map<String, List<String>> responseHeaders = exchange.getResponseHeaders();
|
||||
responseHeaders.put("Content-Type", singletonList(storageResponse.contentType));
|
||||
|
|
|
@ -116,6 +116,11 @@ for (String fixtureName : ['hdfsFixture', 'haHdfsFixture', 'secureHdfsFixture',
|
|||
dependsOn project.configurations.hdfsFixture
|
||||
executable = new File(project.runtimeJavaHome, 'bin/java')
|
||||
env 'CLASSPATH', "${ -> project.configurations.hdfsFixture.asPath }"
|
||||
waitCondition = { fixture, ant ->
|
||||
// the hdfs.MiniHDFS fixture writes the ports file when
|
||||
// it's ready, so we can just wait for the file to exist
|
||||
return fixture.portsFile.exists()
|
||||
}
|
||||
|
||||
final List<String> miniHDFSArgs = []
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.elasticsearch.common.SuppressForbidden;
|
|||
import org.elasticsearch.common.io.Streams;
|
||||
import org.elasticsearch.mocksocket.MockHttpServer;
|
||||
import org.elasticsearch.repositories.s3.AmazonS3TestServer.Response;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -40,6 +41,8 @@ import java.nio.file.StandardCopyOption;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static java.util.Collections.emptyMap;
|
||||
import static java.util.Collections.singleton;
|
||||
import static java.util.Collections.singletonList;
|
||||
|
||||
|
@ -122,7 +125,16 @@ public class AmazonS3Fixture {
|
|||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
Streams.copy(exchange.getRequestBody(), out);
|
||||
|
||||
final Response storageResponse = storageServer.handle(method, path, query, headers, out.toByteArray());
|
||||
Response storageResponse = null;
|
||||
|
||||
final String userAgent = exchange.getRequestHeaders().getFirst("User-Agent");
|
||||
if (userAgent != null && userAgent.startsWith("Apache Ant")) {
|
||||
// This is a request made by the AntFixture, just reply "OK"
|
||||
storageResponse = new Response(RestStatus.OK, emptyMap(), "text/plain; charset=utf-8", "OK".getBytes(UTF_8));
|
||||
} else {
|
||||
// Otherwise simulate a S3 response
|
||||
storageResponse = storageServer.handle(method, path, query, headers, out.toByteArray());
|
||||
}
|
||||
|
||||
Map<String, List<String>> responseHeaders = exchange.getResponseHeaders();
|
||||
responseHeaders.put("Content-Type", singletonList(storageResponse.contentType));
|
||||
|
|
|
@ -29,13 +29,13 @@ dependencies {
|
|||
compile "org.elasticsearch:elasticsearch-nio:${version}"
|
||||
|
||||
// network stack
|
||||
compile "io.netty:netty-buffer:4.1.25.Final"
|
||||
compile "io.netty:netty-codec:4.1.25.Final"
|
||||
compile "io.netty:netty-codec-http:4.1.25.Final"
|
||||
compile "io.netty:netty-common:4.1.25.Final"
|
||||
compile "io.netty:netty-handler:4.1.25.Final"
|
||||
compile "io.netty:netty-resolver:4.1.25.Final"
|
||||
compile "io.netty:netty-transport:4.1.25.Final"
|
||||
compile "io.netty:netty-buffer:4.1.16.Final"
|
||||
compile "io.netty:netty-codec:4.1.16.Final"
|
||||
compile "io.netty:netty-codec-http:4.1.16.Final"
|
||||
compile "io.netty:netty-common:4.1.16.Final"
|
||||
compile "io.netty:netty-handler:4.1.16.Final"
|
||||
compile "io.netty:netty-resolver:4.1.16.Final"
|
||||
compile "io.netty:netty-transport:4.1.16.Final"
|
||||
}
|
||||
|
||||
dependencyLicenses {
|
||||
|
@ -140,6 +140,6 @@ thirdPartyAudit.excludes = [
|
|||
|
||||
'org.conscrypt.AllocatedBuffer',
|
||||
'org.conscrypt.BufferAllocator',
|
||||
'org.conscrypt.Conscrypt',
|
||||
'org.conscrypt.Conscrypt$Engines',
|
||||
'org.conscrypt.HandshakeListener'
|
||||
]
|
|
@ -0,0 +1 @@
|
|||
63b5fa95c74785e16f2c30ce268bc222e35c8cb5
|
|
@ -1 +0,0 @@
|
|||
f366d0cc87b158ca064d27507127e3cc4eb2f089
|
|
@ -0,0 +1 @@
|
|||
d84a1f21768b7309c2954521cf5a1f46c2309eb1
|
|
@ -1 +0,0 @@
|
|||
3e465c75bead40d06b5b9c0612b37cf77c548887
|
|
@ -0,0 +1 @@
|
|||
d64312378b438dfdad84267c599a053327c6f02a
|
|
@ -1 +0,0 @@
|
|||
70888d3f2a829541378f68503ddd52c3193df35a
|
|
@ -0,0 +1 @@
|
|||
177a6b30cca92f6f5f9873c9befd681377a4c328
|
|
@ -1 +0,0 @@
|
|||
e17d5c05c101fe14536ce3fb34b36c54e04791f6
|
|
@ -0,0 +1 @@
|
|||
fec0e63e7dd7f4eeef7ea8dc47a1ff32dfc7ebc2
|
|
@ -1 +0,0 @@
|
|||
ecdfb8fe93a8b75db3ea8746d3437eed845c24bd
|
|
@ -0,0 +1 @@
|
|||
f6eb553b53fb3a90a8ac1170697093fed82eae28
|
|
@ -1 +0,0 @@
|
|||
dc0965d00746b782b33f419b005cbc130973030d
|
|
@ -0,0 +1 @@
|
|||
3c8ee2c4d4a1cbb947a5c184c7aeb2204260958b
|
|
@ -1 +0,0 @@
|
|||
19a6f1f649894b6705aa9d8cbcced188dff133b0
|
|
@ -22,13 +22,11 @@ package org.elasticsearch.http.nio;
|
|||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import io.netty.handler.codec.http.LastHttpContent;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.elasticsearch.common.collect.Tuple;
|
||||
import org.elasticsearch.http.HttpPipelinedRequest;
|
||||
import org.elasticsearch.http.HttpPipeliningAggregator;
|
||||
import org.elasticsearch.http.nio.NettyListener;
|
||||
import org.elasticsearch.http.nio.NioHttpResponse;
|
||||
|
||||
import java.nio.channels.ClosedChannelException;
|
||||
import java.util.List;
|
||||
|
@ -55,17 +53,14 @@ public class NioHttpPipeliningHandler extends ChannelDuplexHandler {
|
|||
|
||||
@Override
|
||||
public void channelRead(final ChannelHandlerContext ctx, final Object msg) {
|
||||
if (msg instanceof LastHttpContent) {
|
||||
HttpPipelinedRequest<LastHttpContent> pipelinedRequest = aggregator.read(((LastHttpContent) msg));
|
||||
ctx.fireChannelRead(pipelinedRequest);
|
||||
} else {
|
||||
ctx.fireChannelRead(msg);
|
||||
}
|
||||
assert msg instanceof FullHttpRequest : "Invalid message type: " + msg.getClass();
|
||||
HttpPipelinedRequest<FullHttpRequest> pipelinedRequest = aggregator.read(((FullHttpRequest) msg));
|
||||
ctx.fireChannelRead(pipelinedRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final ChannelHandlerContext ctx, final Object msg, final ChannelPromise promise) {
|
||||
assert msg instanceof NioHttpResponse : "Message must be type: " + NioHttpResponse.class;
|
||||
assert msg instanceof NioHttpResponse : "Invalid message type: " + msg.getClass();
|
||||
NioHttpResponse response = (NioHttpResponse) msg;
|
||||
boolean success = false;
|
||||
try {
|
||||
|
|
|
@ -23,8 +23,6 @@ grant codeBase "${codebase.elasticsearch-nio}" {
|
|||
};
|
||||
|
||||
grant codeBase "${codebase.netty-common}" {
|
||||
permission java.lang.RuntimePermission "setContextClassLoader";
|
||||
|
||||
// This should only currently be required as we use the netty http client for tests
|
||||
// netty makes and accepts socket connections
|
||||
permission java.net.SocketPermission "*", "accept,connect";
|
||||
|
|
|
@ -16,12 +16,13 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.elasticsearch.test;
|
||||
package org.elasticsearch;
|
||||
|
||||
import org.elasticsearch.common.network.NetworkModule;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.http.nio.NioHttpServerTransport;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.elasticsearch.transport.nio.NioTransport;
|
||||
import org.elasticsearch.transport.nio.NioTransportPlugin;
|
||||
|
|
@ -46,7 +46,7 @@ import org.elasticsearch.nio.NioSocketChannel;
|
|||
import org.elasticsearch.nio.SocketChannelContext;
|
||||
import org.elasticsearch.rest.RestChannel;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.test.NioHttpTestCase;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.junit.Before;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
|
@ -69,7 +69,7 @@ import static org.mockito.Mockito.mock;
|
|||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
public class HttpReadWriteHandlerTests extends NioHttpTestCase {
|
||||
public class HttpReadWriteHandlerTests extends ESTestCase {
|
||||
|
||||
private HttpReadWriteHandler handler;
|
||||
private NioSocketChannel nioSocketChannel;
|
||||
|
|
|
@ -27,14 +27,14 @@ import io.netty.channel.ChannelOutboundHandlerAdapter;
|
|||
import io.netty.channel.ChannelPromise;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import org.elasticsearch.nio.FlushOperation;
|
||||
import org.elasticsearch.test.NioHttpTestCase;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class NettyAdaptorTests extends NioHttpTestCase {
|
||||
public class NettyAdaptorTests extends ESTestCase {
|
||||
|
||||
public void testBasicRead() {
|
||||
TenIntsToStringsHandler handler = new TenIntsToStringsHandler();
|
||||
|
|
|
@ -28,17 +28,15 @@ import io.netty.channel.SimpleChannelInboundHandler;
|
|||
import io.netty.channel.embedded.EmbeddedChannel;
|
||||
import io.netty.handler.codec.http.DefaultFullHttpRequest;
|
||||
import io.netty.handler.codec.http.DefaultFullHttpResponse;
|
||||
import io.netty.handler.codec.http.DefaultHttpRequest;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.FullHttpResponse;
|
||||
import io.netty.handler.codec.http.HttpMethod;
|
||||
import io.netty.handler.codec.http.HttpRequest;
|
||||
import io.netty.handler.codec.http.HttpVersion;
|
||||
import io.netty.handler.codec.http.LastHttpContent;
|
||||
import io.netty.handler.codec.http.QueryStringDecoder;
|
||||
import org.elasticsearch.common.Randomness;
|
||||
import org.elasticsearch.http.HttpPipelinedRequest;
|
||||
import org.elasticsearch.test.NioHttpTestCase;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.junit.After;
|
||||
|
||||
import java.nio.channels.ClosedChannelException;
|
||||
|
@ -61,7 +59,7 @@ import static io.netty.handler.codec.http.HttpResponseStatus.OK;
|
|||
import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1;
|
||||
import static org.hamcrest.core.Is.is;
|
||||
|
||||
public class NioHttpPipeliningHandlerTests extends NioHttpTestCase {
|
||||
public class NioHttpPipeliningHandlerTests extends ESTestCase {
|
||||
|
||||
private final ExecutorService handlerService = Executors.newFixedThreadPool(randomIntBetween(4, 8));
|
||||
private final ExecutorService eventLoopService = Executors.newFixedThreadPool(1);
|
||||
|
@ -147,38 +145,6 @@ public class NioHttpPipeliningHandlerTests extends NioHttpTestCase {
|
|||
assertTrue(embeddedChannel.isOpen());
|
||||
}
|
||||
|
||||
public void testThatPipeliningWorksWithChunkedRequests() throws InterruptedException {
|
||||
final int numberOfRequests = randomIntBetween(2, 128);
|
||||
final EmbeddedChannel embeddedChannel =
|
||||
new EmbeddedChannel(
|
||||
new AggregateUrisAndHeadersHandler(),
|
||||
new NioHttpPipeliningHandler(logger, numberOfRequests),
|
||||
new WorkEmulatorHandler());
|
||||
|
||||
for (int i = 0; i < numberOfRequests; i++) {
|
||||
final DefaultHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/" + i);
|
||||
embeddedChannel.writeInbound(request);
|
||||
embeddedChannel.writeInbound(LastHttpContent.EMPTY_LAST_CONTENT);
|
||||
}
|
||||
|
||||
final List<CountDownLatch> latches = new ArrayList<>();
|
||||
for (int i = numberOfRequests - 1; i >= 0; i--) {
|
||||
latches.add(finishRequest(Integer.toString(i)));
|
||||
}
|
||||
|
||||
for (final CountDownLatch latch : latches) {
|
||||
latch.await();
|
||||
}
|
||||
|
||||
embeddedChannel.flush();
|
||||
|
||||
for (int i = 0; i < numberOfRequests; i++) {
|
||||
assertReadHttpMessageHasContent(embeddedChannel, Integer.toString(i));
|
||||
}
|
||||
|
||||
assertTrue(embeddedChannel.isOpen());
|
||||
}
|
||||
|
||||
public void testThatPipeliningClosesConnectionWithTooManyEvents() throws InterruptedException {
|
||||
final int numberOfRequests = randomIntBetween(2, 128);
|
||||
final EmbeddedChannel embeddedChannel = new EmbeddedChannel(new NioHttpPipeliningHandler(logger, numberOfRequests),
|
||||
|
|
|
@ -51,7 +51,7 @@ import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
|
|||
import org.elasticsearch.rest.BytesRestResponse;
|
||||
import org.elasticsearch.rest.RestChannel;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.test.NioHttpTestCase;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.threadpool.TestThreadPool;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.junit.After;
|
||||
|
@ -83,7 +83,7 @@ import static org.hamcrest.Matchers.is;
|
|||
/**
|
||||
* Tests for the {@link NioHttpServerTransport} class.
|
||||
*/
|
||||
public class NioHttpServerTransportTests extends NioHttpTestCase {
|
||||
public class NioHttpServerTransportTests extends ESTestCase {
|
||||
|
||||
private NetworkService networkService;
|
||||
private ThreadPool threadPool;
|
||||
|
|
|
@ -20,11 +20,11 @@
|
|||
package org.elasticsearch.http.nio;
|
||||
|
||||
import io.netty.handler.codec.http.FullHttpResponse;
|
||||
import org.elasticsearch.NioIntegTestCase;
|
||||
import org.elasticsearch.common.transport.TransportAddress;
|
||||
import org.elasticsearch.http.HttpServerTransport;
|
||||
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
||||
import org.elasticsearch.test.ESIntegTestCase.Scope;
|
||||
import org.elasticsearch.test.NioHttpIntegTestCase;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Locale;
|
||||
|
@ -33,7 +33,7 @@ import static org.hamcrest.Matchers.hasSize;
|
|||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
@ClusterScope(scope = Scope.TEST, supportsDedicatedMasters = false, numDataNodes = 1)
|
||||
public class NioPipeliningIT extends NioHttpIntegTestCase {
|
||||
public class NioPipeliningIT extends NioIntegTestCase {
|
||||
|
||||
@Override
|
||||
protected boolean addMockHttpTransport() {
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.test;
|
||||
|
||||
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
|
||||
|
||||
@ThreadLeakFilters(filters = {ObjectCleanerThreadThreadFilter.class})
|
||||
public abstract class NioHttpIntegTestCase extends NioIntegTestCase {
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.test;
|
||||
|
||||
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
|
||||
|
||||
@ThreadLeakFilters(filters = {ObjectCleanerThreadThreadFilter.class})
|
||||
public abstract class NioHttpTestCase extends ESTestCase {
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.test;
|
||||
|
||||
import com.carrotsearch.randomizedtesting.ThreadFilter;
|
||||
|
||||
/**
|
||||
* The Netty object cleaner thread is not closeable and it does not terminate in a timely manner. This means that thread leak control in
|
||||
* tests will fail test suites when the object cleaner thread has not terminated. Since there is not a reliable way to terminate this thread
|
||||
* we instead filter it out of thread leak control.
|
||||
*/
|
||||
public class ObjectCleanerThreadThreadFilter implements ThreadFilter {
|
||||
|
||||
@Override
|
||||
public boolean reject(final Thread t) {
|
||||
// TODO: replace with constant from Netty when https://github.com/netty/netty/pull/8014 is integrated
|
||||
return "ObjectCleanerThread".equals(t.getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -19,6 +19,7 @@
|
|||
package org.elasticsearch.transport.nio;
|
||||
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.NioIntegTestCase;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
||||
import org.elasticsearch.client.Client;
|
||||
|
@ -35,7 +36,6 @@ import org.elasticsearch.plugins.NetworkPlugin;
|
|||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
||||
import org.elasticsearch.test.ESIntegTestCase.Scope;
|
||||
import org.elasticsearch.test.NioIntegTestCase;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TcpChannel;
|
||||
import org.elasticsearch.transport.TcpTransport;
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
|
||||
package org.elasticsearch.smoketest;
|
||||
|
||||
import com.carrotsearch.randomizedtesting.ThreadFilter;
|
||||
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
||||
|
@ -64,24 +62,8 @@ import static org.hamcrest.Matchers.notNullValue;
|
|||
* then run JUnit. If you changed the default port, set "-Dtests.cluster=localhost:PORT" when running your test.
|
||||
*/
|
||||
@LuceneTestCase.SuppressSysoutChecks(bugUrl = "we log a lot on purpose")
|
||||
@ThreadLeakFilters(filters = {ESSmokeClientTestCase.ObjectCleanerThreadThreadFilter.class})
|
||||
public abstract class ESSmokeClientTestCase extends LuceneTestCase {
|
||||
|
||||
/**
|
||||
* The Netty object cleaner thread is not closeable and it does not terminate in a timely manner. This means that thread leak control in
|
||||
* tests will fail test suites when the object cleaner thread has not terminated. Since there is not a reliable way to terminate this
|
||||
* thread we instead filter it out of thread leak control.
|
||||
*/
|
||||
public static class ObjectCleanerThreadThreadFilter implements ThreadFilter {
|
||||
|
||||
@Override
|
||||
public boolean reject(final Thread t) {
|
||||
// TODO: replace with constant from Netty when https://github.com/netty/netty/pull/8014 is integrated
|
||||
return "ObjectCleanerThread".equals(t.getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Key used to eventually switch to using an external cluster and provide its transport addresses
|
||||
*/
|
||||
|
|
|
@ -18,13 +18,10 @@
|
|||
*/
|
||||
package org.elasticsearch.http;
|
||||
|
||||
import com.carrotsearch.randomizedtesting.ThreadFilter;
|
||||
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
|
||||
import org.elasticsearch.common.network.NetworkModule;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.transport.MockTcpTransportPlugin;
|
||||
import org.elasticsearch.transport.Netty4Plugin;
|
||||
import org.elasticsearch.transport.nio.MockNioTransportPlugin;
|
||||
|
@ -34,19 +31,8 @@ import org.junit.BeforeClass;
|
|||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
@ThreadLeakFilters(filters = {HttpSmokeTestCase.ObjectCleanerThreadThreadFilter.class})
|
||||
public abstract class HttpSmokeTestCase extends ESIntegTestCase {
|
||||
|
||||
public static class ObjectCleanerThreadThreadFilter implements ThreadFilter {
|
||||
|
||||
@Override
|
||||
public boolean reject(final Thread t) {
|
||||
// TODO: replace with constant from Netty when https://github.com/netty/netty/pull/8014 is integrated
|
||||
return "ObjectCleanerThread".equals(t.getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static String nodeTransportTypeKey;
|
||||
private static String nodeHttpTypeKey;
|
||||
private static String clientTypeKey;
|
||||
|
|
|
@ -234,11 +234,11 @@ public class TransportClusterHealthAction extends TransportMasterNodeReadAction<
|
|||
ActiveShardCount waitForActiveShards = request.waitForActiveShards();
|
||||
assert waitForActiveShards.equals(ActiveShardCount.DEFAULT) == false :
|
||||
"waitForActiveShards must not be DEFAULT on the request object, instead it should be NONE";
|
||||
if (waitForActiveShards.equals(ActiveShardCount.ALL)
|
||||
&& response.getUnassignedShards() == 0
|
||||
&& response.getInitializingShards() == 0) {
|
||||
// if we are waiting for all shards to be active, then the num of unassigned and num of initializing shards must be 0
|
||||
waitForCounter++;
|
||||
if (waitForActiveShards.equals(ActiveShardCount.ALL)) {
|
||||
if (response.getUnassignedShards() == 0 && response.getInitializingShards() == 0) {
|
||||
// if we are waiting for all shards to be active, then the num of unassigned and num of initializing shards must be 0
|
||||
waitForCounter++;
|
||||
}
|
||||
} else if (waitForActiveShards.enoughShardsActive(response.getActiveShards())) {
|
||||
// there are enough active shards to meet the requirements of the request
|
||||
waitForCounter++;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue