aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/scala/spark/deploy/client/TestClient.scala
blob: dc004b59ca5ac247d4e7c8125b775a1f1698e7ea (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package spark.deploy.client

import spark.util.AkkaUtils
import spark.{Logging, Utils}
import spark.deploy.{Command, ApplicationDescription}

private[spark] object TestClient {

  class TestListener extends ClientListener with Logging {
    def connected(id: String) {
      logInfo("Connected to master, got app ID " + id)
    }

    def disconnected() {
      logInfo("Disconnected from master")
      System.exit(0)
    }

    def executorAdded(id: String, workerId: String, host: String, cores: Int, memory: Int) {}

    def executorRemoved(id: String, message: String, exitStatus: Option[Int]) {}
  }

  def main(args: Array[String]) {
    val url = args(0)
    val (actorSystem, port) = AkkaUtils.createActorSystem("spark", Utils.localIpAddress, 0)
    val desc = new ApplicationDescription(
      "TestClient", 1, 512, Command("spark.deploy.client.TestExecutor", Seq(), Map()), "dummy-spark-home")
    val listener = new TestListener
    val client = new Client(actorSystem, url, desc, listener)
    client.start()
    actorSystem.awaitTermination()
  }
}