jrunx.cluster
Class ClusterableServiceAdapter
jrunx.kernel.ServiceAdapter
|
+--jrunx.kernel.ServicePartition
|
+--jrunx.kernel.ConfigurableServicePartition
|
+--jrunx.cluster.ClusterableServiceAdapter
- All Implemented Interfaces:
- ClusterableService, ClusterableServiceAdapterMBean, ClusterConstants, ConfigurableServicePartitionMBean, javax.naming.Referenceable, java.rmi.Remote, java.io.Serializable, Service, ServiceMBean, ServicePartitionMBean
- Direct Known Subclasses:
- ContextManager, DeployerService, JRunProxyClusterHelper, RMIBroker, SecurityContextCache, SessionReplicationService, TransactionContextCacheImpl
- public class ClusterableServiceAdapter
- extends ConfigurableServicePartition
- implements ClusterableService, ClusterableServiceAdapterMBean, ClusterConstants
This is an extension of ServiceAdapter that discovers a lookup service (encapsulated
in the jrunx.cluster.ClusterManager) and uses it to find all ClusterableServiceAdapter
instances of the same class, and possibly with some of the same attributes (as defined
by overridden instances of this class), as itself. Once the ClusterableServiceAdapter has remote
references to all of its counterparts in other JRun servers, it can distribute method
invocations across them rather than handle all the method invocations
itself. All of its peers will do the same, providing service failover. The distribution
of method invocations may occur within a load balancing algorithm configured in the service.
ClusterableServiceAdapter registers JINI event listeners with the ClusterManager in order
to handle peer failures and peer joins. It must periodically renew the event listener's
lease with the ClusterManager.
This class is implemented by RMIBroker, which handles all remote method invocations made to
the server. Therefore, any rmi-based invocation (remote EJB, remote services) can
be clusterable. The JNDI ContextManager is also a subclass, making JNDI clusterable.
- Author:
- PS Neville
- See Also:
- Serialized Form
| Fields inherited from class jrunx.kernel.ServiceAdapter |
DEFAULT_DEACTIVATED, DEFAULT_DOMAIN, DOMAIN_NAME_SEPARATOR, DOMAIN_NAME_SUFFIX, domainName, jndiBindable, LOGGER_CACHE_TIME, SCHEDULER_SERVICE, SECURITY_MANAGER, server, status, TRANSACTION_MANAGER |
| Methods inherited from class jrunx.kernel.ServiceAdapter |
bind, findObjectInstance, findObjectInstance, findObjectInstance, getBindToJNDI, getDeactivated, getDomainName, getDomainSearchPath, getJRunService, getLogger, getName, getParentService, getReference, getResourceManager, getServerName, getServerProperties, getStatus, invokeMethod, isInPartition, isPartition, lookup, postDeregister, postRegister, preDeregister, preRegister, requestServer, scheduleRunnable, setBindToJNDI, setDeactivated, setDomainName, setName, setParentService, toString, unbind, unscheduleRunnable, updateStatus |
| Methods inherited from interface jrunx.kernel.ServiceMBean |
bind, getBindToJNDI, getDeactivated, getDomainName, getJRunService, getLogger, getName, getParentService, getServerName, requestServer, setBindToJNDI, setDeactivated, setDomainName, setName, setParentService, unbind |
defaultAlgorithm
protected ClusterAlgorithm defaultAlgorithm
myPeers
protected java.util.ArrayList myPeers
myStub
protected java.rmi.Remote myStub
myHost
protected java.lang.String myHost
myIP
protected java.lang.String myIP
port
protected int port
serverSocketFactoryName
protected java.lang.String serverSocketFactoryName
clientSocketFactoryName
protected java.lang.String clientSocketFactoryName
ClusterableServiceAdapter
public ClusterableServiceAdapter()
addPeerListener
public void addPeerListener(PeerListener peerListener)
- Specified by:
addPeerListener in interface ClusterableServiceAdapterMBean
init
public void init()
throws java.lang.Exception
- Description copied from class:
ServiceAdapter
- Not every service needs to init, implement it out of convenience.
- Specified by:
init in interface Service- Overrides:
init in class ConfigurableServicePartition
start
public void start()
throws java.lang.Exception
- Description copied from class:
ServiceAdapter
- Every service other than mere data collections should start
- Specified by:
start in interface Service- Overrides:
start in class ConfigurableServicePartition
stop
public void stop()
throws java.lang.Exception
- Description copied from class:
ServiceAdapter
- Every service other than mere data collections should stop
- Specified by:
stop in interface Service- Overrides:
stop in class ConfigurableServicePartition
destroy
public void destroy()
throws java.lang.Exception
- Description copied from class:
ServiceAdapter
- Every service is eventually destroyed. Convenience implementation.
- Specified by:
destroy in interface Service- Overrides:
destroy in class ConfigurableServicePartition
getClusterAlgorithm
public ClusterAlgorithm getClusterAlgorithm()
- Specified by:
getClusterAlgorithm in interface ClusterableServiceAdapterMBean
setClusterAlgorithm
public void setClusterAlgorithm(ClusterAlgorithm defaultAlgorithm)
- Specified by:
setClusterAlgorithm in interface ClusterableServiceAdapterMBean
setPort
public void setPort(int n)
- Specified by:
setPort in interface ClusterableServiceAdapterMBean
getPort
public int getPort()
- Specified by:
getPort in interface ClusterableServiceAdapterMBean
setServerSocketFactoryClass
public void setServerSocketFactoryClass(java.lang.String n)
- Specified by:
setServerSocketFactoryClass in interface ClusterableServiceAdapterMBean
getServerSocketFactoryClass
public java.lang.String getServerSocketFactoryClass()
- Specified by:
getServerSocketFactoryClass in interface ClusterableServiceAdapterMBean
setClientSocketFactoryClass
public void setClientSocketFactoryClass(java.lang.String n)
- Specified by:
setClientSocketFactoryClass in interface ClusterableServiceAdapterMBean
getClientSocketFactory
public java.lang.String getClientSocketFactory()
- Specified by:
getClientSocketFactory in interface ClusterableServiceAdapterMBean
getPeers
public java.util.ArrayList getPeers()
throws java.rmi.RemoteException
- Specified by:
getPeers in interface ClusterableService
numPeers
public int numPeers()
- Specified by:
numPeers in interface ClusterableService
getRemoteServerName
public java.lang.String getRemoteServerName()
throws java.rmi.RemoteException
- Specified by:
getRemoteServerName in interface ClusterableService
getRemoteHostName
public java.lang.String getRemoteHostName()
throws java.rmi.RemoteException
- Specified by:
getRemoteHostName in interface ClusterableService
toStub
public java.rmi.Remote toStub()
throws java.rmi.RemoteException
- Specified by:
toStub in interface ClusterableService
killRemoteServer
public void killRemoteServer()
throws java.rmi.RemoteException
- Specified by:
killRemoteServer in interface ClusterableService
getRemoteHostIP
public java.lang.String getRemoteHostIP()
throws java.rmi.RemoteException
- Specified by:
getRemoteHostIP in interface ClusterableService
getServerInfo
public ServerInfo getServerInfo()
throws java.rmi.RemoteException
- Specified by:
getServerInfo in interface ClusterableService
invoke
public Invocation invoke(Invocation inv)
throws java.rmi.RemoteException
- Override for custom invocation functionality
- Specified by:
invoke in interface ClusterableService
addServersToClients
protected void addServersToClients(Invocation inv)
- If any new servers have joined the cluster, tell the invocation about them.
This includes servers that were previously removed, but have now come back on-line.
isValidPeer
protected boolean isValidPeer(ClusterableService peer)
Copyright � 2002 Macromedia Corporation. All Rights Reserved.