Search in sources :

Example 41 with Decision

use of org.elasticsearch.cluster.routing.allocation.decider.Decision in project crate by crate.

the class ReplicaShardAllocatorTests method testThrottleWhenAllocatingToMatchingNode.

/**
 * Tests when the node to allocate to due to matching is being throttled, we move the shard to ignored
 * to wait till throttling on it is done.
 */
public void testThrottleWhenAllocatingToMatchingNode() {
    RoutingAllocation allocation = onePrimaryOnNode1And1Replica(new AllocationDeciders(Arrays.asList(new TestAllocateDecision(Decision.YES), new SameShardAllocationDecider(Settings.EMPTY, new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)), new AllocationDecider() {

        @Override
        public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) {
            if (node.node().equals(node2)) {
                return Decision.THROTTLE;
            }
            return Decision.YES;
        }
    })));
    testAllocator.addData(node1, "MATCH", new StoreFileMetadata("file1", 10, "MATCH_CHECKSUM", MIN_SUPPORTED_LUCENE_VERSION)).addData(node2, "MATCH", new StoreFileMetadata("file1", 10, "MATCH_CHECKSUM", MIN_SUPPORTED_LUCENE_VERSION));
    testAllocator.allocateUnassigned(allocation);
    assertThat(allocation.routingNodes().unassigned().ignored().size(), equalTo(1));
    assertThat(allocation.routingNodes().unassigned().ignored().get(0).shardId(), equalTo(shardId));
}
Also used : SameShardAllocationDecider(org.elasticsearch.cluster.routing.allocation.decider.SameShardAllocationDecider) ClusterSettings(org.elasticsearch.common.settings.ClusterSettings) RoutingNode(org.elasticsearch.cluster.routing.RoutingNode) AllocationDeciders(org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders) StoreFileMetadata(org.elasticsearch.index.store.StoreFileMetadata) RoutingAllocation(org.elasticsearch.cluster.routing.allocation.RoutingAllocation) TestShardRouting(org.elasticsearch.cluster.routing.TestShardRouting) ShardRouting(org.elasticsearch.cluster.routing.ShardRouting) SameShardAllocationDecider(org.elasticsearch.cluster.routing.allocation.decider.SameShardAllocationDecider) AllocationDecider(org.elasticsearch.cluster.routing.allocation.decider.AllocationDecider) Decision(org.elasticsearch.cluster.routing.allocation.decider.Decision)

Aggregations

Decision (org.elasticsearch.cluster.routing.allocation.decider.Decision)41 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)24 RoutingNode (org.elasticsearch.cluster.routing.RoutingNode)18 AllocateUnassignedDecision (org.elasticsearch.cluster.routing.allocation.AllocateUnassignedDecision)18 NodeAllocationResult (org.elasticsearch.cluster.routing.allocation.NodeAllocationResult)16 ShardRouting (org.elasticsearch.cluster.routing.ShardRouting)12 ArrayList (java.util.ArrayList)10 UnassignedInfo (org.elasticsearch.cluster.routing.UnassignedInfo)10 AllocationDecision (org.elasticsearch.cluster.routing.allocation.AllocationDecision)10 ShardId (org.elasticsearch.index.shard.ShardId)9 ClusterInfo (org.elasticsearch.cluster.ClusterInfo)8 ShardRoutingState (org.elasticsearch.cluster.routing.ShardRoutingState)8 MoveDecision (org.elasticsearch.cluster.routing.allocation.MoveDecision)8 XContentParser (org.elasticsearch.common.xcontent.XContentParser)8 HashMap (java.util.HashMap)7 RoutingNodes (org.elasticsearch.cluster.routing.RoutingNodes)6 CrateDummyClusterServiceUnitTest (io.crate.test.integration.CrateDummyClusterServiceUnitTest)5 AllocationDeciders (org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders)5 Settings (org.elasticsearch.common.settings.Settings)5 Test (org.junit.Test)5