Package org.eclipse.jetty.spdy.api

Examples of org.eclipse.jetty.spdy.api.ByteBufferDataInfo


    public void onData(Stream clientStream, final DataInfo clientDataInfo)
    {
        if (LOG.isDebugEnabled())
            LOG.debug("C -> P {} on {}", clientDataInfo, clientStream);

        ByteBufferDataInfo serverDataInfo = new ByteBufferDataInfo(clientDataInfo.asByteBuffer(false), clientDataInfo.isClose())
        {
            @Override
            public void consume(int delta)
            {
                super.consume(delta);
View Full Code Here


        public void onData(Stream serverStream, final DataInfo serverDataInfo)
        {
            if (LOG.isDebugEnabled())
                LOG.debug("S -> P pushed {} on {}", serverDataInfo, serverStream);

            ByteBufferDataInfo clientDataInfo = new ByteBufferDataInfo(serverDataInfo.asByteBuffer(false), serverDataInfo.isClose())
            {
                @Override
                public void consume(int delta)
                {
                    super.consume(delta);
View Full Code Here

            data(stream, dataInfo);
        }

        private void data(final Stream stream, final DataInfo serverDataInfo)
        {
            final ByteBufferDataInfo clientDataInfo = new ByteBufferDataInfo(serverDataInfo.asByteBuffer(false), serverDataInfo.isClose())
            {
                @Override
                public void consume(int delta)
                {
                    super.consume(delta);
View Full Code Here

        return stream;
    }

    private DataInfo toDataInfo(ByteBuffer buffer, boolean close)
    {
        return new ByteBufferDataInfo(buffer, close);
    }
View Full Code Here

                if (LOG.isDebugEnabled())
                    LOG.debug("onContent called with response: {} and content: {}. Sending response content to client.",
                        response, content);
                final ByteBuffer contentCopy = httpClient.getByteBufferPool().acquire(content.remaining(), true);
                BufferUtil.flipPutFlip(content, contentCopy);
                ByteBufferDataInfo dataInfo = new ByteBufferDataInfo(contentCopy, false);
                clientStream.data(dataInfo, new Callback()
                {
                    @Override
                    public void failed(Throwable x)
                    {
                        LOG.debug("failed: ", x);
                        releaseBuffer();
                        response.abort(x);
                    }

                    @Override
                    public void succeeded()
                    {
                        releaseBuffer();
                    }

                    private void releaseBuffer()
                    {
                        httpClient.getByteBufferPool().release(contentCopy);
                    }
                });
            }

            @Override
            public void onSuccess(Response response)
            {
                if (LOG.isDebugEnabled())
                    LOG.debug("onSuccess called. Closing client stream.");
                clientStream.data(new ByteBufferDataInfo(BufferUtil.EMPTY_BUFFER, true), LOGGING_CALLBACK);
            }

            @Override
            public void onFailure(Response response, Throwable failure)
            {
View Full Code Here

        {
            // send the data and let it call the callback
            if (LOG.isDebugEnabled())
                LOG.debug("Send content: {} on stream: {} lastContent={}", BufferUtil.toDetailString(content), stream,
                    lastContent);
            stream.data(new ByteBufferDataInfo(endPoint.getIdleTimeout(), TimeUnit.MILLISECONDS, content, lastContent
            ), callback);
        }
        // else do we need to close
        else if (lastContent && info == null)
        {
            // send empty data to close and let the send call the callback
            if (LOG.isDebugEnabled())
                LOG.debug("No content and lastContent=true. Sending empty ByteBuffer to close stream: {}", stream);
            stream.data(new ByteBufferDataInfo(endPoint.getIdleTimeout(), TimeUnit.MILLISECONDS,
                    BufferUtil.EMPTY_BUFFER, lastContent), callback);
        }
        else if (!lastContent && !hasContent && info == null)
            throw new IllegalStateException("not lastContent, no content and no responseInfo!");
    }
View Full Code Here

            listener.onIdle(idle);
    }

    private void processData(final IStream stream, DataFrame frame, ByteBuffer data)
    {
        ByteBufferDataInfo dataInfo = new ByteBufferDataInfo(data, frame.isClose())
        {
            @Override
            public void consume(int delta)
            {
                super.consume(delta);
View Full Code Here

    }

    private void testSendBigFile(short version) throws Exception
    {
        final int dataSize = 1024 * 1024;
        final ByteBufferDataInfo bigByteBufferDataInfo = new ByteBufferDataInfo(ByteBuffer.allocate(dataSize),false);
        final CountDownLatch allDataReceivedLatch = new CountDownLatch(1);

        Session session = startClient(version, startServer(version, new ServerSessionFrameListener.Adapter()
        {
            @Override
View Full Code Here

                {
                    @Override
                    public void onData(Stream stream, DataInfo dataInfo)
                    {
                        ByteBuffer buffer = dataInfo.asByteBuffer(true);
                        stream.data(new ByteBufferDataInfo(buffer, dataInfo.isClose()), new Callback.Adapter());
                    }
                };
            }
        };
View Full Code Here

            failed = true;
        }

        assertThat("Opening second stream failed", failed, is(true));

        stream.data(new ByteBufferDataInfo(BufferUtil.EMPTY_BUFFER, true));
        assertThat("Data has been received on first stream.", dataReceivedLatch.await(5, TimeUnit.SECONDS), is(true));
    }
View Full Code Here

TOP

Related Classes of org.eclipse.jetty.spdy.api.ByteBufferDataInfo

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.