protected static void innerAllocatedUnassigned(RoutingAllocation allocation, PrimaryShardAllocator primaryShardAllocator, ReplicaShardAllocator replicaShardAllocator) { RoutingNodes.UnassignedShards unassigned = allocation.routingNodes().unassigned(); unassigned.sort(PriorityComparator.getAllocationComparator(allocation)); // sort for priority ordering primaryShardAllocator.allocateUnassigned(allocation); replicaShardAllocator.processExistingRecoveries(allocation); replicaShardAllocator.allocateUnassigned(allocation); }
final RoutingAllocation allocation, final Logger logger) { if (isResponsibleFor(unassignedShard) == false) { final FetchResult<NodeGatewayStartedShards> shardState = fetchData(unassignedShard, allocation); if (shardState.hasData() == false) { allocation.setHasPendingAsyncFetch(); List<NodeAllocationResult> nodeDecisions = null; if (explain) { nodeDecisions = buildDecisionsForAllNodes(unassignedShard, allocation); final NodeShardsResult nodeShardsResult = buildNodeShardsResult(unassignedShard, snapshotRestore, allocation.getIgnoreNodes(unassignedShard.shardId()), inSyncAllocationIds, shardState, logger); final boolean enoughAllocationsFound = nodeShardsResult.orderedAllocationCandidates.size() > 0; unassignedShard.index(), unassignedShard.id(), nodeShardsResult.allocationsFound); return AllocateUnassignedDecision.no(AllocationStatus.NO_VALID_SHARD_COPY, explain ? buildNodeDecisions(null, shardState, inSyncAllocationIds) : null); NodesToAllocate nodesToAllocate = buildNodesToAllocate( allocation, nodeShardsResult.orderedAllocationCandidates, unassignedShard, false ); nodesToAllocate = buildNodesToAllocate(allocation, nodeShardsResult.orderedAllocationCandidates, unassignedShard, true); if (nodesToAllocate.yesNodeShards.isEmpty() == false) { final DecidedNode decidedNode = nodesToAllocate.yesNodeShards.get(0); nodeResults = buildNodeDecisions(nodesToAllocate, shardState, inSyncAllocationIds);
/** * Computes and returns the design for allocating a single unassigned shard. If called on an assigned shard, * {@link AllocateUnassignedDecision#NOT_TAKEN} is returned. */ public AllocateUnassignedDecision decideUnassignedShardAllocation(ShardRouting unassignedShard, RoutingAllocation routingAllocation) { if (unassignedShard.primary()) { return primaryShardAllocator.makeAllocationDecision(unassignedShard, routingAllocation, logger); } else { return replicaShardAllocator.makeAllocationDecision(unassignedShard, routingAllocation, logger); } }
final RoutingAllocation allocation, final Logger logger) { if (isResponsibleFor(unassignedShard) == false) { final FetchResult<NodeGatewayStartedShards> shardState = fetchData(unassignedShard, allocation); if (shardState.hasData() == false) { allocation.setHasPendingAsyncFetch(); List<NodeAllocationResult> nodeDecisions = null; if (explain) { nodeDecisions = buildDecisionsForAllNodes(unassignedShard, allocation); final Set<String> inSyncAllocationIds = indexMetaData.inSyncAllocationIds(unassignedShard.id()); final boolean snapshotRestore = unassignedShard.recoverySource().getType() == RecoverySource.Type.SNAPSHOT; final boolean recoverOnAnyNode = recoverOnAnyNode(indexMetaData); nodeShardsResult = buildVersionBasedNodeShardsResult(unassignedShard, snapshotRestore || recoverOnAnyNode, allocation.getIgnoreNodes(unassignedShard.shardId()), shardState, logger); if (snapshotRestore || recoverOnAnyNode) { enoughAllocationsFound = nodeShardsResult.allocationsFound > 0; } else { enoughAllocationsFound = isEnoughVersionBasedAllocationsFound(indexMetaData, nodeShardsResult); nodeShardsResult = buildAllocationIdBasedNodeShardsResult(unassignedShard, snapshotRestore || recoverOnAnyNode, allocation.getIgnoreNodes(unassignedShard.shardId()), inSyncAllocationIds, shardState, logger); enoughAllocationsFound = nodeShardsResult.orderedAllocationCandidates.size() > 0; unassignedShard.index(), unassignedShard.id(), nodeShardsResult.allocationsFound); return AllocateUnassignedDecision.no(AllocationStatus.NO_VALID_SHARD_COPY, explain ? buildNodeDecisions(null, shardState, inSyncAllocationIds) : null);
ShardRouting shard = unassignedIterator.next(); if (needToFindPrimaryCopy(shard) == false) { continue; AsyncShardFetch.FetchResult<TransportNodesListGatewayStartedShards.NodeGatewayStartedShards> shardState = fetchData(shard, allocation); if (shardState.hasData() == false) { logger.trace("{}: ignoring allocation, still fetching shard started state", shard); NodesAndVersions nodesAndVersions = buildNodesAndVersions(shard, recoverOnAnyNode(indexMetaData.getSettings()), allocation.getIgnoreNodes(shard.shardId()), shardState); logger.debug("[{}][{}] found {} allocations of {}, highest version: [{}]", shard.index(), shard.id(), nodesAndVersions.allocationsFound, shard, nodesAndVersions.highestVersion); if (isEnoughAllocationsFound(shard, indexMetaData, nodesAndVersions) == false) { NodesToAllocate nodesToAllocate = buildNodesToAllocate(shard, allocation, nodesAndVersions); if (nodesToAllocate.yesNodes.isEmpty() == false) { DiscoveryNode node = nodesToAllocate.yesNodes.get(0);
discoNodes.add(dnode.nodeShardState.getNode()); return new NodeAllocationResult(dnode.nodeShardState.getNode(), shardStoreInfo(dnode.nodeShardState, inSyncAllocationIds), dnode.decision); }).collect(Collectors.toList())); new NodeAllocationResult(shardData.getNode(), shardStoreInfo(shardData, inSyncAllocationIds), null) ).collect(Collectors.toList()));
discoNodes.add(dnode.nodeShardState.getNode()); return new NodeAllocationResult(dnode.nodeShardState.getNode(), shardStoreInfo(dnode.nodeShardState, inSyncAllocationIds), dnode.decision); }).collect(Collectors.toList())); new NodeAllocationResult(shardData.getNode(), shardStoreInfo(shardData, inSyncAllocationIds), null) ).collect(Collectors.toList()));
final RoutingAllocation allocation, final Logger logger) { if (isResponsibleFor(unassignedShard) == false) { final FetchResult<NodeGatewayStartedShards> shardState = fetchData(unassignedShard, allocation); if (shardState.hasData() == false) { allocation.setHasPendingAsyncFetch(); List<NodeAllocationResult> nodeDecisions = null; if (explain) { nodeDecisions = buildDecisionsForAllNodes(unassignedShard, allocation); final NodeShardsResult nodeShardsResult = buildNodeShardsResult(unassignedShard, snapshotRestore, allocation.getIgnoreNodes(unassignedShard.shardId()), inSyncAllocationIds, shardState, logger); final boolean enoughAllocationsFound = nodeShardsResult.orderedAllocationCandidates.size() > 0; unassignedShard.index(), unassignedShard.id(), nodeShardsResult.allocationsFound); return AllocateUnassignedDecision.no(AllocationStatus.NO_VALID_SHARD_COPY, explain ? buildNodeDecisions(null, shardState, inSyncAllocationIds) : null); NodesToAllocate nodesToAllocate = buildNodesToAllocate( allocation, nodeShardsResult.orderedAllocationCandidates, unassignedShard, false ); nodesToAllocate = buildNodesToAllocate(allocation, nodeShardsResult.orderedAllocationCandidates, unassignedShard, true); if (nodesToAllocate.yesNodeShards.isEmpty() == false) { final DecidedNode decidedNode = nodesToAllocate.yesNodeShards.get(0); nodeResults = buildNodeDecisions(nodesToAllocate, shardState, inSyncAllocationIds);
protected static void innerAllocatedUnassigned(RoutingAllocation allocation, PrimaryShardAllocator primaryShardAllocator, ReplicaShardAllocator replicaShardAllocator) { RoutingNodes.UnassignedShards unassigned = allocation.routingNodes().unassigned(); unassigned.sort(PriorityComparator.getAllocationComparator(allocation)); // sort for priority ordering primaryShardAllocator.allocateUnassigned(allocation); replicaShardAllocator.processExistingRecoveries(allocation); replicaShardAllocator.allocateUnassigned(allocation); }
/** * Computes and returns the design for allocating a single unassigned shard. If called on an assigned shard, * {@link AllocateUnassignedDecision#NOT_TAKEN} is returned. */ public AllocateUnassignedDecision decideUnassignedShardAllocation(ShardRouting unassignedShard, RoutingAllocation routingAllocation) { if (unassignedShard.primary()) { return primaryShardAllocator.makeAllocationDecision(unassignedShard, routingAllocation, logger); } else { return replicaShardAllocator.makeAllocationDecision(unassignedShard, routingAllocation, logger); } }
discoNodes.add(dnode.nodeShardState.getNode()); return new NodeAllocationResult(dnode.nodeShardState.getNode(), shardStoreInfo(dnode.nodeShardState, inSyncAllocationIds), dnode.decision); }).collect(Collectors.toList())); new NodeAllocationResult(shardData.getNode(), shardStoreInfo(shardData, inSyncAllocationIds), null) ).collect(Collectors.toList()));
final RoutingAllocation allocation, final Logger logger) { if (isResponsibleFor(unassignedShard) == false) { final FetchResult<NodeGatewayStartedShards> shardState = fetchData(unassignedShard, allocation); if (shardState.hasData() == false) { allocation.setHasPendingAsyncFetch(); List<NodeAllocationResult> nodeDecisions = null; if (explain) { nodeDecisions = buildDecisionsForAllNodes(unassignedShard, allocation); final NodeShardsResult nodeShardsResult = buildNodeShardsResult(unassignedShard, snapshotRestore, allocation.getIgnoreNodes(unassignedShard.shardId()), inSyncAllocationIds, shardState, logger); final boolean enoughAllocationsFound = nodeShardsResult.orderedAllocationCandidates.size() > 0; unassignedShard.index(), unassignedShard.id(), nodeShardsResult.allocationsFound); return AllocateUnassignedDecision.no(AllocationStatus.NO_VALID_SHARD_COPY, explain ? buildNodeDecisions(null, shardState, inSyncAllocationIds) : null); NodesToAllocate nodesToAllocate = buildNodesToAllocate( allocation, nodeShardsResult.orderedAllocationCandidates, unassignedShard, false ); nodesToAllocate = buildNodesToAllocate(allocation, nodeShardsResult.orderedAllocationCandidates, unassignedShard, true); if (nodesToAllocate.yesNodeShards.isEmpty() == false) { final DecidedNode decidedNode = nodesToAllocate.yesNodeShards.get(0); nodeResults = buildNodeDecisions(nodesToAllocate, shardState, inSyncAllocationIds);
protected static void innerAllocatedUnassigned(RoutingAllocation allocation, PrimaryShardAllocator primaryShardAllocator, ReplicaShardAllocator replicaShardAllocator) { RoutingNodes.UnassignedShards unassigned = allocation.routingNodes().unassigned(); unassigned.sort(PriorityComparator.getAllocationComparator(allocation)); // sort for priority ordering primaryShardAllocator.allocateUnassigned(allocation); replicaShardAllocator.processExistingRecoveries(allocation); replicaShardAllocator.allocateUnassigned(allocation); }
/** * Computes and returns the design for allocating a single unassigned shard. If called on an assigned shard, * {@link AllocateUnassignedDecision#NOT_TAKEN} is returned. */ public AllocateUnassignedDecision decideUnassignedShardAllocation(ShardRouting unassignedShard, RoutingAllocation routingAllocation) { if (unassignedShard.primary()) { return primaryShardAllocator.makeAllocationDecision(unassignedShard, routingAllocation, logger); } else { return replicaShardAllocator.makeAllocationDecision(unassignedShard, routingAllocation, logger); } }
discoNodes.add(dnode.nodeShardState.getNode()); return new NodeAllocationResult(dnode.nodeShardState.getNode(), shardStoreInfo(dnode.nodeShardState, inSyncAllocationIds), dnode.decision); }).collect(Collectors.toList())); new NodeAllocationResult(shardData.getNode(), shardStoreInfo(shardData, inSyncAllocationIds), null) ).collect(Collectors.toList()));
public boolean allocateUnassigned(final RoutingAllocation allocation) { boolean changed = false; RoutingNodes.UnassignedShards unassigned = allocation.routingNodes().unassigned(); unassigned.sort(PriorityComparator.getAllocationComparator(allocation)); // sort for priority ordering changed |= primaryShardAllocator.allocateUnassigned(allocation); changed |= replicaShardAllocator.processExistingRecoveries(allocation); changed |= replicaShardAllocator.allocateUnassigned(allocation); return changed; }
/** * Computes and returns the design for allocating a single unassigned shard. If called on an assigned shard, * {@link AllocateUnassignedDecision#NOT_TAKEN} is returned. */ public AllocateUnassignedDecision decideUnassignedShardAllocation(ShardRouting unassignedShard, RoutingAllocation routingAllocation) { if (unassignedShard.primary()) { return primaryShardAllocator.makeAllocationDecision(unassignedShard, routingAllocation, logger); } else { return replicaShardAllocator.makeAllocationDecision(unassignedShard, routingAllocation, logger); } }
protected static void innerAllocatedUnassigned(RoutingAllocation allocation, PrimaryShardAllocator primaryShardAllocator, ReplicaShardAllocator replicaShardAllocator) { RoutingNodes.UnassignedShards unassigned = allocation.routingNodes().unassigned(); unassigned.sort(PriorityComparator.getAllocationComparator(allocation)); // sort for priority ordering primaryShardAllocator.allocateUnassigned(allocation); replicaShardAllocator.processExistingRecoveries(allocation); replicaShardAllocator.allocateUnassigned(allocation); }