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;
}
Aggregations