|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.catalina.cluster.tcp.SimpleTcpCluster
A Cluster implementation using simple multicast. Responsible for setting up a cluster and provides callers with a valid multicast receiver/sender. FIXME remove install/remove/start/stop context dummys FIXME wrote testcases
Field Summary | |
static java.lang.String |
AFTER_MANAGERREGISTER_EVENT
|
static java.lang.String |
AFTER_MANAGERUNREGISTER_EVENT
|
static java.lang.String |
AFTER_MEMBERREGISTER_EVENT
|
static java.lang.String |
AFTER_MEMBERUNREGISTER_EVENT
|
static java.lang.String |
BEFORE_MANAGERREGISTER_EVENT
|
static java.lang.String |
BEFORE_MANAGERUNREGISTER_EVENT
|
static java.lang.String |
BEFORE_MEMBERREGISTER_EVENT
|
static java.lang.String |
BEFORE_MEMBERUNREGISTER_EVENT
|
protected java.lang.String |
clusterImpName
Name for logging purpose |
protected java.util.List |
clusterListeners
Listeners of messages |
protected java.lang.String |
clusterName
The cluster name to join |
protected Container |
container
The Container associated with this Cluster. |
protected static java.lang.String |
info
Descriptive information about this component implementation. |
protected LifecycleSupport |
lifecycle
The lifecycle event support for this component. |
static org.apache.commons.logging.Log |
log
|
protected java.util.Map |
managers
The context name <->manager association for distributed contexts. |
protected MembershipService |
membershipService
the service that provides the membership |
static java.lang.String |
RECEIVE_MESSAGE_FAILURE_EVENT
|
static java.lang.String |
SEND_MESSAGE_FAILURE_EVENT
|
protected StringManager |
sm
The string manager for this package. |
protected boolean |
started
Has this component been started? |
protected java.beans.PropertyChangeSupport |
support
The property change support for this component. |
Fields inherited from interface org.apache.catalina.Lifecycle |
AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, DESTROY_EVENT, INIT_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT |
Constructor Summary | |
SimpleTcpCluster()
|
Method Summary | |
void |
addClusterListener(MessageListener listener)
add cluster message listener and register cluster to this listener |
void |
addLifecycleListener(LifecycleListener listener)
Add a lifecycle event listener to this component. |
void |
addManager(java.lang.String name,
Manager manager)
add an application to cluster replication bus |
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 |
createDefaultClusterListener()
Create default session cluster listener: <ClusterListener className="org.apache.catalina.cluster.session.ClusterSessionListener" /> |
protected void |
createDefaultClusterReceiver()
Create default receiver: <Receiver className="org.apache.catalina.cluster.tcp.SocketReplicationListener" tcpListenAddress="auto" tcpListenPort="8015" tcpListenMaxPort="8019" doReceivedProcessingStats="true" /> |
protected void |
createDefaultClusterSender()
Create default cluster sender <Sender className="org.apache.catalina.cluster.tcp.ReplicationTransmitter" replicationMode="fastasyncqueue" doTransmitterProcessingStats="true" doProcessingStats="true"/> |
protected void |
createDefaultClusterValves()
Create default ReplicationValve <Valve className="org.apache.catalina.cluster.tcp.ReplicationValve" filter=".*\.gif;.*\.js;.*\.css;.*\.png;.*\.jpeg;.*\.jpg;.*\.htm;.*\.html;.*\.txt;" primaryIndicator="true" /> |
protected void |
createDefaultMembershipService()
Create default membership service: <Membership className="org.apache.catalina.cluster.mcast.McastService" mcastAddr="228.0.0.4" mcastPort="8012" mcastFrequency="1000" mcastDropTime="30000"/> |
Manager |
createManager(java.lang.String name)
Create new Manager without add to cluster (comes with start the manager) |
MessageListener[] |
findClusterListeners()
Get the cluster listeners associated with this cluster. |
LifecycleListener[] |
findLifecycleListeners()
Get the lifecycle listeners associated with this lifecycle. |
ClusterDeployer |
getClusterDeployer()
get current Deployer |
org.apache.commons.logging.Log |
getClusterLog()
|
java.lang.String |
getClusterLogName()
|
java.lang.String |
getClusterName()
Return the name of the cluster that this Server is currently configured to operate within. |
ClusterReceiver |
getClusterReceiver()
|
ClusterSender |
getClusterSender()
|
Container |
getContainer()
Get the Container associated with our Cluster |
java.lang.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. |
org.apache.commons.logging.Log |
getLogger()
Returns the associates logger with this cluster. |
javax.management.modelmbean.ModelMBean |
getManagedBean(java.lang.Object object)
Returns the ModelMBean |
Manager |
getManager(java.lang.String name)
|
java.lang.String |
getManagerClassName()
|
java.lang.String |
getManagerName(java.lang.String name,
Manager manager)
Returns the name for the cluster manager. |
java.util.Map |
getManagers()
|
javax.management.MBeanServer |
getMBeanServer()
Get current Catalina MBean Server and load mbean registry |
Member[] |
getMembers()
Get all current cluster members |
MembershipService |
getMembershipService()
|
javax.management.ObjectName |
getObjectName()
|
java.lang.Object |
getProperty(java.lang.String key)
get current config |
java.util.Iterator |
getPropertyNames()
Get all properties keys |
java.lang.String |
getProtocol()
Get the protocol used by the cluster. |
Valve[] |
getValves()
get all cluster valves |
boolean |
hasMembers()
has members |
void |
installContext(java.lang.String contextPath,
java.net.URL war)
Install a new web application, whose web application archive is at the specified URL, into this container with the specified context path. |
boolean |
isDefaultMode()
|
boolean |
isDoClusterLog()
|
boolean |
isNotifyLifecycleListenerOnFailure()
|
void |
lifecycleEvent(LifecycleEvent lifecycleEvent)
Use as base to handle start/stop/periodic Events from host. |
protected void |
logReceiveMessage(ClusterMessage message,
long start,
boolean accepted)
log received message to cluster transfer log |
protected void |
logSendMessage(ClusterMessage message,
long start,
Member dest)
log sended message to cluster transfer log |
void |
memberAdded(Member member)
New cluster member is registered |
void |
memberDisappeared(Member member)
Cluster member is gone |
void |
receive(ClusterMessage message)
notify all listeners from receiving a new message is not ClusterMessage emitt Failure Event to LifecylceListener |
protected void |
registerClusterValve()
register all cluster valve to host or engine |
protected void |
registerMBeans()
register Means at cluster. |
void |
removeClusterListener(MessageListener listener)
remove message listener and deregister Cluster from listener |
void |
removeLifecycleListener(LifecycleListener listener)
Remove a lifecycle event listener from this component. |
void |
removeManager(java.lang.String name,
Manager manager)
remove an application form cluster replication bus |
void |
removeProperty(java.lang.String key)
remove a configured property. |
void |
send(ClusterMessage msg)
send message to all cluster members |
void |
send(ClusterMessage msg,
Member dest)
send a cluster message to one member |
void |
sendClusterDomain(ClusterMessage msg)
send message to all cluster members same cluster domain |
void |
sendToMember(ClusterMessage msg,
java.lang.String dest)
send a cluster message to one member (very usefull JMX method for remote scripting) |
void |
setClusterDeployer(ClusterDeployer clusterDeployer)
set a new Deployer, must be set before cluster started! |
void |
setClusterLogName(java.lang.String clusterLogName)
|
void |
setClusterName(java.lang.String clusterName)
Set the name of the cluster to join, if no cluster with this name is present create one. |
void |
setClusterReceiver(ClusterReceiver clusterReceiver)
|
void |
setClusterSender(ClusterSender clusterSender)
|
void |
setContainer(Container container)
Set the Container associated with our Cluster |
void |
setDefaultMode(boolean defaultMode)
|
void |
setDoClusterLog(boolean doClusterLog)
|
void |
setManagerClassName(java.lang.String managerClassName)
|
void |
setMembershipService(MembershipService membershipService)
|
void |
setNotifyLifecycleListenerOnFailure(boolean notifyListenerOnFailure)
|
void |
setObjectName(javax.management.ObjectName name)
|
void |
setProperty(java.lang.String name,
java.lang.Object value)
set config attributes with reflect and propagate to all managers |
void |
setProperty(java.lang.String name,
java.lang.String value)
JMX hack to direct use at jconsole |
void |
setProtocol(java.lang.String protocol)
Set the protocol parameters. |
void |
start()
Prepare for the beginning of active use of the public methods of this component. |
void |
startContext(java.lang.String contextPath)
Start an existing web application, attached to the specified context path in all the other nodes in the cluster. |
void |
stop()
Gracefully terminate the active cluster component. |
void |
stop(java.lang.String contextPath)
Stop an existing web application, attached to the specified context path. |
protected void |
transferProperty(java.lang.String prefix,
java.lang.Object bean)
transfer properties from cluster configuration to subelement bean. |
protected void |
unregisterClusterValve()
unregister all cluster valve to host or engine |
protected void |
unregisterMBeans()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static org.apache.commons.logging.Log log
protected static final java.lang.String info
public static final java.lang.String BEFORE_MEMBERREGISTER_EVENT
public static final java.lang.String AFTER_MEMBERREGISTER_EVENT
public static final java.lang.String BEFORE_MANAGERREGISTER_EVENT
public static final java.lang.String AFTER_MANAGERREGISTER_EVENT
public static final java.lang.String BEFORE_MANAGERUNREGISTER_EVENT
public static final java.lang.String AFTER_MANAGERUNREGISTER_EVENT
public static final java.lang.String BEFORE_MEMBERUNREGISTER_EVENT
public static final java.lang.String AFTER_MEMBERUNREGISTER_EVENT
public static final java.lang.String SEND_MESSAGE_FAILURE_EVENT
public static final java.lang.String RECEIVE_MESSAGE_FAILURE_EVENT
protected MembershipService membershipService
protected java.lang.String clusterImpName
protected StringManager sm
protected java.lang.String clusterName
protected Container container
protected LifecycleSupport lifecycle
protected boolean started
protected java.beans.PropertyChangeSupport support
protected java.util.Map managers
protected java.util.List clusterListeners
Constructor Detail |
public SimpleTcpCluster()
Method Detail |
public java.lang.String getInfo()
<description>/<version>
.
getInfo
in interface Cluster
public void setClusterName(java.lang.String clusterName)
setClusterName
in interface Cluster
clusterName
- The clustername to joinpublic java.lang.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 boolean isDefaultMode()
public void setDefaultMode(boolean defaultMode)
defaultMode
- The defaultMode to set.public java.lang.String getManagerClassName()
public void setManagerClassName(java.lang.String managerClassName)
public ClusterSender getClusterSender()
getClusterSender
in interface CatalinaCluster
public void setClusterSender(ClusterSender clusterSender)
setClusterSender
in interface CatalinaCluster
public ClusterReceiver getClusterReceiver()
getClusterReceiver
in interface CatalinaCluster
public void setClusterReceiver(ClusterReceiver clusterReceiver)
setClusterReceiver
in interface CatalinaCluster
public MembershipService getMembershipService()
getMembershipService
in interface CatalinaCluster
public void setMembershipService(MembershipService membershipService)
setMembershipService
in interface CatalinaCluster
public void addValve(Valve valve)
addValve
in interface CatalinaCluster
valve
- The new cluster Valve.public Valve[] getValves()
getValves
in interface CatalinaCluster
public MessageListener[] findClusterListeners()
public void addClusterListener(MessageListener listener)
addClusterListener
in interface CatalinaCluster
CatalinaCluster.addClusterListener(org.apache.catalina.cluster.MessageListener)
public void removeClusterListener(MessageListener listener)
removeClusterListener
in interface CatalinaCluster
CatalinaCluster.removeClusterListener(org.apache.catalina.cluster.MessageListener)
public ClusterDeployer getClusterDeployer()
getClusterDeployer
in interface CatalinaCluster
public void setClusterDeployer(ClusterDeployer clusterDeployer)
setClusterDeployer
in interface CatalinaCluster
public boolean hasMembers()
hasMembers
in interface CatalinaCluster
public Member[] getMembers()
getMembers
in interface CatalinaCluster
public Member getLocalMember()
getLocalMember
in interface CatalinaCluster
public void setProperty(java.lang.String name, java.lang.String value)
name
- value
- public void setProperty(java.lang.String name, java.lang.Object value)
setProperty
in interface IDynamicProperty
name
- value
- public java.lang.Object getProperty(java.lang.String key)
getProperty
in interface IDynamicProperty
key
-
public java.util.Iterator getPropertyNames()
getPropertyNames
in interface IDynamicProperty
public void removeProperty(java.lang.String key)
removeProperty
in interface IDynamicProperty
key
- protected void transferProperty(java.lang.String prefix, java.lang.Object bean)
prefix
- bean
- public java.util.Map getManagers()
getManagers
in interface CatalinaCluster
public Manager createManager(java.lang.String name)
createManager
in interface Cluster
name
- Context Name of this managerCluster.createManager(java.lang.String)
,
addManager(String, Manager)
,
DeltaManager.start()
public void removeManager(java.lang.String name, Manager manager)
removeManager
in interface CatalinaCluster
CatalinaCluster.removeManager(java.lang.String,Manager)
public void addManager(java.lang.String name, Manager manager)
addManager
in interface CatalinaCluster
name
- of the contextmanager
- manager to registerCatalinaCluster.addManager(java.lang.String,
org.apache.catalina.Manager)
public java.lang.String getManagerName(java.lang.String name, Manager manager)
name
- The current namemanager
- The cluster manager implementation
public Manager getManager(java.lang.String name)
getManager
in interface CatalinaCluster
public void backgroundProcess()
backgroundProcess
in interface Cluster
FarmWarDeployer.backgroundProcess()
,
ReplicationTransmitter.backgroundProcess()
public void addLifecycleListener(LifecycleListener listener)
addLifecycleListener
in interface Lifecycle
listener
- The listener to addpublic LifecycleListener[] findLifecycleListeners()
findLifecycleListeners
in interface Lifecycle
public void removeLifecycleListener(LifecycleListener listener)
removeLifecycleListener
in interface Lifecycle
listener
- The listener to removepublic void lifecycleEvent(LifecycleEvent lifecycleEvent)
lifecycleEvent
in interface LifecycleListener
lifecycleEvent
- LifecycleEvent that has occurredLifecycleListener.lifecycleEvent(org.apache.catalina.LifecycleEvent)
public void start() throws LifecycleException
configure()
,
and before any of the public methods of the component are utilized.
start
in interface CatalinaCluster
java.lang.IllegalStateException
- if this component has already been started
LifecycleException
- if this component detects a fatal error that prevents this
component from being usedprotected void createDefaultMembershipService()
<Membership className="org.apache.catalina.cluster.mcast.McastService" mcastAddr="228.0.0.4" mcastPort="8012" mcastFrequency="1000" mcastDropTime="30000"/>
protected void createDefaultClusterSender()
<Sender className="org.apache.catalina.cluster.tcp.ReplicationTransmitter" replicationMode="fastasyncqueue" doTransmitterProcessingStats="true" doProcessingStats="true"/>
protected void createDefaultClusterReceiver()
<Receiver className="org.apache.catalina.cluster.tcp.SocketReplicationListener" tcpListenAddress="auto" tcpListenPort="8015" tcpListenMaxPort="8019" doReceivedProcessingStats="true" />
protected void createDefaultClusterListener()
<ClusterListener className="org.apache.catalina.cluster.session.ClusterSessionListener" />
protected void createDefaultClusterValves()
<Valve className="org.apache.catalina.cluster.tcp.ReplicationValve" filter=".*\.gif;.*\.js;.*\.css;.*\.png;.*\.jpeg;.*\.jpg;.*\.htm;.*\.html;.*\.txt;" primaryIndicator="true" />
protected void registerClusterValve() throws java.lang.Exception
java.lang.Exception
java.lang.ClassNotFoundException
protected void unregisterClusterValve() throws java.lang.Exception
java.lang.Exception
java.lang.ClassNotFoundException
public void stop() throws LifecycleException
stop
in interface CatalinaCluster
java.lang.IllegalStateException
- if this component has not been started
LifecycleException
- if this component detects a fatal error that needs to be
reportedpublic void sendClusterDomain(ClusterMessage msg)
sendClusterDomain
in interface CatalinaCluster
msg
- ClusterMessageCatalinaCluster.send(org.apache.catalina.cluster.ClusterMessage)
public void send(ClusterMessage msg)
send
in interface CatalinaCluster
msg
- message to transferCatalinaCluster.send(org.apache.catalina.cluster.ClusterMessage)
public void sendToMember(ClusterMessage msg, java.lang.String dest)
msg
- message to transferdest
- Receiver member with nameCatalinaCluster.send(org.apache.catalina.cluster.ClusterMessage,
org.apache.catalina.cluster.Member)
,
McastService.findMemberByName(String)
public void send(ClusterMessage msg, Member dest)
send
in interface CatalinaCluster
msg
- message to transferdest
- Receiver memberCatalinaCluster.send(org.apache.catalina.cluster.ClusterMessage,
org.apache.catalina.cluster.Member)
public void memberAdded(Member member)
memberAdded
in interface MembershipListener
MembershipListener.memberAdded(org.apache.catalina.cluster.Member)
public void memberDisappeared(Member member)
memberDisappeared
in interface MembershipListener
MembershipListener.memberDisappeared(org.apache.catalina.cluster.Member)
public void receive(ClusterMessage message)
receive
in interface CatalinaCluster
message
- receveived Messagepublic java.lang.String getClusterLogName()
public void setClusterLogName(java.lang.String clusterLogName)
clusterLogName
- The clusterLogName to set.public boolean isDoClusterLog()
public void setDoClusterLog(boolean doClusterLog)
doClusterLog
- The doClusterLog to set.public org.apache.commons.logging.Log getLogger()
CatalinaCluster
getLogger
in interface CatalinaCluster
public org.apache.commons.logging.Log getClusterLog()
protected void logReceiveMessage(ClusterMessage message, long start, boolean accepted)
message
- start
- accepted
- protected void logSendMessage(ClusterMessage message, long start, Member dest)
message
- start
- dest
- protected void registerMBeans()
protected void unregisterMBeans()
public javax.management.MBeanServer getMBeanServer() throws java.lang.Exception
java.lang.Exception
public javax.management.modelmbean.ModelMBean getManagedBean(java.lang.Object object) throws java.lang.Exception
object
- The Object to get the ModelMBean for
java.lang.Exception
- If an error occurs this constructors throws this exceptionpublic void setObjectName(javax.management.ObjectName name)
public javax.management.ObjectName getObjectName()
public void setProtocol(java.lang.String protocol)
Cluster
setProtocol
in interface Cluster
protocol
- The protocol used by the clusterCluster.setProtocol(java.lang.String)
public java.lang.String getProtocol()
Cluster
getProtocol
in interface Cluster
Cluster.getProtocol()
public void startContext(java.lang.String contextPath) throws java.io.IOException
Cluster
startContext
in interface Cluster
contextPath
- The context path of the application to be started
java.io.IOException
- if an input/output error occurs during
startupCluster.startContext(java.lang.String)
public void installContext(java.lang.String contextPath, java.net.URL war)
Cluster
If this application is successfully installed, a ContainerEvent of type
PRE_INSTALL_EVENT
will be sent to registered listeners
before the associated Context is started, and a ContainerEvent of type
INSTALL_EVENT
will be sent to all registered listeners
after the associated Context is started, with the newly created
Context
as an argument.
installContext
in interface Cluster
contextPath
- The context path to which this application should
be installed (must be unique)war
- A URL of type "jar:" that points to a WAR file, or type
"file:" that points to an unpacked directory structure containing
the web application to be installedCluster.installContext(java.lang.String, java.net.URL)
public void stop(java.lang.String contextPath) throws java.io.IOException
Cluster
stop
in interface Cluster
contextPath
- The context path of the application to be stopped
java.io.IOException
- if an input/output error occurs while stopping
the web applicationCluster.stop(java.lang.String)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |