public SimpleTomEETcpCluster(final SimpleTcpCluster from) { clusterListeners.addAll(Arrays.asList(from.findClusterListeners())); setClusterName(from.getClusterName()); setContainer(from.getContainer()); setNotifyLifecycleListenerOnFailure(from.isNotifyLifecycleListenerOnFailure()); setChannelSendOptions(from.getChannelSendOptions()); setChannelStartOptions(from.getChannelStartOptions()); setHeartbeatBackgroundEnabled(from.isHeartbeatBackgroundEnabled()); setChannel(from.getChannel()); getManagers().putAll(from.getManagers()); setManagerTemplate(from.getManagerTemplate()); setClusterDeployer(from.getClusterDeployer()); for (final Valve valve : from.getValves()) { addValve(valve); } }
private Property prepareTomcatClustering(Host host, Property engineConfig) throws ContainerException { Property clusterProp = null; List<Property> clusterProps = engineConfig.getPropertiesWithValue("cluster"); if (clusterProps.size() > 1) { throw new ContainerException("Only one cluster configuration allowed per engine"); } if (UtilValidate.isNotEmpty(clusterProps)) { clusterProp = clusterProps.get(0); GroupChannel channel = new GroupChannel(); channel.setChannelReceiver(prepareChannelReceiver(clusterProp)); channel.setChannelSender(prepareChannelSender(clusterProp)); channel.setMembershipService(prepareChannelMcastService(clusterProp)); SimpleTcpCluster cluster = new SimpleTcpCluster(); cluster.setClusterName(clusterProp.name); cluster.setManagerTemplate(prepareClusterManager(clusterProp)); cluster.setChannel(channel); cluster.addValve(prepareClusterValve(clusterProp)); host.setCluster(cluster); Debug.logInfo("Catalina Cluster [" + cluster.getClusterName() + "] configured for host - " + host.getName(), module); } return clusterProp; }
/** * Start Cluster 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 void startInternal() throws LifecycleException { if (log.isInfoEnabled()) log.info(sm.getString("simpleTcpCluster.start")); try { checkDefaults(); registerClusterValve(); channel.addMembershipListener(this); channel.addChannelListener(this); channel.setName(getClusterName() + "-Channel"); channel.start(channelStartOptions); if (clusterDeployer != null) clusterDeployer.start(); registerMember(channel.getLocalMember(false)); } catch (Exception x) { log.error(sm.getString("simpleTcpCluster.startUnable"), x); throw new LifecycleException(x); } setState(LifecycleState.STARTING); }