org.elasticsearch.transport.TransportChannel Java Examples

The following examples show how to use org.elasticsearch.transport.TransportChannel. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PullFullClusterStateAction.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
public void messageReceived(PullFullClusterStateRequest request, final TransportChannel channel) throws Exception {
    ClusterStateWithDLSN clusterStateWithDLSN = clusterStateOpLog.getLatestClusterState();
    if (!clusterStateWithDLSN.state().getClusterName().equals(request.clusterName)) {
       throw new java.lang.Exception("master cluster name is [" + clusterStateWithDLSN.state().getClusterName() + "], request cluster name is [" + request.clusterName + "]");
    }
    if (!clusterStateWithDLSN.state().nodes().localNodeMaster()) {
        throw new java.lang.Exception("current node is no longer master node");
    }
    BytesStreamOutput bStream = new BytesStreamOutput();
    try (StreamOutput stream = CompressorFactory.defaultCompressor().streamOutput(bStream)) {
        clusterStateWithDLSN.writeTo(stream);
    }
    BytesReference fullStateBytes = bStream.bytes();
    channel.sendResponse(new org.elasticsearch.transport.BytesTransportResponse(fullStateBytes));
}
 
Example #2
Source File: NodesFailureDetectionService.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
public void messageReceived(PingRequest request, TransportChannel channel) throws Exception {
    
    // PingRequest will have clusterName set to null if it came from a node of version <1.4.0
    if (request.clusterName != null && !request.clusterName.equals(clusterName)) {
        // Don't introduce new exception for bwc reasons
        throw new IllegalStateException("Got pinged with cluster name [" + request.clusterName + "], but I'm part of cluster [" + clusterName + "]");
    }
    
    // if we are not the node we are supposed to be pinged, send an exception
    // this can happen when a kill -9 is sent, and another node is started using the same port
    if (!localNode.equals(request.pingNode)) {
        logger.warn("Got pinged as node [{}], but I am node [{}], cluster name is equal, it means I am restarted, so rejoin the cluster now", request.pingNode, localNode);
        joinClusterAction.joinElectedMaster(request.masterNode);
        throw new NodeIdNotMatchException(localNode, request.pingNode);
    }
    
    if (request.isDeadNode) {
        logger.warn("master ping me as a dead node, so that I should rejoin the cluster");
        joinClusterAction.joinElectedMaster(request.masterNode);
    }
    channel.sendResponse(new PingResponse(clusterStateOpLog.getDumpedDlsn()));
}
 
Example #3
Source File: BlobHeadRequestHandler.java    From crate with Apache License 2.0 6 votes vote down vote up
/**
 * this is method is called on the recovery source node
 * the target is requesting the head of a file it got a PutReplicaChunkRequest for.
 */
@Override
public void messageReceived(final GetBlobHeadRequest request, TransportChannel channel, Task task) throws Exception {

    final BlobTransferStatus transferStatus = blobTransferTarget.getActiveTransfer(request.transferId);
    assert transferStatus != null :
        "Received GetBlobHeadRequest for transfer" + request.transferId.toString() +
        "but don't have an activeTransfer with that id";

    final DiscoveryNode recipientNode = clusterService.state().getNodes().get(request.senderNodeId);
    final long bytesToSend = request.endPos;

    blobTransferTarget.gotAGetBlobHeadRequest(request.transferId);

    channel.sendResponse(TransportResponse.Empty.INSTANCE);

    threadPool.generic().execute(
        new PutHeadChunkRunnable(
            transferStatus.digestBlob(), bytesToSend, transportService, blobTransferTarget,
            recipientNode, request.transferId)
    );
}
 
Example #4
Source File: BlobHeadRequestHandler.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
/**
 * this is method is called on the recovery source node
 * the target is requesting the head of a file it got a PutReplicaChunkRequest for.
 */
@Override
public void messageReceived(final GetBlobHeadRequest request, TransportChannel channel) throws Exception {

    final BlobTransferStatus transferStatus = blobTransferTarget.getActiveTransfer(request.transferId);
    assert transferStatus != null :
        "Received GetBlobHeadRequest for transfer" + request.transferId.toString() + "but don't have an activeTransfer with that id";

    final DiscoveryNode recipientNode = clusterService.state().getNodes().get(request.senderNodeId);
    final long bytesToSend = request.endPos;

    blobTransferTarget.gotAGetBlobHeadRequest(request.transferId);

    channel.sendResponse(TransportResponse.Empty.INSTANCE);

    threadPool.generic().execute(
        new PutHeadChunkRunnable(
            transferStatus.digestBlob(), bytesToSend, transportService, blobTransferTarget,
            recipientNode, request.transferId)
    );
}
 
