use of org.drools.core.time.SelfRemovalJobContext in project drools by kiegroup.
the class JpaJDKTimerService method createCallableJob.
protected Callable<Void> createCallableJob(Job job, JobContext ctx, Trigger trigger, JDKJobHandle handle, InternalSchedulerService scheduler) {
JpaJDKCallableJob jobInstance = new JpaJDKCallableJob(new SelfRemovalJob(job), new SelfRemovalJobContext(ctx, timerInstances), trigger, handle, scheduler);
this.timerInstances.put(handle.getId(), jobInstance);
return jobInstance;
}
use of org.drools.core.time.SelfRemovalJobContext in project drools by kiegroup.
the class ProtobufOutputMarshaller method writeTimers.
private static ProtobufMessages.Timers writeTimers(Collection<TimerJobInstance> timers, MarshallerWriteContext outCtx) {
if (!timers.isEmpty()) {
List<TimerJobInstance> sortedTimers = new ArrayList<TimerJobInstance>(timers);
Collections.sort(sortedTimers, new Comparator<TimerJobInstance>() {
public int compare(TimerJobInstance o1, TimerJobInstance o2) {
return (int) (o1.getJobHandle().getId() - o2.getJobHandle().getId());
}
});
ProtobufMessages.Timers.Builder _timers = ProtobufMessages.Timers.newBuilder();
for (TimerJobInstance timer : sortedTimers) {
JobContext jctx = ((SelfRemovalJobContext) timer.getJobContext()).getJobContext();
if (jctx instanceof ObjectTypeNode.ExpireJobContext && !((ObjectTypeNode.ExpireJobContext) jctx).getExpireAction().getFactHandle().isValid()) {
continue;
}
TimersOutputMarshaller writer = outCtx.writersByClass.get(jctx.getClass());
Timer _timer = writer.serialize(jctx, outCtx);
if (_timer != null) {
_timers.addTimer(_timer);
}
}
return _timers.build();
}
return null;
}
Aggregations