org.apache.hadoop.hbase.zookeeper
Class ZKAssign

java.lang.Object
  extended by org.apache.hadoop.hbase.zookeeper.ZKAssign

@InterfaceAudience.Private
public class ZKAssign
extends Object

Utility class for doing region assignment in ZooKeeper. This class extends stuff done in ZKUtil to cover specific assignment operations.

Contains only static methods and constants.

Used by both the Master and RegionServer.

All valid transitions outlined below:

MASTER

  1. Master creates an unassigned node as OFFLINE. - Cluster startup and table enabling.
  2. Master forces an existing unassigned node to OFFLINE. - RegionServer failure. - Allows transitions from all states to OFFLINE.
  3. Master deletes an unassigned node that was in a OPENED state. - Normal region transitions. Besides cluster startup, no other deletions of unassigned nodes is allowed.
  4. Master deletes all unassigned nodes regardless of state. - Cluster startup before any assignment happens.

REGIONSERVER

  1. RegionServer creates an unassigned node as CLOSING. - All region closes will do this in response to a CLOSE RPC from Master. - A node can never be transitioned to CLOSING, only created.
  2. RegionServer transitions an unassigned node from CLOSING to CLOSED. - Normal region closes. CAS operation.
  3. RegionServer transitions an unassigned node from OFFLINE to OPENING. - All region opens will do this in response to an OPEN RPC from the Master. - Normal region opens. CAS operation.
  4. RegionServer transitions an unassigned node from OPENING to OPENED. - Normal region opens. CAS operation.


Constructor Summary
ZKAssign()
           
 
Method Summary
static void asyncCreateNodeOffline(ZooKeeperWatcher zkw, HRegionInfo region, ServerName serverName, org.apache.zookeeper.AsyncCallback.StringCallback cb, Object ctx)
          Creates an unassigned node in the OFFLINE state for the specified region.
static void blockUntilNoRIT(ZooKeeperWatcher zkw)
          Blocks until there are no node in regions in transition.
static void blockUntilRIT(ZooKeeperWatcher zkw)
          Blocks until there is at least one node in regions in transition.
static boolean checkClosingState(ZooKeeperWatcher zkw, HRegionInfo region, int expectedVersion)
           
static int createNodeClosing(ZooKeeperWatcher zkw, HRegionInfo region, ServerName serverName)
          Creates a new unassigned node in the CLOSING state for the specified region.
static void createNodeOffline(ZooKeeperWatcher zkw, HRegionInfo region, ServerName serverName)
          Creates a new unassigned node in the OFFLINE state for the specified region.
static void createNodeOffline(ZooKeeperWatcher zkw, HRegionInfo region, ServerName serverName, EventType event)
           
static int createOrForceNodeOffline(ZooKeeperWatcher zkw, HRegionInfo region, ServerName serverName)
          Creates or force updates an unassigned node to the OFFLINE state for the specified region.
static void deleteAllNodes(ZooKeeperWatcher zkw)
          Deletes all unassigned nodes regardless of their state.
static boolean deleteClosedNode(ZooKeeperWatcher zkw, String encodedRegionName, ServerName sn)
          Deletes an existing unassigned node that is in the CLOSED state for the specified region.
static boolean deleteClosingNode(ZooKeeperWatcher zkw, HRegionInfo region, ServerName sn)
          Deletes an existing unassigned node that is in the CLOSING state for the specified region.
static boolean deleteNode(ZooKeeperWatcher zkw, String encodedRegionName, EventType expectedState, int expectedVersion)
          Deletes an existing unassigned node that is in the specified state for the specified region.
static boolean deleteNode(ZooKeeperWatcher zkw, String encodedRegionName, EventType expectedState, ServerName sn)
          Deletes an existing unassigned node that is in the specified state for the specified region.
static boolean deleteNode(ZooKeeperWatcher zkw, String encodedRegionName, EventType expectedState, ServerName serverName, int expectedVersion)
          Deletes an existing unassigned node that is in the specified state for the specified region.
