Skip to content

Commit 00eb6d9

Browse files
committed
rename and javadocs
1 parent 9c4823b commit 00eb6d9

File tree

7 files changed

+33
-21
lines changed

7 files changed

+33
-21
lines changed

server/src/main/java/org/elasticsearch/indices/recovery/PeerRecoveryTargetService.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,11 +510,13 @@ public void onTimeout(TimeValue timeout) {
510510
request.maxSeenAutoIdTimestampOnPrimary(),
511511
request.maxSeqNoOfUpdatesOrDeletesOnPrimary(),
512512
request.retentionLeases(),
513-
request.mappingVersion(),
513+
request.mappingVersionOnPrimary(),
514514
ActionListener.wrap(
515515
checkpoint -> listener.onResponse(new RecoveryTranslogOperationsResponse(checkpoint)),
516516
e -> {
517-
if (mappingVersionOnTarget < request.mappingVersion() && e instanceof MapperException) {
517+
// do not retry if the mapping on replica is at least as recent as the mapping
518+
// that the primary used to index the operations in the request.
519+
if (mappingVersionOnTarget < request.mappingVersionOnPrimary() && e instanceof MapperException) {
518520
retryOnMappingException.accept(e);
519521
} else {
520522
listener.onFailure(e);

server/src/main/java/org/elasticsearch/indices/recovery/RecoverySourceHandler.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,9 @@ public void recoverToTarget(ActionListener<RecoveryResponse> listener) {
219219
final long maxSeenAutoIdTimestamp = shard.getMaxSeenAutoIdTimestamp();
220220
final long maxSeqNoOfUpdatesOrDeletes = shard.getMaxSeqNoOfUpdatesOrDeletes();
221221
final RetentionLeases retentionLeases = shard.getRetentionLeases();
222-
final long mappingVersion = shard.indexSettings().getIndexMetaData().getMappingVersion();
222+
final long mappingVersionOnPrimary = shard.indexSettings().getIndexMetaData().getMappingVersion();
223223
phase2(startingSeqNo, endingSeqNo, phase2Snapshot, maxSeenAutoIdTimestamp, maxSeqNoOfUpdatesOrDeletes,
224-
retentionLeases, mappingVersion, sendSnapshotStep);
224+
retentionLeases, mappingVersionOnPrimary, sendSnapshotStep);
225225
sendSnapshotStep.whenComplete(
226226
r -> IOUtils.close(phase2Snapshot),
227227
e -> {
@@ -586,7 +586,7 @@ private void sendBatch(
586586
final long maxSeenAutoIdTimestamp,
587587
final long maxSeqNoOfUpdatesOrDeletes,
588588
final RetentionLeases retentionLeases,
589-
final long mappingVersion,
589+
final long mappingVersionOnPrimary,
590590
final ActionListener<Long> listener) throws IOException {
591591
assert ThreadPool.assertCurrentMethodIsNotCalledRecursively();
592592
final List<Translog.Operation> operations = nextBatch.get();
@@ -599,7 +599,7 @@ private void sendBatch(
599599
maxSeenAutoIdTimestamp,
600600
maxSeqNoOfUpdatesOrDeletes,
601601
retentionLeases,
602-
mappingVersion,
602+
mappingVersionOnPrimary,
603603
ActionListener.wrap(
604604
newCheckpoint -> {
605605
sendBatch(
@@ -610,7 +610,7 @@ private void sendBatch(
610610
maxSeenAutoIdTimestamp,
611611
maxSeqNoOfUpdatesOrDeletes,
612612
retentionLeases,
613-
mappingVersion,
613+
mappingVersionOnPrimary,
614614
listener);
615615
},
616616
listener::onFailure

server/src/main/java/org/elasticsearch/indices/recovery/RecoveryTarget.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ public void indexTranslogOperations(
320320
final long maxSeenAutoIdTimestampOnPrimary,
321321
final long maxSeqNoOfDeletesOrUpdatesOnPrimary,
322322
final RetentionLeases retentionLeases,
323-
final long mappingVersion,
323+
final long mappingVersionOnPrimary,
324324
final ActionListener<Long> listener) {
325325
ActionListener.completeWith(listener, () -> {
326326
final RecoveryState.Translog translog = state().getTranslog();

server/src/main/java/org/elasticsearch/indices/recovery/RecoveryTargetHandler.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ public interface RecoveryTargetHandler {
6565
* the primary shard when capturing these operations. This value is at least as high as the
6666
* max_seq_no_of_updates on the primary was when any of these ops were processed on it.
6767
* @param retentionLeases the retention leases on the primary
68+
* @param mappingVersionOnPrimary the mapping version which is at least as up to date as the mapping version that the
69+
* primary used to index translog {@code operations} in this request.
70+
* If the mapping version on the replica is not older this version, we should not retry on
71+
* {@link org.elasticsearch.index.mapper.MapperException}; otherwise we should wait for a
72+
* new mapping then retry.
6873
* @param listener a listener which will be notified with the local checkpoint on the target
6974
* after these operations are successfully indexed on the target.
7075
*/
@@ -74,7 +79,7 @@ void indexTranslogOperations(
7479
long maxSeenAutoIdTimestampOnPrimary,
7580
long maxSeqNoOfUpdatesOrDeletesOnPrimary,
7681
RetentionLeases retentionLeases,
77-
long mappingVersion,
82+
long mappingVersionOnPrimary,
7883
ActionListener<Long> listener);
7984

8085
/**

server/src/main/java/org/elasticsearch/indices/recovery/RecoveryTranslogOperationsRequest.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class RecoveryTranslogOperationsRequest extends TransportRequest {
3939
private final long maxSeenAutoIdTimestampOnPrimary;
4040
private final long maxSeqNoOfUpdatesOrDeletesOnPrimary;
4141
private final RetentionLeases retentionLeases;
42-
private final long mappingVersion;
42+
private final long mappingVersionOnPrimary;
4343

4444
RecoveryTranslogOperationsRequest(
4545
final long recoveryId,
@@ -49,15 +49,15 @@ public class RecoveryTranslogOperationsRequest extends TransportRequest {
4949
final long maxSeenAutoIdTimestampOnPrimary,
5050
final long maxSeqNoOfUpdatesOrDeletesOnPrimary,
5151
final RetentionLeases retentionLeases,
52-
final long mappingVersion) {
52+
final long mappingVersionOnPrimary) {
5353
this.recoveryId = recoveryId;
5454
this.shardId = shardId;
5555
this.operations = operations;
5656
this.totalTranslogOps = totalTranslogOps;
5757
this.maxSeenAutoIdTimestampOnPrimary = maxSeenAutoIdTimestampOnPrimary;
5858
this.maxSeqNoOfUpdatesOrDeletesOnPrimary = maxSeqNoOfUpdatesOrDeletesOnPrimary;
5959
this.retentionLeases = retentionLeases;
60-
this.mappingVersion = mappingVersion;
60+
this.mappingVersionOnPrimary = mappingVersionOnPrimary;
6161
}
6262

6363
public long recoveryId() {
@@ -88,8 +88,13 @@ public RetentionLeases retentionLeases() {
8888
return retentionLeases;
8989
}
9090

91-
public long mappingVersion() {
92-
return mappingVersion;
91+
/**
92+
* Returns the mapping version which is at least as up to date as the mapping version that the primary used to index
93+
* the translog operations in this request. If the mapping version on the replica is not older this version, we should not
94+
* retry on {@link org.elasticsearch.index.mapper.MapperException}; otherwise we should wait for a new mapping then retry.
95+
*/
96+
long mappingVersionOnPrimary() {
97+
return mappingVersionOnPrimary;
9398
}
9499

95100
RecoveryTranslogOperationsRequest(StreamInput in) throws IOException {
@@ -102,9 +107,9 @@ public long mappingVersion() {
102107
maxSeqNoOfUpdatesOrDeletesOnPrimary = in.readZLong();
103108
retentionLeases = new RetentionLeases(in);
104109
if (in.getVersion().onOrAfter(Version.V_8_0_0)) {
105-
mappingVersion = in.readVLong();
110+
mappingVersionOnPrimary = in.readVLong();
106111
} else {
107-
mappingVersion = Long.MAX_VALUE;
112+
mappingVersionOnPrimary = Long.MAX_VALUE;
108113
}
109114
}
110115

@@ -119,7 +124,7 @@ public void writeTo(StreamOutput out) throws IOException {
119124
out.writeZLong(maxSeqNoOfUpdatesOrDeletesOnPrimary);
120125
retentionLeases.writeTo(out);
121126
if (out.getVersion().onOrAfter(Version.V_8_0_0)) {
122-
out.writeVLong(mappingVersion);
127+
out.writeVLong(mappingVersionOnPrimary);
123128
}
124129
}
125130
}

server/src/main/java/org/elasticsearch/indices/recovery/RemoteRecoveryTargetHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public void indexTranslogOperations(
112112
final long maxSeenAutoIdTimestampOnPrimary,
113113
final long maxSeqNoOfDeletesOrUpdatesOnPrimary,
114114
final RetentionLeases retentionLeases,
115-
final long mappingVersion,
115+
final long mappingVersionOnPrimary,
116116
final ActionListener<Long> listener) {
117117
final RecoveryTranslogOperationsRequest request = new RecoveryTranslogOperationsRequest(
118118
recoveryId,
@@ -122,7 +122,7 @@ public void indexTranslogOperations(
122122
maxSeenAutoIdTimestampOnPrimary,
123123
maxSeqNoOfDeletesOrUpdatesOnPrimary,
124124
retentionLeases,
125-
mappingVersion);
125+
mappingVersionOnPrimary);
126126
transportService.submitRequest(targetNode, PeerRecoveryTargetService.Actions.TRANSLOG_OPS, request, translogOpsRequestOptions,
127127
new ActionListenerResponseHandler<>(ActionListener.map(listener, r -> r.localCheckpoint),
128128
RecoveryTranslogOperationsResponse::new, ThreadPool.Names.GENERIC));

test/framework/src/main/java/org/elasticsearch/indices/recovery/AsyncRecoveryTarget.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ public void handoffPrimaryContext(ReplicationTracker.PrimaryContext primaryConte
6363
@Override
6464
public void indexTranslogOperations(List<Translog.Operation> operations, int totalTranslogOps,
6565
long maxSeenAutoIdTimestampOnPrimary, long maxSeqNoOfDeletesOrUpdatesOnPrimary,
66-
RetentionLeases retentionLeases, long mappingVersion, ActionListener<Long> listener) {
66+
RetentionLeases retentionLeases, long mappingVersionOnPrimary, ActionListener<Long> listener) {
6767
executor.execute(() -> target.indexTranslogOperations(operations, totalTranslogOps, maxSeenAutoIdTimestampOnPrimary,
68-
maxSeqNoOfDeletesOrUpdatesOnPrimary, retentionLeases, mappingVersion, listener));
68+
maxSeqNoOfDeletesOrUpdatesOnPrimary, retentionLeases, mappingVersionOnPrimary, listener));
6969
}
7070

7171
@Override

0 commit comments

Comments
 (0)