public void waitForJoiningHostsToBeReady ( int expectedHosts , int localHostId ) { try { //register this host as joining. The host registration will be deleted after joining is completed. m_zk . create ( ZKUtil . joinZKPath ( CoreZK . readyjoininghosts , Integer . toString ( localHostId ) ) , null , Ids . OPEN_ACL_UNSAFE , CreateMode . PERSISTENT ) ; while ( true ) { ZKUtil . FutureWatcher fw = new ZKUtil . FutureWatcher ( ) ; int readyHosts = m_zk . getChildren ( CoreZK . readyjoininghosts , fw ) . size ( ) ; if ( readyHosts == expectedHosts ) { break ; } fw . get ( ) ; } } catch ( KeeperException | InterruptedException e ) { org . voltdb . VoltDB . crashLocalVoltDB ( "Error waiting for hosts to be ready" , false , e ) ; } }
For elastic join . Block on this call until the number of ready hosts is equal to the number of expected joining hosts .