当前位置: 首页>>代码示例>>Java>>正文


Java FlushResponse类代码示例

本文整理汇总了Java中org.elasticsearch.action.admin.indices.flush.FlushResponse的典型用法代码示例。如果您正苦于以下问题:Java FlushResponse类的具体用法?Java FlushResponse怎么用?Java FlushResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FlushResponse类属于org.elasticsearch.action.admin.indices.flush包,在下文中一共展示了FlushResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleRequest

import org.elasticsearch.action.admin.indices.flush.FlushResponse; //导入依赖的package包/类
@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);
        }
    });
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:17,代码来源:RestFlushAction.java

示例2: prepareRequest

import org.elasticsearch.action.admin.indices.flush.FlushResponse; //导入依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    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()));
    return channel -> 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);
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:RestFlushAction.java

示例3: postIndexAsyncActions

import org.elasticsearch.action.admin.indices.flush.FlushResponse; //导入依赖的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();
    }
}
 
开发者ID:salyh,项目名称:elasticsearch-sample-plugin-audit,代码行数:24,代码来源:ElasticsearchIntegrationTest.java

示例4: flush

import org.elasticsearch.action.admin.indices.flush.FlushResponse; //导入依赖的package包/类
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;
}
 
开发者ID:codelibs,项目名称:elasticsearch-cluster-runner,代码行数:18,代码来源:ElasticsearchClusterRunner.java

示例5: flush

import org.elasticsearch.action.admin.indices.flush.FlushResponse; //导入依赖的package包/类
/**
 * Flush some or all indices in the cluster.
 */
