本文整理汇总了Java中org.elasticsearch.action.update.UpdateRequest.retryOnConflict方法的典型用法代码示例。如果您正苦于以下问题:Java UpdateRequest.retryOnConflict方法的具体用法?Java UpdateRequest.retryOnConflict怎么用?Java UpdateRequest.retryOnConflict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.action.update.UpdateRequest
的用法示例。
在下文中一共展示了UpdateRequest.retryOnConflict方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: index
import org.elasticsearch.action.update.UpdateRequest; //导入方法依赖的package包/类
@Override
public void index(Workflow workflow) {
try {
String id = workflow.getWorkflowId();
WorkflowSummary summary = new WorkflowSummary(workflow);
byte[] doc = om.writeValueAsBytes(summary);
UpdateRequest req = new UpdateRequest(indexName, WORKFLOW_DOC_TYPE, id);
req.doc(doc, XContentType.JSON);
req.upsert(doc, XContentType.JSON);
req.retryOnConflict(5);
updateWithRetry(req);
} catch (Throwable e) {
log.error("Indexing failed {}", e.getMessage(), e);
}
}
示例2: add
import org.elasticsearch.action.update.UpdateRequest; //导入方法依赖的package包/类
@Override
public void add(EventExecution ee) {
try {
byte[] doc = om.writeValueAsBytes(ee);
String id = ee.getName() + "." + ee.getEvent() + "." + ee.getMessageId() + "." + ee.getId();
UpdateRequest req = new UpdateRequest(logIndexName, EVENT_DOC_TYPE, id);
req.doc(doc, XContentType.JSON);
req.upsert(doc, XContentType.JSON);
req.retryOnConflict(5);
updateWithRetry(req);
} catch (Throwable e) {
log.error("Indexing failed {}", e.getMessage(), e);
}
}
示例3: index
import org.elasticsearch.action.update.UpdateRequest; //导入方法依赖的package包/类
@Override
public void index(Workflow workflow) {
try {
String id = workflow.getWorkflowId();
WorkflowSummary summary = new WorkflowSummary(workflow);
byte[] doc = om.writeValueAsBytes(summary);
UpdateRequest req = new UpdateRequest(indexName, WORKFLOW_DOC_TYPE, id);
req.doc(doc);
req.upsert(doc);
req.retryOnConflict(5);
updateWithRetry(req);
} catch (Throwable e) {
log.error("Indexing failed {}", e.getMessage(), e);
}
}
示例4: add
import org.elasticsearch.action.update.UpdateRequest; //导入方法依赖的package包/类
@Override
public void add(EventExecution ee) {
try {
byte[] doc = om.writeValueAsBytes(ee);
String id = ee.getName() + "." + ee.getEvent() + "." + ee.getMessageId() + "." + ee.getId();
UpdateRequest req = new UpdateRequest(logIndexName, EVENT_DOC_TYPE, id);
req.doc(doc);
req.upsert(doc);
req.retryOnConflict(5);
updateWithRetry(req);
} catch (Throwable e) {
log.error("Indexing failed {}", e.getMessage(), e);
}
}
示例5: addElementToBulkRequest
import org.elasticsearch.action.update.UpdateRequest; //导入方法依赖的package包/类
public void addElementToBulkRequest(Graph graph, BulkRequest bulkRequest, IndexInfo indexInfo, Element element, Authorizations authorizations) {
try {
XContentBuilder json = buildJsonContentFromElement(graph, element, authorizations);
UpdateRequest indexRequest = new UpdateRequest(indexInfo.getIndexName(), ELEMENT_TYPE, element.getId()).doc(json);
indexRequest.retryOnConflict(MAX_RETRIES);
indexRequest.docAsUpsert(true);
bulkRequest.add(indexRequest);
} catch (IOException ex) {
throw new MemgraphException("Could not add element to bulk request", ex);
}
}
示例6: addElementToBulkRequest
import org.elasticsearch.action.update.UpdateRequest; //导入方法依赖的package包/类
public void addElementToBulkRequest(Graph graph, BulkRequest bulkRequest, IndexInfo indexInfo, Element element, Authorizations authorizations) {
try {
XContentBuilder json = buildJsonContentFromElement(graph, element, authorizations);
UpdateRequest indexRequest = new UpdateRequest(indexInfo.getIndexName(), ELEMENT_TYPE, element.getId()).doc(json);
indexRequest.retryOnConflict(MAX_RETRIES);
indexRequest.docAsUpsert(true);
bulkRequest.add(indexRequest);
} catch (IOException ex) {
throw new VertexiumException("Could not add element to bulk request", ex);
}
}
示例7: buildUpdateCommand
import org.elasticsearch.action.update.UpdateRequest; //导入方法依赖的package包/类
private static byte[] buildUpdateCommand(UpdateRequest updateRequest) throws IOException {
try (XContentBuilder builder = XContentFactory.jsonBuilder().startObject()) {
addCommonOptions(builder, "update", updateRequest.index(), updateRequest.type(), updateRequest.id(),
updateRequest.version(), updateRequest.versionType(), updateRequest.routing(),
updateRequest.consistencyLevel(), updateRequest.refresh());
String timestamp = updateRequest.doc() != null ? updateRequest.doc().timestamp() : null;
long ttl = updateRequest.doc() != null ? updateRequest.doc().ttl() : -1;
if (timestamp != null) {
builder.field("_timestamp", timestamp);
}
if (ttl != -1) {
builder.field("_ttl", ttl);
}
if (updateRequest.retryOnConflict() != -1) {
builder.field("_retry_on_conflict", updateRequest.retryOnConflict());
}
if (updateRequest.fields() != null && updateRequest.fields().length > 0) {
builder.field("_fields", Strings.arrayToCommaDelimitedString(updateRequest.fields()));
}
if (updateRequest.doc() != null && updateRequest.doc().parent() != null) {
builder.field("_parent", updateRequest.doc().parent());
} else if (updateRequest.routing() != null) {
builder.field("_parent", updateRequest.routing());
}
return builder.bytes().toBytes();
}
}
示例8: prepareRequest
import org.elasticsearch.action.update.UpdateRequest; //导入方法依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
UpdateRequest updateRequest = new UpdateRequest(request.param("index"), request.param("type"), request.param("id"));
updateRequest.routing(request.param("routing"));
updateRequest.parent(request.param("parent"));
updateRequest.timeout(request.paramAsTime("timeout", updateRequest.timeout()));
updateRequest.setRefreshPolicy(request.param("refresh"));
String waitForActiveShards = request.param("wait_for_active_shards");
if (waitForActiveShards != null) {
updateRequest.waitForActiveShards(ActiveShardCount.parseString(waitForActiveShards));
}
updateRequest.docAsUpsert(request.paramAsBoolean("doc_as_upsert", updateRequest.docAsUpsert()));
FetchSourceContext fetchSourceContext = FetchSourceContext.parseFromRestRequest(request);
String sField = request.param("fields");
if (sField != null && fetchSourceContext != null) {
throw new IllegalArgumentException("[fields] and [_source] cannot be used in the same request");
}
if (sField != null) {
DEPRECATION_LOGGER.deprecated("Deprecated field [fields] used, expected [_source] instead");
String[] sFields = Strings.splitStringByCommaToArray(sField);
updateRequest.fields(sFields);
} else if (fetchSourceContext != null) {
updateRequest.fetchSource(fetchSourceContext);
}
updateRequest.retryOnConflict(request.paramAsInt("retry_on_conflict", updateRequest.retryOnConflict()));
updateRequest.version(RestActions.parseVersion(request));
updateRequest.versionType(VersionType.fromString(request.param("version_type"), updateRequest.versionType()));
request.applyContentParser(parser -> {
updateRequest.fromXContent(parser);
IndexRequest upsertRequest = updateRequest.upsertRequest();
if (upsertRequest != null) {
upsertRequest.routing(request.param("routing"));
upsertRequest.parent(request.param("parent"));
upsertRequest.version(RestActions.parseVersion(request));
upsertRequest.versionType(VersionType.fromString(request.param("version_type"), upsertRequest.versionType()));
}
IndexRequest doc = updateRequest.doc();
if (doc != null) {
doc.routing(request.param("routing"));
doc.parent(request.param("parent")); // order is important, set it after routing, so it will set the routing
doc.version(RestActions.parseVersion(request));
doc.versionType(VersionType.fromString(request.param("version_type"), doc.versionType()));
}
});
return channel ->
client.update(updateRequest, new RestStatusToXContentListener<>(channel, r -> r.getLocation(updateRequest.routing())));
}