org.apache.catalina.tribes.ChannelReceiver Java Examples

The following examples show how to use org.apache.catalina.tribes.ChannelReceiver. 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: ChannelCoordinator.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
public void setClusterReceiver(ChannelReceiver clusterReceiver) {
    if ( clusterReceiver != null ) {
        this.clusterReceiver = clusterReceiver;
        this.clusterReceiver.setMessageListener(this);
    } else {
        if  (this.clusterReceiver!=null ) this.clusterReceiver.setMessageListener(null);
        this.clusterReceiver = null;
    }
}
 
Example #2
Source File: ChannelSF.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Store the specified Channel children.
 *
 * @param aWriter
 *            PrintWriter to which we are storing
 * @param indent
 *            Number of spaces to indent this element
 * @param aChannel
 *            Channel whose properties are being stored
 *
 * @exception Exception
 *                if an exception occurs while storing
 */
@Override
public void storeChildren(PrintWriter aWriter, int indent, Object aChannel,
        StoreDescription parentDesc) throws Exception {
    if (aChannel instanceof Channel) {
        Channel channel = (Channel) aChannel;
        if (channel instanceof ManagedChannel) {
            ManagedChannel managedChannel = (ManagedChannel) channel;
            // Store nested <Membership> element
            MembershipService service = managedChannel.getMembershipService();
            if (service != null) {
                storeElement(aWriter, indent, service);
            }
            // Store nested <Sender> element
            ChannelSender sender = managedChannel.getChannelSender();
            if (sender != null) {
                storeElement(aWriter, indent, sender);
            }
            // Store nested <Receiver> element
            ChannelReceiver receiver = managedChannel.getChannelReceiver();
            if (receiver != null) {
                storeElement(aWriter, indent, receiver);
            }
            Iterator<ChannelInterceptor> interceptors = managedChannel.getInterceptors();
            while (interceptors.hasNext()) {
                ChannelInterceptor interceptor = interceptors.next();
                storeElement(aWriter, indent, interceptor);
            }
        }
   }
}
 
Example #3
Source File: ChannelCoordinator.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
public void setClusterReceiver(ChannelReceiver clusterReceiver) {
    if ( clusterReceiver != null ) {
        this.clusterReceiver = clusterReceiver;
        this.clusterReceiver.setMessageListener(this);
    } else {
        if  (this.clusterReceiver!=null ) this.clusterReceiver.setMessageListener(null);
        this.clusterReceiver = null;
    }
}
 
Example #4
Source File: ChannelCoordinator.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
public ChannelCoordinator(ChannelReceiver receiver,
                          ChannelSender sender,
                          MembershipService service) {
    this();
    this.setClusterReceiver(receiver);
    this.setClusterSender(sender);
    this.setMembershipService(service);
}
 
Example #5
Source File: ChannelCoordinator.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
public void setClusterReceiver(ChannelReceiver clusterReceiver) {
    if ( clusterReceiver != null ) {
        this.clusterReceiver = clusterReceiver;
        this.clusterReceiver.setMessageListener(this);
    } else {
        if  (this.clusterReceiver!=null ) this.clusterReceiver.setMessageListener(null);
        this.clusterReceiver = null;
    }
}
 
Example #6
Source File: ChannelCoordinator.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
public ChannelCoordinator(ChannelReceiver receiver,
                          ChannelSender sender,
                          MembershipService service) {

    this.optionFlag = Channel.SEND_OPTIONS_BYTE_MESSAGE |
            Channel.SEND_OPTIONS_USE_ACK |
            Channel.SEND_OPTIONS_SYNCHRONIZED_ACK;

    this.setClusterReceiver(receiver);
    this.setClusterSender(sender);
    this.setMembershipService(service);
}
 
Example #7
Source File: ChannelCoordinator.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
public ChannelCoordinator(ChannelReceiver receiver,
                          ChannelSender sender,
                          MembershipService service) {
    this();
    this.setClusterReceiver(receiver);
    this.setClusterSender(sender);
    this.setMembershipService(service);
}
 
Example #8
Source File: GroupChannel.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the channel receiver component
 * @return ChannelReceiver
 */
@Override
public ChannelReceiver getChannelReceiver() {
    return coordinator.getClusterReceiver();
}
 
