Remove reinitShadowPrimary (#26349)
With shadow replicas gone, there is no need to have this method anymore.
This commit is contained in:
parent
0551d2ff68
commit
0390c76f0a
|
@ -748,18 +748,6 @@ public class RoutingNodes implements Iterable<RoutingNode> {
|
|||
assert false : "No shard found to remove";
|
||||
}
|
||||
|
||||
private ShardRouting reinitShadowPrimary(ShardRouting candidate) {
|
||||
if (candidate.relocating()) {
|
||||
cancelRelocation(candidate);
|
||||
}
|
||||
ShardRouting reinitializedShard = candidate.reinitializePrimaryShard();
|
||||
updateAssigned(candidate, reinitializedShard);
|
||||
inactivePrimaryCount++;
|
||||
inactiveShardCount++;
|
||||
addRecovery(reinitializedShard);
|
||||
return reinitializedShard;
|
||||
}
|
||||
|
||||
private ShardRouting reinitReplica(ShardRouting shard) {
|
||||
assert shard.primary() == false : "shard must be a replica: " + shard;
|
||||
assert shard.initializing() : "can only reinitialize an initializing replica: " + shard;
|
||||
|
|
|
@ -384,17 +384,6 @@ public final class ShardRouting implements Writeable, ToXContentObject {
|
|||
AllocationId.finishRelocation(allocationId), expectedShardSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the primary shard from started to initializing
|
||||
*/
|
||||
public ShardRouting reinitializePrimaryShard() {
|
||||
assert state == ShardRoutingState.STARTED : this;
|
||||
assert primary : this;
|
||||
return new ShardRouting(shardId, currentNodeId, null, primary, ShardRoutingState.INITIALIZING,
|
||||
StoreRecoverySource.EXISTING_STORE_INSTANCE, new UnassignedInfo(UnassignedInfo.Reason.REINITIALIZED, null),
|
||||
allocationId, UNAVAILABLE_EXPECTED_SHARD_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reinitializes a replica shard, giving it a fresh allocation id
|
||||
*/
|
||||
|
|
|
@ -109,20 +109,6 @@ public class AllocationIdTests extends ESTestCase {
|
|||
assertThat(shard.allocationId(), nullValue());
|
||||
}
|
||||
|
||||
public void testReinitializing() {
|
||||
logger.info("-- build started shard");
|
||||
ShardRouting shard = ShardRouting.newUnassigned(new ShardId("test","_na_", 0), true, StoreRecoverySource.EXISTING_STORE_INSTANCE, new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, null));
|
||||
shard = shard.initialize("node1", null, -1);
|
||||
shard = shard.moveToStarted();
|
||||
AllocationId allocationId = shard.allocationId();
|
||||
|
||||
logger.info("-- reinitializing shard");
|
||||
shard = shard.reinitializePrimaryShard();
|
||||
assertThat(shard.allocationId().getId(), notNullValue());
|
||||
assertThat(shard.allocationId().getRelocationId(), nullValue());
|
||||
assertThat(shard.allocationId().getId(), equalTo(allocationId.getId()));
|
||||
}
|
||||
|
||||
public void testSerialization() throws IOException {
|
||||
AllocationId allocationId = AllocationId.newInitializing();
|
||||
if (randomBoolean()) {
|
||||
|
|
|
@ -1613,8 +1613,8 @@ public class IndexShardTests extends IndexShardTestCase {
|
|||
target.refresh("test");
|
||||
assertDocs(target, "1");
|
||||
flushShard(source); // only flush source
|
||||
final ShardRouting origRouting = target.routingEntry();
|
||||
ShardRouting routing = ShardRoutingHelper.reinitPrimary(origRouting);
|
||||
ShardRouting routing = ShardRoutingHelper.initWithSameId(target.routingEntry(),
|
||||
RecoverySource.StoreRecoverySource.EXISTING_STORE_INSTANCE);
|
||||
final Snapshot snapshot = new Snapshot("foo", new SnapshotId("bar", UUIDs.randomBase64UUID()));
|
||||
routing = ShardRoutingHelper.newWithRestoreSource(routing,
|
||||
new RecoverySource.SnapshotRecoverySource(snapshot, Version.CURRENT, "test"));
|
||||
|
@ -1676,7 +1676,8 @@ public class IndexShardTests extends IndexShardTestCase {
|
|||
}
|
||||
};
|
||||
closeShards(shard);
|
||||
IndexShard newShard = newShard(ShardRoutingHelper.reinitPrimary(shard.routingEntry()),
|
||||
IndexShard newShard = newShard(
|
||||
ShardRoutingHelper.initWithSameId(shard.routingEntry(), RecoverySource.StoreRecoverySource.EXISTING_STORE_INSTANCE),
|
||||
shard.shardPath(), shard.indexSettings().getIndexMetaData(), wrapper, null);
|
||||
|
||||
recoverShardFromStore(newShard);
|
||||
|
@ -1821,7 +1822,8 @@ public class IndexShardTests extends IndexShardTestCase {
|
|||
};
|
||||
|
||||
closeShards(shard);
|
||||
IndexShard newShard = newShard(ShardRoutingHelper.reinitPrimary(shard.routingEntry()),
|
||||
IndexShard newShard = newShard(
|
||||
ShardRoutingHelper.initWithSameId(shard.routingEntry(), RecoverySource.StoreRecoverySource.EXISTING_STORE_INSTANCE),
|
||||
shard.shardPath(), shard.indexSettings().getIndexMetaData(), wrapper, null);
|
||||
|
||||
recoverShardFromStore(newShard);
|
||||
|
|
|
@ -46,14 +46,6 @@ public class ShardRoutingHelper {
|
|||
return routing.initialize(nodeId, null, expectedSize);
|
||||
}
|
||||
|
||||
public static ShardRouting reinitPrimary(ShardRouting routing) {
|
||||
return routing.reinitializePrimaryShard();
|
||||
}
|
||||
|
||||
public static ShardRouting reinitPrimary(ShardRouting routing, UnassignedInfo.Reason reason, RecoverySource recoverySource) {
|
||||
return routing.reinitializePrimaryShard().updateUnassigned(new UnassignedInfo(reason, "test_reinit"), recoverySource);
|
||||
}
|
||||
|
||||
public static ShardRouting initWithSameId(ShardRouting copy, RecoverySource recoverySource) {
|
||||
return new ShardRouting(copy.shardId(), copy.currentNodeId(), copy.relocatingNodeId(),
|
||||
copy.primary(), ShardRoutingState.INITIALIZING, recoverySource, new UnassignedInfo(UnassignedInfo.Reason.REINITIALIZED, null),
|
||||
|
|
Loading…
Reference in New Issue