Search in sources :

Example 6 with CatalinaCluster

use of org.apache.catalina.ha.CatalinaCluster in project tomcat70 by apache.

the class DeltaSession method expire.

public void expire(boolean notify, boolean notifyCluster) {
    // isValid is false
    if (!isValid)
        return;
    synchronized (this) {
        // Double check locking - isValid needs to be volatile
        if (!isValid)
            return;
        if (manager == null)
            return;
        String expiredId = getIdInternal();
        if (notifyCluster && expiredId != 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);
            }
        }
    }
}
Also used : CatalinaCluster(org.apache.catalina.ha.CatalinaCluster) ClusterMessage(org.apache.catalina.ha.ClusterMessage)

Example 7 with CatalinaCluster

use of org.apache.catalina.ha.CatalinaCluster in project tomcat70 by apache.

the class JvmRouteBinderValve method sendSessionIDClusterBackup.

/**
 * Send the changed Sessionid to all clusternodes.
 *
 * @see JvmRouteSessionIDBinderListener#messageReceived(
 *            org.apache.catalina.ha.ClusterMessage)
 * @param sessionId
 *            current failed sessionid
 * @param newSessionID
 *            new session id, bind to the new cluster node
 */
protected void sendSessionIDClusterBackup(Request request, String sessionId, String newSessionID) {
    CatalinaCluster c = getCluster();
    if (c != null && !(getManager(request) instanceof BackupManager)) {
        SessionIDMessage msg = new SessionIDMessage();
        msg.setOrignalSessionID(sessionId);
        msg.setBackupSessionID(newSessionID);
        Context context = request.getContext();
        msg.setContextName(context.getName());
        msg.setHost(context.getParent().getName());
        c.send(msg);
    }
}
Also used : Context(org.apache.catalina.Context) CatalinaCluster(org.apache.catalina.ha.CatalinaCluster)

Example 8 with CatalinaCluster

use of org.apache.catalina.ha.CatalinaCluster in project tomcat70 by apache.

the class ClusterSingleSignOn method startInternal.

// ------------------------------------------------------- Lifecycle Methods
/**
 * Start this component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected synchronized void startInternal() throws LifecycleException {
    // Load the cluster component, if any
    try {
        if (cluster == null) {
            Container host = getContainer();
            if (host instanceof Host) {
                if (host.getCluster() instanceof CatalinaCluster) {
                    setCluster((CatalinaCluster) host.getCluster());
                }
            }
        }
        if (cluster == null) {
            throw new LifecycleException("There is no Cluster for ClusterSingleSignOn");
        }
        ClassLoader[] cls = new ClassLoader[] { this.getClass().getClassLoader() };
        ReplicatedMap<String, SingleSignOnEntry> cache = new ReplicatedMap<String, SingleSignOnEntry>(this, cluster.getChannel(), rpcTimeout, cluster.getClusterName() + "-SSO-cache", cls, terminateOnStartFailure);
        cache.setChannelSendOptions(mapSendOptions);
        cache.setAccessTimeout(accessTimeout);
        this.cache = cache;
    } catch (Throwable t) {
        ExceptionUtils.handleThrowable(t);
        throw new LifecycleException("ClusterSingleSignOn exception during clusterLoad " + t);
    }
    super.startInternal();
}
Also used : Container(org.apache.catalina.Container) LifecycleException(org.apache.catalina.LifecycleException) CatalinaCluster(org.apache.catalina.ha.CatalinaCluster) SingleSignOnEntry(org.apache.catalina.authenticator.SingleSignOnEntry) Host(org.apache.catalina.Host) ReplicatedMap(org.apache.catalina.tribes.tipis.ReplicatedMap)

Example 9 with CatalinaCluster

use of org.apache.catalina.ha.CatalinaCluster in project tomcat70 by apache.

the class ReplicatedContext method startInternal.

/**
 * Start this component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected synchronized void startInternal() throws LifecycleException {
    super.startInternal();
    try {
        CatalinaCluster catclust = (CatalinaCluster) this.getCluster();
        if (catclust != null) {
            ReplicatedMap<String, Object> map = new ReplicatedMap<String, Object>(this, catclust.getChannel(), DEFAULT_REPL_TIMEOUT, getName(), getClassLoaders());
            map.setChannelSendOptions(mapSendOptions);
            ((ReplApplContext) this.context).setAttributeMap(map);
        }
    } catch (Exception x) {
        log.error("Unable to start ReplicatedContext", x);
        throw new LifecycleException("Failed to start ReplicatedContext", x);
    }
}
Also used : LifecycleException(org.apache.catalina.LifecycleException) CatalinaCluster(org.apache.catalina.ha.CatalinaCluster) ReplicatedMap(org.apache.catalina.tribes.tipis.ReplicatedMap) LifecycleException(org.apache.catalina.LifecycleException)

Aggregations

CatalinaCluster (org.apache.catalina.ha.CatalinaCluster)9 LifecycleException (org.apache.catalina.LifecycleException)4 ReplicatedMap (org.apache.catalina.tribes.tipis.ReplicatedMap)4 Container (org.apache.catalina.Container)3 Host (org.apache.catalina.Host)2 SingleSignOnEntry (org.apache.catalina.authenticator.SingleSignOnEntry)2 ClusterManager (org.apache.catalina.ha.ClusterManager)2 ClusterMessage (org.apache.catalina.ha.ClusterMessage)2 SimpleTcpCluster (org.apache.catalina.ha.tcp.SimpleTcpCluster)2 ArrayList (java.util.ArrayList)1 Cluster (org.apache.catalina.Cluster)1 Context (org.apache.catalina.Context)1 LifecycleListener (org.apache.catalina.LifecycleListener)1 Valve (org.apache.catalina.Valve)1 ClusterDeployer (org.apache.catalina.ha.ClusterDeployer)1 ClusterListener (org.apache.catalina.ha.ClusterListener)1 Channel (org.apache.catalina.tribes.Channel)1 TomEEClusterListener (org.apache.tomee.catalina.cluster.TomEEClusterListener)1