Package org.apache.catalina.ha.tcp
Class SimpleTcpCluster
java.lang.Object
org.apache.catalina.util.LifecycleBase
org.apache.catalina.util.LifecycleMBeanBase
org.apache.catalina.ha.tcp.SimpleTcpCluster
- All Implemented Interfaces:
- MBeanRegistration,- Cluster,- Contained,- CatalinaCluster,- JmxEnabled,- Lifecycle,- ChannelListener,- MembershipListener
public class SimpleTcpCluster
extends LifecycleMBeanBase
implements CatalinaCluster, MembershipListener, ChannelListener
A Cluster  implementation using simple multicast. Responsible for setting up a cluster and provides callers
 with a valid multicast receiver/sender.
- Author:
- Remy Maucherat, Peter Rossbach
- 
Nested Class SummaryNested classes/interfaces inherited from interface org.apache.catalina.LifecycleLifecycle.SingleUse
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected ChannelGroup channel.protected final List<ClusterListener>Listeners of messagesprotected StringThe cluster name to joinprotected ContainerThe Container associated with this Cluster.protected booleanhas membersprotected booleancall Channel.heartbeat() at container background threadstatic final Logprotected final Map<String,ClusterManager> The context name <-> manager association for distributed contexts.protected ClusterManagerstatic final Stringstatic final Stringprotected static final StringManagerThe string manager for this package.protected final PropertyChangeSupportThe property change support for this component.Fields inherited from class org.apache.catalina.util.LifecycleMBeanBasemserverFields inherited from interface org.apache.catalina.LifecycleAFTER_DESTROY_EVENT, AFTER_INIT_EVENT, AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_DESTROY_EVENT, BEFORE_INIT_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, CONFIGURE_START_EVENT, CONFIGURE_STOP_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionbooleanaccept(Serializable msg, Member sender) notify all listeners from receiving a new message is not ClusterMessage emit Failure Event to LifecycleListenervoidaddClusterListener(ClusterListener listener) Add cluster message listener and register cluster to this listener.voidAdd cluster valve.voidExecute a periodic task, such as reloading, etc.protected voidcreateManager(String name) Create a new manager which will use this cluster to replicate its sessions.protected voidSub-classes implement this method to perform any instance destruction required.Get the cluster listeners associated with this cluster.intreturns the SendOptions as a comma separated list of names for use by JMXintReturn the name of the cluster that this Server is currently configured to operate within.Get theContainerwith which this instance is associated.protected StringMethod implemented by sub-classes to identify the domain in which MBeans should be registered.getManager(String name) Get ManagergetManagerName(String name, Manager manager) Get a new cluster name for a manager.Member[]protected StringAllow sub-classes to specify the key properties component of theObjectNamethat will be used to register this component.Valve[]booleanprotected voidSub-classes implement this method to perform any instance initialisation required.booleanReturn heartbeat enable flag (default false)booleanvoidmemberAdded(Member member) A member was added to the groupvoidmemberDisappeared(Member member) A member was removed from the group
 If the member left voluntarily, the Member.getCommand will contain the Member.SHUTDOWN_PAYLOAD datavoidmessageReceived(Serializable message, Member sender) Receive a message from the channelvoidmessageReceived(ClusterMessage message) protected voidregister all cluster valve to host or enginevoidregisterManager(Manager manager) Register a manager with the cluster.voidremoveClusterListener(ClusterListener listener) Remove message listener and deregister Cluster from listener.voidremoveManager(Manager manager) Removes a manager from the clustervoidsend(ClusterMessage msg) Sends a message to all the members in the clustervoidsend(ClusterMessage msg, Member dest) Sends a message to a specific member in the cluster.voidsend(ClusterMessage msg, Member dest, int sendOptions) Sends a message with the specified sendOptions to a specific member in the cluster.voidsetChannel(Channel channel) Set the channel associated with the cluster.voidsetChannelSendOptions(int channelSendOptions) voidsetChannelSendOptions(String channelSendOptions) voidsetChannelStartOptions(int channelStartOptions) voidsetClusterDeployer(ClusterDeployer clusterDeployer) Set a new Deployer, must be set before the cluster started.voidsetClusterName(String clusterName) Set the name of the cluster to join, if no cluster with this name is present create one.voidsetContainer(Container container) Set theContainerwith which this instance is associated.voidsetHeartbeatBackgroundEnabled(boolean heartbeatBackgroundEnabled) enabled that container backgroundThread call heartbeat at channelvoidsetManagerTemplate(ClusterManager managerTemplate) voidsetNotifyLifecycleListenerOnFailure(boolean notifyListenerOnFailure) protected voidStart Cluster and implement the requirements ofLifecycleBase.startInternal().protected voidStop Cluster and implement the requirements ofLifecycleBase.stopInternal().toString()protected voidunregister all cluster valve to host or engineMethods inherited from class org.apache.catalina.util.LifecycleMBeanBasegetDomain, getObjectName, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister, unregisterMethods inherited from class org.apache.catalina.util.LifecycleBaseaddLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, getThrowOnFailure, init, removeLifecycleListener, setState, setState, setThrowOnFailure, start, stop
