<commit_before>package beyond.launcher

import akka.actor.Actor
import akka.actor.ActorLogging
import akka.actor.OneForOneStrategy
import akka.actor.Props
import akka.actor.SupervisorStrategy._
import beyond.BeyondConfiguration
import beyond.launcher.ZooKeeperLauncher
import java.net.InetAddress
import java.net.NetworkInterface

class LauncherInitializationException extends RuntimeException
class ServerNotRespondingException extends RuntimeException

object LauncherSupervisor {
  val Name: String = "launcherSupervisor"
}

class LauncherSupervisor extends Actor with ActorLogging {
  override def preStart() {
    def launchZooKeeperServerIfNecessary() {
      import scala.collection.JavaConversions._

      val localAddresses = (for {
        ni <- NetworkInterface.getNetworkInterfaces.toIterator
        address <- ni.getInetAddresses
      } yield address).toSet
      log.info(s"Local addresses $localAddresses")

      val zooKeeperAddresses = BeyondConfiguration.zooKeeperServers.map(InetAddress.getByName)
      log.info(s"ZooKeeper addresses $zooKeeperAddresses")

      if (!(localAddresses & zooKeeperAddresses).isEmpty) {
        context.actorOf(Props[ZooKeeperLauncher], name = "zooKeeperLauncher")
      }
    }

    launchZooKeeperServerIfNecessary()
    context.actorOf(Props[MongoDBLauncher], name = "mongoDBLauncher")
  }

  override val supervisorStrategy =
    OneForOneStrategy() {
      // FIXME: Need policy for launcher exceptions.
      case _: ServerNotRespondingException => Restart
      case t =>
        super.supervisorStrategy.decider.applyOrElse(t, (_: Any) => Escalate)
    }

  override def receive: Receive = {
    case _ =>
  }
}

<commit_msg>Remove unnecessary import.<commit_after>package beyond.launcher

import akka.actor.Actor
import akka.actor.ActorLogging
import akka.actor.OneForOneStrategy
import akka.actor.Props
import akka.actor.SupervisorStrategy._
import beyond.BeyondConfiguration
import java.net.InetAddress
import java.net.NetworkInterface

class LauncherInitializationException extends RuntimeException
class ServerNotRespondingException extends RuntimeException

object LauncherSupervisor {
  val Name: String = "launcherSupervisor"
}

class LauncherSupervisor extends Actor with ActorLogging {
  override def preStart() {
    def launchZooKeeperServerIfNecessary() {
      import scala.collection.JavaConversions._

      val localAddresses = (for {
        ni <- NetworkInterface.getNetworkInterfaces.toIterator
        address <- ni.getInetAddresses
      } yield address).toSet
      log.info(s"Local addresses $localAddresses")

      val zooKeeperAddresses = BeyondConfiguration.zooKeeperServers.map(InetAddress.getByName)
      log.info(s"ZooKeeper addresses $zooKeeperAddresses")

      if (!(localAddresses & zooKeeperAddresses).isEmpty) {
        context.actorOf(Props[ZooKeeperLauncher], name = "zooKeeperLauncher")
      }
    }

    launchZooKeeperServerIfNecessary()
    context.actorOf(Props[MongoDBLauncher], name = "mongoDBLauncher")
  }

  override val supervisorStrategy =
    OneForOneStrategy() {
      // FIXME: Need policy for launcher exceptions.
      case _: ServerNotRespondingException => Restart
      case t =>
        super.supervisorStrategy.decider.applyOrElse(t, (_: Any) => Escalate)
    }

  override def receive: Receive = {
    case _ =>
  }
}


{'fraction_non_alphanumeric': 0.07860131500298864, 'fraction_numerical': 0.0, 'mean_word_length': 4.181114551083591, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '5097674', 'n_tokens_mistral': 1026, 'n_tokens_neox': 962, 'n_words': 196}