org.apache.mesos.MesosSchedulerDriver Scala Examples
The following examples show how to use org.apache.mesos.MesosSchedulerDriver.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
Example 1
Source File: Launcher.scala From amaterasu with Apache License 2.0 | 5 votes |
package org.apache.amaterasu.leader.mesos import java.io.FileInputStream import org.apache.amaterasu.common.configuration.ClusterConfig import org.apache.amaterasu.common.logging.Logging import org.apache.amaterasu.leader.Kami import org.apache.amaterasu.leader.mesos.schedulers.ClusterScheduler import org.apache.mesos.{MesosSchedulerDriver, Protos} object Launcher extends App with Logging { println( """ Apache ( ) )\ ) ) ( /( ( ( ) ( ((_)( ( ( /( )\() ))\ )( ( /( ( ))\ )\ _ )\ )\ ' )(_))(_))/ /((_)(()\ )(_)) )\ /((_) (_)_\(_) _((_)) ((_) _ | |_ (_)) ((_)((_)_ ((_)(_))( / _ \ | ' \()/ _` || _|/ -_) | '_|/ _` |(_-<| || | /_/ \_\ |_|_|_| \__,_| \__|\___| |_| \__,_|/__/ \_,_| Durable Dataflow Cluster Version 0.1.0 """ ) val config = ClusterConfig(new FileInputStream("scripts/amaterasu.properties")) val kami = Kami(Seq("https://github.com/roadan/amaterasu-job-sample.git")) // for multi-tenancy reasons the name of the framework is composed out of the username ( which defaults // to empty string concatenated with - Amaterasu val framework = Protos.FrameworkInfo.newBuilder() .setName(s"${config.user} - Amaterasu") .setFailoverTimeout(config.timeout) .setUser(config.user).build() log.debug(s"The framework user is ${config.user}") val masterAddress = s"${config.master}:${config.masterPort}" val scheduler = ClusterScheduler(kami, config) val driver = new MesosSchedulerDriver(scheduler, framework, masterAddress) log.debug(s"Connecting to master on: $masterAddress") driver.run() }
Example 2
Source File: JobLauncher.scala From amaterasu with Apache License 2.0 | 5 votes |
package org.apache.amaterasu.leader.mesos import java.io.FileInputStream import java.nio.file.Paths import org.apache.amaterasu.common.logging.Logging import org.apache.amaterasu.common.configuration.ClusterConfig import org.apache.amaterasu.leader.mesos.schedulers.JobScheduler import org.apache.mesos.Protos.FrameworkID import org.apache.mesos.{MesosSchedulerDriver, Protos} case class Args( repo: String = "", branch: String = "master", env: String = "default", name: String = "amaterasu-job", jobId: String = null, report: String = "code", home: String = "" ) object JobLauncher extends App with Logging { val parser = new scopt.OptionParser[Args]("amaterasu job") { head("amaterasu job", "0.2.0-incubating") //TODO: Get the version from the build opt[String]('r', "repo") action { (x, c) => c.copy(repo = x) } text "The git repo containing the job" opt[String]('b', "branch") action { (x, c) => c.copy(branch = x) } text "The branch to be executed (default is master)" opt[String]('e', "env") action { (x, c) => c.copy(env = x) } text "The environment to be executed (test, prod, etc. values from the default env are taken if np env specified)" opt[String]('n', "name") action { (x, c) => c.copy(name = x) } text "The name of the job" opt[String]('i', "job-id") action { (x, c) => c.copy(jobId = x) } text "The jobId - should be passed only when resuming a job" opt[String]('r', "report") action { (x, c) => c.copy(report = x) } opt[String]('h', "home") action { (x, c) => c.copy(home = x) } text "The level of reporting" } parser.parse(args, Args()) match { case Some(arguments) => val config = ClusterConfig(new FileInputStream(s"${arguments.home}/amaterasu.properties")) val frameworkBuilder = Protos.FrameworkInfo.newBuilder() .setName(s"${arguments.name} - Amaterasu Job") .setFailoverTimeout(config.timeout) .setUser(config.user) // TODO: test this val resume = arguments.jobId != null if (resume) { frameworkBuilder.setId(FrameworkID.newBuilder().setValue(arguments.jobId)) } val framework = frameworkBuilder.build() val masterAddress = s"${config.master}:${config.masterPort}" val scheduler = JobScheduler( arguments.repo, arguments.branch, arguments.env, resume, config, arguments.report, arguments.home ) val driver = new MesosSchedulerDriver(scheduler, framework, masterAddress) log.debug(s"Connecting to master on: $masterAddress") driver.run() case None => // arguments are bad, error message will have been displayed } }