Reuse FollowParameters' parse fields. (#38508)
This commit is contained in:
parent
e213ad3e88
commit
4625807505
|
@ -28,6 +28,17 @@ import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static org.elasticsearch.xpack.core.ccr.action.FollowParameters.MAX_READ_REQUEST_OPERATION_COUNT;
|
||||||
|
import static org.elasticsearch.xpack.core.ccr.action.FollowParameters.MAX_READ_REQUEST_SIZE;
|
||||||
|
import static org.elasticsearch.xpack.core.ccr.action.FollowParameters.MAX_OUTSTANDING_READ_REQUESTS;
|
||||||
|
import static org.elasticsearch.xpack.core.ccr.action.FollowParameters.MAX_WRITE_REQUEST_OPERATION_COUNT;
|
||||||
|
import static org.elasticsearch.xpack.core.ccr.action.FollowParameters.MAX_WRITE_REQUEST_SIZE;
|
||||||
|
import static org.elasticsearch.xpack.core.ccr.action.FollowParameters.MAX_OUTSTANDING_WRITE_REQUESTS;
|
||||||
|
import static org.elasticsearch.xpack.core.ccr.action.FollowParameters.MAX_WRITE_BUFFER_COUNT;
|
||||||
|
import static org.elasticsearch.xpack.core.ccr.action.FollowParameters.MAX_WRITE_BUFFER_SIZE;
|
||||||
|
import static org.elasticsearch.xpack.core.ccr.action.FollowParameters.MAX_RETRY_DELAY;
|
||||||
|
import static org.elasticsearch.xpack.core.ccr.action.FollowParameters.READ_POLL_TIMEOUT;
|
||||||
|
|
||||||
public class ShardFollowTask implements XPackPlugin.XPackPersistentTaskParams {
|
public class ShardFollowTask implements XPackPlugin.XPackPersistentTaskParams {
|
||||||
|
|
||||||
public static final String NAME = "xpack/ccr/shard_follow_task";
|
public static final String NAME = "xpack/ccr/shard_follow_task";
|
||||||
|
@ -36,24 +47,14 @@ public class ShardFollowTask implements XPackPlugin.XPackPersistentTaskParams {
|
||||||
public static final Set<String> HEADER_FILTERS =
|
public static final Set<String> HEADER_FILTERS =
|
||||||
Collections.unmodifiableSet(new HashSet<>(Arrays.asList("es-security-runas-user", "_xpack_security_authentication")));
|
Collections.unmodifiableSet(new HashSet<>(Arrays.asList("es-security-runas-user", "_xpack_security_authentication")));
|
||||||
|
|
||||||
static final ParseField REMOTE_CLUSTER_FIELD = new ParseField("remote_cluster");
|
private static final ParseField REMOTE_CLUSTER_FIELD = new ParseField("remote_cluster");
|
||||||
static final ParseField FOLLOW_SHARD_INDEX_FIELD = new ParseField("follow_shard_index");
|
private static final ParseField FOLLOW_SHARD_INDEX_FIELD = new ParseField("follow_shard_index");
|
||||||
static final ParseField FOLLOW_SHARD_INDEX_UUID_FIELD = new ParseField("follow_shard_index_uuid");
|
private static final ParseField FOLLOW_SHARD_INDEX_UUID_FIELD = new ParseField("follow_shard_index_uuid");
|
||||||
static final ParseField FOLLOW_SHARD_SHARDID_FIELD = new ParseField("follow_shard_shard");
|
private static final ParseField FOLLOW_SHARD_SHARDID_FIELD = new ParseField("follow_shard_shard");
|
||||||
static final ParseField LEADER_SHARD_INDEX_FIELD = new ParseField("leader_shard_index");
|
private static final ParseField LEADER_SHARD_INDEX_FIELD = new ParseField("leader_shard_index");
|
||||||
static final ParseField LEADER_SHARD_INDEX_UUID_FIELD = new ParseField("leader_shard_index_uuid");
|
private static final ParseField LEADER_SHARD_INDEX_UUID_FIELD = new ParseField("leader_shard_index_uuid");
|
||||||
static final ParseField LEADER_SHARD_SHARDID_FIELD = new ParseField("leader_shard_shard");
|
private static final ParseField LEADER_SHARD_SHARDID_FIELD = new ParseField("leader_shard_shard");
|
||||||
static final ParseField HEADERS = new ParseField("headers");
|
private static final ParseField HEADERS = new ParseField("headers");
|
||||||
public static final ParseField MAX_READ_REQUEST_OPERATION_COUNT = new ParseField("max_read_request_operation_count");
|
|
||||||
public static final ParseField MAX_READ_REQUEST_SIZE = new ParseField("max_read_request_size");
|
|
||||||
public static final ParseField MAX_OUTSTANDING_READ_REQUESTS = new ParseField("max_outstanding_read_requests");
|
|
||||||
public static final ParseField MAX_WRITE_REQUEST_OPERATION_COUNT = new ParseField("max_write_request_operation_count");
|
|
||||||
public static final ParseField MAX_WRITE_REQUEST_SIZE = new ParseField("max_write_request_size");
|
|
||||||
public static final ParseField MAX_OUTSTANDING_WRITE_REQUESTS = new ParseField("max_outstanding_write_requests");
|
|
||||||
public static final ParseField MAX_WRITE_BUFFER_COUNT = new ParseField("max_write_buffer_count");
|
|
||||||
public static final ParseField MAX_WRITE_BUFFER_SIZE = new ParseField("max_write_buffer_size");
|
|
||||||
public static final ParseField MAX_RETRY_DELAY = new ParseField("max_retry_delay");
|
|
||||||
public static final ParseField READ_POLL_TIMEOUT = new ParseField("read_poll_timeout");
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private static ConstructingObjectParser<ShardFollowTask, Void> PARSER = new ConstructingObjectParser<>(NAME,
|
private static ConstructingObjectParser<ShardFollowTask, Void> PARSER = new ConstructingObjectParser<>(NAME,
|
||||||
|
|
|
@ -32,6 +32,17 @@ import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static org.elasticsearch.xpack.core.ccr.action.FollowParameters.MAX_READ_REQUEST_OPERATION_COUNT;
|
||||||
|
import static org.elasticsearch.xpack.core.ccr.action.FollowParameters.MAX_READ_REQUEST_SIZE;
|
||||||
|
import static org.elasticsearch.xpack.core.ccr.action.FollowParameters.MAX_OUTSTANDING_READ_REQUESTS;
|
||||||
|
import static org.elasticsearch.xpack.core.ccr.action.FollowParameters.MAX_WRITE_REQUEST_OPERATION_COUNT;
|
||||||
|
import static org.elasticsearch.xpack.core.ccr.action.FollowParameters.MAX_WRITE_REQUEST_SIZE;
|
||||||
|
import static org.elasticsearch.xpack.core.ccr.action.FollowParameters.MAX_OUTSTANDING_WRITE_REQUESTS;
|
||||||
|
import static org.elasticsearch.xpack.core.ccr.action.FollowParameters.MAX_WRITE_BUFFER_COUNT;
|
||||||
|
import static org.elasticsearch.xpack.core.ccr.action.FollowParameters.MAX_WRITE_BUFFER_SIZE;
|
||||||
|
import static org.elasticsearch.xpack.core.ccr.action.FollowParameters.MAX_RETRY_DELAY;
|
||||||
|
import static org.elasticsearch.xpack.core.ccr.action.FollowParameters.READ_POLL_TIMEOUT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom metadata that contains auto follow patterns and what leader indices an auto follow pattern has already followed.
|
* Custom metadata that contains auto follow patterns and what leader indices an auto follow pattern has already followed.
|
||||||
*/
|
*/
|
||||||
|
@ -180,16 +191,6 @@ public class AutoFollowMetadata extends AbstractNamedDiffable<MetaData.Custom> i
|
||||||
public static final ParseField REMOTE_CLUSTER_FIELD = new ParseField("remote_cluster");
|
public static final ParseField REMOTE_CLUSTER_FIELD = new ParseField("remote_cluster");
|
||||||
public static final ParseField LEADER_PATTERNS_FIELD = new ParseField("leader_index_patterns");
|
public static final ParseField LEADER_PATTERNS_FIELD = new ParseField("leader_index_patterns");
|
||||||
public static final ParseField FOLLOW_PATTERN_FIELD = new ParseField("follow_index_pattern");
|
public static final ParseField FOLLOW_PATTERN_FIELD = new ParseField("follow_index_pattern");
|
||||||
public static final ParseField MAX_READ_REQUEST_OPERATION_COUNT = new ParseField("max_read_request_operation_count");
|
|
||||||
public static final ParseField MAX_READ_REQUEST_SIZE = new ParseField("max_read_request_size");
|
|
||||||
public static final ParseField MAX_OUTSTANDING_READ_REQUESTS = new ParseField("max_outstanding_read_requests");
|
|
||||||
public static final ParseField MAX_WRITE_REQUEST_OPERATION_COUNT = new ParseField("max_write_request_operation_count");
|
|
||||||
public static final ParseField MAX_WRITE_REQUEST_SIZE = new ParseField("max_write_request_size");
|
|
||||||
public static final ParseField MAX_OUTSTANDING_WRITE_REQUESTS = new ParseField("max_outstanding_write_requests");
|
|
||||||
public static final ParseField MAX_WRITE_BUFFER_COUNT = new ParseField("max_write_buffer_count");
|
|
||||||
public static final ParseField MAX_WRITE_BUFFER_SIZE = new ParseField("max_write_buffer_size");
|
|
||||||
public static final ParseField MAX_RETRY_DELAY = new ParseField("max_retry_delay");
|
|
||||||
public static final ParseField READ_POLL_TIMEOUT = new ParseField("read_poll_timeout");
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private static final ConstructingObjectParser<AutoFollowPattern, Void> PARSER =
|
private static final ConstructingObjectParser<AutoFollowPattern, Void> PARSER =
|
||||||
|
|
|
@ -15,7 +15,6 @@ import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.common.xcontent.AbstractObjectParser;
|
import org.elasticsearch.common.xcontent.AbstractObjectParser;
|
||||||
import org.elasticsearch.common.xcontent.ObjectParser;
|
import org.elasticsearch.common.xcontent.ObjectParser;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.xpack.core.ccr.AutoFollowMetadata;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
@ -24,18 +23,18 @@ import static org.elasticsearch.action.ValidateActions.addValidationError;
|
||||||
|
|
||||||
public class FollowParameters implements Writeable {
|
public class FollowParameters implements Writeable {
|
||||||
|
|
||||||
static final TimeValue RETRY_DELAY_MAX = TimeValue.timeValueMinutes(5);
|
private static final TimeValue RETRY_DELAY_MAX = TimeValue.timeValueMinutes(5);
|
||||||
|
|
||||||
static final ParseField MAX_READ_REQUEST_OPERATION_COUNT = new ParseField("max_read_request_operation_count");
|
public static final ParseField MAX_READ_REQUEST_OPERATION_COUNT = new ParseField("max_read_request_operation_count");
|
||||||
static final ParseField MAX_WRITE_REQUEST_OPERATION_COUNT = new ParseField("max_write_request_operation_count");
|
public static final ParseField MAX_WRITE_REQUEST_OPERATION_COUNT = new ParseField("max_write_request_operation_count");
|
||||||
static final ParseField MAX_OUTSTANDING_READ_REQUESTS = new ParseField("max_outstanding_read_requests");
|
public static final ParseField MAX_OUTSTANDING_READ_REQUESTS = new ParseField("max_outstanding_read_requests");
|
||||||
static final ParseField MAX_OUTSTANDING_WRITE_REQUESTS = new ParseField("max_outstanding_write_requests");
|
public static final ParseField MAX_OUTSTANDING_WRITE_REQUESTS = new ParseField("max_outstanding_write_requests");
|
||||||
static final ParseField MAX_READ_REQUEST_SIZE = new ParseField("max_read_request_size");
|
public static final ParseField MAX_READ_REQUEST_SIZE = new ParseField("max_read_request_size");
|
||||||
static final ParseField MAX_WRITE_REQUEST_SIZE = new ParseField("max_write_request_size");
|
public static final ParseField MAX_WRITE_REQUEST_SIZE = new ParseField("max_write_request_size");
|
||||||
static final ParseField MAX_WRITE_BUFFER_COUNT = new ParseField("max_write_buffer_count");
|
public static final ParseField MAX_WRITE_BUFFER_COUNT = new ParseField("max_write_buffer_count");
|
||||||
static final ParseField MAX_WRITE_BUFFER_SIZE = new ParseField("max_write_buffer_size");
|
public static final ParseField MAX_WRITE_BUFFER_SIZE = new ParseField("max_write_buffer_size");
|
||||||
static final ParseField MAX_RETRY_DELAY = new ParseField("max_retry_delay");
|
public static final ParseField MAX_RETRY_DELAY = new ParseField("max_retry_delay");
|
||||||
static final ParseField READ_POLL_TIMEOUT = new ParseField("read_poll_timeout");
|
public static final ParseField READ_POLL_TIMEOUT = new ParseField("read_poll_timeout");
|
||||||
|
|
||||||
Integer maxReadRequestOperationCount;
|
Integer maxReadRequestOperationCount;
|
||||||
Integer maxWriteRequestOperationCount;
|
Integer maxWriteRequestOperationCount;
|
||||||
|
@ -258,12 +257,12 @@ public class FollowParameters implements Writeable {
|
||||||
parser.declareField(
|
parser.declareField(
|
||||||
FollowParameters::setMaxReadRequestSize,
|
FollowParameters::setMaxReadRequestSize,
|
||||||
(p, c) -> ByteSizeValue.parseBytesSizeValue(p.text(), MAX_READ_REQUEST_SIZE.getPreferredName()),
|
(p, c) -> ByteSizeValue.parseBytesSizeValue(p.text(), MAX_READ_REQUEST_SIZE.getPreferredName()),
|
||||||
AutoFollowMetadata.AutoFollowPattern.MAX_READ_REQUEST_SIZE,
|
MAX_READ_REQUEST_SIZE,
|
||||||
ObjectParser.ValueType.STRING);
|
ObjectParser.ValueType.STRING);
|
||||||
parser.declareField(
|
parser.declareField(
|
||||||
FollowParameters::setMaxWriteRequestSize,
|
FollowParameters::setMaxWriteRequestSize,
|
||||||
(p, c) -> ByteSizeValue.parseBytesSizeValue(p.text(), MAX_WRITE_REQUEST_SIZE.getPreferredName()),
|
(p, c) -> ByteSizeValue.parseBytesSizeValue(p.text(), MAX_WRITE_REQUEST_SIZE.getPreferredName()),
|
||||||
AutoFollowMetadata.AutoFollowPattern.MAX_WRITE_REQUEST_SIZE,
|
MAX_WRITE_REQUEST_SIZE,
|
||||||
ObjectParser.ValueType.STRING);
|
ObjectParser.ValueType.STRING);
|
||||||
parser.declareInt(FollowParameters::setMaxWriteBufferCount, MAX_WRITE_BUFFER_COUNT);
|
parser.declareInt(FollowParameters::setMaxWriteBufferCount, MAX_WRITE_BUFFER_COUNT);
|
||||||
parser.declareField(
|
parser.declareField(
|
||||||
|
|
Loading…
Reference in New Issue