static void deleteNodeFailSilent(ZooKeeperWatcher watcher, HRegionInfo regionInfo)
          Delete the assignment node regardless of its current state.
static boolean deleteOfflineNode(ZooKeeperWatcher zkw, String encodedRegionName, ServerName sn)
          Deletes an existing unassigned node that is in the OFFLINE state for the specified region.
static boolean deleteOpenedNode(ZooKeeperWatcher zkw, String encodedRegionName, ServerName sn)
          Deletes an existing unassigned node that is in the OPENED state for the specified region.
static byte[] getData(ZooKeeperWatcher zkw, String pathOrRegionName)
          Gets the current data in the unassigned node for the specified region name or fully-qualified path.
static byte[] getDataAndWatch(ZooKeeperWatcher zkw, String pathOrRegionName, org.apache.zookeeper.data.Stat stat)
          Gets the current data in the unassigned node for the specified region name or fully-qualified path.
static byte[] getDataNoWatch(ZooKeeperWatcher zkw, String pathOrRegionName, org.apache.zookeeper.data.Stat stat)
          Gets the current data in the unassigned node for the specified region name or fully-qualified path.
static String getNodeName(ZooKeeperWatcher zkw, String regionName)
          Gets the full path node name for the unassigned node for the specified region.
static String getPath(ZooKeeperWatcher zkw, String pathOrRegionName)
           
static String getRegionName(ZooKeeperWatcher zkw, String path)
          Gets the region name from the full path node name of an unassigned node.
static int getVersion(ZooKeeperWatcher zkw, HRegionInfo region)
          Get the version of the specified znode
static int retransitionNodeOpening(ZooKeeperWatcher zkw, HRegionInfo region, ServerName serverName, int expectedVersion, boolean updateZNode)
          Retransitions an existing unassigned node for the specified region which is currently in the OPENING state to be in the OPENING state.
static int transitionNode(ZooKeeperWatcher zkw, HRegionInfo region, ServerName serverName, EventType beginState, EventType endState, int expectedVersion)
          Method that actually performs unassigned node transitions.
static int transitionNode(ZooKeeperWatcher zkw, HRegionInfo region, ServerName serverName, EventType beginState, EventType endState, int expectedVersion, byte[] payload)
           
static int transitionNodeClosed(ZooKeeperWatcher zkw, HRegionInfo region, ServerName serverName, int expectedVersion)
          Transitions an existing unassigned node for the specified region which is currently in the CLOSING state to be in the CLOSED state.
static int transitionNodeOpened(ZooKeeperWatcher zkw, HRegionInfo region, ServerName serverName, int expectedVersion)
          Transitions an existing unassigned node for the specified region which is currently in the OPENING state to be in the OPENED state.
static int transitionNodeOpening(ZooKeeperWatcher zkw, HRegionInfo region, ServerName serverName)
          Transitions an existing unassigned node for the specified region which is currently in the OFFLINE state to be in the OPENING state.
static int transitionNodeOpening(ZooKeeperWatcher zkw, HRegionInfo region, ServerName serverName, EventType beginState)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZKAssign

public ZKAssign()
Method Detail

getNodeName

public static String getNodeName(ZooKeeperWatcher zkw,
                                 String regionName)
Gets the full path node name for the unassigned node for the specified region.

Parameters:
zkw - zk reference
regionName - region name
Returns:
full path node name

getRegionName

public static String getRegionName(ZooKeeperWatcher zkw,
                                   String path)
Gets the region name from the full path node name of an unassigned node.

Parameters:
path - full zk path
Returns:
region name

createNodeOffline

public static void createNodeOffline(ZooKeeperWatcher zkw,
                                     HRegionInfo region,
                                     ServerName serverName)
                              throws org.apache.zookeeper.KeeperException,
                                     org.apache.zookeeper.KeeperException.NodeExistsException
Creates a new unassigned node in the OFFLINE state for the specified region.

