use of org.drools.core.time.JobHandle in project jbpm by kiegroup.
the class TaskDeadlinesServiceImpl method unschedule.
public void unschedule(long taskId, Deadline deadline, DeadlineType type) {
Task task = persistenceContext.findTask(taskId);
String deploymentId = task.getTaskData().getDeploymentId();
TimerService timerService = TimerServiceRegistry.getInstance().get(deploymentId + TimerServiceRegistry.TIMER_SERVICE_SUFFIX);
if (timerService instanceof GlobalTimerService) {
TaskDeadlineJob deadlineJob = new TaskDeadlineJob(taskId, deadline.getId(), type, deploymentId, task.getTaskData().getProcessInstanceId());
logger.debug("unscheduling timer job for deadline {} {} and task {} using timer service {}", deadlineJob.getId(), deadline.getId(), taskId, timerService);
JobHandle jobHandle = jobHandles.remove(deadlineJob.getId());
if (jobHandle == null) {
jobHandle = ((GlobalTimerService) timerService).buildJobHandleForContext(new TaskDeadlineJobContext(deadlineJob.getId(), task.getTaskData().getProcessInstanceId(), deploymentId));
}
timerService.removeJob(jobHandle);
// mark the deadlines so they won't be rescheduled again
deadline.setEscalated(true);
}
}
use of org.drools.core.time.JobHandle in project drools by kiegroup.
the class EventFactHandle method unscheduleAllJobs.
public void unscheduleAllJobs(ReteEvaluator reteEvaluator) {
if (!jobs.isEmpty()) {
synchronized (jobs) {
TimerService clock = reteEvaluator.getTimerService();
while (!jobs.isEmpty()) {
JobHandle job = jobs.removeFirst();
clock.removeJob(job);
}
}
}
}
use of org.drools.core.time.JobHandle in project drools by kiegroup.
the class ExpireJobContextTimerInputMarshaller method read.
public void read(ProtobufMarshallerReaderContext inCtx) throws IOException, ClassNotFoundException {
InternalFactHandle factHandle = inCtx.getHandles().get(inCtx.readLong());
long nextTimeStamp = inCtx.readLong();
TimerService clock = inCtx.getWorkingMemory().getTimerService();
JobContext jobctx = new ExpireJobContext(new WorkingMemoryReteExpireAction((EventFactHandle) factHandle), inCtx.getWorkingMemory());
JobHandle handle = clock.scheduleJob(job, jobctx, PointInTimeTrigger.createPointInTimeTrigger(nextTimeStamp, null));
jobctx.setJobHandle(handle);
}
use of org.drools.core.time.JobHandle in project drools by kiegroup.
the class EventFactHandle method unscheduleAllJobs.
public void unscheduleAllJobs(InternalWorkingMemory workingMemory) {
if (!jobs.isEmpty()) {
synchronized (jobs) {
TimerService clock = workingMemory.getTimerService();
while (!jobs.isEmpty()) {
JobHandle job = jobs.removeFirst();
clock.removeJob(job);
}
}
}
}
use of org.drools.core.time.JobHandle in project drools by kiegroup.
the class SlidingTimeWindow method updateNextExpiration.
protected void updateNextExpiration(final InternalFactHandle fact, final InternalWorkingMemory workingMemory, final Behavior.Context context, final int nodeId) {
TimerService clock = workingMemory.getTimerService();
if (fact != null) {
long nextTimestamp = ((EventFactHandle) fact).getStartTimestamp() + getSize();
if (nextTimestamp < clock.getCurrentTime()) {
// Past and out-of-order events should not be insert,
// but the engine silently accepts them anyway, resulting in possibly undesirable behaviors
workingMemory.queueWorkingMemoryAction(new BehaviorExpireWMAction(nodeId, this, context));
} else {
JobContext jobctx = new BehaviorJobContext(nodeId, workingMemory, this, context);
JobHandle handle = clock.scheduleJob(job, jobctx, new PointInTimeTrigger(nextTimestamp, null, null));
jobctx.setJobHandle(handle);
}
}
}
Aggregations