org.drools.reteoo
Class PropagationQueuingNode

java.lang.Object
  extended by org.drools.common.BaseNode
      extended by org.drools.reteoo.ObjectSource
          extended by org.drools.reteoo.PropagationQueuingNode
All Implemented Interfaces:
Externalizable, Serializable, NetworkNode, NodeMemory, ObjectSink, ObjectSinkNode, Sink

public class PropagationQueuingNode
extends ObjectSource
implements ObjectSinkNode, NodeMemory

A node that will add the propagation to the working memory actions queue, in order to allow multiple threads to concurrently assert objects to multiple entry points.

See Also:
Serialized Form

Nested Class Summary
static class PropagationQueuingNode.PropagateAction
          This is the action that is added to the working memory actions queue, so that this node propagation can be triggered at a safe point
static class PropagationQueuingNode.PropagationQueueingNodeMemory
          Memory implementation for the node
 
Field Summary
 
Fields inherited from class org.drools.reteoo.ObjectSource
sink, source
 
Fields inherited from class org.drools.common.BaseNode
associations, id, partitionId, partitionsEnabled
 
Constructor Summary
PropagationQueuingNode()
           
PropagationQueuingNode(int id, ObjectSource objectSource, BuildContext context)
          Construct a PropagationQueuingNode that will queue up propagations until it the engine reaches a safe propagation point, when all the queued facts are propagated.
 
Method Summary
 void assertObject(InternalFactHandle factHandle, PropagationContext context, InternalWorkingMemory workingMemory)
           
 void attach()
          Attaches the node into the network.
 void attach(InternalWorkingMemory[] workingMemories)
           
 Memory createMemory(RuleBaseConfiguration config)
           
 ObjectSinkNode getNextObjectSinkNode()
          Returns the next node
 ObjectSinkNode getPreviousObjectSinkNode()
          Returns the previous node
 boolean isObjectMemoryEnabled()
           
 void modifyObject(InternalFactHandle factHandle, ModifyPreviousTuples modifyPreviousTuples, PropagationContext context, InternalWorkingMemory workingMemory)
           
 void propagateActions(InternalWorkingMemory workingMemory)
          Propagate all queued actions (asserts and retracts).
 void readExternal(ObjectInput in)
           
 void retractObject(InternalFactHandle handle, PropagationContext context, InternalWorkingMemory workingMemory)
           
 void setNextObjectSinkNode(ObjectSinkNode next)
          Sets the next node
 void setObjectMemoryEnabled(boolean objectMemoryOn)
           
 void setPreviousObjectSinkNode(ObjectSinkNode previous)
          Sets the previous node
 void updateSink(ObjectSink sink, PropagationContext context, InternalWorkingMemory workingMemory)
           
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class org.drools.reteoo.ObjectSource
addObjectSink, doRemove, getParentObjectSource, getSinkPropagator, isInUse, networkUpdated, removeObjectSink
 
Methods inherited from class org.drools.common.BaseNode
addAssociation, getAssociations, getId, getPartitionId, hashCode, remove, removeAssociation, setPartitionId, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.drools.common.NetworkNode
getId, getPartitionId
 
Methods inherited from interface org.drools.common.NodeMemory
getId
 

Constructor Detail

PropagationQueuingNode

public PropagationQueuingNode()

PropagationQueuingNode

public PropagationQueuingNode(int id,
                              ObjectSource objectSource,
                              BuildContext context)
Construct a PropagationQueuingNode that will queue up propagations until it the engine reaches a safe propagation point, when all the queued facts are propagated.

Parameters:
id - Node's ID
objectSource - Node's object source
context -
Method Detail

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Overrides:
readExternal in class ObjectSource
Throws:
IOException
ClassNotFoundException

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Overrides:
writeExternal in class ObjectSource
Throws:
IOException

updateSink

public void updateSink(ObjectSink sink,
                       PropagationContext context,
                       InternalWorkingMemory workingMemory)
Specified by:
updateSink in class ObjectSource
See Also:
ObjectSource.updateSink(org.drools.reteoo.ObjectSink, org.drools.spi.PropagationContext, org.drools.common.InternalWorkingMemory)

attach

public void attach()
Description copied from class: BaseNode
Attaches the node into the network. Usually to the parent ObjectSource or TupleSource

Specified by:
attach in class BaseNode
See Also:
BaseNode.attach()

attach

public void attach(InternalWorkingMemory[] workingMemories)
Specified by:
attach in class BaseNode
See Also:
BaseNode.attach(org.drools.common.InternalWorkingMemory[])

getNextObjectSinkNode

public ObjectSinkNode getNextObjectSinkNode()
Description copied from interface: ObjectSinkNode
Returns the next node

Specified by:
getNextObjectSinkNode in interface ObjectSinkNode
Returns:
The next LinkedListNode
See Also:
ObjectSinkNode.getNextObjectSinkNode()

getPreviousObjectSinkNode

public ObjectSinkNode getPreviousObjectSinkNode()
Description copied from interface: ObjectSinkNode
Returns the previous node

Specified by:
getPreviousObjectSinkNode in interface ObjectSinkNode
Returns:
The previous LinkedListNode
See Also:
ObjectSinkNode.getPreviousObjectSinkNode()

setNextObjectSinkNode

public void setNextObjectSinkNode(ObjectSinkNode next)
Description copied from interface: ObjectSinkNode
Sets the next node

Specified by:
setNextObjectSinkNode in interface ObjectSinkNode
Parameters:
next - The next LinkedListNode
See Also:
ObjectSinkNode.setNextObjectSinkNode(org.drools.reteoo.ObjectSinkNode)

setPreviousObjectSinkNode

public void setPreviousObjectSinkNode(ObjectSinkNode previous)
Description copied from interface: ObjectSinkNode
Sets the previous node

Specified by:
setPreviousObjectSinkNode in interface ObjectSinkNode
Parameters:
previous - The previous LinkedListNode
See Also:
ObjectSinkNode.setPreviousObjectSinkNode(org.drools.reteoo.ObjectSinkNode)

isObjectMemoryEnabled

public boolean isObjectMemoryEnabled()

assertObject

public void assertObject(InternalFactHandle factHandle,
                         PropagationContext context,
                         InternalWorkingMemory workingMemory)
Specified by:
assertObject in interface ObjectSink
See Also:
ObjectSink.assertObject(InternalFactHandle, org.drools.spi.PropagationContext, org.drools.common.InternalWorkingMemory)

retractObject

public void retractObject(InternalFactHandle handle,
                          PropagationContext context,
                          InternalWorkingMemory workingMemory)

modifyObject

public void modifyObject(InternalFactHandle factHandle,
                         ModifyPreviousTuples modifyPreviousTuples,
                         PropagationContext context,
                         InternalWorkingMemory workingMemory)
Specified by:
modifyObject in interface ObjectSink

propagateActions

public void propagateActions(InternalWorkingMemory workingMemory)
Propagate all queued actions (asserts and retracts).

This method implementation is based on optimistic behavior to avoid the use of locks. There may eventually be a minimum wasted effort, but overall it will be better than paying for the lock's cost.

Parameters:
workingMemory -

setObjectMemoryEnabled

public void setObjectMemoryEnabled(boolean objectMemoryOn)

createMemory

public Memory createMemory(RuleBaseConfiguration config)
Specified by:
createMemory in interface NodeMemory


Copyright © 2001-2012 JBoss by Red Hat. All Rights Reserved.