Example #9
Source File: TestUdpPackages.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
public static Data createRandomData() {
    return createRandomData(ChannelReceiver.MAX_UDP_SIZE);
}
 
Example #10
Source File: TestMulticastPackages.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
public static Data createRandomData() {
    return createRandomData(ChannelReceiver.MAX_UDP_SIZE);
}
 
Example #11
Source File: NioReplicationTask.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
public synchronized void run() {
    if ( buffer == null ) {
        int size = getRxBufSize();
        if (key.channel() instanceof DatagramChannel) {
            size = ChannelReceiver.MAX_UDP_SIZE;
        }
        if ( (getOptions() & OPTION_DIRECT_BUFFER) == OPTION_DIRECT_BUFFER) {
            buffer = ByteBuffer.allocateDirect(size);
        } else {
            buffer = ByteBuffer.allocate(size);
        }
    } else {
        buffer.clear();
    }
    if (key == null) {
        return; // just in case
    }
    if ( log.isTraceEnabled() )
        log.trace("Servicing key:"+key);

    try {
        ObjectReader reader = (ObjectReader)key.attachment();
        if ( reader == null ) {
            if ( log.isTraceEnabled() )
                log.trace("No object reader, cancelling:"+key);
            cancelKey(key);
        } else {
            if ( log.isTraceEnabled() )
                log.trace("Draining channel:"+key);

            drainChannel(key, reader);
        }
    } catch (Exception e) {
        //this is common, since the sockets on the other
        //end expire after a certain time.
        if ( e instanceof CancelledKeyException ) {
            //do nothing
        } else if ( e instanceof IOException ) {
            //dont spew out stack traces for IO exceptions unless debug is enabled.
            if (log.isDebugEnabled()) log.debug ("IOException in replication worker, unable to drain channel. Probable cause: Keep alive socket closed["+e.getMessage()+"].", e);
            else log.warn ("IOException in replication worker, unable to drain channel. Probable cause: Keep alive socket closed["+e.getMessage()+"].");
        } else if ( log.isErrorEnabled() ) {
            //this is a real error, log it.
            log.error("Exception caught in TcpReplicationThread.drainChannel.",e);
        }
        cancelKey(key);
    } finally {

    }
    key = null;
    // done, ready for more, return to pool
    getTaskPool().returnWorker (this);
}
 
Example #12
Source File: GroupChannel.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
/**
 * Sets the channel receiver component
 * @param clusterReceiver ChannelReceiver
 */
@Override
public void setChannelReceiver(ChannelReceiver clusterReceiver) {
    coordinator.setClusterReceiver(clusterReceiver);
}
 
Example #13
Source File: GroupChannel.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the channel receiver component
 * @return ChannelReceiver
 */
@Override
public ChannelReceiver getChannelReceiver() {
    return coordinator.getClusterReceiver();
}
 
Example #14
Source File: ChannelCoordinator.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
public ChannelReceiver getClusterReceiver() {
    return clusterReceiver;
}
 
Example #15
Source File: TestUdpPackages.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
public static Data createRandomData() {
    return createRandomData(ChannelReceiver.MAX_UDP_SIZE);
}
 
Example #16
Source File: TestMulticastPackages.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
public static Data createRandomData() {
    return createRandomData(ChannelReceiver.MAX_UDP_SIZE);
}
 
Example #17
Source File: NioReplicationTask.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
public synchronized void run() {
    if ( buffer == null ) {
        int size = getRxBufSize();
        if (key.channel() instanceof DatagramChannel) {
            size = ChannelReceiver.MAX_UDP_SIZE;
        }
        if ( (getOptions() & OPTION_DIRECT_BUFFER) == OPTION_DIRECT_BUFFER) {
            buffer = ByteBuffer.allocateDirect(size);
        } else {
            buffer = ByteBuffer.allocate(size);
        }
    } else {
        buffer.clear();
    }
    if (key == null) {
        return; // just in case
    }
    if ( log.isTraceEnabled() )
        log.trace("Servicing key:"+key);

    try {
        ObjectReader reader = (ObjectReader)key.attachment();
        if ( reader == null ) {
            if ( log.isTraceEnabled() )
                log.trace("No object reader, cancelling:"+key);
            cancelKey(key);
        } else {
            if ( log.isTraceEnabled() )
                log.trace("Draining channel:"+key);

            drainChannel(key, reader);
        }
    } catch (Exception e) {
        //this is common, since the sockets on the other
        //end expire after a certain time.
        if ( e instanceof CancelledKeyException ) {
            //do nothing
        } else if ( e instanceof IOException ) {
            //dont spew out stack traces for IO exceptions unless debug is enabled.
            if (log.isDebugEnabled()) log.debug ("IOException in replication worker, unable to drain channel. Probable cause: Keep alive socket closed["+e.getMessage()+"].", e);
            else log.warn ("IOException in replication worker, unable to drain channel. Probable cause: Keep alive socket closed["+e.getMessage()+"].");
        } else if ( log.isErrorEnabled() ) {
            //this is a real error, log it.
            log.error("Exception caught in TcpReplicationThread.drainChannel.",e);
        }
        cancelKey(key);
    } finally {

    }
    key = null;
    // done, ready for more, return to pool
    getTaskPool().returnWorker (this);
}
 
