org.apache.mesos.MesosSchedulerDriver Java 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. You may check out the related API usage on the sidebar.
Example #1
Source File: SchedulerService.java    From shardingsphere-elasticjob-cloud with Apache License 2.0 6 votes vote down vote up
private SchedulerDriver getSchedulerDriver(final TaskScheduler taskScheduler, final JobEventBus jobEventBus, final FrameworkIDService frameworkIDService) {
    Optional<String> frameworkIDOptional = frameworkIDService.fetch();
    Protos.FrameworkInfo.Builder builder = Protos.FrameworkInfo.newBuilder();
    if (frameworkIDOptional.isPresent()) {
        builder.setId(Protos.FrameworkID.newBuilder().setValue(frameworkIDOptional.get()).build());
    }
    Optional<String> role = env.getMesosRole();
    String frameworkName = MesosConfiguration.FRAMEWORK_NAME;
    if (role.isPresent()) {
        builder.setRole(role.get());
        frameworkName += "-" + role.get();
    }
    builder.addCapabilitiesBuilder().setType(Protos.FrameworkInfo.Capability.Type.PARTITION_AWARE);
    MesosConfiguration mesosConfig = env.getMesosConfiguration();
    Protos.FrameworkInfo frameworkInfo = builder.setUser(mesosConfig.getUser()).setName(frameworkName)
            .setHostname(mesosConfig.getHostname()).setFailoverTimeout(MesosConfiguration.FRAMEWORK_FAILOVER_TIMEOUT_SECONDS)
            .setWebuiUrl(WEB_UI_PROTOCOL + env.getFrameworkHostPort()).setCheckpoint(true).build();
    return new MesosSchedulerDriver(new SchedulerEngine(taskScheduler, facadeService, jobEventBus, frameworkIDService, statisticManager), frameworkInfo, mesosConfig.getUrl());
}
 
Example #2
Source File: SchedulerDriverFactoryTest.java    From dcos-commons with Apache License 2.0 6 votes vote down vote up
/**
 * Avoid calls to the MesosSchedulerDriver constructor, which triggers errors about libmesos not
 * being present.
 */
@Override
protected MesosSchedulerDriver createInternal(
        final Scheduler scheduler,
        final FrameworkInfo frameworkInfo,
        final String masterUrl,
        final Credential credential,
        final String mesosAPIVersion) {
    createCalls++;
    if (credential != null) {
        lastCallHadCredential = true;
        lastCallHadSecret = credential.hasSecret();
    } else {
        lastCallHadCredential = false;
        lastCallHadSecret = false;
    }
    return null; // avoid requiring a NoOpSchedulerDriver
}
 
Example #3
Source File: MesosNimbus.java    From storm with Apache License 2.0 6 votes vote down vote up
@Override
public void prepare(Map conf, String localDir) {
  try {
    initializeMesosStormConf(conf, localDir);
    startLocalHttpServer();

    MesosSchedulerDriver driver = createMesosDriver();

    driver.start();

    LOG.info("Waiting for scheduler driver to register MesosNimbus with mesos-master and complete initialization...");

    _mesosScheduler.waitUntilRegistered();

    LOG.info("Scheduler registration and initialization complete...");

    _registeredAndInitialized = true;

  } catch (Exception e) {
    LOG.error("Failed to prepare scheduler ", e);
    throw new RuntimeException(e);
  }
}
 
Example #4
Source File: MyriadDriver.java    From myriad with Apache License 2.0 6 votes vote down vote up
@Inject
public MyriadDriver(final MyriadScheduler scheduler,
		final MyriadConfiguration cfg, final SchedulerState schedulerState) {
	this.scheduler = scheduler;
	FrameworkID frameworkId = schedulerState.getFrameworkId();
	Builder frameworkInfoBuilder = FrameworkInfo.newBuilder().setUser("")
			.setName(cfg.getFrameworkName())
			.setCheckpoint(cfg.getCheckpoint())
			.setFailoverTimeout(cfg.getFrameworkFailoverTimeout());
	if (frameworkId != null) {
		frameworkInfoBuilder.setId(frameworkId);
	}
	this.myriadFrameworkInfo = frameworkInfoBuilder.build();
	this.driver = new MesosSchedulerDriver(this.scheduler,
			this.myriadFrameworkInfo, cfg.getMesosMaster());
}
 
Example #5
Source File: DriverFactoryImpl.java    From attic-aurora with Apache License 2.0 6 votes vote down vote up
@Override
public SchedulerDriver create(
    Scheduler scheduler,
    Optional<Protos.Credential> credentials,
    Protos.FrameworkInfo frameworkInfo,
    String master) {

  FrameworkInfo convertedFrameworkInfo = convert(frameworkInfo);
  Optional<Credential> convertedCredentials = credentials.map(ProtosConversion::convert);

  if (credentials.isPresent()) {
    return new MesosSchedulerDriver(
        scheduler,
        convertedFrameworkInfo,
        master,
        false, // Disable implicit acknowledgements.
        convertedCredentials.get());
  } else {
    return new MesosSchedulerDriver(
        scheduler,
        convertedFrameworkInfo,
        master,
        false); // Disable implicit acknowledgements.
  }
}
 
Example #6
Source File: MesosLauncher.java    From twister2 with Apache License 2.0 5 votes vote down vote up
private void runFramework(String mesosMaster, JobAPI.Job job) {

    Scheduler scheduler = new MesosScheduler(controller, config, job);
    driver = new MesosSchedulerDriver(scheduler, controller.getFrameworkInfo(),
        mesosMaster);
    int status = driver.run() == Protos.Status.DRIVER_STOPPED ? 0 : 1;

    LOG.warning("Job already terminated!");
    //driver.stop();
    //System.exit(status);
  }
 
Example #7
Source File: MesosScheduler.java    From incubator-heron with Apache License 2.0 5 votes vote down vote up
protected SchedulerDriver getSchedulerDriver(String masterURI, MesosFramework framework) {
  Protos.FrameworkInfo.Builder frameworkBuilder = Protos.FrameworkInfo.newBuilder()
      .setUser("") // Have Mesos fill in the current user.
      .setName("heron_scheduler_" + Context.topologyName(config))
      .setCheckpoint(true);

  return new MesosSchedulerDriver(
      framework,
      frameworkBuilder.build(),
      masterURI);
}
 
Example #8
Source File: REEFScheduler.java    From reef with Apache License 2.0 5 votes vote down vote up
@Inject
REEFScheduler(final REEFEventHandlers reefEventHandlers,
              final MesosRemoteManager mesosRemoteManager,
              final REEFExecutors executors,
              final REEFFileNames fileNames,
              final EStage<SchedulerDriver> schedulerDriverEStage,
              final ClasspathProvider classpath,
              @Parameter(JobIdentifier.class) final String jobIdentifier,
              @Parameter(MesosMasterIp.class) final String masterIp,
              @Parameter(MesosSlavePort.class) final int slavePort,
              @Parameter(JobSubmissionDirectoryPrefix.class) final String jobSubmissionDirectoryPrefix) {
  this.mesosRemoteManager = mesosRemoteManager;
  this.reefEventHandlers = reefEventHandlers;
  this.executors = executors;
  this.fileNames = fileNames;
  this.jobSubmissionDirectoryPrefix = jobSubmissionDirectoryPrefix;
  this.reefTarUri = getReefTarUri(jobIdentifier);
  this.classpath = classpath;
  this.schedulerDriverEStage = schedulerDriverEStage;

  final Protos.FrameworkInfo frameworkInfo = Protos.FrameworkInfo.newBuilder()
      .setUser("")
      .setName(REEF_JOB_NAME_PREFIX + jobIdentifier)
      .build();
  this.mesosMaster = new MesosSchedulerDriver(this, frameworkInfo, masterIp);
  this.mesosSlavePort = slavePort;
}
 
Example #9
Source File: StdSchedulerDriverFactory.java    From titus-control-plane with Apache License 2.0 4 votes vote down vote up
@Override
public SchedulerDriver createDriver(Protos.FrameworkInfo framework, String mesosMaster, Scheduler scheduler) {
    return new MesosSchedulerDriver(scheduler, framework, mesosMaster);
}
 
