Java Code Examples for org.apache.catalina.ha.ClusterMessage#setAddress()

The following examples show how to use org.apache.catalina.ha.ClusterMessage#setAddress() . 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: SimpleTcpCluster.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * send a cluster message to one member
 *
 * @param msg message to transfer
 * @param dest Receiver member
 * @see org.apache.catalina.ha.CatalinaCluster#send(org.apache.catalina.ha.ClusterMessage,
 *      org.apache.catalina.tribes.Member)
 */
@Override
public void send(ClusterMessage msg, Member dest) {
    try {
        msg.setAddress(getLocalMember());
        int sendOptions = channelSendOptions;
        if (msg instanceof SessionMessage
                && ((SessionMessage)msg).getEventType() == SessionMessage.EVT_ALL_SESSION_DATA) {
            sendOptions = Channel.SEND_OPTIONS_SYNCHRONIZED_ACK|Channel.SEND_OPTIONS_USE_ACK;
        }
        if (dest != null) {
            if (!getLocalMember().equals(dest)) {
                channel.send(new Member[] {dest}, msg, sendOptions);
            } else
                log.error(sm.getString("simpleTcpCluster.unableSend.localMember", msg));
        } else {
            Member[] destmembers = channel.getMembers();
            if (destmembers.length>0)
                channel.send(destmembers,msg, sendOptions);
            else if (log.isDebugEnabled())
                log.debug("No members in cluster, ignoring message:"+msg);
        }
    } catch (Exception x) {
        log.error(sm.getString("simpleTcpCluster.sendFailed"), x);
    }
}
 
Example 2
Source File: SimpleTcpCluster.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * send a cluster message to one member
 * 
 * @param msg message to transfer
 * @param dest Receiver member
 * @see org.apache.catalina.ha.CatalinaCluster#send(org.apache.catalina.ha.ClusterMessage,
 *      org.apache.catalina.tribes.Member)
 */
@Override
public void send(ClusterMessage msg, Member dest) {
    try {
        msg.setAddress(getLocalMember());
        int sendOptions = channelSendOptions;
        if (msg instanceof SessionMessage
                && ((SessionMessage)msg).getEventType() == SessionMessage.EVT_ALL_SESSION_DATA) {
            sendOptions = Channel.SEND_OPTIONS_SYNCHRONIZED_ACK|Channel.SEND_OPTIONS_USE_ACK;
        }
        if (dest != null) {
            if (!getLocalMember().equals(dest)) {
                channel.send(new Member[] {dest}, msg, sendOptions);
            } else
                log.error("Unable to send message to local member " + msg);
        } else {
            Member[] destmembers = channel.getMembers();
            if (destmembers.length>0)
                channel.send(destmembers,msg, sendOptions);
            else if (log.isDebugEnabled()) 
                log.debug("No members in cluster, ignoring message:"+msg);
        }
    } catch (Exception x) {
        log.error("Unable to send message through cluster sender.", x);
    }
}
 
Example 3
Source File: SimpleTcpCluster.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * send a cluster message to one member
 * 
 * @param msg message to transfer
 * @param dest Receiver member
 * @see org.apache.catalina.ha.CatalinaCluster#send(org.apache.catalina.ha.ClusterMessage,
 *      org.apache.catalina.tribes.Member)
 */
@Override
public void send(ClusterMessage msg, Member dest) {
    try {
        msg.setAddress(getLocalMember());
        int sendOptions = channelSendOptions;
        if (msg instanceof SessionMessage
                && ((SessionMessage)msg).getEventType() == SessionMessage.EVT_ALL_SESSION_DATA) {
            sendOptions = Channel.SEND_OPTIONS_SYNCHRONIZED_ACK|Channel.SEND_OPTIONS_USE_ACK;
        }
        if (dest != null) {
            if (!getLocalMember().equals(dest)) {
                channel.send(new Member[] {dest}, msg, sendOptions);
            } else
                log.error("Unable to send message to local member " + msg);
        } else {
            Member[] destmembers = channel.getMembers();
            if (destmembers.length>0)
                channel.send(destmembers,msg, sendOptions);
            else if (log.isDebugEnabled()) 
                log.debug("No members in cluster, ignoring message:"+msg);
        }
    } catch (Exception x) {
        log.error("Unable to send message through cluster sender.", x);
    }
}
 
Example 4
Source File: SimpleTcpCluster.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
@Override
public void messageReceived(Serializable message, Member sender) {
    ClusterMessage fwd = (ClusterMessage)message;
    fwd.setAddress(sender);
    messageReceived(fwd);
}
 
Example 5
Source File: SimpleTcpCluster.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
public void messageReceived(Serializable message, Member sender) {
    ClusterMessage fwd = (ClusterMessage)message;
    fwd.setAddress(sender);
    messageReceived(fwd);
}
 
Example 6
Source File: SimpleTcpCluster.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
public void messageReceived(Serializable message, Member sender) {
    ClusterMessage fwd = (ClusterMessage)message;
    fwd.setAddress(sender);
    messageReceived(fwd);
}