本文整理汇总了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;
}
示例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");
}
示例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");
}
}