private void runAllActiveClients()

in src/main/java/com/uber/rss/clients/ReplicatedWriteClient.java [145:181]


  private void runAllActiveClients(Consumer<ServerIdAwareSyncWriteClient> action) {
    Exception exception = null;
    boolean succeeded = false;
    int numActiveClients = 0;
    for (int i = 0; i < clients.length; i++) {
      ServerIdAwareSyncWriteClient client = clients[i];
      if (client != null) {
        numActiveClients++;
        try {
          action.accept(client);
          succeeded = true;
        } catch (Exception ex) {
          exception = ex;
          M3Stats.addException(ex, this.getClass().getSimpleName());
          logger.warn("Failed to run client: " + client, ex);

          clients[i] = null;
          try {
            client.close();
          } catch (Throwable closeException) {
            logger.warn("Failed to close client: " + client, closeException);
          }
        }
      }
    }

    if (numActiveClients == 0) {
      throw new RssException("No active client connecting to server replication group: " + serverReplicationGroup);
    }

    if (!succeeded) {
      if (exception == null) {
        throw new RssInvalidStateException(String.format("No underlying client succeeded, but no exception as well, %s", this));
      }
      ExceptionUtils.throwException(exception);
    }
  }