• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DocWriteRequest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: add

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
/**
 * Adds a list of requests to be executed. Either index or delete requests.
 */
public BulkRequest add(Iterable<DocWriteRequest> requests) {
    for (DocWriteRequest request : requests) {
        add(request);
    }
    return this;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:BulkRequest.java


示例2: getBulkRequest

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
BulkRequest getBulkRequest() {
    if (itemResponses.isEmpty()) {
        return bulkRequest;
    } else {
        BulkRequest modifiedBulkRequest = new BulkRequest();
        modifiedBulkRequest.setRefreshPolicy(bulkRequest.getRefreshPolicy());
        modifiedBulkRequest.waitForActiveShards(bulkRequest.waitForActiveShards());
        modifiedBulkRequest.timeout(bulkRequest.timeout());

        int slot = 0;
        List<DocWriteRequest> requests = bulkRequest.requests();
        originalSlots = new int[requests.size()]; // oversize, but that's ok
        for (int i = 0; i < requests.size(); i++) {
            DocWriteRequest request = requests.get(i);
            if (failedSlots.get(i) == false) {
                modifiedBulkRequest.add(request);
                originalSlots[slot++] = i;
            }
        }
        return modifiedBulkRequest;
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:TransportBulkAction.java


示例3: writeTo

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeVInt(id);
    if (out.getVersion().before(Version.V_6_0_0_alpha1_UNRELEASED)) { // TODO remove once backported
        // old nodes expect updated version and version type on the request
        if (primaryResponse != null) {
            request.version(primaryResponse.getVersion());
            request.versionType(request.versionType().versionTypeForReplicationAndRecovery());
            DocWriteRequest.writeDocumentRequest(out, request);
        } else {
            DocWriteRequest.writeDocumentRequest(out, request);
        }
    } else {
        DocWriteRequest.writeDocumentRequest(out, request);
    }
    out.writeOptionalStreamable(primaryResponse);
    if (out.getVersion().before(Version.V_6_0_0_alpha1_UNRELEASED)) { // TODO remove once backported
        if (primaryResponse != null) {
            out.writeBoolean(primaryResponse.isFailed()
                    || primaryResponse.getResponse().getResult() == DocWriteResponse.Result.NOOP);
        } else {
            out.writeBoolean(false);
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:26,代码来源:BulkItemRequest.java


示例4: testIndexRequestOpTypeFromString

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
public void testIndexRequestOpTypeFromString() throws Exception {
    String create = "create";
    String index = "index";
    String createUpper = "CREATE";
    String indexUpper = "INDEX";

    IndexRequest indexRequest = new IndexRequest("");
    indexRequest.opType(create);
    assertThat(indexRequest.opType() , equalTo(DocWriteRequest.OpType.CREATE));
    indexRequest.opType(createUpper);
    assertThat(indexRequest.opType() , equalTo(DocWriteRequest.OpType.CREATE));
    indexRequest.opType(index);
    assertThat(indexRequest.opType() , equalTo(DocWriteRequest.OpType.INDEX));
    indexRequest.opType(indexUpper);
    assertThat(indexRequest.opType() , equalTo(DocWriteRequest.OpType.INDEX));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:IndexRequestTests.java


示例5: testExecuteBulkIndexRequestWithRejection

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
public void testExecuteBulkIndexRequestWithRejection() throws Exception {
    IndexMetaData metaData = indexMetaData();
    IndexShard shard = newStartedShard(true);

    BulkItemRequest[] items = new BulkItemRequest[1];
    DocWriteRequest writeRequest = new IndexRequest("index", "type", "id").source(Requests.INDEX_CONTENT_TYPE, "foo", "bar");
    items[0] = new BulkItemRequest(0, writeRequest);
    BulkShardRequest bulkShardRequest = new BulkShardRequest(shardId, RefreshPolicy.NONE, items);

    Translog.Location location = new Translog.Location(0, 0, 0);
    UpdateHelper updateHelper = null;

    // Pretend the mappings haven't made it to the node yet, and throw  a rejection
    Exception err = new ReplicationOperation.RetryOnPrimaryException(shardId, "rejection");

    try {
        TransportShardBulkAction.executeBulkItemRequest(metaData, shard, bulkShardRequest, location,
                0, updateHelper, threadPool::absoluteTimeInMillis, new ThrowingMappingUpdatePerformer(err));
        fail("should have thrown a retry exception");
    } catch (ReplicationOperation.RetryOnPrimaryException e) {
        assertThat(e, equalTo(err));
    }

    closeShards(shard);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:26,代码来源:TransportShardBulkActionTests.java


示例6: testNoopUpdateReplicaRequest

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
public void testNoopUpdateReplicaRequest() throws Exception {
    DocWriteRequest writeRequest = new IndexRequest("index", "type", "id").source(Requests.INDEX_CONTENT_TYPE, "field", "value");
    BulkItemRequest replicaRequest = new BulkItemRequest(0, writeRequest);

    DocWriteResponse noopUpdateResponse = new UpdateResponse(shardId, "index", "id", 0, DocWriteResponse.Result.NOOP);
    BulkItemResultHolder noopResults = new BulkItemResultHolder(noopUpdateResponse, null, replicaRequest);

    Translog.Location location = new Translog.Location(0, 0, 0);
    BulkItemRequest[] items = new BulkItemRequest[0];
    BulkShardRequest bulkShardRequest = new BulkShardRequest(shardId, RefreshPolicy.NONE, items);
    Translog.Location newLocation = TransportShardBulkAction.updateReplicaRequest(noopResults,
            DocWriteRequest.OpType.UPDATE, location, bulkShardRequest);

    BulkItemResponse primaryResponse = replicaRequest.getPrimaryResponse();

    // Basically nothing changes in the request since it's a noop
    assertThat(newLocation, equalTo(location));
    assertThat(primaryResponse.getItemId(), equalTo(0));
    assertThat(primaryResponse.getId(), equalTo("id"));
    assertThat(primaryResponse.getOpType(), equalTo(DocWriteRequest.OpType.UPDATE));
    assertThat(primaryResponse.getResponse(), equalTo(noopUpdateResponse));
    assertThat(primaryResponse.getResponse().getResult(), equalTo(DocWriteResponse.Result.NOOP));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:TransportShardBulkActionTests.java


示例7: processDocumentActions

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
public void processDocumentActions(Stream<DocumentAction> documentActions)
{
	LOG.trace("Processing document actions ...");
	BulkProcessor bulkProcessor = bulkProcessorFactory.create(client);
	try
	{
		documentActions.forEachOrdered(documentAction ->
		{
			DocWriteRequest docWriteRequest = toDocWriteRequest(documentAction);
			bulkProcessor.add(docWriteRequest);
		});
	}
	finally
	{
		waitForCompletion(bulkProcessor);
		LOG.debug("Processed document actions.");
	}
}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:19,代码来源:ClientFacade.java


示例8: setRandomVersion

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
private static void setRandomVersion(DocWriteRequest<?> request, Map<String, String> expectedParams) {
    if (randomBoolean()) {
        long version = randomFrom(Versions.MATCH_ANY, Versions.MATCH_DELETED, Versions.NOT_FOUND, randomNonNegativeLong());
        request.version(version);
        if (version != Versions.MATCH_ANY) {
            expectedParams.put("version", Long.toString(version));
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:RequestTests.java


示例9: setRandomVersionType

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
private static void setRandomVersionType(DocWriteRequest<?> request, Map<String, String> expectedParams) {
    if (randomBoolean()) {
        VersionType versionType = randomFrom(VersionType.values());
        request.versionType(versionType);
        if (versionType != VersionType.INTERNAL) {
            expectedParams.put("version_type", versionType.name().toLowerCase(Locale.ROOT));
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:RequestTests.java


示例10: hasIndexRequestsWithPipelines

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
/**
 * @return Whether this bulk request contains index request with an ingest pipeline enabled.
 */
public boolean hasIndexRequestsWithPipelines() {
    for (DocWriteRequest actionRequest : requests) {
        if (actionRequest instanceof IndexRequest) {
            IndexRequest indexRequest = (IndexRequest) actionRequest;
            if (Strings.hasText(indexRequest.getPipeline())) {
                return true;
            }
        }
    }

    return false;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:BulkRequest.java


示例11: readFrom

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    waitForActiveShards = ActiveShardCount.readFrom(in);
    int size = in.readVInt();
    for (int i = 0; i < size; i++) {
        requests.add(DocWriteRequest.readDocumentRequest(in));
    }
    refreshPolicy = RefreshPolicy.readFrom(in);
    timeout = new TimeValue(in);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:BulkRequest.java


示例12: writeTo

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
@Override
public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    waitForActiveShards.writeTo(out);
    out.writeVInt(requests.size());
    for (DocWriteRequest request : requests) {
        DocWriteRequest.writeDocumentRequest(out, request);
    }
    refreshPolicy.writeTo(out);
    timeout.writeTo(out);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:BulkRequest.java


示例13: setResponseFailureIfIndexMatches

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
private boolean setResponseFailureIfIndexMatches(AtomicArray<BulkItemResponse> responses, int idx, DocWriteRequest request, String index, Exception e) {
    if (index.equals(request.index())) {
        responses.set(idx, new BulkItemResponse(idx, request.opType(), new BulkItemResponse.Failure(request.index(), request.type(), request.id(), e)));
        return true;
    }
    return false;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:TransportBulkAction.java


示例14: resolveIfAbsent

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
Index resolveIfAbsent(DocWriteRequest request) {
    Index concreteIndex = indices.get(request.index());
    if (concreteIndex == null) {
        concreteIndex = indexNameExpressionResolver.concreteSingleIndex(state, request);
        indices.put(request.index(), concreteIndex);
    }
    return concreteIndex;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:TransportBulkAction.java


示例15: shardOperationOnReplica

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
@Override
protected WriteReplicaResult<Request> shardOperationOnReplica(
    Request replicaRequest, IndexShard replica) throws Exception {
    BulkItemRequest[] itemRequests = new BulkItemRequest[1];
    WriteRequest.RefreshPolicy refreshPolicy = replicaRequest.getRefreshPolicy();
    itemRequests[0] = new BulkItemRequest(0, ((DocWriteRequest) replicaRequest));
    BulkShardRequest bulkShardRequest = new BulkShardRequest(replicaRequest.shardId(), refreshPolicy, itemRequests);
    WriteReplicaResult<BulkShardRequest> result = shardBulkAction.shardOperationOnReplica(bulkShardRequest, replica);
    // a replica operation can never throw a document-level failure,
    // as the same document has been already indexed successfully in the primary
    return new WriteReplicaResult<>(replicaRequest, result.location, null, replica, logger);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:TransportSingleItemBulkWriteAction.java


示例16: toSingleItemBulkRequest

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
public static BulkRequest toSingleItemBulkRequest(ReplicatedWriteRequest request) {
    BulkRequest bulkRequest = new BulkRequest();
    bulkRequest.add(((DocWriteRequest) request));
    bulkRequest.setRefreshPolicy(request.getRefreshPolicy());
    bulkRequest.timeout(request.timeout());
    bulkRequest.waitForActiveShards(request.waitForActiveShards());
    request.setRefreshPolicy(WriteRequest.RefreshPolicy.NONE);
    return bulkRequest;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:TransportSingleItemBulkWriteAction.java


示例17: testExecuteBulkIndexRequestWithConflictingMappings

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
public void testExecuteBulkIndexRequestWithConflictingMappings() throws Exception {
    IndexMetaData metaData = indexMetaData();
    IndexShard shard = newStartedShard(true);

    BulkItemRequest[] items = new BulkItemRequest[1];
    DocWriteRequest writeRequest = new IndexRequest("index", "type", "id").source(Requests.INDEX_CONTENT_TYPE, "foo", "bar");
    items[0] = new BulkItemRequest(0, writeRequest);
    BulkShardRequest bulkShardRequest = new BulkShardRequest(shardId, RefreshPolicy.NONE, items);

    Translog.Location location = new Translog.Location(0, 0, 0);
    UpdateHelper updateHelper = null;

    // Return a mapping conflict (IAE) when trying to update the mapping
    Exception err = new IllegalArgumentException("mapping conflict");

    Translog.Location newLocation = TransportShardBulkAction.executeBulkItemRequest(metaData, shard, bulkShardRequest,
            location, 0, updateHelper, threadPool::absoluteTimeInMillis, new FailingMappingUpdatePerformer(err));

    // Translog shouldn't change, as there were conflicting mappings
    assertThat(newLocation, equalTo(location));

    BulkItemResponse primaryResponse = bulkShardRequest.items()[0].getPrimaryResponse();

    // Since this was not a conflict failure, the primary response
    // should be filled out with the failure information
    assertThat(primaryResponse.getItemId(), equalTo(0));
    assertThat(primaryResponse.getId(), equalTo("id"));
    assertThat(primaryResponse.getOpType(), equalTo(DocWriteRequest.OpType.INDEX));
    assertTrue(primaryResponse.isFailed());
    assertThat(primaryResponse.getFailureMessage(), containsString("mapping conflict"));
    BulkItemResponse.Failure failure = primaryResponse.getFailure();
    assertThat(failure.getIndex(), equalTo("index"));
    assertThat(failure.getType(), equalTo("type"));
    assertThat(failure.getId(), equalTo("id"));
    assertThat(failure.getCause(), equalTo(err));
    assertThat(failure.getStatus(), equalTo(RestStatus.BAD_REQUEST));

    closeShards(shard);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:40,代码来源:TransportShardBulkActionTests.java


示例18: testUpdateReplicaRequestWithFailure

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
public void testUpdateReplicaRequestWithFailure() throws Exception {
    DocWriteRequest writeRequest = new IndexRequest("index", "type", "id").source(Requests.INDEX_CONTENT_TYPE, "field", "value");
    BulkItemRequest replicaRequest = new BulkItemRequest(0, writeRequest);

    Exception err = new ElasticsearchException("I'm dead <(x.x)>");
    Engine.IndexResult indexResult = new Engine.IndexResult(err, 0, 0);
    BulkItemResultHolder failedResults = new BulkItemResultHolder(null, indexResult, replicaRequest);

    Translog.Location location = new Translog.Location(0, 0, 0);
    BulkItemRequest[] items = new BulkItemRequest[0];
    BulkShardRequest bulkShardRequest = new BulkShardRequest(shardId, RefreshPolicy.NONE, items);
    Translog.Location newLocation = TransportShardBulkAction.updateReplicaRequest(failedResults,
            DocWriteRequest.OpType.UPDATE, location, bulkShardRequest);

    BulkItemResponse primaryResponse = replicaRequest.getPrimaryResponse();

    // Since this was not a conflict failure, the primary response
    // should be filled out with the failure information
    assertThat(newLocation, equalTo(location));
    assertThat(primaryResponse.getItemId(), equalTo(0));
    assertThat(primaryResponse.getId(), equalTo("id"));
    assertThat(primaryResponse.getOpType(), equalTo(DocWriteRequest.OpType.INDEX));
    assertTrue(primaryResponse.isFailed());
    assertThat(primaryResponse.getFailureMessage(), containsString("I'm dead <(x.x)>"));
    BulkItemResponse.Failure failure = primaryResponse.getFailure();
    assertThat(failure.getIndex(), equalTo("index"));
    assertThat(failure.getType(), equalTo("type"));
    assertThat(failure.getId(), equalTo("id"));
    assertThat(failure.getCause(), equalTo(err));
    assertThat(failure.getStatus(), equalTo(RestStatus.INTERNAL_SERVER_ERROR));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:32,代码来源:TransportShardBulkActionTests.java


示例19: testUpdateReplicaRequestWithConflictFailure

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
public void testUpdateReplicaRequestWithConflictFailure() throws Exception {
    DocWriteRequest writeRequest = new IndexRequest("index", "type", "id").source(Requests.INDEX_CONTENT_TYPE, "field", "value");
    BulkItemRequest replicaRequest = new BulkItemRequest(0, writeRequest);

    Exception err = new VersionConflictEngineException(shardId, "type", "id", "I'm conflicted <(;_;)>");
    Engine.IndexResult indexResult = new Engine.IndexResult(err, 0, 0);
    BulkItemResultHolder failedResults = new BulkItemResultHolder(null, indexResult, replicaRequest);

    Translog.Location location = new Translog.Location(0, 0, 0);
    BulkItemRequest[] items = new BulkItemRequest[0];
    BulkShardRequest bulkShardRequest = new BulkShardRequest(shardId, RefreshPolicy.NONE, items);
    Translog.Location newLocation = TransportShardBulkAction.updateReplicaRequest(failedResults,
            DocWriteRequest.OpType.UPDATE, location, bulkShardRequest);

    BulkItemResponse primaryResponse = replicaRequest.getPrimaryResponse();

    // Since this was not a conflict failure, the primary response
    // should be filled out with the failure information
    assertThat(newLocation, equalTo(location));
    assertThat(primaryResponse.getItemId(), equalTo(0));
    assertThat(primaryResponse.getId(), equalTo("id"));
    assertThat(primaryResponse.getOpType(), equalTo(DocWriteRequest.OpType.INDEX));
    assertTrue(primaryResponse.isFailed());
    assertThat(primaryResponse.getFailureMessage(), containsString("I'm conflicted <(;_;)>"));
    BulkItemResponse.Failure failure = primaryResponse.getFailure();
    assertThat(failure.getIndex(), equalTo("index"));
    assertThat(failure.getType(), equalTo("type"));
    assertThat(failure.getId(), equalTo("id"));
    assertThat(failure.getCause(), equalTo(err));
    assertThat(failure.getStatus(), equalTo(RestStatus.CONFLICT));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:32,代码来源:TransportShardBulkActionTests.java


示例20: testUpdateReplicaRequestWithSuccess

import org.elasticsearch.action.DocWriteRequest; //导入依赖的package包/类
public void testUpdateReplicaRequestWithSuccess() throws Exception {
    DocWriteRequest writeRequest = new IndexRequest("index", "type", "id").source(Requests.INDEX_CONTENT_TYPE, "field", "value");
    BulkItemRequest replicaRequest = new BulkItemRequest(0, writeRequest);

    boolean created = randomBoolean();
    Translog.Location resultLocation = new Translog.Location(42, 42, 42);
    Engine.IndexResult indexResult = new FakeResult(1, 1, created, resultLocation);
    DocWriteResponse indexResponse = new IndexResponse(shardId, "index", "id", 1, 1, created);
    BulkItemResultHolder goodResults = new BulkItemResultHolder(indexResponse, indexResult, replicaRequest);

    Translog.Location originalLocation = new Translog.Location(21, 21, 21);
    BulkItemRequest[] items = new BulkItemRequest[0];
    BulkShardRequest bulkShardRequest = new BulkShardRequest(shardId, RefreshPolicy.NONE, items);
    Translog.Location newLocation = TransportShardBulkAction.updateReplicaRequest(goodResults,
            DocWriteRequest.OpType.INDEX, originalLocation, bulkShardRequest);

    BulkItemResponse primaryResponse = replicaRequest.getPrimaryResponse();

    // Check that the translog is successfully advanced
    assertThat(newLocation, equalTo(resultLocation));
    // Since this was not a conflict failure, the primary response
    // should be filled out with the failure information
    assertThat(primaryResponse.getItemId(), equalTo(0));
    assertThat(primaryResponse.getId(), equalTo("id"));
    assertThat(primaryResponse.getOpType(), equalTo(DocWriteRequest.OpType.INDEX));
    DocWriteResponse response = primaryResponse.getResponse();
    assertThat(response.status(), equalTo(created ? RestStatus.CREATED : RestStatus.OK));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:29,代码来源:TransportShardBulkActionTests.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ManagementConfiguration类代码示例发布时间:2022-05-23
下一篇:
Java KieModule类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap