public void addNode(NodeInfo nodeInfo) { netConfig.addNode(nodeInfo); }
public NodeInfo getInfo(int number) { return netConfig.getInfo(number); }
result[1] = new NetConfig(nodeInfos); return result; } catch (Exception e) {
public List<NodeInfo> allNodes() { return netConfig.toList(); }
/** * Enumerate all nodes passing them to the consumer * * @param consumer is {@link Consumer} object */ public void eachNode(Consumer<NodeInfo> consumer) { netConfig.forEachNode(n -> consumer.accept(n)); }
public void removeNode(NodeInfo nodeInfo) { netConfig.removeNode(nodeInfo); } }
public int getNodesCount() { return netConfig.size(); }
nodes.add(node2); NetConfig nc = new NetConfig(nodes);
for(NodeInfo nodeInfo : netConfig.toList()) { String sqlText; if(nodeInfo.getNumber() == myInfo.getNumber()) {
/** * Deliver notification to all nodes except one * * @param exceptNode if not null, do not deliver to it. * @param notification notification fo deliver */ public void broadcast(NodeInfo exceptNode, Notification notification) { netConfig.forEachNode(node -> { if (exceptNode != null && !exceptNode.equals(node)) deliver(node, notification); }); }
nodes.add(node2); NetConfig nc = new NetConfig(nodes);
/** * @see UDPAdapter#getOrCreateSession * @param remoteId id of remote node, {@link NodeInfo} will be got from {@link UDPAdapter#netConfig} * @return session */ private Session getOrCreateSession(int remoteId) { NodeInfo destination = netConfig.getInfo(remoteId); if (destination == null) { callErrorCallbacks("(getOrCreateSession) unknown nodeId has received: "+remoteId); return null; } return getOrCreateSession(destination); }
private void checkNode(Session session, boolean checkKeyLimit) throws CommandFailedException { // checking node if (node == null) { throw new CommandFailedException(Errors.NOT_READY, "", "please call again after a while"); } if(node.isSanitating()) { //WHILE NODE IS SANITATING IT COMMUNICATES WITH THE OTHER NODES ONLY if(netConfig.toList().stream().anyMatch(nodeInfo -> nodeInfo.getPublicKey().equals(session.getPublicKey()))) return; throw new CommandFailedException(Errors.NOT_READY, "", "please call again after a while"); } // checking key limit if (checkKeyLimit) if (!node.checkKeyLimit(session.getPublicKey())) throw new CommandFailedException(Errors.COMMAND_FAILED, "", "exceeded the limit of requests for key per minute, please call again after a while"); }
public NetConfig(Collection<NodeInfo> nodes) { nodes.forEach(n->{ addNode(n); }); }