org.ow2.carol.cmi.controller.server.impl.jgroups
Class JGroupsClusterViewManager

java.lang.Object
  extended by org.ow2.carol.cmi.controller.common.AbsClusterViewManager
      extended by org.ow2.carol.cmi.controller.server.AbsServerClusterViewManager
          extended by org.ow2.carol.cmi.controller.server.impl.jgroups.JGroupsClusterViewManager
All Implemented Interfaces:
org.jgroups.ChannelListener, org.ow2.carol.cmi.controller.common.ClusterViewManager, SynchronizedDistributedTree.DistributedTreeListener, SynchronizedDistributedTree.ViewListener, org.ow2.carol.cmi.controller.server.ServerClusterViewManager, org.ow2.carol.cmi.smart.api.SmartConnector

@ThreadSafe
public final class JGroupsClusterViewManager
extends org.ow2.carol.cmi.controller.server.AbsServerClusterViewManager
implements SynchronizedDistributedTree.DistributedTreeListener, SynchronizedDistributedTree.ViewListener, org.jgroups.ChannelListener

Manager implemented with JGroups that contains CMI logic for the server-side.

Author:
The new CMI team
See Also:
DistributedTree

Field Summary
static boolean isChannelClosed
          True if the channel is closed
 
Method Summary
protected  void addCMIReference(org.ow2.carol.cmi.reference.CMIReference cmiReference)
          Adds a CMIReference to the cluster view.
protected  void addDistributedObjectInfo(java.lang.String objectName, org.ow2.carol.cmi.controller.server.DistributedObjectInfo distributedObjectInfo)
          Add informations on the clustered object with the given name.
 void addPoolToEmpty(java.lang.String objectName)
          Adds the pool of the object with the given name of the list of pool that should be empty.
 void addServerToBlackList(org.ow2.carol.cmi.reference.ServerRef serverRef)
          Add a server to the blacklist.
 void channelClosed(org.jgroups.Channel arg0)
           
 void channelConnected(org.jgroups.Channel arg0)
           
 void channelDisconnected(org.jgroups.Channel arg0)
           
 void channelReconnected(org.jgroups.Address arg0)
           
 void channelShunned()
           
protected  boolean containObject(java.lang.String objectName)
          Returns true if the given object is already replicated.
 void doStart()
          Start the server-side manager.
 void doStop()
          Stop the server-side manager.
 java.util.Set<java.lang.String> getClusterNames()
          Returns the set of name of cluster.
 java.util.List<org.ow2.carol.cmi.reference.CMIReference> getCMIReferences(java.lang.String objectName)
          Returns a list of CMIReference for an object with the given name.
 java.util.List<org.ow2.carol.cmi.reference.CMIReference> getCMIReferences(java.lang.String objectName, java.lang.String protocolName)
          Returns a list of CMIReference for an object with the given name and protocol.
 int getDelayToRefresh()
          Returns the time between each update of the cluster view by clients.
protected  org.ow2.carol.cmi.controller.server.DistributedObjectInfo getDistributedObjectInfo(java.lang.String objectName)
          Returns informations on this object.
 int getLoadFactor(org.ow2.carol.cmi.reference.ServerRef serverRef)
          Returns the load-factor for the server with the given address.
 int getNbClientsConnectedToProvider()
           
 java.util.Set<java.lang.String> getObjectNames()
           
 java.util.Set<java.lang.String> getObjectNames(java.lang.String clusterName)
          Returns the set of name of object for a given name of cluster.
 java.util.Set<java.lang.String> getServerObjectForProtocol(java.lang.String serverUrl, java.lang.String protocolName)
          Gets all objects hosted on a given server started with the given protocol.
 java.util.Set<org.ow2.carol.cmi.reference.ServerRef> getServerRefs(java.lang.String protocolName)
          Return the list of servers for a given protocol.
