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


Java ShardRouting.unassigned方法代码示例

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


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

示例1: decideShardAllocation

import org.elasticsearch.cluster.routing.ShardRouting; //导入方法依赖的package包/类
@Override
public ShardAllocationDecision decideShardAllocation(final ShardRouting shard, final RoutingAllocation allocation) {
    Balancer balancer = new Balancer(logger, allocation, weightFunction, threshold);
    AllocateUnassignedDecision allocateUnassignedDecision = AllocateUnassignedDecision.NOT_TAKEN;
    MoveDecision moveDecision = MoveDecision.NOT_TAKEN;
    if (shard.unassigned()) {
        allocateUnassignedDecision = balancer.decideAllocateUnassigned(shard, Sets.newHashSet());
    } else {
        moveDecision = balancer.decideMove(shard);
        if (moveDecision.isDecisionTaken() && moveDecision.canRemain()) {
            MoveDecision rebalanceDecision = balancer.decideRebalance(shard);
            moveDecision = rebalanceDecision.withRemainDecision(moveDecision.getCanRemainDecision());
        }
    }
    return new ShardAllocationDecision(allocateUnassignedDecision, moveDecision);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:BalancedShardsAllocator.java

示例2: canAllocate

import org.elasticsearch.cluster.routing.ShardRouting; //导入方法依赖的package包/类
@Override
public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) {
    if (shardRouting.unassigned()) {
        // only for unassigned - we filter allocation right after the index creation ie. for shard shrinking etc. to ensure
        // that once it has been allocated post API the replicas can be allocated elsewhere without user interaction
        // this is a setting that can only be set within the system!
        IndexMetaData indexMd = allocation.metaData().getIndexSafe(shardRouting.index());
        DiscoveryNodeFilters initialRecoveryFilters = indexMd.getInitialRecoveryFilters();
        if (initialRecoveryFilters != null  &&
            RecoverySource.isInitialRecovery(shardRouting.recoverySource().getType()) &&
            initialRecoveryFilters.match(node.node()) == false) {
            String explanation = (shardRouting.recoverySource().getType() == RecoverySource.Type.LOCAL_SHARDS) ?
                "initial allocation of the shrunken index is only allowed on nodes [%s] that hold a copy of every shard in the index" :
                "initial allocation of the index is only allowed on nodes [%s]";
            return allocation.decision(Decision.NO, NAME, explanation, initialRecoveryFilters);
        }
    }
    return shouldFilter(shardRouting, node, allocation);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:FilterAllocationDecider.java

示例3: waitingShardsStartedOrUnassigned

import org.elasticsearch.cluster.routing.ShardRouting; //导入方法依赖的package包/类
private boolean waitingShardsStartedOrUnassigned(ClusterChangedEvent event) {
    SnapshotsInProgress curr = event.state().custom(SnapshotsInProgress.TYPE);
    if (curr != null) {
        for (SnapshotsInProgress.Entry entry : curr.entries()) {
            if (entry.state() == State.STARTED && !entry.waitingIndices().isEmpty()) {
                for (ObjectCursor<String> index : entry.waitingIndices().keys()) {
                    if (event.indexRoutingTableChanged(index.value)) {
                        IndexRoutingTable indexShardRoutingTable = event.state().getRoutingTable().index(index.value);
                        for (ShardId shardId : entry.waitingIndices().get(index.value)) {
                            ShardRouting shardRouting = indexShardRoutingTable.shard(shardId.id()).primaryShard();
                            if (shardRouting != null && (shardRouting.started() || shardRouting.unassigned())) {
                                return true;
                            }
                        }
                    }
                }
            }
        }
    }
    return false;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:SnapshotsService.java

示例4: explainShard

import org.elasticsearch.cluster.routing.ShardRouting; //导入方法依赖的package包/类
public static ClusterAllocationExplanation explainShard(ShardRouting shardRouting, RoutingAllocation allocation,
                                                        ClusterInfo clusterInfo, boolean includeYesDecisions,
                                                        GatewayAllocator gatewayAllocator, ShardsAllocator shardAllocator) {
    allocation.setDebugMode(includeYesDecisions ? DebugMode.ON : DebugMode.EXCLUDE_YES_DECISIONS);

    ShardAllocationDecision shardDecision;
    if (shardRouting.initializing() || shardRouting.relocating()) {
        shardDecision = ShardAllocationDecision.NOT_TAKEN;
    } else {
        AllocateUnassignedDecision allocateDecision = shardRouting.unassigned() ?
            gatewayAllocator.decideUnassignedShardAllocation(shardRouting, allocation) : AllocateUnassignedDecision.NOT_TAKEN;
        if (allocateDecision.isDecisionTaken() == false) {
            shardDecision = shardAllocator.decideShardAllocation(shardRouting, allocation);
        } else {
            shardDecision = new ShardAllocationDecision(allocateDecision, MoveDecision.NOT_TAKEN);
        }
    }

    return new ClusterAllocationExplanation(shardRouting,
        shardRouting.currentNodeId() != null ? allocation.nodes().get(shardRouting.currentNodeId()) : null,
        shardRouting.relocatingNodeId() != null ? allocation.nodes().get(shardRouting.relocatingNodeId()) : null,
        clusterInfo, shardDecision);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:TransportClusterAllocationExplainAction.java

示例5: performOnReplicas

import org.elasticsearch.cluster.routing.ShardRouting; //导入方法依赖的package包/类
private void performOnReplicas(ReplicaRequest replicaRequest, List<ShardRouting> shards) {
    final String localNodeId = primary.routingEntry().currentNodeId();
    // If the index gets deleted after primary operation, we skip replication
    for (final ShardRouting shard : shards) {
        if (executeOnReplicas == false || shard.unassigned()) {
            if (shard.primary() == false) {
                totalShards.incrementAndGet();
            }
            continue;
        }

        if (shard.currentNodeId().equals(localNodeId) == false) {
            performOnReplica(shard, replicaRequest);
        }

        if (shard.relocating() && shard.relocatingNodeId().equals(localNodeId) == false) {
            performOnReplica(shard.getTargetRelocatingShard(), replicaRequest);
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:ReplicationOperation.java

示例6: getExpectedReplicas

import org.elasticsearch.cluster.routing.ShardRouting; //导入方法依赖的package包/类
private Set<ShardRouting> getExpectedReplicas(ShardId shardId, ClusterState state) {
    Set<ShardRouting> expectedReplicas = new HashSet<>();
    String localNodeId = state.nodes().getLocalNodeId();
    if (state.routingTable().hasIndex(shardId.getIndexName())) {
        for (ShardRouting shardRouting : state.routingTable().shardRoutingTable(shardId)) {
            if (shardRouting.unassigned()) {
                continue;
            }
            if (localNodeId.equals(shardRouting.currentNodeId()) == false) {
                expectedReplicas.add(shardRouting);
            }

            if (shardRouting.relocating() && localNodeId.equals(shardRouting.relocatingNodeId()) == false) {
                expectedReplicas.add(shardRouting.getTargetRelocatingShard());
            }
        }
    }
    return expectedReplicas;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:ReplicationOperationTests.java

示例7: waitingShardsStartedOrUnassigned

import org.elasticsearch.cluster.routing.ShardRouting; //导入方法依赖的package包/类
private boolean waitingShardsStartedOrUnassigned(ClusterChangedEvent event) {
    SnapshotsInProgress curr = event.state().custom(SnapshotsInProgress.TYPE);
    if (curr != null) {
        for (SnapshotsInProgress.Entry entry : curr.entries()) {
            if (entry.state() == State.STARTED && !entry.waitingIndices().isEmpty()) {
                for (String index : entry.waitingIndices().keySet()) {
                    if (event.indexRoutingTableChanged(index)) {
                        IndexRoutingTable indexShardRoutingTable = event.state().getRoutingTable().index(index);
                        for (ShardId shardId : entry.waitingIndices().get(index)) {
                            ShardRouting shardRouting = indexShardRoutingTable.shard(shardId.id()).primaryShard();
                            if (shardRouting != null && (shardRouting.started() || shardRouting.unassigned())) {
                                return true;
                            }
                        }
                    }
                }
            }
        }
    }
    return false;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:22,代码来源:SnapshotsService.java

示例8: isResponsibleFor

import org.elasticsearch.cluster.routing.ShardRouting; //导入方法依赖的package包/类
/**
 * Is the allocator responsible for allocating the given {@link ShardRouting}?
 */
private static boolean isResponsibleFor(final ShardRouting shard) {
    return shard.primary() // must be primary
            && shard.unassigned() // must be unassigned
            // only handle either an existing store or a snapshot recovery
            && (shard.recoverySource().getType() == RecoverySource.Type.EXISTING_STORE
                || shard.recoverySource().getType() == RecoverySource.Type.SNAPSHOT);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:PrimaryShardAllocator.java

示例9: isResponsibleFor

import org.elasticsearch.cluster.routing.ShardRouting; //导入方法依赖的package包/类
/**
 * Is the allocator responsible for allocating the given {@link ShardRouting}?
 */
private static boolean isResponsibleFor(final ShardRouting shard) {
    return shard.primary() == false // must be a replica
               && shard.unassigned() // must be unassigned
               // if we are allocating a replica because of index creation, no need to go and find a copy, there isn't one...
               && shard.unassignedInfo().getReason() != UnassignedInfo.Reason.INDEX_CREATED;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:ReplicaShardAllocator.java

示例10: ClusterShardHealth

import org.elasticsearch.cluster.routing.ShardRouting; //导入方法依赖的package包/类
public ClusterShardHealth(final int shardId, final IndexShardRoutingTable shardRoutingTable) {
    this.shardId = shardId;
    int computeActiveShards = 0;
    int computeRelocatingShards = 0;
    int computeInitializingShards = 0;
    int computeUnassignedShards = 0;
    for (ShardRouting shardRouting : shardRoutingTable) {
        if (shardRouting.active()) {
            computeActiveShards++;
            if (shardRouting.relocating()) {
                // the shard is relocating, the one it is relocating to will be in initializing state, so we don't count it
                computeRelocatingShards++;
            }
        } else if (shardRouting.initializing()) {
            computeInitializingShards++;
        } else if (shardRouting.unassigned()) {
            computeUnassignedShards++;
        }
    }
    ClusterHealthStatus computeStatus;
    final ShardRouting primaryRouting = shardRoutingTable.primaryShard();
    if (primaryRouting.active()) {
        if (computeActiveShards == shardRoutingTable.size()) {
            computeStatus = ClusterHealthStatus.GREEN;
        } else {
            computeStatus = ClusterHealthStatus.YELLOW;
        }
    } else {
        computeStatus = getInactivePrimaryHealth(primaryRouting);
    }
    this.status = computeStatus;
    this.activeShards = computeActiveShards;
    this.relocatingShards = computeRelocatingShards;
    this.initializingShards = computeInitializingShards;
    this.unassignedShards = computeUnassignedShards;
    this.primaryActive = primaryRouting.active();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:38,代码来源:ClusterShardHealth.java

示例11: ClusterShardHealth

import org.elasticsearch.cluster.routing.ShardRouting; //导入方法依赖的package包/类
public ClusterShardHealth(int shardId, final IndexShardRoutingTable shardRoutingTable) {
    this.shardId = shardId;
    for (ShardRouting shardRouting : shardRoutingTable) {
        if (shardRouting.active()) {
            activeShards++;
            if (shardRouting.relocating()) {
                // the shard is relocating, the one it is relocating to will be in initializing state, so we don't count it
                relocatingShards++;
            }
            if (shardRouting.primary()) {
                primaryActive = true;
            }
        } else if (shardRouting.initializing()) {
            initializingShards++;
        } else if (shardRouting.unassigned()) {
            unassignedShards++;
        }
    }
    if (primaryActive) {
        if (activeShards == shardRoutingTable.size()) {
            status = ClusterHealthStatus.GREEN;
        } else {
            status = ClusterHealthStatus.YELLOW;
        }
    } else {
        status = ClusterHealthStatus.RED;
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:29,代码来源:ClusterShardHealth.java


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