public static void startAndWait ( PersistentNode node , int maxWaitSec ) { node . start ( ) ; int waitTime = 0 ; try { while ( node . waitForInitialCreate ( 1 , TimeUnit . SECONDS ) == false ) { waitTime += 1 ; log . info ( "Waited " + waitTime + " sec for ephemeral node to be created" ) ; if ( waitTime > maxWaitSec ) { throw new IllegalStateException ( "Failed to create ephemeral node" ) ; } } } catch ( InterruptedException e ) { throw new IllegalStateException ( e ) ; } }
Starts the ephemeral node and waits for it to be created