SMILA 1.0 API documentation

org.eclipse.smila.zookeeper.internal
Class ZooKeeperServiceImpl

java.lang.Object
  extended by org.eclipse.smila.zookeeper.internal.ZooKeeperServiceImpl
All Implemented Interfaces:
ZooKeeperService

public class ZooKeeperServiceImpl
extends java.lang.Object
implements ZooKeeperService

OSGi services that configures and starts a ZooKeeper, either stand-alone if we are not running in a multi-node cluster or without ClusterConfigService at all or as distributed on the complete cluster.


Field Summary
 
Fields inherited from interface org.eclipse.smila.zookeeper.ZooKeeperService
BUNDLE_ID
 
Constructor Summary
ZooKeeperServiceImpl()
           
 
Method Summary
protected  void activate(ComponentContext context)
          OSGi Declarative Services service activation method.
 void closeClient()
          close the client quietly.
protected  void deactivate(ComponentContext context)
          OSGi Declarative Services service deactivation method.
 ZooKeeper getClient()
          get zookeeper client, create if it doesn't exist.
 long getFailSafetyLevel()
          
 AnyMap getServerState()
           
 void process(WatchedEvent event)
          we only use Watches for zookeeper client state change events.
 void registerWatcher(Watcher watcher)
          register a watcher for ZooKeeper events.
 void setClusterConfigService(ClusterConfigService clusterConfigService)
          set new ClusterConfigService.
 void unregisterWatcher(Watcher watcher)
          unregister a watcher for ZooKeeper events.
 void unsetClusterConfigService(ClusterConfigService clusterConfigService)
          remove a ClusterConfigService.
 void waitForClientConnected()
          wait until the zookeeper client is (re)connected.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZooKeeperServiceImpl

public ZooKeeperServiceImpl()
Method Detail

getClient

public ZooKeeper getClient()
                    throws java.io.IOException,
                           ClusterConfigException
get zookeeper client, create if it doesn't exist.

Specified by:
getClient in interface ZooKeeperService
Returns:
client
Throws:
java.io.IOException - error creating client
ClusterConfigException - if the cluster configuration cannot be read

closeClient

public void closeClient()
close the client quietly.

Specified by:
closeClient in interface ZooKeeperService

getFailSafetyLevel

public long getFailSafetyLevel()

Specified by:
getFailSafetyLevel in interface ZooKeeperService
Returns:
number of nodes that may fail without ZooKeeper service stopping to work.

activate

protected void activate(ComponentContext context)
OSGi Declarative Services service activation method.

Parameters:
context - OSGi service component context.

deactivate

protected void deactivate(ComponentContext context)
OSGi Declarative Services service deactivation method.

Parameters:
context - OSGi service component context.

setClusterConfigService

public void setClusterConfigService(ClusterConfigService clusterConfigService)
set new ClusterConfigService. To be called by DS runtime before activation.

Parameters:
clusterConfigService - new ClusterConfigService

unsetClusterConfigService

public void unsetClusterConfigService(ClusterConfigService clusterConfigService)
remove a ClusterConfigService. To be called by DS runtime after deactivation.


waitForClientConnected

public void waitForClientConnected()
Description copied from interface: ZooKeeperService
wait until the zookeeper client is (re)connected.

Specified by:
waitForClientConnected in interface ZooKeeperService

process

public void process(WatchedEvent event)
we only use Watches for zookeeper client state change events.


registerWatcher

public void registerWatcher(Watcher watcher)
register a watcher for ZooKeeper events.

Specified by:
registerWatcher in interface ZooKeeperService

unregisterWatcher

public void unregisterWatcher(Watcher watcher)
unregister a watcher for ZooKeeper events.

Specified by:
unregisterWatcher in interface ZooKeeperService

getServerState

public AnyMap getServerState()
Specified by:
getServerState in interface ZooKeeperService
Returns:
zookeeper server/cluster state for monitoring.

SMILA 1.0 API documentation