protected  void initStats()
          Initialize the statistics.
 boolean isPoolToEmpty(java.lang.String objectName)
          Returns true if the pool for object with the given name should be empty.
 boolean isServerBlackListed(org.ow2.carol.cmi.reference.ServerRef serverRef)
          Return true if the server with the given reference if blacklisted.
 void nodeAdded(java.lang.String fqn, java.io.Serializable element)
           
 void nodeModified(java.lang.String fqn, java.io.Serializable oldElement, java.io.Serializable newElement)
           
 void nodeRemoved(java.lang.String fqn)
           
 void registerClient(java.util.UUID uuid)
          Register a new client.
 void removeCMIReference(org.ow2.carol.cmi.reference.CMIReference cmiReference)
          Removes a CMIReference from the cluster view.
 void removePoolToEmpty(java.lang.String objectName)
          Removes the pool of the object with the given name of the list of pool that should be empty.
 void removeServerFromBlackList(org.ow2.carol.cmi.reference.ServerRef serverRef)
          Remove a server to the blacklist.
 void setDelayToRefresh(int delay)
          Sets the time between each update of the cluster view by clients.
protected  void setDistributedObjectInfo(java.lang.String objectName, org.ow2.carol.cmi.controller.server.DistributedObjectInfo distributedObjectInfo)
          Sets informations on the clustered object with the given name.
 void setLoadFactor(org.ow2.carol.cmi.reference.ServerRef serverRef, int loadFactor)
          Sets the load-factor for the server with the given address.
 void viewChange(java.util.Vector<org.jgroups.Address> newMbrs, java.util.Vector<org.jgroups.Address> oldMbrs)
           
 
Methods inherited from class org.ow2.carol.cmi.controller.server.AbsServerClusterViewManager
addObjectInstance, addObjectToWatch, addProtocol, getApplicationExceptionNames, getAvailableLBPoliciesAndStrategies, getBusinessName, getClusterName, getDateOfProperties, getInetAddress, getInitialContextFactoryName, getInterface, getItfName, getJMXServiceURL, getLBPolicyClass, getLBPolicyClassName, getLBStrategyClass, getLBStrategyClassName, getMaxPoolSize, getMinPoolSize, getPropertiesForLBPolicy, getPropertyForLBPolicy, getProtocols, getProviderURLs, getRefOnLocalRegistry, getRemoteClass, getServerClusterViewManager, hasState, isClustered, isEmbeddedLBPolicy, isEmbeddedLBStrategy, isReplicated, isReplicationManagerStarted, setAlgorithmForLBPolicy, setLBPolicyClassName, setLBStrategyClassName, setMaxPoolSize, setMinPoolSize, setPropertiesForLBPolicy, setPropertyForLBPolicy, setReplicationManagerStarted, start, stop
 
Methods inherited from class org.ow2.carol.cmi.controller.common.AbsClusterViewManager
getClusterViewManager, getCmiThreadFactory, getLBPolicy, getLocalMaxPoolSize, getLocalMinPoolSize, getNamesOfWatchedObject, getPool, getSessionId, getUUID, hasPool, isWatched, setClusterViewManager, setLocalMaxSize, setLocalMinSize, setPool, updateLBPolicy, watch
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.ow2.carol.cmi.controller.common.ClusterViewManager
getLBPolicy, getPool, getSessionId, getUUID, setPool
 

Field Detail

isChannelClosed

public static final boolean isChannelClosed
True if the channel is closed

See Also:
Constant Field Values
Method Detail

doStart

public void doStart()
Start the server-side manager.

Specified by:
doStart in class org.ow2.carol.cmi.controller.server.AbsServerClusterViewManager

doStop

public void doStop()
Stop the server-side manager.

Specified by:
doStop in class org.ow2.carol.cmi.controller.server.AbsServerClusterViewManager

containObject

protected boolean containObject(java.lang.String objectName)
Returns true if the given object is already replicated.

