Examples of BytesArray


Examples of org.elasticsearch.common.bytes.BytesArray

        PutChunkReplicaRequest requestOut = new PutChunkReplicaRequest();
        requestOut.index("foo");
        requestOut.transferId = transferId;
        requestOut.currentPos = 10;
        requestOut.isLast = false;
        requestOut.content = new BytesArray(new byte[] { 0x65, 0x66 });
        requestOut.sourceNodeId = "nodeId";

        requestOut.writeTo(outputStream);
        BytesStreamInput inputStream = new BytesStreamInput(outputStream.bytes().copyBytesArray());
View Full Code Here

Examples of org.elasticsearch.common.bytes.BytesArray

    private String uploadFile(Client client, String content) {
        byte[] digest = getDigest(content);
        String digestString = Hex.encodeHexString(digest);
        byte[] contentBytes = content.getBytes();
        logger.trace("Uploading {} digest {}", content, digestString);
        BytesArray bytes = new BytesArray(new byte[]{contentBytes[0]});
        if (content.length() == 1) {
            client.execute(StartBlobAction.INSTANCE,
                    new StartBlobRequest(BlobIndices.fullIndexName("test"), digest, bytes,true))
                    .actionGet();
        } else {
            StartBlobRequest startBlobRequest = new StartBlobRequest(
                    BlobIndices.fullIndexName("test"), digest, bytes, false);
            client.execute(StartBlobAction.INSTANCE, startBlobRequest).actionGet();
            for (int i = 1; i < contentBytes.length; i++) {
                try {
                    Thread.sleep(timeBetweenChunks.get());
                } catch (InterruptedException ex) {
                    Thread.interrupted();
                }
                bytes = new BytesArray(new byte[]{contentBytes[i]});
                client.execute(PutChunkAction.INSTANCE,
                        new PutChunkRequest(
                                BlobIndices.fullIndexName("test"), digest,
                                startBlobRequest.transferId(), bytes, i,
                                (i + 1) == content.length())
View Full Code Here

Examples of org.elasticsearch.common.bytes.BytesArray

        }

        DigestBlob digestBlob = DigestBlob.resumeTransfer(
            container, digest, transferId, currentPos);

        BytesArray contentHead = new BytesArray("A".getBytes());
        digestBlob.addToHead(contentHead);

        BytesArray contentTail = new BytesArray("CDEFGHIJKL".getBytes());
        digestBlob.addContent(contentTail, false);

        contentHead = new BytesArray("B".getBytes());
        digestBlob.addToHead(contentHead);

        contentTail = new BytesArray("MNO".getBytes());
        digestBlob.addContent(contentTail, true);

        byte[] buffer = new byte[15];
        FileInputStream stream = new FileInputStream(digestBlob.file());
        stream.read(buffer, 0, 15);
        assertEquals("ABCDEFGHIJKLMNO", new BytesArray(buffer).toUtf8().trim());
        File file = digestBlob.commit();
        assertTrue(file.exists());
        file.delete();
    }
View Full Code Here

Examples of org.elasticsearch.common.bytes.BytesArray

        UUID transferId = UUID.randomUUID();
        BlobContainer container = new BlobContainer(tmpDir.toFile());
        DigestBlob digestBlob = DigestBlob.resumeTransfer(
            container, "417de3231e23dcd6d224ff60918024bc6c59aa58", transferId, 2);

        BytesArray contentTail = new BytesArray("CDEFGHIJKLMN".getBytes());
        digestBlob.addContent(contentTail, false);

        BytesArray contentHead = new BytesArray("AB".getBytes());
        digestBlob.addToHead(contentHead);

        contentTail = new BytesArray("O".getBytes());
        digestBlob.addContent(contentTail, true);

        byte[] buffer = new byte[15];
        FileInputStream stream = new FileInputStream(digestBlob.file());
        stream.read(buffer, 0, 15);
        assertEquals("ABCDEFGHIJKLMNO", new BytesArray(buffer).toUtf8().trim());
        File file = digestBlob.commit();
        assertTrue(file.exists());
        file.delete();
    }
View Full Code Here

Examples of org.elasticsearch.common.bytes.BytesArray

        public BytesReference generateSource() {
            BytesRef value = input.value();
            if (value == null) {
                return null;
            }
            return new BytesArray(value);
        }
View Full Code Here

Examples of org.elasticsearch.common.bytes.BytesArray

                    if (rest != null) {
                        builder.field(columnIdent.name(), rest);
                    }
                } else {
                    if (value instanceof BytesRef) {
                        value = new BytesText(new BytesArray((BytesRef) value));
                    }
                    builder.field(columnIdent.name(), value);
                }
            } catch (ClassCastException e) {
                // symbol is no input
View Full Code Here

Examples of org.elasticsearch.common.bytes.BytesArray

                }
            ).txGet();

        Set<BytesArray> result = new HashSet<BytesArray>();
        for (byte[] digests : response.existingDigests) {
            result.add(new BytesArray(digests));
        }
        return result;
    }
