X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Fjsite%2Fcore%2FRequestManager.java;h=925573d9328c1c3927eb0b61ed3f205d38b51526;hb=ebd531bc775036dd66a7e20abebbcb480af35491;hp=f2aa23f6aa1d69bdcad39987a82e89592c1d6427;hpb=1a15797202b29b63a0677041c437bb0dcb559e54;p=jSite2.git diff --git a/src/net/pterodactylus/jsite/core/RequestManager.java b/src/net/pterodactylus/jsite/core/RequestManager.java index f2aa23f..925573d 100644 --- a/src/net/pterodactylus/jsite/core/RequestManager.java +++ b/src/net/pterodactylus/jsite/core/RequestManager.java @@ -22,7 +22,10 @@ package net.pterodactylus.jsite.core; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -53,6 +56,10 @@ public class RequestManager implements NodeListener { /** The node manager. */ private NodeManager nodeManager; + /** Request lists for all nodes. */ + @SuppressWarnings("unused") + private Map> nodeRequests = Collections.synchronizedMap(new HashMap>()); + // // EVENT MANAGEMENT // @@ -109,6 +116,10 @@ public class RequestManager implements NodeListener { // ACTIONS // + // + // PRIVATE ACTIONS + // + /** * Requests a list of all running requests from a node. This method will * block until the request has been sent! @@ -118,7 +129,7 @@ public class RequestManager implements NodeListener { * @throws IOException * if an I/O error occurs while communicating with the node */ - public void getRequests(final Node node) throws IOException { + private void getRequests(final Node node) throws IOException { HighLevelClient highLevelClient = nodeManager.borrowHighLevelClient(node); if (highLevelClient == null) { logger.log(Level.WARNING, "no client for node: " + node); @@ -156,8 +167,38 @@ public class RequestManager implements NodeListener { /** * {@inheritDoc} */ + public void nodeAdded(Node node) { + /* ignore. */ + } + + /** + * {@inheritDoc} + */ + public void nodeRemoved(Node node) { + /* ignore. */ + } + + /** + * {@inheritDoc} + */ public void nodeConnected(Node node) { - /* TODO - get all requests. */ + HighLevelClient highLevelClient = nodeManager.borrowHighLevelClient(node); + if (highLevelClient == null) { + logger.log(Level.WARNING, "got no high-level client for node " + node); + return; + } + try { + highLevelClient.setWatchGlobal(true); + } catch (IOException ioe1) { + /* ignore exception, disconnects are handled elsewhere. */ + } finally { + nodeManager.returnHighLevelClient(highLevelClient); + } + try { + getRequests(node); + } catch (IOException e) { + /* ignore exception, disconnects are handled elsewhere. */ + } } /**