Search in sources :

Example 1 with ActiveNotFoundException

use of org.apache.hadoop.ha.ActiveStandbyElector.ActiveNotFoundException in project hadoop by apache.

the class ZKFailoverController method getCurrentActive.

/**
   * @return an {@link HAServiceTarget} for the current active node
   * in the cluster, or null if no node is active.
   * @throws IOException if a ZK-related issue occurs
   * @throws InterruptedException if thread is interrupted 
   */
private HAServiceTarget getCurrentActive() throws IOException, InterruptedException {
    synchronized (elector) {
        synchronized (this) {
            byte[] activeData;
            try {
                activeData = elector.getActiveData();
            } catch (ActiveNotFoundException e) {
                return null;
            } catch (KeeperException ke) {
                throw new IOException("Unexpected ZooKeeper issue fetching active node info", ke);
            }
            HAServiceTarget oldActive = dataToTarget(activeData);
            return oldActive;
        }
    }
}
Also used : ActiveNotFoundException(org.apache.hadoop.ha.ActiveStandbyElector.ActiveNotFoundException) IOException(java.io.IOException) KeeperException(org.apache.zookeeper.KeeperException)

Aggregations

IOException (java.io.IOException)1 ActiveNotFoundException (org.apache.hadoop.ha.ActiveStandbyElector.ActiveNotFoundException)1 KeeperException (org.apache.zookeeper.KeeperException)1