|
| 1 | +/* |
| 2 | + * Licensed to Elasticsearch under one or more contributor |
| 3 | + * license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright |
| 5 | + * ownership. Elasticsearch licenses this file to you under |
| 6 | + * the Apache License, Version 2.0 (the "License"); you may |
| 7 | + * not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +package org.elasticsearch.client.ccr; |
| 21 | + |
| 22 | +import org.elasticsearch.common.ParseField; |
| 23 | +import org.elasticsearch.common.unit.ByteSizeValue; |
| 24 | +import org.elasticsearch.common.unit.TimeValue; |
| 25 | +import org.elasticsearch.common.xcontent.ToXContent; |
| 26 | +import org.elasticsearch.common.xcontent.XContentBuilder; |
| 27 | + |
| 28 | +import java.io.IOException; |
| 29 | +import java.util.Objects; |
| 30 | + |
| 31 | +public class FollowConfig { |
| 32 | + |
| 33 | + static final ParseField MAX_READ_REQUEST_OPERATION_COUNT = new ParseField("max_read_request_operation_count"); |
| 34 | + static final ParseField MAX_READ_REQUEST_SIZE = new ParseField("max_read_request_size"); |
| 35 | + static final ParseField MAX_OUTSTANDING_READ_REQUESTS = new ParseField("max_outstanding_read_requests"); |
| 36 | + static final ParseField MAX_WRITE_REQUEST_OPERATION_COUNT = new ParseField("max_write_request_operation_count"); |
| 37 | + static final ParseField MAX_WRITE_REQUEST_SIZE = new ParseField("max_write_request_size"); |
| 38 | + static final ParseField MAX_OUTSTANDING_WRITE_REQUESTS = new ParseField("max_outstanding_write_requests"); |
| 39 | + static final ParseField MAX_WRITE_BUFFER_COUNT = new ParseField("max_write_buffer_count"); |
| 40 | + static final ParseField MAX_WRITE_BUFFER_SIZE = new ParseField("max_write_buffer_size"); |
| 41 | + static final ParseField MAX_RETRY_DELAY_FIELD = new ParseField("max_retry_delay"); |
| 42 | + static final ParseField READ_POLL_TIMEOUT = new ParseField("read_poll_timeout"); |
| 43 | + |
| 44 | + private Integer maxReadRequestOperationCount; |
| 45 | + private Integer maxOutstandingReadRequests; |
| 46 | + private ByteSizeValue maxReadRequestSize; |
| 47 | + private Integer maxWriteRequestOperationCount; |
| 48 | + private ByteSizeValue maxWriteRequestSize; |
| 49 | + private Integer maxOutstandingWriteRequests; |
| 50 | + private Integer maxWriteBufferCount; |
| 51 | + private ByteSizeValue maxWriteBufferSize; |
| 52 | + private TimeValue maxRetryDelay; |
| 53 | + private TimeValue readPollTimeout; |
| 54 | + |
| 55 | + FollowConfig() { |
| 56 | + } |
| 57 | + |
| 58 | + public Integer getMaxReadRequestOperationCount() { |
| 59 | + return maxReadRequestOperationCount; |
| 60 | + } |
| 61 | + |
| 62 | + public void setMaxReadRequestOperationCount(Integer maxReadRequestOperationCount) { |
| 63 | + this.maxReadRequestOperationCount = maxReadRequestOperationCount; |
| 64 | + } |
| 65 | + |
| 66 | + public Integer getMaxOutstandingReadRequests() { |
| 67 | + return maxOutstandingReadRequests; |
| 68 | + } |
| 69 | + |
| 70 | + public void setMaxOutstandingReadRequests(Integer maxOutstandingReadRequests) { |
| 71 | + this.maxOutstandingReadRequests = maxOutstandingReadRequests; |
| 72 | + } |
| 73 | + |
| 74 | + public ByteSizeValue getMaxReadRequestSize() { |
| 75 | + return maxReadRequestSize; |
| 76 | + } |
| 77 | + |
| 78 | + public void setMaxReadRequestSize(ByteSizeValue maxReadRequestSize) { |
| 79 | + this.maxReadRequestSize = maxReadRequestSize; |
| 80 | + } |
| 81 | + |
| 82 | + public Integer getMaxWriteRequestOperationCount() { |
| 83 | + return maxWriteRequestOperationCount; |
| 84 | + } |
| 85 | + |
| 86 | + public void setMaxWriteRequestOperationCount(Integer maxWriteRequestOperationCount) { |
| 87 | + this.maxWriteRequestOperationCount = maxWriteRequestOperationCount; |
| 88 | + } |
| 89 | + |
| 90 | + public ByteSizeValue getMaxWriteRequestSize() { |
| 91 | + return maxWriteRequestSize; |
| 92 | + } |
| 93 | + |
| 94 | + public void setMaxWriteRequestSize(ByteSizeValue maxWriteRequestSize) { |
| 95 | + this.maxWriteRequestSize = maxWriteRequestSize; |
| 96 | + } |
| 97 | + |
| 98 | + public Integer getMaxOutstandingWriteRequests() { |
| 99 | + return maxOutstandingWriteRequests; |
| 100 | + } |
| 101 | + |
| 102 | + public void setMaxOutstandingWriteRequests(Integer maxOutstandingWriteRequests) { |
| 103 | + this.maxOutstandingWriteRequests = maxOutstandingWriteRequests; |
| 104 | + } |
| 105 | + |
| 106 | + public Integer getMaxWriteBufferCount() { |
| 107 | + return maxWriteBufferCount; |
| 108 | + } |
| 109 | + |
| 110 | + public void setMaxWriteBufferCount(Integer maxWriteBufferCount) { |
| 111 | + this.maxWriteBufferCount = maxWriteBufferCount; |
| 112 | + } |
| 113 | + |
| 114 | + public ByteSizeValue getMaxWriteBufferSize() { |
| 115 | + return maxWriteBufferSize; |
| 116 | + } |
| 117 | + |
| 118 | + public void setMaxWriteBufferSize(ByteSizeValue maxWriteBufferSize) { |
| 119 | + this.maxWriteBufferSize = maxWriteBufferSize; |
| 120 | + } |
| 121 | + |
| 122 | + public TimeValue getMaxRetryDelay() { |
| 123 | + return maxRetryDelay; |
| 124 | + } |
| 125 | + |
| 126 | + public void setMaxRetryDelay(TimeValue maxRetryDelay) { |
| 127 | + this.maxRetryDelay = maxRetryDelay; |
| 128 | + } |
| 129 | + |
| 130 | + public TimeValue getReadPollTimeout() { |
| 131 | + return readPollTimeout; |
| 132 | + } |
| 133 | + |
| 134 | + public void setReadPollTimeout(TimeValue readPollTimeout) { |
| 135 | + this.readPollTimeout = readPollTimeout; |
| 136 | + } |
| 137 | + |
| 138 | + void toXContentFragment(XContentBuilder builder, ToXContent.Params params) throws IOException { |
| 139 | + if (maxReadRequestOperationCount != null) { |
| 140 | + builder.field(MAX_READ_REQUEST_OPERATION_COUNT.getPreferredName(), maxReadRequestOperationCount); |
| 141 | + } |
| 142 | + if (maxReadRequestSize != null) { |
| 143 | + builder.field(MAX_READ_REQUEST_SIZE.getPreferredName(), maxReadRequestSize.getStringRep()); |
| 144 | + } |
| 145 | + if (maxWriteRequestOperationCount != null) { |
| 146 | + builder.field(MAX_WRITE_REQUEST_OPERATION_COUNT.getPreferredName(), maxWriteRequestOperationCount); |
| 147 | + } |
| 148 | + if (maxWriteRequestSize != null) { |
| 149 | + builder.field(MAX_WRITE_REQUEST_SIZE.getPreferredName(), maxWriteRequestSize.getStringRep()); |
| 150 | + } |
| 151 | + if (maxWriteBufferCount != null) { |
| 152 | + builder.field(MAX_WRITE_BUFFER_COUNT.getPreferredName(), maxWriteBufferCount); |
| 153 | + } |
| 154 | + if (maxWriteBufferSize != null) { |
| 155 | + builder.field(MAX_WRITE_BUFFER_SIZE.getPreferredName(), maxWriteBufferSize.getStringRep()); |
| 156 | + } |
| 157 | + if (maxOutstandingReadRequests != null) { |
| 158 | + builder.field(MAX_OUTSTANDING_READ_REQUESTS.getPreferredName(), maxOutstandingReadRequests); |
| 159 | + } |
| 160 | + if (maxOutstandingWriteRequests != null) { |
| 161 | + builder.field(MAX_OUTSTANDING_WRITE_REQUESTS.getPreferredName(), maxOutstandingWriteRequests); |
| 162 | + } |
| 163 | + if (maxRetryDelay != null) { |
| 164 | + builder.field(MAX_RETRY_DELAY_FIELD.getPreferredName(), maxRetryDelay.getStringRep()); |
| 165 | + } |
| 166 | + if (readPollTimeout != null) { |
| 167 | + builder.field(READ_POLL_TIMEOUT.getPreferredName(), readPollTimeout.getStringRep()); |
| 168 | + } |
| 169 | + } |
| 170 | + |
| 171 | + @Override |
| 172 | + public boolean equals(Object o) { |
| 173 | + if (this == o) return true; |
| 174 | + if (o == null || getClass() != o.getClass()) return false; |
| 175 | + FollowConfig that = (FollowConfig) o; |
| 176 | + return Objects.equals(maxReadRequestOperationCount, that.maxReadRequestOperationCount) && |
| 177 | + Objects.equals(maxOutstandingReadRequests, that.maxOutstandingReadRequests) && |
| 178 | + Objects.equals(maxReadRequestSize, that.maxReadRequestSize) && |
| 179 | + Objects.equals(maxWriteRequestOperationCount, that.maxWriteRequestOperationCount) && |
| 180 | + Objects.equals(maxWriteRequestSize, that.maxWriteRequestSize) && |
| 181 | + Objects.equals(maxOutstandingWriteRequests, that.maxOutstandingWriteRequests) && |
| 182 | + Objects.equals(maxWriteBufferCount, that.maxWriteBufferCount) && |
| 183 | + Objects.equals(maxWriteBufferSize, that.maxWriteBufferSize) && |
| 184 | + Objects.equals(maxRetryDelay, that.maxRetryDelay) && |
| 185 | + Objects.equals(readPollTimeout, that.readPollTimeout); |
| 186 | + } |
| 187 | + |
| 188 | + @Override |
| 189 | + public int hashCode() { |
| 190 | + return Objects.hash( |
| 191 | + maxReadRequestOperationCount, |
| 192 | + maxOutstandingReadRequests, |
| 193 | + maxReadRequestSize, |
| 194 | + maxWriteRequestOperationCount, |
| 195 | + maxWriteRequestSize, |
| 196 | + maxOutstandingWriteRequests, |
| 197 | + maxWriteBufferCount, |
| 198 | + maxWriteBufferSize, |
| 199 | + maxRetryDelay, |
| 200 | + readPollTimeout |
| 201 | + ); |
| 202 | + } |
| 203 | +} |
0 commit comments