Java Code Examples for org.apache.catalina.ha.ClusterManager#setCluster()

The following examples show how to use org.apache.catalina.ha.ClusterManager#setCluster() . 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
/**
 * 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;
}
 
Example 2
Source File: SimpleTcpCluster.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Override
public void registerManager(Manager manager) {

    if (! (manager instanceof ClusterManager)) {
        log.warn(sm.getString("simpleTcpCluster.clustermanager.notImplement", manager));
        return;
    }
    ClusterManager cmanager = (ClusterManager) manager;
    // Notify our interested LifecycleListeners
    fireLifecycleEvent(BEFORE_MANAGERREGISTER_EVENT, manager);
    String clusterName = getManagerName(cmanager.getName(), manager);
    cmanager.setName(clusterName);
    cmanager.setCluster(this);

    managers.put(clusterName, cmanager);
    // Notify our interested LifecycleListeners
    fireLifecycleEvent(AFTER_MANAGERREGISTER_EVENT, manager);
}
 
Example 3
Source File: SimpleTcpCluster.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * 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("Unable to clone cluster manager, defaulting to org.apache.catalina.ha.session.DeltaManager", x);
        manager = new org.apache.catalina.ha.session.DeltaManager();
    } finally {
        if ( manager != null) manager.setCluster(this);
    }
    return manager;
}
 
Example 4
Source File: SimpleTcpCluster.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Override
public void registerManager(Manager manager) {

    if (! (manager instanceof ClusterManager)) {
        log.warn("Manager [ " + manager + "] does not implement ClusterManager, addition to cluster has been aborted.");
        return;
    }
    ClusterManager cmanager = (ClusterManager) manager ;
    cmanager.setDistributable(true);
    // Notify our interested LifecycleListeners
    fireLifecycleEvent(BEFORE_MANAGERREGISTER_EVENT, manager);
    String clusterName = getManagerName(cmanager.getName(), manager);
    cmanager.setName(clusterName);
    cmanager.setCluster(this);

    managers.put(clusterName, cmanager);
    // Notify our interested LifecycleListeners
    fireLifecycleEvent(AFTER_MANAGERREGISTER_EVENT, manager);    
}
 
Example 5
Source File: SimpleTcpCluster.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * 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("Unable to clone cluster manager, defaulting to org.apache.catalina.ha.session.DeltaManager", x);
        manager = new org.apache.catalina.ha.session.DeltaManager();
    } finally {
        if ( manager != null) manager.setCluster(this);
    }
    return manager;
}
 
Example 6
Source File: SimpleTcpCluster.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Override
public void registerManager(Manager manager) {

    if (! (manager instanceof ClusterManager)) {
        log.warn("Manager [ " + manager + "] does not implement ClusterManager, addition to cluster has been aborted.");
        return;
    }
    ClusterManager cmanager = (ClusterManager) manager;
    // Notify our interested LifecycleListeners
    fireLifecycleEvent(BEFORE_MANAGERREGISTER_EVENT, manager);
    String clusterName = getManagerName(cmanager.getName(), manager);
    cmanager.setName(clusterName);
    cmanager.setCluster(this);

    managers.put(clusterName, cmanager);
    // Notify our interested LifecycleListeners
    fireLifecycleEvent(AFTER_MANAGERREGISTER_EVENT, manager);    
}
 
Example 7
Source File: SimpleTcpCluster.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 8
Source File: SimpleTcpCluster.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Remove an application from cluster replication bus.
 * 
 * @see org.apache.catalina.Cluster#removeManager(Manager)
 */
@Override
public void removeManager(Manager manager) {
    if (manager != null && 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);
    }
}
 
Example 9
Source File: SimpleTcpCluster.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Remove an application from cluster replication bus.
 * 
 * @see org.apache.catalina.Cluster#removeManager(Manager)
 */
@Override
public void removeManager(Manager manager) {
    if (manager != null && 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);
    }
}