|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectplanet.generic.commonapi.NetworkNodeImpl
Superclass which represents a node in a peer-to-peer system, regardless of the underlying protocol. All nodes, implement the methods of this class. This contains all required elements to use java.util.Timer (JDK standard) for real execution context. Only the required concrete Node implementation must extend this abstract class, instead of planet.generic.commonapi.NodeImpl. Another required action is shows at properties file for simulator the class to use for Timer as follows: # Default Timer Class DEFAULT_TIMER = planet.util.timer.ThreadTimer
Field Summary | |
protected boolean |
alive
|
protected java.util.Hashtable |
endpoints
Local EndPoints. |
protected Id |
id
|
protected java.util.Hashtable |
listeners
|
protected NodeHandle |
nodeHandle
NodeHandle for the actual Node. |
Constructor Summary | |
NetworkNodeImpl(Id id)
Constructor, create a new Node instance with node Id |
Method Summary | |
void |
addMessageListener(java.lang.String key,
MessageListener listener)
Adds a listener to the node so that it executes herself when the message response arrives |
Id |
getId()
Returns the id of the node * |
IdFactory |
getIdFactory()
Returns a factory for Ids specific to this node's protocol. |
abstract java.util.Hashtable |
getInfo()
Returns information of the node |
NodeHandle |
getLocalHandle()
Returns the local NodeHandle |
Application[] |
getRegisteredApplications()
Returns all references of the applications that mantains this node. |
protected boolean |
hasMoreMessages()
Checks if the incoming queue have a messages to send |
abstract void |
join(Id bootstrap)
The node joins in the network |
abstract void |
leave()
The node leaves the network |
abstract void |
lookup(Id key)
Lookup of a key |
protected RouteMessage |
nextMessage()
Return the next message and dequeue this of the incoming queue |
Queue |
outMessages()
Returns the present outgoing queue of this node |
boolean |
process(int actualStep)
Given a time fraction, the node it can do everything what needs during this |
void |
receive(RouteMessage msg)
Puts a message in the incoming queue of this node |
EndPoint |
registerApplication(Application app,
java.lang.String instance)
This returns a VirtualizedNode specific to the given application and instance name to the application, which the application can then use in order to send an receive messages. |
void |
removeMessageListener(java.lang.String key)
Remove the message listener of the node |
protected void |
run(int time)
Given a time fraction, the node runs and do everything what needs during this |
void |
send(RouteMessage msg)
Puts a message in the outcoming queue of this node |
void |
setTimer(TimerTask task,
long firstTime)
Sets a task to be executed only one time at specified firstTime. |
void |
setTimer(TimerTask task,
long firstTime,
long period)
Sets a task to be executed periodicly at each period of time. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface planet.commonapi.Node |
broadcast, fail, getAllLinks, getEInGML, getNewE, getPred, getSucc, getSuccList, isAlive, isLocalMessage, localLookup, neighborSet, networkStabilized, playsGoodRole, prettyPrintNode, printNode, range, replicaSet, routeData, setGoodRole |
Field Detail |
protected Id id
protected transient java.util.Hashtable listeners
protected boolean alive
protected NodeHandle nodeHandle
protected java.util.Hashtable endpoints
Constructor Detail |
public NetworkNodeImpl(Id id) throws InitializationException
id
- IdMethod Detail |
public abstract void join(Id bootstrap)
join
in interface Node
bootstrap
- Id of a node in the networkpublic abstract void leave()
leave
in interface Node
public abstract void lookup(Id key)
key
- Idpublic boolean process(int actualStep)
process
in interface Node
actualStep
- Actual step in simulation time.
public void receive(RouteMessage msg) throws QueueFull
receive
in interface Node
msg
- received Message
QueueFull
- if the incoming queue of the actual Node is full.public void send(RouteMessage msg) throws QueueFull
send
in interface Node
msg
- sended Message
QueueFull
- if the outgoing queue of the actual Node is full.public Queue outMessages()
outMessages
in interface Node
protected boolean hasMoreMessages()
protected RouteMessage nextMessage()
protected void run(int time)
time
- fractionpublic Id getId()
getId
in interface Node
public void addMessageListener(java.lang.String key, MessageListener listener)
key
- String representation of id routing messagelistener
- MessageListener linked to Messagepublic void removeMessageListener(java.lang.String key)
key
- String representation of id routing messagepublic abstract java.util.Hashtable getInfo()
public NodeHandle getLocalHandle()
getLocalHandle
in interface Node
Node.getLocalHandle()
public void setTimer(TimerTask task, long firstTime, long period)
setTimer
in interface Node
task
- Job to do at each activation of the task.firstTime
- First activation of the task, measured in steps or millis.
Its value is the absolute time, not relative for the actual time.period
- Number of steps or millis to periodicly execute the task.Node.setTimer(planet.util.timer.TimerTask, long, long)
public void setTimer(TimerTask task, long firstTime)
setTimer
in interface Node
task
- Job to do at activation.firstTime
- Moment to be activated, in steps or millis, measured
in absolute time, not relative of actual time.Node.setTimer(planet.util.timer.TimerTask, long)
public EndPoint registerApplication(Application app, java.lang.String instance)
registerApplication
in interface Node
app
- The Applicationinstance
- An identifier for a given instance
public Application[] getRegisteredApplications()
getRegisteredApplications
in interface Node
public IdFactory getIdFactory() throws InitializationException
getIdFactory
in interface Node
InitializationException
- if occurs any problem with
IdFactory initialization.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |