org.elasticsearch.action.admin.indices.flush.FlushResponse Java Examples
The following examples show how to use
org.elasticsearch.action.admin.indices.flush.FlushResponse.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FessEsClient.java From fess with Apache License 2.0 | 6 votes |
public void flush(final String... indices) { client.admin().indices().prepareFlush(indices).execute(new ActionListener<FlushResponse>() { @Override public void onResponse(final FlushResponse response) { if (logger.isDebugEnabled()) { logger.debug(() -> "Flushed " + stream(indices).get(stream -> stream.collect(Collectors.joining(", ")))); } } @Override public void onFailure(final Exception e) { logger.error(() -> "Failed to flush " + stream(indices).get(stream -> stream.collect(Collectors.joining(", "))), e); } }); }
Example #2
Source File: RestFlushAction.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { FlushRequest flushRequest = new FlushRequest(Strings.splitStringByCommaToArray(request.param("index"))); flushRequest.indicesOptions(IndicesOptions.fromRequest(request, flushRequest.indicesOptions())); flushRequest.force(request.paramAsBoolean("force", flushRequest.force())); flushRequest.waitIfOngoing(request.paramAsBoolean("wait_if_ongoing", flushRequest.waitIfOngoing())); client.admin().indices().flush(flushRequest, new RestBuilderListener<FlushResponse>(channel) { @Override public RestResponse buildResponse(FlushResponse response, XContentBuilder builder) throws Exception { builder.startObject(); buildBroadcastShardsHeader(builder, request, response); builder.endObject(); return new BytesRestResponse(OK, builder); } }); }
Example #3
Source File: EsTranslogHandler.java From io with Apache License 2.0 | 5 votes |
@Override FlushResponse onParticularError(ElasticsearchException e) { String message = String.format("ES translog flush failed. index[%s] cause[%s]", indexName, e.toString()); log.debug(message); return null; }
Example #4
Source File: FlushRequestBuilder.java From elasticshell with Apache License 2.0 | 5 votes |
@Override protected XContentBuilder toXContent(FlushRequest request, FlushResponse response, XContentBuilder builder) throws IOException { builder.startObject(); builder.field(Fields.OK, true); buildBroadcastShardsHeader(builder, response); builder.endObject(); return builder; }
Example #5
Source File: AbstractElasticSearchTest.java From camunda-bpm-elasticsearch with Apache License 2.0 | 5 votes |
private FlushResponse flush(boolean ignoreNotAllowed) { waitForRelocation(); FlushResponse actionGet = adminClient.indices().prepareFlush().setForce(true).setFull(true).execute().actionGet(); if (ignoreNotAllowed) { for (ShardOperationFailedException failure : actionGet.getShardFailures()) { // assertThat("unexpected flush failure " + failure.reason(), failure.status(), equalTo(RestStatus.SERVICE_UNAVAILABLE)); } } else { // assertNoFailures(actionGet); } return actionGet; }
Example #6
Source File: TransportClient.java From elasticsearch-jest-example with MIT License | 5 votes |
/** * 仅仅只删除索引 * @param index * @param type * @param id */ private static void deleteIndex(String index, String type, String id){ Client client = createTransportClient(); DeleteResponse response = client.prepareDelete(index, type, id) .execute() .actionGet(); boolean isFound = response.isFound(); System.out.println("索引是否 存在:"+isFound); // 发现doc已删除则返回true System.out.println("****************index ***********************"); // Index name String _index = response.getIndex(); // Type name String _type = response.getType(); // Document ID (generated or not) String _id = response.getId(); // Version (if it's the first time you index this document, you will get: 1) long _version = response.getVersion(); System.out.println(_index+","+_type+","+_id+","+_version); //优化索引 OptimizeRequest optimizeRequest = new OptimizeRequest(index); OptimizeResponse optimizeResponse = client.admin().indices().optimize(optimizeRequest).actionGet(); System.out.println(optimizeResponse.getTotalShards()+","+optimizeResponse.getSuccessfulShards()+","+optimizeResponse.getFailedShards()); //刷新索引 FlushRequest flushRequest = new FlushRequest(index); flushRequest.force(true); FlushResponse flushResponse = client.admin().indices().flush(flushRequest).actionGet(); System.out.println(flushResponse.getTotalShards()+","+flushResponse.getSuccessfulShards()+","+flushResponse.getFailedShards()); }
Example #7
Source File: ElasticsearchClusterRunner.java From elasticsearch-cluster-runner with Apache License 2.0 | 5 votes |
public FlushResponse flush(final BuilderCallback<FlushRequestBuilder> builder) { waitForRelocation(); final FlushResponse actionGet = builder.apply(client().admin().indices().prepareFlush()).execute().actionGet(); final ShardOperationFailedException[] shardFailures = actionGet.getShardFailures(); if (shardFailures != null && shardFailures.length != 0) { final StringBuilder buf = new StringBuilder(100); for (final ShardOperationFailedException shardFailure : shardFailures) { buf.append(shardFailure.toString()).append('\n'); } onFailure(buf.toString(), actionGet); } return actionGet; }
Example #8
Source File: EsTranslogHandler.java From io with Apache License 2.0 | 5 votes |
@Override FlushResponse doProcess() { FlushResponse res = esClient.flushTransLog(indexName).actionGet(); int failedShards = res.getFailedShards(); // 例外が発生しないがflushのエラーになった場合は、他のリクエストでのflushにまかせるため、ここではエラーとはしていない。 if (failedShards > 0) { String message = String.format("ES translog flush failed. index[%s] failedShardsCount[%d]", indexName, failedShards); log.info(message); } return res; }
Example #9
Source File: EsTranslogHandler.java From io with Apache License 2.0 | 5 votes |
@Override FlushResponse onParticularError(ElasticsearchException e) { String message = String.format("ES translog flush failed. index[%s] cause[%s]", indexName, e.toString()); log.debug(message); return null; }
Example #10
Source File: EsTranslogHandler.java From io with Apache License 2.0 | 5 votes |
@Override FlushResponse doProcess() { FlushResponse res = esClient.flushTransLog(indexName).actionGet(); int failedShards = res.getFailedShards(); // 例外が発生しないがflushのエラーになった場合は、他のリクエストでのflushにまかせるため、ここではエラーとはしていない。 if (failedShards > 0) { String message = String.format("ES translog flush failed. index[%s] failedShardsCount[%d]", indexName, failedShards); log.info(message); } return res; }
Example #11
Source File: InternalEsClient.java From io with Apache License 2.0 | 4 votes |
/** * flushを行う. * @param index flush対象のindex名 * @return 非同期応答 */ public ActionFuture<FlushResponse> flushTransLog(String index) { ActionFuture<FlushResponse> ret = esTransportClient.admin().indices().flush(new FlushRequest(index)); this.fireEvent(Event.afterRequest, index, null, null, null, "Flush"); return ret; }
Example #12
Source File: AbstractClient.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override public ActionFuture<FlushResponse> flush(final FlushRequest request) { return execute(FlushAction.INSTANCE, request); }
Example #13
Source File: ElasticsearchClusterRunner.java From elasticsearch-cluster-runner with Apache License 2.0 | 4 votes |
public FlushResponse flush() { return flush(true); }
Example #14
Source File: ElasticsearchClusterRunner.java From elasticsearch-cluster-runner with Apache License 2.0 | 4 votes |
public FlushResponse flush(final boolean force) { return flush(builder -> builder.setWaitIfOngoing(true).setForce(force)); }
Example #15
Source File: InternalEsClient.java From io with Apache License 2.0 | 4 votes |
/** * flushを行う. * @param index flush対象のindex名 * @return 非同期応答 */ public ActionFuture<FlushResponse> flushTransLog(String index) { ActionFuture<FlushResponse> ret = esTransportClient.admin().indices().flush(new FlushRequest(index)); this.fireEvent(Event.afterRequest, index, null, null, null, "Flush"); return ret; }
Example #16
Source File: AbstractElasticSearchTest.java From camunda-bpm-elasticsearch with Apache License 2.0 | 4 votes |
/** * Flushes all indices in the cluster */ protected final FlushResponse flush() { return flush(true); }
Example #17
Source File: FlushRequestBuilder.java From elasticshell with Apache License 2.0 | 4 votes |
@Override protected ActionFuture<FlushResponse> doExecute(FlushRequest request) { return client.admin().indices().flush(request); }
Example #18
Source File: AbstractClient.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override public void flush(final FlushRequest request, final ActionListener<FlushResponse> listener) { execute(FlushAction.INSTANCE, request, listener); }
Example #19
Source File: IndicesAdminClient.java From Elasticsearch with Apache License 2.0 | 2 votes |
/** * Explicitly flush one or more indices (releasing memory from the node). * * @param request The flush request * @param listener A listener to be notified with a result * @see org.elasticsearch.client.Requests#flushRequest(String...) */ void flush(FlushRequest request, ActionListener <FlushResponse> listener);
Example #20
Source File: IndicesAdminClient.java From Elasticsearch with Apache License 2.0 | 2 votes |
/** * Explicitly flush one or more indices (releasing memory from the node). * * @param request The flush request * @return A result future * @see org.elasticsearch.client.Requests#flushRequest(String...) */ ActionFuture<FlushResponse> flush(FlushRequest request);