Example #5
Source File: TransportReplicationAction.java    From crate with Apache License 2.0 6 votes vote down vote up
AsyncReplicaAction(
        ReplicaRequest request,
        String targetAllocationID,
        long primaryTerm,
        long globalCheckpoint,
        long maxSeqNoOfUpdatesOrDeletes,
        TransportChannel channel,
        ReplicationTask task) {
    this.request = request;
    this.channel = channel;
    this.task = task;
    this.targetAllocationID = targetAllocationID;
    this.primaryTerm = primaryTerm;
    this.globalCheckpoint = globalCheckpoint;
    this.maxSeqNoOfUpdatesOrDeletes = maxSeqNoOfUpdatesOrDeletes;
    final ShardId shardId = request.shardId();
    assert shardId != null : "request shardId must be set";
    this.replica = getIndexShard(shardId);
}
 
Example #6
Source File: BlobRecoveryTarget.java    From crate with Apache License 2.0 6 votes vote down vote up
@Override
public void messageReceived(BlobStartRecoveryRequest request, TransportChannel channel, Task task) throws Exception {
    LOGGER.info("[{}] StartRecoveryRequestHandler start recovery with recoveryId {}",
                request.shardId().getId(), request.recoveryId);

    try (RecoveriesCollection.RecoveryRef statusSafe = peerRecoveryTargetService.onGoingRecoveries.getRecoverySafe(
        request.recoveryId(), request.shardId())) {
        RecoveryTarget onGoingIndexRecovery = statusSafe.target();

        if (onGoingIndexRecovery.cancellableThreads().isCancelled()) {
            throw new IndexShardClosedException(request.shardId());
        }
        BlobShard blobShard = blobIndicesService.blobShardSafe(request.shardId());

        BlobRecoveryStatus status = new BlobRecoveryStatus(onGoingIndexRecovery, blobShard);
        onGoingBlobRecoveries.put(request.recoveryId(), status);
        channel.sendResponse(TransportResponse.Empty.INSTANCE);
    }
}
 
Example #7
Source File: BlobRecoveryTarget.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void messageReceived(BlobRecoveryStartTransferRequest request, TransportChannel channel, Task task) throws Exception {
    BlobRecoveryStatus status = onGoingBlobRecoveries.get(request.recoveryId());
    LOGGER.debug("received BlobRecoveryStartTransferRequest for file {} with size {}",
                 request.path(), request.size());
    if (status == null) {
        throw new IllegalBlobRecoveryStateException("Could not retrieve onGoingRecoveryStatus");
    }
    if (status.canceled()) {
        throw new IndexShardClosedException(status.shardId());
    }


    BlobShard shard = status.blobShard;
    String tmpPath = request.path() + "." + request.transferId();
    Path baseDirectory = shard.blobContainer().getBaseDirectory();
    FileOutputStream outputStream = new FileOutputStream(baseDirectory.resolve(tmpPath).toFile());
    request.content().writeTo(outputStream);

    if (request.size() == request.content().length()) {  // start request contains the whole file.
        outputStream.close();
        Path source = baseDirectory.resolve(tmpPath);
        Path target = baseDirectory.resolve(request.path());

        Files.move(source, target, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE);
    } else {
        BlobRecoveryTransferStatus transferStatus = new BlobRecoveryTransferStatus(
            request.transferId(), outputStream, tmpPath, request.path()
        );
        status.onGoingTransfers().put(request.transferId(), transferStatus);
    }

    channel.sendResponse(TransportResponse.Empty.INSTANCE);
}
 
