private void purgeDeadJobInstances ( DbConn cnx , Node node ) { for ( JobInstance ji : JobInstance . select ( cnx , "ji_select_by_node" , node . getId ( ) ) ) { try { cnx . runSelectSingle ( "history_select_state_by_id" , String . class , ji . getId ( ) ) ; } catch ( NoResultException e ) { History . create ( cnx , ji , State . CRASHED , Calendar . getInstance ( ) ) ; Message . create ( cnx , "Job was supposed to be running at server startup - usually means it was killed along a server by an admin or a crash" , ji . getId ( ) ) ; } cnx . runUpdate ( "ji_delete_by_id" , ji . getId ( ) ) ; } cnx . commit ( ) ; }
To be called at node startup - it purges all job instances associated to this node .