Examples of BlobShard


Examples of io.crate.blob.v2.BlobShard

    private CollectingProjector getProjector(BlobContainer container,
                                             List<Input<?>> inputs,
                                             List<BlobCollectorExpression<?>> expressions,
                                             Input<Boolean> condition) throws Exception {
        CollectingProjector projector = new CollectingProjector();
        BlobShard blobShard = mock(BlobShard.class);
        when(blobShard.blobContainer()).thenReturn(container);

        BlobDocCollector collector = new BlobDocCollector(
                blobShard,
                inputs,
                expressions,
View Full Code Here

Examples of io.crate.blob.v2.BlobShard

        logger.trace("--> expected {} got {}", indexCounter.get(), uploadedDigests.size());
        assertEquals(indexCounter.get(), uploadedDigests.size());

        blobIndices = cluster().getInstance(BlobIndices.class, node2);
        for (String digest : uploadedDigests) {
            BlobShard blobShard = blobIndices.localBlobShard(BlobIndices.fullIndexName("test"), digest);
            long length = blobShard.blobContainer().getFile(digest).length();
            assertThat(length, greaterThanOrEqualTo(1L));
        }

    }
View Full Code Here

Examples of io.crate.blob.v2.BlobShard

    }

    public void startTransfer(int shardId, StartBlobRequest request, StartBlobResponse response) {
        logger.debug("startTransfer {} {}", request.transferId(), request.isLast());

        BlobShard blobShard = blobIndices.blobShardSafe(request.index(), shardId);
        File existing = blobShard.blobContainer().getFile(request.id());
        long size = existing.length();
        if (existing.exists()) {
            // the file exists
            response.status(RemoteDigestBlob.Status.EXISTS);
            response.size(size);
            return;
        }

        DigestBlob digestBlob = blobShard.blobContainer().createBlob(request.id(), request.transferId());
        digestBlob.addContent(request.content(), request.isLast());

        response.size(digestBlob.size());
        if (request.isLast()) {
            try {
View Full Code Here

Examples of io.crate.blob.v2.BlobShard

                        return new BlobTransferInfoResponse();
                    }
                }
            ).txGet();

        BlobShard blobShard;
        try {
            blobShard = blobIndices.blobShardFuture(transferInfoResponse.index, shardId).get();
        } catch (InterruptedException | ExecutionException e) {
            throw new TransferRestoreException("failure loading blobShard", request.transferId, e);
        }

        DigestBlob digestBlob = DigestBlob.resumeTransfer(
            blobShard.blobContainer(), transferInfoResponse.digest, request.transferId, request.currentPos
        );

        assert digestBlob != null : "DigestBlob couldn't be restored";

        BlobTransferStatus status;
View Full Code Here

Examples of io.crate.blob.v2.BlobShard

    @Override
    protected PrimaryResponse<DeleteBlobResponse, DeleteBlobRequest> shardOperationOnPrimary(ClusterState clusterState,
            PrimaryOperationRequest shardRequest) {
        logger.trace("shardOperationOnPrimary {}", shardRequest);
        final DeleteBlobRequest request = shardRequest.request;
        BlobShard blobShard = blobIndices.blobShardSafe(shardRequest.request.index(), shardRequest.shardId);
        boolean deleted = blobShard.delete(request.id());
        final DeleteBlobResponse response = new DeleteBlobResponse(deleted);
        return new PrimaryResponse<>(request, response, null);
    }
View Full Code Here

Examples of io.crate.blob.v2.BlobShard

    }

    @Override
    protected void shardOperationOnReplica(ReplicaOperationRequest shardRequest) {
        logger.warn("shardOperationOnReplica operating on replica but relocation is not implemented {}", shardRequest);
        BlobShard blobShard = blobIndices.blobShardSafe(shardRequest.request.index(), shardRequest.shardId);
        blobShard.delete(shardRequest.request.id());
    }
View Full Code Here

Examples of io.crate.blob.v2.BlobShard

            if (onGoingIndexRecovery.isCanceled()) {
                throw new IndexShardClosedException(request.shardId());
            }

            BlobShard blobShard = indicesService.indexServiceSafe(
                    onGoingIndexRecovery.shardId.getIndex()).shardInjectorSafe(
                    onGoingIndexRecovery.shardId.id()).getInstance(BlobShard.class);

            BlobRecoveryStatus status = new BlobRecoveryStatus(onGoingIndexRecovery, blobShard);
            onGoingRecoveries.put(request.recoveryId(), status);
View Full Code Here

Examples of io.crate.blob.v2.BlobShard

                 // 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());
            }

            BytesReference content = request.content();
            if (!content.hasArray()) {
                content = content.toBytesArray();
            }
            transferStatus.outputStream().write(
                content.array(), content.arrayOffset(), content.length()
            );

            if (request.isLast()) {
                transferStatus.outputStream().close();
                File source = new File(shard.blobContainer().getBaseDirectory(),
                    transferStatus.sourcePath()
                );
                File target = new File(shard.blobContainer().getBaseDirectory(),
                    transferStatus.targetPath()
                );

                if (target.exists()) {
                    logger.info("target file {} exists already.", target.getName());
View Full Code Here

Examples of io.crate.blob.v2.BlobShard

            }
            if (status.canceled()) {
                throw new IndexShardClosedException(status.shardId());
            }

            BlobShard shard = status.blobShard;
            String tmpPath = request.path() + "." + request.transferId();
            FileOutputStream outputStream = new FileOutputStream(
                new File(shard.blobContainer().getBaseDirectory(), tmpPath)
            );

            BytesReference content = request.content();
            if (!content.hasArray()) {
                content = content.toBytesArray();
            }
            outputStream.write(content.array(), content.arrayOffset(), content.length());

            if (request.size() == request.content().length()) {  // start request contains the whole file.
                outputStream.close();
                File source = new File(shard.blobContainer().getBaseDirectory(), tmpPath);
                File target = new File(shard.blobContainer().getBaseDirectory(), request.path());
                if (!target.exists()) {
                    if (!source.renameTo(target)) {
                        throw new IllegalBlobRecoveryStateException(
                            "couldn't rename file to " + request.path()
                        );
View Full Code Here

Examples of io.crate.blob.v2.BlobShard

public class BlobShardFuture extends BaseFuture<BlobShard> {

    public BlobShardFuture(final BlobIndices blobIndices, final IndicesLifecycle indicesLifecycle,
                           final String index, final int shardId)
    {
        BlobShard blobShard = blobIndices.blobShard(index, shardId);
        if (blobShard != null) {
            set(blobShard);
            return;
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.