<commit_before>package spray.contrib.socketio.examples

import com.typesafe.config.{ Config, ConfigFactory }
import akka.actor.{ Props, ActorSystem }
import akka.io.IO
import akka.persistence.Persistence
import akka.persistence.journal.leveldb.{ SharedLeveldbJournal, SharedLeveldbStore }
import rx.lang.scala.Observer
import spray.can.server.UHttp
import rx.lang.scala.Subject
import spray.can.Http
import spray.contrib.socketio.SocketIOExtension
import spray.contrib.socketio.examples.benchmark.SocketIOTestServer.SocketIOServer
import spray.contrib.socketio.namespace.Namespace
import spray.contrib.socketio.namespace.Namespace.OnData
import spray.contrib.socketio.namespace.Namespace.OnEvent
import spray.contrib.socketio.namespace.NamespaceExtension
import spray.contrib.socketio.packet.EventPacket
import spray.contrib.socketio.packet.MessagePacket
import spray.json.JsArray
import spray.json.JsString

object SimpleClusterServer extends App with MySslConfiguration {
  val usage = """
    Usage: SimpleClusterServer [transport|connectionActive|business] -Dakka.cluster.seed-nodes.0=akka.tcp://ClusterSystem@host1:port -Dakka.remote.netty.tcp.hostname=host1 -Dakka.remote.netty.tcp.port=port
              """

  def exitWithUsage = {
    println(usage)
    sys.exit(1)
  }

  def startCluster(config: Config): ActorSystem = {
    val system = ActorSystem("ClusterSystem", config)
    SocketIOExtension(system)
    system
  }

  if (args.length == 0) {
    exitWithUsage
  }
  val arglist = args.toList

  import ConfigFactory._

  val commonSettings = load(ConfigFactory.parseString(
    """
      |akka.loglevel = INFO
      |akka.actor.provider = "akka.cluster.ClusterActorRefProvider"
      |akka.persistence.journal.plugin = "akka.persistence.journal.leveldb-shared"
      |akka.persistence.journal.leveldb-shared.store {
      |  native = off
      |  dir = "target/test-shared-journal"
      |}
      |akka.persistence.snapshot-store.local.dir = "target/test-snapshots"
      |akka.contrib.cluster.sharding.role = "connectionActive"
      |transport.hostname = "0.0.0.0"
      |transport.port = 8080
      |spray.socketio.mode = "cluster"
    """.stripMargin))

  implicit var system: ActorSystem = _

  arglist match {
    case "transport" :: tail =>
      val config = parseString("akka.cluster.roles =[\"transport\"]").withFallback(commonSettings)
      system = startCluster(config)

      implicit val resolver = SocketIOExtension(system).resolver
      val server = system.actorOf(SocketIOServer.props(resolver), name = "socketio-server")<commit_msg>Fix bug that bench server do not recognize the config file<commit_after>package spray.contrib.socketio.examples

import com.typesafe.config.{ Config, ConfigFactory }
import akka.actor.{ Props, ActorSystem }
import akka.io.IO
import akka.persistence.Persistence
import akka.persistence.journal.leveldb.{ SharedLeveldbJournal, SharedLeveldbStore }
import rx.lang.scala.Observer
import spray.can.server.UHttp
import rx.lang.scala.Subject
import spray.can.Http
import spray.contrib.socketio.SocketIOExtension
import spray.contrib.socketio.examples.benchmark.SocketIOTestServer.SocketIOServer
import spray.contrib.socketio.namespace.Namespace
import spray.contrib.socketio.namespace.Namespace.OnData
import spray.contrib.socketio.namespace.Namespace.OnEvent
import spray.contrib.socketio.namespace.NamespaceExtension
import spray.contrib.socketio.packet.EventPacket
import spray.contrib.socketio.packet.MessagePacket
import spray.json.JsArray
import spray.json.JsString

object SimpleClusterServer extends App with MySslConfiguration {
  val usage = """
    Usage: SimpleClusterServer [transport|connectionActive|business] -Dakka.cluster.seed-nodes.0=akka.tcp://ClusterSystem@host1:port -Dakka.remote.netty.tcp.hostname=host1 -Dakka.remote.netty.tcp.port=port
              """

  def exitWithUsage = {
    println(usage)
    sys.exit(1)
  }

  def startCluster(config: Config): ActorSystem = {
    val system = ActorSystem("ClusterSystem", config)
    SocketIOExtension(system)
    system
  }

  if (args.length == 0) {
    exitWithUsage
  }
  val arglist = args.toList

  import ConfigFactory._

  val commonSettings = parseString(
    """
      |akka.actor.provider = "akka.cluster.ClusterActorRefProvider"
      |akka.persistence.journal.plugin = "akka.persistence.journal.leveldb-shared"
      |akka.persistence.journal.leveldb-shared.store {
      |  native = off
      |  dir = "target/test-shared-journal"
      |}
      |akka.persistence.snapshot-store.local.dir = "target/test-snapshots"
      |akka.contrib.cluster.sharding.role = "connectionActive"
      |transport.hostname = "0.0.0.0"
      |transport.port = 8080
      |spray.socketio.mode = "cluster"
    """.stripMargin).withFallback(load())

  implicit var system: ActorSystem = _

  arglist match {
    case "transport" :: tail =>
      val config = parseString("akka.cluster.roles =[\"transport\"]").withFallback(commonSettings)
      system = startCluster(config)

      implicit val resolver = SocketIOExtension(system).resolver
      val server = system.actorOf(SocketIOServer.props(resolver), name = "socketio-server")
{'fraction_non_alphanumeric': 0.10919317300232738, 'fraction_numerical': 0.00504266873545384, 'mean_word_length': 4.172517552657974, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '2498948', 'n_tokens_mistral': 1572, 'n_tokens_neox': 1545, 'n_words': 271}