Class LocalNetwork

  • All Implemented Interfaces:
    Network

    public class LocalNetwork
    extends java.lang.Object
    implements Network
    Author:
    Simon Thoresen Hult
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean allocServiceAddress​(RoutingNode recipient)
      Resolves the service address of the recipient referenced by the given routing node.
      void attach​(NetworkOwner owner)
      Attach the network layer to the given owner
      void freeServiceAddress​(RoutingNode recipient)
      Frees the service address from the given routing node.
      java.lang.String getConnectionSpec()
      Returns a string that represents the connection specs of this network.
      com.yahoo.jrt.slobrok.api.IMirror getMirror()
      Returns a reference to a name server mirror.
      void registerSession​(java.lang.String session)
      Register a session name with the network layer.
      void send​(Message msg, java.util.List<RoutingNode> recipients)
      Send a message to the given recipients.
      void shutdown()
      Shuts down the network.
      void sync()
      Synchronize with internal threads.
      void unregisterSession​(java.lang.String session)
      Unregister a session name with the network layer.
      boolean waitUntilReady​(double seconds)
      Waits for at most the given number of seconds for all dependencies to become ready.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LocalNetwork

        public LocalNetwork()
      • LocalNetwork

        public LocalNetwork​(LocalWire wire)
    • Method Detail

      • waitUntilReady

        public boolean waitUntilReady​(double seconds)
        Description copied from interface: Network
        Waits for at most the given number of seconds for all dependencies to become ready.
        Specified by:
        waitUntilReady in interface Network
        Parameters:
        seconds - The timeout.
        Returns:
        True if ready.
      • attach

        public void attach​(NetworkOwner owner)
        Description copied from interface: Network
        Attach the network layer to the given owner
        Specified by:
        attach in interface Network
        Parameters:
        owner - owner of the network
      • registerSession

        public void registerSession​(java.lang.String session)
        Description copied from interface: Network
        Register a session name with the network layer. This will make the session visible to other nodes.
        Specified by:
        registerSession in interface Network
        Parameters:
        session - the session name
      • unregisterSession

        public void unregisterSession​(java.lang.String session)
        Description copied from interface: Network
        Unregister a session name with the network layer. This will make the session unavailable for other nodes.
        Specified by:
        unregisterSession in interface Network
        Parameters:
        session - session name
      • allocServiceAddress

        public boolean allocServiceAddress​(RoutingNode recipient)
        Description copied from interface: Network
        Resolves the service address of the recipient referenced by the given routing node. If a recipient can not be resolved, this method tags the node with an error. If this method succeeds, you need to invoke Network.freeServiceAddress(RoutingNode) once you are done with the service address.
        Specified by:
        allocServiceAddress in interface Network
        Parameters:
        recipient - The node whose service address to allocate.
        Returns:
        True if a service address was allocated.
      • freeServiceAddress

        public void freeServiceAddress​(RoutingNode recipient)
        Description copied from interface: Network
        Frees the service address from the given routing node. This allows the network layer to track and close connections as required.
        Specified by:
        freeServiceAddress in interface Network
        Parameters:
        recipient - The node whose service address to free.
      • send

        public void send​(Message msg,
                         java.util.List<RoutingNode> recipients)
        Description copied from interface: Network
        Send a message to the given recipients. A RoutingNode contains all the necessary context for sending.
        Specified by:
        send in interface Network
        Parameters:
        msg - The message to send.
        recipients - A list of routing leaf nodes resolved for the message.
      • sync

        public void sync()
        Description copied from interface: Network
        Synchronize with internal threads. This method will handshake with all internal threads. This has the implicit effect of waiting for all active callbacks. Note that this method should never be invoked from a callback since that would make the thread wait for itself... forever. This method is typically used to untangle during session shutdown.
        Specified by:
        sync in interface Network
      • shutdown

        public void shutdown()
        Description copied from interface: Network
        Shuts down the network. This is a blocking call that waits for all scheduled tasks to complete.
        Specified by:
        shutdown in interface Network
      • getConnectionSpec

        public java.lang.String getConnectionSpec()
        Description copied from interface: Network
        Returns a string that represents the connection specs of this network. It is in not a complete address since it know nothing of the sessions that run on it.
        Specified by:
        getConnectionSpec in interface Network
        Returns:
        The connection string.
      • getMirror

        public com.yahoo.jrt.slobrok.api.IMirror getMirror()
        Description copied from interface: Network
        Returns a reference to a name server mirror.
        Specified by:
        getMirror in interface Network
        Returns:
        The mirror object.