當前位置: 首頁>>代碼示例>>Java>>正文


Java AwarenessAllocationDecider類代碼示例

本文整理匯總了Java中org.elasticsearch.cluster.routing.allocation.decider.AwarenessAllocationDecider的典型用法代碼示例。如果您正苦於以下問題:Java AwarenessAllocationDecider類的具體用法?Java AwarenessAllocationDecider怎麽用?Java AwarenessAllocationDecider使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AwarenessAllocationDecider類屬於org.elasticsearch.cluster.routing.allocation.decider包,在下文中一共展示了AwarenessAllocationDecider類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createAllocationDeciders

import org.elasticsearch.cluster.routing.allocation.decider.AwarenessAllocationDecider; //導入依賴的package包/類
/** Return a new {@link AllocationDecider} instance with builtin deciders as well as those from plugins. */
public static Collection<AllocationDecider> createAllocationDeciders(Settings settings, ClusterSettings clusterSettings,
                                                                     List<ClusterPlugin> clusterPlugins) {
    // collect deciders by class so that we can detect duplicates
    Map<Class, AllocationDecider> deciders = new LinkedHashMap<>();
    addAllocationDecider(deciders, new MaxRetryAllocationDecider(settings));
    addAllocationDecider(deciders, new ReplicaAfterPrimaryActiveAllocationDecider(settings));
    addAllocationDecider(deciders, new RebalanceOnlyWhenActiveAllocationDecider(settings));
    addAllocationDecider(deciders, new ClusterRebalanceAllocationDecider(settings, clusterSettings));
    addAllocationDecider(deciders, new ConcurrentRebalanceAllocationDecider(settings, clusterSettings));
    addAllocationDecider(deciders, new EnableAllocationDecider(settings, clusterSettings));
    addAllocationDecider(deciders, new NodeVersionAllocationDecider(settings));
    addAllocationDecider(deciders, new SnapshotInProgressAllocationDecider(settings));
    addAllocationDecider(deciders, new FilterAllocationDecider(settings, clusterSettings));
    addAllocationDecider(deciders, new SameShardAllocationDecider(settings, clusterSettings));
    addAllocationDecider(deciders, new DiskThresholdDecider(settings, clusterSettings));
    addAllocationDecider(deciders, new ThrottlingAllocationDecider(settings, clusterSettings));
    addAllocationDecider(deciders, new ShardsLimitAllocationDecider(settings, clusterSettings));
    addAllocationDecider(deciders, new AwarenessAllocationDecider(settings, clusterSettings));

    clusterPlugins.stream()
        .flatMap(p -> p.createAllocationDeciders(settings, clusterSettings).stream())
        .forEach(d -> addAllocationDecider(deciders, d));

    return deciders.values();
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:27,代碼來源:ClusterModule.java

示例2: testAllocationDeciderOrder

import org.elasticsearch.cluster.routing.allocation.decider.AwarenessAllocationDecider; //導入依賴的package包/類
public void testAllocationDeciderOrder() {
    List<Class<? extends AllocationDecider>> expectedDeciders = Arrays.asList(
        MaxRetryAllocationDecider.class,
        ReplicaAfterPrimaryActiveAllocationDecider.class,
        RebalanceOnlyWhenActiveAllocationDecider.class,
        ClusterRebalanceAllocationDecider.class,
        ConcurrentRebalanceAllocationDecider.class,
        EnableAllocationDecider.class,
        NodeVersionAllocationDecider.class,
        SnapshotInProgressAllocationDecider.class,
        FilterAllocationDecider.class,
        SameShardAllocationDecider.class,
        DiskThresholdDecider.class,
        ThrottlingAllocationDecider.class,
        ShardsLimitAllocationDecider.class,
        AwarenessAllocationDecider.class);
    Collection<AllocationDecider> deciders = ClusterModule.createAllocationDeciders(Settings.EMPTY,
        new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), Collections.emptyList());
    Iterator<AllocationDecider> iter = deciders.iterator();
    int idx = 0;
    while (iter.hasNext()) {
        AllocationDecider decider = iter.next();
        assertSame(decider.getClass(), expectedDeciders.get(idx++));
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:26,代碼來源:ClusterModuleTests.java

示例3: OperationRouting

import org.elasticsearch.cluster.routing.allocation.decider.AwarenessAllocationDecider; //導入依賴的package包/類
public OperationRouting(Settings settings, ClusterSettings clusterSettings) {
    super(settings);
    this.awarenessAttributes = AwarenessAllocationDecider.CLUSTER_ROUTING_ALLOCATION_AWARENESS_ATTRIBUTE_SETTING.get(settings);
    clusterSettings.addSettingsUpdateConsumer(AwarenessAllocationDecider.CLUSTER_ROUTING_ALLOCATION_AWARENESS_ATTRIBUTE_SETTING,
        this::setAwarenessAttributes);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:7,代碼來源:OperationRouting.java

示例4: testMultipleAwarenessAttributes

import org.elasticsearch.cluster.routing.allocation.decider.AwarenessAllocationDecider; //導入依賴的package包/類
public void testMultipleAwarenessAttributes() {
    AllocationService strategy = createAllocationService(Settings.builder()
        .put(AwarenessAllocationDecider.CLUSTER_ROUTING_ALLOCATION_AWARENESS_ATTRIBUTE_SETTING.getKey(), "zone, rack")
        .put(AwarenessAllocationDecider.CLUSTER_ROUTING_ALLOCATION_AWARENESS_FORCE_GROUP_SETTING.getKey() + "zone.values", "a, b")
        .put(AwarenessAllocationDecider.CLUSTER_ROUTING_ALLOCATION_AWARENESS_FORCE_GROUP_SETTING.getKey() + "rack.values", "c, d")
        .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
        .build());

    logger.info("Building initial routing table for 'testUnbalancedZones'");

    MetaData metaData = MetaData.builder()
        .put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(1))
        .build();

    RoutingTable initialRoutingTable = RoutingTable.builder().addAsNew(metaData.index("test")).build();

    ClusterState clusterState = ClusterState.builder(
        org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)
    ).metaData(metaData).routingTable(initialRoutingTable).build();

    logger.info("--> adding two nodes in different zones and do rerouting");
    Map<String, String> nodeAAttributes = new HashMap<>();
    nodeAAttributes.put("zone", "a");
    nodeAAttributes.put("rack", "c");
    Map<String, String> nodeBAttributes = new HashMap<>();
    nodeBAttributes.put("zone", "b");
    nodeBAttributes.put("rack", "d");
    clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
        .add(newNode("A-0", nodeAAttributes))
        .add(newNode("B-0", nodeBAttributes))
    ).build();
    clusterState = strategy.reroute(clusterState, "reroute");
    assertThat(clusterState.getRoutingNodes().shardsWithState(STARTED).size(), equalTo(0));
    assertThat(clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size(), equalTo(1));

    logger.info("--> start the shards (primaries)");
    clusterState = strategy.applyStartedShards(clusterState, clusterState.getRoutingNodes().shardsWithState(INITIALIZING));
    assertThat(clusterState.getRoutingNodes().shardsWithState(STARTED).size(), equalTo(1));
    assertThat(clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size(), equalTo(1));

    clusterState = strategy.applyStartedShards(clusterState, clusterState.getRoutingNodes().shardsWithState(INITIALIZING));
    logger.info("--> all replicas are allocated and started since we have one node in each zone and rack");
    assertThat(clusterState.getRoutingNodes().shardsWithState(STARTED).size(), equalTo(2));
    assertThat(clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size(), equalTo(0));
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:46,代碼來源:AwarenessAllocationTests.java

示例5: testAwarenessZones

import org.elasticsearch.cluster.routing.allocation.decider.AwarenessAllocationDecider; //導入依賴的package包/類
public void testAwarenessZones() throws Exception {
    Settings commonSettings = Settings.builder()
            .put(AwarenessAllocationDecider.CLUSTER_ROUTING_ALLOCATION_AWARENESS_FORCE_GROUP_SETTING.getKey() + "zone.values", "a,b")
            .put(AwarenessAllocationDecider.CLUSTER_ROUTING_ALLOCATION_AWARENESS_ATTRIBUTE_SETTING.getKey(), "zone")
            .put(ZenDiscovery.JOIN_TIMEOUT_SETTING.getKey(), "10s")
            .build();

    logger.info("--> starting 4 nodes on different zones");
    List<String> nodes = internalCluster().startNodes(
            Settings.builder().put(commonSettings).put("node.attr.zone", "a").build(),
            Settings.builder().put(commonSettings).put("node.attr.zone", "b").build(),
            Settings.builder().put(commonSettings).put("node.attr.zone", "b").build(),
            Settings.builder().put(commonSettings).put("node.attr.zone", "a").build()
    );
    String A_0 = nodes.get(0);
    String B_0 = nodes.get(1);
    String B_1 = nodes.get(2);
    String A_1 = nodes.get(3);

    logger.info("--> waiting for nodes to form a cluster");
    ClusterHealthResponse health = client().admin().cluster().prepareHealth().setWaitForNodes("4").execute().actionGet();
    assertThat(health.isTimedOut(), equalTo(false));

    client().admin().indices().prepareCreate("test")
    .setSettings(Settings.builder().put("index.number_of_shards", 5)
            .put("index.number_of_replicas", 1)).execute().actionGet();

    logger.info("--> waiting for shards to be allocated");
    health = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().setWaitForNoRelocatingShards(true).execute().actionGet();
    assertThat(health.isTimedOut(), equalTo(false));

    ClusterState clusterState = client().admin().cluster().prepareState().execute().actionGet().getState();
    ObjectIntHashMap<String> counts = new ObjectIntHashMap<>();

    for (IndexRoutingTable indexRoutingTable : clusterState.routingTable()) {
        for (IndexShardRoutingTable indexShardRoutingTable : indexRoutingTable) {
            for (ShardRouting shardRouting : indexShardRoutingTable) {
                counts.addTo(clusterState.nodes().get(shardRouting.currentNodeId()).getName(), 1);
            }
        }
    }
    assertThat(counts.get(A_1), anyOf(equalTo(2),equalTo(3)));
    assertThat(counts.get(B_1), anyOf(equalTo(2),equalTo(3)));
    assertThat(counts.get(A_0), anyOf(equalTo(2),equalTo(3)));
    assertThat(counts.get(B_0), anyOf(equalTo(2),equalTo(3)));
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:47,代碼來源:AwarenessAllocationIT.java

示例6: registerBuiltinClusterSettings

import org.elasticsearch.cluster.routing.allocation.decider.AwarenessAllocationDecider; //導入依賴的package包/類
private void registerBuiltinClusterSettings() {
    registerClusterDynamicSetting(AwarenessAllocationDecider.CLUSTER_ROUTING_ALLOCATION_AWARENESS_ATTRIBUTES, Validator.EMPTY);
    registerClusterDynamicSetting(AwarenessAllocationDecider.CLUSTER_ROUTING_ALLOCATION_AWARENESS_FORCE_GROUP + "*", Validator.EMPTY);
    registerClusterDynamicSetting(BalancedShardsAllocator.SETTING_INDEX_BALANCE_FACTOR, Validator.FLOAT);
    registerClusterDynamicSetting(BalancedShardsAllocator.SETTING_SHARD_BALANCE_FACTOR, Validator.FLOAT);
    registerClusterDynamicSetting(BalancedShardsAllocator.SETTING_THRESHOLD, Validator.NON_NEGATIVE_FLOAT);
    registerClusterDynamicSetting(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE, ClusterRebalanceAllocationDecider.ALLOCATION_ALLOW_REBALANCE_VALIDATOR);
    registerClusterDynamicSetting(ConcurrentRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_CLUSTER_CONCURRENT_REBALANCE, Validator.INTEGER);
    registerClusterDynamicSetting(EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE, Validator.EMPTY);
    registerClusterDynamicSetting(EnableAllocationDecider.CLUSTER_ROUTING_REBALANCE_ENABLE, Validator.EMPTY);
    registerClusterDynamicSetting(DisableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_DISABLE_NEW_ALLOCATION, Validator.EMPTY);
    registerClusterDynamicSetting(DisableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_DISABLE_ALLOCATION, Validator.EMPTY);
    registerClusterDynamicSetting(DisableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_DISABLE_REPLICA_ALLOCATION, Validator.EMPTY);
    registerClusterDynamicSetting(DiscoverySettings.NO_MASTER_BLOCK, Validator.EMPTY);
    registerClusterDynamicSetting(FilterAllocationDecider.CLUSTER_ROUTING_INCLUDE_GROUP + "*", Validator.EMPTY);
    registerClusterDynamicSetting(FilterAllocationDecider.CLUSTER_ROUTING_EXCLUDE_GROUP + "*", Validator.EMPTY);
    registerClusterDynamicSetting(FilterAllocationDecider.CLUSTER_ROUTING_REQUIRE_GROUP + "*", Validator.EMPTY);
    registerClusterDynamicSetting(IndicesStore.INDICES_STORE_THROTTLE_TYPE, Validator.EMPTY);
    registerClusterDynamicSetting(IndicesStore.INDICES_STORE_THROTTLE_MAX_BYTES_PER_SEC, Validator.BYTES_SIZE);
    registerClusterDynamicSetting(IndicesTTLService.INDICES_TTL_INTERVAL, Validator.TIME);
    registerClusterDynamicSetting(MappingUpdatedAction.INDICES_MAPPING_DYNAMIC_TIMEOUT, Validator.TIME);
    registerClusterDynamicSetting(MetaData.SETTING_READ_ONLY, Validator.EMPTY);
    registerClusterDynamicSetting(RecoverySettings.INDICES_RECOVERY_FILE_CHUNK_SIZE, Validator.POSITIVE_BYTES_SIZE);
    registerClusterDynamicSetting(RecoverySettings.INDICES_RECOVERY_TRANSLOG_OPS, Validator.INTEGER);
    registerClusterDynamicSetting(RecoverySettings.INDICES_RECOVERY_TRANSLOG_SIZE, Validator.BYTES_SIZE);
    registerClusterDynamicSetting(RecoverySettings.INDICES_RECOVERY_COMPRESS, Validator.EMPTY);
    registerClusterDynamicSetting(RecoverySettings.INDICES_RECOVERY_CONCURRENT_STREAMS, Validator.POSITIVE_INTEGER);
    registerClusterDynamicSetting(RecoverySettings.INDICES_RECOVERY_CONCURRENT_SMALL_FILE_STREAMS, Validator.POSITIVE_INTEGER);
    registerClusterDynamicSetting(RecoverySettings.INDICES_RECOVERY_MAX_BYTES_PER_SEC, Validator.BYTES_SIZE);
    registerClusterDynamicSetting(RecoverySettings.INDICES_RECOVERY_RETRY_DELAY_STATE_SYNC, Validator.TIME_NON_NEGATIVE);
    registerClusterDynamicSetting(RecoverySettings.INDICES_RECOVERY_RETRY_DELAY_NETWORK, Validator.TIME_NON_NEGATIVE);
    registerClusterDynamicSetting(RecoverySettings.INDICES_RECOVERY_ACTIVITY_TIMEOUT, Validator.TIME_NON_NEGATIVE);
    registerClusterDynamicSetting(RecoverySettings.INDICES_RECOVERY_INTERNAL_ACTION_TIMEOUT, Validator.TIME_NON_NEGATIVE);
    registerClusterDynamicSetting(RecoverySettings.INDICES_RECOVERY_INTERNAL_LONG_ACTION_TIMEOUT, Validator.TIME_NON_NEGATIVE);
    registerClusterDynamicSetting(RecoverySettings.INDICES_RECOVERY_MAX_SIZE_PER_SEC, Validator.BYTES_SIZE);
    registerClusterDynamicSetting(ThreadPool.THREADPOOL_GROUP + "*", ThreadPool.THREAD_POOL_TYPE_SETTINGS_VALIDATOR);
    registerClusterDynamicSetting(ThrottlingAllocationDecider.CLUSTER_ROUTING_ALLOCATION_NODE_INITIAL_PRIMARIES_RECOVERIES, Validator.INTEGER);
    registerClusterDynamicSetting(ThrottlingAllocationDecider.CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_RECOVERIES, Validator.INTEGER);
    registerClusterDynamicSetting(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK, Validator.EMPTY);
    registerClusterDynamicSetting(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK, Validator.EMPTY);
    registerClusterDynamicSetting(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED, Validator.BOOLEAN);
    registerClusterDynamicSetting(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS, Validator.BOOLEAN);
    registerClusterDynamicSetting(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_REROUTE_INTERVAL, Validator.TIME_NON_NEGATIVE);
    registerClusterDynamicSetting(InternalClusterInfoService.INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL, Validator.TIME_NON_NEGATIVE);
    registerClusterDynamicSetting(InternalClusterInfoService.INTERNAL_CLUSTER_INFO_TIMEOUT, Validator.TIME_NON_NEGATIVE);
    registerClusterDynamicSetting(SnapshotInProgressAllocationDecider.CLUSTER_ROUTING_ALLOCATION_SNAPSHOT_RELOCATION_ENABLED, Validator.EMPTY);
    registerClusterDynamicSetting(DestructiveOperations.REQUIRES_NAME, Validator.EMPTY);
    registerClusterDynamicSetting(DiscoverySettings.PUBLISH_TIMEOUT, Validator.TIME_NON_NEGATIVE);
    registerClusterDynamicSetting(DiscoverySettings.PUBLISH_DIFF_ENABLE, Validator.BOOLEAN);
    registerClusterDynamicSetting(HierarchyCircuitBreakerService.TOTAL_CIRCUIT_BREAKER_LIMIT_SETTING, Validator.MEMORY_SIZE);
    registerClusterDynamicSetting(HierarchyCircuitBreakerService.FIELDDATA_CIRCUIT_BREAKER_LIMIT_SETTING, Validator.MEMORY_SIZE);
    registerClusterDynamicSetting(HierarchyCircuitBreakerService.FIELDDATA_CIRCUIT_BREAKER_OVERHEAD_SETTING, Validator.NON_NEGATIVE_DOUBLE);
    registerClusterDynamicSetting(HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_LIMIT_SETTING, Validator.MEMORY_SIZE);
    registerClusterDynamicSetting(HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_OVERHEAD_SETTING, Validator.NON_NEGATIVE_DOUBLE);
    registerClusterDynamicSetting(InternalClusterService.SETTING_CLUSTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD, Validator.TIME_NON_NEGATIVE);
    registerClusterDynamicSetting(SearchService.DEFAULT_SEARCH_TIMEOUT, Validator.TIMEOUT);
    registerClusterDynamicSetting(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES, ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_VALIDATOR);
    registerClusterDynamicSetting(TransportService.SETTING_TRACE_LOG_INCLUDE, Validator.EMPTY);
    registerClusterDynamicSetting(TransportService.SETTING_TRACE_LOG_INCLUDE + ".*", Validator.EMPTY);
    registerClusterDynamicSetting(TransportService.SETTING_TRACE_LOG_EXCLUDE, Validator.EMPTY);
    registerClusterDynamicSetting(TransportService.SETTING_TRACE_LOG_EXCLUDE + ".*", Validator.EMPTY);
    registerClusterDynamicSetting(TransportCloseIndexAction.SETTING_CLUSTER_INDICES_CLOSE_ENABLE, Validator.BOOLEAN);
    registerClusterDynamicSetting(ShardsLimitAllocationDecider.CLUSTER_TOTAL_SHARDS_PER_NODE, Validator.INTEGER);
    registerClusterDynamicSetting(AuditService.AUDIT_LOG_THRESHOLD, Validator.TIME);
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:66,代碼來源:ClusterModule.java

示例7: OperationRouting

import org.elasticsearch.cluster.routing.allocation.decider.AwarenessAllocationDecider; //導入依賴的package包/類
@Inject
public OperationRouting(Settings settings, AwarenessAllocationDecider awarenessAllocationDecider) {
    super(settings);
    this.awarenessAllocationDecider = awarenessAllocationDecider;
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:6,代碼來源:OperationRouting.java


注:本文中的org.elasticsearch.cluster.routing.allocation.decider.AwarenessAllocationDecider類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。