Example #8
Source File: TransportCancelTasksAction.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void messageReceived(final BanParentTaskRequest request, final TransportChannel channel) throws Exception {
    if (request.ban) {
        logger.debug("Received ban for the parent [{}] on the node [{}], reason: [{}]", request.parentTaskId,
            clusterService.localNode().getId(), request.reason);
        taskManager.setBan(request.parentTaskId, request.reason);
    } else {
        logger.debug("Removing ban for the parent [{}] on the node [{}]", request.parentTaskId,
            clusterService.localNode().getId());
        taskManager.removeBan(request.parentTaskId);
    }
    channel.sendResponse(TransportResponse.Empty.INSTANCE);
}
 
Example #9
Source File: TransportBroadcastByNodeAction.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void messageReceived(final NodeRequest request, TransportChannel channel) throws Exception {
    List<ShardRouting> shards = request.getShards();
    final int totalShards = shards.size();
    if (logger.isTraceEnabled()) {
        logger.trace("[{}] executing operation on [{}] shards", actionName, totalShards);
    }
    final Object[] shardResultOrExceptions = new Object[totalShards];

    int shardIndex = -1;
    for (final ShardRouting shardRouting : shards) {
        shardIndex++;
        onShardOperation(request, shardResultOrExceptions, shardIndex, shardRouting);
    }

    List<BroadcastShardOperationFailedException> accumulatedExceptions = new ArrayList<>();
    List<ShardOperationResult> results = new ArrayList<>();
    for (int i = 0; i < totalShards; i++) {
        if (shardResultOrExceptions[i] instanceof BroadcastShardOperationFailedException) {
            accumulatedExceptions.add((BroadcastShardOperationFailedException) shardResultOrExceptions[i]);
        } else {
            results.add((ShardOperationResult) shardResultOrExceptions[i]);
        }
    }

    channel.sendResponse(new NodeResponse(request.getNodeId(), totalShards, results, accumulatedExceptions));
}
 
Example #10
Source File: VerifyNodeRepositoryAction.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void messageReceived(VerifyNodeRepositoryRequest request, TransportChannel channel, Task task) throws Exception {
    DiscoveryNode localNode = clusterService.state().nodes().getLocalNode();
    try {
        doVerify(request.repository, request.verificationToken, localNode);
    } catch (Exception ex) {
        LOGGER.warn(() -> new ParameterizedMessage("[{}] failed to verify repository", request.repository), ex);
        throw ex;
    }
    channel.sendResponse(TransportResponse.Empty.INSTANCE);
}
 
Example #11
Source File: TransportReplicaShardIngestAction.java    From elasticsearch-helper with Apache License 2.0 5 votes vote down vote up
@Override
public void messageReceived(final ReplicaOperationRequest request, final TransportChannel channel) throws Exception {
    try {
        ActionResponse response = shardOperationOnReplica(request);
        channel.sendResponse(response);
    } catch (Throwable t) {
        logger.error(t.getMessage(), t);
        channel.sendResponse(t);
    }
}
 
Example #12
Source File: PeerRecoveryTargetService.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void messageReceived(final RecoveryFileChunkRequest request, TransportChannel channel, Task task) throws Exception {
    try (RecoveryRef recoveryRef = onGoingRecoveries.getRecoverySafe(request.recoveryId(), request.shardId())) {
        final RecoveryTarget recoveryTarget = recoveryRef.target();
        final RecoveryState.Index indexState = recoveryTarget.state().getIndex();
        if (request.sourceThrottleTimeInNanos() != RecoveryState.Index.UNKNOWN) {
            indexState.addSourceThrottling(request.sourceThrottleTimeInNanos());
        }

        RateLimiter rateLimiter = recoverySettings.rateLimiter();
        if (rateLimiter != null) {
            long bytes = bytesSinceLastPause.addAndGet(request.content().length());
            if (bytes > rateLimiter.getMinPauseCheckBytes()) {
                // Time to pause
                bytesSinceLastPause.addAndGet(-bytes);
                long throttleTimeInNanos = rateLimiter.pause(bytes);
                indexState.addTargetThrottling(throttleTimeInNanos);
                recoveryTarget.indexShard().recoveryStats().addThrottleTime(throttleTimeInNanos);
            }
        }

        final ActionListener<TransportResponse> listener =
            new HandledTransportAction.ChannelActionListener<>(channel, Actions.FILE_CHUNK, request);
        recoveryTarget.writeFileChunk(
            request.metadata(),
            request.position(),
            request.content(),
            request.lastChunk(),
            request.totalTranslogOps(),
            ActionListener.wrap(
                nullVal -> listener.onResponse(TransportResponse.Empty.INSTANCE),
                listener::onFailure)
        );
    }
    channel.sendResponse(TransportResponse.Empty.INSTANCE);
}
 
