|
@@ -94,7 +94,7 @@ public class AllocationCommandsTests extends ESAllocationTestCase {
|
|
|
} else {
|
|
|
toNodeId = "node1";
|
|
|
}
|
|
|
- rerouteResult = allocation.reroute(clusterState, new AllocationCommands(new MoveAllocationCommand("test", 0, existingNodeId, toNodeId)));
|
|
|
+ rerouteResult = allocation.reroute(clusterState, new AllocationCommands(new MoveAllocationCommand("test", 0, existingNodeId, toNodeId)), false, false);
|
|
|
assertThat(rerouteResult.changed(), equalTo(true));
|
|
|
clusterState = ClusterState.builder(clusterState).routingTable(rerouteResult.routingTable()).build();
|
|
|
assertThat(clusterState.getRoutingNodes().node(existingNodeId).iterator().next().state(), equalTo(ShardRoutingState.RELOCATING));
|
|
@@ -148,7 +148,7 @@ public class AllocationCommandsTests extends ESAllocationTestCase {
|
|
|
|
|
|
logger.info("--> allocating to non-existent node, should fail");
|
|
|
try {
|
|
|
- allocation.reroute(clusterState, new AllocationCommands(randomAllocateCommand(index, shardId.id(), "node42")));
|
|
|
+ allocation.reroute(clusterState, new AllocationCommands(randomAllocateCommand(index, shardId.id(), "node42")), false, false);
|
|
|
fail("expected IllegalArgumentException when allocating to non-existing node");
|
|
|
} catch (IllegalArgumentException e) {
|
|
|
assertThat(e.getMessage(), containsString("failed to resolve [node42], no matching nodes"));
|
|
@@ -156,7 +156,7 @@ public class AllocationCommandsTests extends ESAllocationTestCase {
|
|
|
|
|
|
logger.info("--> allocating to non-data node, should fail");
|
|
|
try {
|
|
|
- allocation.reroute(clusterState, new AllocationCommands(randomAllocateCommand(index, shardId.id(), "node4")));
|
|
|
+ allocation.reroute(clusterState, new AllocationCommands(randomAllocateCommand(index, shardId.id(), "node4")), false, false);
|
|
|
fail("expected IllegalArgumentException when allocating to non-data node");
|
|
|
} catch (IllegalArgumentException e) {
|
|
|
assertThat(e.getMessage(), containsString("allocation can only be done on data nodes"));
|
|
@@ -164,7 +164,7 @@ public class AllocationCommandsTests extends ESAllocationTestCase {
|
|
|
|
|
|
logger.info("--> allocating non-existing shard, should fail");
|
|
|
try {
|
|
|
- allocation.reroute(clusterState, new AllocationCommands(randomAllocateCommand("test", 1, "node2")));
|
|
|
+ allocation.reroute(clusterState, new AllocationCommands(randomAllocateCommand("test", 1, "node2")), false, false);
|
|
|
fail("expected ShardNotFoundException when allocating non-existing shard");
|
|
|
} catch (ShardNotFoundException e) {
|
|
|
assertThat(e.getMessage(), containsString("no such shard"));
|
|
@@ -172,7 +172,7 @@ public class AllocationCommandsTests extends ESAllocationTestCase {
|
|
|
|
|
|
logger.info("--> allocating non-existing index, should fail");
|
|
|
try {
|
|
|
- allocation.reroute(clusterState, new AllocationCommands(randomAllocateCommand("test2", 0, "node2")));
|
|
|
+ allocation.reroute(clusterState, new AllocationCommands(randomAllocateCommand("test2", 0, "node2")), false, false);
|
|
|
fail("expected ShardNotFoundException when allocating non-existing index");
|
|
|
} catch (IndexNotFoundException e) {
|
|
|
assertThat(e.getMessage(), containsString("no such index"));
|
|
@@ -180,7 +180,7 @@ public class AllocationCommandsTests extends ESAllocationTestCase {
|
|
|
|
|
|
logger.info("--> allocating empty primary with acceptDataLoss flag set to false");
|
|
|
try {
|
|
|
- allocation.reroute(clusterState, new AllocationCommands(new AllocateEmptyPrimaryAllocationCommand("test", 0, "node1", false)));
|
|
|
+ allocation.reroute(clusterState, new AllocationCommands(new AllocateEmptyPrimaryAllocationCommand("test", 0, "node1", false)), false, false);
|
|
|
fail("expected IllegalArgumentException when allocating empty primary with acceptDataLoss flag set to false");
|
|
|
} catch (IllegalArgumentException e) {
|
|
|
assertThat(e.getMessage(), containsString("allocating an empty primary for " + shardId + " can result in data loss. Please confirm by setting the accept_data_loss parameter to true"));
|
|
@@ -188,14 +188,14 @@ public class AllocationCommandsTests extends ESAllocationTestCase {
|
|
|
|
|
|
logger.info("--> allocating stale primary with acceptDataLoss flag set to false");
|
|
|
try {
|
|
|
- allocation.reroute(clusterState, new AllocationCommands(new AllocateStalePrimaryAllocationCommand(index, shardId.id(), "node1", false)));
|
|
|
+ allocation.reroute(clusterState, new AllocationCommands(new AllocateStalePrimaryAllocationCommand(index, shardId.id(), "node1", false)), false, false);
|
|
|
fail("expected IllegalArgumentException when allocating stale primary with acceptDataLoss flag set to false");
|
|
|
} catch (IllegalArgumentException e) {
|
|
|
assertThat(e.getMessage(), containsString("allocating an empty primary for " + shardId + " can result in data loss. Please confirm by setting the accept_data_loss parameter to true"));
|
|
|
}
|
|
|
|
|
|
logger.info("--> allocating empty primary with acceptDataLoss flag set to true");
|
|
|
- rerouteResult = allocation.reroute(clusterState, new AllocationCommands(new AllocateEmptyPrimaryAllocationCommand("test", 0, "node1", true)));
|
|
|
+ rerouteResult = allocation.reroute(clusterState, new AllocationCommands(new AllocateEmptyPrimaryAllocationCommand("test", 0, "node1", true)), false, false);
|
|
|
assertThat(rerouteResult.changed(), equalTo(true));
|
|
|
clusterState = ClusterState.builder(clusterState).routingTable(rerouteResult.routingTable()).build();
|
|
|
assertThat(clusterState.getRoutingNodes().node("node1").size(), equalTo(1));
|
|
@@ -211,13 +211,13 @@ public class AllocationCommandsTests extends ESAllocationTestCase {
|
|
|
|
|
|
logger.info("--> allocate the replica shard on the primary shard node, should fail");
|
|
|
try {
|
|
|
- allocation.reroute(clusterState, new AllocationCommands(new AllocateReplicaAllocationCommand("test", 0, "node1")));
|
|
|
+ allocation.reroute(clusterState, new AllocationCommands(new AllocateReplicaAllocationCommand("test", 0, "node1")), false, false);
|
|
|
fail("expected IllegalArgumentException when allocating replica shard on the primary shard node");
|
|
|
} catch (IllegalArgumentException e) {
|
|
|
}
|
|
|
|
|
|
logger.info("--> allocate the replica shard on on the second node");
|
|
|
- rerouteResult = allocation.reroute(clusterState, new AllocationCommands(new AllocateReplicaAllocationCommand("test", 0, "node2")));
|
|
|
+ rerouteResult = allocation.reroute(clusterState, new AllocationCommands(new AllocateReplicaAllocationCommand("test", 0, "node2")), false, false);
|
|
|
assertThat(rerouteResult.changed(), equalTo(true));
|
|
|
clusterState = ClusterState.builder(clusterState).routingTable(rerouteResult.routingTable()).build();
|
|
|
assertThat(clusterState.getRoutingNodes().node("node1").size(), equalTo(1));
|
|
@@ -236,7 +236,7 @@ public class AllocationCommandsTests extends ESAllocationTestCase {
|
|
|
|
|
|
logger.info("--> verify that we fail when there are no unassigned shards");
|
|
|
try {
|
|
|
- allocation.reroute(clusterState, new AllocationCommands(randomAllocateCommand("test", 0, "node3")));
|
|
|
+ allocation.reroute(clusterState, new AllocationCommands(randomAllocateCommand("test", 0, "node3")), false, false);
|
|
|
fail("expected IllegalArgumentException when allocating shard while no unassigned shard available");
|
|
|
} catch (IllegalArgumentException e) {
|
|
|
}
|
|
@@ -268,7 +268,7 @@ public class AllocationCommandsTests extends ESAllocationTestCase {
|
|
|
assertThat(clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size(), equalTo(0));
|
|
|
|
|
|
logger.info("--> allocating empty primary shard with accept_data_loss flag set to true");
|
|
|
- rerouteResult = allocation.reroute(clusterState, new AllocationCommands(new AllocateEmptyPrimaryAllocationCommand("test", 0, "node1", true)));
|
|
|
+ rerouteResult = allocation.reroute(clusterState, new AllocationCommands(new AllocateEmptyPrimaryAllocationCommand("test", 0, "node1", true)), false, false);
|
|
|
assertThat(rerouteResult.changed(), equalTo(true));
|
|
|
clusterState = ClusterState.builder(clusterState).routingTable(rerouteResult.routingTable()).build();
|
|
|
assertThat(clusterState.getRoutingNodes().node("node1").size(), equalTo(1));
|
|
@@ -277,7 +277,7 @@ public class AllocationCommandsTests extends ESAllocationTestCase {
|
|
|
|
|
|
logger.info("--> cancel primary allocation, make sure it fails...");
|
|
|
try {
|
|
|
- allocation.reroute(clusterState, new AllocationCommands(new CancelAllocationCommand("test", 0, "node1", false)));
|
|
|
+ allocation.reroute(clusterState, new AllocationCommands(new CancelAllocationCommand("test", 0, "node1", false)), false, false);
|
|
|
fail();
|
|
|
} catch (IllegalArgumentException e) {
|
|
|
}
|
|
@@ -291,13 +291,13 @@ public class AllocationCommandsTests extends ESAllocationTestCase {
|
|
|
|
|
|
logger.info("--> cancel primary allocation, make sure it fails...");
|
|
|
try {
|
|
|
- allocation.reroute(clusterState, new AllocationCommands(new CancelAllocationCommand("test", 0, "node1", false)));
|
|
|
+ allocation.reroute(clusterState, new AllocationCommands(new CancelAllocationCommand("test", 0, "node1", false)), false, false);
|
|
|
fail();
|
|
|
} catch (IllegalArgumentException e) {
|
|
|
}
|
|
|
|
|
|
logger.info("--> allocate the replica shard on on the second node");
|
|
|
- rerouteResult = allocation.reroute(clusterState, new AllocationCommands(new AllocateReplicaAllocationCommand("test", 0, "node2")));
|
|
|
+ rerouteResult = allocation.reroute(clusterState, new AllocationCommands(new AllocateReplicaAllocationCommand("test", 0, "node2")), false, false);
|
|
|
assertThat(rerouteResult.changed(), equalTo(true));
|
|
|
clusterState = ClusterState.builder(clusterState).routingTable(rerouteResult.routingTable()).build();
|
|
|
assertThat(clusterState.getRoutingNodes().node("node1").size(), equalTo(1));
|
|
@@ -306,7 +306,7 @@ public class AllocationCommandsTests extends ESAllocationTestCase {
|
|
|
assertThat(clusterState.getRoutingNodes().node("node2").shardsWithState(INITIALIZING).size(), equalTo(1));
|
|
|
|
|
|
logger.info("--> cancel the relocation allocation");
|
|
|
- rerouteResult = allocation.reroute(clusterState, new AllocationCommands(new CancelAllocationCommand("test", 0, "node2", false)));
|
|
|
+ rerouteResult = allocation.reroute(clusterState, new AllocationCommands(new CancelAllocationCommand("test", 0, "node2", false)), false, false);
|
|
|
assertThat(rerouteResult.changed(), equalTo(true));
|
|
|
clusterState = ClusterState.builder(clusterState).routingTable(rerouteResult.routingTable()).build();
|
|
|
assertThat(clusterState.getRoutingNodes().node("node1").size(), equalTo(1));
|
|
@@ -315,7 +315,7 @@ public class AllocationCommandsTests extends ESAllocationTestCase {
|
|
|
assertThat(clusterState.getRoutingNodes().node("node3").size(), equalTo(0));
|
|
|
|
|
|
logger.info("--> allocate the replica shard on on the second node");
|
|
|
- rerouteResult = allocation.reroute(clusterState, new AllocationCommands(new AllocateReplicaAllocationCommand("test", 0, "node2")));
|
|
|
+ rerouteResult = allocation.reroute(clusterState, new AllocationCommands(new AllocateReplicaAllocationCommand("test", 0, "node2")), false, false);
|
|
|
assertThat(rerouteResult.changed(), equalTo(true));
|
|
|
clusterState = ClusterState.builder(clusterState).routingTable(rerouteResult.routingTable()).build();
|
|
|
assertThat(clusterState.getRoutingNodes().node("node1").size(), equalTo(1));
|
|
@@ -325,7 +325,7 @@ public class AllocationCommandsTests extends ESAllocationTestCase {
|
|
|
|
|
|
logger.info("--> cancel the primary being replicated, make sure it fails");
|
|
|
try {
|
|
|
- allocation.reroute(clusterState, new AllocationCommands(new CancelAllocationCommand("test", 0, "node1", false)));
|
|
|
+ allocation.reroute(clusterState, new AllocationCommands(new CancelAllocationCommand("test", 0, "node1", false)), false, false);
|
|
|
fail();
|
|
|
} catch (IllegalArgumentException e) {
|
|
|
}
|
|
@@ -339,7 +339,7 @@ public class AllocationCommandsTests extends ESAllocationTestCase {
|
|
|
assertThat(clusterState.getRoutingNodes().node("node2").shardsWithState(STARTED).size(), equalTo(1));
|
|
|
|
|
|
logger.info("--> cancel allocation of the replica shard");
|
|
|
- rerouteResult = allocation.reroute(clusterState, new AllocationCommands(new CancelAllocationCommand("test", 0, "node2", false)));
|
|
|
+ rerouteResult = allocation.reroute(clusterState, new AllocationCommands(new CancelAllocationCommand("test", 0, "node2", false)), false, false);
|
|
|
assertThat(rerouteResult.changed(), equalTo(true));
|
|
|
clusterState = ClusterState.builder(clusterState).routingTable(rerouteResult.routingTable()).build();
|
|
|
assertThat(clusterState.getRoutingNodes().node("node1").size(), equalTo(1));
|
|
@@ -348,7 +348,7 @@ public class AllocationCommandsTests extends ESAllocationTestCase {
|
|
|
assertThat(clusterState.getRoutingNodes().node("node3").size(), equalTo(0));
|
|
|
|
|
|
logger.info("--> allocate the replica shard on on the second node");
|
|
|
- rerouteResult = allocation.reroute(clusterState, new AllocationCommands(new AllocateReplicaAllocationCommand("test", 0, "node2")));
|
|
|
+ rerouteResult = allocation.reroute(clusterState, new AllocationCommands(new AllocateReplicaAllocationCommand("test", 0, "node2")), false, false);
|
|
|
clusterState = ClusterState.builder(clusterState).routingTable(rerouteResult.routingTable()).build();
|
|
|
assertThat(rerouteResult.changed(), equalTo(true));
|
|
|
assertThat(clusterState.getRoutingNodes().node("node1").size(), equalTo(1));
|
|
@@ -364,7 +364,7 @@ public class AllocationCommandsTests extends ESAllocationTestCase {
|
|
|
assertThat(clusterState.getRoutingNodes().node("node2").shardsWithState(STARTED).size(), equalTo(1));
|
|
|
|
|
|
logger.info("--> move the replica shard");
|
|
|
- rerouteResult = allocation.reroute(clusterState, new AllocationCommands(new MoveAllocationCommand("test", 0, "node2", "node3")));
|
|
|
+ rerouteResult = allocation.reroute(clusterState, new AllocationCommands(new MoveAllocationCommand("test", 0, "node2", "node3")), false, false);
|
|
|
clusterState = ClusterState.builder(clusterState).routingTable(rerouteResult.routingTable()).build();
|
|
|
assertThat(clusterState.getRoutingNodes().node("node1").size(), equalTo(1));
|
|
|
assertThat(clusterState.getRoutingNodes().node("node1").shardsWithState(STARTED).size(), equalTo(1));
|
|
@@ -374,7 +374,7 @@ public class AllocationCommandsTests extends ESAllocationTestCase {
|
|
|
assertThat(clusterState.getRoutingNodes().node("node3").shardsWithState(INITIALIZING).size(), equalTo(1));
|
|
|
|
|
|
logger.info("--> cancel the move of the replica shard");
|
|
|
- rerouteResult = allocation.reroute(clusterState, new AllocationCommands(new CancelAllocationCommand("test", 0, "node3", false)));
|
|
|
+ rerouteResult = allocation.reroute(clusterState, new AllocationCommands(new CancelAllocationCommand("test", 0, "node3", false)), false, false);
|
|
|
clusterState = ClusterState.builder(clusterState).routingTable(rerouteResult.routingTable()).build();
|
|
|
assertThat(clusterState.getRoutingNodes().node("node1").size(), equalTo(1));
|
|
|
assertThat(clusterState.getRoutingNodes().node("node1").shardsWithState(STARTED).size(), equalTo(1));
|
|
@@ -383,7 +383,7 @@ public class AllocationCommandsTests extends ESAllocationTestCase {
|
|
|
|
|
|
|
|
|
logger.info("--> cancel the primary allocation (with allow_primary set to true)");
|
|
|
- rerouteResult = allocation.reroute(clusterState, new AllocationCommands(new CancelAllocationCommand("test", 0, "node1", true)));
|
|
|
+ rerouteResult = allocation.reroute(clusterState, new AllocationCommands(new CancelAllocationCommand("test", 0, "node1", true)), false, false);
|
|
|
clusterState = ClusterState.builder(clusterState).routingTable(rerouteResult.routingTable()).build();
|
|
|
assertThat(rerouteResult.changed(), equalTo(true));
|
|
|
logger.error(clusterState.prettyPrint());
|