- 
Field Details- 
log
- 
BEFORE_MEMBERREGISTER_EVENT- See Also:
 
- 
AFTER_MEMBERREGISTER_EVENT- See Also:
 
- 
BEFORE_MANAGERREGISTER_EVENT- See Also:
 
- 
AFTER_MANAGERREGISTER_EVENT- See Also:
 
- 
BEFORE_MANAGERUNREGISTER_EVENT- See Also:
 
- 
AFTER_MANAGERUNREGISTER_EVENT- See Also:
 
- 
BEFORE_MEMBERUNREGISTER_EVENT- See Also:
 
- 
AFTER_MEMBERUNREGISTER_EVENT- See Also:
 
- 
SEND_MESSAGE_FAILURE_EVENT- See Also:
 
- 
RECEIVE_MESSAGE_FAILURE_EVENT- See Also:
 
- 
channelGroup channel.
- 
smThe string manager for this package.
- 
clusterNameThe cluster name to join
- 
heartbeatBackgroundEnabledprotected boolean heartbeatBackgroundEnabledcall Channel.heartbeat() at container background thread- See Also:
 
- 
containerThe Container associated with this Cluster.
- 
supportThe property change support for this component.
- 
managersThe context name <-> manager association for distributed contexts.
- 
managerTemplate
- 
clusterListenersListeners of messages
- 
hasMembersprotected boolean hasMembershas members
 
- 
- 
Constructor Details- 
SimpleTcpClusterpublic SimpleTcpCluster()
 
- 
- 
Method Details- 
isHeartbeatBackgroundEnabledpublic boolean isHeartbeatBackgroundEnabled()Return heartbeat enable flag (default false)- Returns:
- the heartbeatBackgroundEnabled
 
- 
setHeartbeatBackgroundEnabledpublic void setHeartbeatBackgroundEnabled(boolean heartbeatBackgroundEnabled) enabled that container backgroundThread call heartbeat at channel- Parameters:
- heartbeatBackgroundEnabled- the heartbeatBackgroundEnabled to set
 
- 
setClusterNameDescription copied from interface:ClusterSet the name of the cluster to join, if no cluster with this name is present create one.- Specified by:
- setClusterNamein interface- Cluster
- Parameters:
- clusterName- The clustername to join
 
- 
getClusterNameDescription copied from interface:ClusterReturn the name of the cluster that this Server is currently configured to operate within.- Specified by:
- getClusterNamein interface- Cluster
- Returns:
- The name of the cluster associated with this server
 
- 
setContainerDescription copied from interface:ContainedSet theContainerwith which this instance is associated.- Specified by:
- setContainerin interface- Contained
- Parameters:
- container- The Container instance with which this instance is to be associated, or- nullto disassociate this instance from any Container
 
- 
getContainerDescription copied from interface:ContainedGet theContainerwith which this instance is associated.- Specified by:
- getContainerin interface- Contained
- Returns:
- The Container with which this instance is associated or nullif not associated with a Container
 
- 
isNotifyLifecycleListenerOnFailurepublic boolean isNotifyLifecycleListenerOnFailure()- Returns:
- Returns the notifyLifecycleListenerOnFailure.
 
