org.elasticsearch.action.admin.indices.refresh.RefreshResponse Java Examples

The following examples show how to use org.elasticsearch.action.admin.indices.refresh.RefreshResponse. 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 vote down vote up
public void refresh(final String... indices) {
    client.admin().indices().prepareRefresh(indices).execute(new ActionListener<RefreshResponse>() {
        @Override
        public void onResponse(final RefreshResponse response) {
            if (logger.isDebugEnabled()) {
                logger.debug(() -> "Refreshed " + stream(indices).get(stream -> stream.collect(Collectors.joining(", "))));
            }
        }

        @Override
        public void onFailure(final Exception e) {
            logger.error(() -> "Failed to refresh " + stream(indices).get(stream -> stream.collect(Collectors.joining(", "))), e);
        }
    });

}
 
Example #2
Source File: ElasticsearchClusterRunner.java    From elasticsearch-cluster-runner with Apache License 2.0 5 votes vote down vote up
public RefreshResponse refresh(final BuilderCallback<RefreshRequestBuilder> builder) {
    waitForRelocation();
    final RefreshResponse actionGet = builder.apply(client().admin().indices().prepareRefresh()).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 #3
Source File: ESIntegTestCase.java    From crate with Apache License 2.0 5 votes vote down vote up
/**
 * Waits for relocations and refreshes all indices in the cluster.
 *
 * @see #waitForRelocation()
 */
protected final RefreshResponse refresh(String... indices) {
    waitForRelocation();
    // TODO RANDOMIZE with flush?
    RefreshResponse actionGet = client().admin().indices().prepareRefresh(indices).execute().actionGet();
    assertNoFailures(actionGet);
    return actionGet;
}
 
Example #4
Source File: RefreshRequestBuilder.java    From elasticshell with Apache License 2.0 5 votes vote down vote up
@Override
protected XContentBuilder toXContent(RefreshRequest request, RefreshResponse 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 vote down vote up
/**
   * Waits for relocations and refreshes all indices in the cluster.
   *
   * @see #waitForRelocation()
   */
  protected final RefreshResponse refresh() {
    waitForRelocation();
    // TODO RANDOMIZE with flush?
    RefreshResponse actionGet = adminClient.indices().prepareRefresh().execute().actionGet();
//    assertNoFailures(actionGet);
    return actionGet;
  }
 
Example #6
Source File: EsEntityIndexImpl.java    From usergrid with Apache License 2.0 5 votes vote down vote up
public Observable<IndexRefreshCommandInfo> refreshAsync() {

        refreshIndexMeter.mark();
        final long start = System.currentTimeMillis();

        String[] indexes = getIndexes();
        if (indexes.length == 0) {
            if (logger.isTraceEnabled()) {
                logger.trace("Not refreshing indexes. none found");
            }
        }
        //Added For Graphite Metrics
        RefreshResponse response =
            esProvider.getClient().admin().indices().prepareRefresh(indexes).execute().actionGet();
        int failedShards = response.getFailedShards();
        int successfulShards = response.getSuccessfulShards();
        ShardOperationFailedException[] sfes = response.getShardFailures();
        if (sfes != null) {
            for (ShardOperationFailedException sfe : sfes) {
                logger.error("Failed to refresh index:{} reason:{}", sfe.index(), sfe.reason());
            }
        }
        if (logger.isTraceEnabled()) {
            logger.trace("Refreshed indexes: {},success:{} failed:{} ", StringUtils.join(indexes, ", "),
                successfulShards, failedShards);
        }

        IndexRefreshCommandInfo refreshResults = new IndexRefreshCommandInfo(failedShards == 0,
            System.currentTimeMillis() - start);


        return ObservableTimer.time(Observable.just(refreshResults), refreshTimer);
    }
 
Example #7
Source File: DDLStatementDispatcher.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public ListenableFuture<Long> visitRefreshTableStatement(RefreshTableAnalyzedStatement analysis, SingleJobTask jobId) {
    if (analysis.indexNames().isEmpty()) {
        return Futures.immediateFuture(null);
    }
    RefreshRequest request = new RefreshRequest(analysis.indexNames().toArray(
            new String[analysis.indexNames().size()]));
    request.indicesOptions(IndicesOptions.lenientExpandOpen());

    final SettableFuture<Long> future = SettableFuture.create();
    ActionListener<RefreshResponse> listener = ActionListeners.wrap(future, Functions.<Long>constant(new Long(analysis.indexNames().size())));
    transportActionProvider.transportRefreshAction().execute(request, listener);
    return future;
}
 
Example #8
Source File: DcRefreshResponseImpl.java    From io with Apache License 2.0 5 votes vote down vote up
/**
 * .
 * @param response
 *            .
 * @return .
 */
public static DcRefreshResponse getInstance(RefreshResponse response) {
    if (response == null) {
        return null;
    }
    return new DcRefreshResponseImpl(response);
}
 
Example #9
Source File: DcRefreshResponseImpl.java    From io with Apache License 2.0 5 votes vote down vote up
/**
 * .
 * @param response
 *            .
 * @return .
 */
public static DcRefreshResponse getInstance(RefreshResponse response) {
    if (response == null) {
        return null;
    }
    return new DcRefreshResponseImpl(response);
}
 
Example #10
Source File: PluginClient.java    From openshift-elasticsearch-plugin with Apache License 2.0 5 votes vote down vote up
public RefreshResponse refreshIndices(String... indices) {
    return execute(new Callable<RefreshResponse>() {
        @Override
        public RefreshResponse call() throws Exception {
            RefreshRequestBuilder builder = client.admin().indices().prepareRefresh(indices);
            RefreshResponse response = builder.get();
            LOGGER.debug("Refreshed '{}' successfully on {} of {} shards", indices, response.getSuccessfulShards(),
                    response.getTotalShards());
            return response;
        }
    });
}
 
Example #11
Source File: RestRefreshAction.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
    RefreshRequest refreshRequest = new RefreshRequest(Strings.splitStringByCommaToArray(request.param("index")));
    refreshRequest.indicesOptions(IndicesOptions.fromRequest(request, refreshRequest.indicesOptions()));
    client.admin().indices().refresh(refreshRequest, new RestBuilderListener<RefreshResponse>(channel) {
        @Override
        public RestResponse buildResponse(RefreshResponse response, XContentBuilder builder) throws Exception {
            builder.startObject();
            buildBroadcastShardsHeader(builder, request, response);
            builder.endObject();
            return new BytesRestResponse(OK, builder);
        }
    });
}
 
Example #12
Source File: AbstractClient.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public ActionFuture<RefreshResponse> refresh(final RefreshRequest request) {
    return execute(RefreshAction.INSTANCE, request);
}
 
Example #13
Source File: AbstractClient.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public void refresh(final RefreshRequest request, final ActionListener<RefreshResponse> listener) {
    execute(RefreshAction.INSTANCE, request, listener);
}
 
Example #14
Source File: AbstractClient.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public ActionFuture<RefreshResponse> refresh(final RefreshRequest request) {
    return execute(RefreshAction.INSTANCE, request);
}
 
Example #15
Source File: AbstractClient.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public void refresh(final RefreshRequest request, final ActionListener<RefreshResponse> listener) {
    execute(RefreshAction.INSTANCE, request, listener);
}
 
Example #16
Source File: RefreshRequestBuilder.java    From elasticshell with Apache License 2.0 4 votes vote down vote up
@Override
protected ActionFuture<RefreshResponse> doExecute(RefreshRequest request) {
    return client.admin().indices().refresh(request);
}
 
Example #17
Source File: EsAbstractBehavior.java    From fess with Apache License 2.0 4 votes vote down vote up
public RefreshResponse refresh() {
    return client.admin().indices().prepareRefresh(asEsIndex()).execute().actionGet(refreshTimeout);
}
 
Example #18
Source File: EsAbstractBehavior.java    From fess with Apache License 2.0 4 votes vote down vote up
public RefreshResponse refresh() {
    return client.admin().indices().prepareRefresh(asEsIndex()).execute().actionGet(refreshTimeout);
}
 
Example #19
Source File: EsAbstractBehavior.java    From fess with Apache License 2.0 4 votes vote down vote up
public RefreshResponse refresh() {
    return client.admin().indices().prepareRefresh(asEsIndex()).execute().actionGet(refreshTimeout);
}
 
Example #20
Source File: BaseElasticSearchIndexBuilder.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
 * refresh the index from the current stored state {@inheritDoc}
 */
public void refreshIndex() {
    RefreshResponse response = client.admin().indices().refresh(new RefreshRequest(indexName)).actionGet();
}
 
Example #21
Source File: ElasticsearchClusterRunner.java    From elasticsearch-cluster-runner with Apache License 2.0 4 votes vote down vote up
public RefreshResponse refresh() {
    return refresh(builder -> builder);
}
 
Example #22
Source File: InternalEsClient.java    From io with Apache License 2.0 4 votes vote down vote up
/**
 * 引数で指定されたインデックスに対してrefreshする.
 * @param index インデックス名
 * @return レスポンス
 */
public DcRefreshResponse refresh(String index) {
    RefreshResponse response = esTransportClient.admin().indices()
            .refresh(new RefreshRequest(index)).actionGet();
    return DcRefreshResponseImpl.getInstance(response);
}
 
Example #23
Source File: BaseElasticSearchIndexBuilder.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
 * refresh the index from the current stored state {@inheritDoc}
 */
public void refreshIndex() {
    RefreshResponse response = client.admin().indices().refresh(new RefreshRequest(indexName)).actionGet();
}
 
Example #24
Source File: InternalEsClient.java    From io with Apache License 2.0 4 votes vote down vote up
/**
 * 引数で指定されたインデックスに対してrefreshする.
 * @param index インデックス名
 * @return レスポンス
 */
public DcRefreshResponse refresh(String index) {
    RefreshResponse response = esTransportClient.admin().indices()
            .refresh(new RefreshRequest(index)).actionGet();
    return DcRefreshResponseImpl.getInstance(response);
}
 
Example #25
Source File: IndicesAdminClient.java    From Elasticsearch with Apache License 2.0 2 votes vote down vote up
/**
 * Explicitly refresh one or more indices (making the content indexed since the last refresh searchable).
 *
 * @param request  The refresh request
 * @param listener A listener to be notified with a result
 * @see org.elasticsearch.client.Requests#refreshRequest(String...)
 */
void refresh(RefreshRequest request, ActionListener<RefreshResponse> listener);
 
Example #26
Source File: IndicesAdminClient.java    From Elasticsearch with Apache License 2.0 2 votes vote down vote up
/**
 * Explicitly refresh one or more indices (making the content indexed since the last refresh searchable).
 *
 * @param request The refresh request
 * @return The result future
 * @see org.elasticsearch.client.Requests#refreshRequest(String...)
 */
ActionFuture<RefreshResponse> refresh(RefreshRequest request);
 
Example #27
Source File: DcRefreshResponseImpl.java    From io with Apache License 2.0 2 votes vote down vote up
/**
 * RefreshResponseを指定してインスタンスを生成する.
 * @param response
 *            ESからのレスポンスオブジェクト
 */
private DcRefreshResponseImpl(RefreshResponse response) {
    super(response);
    this.refreshResponse = response;
}
 
Example #28
Source File: IndicesAdminClient.java    From crate with Apache License 2.0 2 votes vote down vote up
/**
 * Explicitly refresh one or more indices (making the content indexed since the last refresh searchable).
 *
 * @param request The refresh request
 * @return The result future
 * @see org.elasticsearch.client.Requests#refreshRequest(String...)
 */
ActionFuture<RefreshResponse> refresh(RefreshRequest request);
 
Example #29
Source File: IndicesAdminClient.java    From crate with Apache License 2.0 2 votes vote down vote up
/**
 * Explicitly refresh one or more indices (making the content indexed since the last refresh searchable).
 *
 * @param request  The refresh request
 * @param listener A listener to be notified with a result
 * @see org.elasticsearch.client.Requests#refreshRequest(String...)
 */
void refresh(RefreshRequest request, ActionListener<RefreshResponse> listener);
 
Example #30
Source File: DcRefreshResponseImpl.java    From io with Apache License 2.0 2 votes vote down vote up
/**
 * RefreshResponseを指定してインスタンスを生成する.
 * @param response
 *            ESからのレスポンスオブジェクト
 */
private DcRefreshResponseImpl(RefreshResponse response) {
    super(response);
    this.refreshResponse = response;
}