Example #13
Source File: PeerRecoveryTargetService.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void messageReceived(RecoveryCleanFilesRequest request, TransportChannel channel, Task task) throws Exception {
    try (RecoveryRef recoveryRef = onGoingRecoveries.getRecoverySafe(request.recoveryId(), request.shardId()
    )) {
        recoveryRef.target().cleanFiles(request.totalTranslogOps(), request.sourceMetaSnapshot());
        channel.sendResponse(TransportResponse.Empty.INSTANCE);
    }
}
 
Example #14
Source File: PeerRecoveryTargetService.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void messageReceived(RecoveryFilesInfoRequest request, TransportChannel channel, Task task) throws Exception {
    try (RecoveryRef recoveryRef = onGoingRecoveries.getRecoverySafe(request.recoveryId(), request.shardId()
    )) {
        recoveryRef.target().receiveFileInfo(request.phase1FileNames, request.phase1FileSizes, request.phase1ExistingFileNames,
                request.phase1ExistingFileSizes, request.totalTranslogOps);
        channel.sendResponse(TransportResponse.Empty.INSTANCE);
    }
}
 
Example #15
Source File: BlobRecoveryTarget.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void messageReceived(BlobRecoveryChunkRequest request, TransportChannel channel, Task task) throws Exception {

    BlobRecoveryStatus onGoingRecovery = onGoingBlobRecoveries.get(request.recoveryId());
    if (onGoingRecovery == null) {
        // shard is getting closed on us
        throw new IllegalBlobRecoveryStateException("Could not retrieve onGoingRecoveryStatus");
    }


    BlobRecoveryTransferStatus transferStatus = onGoingRecovery.onGoingTransfers().get(request.transferId());
    BlobShard shard = onGoingRecovery.blobShard;
    if (onGoingRecovery.canceled()) {
        onGoingRecovery.sentCanceledToSource();
        throw new IndexShardClosedException(onGoingRecovery.shardId());
    }

    if (transferStatus == null) {
        throw new IndexShardClosedException(onGoingRecovery.shardId());
    }

    request.content().writeTo(transferStatus.outputStream());

    if (request.isLast()) {
        transferStatus.outputStream().close();
        Path baseDirectory = shard.blobContainer().getBaseDirectory();
        Path source = baseDirectory.resolve(transferStatus.sourcePath());
        Path target = baseDirectory.resolve(transferStatus.targetPath());

        Files.move(source, target, StandardCopyOption.ATOMIC_MOVE, StandardCopyOption.REPLACE_EXISTING);
        onGoingRecovery.onGoingTransfers().remove(request.transferId());
    }

    channel.sendResponse(TransportResponse.Empty.INSTANCE);
}
 
Example #16
Source File: BlobRecoveryTarget.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void messageReceived(BlobStartPrefixSyncRequest request, TransportChannel channel, Task task) throws Exception {
    BlobRecoveryStatus status = onGoingBlobRecoveries.get(request.recoveryId());
    if (status == null) {
        throw new IllegalBlobRecoveryStateException(
            "could not retrieve BlobRecoveryStatus"
        );
    }
    if (status.canceled()) {
        throw new IndexShardClosedException(status.shardId());
    }
    byte[][] currentDigests = status.blobShard.currentDigests(request.prefix());
    BlobStartPrefixResponse response = new BlobStartPrefixResponse(currentDigests);
    channel.sendResponse(response);
}
 
Example #17
Source File: TransportBroadcastByNodeAction.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void messageReceived(final NodeRequest request, TransportChannel channel, Task task) throws Exception {
    List<ShardRouting> shards = request.getShards();
    final int totalShards = shards.size();
    if (logger.isTraceEnabled()) {
        logger.trace("[{}] executing operation on [{}] shards", actionName, totalShards);
    }
    final Object[] shardResultOrExceptions = new Object[totalShards];

    int shardIndex = -1;
    for (final ShardRouting shardRouting : shards) {
        shardIndex++;
        onShardOperation(request, shardResultOrExceptions, shardIndex, shardRouting);
    }

    List<BroadcastShardOperationFailedException> accumulatedExceptions = new ArrayList<>();
    List<ShardOperationResult> results = new ArrayList<>();
    for (int i = 0; i < totalShards; i++) {
        if (shardResultOrExceptions[i] instanceof BroadcastShardOperationFailedException) {
            accumulatedExceptions.add((BroadcastShardOperationFailedException) shardResultOrExceptions[i]);
        } else {
            results.add((ShardOperationResult) shardResultOrExceptions[i]);
        }
    }

    channel.sendResponse(new NodeResponse(request.getNodeId(), totalShards, results, accumulatedExceptions));
}
 