Does not transition nodes from other states. If a node already exists for this region, a KeeperException.NodeExistsException will be thrown.

Sets a watcher on the unassigned region node if the method is successful.

This method should only be used during cluster startup and the enabling of a table.

Parameters:
zkw - zk reference
region - region to be created as offline
serverName - server transition will happen on
Throws:
org.apache.zookeeper.KeeperException - if unexpected zookeeper exception
KeeperException.NodeExistsException - if node already exists

createNodeOffline

public static void createNodeOffline(ZooKeeperWatcher zkw,
                                     HRegionInfo region,
                                     ServerName serverName,
                                     EventType event)
                              throws org.apache.zookeeper.KeeperException,
                                     org.apache.zookeeper.KeeperException.NodeExistsException
Throws:
org.apache.zookeeper.KeeperException
org.apache.zookeeper.KeeperException.NodeExistsException

asyncCreateNodeOffline

public static void asyncCreateNodeOffline(ZooKeeperWatcher zkw,
                                          HRegionInfo region,
                                          ServerName serverName,
                                          org.apache.zookeeper.AsyncCallback.StringCallback cb,
                                          Object ctx)
                                   throws org.apache.zookeeper.KeeperException
Creates an unassigned node in the OFFLINE state for the specified region.

Runs asynchronously. Depends on no pre-existing znode.

Sets a watcher on the unassigned region node.

Parameters:
zkw - zk reference
region - region to be created as offline
serverName - server transition will happen on
cb -
ctx -
Throws:
org.apache.zookeeper.KeeperException - if unexpected zookeeper exception
KeeperException.NodeExistsException - if node already exists

createOrForceNodeOffline

public static int createOrForceNodeOffline(ZooKeeperWatcher zkw,
                                           HRegionInfo region,
                                           ServerName serverName)
                                    throws org.apache.zookeeper.KeeperException
Creates or force updates an unassigned node to the OFFLINE state for the specified region.

Attempts to create the node but if it exists will force it to transition to and OFFLINE state.

Sets a watcher on the unassigned region node if the method is successful.

This method should be used when assigning a region.

Parameters:
zkw - zk reference
region - region to be created as offline
serverName - server transition will happen on
Returns:
the version of the znode created in OFFLINE state, -1 if unsuccessful.
Throws:
org.apache.zookeeper.KeeperException - if unexpected zookeeper exception
KeeperException.NodeExistsException - if node already exists

deleteOpenedNode

public static boolean deleteOpenedNode(ZooKeeperWatcher zkw,
                                       String encodedRegionName,
                                       ServerName sn)
                                throws org.apache.zookeeper.KeeperException,
                                       org.apache.zookeeper.KeeperException.NoNodeException
Deletes an existing unassigned node that is in the OPENED state for the specified region.

If a node does not already exist for this region, a KeeperException.NoNodeException will be thrown.

No watcher is set whether this succeeds or not.

Returns false if the node was not in the proper state but did exist.

This method is used during normal region transitions when a region finishes successfully opening. This is the Master acknowledging completion of the specified regions transition.

Parameters:
zkw - zk reference
encodedRegionName - opened region to be deleted from zk
sn - the expected region transition target server name
Throws:
org.apache.zookeeper.KeeperException - if unexpected zookeeper exception
KeeperException.NoNodeException - if node does not exist

deleteOfflineNode

public static boolean deleteOfflineNode(ZooKeeperWatcher zkw,
                                        String encodedRegionName,
                                        ServerName sn)
                                 throws org.apache.zookeeper.KeeperException,
                                        org.apache.zookeeper.KeeperException.NoNodeException
Deletes an existing unassigned node that is in the OFFLINE state for the specified region.

If a node does not already exist for this region, a KeeperException.NoNodeException will be thrown.

No watcher is set whether this succeeds or not.

Returns false if the node was not in the proper state but did exist.

This method is used during master failover when the regions on an RS that has died are all set to OFFLINE before being processed.

