- if (connectResult.isConnected()) {
- synchronized (syncObject) {
- nodes.add(node);
- nodeConnections.put(node, highLevelClient);
- clientNodes.put(highLevelClient, node);
- }
+ }
+
+ /**
+ * 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 + ")");
+ if (!nodes.contains(node)) {
+ logger.log(Level.WARNING, "Was told to connect to node (" + node + ") I don’t know about!");
+ return;
+ }
+ try {
+ FcpClient fcpClient = new FcpClient(clientName, node.getHostname(), node.getPort());
+ fcpClient.connect();
+ nodeListenerSupport.fireNodeConnected(node);
+ } catch (UnknownHostException uhe1) {
+ nodeListenerSupport.fireNodeConnectionFailed(node, uhe1);
+ } catch (IOException ioe1) {
+ nodeListenerSupport.fireNodeConnectionFailed(node, ioe1);
+ } catch (FcpException fe1) {
+ nodeListenerSupport.fireNodeConnectionFailed(node, fe1);