本文整理了Java中org.elasticsearch.action.WriteConsistencyLevel
类的一些代码示例,展示了WriteConsistencyLevel
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WriteConsistencyLevel
类的具体详情如下:
包路径:org.elasticsearch.action.WriteConsistencyLevel
类名称:WriteConsistencyLevel
[英]Write Consistency Level control how many replicas should be active for a write operation to occur (a write operation can be index, or delete).
[中]写一致性级别控制一次写操作应该有多少副本处于活动状态(一次写操作可以是索引或删除)。
代码示例来源:origin: apache/usergrid
private BulkRequestBuilder initRequest() {
BulkRequestBuilder bulkRequest = client.prepareBulk();
bulkRequest.setConsistencyLevel( WriteConsistencyLevel.fromString( config.getWriteConsistencyLevel() ) );
bulkRequest.setRefresh( config.isForcedRefresh() );
return bulkRequest;
}
代码示例来源:origin: harbby/presto-connectors
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeByte(consistencyLevel.id());
out.writeVInt(requests.size());
for (ActionRequest request : requests) {
if (request instanceof IndexRequest) {
out.writeByte((byte) 0);
} else if (request instanceof DeleteRequest) {
out.writeByte((byte) 1);
} else if (request instanceof UpdateRequest) {
out.writeByte((byte) 2);
}
request.writeTo(out);
}
out.writeBoolean(refresh);
timeout.writeTo(out);
}
}
代码示例来源:origin: harbby/presto-connectors
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
consistencyLevel = WriteConsistencyLevel.fromId(in.readByte());
int size = in.readVInt();
for (int i = 0; i < size; i++) {
byte type = in.readByte();
if (type == 0) {
IndexRequest request = new IndexRequest();
request.readFrom(in);
requests.add(request);
} else if (type == 1) {
DeleteRequest request = new DeleteRequest();
request.readFrom(in);
requests.add(request);
} else if (type == 2) {
UpdateRequest request = new UpdateRequest();
request.readFrom(in);
requests.add(request);
}
}
refresh = in.readBoolean();
timeout = TimeValue.readTimeValue(in);
}
代码示例来源:origin: ef-labs/vertx-elasticsearch-service
@Override
public JsonObject toJson() {
JsonObject json = super.toJson();
if (getConsistencyLevel() != null) {
json.put(FIELD_CONSISTENCY_LEVEL, getConsistencyLevel().toString().toLowerCase());
}
if (getTimeout() != null) json.put(FIELD_TIMEOUT, getTimeout());
return json;
}
代码示例来源:origin: org.elasticsearch.module/reindex
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
searchRequest.writeTo(out);
out.writeBoolean(abortOnVersionConflict);
out.writeVInt(size);
out.writeBoolean(refresh);
timeout.writeTo(out);
out.writeByte(consistency.id());
retryBackoffInitialTime.writeTo(out);
out.writeVInt(maxRetries);
if (out.getVersion().onOrAfter(Version.V_2_4_0)) {
out.writeFloat(requestsPerSecond);
}
}
代码示例来源:origin: harbby/presto-connectors
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
if (in.readBoolean()) {
shardId = ShardId.readShardId(in);
} else {
shardId = null;
}
consistencyLevel = WriteConsistencyLevel.fromId(in.readByte());
timeout = TimeValue.readTimeValue(in);
index = in.readString();
canHaveDuplicates = in.readBoolean();
// no need to serialize threaded* parameters, since they only matter locally
if (in.getVersion().onOrAfter(Version.V_2_4_0)) {
routedBasedOnClusterVersion = in.readVLong();
}
}
代码示例来源:origin: ef-labs/vertx-elasticsearch-service
protected AbstractWriteOptions(JsonObject json) {
super(json);
timeout = json.getString(FIELD_TIMEOUT);
String s = json.getString(FIELD_CONSISTENCY_LEVEL);
if (s != null) consistencyLevel = WriteConsistencyLevel.fromString(s);
}
代码示例来源:origin: com.strapdata.elasticsearch.module/reindex
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
searchRequest.writeTo(out);
out.writeBoolean(abortOnVersionConflict);
out.writeVInt(size);
out.writeBoolean(refresh);
timeout.writeTo(out);
out.writeByte(consistency.id());
retryBackoffInitialTime.writeTo(out);
out.writeVInt(maxRetries);
if (out.getVersion().onOrAfter(Version.V_2_4_0)) {
out.writeFloat(requestsPerSecond);
}
}
代码示例来源:origin: org.elasticsearch.module/reindex
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
searchRequest = new SearchRequest();
searchRequest.readFrom(in);
abortOnVersionConflict = in.readBoolean();
size = in.readVInt();
refresh = in.readBoolean();
timeout = TimeValue.readTimeValue(in);
consistency = WriteConsistencyLevel.fromId(in.readByte());
retryBackoffInitialTime = TimeValue.readTimeValue(in);
maxRetries = in.readVInt();
if (in.getVersion().onOrAfter(Version.V_2_4_0)) {
requestsPerSecond = in.readFloat();
}
}
代码示例来源:origin: javanna/elasticshell
public UpdateRequestBuilder<JsonInput, JsonOutput> consistencyLevel(String consistencyLevel) {
request.consistencyLevel(WriteConsistencyLevel.fromString(consistencyLevel));
return this;
}
代码示例来源:origin: harbby/presto-connectors
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
if (shardId != null) {
out.writeBoolean(true);
shardId.writeTo(out);
} else {
out.writeBoolean(false);
}
out.writeByte(consistencyLevel.id());
timeout.writeTo(out);
out.writeString(index);
out.writeBoolean(canHaveDuplicates);
if (out.getVersion().onOrAfter(Version.V_2_4_0)) {
out.writeVLong(routedBasedOnClusterVersion);
}
}
代码示例来源:origin: com.strapdata.elasticsearch.module/reindex
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
searchRequest = new SearchRequest();
searchRequest.readFrom(in);
abortOnVersionConflict = in.readBoolean();
size = in.readVInt();
refresh = in.readBoolean();
timeout = TimeValue.readTimeValue(in);
consistency = WriteConsistencyLevel.fromId(in.readByte());
retryBackoffInitialTime = TimeValue.readTimeValue(in);
maxRetries = in.readVInt();
if (in.getVersion().onOrAfter(Version.V_2_4_0)) {
requestsPerSecond = in.readFloat();
}
}
代码示例来源:origin: javanna/elasticshell
public IndexRequestBuilder<JsonInput, JsonOutput> consistencyLevel(String consistencyLevel) {
request.consistencyLevel(WriteConsistencyLevel.fromString(consistencyLevel));
return this;
}
代码示例来源:origin: harbby/presto-connectors
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeByte(consistencyLevel.id());
out.writeString(type);
out.writeString(id);
代码示例来源:origin: harbby/presto-connectors
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
consistencyLevel = WriteConsistencyLevel.fromId(in.readByte());
type = in.readString();
id = in.readString();
代码示例来源:origin: javanna/elasticshell
public DeleteRequestBuilder<JsonInput, JsonOutput> consistencyLevel(String consistencyLevel) {
request.consistencyLevel(WriteConsistencyLevel.fromString(consistencyLevel));
return this;
}
代码示例来源:origin: javanna/elasticshell
public DeleteByQueryRequestBuilder<JsonInput, JsonOutput> consistencyLevel(String consistencyLevel) {
request.consistencyLevel(WriteConsistencyLevel.fromString(consistencyLevel));
return this;
}
代码示例来源:origin: org.elasticsearch.module/reindex
public static void parseCommon(AbstractBulkByScrollRequest<?> internalRequest, RestRequest request) {
internalRequest.setRefresh(request.paramAsBoolean("refresh", internalRequest.isRefresh()));
internalRequest.setTimeout(request.paramAsTime("timeout", internalRequest.getTimeout()));
String consistency = request.param("consistency");
if (consistency != null) {
internalRequest.setConsistency(WriteConsistencyLevel.fromString(consistency));
}
}
代码示例来源:origin: com.strapdata.elasticsearch.module/reindex
public static void parseCommon(AbstractBulkByScrollRequest<?> internalRequest, RestRequest request) {
internalRequest.setRefresh(request.paramAsBoolean("refresh", internalRequest.isRefresh()));
internalRequest.setTimeout(request.paramAsTime("timeout", internalRequest.getTimeout()));
String consistency = request.param("consistency");
if (consistency != null) {
internalRequest.setConsistency(WriteConsistencyLevel.fromString(consistency));
}
}
代码示例来源:origin: harbby/presto-connectors
protected TransportReplicationAction(Settings settings, String actionName, TransportService transportService,
ClusterService clusterService, IndicesService indicesService,
ThreadPool threadPool, ShardStateAction shardStateAction,
MappingUpdatedAction mappingUpdatedAction, ActionFilters actionFilters,
IndexNameExpressionResolver indexNameExpressionResolver, Class<Request> request,
Class<ReplicaRequest> replicaRequest, String executor) {
super(settings, actionName, threadPool, actionFilters, indexNameExpressionResolver, transportService.getTaskManager());
this.transportService = transportService;
this.clusterService = clusterService;
this.indicesService = indicesService;
this.shardStateAction = shardStateAction;
this.mappingUpdatedAction = mappingUpdatedAction;
this.transportPrimaryAction = actionName + "[p]";
this.transportReplicaAction = actionName + "[r]";
this.executor = executor;
this.checkWriteConsistency = checkWriteConsistency();
transportService.registerRequestHandler(actionName, request, ThreadPool.Names.SAME, new OperationTransportHandler());
transportService.registerRequestHandler(transportPrimaryAction, request, executor, new PrimaryOperationTransportHandler());
// we must never reject on because of thread pool capacity on replicas
transportService.registerRequestHandler(transportReplicaAction, replicaRequest, executor, true, true, new ReplicaOperationTransportHandler());
this.transportOptions = transportOptions();
this.defaultWriteConsistencyLevel = WriteConsistencyLevel.fromString(settings.get("action.write_consistency", "quorum"));
}
内容来源于网络,如有侵权,请联系作者删除!