- 
setNotifyLifecycleListenerOnFailurepublic void setNotifyLifecycleListenerOnFailure(boolean notifyListenerOnFailure) - Parameters:
- notifyListenerOnFailure- The notifyLifecycleListenerOnFailure to set.
 
- 
addValveDescription copied from interface:CatalinaClusterAdd cluster valve. Cluster Valves are only add to container when cluster is started.- Specified by:
- addValvein interface- CatalinaCluster
- Parameters:
- valve- The new cluster Valve.
 
- 
getValves- Specified by:
- getValvesin interface- CatalinaCluster
- Returns:
- the current cluster valves
 
- 
findClusterListenersGet the cluster listeners associated with this cluster. If this Array has no listeners registered, a zero-length array is returned.- Returns:
- the listener array
 
- 
addClusterListenerDescription copied from interface:CatalinaClusterAdd cluster message listener and register cluster to this listener.- Specified by:
- addClusterListenerin interface- CatalinaCluster
- Parameters:
- listener- The new listener
 
- 
removeClusterListenerDescription copied from interface:CatalinaClusterRemove message listener and deregister Cluster from listener.- Specified by:
- removeClusterListenerin interface- CatalinaCluster
- Parameters:
- listener- The listener to remove
 
- 
getClusterDeployer- Specified by:
- getClusterDeployerin interface- CatalinaCluster
- Returns:
- the current Deployer
 
- 
setClusterDeployerDescription copied from interface:CatalinaClusterSet a new Deployer, must be set before the cluster started.- Specified by:
- setClusterDeployerin interface- CatalinaCluster
- Parameters:
- clusterDeployer- The associated deployer
 
- 
setChannelDescription copied from interface:CatalinaClusterSet the channel associated with the cluster.- Specified by:
- setChannelin interface- CatalinaCluster
- Parameters:
- channel- the channel
 
- 
setManagerTemplate
- 
setChannelSendOptionspublic void setChannelSendOptions(int channelSendOptions) 
- 
setChannelSendOptions
- 
hasMemberspublic boolean hasMembers()- Specified by:
- hasMembersin interface- CatalinaCluster
- Returns:
- trueif the cluster has members.
 
- 
getMembers- Specified by:
- getMembersin interface- CatalinaCluster
- Returns:
- an array containing all the members currently participating in the cluster.
 
- 
getLocalMember- Specified by:
- getLocalMemberin interface- CatalinaCluster
- Returns:
- the member that represents this node.
 
- 
getManagers- Specified by:
- getManagersin interface- CatalinaCluster
- Returns:
- The map of managers
 
- 
getChannel- Specified by:
- getChannelin interface- CatalinaCluster
- Returns:
- the channel associated with the cluster
 
- 
getManagerTemplate
- 
getChannelSendOptionspublic int getChannelSendOptions()
- 
getChannelSendOptionsNamereturns the SendOptions as a comma separated list of names for use by JMX- Returns:
- a comma separated list of the option names
 
- 
createManagerDescription copied from interface:ClusterCreate a new manager which will use this cluster to replicate its sessions.- Specified by:
- createManagerin interface- Cluster
- Parameters:
- name- Name (key) of the application with which the manager is associated
- Returns:
- The newly created Manager instance
 
- 
registerManagerDescription copied from interface:ClusterRegister a manager with the cluster. If the cluster is not responsible for creating a manager, then the container will at least notify the cluster that this manager is participating in the cluster.- Specified by:
- registerManagerin interface- Cluster
- Parameters:
- manager- Manager
 
- 
removeManagerDescription copied from interface:ClusterRemoves a manager from the cluster- Specified by:
- removeManagerin interface- Cluster
- Parameters:
- manager- Manager
 
- 
getManagerNameDescription copied from interface:CatalinaClusterGet a new cluster name for a manager.- Specified by:
- getManagerNamein interface- CatalinaCluster
- Parameters:
- name- Override name (optional)
- manager- The manager
- Returns:
- the manager name in the cluster
 
