Package org.apache.mina.common

Examples of org.apache.mina.common.WriteFuture


        {
            // no; bail out
            return DefaultWriteFuture.newNotWrittenFuture( session );
        }
       
        WriteFuture writeFuture = null;
       
        // write net data
       
        // set flag that we are writing encrypted data
        // (used in SSLFilter.filterWrite())
View Full Code Here


    }
   
    public WriteFuture flush()
    {
        Queue bufferQueue = this.bufferQueue;
        WriteFuture future = null;
        if( bufferQueue.isEmpty() )
        {
            return null;
        }
        else
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

        if (!getOutNetBuffer().hasRemaining()) {
            // no; bail out
            return DefaultWriteFuture.newNotWrittenFuture(session);
        }

        WriteFuture writeFuture = null;

        // write net data

        // set flag that we are writing encrypted data
        // (used in SSLFilter.filterWrite())
View Full Code Here

     * @throws IllegalArgumentException if this filter is not managing the specified session
     */
    public WriteFuture stopSSL(IoSession session) throws SSLException {
        SSLHandler handler = getSSLSessionHandler(session);
        NextFilter nextFilter = (NextFilter) session.getAttribute(NEXT_FILTER);
        WriteFuture future;
        synchronized (handler) {
            future = initiateClosure(nextFilter, session);
        }

        handler.flushScheduledEvents();
View Full Code Here

            // SSL might have not started yet.
            nextFilter.filterClose(session);
            return;
        }

        WriteFuture future = null;
        try {
            synchronized (handler) {
                if (isSSLStarted(session)) {
                    future = initiateClosure(nextFilter, session);
                }
            }

            handler.flushScheduledEvents();
        } finally {
            if (future == null) {
                nextFilter.filterClose(session);
            } else {
                future.addListener(new IoFutureListener() {
                    public void operationComplete(IoFuture future) {
                        nextFilter.filterClose(session);
                    }
                });
            }
View Full Code Here

        if (!handler.closeOutbound()) {
            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

            this.nextFilter = nextFilter;
            this.writeRequest = writeRequest;
        }

        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

     * @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
        if (LOG.isTraceEnabled()) {
            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

        bufferQueue.push(newBuf);
    }

    public WriteFuture flush() {
        Queue bufferQueue = this.bufferQueue;
        WriteFuture future = null;
        if (bufferQueue.isEmpty()) {
            return null;
        } else {
            for (;;) {
                ByteBuffer buf = (ByteBuffer) bufferQueue.pop();
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.