|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectplanet.generic.commonapi.NodeImpl
Superclass which represents a node in a peer-to-peer system, regardless of the underlying protocol. All nodes, implement the methods of this class.
Field Summary | |
protected java.util.Hashtable |
endpoints
Local EndPoints. |
protected Id |
id
|
protected java.util.Hashtable |
listeners
|
protected NodeHandle |
nodeHandle
NodeHandle for the actual Node. |
protected boolean |
role
|
Constructor Summary | |
NodeImpl(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 |
void |
dispatchDataMessage(RouteMessage msg,
int requestMode,
int refreshMode)
Make a generic treatment of the DATA messages (application layer messages). |
abstract NodeHandle |
getClosestNodeHandle(Id id)
Returns the NodeHandle closest to id. |
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 |
void |
getNewE(java.util.Iterator it,
GMLConstraint constraint,
java.util.Collection E,
java.lang.String color)
Adds a new Edge to E set according to specified GMLConstraint. |
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 |
protected void |
invokeByStepToAllApplications()
Invokes to each registered Application, by the related EndPoint, the byStep() method. |
boolean |
isLocalMessage(RouteMessage msg)
The isLocalMessage's method is an extension method for commonapi specs. |
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 |
playsGoodRole()
The playsGoodRole's method is an extension method for commonapi specs. |
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 |
void |
send(RouteMessage msg)
Puts a message in the outcoming queue of this node |
void |
setGoodRole(boolean role)
The setGoodRole's method is an extension method for commonapi specs. |
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, getPred, getSucc, getSuccList, isAlive, localLookup, neighborSet, networkStabilized, prettyPrintNode, printNode, range, replicaSet, routeData |
Field Detail |
protected Id id
protected transient java.util.Hashtable listeners
protected NodeHandle nodeHandle
protected java.util.Hashtable endpoints
protected boolean role
Constructor Detail |
public NodeImpl(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.
protected void invokeByStepToAllApplications()
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()
public 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 relative time, not in absolute 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 relative time, not in absolute 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.public boolean playsGoodRole()
playsGoodRole
in interface Node
public void setGoodRole(boolean role)
setGoodRole
in interface Node
role
- public boolean isLocalMessage(RouteMessage msg)
isLocalMessage
in interface Node
BehavioursPool
public void getNewE(java.util.Iterator it, GMLConstraint constraint, java.util.Collection E, java.lang.String color)
getNewE
in interface Node
it
- Iterator over a collection of nodeHandles.constraint
- Specific constraints.color
- Fill color of the edge.E
- Edge set.public abstract NodeHandle getClosestNodeHandle(Id id)
id
- Id to find.
public void dispatchDataMessage(RouteMessage msg, int requestMode, int refreshMode)
msg
- RouteMessage to be treated.requestMode
- RouteMessage REQUEST mode for the actual Overlay implementation.refreshMode
- RouteMessage REFRESH mode for the actual Overlay implementation.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |