@Test
    public void exhaustConnections() throws InterruptedException {
      List<Thread> threads = new ArrayList<>();
      int workerNum = 0;
      for (String jobKey : JOB_KEYS) {
        final Settings workerSettings = SETTINGS.copy();
        if (POOLED) {
          SettingsUtils.setJobTransportPoolingKey(workerSettings, jobKey);
        }
        Thread worker = new Thread(new Exhauster(++workerNum, workerSettings));
        worker.start();
        threads.add(worker);
      }

      for (Thread thread : threads) {
        thread.join();
      }
    }
  public NetworkClient(Settings settings, TransportFactory transportFactory) {
    this.settings = settings.copy();
    this.nodes = SettingsUtils.discoveredOrDeclaredNodes(settings);
    this.transportFactory = transportFactory;

    // shuffle the list of nodes so in case of failures, the fallback is spread
    Collections.shuffle(nodes);

    if (SettingsUtils.hasPinnedNode(settings)) {
      // move pinned node in front to be selected (only once)
      String pinnedNode = SettingsUtils.getPinnedNode(settings);

      if (log.isDebugEnabled()) {
        log.debug("Opening (pinned) network client to " + pinnedNode);
      }

      nodes.remove(pinnedNode);
      nodes.add(0, pinnedNode);
    }

    selectNextNode();

    Assert.notNull(currentTransport, "no node information provided");
  }