Package org.jboss.netty.buffer

Examples of org.jboss.netty.buffer.ChannelBuffer.writeBytes()


    public void sendResponse(StoreStats performanceStats,
                             boolean isFromLocalZone,
                             long startTimeInMs) throws Exception {

        ChannelBuffer responseContent = ChannelBuffers.dynamicBuffer(this.responseValue.length);
        responseContent.writeBytes(responseValue);

        // 1. Create the Response object
        HttpResponse response = new DefaultHttpResponse(HTTP_1_1, OK);

        // 2. Set the right headers
View Full Code Here


            logger.error("Exception while writing mutipart to output stream", e);
            throw e;
        }

        ChannelBuffer responseContent = ChannelBuffers.dynamicBuffer();
        responseContent.writeBytes(keysOutputStream.toByteArray());

        // Create the Response object
        HttpResponse response = new DefaultHttpResponse(HTTP_1_1, OK);

        // Set the right headers
View Full Code Here

            logger.error("Exception while writing multipart to output stream", e);
            outputStream.close();
            throw e;
        }
        ChannelBuffer responseContent = ChannelBuffers.dynamicBuffer();
        responseContent.writeBytes(outputStream.toByteArray());

        // Create the Response object
        HttpResponse response = new DefaultHttpResponse(HTTP_1_1, OK);

        // Set the right headers
View Full Code Here

        }

        String eTags = RestUtils.getSerializedVectorClocks(vectorClocks);
        byte[] responseContent = eTags.getBytes();
        ChannelBuffer responseContentBuffer = ChannelBuffers.dynamicBuffer(responseContent.length);
        responseContentBuffer.writeBytes(responseContent);

        // Create the Response object
        HttpResponse response = new DefaultHttpResponse(HTTP_1_1, OK);

        // Set the right headers
View Full Code Here

        return false;
    }

    private void sendMessage(int partitionId, byte[] message) {
        ChannelBuffer buffer = ChannelBuffers.buffer(message.length);
        buffer.writeBytes(message);

        if (!partitionChannelMap.containsKey(partitionId)) {
            if (!connectTo(partitionId)) {
                // Couldn't connect, discard message
                return;
View Full Code Here

        }
        HttpMessage request = (HttpMessage) e.getMessage();
        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
        encodeInitialLine(buf, request);
        encodeHeaders(buf, request);
        buf.writeBytes(CRLF);
        if (request.getContent() != null) {
            buf.writeBytes(request.getContent());
        }
        write(ctx, e.getChannel(), e.getFuture(), buf, e.getRemoteAddress());
    }
View Full Code Here

        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
        encodeInitialLine(buf, request);
        encodeHeaders(buf, request);
        buf.writeBytes(CRLF);
        if (request.getContent() != null) {
            buf.writeBytes(request.getContent());
        }
        write(ctx, e.getChannel(), e.getFuture(), buf, e.getRemoteAddress());
    }

    /**
 
View Full Code Here

        int ret = 0;
        int readBytes = 0;
        boolean failure = true;
        try {
            while ((ret = buf.writeBytes(ch, buf.writableBytes())) > 0) {
                readBytes += ret;
                if (!buf.writable()) {
                    break;
                }
            }
View Full Code Here

        int ret = 0;
        int readBytes = 0;
        boolean failure = true;
        try {
            while ((ret = preallocatedDirectBuffer.writeBytes(ch, preallocatedDirectBuffer.writableBytes())) > 0) {
                readBytes += ret;
                if (!preallocatedDirectBuffer.writable()) {
                    break;
                }
            }
View Full Code Here

                        }
                    }
                    if (result.bytesProduced() > 0) {
                        outNetBuf.flip();
                        msg = ChannelBuffers.buffer(outNetBuf.remaining());
                        msg.writeBytes(outNetBuf.array(), 0, msg.capacity());
                        outNetBuf.clear();

                        if (pendingWrite.outAppBuf.hasRemaining()) {
                            // pendingWrite's future shouldn't be notified if
                            // only partial data is written.
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.