parent
5881322b3f
commit
c394eb9ae9
|
@ -380,6 +380,11 @@ public class IndexShard extends AbstractIndexShardComponent implements IndicesCl
|
|||
return this.pendingPrimaryTerm;
|
||||
}
|
||||
|
||||
/** Returns the primary term that is currently being used to assign to operations */
|
||||
public long getOperationPrimaryTerm() {
|
||||
return this.operationPrimaryTerm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the latest cluster routing entry received with this shard.
|
||||
*/
|
||||
|
|
|
@ -78,7 +78,7 @@ public class TransportBulkShardOperationsAction
|
|||
index.type(),
|
||||
index.id(),
|
||||
index.seqNo(),
|
||||
primary.getPrimaryTerm(),
|
||||
primary.getOperationPrimaryTerm(),
|
||||
index.version(),
|
||||
BytesReference.toBytes(index.source()),
|
||||
index.routing(),
|
||||
|
@ -91,12 +91,12 @@ public class TransportBulkShardOperationsAction
|
|||
delete.id(),
|
||||
delete.uid(),
|
||||
delete.seqNo(),
|
||||
primary.getPrimaryTerm(),
|
||||
primary.getOperationPrimaryTerm(),
|
||||
delete.version());
|
||||
break;
|
||||
case NO_OP:
|
||||
final Translog.NoOp noOp = (Translog.NoOp) operation;
|
||||
operationWithPrimaryTerm = new Translog.NoOp(noOp.seqNo(), primary.getPrimaryTerm(), noOp.reason());
|
||||
operationWithPrimaryTerm = new Translog.NoOp(noOp.seqNo(), primary.getOperationPrimaryTerm(), noOp.reason());
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("unexpected operation type [" + operation.opType() + "]");
|
||||
|
|
|
@ -65,12 +65,12 @@ public class BulkShardOperationsTests extends IndexShardTestCase {
|
|||
assertThat(snapshot.totalOperations(), equalTo(operations.size()));
|
||||
Translog.Operation operation;
|
||||
while ((operation = snapshot.next()) != null) {
|
||||
assertThat(operation.primaryTerm(), equalTo(followerPrimary.getPrimaryTerm()));
|
||||
assertThat(operation.primaryTerm(), equalTo(followerPrimary.getOperationPrimaryTerm()));
|
||||
}
|
||||
}
|
||||
|
||||
for (final Translog.Operation operation : result.replicaRequest().getOperations()) {
|
||||
assertThat(operation.primaryTerm(), equalTo(followerPrimary.getPrimaryTerm()));
|
||||
assertThat(operation.primaryTerm(), equalTo(followerPrimary.getOperationPrimaryTerm()));
|
||||
}
|
||||
|
||||
closeShards(followerPrimary);
|
||||
|
|
|
@ -57,7 +57,7 @@ public class FollowEngineIndexShardTests extends IndexShardTestCase {
|
|||
true,
|
||||
ShardRoutingState.STARTED,
|
||||
replicaRouting.allocationId());
|
||||
indexShard.updateShardState(primaryRouting, indexShard.getPrimaryTerm() + 1, (shard, listener) -> {},
|
||||
indexShard.updateShardState(primaryRouting, indexShard.getOperationPrimaryTerm() + 1, (shard, listener) -> {},
|
||||
0L, Collections.singleton(primaryRouting.allocationId().getId()),
|
||||
new IndexShardRoutingTable.Builder(primaryRouting.shardId()).addShard(primaryRouting).build(), Collections.emptySet());
|
||||
|
||||
|
|
Loading…
Reference in New Issue