@ Override public boolean removeJob ( JobKey jobKey , Jedis jedis ) throws JobPersistenceException { final String jobHashKey = redisSchema . jobHashKey ( jobKey ) ; final String jobBlockedKey = redisSchema . jobBlockedKey ( jobKey ) ; final String jobDataMapHashKey = redisSchema . jobDataMapHashKey ( jobKey ) ; final String jobGroupSetKey = redisSchema . jobGroupSetKey ( jobKey ) ; final String jobTriggerSetKey = redisSchema . jobTriggersSetKey ( jobKey ) ; Pipeline pipe = jedis . pipelined ( ) ; // remove the job and any associated data Response < Long > delJobHashKeyResponse = pipe . del ( jobHashKey ) ; // remove the blocked job key pipe . del ( jobBlockedKey ) ; // remove the job's data map pipe . del ( jobDataMapHashKey ) ; // remove the job from the set of all jobs pipe . srem ( redisSchema . jobsSet ( ) , jobHashKey ) ; // remove the job from the set of blocked jobs pipe . srem ( redisSchema . blockedJobsSet ( ) , jobHashKey ) ; // remove the job from its group pipe . srem ( jobGroupSetKey , jobHashKey ) ; // retrieve the keys for all triggers associated with this job, then delete that set Response < Set < String > > jobTriggerSetResponse = pipe . smembers ( jobTriggerSetKey ) ; pipe . del ( jobTriggerSetKey ) ; Response < Long > jobGroupSetSizeResponse = pipe . scard ( jobGroupSetKey ) ; pipe . sync ( ) ; if ( jobGroupSetSizeResponse . get ( ) == 0 ) { // The group now contains no jobs. Remove it from the set of all job groups. jedis . srem ( redisSchema . jobGroupsSet ( ) , jobGroupSetKey ) ; } // remove all triggers associated with this job pipe = jedis . pipelined ( ) ; for ( String triggerHashKey : jobTriggerSetResponse . get ( ) ) { // get this trigger's TriggerKey final TriggerKey triggerKey = redisSchema . triggerKey ( triggerHashKey ) ; final String triggerGroupSetKey = redisSchema . triggerGroupSetKey ( triggerKey ) ; unsetTriggerState ( triggerHashKey , jedis ) ; // remove the trigger from the set of all triggers pipe . srem ( redisSchema . triggersSet ( ) , triggerHashKey ) ; // remove the trigger's group from the set of all trigger groups pipe . srem ( redisSchema . triggerGroupsSet ( ) , triggerGroupSetKey ) ; // remove this trigger from its group pipe . srem ( triggerGroupSetKey , triggerHashKey ) ; // delete the trigger pipe . del ( triggerHashKey ) ; } pipe . sync ( ) ; return delJobHashKeyResponse . get ( ) == 1 ; }
Remove the given job from Redis