spawn() throws no exception...

This commit is contained in:
senft-lap 2012-12-04 16:49:07 +01:00
parent 733199fda8
commit effd467bbf
3 changed files with 21 additions and 17 deletions

View File

@ -5,6 +5,8 @@ import java.util.HashMap;
import java.util.Map;
import java.util.logging.LogManager;
import analysis.NetworkDumper;
import node.Node;
public class Main {
@ -42,6 +44,13 @@ public class Main {
switch (cmd) {
case "br":
nodes.get(node).gatherInformationOfNetwork();
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
}
NetworkDumper dumper = new NetworkDumper(nodes.get(node));
dumper.write(dumper.networkToDot(nodes.get(node)
.getNetwork()));
break;
case "spawn":
if (splitted.length > 2) {

View File

@ -55,20 +55,17 @@ public class RandomGenerator2 {
}
private void spawn() {
try {
if (nodes.isEmpty()) {
nodes.add(new Node());
} else {
Node randomNode = getRandomNode();
Node newNode = randomNode.spawn();
nodes.add(newNode);
}
numSpawned++;
if (maxNodes < nodes.size()) {
maxNodes = nodes.size();
}
} catch (IOException e) {
}
if (nodes.isEmpty()) {
nodes.add(new Node());
} else {
Node randomNode = getRandomNode();
Node newNode = randomNode.spawn();
nodes.add(newNode);
}
numSpawned++;
if (maxNodes < nodes.size()) {
maxNodes = nodes.size();
}
}
private void kill() {

View File

@ -66,10 +66,8 @@ public class Node {
* Create another peer, mutually link creator and spawn.
*
* @return the spawned Node
* @throws IOException
* if no connection could be established to the new node
*/
public Node spawn() throws IOException {
public Node spawn() {
LOGGER.log(Level.FINE, "Name: " + getName() + ", Spawning new node.");
Node newNode = new Node();
addNeighbor(newNode.getAddress());