code: private void selectNode(final Object key, final Handler<AsyncResult<String>> doneHandler) {
      context.execute(new Action<String>() {
        @Override
        public String perform() {
          String address = nodeSelectors.get(key);
          if (address != null) {
            return address;
          }
          Set<String> nodes = new HashSet<>();
          for (String group : groups.keySet()) {
            nodes.addAll(groups.get(group));
          }
          int index = new Random().nextInt(nodes.size());
          int i = 0;
          for (String node : nodes) {
            if (i == index) {
              nodeSelectors.put(key, node);
              return node;
            }
            i++;
          }
          return null;
        }
      }, doneHandler);
    }
docs: Selects a node.