protected Context createContext ( ) throws DurableDataLogException { val serviceConfig = getServiceConfig ( ) ; val bkConfig = getCommandArgs ( ) . getState ( ) . getConfigBuilder ( ) . include ( BookKeeperConfig . builder ( ) . with ( BookKeeperConfig . ZK_ADDRESS , serviceConfig . getZkURL ( ) ) ) . build ( ) . getConfig ( BookKeeperConfig :: builder ) ; val zkClient = createZKClient ( ) ; val factory = new BookKeeperLogFactory ( bkConfig , zkClient , getCommandArgs ( ) . getState ( ) . getExecutor ( ) ) ; try { factory . initialize ( ) ; } catch ( DurableDataLogException ex ) { zkClient . close ( ) ; throw ex ; } val bkAdmin = new BookKeeperAdmin ( factory . getBookKeeperClient ( ) ) ; return new Context ( serviceConfig , bkConfig , zkClient , factory , bkAdmin ) ; }
Creates a new Context to be used by the BookKeeper command .