public int size() { return client.size(); }
public void setNodes(List<NodeRecord> nodes) { this.nodes = nodes; clients = new ArrayList<>(size()); clients.addAll(Collections.nCopies(nodes.size(),null)); }
/** * Create new client protocol session. It loads network configuration and creates client protocol session with random node. Allows delayed start of http client * @param someNodeUrl url on some node in network * @param clientPrivateKey client private key * @param session set to null or to the reconstructed instance * @param delayedStart indicates if start of http client should be delayed * @throws IOException */ public Client(String someNodeUrl, PrivateKey clientPrivateKey, BasicHttpClientSession session, boolean delayedStart) throws IOException { this.clientPrivateKey = clientPrivateKey; loadNetworkFrom(someNodeUrl); clients = new ArrayList<>(size()); for (int i = 0; i < size(); i++) { clients.add(null); } NodeRecord r = Do.sample(nodes); httpClient = new BasicHttpClient(r.url); this.nodePublicKey = r.key; if(!delayedStart) httpClient.start(clientPrivateKey, r.key, session); }
public ClientNetwork(String nodeUrl, PrivateKey privateKey, BasicHttpClientSession session) throws IOException { client = new Client(nodeUrl, privateKey, session); if (client == null) throw new IOException("failed to connect to to the universa network"); reporter.verbose("Read Universa network configuration: " + client.size() + " nodes"); reporter.message("Network version: " + client.getVersion()); }
AtomicInteger okNodes = new AtomicInteger(0); final List<Client.NodeRecord> nodes = client.getNodes(); for (int nn = 0; nn < client.size(); nn++) { final int nodeNumber = nn; futures.add( es.shutdown(); int n = okNodes.get(); if (n >= client.size() * 0.12) reporter.message("Universa network is active, " + n + " node(s) are reachable"); else
public ClientNetwork(String nodeUrl, BasicHttpClientSession session, boolean delayedStart) throws IOException { client = new Client(nodeUrl, CLIMain.getPrivateKey(), session, delayedStart); if (client == null) throw new IOException("failed to connect to to the universa network"); reporter.verbose("Read Universa network configuration: " + client.size() + " nodes"); reporter.message("Network version: " + client.getVersion()); }
public ClientNetwork(BasicHttpClientSession session, boolean delayedStart) throws IOException { for (int i = 1; i < 10; i++) { try { client = new Client("http://node-" + Do.randomIntInRange(1, 10) + "-com.universa.io:8080", CLIMain.getPrivateKey(), session, delayedStart); break; } catch (IOException e) { reporter.warning("failed to read network from node " + i); } } if (client == null) throw new IOException("failed to connect to to the universa network"); reporter.verbose("Read Universa network configuration: " + client.size() + " nodes"); reporter.message("Network version: " + client.getVersion()); }