@ Override public void addJob ( final Job job ) throws JobExistsException { log . info ( "adding job: {}" , job ) ; final JobId id = job . getId ( ) ; final UUID operationId = UUID . randomUUID ( ) ; final String creationPath = Paths . configJobCreation ( id , operationId ) ; final ZooKeeperClient client = provider . get ( "addJob" ) ; try { try { client . ensurePath ( Paths . historyJob ( id ) ) ; client . transaction ( create ( Paths . configJob ( id ) , job ) , create ( Paths . configJobRefShort ( id ) , id ) , create ( Paths . configJobHosts ( id ) ) , create ( creationPath ) , // Touch the jobs root node so that its version is bumped on every job // change down the tree. Effectively, make it that version == cVersion. set ( Paths . configJobs ( ) , UUID . randomUUID ( ) . toString ( ) . getBytes ( ) ) ) ; } catch ( final NodeExistsException e ) { if ( client . exists ( creationPath ) != null ) { // The job was created, we're done here return ; } throw new JobExistsException ( id . toString ( ) ) ; } } catch ( NoNodeException e ) { throw new HeliosRuntimeException ( "adding job " + job + " failed due to missing ZK path: " + e . getPath ( ) , e ) ; } catch ( final KeeperException e ) { throw new HeliosRuntimeException ( "adding job " + job + " failed" , e ) ; } }
Adds a job into the configuration .