private[this] def validatePreconditions()

in src/main/scala/com/twitter/iago/feeder/ParrotFeeder.scala [109:151]


  private[this] def validatePreconditions(): Boolean = {
    if (config.batchSizeF() <= 0) {
      log.error("batchSize is set <= 0! Shutting down")
      return false
    }

    if (config.maxRequestsF() <= 0) {
      log.error("maxRequests is <= 0! Shutting down")
      return false
    }

    if (!lines.hasNext) {
      log.error("The log file is empty! Shutting down")
      return false
    }

    // Must call this before blocking below
    cluster.connectParrots()

    // This gives our server(s) a chance to start up by waiting on a latch the Poller manages.
    // This technically could have a bug -- if a server were to start up and then disappear,
    // the latch would still potentially tick down in the poller, and we'd end up with
    // fewer servers than expected. The code further down will cover that condition.

    val wantedInstances = config.numInstancesF()
    log.info("Awaiting %d servers to stand up and be recognized.", wantedInstances)
    allServers.await(5, TimeUnit.MINUTES)

    if (cluster.runningParrots.isEmpty) {
      log.error("Empty Parrots list! Is Parrot running somewhere?")
      return false
    }

    val actualInstances = cluster.runningParrots.size

    if (actualInstances != wantedInstances) {
      log.error("Found %d servers, expected %d", actualInstances, wantedInstances)
      cluster.runningParrots foreach { parrot =>
        log.error("Server: %s", parrot.address)
      }
    }
    true
  }