Package org.drools.core.reteoo
Class WindowNode
- java.lang.Object
-
- org.drools.core.common.BaseNode
-
- org.drools.core.reteoo.ObjectSource
-
- org.drools.core.reteoo.WindowNode
-
- All Implemented Interfaces:
Externalizable
,Serializable
,MemoryFactory<WindowNode.WindowMemory>
,NetworkNode
,ObjectSink
,ObjectSinkNode
,RightTupleSink
,Sink
public class WindowNode extends ObjectSource implements ObjectSinkNode, RightTupleSink, MemoryFactory<WindowNode.WindowMemory>
WindowNodes
are nodes in theRete
network used to manage windows. They support multiple types of windows, like sliding windows, tumbling windows, etc. This class must act as a lock-gate for all working memory actions on it and propagated down the network in this branch, as there can be concurrent threads propagating events and expiring events working on this node at the same time. It requires it to be thread safe.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
WindowNode.WindowMemory
-
Field Summary
Fields Modifier and Type Field Description protected BehaviorManager
behavior
-
Fields inherited from class org.drools.core.reteoo.ObjectSource
alphaNodeHashingThreshold, alphaNodeRangeIndexThreshold, declaredMask, inferredMask, sink, source
-
Fields inherited from class org.drools.core.common.BaseNode
associations, hashcode, id, memoryId, partitionId, partitionsEnabled
-
-
Constructor Summary
Constructors Constructor Description WindowNode()
WindowNode(int id, List<AlphaNodeFieldConstraint> constraints, List<Behavior> behaviors, ObjectSource objectSource, BuildContext context)
Construct aWindowNode
with a unique id using the provided list ofAlphaNodeFieldConstraint
and the givenObjectSource
.
-
Method Summary
-
Methods inherited from class org.drools.core.reteoo.ObjectSource
addObjectSink, doRemove, getDeclaredMask, getKnowledgeBase, getObjectSinkPropagator, getObjectTypeNode, getParentObjectSource, initDeclaredMask, isInUse, networkUpdated, removeObjectSink, resetInferredMask, setObjectSinkPropagator, setParentObjectSource, setPartitionId, setPartitionIdWithSinks, setSourcePartitionId, updateMask
-
Methods inherited from class org.drools.core.common.BaseNode
addAssociation, addAssociation, attach, getAssociatedRules, getAssociatedRuleSize, getAssociationsSize, getAssociationsSize, getId, getMemoryId, getPartitionId, getSinks, hashCode, initMemoryId, isAssociatedWith, isStreamMode, remove, removeAssociation, setId, setPartitionsEnabled, setStreamMode
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.drools.core.common.MemoryFactory
getMemoryId
-
Methods inherited from interface org.drools.core.common.NetworkNode
getAssociatedRules, getAssociatedRuleSize, getAssociationsSize, getAssociationsSize, getId, getPartitionId, isAssociatedWith
-
Methods inherited from interface org.drools.core.reteoo.ObjectSinkNode
setPartitionIdWithSinks
-
-
-
-
Field Detail
-
behavior
protected BehaviorManager behavior
-
-
Constructor Detail
-
WindowNode
public WindowNode()
-
WindowNode
public WindowNode(int id, List<AlphaNodeFieldConstraint> constraints, List<Behavior> behaviors, ObjectSource objectSource, BuildContext context)
Construct aWindowNode
with a unique id using the provided list ofAlphaNodeFieldConstraint
and the givenObjectSource
.- Parameters:
id
- Node's IDconstraints
- Node's constraintsbehaviors
- list of behaviors for this window nodeobjectSource
- Node's object source
-
-
Method Detail
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternal
in interfaceExternalizable
- Overrides:
readExternal
in classObjectSource
- Throws:
IOException
ClassNotFoundException
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternal
in interfaceExternalizable
- Overrides:
writeExternal
in classObjectSource
- Throws:
IOException
-
getType
public short getType()
- Specified by:
getType
in interfaceNetworkNode
-
getConstraints
public List<AlphaNodeFieldConstraint> getConstraints()
Returns theFieldConstraints
- Returns:
FieldConstraints
-
getBehaviors
public Behavior[] getBehaviors()
Returns the list of behaviors for this window node
-
doAttach
public void doAttach(BuildContext context)
-
assertObject
public void assertObject(InternalFactHandle factHandle, PropagationContext pctx, InternalWorkingMemory workingMemory)
- Specified by:
assertObject
in interfaceObjectSink
-
retractRightTuple
public void retractRightTuple(RightTuple rightTuple, PropagationContext pctx, InternalWorkingMemory wm)
- Specified by:
retractRightTuple
in interfaceRightTupleSink
-
modifyRightTuple
public void modifyRightTuple(RightTuple rightTuple, PropagationContext context, InternalWorkingMemory workingMemory)
- Specified by:
modifyRightTuple
in interfaceRightTupleSink
-
modifyObject
public void modifyObject(InternalFactHandle factHandle, ModifyPreviousTuples modifyPreviousTuples, PropagationContext context, InternalWorkingMemory wm)
- Specified by:
modifyObject
in interfaceObjectSink
-
byPassModifyToBetaNode
public void byPassModifyToBetaNode(InternalFactHandle factHandle, ModifyPreviousTuples modifyPreviousTuples, PropagationContext context, InternalWorkingMemory workingMemory)
- Specified by:
byPassModifyToBetaNode
in interfaceObjectSink
-
updateSink
public void updateSink(ObjectSink sink, PropagationContext context, InternalWorkingMemory wm)
- Specified by:
updateSink
in classObjectSource
-
createMemory
public WindowNode.WindowMemory createMemory(RuleBaseConfiguration config, InternalWorkingMemory wm)
Creates the WindowNode's memory.- Specified by:
createMemory
in interfaceMemoryFactory<WindowNode.WindowMemory>
-
getNextObjectSinkNode
public ObjectSinkNode getNextObjectSinkNode()
Returns the next node- Specified by:
getNextObjectSinkNode
in interfaceObjectSinkNode
- Returns:
- The next ObjectSinkNode
-
setNextObjectSinkNode
public void setNextObjectSinkNode(ObjectSinkNode next)
Sets the next node- Specified by:
setNextObjectSinkNode
in interfaceObjectSinkNode
- Parameters:
next
- The next ObjectSinkNode
-
getPreviousObjectSinkNode
public ObjectSinkNode getPreviousObjectSinkNode()
Returns the previous node- Specified by:
getPreviousObjectSinkNode
in interfaceObjectSinkNode
- Returns:
- The previous ObjectSinkNode
-
setPreviousObjectSinkNode
public void setPreviousObjectSinkNode(ObjectSinkNode previous)
Sets the previous node- Specified by:
setPreviousObjectSinkNode
in interfaceObjectSinkNode
- Parameters:
previous
- The previous ObjectSinkNode
-
getEntryPoint
public EntryPointId getEntryPoint()
-
calculateDeclaredMask
public BitMask calculateDeclaredMask(Class modifiedClass, List<String> settableProperties)
- Specified by:
calculateDeclaredMask
in classObjectSource
-
getRightInputOtnId
public ObjectTypeNode.Id getRightInputOtnId()
- Specified by:
getRightInputOtnId
in interfaceRightTupleSink
-
setRightInputOtnId
public void setRightInputOtnId(ObjectTypeNode.Id rightInputOtnId)
-
-