本文整理汇总了Java中org.elasticsearch.action.admin.indices.refresh.RefreshResponse类的典型用法代码示例。如果您正苦于以下问题:Java RefreshResponse类的具体用法?Java RefreshResponse怎么用?Java RefreshResponse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RefreshResponse类属于org.elasticsearch.action.admin.indices.refresh包,在下文中一共展示了RefreshResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: refreshAndFinish
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse; //导入依赖的package包/类
/**
* Start terminating a request that finished non-catastrophically by refreshing the modified indices and then proceeding to
* {@link #finishHim(Exception, List, List, boolean)}.
*/
void refreshAndFinish(List<Failure> indexingFailures, List<SearchFailure> searchFailures, boolean timedOut) {
if (task.isCancelled() || false == mainRequest.isRefresh() || destinationIndices.isEmpty()) {
finishHim(null, indexingFailures, searchFailures, timedOut);
return;
}
RefreshRequest refresh = new RefreshRequest();
refresh.indices(destinationIndices.toArray(new String[destinationIndices.size()]));
client.admin().indices().refresh(refresh, new ActionListener<RefreshResponse>() {
@Override
public void onResponse(RefreshResponse response) {
finishHim(null, indexingFailures, searchFailures, timedOut);
}
@Override
public void onFailure(Exception e) {
finishHim(e);
}
});
}
示例2: testRefreshIndex
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse; //导入依赖的package包/类
@Test
public void testRefreshIndex() {
// Test data
final String indexName = "Index_Name";
final AdminClient adminClient = createMock(AdminClient.class);
final IndicesAdminClient indicesAdminClient = createMock(IndicesAdminClient.class);
final RefreshRequestBuilder refreshRequestBuilder = createMock(RefreshRequestBuilder.class);
final PutMappingResponse putMappingResponse = createMock(PutMappingResponse.class);
// Reset
resetAll();
// Expectations
expect(esClient.admin()).andReturn(adminClient);
expect(adminClient.indices()).andReturn(indicesAdminClient);
expect(indicesAdminClient.prepareRefresh(indexName)).andReturn(refreshRequestBuilder);
expect(refreshRequestBuilder.get()).andReturn(createMock(RefreshResponse.class));
// Replay
replayAll();
// Run test scenario
elasticsearchClientWrapper.refreshIndex(indexName);
// Verify
verifyAll();
}
示例3: postIndexAsyncActions
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse; //导入依赖的package包/类
/**
* Maybe refresh, optimize, or flush then always make sure there aren't too many in flight async operations.
*/
private void postIndexAsyncActions(final String[] indices, final List<CountDownLatch> inFlightAsyncOperations, final boolean maybeFlush)
throws InterruptedException {
if (rarely()) {
if (rarely()) {
client().admin().indices().prepareRefresh(indices).setIndicesOptions(IndicesOptions.lenientExpandOpen())
.execute(new LatchedActionListener<RefreshResponse>(newLatch(inFlightAsyncOperations)));
} else if (maybeFlush && rarely()) {
client().admin().indices().prepareFlush(indices).setIndicesOptions(IndicesOptions.lenientExpandOpen())
.execute(new LatchedActionListener<FlushResponse>(newLatch(inFlightAsyncOperations)));
} else if (rarely()) {
client().admin().indices().prepareOptimize(indices).setIndicesOptions(IndicesOptions.lenientExpandOpen())
.setMaxNumSegments(between(1, 10)).setFlush(maybeFlush && randomBoolean())
.execute(new LatchedActionListener<OptimizeResponse>(newLatch(inFlightAsyncOperations)));
}
}
while (inFlightAsyncOperations.size() > MAX_IN_FLIGHT_ASYNC_INDEXES) {
final int waitFor = between(0, inFlightAsyncOperations.size() - 1);
inFlightAsyncOperations.remove(waitFor).await();
}
}
示例4: refresh
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse; //导入依赖的package包/类
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;
}
示例5: refresh
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse; //导入依赖的package包/类
/**
* 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;
}
示例6: prepareRequest
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse; //导入依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
RefreshRequest refreshRequest = new RefreshRequest(Strings.splitStringByCommaToArray(request.param("index")));
refreshRequest.indicesOptions(IndicesOptions.fromRequest(request, refreshRequest.indicesOptions()));
return channel -> 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(response.getStatus(), builder);
}
});
}
示例7: refreshAndAssert
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse; //导入依赖的package包/类
private void refreshAndAssert() throws Exception {
assertBusy(new Runnable() {
@Override
public void run() {
RefreshResponse actionGet = client().admin().indices().prepareRefresh().get();
assertAllSuccessful(actionGet);
}
}, 5, TimeUnit.MINUTES);
}
示例8: visitRefreshTableStatement
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse; //导入依赖的package包/类
@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;
}
示例9: handleRequest
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse; //导入依赖的package包/类
@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);
}
});
}
示例10: refreshKibanaUser
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse; //导入依赖的package包/类
private void refreshKibanaUser(String kibanaIndex, Client esClient) {
RefreshRequest request = new RefreshRequest().indices(kibanaIndex);
request.putHeader(ConfigConstants.SG_CONF_REQUEST_HEADER, "true");
RefreshResponse response = esClient.admin().indices().refresh(request).actionGet();
LOGGER.debug("Refreshed '{}' successfully on {} of {} shards", kibanaIndex, response.getSuccessfulShards(),
response.getTotalShards());
}
示例11: refresh
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse; //导入依赖的package包/类
/**
* Waits for relocations and refreshes all indices in the cluster.
*
* @see #waitForRelocation()
*/
protected final RefreshResponse refresh() {
waitForRelocation();
// TODO RANDOMIZE with flush?
final RefreshResponse actionGet = client().admin().indices().prepareRefresh().execute().actionGet();
assertNoFailures(actionGet);
return actionGet;
}
示例12: refreshElasticsearch
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse; //导入依赖的package包/类
private void refreshElasticsearch(String index) {
try {
RefreshResponse refreshResponse = elasticsearch.admin().indices().prepareRefresh(index).get();
logger.debug("failed: {}", refreshResponse.getFailedShards());
logger.debug("succeeded: {}", refreshResponse.getSuccessfulShards());
} catch (Exception e) {
logger.debug(e.getMessage());
}
}
示例13: refreshAsync
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse; //导入依赖的package包/类
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);
}
示例14: refresh
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse; //导入依赖的package包/类
/**
* 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;
}
示例15: toXContent
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse; //导入依赖的package包/类
@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;
}