本文整理汇总了Java中org.apache.catalina.ha.ClusterMessage类的典型用法代码示例。如果您正苦于以下问题:Java ClusterMessage类的具体用法?Java ClusterMessage怎么用?Java ClusterMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClusterMessage类属于org.apache.catalina.ha包,在下文中一共展示了ClusterMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: send
import org.apache.catalina.ha.ClusterMessage; //导入依赖的package包/类
/**
* 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);
}
}
示例2: send
import org.apache.catalina.ha.ClusterMessage; //导入依赖的package包/类
/**
* 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);
}
}
示例3: send
import org.apache.catalina.ha.ClusterMessage; //导入依赖的package包/类
/**
* 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());
if (dest != null) {
if (!getLocalMember().equals(dest)) {
channel.send(new Member[] {dest}, msg,channelSendOptions);
} else
log.error("Unable to send message to local member " + msg);
} else {
Member[] destmembers = channel.getMembers();
if (destmembers.length>0)
channel.send(destmembers,msg,channelSendOptions);
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);
}
}
示例4: requestCompleted
import org.apache.catalina.ha.ClusterMessage; //导入依赖的package包/类
@Override
public ClusterMessage requestCompleted(String sessionId) {
if (!getState().isAvailable()) return null;
LazyReplicatedMap<String,Session> map =
(LazyReplicatedMap<String,Session>)sessions;
map.replicate(sessionId,false);
return null;
}
示例5: messageDataReceived
import org.apache.catalina.ha.ClusterMessage; //导入依赖的package包/类
/**
* A message was received from another node, this is the callback method to
* implement if you are interested in receiving replication messages.
*
* @param cmsg -
* the message received.
*/
@Override
public void messageDataReceived(ClusterMessage cmsg) {
if (cmsg != null && cmsg instanceof SessionMessage) {
SessionMessage msg = (SessionMessage) cmsg;
switch (msg.getEventType()) {
case SessionMessage.EVT_GET_ALL_SESSIONS:
case SessionMessage.EVT_SESSION_CREATED:
case SessionMessage.EVT_SESSION_EXPIRED:
case SessionMessage.EVT_SESSION_ACCESSED:
case SessionMessage.EVT_SESSION_DELTA:
case SessionMessage.EVT_CHANGE_SESSION_ID: {
synchronized(receivedMessageQueue) {
if(receiverQueue) {
receivedMessageQueue.add(msg);
return ;
}
}
break;
}
default: {
//we didn't queue, do nothing
break;
}
} //switch
messageReceived(msg, msg.getAddress() != null ? (Member) msg.getAddress() : null);
}
}
示例6: send
import org.apache.catalina.ha.ClusterMessage; //导入依赖的package包/类
/**
* send manager requestCompleted message to cluster
* @param manager SessionManager
* @param cluster replication cluster
* @param sessionId sessionid from the manager
* @see DeltaManager#requestCompleted(String)
* @see SimpleTcpCluster#send(ClusterMessage)
*/
protected void send(ClusterManager manager, CatalinaCluster cluster, String sessionId) {
ClusterMessage msg = manager.requestCompleted(sessionId);
if (msg != null) {
cluster.send(msg);
if(doStatistics())
nrOfSendRequests++;
}
}
示例7: messageReceived
import org.apache.catalina.ha.ClusterMessage; //导入依赖的package包/类
public void messageReceived(ClusterMessage message) {
if (log.isDebugEnabled() && message != null)
log.debug("Assuming clocks are synched: Replication for "
+ message.getUniqueId() + " took="
+ (System.currentTimeMillis() - (message).getTimestamp())
+ " ms.");
//invoke all the listeners
boolean accepted = false;
if (message != null) {
for (Iterator<ClusterListener> iter = clusterListeners.iterator();
iter.hasNext();) {
ClusterListener listener = iter.next();
if (listener.accept(message)) {
accepted = true;
listener.messageReceived(message);
}
}
if (!accepted && notifyLifecycleListenerOnFailure) {
Member dest = message.getAddress();
// Notify our interested LifecycleListeners
fireLifecycleEvent(RECEIVE_MESSAGE_FAILURE_EVENT,
new SendMessageData(message, dest, null));
if (log.isDebugEnabled()) {
log.debug("Message " + message.toString() + " from type "
+ message.getClass().getName()
+ " transfered but no listener registered");
}
}
}
return;
}
示例8: requestCompleted
import org.apache.catalina.ha.ClusterMessage; //导入依赖的package包/类
@Override
public ClusterMessage requestCompleted(String sessionId) {
if (!getState().isAvailable())
return null;
LazyReplicatedMap<String, Session> map = (LazyReplicatedMap<String, Session>) sessions;
map.replicate(sessionId, false);
return null;
}
示例9: messageDataReceived
import org.apache.catalina.ha.ClusterMessage; //导入依赖的package包/类
/**
* A message was received from another node, this is the callback method to
* implement if you are interested in receiving replication messages.
*
* @param cmsg
* - the message received.
*/
@Override
public void messageDataReceived(ClusterMessage cmsg) {
if (cmsg != null && cmsg instanceof SessionMessage) {
SessionMessage msg = (SessionMessage) cmsg;
switch (msg.getEventType()) {
case SessionMessage.EVT_GET_ALL_SESSIONS:
case SessionMessage.EVT_SESSION_CREATED:
case SessionMessage.EVT_SESSION_EXPIRED:
case SessionMessage.EVT_SESSION_ACCESSED:
case SessionMessage.EVT_SESSION_DELTA:
case SessionMessage.EVT_CHANGE_SESSION_ID: {
synchronized (receivedMessageQueue) {
if (receiverQueue) {
receivedMessageQueue.add(msg);
return;
}
}
break;
}
default: {
// we didn't queue, do nothing
break;
}
} // switch
messageReceived(msg, msg.getAddress() != null ? (Member) msg.getAddress() : null);
}
}
示例10: messageReceived
import org.apache.catalina.ha.ClusterMessage; //导入依赖的package包/类
/**
* Callback from the cluster, when a message is received, The cluster will
* broadcast it invoking the messageReceived on the receiver.
*
* @param msg
* ClusterMessage - the message received from the cluster
*/
@Override
public void messageReceived(ClusterMessage msg) {
if (msg instanceof SessionIDMessage) {
SessionIDMessage sessionmsg = (SessionIDMessage) msg;
if (log.isDebugEnabled())
log.debug(sm.getString("jvmRoute.receiveMessage.sessionIDChanged", sessionmsg.getOrignalSessionID(),
sessionmsg.getBackupSessionID(), sessionmsg.getContextName()));
Container container = getCluster().getContainer();
Container host = null;
if (container instanceof Engine) {
host = container.findChild(sessionmsg.getHost());
} else {
host = container;
}
if (host != null) {
Context context = (Context) host.findChild(sessionmsg.getContextName());
if (context != null) {
try {
Session session = context.getManager().findSession(sessionmsg.getOrignalSessionID());
if (session != null) {
session.setId(sessionmsg.getBackupSessionID());
} else if (log.isInfoEnabled())
log.info(sm.getString("jvmRoute.lostSession", sessionmsg.getOrignalSessionID(),
sessionmsg.getContextName()));
} catch (IOException e) {
log.error(e);
}
} else if (log.isErrorEnabled())
log.error(sm.getString("jvmRoute.contextNotFound", sessionmsg.getContextName(),
((StandardEngine) host.getParent()).getJvmRoute()));
} else if (log.isErrorEnabled())
log.error(sm.getString("jvmRoute.hostNotFound", sessionmsg.getContextName()));
}
return;
}
示例11: messageReceived
import org.apache.catalina.ha.ClusterMessage; //导入依赖的package包/类
public void messageReceived(ClusterMessage message) {
if (log.isDebugEnabled() && message != null)
log.debug("Assuming clocks are synched: Replication for " + message.getUniqueId() + " took="
+ (System.currentTimeMillis() - (message).getTimestamp()) + " ms.");
// invoke all the listeners
boolean accepted = false;
if (message != null) {
for (Iterator<ClusterListener> iter = clusterListeners.iterator(); iter.hasNext();) {
ClusterListener listener = iter.next();
if (listener.accept(message)) {
accepted = true;
listener.messageReceived(message);
}
}
if (!accepted && notifyLifecycleListenerOnFailure) {
Member dest = message.getAddress();
// Notify our interested LifecycleListeners
fireLifecycleEvent(RECEIVE_MESSAGE_FAILURE_EVENT, new SendMessageData(message, dest, null));
if (log.isDebugEnabled()) {
log.debug("Message " + message.toString() + " from type " + message.getClass().getName()
+ " transfered but no listener registered");
}
}
}
return;
}
示例12: requestCompleted
import org.apache.catalina.ha.ClusterMessage; //导入依赖的package包/类
@Override
public ClusterMessage requestCompleted(String sessionId) {
if (!getState().isAvailable()) return null;
LazyReplicatedMap map = (LazyReplicatedMap)sessions;
map.replicate(sessionId,false);
return null;
}
示例13: expire
import org.apache.catalina.ha.ClusterMessage; //导入依赖的package包/类
public void expire(boolean notify, boolean notifyCluster) {
if (expiring)
return;
String expiredId = getIdInternal();
if(notifyCluster && expiredId != null && manager != null &&
manager instanceof DeltaManager) {
DeltaManager dmanager = (DeltaManager)manager;
CatalinaCluster cluster = dmanager.getCluster();
ClusterMessage msg = dmanager.requestCompleted(expiredId, true);
if (msg != null) {
cluster.send(msg);
}
}
super.expire(notify);
if (notifyCluster) {
if (log.isDebugEnabled())
log.debug(sm.getString("deltaSession.notifying",
((ClusterManager)manager).getName(),
Boolean.valueOf(isPrimarySession()),
expiredId));
if ( manager instanceof DeltaManager ) {
( (DeltaManager) manager).sessionExpired(expiredId);
}
}
}
示例14: messageReceived
import org.apache.catalina.ha.ClusterMessage; //导入依赖的package包/类
/**
* Callback from the cluster, when a message is received, The cluster will
* broadcast it invoking the messageReceived on the receiver.
*
* @param myobj
* ClusterMessage - the message received from the cluster
*/
@Override
public void messageReceived(ClusterMessage myobj) {
if (myobj != null && myobj instanceof SessionMessage) {
SessionMessage msg = (SessionMessage) myobj;
String ctxname = msg.getContextName();
//check if the message is a EVT_GET_ALL_SESSIONS,
//if so, wait until we are fully started up
Map<String,ClusterManager> managers = cluster.getManagers() ;
if (ctxname == null) {
for (Map.Entry<String, ClusterManager> entry :
managers.entrySet()) {
if (entry.getValue() != null)
entry.getValue().messageDataReceived(msg);
else {
//this happens a lot before the system has started
// up
if (log.isDebugEnabled())
log.debug("Context manager doesn't exist:"
+ entry.getKey());
}
}
} else {
ClusterManager mgr = managers.get(ctxname);
if (mgr != null)
mgr.messageDataReceived(msg);
else if (log.isWarnEnabled())
log.warn("Context manager doesn't exist:" + ctxname);
}
}
return;
}
示例15: send
import org.apache.catalina.ha.ClusterMessage; //导入依赖的package包/类
private void send(final ClusterMessage message, final AppInfo app) {
for (final CatalinaCluster cluster : clusters) {
final String path = app.path;
if (new File(path).exists() && !app.autoDeploy) {
cluster.send(message);
}
}
}