當前位置: 首頁>>代碼示例>>Java>>正文


Java BulkRequest.waitForActiveShards方法代碼示例

本文整理匯總了Java中org.elasticsearch.action.bulk.BulkRequest.waitForActiveShards方法的典型用法代碼示例。如果您正苦於以下問題:Java BulkRequest.waitForActiveShards方法的具體用法?Java BulkRequest.waitForActiveShards怎麽用?Java BulkRequest.waitForActiveShards使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.elasticsearch.action.bulk.BulkRequest的用法示例。


在下文中一共展示了BulkRequest.waitForActiveShards方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: prepareRequest

import org.elasticsearch.action.bulk.BulkRequest; //導入方法依賴的package包/類
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    BulkRequest bulkRequest = Requests.bulkRequest();
    String defaultIndex = request.param("index");
    String defaultType = request.param("type");
    String defaultRouting = request.param("routing");
    String fieldsParam = request.param("fields");
    String defaultPipeline = request.param("pipeline");
    String[] defaultFields = fieldsParam != null ? Strings.commaDelimitedListToStringArray(fieldsParam) : null;

    String waitForActiveShards = request.param("wait_for_active_shards");
    if (waitForActiveShards != null) {
        bulkRequest.waitForActiveShards(ActiveShardCount.parseString(waitForActiveShards));
    }
    bulkRequest.timeout(request.paramAsTime("timeout", BulkShardRequest.DEFAULT_TIMEOUT));
    bulkRequest.setRefreshPolicy(request.param("refresh"));
    bulkRequest.add(request.content(), defaultIndex, defaultType, defaultRouting, defaultFields, null, defaultPipeline, null, true,
        request.getXContentType());

    // short circuit the call to the transport layer
    return channel -> {
        BulkRestBuilderListener listener = new BulkRestBuilderListener(channel, request);
        listener.onResponse(bulkRequest);
    };
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:26,代碼來源:RestNoopBulkAction.java

示例2: prepareRequest

import org.elasticsearch.action.bulk.BulkRequest; //導入方法依賴的package包/類
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    BulkRequest bulkRequest = Requests.bulkRequest();
    String defaultIndex = request.param("index");
    String defaultType = request.param("type");
    String defaultRouting = request.param("routing");
    FetchSourceContext defaultFetchSourceContext = FetchSourceContext.parseFromRestRequest(request);
    String fieldsParam = request.param("fields");
    if (fieldsParam != null) {
        DEPRECATION_LOGGER.deprecated("Deprecated field [fields] used, expected [_source] instead");
    }
    String[] defaultFields = fieldsParam != null ? Strings.commaDelimitedListToStringArray(fieldsParam) : null;
    String defaultPipeline = request.param("pipeline");
    String waitForActiveShards = request.param("wait_for_active_shards");
    if (waitForActiveShards != null) {
        bulkRequest.waitForActiveShards(ActiveShardCount.parseString(waitForActiveShards));
    }
    bulkRequest.timeout(request.paramAsTime("timeout", BulkShardRequest.DEFAULT_TIMEOUT));
    bulkRequest.setRefreshPolicy(request.param("refresh"));
    bulkRequest.add(request.content(), defaultIndex, defaultType, defaultRouting, defaultFields,
        defaultFetchSourceContext, defaultPipeline, null, allowExplicitIndex, request.getXContentType());

    return channel -> client.bulk(bulkRequest, new RestStatusToXContentListener<>(channel));
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:25,代碼來源:RestBulkAction.java

示例3: prepareBulkRequest

import org.elasticsearch.action.bulk.BulkRequest; //導入方法依賴的package包/類
/**
 * Prepare the bulk request. Called on the generic thread pool after some preflight checks have been done one the SearchResponse and any
 * delay has been slept. Uses the generic thread pool because reindex is rare enough not to need its own thread pool and because the
 * thread may be blocked by the user script.
 */
void prepareBulkRequest(TimeValue thisBatchStartTime, ScrollableHitSource.Response response) {
    if (task.isCancelled()) {
        finishHim(null);
        return;
    }
    if (response.getHits().isEmpty()) {
        refreshAndFinish(emptyList(), emptyList(), false);
        return;
    }
    task.countBatch();
    List<? extends ScrollableHitSource.Hit> hits = response.getHits();
    if (mainRequest.getSize() != SIZE_ALL_MATCHES) {
        // Truncate the hits if we have more than the request size
        long remaining = max(0, mainRequest.getSize() - task.getSuccessfullyProcessed());
        if (remaining < hits.size()) {
            hits = hits.subList(0, (int) remaining);
        }
    }
    BulkRequest request = buildBulk(hits);
    if (request.requests().isEmpty()) {
        /*
         * If we noop-ed the entire batch then just skip to the next batch or the BulkRequest would fail validation.
         */
        startNextScroll(thisBatchStartTime, 0);
        return;
    }
    request.timeout(mainRequest.getTimeout());
    request.waitForActiveShards(mainRequest.getWaitForActiveShards());
    if (logger.isDebugEnabled()) {
        logger.debug("sending [{}] entry, [{}] bulk request", request.requests().size(),
                new ByteSizeValue(request.estimatedSizeInBytes()));
    }
    sendBulkRequest(thisBatchStartTime, request);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:40,代碼來源:AbstractAsyncBulkByScrollAction.java


注:本文中的org.elasticsearch.action.bulk.BulkRequest.waitForActiveShards方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。