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


Java BalancedShardsAllocator类代码示例

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


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

示例1: createShardsAllocator

import org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator; //导入依赖的package包/类
private static ShardsAllocator createShardsAllocator(Settings settings, ClusterSettings clusterSettings,
                                                     List<ClusterPlugin> clusterPlugins) {
    Map<String, Supplier<ShardsAllocator>> allocators = new HashMap<>();
    allocators.put(BALANCED_ALLOCATOR, () -> new BalancedShardsAllocator(settings, clusterSettings));

    for (ClusterPlugin plugin : clusterPlugins) {
        plugin.getShardsAllocators(settings, clusterSettings).forEach((k, v) -> {
            if (allocators.put(k, v) != null) {
                throw new IllegalArgumentException("ShardsAllocator [" + k + "] already defined");
            }
        });
    }
    String allocatorName = SHARDS_ALLOCATOR_TYPE_SETTING.get(settings);
    Supplier<ShardsAllocator> allocatorSupplier = allocators.get(allocatorName);
    if (allocatorSupplier == null) {
        throw new IllegalArgumentException("Unknown ShardsAllocator [" + allocatorName + "]");
    }
    return Objects.requireNonNull(allocatorSupplier.get(),
        "ShardsAllocator factory for [" + allocatorName + "] returned null");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:ClusterModule.java

示例2: testRebalanceNotAllowedDuringPendingAsyncFetch

import org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator; //导入依赖的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

示例3: testDontBalanceShardWhenThresholdNotMet

import org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator; //导入依赖的package包/类
public void testDontBalanceShardWhenThresholdNotMet() {
    AllocationDecider canAllocateDecider = new AllocationDecider(Settings.EMPTY) {
        @Override
        public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) {
            return Decision.YES;
        }
    };
    // ridiculously high threshold setting so we won't rebalance
    Settings balancerSettings = Settings.builder().put(BalancedShardsAllocator.THRESHOLD_SETTING.getKey(), 1000f).build();
    Tuple<ClusterState, MoveDecision> rebalance = setupStateAndRebalance(canAllocateDecider, balancerSettings, false);
    ClusterState clusterState = rebalance.v1();
    MoveDecision rebalanceDecision = rebalance.v2();
    assertEquals(Type.YES, rebalanceDecision.getClusterRebalanceDecision().type());
    assertEquals(AllocationDecision.NO, rebalanceDecision.getAllocationDecision());
    assertNotNull(rebalanceDecision.getExplanation());
    assertEquals(clusterState.nodes().getSize() - 1, rebalanceDecision.getNodeDecisions().size());
    assertNull(rebalanceDecision.getTargetNode());
    int prevRanking = 0;
    for (NodeAllocationResult result : rebalanceDecision.getNodeDecisions()) {
        assertThat(result.getWeightRanking(), greaterThanOrEqualTo(prevRanking));
        prevRanking = result.getWeightRanking();
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:BalancedSingleShardTests.java

示例4: testIndexBalance

import org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator; //导入依赖的package包/类
public void testIndexBalance() {
    /* Tests balance over indices only */
    final float indexBalance = 1.0f;
    final float replicaBalance = 0.0f;
    final float balanceTreshold = 1.0f;

    Settings.Builder settings = Settings.builder();
    settings.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString());
    settings.put(BalancedShardsAllocator.INDEX_BALANCE_FACTOR_SETTING.getKey(), indexBalance);
    settings.put(BalancedShardsAllocator.SHARD_BALANCE_FACTOR_SETTING.getKey(), replicaBalance);
    settings.put(BalancedShardsAllocator.THRESHOLD_SETTING.getKey(), balanceTreshold);

    AllocationService strategy = createAllocationService(settings.build(), new NoopGatewayAllocator());

    ClusterState clusterState = initCluster(strategy);
    assertIndexBalance(clusterState.getRoutingTable(), clusterState.getRoutingNodes(), numberOfNodes, numberOfIndices, numberOfReplicas, numberOfShards, balanceTreshold);

    clusterState = addNode(clusterState, strategy);
    assertIndexBalance(clusterState.getRoutingTable(), clusterState.getRoutingNodes(), numberOfNodes + 1, numberOfIndices, numberOfReplicas, numberOfShards, balanceTreshold);

    clusterState = removeNodes(clusterState, strategy);
    assertIndexBalance(clusterState.getRoutingTable(), clusterState.getRoutingNodes(), (numberOfNodes + 1) - (numberOfNodes + 1) / 2, numberOfIndices, numberOfReplicas, numberOfShards, balanceTreshold);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:BalanceConfigurationTests.java

示例5: testReplicaBalance

import org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator; //导入依赖的package包/类
public void testReplicaBalance() {
    /* Tests balance over replicas only */
    final float indexBalance = 0.0f;
    final float replicaBalance = 1.0f;
    final float balanceTreshold = 1.0f;

    Settings.Builder settings = Settings.builder();
    settings.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString());
    settings.put(BalancedShardsAllocator.INDEX_BALANCE_FACTOR_SETTING.getKey(), indexBalance);
    settings.put(BalancedShardsAllocator.SHARD_BALANCE_FACTOR_SETTING.getKey(), replicaBalance);
    settings.put(BalancedShardsAllocator.THRESHOLD_SETTING.getKey(), balanceTreshold);

    AllocationService strategy = createAllocationService(settings.build(), new NoopGatewayAllocator());

    ClusterState clusterState = initCluster(strategy);
    assertReplicaBalance(logger, clusterState.getRoutingNodes(), numberOfNodes, numberOfIndices, numberOfReplicas, numberOfShards, balanceTreshold);

    clusterState = addNode(clusterState, strategy);
    assertReplicaBalance(logger, clusterState.getRoutingNodes(), numberOfNodes + 1, numberOfIndices, numberOfReplicas, numberOfShards, balanceTreshold);

    clusterState = removeNodes(clusterState, strategy);
    assertReplicaBalance(logger, clusterState.getRoutingNodes(), (numberOfNodes + 1) - (numberOfNodes + 1) / 2, numberOfIndices, numberOfReplicas, numberOfShards, balanceTreshold);

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

示例6: testRebalanceNonStartedShardNotAllowed

import org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator; //导入依赖的package包/类
public void testRebalanceNonStartedShardNotAllowed() {
    BalancedShardsAllocator allocator = new BalancedShardsAllocator(Settings.EMPTY);
    ClusterState clusterState = ClusterStateCreationUtils.state("idx", randomBoolean(),
        randomFrom(ShardRoutingState.INITIALIZING, ShardRoutingState.UNASSIGNED, ShardRoutingState.RELOCATING));
    ShardRouting shard = clusterState.routingTable().index("idx").shard(0).primaryShard();
    MoveDecision rebalanceDecision = allocator.decideShardAllocation(shard, newRoutingAllocation(
        new AllocationDeciders(Settings.EMPTY, Collections.emptyList()), clusterState)).getMoveDecision();
    assertSame(MoveDecision.NOT_TAKEN, rebalanceDecision);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:BalancedSingleShardTests.java

示例7: testRebalancingNotAllowedDueToCanRebalance

import org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator; //导入依赖的package包/类
public void testRebalancingNotAllowedDueToCanRebalance() {
    final Decision canRebalanceDecision = randomFrom(Decision.NO, Decision.THROTTLE);
    AllocationDecider noRebalanceDecider = new AllocationDecider(Settings.EMPTY) {
        @Override
        public Decision canRebalance(ShardRouting shardRouting, RoutingAllocation allocation) {
            return allocation.decision(canRebalanceDecision, "TEST", "foobar");
        }
    };
    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.singleton(noRebalanceDecider)), clusterState);
    MoveDecision rebalanceDecision = allocator.decideShardAllocation(shard, routingAllocation).getMoveDecision();
    assertEquals(canRebalanceDecision.type(), rebalanceDecision.getClusterRebalanceDecision().type());
    assertEquals(AllocationDecision.fromDecisionType(canRebalanceDecision.type()), rebalanceDecision.getAllocationDecision());
    assertThat(rebalanceDecision.getExplanation(), containsString(canRebalanceDecision.type() == Type.THROTTLE ?
        "rebalancing is throttled" : "rebalancing is not allowed"));
    assertNotNull(rebalanceDecision.getNodeDecisions());
    assertNull(rebalanceDecision.getTargetNode());
    assertEquals(1, rebalanceDecision.getClusterRebalanceDecision().getDecisions().size());
    for (Decision subDecision : rebalanceDecision.getClusterRebalanceDecision().getDecisions()) {
        assertEquals("foobar", ((Decision.Single) subDecision).getExplanation());
    }

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

示例8: setupStateAndRebalance

import org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator; //导入依赖的package包/类
private Tuple<ClusterState, MoveDecision> setupStateAndRebalance(AllocationDecider allocationDecider,
                                                                 Settings balancerSettings,
                                                                 boolean rebalanceExpected) {
    AllocationDecider rebalanceDecider = new AllocationDecider(Settings.EMPTY) {
        @Override
        public Decision canRebalance(ShardRouting shardRouting, RoutingAllocation allocation) {
            return Decision.YES;
        }
    };
    List<AllocationDecider> allocationDeciders = Arrays.asList(rebalanceDecider, allocationDecider);
    final int numShards = randomIntBetween(8, 13);
    BalancedShardsAllocator allocator = new BalancedShardsAllocator(balancerSettings);
    ClusterState clusterState = ClusterStateCreationUtils.state("idx", 2, numShards);
    // add a new node so shards can be rebalanced there
    DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder(clusterState.nodes());
    nodesBuilder.add(newNode(randomAsciiOfLength(7)));
    clusterState = ClusterState.builder(clusterState).nodes(nodesBuilder).build();
    ShardRouting shard = clusterState.routingTable().index("idx").shard(0).primaryShard();
    RoutingAllocation routingAllocation = newRoutingAllocation(
        new AllocationDeciders(Settings.EMPTY, allocationDeciders), clusterState);
    MoveDecision rebalanceDecision = allocator.decideShardAllocation(shard, routingAllocation).getMoveDecision();

    if (rebalanceExpected == false) {
        assertAssignedNodeRemainsSame(allocator, routingAllocation, shard);
    }

    return Tuple.tuple(clusterState, rebalanceDecision);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:29,代码来源:BalancedSingleShardTests.java

示例9: assertAssignedNodeRemainsSame

import org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator; //导入依赖的package包/类
private void assertAssignedNodeRemainsSame(BalancedShardsAllocator allocator, RoutingAllocation routingAllocation,
                                           ShardRouting originalRouting) {
    allocator.allocate(routingAllocation);
    RoutingNodes routingNodes = routingAllocation.routingNodes();
    // make sure the previous node id is the same as the current one after rerouting
    assertEquals(originalRouting.currentNodeId(), routingNodes.activePrimary(originalRouting.shardId()).currentNodeId());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:BalancedSingleShardTests.java

示例10: testRestoreDoesNotAllocateSnapshotOnOlderNodes

import org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator; //导入依赖的package包/类
public void testRestoreDoesNotAllocateSnapshotOnOlderNodes() {
    final DiscoveryNode newNode = new DiscoveryNode("newNode", buildNewFakeTransportAddress(), emptyMap(),
            MASTER_DATA_ROLES, Version.CURRENT);
    final DiscoveryNode oldNode1 = new DiscoveryNode("oldNode1", buildNewFakeTransportAddress(), emptyMap(),
            MASTER_DATA_ROLES, VersionUtils.getPreviousVersion());
    final DiscoveryNode oldNode2 = new DiscoveryNode("oldNode2", buildNewFakeTransportAddress(), emptyMap(),
            MASTER_DATA_ROLES, VersionUtils.getPreviousVersion());

    int numberOfShards = randomIntBetween(1, 3);
    final IndexMetaData.Builder indexMetaData = IndexMetaData.builder("test").settings(settings(Version.CURRENT))
        .numberOfShards(numberOfShards).numberOfReplicas(randomIntBetween(0, 3));
    for (int i = 0; i < numberOfShards; i++) {
        indexMetaData.putInSyncAllocationIds(i, Collections.singleton("_test_"));
    }
    MetaData metaData = MetaData.builder().put(indexMetaData).build();

    ClusterState state = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
        .metaData(metaData)
        .routingTable(RoutingTable.builder().addAsRestore(metaData.index("test"),
            new SnapshotRecoverySource(new Snapshot("rep1", new SnapshotId("snp1", UUIDs.randomBase64UUID())),
            Version.CURRENT, "test")).build())
        .nodes(DiscoveryNodes.builder().add(newNode).add(oldNode1).add(oldNode2)).build();
    AllocationDeciders allocationDeciders = new AllocationDeciders(Settings.EMPTY, Arrays.asList(
        new ReplicaAfterPrimaryActiveAllocationDecider(Settings.EMPTY),
        new NodeVersionAllocationDecider(Settings.EMPTY)));
    AllocationService strategy = new MockAllocationService(Settings.EMPTY,
        allocationDeciders,
        new TestGatewayAllocator(), new BalancedShardsAllocator(Settings.EMPTY), EmptyClusterInfoService.INSTANCE);
    state = strategy.reroute(state, new AllocationCommands(), true, false).getClusterState();

    // Make sure that primary shards are only allocated on the new node
    for (int i = 0; i < numberOfShards; i++) {
        assertEquals("newNode", state.routingTable().index("test").getShards().get(i).primaryShard().currentNodeId());
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:36,代码来源:NodeVersionAllocationDeciderTests.java

示例11: testPersistedSettings

import org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator; //导入依赖的package包/类
public void testPersistedSettings() {
    Settings.Builder settings = Settings.builder();
    settings.put(BalancedShardsAllocator.INDEX_BALANCE_FACTOR_SETTING.getKey(), 0.2);
    settings.put(BalancedShardsAllocator.SHARD_BALANCE_FACTOR_SETTING.getKey(), 0.3);
    settings.put(BalancedShardsAllocator.THRESHOLD_SETTING.getKey(), 2.0);
    ClusterSettings service = new ClusterSettings(Settings.builder().build(), ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
    BalancedShardsAllocator allocator = new BalancedShardsAllocator(settings.build(), service);
    assertThat(allocator.getIndexBalance(), Matchers.equalTo(0.2f));
    assertThat(allocator.getShardBalance(), Matchers.equalTo(0.3f));
    assertThat(allocator.getThreshold(), Matchers.equalTo(2.0f));

    settings = Settings.builder();
    settings.put(BalancedShardsAllocator.INDEX_BALANCE_FACTOR_SETTING.getKey(), 0.2);
    settings.put(BalancedShardsAllocator.SHARD_BALANCE_FACTOR_SETTING.getKey(), 0.3);
    settings.put(BalancedShardsAllocator.THRESHOLD_SETTING.getKey(), 2.0);
    settings.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString());
    service.applySettings(settings.build());
    assertThat(allocator.getIndexBalance(), Matchers.equalTo(0.2f));
    assertThat(allocator.getShardBalance(), Matchers.equalTo(0.3f));
    assertThat(allocator.getThreshold(), Matchers.equalTo(2.0f));

    settings = Settings.builder();
    settings.put(BalancedShardsAllocator.INDEX_BALANCE_FACTOR_SETTING.getKey(), 0.5);
    settings.put(BalancedShardsAllocator.SHARD_BALANCE_FACTOR_SETTING.getKey(), 0.1);
    settings.put(BalancedShardsAllocator.THRESHOLD_SETTING.getKey(), 3.0);
    service.applySettings(settings.build());
    assertThat(allocator.getIndexBalance(), Matchers.equalTo(0.5f));
    assertThat(allocator.getShardBalance(), Matchers.equalTo(0.1f));
    assertThat(allocator.getThreshold(), Matchers.equalTo(3.0f));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:31,代码来源:BalanceConfigurationTests.java

示例12: setUp

import org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
    super.setUp();
    strategy = new AllocationService(Settings.builder().build(), new AllocationDeciders(Settings.EMPTY,
        Collections.singleton(new MaxRetryAllocationDecider(Settings.EMPTY))),
        new TestGatewayAllocator(), new BalancedShardsAllocator(Settings.EMPTY), EmptyClusterInfoService.INSTANCE);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:MaxRetryAllocationDeciderTests.java

示例13: newAllocationService

import org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator; //导入依赖的package包/类
private static AllocationService newAllocationService(Settings settings, Set<AllocationDecider> deciders) {
    return new AllocationService(settings,
                                 new AllocationDeciders(settings, deciders),
                                 new TestGatewayAllocator(),
                                 new BalancedShardsAllocator(settings),
                                 EmptyClusterInfoService.INSTANCE);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:DecisionsImpactOnClusterHealthTests.java

示例14: testShrinkIndexSettings

import org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator; //导入依赖的package包/类
public void testShrinkIndexSettings() {
    String indexName = randomAsciiOfLength(10);
    // create one that won't fail
    ClusterState clusterState = ClusterState.builder(createClusterState(indexName, randomIntBetween(2, 10), 0,
        Settings.builder()
            .put("index.blocks.write", true)
            .build())).nodes(DiscoveryNodes.builder().add(newNode("node1")))
        .build();
    AllocationService service = new AllocationService(Settings.builder().build(), new AllocationDeciders(Settings.EMPTY,
        Collections.singleton(new MaxRetryAllocationDecider(Settings.EMPTY))),
        new TestGatewayAllocator(), new BalancedShardsAllocator(Settings.EMPTY), EmptyClusterInfoService.INSTANCE);

    RoutingTable routingTable = service.reroute(clusterState, "reroute").routingTable();
    clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
    // now we start the shard
    routingTable = service.applyStartedShards(clusterState,
        routingTable.index(indexName).shardsWithState(ShardRoutingState.INITIALIZING)).routingTable();
    clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
    int numSourceShards = clusterState.metaData().index(indexName).getNumberOfShards();
    DocsStats stats = new DocsStats(randomIntBetween(0, (IndexWriter.MAX_DOCS) / numSourceShards), randomIntBetween(1, 1000));
    ShrinkRequest target = new ShrinkRequest("target", indexName);
    final ActiveShardCount activeShardCount = randomBoolean() ? ActiveShardCount.ALL : ActiveShardCount.ONE;
    target.setWaitForActiveShards(activeShardCount);
    CreateIndexClusterStateUpdateRequest request = TransportShrinkAction.prepareCreateIndexRequest(
        target, clusterState, (i) -> stats,
        new IndexNameExpressionResolver(Settings.EMPTY));
    assertNotNull(request.shrinkFrom());
    assertEquals(indexName, request.shrinkFrom().getName());
    assertEquals("1", request.settings().get("index.number_of_shards"));
    assertEquals("shrink_index", request.cause());
    assertEquals(request.waitForActiveShards(), activeShardCount);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:33,代码来源:TransportShrinkActionTests.java

示例15: ClusterModule

import org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator; //导入依赖的package包/类
public ClusterModule(Settings settings) {
    this.settings = settings;

    registerBuiltinClusterSettings();
    registerBuiltinIndexSettings();

    for (Class<? extends AllocationDecider> decider : ClusterModule.DEFAULT_ALLOCATION_DECIDERS) {
        registerAllocationDecider(decider);
    }
    registerShardsAllocator(ClusterModule.BALANCED_ALLOCATOR, BalancedShardsAllocator.class);
    registerShardsAllocator(ClusterModule.EVEN_SHARD_COUNT_ALLOCATOR, BalancedShardsAllocator.class);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:13,代码来源:ClusterModule.java


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