Class Network
java.lang.Object
tools.refinery.interpreter.rete.network.Network
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ArrayList
<ReteContainer> protected final Map
<ReteContainer, Long> protected InputConnector
protected tools.refinery.interpreter.rete.network.NodeFactory
protected Map
<ReteContainer, Long> protected Lock
protected Lock
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
connectRemoteNodes
(Address<? extends Supplier> supplier, Address<? extends Receiver> receiver, boolean synchronise) Establishes connection between a supplier and a receiver node, regardless which container they are in.void
disconnectRemoteNodes
(Address<? extends Supplier> supplier, Address<? extends Receiver> receiver, boolean desynchronise) Severs connection between a supplier and a receiver node, regardless which container they are in.Returns the head container, that is guaranteed to reside in the same JVM as the Network object.Returns the next container in round-robin fashion.tools.refinery.interpreter.rete.network.NodeFactory
void
kill()
Kills this Network along with all containers and message consumption cycles.void
sendConstructionUpdate
(Address<? extends Receiver> receiver, Direction direction, Tuple updateElement) Sends an update message to the receiver node, indicating a newly found or lost partial matching.void
sendConstructionUpdates
(Address<? extends Receiver> receiver, Direction direction, Collection<Tuple> updateElements) Sends multiple update messages atomically to the receiver node, indicating a newly found or lost partial matching.void
sendExternalUpdate
(Address<? extends Receiver> receiver, Direction direction, Tuple updateElement) Sends an update message to the receiver node, indicating a newly found or lost partial matching.void
Waits until all rete update operations are settled in all containers.void
waitForReteTermination
(Runnable action) Waits to execute action until all rete update operations are settled in all containers.
-
Field Details
-
containers
-
globalTerminationCriteria
-
reportedClocks
-
updateLock
-
structuralChangeLock
-
nodeFactory
protected tools.refinery.interpreter.rete.network.NodeFactory nodeFactory -
inputConnector
-
-
Constructor Details
-
Network
- Parameters:
threads
- the number of threads to operate the network with; 0 means single-threaded operation, 1 starts an asynchronous thread to operate the RETE net, >1 uses multiple RETE containers.
-
-
Method Details
-
getExistingNodeByRecipe
- Throws:
IllegalStateException
- if no node has been constructed for the recipe
-
getNodeByRecipeIfExists
- Returns:
- null if no node has been constructed for the recipe
-
kill
public void kill()Kills this Network along with all containers and message consumption cycles. -
getHeadContainer
Returns the head container, that is guaranteed to reside in the same JVM as the Network object. -
getNextContainer
Returns the next container in round-robin fashion. Configurable not to yield head container. -
sendExternalUpdate
public void sendExternalUpdate(Address<? extends Receiver> receiver, Direction direction, Tuple updateElement) Sends an update message to the receiver node, indicating a newly found or lost partial matching. The node may reside in any of the containers associated with this network. To be called from a user thread during normal operation, NOT during construction.- Since:
- 2.4
-
sendConstructionUpdate
public void sendConstructionUpdate(Address<? extends Receiver> receiver, Direction direction, Tuple updateElement) Sends an update message to the receiver node, indicating a newly found or lost partial matching. The node may reside in any of the containers associated with this network. To be called from a user thread during construction.- Since:
- 2.4
-
sendConstructionUpdates
public void sendConstructionUpdates(Address<? extends Receiver> receiver, Direction direction, Collection<Tuple> updateElements) Sends multiple update messages atomically to the receiver node, indicating a newly found or lost partial matching. The node may reside in any of the containers associated with this network. To be called from a user thread during construction.- Since:
- 2.4
-
connectRemoteNodes
public void connectRemoteNodes(Address<? extends Supplier> supplier, Address<? extends Receiver> receiver, boolean synchronise) Establishes connection between a supplier and a receiver node, regardless which container they are in. Not to be called remotely, because this method enforces the structural lock.- Parameters:
supplier
-receiver
-synchronise
- indicates whether the receiver should be synchronised to the current contents of the supplier
-
disconnectRemoteNodes
public void disconnectRemoteNodes(Address<? extends Supplier> supplier, Address<? extends Receiver> receiver, boolean desynchronise) Severs connection between a supplier and a receiver node, regardless which container they are in. Not to be called remotely, because this method enforces the structural lock.- Parameters:
supplier
-receiver
-desynchronise
- indicates whether the current contents of the supplier should be subtracted from the receiver
-
waitForReteTermination
public void waitForReteTermination()Waits until all rete update operations are settled in all containers. Returns immediately, if no updates are pending. To be called from any user thread. -
waitForReteTermination
Waits to execute action until all rete update operations are settled in all containers. Runs action and returns immediately, if no updates are pending. The given action is guaranteed to be run when the terminated state still persists.- Parameters:
action
- the action to be run when reaching the steady-state. To be called from any user thread.
-
getRecipeTraces
- Returns:
- an unmodifiable set of known recipe traces
-
getContainers
- Returns:
- an unmodifiable list of containers
-
getStructuralChangeLock
-
getNodeFactory
public tools.refinery.interpreter.rete.network.NodeFactory getNodeFactory() -
getInputConnector
-
getEngine
-