Search in sources :

Example 11 with ClusterManager

use of org.apache.catalina.ha.ClusterManager in project tomcat by apache.

the class SimpleTcpCluster method removeManager.

/**
 * Remove an application from cluster replication bus.
 *
 * @param manager The manager
 * @see org.apache.catalina.Cluster#removeManager(Manager)
 */
@Override
public void removeManager(Manager manager) {
    if (manager instanceof ClusterManager) {
        ClusterManager cmgr = (ClusterManager) manager;
        // Notify our interested LifecycleListeners
        fireLifecycleEvent(BEFORE_MANAGERUNREGISTER_EVENT, manager);
        managers.remove(getManagerName(cmgr.getName(), manager));
        cmgr.setCluster(null);
        // Notify our interested LifecycleListeners
        fireLifecycleEvent(AFTER_MANAGERUNREGISTER_EVENT, manager);
    }
}
Also used : ClusterManager(org.apache.catalina.ha.ClusterManager)

Example 12 with ClusterManager

use of org.apache.catalina.ha.ClusterManager in project tomcat by apache.

the class SimpleTcpCluster method createManager.

/**
 * Create new Manager without add to cluster (comes with start the manager)
 *
 * @param name
 *            Context Name of this manager
 * @see org.apache.catalina.Cluster#createManager(java.lang.String)
 * @see DeltaManager#start()
 */
@Override
public synchronized Manager createManager(String name) {
    if (log.isDebugEnabled()) {
        log.debug("Creating ClusterManager for context " + name + " using class " + getManagerTemplate().getClass().getName());
    }
    ClusterManager manager = null;
    try {
        manager = managerTemplate.cloneFromTemplate();
        manager.setName(name);
    } catch (Exception x) {
        log.error(sm.getString("simpleTcpCluster.clustermanager.cloneFailed"), x);
        manager = new org.apache.catalina.ha.session.DeltaManager();
    } finally {
        if (manager != null) {
            manager.setCluster(this);
        }
    }
    return manager;
}
Also used : DeltaManager(org.apache.catalina.ha.session.DeltaManager) ClusterManager(org.apache.catalina.ha.ClusterManager) LifecycleException(org.apache.catalina.LifecycleException)

Example 13 with ClusterManager

use of org.apache.catalina.ha.ClusterManager in project tomcat by apache.

the class DeltaSession method setOwner.

@Override
public void setOwner(Object owner) {
    if (owner instanceof ClusterManager && getManager() == null) {
        ClusterManager cm = (ClusterManager) owner;
        this.setManager(cm);
        this.setValid(true);
        this.setPrimarySession(false);
        this.access();
        this.resetDeltaRequest();
        this.endAccess();
    }
}
Also used : ClusterManager(org.apache.catalina.ha.ClusterManager)

Example 14 with ClusterManager

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

the class DeltaSession method applyDiff.

/**
 * Applies a diff to an existing object.
 * @param diff byte[]
 * @param offset int
 * @param length int
 * @throws IOException
 */
@Override
public void applyDiff(byte[] diff, int offset, int length) throws IOException, ClassNotFoundException {
    try {
        lock();
        ReplicationStream stream = ((ClusterManager) getManager()).getReplicationStream(diff, offset, length);
        ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
        try {
            ClassLoader[] loaders = getClassLoaders();
            if (loaders != null && loaders.length > 0)
                Thread.currentThread().setContextClassLoader(loaders[0]);
            getDeltaRequest().readExternal(stream);
            getDeltaRequest().execute(this, ((ClusterManager) getManager()).isNotifyListenersOnReplication());
            stream.close();
        } finally {
            Thread.currentThread().setContextClassLoader(contextLoader);
        }
    } finally {
        unlock();
    }
}
Also used : ReplicationStream(org.apache.catalina.tribes.io.ReplicationStream) ClusterManager(org.apache.catalina.ha.ClusterManager)

Example 15 with ClusterManager

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

the class DeltaSession method setOwner.

@Override
public void setOwner(Object owner) {
    if (owner instanceof ClusterManager && getManager() == null) {
        ClusterManager cm = (ClusterManager) owner;
        this.setManager(cm);
        this.setValid(true);
        this.setPrimarySession(false);
        this.access();
        this.resetDeltaRequest();
        this.endAccess();
    }
}
Also used : ClusterManager(org.apache.catalina.ha.ClusterManager)

Aggregations

ClusterManager (org.apache.catalina.ha.ClusterManager)16 Map (java.util.Map)2 Context (org.apache.catalina.Context)2 LifecycleException (org.apache.catalina.LifecycleException)2 StandardContext (org.apache.catalina.core.StandardContext)2 CatalinaCluster (org.apache.catalina.ha.CatalinaCluster)2 DeltaManager (org.apache.catalina.ha.session.DeltaManager)2 ObjectInputStream (java.io.ObjectInputStream)1 ArrayList (java.util.ArrayList)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 ClusterMessage (org.apache.catalina.ha.ClusterMessage)1 DeltaSession (org.apache.catalina.ha.session.DeltaSession)1 SimpleTcpCluster (org.apache.catalina.ha.tcp.SimpleTcpCluster)1 Channel (org.apache.catalina.tribes.Channel)1 ReplicationStream (org.apache.catalina.tribes.io.ReplicationStream)1