Search in sources :

Example 1 with BehaviorJobContext

use of org.drools.core.rule.SlidingTimeWindow.BehaviorJobContext in project drools by kiegroup.

the class BehaviorJobContextTimerOutputMarshaller method serialize.

@Override
public ProtobufMessages.Timers.Timer serialize(JobContext jobCtx, MarshallerWriteContext outputCtx) {
    // BehaviorJob, no state
    BehaviorJobContext bjobCtx = (BehaviorJobContext) jobCtx;
    // write out SlidingTimeWindowContext
    SlidingTimeWindowContext slCtx = (SlidingTimeWindowContext) bjobCtx.behaviorContext;
    EventFactHandle handle = slCtx.peek();
    return ProtobufMessages.Timers.Timer.newBuilder().setType(ProtobufMessages.Timers.TimerType.BEHAVIOR).setBehavior(ProtobufMessages.Timers.BehaviorTimer.newBuilder().setHandleId(handle.getId()).build()).build();
}
Also used : BehaviorJobContext(org.drools.core.rule.SlidingTimeWindow.BehaviorJobContext) EventFactHandle(org.drools.core.common.EventFactHandle) SlidingTimeWindowContext(org.drools.core.rule.SlidingTimeWindow.SlidingTimeWindowContext)

Example 2 with BehaviorJobContext

use of org.drools.core.rule.SlidingTimeWindow.BehaviorJobContext in project drools by kiegroup.

the class BehaviorJobContextTimerOutputMarshaller method write.

public void write(JobContext jobCtx, MarshallerWriteContext outputCtx) throws IOException {
    outputCtx.writeShort(PersisterEnums.BEHAVIOR_TIMER);
    // BehaviorJob, no state
    BehaviorJobContext bjobCtx = (BehaviorJobContext) jobCtx;
    // write out SlidingTimeWindowContext
    SlidingTimeWindowContext slCtx = (SlidingTimeWindowContext) bjobCtx.behaviorContext;
    EventFactHandle handle = slCtx.peek();
    outputCtx.writeLong(handle.getId());
}
Also used : BehaviorJobContext(org.drools.core.rule.SlidingTimeWindow.BehaviorJobContext) EventFactHandle(org.drools.core.common.EventFactHandle) SlidingTimeWindowContext(org.drools.core.rule.SlidingTimeWindow.SlidingTimeWindowContext)

Aggregations

EventFactHandle (org.drools.core.common.EventFactHandle)2 BehaviorJobContext (org.drools.core.rule.SlidingTimeWindow.BehaviorJobContext)2 SlidingTimeWindowContext (org.drools.core.rule.SlidingTimeWindow.SlidingTimeWindowContext)2