|
|||||||||||
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()
Initializes internal data structures. |
Method Summary | |
void |
addEdges(java.lang.String resultName,
java.util.Iterator it,
ResultsConstraint constraint,
java.util.Collection edgeCollection,
java.lang.String color)
Adds new ResultsEdges to edgeCollection according to specified constraint. |
void |
addMessageListener(java.lang.String key,
MessageListener listener)
Adds a listener to the node so that it executes herself when the message response arrives |
RouteMessage |
buildMessage(RouteMessage toCopy)
Builds a new RouteMessage with all the values appeared in toCopy, and the specified nextHop. |
RouteMessage |
buildMessage(java.lang.String key,
NodeHandle from,
NodeHandle to,
NodeHandle nextHop,
int type,
int mode,
java.lang.String appId,
Message msg)
A wrapper method, that sends a RouteMessage with the specified data. |
ResultsEdge |
buildNewEdge(java.lang.String resultName,
Id left,
Id right,
java.lang.String color)
Builds a ResultsEdge with the specified bounds and following the resultsName type format. |
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 * |
abstract java.util.Hashtable |
getInfo()
Returns information of the node |
NodeHandle |
getLocalHandle()
Returns the local NodeHandle |
EndPoint |
getRegisteredApplication(java.lang.String instanceName)
Get the registered application by the instanceName name. |
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 |
Queue |
inMessages()
|
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(NodeHandle bootstrap)
The node joins in the network |
abstract void |
leave()
The node leaves the network |
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 |
boolean |
sendMessage(RouteMessage msg)
Puts the RouteMessage msg to the outgoing queue of this node. |
void |
sendMessage(RouteMessage rMsg,
java.lang.String key,
NodeHandle from,
NodeHandle to,
NodeHandle nextHop,
int type,
int mode,
Message msg)
A wrapper method, that send a RouteMessage with the specified data. |
boolean |
sendMessage(java.lang.String key,
NodeHandle from,
NodeHandle to,
int type,
int mode,
Message msg)
A wrapper method, that sends a RouteMessage with the specified data. |
boolean |
sendMessage(java.lang.String key,
NodeHandle from,
NodeHandle to,
NodeHandle nextHop,
int type,
int mode,
Message msg)
A wrapper method, that sends a RouteMessage with the specified data. |
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. |
Node |
setValues(Id newId)
Sets the new Id. |
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, buildEdges, fail, getAllLinks, getPred, getSucc, getSuccList, isAlive, localLookup, neighborSet, 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()
Method Detail |
public abstract void join(NodeHandle bootstrap)
join
in interface Node
bootstrap
- Id of a node in the networkpublic abstract void leave()
leave
in interface Node
public 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 RouteMessage buildMessage(java.lang.String key, NodeHandle from, NodeHandle to, NodeHandle nextHop, int type, int mode, java.lang.String appId, Message msg)
key
- Key of the communication.from
- Communication sourceto
- Communication destinationnextHop
- Next hop in the communication.type
- RouteMessage typemode
- RouteMessage modeappId
- Name of the related application.msg
- Data to be sent with the RouteMessage
public RouteMessage buildMessage(RouteMessage toCopy)
toCopy
- Message to be cloned.
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 boolean sendMessage(RouteMessage msg)
msg
- RouteMessage to be sent.public boolean sendMessage(java.lang.String key, NodeHandle from, NodeHandle to, int type, int mode, Message msg)
key
- Key of the communication.from
- Communication sourceto
- Communication destinationtype
- RouteMessage typemode
- RouteMessage modemsg
- Data to be sent with the RouteMessagepublic boolean sendMessage(java.lang.String key, NodeHandle from, NodeHandle to, NodeHandle nextHop, int type, int mode, Message msg)
key
- Key of the communication.from
- Communication sourceto
- Communication destinationnextHop
- Next hop in the communication.type
- RouteMessage typemode
- RouteMessage modemsg
- Data to be sent with the RouteMessagepublic void sendMessage(RouteMessage rMsg, java.lang.String key, NodeHandle from, NodeHandle to, NodeHandle nextHop, int type, int mode, Message msg)
rMsg
- RouteMessage to be used.key
- Communication keyfrom
- Communication source.to
- Communication destination.type
- RouteMessage typemode
- RouteMessage modemsg
- Data to be sent with the RouteMessagepublic Queue outMessages()
outMessages
in interface Node
public Queue inMessages()
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 EndPoint getRegisteredApplication(java.lang.String instanceName)
getRegisteredApplication
in interface Node
instanceName
- Name of the registered application.
public Application[] getRegisteredApplications()
getRegisteredApplications
in interface Node
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 addEdges(java.lang.String resultName, java.util.Iterator it, ResultsConstraint constraint, java.util.Collection edgeCollection, java.lang.String color)
resultName
- Result type name to use.it
- Iterator over a collection of nodeHandles.constraint
- Specific constraints to test all built edges.edgeCollection
- Edges collection where they have to be added.color
- Fill color of the edge.public ResultsEdge buildNewEdge(java.lang.String resultName, Id left, Id right, java.lang.String color)
resultName
- Result type name to use.left
- One bound of the link.right
- Second bound of the link.color
- Edge color.
public abstract NodeHandle getClosestNodeHandle(Id id)
getClosestNodeHandle
in interface Node
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.public Node setValues(Id newId) throws InitializationException
setValues
in interface Node
newId
- New Id.
InitializationException
Node.setValues(planet.commonapi.Id)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |