当前位置: 首页>>代码示例>>Java>>正文


Java AllocationDeciders类代码示例

本文整理汇总了Java中org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders的典型用法代码示例。如果您正苦于以下问题:Java AllocationDeciders类的具体用法?Java AllocationDeciders怎么用?Java AllocationDeciders使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AllocationDeciders类属于org.elasticsearch.cluster.routing.allocation.decider包,在下文中一共展示了AllocationDeciders类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configure

import org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders; //导入依赖的package包/类
@Override
protected void configure() {
    bind(GatewayAllocator.class).asEagerSingleton();
    bind(AllocationService.class).asEagerSingleton();
    bind(ClusterService.class).toInstance(clusterService);
    bind(NodeConnectionsService.class).asEagerSingleton();
    bind(MetaDataCreateIndexService.class).asEagerSingleton();
    bind(MetaDataDeleteIndexService.class).asEagerSingleton();
    bind(MetaDataIndexStateService.class).asEagerSingleton();
    bind(MetaDataMappingService.class).asEagerSingleton();
    bind(MetaDataIndexAliasesService.class).asEagerSingleton();
    bind(MetaDataUpdateSettingsService.class).asEagerSingleton();
    bind(MetaDataIndexTemplateService.class).asEagerSingleton();
    bind(IndexNameExpressionResolver.class).toInstance(indexNameExpressionResolver);
    bind(RoutingService.class).asEagerSingleton();
    bind(DelayedAllocationService.class).asEagerSingleton();
    bind(ShardStateAction.class).asEagerSingleton();
    bind(NodeMappingRefreshAction.class).asEagerSingleton();
    bind(MappingUpdatedAction.class).asEagerSingleton();
    bind(TaskResultsService.class).asEagerSingleton();
    bind(AllocationDeciders.class).toInstance(new AllocationDeciders(settings, allocationDeciders));
    bind(ShardsAllocator.class).toInstance(shardsAllocator);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:ClusterModule.java

示例2: testUnassignedShardAndEmptyNodesInRoutingTable

import org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders; //导入依赖的package包/类
public void testUnassignedShardAndEmptyNodesInRoutingTable() throws Exception {
    internalCluster().startNode();
    createIndex("a");
    ensureSearchable("a");
    ClusterState current = clusterService().state();
    GatewayAllocator allocator = internalCluster().getInstance(GatewayAllocator.class);

    AllocationDeciders allocationDeciders = new AllocationDeciders(Settings.EMPTY, Collections.emptyList());
    RoutingNodes routingNodes = new RoutingNodes(
            ClusterState.builder(current)
                    .routingTable(RoutingTable.builder(current.routingTable()).remove("a").addAsRecovery(current.metaData().index("a")).build())
                    .nodes(DiscoveryNodes.EMPTY_NODES)
                    .build(), false
    );
    RoutingAllocation routingAllocation = new RoutingAllocation(allocationDeciders, routingNodes, current, ClusterInfo.EMPTY, System.nanoTime(), false);
    allocator.allocateUnassigned(routingAllocation);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:RareClusterStateIT.java

示例3: testDontAllocateOnNoOrThrottleForceAllocationDecision

import org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders; //导入依赖的package包/类
/**
 * Tests that when the nodes with prior copies of the given shard all return a decision of NO, and
 * {@link AllocationDecider#canForceAllocatePrimary(ShardRouting, RoutingNode, RoutingAllocation)}
 * returns a NO or THROTTLE decision for a node, then we do not force allocate to that node.
 */
public void testDontAllocateOnNoOrThrottleForceAllocationDecision() {
    testAllocator.addData(node1, "allocId1", randomBoolean());
    boolean forceDecisionNo = randomBoolean();
    AllocationDeciders deciders = new AllocationDeciders(Settings.EMPTY, Arrays.asList(
        // since both deciders here return a NO decision for allocating a shard,
        // the allocator will see if it can force assign the primary, where the decision will be either NO or THROTTLE,
        // so the shard will remain un-initialized
        new TestAllocateDecision(Decision.NO), forceDecisionNo ? getNoDeciderThatDeniesForceAllocate() :
                                                                 getNoDeciderThatThrottlesForceAllocate()
    ));
    RoutingAllocation allocation = routingAllocationWithOnePrimaryNoReplicas(deciders, CLUSTER_RECOVERED, "allocId1");
    testAllocator.allocateUnassigned(allocation);
    assertThat(allocation.routingNodesChanged(), equalTo(true));
    List<ShardRouting> ignored = allocation.routingNodes().unassigned().ignored();
    assertEquals(ignored.size(), 1);
    assertEquals(ignored.get(0).unassignedInfo().getLastAllocationStatus(),
        forceDecisionNo ? AllocationStatus.DECIDERS_NO : AllocationStatus.DECIDERS_THROTTLED);
    assertTrue(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).isEmpty());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:PrimaryShardAllocatorTests.java

示例4: testDontForceAllocateOnThrottleDecision

import org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders; //导入依赖的package包/类
/**
 * Tests that when the nodes with prior copies of the given shard return a THROTTLE decision,
 * then we do not force allocate to that node but instead throttle.
 */
public void testDontForceAllocateOnThrottleDecision() {
    testAllocator.addData(node1, "allocId1", randomBoolean());
    AllocationDeciders deciders = new AllocationDeciders(Settings.EMPTY, Arrays.asList(
        // since we have a NO decision for allocating a shard (because the second decider returns a NO decision),
        // the allocator will see if it can force assign the primary, and in this case,
        // the TestAllocateDecision's decision for force allocating is to THROTTLE (using
        // the default behavior) so despite the other decider's decision to return YES for
        // force allocating the shard, we still THROTTLE due to the decision from TestAllocateDecision
        new TestAllocateDecision(Decision.THROTTLE), getNoDeciderThatAllowsForceAllocate()
    ));
    RoutingAllocation allocation = routingAllocationWithOnePrimaryNoReplicas(deciders, CLUSTER_RECOVERED, "allocId1");
    testAllocator.allocateUnassigned(allocation);
    assertThat(allocation.routingNodesChanged(), equalTo(true));
    List<ShardRouting> ignored = allocation.routingNodes().unassigned().ignored();
    assertEquals(ignored.size(), 1);
    assertEquals(ignored.get(0).unassignedInfo().getLastAllocationStatus(), AllocationStatus.DECIDERS_THROTTLED);
    assertTrue(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).isEmpty());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:PrimaryShardAllocatorTests.java

示例5: getRestoreRoutingAllocation

import org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders; //导入依赖的package包/类
private RoutingAllocation getRestoreRoutingAllocation(AllocationDeciders allocationDeciders, String... allocIds) {
    MetaData metaData = MetaData.builder()
        .put(IndexMetaData.builder(shardId.getIndexName()).settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(0)
            .putInSyncAllocationIds(0, Sets.newHashSet(allocIds)))
        .build();

    final Snapshot snapshot = new Snapshot("test", new SnapshotId("test", UUIDs.randomBase64UUID()));
    RoutingTable routingTable = RoutingTable.builder()
        .addAsRestore(metaData.index(shardId.getIndex()), new SnapshotRecoverySource(snapshot, Version.CURRENT, shardId.getIndexName()))
        .build();
    ClusterState state = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
        .metaData(metaData)
        .routingTable(routingTable)
        .nodes(DiscoveryNodes.builder().add(node1).add(node2).add(node3)).build();
    return new RoutingAllocation(allocationDeciders, new RoutingNodes(state, false), state, null, System.nanoTime(), false);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:PrimaryShardAllocatorTests.java

示例6: getRecoverOnAnyNodeRoutingAllocation

import org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders; //导入依赖的package包/类
private RoutingAllocation getRecoverOnAnyNodeRoutingAllocation(AllocationDeciders allocationDeciders, String... allocIds) {
    MetaData metaData = MetaData.builder()
        .put(IndexMetaData.builder(shardId.getIndexName()).settings(settings(Version.CURRENT)
            .put(IndexMetaData.SETTING_SHARED_FILESYSTEM, true)
            .put(IndexMetaData.SETTING_SHARED_FS_ALLOW_RECOVERY_ON_ANY_NODE, true))
            .numberOfShards(1).numberOfReplicas(0).putInSyncAllocationIds(0, Sets.newHashSet(allocIds)))
        .build();

    RoutingTable routingTable = RoutingTable.builder()
        .addAsRestore(metaData.index(shardId.getIndex()), new SnapshotRecoverySource(new Snapshot("test", new SnapshotId("test", UUIDs.randomBase64UUID())), Version.CURRENT, shardId.getIndexName()))
        .build();
    ClusterState state = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
        .metaData(metaData)
        .routingTable(routingTable)
        .nodes(DiscoveryNodes.builder().add(node1).add(node2).add(node3)).build();
    return new RoutingAllocation(allocationDeciders, new RoutingNodes(state, false), state, null, System.nanoTime(), false);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:PrimaryShardAllocatorTests.java

示例7: onePrimaryOnNode1And1ReplicaRecovering

import org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders; //导入依赖的package包/类
private RoutingAllocation onePrimaryOnNode1And1ReplicaRecovering(AllocationDeciders deciders) {
    ShardRouting primaryShard = TestShardRouting.newShardRouting(shardId, node1.getId(), true, ShardRoutingState.STARTED);
    MetaData metaData = MetaData.builder()
            .put(IndexMetaData.builder(shardId.getIndexName()).settings(settings(Version.CURRENT))
                .numberOfShards(1).numberOfReplicas(1)
                .putInSyncAllocationIds(0, Sets.newHashSet(primaryShard.allocationId().getId())))
            .build();
    RoutingTable routingTable = RoutingTable.builder()
            .add(IndexRoutingTable.builder(shardId.getIndex())
                            .addIndexShard(new IndexShardRoutingTable.Builder(shardId)
                                    .addShard(primaryShard)
                                    .addShard(TestShardRouting.newShardRouting(shardId, node2.getId(), null, false, ShardRoutingState.INITIALIZING, new UnassignedInfo(UnassignedInfo.Reason.CLUSTER_RECOVERED, null)))
                                    .build())
            )
            .build();
    ClusterState state = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
            .metaData(metaData)
            .routingTable(routingTable)
            .nodes(DiscoveryNodes.builder().add(node1).add(node2).add(node3)).build();
    return new RoutingAllocation(deciders, new RoutingNodes(state, false), state, ClusterInfo.EMPTY, System.nanoTime(), false);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:ReplicaShardAllocatorTests.java

示例8: testRebalanceNotAllowedDuringPendingAsyncFetch

import org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders; //导入依赖的package包/类
public void testRebalanceNotAllowedDuringPendingAsyncFetch() {
    BalancedShardsAllocator allocator = new BalancedShardsAllocator(Settings.EMPTY);
    ClusterState clusterState = ClusterStateCreationUtils.state("idx", randomBoolean(), ShardRoutingState.STARTED);
    ShardRouting shard = clusterState.routingTable().index("idx").shard(0).primaryShard();
    RoutingAllocation routingAllocation = newRoutingAllocation(
        new AllocationDeciders(Settings.EMPTY, Collections.emptyList()), clusterState);
    routingAllocation.setHasPendingAsyncFetch();
    MoveDecision rebalanceDecision = allocator.decideShardAllocation(shard, routingAllocation).getMoveDecision();
    assertNotNull(rebalanceDecision.getClusterRebalanceDecision());
    assertEquals(AllocationDecision.AWAITING_INFO, rebalanceDecision.getAllocationDecision());
    assertThat(rebalanceDecision.getExplanation(),
        startsWith("cannot rebalance as information about existing copies of this shard in the cluster is still being gathered"));
    assertEquals(clusterState.nodes().getSize() - 1, rebalanceDecision.getNodeDecisions().size());
    assertNull(rebalanceDecision.getTargetNode());

    assertAssignedNodeRemainsSame(allocator, routingAllocation, shard);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:BalancedSingleShardTests.java

示例9: defaultAllocationDeciders

import org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders; //导入依赖的package包/类
public static AllocationDeciders defaultAllocationDeciders(Settings settings, ClusterSettings clusterSettings) throws
    IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchMethodException {
    Collection<AllocationDecider> deciders =
        ClusterModule.createAllocationDeciders(settings, clusterSettings, Collections.emptyList());
    return new AllocationDeciders(settings, deciders);

}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:Allocators.java

示例10: RoutingAllocation

import org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders; //导入依赖的package包/类
/**
 * Creates a new {@link RoutingAllocation}
 *  @param deciders {@link AllocationDeciders} to used to make decisions for routing allocations
 * @param routingNodes Routing nodes in the current cluster
 * @param clusterState cluster state before rerouting
 * @param currentNanoTime the nano time to use for all delay allocation calculation (typically {@link System#nanoTime()})
 */
public RoutingAllocation(AllocationDeciders deciders, RoutingNodes routingNodes, ClusterState clusterState, ClusterInfo clusterInfo,
                         long currentNanoTime, boolean retryFailed) {
    this.deciders = deciders;
    this.routingNodes = routingNodes;
    this.metaData = clusterState.metaData();
    this.routingTable = clusterState.routingTable();
    this.nodes = clusterState.nodes();
    this.customs = clusterState.customs();
    this.clusterInfo = clusterInfo;
    this.currentNanoTime = currentNanoTime;
    this.retryFailed = retryFailed;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:RoutingAllocation.java

示例11: AllocationService

import org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders; //导入依赖的package包/类
@Inject
public AllocationService(Settings settings, AllocationDeciders allocationDeciders, GatewayAllocator gatewayAllocator,
                         ShardsAllocator shardsAllocator, ClusterInfoService clusterInfoService) {
    super(settings);
    this.allocationDeciders = allocationDeciders;
    this.gatewayAllocator = gatewayAllocator;
    this.shardsAllocator = shardsAllocator;
    this.clusterInfoService = clusterInfoService;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:AllocationService.java

示例12: TransportClusterAllocationExplainAction

import org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders; //导入依赖的package包/类
@Inject
public TransportClusterAllocationExplainAction(Settings settings, TransportService transportService, ClusterService clusterService,
                                               ThreadPool threadPool, ActionFilters actionFilters,
                                               IndexNameExpressionResolver indexNameExpressionResolver,
                                               ClusterInfoService clusterInfoService, AllocationDeciders allocationDeciders,
                                               ShardsAllocator shardAllocator, GatewayAllocator gatewayAllocator) {
    super(settings, ClusterAllocationExplainAction.NAME, transportService, clusterService, threadPool, actionFilters,
            indexNameExpressionResolver, ClusterAllocationExplainRequest::new);
    this.clusterInfoService = clusterInfoService;
    this.allocationDeciders = allocationDeciders;
    this.shardAllocator = shardAllocator;
    this.gatewayAllocator = gatewayAllocator;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:TransportClusterAllocationExplainAction.java

示例13: testForceAllocatePrimary

import org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders; //导入依赖的package包/类
/**
 * Tests that when the nodes with prior copies of the given shard all return a decision of NO, but
 * {@link AllocationDecider#canForceAllocatePrimary(ShardRouting, RoutingNode, RoutingAllocation)}
 * returns a YES decision for at least one of those NO nodes, then we force allocate to one of them
 */
public void testForceAllocatePrimary() {
    testAllocator.addData(node1, "allocId1", randomBoolean());
    AllocationDeciders deciders = new AllocationDeciders(Settings.EMPTY, Arrays.asList(
        // since the deciders return a NO decision for allocating a shard (due to the guaranteed NO decision from the second decider),
        // the allocator will see if it can force assign the primary, where the decision will be YES
        new TestAllocateDecision(randomBoolean() ? Decision.YES : Decision.NO), getNoDeciderThatAllowsForceAllocate()
    ));
    RoutingAllocation allocation = routingAllocationWithOnePrimaryNoReplicas(deciders, CLUSTER_RECOVERED, "allocId1");
    testAllocator.allocateUnassigned(allocation);
    assertThat(allocation.routingNodesChanged(), equalTo(true));
    assertTrue(allocation.routingNodes().unassigned().ignored().isEmpty());
    assertEquals(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).size(), 1);
    assertEquals(allocation.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).get(0).currentNodeId(), node1.getId());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:PrimaryShardAllocatorTests.java

示例14: routingAllocationWithOnePrimaryNoReplicas

import org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders; //导入依赖的package包/类
private RoutingAllocation routingAllocationWithOnePrimaryNoReplicas(AllocationDeciders deciders, UnassignedInfo.Reason reason,
                                                                    String... activeAllocationIds) {
    MetaData metaData = MetaData.builder()
            .put(IndexMetaData.builder(shardId.getIndexName()).settings(settings(Version.CURRENT))
                .numberOfShards(1).numberOfReplicas(0).putInSyncAllocationIds(shardId.id(), Sets.newHashSet(activeAllocationIds)))
            .build();
    RoutingTable.Builder routingTableBuilder = RoutingTable.builder();
    switch (reason) {

        case INDEX_CREATED:
            routingTableBuilder.addAsNew(metaData.index(shardId.getIndex()));
            break;
        case CLUSTER_RECOVERED:
            routingTableBuilder.addAsRecovery(metaData.index(shardId.getIndex()));
            break;
        case INDEX_REOPENED:
            routingTableBuilder.addAsFromCloseToOpen(metaData.index(shardId.getIndex()));
            break;
        default:
            throw new IllegalArgumentException("can't do " + reason + " for you. teach me");
    }
    ClusterState state = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
            .metaData(metaData)
            .routingTable(routingTableBuilder.build())
            .nodes(DiscoveryNodes.builder().add(node1).add(node2).add(node3)).build();
    return new RoutingAllocation(deciders, new RoutingNodes(state, false), state, null, System.nanoTime(), false);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:28,代码来源:PrimaryShardAllocatorTests.java

示例15: onePrimaryOnNode1And1Replica

import org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders; //导入依赖的package包/类
private RoutingAllocation onePrimaryOnNode1And1Replica(AllocationDeciders deciders, Settings settings, UnassignedInfo.Reason reason) {
    ShardRouting primaryShard = TestShardRouting.newShardRouting(shardId, node1.getId(), true, ShardRoutingState.STARTED);
    MetaData metaData = MetaData.builder()
            .put(IndexMetaData.builder(shardId.getIndexName()).settings(settings(Version.CURRENT).put(settings))
                .numberOfShards(1).numberOfReplicas(1)
                .putInSyncAllocationIds(0, Sets.newHashSet(primaryShard.allocationId().getId())))
        .build();
    // mark shard as delayed if reason is NODE_LEFT
    boolean delayed = reason == UnassignedInfo.Reason.NODE_LEFT &&
        UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.get(settings).nanos() > 0;
    int failedAllocations = reason == UnassignedInfo.Reason.ALLOCATION_FAILED ? 1 : 0;
    RoutingTable routingTable = RoutingTable.builder()
            .add(IndexRoutingTable.builder(shardId.getIndex())
                            .addIndexShard(new IndexShardRoutingTable.Builder(shardId)
                                    .addShard(primaryShard)
                                    .addShard(ShardRouting.newUnassigned(shardId, false,
                                        RecoverySource.PeerRecoverySource.INSTANCE,
                                        new UnassignedInfo(reason, null, null, failedAllocations, System.nanoTime(),
                                            System.currentTimeMillis(), delayed, UnassignedInfo.AllocationStatus.NO_ATTEMPT)
                                        ))
                                    .build())
            )
            .build();
    ClusterState state = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
            .metaData(metaData)
            .routingTable(routingTable)
            .nodes(DiscoveryNodes.builder().add(node1).add(node2).add(node3)).build();
    return new RoutingAllocation(deciders, new RoutingNodes(state, false), state, ClusterInfo.EMPTY, System.nanoTime(), false);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:30,代码来源:ReplicaShardAllocatorTests.java


注:本文中的org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。