Package org.elasticsearch.common.io.stream

Examples of org.elasticsearch.common.io.stream.HandlesStreamInput


        out.writeInt(1);
        out.writeUTF("else");
        out.writeUTF(higherThresholdValue);
        out.writeUTF(lowerThresholdValue);

        HandlesStreamInput in = new HandlesStreamInput(new BytesStreamInput(bytesOut.copiedByteArray()));
        assertThat(in.readUTF(), equalTo(lowerThresholdValue));
        assertThat(in.readUTF(), equalTo(higherThresholdValue));
        assertThat(in.readInt(), equalTo(1));
        assertThat(in.readUTF(), equalTo("else"));
        assertThat(in.readUTF(), equalTo(higherThresholdValue));
        assertThat(in.readUTF(), equalTo(lowerThresholdValue));
    }
View Full Code Here


        long requestId = buffer.readLong();
        byte status = buffer.readByte();
        boolean isRequest = TransportStreams.statusIsRequest(status);

        HandlesStreamInput handlesStream;
        if (TransportStreams.statusIsCompress(status)) {
            handlesStream = CachedStreamInput.cachedHandlesLzf(streamIn);
        } else {
            handlesStream = CachedStreamInput.cachedHandles(streamIn);
        }

        if (isRequest) {
            String action = handleRequest(event, handlesStream, requestId);
            if (buffer.readerIndex() != expectedIndexReader) {
                if (buffer.readerIndex() < expectedIndexReader) {
                    logger.warn("Message not fully read (request) for [{}] and action [{}], resetting", requestId, action);
                } else {
                    logger.warn("Message read past expected size (request) for [{}] and action [{}], resetting", requestId, action);
                }
                buffer.readerIndex(expectedIndexReader);
            }
        } else {
            TransportResponseHandler handler = transportServiceAdapter.remove(requestId);
            // ignore if its null, the adapter logs it
            if (handler != null) {
                if (TransportStreams.statusIsError(status)) {
                    handlerResponseError(handlesStream, handler);
                } else {
                    handleResponse(handlesStream, handler);
                }
            } else {
                // if its null, skip those bytes
                buffer.readerIndex(markedReaderIndex + size);
            }
            if (buffer.readerIndex() != expectedIndexReader) {
                if (buffer.readerIndex() < expectedIndexReader) {
                    logger.warn("Message not fully read (response) for [{}] handler {}, error [{}], resetting", requestId, handler, TransportStreams.statusIsError(status));
                } else {
                    logger.warn("Message read past expected size (response) for [{}] handler {}, error [{}], resetting", requestId, handler, TransportStreams.statusIsError(status));
                }
                buffer.readerIndex(expectedIndexReader);
            }
        }
        handlesStream.cleanHandles();
    }
View Full Code Here

    private void addFromBytesReference(BytesReference bytesReference, DownstreamOperationContext ctx) {
        // bytesReference must be wrapped into HandlesStreamInput because it has a different readString()
        // implementation than BytesStreamInput alone.
        // and the memoryOutputStream originates from a HandlesStreamOutput.
        HandlesStreamInput wrappedStream = new HandlesStreamInput(new BytesStreamInput(bytesReference));
        Object[][] rows = null;
        try {
            rows = DistributedResultRequest.readRemaining(ctx.streamers(), wrappedStream);
        } catch (IOException e) {
            ctx.addFailure(e);
View Full Code Here

        out.writeSharedString(test4);
        out.writeSharedString(test5);
        out.writeSharedString(test6);

        BytesStreamInput bin = new BytesStreamInput(bout.bytes());
        HandlesStreamInput in = new HandlesStreamInput(bin);
        String s1 = in.readString();
        String s2 = in.readString();
        String s3 = in.readString();
        String s4 = in.readString();
        String s5 = in.readSharedString();
        String s6 = in.readSharedString();
        String s7 = in.readSharedString();
        String s8 = in.readSharedString();

        assertThat(s1, equalTo(test1));
        assertThat(s2, equalTo(test1));
        assertThat(s3, equalTo(test2));
        assertThat(s4, equalTo(test3));
View Full Code Here

TOP

Related Classes of org.elasticsearch.common.io.stream.HandlesStreamInput

Copyright © 2018 www.massapicom. 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.