private void manageCluster(final Cluster cluster) { if (cluster == null || cluster instanceof SimpleTomEETcpCluster) { return; } Cluster current = cluster; if (cluster instanceof SimpleTcpCluster) { final Container container = cluster.getContainer(); current = new SimpleTomEETcpCluster((SimpleTcpCluster) cluster); container.setCluster(current); } if (current instanceof CatalinaCluster) { final CatalinaCluster haCluster = (CatalinaCluster) current; TomEEClusterListener listener = SystemInstance.get().getComponent(TomEEClusterListener.class); if (listener == null) { listener = new TomEEClusterListener(); SystemInstance.get().setComponent(TomEEClusterListener.class, listener); } haCluster.addClusterListener(listener); // better to be a singleton clusters.add(haCluster); } }
@Override protected void startInternal() throws LifecycleException { super.startInternal(); if (getCluster() == null) { Cluster cluster = getContainer().getCluster(); if (cluster instanceof CatalinaCluster) { setCluster((CatalinaCluster)cluster); } } if (cluster != null) cluster.registerManager(this); }
/** * 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 { if (cluster == null) { Cluster containerCluster = getContainer().getCluster(); if (containerCluster instanceof CatalinaCluster) { setCluster((CatalinaCluster)containerCluster); } else { if (log.isWarnEnabled()) { log.warn(sm.getString("ReplicationValve.nocluster")); } } } super.startInternal(); }
/** * Return the Cluster with which this Container is associated. If there is * no associated Cluster, return the Cluster associated with our parent * Container (if any); otherwise return <code>null</code>. */ @Override public Cluster getCluster() { if (cluster != null) return (cluster); if (parent != null) return (parent.getCluster()); return (null); }
/** * Return the Cluster with which this Container is associated. If there is * no associated Cluster, return the Cluster associated with our parent * Container (if any); otherwise return <code>null</code>. */ public Cluster getCluster() { if (cluster != null) return (cluster); if (parent != null) return (parent.getCluster()); return (null); }
/** * Start this manager * * @exception LifecycleException if an error occurs */ public void start() throws LifecycleException { Container container = getContainer(); Cluster cluster = null; if(container != null) cluster = container.getCluster(); if(cluster != null) { this.clusterSender = cluster.getClusterSender(getName()); this.clusterReceiver = cluster.getClusterReceiver(getName()); } super.start(); }
@Override protected void startInternal() throws LifecycleException { super.startInternal(); if (getCluster() == null) { Cluster cluster = getContainer().getCluster(); if (cluster instanceof CatalinaCluster) { setCluster((CatalinaCluster) cluster); } } if (cluster != null) cluster.registerManager(this); }
/** * 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 { if (cluster == null) { Cluster containerCluster = getContainer().getCluster(); if (containerCluster instanceof CatalinaCluster) { setCluster((CatalinaCluster) containerCluster); } else { if (log.isWarnEnabled()) { log.warn(sm.getString("ReplicationValve.nocluster")); } } } super.startInternal(); }
/** * Start this component and implement the requirements * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}. * * Starts the cluster communication channel, this will connect with the * other nodes in the cluster, and request the current session state to be * transferred to this node. * * @exception LifecycleException if this component detects a fatal error * that prevents this component from being used */ @SuppressWarnings("unchecked") @Override protected synchronized void startInternal() throws LifecycleException { super.startInternal(); try { if (getCluster() == null) { Cluster cluster = getContainer().getCluster(); if (cluster instanceof CatalinaCluster) { setCluster((CatalinaCluster)cluster); } else { throw new LifecycleException( sm.getString("backupManager.noCluster", getName())); } } cluster.registerManager(this); LazyReplicatedMap map = new LazyReplicatedMap(this, cluster.getChannel(), rpcTimeout, getMapName(), getClassLoaders(), terminateOnStartFailure); map.setChannelSendOptions(mapSendOptions); this.sessions = map; } catch ( Exception x ) { log.error(sm.getString("backupManager.startUnable", getName()),x); throw new LifecycleException(sm.getString("backupManager.startFailed", getName()),x); } setState(LifecycleState.STARTING); }
@Override @SuppressWarnings("unchecked") public final T setCluster(Cluster cluster) { LOGGER.log(Level.FINE, "setCluster({0})", cluster.getClass().getName()); cluster.setContainer(getContainer()); container.setCluster(cluster); return (T) this; }
@Override public Cluster getCluster() { return null; }
@Override public void setCluster(Cluster cluster) { /* NO-OP */ }
@Override public void setCluster(Cluster cluster) { // NO-OP }
/** * 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(); // Load unloaded sessions, if any try { //the channel is already running Cluster cluster = getCluster() ; // stop remove cluster binding if(cluster == null) { Container context = getContainer(); if (context != null) { cluster = context.getCluster(); if(cluster instanceof CatalinaCluster) { setCluster((CatalinaCluster) cluster); } else { cluster = null; } } } if (cluster == null) { log.error(sm.getString("deltaManager.noCluster", getName())); return; } else { if (log.isInfoEnabled()) { String type = "unknown" ; if( cluster.getContainer() instanceof Host){ type = "Host" ; } else if( cluster.getContainer() instanceof Engine){ type = "Engine" ; } log.info(sm.getString("deltaManager.registerCluster", getName(), type, cluster.getClusterName())); } } if (log.isInfoEnabled()) log.info(sm.getString("deltaManager.startClustering", getName())); //to survice context reloads, as only a stop/start is called, not // createManager cluster.registerManager(this); getAllClusterSessions(); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); log.error(sm.getString("deltaManager.managerLoad"), t); } setState(LifecycleState.STARTING); }