<commit_before>package com.airbnb.scheduler.config

import org.rogach.scallop.ScallopConf
import java.net.InetSocketAddress
import org.joda.time.Period


/**
 * Configuration values that may be parsed from a YAML file.
 * @author <NAME> (<EMAIL>)
 */
trait SchedulerConfiguration extends ScallopConf {

  lazy val master = opt[String]("master",
    descr = "The URL of the Mesos master",
    default = Some("local"),
    required = true,
    noshort = true)

  lazy val user = opt[String]("user",
    descr = "The mesos user to run the processes under",
    default = Some("root"))

  //TODO(FL): Be consistent and do everything in millis
  lazy val failoverTimeoutSeconds = opt[Int]("failover_timeout",
    descr = "The failover timeout in seconds for Mesos",
    default = Some(1200))

  lazy val scheduleHorizonSeconds = opt[Int]("schedule_horizon",
    descr = "The look-ahead time for scheduling tasks in seconds",
    default = Some(60))

  lazy val clusterName = opt[String]("cluster_name",
    descr = "The name of the cluster where Chronos is run",
    default = None)

  def zookeeperServers() : String = {
    if (zookeeperServersString().startsWith("zk://")) {
      return zookeeperServersString().replace("zk://", "").replaceAll("/.*", "")
    }
    zookeeperServersString()
  }

  lazy val zookeeperServersString = opt[String]("zk_hosts",
    descr = "The list of ZooKeeper servers for storing state",
    default = Some("localhost:2181"))

  def zooKeeperHostAddresses: Seq[InetSocketAddress] =
    for (s <- zookeeperServers().split(",")) yield {
      val splits = s.split(":")
      require(splits.length == 2, "expected host:port for zk servers")
      new InetSocketAddress(splits(0), splits(1).toInt)
    }

  lazy val hostname = opt[String]("hostname",
    descr = "The advertised hostname stored in ZooKeeper so another standby " +
      "host can redirect to this elected leader",
    default = Some(java.net.InetAddress.getLocalHost().getHostName()))

  lazy val leaderMaxIdleTimeMs = opt[Int]("leader_max_idle_time",
    descr = "The look-ahead time for scheduling tasks in milliseconds",
    default = Some(5000))

  lazy val zooKeeperTimeout = opt[Long]("zk_timeout",
    descr = "The timeout for ZooKeeper in milliseconds",
    default = Some(10000L))

  lazy val zooKeeperPath = opt[String]("zk_path",
    descr = "Path in ZooKeeper for storing state",
    default = Some("/chronos/state"))

  def zooKeeperStatePath = "%s/state".format(zooKeeperPath())

  def zooKeeperCandidatePath = "%s/candidate".format(zooKeeperPath())

  lazy val mailServer = opt[String]("mail_server",
    descr = "Address of the mailserver",
    default = None)

  lazy val mailUser = opt[String]("mail_user",
    descr = "Mail user (for auth)",
    default = None)

  lazy val mailPassword = opt[String]("mail_password",
    descr = "Mail password (for auth)",
    default = None)

  lazy val mailFrom = opt[String]("mail_from",
    descr = "Mail from field",
    default = None)

  lazy val mailSslOn = opt[Boolean]("mail_ssl",
    descr = "Mail SSL",
    default = Some(false))

  lazy val ravenDsn = opt[String]("raven_dsn",
    descr = "Raven DSN for connecting to a raven or sentry event service",
    default = None)

  lazy val failureRetryDelayMs = opt[Long]("failure_retry",
    descr = "Number of ms between retries",<commit_msg>better help for mail server option<commit_after>package com.airbnb.scheduler.config

import org.rogach.scallop.ScallopConf
import java.net.InetSocketAddress
import org.joda.time.Period


/**
 * Configuration values that may be parsed from a YAML file.
 * @author <NAME> (<EMAIL>)
 */
trait SchedulerConfiguration extends ScallopConf {

  lazy val master = opt[String]("master",
    descr = "The URL of the Mesos master",
    default = Some("local"),
    required = true,
    noshort = true)

  lazy val user = opt[String]("user",
    descr = "The mesos user to run the processes under",
    default = Some("root"))

  //TODO(FL): Be consistent and do everything in millis
  lazy val failoverTimeoutSeconds = opt[Int]("failover_timeout",
    descr = "The failover timeout in seconds for Mesos",
    default = Some(1200))

  lazy val scheduleHorizonSeconds = opt[Int]("schedule_horizon",
    descr = "The look-ahead time for scheduling tasks in seconds",
    default = Some(60))

  lazy val clusterName = opt[String]("cluster_name",
    descr = "The name of the cluster where Chronos is run",
    default = None)

  def zookeeperServers() : String = {
    if (zookeeperServersString().startsWith("zk://")) {
      return zookeeperServersString().replace("zk://", "").replaceAll("/.*", "")
    }
    zookeeperServersString()
  }

  lazy val zookeeperServersString = opt[String]("zk_hosts",
    descr = "The list of ZooKeeper servers for storing state",
    default = Some("localhost:2181"))

  def zooKeeperHostAddresses: Seq[InetSocketAddress] =
    for (s <- zookeeperServers().split(",")) yield {
      val splits = s.split(":")
      require(splits.length == 2, "expected host:port for zk servers")
      new InetSocketAddress(splits(0), splits(1).toInt)
    }

  lazy val hostname = opt[String]("hostname",
    descr = "The advertised hostname stored in ZooKeeper so another standby " +
      "host can redirect to this elected leader",
    default = Some(java.net.InetAddress.getLocalHost().getHostName()))

  lazy val leaderMaxIdleTimeMs = opt[Int]("leader_max_idle_time",
    descr = "The look-ahead time for scheduling tasks in milliseconds",
    default = Some(5000))

  lazy val zooKeeperTimeout = opt[Long]("zk_timeout",
    descr = "The timeout for ZooKeeper in milliseconds",
    default = Some(10000L))

  lazy val zooKeeperPath = opt[String]("zk_path",
    descr = "Path in ZooKeeper for storing state",
    default = Some("/chronos/state"))

  def zooKeeperStatePath = "%s/state".format(zooKeeperPath())

  def zooKeeperCandidatePath = "%s/candidate".format(zooKeeperPath())

  lazy val mailServer = opt[String]("mail_server",
    descr = "Address of the mailserver in server:port format",
    default = None)

  lazy val mailUser = opt[String]("mail_user",
    descr = "Mail user (for auth)",
    default = None)

  lazy val mailPassword = opt[String]("mail_password",
    descr = "Mail password (for auth)",
    default = None)

  lazy val mailFrom = opt[String]("mail_from",
    descr = "Mail from field",
    default = None)

  lazy val mailSslOn = opt[Boolean]("mail_ssl",
    descr = "Mail SSL",
    default = Some(false))

  lazy val ravenDsn = opt[String]("raven_dsn",
    descr = "Raven DSN for connecting to a raven or sentry event service",
    default = None)

  lazy val failureRetryDelayMs = opt[Long]("failure_retry",
    descr = "Number of ms between retries",
{'fraction_non_alphanumeric': 0.12305180347335609, 'fraction_numerical': 0.006531096927415764, 'mean_word_length': 3.9075018208302987, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '140651', 'n_tokens_mistral': 2214, 'n_tokens_neox': 2116, 'n_words': 615}