Search in sources :

Example 1 with BlobInfoRequest

use of io.crate.blob.pending_transfer.BlobInfoRequest 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;
}
Also used : GetBlobHeadRequest(io.crate.blob.pending_transfer.GetBlobHeadRequest) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) BlobTransferInfoResponse(io.crate.blob.pending_transfer.BlobTransferInfoResponse) BlobInfoRequest(io.crate.blob.pending_transfer.BlobInfoRequest) BlobShard(io.crate.blob.v2.BlobShard) DiscoveryNodes(org.elasticsearch.cluster.node.DiscoveryNodes)

Aggregations

BlobInfoRequest (io.crate.blob.pending_transfer.BlobInfoRequest)1 BlobTransferInfoResponse (io.crate.blob.pending_transfer.BlobTransferInfoResponse)1 GetBlobHeadRequest (io.crate.blob.pending_transfer.GetBlobHeadRequest)1 BlobShard (io.crate.blob.v2.BlobShard)1 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)1 DiscoveryNodes (org.elasticsearch.cluster.node.DiscoveryNodes)1