- 
getManagerDescription copied from interface:CatalinaClusterGet Manager- Specified by:
- getManagerin interface- CatalinaCluster
- Parameters:
- name- The manager name
- Returns:
- The manager
 
- 
backgroundProcesspublic void backgroundProcess()Description copied from interface:ClusterExecute a periodic task, such as reloading, etc. This method will be invoked inside the classloading context of this container. Unexpected throwables will be caught and logged.- Specified by:
- backgroundProcessin interface- Cluster
 
- 
initInternalDescription copied from class:LifecycleBaseSub-classes implement this method to perform any instance initialisation required.- Overrides:
- initInternalin class- LifecycleMBeanBase
- Throws:
- LifecycleException- If the initialisation fails
 
- 
startInternalStart Cluster and implement the requirements ofLifecycleBase.startInternal().- Specified by:
- startInternalin class- LifecycleBase
- Throws:
- LifecycleException- if this component detects a fatal error that prevents this component from being used
 
- 
checkDefaultsprotected void checkDefaults()
- 
registerClusterValveprotected void registerClusterValve()register all cluster valve to host or engine
- 
unregisterClusterValveprotected void unregisterClusterValve()unregister all cluster valve to host or engine
- 
stopInternalStop Cluster and implement the requirements ofLifecycleBase.stopInternal().- Specified by:
- stopInternalin class- LifecycleBase
- Throws:
- LifecycleException- if this component detects a fatal error that prevents this component from being used
 
- 
destroyInternalDescription copied from class:LifecycleBaseSub-classes implement this method to perform any instance destruction required.- Overrides:
- destroyInternalin class- LifecycleMBeanBase
- Throws:
- LifecycleException- If the destruction fails
 
- 
toString
- 
sendDescription copied from interface:CatalinaClusterSends a message to all the members in the cluster- Specified by:
- sendin interface- CatalinaCluster
- Parameters:
- msg- ClusterMessage
 
- 
sendDescription copied from interface:CatalinaClusterSends a message to a specific member in the cluster.- Specified by:
- sendin interface- CatalinaCluster
- Parameters:
- msg- ClusterMessage
- dest- Member
 
- 
sendDescription copied from interface:CatalinaClusterSends a message with the specified sendOptions to a specific member in the cluster.- Specified by:
- sendin interface- CatalinaCluster
- Parameters:
- msg- ClusterMessage
- dest- Member
- sendOptions- sendOptions
 
- 
memberAddedDescription copied from interface:MembershipListenerA member was added to the group- Specified by:
- memberAddedin interface- MembershipListener
- Parameters:
- member- Member - the member that was added
 
- 
memberDisappearedDescription copied from interface:MembershipListenerA member was removed from the group
 If the member left voluntarily, the Member.getCommand will contain the Member.SHUTDOWN_PAYLOAD data- Specified by:
- memberDisappearedin interface- MembershipListener
- Parameters:
- member- Member
- See Also:
 
- 
acceptnotify all listeners from receiving a new message is not ClusterMessage emit Failure Event to LifecycleListener- Specified by:
- acceptin interface- ChannelListener
- Parameters:
- msg- received Message
- sender- Member
- Returns:
- boolean
 
- 
messageReceivedDescription copied from interface:ChannelListenerReceive a message from the channel- Specified by:
- messageReceivedin interface- ChannelListener
- Parameters:
- message- Serializable
- sender- - the source of the message
 
- 
messageReceived
- 
getChannelStartOptionspublic int getChannelStartOptions()
- 
setChannelStartOptionspublic void setChannelStartOptions(int channelStartOptions) 
- 
getDomainInternalDescription copied from class:LifecycleMBeanBaseMethod implemented by sub-classes to identify the domain in which MBeans should be registered.- Specified by:
- getDomainInternalin class- LifecycleMBeanBase
- Returns:
- The name of the domain to use to register MBeans.
 
- 
getObjectNameKeyPropertiesDescription copied from class:LifecycleMBeanBaseAllow sub-classes to specify the key properties component of theObjectNamethat will be used to register this component.- Specified by:
- getObjectNameKeyPropertiesin class- LifecycleMBeanBase
- Returns:
- The string representation of the key properties component of the desired ObjectName
 
 
-