Java Code Examples for org.apache.mesos.Protos#Status

The following examples show how to use org.apache.mesos.Protos#Status . 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: FakeSchedulerDriver.java    From attic-aurora with Apache License 2.0 5 votes vote down vote up
@Override
public Protos.Status launchTasks(
    Collection<Protos.OfferID> offerIds,
    Collection<Protos.TaskInfo> tasks,
    Protos.Filters filters) {
  return null;
}
 
Example 2
Source File: FrameworkRunner.java    From dcos-commons with Apache License 2.0 4 votes vote down vote up
/**
 * Registers the framework with Mesos and starts running the framework.
 * This function should never return.
 */
public void registerAndRunFramework(Persister persister, MesosEventClient mesosEventClient) {
  // During uninstall, the Framework ID is the last thing to be removed (along with the rest of
  // zk). If it's gone and the framework is still in uninstall mode, and that indicates we
  // previously finished an uninstall and then got restarted before getting pruned from Marathon.
  // If we tried to register again, it would be with an unset framework id, which would in turn
  // result in us registering a new framework with Mesos from scratch. We avoid that situation
  // by instead just running the process in a bare-bones state where it's only serving the
  // endpoints necessary for Cosmos to remove the process it from Marathon, and where it's not
  // actually registering with Mesos.
  if (schedulerConfig.isUninstallEnabled() &&
      !new FrameworkStore(persister).fetchFrameworkId().isPresent())
  {
    LOGGER.info("Not registering with Mesos because uninstall is complete.");

    try {
      // Just in case, try to clear any other remaining data from ZK. In practice there shouldn't
      // be any left?
      PersisterUtils.clearAllData(persister);
    } catch (PersisterException e) {
      throw new IllegalStateException("Unable to clear all data", e);
    }

    runSkeletonScheduler();
    // The skeleton scheduler should never exit. But just in case...:
    ProcessExit.exit(ProcessExit.DRIVER_EXITED);
  }

  FrameworkStore frameworkStore = new FrameworkStore(persister);

  FrameworkScheduler frameworkScheduler = new FrameworkScheduler(
      getResourceRoles(),
      schedulerConfig,
      persister,
      frameworkStore,
      mesosEventClient);
  // Notify the framework that it can start accepting offers.
  // This is to avoid the following scenario:
  // - We accept an offer/launch a task
  // - The task has config templates to be retrieved from the scheduler HTTP service...
  // - ... but the scheduler hasn't finishing launching its HTTP service
  ApiServer httpServer = ApiServer.start(
      EndpointUtils.toSchedulerAutoIpHostname(
          frameworkConfig.getFrameworkName(),
          schedulerConfig
      ),
      schedulerConfig,
      mesosEventClient.getHTTPEndpoints(),
      frameworkScheduler::setApiServerStarted
  );

  Protos.FrameworkInfo frameworkInfo = getFrameworkInfo(frameworkStore.fetchFrameworkId());
  LOGGER.info("Registering framework: {}", TextFormat.shortDebugString(frameworkInfo));
  String zkUri = String.format("zk://%s/mesos", frameworkConfig.getZookeeperHostPort());
  Protos.Status status = new SchedulerDriverFactory()
      .create(frameworkScheduler, frameworkInfo, zkUri, schedulerConfig)
      .run();
  LOGGER.info("Scheduler driver exited with status: {}", status);
  // DRIVER_STOPPED will occur when we call stop(boolean) during uninstall.
  // When this happens, we want to continue running so that we can advertise that the uninstall
  // plan is complete.
  if (status == Protos.Status.DRIVER_STOPPED) {
    // Following Mesos driver thread exit, attach to the API server thread.
    // It should run indefinitely.
    httpServer.join();
  }
  ProcessExit.exit(ProcessExit.DRIVER_EXITED);
}
 
Example 3
Source File: MockExecutorDriver.java    From cassandra-mesos-deprecated with Apache License 2.0 4 votes vote down vote up
@Override
public Protos.Status sendStatusUpdate(final Protos.TaskStatus status) {
    taskStatusList.add(status);
    return Protos.Status.DRIVER_RUNNING;
}
 
Example 4
Source File: IgniteSchedulerSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public Protos.Status join() {
    return null;
}
 
Example 5
Source File: MockSchedulerDriver.java    From cassandra-mesos-deprecated with Apache License 2.0 4 votes vote down vote up
@Override
public Protos.Status reconcileTasks(final Collection<Protos.TaskStatus> statuses) {
    return Protos.Status.DRIVER_RUNNING;
}
 
Example 6
Source File: IgniteSchedulerSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public Protos.Status acknowledgeStatusUpdate(Protos.TaskStatus status) {
    return null;
}
 
Example 7
Source File: FakeSchedulerDriver.java    From attic-aurora with Apache License 2.0 4 votes vote down vote up
@Override
public Protos.Status killTask(
    Protos.TaskID taskId) {
  return null;
}
 
Example 8
Source File: MockSchedulerDriver.java    From cassandra-mesos-deprecated with Apache License 2.0 4 votes vote down vote up
@Override
public Protos.Status launchTasks(final Protos.OfferID offerId, final Collection<Protos.TaskInfo> tasks, final Protos.Filters filters) {
    return launchTasks(Collections.singleton(offerId), tasks, filters);
}
 
