Package i5.las2peer.p2p
Class LocalNodeManager
java.lang.Object
i5.las2peer.p2p.LocalNodeManager
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
deliverPendingMessages
(String recipientId, long nodeId) fetch all pending messages for the given agentLong[]
findAllNodesWithAgent
(String agentId) get the ids of all nodes where the given agent is runningLong[]
findAllNodesWithTopic
(long topicId) get the ids of all nodes where agents listening to the given topic are runninglong
findFirstNodeWithAgent
(String agentId) find the first node, where the given agent is registered toObject[]
int
int
getNode
(long id) get a node from the central storageboolean
hasNode
(long id) does the given node exist in the central storage?factory: launch a node an register the given agentfactory: launch a nodevoid
localSendMessage
(long nodeId, Message message) does the actual sending of a message in a separate thread with a configurable delaynewNode()
create a LocalNode using a FileSystemRepository at the given locationcreate a LocalNode using a FileSystemRepository at the given locationsprotected void
get all expired messages and notify their sendersvoid
registerNode
(LocalNode node) register a node for later usevoid
reset()
do a complete restart of all nodes, artifacts and messagesvoid
setMaxMessageWait
(int time) void
setMinMessageWait
(int time) void
setPendingTimeOut
(int newtimeout) void
stop the timeout cleaner threadprotected void
storeMessage
(Message message, MessageResultListener listener) store messages for agents not known to this "network" of nodesvoid
unregisterNode
(LocalNode node) remove a node from the central storage
-
Constructor Details
-
LocalNodeManager
public LocalNodeManager()
-
-
Method Details
-
newNode
- Returns:
- a new configured but not running node
-
newNode
create a LocalNode using a FileSystemRepository at the given location- Parameters:
fileSystemRepository
- a path to the service directory- Returns:
- Returns a LocalNode instance
-
newNode
create a LocalNode using a FileSystemRepository at the given locations- Parameters:
fileSystemRepositories
- a path to the service directories- Returns:
- Returns a LocalNode instance
-
launchNode
factory: launch a node- Returns:
- a freshly started node
-
launchAgent
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
register a node for later use- Parameters:
node
- A node to register to
-
unregisterNode
remove a node from the central storage- Parameters:
node
- A node to register to
-
getNode
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
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
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
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
store messages for agents not known to this "network" of nodes- Parameters:
message
- A message to storelistener
- A message result listener to add the message
-
deliverPendingMessages
fetch all pending messages for the given agent- Parameters:
recipientId
- A recipient id to servenodeId
- 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
does the actual sending of a message in a separate thread with a configurable delay- Parameters:
nodeId
- A node id to send tomessage
- A message to send
-
getAllNodes
-
getStorage
-
getKnownAgents
-