Parameters:
zkw - zk reference
encodedRegionName - closed region to be deleted from zk
sn - the expected region transition target server name
Throws:
org.apache.zookeeper.KeeperException - if unexpected zookeeper exception
KeeperException.NoNodeException - if node does not exist

deleteClosedNode

public static boolean deleteClosedNode(ZooKeeperWatcher zkw,
                                       String encodedRegionName,
                                       ServerName sn)
                                throws org.apache.zookeeper.KeeperException,
                                       org.apache.zookeeper.KeeperException.NoNodeException
Deletes an existing unassigned node that is in the CLOSED state for the specified region.

If a node does not already exist for this region, a KeeperException.NoNodeException will be thrown.

No watcher is set whether this succeeds or not.

Returns false if the node was not in the proper state but did exist.

This method is used during table disables when a region finishes successfully closing. This is the Master acknowledging completion of the specified regions transition to being closed.

Parameters:
zkw - zk reference
encodedRegionName - closed region to be deleted from zk
sn - the expected region transition target server name
Throws:
org.apache.zookeeper.KeeperException - if unexpected zookeeper exception
KeeperException.NoNodeException - if node does not exist

deleteClosingNode

public static boolean deleteClosingNode(ZooKeeperWatcher zkw,
                                        HRegionInfo region,
                                        ServerName sn)
                                 throws org.apache.zookeeper.KeeperException,
                                        org.apache.zookeeper.KeeperException.NoNodeException
Deletes an existing unassigned node that is in the CLOSING state for the specified region.

If a node does not already exist for this region, a KeeperException.NoNodeException will be thrown.

No watcher is set whether this succeeds or not.

Returns false if the node was not in the proper state but did exist.

This method is used during table disables when a region finishes successfully closing. This is the Master acknowledging completion of the specified regions transition to being closed.

Parameters:
zkw - zk reference
region - closing region to be deleted from zk
sn - the expected region transition target server name
Throws:
org.apache.zookeeper.KeeperException - if unexpected zookeeper exception
KeeperException.NoNodeException - if node does not exist

deleteNode

public static boolean deleteNode(ZooKeeperWatcher zkw,
                                 String encodedRegionName,
                                 EventType expectedState,
                                 ServerName sn)
                          throws org.apache.zookeeper.KeeperException,
                                 org.apache.zookeeper.KeeperException.NoNodeException
Deletes an existing unassigned node that is in the specified state for the specified region.

If a node does not already exist for this region, a KeeperException.NoNodeException will be thrown.

No watcher is set whether this succeeds or not.

Returns false if the node was not in the proper state but did exist.

This method is used when a region finishes opening/closing. The Master acknowledges completion of the specified regions transition to being closed/opened.

Parameters:
zkw - zk reference
encodedRegionName - region to be deleted from zk
expectedState - state region must be in for delete to complete
sn - the expected region transition target server name
Throws:
org.apache.zookeeper.KeeperException - if unexpected zookeeper exception
KeeperException.NoNodeException - if node does not exist

deleteNode

public static boolean deleteNode(ZooKeeperWatcher zkw,
                                 String encodedRegionName,
                                 EventType expectedState,
                                 int expectedVersion)
                          throws org.apache.zookeeper.KeeperException,
                                 org.apache.zookeeper.KeeperException.NoNodeException
Deletes an existing unassigned node that is in the specified state for the specified region.

If a node does not already exist for this region, a KeeperException.NoNodeException will be thrown.

No watcher is set whether this succeeds or not.

Returns false if the node was not in the proper state but did exist.

This method is used when a region finishes opening/closing. The Master acknowledges completion of the specified regions transition to being closed/opened.

Parameters:
zkw - zk reference
encodedRegionName - region to be deleted from zk
expectedState - state region must be in for delete to complete
expectedVersion - of the znode that is to be deleted. If expectedVersion need not be compared while deleting the znode pass -1
Throws:
org.apache.zookeeper.KeeperException - if unexpected zookeeper exception
KeeperException.NoNodeException - if node does not exist

deleteNode

public static boolean deleteNode(ZooKeeperWatcher zkw,
                                 String encodedRegionName,
                                 EventType expectedState,
                                 ServerName serverName,
                                 int expectedVersion)
                          throws org.apache.zookeeper.KeeperException,
                                 org.apache.zookeeper.KeeperException.NoNodeException
Deletes an existing unassigned node that is in the specified state for the specified region.

If a node does not already exist for this region, a KeeperException.NoNodeException will be thrown.

No watcher is set whether this succeeds or not.

Returns false if the node was not in the proper state but did exist.

This method is used when a region finishes opening/closing. The Master acknowledges completion of the specified regions transition to being closed/opened.

Parameters:
zkw - zk reference
encodedRegionName - region to be deleted from zk
expectedState - state region must be in for delete to complete
serverName - the expected region transition target server name
expectedVersion - of the znode that is to be deleted. If expectedVersion need not be compared while deleting the znode pass -1
Throws:
org.apache.zookeeper.KeeperException - if unexpected zookeeper exception
KeeperException.NoNodeException - if node does not exist

deleteAllNodes

public static void deleteAllNodes(ZooKeeperWatcher zkw)
                           throws org.apache.zookeeper.KeeperException
Deletes all unassigned nodes regardless of their state.

No watchers are set.

This method is used by the Master during cluster startup to clear out any existing state from other cluster runs.

Parameters:
zkw - zk reference
Throws:
org.apache.zookeeper.KeeperException - if unexpected zookeeper exception

createNodeClosing

public static int createNodeClosing(ZooKeeperWatcher zkw,
                                    HRegionInfo region,
                                    ServerName serverName)
                             throws org.apache.zookeeper.KeeperException,
                                    org.apache.zookeeper.KeeperException.NodeExistsException
Creates a new unassigned node in the CLOSING state for the specified region.

Does not transition nodes from any states. If a node already exists for this region, a KeeperException.NodeExistsException will be thrown.

If creation is successful, returns the version number of the CLOSING node created.

Set a watch.

This method should only be used by a Master when initiating a close of a region before sending a close request to the region server.

Parameters:
zkw - zk reference
region - region to be created as closing
serverName - server transition will happen on
Returns:
version of node after transition, -1 if unsuccessful transition
Throws:
org.apache.zookeeper.KeeperException - if unexpected zookeeper exception
KeeperException.NodeExistsException - if node already exists

transitionNodeClosed

public static int transitionNodeClosed(ZooKeeperWatcher zkw,
                                       HRegionInfo region,
                                       ServerName serverName,
                                       int expectedVersion)
                                throws org.apache.zookeeper.KeeperException
Transitions an existing unassigned node for the specified region which is currently in the CLOSING state to be in the CLOSED state.

Does not transition nodes from other states. If for some reason the node could not be transitioned, the method returns -1. If the transition is successful, the version of the node after transition is returned.

This method can fail and return false for three different reasons:

Does not set any watches.

This method should only be used by a RegionServer when initiating a close of a region after receiving a CLOSE RPC from the Master.

Parameters:
zkw - zk reference
region - region to be transitioned to closed
serverName - server transition happens on
Returns:
version of node after transition, -1 if unsuccessful transition
Throws:
org.apache.zookeeper.KeeperException - if unexpected zookeeper exception

transitionNodeOpening

public static int transitionNodeOpening(ZooKeeperWatcher zkw,
                                        HRegionInfo region,
                                        ServerName serverName)
                                 throws org.apache.zookeeper.KeeperException
Transitions an existing unassigned node for the specified region which is currently in the OFFLINE state to be in the OPENING state.

Does not transition nodes from other states. If for some reason the node could not be transitioned, the method returns -1. If the transition is successful, the version of the node written as OPENING is returned.

This method can fail and return -1 for three different reasons:

Does not set any watches.

This method should only be used by a RegionServer when initiating an open of a region after receiving an OPEN RPC from the Master.

