本文整理匯總了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())));
}