com.bigdata.zookeeper
Class ZooHelper

java.lang.Object
  extended by com.bigdata.zookeeper.ZooHelper

public class ZooHelper
extends Object

Utility class for issuing the four letter commands to a zookeeper service.

Version:
$Id$
Author:
Bryan Thompson

Field Summary
protected static org.apache.log4j.Logger log
           
 
Constructor Summary
ZooHelper()
           
 
Method Summary
static void destroyZNodes(org.apache.zookeeper.ZooKeeper zookeeper, String zpath, int depth)
          Destroys all znodes under the specified zpath and then the znode at the specified zpath.
static String dump(InetAddress addr, int clientPort)
          Sends a "dump" command and return the result.
static boolean isRunning(InetAddress addr, int clientPort)
          Return true if zookeeper is running on the specified host at the client port.
static void kill(int clientPort)
          Kills a local zookeeper instance responding at the specified client port.
static void main(String[] args)
          Send four letter commands to zookeeper.
static void ruok(InetAddress addr, int clientPort)
          Inquires whether a zookeeper instance is running in a non-error state and returns iff the service reports "imok".
static String stat(InetAddress addr, int clientPort)
          Sends a "stat" command and return the result.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.apache.log4j.Logger log
Constructor Detail

ZooHelper

public ZooHelper()
Method Detail

ruok

public static void ruok(InetAddress addr,
                        int clientPort)
                 throws IOException
Inquires whether a zookeeper instance is running in a non-error state and returns iff the service reports "imok".

Parameters:
addr - The address of the zookeeper instance.
clientPort - The client port.
Throws:
IOException - if there is any problem communicating with the service, including a timeout (the service is not responsive).

kill

public static void kill(int clientPort)
                 throws UnknownHostException,
                        IOException
Kills a local zookeeper instance responding at the specified client port.

Parameters:
clientPort - The client port.
Throws:
IOException - if there is any problem communicating with the service, including a timeout (the service is not responsive).
UnknownHostException

stat

public static String stat(InetAddress addr,
                          int clientPort)
                   throws UnknownHostException,
                          IOException
Sends a "stat" command and return the result.

Parameters:
addr - The address of the zookeeper instance.
clientPort - The client port for zookeeper.
Returns:
The result.
Throws:
UnknownHostException - if the hostname can not be resolved.
IOException - if there is any problem communicating with the service, including a timeout (the service is not responsive).

dump

public static String dump(InetAddress addr,
                          int clientPort)
                   throws UnknownHostException,
                          IOException
Sends a "dump" command and return the result.

Parameters:
addr - The address of the zookeeper instance.
clientPort - The client port for zookeeper.
Returns:
The result.
Throws:
UnknownHostException - if the hostname can not be resolved.
IOException - if there is any problem communicating with the service, including a timeout (the service is not responsive).

isRunning

public static boolean isRunning(InetAddress addr,
                                int clientPort)
Return true if zookeeper is running on the specified host at the client port.

Returns:
true if zookeeper responds to an [ruok] request on that host and client port.

destroyZNodes

public static void destroyZNodes(org.apache.zookeeper.ZooKeeper zookeeper,
                                 String zpath,
                                 int depth)
                          throws org.apache.zookeeper.KeeperException,
                                 InterruptedException
Destroys all znodes under the specified zpath and then the znode at the specified zpath. If there is no such znode, then return immediately.

Parameters:
zookeeper -
zpath - The path to the root of the hierarchy to be destroyed.
depth - The depth (initially zero).
Throws:
org.apache.zookeeper.KeeperException
InterruptedException

main

public static void main(String[] args)
                 throws IOException
Send four letter commands to zookeeper.

Parameters:
args - host:clientPort command
Throws:
IOException


Copyright © 2006-2012 SYSTAP, LLC. All Rights Reserved.