Parameters:
zkw - zk reference
region - region to be transitioned to opening
serverName - server transition happens on
Returns:
version of node after transition, -1 if unsuccessful transition
Throws:
org.apache.zookeeper.KeeperException - if unexpected zookeeper exception

transitionNodeOpening

public static int transitionNodeOpening(ZooKeeperWatcher zkw,
                                        HRegionInfo region,
                                        ServerName serverName,
                                        EventType beginState)
                                 throws org.apache.zookeeper.KeeperException
Throws:
org.apache.zookeeper.KeeperException

retransitionNodeOpening

public static int retransitionNodeOpening(ZooKeeperWatcher zkw,
                                          HRegionInfo region,
                                          ServerName serverName,
                                          int expectedVersion,
                                          boolean updateZNode)
                                   throws org.apache.zookeeper.KeeperException
Retransitions an existing unassigned node for the specified region which is currently in the OPENING state to be in the OPENING state.

Does not transition nodes from other states. If for some reason the node could not be transitioned, the method returns -1. If the transition is successful, the version of the node rewritten as OPENING is returned.

This method can fail and return -1 for three different reasons:

Does not set any watches.

This method should only be used by a RegionServer when initiating an open of a region after receiving an OPEN RPC from the Master.

Parameters:
zkw - zk reference
region - region to be transitioned to opening
serverName - server transition happens on
updateZNode - write the znode. If false, we only check.
Returns:
version of node after transition, -1 if unsuccessful transition
Throws:
org.apache.zookeeper.KeeperException - if unexpected zookeeper exception

transitionNodeOpened

public static int transitionNodeOpened(ZooKeeperWatcher zkw,
                                       HRegionInfo region,
                                       ServerName serverName,
                                       int expectedVersion)
                                throws org.apache.zookeeper.KeeperException
Transitions an existing unassigned node for the specified region which is currently in the OPENING state to be in the OPENED state.

Does not transition nodes from other states. If for some reason the node could not be transitioned, the method returns -1. If the transition is successful, the version of the node after transition is returned.

This method can fail and return false for three different reasons:

Does not set any watches.

This method should only be used by a RegionServer when completing the open of a region.

Parameters:
zkw - zk reference
region - region to be transitioned to opened
serverName - server transition happens on
Returns:
version of node after transition, -1 if unsuccessful transition
Throws:
org.apache.zookeeper.KeeperException - if unexpected zookeeper exception

checkClosingState

public static boolean checkClosingState(ZooKeeperWatcher zkw,
                                        HRegionInfo region,
                                        int expectedVersion)
                                 throws org.apache.zookeeper.KeeperException
Parameters:
zkw - zk reference
region - region to be closed
expectedVersion - expected version of the znode
Returns:
true if the znode exists, has the right version and the right state. False otherwise.
Throws:
org.apache.zookeeper.KeeperException

transitionNode

public static int transitionNode(ZooKeeperWatcher zkw,
                                 HRegionInfo region,
                                 ServerName serverName,
                                 EventType beginState,
                                 EventType endState,
                                 int expectedVersion)
                          throws org.apache.zookeeper.KeeperException
Method that actually performs unassigned node transitions.

Attempts to transition the unassigned node for the specified region from the expected state to the state in the specified transition data.

Method first reads existing data and verifies it is in the expected state. If the node does not exist or the node is not in the expected state, the method returns -1. If the transition is successful, the version number of the node following the transition is returned.

If the read state is what is expected, it attempts to write the new state and data into the node. When doing this, it includes the expected version (determined when the existing state was verified) to ensure that only one transition is successful. If there is a version mismatch, the method returns -1.

If the write is successful, no watch is set and the method returns true.

Parameters:
zkw - zk reference
region - region to be transitioned to opened
serverName - server transition happens on
endState - state to transition node to if all checks pass
beginState - state the node must currently be in to do transition
expectedVersion - expected version of data before modification, or -1
Returns:
version of node after transition, -1 if unsuccessful transition
Throws:
org.apache.zookeeper.KeeperException - if unexpected zookeeper exception

