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


Java ShardRouting.allocatedPostIndexCreate方法代码示例

本文整理汇总了Java中org.elasticsearch.cluster.routing.ShardRouting.allocatedPostIndexCreate方法的典型用法代码示例。如果您正苦于以下问题:Java ShardRouting.allocatedPostIndexCreate方法的具体用法?Java ShardRouting.allocatedPostIndexCreate怎么用?Java ShardRouting.allocatedPostIndexCreate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.cluster.routing.ShardRouting的用法示例。


在下文中一共展示了ShardRouting.allocatedPostIndexCreate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: needToFindPrimaryCopy

import org.elasticsearch.cluster.routing.ShardRouting; //导入方法依赖的package包/类
/**
 * Does the shard need to find a primary copy?
 */
boolean needToFindPrimaryCopy(ShardRouting shard) {
    if (shard.primary() == false) {
        return false;
    }

    // this is an API allocation, ignore since we know there is no data...
    if (shard.allocatedPostIndexCreate() == false) {
        return false;
    }

    return true;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:16,代码来源:PrimaryShardAllocator.java

示例2: canAllocate

import org.elasticsearch.cluster.routing.ShardRouting; //导入方法依赖的package包/类
@Override
public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) {
    if (allocation.ignoreDisable()) {
        return allocation.decision(Decision.YES, NAME, "allocation disabling is ignored");
    }
    Settings indexSettings = allocation.routingNodes().metaData().index(shardRouting.index()).getSettings();
    if (shardRouting.primary() && shardRouting.allocatedPostIndexCreate() == false) {
        // if its primary, and it hasn't been allocated post API (meaning its a "fresh newly created shard"), only disable allocation
        // on a special disable allocation flag
        if (indexSettings.getAsBoolean(INDEX_ROUTING_ALLOCATION_DISABLE_NEW_ALLOCATION, disableNewAllocation)) {
            return allocation.decision(Decision.NO, NAME, "new primary allocation is disabled");
        } else {
            return allocation.decision(Decision.YES, NAME, "new primary allocation is enabled");
        }
    }
    if (indexSettings.getAsBoolean(INDEX_ROUTING_ALLOCATION_DISABLE_ALLOCATION, disableAllocation)) {
        return allocation.decision(Decision.NO, NAME, "all allocation is disabled");
    }
    if (indexSettings.getAsBoolean(INDEX_ROUTING_ALLOCATION_DISABLE_REPLICA_ALLOCATION, disableReplicaAllocation)) {
        if (shardRouting.primary()) {
            return allocation.decision(Decision.YES, NAME, "primary allocation is enabled");
        } else {
            return allocation.decision(Decision.NO, NAME, "replica allocation is disabled");
        }
    }
    return allocation.decision(Decision.YES, NAME, "all allocation is enabled");
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:28,代码来源:DisableAllocationDecider.java

示例3: canAllocate

import org.elasticsearch.cluster.routing.ShardRouting; //导入方法依赖的package包/类
@Override
public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) {
    if (allocation.ignoreDisable()) {
        return allocation.decision(Decision.YES, NAME, "allocation disabling is ignored");
    }

    Settings indexSettings = allocation.routingNodes().metaData().index(shardRouting.index()).getSettings();
    String enableIndexValue = indexSettings.get(INDEX_ROUTING_ALLOCATION_ENABLE);
    final Allocation enable;
    if (enableIndexValue != null) {
        enable = Allocation.parse(enableIndexValue);
    } else {
        enable = this.enableAllocation;
    }
    switch (enable) {
        case ALL:
            return allocation.decision(Decision.YES, NAME, "all allocations are allowed");
        case NONE:
            return allocation.decision(Decision.NO, NAME, "no allocations are allowed");
        case NEW_PRIMARIES:
            if (shardRouting.primary() && shardRouting.allocatedPostIndexCreate() == false) {
                return allocation.decision(Decision.YES, NAME, "new primary allocations are allowed");
            } else {
                return allocation.decision(Decision.NO, NAME, "non-new primary allocations are forbidden");
            }
        case PRIMARIES:
            if (shardRouting.primary()) {
                return allocation.decision(Decision.YES, NAME, "primary allocations are allowed");
            } else {
                return allocation.decision(Decision.NO, NAME, "replica allocations are forbidden");
            }
        default:
            throw new IllegalStateException("Unknown allocation option");
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:36,代码来源:EnableAllocationDecider.java


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