Example #18
Source File: BlobRecoveryTarget.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void messageReceived(BlobRecoveryDeleteRequest request, TransportChannel channel, Task task) throws Exception {
    BlobRecoveryStatus status = onGoingBlobRecoveries.get(request.recoveryId());
    if (status.canceled()) {
        throw new IndexShardClosedException(status.shardId());
    }
    for (BytesReference digest : request.digests) {
        status.blobShard.delete(Hex.encodeHexString(BytesReference.toBytes(digest)));
    }
    channel.sendResponse(TransportResponse.Empty.INSTANCE);
}
 
Example #19
Source File: BlobRecoveryTarget.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void messageReceived(BlobFinalizeRecoveryRequest request, TransportChannel channel, Task task) throws Exception {

    BlobRecoveryStatus status = onGoingBlobRecoveries.get(request.recoveryId);

    for (BlobRecoveryTransferStatus transferStatus : status.onGoingTransfers().values()) {
        if (transferStatus.outputStream().getChannel().isOpen()) {
            throw new IllegalBlobRecoveryStateException(
                "File channel was left open for "
            );
        }
    }
    onGoingBlobRecoveries.remove(request.recoveryId);
    channel.sendResponse(TransportResponse.Empty.INSTANCE);
}
 
Example #20
Source File: PeerRecoveryTargetService.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void messageReceived(RecoveryPrepareForTranslogOperationsRequest request, TransportChannel channel, Task task) throws Exception {
    try (RecoveryRef recoveryRef = onGoingRecoveries.getRecoverySafe(request.recoveryId(), request.shardId())) {
        final ActionListener<TransportResponse> listener =
            new HandledTransportAction.ChannelActionListener<>(channel, Actions.PREPARE_TRANSLOG, request);
        recoveryRef.target().prepareForTranslogOperations(
            request.isFileBasedRecovery(),
            request.totalTranslogOps(),
            ActionListener.wrap(
                nullVal -> listener.onResponse(TransportResponse.Empty.INSTANCE),
                listener::onFailure)
        );
    }
}
 
Example #21
Source File: PeerRecoveryTargetService.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void messageReceived(RecoveryFinalizeRecoveryRequest request, TransportChannel channel, Task task) throws Exception {
    try (RecoveryRef recoveryRef = onGoingRecoveries.getRecoverySafe(request.recoveryId(), request.shardId())) {
        final ActionListener<TransportResponse> listener =
            new HandledTransportAction.ChannelActionListener<>(channel, Actions.FINALIZE, request);
        recoveryRef.target().finalizeRecovery(
            request.globalCheckpoint(),
            ActionListener.wrap(
                nullVal -> listener.onResponse(TransportResponse.Empty.INSTANCE),
                listener::onFailure
            )
        );
    }
}
 
Example #22
Source File: PeerRecoveryTargetService.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void messageReceived(RecoveryWaitForClusterStateRequest request, TransportChannel channel, Task task) throws Exception {
    try (RecoveryRef recoveryRef = onGoingRecoveries.getRecoverySafe(request.recoveryId(), request.shardId()
    )) {
        recoveryRef.target().ensureClusterStateVersion(request.clusterStateVersion());
    }
    channel.sendResponse(TransportResponse.Empty.INSTANCE);
}
 
Example #23
Source File: PeerRecoveryTargetService.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void messageReceived(final RecoveryHandoffPrimaryContextRequest request, final TransportChannel channel, Task task) throws Exception {
    try (RecoveryRef recoveryRef = onGoingRecoveries.getRecoverySafe(request.recoveryId(), request.shardId())) {
        recoveryRef.target().handoffPrimaryContext(request.primaryContext());
    }
    channel.sendResponse(TransportResponse.Empty.INSTANCE);
}
 