Specified by:
containObject in class org.ow2.carol.cmi.controller.server.AbsServerClusterViewManager
Parameters:
objectName - a name of object
Returns:
true if the given object is already replicated

getDistributedObjectInfo

protected org.ow2.carol.cmi.controller.server.DistributedObjectInfo getDistributedObjectInfo(java.lang.String objectName)
                                                                                      throws org.ow2.carol.cmi.reference.ObjectNotFoundException
Returns informations on this object.

Specified by:
getDistributedObjectInfo in class org.ow2.carol.cmi.controller.server.AbsServerClusterViewManager
Parameters:
objectName - a name of object
Returns:
informations on this object
Throws:
org.ow2.carol.cmi.reference.ObjectNotFoundException - if the given object is not found

addDistributedObjectInfo

protected void addDistributedObjectInfo(java.lang.String objectName,
                                        org.ow2.carol.cmi.controller.server.DistributedObjectInfo distributedObjectInfo)
Add informations on the clustered object with the given name.

Specified by:
addDistributedObjectInfo in class org.ow2.carol.cmi.controller.server.AbsServerClusterViewManager
Parameters:
objectName - a name of object
distributedObjectInfo - informations on the clustered object

setDistributedObjectInfo

protected void setDistributedObjectInfo(java.lang.String objectName,
                                        org.ow2.carol.cmi.controller.server.DistributedObjectInfo distributedObjectInfo)
Sets informations on the clustered object with the given name.

Specified by:
setDistributedObjectInfo in class org.ow2.carol.cmi.controller.server.AbsServerClusterViewManager
Parameters:
objectName - a name of object
distributedObjectInfo - informations on the clustered object

getServerRefs

public java.util.Set<org.ow2.carol.cmi.reference.ServerRef> getServerRefs(java.lang.String protocolName)
                                                                   throws org.ow2.carol.cmi.controller.server.ServerClusterViewManagerException
Return the list of servers for a given protocol.

Specified by:
getServerRefs in interface org.ow2.carol.cmi.controller.server.ServerClusterViewManager
Parameters:
protocolName - a name of protocol
Returns:
the set of references on server connected to this server
Throws:
org.ow2.carol.cmi.controller.server.ServerClusterViewManagerException - if the given protocol name doesn't exist

getServerObjectForProtocol

public java.util.Set<java.lang.String> getServerObjectForProtocol(java.lang.String serverUrl,
                                                                  java.lang.String protocolName)
                                                           throws org.ow2.carol.cmi.controller.server.ServerClusterViewManagerException
Gets all objects hosted on a given server started with the given protocol.

Specified by:
getServerObjectForProtocol in interface org.ow2.carol.cmi.controller.server.ServerClusterViewManager
Parameters:
serverUrl - a server reference
protocolName - a given protocol
Returns:
the set of references on objects for the given server.
Throws:
org.ow2.carol.cmi.controller.server.ServerClusterViewManagerException - if the protocol name doesn't exist or the server is not bound on the given protocol

getCMIReferences

public java.util.List<org.ow2.carol.cmi.reference.CMIReference> getCMIReferences(java.lang.String objectName,
                                                                                 java.lang.String protocolName)
                                                                          throws org.ow2.carol.cmi.reference.ObjectNotFoundException
Returns a list of CMIReference for an object with the given name and protocol. The objects deployed on a blacklisted server are discarded.

Specified by:
getCMIReferences in interface org.ow2.carol.cmi.controller.common.ClusterViewManager
Parameters:
objectName - a name of object
protocolName - a name of protocol
Returns:
a list of CMIReference for an object with the given name and protocol
Throws:
org.ow2.carol.cmi.reference.ObjectNotFoundException - if none object has the given name for the given protocol

getCMIReferences

public java.util.List<org.ow2.carol.cmi.reference.CMIReference> getCMIReferences(java.lang.String objectName)
                                                                          throws org.ow2.carol.cmi.reference.ObjectNotFoundException
