* @return a SessionMessage to be sent,
*/
public ClusterMessage requestCompleted(String sessionId) {
+ return requestCompleted(sessionId, false);
+ }
+
+ /**
+ * When the request has been completed, the replication valve will notify
+ * the manager, and the manager will decide whether any replication is
+ * needed or not. If there is a need for replication, the manager will
+ * create a session message and that will be replicated. The cluster
+ * determines where it gets sent.
+ *
+ * Session expiration also calls this method, but with expires == true.
+ *
+ * @param sessionId -
+ * the sessionId that just completed.
+ * @param expires -
+ * whether this method has been called during session expiration
+ * @return a SessionMessage to be sent,
+ */
+ public ClusterMessage requestCompleted(String sessionId, boolean expires) {
DeltaSession session = null;
try {
session = (DeltaSession) findSession(sessionId);
}
}
if(!isDeltaRequest) {
- if(!session.isPrimarySession()) {
+ if(!expires && !session.isPrimarySession()) {
counterSend_EVT_SESSION_ACCESSED++;
msg = new SessionMessageImpl(getName(),
SessionMessage.EVT_SESSION_ACCESSED,
log.debug(sm.getString("deltaManager.createMessage.delta",getName(), sessionId));
}
}
- session.setPrimarySession(true);
+ if (!expires)
+ session.setPrimarySession(true);
//check to see if we need to send out an access message
- if ((msg == null)) {
+ if (!expires && (msg == null)) {
long replDelta = System.currentTimeMillis() - session.getLastTimeReplicated();
if (replDelta > (getMaxInactiveInterval() * 1000)) {
counterSend_EVT_SESSION_ACCESSED++;
import org.apache.catalina.Manager;
import org.apache.catalina.SessionListener;
import org.apache.catalina.ha.ClusterManager;
+import org.apache.catalina.ha.CatalinaCluster;
import org.apache.catalina.ha.ClusterSession;
+import org.apache.catalina.ha.ClusterMessage;
import org.apache.catalina.realm.GenericPrincipal;
import org.apache.catalina.session.StandardSession;
import org.apache.catalina.tribes.io.ReplicationStream;
}
public void expire(boolean notify, boolean notifyCluster) {
+ if (expiring)
+ return;
String expiredId = getIdInternal();
+
+ if(expiredId != null && manager != null &&
+ manager instanceof DeltaManager) {
+ DeltaManager dmanager = (DeltaManager)manager;
+ CatalinaCluster cluster = dmanager.getCluster();
+ ClusterMessage msg = dmanager.requestCompleted(expiredId, true);
+ if (msg != null) {
+ if(dmanager.doDomainReplication()) {
+ cluster.sendClusterDomain(msg);
+ } else {
+ cluster.send(msg);
+ }
+ }
+ }
+
super.expire(notify);
if (notifyCluster) {