/** * A shard exists/existed in a node only if shard state file exists in the node */ private boolean shardExistsInNode(final NodeGatewayStartedShards response) { return response.storeException() != null || response.allocationId() != null; }
@Override protected void doRun() throws Exception { gateway.performStateRecovery(recoveryListener); } });
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); }
@Override protected AsyncShardFetch.FetchResult<TransportNodesListShardStoreMetaData.NodeStoreFilesMetaData> fetchData(ShardRouting shard, RoutingAllocation allocation) { AsyncShardFetch<TransportNodesListShardStoreMetaData.NodeStoreFilesMetaData> fetch = asyncFetchStore.computeIfAbsent(shard.shardId(), shardId -> new InternalAsyncFetch<>(logger, "shard_store", shard.shardId(), storeAction)); AsyncShardFetch.FetchResult<TransportNodesListShardStoreMetaData.NodeStoreFilesMetaData> shardStores = fetch.fetchData(allocation.nodes(), allocation.getIgnoreNodes(shard.shardId())); if (shardStores.hasData()) { shardStores.processAllocation(allocation); } return shardStores; }
@Override protected NodeGatewayMetaState nodeOperation(NodeRequest request) { try { return new NodeGatewayMetaState(clusterService.localNode(), metaState.loadMetaState()); } catch (Exception e) { throw new ElasticsearchException("failed to load metadata", e); } }
/** * 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); } }
@Override public AllocateDangledResponse read(StreamInput in) throws IOException { final AllocateDangledResponse response = new AllocateDangledResponse(); response.readFrom(in); return response; }
@Override protected NodeGatewayStartedShards newNodeResponse() { return new NodeGatewayStartedShards(); }
@Override protected NodeRequest newNodeRequest(String nodeId, Request request) { return new NodeRequest(nodeId); }
@Override public void handleResponse(AllocateDangledResponse response) { listener.onResponse(response); }
@Override protected NodeRequest newNodeRequest(String nodeId, Request request) { return new NodeRequest(nodeId, request); }
public NodeRequest(String nodeId, Request request) { super(nodeId); this.shardId = request.shardId(); }
Throwable getFailure() { assert hasData() : "getting failure when data has not been fetched"; return failure; }
@Override protected NodeGatewayMetaState newNodeResponse() { return new NodeGatewayMetaState(); }
@Override public void handleException(TransportException exp) { listener.onFailure(exp); }
public MetaData loadMetaState() throws IOException { return metaStateService.loadFullState(); }
/** * Finds (@{link #findNewAndAddDanglingIndices}) and adds the new dangling indices * to the currently tracked dangling indices. */ void findNewAndAddDanglingIndices(final MetaData metaData) { danglingIndices.putAll(findNewDanglingIndices(metaData)); }
public void allocateUnassigned(final RoutingAllocation allocation) { innerAllocatedUnassigned(allocation, primaryShardAllocator, replicaShardAllocator); }