Package net.gleamynode.netty.array

Examples of net.gleamynode.netty.array.ByteArray


    private ChannelFuture wrap(PipeContext<ChannelEvent> context, Channel channel)
            throws SSLException {

        ChannelFuture future = null;
        ByteArray msg;
        ByteBuffer outNetBuf = bufferPool.acquire();
        try {
            loop:
            for (;;) {
                // Acquire a lock to make sure unencrypted data is polled
                // in order and their encrypted counterpart is offered in
                // order.
                synchronized (pendingUnencryptedWrites) {
                    PendingWrite pendingWrite = pendingUnencryptedWrites.peek();
                    if (pendingWrite == null) {
                        break;
                    }

                    ByteBuffer outAppBuf = pendingWrite.outAppBuf;

                    SSLEngineResult result;
                    try {
                        result = engine.wrap(outAppBuf, outNetBuf);
                    } finally {
                        if (!outAppBuf.hasRemaining()) {
                            pendingUnencryptedWrites.remove();
                        }
                    }
                    if (result.bytesProduced() > 0) {
                        outNetBuf.flip();
                        msg = new HeapByteArray(outNetBuf.remaining());
                        msg.set(msg.firstIndex(), outNetBuf.array(), 0, msg.length());
                        outNetBuf.clear();

                        if (pendingWrite.outAppBuf.hasRemaining()) {
                            // pendingWrite's future shouldn't be notified if
                            // only partial data is written.
View Full Code Here


    }

    @Override
    public void get(int index, ByteBuffer dst) {
        if (isReplaying()) {
            ByteArray src = (ByteArray) replay();
            if (src.length() != dst.remaining()) {
                throw new IllegalStateException(
                        "mismatching request: dst.remaining() has been changed since rewind.");
            }
            src.get(0, dst);
        } else if (index < super.firstIndex()) {
            throw new NoSuchElementException();
        } else if (index + dst.remaining() > super.endIndex()) {
            rewind();
        } else {
            ByteArray src = new HeapByteArray(dst.remaining());
            super.get(index, src, 0, dst.remaining());
            src.get(0, dst);
            record(src);
        }
    }
View Full Code Here

            for (;;) {
                result = engine.wrap(EMPTY_BUFFER, outNetBuf);

                if (result.bytesProduced() > 0) {
                    outNetBuf.flip();
                    ByteArray msg = new HeapByteArray(outNetBuf.remaining());
                    msg.set(msg.firstIndex(), outNetBuf.array(), 0, msg.length());
                    outNetBuf.clear();
                    if (channel.isConnected()) {
                        future = new DefaultChannelFuture(channel, false);
                        ChannelDownstream.write(ctx, channel, future, msg);
                    }
View Full Code Here

            }

            outAppBuf.flip();

            if (outAppBuf.hasRemaining()) {
                ByteArray frame = new HeapByteArray(outAppBuf.remaining());
                frame.set(frame.firstIndex(), outAppBuf.array(), 0, frame.length());
                return frame;
            } else {
                return null;
            }
        } catch (SSLException e) {
View Full Code Here

                    fireExceptionCaught(channel, t);
                }
                break;
            }

            ByteArray array;
            if (readBytes == buf.length) {
                array = new HeapByteArray(buf);
            } else {
                array = new StaticPartialByteArray(buf, 0, readBytes);
            }
View Full Code Here

        ObjectOutputStream oout = new CompactObjectOutputStream(bout);
        oout.writeObject(obj);
        oout.flush();
        oout.close();
   
        ByteArray array = bout.array();
        writeInt(array.length());
        array.copyTo(this);
    }
View Full Code Here

        }
        if (dataLen > maxObjectSize) {
            throw new StreamCorruptedException(
                    "data length too big: " + dataLen + " (max: " + maxObjectSize + ')');
        }
        ByteArray data = buffer.read(dataLen);
        return new CompactObjectInputStream(new ByteArrayInputStream(data)).readObject();
    }
View Full Code Here

TOP

Related Classes of net.gleamynode.netty.array.ByteArray

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.