|
9 | 9 | import org.elasticsearch.ElasticsearchException;
|
10 | 10 | import org.elasticsearch.common.ParseField;
|
11 | 11 | import org.elasticsearch.common.Strings;
|
| 12 | +import org.elasticsearch.common.collect.Tuple; |
12 | 13 | import org.elasticsearch.common.io.stream.StreamInput;
|
13 | 14 | import org.elasticsearch.common.io.stream.StreamOutput;
|
14 | 15 | import org.elasticsearch.common.unit.ByteSizeUnit;
|
@@ -84,17 +85,17 @@ public class ShardFollowNodeTaskStatus implements Task.Status {
|
84 | 85 | (long) args[19],
|
85 | 86 | (long) args[20],
|
86 | 87 | new TreeMap<>(
|
87 |
| - ((List<Map.Entry<Long, ElasticsearchException>>) args[21]) |
| 88 | + ((List<Map.Entry<Long, Tuple<Integer, ElasticsearchException>>>) args[21]) |
88 | 89 | .stream()
|
89 | 90 | .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))),
|
90 | 91 | (long) args[22]));
|
91 | 92 |
|
92 | 93 | public static final String FETCH_EXCEPTIONS_ENTRY_PARSER_NAME = "shard-follow-node-task-status-fetch-exceptions-entry";
|
93 | 94 |
|
94 |
| - static final ConstructingObjectParser<Map.Entry<Long, ElasticsearchException>, Void> FETCH_EXCEPTIONS_ENTRY_PARSER = |
| 95 | + static final ConstructingObjectParser<Map.Entry<Long, Tuple<Integer, ElasticsearchException>>, Void> FETCH_EXCEPTIONS_ENTRY_PARSER = |
95 | 96 | new ConstructingObjectParser<>(
|
96 | 97 | FETCH_EXCEPTIONS_ENTRY_PARSER_NAME,
|
97 |
| - args -> new AbstractMap.SimpleEntry<>((long) args[0], (ElasticsearchException) args[1])); |
| 98 | + args -> new AbstractMap.SimpleEntry<>((long) args[0], Tuple.tuple((Integer)args[1], (ElasticsearchException)args[2]))); |
98 | 99 |
|
99 | 100 | static {
|
100 | 101 | STATUS_PARSER.declareString(ConstructingObjectParser.constructorArg(), LEADER_INDEX);
|
@@ -123,10 +124,12 @@ public class ShardFollowNodeTaskStatus implements Task.Status {
|
123 | 124 | }
|
124 | 125 |
|
125 | 126 | static final ParseField FETCH_EXCEPTIONS_ENTRY_FROM_SEQ_NO = new ParseField("from_seq_no");
|
| 127 | + static final ParseField FETCH_EXCEPTIONS_RETRIES = new ParseField("retries"); |
126 | 128 | static final ParseField FETCH_EXCEPTIONS_ENTRY_EXCEPTION = new ParseField("exception");
|
127 | 129 |
|
128 | 130 | static {
|
129 | 131 | FETCH_EXCEPTIONS_ENTRY_PARSER.declareLong(ConstructingObjectParser.constructorArg(), FETCH_EXCEPTIONS_ENTRY_FROM_SEQ_NO);
|
| 132 | + FETCH_EXCEPTIONS_ENTRY_PARSER.declareInt(ConstructingObjectParser.constructorArg(), FETCH_EXCEPTIONS_RETRIES); |
130 | 133 | FETCH_EXCEPTIONS_ENTRY_PARSER.declareObject(
|
131 | 134 | ConstructingObjectParser.constructorArg(),
|
132 | 135 | (p, c) -> ElasticsearchException.fromXContent(p),
|
@@ -259,9 +262,9 @@ public long numberOfOperationsIndexed() {
|
259 | 262 | return numberOfOperationsIndexed;
|
260 | 263 | }
|
261 | 264 |
|
262 |
| - private final NavigableMap<Long, ElasticsearchException> fetchExceptions; |
| 265 | + private final NavigableMap<Long, Tuple<Integer, ElasticsearchException>> fetchExceptions; |
263 | 266 |
|
264 |
| - public NavigableMap<Long, ElasticsearchException> fetchExceptions() { |
| 267 | + public NavigableMap<Long, Tuple<Integer, ElasticsearchException>> fetchExceptions() { |
265 | 268 | return fetchExceptions;
|
266 | 269 | }
|
267 | 270 |
|
@@ -293,7 +296,7 @@ public ShardFollowNodeTaskStatus(
|
293 | 296 | final long numberOfSuccessfulBulkOperations,
|
294 | 297 | final long numberOfFailedBulkOperations,
|
295 | 298 | final long numberOfOperationsIndexed,
|
296 |
| - final NavigableMap<Long, ElasticsearchException> fetchExceptions, |
| 299 | + final NavigableMap<Long, Tuple<Integer, ElasticsearchException>> fetchExceptions, |
297 | 300 | final long timeSinceLastFetchMillis) {
|
298 | 301 | this.leaderIndex = leaderIndex;
|
299 | 302 | this.followerIndex = followerIndex;
|
@@ -342,7 +345,8 @@ public ShardFollowNodeTaskStatus(final StreamInput in) throws IOException {
|
342 | 345 | this.numberOfSuccessfulBulkOperations = in.readVLong();
|
343 | 346 | this.numberOfFailedBulkOperations = in.readVLong();
|
344 | 347 | this.numberOfOperationsIndexed = in.readVLong();
|
345 |
| - this.fetchExceptions = new TreeMap<>(in.readMap(StreamInput::readVLong, StreamInput::readException)); |
| 348 | + this.fetchExceptions = |
| 349 | + new TreeMap<>(in.readMap(StreamInput::readVLong, stream -> Tuple.tuple(stream.readVInt(), stream.readException()))); |
346 | 350 | this.timeSinceLastFetchMillis = in.readZLong();
|
347 | 351 | }
|
348 | 352 |
|
@@ -374,7 +378,10 @@ public void writeTo(final StreamOutput out) throws IOException {
|
374 | 378 | out.writeVLong(numberOfSuccessfulBulkOperations);
|
375 | 379 | out.writeVLong(numberOfFailedBulkOperations);
|
376 | 380 | out.writeVLong(numberOfOperationsIndexed);
|
377 |
| - out.writeMap(fetchExceptions, StreamOutput::writeVLong, StreamOutput::writeException); |
| 381 | + out.writeMap( |
| 382 | + fetchExceptions, |
| 383 | + StreamOutput::writeVLong, |
| 384 | + (stream, value) -> { stream.writeVInt(value.v1()); stream.writeException(value.v2()); }); |
378 | 385 | out.writeZLong(timeSinceLastFetchMillis);
|
379 | 386 | }
|
380 | 387 |
|
@@ -421,14 +428,15 @@ public XContentBuilder toXContentFragment(final XContentBuilder builder, final P
|
421 | 428 | builder.field(NUMBER_OF_OPERATIONS_INDEXED_FIELD.getPreferredName(), numberOfOperationsIndexed);
|
422 | 429 | builder.startArray(FETCH_EXCEPTIONS.getPreferredName());
|
423 | 430 | {
|
424 |
| - for (final Map.Entry<Long, ElasticsearchException> entry : fetchExceptions.entrySet()) { |
| 431 | + for (final Map.Entry<Long, Tuple<Integer, ElasticsearchException>> entry : fetchExceptions.entrySet()) { |
425 | 432 | builder.startObject();
|
426 | 433 | {
|
427 | 434 | builder.field(FETCH_EXCEPTIONS_ENTRY_FROM_SEQ_NO.getPreferredName(), entry.getKey());
|
| 435 | + builder.field(FETCH_EXCEPTIONS_RETRIES.getPreferredName(), entry.getValue().v1()); |
428 | 436 | builder.field(FETCH_EXCEPTIONS_ENTRY_EXCEPTION.getPreferredName());
|
429 | 437 | builder.startObject();
|
430 | 438 | {
|
431 |
| - ElasticsearchException.generateThrowableXContent(builder, params, entry.getValue()); |
| 439 | + ElasticsearchException.generateThrowableXContent(builder, params, entry.getValue().v2()); |
432 | 440 | }
|
433 | 441 | builder.endObject();
|
434 | 442 | }
|
@@ -515,7 +523,7 @@ public int hashCode() {
|
515 | 523 | }
|
516 | 524 |
|
517 | 525 | private static List<String> getFetchExceptionMessages(final ShardFollowNodeTaskStatus status) {
|
518 |
| - return status.fetchExceptions().values().stream().map(ElasticsearchException::getMessage).collect(Collectors.toList()); |
| 526 | + return status.fetchExceptions().values().stream().map(t -> t.v2().getMessage()).collect(Collectors.toList()); |
519 | 527 | }
|
520 | 528 |
|
521 | 529 | public String toString() {
|
|
0 commit comments