org.apache.s4.comm.topology
Class ClusterFromZK

java.lang.Object
  extended by org.apache.s4.comm.topology.ClusterFromZK
All Implemented Interfaces:
Cluster, org.I0Itec.zkclient.IZkChildListener, org.I0Itec.zkclient.IZkDataListener, org.I0Itec.zkclient.IZkStateListener

public class ClusterFromZK
extends java.lang.Object
implements Cluster, org.I0Itec.zkclient.IZkChildListener, org.I0Itec.zkclient.IZkDataListener, org.I0Itec.zkclient.IZkStateListener

Represents a logical cluster definition fetched from Zookeeper. Notifies listeners of runtime changes in the configuration.


Constructor Summary
ClusterFromZK(java.lang.String clusterName, java.lang.String zookeeperAddress, int sessionTimeout, int connectionTimeout)
          only the local topology
ClusterFromZK(java.lang.String clusterName, ZkClient zkClient, java.lang.String machineId)
          any topology
 
Method Summary
 void addListener(ClusterChangeListener listener)
           
 boolean equals(java.lang.Object obj)
           
 PhysicalCluster getPhysicalCluster()
           
 void handleChildChange(java.lang.String paramString, java.util.List<java.lang.String> paramList)
           
 void handleDataChange(java.lang.String dataPath, java.lang.Object data)
           
 void handleDataDeleted(java.lang.String dataPath)
           
 void handleNewSession()
           
 void handleStateChanged(org.apache.zookeeper.Watcher.Event.KeeperState state)
           
 int hashCode()
           
 void removeListener(ClusterChangeListener listener)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClusterFromZK

@Inject
public ClusterFromZK(java.lang.String clusterName,
                            java.lang.String zookeeperAddress,
                            int sessionTimeout,
                            int connectionTimeout)
              throws java.lang.Exception
only the local topology

Throws:
java.lang.Exception

ClusterFromZK

public ClusterFromZK(java.lang.String clusterName,
                     ZkClient zkClient,
                     java.lang.String machineId)
any topology

Method Detail

getPhysicalCluster

public PhysicalCluster getPhysicalCluster()
Specified by:
getPhysicalCluster in interface Cluster

addListener

public void addListener(ClusterChangeListener listener)
Specified by:
addListener in interface Cluster

removeListener

public void removeListener(ClusterChangeListener listener)
Specified by:
removeListener in interface Cluster

handleChildChange

public void handleChildChange(java.lang.String paramString,
                              java.util.List<java.lang.String> paramList)
                       throws java.lang.Exception
Specified by:
handleChildChange in interface org.I0Itec.zkclient.IZkChildListener
Throws:
java.lang.Exception

handleDataChange

public void handleDataChange(java.lang.String dataPath,
                             java.lang.Object data)
                      throws java.lang.Exception
Specified by:
handleDataChange in interface org.I0Itec.zkclient.IZkDataListener
Throws:
java.lang.Exception

handleDataDeleted

public void handleDataDeleted(java.lang.String dataPath)
                       throws java.lang.Exception
Specified by:
handleDataDeleted in interface org.I0Itec.zkclient.IZkDataListener
Throws:
java.lang.Exception

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

handleStateChanged

public void handleStateChanged(org.apache.zookeeper.Watcher.Event.KeeperState state)
                        throws java.lang.Exception
Specified by:
handleStateChanged in interface org.I0Itec.zkclient.IZkStateListener
Throws:
java.lang.Exception

handleNewSession

public void handleNewSession()
                      throws java.lang.Exception
Specified by:
handleNewSession in interface org.I0Itec.zkclient.IZkStateListener
Throws:
java.lang.Exception