Class LocalNodeManager

java.lang.Object
i5.las2peer.p2p.LocalNodeManager

public class LocalNodeManager extends Object
  • Constructor Details

    • LocalNodeManager

      public LocalNodeManager()
  • Method Details

    • newNode

      public LocalNode newNode()
      Returns:
      a new configured but not running node
    • newNode

      public LocalNode newNode(String fileSystemRepository)
      create a LocalNode using a FileSystemRepository at the given location
      Parameters:
      fileSystemRepository - a path to the service directory
      Returns:
      Returns a LocalNode instance
    • newNode

      public LocalNode newNode(String[] fileSystemRepositories)
      create a LocalNode using a FileSystemRepository at the given locations
      Parameters:
      fileSystemRepositories - a path to the service directories
      Returns:
      Returns a LocalNode instance
    • launchNode

      public LocalNode launchNode()
      factory: launch a node
      Returns:
      a freshly started node
    • launchAgent

      public LocalNode launchAgent(AgentImpl a) throws AgentException
      factory: launch a node an register the given agent
      Parameters:
      a - An agent to launch
      Returns:
      a freshly started node hosting the given agent
      Throws:
      AgentException - If agent registration fails
    • registerNode

      public void registerNode(LocalNode node)
      register a node for later use
      Parameters:
      node - A node to register to
    • unregisterNode

      public void unregisterNode(LocalNode node)
      remove a node from the central storage
      Parameters:
      node - A node to register to
    • getNode

      public LocalNode getNode(long id)
      get a node from the central storage
      Parameters:
      id - A node id
      Returns:
      the node with the given id
    • hasNode

      public boolean hasNode(long id)
      does the given node exist in the central storage?
      Parameters:
      id - A node id
      Returns:
      true, if a node of the given it is known to the registry
    • reset

      public void reset()
      do a complete restart of all nodes, artifacts and messages
    • stopCleaner

      public void stopCleaner()
      stop the timeout cleaner thread
    • findFirstNodeWithAgent

      public long findFirstNodeWithAgent(String agentId) throws AgentNotRegisteredException
      find the first node, where the given agent is registered to
      Parameters:
      agentId - An agent id
      Returns:
      id of a node hosting the given agent
      Throws:
      AgentNotRegisteredException - If the agent is not registered at any node
    • findAllNodesWithAgent

      public Long[] findAllNodesWithAgent(String agentId)
      get the ids of all nodes where the given agent is running
      Parameters:
      agentId - An agent id
      Returns:
      array with all ids of nodes hosting the given agent
    • findAllNodesWithTopic

      public Long[] findAllNodesWithTopic(long topicId)
      get the ids of all nodes where agents listening to the given topic are running
      Parameters:
      topicId - A topic id
      Returns:
      Returns a list with all node ids for the given topic
    • storeMessage

      protected void storeMessage(Message message, MessageResultListener listener)
      store messages for agents not known to this "network" of nodes
      Parameters:
      message - A message to store
      listener - A message result listener to add the message
    • deliverPendingMessages

      protected void deliverPendingMessages(String recipientId, long nodeId)
      fetch all pending messages for the given agent
      Parameters:
      recipientId - A recipient id to serve
      nodeId - A node id to send to
    • notifyExpiredMessages

      protected void notifyExpiredMessages()
      get all expired messages and notify their senders
    • setPendingTimeOut

      public void setPendingTimeOut(int newtimeout)
    • getMinMessageWait

      public int getMinMessageWait()
    • getMaxMessageWait

      public int getMaxMessageWait()
    • setMinMessageWait

      public void setMinMessageWait(int time)
    • setMaxMessageWait

      public void setMaxMessageWait(int time)
    • localSendMessage

      public void localSendMessage(long nodeId, Message message)
      does the actual sending of a message in a separate thread with a configurable delay
      Parameters:
      nodeId - A node id to send to
      message - A message to send
    • getAllNodes

      public Object[] getAllNodes()
    • getStorage

      public LocalStorage getStorage()
    • getKnownAgents

      public Hashtable<String,String> getKnownAgents()