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;
/** The node manager. */
private NodeManager nodeManager;
+ /** Request lists for all nodes. */
+ @SuppressWarnings("unused")
+ private Map<Node, Set<Request>> nodeRequests = Collections.synchronizedMap(new HashMap<Node, Set<Request>>());
+
//
// EVENT MANAGEMENT
//
// ACTIONS
//
+ //
+ // PRIVATE ACTIONS
+ //
+
/**
* Requests a list of all running requests from a node. This method will
* block until the request has been sent!
* @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);
/**
* {@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. */
+ }
}
/**