protected final FlushResponse flush(String... indices) {
    waitForRelocation();
    FlushResponse actionGet = client().admin().indices().prepareFlush(indices).execute().actionGet();
    for (ShardOperationFailedException failure : actionGet.getShardFailures()) {
        assertThat("unexpected flush failure " + failure.reason(), failure.status(), equalTo(RestStatus.SERVICE_UNAVAILABLE));
    }
    return actionGet;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:ESIntegTestCase.java

示例6: testWaitIfOngoing

import org.elasticsearch.action.admin.indices.flush.FlushResponse; //导入依赖的package包/类
public void testWaitIfOngoing() throws InterruptedException {
    createIndex("test");
    ensureGreen("test");
    final int numIters = scaledRandomIntBetween(10, 30);
    for (int i = 0; i < numIters; i++) {
        for (int j = 0; j < 10; j++) {
            client().prepareIndex("test", "test").setSource("{}", XContentType.JSON).get();
        }
        final CountDownLatch latch = new CountDownLatch(10);
        final CopyOnWriteArrayList<Throwable> errors = new CopyOnWriteArrayList<>();
        for (int j = 0; j < 10; j++) {
            client().admin().indices().prepareFlush("test").execute(new ActionListener<FlushResponse>() {
                @Override
                public void onResponse(FlushResponse flushResponse) {
                    try {
                        // don't use assertAllSuccessful it uses a randomized context that belongs to a different thread
                        assertThat("Unexpected ShardFailures: " + Arrays.toString(flushResponse.getShardFailures()), flushResponse.getFailedShards(), equalTo(0));
                        latch.countDown();
                    } catch (Exception ex) {
                        onFailure(ex);
                    }

                }

                @Override
                public void onFailure(Exception e) {
                    errors.add(e);
                    latch.countDown();
                }
            });
        }
        latch.await();
        assertThat(errors, emptyIterable());
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:36,代码来源:FlushIT.java

示例7: assertImmediateResponse

import org.elasticsearch.action.admin.indices.flush.FlushResponse; //导入依赖的package包/类
public FlushResponse assertImmediateResponse(String index, TransportFlushAction flushAction) throws InterruptedException, ExecutionException {
    Date beginDate = new Date();
    FlushResponse flushResponse = flushAction.execute(new FlushRequest(index)).get();
    Date endDate = new Date();
    long maxTime = 500;
    assertThat("this should not take longer than " + maxTime + " ms. The request hangs somewhere", endDate.getTime() - beginDate.getTime(), lessThanOrEqualTo(maxTime));
    return flushResponse;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:BroadcastReplicationTests.java

示例8: flush

import org.elasticsearch.action.admin.indices.flush.FlushResponse; //导入依赖的package包/类
/**
 * Flush some or all indices in the cluster.
 */
protected final FlushResponse flush(final String... indices) {
    waitForRelocation();
    final FlushResponse actionGet = client().admin().indices().prepareFlush(indices).setWaitIfOngoing(true).execute().actionGet();
    for (final ShardOperationFailedException failure : actionGet.getShardFailures()) {
        assertThat("unexpected flush failure " + failure.reason(), failure.status(), equalTo(RestStatus.SERVICE_UNAVAILABLE));
    }
    return actionGet;
}
 
开发者ID:salyh,项目名称:elasticsearch-sample-plugin-audit,代码行数:12,代码来源:ElasticsearchIntegrationTest.java

示例9: deleteIndex

import org.elasticsearch.action.admin.indices.flush.FlushResponse; //导入依赖的package包/类
/**
 * 仅仅只删除索引
 * @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());
	
}
 
开发者ID:ameizi,项目名称:elasticsearch-jest-example,代码行数:37,代码来源:TransportClient.java

示例10: flush

import org.elasticsearch.action.admin.indices.flush.FlushResponse; //导入依赖的package包/类
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;
  }
 
开发者ID:camunda,项目名称:camunda-bpm-elasticsearch,代码行数:13,代码来源:AbstractElasticSearchTest.java

示例11: toXContent

import org.elasticsearch.action.admin.indices.flush.FlushResponse; //导入依赖的package包/类
@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;
}
 
开发者ID:javanna,项目名称:elasticshell,代码行数:9,代码来源:FlushRequestBuilder.java

示例12: flush

import org.elasticsearch.action.admin.indices.flush.FlushResponse; //导入依赖的package包/类
@Override
public ActionFuture<FlushResponse> flush(final FlushRequest request) {
    return execute(FlushAction.INSTANCE, request);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AbstractClient.java

示例13: testSimpleRecovery

import org.elasticsearch.action.admin.indices.flush.FlushResponse; //导入依赖的package包/类
public void testSimpleRecovery() throws Exception {
    assertAcked(prepareCreate("test", 1).execute().actionGet());

    NumShards numShards = getNumShards("test");

    client().index(indexRequest("test").type("type1").id("1").source(source("1", "test"), XContentType.JSON)).actionGet();
    FlushResponse flushResponse = client().admin().indices().flush(flushRequest("test")).actionGet();
    assertThat(flushResponse.getTotalShards(), equalTo(numShards.totalNumShards));
    assertThat(flushResponse.getSuccessfulShards(), equalTo(numShards.numPrimaries));
    assertThat(flushResponse.getFailedShards(), equalTo(0));
    client().index(indexRequest("test").type("type1").id("2").source(source("2", "test"), XContentType.JSON)).actionGet();
    RefreshResponse refreshResponse = client().admin().indices().refresh(refreshRequest("test")).actionGet();
    assertThat(refreshResponse.getTotalShards(), equalTo(numShards.totalNumShards));
    assertThat(refreshResponse.getSuccessfulShards(), equalTo(numShards.numPrimaries));
    assertThat(refreshResponse.getFailedShards(), equalTo(0));

    allowNodes("test", 2);

    logger.info("Running Cluster Health");
    ensureGreen();

    GetResponse getResult;

    for (int i = 0; i < 5; i++) {
        getResult = client().get(getRequest("test").type("type1").id("1").operationThreaded(false)).actionGet();
        assertThat(getResult.getSourceAsString(), equalTo(source("1", "test")));
        getResult = client().get(getRequest("test").type("type1").id("1").operationThreaded(false)).actionGet();
        assertThat(getResult.getSourceAsString(), equalTo(source("1", "test")));
        getResult = client().get(getRequest("test").type("type1").id("2").operationThreaded(true)).actionGet();
        assertThat(getResult.getSourceAsString(), equalTo(source("2", "test")));
        getResult = client().get(getRequest("test").type("type1").id("2").operationThreaded(true)).actionGet();
        assertThat(getResult.getSourceAsString(), equalTo(source("2", "test")));
    }

    // now start another one so we move some primaries
    allowNodes("test", 3);
    Thread.sleep(200);
    logger.info("Running Cluster Health");
    ensureGreen();

    for (int i = 0; i < 5; i++) {
        getResult = client().get(getRequest("test").type("type1").id("1")).actionGet();
        assertThat(getResult.getSourceAsString(), equalTo(source("1", "test")));
        getResult = client().get(getRequest("test").type("type1").id("1")).actionGet();
        assertThat(getResult.getSourceAsString(), equalTo(source("1", "test")));
        getResult = client().get(getRequest("test").type("type1").id("1")).actionGet();
        assertThat(getResult.getSourceAsString(), equalTo(source("1", "test")));
        getResult = client().get(getRequest("test").type("type1").id("2").operationThreaded(true)).actionGet();
        assertThat(getResult.getSourceAsString(), equalTo(source("2", "test")));
        getResult = client().get(getRequest("test").type("type1").id("2").operationThreaded(true)).actionGet();
        assertThat(getResult.getSourceAsString(), equalTo(source("2", "test")));
        getResult = client().get(getRequest("test").type("type1").id("2").operationThreaded(true)).actionGet();
        assertThat(getResult.getSourceAsString(), equalTo(source("2", "test")));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:56,代码来源:SimpleRecoveryIT.java

示例14: doExecute

import org.elasticsearch.action.admin.indices.flush.FlushResponse; //导入依赖的package包/类
@Override
protected ActionFuture<FlushResponse> doExecute(FlushRequest request) {
    return client.admin().indices().flush(request);
}
 
开发者ID:javanna,项目名称:elasticshell,代码行数:5,代码来源:FlushRequestBuilder.java

示例15: flush

import org.elasticsearch.action.admin.indices.flush.FlushResponse; //导入依赖的package包/类
/**
 * 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);
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:IndicesAdminClient.java


注:本文中的org.elasticsearch.action.admin.indices.flush.FlushResponse类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。