Class CommunicationTracker
java.lang.Object
tools.refinery.interpreter.rete.network.communication.CommunicationTracker
- Direct Known Subclasses:
- TimelessCommunicationTracker,- TimelyCommunicationTracker
An instance of this class is associated with every 
(1) It allows RETE nodes to register their communication dependencies on-the-fly. These dependencies can be registered or unregistered when nodes are disposed of.
(2) It allows RETE nodes to register their mailboxes as dirty, that is, they can tell the tracker that they have something to send to other nodes in the network. The tracker is then responsible for ordering these messages (more precisely, the mailboxes that contain the messages) for the associated
ReteContainer. The tracker serves two purposes: (1) It allows RETE nodes to register their communication dependencies on-the-fly. These dependencies can be registered or unregistered when nodes are disposed of.
(2) It allows RETE nodes to register their mailboxes as dirty, that is, they can tell the tracker that they have something to send to other nodes in the network. The tracker is then responsible for ordering these messages (more precisely, the mailboxes that contain the messages) for the associated
ReteContainer. The ordering is
 governed by the strongly connected components in the dependency network and follows a topological sorting scheme;
 those mailboxes will be emptied first whose owner nodes do not depend on other undelivered messages.- Since:
- 1.6
- 
Field SummaryFieldsModifier and TypeFieldDescriptionThe dependency graph of the communications in the RETE networkprotected final Map<Node, CommunicationGroup> Precomputed node -> communication group mapprotected final Queue<CommunicationGroup> Priority queue of active communication groupsprotected intThe maximum group id assigned so farprotected intThe minimum group id assigned so far
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidbooleanareInSameGroup(Node left, Node right) Returns true if the given twoNodes are in the sameCommunicationGroup.protected CommunicationGroupcreateAndStoreGroup(Node representative, int index) protected abstract CommunicationGroupcreateGroup(Node representative, int index) voiddeactivate(CommunicationGroup group) getPartition(Node node) protected NodegetRepresentative(Node node) protected booleanhasOutgoingEdges(Node representative) booleanisEmpty()booleanisInRecursiveGroup(Node node) Returns true if the givenNodeis in a recursiveCommunicationGroup, false otherwise.protected booleanisRecursionCutPoint(Node source, Node target) Returns true if the given source-target edge in the communication network acts as a recursion cut point.protected booleanisSingleton(Node node) protected abstract voidThis hook allows concrete tracker implementations to perform tracker-specific post processing on groups.protected abstract voidpostProcessNode(Node node) This hook allows concrete tracker implementations to perform tracker-specific post processing on nodes (cf.abstract IndexerListenerproxifyIndexerListener(Node requester, IndexerListener original) Creates a proxy for the givenIndexerListenerfor the given requesterNode.abstract MailboxproxifyMailbox(Node requester, Mailbox original) protected abstract voidreconstructQueueContents(Set<CommunicationGroup> oldActiveGroups) This method is responsible for reconstructing the active queue contents after the network structure has changed.voidregisterDependency(Node source, Node target) voidunregisterDependency(Node source, Node target) Unregisters a dependency between source and target.
- 
Field Details- 
minGroupIdprotected int minGroupIdThe minimum group id assigned so far
- 
maxGroupIdprotected int maxGroupIdThe maximum group id assigned so far
- 
dependencyGraphThe dependency graph of the communications in the RETE network
- 
groupMapPrecomputed node -> communication group map
- 
groupQueuePriority queue of active communication groups
 
- 
- 
Constructor Details- 
CommunicationTrackerpublic CommunicationTracker(org.apache.log4j.Logger logger) 
 
- 
- 
Method Details- 
getDependencyGraph
- 
getGroup
- 
getPartition
- 
isSingleton
- 
getRepresentative
- 
hasOutgoingEdges
- 
getReducedGraph
- 
reconstructQueueContentsThis method is responsible for reconstructing the active queue contents after the network structure has changed. It it defined as abstract because the reconstruction logic is specific to eachCommunicationTracker.- Since:
- 2.4
 
- 
activateUnenqueued
- 
deactivate
- 
getAndRemoveFirstGroup
- 
isEmptypublic boolean isEmpty()
- 
createGroup
- 
createAndStoreGroup
- 
registerDependencyRegisters the dependency that the targetNodedepends on the sourceNode. In other words, source may send messages to target in the RETE network. If the dependency edge is already present, this method call is a noop.- Parameters:
- source- the source node
- target- the target node
 
- 
isInRecursiveGroupReturns true if the givenNodeis in a recursiveCommunicationGroup, false otherwise.
- 
areInSameGroupReturns true if the given twoNodes are in the sameCommunicationGroup.
- 
unregisterDependencyUnregisters a dependency between source and target.- Parameters:
- source- the source node
- target- the target node
 
- 
isRecursionCutPointReturns true if the given source-target edge in the communication network acts as a recursion cut point. The current implementation considers edges leading intoProductionNodes as cut point iff both source and target belong to the same group.- Parameters:
- source- the source node
- target- the target node
- Returns:
- true if the edge is a cut point, false otherwise
- Since:
- 2.4
 
- 
postProcessNodeThis hook allows concrete tracker implementations to perform tracker-specific post processing on nodes (cf.NetworkStructureChangeSensitiveNodeandBehaviorChangingMailbox). At the time of the invocation, the network topology has already been updated.
- 
postProcessGroupThis hook allows concrete tracker implementations to perform tracker-specific post processing on groups. At the time of the invocation, the network topology has already been updated.- Since:
- 2.4
 
- 
proxifyMailboxCreates a proxy for the givenMailboxfor the given requesterNode. The proxy creation isCommunicationTracker-specific and depends on the identity of the requester. This method is primarily used to createTimelyMailboxProxys depending on the network topology. There is no guarantee that the same proxy instance is returned when this method is called multiple times with the same arguments.
- 
proxifyIndexerListenerCreates a proxy for the givenIndexerListenerfor the given requesterNode. The proxy creation isCommunicationTracker-specific and depends on the identity of the requester. This method is primarily used to createTimelyIndexerListenerProxys depending on the network topology. There is no guarantee that the same proxy instance is returned when this method is called multiple times with the same arguments.
 
-