public boolean ping(int i) { try { return getClient(i).ping(); } catch (Exception e) { } return false; }
/** * Get session of http client connected to node with given number * * @param i number of the node to return session with * @return session */ public BasicHttpClientSession getSession(int i) throws IllegalStateException, IOException { return getClient(i).httpClient.getSession(); }
Client c = getClient(nn); ItemResult r = c.command("getState", "itemId", itemId).getOrThrow("itemResult"); r.meta.put("url", c.getNodeNumber());
clients.put(i,client.getClient(i)); clients.get(i).ping();
try { Client c = clients.getClient(i);
public static synchronized ClientNetwork getClientNetwork() throws IOException { if (clientNetwork == null) { reporter.verbose("ClientNetwork not exist, create one"); BasicHttpClientSession s = null; reporter.verbose("ClientNetwork nodeUrl: " + nodeUrl); if(nodeUrl != null) { clientNetwork = new ClientNetwork(nodeUrl, null, true); } else { clientNetwork = new ClientNetwork(null, true); } if (clientNetwork.client == null) throw new IOException("failed to connect to to the universa network"); if(nodeNumber != -1) { List<Client.NodeRecord> nodes = clientNetwork.client.getNodes(); clientNetwork.client = clientNetwork.client.getClient(nodeNumber-1); clientNetwork.client.setNodes(nodes); } if(!options.has("no-cache")) { s = getSession(clientNetwork.getNodeNumber()); } reporter.verbose("Session for " + clientNetwork.getNodeNumber() + " is exist: " + (s != null)); if(s != null) reporter.verbose("Session id is " + s.getSessionId()); clientNetwork.start(s); } if(clientNetwork != null) session = clientNetwork.getSession(); return clientNetwork; }