Returns a list of CMIReference for an object with the given name.

Specified by:
getCMIReferences in interface org.ow2.carol.cmi.controller.server.ServerClusterViewManager
Parameters:
objectName - a name of object
Returns:
a list of CMIReference for an object with the given name
Throws:
org.ow2.carol.cmi.reference.ObjectNotFoundException - if no object is bound with the given name

addCMIReference

protected void addCMIReference(org.ow2.carol.cmi.reference.CMIReference cmiReference)
Adds a CMIReference to the cluster view.

Specified by:
addCMIReference in class org.ow2.carol.cmi.controller.server.AbsServerClusterViewManager
Parameters:
cmiReference - a reference on an instance

removeCMIReference

public void removeCMIReference(org.ow2.carol.cmi.reference.CMIReference cmiReference)
Removes a CMIReference from the cluster view.

Specified by:
removeCMIReference in interface org.ow2.carol.cmi.controller.server.ServerClusterViewManager
Parameters:
cmiReference - a reference on a clustered object

getClusterNames

public java.util.Set<java.lang.String> getClusterNames()
Returns the set of name of cluster.

Specified by:
getClusterNames in interface org.ow2.carol.cmi.controller.server.ServerClusterViewManager
Returns:
a set of name of cluster

getObjectNames

public java.util.Set<java.lang.String> getObjectNames(java.lang.String clusterName)
Returns the set of name of object for a given name of cluster.

Specified by:
getObjectNames in interface org.ow2.carol.cmi.controller.server.ServerClusterViewManager
Parameters:
clusterName - a name of cluster
Returns:
the set of name of object for a given name of cluster

getObjectNames

public java.util.Set<java.lang.String> getObjectNames()
Specified by:
getObjectNames in interface org.ow2.carol.cmi.controller.common.ClusterViewManager
Specified by:
getObjectNames in interface org.ow2.carol.cmi.controller.server.ServerClusterViewManager
Returns:
the set of name of object

getDelayToRefresh

public int getDelayToRefresh()
Returns the time between each update of the cluster view by clients.

Specified by:
getDelayToRefresh in interface org.ow2.carol.cmi.controller.common.ClusterViewManager
Returns:
the time between each update of the cluster view by clients

setDelayToRefresh

public void setDelayToRefresh(int delay)
Sets the time between each update of the cluster view by clients.

Specified by:
setDelayToRefresh in interface org.ow2.carol.cmi.controller.server.ServerClusterViewManager
Parameters:
delay - the time between each update of the cluster view by clients

isPoolToEmpty

public boolean isPoolToEmpty(java.lang.String objectName)
Returns true if the pool for object with the given name should be empty.

Specified by:
isPoolToEmpty in interface org.ow2.carol.cmi.controller.common.ClusterViewManager
Parameters:
objectName - a name of object
Returns:
true if the pool for object with the given name should be empty

addPoolToEmpty

public void addPoolToEmpty(java.lang.String objectName)
Adds the pool of the object with the given name of the list of pool that should be empty.

Specified by:
addPoolToEmpty in interface org.ow2.carol.cmi.controller.server.ServerClusterViewManager
Parameters:
objectName - a name of object

removePoolToEmpty

public void removePoolToEmpty(java.lang.String objectName)
Removes the pool of the object with the given name of the list of pool that should be empty.

Specified by:
removePoolToEmpty in interface org.ow2.carol.cmi.controller.server.ServerClusterViewManager
Parameters:
objectName - a name of object

isServerBlackListed

public boolean isServerBlackListed(org.ow2.carol.cmi.reference.ServerRef serverRef)
Return true if the server with the given reference if blacklisted.

Specified by:
isServerBlackListed in interface org.ow2.carol.cmi.controller.server.ServerClusterViewManager
Parameters:
serverRef - a reference on a server
Returns:
true the server with the given reference if blacklisted

