Package org.drools.core.common

Examples of org.drools.core.common.EventFactHandle


                              final Object context,
                              final InternalFactHandle fact,
                              final PropagationContext pctx,
                              final InternalWorkingMemory workingMemory) {
        final SlidingTimeWindowContext queue = (SlidingTimeWindowContext) context;
        final EventFactHandle handle = (EventFactHandle) fact;
        synchronized (queue.queue) {
            queue.queue.add( handle );
            if ( queue.queue.peek() == handle ) {
                // update next expiration time
                updateNextExpiration( handle,
View Full Code Here


                            final Object context,
                            final InternalFactHandle fact,
                            final PropagationContext pctx,
                            final InternalWorkingMemory workingMemory) {
        final SlidingTimeWindowContext queue = (SlidingTimeWindowContext) context;
        final EventFactHandle handle = (EventFactHandle) fact;
        // it may be a call back to expire the tuple that is already being expired
        synchronized (queue.queue) {
            if ( queue.expiringHandle != handle ) {
                if ( queue.queue.peek() == handle ) {
                    // it was the head of the queue
View Full Code Here

                            final PropagationContext pctx,
                            final InternalWorkingMemory workingMemory) {
        TimerService clock = workingMemory.getTimerService();
        long currentTime = clock.getCurrentTime();
        SlidingTimeWindowContext queue = (SlidingTimeWindowContext) context;
        EventFactHandle handle = queue.queue.peek();
        synchronized (queue.queue) {
            while ( handle != null && isExpired( currentTime,
                                                 handle ) ) {
                queue.expiringHandle = handle;
                queue.queue.remove();
                if( handle.isValid()) {
                    // if not expired yet, expire it
                    final PropagationContext expiresPctx = new PropagationContextImpl( workingMemory.getNextPropagationIdCounter(),
                                                                                       PropagationContext.EXPIRATION,
                                                                                       null,
                                                                                       null,
View Full Code Here

            BehaviorJobContext bjobCtx = ( BehaviorJobContext ) jobCtx;
           
            // write out SlidingTimeWindowContext
            SlidingTimeWindowContext slCtx = ( SlidingTimeWindowContext ) bjobCtx.behaviorContext;
 
            EventFactHandle handle = slCtx.getQueue().peek();
            outputCtx.writeInt( handle.getId() );

//            BetaNode node = (BetaNode) handle.getRightTupleSink();
//            outputCtx.writeInt( node.getId() );
//
//            Behavior[] behaviors = node.getBehaviors();
View Full Code Here

            // BehaviorJob, no state           
            BehaviorJobContext bjobCtx = ( BehaviorJobContext ) jobCtx;
            // write out SlidingTimeWindowContext
            SlidingTimeWindowContext slCtx = ( SlidingTimeWindowContext ) bjobCtx.behaviorContext;
 
            EventFactHandle handle = slCtx.getQueue().peek();
           
            return ProtobufMessages.Timers.Timer.newBuilder()
                    .setType( ProtobufMessages.Timers.TimerType.BEHAVIOR )
                    .setBehavior( ProtobufMessages.Timers.BehaviorTimer.newBuilder()
                                  .setHandleId( handle.getId() )
                                  .build() )
                    .build();
        }
View Full Code Here

    private void removeQueuedTupleEntry() {
        TupleEntry tupleEntry = pmem.getQueue().remove();
        PropagationContext originalPctx = tupleEntry.getPropagationContext();

        EventFactHandle  evFh1 = null;
        EventFactHandle  evFh2 = null;
        if ( tupleEntry.getLeftTuple() != null ) {
            evFh1 = ( EventFactHandle ) tupleEntry.getLeftTuple().getLastHandle();
        else {
            evFh1 = ( EventFactHandle ) tupleEntry.getRightTuple().getFactHandle();
        }
View Full Code Here

            outputCtx.writeShort( WorkingMemoryAction.WorkingMemoryBehahviourRetract );

            // write out SlidingTimeWindowContext
            SlidingTimeWindowContext slCtx = ( SlidingTimeWindowContext ) context;

            EventFactHandle handle = slCtx.getQueue().peek();
            outputCtx.writeInt( handle.getId() );
        }
View Full Code Here

        _handle.setId( handle.getId() );
        _handle.setRecency( handle.getRecency() );

        if ( _handle.getType() == ProtobufMessages.FactHandle.HandleType.EVENT ) {
            // is event
            EventFactHandle efh = (EventFactHandle) handle;
            _handle.setTimestamp( efh.getStartTimestamp() );
            _handle.setDuration( efh.getDuration() );
            _handle.setIsExpired( efh.isExpired() );
            _handle.setActivationsCount( efh.getActivationsCount() );
        }

        if ( handle.getEqualityKey() != null &&
             handle.getEqualityKey().getStatus() == EqualityKey.JUSTIFIED ) {
            _handle.setIsJustified( true );
View Full Code Here

                  new Integer(99));
        props.put( "duration",
                   new Integer( 52 ) );
        msg.setProperties(props);

        EventFactHandle efh = (EventFactHandle) ksession.insert( msg );
        assertEquals( 98,
                      efh.getStartTimestamp() );
        assertEquals( 53,
                      efh.getDuration() );

    }
View Full Code Here

        StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
        Message msg = new Message();
        msg.setStartTime( new Timestamp( 10000 ) );
        msg.setDuration( 1000l );

        EventFactHandle efh = (EventFactHandle) ksession.insert( msg );
        assertEquals( 10000,
                      efh.getStartTimestamp() );
        assertEquals( 1000,
                      efh.getDuration() );
    }
View Full Code Here

TOP

Related Classes of org.drools.core.common.EventFactHandle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.