|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectplanet.generic.commonapi.NetworkImpl
This implementation of Network interface pretends to abstract
any network, based with the actual commonapi, of course. The
time is abstracted to discrete simulation steps.
Operationals modes for this network implementation:
| Nested Class Summary | |
class |
NetworkImpl.NetworkIterator
This class implements the java.util.Iterator interface and is backed up by TreeMap that contains all existing nodes on the network. |
| Constructor Summary | |
NetworkImpl()
Initialize the network with no nodes and wihtout simulation steps. |
|
| Method Summary | |
boolean |
existNode(NodeHandle node)
Inform if exist on the network one node with NodeHandle node. |
void |
failNodes(NodeHandle[] nodes)
Runs the stabilization process after each fail node. |
int |
getProximity(NodeHandle nodeA,
NodeHandle nodeB)
Always returns 1 (one). |
Application |
getRandomApplication(java.lang.String appId)
Gets a reference of some application on any node of the network. |
Node |
getRandomNode(java.util.Random r)
Returns a randomly selected node of actual network. |
int |
getSimulatedSteps()
Gets the actual number of simulated steps. |
java.lang.String |
getTopology()
Gets the actual topology of the underlying network. |
java.util.Iterator |
iterator()
Builds an Iterator to iterate over all nodes of the network. |
void |
joinNode(Node node)
Add the node to the actual network. |
void |
joinNode(Node node,
NodeHandle bootstrap)
Adds node to the network, using the node with Id bootstrap to enter it. |
int |
joinNodes(int size)
Add size nodes to the actual network. |
int |
joinNodes(int size,
NodeHandle[] bootstrap)
Add size nodes to the actual network. |
void |
leaveNodes(NodeHandle[] nodes)
Leave theese nodes for the network. |
protected int[] |
makeRandomIndexes(int max)
Returns an array of indexes in range (0..number of nodes) to use to identify which nodes to select. |
void |
prettyPrintNodes()
Shows only the owner Id, the successor and predecessor for each Node. |
void |
printNodes()
Shows for each Node its printNode(). |
protected boolean |
process()
Process all nodes one step at this network. |
int |
registerApplication(NodeHandle[] nodes)
Register the Application specified at properties file to the specified nodes by theirs Ids. |
void |
registerApplicationAll()
Register the Application app to all nodes existing at the underlying network. |
void |
registerApplicationRandom(int nodes)
Register the Application app to radomly at the number of Nodes nodes. |
int |
run(int steps)
Simulate a total number steps steps. |
protected void |
send(Queue messages)
Takes all messages of queue and send to all destination nodes. |
protected boolean |
sendMessages()
Sends all message pending to be delivered by all nodes. |
Network |
setValues(java.lang.String topology,
NodeFactory nodeFactory)
Sets the initial values for the new Network instance. |
boolean |
simulate()
Simulate one step. |
int |
size()
Returns the actual number of nodes to the network. |
int |
stabilize()
Stabilize the network. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public NetworkImpl()
| Method Detail |
public Network setValues(java.lang.String topology,
NodeFactory nodeFactory)
throws InitializationException
setValues in interface Networktopology - Desired network topology.nodeFactory - NodeFactory implementation to be used to build
the network.
InitializationException - if any error occurs during
the initialization process.Network.setValues(java.lang.String, planet.commonapi.factory.NodeFactory)
public void joinNode(Node node)
throws InitializationException
joinNode in interface Networknode - Node to add to the network.
InitializationExceptionNetwork.joinNode(planet.commonapi.Node)
public void joinNode(Node node,
NodeHandle bootstrap)
throws InitializationException
joinNode in interface Networknode - Node to add to the network.bootstrap - Id of the node to use as bootstrap for node.
InitializationException - if the bootstrap not exists in the network.Network.joinNode(planet.commonapi.Node, planet.commonapi.NodeHandle)
public int joinNodes(int size)
throws InitializationException
joinNodes in interface Networksize - Number of nodes to add to the network.
InitializationException - if occur some problem with building nodes.Network.joinNodes(int)
public int joinNodes(int size,
NodeHandle[] bootstrap)
throws InitializationException
joinNodes in interface Networksize - Number of nodes to add to the network.bootstrap - NodeHandles of nodes to use as bootstrap for new nodes.
InitializationException - if occur some problem with building nodes.Network.joinNodes(int, planet.commonapi.NodeHandle[])
public void leaveNodes(NodeHandle[] nodes)
throws InitializationException
leaveNodes in interface Networknodes - Ids for nodes to leave.
InitializationException - if exists some Id in the array
as parameter that not exists in the network. The message includes
which are of them.Network.leaveNodes(planet.commonapi.NodeHandle[])
public void failNodes(NodeHandle[] nodes)
throws InitializationException
failNodes in interface Networknodes - Node's NodeHandles that must fail.
InitializationExceptionNetwork.failNodes(planet.commonapi.NodeHandle[])
public void registerApplicationAll()
throws InitializationException
registerApplicationAll in interface NetworkInitializationExceptionNetwork.registerApplicationAll()
public int registerApplication(NodeHandle[] nodes)
throws InitializationException
registerApplication in interface Networknodes - NodeHandles of those nodes to register Application app.
InitializationExceptionNetwork.registerApplication(planet.commonapi.NodeHandle[])
public void registerApplicationRandom(int nodes)
throws InitializationException
registerApplicationRandom in interface Networknodes - Number of nodes to radomly select to register the
Application app.
InitializationExceptionNetwork.registerApplicationRandom(int)protected int[] makeRandomIndexes(int max)
max - Number of indexes generate.
public java.lang.String getTopology()
getTopology in interface NetworkNetwork.getTopology(),
Topologypublic int size()
size in interface NetworkNetwork.size()public void printNodes()
printNodes in interface Networkpublic void prettyPrintNodes()
prettyPrintNodes in interface Networkpublic int run(int steps)
run in interface Networksteps - Number of steps to simulate.
Network.run(int)public boolean simulate()
simulate in interface NetworkNetwork.simulate()protected boolean process()
protected boolean sendMessages()
protected void send(Queue messages)
messages - Queue with messages to sendQueue,
Globalspublic Node getRandomNode(java.util.Random r)
getRandomNode in interface Networkr - Generator of random numbers.
Network.getRandomNode(java.util.Random)public boolean existNode(NodeHandle node)
existNode in interface Networknode - NodeHandle of the node to be search.
Network.existNode(planet.commonapi.NodeHandle)public int stabilize()
stabilize in interface NetworkNetwork.stabilize()public Application getRandomApplication(java.lang.String appId)
getRandomApplication in interface NetworkappId - Application identification for searching it.
Network.getRandomApplication(java.lang.String)public java.util.Iterator iterator()
iterator in interface Networkpublic int getSimulatedSteps()
getSimulatedSteps in interface NetworkNetwork.getSimulatedSteps()
public int getProximity(NodeHandle nodeA,
NodeHandle nodeB)
getProximity in interface NetworknodeA - First node to evaluate.nodeB - Second node to evaluate.
Network.getProximity(planet.commonapi.NodeHandle, planet.commonapi.NodeHandle)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||