|
@@ -51,6 +51,7 @@ import org.elasticsearch.common.collect.ImmutableOpenMap;
|
|
|
import org.elasticsearch.common.settings.ClusterSettings;
|
|
import org.elasticsearch.common.settings.ClusterSettings;
|
|
|
import org.elasticsearch.common.settings.Settings;
|
|
import org.elasticsearch.common.settings.Settings;
|
|
|
import org.elasticsearch.index.shard.ShardId;
|
|
import org.elasticsearch.index.shard.ShardId;
|
|
|
|
|
+import org.elasticsearch.snapshots.EmptySnapshotsInfoService;
|
|
|
import org.elasticsearch.test.gateway.TestGatewayAllocator;
|
|
import org.elasticsearch.test.gateway.TestGatewayAllocator;
|
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
@@ -109,7 +110,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
|
|
return clusterInfo;
|
|
return clusterInfo;
|
|
|
};
|
|
};
|
|
|
AllocationService strategy = new AllocationService(deciders,
|
|
AllocationService strategy = new AllocationService(deciders,
|
|
|
- new TestGatewayAllocator(), new BalancedShardsAllocator(Settings.EMPTY), cis);
|
|
|
|
|
|
|
+ new TestGatewayAllocator(), new BalancedShardsAllocator(Settings.EMPTY), cis, EmptySnapshotsInfoService.INSTANCE);
|
|
|
|
|
|
|
|
Metadata metadata = Metadata.builder()
|
|
Metadata metadata = Metadata.builder()
|
|
|
.put(IndexMetadata.builder("test").settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(1))
|
|
.put(IndexMetadata.builder("test").settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(1))
|
|
@@ -188,7 +189,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
|
|
makeDecider(diskSettings))));
|
|
makeDecider(diskSettings))));
|
|
|
|
|
|
|
|
strategy = new AllocationService(deciders, new TestGatewayAllocator(),
|
|
strategy = new AllocationService(deciders, new TestGatewayAllocator(),
|
|
|
- new BalancedShardsAllocator(Settings.EMPTY), cis);
|
|
|
|
|
|
|
+ new BalancedShardsAllocator(Settings.EMPTY), cis, EmptySnapshotsInfoService.INSTANCE);
|
|
|
|
|
|
|
|
clusterState = strategy.reroute(clusterState, "reroute");
|
|
clusterState = strategy.reroute(clusterState, "reroute");
|
|
|
logShardStates(clusterState);
|
|
logShardStates(clusterState);
|
|
@@ -216,7 +217,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
|
|
makeDecider(diskSettings))));
|
|
makeDecider(diskSettings))));
|
|
|
|
|
|
|
|
strategy = new AllocationService(deciders, new TestGatewayAllocator(),
|
|
strategy = new AllocationService(deciders, new TestGatewayAllocator(),
|
|
|
- new BalancedShardsAllocator(Settings.EMPTY), cis);
|
|
|
|
|
|
|
+ new BalancedShardsAllocator(Settings.EMPTY), cis, EmptySnapshotsInfoService.INSTANCE);
|
|
|
|
|
|
|
|
clusterState = strategy.reroute(clusterState, "reroute");
|
|
clusterState = strategy.reroute(clusterState, "reroute");
|
|
|
|
|
|
|
@@ -285,7 +286,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
AllocationService strategy = new AllocationService(deciders, new TestGatewayAllocator(),
|
|
AllocationService strategy = new AllocationService(deciders, new TestGatewayAllocator(),
|
|
|
- new BalancedShardsAllocator(Settings.EMPTY), cis);
|
|
|
|
|
|
|
+ new BalancedShardsAllocator(Settings.EMPTY), cis, EmptySnapshotsInfoService.INSTANCE);
|
|
|
|
|
|
|
|
Metadata metadata = Metadata.builder()
|
|
Metadata metadata = Metadata.builder()
|
|
|
.put(IndexMetadata.builder("test").settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(2))
|
|
.put(IndexMetadata.builder("test").settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(2))
|
|
@@ -331,7 +332,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
|
|
return clusterInfo2;
|
|
return clusterInfo2;
|
|
|
};
|
|
};
|
|
|
strategy = new AllocationService(deciders, new TestGatewayAllocator(),
|
|
strategy = new AllocationService(deciders, new TestGatewayAllocator(),
|
|
|
- new BalancedShardsAllocator(Settings.EMPTY), cis);
|
|
|
|
|
|
|
+ new BalancedShardsAllocator(Settings.EMPTY), cis, EmptySnapshotsInfoService.INSTANCE);
|
|
|
|
|
|
|
|
clusterState = strategy.reroute(clusterState, "reroute");
|
|
clusterState = strategy.reroute(clusterState, "reroute");
|
|
|
logShardStates(clusterState);
|
|
logShardStates(clusterState);
|
|
@@ -393,7 +394,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
|
|
makeDecider(diskSettings))));
|
|
makeDecider(diskSettings))));
|
|
|
|
|
|
|
|
strategy = new AllocationService(deciders, new TestGatewayAllocator(),
|
|
strategy = new AllocationService(deciders, new TestGatewayAllocator(),
|
|
|
- new BalancedShardsAllocator(Settings.EMPTY), cis);
|
|
|
|
|
|
|
+ new BalancedShardsAllocator(Settings.EMPTY), cis, EmptySnapshotsInfoService.INSTANCE);
|
|
|
|
|
|
|
|
clusterState = strategy.reroute(clusterState, "reroute");
|
|
clusterState = strategy.reroute(clusterState, "reroute");
|
|
|
logShardStates(clusterState);
|
|
logShardStates(clusterState);
|
|
@@ -422,7 +423,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
|
|
makeDecider(diskSettings))));
|
|
makeDecider(diskSettings))));
|
|
|
|
|
|
|
|
strategy = new AllocationService(deciders, new TestGatewayAllocator(),
|
|
strategy = new AllocationService(deciders, new TestGatewayAllocator(),
|
|
|
- new BalancedShardsAllocator(Settings.EMPTY), cis);
|
|
|
|
|
|
|
+ new BalancedShardsAllocator(Settings.EMPTY), cis, EmptySnapshotsInfoService.INSTANCE);
|
|
|
|
|
|
|
|
clusterState = strategy.reroute(clusterState, "reroute");
|
|
clusterState = strategy.reroute(clusterState, "reroute");
|
|
|
|
|
|
|
@@ -517,7 +518,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
AllocationService strategy = new AllocationService(deciders, new TestGatewayAllocator(),
|
|
AllocationService strategy = new AllocationService(deciders, new TestGatewayAllocator(),
|
|
|
- new BalancedShardsAllocator(Settings.EMPTY), cis);
|
|
|
|
|
|
|
+ new BalancedShardsAllocator(Settings.EMPTY), cis, EmptySnapshotsInfoService.INSTANCE);
|
|
|
|
|
|
|
|
Metadata metadata = Metadata.builder()
|
|
Metadata metadata = Metadata.builder()
|
|
|
.put(IndexMetadata.builder("test").settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(0))
|
|
.put(IndexMetadata.builder("test").settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(0))
|
|
@@ -577,7 +578,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
AllocationService strategy = new AllocationService(deciders, new TestGatewayAllocator(),
|
|
AllocationService strategy = new AllocationService(deciders, new TestGatewayAllocator(),
|
|
|
- new BalancedShardsAllocator(Settings.EMPTY), cis);
|
|
|
|
|
|
|
+ new BalancedShardsAllocator(Settings.EMPTY), cis, EmptySnapshotsInfoService.INSTANCE);
|
|
|
|
|
|
|
|
Metadata metadata = Metadata.builder()
|
|
Metadata metadata = Metadata.builder()
|
|
|
.put(IndexMetadata.builder("test").settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(0))
|
|
.put(IndexMetadata.builder("test").settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(0))
|
|
@@ -671,7 +672,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
|
|
final ClusterInfoService cis = clusterInfoReference::get;
|
|
final ClusterInfoService cis = clusterInfoReference::get;
|
|
|
|
|
|
|
|
AllocationService strategy = new AllocationService(deciders, new TestGatewayAllocator(),
|
|
AllocationService strategy = new AllocationService(deciders, new TestGatewayAllocator(),
|
|
|
- new BalancedShardsAllocator(Settings.EMPTY), cis);
|
|
|
|
|
|
|
+ new BalancedShardsAllocator(Settings.EMPTY), cis, EmptySnapshotsInfoService.INSTANCE);
|
|
|
|
|
|
|
|
Metadata metadata = Metadata.builder()
|
|
Metadata metadata = Metadata.builder()
|
|
|
.put(IndexMetadata.builder("test").settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(1))
|
|
.put(IndexMetadata.builder("test").settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(1))
|
|
@@ -851,7 +852,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
|
|
);
|
|
);
|
|
|
ClusterState clusterState = ClusterState.builder(baseClusterState).routingTable(builder.build()).build();
|
|
ClusterState clusterState = ClusterState.builder(baseClusterState).routingTable(builder.build()).build();
|
|
|
RoutingAllocation routingAllocation = new RoutingAllocation(null, new RoutingNodes(clusterState), clusterState, clusterInfo,
|
|
RoutingAllocation routingAllocation = new RoutingAllocation(null, new RoutingNodes(clusterState), clusterState, clusterInfo,
|
|
|
- System.nanoTime());
|
|
|
|
|
|
|
+ null, System.nanoTime());
|
|
|
routingAllocation.debugDecision(true);
|
|
routingAllocation.debugDecision(true);
|
|
|
Decision decision = diskThresholdDecider.canRemain(firstRouting, firstRoutingNode, routingAllocation);
|
|
Decision decision = diskThresholdDecider.canRemain(firstRouting, firstRoutingNode, routingAllocation);
|
|
|
assertThat(decision.type(), equalTo(Decision.Type.NO));
|
|
assertThat(decision.type(), equalTo(Decision.Type.NO));
|
|
@@ -877,7 +878,8 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
|
|
)
|
|
)
|
|
|
);
|
|
);
|
|
|
clusterState = ClusterState.builder(baseClusterState).routingTable(builder.build()).build();
|
|
clusterState = ClusterState.builder(baseClusterState).routingTable(builder.build()).build();
|
|
|
- routingAllocation = new RoutingAllocation(null, new RoutingNodes(clusterState), clusterState, clusterInfo, System.nanoTime());
|
|
|
|
|
|
|
+ routingAllocation = new RoutingAllocation(null, new RoutingNodes(clusterState), clusterState, clusterInfo, null,
|
|
|
|
|
+ System.nanoTime());
|
|
|
routingAllocation.debugDecision(true);
|
|
routingAllocation.debugDecision(true);
|
|
|
decision = diskThresholdDecider.canRemain(firstRouting, firstRoutingNode, routingAllocation);
|
|
decision = diskThresholdDecider.canRemain(firstRouting, firstRoutingNode, routingAllocation);
|
|
|
assertThat(decision.type(), equalTo(Decision.Type.YES));
|
|
assertThat(decision.type(), equalTo(Decision.Type.YES));
|
|
@@ -907,7 +909,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
|
|
diskThresholdDecider
|
|
diskThresholdDecider
|
|
|
)));
|
|
)));
|
|
|
AllocationService strategy = new AllocationService(deciders, new TestGatewayAllocator(),
|
|
AllocationService strategy = new AllocationService(deciders, new TestGatewayAllocator(),
|
|
|
- new BalancedShardsAllocator(Settings.EMPTY), cis);
|
|
|
|
|
|
|
+ new BalancedShardsAllocator(Settings.EMPTY), cis, EmptySnapshotsInfoService.INSTANCE);
|
|
|
// Ensure that the reroute call doesn't alter the routing table, since the first primary is relocating away
|
|
// Ensure that the reroute call doesn't alter the routing table, since the first primary is relocating away
|
|
|
// and therefor we will have sufficient disk space on node1.
|
|
// and therefor we will have sufficient disk space on node1.
|
|
|
ClusterState result = strategy.reroute(clusterState, "reroute");
|
|
ClusterState result = strategy.reroute(clusterState, "reroute");
|
|
@@ -979,7 +981,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
|
|
);
|
|
);
|
|
|
ClusterState clusterState = ClusterState.builder(baseClusterState).routingTable(builder.build()).build();
|
|
ClusterState clusterState = ClusterState.builder(baseClusterState).routingTable(builder.build()).build();
|
|
|
RoutingAllocation routingAllocation = new RoutingAllocation(null, new RoutingNodes(clusterState), clusterState, clusterInfo,
|
|
RoutingAllocation routingAllocation = new RoutingAllocation(null, new RoutingNodes(clusterState), clusterState, clusterInfo,
|
|
|
- System.nanoTime());
|
|
|
|
|
|
|
+ null, System.nanoTime());
|
|
|
routingAllocation.debugDecision(true);
|
|
routingAllocation.debugDecision(true);
|
|
|
Decision decision = diskThresholdDecider.canRemain(firstRouting, firstRoutingNode, routingAllocation);
|
|
Decision decision = diskThresholdDecider.canRemain(firstRouting, firstRoutingNode, routingAllocation);
|
|
|
|
|
|
|
@@ -999,7 +1001,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
|
|
)));
|
|
)));
|
|
|
|
|
|
|
|
AllocationService strategy = new AllocationService(deciders, new TestGatewayAllocator(),
|
|
AllocationService strategy = new AllocationService(deciders, new TestGatewayAllocator(),
|
|
|
- new BalancedShardsAllocator(Settings.EMPTY), cis);
|
|
|
|
|
|
|
+ new BalancedShardsAllocator(Settings.EMPTY), cis, EmptySnapshotsInfoService.INSTANCE);
|
|
|
ClusterState result = strategy.reroute(clusterState, "reroute");
|
|
ClusterState result = strategy.reroute(clusterState, "reroute");
|
|
|
|
|
|
|
|
assertThat(result.routingTable().index("test").getShards().get(0).primaryShard().state(), equalTo(STARTED));
|
|
assertThat(result.routingTable().index("test").getShards().get(0).primaryShard().state(), equalTo(STARTED));
|
|
@@ -1032,7 +1034,8 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
clusterState = ClusterState.builder(updateClusterState).routingTable(builder.build()).build();
|
|
clusterState = ClusterState.builder(updateClusterState).routingTable(builder.build()).build();
|
|
|
- routingAllocation = new RoutingAllocation(null, new RoutingNodes(clusterState), clusterState, clusterInfo, System.nanoTime());
|
|
|
|
|
|
|
+ routingAllocation = new RoutingAllocation(null, new RoutingNodes(clusterState), clusterState, clusterInfo, null,
|
|
|
|
|
+ System.nanoTime());
|
|
|
routingAllocation.debugDecision(true);
|
|
routingAllocation.debugDecision(true);
|
|
|
decision = diskThresholdDecider.canRemain(firstRouting, firstRoutingNode, routingAllocation);
|
|
decision = diskThresholdDecider.canRemain(firstRouting, firstRoutingNode, routingAllocation);
|
|
|
assertThat(decision.type(), equalTo(Decision.Type.YES));
|
|
assertThat(decision.type(), equalTo(Decision.Type.YES));
|
|
@@ -1096,7 +1099,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
|
|
diskThresholdDecider
|
|
diskThresholdDecider
|
|
|
)));
|
|
)));
|
|
|
AllocationService strategy = new AllocationService(deciders,
|
|
AllocationService strategy = new AllocationService(deciders,
|
|
|
- new TestGatewayAllocator(), new BalancedShardsAllocator(Settings.EMPTY), cis);
|
|
|
|
|
|
|
+ new TestGatewayAllocator(), new BalancedShardsAllocator(Settings.EMPTY), cis, EmptySnapshotsInfoService.INSTANCE);
|
|
|
ClusterState result = strategy.reroute(clusterState, "reroute");
|
|
ClusterState result = strategy.reroute(clusterState, "reroute");
|
|
|
|
|
|
|
|
ShardRouting shardRouting = result.routingTable().index("test").getShards().get(0).primaryShard();
|
|
ShardRouting shardRouting = result.routingTable().index("test").getShards().get(0).primaryShard();
|
|
@@ -1117,7 +1120,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
|
|
clusterState = ClusterState.builder(clusterState).routingTable(forceAssignedRoutingTable).build();
|
|
clusterState = ClusterState.builder(clusterState).routingTable(forceAssignedRoutingTable).build();
|
|
|
|
|
|
|
|
RoutingAllocation routingAllocation = new RoutingAllocation(null, new RoutingNodes(clusterState), clusterState, clusterInfo,
|
|
RoutingAllocation routingAllocation = new RoutingAllocation(null, new RoutingNodes(clusterState), clusterState, clusterInfo,
|
|
|
- System.nanoTime());
|
|
|
|
|
|
|
+ null, System.nanoTime());
|
|
|
routingAllocation.debugDecision(true);
|
|
routingAllocation.debugDecision(true);
|
|
|
Decision decision = diskThresholdDecider.canRemain(startedShard, clusterState.getRoutingNodes().node("data"), routingAllocation);
|
|
Decision decision = diskThresholdDecider.canRemain(startedShard, clusterState.getRoutingNodes().node("data"), routingAllocation);
|
|
|
assertThat(decision.type(), equalTo(Decision.Type.NO));
|
|
assertThat(decision.type(), equalTo(Decision.Type.NO));
|