use of org.apache.catalina.ha.ClusterManager in project tomcat70 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("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;
}
use of org.apache.catalina.ha.ClusterManager in project tomcat70 by apache.
the class SimpleTcpCluster method removeManager.
/**
* 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);
}
}
use of org.apache.catalina.ha.ClusterManager in project tomcat70 by apache.
the class SimpleTcpCluster method registerManager.
@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);
}
use of org.apache.catalina.ha.ClusterManager in project tomcat70 by apache.
the class ClusterSessionListener method messageReceived.
/**
* 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 {
// 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);
// timeout of GET_ALL_SESSIONS sync phase.
if (msg.getEventType() == SessionMessage.EVT_GET_ALL_SESSIONS) {
SessionMessage replymsg = new SessionMessageImpl(ctxname, SessionMessage.EVT_ALL_SESSION_NOCONTEXTMANAGER, null, "NO-CONTEXT-MANAGER", "NO-CONTEXT-MANAGER-" + ctxname);
cluster.send(replymsg, msg.getAddress());
}
}
}
}
return;
}
use of org.apache.catalina.ha.ClusterManager in project tomcat by apache.
the class CatalinaClusterSF method storeChildren.
/**
* Store the specified Cluster children.
*
* @param aWriter
* PrintWriter to which we are storing
* @param indent
* Number of spaces to indent this element
* @param aCluster
* Cluster whose properties are being stored
*
* @exception Exception
* if an exception occurs while storing
*/
@Override
public void storeChildren(PrintWriter aWriter, int indent, Object aCluster, StoreDescription parentDesc) throws Exception {
if (aCluster instanceof CatalinaCluster) {
CatalinaCluster cluster = (CatalinaCluster) aCluster;
if (cluster instanceof SimpleTcpCluster) {
SimpleTcpCluster tcpCluster = (SimpleTcpCluster) cluster;
// Store nested <Manager> element
ClusterManager manager = tcpCluster.getManagerTemplate();
if (manager != null) {
storeElement(aWriter, indent, manager);
}
}
// Store nested <Channel> element
Channel channel = cluster.getChannel();
if (channel != null) {
storeElement(aWriter, indent, channel);
}
// Store nested <Deployer> element
ClusterDeployer deployer = cluster.getClusterDeployer();
if (deployer != null) {
storeElement(aWriter, indent, deployer);
}
// Store nested <Valve> element
// ClusterValve are not store at Hosts element, see
Valve[] valves = cluster.getValves();
storeElementArray(aWriter, indent, valves);
if (aCluster instanceof SimpleTcpCluster) {
// Store nested <Listener> elements
LifecycleListener[] listeners = ((SimpleTcpCluster) cluster).findLifecycleListeners();
storeElementArray(aWriter, indent, listeners);
// Store nested <ClusterListener> elements
ClusterListener[] mlisteners = ((SimpleTcpCluster) cluster).findClusterListeners();
List<ClusterListener> clusterListeners = new ArrayList<>();
for (ClusterListener clusterListener : mlisteners) {
if (clusterListener != deployer) {
clusterListeners.add(clusterListener);
}
}
storeElementArray(aWriter, indent, clusterListeners.toArray());
}
}
}
Aggregations