From: David ‘Bombe’ Roden Date: Mon, 27 Oct 2008 19:35:26 +0000 (+0100) Subject: Add random mumber for different jSite instances. X-Git-Tag: 0.7~38 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=0cffcea7c8788a104fb41c9ff55b53fd2aa99cb4;p=jSite.git Add random mumber for different jSite instances. --- diff --git a/src/de/todesbaum/jsite/application/Freenet7Interface.java b/src/de/todesbaum/jsite/application/Freenet7Interface.java index 4c9d9c5..d670fd2 100644 --- a/src/de/todesbaum/jsite/application/Freenet7Interface.java +++ b/src/de/todesbaum/jsite/application/Freenet7Interface.java @@ -34,6 +34,9 @@ import de.todesbaum.util.freenet.fcp2.Node; */ public class Freenet7Interface { + /** Random number to differentiate several jSites. */ + private static final int number = (int) (Math.random() * Integer.MAX_VALUE); + /** Counter. */ private static int counter = 0; @@ -52,7 +55,7 @@ public class Freenet7Interface { */ public void setNodeAddress(String hostname) { node = new Node(hostname); - connection = new Connection(node, "connection-" + counter++); + connection = new Connection(node, "jSite-" + number + "-connection-" + counter++); } /** @@ -65,7 +68,7 @@ public class Freenet7Interface { */ public void setNodeAddress(String hostname, int port) { node = new Node(hostname, port); - connection = new Connection(node, "connection-" + counter++); + connection = new Connection(node, "jSite-" + number + "-connection-" + counter++); } /** @@ -77,7 +80,7 @@ public class Freenet7Interface { public void setNode(de.todesbaum.jsite.application.Node node) { if (node != null) { this.node = new Node(node.getHostname(), node.getPort()); - connection = new Connection(node, "connection-" + counter++); + connection = new Connection(node, "jSite-" + number + "-connection-" + counter++); } else { this.node = null; connection = null; diff --git a/src/de/todesbaum/jsite/application/ProjectInserter.java b/src/de/todesbaum/jsite/application/ProjectInserter.java index 3d2457b..a761951 100644 --- a/src/de/todesbaum/jsite/application/ProjectInserter.java +++ b/src/de/todesbaum/jsite/application/ProjectInserter.java @@ -54,6 +54,9 @@ import de.todesbaum.util.io.StreamCopier; */ public class ProjectInserter implements FileScannerListener, Runnable { + /** Random number for FCP instances. */ + private static final int random = (int) (Math.random() * Integer.MAX_VALUE); + /** Counter for FCP connection identifier. */ private static int counter = 0; @@ -366,7 +369,7 @@ public class ProjectInserter implements FileScannerListener, Runnable { List files = fileScanner.getFiles(); /* create connection to node */ - Connection connection = freenetInterface.getConnection("project-insert-" + counter++); + Connection connection = freenetInterface.getConnection("project-insert-" + random + counter++); boolean connected = false; Throwable cause = null; try {