From 6a23d56e2d7209d3983c12b97edd9c0eccc8555d Mon Sep 17 00:00:00 2001 From: senft-desktop Date: Wed, 19 Dec 2012 09:17:27 +0100 Subject: [PATCH] New static ID for first node, logger level --- ws2012/P2P/uebungen/8/logging.properties | 9 ++++----- ws2012/P2P/uebungen/8/src/node/Identifier.java | 8 ++++---- ws2012/P2P/uebungen/8/src/node/Node.java | 3 ++- ws2012/P2P/uebungen/8/src/routingtable/Bucket.java | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ws2012/P2P/uebungen/8/logging.properties b/ws2012/P2P/uebungen/8/logging.properties index 641865ca..cca961a3 100644 --- a/ws2012/P2P/uebungen/8/logging.properties +++ b/ws2012/P2P/uebungen/8/logging.properties @@ -1,8 +1,7 @@ -handlers=java.util.logging.FileHandler, java.util.logging.ConsoleHandler +handlers=java.util.logging.ConsoleHandler -tutego.level = ALL +.level=ALL java.util.logging.SimpleFormatter.format=[%1$tF %1$tr] %3$s %4$s: %5$s %n - -java.util.logging.ConsoleHandler.level=ALL -java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter \ No newline at end of file +java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter +java.util.logging.ConsoleHandler.level = ALL diff --git a/ws2012/P2P/uebungen/8/src/node/Identifier.java b/ws2012/P2P/uebungen/8/src/node/Identifier.java index ce4b024f..f81144d7 100644 --- a/ws2012/P2P/uebungen/8/src/node/Identifier.java +++ b/ws2012/P2P/uebungen/8/src/node/Identifier.java @@ -13,14 +13,14 @@ public class Identifier { this.bits = BitSet.valueOf(bytes); } - public Identifier(BitSet bits) { + private Identifier(BitSet bits) { this.bits = bits; } - public Identifier() { + public static Identifier getStaticIdentifier() { BitSet middle = new BitSet(Node.ID_BITS); - middle.set(0); - this.bits = middle; + middle.set(Node.ID_BITS - 1); + return new Identifier(middle); } public static Identifier getRandomIdentifier() { diff --git a/ws2012/P2P/uebungen/8/src/node/Node.java b/ws2012/P2P/uebungen/8/src/node/Node.java index 3f72dab5..0a1695a8 100644 --- a/ws2012/P2P/uebungen/8/src/node/Node.java +++ b/ws2012/P2P/uebungen/8/src/node/Node.java @@ -32,7 +32,8 @@ public class Node { * The first node is always spawned on port 50000 */ private static final int INITIAL_PORT = 50000; - private static final Identifier INITIAL_ID = new Identifier(); + private static final Identifier INITIAL_ID = Identifier + .getStaticIdentifier(); private final static Logger LOGGER = Logger.getLogger(Node.class.getName()); diff --git a/ws2012/P2P/uebungen/8/src/routingtable/Bucket.java b/ws2012/P2P/uebungen/8/src/routingtable/Bucket.java index 310f449b..f7f5282b 100644 --- a/ws2012/P2P/uebungen/8/src/routingtable/Bucket.java +++ b/ws2012/P2P/uebungen/8/src/routingtable/Bucket.java @@ -44,7 +44,7 @@ public class Bucket { if (entries.contains(newEntry)) { // Move to beginning LOGGER.log( - Level.INFO, + Level.FINE, "Node {0} ({1}) already in routing table. Move to end of bucket.", new Object[] { newEntry.id, newEntry.address }); if (entries.size() > 1) {