All Packages Class Hierarchy This Package Previous Next Index
Class vnet.NetNode
java.lang.Object
|
+----java.util.Observable
|
+----vnet.NetNode
- public class NetNode
- extends Observable
Class to represent a node in the net.
It is a node simulation of a machine (PC, Workstation), where any server
and clients can be running. In this simulation, a program can start (a
server is binded to the node, of a client uses the node), and the node can
fail down (the machine switch off or it just fails).
It implements the Observable function of the observer pattern.
- Version:
- 0.2, august-1997
- Author:
- LuisM Pena
-
NetNode(NodeId, long)
-
-
addLink(NetLink)
- Associates a new link
-
bind(String, Object, NetNode)
- Binds a server with a server name to this node
The observers of the node will receive a BindEvent notification
-
checkWay(NetNode, BindedServer)
- Checks that there is a way to the final node, and that in the final node
the server is alive.
-
destroy()
- Destructor of the node: clears the associated links
The observers of the node will receive a NodeDestroyedEvent notification
The list of observers is cleared
-
getId()
- Returns the identity of the Node
-
getLinks()
- Gets the Links associated to the node (its communicationc channels)
-
getServers()
- Gets the servers binded to the node
-
lookup(String)
- Starts the searching of a server in the net, returning a virtual path
to that server, or null if it is not found.
-
lookup(String, NetNode)
- Starts the searching of a server on an specified node in the net, returning a
virtual path to that server, or null if it is not found.
-
rebind(String, Object, NetNode)
- Bind a server with a server name to this node, no matter if the serverName
is already used.
-
removeLink(NetLink)
- Removes a link
-
unbind(String)
- Unbinds the server with the server name specified, raising an exception if
such a server doesn't exist in the node
The observers of the node will receive a BindEvent notification
NetNode
public NetNode(NodeId id,
long delay)
- Parameters:
- id - the identity of the node
- delay - the delay involving any operation on this node
getId
public NodeId getId()
- Returns the identity of the Node
- Returns:
- The identity of the node
getLinks
public Enumeration getLinks()
- Gets the Links associated to the node (its communicationc channels)
- Returns:
- The links associated to the node
addLink
public void addLink(NetLink link) throws VNException
- Associates a new link
- Throws: VNException
- if the node already includes that link
removeLink
public void removeLink(NetLink link) throws VNException
- Removes a link
- Throws: VNException
- if the node doesn't have that link
destroy
public void destroy() throws VNException
- Destructor of the node: clears the associated links
The observers of the node will receive a NodeDestroyedEvent notification
The list of observers is cleared
- Throws: VNException
- if the links fail to be cleared
- See Also:
- destroy, NodeDestroyedEvent
bind
public void bind(String serverName,
Object server,
NetNode hostNode) throws AlreadyBoundException, CommException
- Binds a server with a server name to this node
The observers of the node will receive a BindEvent notification
- Parameters:
- serverName - the name of the server
- server - the server being binded
- hostNode - the NetNode where this server is hosted (it can be
different from the node where it is going to be binded)
- Throws: AlreadyBoundException
- if the serverName is already in use in this node
- Throws: CommException
- if the hostNode can not be reached from this node
- See Also:
- BindEvent
rebind
public void rebind(String serverName,
Object server,
NetNode hostNode) throws CommException
- Bind a server with a server name to this node, no matter if the serverName
is already used.
This operation is done in two steps; first, the server is unbinded if it was
already binded, and, second, the new server is binded.
The observers of the node will see both notifications, the bind and the unbind.
- Parameters:
- serverName - the name of the server
- server - the server being binded
- hostNode - the NetNode where this server is hosted (it can be
different from the node where it is going to be binded)
- Throws: CommException
- if the hostNode can not be reached from this node
- See Also:
- BindEvent, unbind, bind
unbind
public void unbind(String serverName) throws NotBoundException
- Unbinds the server with the server name specified, raising an exception if
such a server doesn't exist in the node
The observers of the node will receive a BindEvent notification
- Parameters:
- serverName - the name of the server
- Throws: NotBoundException
- if the serverName is not known in this node
- See Also:
- BindEvent
getServers
public Enumeration getServers()
- Gets the servers binded to the node
- Returns:
- the name of the servers binded to this node
lookup
public VirtualPath lookup(String server)
- Starts the searching of a server in the net, returning a virtual path
to that server, or null if it is not found.
When the server is not found in the node, the links are used to propagate
the lookup; the algorythm to select a link to propagate the link will always
select the link that has been longer inactive.
The observers of nodes and links that are visited during the lookup will send a
LookupOnNodeEvent and LookupOnLinkEvent notification
- Parameters:
- server - the name of the server
- See Also:
- NetLink, LookupOnNodeEvent, LookupOnLinkEvent
lookup
public VirtualPath lookup(String server,
NetNode host) throws CommException
- Starts the searching of a server on an specified node in the net, returning a
virtual path to that server, or null if it is not found.
When the server is not found in the node, the links are used to propagate
the lookup; the algorythm to select a link to propagate the link will always
select the link that has been longer inactive.
The observers of nodes and links that are visited during the lookup will send a
LookupOnNodeEvent and LookupOnLinkEvent notification
- Parameters:
- server - the name of the server
- host - the node where the server is binded, or null if any node is valid
- Throws: CommException
- if the node final can not be reached
- See Also:
- NetLink, LookupOnNodeEvent, LookupOnLinkEvent
checkWay
public void checkWay(NetNode Final,
BindedServer Server) throws CommException
- Checks that there is a way to the final node, and that in the final node
the server is alive.
The observers of nodes and links that are visited during this check will send a
LookupOnNodeEvent and LookupOnLinkEvent notification
- Parameters:
- Final - the final node to reache
- Server - the server to reache
- Throws: CommException
- if the node final can not be reached or if the
server is not binded to that node
- See Also:
- LookupOnNodeEvent, LookupOnLinkEvent
All Packages Class Hierarchy This Package Previous Next Index