Example #10
Source File: ResourceMesosSchedulerFactory.java    From oodt with Apache License 2.0 4 votes vote down vote up
public Scheduler construct() {
    try {
        String uri = System.getProperty("org.apache.oodt.cas.resource.mesos.executor.uri","./oodt-executor.in");
        //Framework info
        FrameworkInfo.Builder frameworkBuilder = FrameworkInfo.newBuilder()
                    .setName("OODT Resource Manager Mesos Framework").setUser("")
                    .setId(FrameworkID.newBuilder().setValue("OODT-Resource Framework").build());
        FrameworkInfo framework = frameworkBuilder.build();
        ExecutorInfo executor = ExecutorInfo.newBuilder().setExecutorId(ExecutorID.newBuilder().setValue("OODT-Resource").build())
                .setCommand(CommandInfo.newBuilder().setValue(new File(uri).getCanonicalPath()).build())
                .setName("OODT Resource Manager Executor").build();
        SchedulerDriver driver = null;

        //Resource manager properties
        String batchmgrClassStr = "org.apache.oodt.cas.resource.batchmgr.MesosBatchManagerFactory";
        String monitorClassStr = "org.apache.oodt.cas.resource.monitor.MesosMonitorFactory";
        String jobQueueClassStr = System.getProperty("resource.jobqueue.factory","org.apache.oodt.cas.resource.jobqueue.JobStackJobQueueFactory");
        String ip = System.getProperty("resource.mesos.master.ip","127.0.0.1:5050");

        batch = (MesosBatchManager)GenericResourceManagerObjectFactory.getBatchmgrServiceFromFactory(batchmgrClassStr);
        mon = GenericResourceManagerObjectFactory.getMonitorServiceFromFactory(monitorClassStr);
        queue = GenericResourceManagerObjectFactory.getJobQueueServiceFromFactory(jobQueueClassStr);
        batch.setMonitor(mon);
        batch.setDriver(driver);
        batch.setJobRepository(queue.getJobRepository());

        LOG.log(Level.INFO,"Connecting to Mesos Master at: "+ip);
        System.out.println("Connecting to Mesos Master at: "+ip);
        ResourceMesosScheduler scheduler = new ResourceMesosScheduler(batch, executor, queue, mon);

        final MesosSchedulerDriver mesos = new MesosSchedulerDriver(scheduler, framework, ip);
        //Anonymous thread to run
        new Thread(new Runnable() {
            public void run() {
                int status = mesos.run() == Status.DRIVER_STOPPED ? 0 : 1;
                mesos.stop();
            }
        }).start();
        return scheduler;
    } catch(IOException ioe) {
        LOG.log(Level.SEVERE,"Exception detected: "+ioe.getMessage());
        ioLOG.log(Level.SEVERE, e.getMessage());
        throw new RuntimeException(ioe);
    }
}
 
Example #11
Source File: BdsMesosFramework.java    From BigDataScript with Apache License 2.0 4 votes vote down vote up
public MesosSchedulerDriver getDriver() {
	return schedulerDriver;
}
 
Example #12
Source File: HelloWorldMain.java    From tutorials with MIT License 3 votes vote down vote up
public static void main(String[] args) {

        String path = System.getProperty("user.dir")
                + "/target/libraries2-1.0.0-SNAPSHOT.jar";

        CommandInfo.URI uri = CommandInfo.URI.newBuilder().setValue(path).setExtract(false).build();

        String helloWorldCommand = "java -cp libraries2-1.0.0-SNAPSHOT.jar com.baeldung.mesos.executors.HelloWorldExecutor";
        CommandInfo commandInfoHelloWorld = CommandInfo.newBuilder().setValue(helloWorldCommand).addUris(uri)
                .build();

        ExecutorInfo executorHelloWorld = ExecutorInfo.newBuilder()
                .setExecutorId(Protos.ExecutorID.newBuilder().setValue("HelloWorldExecutor"))
                .setCommand(commandInfoHelloWorld).setName("Hello World (Java)").setSource("java").build();

        FrameworkInfo.Builder frameworkBuilder = FrameworkInfo.newBuilder().setFailoverTimeout(120000)
                .setUser("")
                .setName("Hello World Framework (Java)");

        frameworkBuilder.setPrincipal("test-framework-java");

        MesosSchedulerDriver driver = new MesosSchedulerDriver(new HelloWorldScheduler(executorHelloWorld), frameworkBuilder.build(), args[0]);

        int status = driver.run() == Protos.Status.DRIVER_STOPPED ? 0 : 1;

        // Ensure that the driver process terminates.
        driver.stop();

        System.exit(status);
    }