Package org.drools.core.common

Examples of org.drools.core.common.EventFactHandle


        final WindowMemory memory = (WindowMemory) workingMemory.getNodeMemory(this);

        // must guarantee single thread from now on
        memory.gate.lock();

        EventFactHandle originalFactHandle = ( EventFactHandle ) rightTuple.getFactHandle();
        EventFactHandle cloneFactHandle  = ( EventFactHandle ) rightTuple.getObject();
        originalFactHandle.quickCloneUpdate( cloneFactHandle ); // make sure all fields are updated

        // behavior modify
        try {
            int index = 0;
            boolean isAllowed = true;
            for (AlphaNodeFieldConstraint constraint : constraints) {
                if (!constraint.isAllowed(cloneFactHandle,
                                          workingMemory,
                                          memory.context[index++])) {
                    isAllowed = false;
                    break;
                }
            }

            if  ( isAllowed ) {
                ModifyPreviousTuples modifyPreviousTuples = new ModifyPreviousTuples(cloneFactHandle.getFirstLeftTuple(), cloneFactHandle.getFirstRightTuple(), epNode );
                cloneFactHandle.clearLeftTuples();
                cloneFactHandle.clearRightTuples();

                this.sink.propagateModifyObject(cloneFactHandle,
                                                modifyPreviousTuples,
                                                context,
                                                workingMemory);
View Full Code Here


        final WindowMemory memory = (WindowMemory) workingMemory.getNodeMemory(this);

        // must guarantee single thread from now on
        memory.gate.lock();

        EventFactHandle originalFactHandle = ( EventFactHandle ) rightTuple.getFactHandle();
        EventFactHandle cloneFactHandle  = ( EventFactHandle ) rightTuple.getObject();
        originalFactHandle.quickCloneUpdate( cloneFactHandle ); // make sure all fields are updated

        // behavior modify
        try {
            int index = 0;
            boolean isAllowed = true;
            for (AlphaNodeFieldConstraint constraint : constraints) {
                if (!constraint.isAllowed(cloneFactHandle,
                                          workingMemory,
                                          memory.context[index++])) {
                    isAllowed = false;
                    break;
                }
            }

            if  ( isAllowed ) {
                ModifyPreviousTuples modifyPreviousTuples = new ModifyPreviousTuples(cloneFactHandle.getFirstLeftTuple(), cloneFactHandle.getFirstRightTuple(), epNode );
                cloneFactHandle.clearLeftTuples();
                cloneFactHandle.clearRightTuples();

                this.sink.propagateModifyObject(cloneFactHandle,
                                                modifyPreviousTuples,
                                                context,
                                                workingMemory);
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

    public void assertObject(final InternalFactHandle factHandle,
                             final PropagationContext pctx,
                             final InternalWorkingMemory workingMemory) {
        final WindowMemory memory = (WindowMemory) workingMemory.getNodeMemory(this);

        EventFactHandle evFh = ( EventFactHandle ) factHandle;
        // must guarantee single thread from now on
        memory.gate.lock();
        try {
            int index = 0;
            for (AlphaNodeFieldConstraint constraint : constraints) {
                if (!constraint.isAllowed(evFh, workingMemory, memory.context[index++])) {
                    return;
                }
            }

            RightTuple rightTuple = new RightTuple( evFh, this );
            rightTuple.setPropagationContext( pctx );

            InternalFactHandle clonedFh = evFh.cloneAndLink()// this is cloned, as we need to separate the child RightTuple references
            rightTuple.setObject( clonedFh );

            // process the behavior
            if (!behavior.assertFact(memory, clonedFh, pctx, workingMemory)) {
                return;
View Full Code Here

    public Trigger createTrigger(Activation item, InternalWorkingMemory wm) {
        long timestamp;
        if (eventFactHandle != null) {
            LeftTuple leftTuple = item.getTuple();
            EventFactHandle  fh = (EventFactHandle) leftTuple.get(eventFactHandle);
            timestamp = fh.getStartTimestamp();
        } else {
            timestamp = wm.getTimerService().getCurrentTime();
        }
        String[] calendarNames = item.getRule().getCalendars();
        Calendars calendars = wm.getCalendars();
View Full Code Here

                              final PropagationContext pctx,
                              final InternalWorkingMemory workingMemory) {
        SlidingLengthWindowContext window = (SlidingLengthWindowContext) context;
        window.pos = (window.pos + 1) % window.handles.length;
        if ( window.handles[window.pos] != null ) {
            final EventFactHandle previous = window.handles[window.pos];
            // retract previous
            PropagationContextFactory pctxFactory = workingMemory.getKnowledgeBase().getConfiguration().getComponentFactory().getPropagationContextFactory();
            final PropagationContext expiresPctx = pctxFactory.createPropagationContext(pctx.getPropagationNumber(), PropagationContext.EXPIRATION,
                                                                                        null, null, previous);
            ObjectTypeNode.doRetractObject( previous, expiresPctx, workingMemory);
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;
        long currentTime = workingMemory.getTimerService().getCurrentTime();
        if ( isExpired( currentTime, handle ) ) {
            return false;
        }
        synchronized (queue.queue) {
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 InternalWorkingMemory workingMemory) {
        TimerService clock = workingMemory.getTimerService();
        long currentTime = clock.getCurrentTime();
        SlidingTimeWindowContext queue = (SlidingTimeWindowContext) context;
        synchronized (queue.queue) {
            EventFactHandle handle = queue.queue.peek();
            while ( handle != null && isExpired( currentTime,
                                                 handle ) ) {
                queue.expiringHandle = handle;
                queue.queue.remove();
                if( handle.isValid()) {
                    // if not expired yet, expire it
                    PropagationContextFactory pctxFactory = workingMemory.getKnowledgeBase().getConfiguration().getComponentFactory().getPropagationContextFactory();
                    final PropagationContext expiresPctx = pctxFactory.createPropagationContext(workingMemory.getNextPropagationIdCounter(), PropagationContext.EXPIRATION,
                                                                                                null, null, handle);
                    ObjectTypeNode.doRetractObject(handle, expiresPctx, workingMemory);
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

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.