View Full Code Here

Examples of org.elasticsearch.common.bytes.BytesArray

            // byte[1] and byte[1] have different hashCodes
            // so setA.removeAll(setB) wouldn't work with byte[], that's why BytesArray is used here
            Set<BytesArray> remoteDigests = getExistingDigestsFromTarget(prefix);
            Set<BytesArray> localDigests = new HashSet<BytesArray>();
            for (byte[] digest : blobShard.currentDigests(prefix)) {
                localDigests.add(new BytesArray(digest));
            }

            Set<BytesArray> localButNotRemoteDigests = new HashSet<BytesArray>(localDigests);
            localButNotRemoteDigests.removeAll(remoteDigests);
View Full Code Here

Examples of org.elasticsearch.common.bytes.BytesArray

                    String filePath = file.getAbsolutePath();
                    String relPath = filePath.substring(baseDir.length(), filePath.length());
                    byte[] buf = new byte[BUFFER_SIZE];
                    int bytesRead = fileStream.read(buf, 0, BUFFER_SIZE);
                    long bytesReadTotal = 0;
                    BytesArray content = new BytesArray(buf, 0, bytesRead);
                    BlobRecoveryStartTransferRequest startTransferRequest =
                        new BlobRecoveryStartTransferRequest(request.recoveryId(), relPath, content,
                            fileSize
                        );

                    if (bytesRead > 0) {
                        bytesReadTotal += bytesRead;

                        logger.trace("[{}][{}] send BlobRecoveryStartTransferRequest to {} for file {} with size {}",
                            request.shardId().index().name(), request.shardId().id(),
                            request.targetNode().getName(),
                            relPath,
                            fileSize
                        );
                        transportService.submitRequest(
                            request.targetNode(),
                            BlobRecoveryTarget.Actions.START_TRANSFER,
                            startTransferRequest,
                            TransportRequestOptions.options(),
                            EmptyTransportResponseHandler.INSTANCE_SAME
                        ).txGet();

                        boolean isLast = false;
                        boolean sentChunks = false;
                        while ((bytesRead = fileStream.read(buf, 0, BUFFER_SIZE)) > 0) {

                            sentChunks = true;
                            bytesReadTotal += bytesRead;

                            if (shard.state() == IndexShardState.CLOSED) { // check if the shard got closed on us
                                throw new IndexShardClosedException(shard.shardId());
                            }
                            if (bytesReadTotal == fileSize) {
                                isLast = true;
                            }
                            content = new BytesArray(buf, 0, bytesRead);

                            transportService.submitRequest(request.targetNode(),
                                BlobRecoveryTarget.Actions.TRANSFER_CHUNK,
                                new BlobRecoveryChunkRequest(request.recoveryId(),
                                    startTransferRequest.transferId(), content, isLast),
View Full Code Here

Examples of org.elasticsearch.common.bytes.BytesArray

        logger.trace("start blob upload");
        assert (transferId == null);
        StartBlobRequest request = new StartBlobRequest(
                index,
                Hex.decodeHex(digest),
                new BytesArray(buffer.array()),
                last
        );
        size += buffer.readableBytes();
        startResponse = client.execute(StartBlobAction.INSTANCE, request).actionGet();
        transferId = request.transferId();
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.