Package org.xbib.elasticsearch.common.io.stream

Examples of org.xbib.elasticsearch.common.io.stream.BytesStreamOutput


        }

        byte status = 0;
        status = TransportStatus.setRequest(status);

        BytesStreamOutput bStream = new BytesStreamOutput();
        bStream.skip(NettyHeader.HEADER_SIZE);
        StreamOutput stream = bStream;
        stream = new HandlesStreamOutput(stream);

        // we pick the smallest of the 2, to support both backward and forward compatibility
        // note, this is the only place we need to do this, since from here on, we use the serialized version
        // as the version to use also when the node receiving this request will send the response with
        Version version = Version.smallest(this.version, node.version());

        stream.setVersion(version);
        stream.writeString(action);

        ChannelBuffer buffer;
        request.writeTo(stream);
        stream.close();
        buffer = bStream.ourBytes().toChannelBuffer();
        NettyHeader.writeHeader(buffer, requestId, status, version);
        targetChannel.write(buffer);
    }
View Full Code Here


        }
    }

    @Override
    public void sendResponse(Throwable error) throws IOException {
        BytesStreamOutput stream = new BytesStreamOutput();
        try {
            stream.skip(NettyHeader.HEADER_SIZE);
            RemoteTransportException tx = new RemoteTransportException(transport.nodeName(), transport.wrapAddress(channel.getLocalAddress()), action, error);
            ThrowableObjectOutputStream too = new ThrowableObjectOutputStream(stream);
            too.writeObject(tx);
            too.close();
        } catch (NotSerializableException e) {
            stream.reset();
            stream.skip(org.elasticsearch.transport.netty.NettyHeader.HEADER_SIZE);
            RemoteTransportException tx = new RemoteTransportException(transport.nodeName(), transport.wrapAddress(channel.getLocalAddress()), action, new NotSerializableTransportException(error));
            ThrowableObjectOutputStream too = new ThrowableObjectOutputStream(stream);
            too.writeObject(tx);
            too.close();
        }

        byte status = 0;
        status = TransportStatus.setResponse(status);
        status = TransportStatus.setError(status);

        ChannelBuffer buffer = stream.ourBytes().toChannelBuffer();
        NettyHeader.writeHeader(buffer, requestId, status, version);
        channel.write(buffer);
    }
View Full Code Here

TOP

Related Classes of org.xbib.elasticsearch.common.io.stream.BytesStreamOutput

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.