org.eclipse.incquery.runtime.rete.network

## Class ReteContainer

- java.lang.Object
- - org.eclipse.incquery.runtime.rete.network.ReteContainer

-     public final class ReteContainer
      extends java.lang.Object

  Author:
    Gabor Bergmann Mutexes: externalMessageLock - enlisting messages into and retrieving from the external message queue

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ReteContainer(Network network, boolean threaded)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    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 synchronises 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` | `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` | `flushUpdates()` Finalises all update sequences and returns.
    `java.util.Collection<Node>` | `getAllNodes()` Access all the Rete nodes inside this container.
    `org.eclipse.incquery.runtime.rete.network.ConnectionFactory` | `getConnectionFactory()`
    `InputConnector` | `getInputConnectionFactory()`
    `Network` | `getNetwork()`
    `org.eclipse.incquery.runtime.rete.network.NodeFactory` | `getNodeFactory()`
    `NodeProvisioner` | `getProvisioner()`
    `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> Address<N>` | `makeAddress(N node)` Provides an external address for the selected node.
    `java.util.Collection<Tuple>` | `pullContents(Supplier supplier)` Retrieves a safe copy of the contents of a supplier.
    `java.util.Collection<Tuple>` | `pullPropagatedContents(SingleInputNode supplier)` Retrieves the 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 Production> production)` Proxies for the getPosMapping() of Production nodes.
    `java.util.Collection<Tuple>` | `remotePull(Address<? extends Supplier> supplier)` Retrieves the contents of a supplier for a remote caller.
    `<N extends Node> N` | `resolveLocal(Address<N> address)` Returns an addressed node at this container.
    `void` | `sendConstructionUpdate(Receiver receiver, Direction direction, Tuple updateElement)` Sends an update message to the receiver node, indicating a newly found or lost partial matching.
    `void` | `sendConstructionUpdates(Receiver receiver, Direction direction, java.util.Collection<Tuple> updateElements)` Sends several update messages atomically to the receiver node, indicating a newly found or lost partial matching.
    `void` | `sendUpdateInternal(Receiver receiver, Direction direction, Tuple updateElement)` Sends an update message to the receiver node, indicating a newly found or lost partial matching.
    `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.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### ReteContainer

          public ReteContainer(Network network,
                               boolean threaded)

      Parameters:
        `threaded` - false if operating in a single-threaded environment

  - ### Method Detail

    - #### kill

          public void kill()

      Stops this container. To be called by Network.kill()

    - #### 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. Assumption is that this container is the home of the receiver, but it is not strictly necessary.
      Parameters:
        `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. Assumption is that this container is the home of the receiver, but it is not strictly necessary.
      Parameters:
        `desynchronise` - indicates whether the current contents of the supplier should be subtracted from the receiver

    - #### connectRemoteSupplier

          public void connectRemoteSupplier(Address<? extends Supplier> supplier,
                                            Receiver receiver,
                                            boolean synchronise)

      Establishes connection between a remote supplier and a local receiver node.
      Parameters:
        `synchronise` - indicates whether the receiver should be synchronised to the current contents of the supplier

    - #### disconnectRemoteSupplier

          public void disconnectRemoteSupplier(Address<? extends Supplier> supplier,
                                               Receiver receiver,
                                               boolean desynchronise)

      Severs connection between a remote supplier and a local receiver node.
      Parameters:
        `desynchronise` - indicates whether the current contents of the supplier should be subtracted from the receiver

    - #### connect

          public void connect(Supplier supplier,
                              Receiver receiver)

      Connects a receiver to a supplier

    - #### disconnect

          public void disconnect(Supplier supplier,
                                 Receiver receiver)

      Disconnects a receiver from a supplier

    - #### connectAndSynchronize

          public void connectAndSynchronize(Supplier supplier,
                                            Receiver receiver)

      Connects a receiver to a remote supplier, and synchronises it to the current contents of the supplier

    - #### disconnectAndDesynchronize

          public void disconnectAndDesynchronize(Supplier supplier,
                                                 Receiver receiver)

      Disconnects a receiver from a supplier

    - #### sendConstructionUpdate

          public void sendConstructionUpdate(Receiver receiver,
                                             Direction direction,
                                             Tuple updateElement)

      Sends an update message to the receiver node, indicating a newly found or lost partial matching. They are inserted into the queue atomically. Delivery is either synchronous or asynchronous. Designed to be called during network construction.

    - #### sendConstructionUpdates

          public void sendConstructionUpdates(Receiver receiver,
                                              Direction direction,
                                              java.util.Collection<Tuple> updateElements)

      Sends several update messages atomically to the receiver node, indicating a newly found or lost partial matching. They are inserted into the queue atomically. Delivery is either synchronous or asynchronous. Designed to be called during network construction.

    - #### sendUpdateInternal

          public void sendUpdateInternal(Receiver receiver,
                                         Direction direction,
                                         Tuple updateElement)

      Sends an update message to the receiver node, indicating a newly found or lost partial matching. NOT to be called from user threads.

    - #### sendUpdateToRemoteAddress

          public void sendUpdateToRemoteAddress(Address<? extends Receiver> address,
                                                Direction direction,
                                                Tuple updateElement)

      Sends an update message to a node in a different container. The receiver is indicated by the Address. Designed to be called by RemoteReceivers, DO NOT use in any other way.

    - #### flushUpdates

          public void flushUpdates()

      Finalises all update sequences and returns. To be called from user threads (e.g. network construction).

    - #### pullContents

          public java.util.Collection<Tuple> pullContents(Supplier supplier)

      Retrieves a safe copy of the contents of a supplier.

    - #### pullPropagatedContents

          public java.util.Collection<Tuple> pullPropagatedContents(SingleInputNode supplier)

      Retrieves the contents of a SingleInputNode's parentage.

    - #### remotePull

          public java.util.Collection<Tuple> remotePull(Address<? extends Supplier> supplier)

      Retrieves the contents of a supplier for a remote caller. Assumption is that this container is the home of the supplier, but it is not strictly necessary.
      Parameters:
        `supplier` - the address of the supplier to be pulled.

    - #### remotePosMapping

          public java.util.Map<java.lang.String,java.lang.Integer> remotePosMapping(Address<? extends Production> production)

      Proxies for the getPosMapping() of Production nodes. Retrieves the posmapping of a remote or local Production to a remote or local caller.

    - #### makeAddress

          public <N extends Node> Address<N> makeAddress(N node)

      Provides an external address for the selected node.

    - #### isLocal

          public boolean isLocal(Address<? extends Node> address)

      Checks whether a certain address points to a node at this container.

    - #### resolveLocal

          public <N extends Node> N resolveLocal(Address<N> address)

      Returns an addressed node at this container.
      Throws:
        `java.lang.IllegalArgumentException` - if address is non-local

    - #### registerNode

          public long registerNode(Node n)

      Registers a node into the rete network (should be called by constructor). Every node MUST be registered by its constructor.
      Returns:
        the unique nodeId issued to the node.

    - #### unregisterNode

          public void unregisterNode(Node n)

      Unregisters a node from the rete network. Do NOT call if node is still connected to other Nodes, or Adressed or otherwise referenced.

    - #### registerClearable

          public void registerClearable(Clearable c)

      Registers a pattern memory into the rete network. Every memory MUST be registered by its owner node.

    - #### unregisterClearable

          public void unregisterClearable(Clearable c)

      Unregisters a pattern memory from the rete network.

    - #### clearAll

          public void clearAll()

      Clears all memory contents in the network. Reverts to initial state.

    - #### getNodeFactory

          public org.eclipse.incquery.runtime.rete.network.NodeFactory getNodeFactory()

    - #### getConnectionFactory

          public org.eclipse.incquery.runtime.rete.network.ConnectionFactory getConnectionFactory()

    - #### getProvisioner

          public NodeProvisioner getProvisioner()

    - #### getNetwork

          public Network getNetwork()

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### getAllNodes

          public java.util.Collection<Node> getAllNodes()

      Access all the Rete nodes inside this container.
      Returns:
        the collection of `Node` instances

    - #### getInputConnectionFactory

          public InputConnector getInputConnectionFactory()