use of io.crate.blob.pending_transfer.BlobTransferInfoResponse 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();
BlobTransferInfoResponse transferInfoResponse = (BlobTransferInfoResponse) transportService.submitRequest(recipientNodeId, BlobHeadRequestHandler.Actions.GET_TRANSFER_INFO, new BlobInfoRequest(senderNodeId, request.transferId), TransportRequestOptions.EMPTY, new FutureTransportResponseHandler<TransportResponse>() {
@Override
public TransportResponse newInstance() {
return new BlobTransferInfoResponse();
}
}).txGet();
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(transferInfoResponse.index, request.transferId, digestBlob);
activeTransfers.put(request.transferId, status);
logger.trace("Restored transferStatus for digest {} transferId: {}", transferInfoResponse.digest, request.transferId);
transportService.submitRequest(recipientNodeId, BlobHeadRequestHandler.Actions.GET_BLOB_HEAD, new GetBlobHeadRequest(senderNodeId, request.transferId(), request.currentPos), TransportRequestOptions.EMPTY, EmptyTransportResponseHandler.INSTANCE_SAME).txGet();
return status;
}
Aggregations