Package org.apache.mina.common

Examples of org.apache.mina.common.WriteFuture


            this.writeRequest = writeRequest;
        }

        protected WriteFuture doFlush( ByteBuffer buf )
        {
            WriteFuture future = new DefaultWriteFuture( session );
            nextFilter.filterWrite(
                    session,
                    new WriteRequest(
                            new HiddenByteBuffer( buf ),
                            future, writeRequest.getDestination() ) );
View Full Code Here


   
    public void filterClose( final NextFilter nextFilter, final IoSession session ) throws SSLException
    {
        SSLHandler handler = getSSLSessionHandler( session );

        WriteFuture future = null;
        synchronized( handler )
        {
            try
            {
                if( isSSLStarted( session ) )
                {
                    future = initiateClosure( nextFilter, session );
                }
            }
            finally
            {
                if( future == null )
                {
                    nextFilter.filterClose( session );
                }
                else
                {
                    future.addListener( new IoFutureListener()
                    {
                        public void operationComplete( IoFuture future )
                        {
                            nextFilter.filterClose( session );
                        }
View Full Code Here

        {
            return DefaultWriteFuture.newNotWrittenFuture( session );
        }
       
        // there might be data to write out here?
        WriteFuture future = handler.writeNetBuffer( nextFilter );
       
        if( handler.isInboundDone() )
        {
            handler.destroy();
        }
View Full Code Here

        try
        {
            ConnectFuture future = connector.connect( new InetSocketAddress( "localhost", port ), new IoHandlerAdapter() );
            future.join();
           
            WriteFuture writeFuture = future.getSession().write( ByteBuffer.allocate( 16 ).putInt( 0 ).flip() );
            writeFuture.join();
            Assert.assertTrue( writeFuture.isWritten() );
           
            future.getSession().close();
   
            for( int i = 0; i < 30; i ++ )
            {
View Full Code Here

        writeFrame(frame, false);
    }

    public void writeFrame(AMQDataBlock frame, boolean wait)
    {
        WriteFuture f = _minaProtocolSession.write(frame);
        if (wait)
        {
            // fixme -- time out?
            f.join();
        }
        else
        {
            _lastWriteFuture = f;
        }
View Full Code Here

     * @throws CamelExchangeException is thrown if the body could not be written for some reasons
     *                                (eg remote connection is closed etc.)
     */
    public static void writeBody(IoSession session, Object body, Exchange exchange) throws CamelExchangeException {
        // the write operation is asynchronous. Use WriteFuture to wait until the session has been written
        WriteFuture future = session.write(body);
        // must use a timeout (we use 10s) as in some very high performance scenarios a write can cause
        // thread hanging forever
        future.join(10 * 1000L);
        if (!future.isWritten()) {
            LOG.warn("Cannot write body: " + body + " using session: " + session);
            throw new CamelExchangeException("Cannot write body", exchange);
        }
    }
View Full Code Here

            this.writeRequest = writeRequest;
        }

        @Override
        protected WriteFuture doFlush(ByteBuffer buf) {
            WriteFuture future = new DefaultWriteFuture(session);
            nextFilter.filterWrite(session, new WriteRequest(
                    new HiddenByteBuffer(buf), future, writeRequest
                            .getDestination()));
            return future;
        }
View Full Code Here

    public WriteFuture write(Object message, SocketAddress remoteAddress) {
        if (isClosing() ) {
            return DefaultWriteFuture.newNotWrittenFuture(this);
        }

        WriteFuture future = new DefaultWriteFuture(this);
        write0(new WriteRequest(message, future, remoteAddress));

        return future;
    }
View Full Code Here

     * @throws CamelExchangeException is thrown if the body could not be written for some reasons
     *                                (eg remote connection is closed etc.)
     */
    public static void writeBody(IoSession session, Object body, Exchange exchange) throws CamelExchangeException {
        // the write operation is asynchronous. Use WriteFuture to wait until the session has been written
        WriteFuture future = session.write(body);
        // must use a timeout (we use 10s) as in some very high performance scenarios a write can cause
        // thread hanging forever
        LOG.trace("Waiting for write to complete");
        future.join(10 * 1000L);
        if (!future.isWritten()) {
            LOG.warn("Cannot write body: " + body + " using session: " + session);
            throw new CamelExchangeException("Cannot write body", exchange);
        }
    }
View Full Code Here

    private void testConnector0( IoSession session ) throws InterruptedException
    {
        EchoConnectorHandler handler = ( EchoConnectorHandler ) session.getHandler();
        ByteBuffer readBuf = handler.readBuf;
        readBuf.clear();
        WriteFuture writeFuture = null;
        for( int i = 0; i < COUNT; i ++ )
        {
            ByteBuffer buf = ByteBuffer.allocate( DATA_SIZE );
            buf.limit( DATA_SIZE );
            fillWriteBuffer( buf, i );
            buf.flip();
           
            writeFuture = session.write( buf );
           
            if( session.getTransportType().isConnectionless() )
            {
                // This will align message arrival order in connectionless transport types
                waitForResponse( handler, ( i + 1 ) * DATA_SIZE );
            }
        }
       
        writeFuture.join();

        waitForResponse( handler, DATA_SIZE * COUNT );

        // Assert data
        //// Please note that BufferOverflowException can be thrown
View Full Code Here

TOP

Related Classes of org.apache.mina.common.WriteFuture

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.