Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
idegtiarenko committed Jan 17, 2024
1 parent 04e9863 commit c1367fd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -308,14 +308,12 @@ public void testInvalidNodes() throws Exception {
IndexShardRoutingTable.Builder wrongRoutingTableBuilder = new IndexShardRoutingTable.Builder(shardId);
for (int i = 0; i < routingTable.size(); i++) {
ShardRouting shardRouting = routingTable.shard(i);
ShardRouting wrongShardRouting = aShardRouting(
shardId,
shardRouting.currentNodeId() + randomIntBetween(10, 100),
shardRouting.relocatingNodeId(),
shardRouting.primary(),
shardRouting.state(),
shardRouting.unassignedInfo()
).withRole(shardRouting.role()).build();
String currentNodeId = shardRouting.currentNodeId() + randomIntBetween(10, 100);
ShardRouting wrongShardRouting = aShardRouting(shardId, currentNodeId, shardRouting.primary(), shardRouting.state())
.withRelocatingNodeId(shardRouting.relocatingNodeId())
.withUnassignedInfo(shardRouting.unassignedInfo())
.withRole(shardRouting.role())
.build();
wrongRoutingTableBuilder.addShard(wrongShardRouting);
}
IndexShardRoutingTable wrongRoutingTable = wrongRoutingTableBuilder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,10 @@ public static ClusterState state(
unassignedInfo = new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, null);
}
indexShardRoutingBuilder.addShard(
aShardRouting(index, 0, primaryNode, relocatingNode, true, primaryState, unassignedInfo).withRole(primaryRole).build()
aShardRouting(index, 0, primaryNode, true, primaryState).withRelocatingNodeId(relocatingNode)
.withUnassignedInfo(unassignedInfo)
.withRole(primaryRole)
.build()
);

for (var replicaState : replicaStates) {
Expand All @@ -192,9 +195,10 @@ public static ClusterState state(
unassignedInfo = new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, null);
}
indexShardRoutingBuilder.addShard(
aShardRouting(index, shardId.id(), replicaNode, relocatingNode, false, replicaState.v1(), unassignedInfo).withRole(
replicaState.v2()
).build()
aShardRouting(index, shardId.id(), replicaNode, false, replicaState.v1()).withRelocatingNodeId(relocatingNode)
.withUnassignedInfo(unassignedInfo)
.withRole(replicaState.v2())
.build()
);
}
final IndexShardRoutingTable indexShardRoutingTable = indexShardRoutingBuilder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,32 +41,6 @@ public static Builder aShardRouting(ShardId shardId, String currentNodeId, boole
return new Builder(shardId, currentNodeId, primary, state);
}

public static Builder aShardRouting(
String index,
int shardId,
String currentNodeId,
String relocatingNodeId,
boolean primary,
ShardRoutingState state,
UnassignedInfo unassignedInfo
) {
return new Builder(new ShardId(index, IndexMetadata.INDEX_UUID_NA_VALUE, shardId), currentNodeId, primary, state)
.withRelocatingNodeId(relocatingNodeId)
.withUnassignedInfo(unassignedInfo);
}

public static Builder aShardRouting(
ShardId shardId,
String currentNodeId,
String relocatingNodeId,
boolean primary,
ShardRoutingState state,
UnassignedInfo unassignedInfo
) {
return new Builder(shardId, currentNodeId, primary, state).withRelocatingNodeId(relocatingNodeId)
.withUnassignedInfo(unassignedInfo);
}

public static class Builder {

private final ShardId shardId;
Expand Down

0 comments on commit c1367fd

Please sign in to comment.