Search in sources :

Example 1 with GetBlobHeadRequest

use of io.crate.blob.transfer.GetBlobHeadRequest in project crate by crate.

the class BlobTransferTarget method restoreTransferStatus.

private BlobTransferStatus restoreTransferStatus(PutChunkReplicaRequest request) {
    LOGGER.trace("Restoring transferContext for PutChunkReplicaRequest with transferId {}", request.transferId);
    DiscoveryNodes nodes = clusterService.state().getNodes();
    DiscoveryNode recipientNodeId = nodes.get(request.sourceNodeId);
    String senderNodeId = nodes.getLocalNodeId();
    var listener = new PlainActionFuture<BlobTransferInfoResponse>();
    transportService.sendRequest(recipientNodeId, BlobHeadRequestHandler.Actions.GET_TRANSFER_INFO, new BlobInfoRequest(senderNodeId, request.transferId), TransportRequestOptions.EMPTY, new ActionListenerResponseHandler<>(listener, BlobTransferInfoResponse::new));
    BlobTransferInfoResponse transferInfoResponse = listener.actionGet();
    BlobShard blobShard = blobIndicesService.blobShardSafe(request.shardId());
    DigestBlob digestBlob = DigestBlob.resumeTransfer(blobShard.blobContainer(), transferInfoResponse.digest, request.transferId, request.currentPos);
    assert digestBlob != null : "DigestBlob couldn't be restored";
    BlobTransferStatus status;
    status = new BlobTransferStatus(request.shardId(), request.transferId, digestBlob);
    activeTransfers.put(request.transferId, status);
    LOGGER.trace("Restored transferStatus for digest {} transferId: {}", transferInfoResponse.digest, request.transferId);
    var getBlobHeadListener = new PlainActionFuture<>();
    transportService.sendRequest(recipientNodeId, BlobHeadRequestHandler.Actions.GET_BLOB_HEAD, new GetBlobHeadRequest(senderNodeId, request.transferId(), request.currentPos), TransportRequestOptions.EMPTY, new ActionListenerResponseHandler<>(getBlobHeadListener, in -> TransportResponse.Empty.INSTANCE));
    getBlobHeadListener.actionGet();
    return status;
}
Also used : GetBlobHeadRequest(io.crate.blob.transfer.GetBlobHeadRequest) ConcurrentCollections(org.elasticsearch.common.util.concurrent.ConcurrentCollections) BlobShard(io.crate.blob.v2.BlobShard) ClusterService(org.elasticsearch.cluster.service.ClusterService) CompletableFuture(java.util.concurrent.CompletableFuture) ArrayList(java.util.ArrayList) ConcurrentMap(java.util.concurrent.ConcurrentMap) Inject(org.elasticsearch.common.inject.Inject) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) ActionListenerResponseHandler(org.elasticsearch.action.ActionListenerResponseHandler) ThreadPool(org.elasticsearch.threadpool.ThreadPool) TransportResponse(org.elasticsearch.transport.TransportResponse) TransportService(org.elasticsearch.transport.TransportService) DigestMismatchException(io.crate.blob.exceptions.DigestMismatchException) BlobHeadRequestHandler(io.crate.blob.transfer.BlobHeadRequestHandler) DiscoveryNodes(org.elasticsearch.cluster.node.DiscoveryNodes) PlainActionFuture(org.elasticsearch.action.support.PlainActionFuture) IOUtils(org.apache.lucene.util.IOUtils) UUID(java.util.UUID) BlobAlreadyExistsException(io.crate.blob.exceptions.BlobAlreadyExistsException) BlobInfoRequest(io.crate.blob.transfer.BlobInfoRequest) BlobIndicesService(io.crate.blob.v2.BlobIndicesService) File(java.io.File) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) Logger(org.apache.logging.log4j.Logger) TimeValue(io.crate.common.unit.TimeValue) TransportRequestOptions(org.elasticsearch.transport.TransportRequestOptions) BlobTransferInfoResponse(io.crate.blob.transfer.BlobTransferInfoResponse) LogManager(org.apache.logging.log4j.LogManager) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) GetBlobHeadRequest(io.crate.blob.transfer.GetBlobHeadRequest) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) BlobTransferInfoResponse(io.crate.blob.transfer.BlobTransferInfoResponse) BlobInfoRequest(io.crate.blob.transfer.BlobInfoRequest) PlainActionFuture(org.elasticsearch.action.support.PlainActionFuture) BlobShard(io.crate.blob.v2.BlobShard) DiscoveryNodes(org.elasticsearch.cluster.node.DiscoveryNodes)

Aggregations

BlobAlreadyExistsException (io.crate.blob.exceptions.BlobAlreadyExistsException)1 DigestMismatchException (io.crate.blob.exceptions.DigestMismatchException)1 BlobHeadRequestHandler (io.crate.blob.transfer.BlobHeadRequestHandler)1 BlobInfoRequest (io.crate.blob.transfer.BlobInfoRequest)1 BlobTransferInfoResponse (io.crate.blob.transfer.BlobTransferInfoResponse)1 GetBlobHeadRequest (io.crate.blob.transfer.GetBlobHeadRequest)1 BlobIndicesService (io.crate.blob.v2.BlobIndicesService)1 BlobShard (io.crate.blob.v2.BlobShard)1 TimeValue (io.crate.common.unit.TimeValue)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 UUID (java.util.UUID)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeUnit (java.util.concurrent.TimeUnit)1 LogManager (org.apache.logging.log4j.LogManager)1