public final class ReteContainer
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected IQueryBackendContext |
backendContext |
protected java.util.LinkedList<Clearable> |
clearables |
protected java.lang.Long |
clock |
protected org.eclipse.viatra.query.runtime.rete.network.ConnectionFactory |
connectionFactory |
protected java.lang.Thread |
consumerThread |
protected java.util.Set<org.eclipse.viatra.query.runtime.rete.network.delayed.DelayedCommand> |
delayedCommandBuffer |
protected java.util.Set<org.eclipse.viatra.query.runtime.rete.network.delayed.DelayedCommand> |
delayedCommandQueue |
protected boolean |
executingDelayedCommands |
protected java.lang.Object |
externalMessageLock |
protected java.util.Deque<org.eclipse.viatra.query.runtime.rete.network.UpdateMessage> |
externalMessageQueue |
protected java.util.Deque<org.eclipse.viatra.query.runtime.rete.network.UpdateMessage> |
internalMessageQueue |
protected boolean |
killed |
protected org.apache.log4j.Logger |
logger |
static java.util.function.Function<Node,java.lang.String> |
NAME_MAPPER |
protected Network |
network |
protected long |
nextId |
protected NodeProvisioner |
nodeProvisioner |
protected java.util.Map<java.lang.Long,Node> |
nodesById |
protected java.util.Map<ReteContainer,java.lang.Long> |
terminationCriteria |
protected CommunicationTracker |
tracker |
Constructor and Description |
---|
ReteContainer(Network network,
boolean threaded) |
Modifier and Type | Method and Description |
---|---|
void |
clearAll()
Clears all memory contents in the network.
|
void |
connect(Supplier supplier,
Receiver receiver)
Connects a receiver to a supplier
|
void |
connectAndSynchronize(Supplier supplier,
Receiver receiver)
Connects a receiver to a remote supplier, and synchronizes it to the current contents of the supplier
|
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.
|
void |
connectRemoteSupplier(Address<? extends Supplier> supplier,
Receiver receiver,
boolean synchronise)
Establishes connection between a remote supplier and a local receiver node.
|
void |
deliverMessagesSingleThreaded()
Sends out all pending messages to their receivers.
|
void |
disconnect(Supplier supplier,
Receiver receiver)
Disconnects a receiver from a supplier
|
void |
disconnectAndDesynchronize(Supplier supplier,
Receiver receiver)
Disconnects a receiver from a supplier
|
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.
|
void |
disconnectRemoteSupplier(Address<? extends Supplier> supplier,
Receiver receiver,
boolean desynchronise)
Severs connection between a remote supplier and a local receiver node.
|
void |
executeDelayedCommands() |
void |
flushUpdates()
Finalises all update sequences and returns.
|
java.util.Collection<Node> |
getAllNodes()
Access all the Rete nodes inside this container.
|
CommunicationTracker |
getCommunicationTracker() |
org.eclipse.viatra.query.runtime.rete.network.ConnectionFactory |
getConnectionFactory() |
java.util.Set<org.eclipse.viatra.query.runtime.rete.network.delayed.DelayedCommand> |
getDelayedCommandQueue() |
InputConnector |
getInputConnectionFactory() |
Network |
getNetwork() |
org.eclipse.viatra.query.runtime.rete.network.NodeFactory |
getNodeFactory() |
NodeProvisioner |
getProvisioner() |
boolean |
isDifferentialDataFlowEvaluation() |
boolean |
isExecutingDelayedCommands() |
boolean |
isLocal(Address<? extends Node> address)
Checks whether a certain address points to a node at this container.
|
void |
kill()
Stops this container.
|
<N extends Node> |
makeAddress(N node)
Provides an external address for the selected node.
|
java.util.Set<Tuple> |
pullContents(Supplier supplier,
boolean flush)
Retrieves a safe copy of the contents of a supplier.
|
java.util.Map<Tuple,Timestamp> |
pullContentsWithTimestamp(Supplier supplier,
boolean flush) |
java.util.Collection<Tuple> |
pullPropagatedContents(SingleInputNode supplier,
boolean flush)
Retrieves the contents of a SingleInputNode's parentage.
|
java.util.Map<Tuple,Timestamp> |
pullPropagatedContentsWithTimestamp(SingleInputNode supplier,
boolean flush)
Retrieves the timestamp-aware contents of a SingleInputNode's parentage.
|
void |
registerClearable(Clearable c)
Registers a pattern memory into the rete network.
|
long |
registerNode(Node n)
Registers a node into the rete network (should be called by constructor).
|
java.util.Map<java.lang.String,java.lang.Integer> |
remotePosMapping(Address<? extends ProductionNode> production)
Proxies for the getPosMapping() of Production nodes.
|
java.util.Collection<Tuple> |
remotePull(Address<? extends Supplier> supplier,
boolean flush)
Retrieves the contents of a supplier for a remote caller.
|
<N extends Node> |
resolveLocal(Address<N> address)
Returns an addressed node at this container.
|
void |
sendUpdateToRemoteAddress(Address<? extends Receiver> address,
Direction direction,
Tuple updateElement)
Sends an update message to a node in a different container.
|
java.lang.String |
toString() |
void |
unregisterClearable(Clearable c)
Unregisters a pattern memory from the rete network.
|
void |
unregisterNode(Node n)
Unregisters a node from the rete network.
|
protected java.lang.Thread consumerThread
protected boolean killed
protected Network network
protected java.util.LinkedList<Clearable> clearables
protected java.util.Map<java.lang.Long,Node> nodesById
protected long nextId
protected org.eclipse.viatra.query.runtime.rete.network.ConnectionFactory connectionFactory
protected NodeProvisioner nodeProvisioner
protected java.util.Deque<org.eclipse.viatra.query.runtime.rete.network.UpdateMessage> internalMessageQueue
protected java.util.Deque<org.eclipse.viatra.query.runtime.rete.network.UpdateMessage> externalMessageQueue
protected java.lang.Object externalMessageLock
protected java.lang.Long clock
protected java.util.Map<ReteContainer,java.lang.Long> terminationCriteria
protected final org.apache.log4j.Logger logger
protected final CommunicationTracker tracker
protected final IQueryBackendContext backendContext
protected java.util.Set<org.eclipse.viatra.query.runtime.rete.network.delayed.DelayedCommand> delayedCommandQueue
protected java.util.Set<org.eclipse.viatra.query.runtime.rete.network.delayed.DelayedCommand> delayedCommandBuffer
protected boolean executingDelayedCommands
public static final java.util.function.Function<Node,java.lang.String> NAME_MAPPER
public ReteContainer(Network network, boolean threaded)
threaded
- false if operating in a single-threaded environmentpublic boolean isDifferentialDataFlowEvaluation()
public CommunicationTracker getCommunicationTracker()
public void kill()
public void connectRemoteNodes(Address<? extends Supplier> supplier, Address<? extends Receiver> receiver, boolean synchronise)
synchronise
- indicates whether the receiver should be synchronised to the current contents of the supplierpublic void disconnectRemoteNodes(Address<? extends Supplier> supplier, Address<? extends Receiver> receiver, boolean desynchronise)
desynchronise
- indicates whether the current contents of the supplier should be subtracted from the receiverpublic void connectRemoteSupplier(Address<? extends Supplier> supplier, Receiver receiver, boolean synchronise)
synchronise
- indicates whether the receiver should be synchronised to the current contents of the supplierpublic void disconnectRemoteSupplier(Address<? extends Supplier> supplier, Receiver receiver, boolean desynchronise)
desynchronise
- indicates whether the current contents of the supplier should be subtracted from the receiverpublic void disconnect(Supplier supplier, Receiver receiver)
public boolean isExecutingDelayedCommands()
public java.util.Set<org.eclipse.viatra.query.runtime.rete.network.delayed.DelayedCommand> getDelayedCommandQueue()
public void connectAndSynchronize(Supplier supplier, Receiver receiver)
public void disconnectAndDesynchronize(Supplier supplier, Receiver receiver)
public void executeDelayedCommands()
public void sendUpdateToRemoteAddress(Address<? extends Receiver> address, Direction direction, Tuple updateElement)
public void flushUpdates()
public java.util.Set<Tuple> pullContents(Supplier supplier, boolean flush)
public java.util.Map<Tuple,Timestamp> pullContentsWithTimestamp(Supplier supplier, boolean flush)
public java.util.Collection<Tuple> pullPropagatedContents(SingleInputNode supplier, boolean flush)
public java.util.Map<Tuple,Timestamp> pullPropagatedContentsWithTimestamp(SingleInputNode supplier, boolean flush)
public java.util.Collection<Tuple> remotePull(Address<? extends Supplier> supplier, boolean flush)
supplier
- the address of the supplier to be pulled.public java.util.Map<java.lang.String,java.lang.Integer> remotePosMapping(Address<? extends ProductionNode> production)
public void deliverMessagesSingleThreaded()
public <N extends Node> Address<N> makeAddress(N node)
public boolean isLocal(Address<? extends Node> address)
public <N extends Node> N resolveLocal(Address<N> address)
java.lang.IllegalArgumentException
- if address is non-localpublic long registerNode(Node n)
public void unregisterNode(Node n)
public void registerClearable(Clearable c)
public void unregisterClearable(Clearable c)
public void clearAll()
public org.eclipse.viatra.query.runtime.rete.network.NodeFactory getNodeFactory()
public org.eclipse.viatra.query.runtime.rete.network.ConnectionFactory getConnectionFactory()
public NodeProvisioner getProvisioner()
public Network getNetwork()
public java.lang.String toString()
toString
in class java.lang.Object
public java.util.Collection<Node> getAllNodes()
Node
instancespublic InputConnector getInputConnectionFactory()