public static Pair < BabySitter , List < String > > blockingFactory ( ZooKeeper zk , String dir , Callback cb , ExecutorService es ) throws InterruptedException , ExecutionException { BabySitter bs = new BabySitter ( zk , dir , cb , es ) ; List < String > initialChildren ; try { initialChildren = bs . m_eventHandler . call ( ) ; } catch ( Exception e ) { throw new ExecutionException ( e ) ; } return new Pair < BabySitter , List < String > > ( bs , initialChildren ) ; }
Create a new BabySitter and block on reading the initial children list . Use the provided ExecutorService to queue events to rather than creating a private ExecutorService . The initial set of children will be retrieved in the current thread and not the ExecutorService because it is assumed this is being called from the ExecutorService