Example #24
Source File: ShardStateAction.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void messageReceived(StartedShardEntry request, TransportChannel channel, Task task) throws Exception {
    logger.debug("{} received shard started for [{}]", request.shardId, request);
    clusterService.submitStateUpdateTask(
        "shard-started " + request,
        request,
        ClusterStateTaskConfig.build(Priority.URGENT),
        shardStartedClusterStateTaskExecutor,
        shardStartedClusterStateTaskExecutor);
    channel.sendResponse(TransportResponse.Empty.INSTANCE);
}
 
Example #25
Source File: BlobHeadRequestHandler.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void messageReceived(BlobInfoRequest request, TransportChannel channel, Task task) throws Exception {
    final BlobTransferStatus transferStatus = blobTransferTarget.getActiveTransfer(request.transferId);
    assert transferStatus != null :
        "Received GetBlobHeadRequest for transfer " + request.transferId.toString() +
        " but don't have an activeTransfer with that id";

    BlobTransferInfoResponse response = new BlobTransferInfoResponse(
        transferStatus.index(),
        transferStatus.digestBlob().getDigest()
    );
    channel.sendResponse(response);
}
 
Example #26
Source File: BlobHeadRequestHandler.java    From crate with Apache License 2.0 5 votes vote down vote up
/**
 * called when the target node in a recovery receives a PutBlobHeadChunkRequest
 */
@Override
public void messageReceived(PutBlobHeadChunkRequest request, TransportChannel channel, Task task) throws Exception {
    BlobTransferStatus transferStatus = blobTransferTarget.getActiveTransfer(request.transferId);
    assert transferStatus != null : "transferStatus should not be null";
    transferStatus.digestBlob().addToHead(request.content);
    channel.sendResponse(TransportResponse.Empty.INSTANCE);
}
 
Example #27
Source File: BlobRecoveryTarget.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void messageReceived(BlobStartPrefixSyncRequest request, TransportChannel channel) throws Exception {
    BlobRecoveryStatus status = onGoingRecoveries.get(request.recoveryId());
    if (status == null) {
        throw new IllegalBlobRecoveryStateException(
            "could not retrieve BlobRecoveryStatus"
        );
    }
    if (status.canceled()) {
        throw new IndexShardClosedException(status.shardId());
    }
    BlobStartPrefixResponse response = new BlobStartPrefixResponse();
    response.existingDigests = status.blobShard.currentDigests(request.prefix());
    channel.sendResponse(response);
}
 
Example #28
Source File: BlobRecoveryTarget.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void messageReceived(BlobRecoveryDeleteRequest request, TransportChannel channel) throws Exception {
    BlobRecoveryStatus status = onGoingRecoveries.get(request.recoveryId());
    if (status.canceled()) {
        throw new IndexShardClosedException(status.shardId());
    }
    for (BytesReference digest : request.digests) {
        status.blobShard.delete(Hex.encodeHexString(digest.toBytes()));
    }
    channel.sendResponse(TransportResponse.Empty.INSTANCE);
}
 
Example #29
Source File: BlobRecoveryTarget.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void messageReceived(BlobFinalizeRecoveryRequest request, TransportChannel channel) throws Exception {

    BlobRecoveryStatus status = onGoingRecoveries.get(request.recoveryId);

    for (BlobRecoveryTransferStatus transferStatus : status.onGoingTransfers().values()) {
        if (transferStatus.outputStream().getChannel().isOpen()) {
            throw new IllegalBlobRecoveryStateException(
                "File channel was left open for "
            );
        }
    }
    onGoingRecoveries.remove(request.recoveryId);
    channel.sendResponse(TransportResponse.Empty.INSTANCE);
}
 
Example #30
Source File: BlobHeadRequestHandler.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
/**
 * called when the target node in a recovery receives a PutBlobHeadChunkRequest
 */
@Override
public void messageReceived(PutBlobHeadChunkRequest request, TransportChannel channel) throws Exception {
    BlobTransferStatus transferStatus = blobTransferTarget.getActiveTransfer(request.transferId);
    assert transferStatus != null;
    transferStatus.digestBlob().addToHead(request.content);
    channel.sendResponse(TransportResponse.Empty.INSTANCE);
}