public class SimpleTcpCluster extends LifecycleMBeanBase implements CatalinaCluster, LifecycleListener, IDynamicProperty, MembershipListener, ChannelListener
Lifecycle.SingleUse
Modifier and Type | Field and Description |
---|---|
static String |
AFTER_MANAGERREGISTER_EVENT |
static String |
AFTER_MANAGERUNREGISTER_EVENT |
static String |
AFTER_MEMBERREGISTER_EVENT |
static String |
AFTER_MEMBERUNREGISTER_EVENT |
static String |
BEFORE_MANAGERREGISTER_EVENT |
static String |
BEFORE_MANAGERUNREGISTER_EVENT |
static String |
BEFORE_MEMBERREGISTER_EVENT |
static String |
BEFORE_MEMBERUNREGISTER_EVENT |
protected Channel |
channel
Group channel.
|
protected String |
clusterImpName
Name for logging purpose
|
protected List<ClusterListener> |
clusterListeners
Listeners of messages
|
protected String |
clusterName
The cluster name to join
|
protected Container |
container
The Container associated with this Cluster.
|
protected boolean |
hasMembers
has members
|
protected boolean |
heartbeatBackgroundEnabled
call Channel.heartbeat() at container background thread
|
protected static String |
info
Descriptive information about this component implementation.
|
static Log |
log |
protected Map<String,ClusterManager> |
managers
The context name <-> manager association for distributed contexts.
|
protected ClusterManager |
managerTemplate |
static String |
RECEIVE_MESSAGE_FAILURE_EVENT |
static String |
SEND_MESSAGE_FAILURE_EVENT |
protected static StringManager |
sm
The string manager for this package.
|
protected PropertyChangeSupport |
support
The property change support for this component.
|
mserver
AFTER_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 and Description |
---|
SimpleTcpCluster() |
Modifier and Type | Method and Description |
---|---|
boolean |
accept(Serializable msg,
Member sender)
notify all listeners from receiving a new message is not ClusterMessage
emit Failure Event to LifecycleListener
|
void |
addClusterListener(ClusterListener listener)
Add cluster message listener and register cluster to this listener.
|
void |
addValve(Valve valve)
Add cluster valve
Cluster Valves are only add to container when cluster is started!
|
void |
backgroundProcess()
Execute a periodic task, such as reloading, etc.
|
protected void |
checkDefaults() |
Manager |
createManager(String name)
Create new Manager without add to cluster (comes with start the manager)
|
protected void |
destroyInternal()
Sub-classes wishing to perform additional clean-up should override this
method, ensuring that super.destroyInternal() is the last call in the
overriding method.
|
ClusterListener[] |
findClusterListeners()
Get the cluster listeners associated with this cluster.
|
Channel |
getChannel() |
int |
getChannelSendOptions() |
int |
getChannelStartOptions() |
ClusterDeployer |
getClusterDeployer() |
String |
getClusterName()
Return the name of the cluster that this Server is currently configured
to operate within.
|
Container |
getContainer()
Get the Container associated with our Cluster
|
protected String |
getDomainInternal()
Method implemented by sub-classes to identify the domain in which MBeans
should be registered.
|
String |
getInfo()
Return descriptive information about this Cluster implementation and the
corresponding version number, in the format
<description>/<version> . |
Member |
getLocalMember()
Return the member that represents this node.
|
Log |
getLogger()
Returns the associates logger with this cluster.
|
Manager |
getManager(String name) |
String |
getManagerName(String name,
Manager manager) |
Map<String,ClusterManager> |
getManagers() |
ClusterManager |
getManagerTemplate() |
Member[] |
getMembers()
Get all current cluster members
|
protected String |
getObjectNameKeyProperties()
Allow sub-classes to specify the key properties component of the
ObjectName that will be used to register this component. |
Object |
getProperty(String key)
Deprecated.
Unused - will be removed in Tomcat 8.0.x
|
Iterator<String> |
getPropertyNames()
Deprecated.
Unused - will be removed in Tomcat 8.0.x
|
String |
getProtocol()
Get the protocol used by the cluster.
|
Valve[] |
getValves()
get all cluster valves
|
boolean |
hasMembers()
Returns that cluster has members.
|
protected void |
initInternal()
Sub-classes wishing to perform additional initialization should override
this method, ensuring that super.initInternal() is the first call in the
overriding method.
|
boolean |
isHeartbeatBackgroundEnabled()
Return heartbeat enable flag (default false)
|
boolean |
isNotifyLifecycleListenerOnFailure() |
void |
lifecycleEvent(LifecycleEvent lifecycleEvent)
Deprecated.
Unused - will be removed in Tomcat 8.0.x
|
void |
memberAdded(Member member)
New cluster member is registered
|
void |
memberDisappeared(Member member)
Cluster member is gone
|
void |
messageReceived(ClusterMessage message) |
void |
messageReceived(Serializable message,
Member sender)
Receive a message from the channel
|
protected void |
registerClusterValve()
register all cluster valve to host or engine
|
void |
registerManager(Manager manager)
Register a manager with the cluster.
|
void |
removeClusterListener(ClusterListener listener)
Remove message listener and deregister Cluster from listener.
|
void |
removeManager(Manager manager)
Remove an application from cluster replication bus.
|
void |
removeProperty(String key)
Deprecated.
Unused - will be removed in Tomcat 8.0.x
|
void |
send(ClusterMessage msg)
send message to all cluster members
|
void |
send(ClusterMessage msg,
Member dest)
send a cluster message to one member
|
void |
setChannel(Channel channel) |
void |
setChannelSendOptions(int channelSendOptions) |
void |
setChannelStartOptions(int channelStartOptions) |
void |
setClusterDeployer(ClusterDeployer clusterDeployer)
set a new Deployer, must be set before cluster started!
|
void |
setClusterName(String clusterName)
Set the name of the cluster to join, if no cluster with this name is
present create one.
|
void |
setContainer(Container container)
Set the Container associated with our Cluster
|
void |
setHeartbeatBackgroundEnabled(boolean heartbeatBackgroundEnabled)
enabled that container backgroundThread call heartbeat at channel
|
void |
setManagerTemplate(ClusterManager managerTemplate) |
void |
setNotifyLifecycleListenerOnFailure(boolean notifyListenerOnFailure) |
boolean |
setProperty(String name,
Object value)
Deprecated.
Unused - will be removed in Tomcat 8.0.x
|
boolean |
setProperty(String name,
String value)
Deprecated.
Unused - will be removed in Tomcat 8.0.x
|
void |
setProtocol(String protocol)
Set the protocol parameters.
|
protected void |
startInternal()
Start Cluster and implement the requirements
of
LifecycleBase.startInternal() . |
protected void |
stopInternal()
Stop Cluster and implement the requirements
of
LifecycleBase.stopInternal() . |
String |
toString()
Return a String rendering of this object.
|
protected void |
transferProperty(String prefix,
Object bean)
Deprecated.
Unused - will be removed in Tomcat 8.0.x
|
protected void |
unregisterClusterValve()
unregister all cluster valve to host or engine
|
getDomain, getObjectName, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister
addLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, getThrowOnFailure, init, removeLifecycleListener, setState, setState, setThrowOnFailure, start, stop
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
start, stop
equals, hashCode
public static final Log log
protected static final String info
public static final String BEFORE_MEMBERREGISTER_EVENT
public static final String AFTER_MEMBERREGISTER_EVENT
public static final String BEFORE_MANAGERREGISTER_EVENT
public static final String AFTER_MANAGERREGISTER_EVENT
public static final String BEFORE_MANAGERUNREGISTER_EVENT
public static final String AFTER_MANAGERUNREGISTER_EVENT
public static final String BEFORE_MEMBERUNREGISTER_EVENT
public static final String AFTER_MEMBERUNREGISTER_EVENT
public static final String SEND_MESSAGE_FAILURE_EVENT
public static final String RECEIVE_MESSAGE_FAILURE_EVENT
protected Channel channel
protected String clusterImpName
protected static final StringManager sm
protected String clusterName
protected boolean heartbeatBackgroundEnabled
GroupChannel.heartbeat()
protected Container container
protected PropertyChangeSupport support
protected Map<String,ClusterManager> managers
protected ClusterManager managerTemplate
protected List<ClusterListener> clusterListeners
protected boolean hasMembers
public String getInfo()
<description>/<version>
.public boolean isHeartbeatBackgroundEnabled()
public void setHeartbeatBackgroundEnabled(boolean heartbeatBackgroundEnabled)
heartbeatBackgroundEnabled
- the heartbeatBackgroundEnabled to setpublic void setClusterName(String clusterName)
setClusterName
in interface Cluster
clusterName
- The clustername to joinpublic String getClusterName()
getClusterName
in interface Cluster
public void setContainer(Container container)
setContainer
in interface Cluster
container
- The Container to usepublic Container getContainer()
getContainer
in interface Cluster
public boolean isNotifyLifecycleListenerOnFailure()
public void setNotifyLifecycleListenerOnFailure(boolean notifyListenerOnFailure)
notifyListenerOnFailure
- The notifyLifecycleListenerOnFailure to set.public void addValve(Valve valve)
addValve
in interface CatalinaCluster
valve
- The new cluster Valve.public Valve[] getValves()
getValves
in interface CatalinaCluster
public ClusterListener[] findClusterListeners()
public void addClusterListener(ClusterListener listener)
addClusterListener
in interface CatalinaCluster
listener
- The new listenerCatalinaCluster.addClusterListener(org.apache.catalina.ha.ClusterListener)
public void removeClusterListener(ClusterListener listener)
removeClusterListener
in interface CatalinaCluster
listener
- The listener to removeCatalinaCluster.removeClusterListener(org.apache.catalina.ha.ClusterListener)
public ClusterDeployer getClusterDeployer()
getClusterDeployer
in interface CatalinaCluster
public void setClusterDeployer(ClusterDeployer clusterDeployer)
setClusterDeployer
in interface CatalinaCluster
clusterDeployer
- The associated deployerpublic void setChannel(Channel channel)
setChannel
in interface CatalinaCluster
public void setManagerTemplate(ClusterManager managerTemplate)
public void setChannelSendOptions(int channelSendOptions)
public boolean hasMembers()
CatalinaCluster
hasMembers
in interface CatalinaCluster
public Member[] getMembers()
getMembers
in interface CatalinaCluster
public Member getLocalMember()
getLocalMember
in interface CatalinaCluster
@Deprecated public boolean setProperty(String name, String value)
name
- value
- @Deprecated public boolean setProperty(String name, Object value)
setProperty
in interface IDynamicProperty
name
- value
- @Deprecated public Object getProperty(String key)
getProperty
in interface IDynamicProperty
key
- @Deprecated public Iterator<String> getPropertyNames()
getPropertyNames
in interface IDynamicProperty
@Deprecated public void removeProperty(String key)
removeProperty
in interface IDynamicProperty
key
- @Deprecated protected void transferProperty(String prefix, Object bean)
prefix
- bean
- public Map<String,ClusterManager> getManagers()
getManagers
in interface CatalinaCluster
public Channel getChannel()
getChannel
in interface CatalinaCluster
public ClusterManager getManagerTemplate()
public int getChannelSendOptions()
public Manager createManager(String name)
createManager
in interface Cluster
name
- Context Name of this managerCluster.createManager(java.lang.String)
,
LifecycleBase.start()
public void registerManager(Manager manager)
Cluster
registerManager
in interface Cluster
manager
- Managerpublic void removeManager(Manager manager)
removeManager
in interface Cluster
manager
- The managerCluster.removeManager(Manager)
public String getManagerName(String name, Manager manager)
getManagerName
in interface CatalinaCluster
public Manager getManager(String name)
getManager
in interface CatalinaCluster
public void backgroundProcess()
backgroundProcess
in interface Cluster
FarmWarDeployer.backgroundProcess()
,
GroupChannel.heartbeat()
,
GroupChannel.HeartbeatThread.run()
@Deprecated public void lifecycleEvent(LifecycleEvent lifecycleEvent)
lifecycleEvent
in interface LifecycleListener
lifecycleEvent
- LifecycleEvent that has occurredLifecycleListener.lifecycleEvent(org.apache.catalina.LifecycleEvent)
protected void initInternal() throws LifecycleException
LifecycleMBeanBase
initInternal
in class LifecycleMBeanBase
LifecycleException
- If the initialisation failsprotected void startInternal() throws LifecycleException
LifecycleBase.startInternal()
.startInternal
in class LifecycleBase
LifecycleException
- if this component detects a fatal error
that prevents this component from being usedprotected void checkDefaults()
protected void registerClusterValve()
protected void unregisterClusterValve()
protected void stopInternal() throws LifecycleException
LifecycleBase.stopInternal()
.stopInternal
in class LifecycleBase
LifecycleException
- if this component detects a fatal error
that prevents this component from being usedprotected void destroyInternal() throws LifecycleException
LifecycleMBeanBase
destroyInternal
in class LifecycleMBeanBase
LifecycleException
- If the destruction failspublic String toString()
public void send(ClusterMessage msg)
send
in interface CatalinaCluster
msg
- message to transferCatalinaCluster.send(org.apache.catalina.ha.ClusterMessage)
public void send(ClusterMessage msg, Member dest)
send
in interface CatalinaCluster
msg
- message to transferdest
- Receiver memberCatalinaCluster.send(org.apache.catalina.ha.ClusterMessage,
org.apache.catalina.tribes.Member)
public void memberAdded(Member member)
memberAdded
in interface MembershipListener
member
- Member - the member that was addedMembershipListener.memberAdded(org.apache.catalina.tribes.Member)
public void memberDisappeared(Member member)
memberDisappeared
in interface MembershipListener
member
- MemberMembershipListener.memberDisappeared(org.apache.catalina.tribes.Member)
public boolean accept(Serializable msg, Member sender)
accept
in interface ChannelListener
msg
- received Messagesender
- Memberpublic void messageReceived(Serializable message, Member sender)
ChannelListener
messageReceived
in interface ChannelListener
message
- Serializablesender
- - the source of the messagepublic void messageReceived(ClusterMessage message)
public Log getLogger()
CatalinaCluster
getLogger
in interface CatalinaCluster
public void setProtocol(String protocol)
Cluster
setProtocol
in interface Cluster
protocol
- The protocol used by the clusterCluster.setProtocol(java.lang.String)
public String getProtocol()
Cluster
getProtocol
in interface Cluster
Cluster.getProtocol()
public int getChannelStartOptions()
public void setChannelStartOptions(int channelStartOptions)
protected String getDomainInternal()
LifecycleMBeanBase
getDomainInternal
in class LifecycleMBeanBase
protected String getObjectNameKeyProperties()
LifecycleMBeanBase
ObjectName
that will be used to register this component.getObjectNameKeyProperties
in class LifecycleMBeanBase
ObjectName
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.