Example #18
Source File: GroupChannel.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
/**
 * Sets the channel receiver component
 * @param clusterReceiver ChannelReceiver
 */
@Override
public void setChannelReceiver(ChannelReceiver clusterReceiver) {
    coordinator.setClusterReceiver(clusterReceiver);
}
 
Example #19
Source File: ChannelCoordinator.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
public ChannelReceiver getClusterReceiver() {
    return clusterReceiver;
}
 
Example #20
Source File: TestUdpPackages.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
public static Data createRandomData() {
    return createRandomData(ChannelReceiver.MAX_UDP_SIZE);
}
 
Example #21
Source File: TestMulticastPackages.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
public static Data createRandomData() {
    return createRandomData(ChannelReceiver.MAX_UDP_SIZE);
}
 
Example #22
Source File: NioReplicationTask.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
@Override
public synchronized void run() {
    if ( buffer == null ) {
        int size = getRxBufSize();
        if (key.channel() instanceof DatagramChannel) {
            size = ChannelReceiver.MAX_UDP_SIZE;
        }
        if ( (getOptions() & OPTION_DIRECT_BUFFER) == OPTION_DIRECT_BUFFER) {
            buffer = ByteBuffer.allocateDirect(size);
        } else {
            buffer = ByteBuffer.allocate(size);
        }
    } else {
        buffer.clear();
    }
    if (key == null) {
        return; // just in case
    }
    if ( log.isTraceEnabled() )
        log.trace("Servicing key:"+key);

    try {
        ObjectReader reader = (ObjectReader)key.attachment();
        if ( reader == null ) {
            if ( log.isTraceEnabled() )
                log.trace("No object reader, cancelling:"+key);
            cancelKey(key);
        } else {
            if ( log.isTraceEnabled() )
                log.trace("Draining channel:"+key);

            drainChannel(key, reader);
        }
    } catch (Exception e) {
        //this is common, since the sockets on the other
        //end expire after a certain time.
        if ( e instanceof CancelledKeyException ) {
            //do nothing
        } else if ( e instanceof IOException ) {
            //dont spew out stack traces for IO exceptions unless debug is enabled.
            if (log.isDebugEnabled()) log.debug ("IOException in replication worker, unable to drain channel. Probable cause: Keep alive socket closed["+e.getMessage()+"].", e);
            else log.warn (sm.getString("nioReplicationTask.unable.drainChannel.ioe", e.getMessage()));
        } else if ( log.isErrorEnabled() ) {
            //this is a real error, log it.
            log.error(sm.getString("nioReplicationTask.exception.drainChannel"),e);
        }
        cancelKey(key);
    }
    key = null;
    // done, ready for more, return to pool
    getTaskPool().returnWorker (this);
}
 
Example #23
Source File: GroupChannel.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
/**
 * Sets the channel receiver component
 * @param clusterReceiver ChannelReceiver
 */
@Override
public void setChannelReceiver(ChannelReceiver clusterReceiver) {
    coordinator.setClusterReceiver(clusterReceiver);
}
 
Example #24
Source File: GroupChannel.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
/**
 * Returns the channel receiver component
 * @return ChannelReceiver
 */
@Override
public ChannelReceiver getChannelReceiver() {
    return coordinator.getClusterReceiver();
}
 
Example #25
Source File: ChannelCoordinator.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
public ChannelReceiver getClusterReceiver() {
    return clusterReceiver;
}