|
@@ -56,6 +56,7 @@ import java.util.Arrays;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.HashSet;
|
|
|
import java.util.Map;
|
|
|
+import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
|
|
import static java.util.Collections.emptyMap;
|
|
|
import static java.util.Collections.singleton;
|
|
@@ -729,10 +730,9 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
|
|
ImmutableOpenMap<String, Long> shardSizes = shardSizesBuilder.build();
|
|
|
final ClusterInfo clusterInfo = new DevNullClusterInfo(usages, usages, shardSizes);
|
|
|
|
|
|
+ DiskThresholdDecider decider = makeDecider(diskSettings);
|
|
|
AllocationDeciders deciders = new AllocationDeciders(Settings.EMPTY,
|
|
|
- new HashSet<>(Arrays.asList(
|
|
|
- new SameShardAllocationDecider(Settings.EMPTY),
|
|
|
- makeDecider(diskSettings))));
|
|
|
+ new HashSet<>(Arrays.asList(new SameShardAllocationDecider(Settings.EMPTY), decider)));
|
|
|
|
|
|
ClusterInfoService cis = new ClusterInfoService() {
|
|
|
@Override
|
|
@@ -832,6 +832,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
|
|
ImmutableOpenMap.Builder<String, Long> shardSizesBuilder = ImmutableOpenMap.builder();
|
|
|
shardSizesBuilder.put("[test][0][p]", 40L);
|
|
|
shardSizesBuilder.put("[test][1][p]", 40L);
|
|
|
+ shardSizesBuilder.put("[foo][0][p]", 10L);
|
|
|
ImmutableOpenMap<String, Long> shardSizes = shardSizesBuilder.build();
|
|
|
|
|
|
final ClusterInfo clusterInfo = new DevNullClusterInfo(usages, usages, shardSizes);
|
|
@@ -839,10 +840,12 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
|
|
DiskThresholdDecider diskThresholdDecider = makeDecider(diskSettings);
|
|
|
MetaData metaData = MetaData.builder()
|
|
|
.put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(2).numberOfReplicas(0))
|
|
|
+ .put(IndexMetaData.builder("foo").settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(0))
|
|
|
.build();
|
|
|
|
|
|
RoutingTable initialRoutingTable = RoutingTable.builder()
|
|
|
.addAsNew(metaData.index("test"))
|
|
|
+ .addAsNew(metaData.index("foo"))
|
|
|
.build();
|
|
|
|
|
|
DiscoveryNode discoveryNode1 = new DiscoveryNode("node1", new LocalTransportAddress("1"), emptyMap(),
|
|
@@ -881,6 +884,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
|
|
// Two shards consuming each 80% of disk space while 70% is allowed, but one is relocating, so shard 0 can stay
|
|
|
firstRouting = TestShardRouting.newShardRouting("test", 0, "node1", null, true, ShardRoutingState.STARTED);
|
|
|
secondRouting = TestShardRouting.newShardRouting("test", 1, "node1", "node2", true, ShardRoutingState.RELOCATING);
|
|
|
+ ShardRouting fooRouting = TestShardRouting.newShardRouting("foo", 0, "node1", null, true, ShardRoutingState.UNASSIGNED);
|
|
|
firstRoutingNode = new RoutingNode("node1", discoveryNode1, firstRouting, secondRouting);
|
|
|
builder = RoutingTable.builder().add(
|
|
|
IndexRoutingTable.builder(firstRouting.index())
|
|
@@ -898,6 +902,8 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
|
|
false);
|
|
|
decision = diskThresholdDecider.canRemain(firstRouting, firstRoutingNode, routingAllocation);
|
|
|
assertThat(decision.type(), equalTo(Decision.Type.YES));
|
|
|
+ decision = diskThresholdDecider.canAllocate(fooRouting, firstRoutingNode, routingAllocation);
|
|
|
+ assertThat(decision.type(), equalTo(Decision.Type.NO));
|
|
|
|
|
|
// Creating AllocationService instance and the services it depends on...
|
|
|
ClusterInfoService cis = new ClusterInfoService() {
|