Java 类org.elasticsearch.action.search.ClearScrollResponse 实例源码

项目:elasticsearch_my    文件:ClientScrollableHitSource.java   
@Override
public void clearScroll(String scrollId, Runnable onCompletion) {
    ClearScrollRequest clearScrollRequest = new ClearScrollRequest();
    clearScrollRequest.addScrollId(scrollId);
    /*
     * Unwrap the client so we don't set our task as the parent. If we *did* set our ID then the clear scroll would be cancelled as
     * if this task is cancelled. But we want to clear the scroll regardless of whether or not the main request was cancelled.
     */
    client.unwrap().clearScroll(clearScrollRequest, new ActionListener<ClearScrollResponse>() {
        @Override
        public void onResponse(ClearScrollResponse response) {
            logger.debug("Freed [{}] contexts", response.getNumFreed());
            onCompletion.run();
        }

        @Override
        public void onFailure(Exception e) {
            logger.warn((Supplier<?>) () -> new ParameterizedMessage("Failed to clear scroll [{}]", scrollId), e);
            onCompletion.run();
        }
    });
}
项目:Elasticsearch    文件:RestClearScrollAction.java   
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
    String scrollIds = request.param("scroll_id");
    ClearScrollRequest clearRequest = new ClearScrollRequest();
    clearRequest.setScrollIds(Arrays.asList(splitScrollIds(scrollIds)));
    if (RestActions.hasBodyContent(request)) {
        XContentType type = RestActions.guessBodyContentType(request);
       if (type == null) {
           scrollIds = RestActions.getRestContent(request).toUtf8();
           clearRequest.setScrollIds(Arrays.asList(splitScrollIds(scrollIds)));
       } else {
           // NOTE: if rest request with xcontent body has request parameters, these parameters does not override xcontent value
           clearRequest.setScrollIds(null);
           buildFromContent(RestActions.getRestContent(request), clearRequest);
       }
    }

    client.clearScroll(clearRequest, new RestStatusToXContentListener<ClearScrollResponse>(channel));
}
项目:elasticsearch-reindexing    文件:ReindexingService.java   
public void interrupt() {
    interrupted.set(true);
    if (scrollId != null) {
        client.prepareClearScroll().addScrollId(scrollId)
                .execute(new ActionListener<ClearScrollResponse>() {

                    @Override
                    public void onResponse(ClearScrollResponse response) {
                        // nothing
                    }

                    @Override
                    public void onFailure(Throwable e) {
                        if (logger.isDebugEnabled()) {
                            logger.debug(
                                    "Failed to stop reindexing for "
                                            + toIndex + ".", e);
                        }
                    }
                });
    }
}
项目:elasticsearch_my    文件:SearchScrollIT.java   
public void testClearNonExistentScrollId() throws Exception {
    createIndex("idx");
    ClearScrollResponse response = client().prepareClearScroll()
            .addScrollId("DnF1ZXJ5VGhlbkZldGNoAwAAAAAAAAABFnRtLWMyRzBqUUQyNk1uM0xDTjJ4S0EAAAAAAAAAARYzNkhxbWFTYVFVNmgxTGQyYUZVYV9nAAAAAAAAAAEWdVcxNWZmRGZSVFN2V0xMUGF2NGx1Zw==")
            .get();
    // Whether we actually clear a scroll, we can't know, since that information isn't serialized in the
    // free search context response, which is returned from each node we want to clear a particular scroll.
    assertThat(response.isSucceeded(), is(true));
    assertThat(response.getNumFreed(), equalTo(0));
    assertThat(response.status(), equalTo(RestStatus.NOT_FOUND));
    assertToXContentResponse(response, true, response.getNumFreed());
}
项目:elasticsearch_my    文件:SearchScrollIT.java   
public void testThatNonExistingScrollIdReturnsCorrectException() throws Exception {
    client().prepareIndex("index", "type", "1").setSource("field", "value").execute().get();
    refresh();

    SearchResponse searchResponse = client().prepareSearch("index").setSize(1).setScroll("1m").get();
    assertThat(searchResponse.getScrollId(), is(notNullValue()));

    ClearScrollResponse clearScrollResponse = client().prepareClearScroll().addScrollId(searchResponse.getScrollId()).get();
    assertThat(clearScrollResponse.isSucceeded(), is(true));

    assertThrows(internalCluster().transportClient().prepareSearchScroll(searchResponse.getScrollId()), RestStatus.NOT_FOUND);
}
项目:elasticsearch_my    文件:SearchScrollIT.java   
private void assertToXContentResponse(ClearScrollResponse response, boolean succeed, int numFreed) throws IOException {
    XContentBuilder builder = XContentFactory.jsonBuilder();
    response.toXContent(builder, ToXContent.EMPTY_PARAMS);
    Map<String, Object> map = XContentHelper.convertToMap(builder.bytes(), false, builder.contentType()).v2();
    assertThat(map.get("succeeded"), is(succeed));
    assertThat(map.get("num_freed"), equalTo(numFreed));
}
项目:nlptab    文件:FsDataSource.java   
@Override
public void close() throws IOException {
    if (response != null) {
        ClearScrollResponse clearScrollResponse = client.prepareClearScroll()
                .addScrollId(response.getScrollId())
                .execute()
                .actionGet();

        if (!clearScrollResponse.isSucceeded()) {
            LOGGER.debug("Failed to clear scroll: {}", clearScrollResponse.status());
        }
    }
}
项目:elasticsearch_my    文件:ESIntegTestCase.java   
/**
 * Clears the given scroll Ids
 */
public void clearScroll(String... scrollIds) {
    ClearScrollResponse clearResponse = client().prepareClearScroll()
        .setScrollIds(Arrays.asList(scrollIds)).get();
    assertThat(clearResponse.isSucceeded(), equalTo(true));
}
项目:elasticsearch_my    文件:AbstractClient.java   
@Override
public void clearScroll(ClearScrollRequest request, ActionListener<ClearScrollResponse> listener) {
    execute(ClearScrollAction.INSTANCE, request, listener);
}
项目:elasticsearch_my    文件:AbstractClient.java   
@Override
public ActionFuture<ClearScrollResponse> clearScroll(ClearScrollRequest request) {
    return execute(ClearScrollAction.INSTANCE, request);
}
项目:elasticsearch-java-client    文件:DummyClient.java   
@Override
public void clearScroll(ClearScrollRequest request,
        ActionListener<ClearScrollResponse> listener) {
    // TODO Auto-generated method stub

}
项目:elasticsearch-java-client    文件:DummyClient.java   
@Override
public ActionFuture<ClearScrollResponse> clearScroll(ClearScrollRequest request) {
    // TODO Auto-generated method stub
    return null;
}
项目:elasticsearch-sample-plugin-audit    文件:ElasticsearchIntegrationTest.java   
/**
 * Clears the given scroll Ids
 */
public void clearScroll(final String... scrollIds) {
    final ClearScrollResponse clearResponse = client().prepareClearScroll().setScrollIds(Arrays.asList(scrollIds)).get();
    assertThat(clearResponse.isSucceeded(), equalTo(true));
}
项目:elasticsearch_my    文件:Client.java   
/**
 * Clears the search contexts associated with specified scroll ids.
 */
ActionFuture<ClearScrollResponse> clearScroll(ClearScrollRequest request);
项目:elasticsearch_my    文件:Client.java   
/**
 * Clears the search contexts associated with specified scroll ids.
 */
void clearScroll(ClearScrollRequest request, ActionListener<ClearScrollResponse> listener);