X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Fjsite%2Fcore%2FNodeManager.java;h=f032570c02a97cb9306f09405365c42ebb1cd06a;hb=c63257e8cc0ba1a5aca9364b22171abe7279d479;hp=c251232d246364ea618a34009f8bdb15ee4546fd;hpb=f2aa4d06e218670fe40b602ea068db3c50446358;p=jSite2.git diff --git a/src/net/pterodactylus/jsite/core/NodeManager.java b/src/net/pterodactylus/jsite/core/NodeManager.java index c251232..f032570 100644 --- a/src/net/pterodactylus/jsite/core/NodeManager.java +++ b/src/net/pterodactylus/jsite/core/NodeManager.java @@ -49,7 +49,7 @@ import net.pterodactylus.util.number.Hex; /** * TODO - * + * * @author David ‘Bombe’ Roden <bombe@freenetproject.org> */ public class NodeManager implements Iterable, PropertyChangeListener, HighLevelClientListener { @@ -83,7 +83,7 @@ public class NodeManager implements Iterable, PropertyChangeListener, High /** * Creates a new FCP collector. - * + * * @param clientName * The name of the FCP client * @param directory @@ -100,7 +100,7 @@ public class NodeManager implements Iterable, PropertyChangeListener, High /** * Adds the given listener to the list of listeners. - * + * * @param nodeListener * The listener to add */ @@ -110,7 +110,7 @@ public class NodeManager implements Iterable, PropertyChangeListener, High /** * Removes the given listener from the list of listeners. - * + * * @param nodeListener * The listener to remove */ @@ -120,11 +120,12 @@ public class NodeManager implements Iterable, PropertyChangeListener, High /** * Notifies all listeners that a node was added. - * + * * @param node * The node that was added. */ private void fireNodeAdded(Node node) { + logger.log(Level.FINEST, "firing nodeAdded event with [node=" + node + "]"); for (NodeListener nodeListener : nodeListeners) { nodeListener.nodeAdded(node); } @@ -132,11 +133,12 @@ public class NodeManager implements Iterable, PropertyChangeListener, High /** * Notifies all listeners that a node was removed. - * + * * @param node * The node that was removed */ private void fireNodeRemoved(Node node) { + logger.log(Level.FINEST, "firing nodeRemoved event with [node=" + node + "]"); for (NodeListener nodeListener : nodeListeners) { nodeListener.nodeRemoved(node); } @@ -144,11 +146,12 @@ public class NodeManager implements Iterable, PropertyChangeListener, High /** * Notifies all listeners that the given node was connected. - * + * * @param node * The node that is now connected */ private void fireNodeConnected(Node node) { + logger.log(Level.FINEST, "firing nodeConnected event with [node=" + node + "]"); for (NodeListener nodeListener : nodeListeners) { nodeListener.nodeConnected(node); } @@ -156,13 +159,14 @@ public class NodeManager implements Iterable, PropertyChangeListener, High /** * Notifies all listeners that a connection to a node has failed. - * + * * @param node * The node that could not be connected * @param cause * The cause of the failure */ private void fireNodeConnectionFailed(Node node, Throwable cause) { + logger.log(Level.FINEST, "firing nodeConnectionFailed event with [node=" + node + ",cause=" + cause + "]"); for (NodeListener nodeListener : nodeListeners) { nodeListener.nodeConnectionFailed(node, cause); } @@ -170,7 +174,7 @@ public class NodeManager implements Iterable, PropertyChangeListener, High /** * Notifies all listeners that the given node was disconnected. - * + * * @param node * The node that is now disconnected * @param throwable @@ -178,6 +182,7 @@ public class NodeManager implements Iterable, PropertyChangeListener, High * if there was no exception */ private void fireNodeDisconnected(Node node, Throwable throwable) { + logger.log(Level.FINEST, "firing nodeDisconnected event with [node=" + node + ",throwable=" + throwable + "]"); for (NodeListener nodeListener : nodeListeners) { nodeListener.nodeDisconnected(node, throwable); } @@ -189,7 +194,7 @@ public class NodeManager implements Iterable, PropertyChangeListener, High /** * Returns the directory in which the nodes are stored. - * + * * @return The directory the nodes are stored in */ public String getDirectory() { @@ -198,7 +203,7 @@ public class NodeManager implements Iterable, PropertyChangeListener, High /** * Checks whether the given node is already connected. - * + * * @param node * The node to check * @return true if the node is already connected, @@ -221,11 +226,12 @@ public class NodeManager implements Iterable, PropertyChangeListener, High /** * Loads nodes. - * + * * @throws IOException * if an I/O error occurs loading the nodes */ public void load() throws IOException { + logger.log(Level.FINEST, "load()"); File directoryFile = new File(directory); File nodeFile = new File(directoryFile, "nodes.properties"); if (!nodeFile.exists() || !nodeFile.isFile() || !nodeFile.canRead()) { @@ -277,7 +283,7 @@ public class NodeManager implements Iterable, PropertyChangeListener, High newNode.setPort(nodePort); loadedNodes.add(newNode); } - logger.fine("loaded " + loadedNodes.size() + " nodes from config"); + logger.log(Level.FINE, "loaded " + loadedNodes.size() + " nodes from config"); synchronized (syncObject) { nodes.clear(); for (Node node : loadedNodes) { @@ -288,11 +294,12 @@ public class NodeManager implements Iterable, PropertyChangeListener, High /** * Saves all configured nodes. - * + * * @throws IOException * if an I/O error occurs saving the nodes */ public void save() throws IOException { + logger.log(Level.FINEST, "save()"); File directoryFile = new File(directory); if (!directoryFile.exists()) { if (!directoryFile.mkdirs()) { @@ -320,7 +327,7 @@ public class NodeManager implements Iterable, PropertyChangeListener, High /** * Adds the given node to this manager. - * + * * @see #connect(Node) * @param node * The node to connect to @@ -328,8 +335,9 @@ public class NodeManager implements Iterable, PropertyChangeListener, High * if the node was not added because it was already known */ public boolean addNode(Node node) { + logger.log(Level.FINEST, "addNode(node=" + node + ")"); if (nodes.contains(node)) { - logger.warning("was told to add already known node: " + node); + logger.log(Level.WARNING, "was told to add already known node: " + node); return false; } node.addPropertyChangeListener(this); @@ -346,11 +354,12 @@ public class NodeManager implements Iterable, PropertyChangeListener, High /** * Removes the given node from the node manager, disconnecting it if it is * currently connected. - * + * * @param node * The node to remove */ public void removeNode(Node node) { + logger.log(Level.FINEST, "removeNode(node=" + node + ")"); synchronized (syncObject) { if (!nodes.contains(node)) { return; @@ -367,15 +376,16 @@ public class NodeManager implements Iterable, PropertyChangeListener, High /** * Tries to establish a connection with the given node. - * + * * @param node * The node to connect to */ public void connect(Node node) { + logger.log(Level.FINEST, "connect(node=" + node + ")"); HighLevelClient highLevelClient; highLevelClient = nodeClients.get(node); if (highLevelClient == null) { - logger.warning("was told to connect to unknown node: " + node); + logger.log(Level.WARNING, "was told to connect to unknown node: " + node); return; } try { @@ -389,11 +399,12 @@ public class NodeManager implements Iterable, PropertyChangeListener, High /** * Disconnects the given node without removing it. - * + * * @param node * The node to disconnect */ public void disconnect(Node node) { + logger.log(Level.FINEST, "disconnect(node=" + node + ")"); synchronized (syncObject) { if (!nodes.contains(node)) { return; @@ -405,7 +416,7 @@ public class NodeManager implements Iterable, PropertyChangeListener, High /** * Returns a list of all nodes. - * + * * @return A list of all nodes */ public List getNodes() { @@ -414,7 +425,7 @@ public class NodeManager implements Iterable, PropertyChangeListener, High /** * Returns the high-level client for a given node. - * + * * @param node * The node to get a high-level client for * @return The high-level client for a node, or null if the @@ -426,7 +437,7 @@ public class NodeManager implements Iterable, PropertyChangeListener, High /** * Returns the node for a high-level client. - * + * * @param highLevelClient * The high-level client to get the node for * @return The node for the high-level client, or null if the @@ -438,7 +449,7 @@ public class NodeManager implements Iterable, PropertyChangeListener, High /** * Returns the node identified by the given ID. - * + * * @param id * The ID of the node * @return The node with the given ID, or null if no such @@ -450,7 +461,7 @@ public class NodeManager implements Iterable, PropertyChangeListener, High /** * Generates a new SSK key pair. - * + * * @return An array with the private key at index 0 and the * public key at index 1 * @throws IOException @@ -459,6 +470,7 @@ public class NodeManager implements Iterable, PropertyChangeListener, High * if there is a problem with the node */ public String[] generateKeyPair() throws IOException, JSiteException { + logger.log(Level.FINEST, "generateKeyPair()"); if (nodes.isEmpty()) { throw new NoNodeException("no node configured"); } @@ -487,7 +499,7 @@ public class NodeManager implements Iterable, PropertyChangeListener, High * {@inheritDoc} */ public void clientConnected(HighLevelClient highLevelClient) { - logger.log(Level.FINER, "clientConnected(c=" + highLevelClient + ")"); + logger.log(Level.FINEST, "clientConnected(highLevelClient=" + highLevelClient + ")"); Node node = clientNodes.get(highLevelClient); if (node == null) { logger.log(Level.WARNING, "got event for unknown client"); @@ -500,7 +512,7 @@ public class NodeManager implements Iterable, PropertyChangeListener, High * {@inheritDoc} */ public void clientDisconnected(HighLevelClient highLevelClient, Throwable throwable) { - logger.log(Level.FINER, "clientDisconnected(c=" + highLevelClient + ",t=" + throwable + ")"); + logger.log(Level.FINEST, "clientDisconnected(highLevelClient=" + highLevelClient + ",throwable=" + throwable + ")"); synchronized (syncObject) { Node node = clientNodes.get(highLevelClient); if (node == null) {