addServerToBlackList

public void addServerToBlackList(org.ow2.carol.cmi.reference.ServerRef serverRef)
Add a server to the blacklist.

Specified by:
addServerToBlackList in interface org.ow2.carol.cmi.controller.server.ServerClusterViewManager
Parameters:
serverRef - a reference on a server

removeServerFromBlackList

public void removeServerFromBlackList(org.ow2.carol.cmi.reference.ServerRef serverRef)
Remove a server to the blacklist.

Specified by:
removeServerFromBlackList in interface org.ow2.carol.cmi.controller.server.ServerClusterViewManager
Parameters:
serverRef - a reference on a server

getLoadFactor

public int getLoadFactor(org.ow2.carol.cmi.reference.ServerRef serverRef)
                  throws org.ow2.carol.cmi.reference.ServerNotFoundException
Returns the load-factor for the server with the given address.

Specified by:
getLoadFactor in interface org.ow2.carol.cmi.controller.common.ClusterViewManager
Parameters:
serverRef - a reference on a server
Returns:
the load-factor for the server with the given address
Throws:
org.ow2.carol.cmi.reference.ServerNotFoundException - if none server has the given address

setLoadFactor

public void setLoadFactor(org.ow2.carol.cmi.reference.ServerRef serverRef,
                          int loadFactor)
Sets the load-factor for the server with the given address.

Specified by:
setLoadFactor in interface org.ow2.carol.cmi.controller.server.ServerClusterViewManager
Parameters:
serverRef - a reference on a server
loadFactor - the load-factor for the server with the given address

initStats

protected void initStats()
Initialize the statistics.

Specified by:
initStats in class org.ow2.carol.cmi.controller.server.AbsServerClusterViewManager

getNbClientsConnectedToProvider

public int getNbClientsConnectedToProvider()
Specified by:
getNbClientsConnectedToProvider in interface org.ow2.carol.cmi.controller.server.ServerClusterViewManager
Returns:
the numbers of clients connected to a provider of the cluster view

registerClient

public void registerClient(java.util.UUID uuid)
Register a new client.

Specified by:
registerClient in interface org.ow2.carol.cmi.controller.server.ServerClusterViewManager
Parameters:
uuid - the Universally Unique Identifier of the client

nodeAdded

public void nodeAdded(java.lang.String fqn,
                      java.io.Serializable element)
Specified by:
nodeAdded in interface SynchronizedDistributedTree.DistributedTreeListener

nodeModified

public void nodeModified(java.lang.String fqn,
                         java.io.Serializable oldElement,
                         java.io.Serializable newElement)
Specified by:
nodeModified in interface SynchronizedDistributedTree.DistributedTreeListener

nodeRemoved

public void nodeRemoved(java.lang.String fqn)
Specified by:
nodeRemoved in interface SynchronizedDistributedTree.DistributedTreeListener

viewChange

public void viewChange(java.util.Vector<org.jgroups.Address> newMbrs,
                       java.util.Vector<org.jgroups.Address> oldMbrs)
Specified by:
viewChange in interface SynchronizedDistributedTree.ViewListener

channelClosed

public void channelClosed(org.jgroups.Channel arg0)
Specified by:
channelClosed in interface org.jgroups.ChannelListener

channelConnected

public void channelConnected(org.jgroups.Channel arg0)
Specified by:
channelConnected in interface org.jgroups.ChannelListener

channelDisconnected

public void channelDisconnected(org.jgroups.Channel arg0)
Specified by:
channelDisconnected in interface org.jgroups.ChannelListener

channelReconnected

public void channelReconnected(org.jgroups.Address arg0)
Specified by:
channelReconnected in interface org.jgroups.ChannelListener

channelShunned

public void channelShunned()
Specified by:
channelShunned in interface org.jgroups.ChannelListener


Copyright © 2008 OW2 Consortium. All Rights Reserved.