Java Code Examples for org.apache.catalina.tribes.io.ObjectReader#finish()

The following examples show how to use org.apache.catalina.tribes.io.ObjectReader#finish() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NioReplicationTask.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
private void cancelKey(final SelectionKey key) {
    if ( log.isTraceEnabled() )
        log.trace("Adding key for cancel event:"+key);

    ObjectReader reader = (ObjectReader)key.attachment();
    if ( reader != null ) {
        reader.setCancelled(true);
        reader.finish();
    }
    Runnable cx = new Runnable() {
        @Override
        public void run() {
            if ( log.isTraceEnabled() )
                log.trace("Cancelling key:"+key);

            NioReceiver.cancelledKey(key);
        }
    };
    receiver.addEvent(cx);
}
 
Example 2
Source File: NioReplicationTask.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
private void cancelKey(final SelectionKey key) {
    if ( log.isTraceEnabled() )
        log.trace("Adding key for cancel event:"+key);

    ObjectReader reader = (ObjectReader)key.attachment();
    if ( reader != null ) {
        reader.setCancelled(true);
        reader.finish();
    }
    Runnable cx = new Runnable() {
        @Override
        public void run() {
            if ( log.isTraceEnabled() )
                log.trace("Cancelling key:"+key);

            NioReceiver.cancelledKey(key);
        }
    };
    receiver.addEvent(cx);
}
 
Example 3
Source File: NioReplicationTask.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
private void cancelKey(final SelectionKey key) {
    if ( log.isTraceEnabled() )
        log.trace("Adding key for cancel event:"+key);

    ObjectReader reader = (ObjectReader)key.attachment();
    if ( reader != null ) {
        reader.setCancelled(true);
        reader.finish();
    }
    Runnable cx = new Runnable() {
        @Override
        public void run() {
            if ( log.isTraceEnabled() )
                log.trace("Cancelling key:"+key);

            NioReceiver.cancelledKey(key);
        }
    };
    receiver.addEvent(cx);
}
 
Example 4
Source File: NioReplicationTask.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
protected void registerForRead(final SelectionKey key, ObjectReader reader) {
    if ( log.isTraceEnabled() )
        log.trace("Adding key for read event:"+key);
    reader.finish();
    //register our OP_READ interest
    Runnable r = new Runnable() {
        @Override
        public void run() {
            try {
                if (key.isValid()) {
                    // cycle the selector so this key is active again
                    key.selector().wakeup();
                    // resume interest in OP_READ, OP_WRITE
                    int resumeOps = key.interestOps() | SelectionKey.OP_READ;
                    key.interestOps(resumeOps);
                    if ( log.isTraceEnabled() )
                        log.trace("Registering key for read:"+key);
                }
            } catch (CancelledKeyException ckx ) {
                NioReceiver.cancelledKey(key);
                if ( log.isTraceEnabled() )
                    log.trace("CKX Cancelling key:"+key);

            } catch (Exception x) {
                log.error(sm.getString("nioReplicationTask.error.register.key", key),x);
            }
        }
    };
    receiver.addEvent(r);
}
 
Example 5
Source File: NioReplicationTask.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
protected void registerForRead(final SelectionKey key, ObjectReader reader) {
    if ( log.isTraceEnabled() )
        log.trace("Adding key for read event:"+key);
    reader.finish();
    //register our OP_READ interest
    Runnable r = new Runnable() {
        @Override
        public void run() {
            try {
                if (key.isValid()) {
                    // cycle the selector so this key is active again
                    key.selector().wakeup();
                    // resume interest in OP_READ, OP_WRITE
                    int resumeOps = key.interestOps() | SelectionKey.OP_READ;
                    key.interestOps(resumeOps);
                    if ( log.isTraceEnabled() )
                        log.trace("Registering key for read:"+key);
                }
            } catch (CancelledKeyException ckx ) {
                NioReceiver.cancelledKey(key);
                if ( log.isTraceEnabled() )
                    log.trace("CKX Cancelling key:"+key);

            } catch (Exception x) {
                log.error("Error registering key for read:"+key,x);
            }
        }
    };
    receiver.addEvent(r);
}
 
Example 6
Source File: NioReplicationTask.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
protected void registerForRead(final SelectionKey key, ObjectReader reader) {
    if ( log.isTraceEnabled() )
        log.trace("Adding key for read event:"+key);
    reader.finish();
    //register our OP_READ interest
    Runnable r = new Runnable() {
        @Override
        public void run() {
            try {
                if (key.isValid()) {
                    // cycle the selector so this key is active again
                    key.selector().wakeup();
                    // resume interest in OP_READ, OP_WRITE
                    int resumeOps = key.interestOps() | SelectionKey.OP_READ;
                    key.interestOps(resumeOps);
                    if ( log.isTraceEnabled() )
                        log.trace("Registering key for read:"+key);
                }
            } catch (CancelledKeyException ckx ) {
                NioReceiver.cancelledKey(key);
                if ( log.isTraceEnabled() )
                    log.trace("CKX Cancelling key:"+key);

            } catch (Exception x) {
                log.error("Error registering key for read:"+key,x);
            }
        }
    };
    receiver.addEvent(r);
}