transitionNode

public static int transitionNode(ZooKeeperWatcher zkw,
                                 HRegionInfo region,
                                 ServerName serverName,
                                 EventType beginState,
                                 EventType endState,
                                 int expectedVersion,
                                 byte[] payload)
                          throws org.apache.zookeeper.KeeperException
Throws:
org.apache.zookeeper.KeeperException

getData

public static byte[] getData(ZooKeeperWatcher zkw,
                             String pathOrRegionName)
                      throws org.apache.zookeeper.KeeperException
Gets the current data in the unassigned node for the specified region name or fully-qualified path.

Returns null if the region does not currently have a node.

Sets a watch on the node if the node exists.

Parameters:
zkw - zk reference
pathOrRegionName - fully-specified path or region name
Returns:
znode content
Throws:
org.apache.zookeeper.KeeperException - if unexpected zookeeper exception

getDataAndWatch

public static byte[] getDataAndWatch(ZooKeeperWatcher zkw,
                                     String pathOrRegionName,
                                     org.apache.zookeeper.data.Stat stat)
                              throws org.apache.zookeeper.KeeperException
Gets the current data in the unassigned node for the specified region name or fully-qualified path.

Returns null if the region does not currently have a node.

Sets a watch on the node if the node exists.

Parameters:
zkw - zk reference
pathOrRegionName - fully-specified path or region name
stat - object to populate the version.
Returns:
znode content
Throws:
org.apache.zookeeper.KeeperException - if unexpected zookeeper exception

getDataNoWatch

public static byte[] getDataNoWatch(ZooKeeperWatcher zkw,
                                    String pathOrRegionName,
                                    org.apache.zookeeper.data.Stat stat)
                             throws org.apache.zookeeper.KeeperException
Gets the current data in the unassigned node for the specified region name or fully-qualified path.

Returns null if the region does not currently have a node.

Does not set a watch.

Parameters:
zkw - zk reference
pathOrRegionName - fully-specified path or region name
stat - object to store node info into on getData call
Returns:
znode content
Throws:
org.apache.zookeeper.KeeperException - if unexpected zookeeper exception

getPath

public static String getPath(ZooKeeperWatcher zkw,
                             String pathOrRegionName)
Parameters:
zkw -
pathOrRegionName -
Returns:
Path to znode

getVersion

public static int getVersion(ZooKeeperWatcher zkw,
                             HRegionInfo region)
                      throws org.apache.zookeeper.KeeperException
Get the version of the specified znode

Parameters:
zkw - zk reference
region - region's info
Returns:
the version of the znode, -1 if it doesn't exist
Throws:
org.apache.zookeeper.KeeperException

deleteNodeFailSilent

public static void deleteNodeFailSilent(ZooKeeperWatcher watcher,
                                        HRegionInfo regionInfo)
                                 throws org.apache.zookeeper.KeeperException
Delete the assignment node regardless of its current state.

Fail silent even if the node does not exist at all.

Parameters:
watcher -
regionInfo -
Throws:
org.apache.zookeeper.KeeperException

blockUntilNoRIT

public static void blockUntilNoRIT(ZooKeeperWatcher zkw)
                            throws org.apache.zookeeper.KeeperException,
                                   InterruptedException
Blocks until there are no node in regions in transition.

Used in testing only.

Parameters:
zkw - zk reference
Throws:
org.apache.zookeeper.KeeperException
InterruptedException

blockUntilRIT

public static void blockUntilRIT(ZooKeeperWatcher zkw)
                          throws org.apache.zookeeper.KeeperException,
                                 InterruptedException
Blocks until there is at least one node in regions in transition.

Used in testing only.

Parameters:
zkw - zk reference
Throws:
org.apache.zookeeper.KeeperException
InterruptedException


Copyright © 2007-2016 The Apache Software Foundation. All Rights Reserved.