X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Fjsite%2Fcore%2FNodeManager.java;h=fe52fd772b980d49c2b71a4025a98538b935608f;hb=f7bfc2672693384db5c7a9ee252f6a548e513489;hp=5ed51a719d680f7f0bd7a7f320dd6c03ac59bc67;hpb=439bd54002fcdfa9f88d7f21236d4d8b3fadd6b0;p=jSite2.git
diff --git a/src/net/pterodactylus/jsite/core/NodeManager.java b/src/net/pterodactylus/jsite/core/NodeManager.java
index 5ed51a7..fe52fd7 100644
--- a/src/net/pterodactylus/jsite/core/NodeManager.java
+++ b/src/net/pterodactylus/jsite/core/NodeManager.java
@@ -43,7 +43,7 @@ import net.pterodactylus.util.logging.Logging;
/**
* TODO
- *
+ *
* @author David âBombeâ Roden <bombe@freenetproject.org>
* @version $Id$
*/
@@ -78,7 +78,7 @@ public class NodeManager implements HighLevelClientListener {
/**
* Creates a new FCP collector.
- *
+ *
* @param clientName
* The name of the FCP client
* @param directory
@@ -95,7 +95,7 @@ public class NodeManager implements HighLevelClientListener {
/**
* Adds the given listener to the list of listeners.
- *
+ *
* @param nodeListener
* The listener to add
*/
@@ -105,7 +105,7 @@ public class NodeManager implements HighLevelClientListener {
/**
* Removes the given listener from the list of listeners.
- *
+ *
* @param nodeListener
* The listener to remove
*/
@@ -115,7 +115,7 @@ public class NodeManager implements HighLevelClientListener {
/**
* Notifies all listeners that the given node was connected.
- *
+ *
* @param node
* The node that is now connected
*/
@@ -127,7 +127,7 @@ public class NodeManager implements HighLevelClientListener {
/**
* Notifies all listeners that the given node was disconnected.
- *
+ *
* @param node
* The node that is now disconnected
* @param throwable
@@ -146,7 +146,7 @@ public class NodeManager implements HighLevelClientListener {
/**
* Returns the directory in which the nodes are stored.
- *
+ *
* @return The directory the nodes are stored in
*/
public String getDirectory() {
@@ -155,7 +155,7 @@ public class NodeManager implements HighLevelClientListener {
/**
* Checks whether the given node is already connected.
- *
+ *
* @param node
* The node to check
* @return true
if the node is already connected,
@@ -171,7 +171,7 @@ public class NodeManager implements HighLevelClientListener {
/**
* Loads nodes.
- *
+ *
* @throws IOException
* if an I/O error occurs loading the nodes
*/
@@ -230,7 +230,7 @@ public class NodeManager implements HighLevelClientListener {
/**
* Saves all configured nodes.
- *
+ *
* @throws IOException
* if an I/O error occurs saving the nodes
*/
@@ -261,7 +261,7 @@ public class NodeManager implements HighLevelClientListener {
/**
* Adds the given node to this manager.
- *
+ *
* @see #connect(Node)
* @param node
* The node to connect to
@@ -277,7 +277,7 @@ public class NodeManager implements HighLevelClientListener {
/**
* Removes the given node from the node manager, disconnecting it if it is
* currently connected.
- *
+ *
* @param node
* The node to remove
*/
@@ -294,7 +294,7 @@ public class NodeManager implements HighLevelClientListener {
/**
* Tries to establish a connection with the given node.
- *
+ *
* @param node
* The node to connect to
*/
@@ -314,7 +314,7 @@ public class NodeManager implements HighLevelClientListener {
/**
* Disconnects the given node without removing it.
- *
+ *
* @param node
* The node to disconnect
*/
@@ -330,7 +330,7 @@ public class NodeManager implements HighLevelClientListener {
/**
* Returns a list of all nodes.
- *
+ *
* @return A list of all nodes
*/
public List getNodes() {
@@ -344,7 +344,7 @@ public class NodeManager implements HighLevelClientListener {
/**
* Finds a currently unused high-level client, optionally waiting until a
* client is free and marking it used.
- *
+ *
* @param wait
* true
to wait for a free connection,
* false
to return null
@@ -374,6 +374,11 @@ public class NodeManager implements HighLevelClientListener {
if (!wait) {
return null;
}
+ try {
+ syncObject.wait();
+ } catch (InterruptedException e) {
+ /* ignore, just re-check. */
+ }
}
/* we never get here, but the compiler doesn't realize. */
return null;
@@ -401,7 +406,7 @@ public class NodeManager implements HighLevelClientListener {
* {@inheritDoc}
*/
public void clientDisconnected(HighLevelClient highLevelClient, Throwable throwable) {
- logger.log(Level.FINER, "clientDisconnected(c=" + highLevelClient + ",t=" + throwable +")");
+ logger.log(Level.FINER, "clientDisconnected(c=" + highLevelClient + ",t=" + throwable + ")");
synchronized (syncObject) {
Node node = clientNodes.remove(highLevelClient);
if (node == null) {
@@ -409,6 +414,7 @@ public class NodeManager implements HighLevelClientListener {
return;
}
nodeClients.remove(node);
+ usedConnections.remove(highLevelClient);
fireNodeDisconnected(node, throwable);
}
}