Example 9
Source File: SingularityExecutorRunner.java    From Singularity with Apache License 2.0 4 votes vote down vote up
public static void main(String... args) {
  final long start = System.currentTimeMillis();

  try {
    final Injector injector = Guice.createInjector(
      Stage.PRODUCTION,
      new SingularityRunnerBaseModule(
        SingularityExecutorConfiguration.class,
        ImmutableSet.<Class<? extends BaseRunnerConfiguration>>of(
          SingularityS3Configuration.class
        )
      ),
      new SingularityExecutorModule()
    );
    final SingularityExecutorRunner executorRunner = injector.getInstance(
      SingularityExecutorRunner.class
    );
    final LocalDownloadServiceFetcher downloadServiceFetcher = injector.getInstance(
      LocalDownloadServiceFetcher.class
    );
    downloadServiceFetcher.start();

    final Protos.Status driverStatus = executorRunner.run();

    LOG.info(
      "Executor finished after {} with status: {}",
      JavaUtils.duration(start),
      driverStatus
    );

    downloadServiceFetcher.stop();
    stopLog();

    System.exit(driverStatus == Protos.Status.DRIVER_STOPPED ? 0 : 1);
  } catch (Throwable t) {
    LOG.error("Finished after {} with error", JavaUtils.duration(start), t);

    stopLog();

    System.exit(1);
  }
}
 
Example 10
Source File: MesosSchedulerCallbackHandler.java    From titus-control-plane with Apache License 2.0 4 votes vote down vote up
private void reconcileTasksKnownToUs(SchedulerDriver driver) {
    final List<TaskStatus> tasksToInitialize = new ArrayList<>();

    for (Task task : v3JobOperations.getTasks()) {
        com.netflix.titus.api.jobmanager.model.job.TaskState taskState = task.getStatus().getState();
        TaskState mesosState;
        switch (taskState) {
            case Started:
                mesosState = TaskState.TASK_RUNNING;
                break;
            case KillInitiated:
                mesosState = TaskState.TASK_KILLING;
                break;
            default:
                mesosState = null;
        }
        if (mesosState != null) {
            String taskHost = task.getTaskContext().get(TaskAttributes.TASK_ATTRIBUTES_AGENT_HOST);
            if (taskHost != null) {
                tasksToInitialize.add(TaskStatus.newBuilder()
                        .setTaskId(Protos.TaskID.newBuilder().setValue(task.getId()).build())
                        .setState(mesosState)
                        .setSlaveId(SlaveID.newBuilder().setValue(taskHost).build())
                        .build()
                );
            }
        }
    }
    if (!tasksToInitialize.isEmpty()) {
        Protos.Status status = traceMesosRequest(
                "Reconciling active tasks: count=" + tasksToInitialize.size(),
                () -> driver.reconcileTasks(tasksToInitialize)
        );
        numReconcileTasks.increment();
        logger.info("Sent request to reconcile {} tasks, status={}", tasksToInitialize.size(), status);
        logger.info("Last offer received {} secs ago", (System.currentTimeMillis() - lastOfferReceivedAt.get()) / 1000);
        logger.info("Last valid offer received {} secs ago", (System.currentTimeMillis() - lastValidOfferReceivedAt.get()) / 1000);
        switch (status) {
            case DRIVER_ABORTED:
            case DRIVER_STOPPED:
                logger.error("Unexpected to see Mesos driver status of {} from reconcile request. Committing suicide!", status);
                SystemExt.forcedProcessExit(2);
        }
    }
}
 
Example 11
Source File: IgniteSchedulerSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public Protos.Status run() {
    return null;
}
 
Example 12
Source File: FakeSchedulerDriver.java    From attic-aurora with Apache License 2.0 4 votes vote down vote up
@Override
public Protos.Status sendFrameworkMessage(
    Protos.ExecutorID executorId,
    Protos.SlaveID slaveId, byte[] data) {
  return null;
}
 
Example 13
Source File: ExecutorDriverDispatcher.java    From dcos-cassandra-service with Apache License 2.0 4 votes vote down vote up
private static final int exitCode(final Protos.Status status) {
    return (status == Protos.Status.DRIVER_ABORTED ||
            status == Protos.Status.DRIVER_NOT_STARTED) ?
            -1 : 0;
}
 
Example 14
Source File: MockExecutorDriver.java    From cassandra-mesos-deprecated with Apache License 2.0 4 votes vote down vote up
@Override
public Protos.Status stop() {
    return Protos.Status.DRIVER_STOPPED;
}
 
Example 15
Source File: FakeSchedulerDriver.java    From attic-aurora with Apache License 2.0 4 votes vote down vote up
@Override
public Protos.Status launchTasks(
    Protos.OfferID offerId,
    Collection<Protos.TaskInfo> tasks) {
  return null;
}
 
Example 16
Source File: MockSchedulerDriver.java    From cassandra-mesos-deprecated with Apache License 2.0 4 votes vote down vote up
@Override
public Protos.Status launchTasks(final Protos.OfferID offerId, final Collection<Protos.TaskInfo> tasks) {
    return launchTasks(Collections.singleton(offerId), tasks);
}
 
Example 17
Source File: MockSchedulerDriver.java    From cassandra-mesos-deprecated with Apache License 2.0 4 votes vote down vote up
@Override
public Protos.Status stop(final boolean failover) {
    return Protos.Status.DRIVER_STOPPED;
}
 
Example 18
Source File: FakeSchedulerDriver.java    From attic-aurora with Apache License 2.0 4 votes vote down vote up
@Override
public Protos.Status stop(boolean failover) {
  return null;
}
 
Example 19
Source File: IgniteSchedulerSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public Protos.Status start() {
    return null;
}
 
Example 20
Source File: IgniteSchedulerSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public Protos.Status abort() {
    return null;
}