Java Code Examples for org.apache.mesos.ExecutorDriver#sendStatusUpdate()

The following examples show how to use org.apache.mesos.ExecutorDriver#sendStatusUpdate() . 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: CassandraExecutor.java    From cassandra-mesos-deprecated with Apache License 2.0 6 votes vote down vote up
@Override
public void killTask(final ExecutorDriver driver, final TaskID taskId) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("killTask(driver : {}, taskId : {})", driver, protoToString(taskId));
    }

    if (serverTask != null && serverTask.getTaskId().equals(taskId)) {
        killCassandraDaemon(driver);
    }
    else if (executorInfo.getExecutorId().getValue().equals(taskId.getValue())) {
        killCassandraDaemon(driver);

        driver.sendStatusUpdate(taskStatus(executorInfo.getExecutorId(), taskId, TaskState.TASK_FINISHED, ExecutorUtils.nullSlaveStatusDetails()));
        driver.stop();
    }
}
 
Example 2
Source File: CassandraExecutor.java    From cassandra-mesos-deprecated with Apache License 2.0 6 votes vote down vote up
/**
 * Handles the state when the Cassandra server process exited on its own and cleans up our state.
 */
private void handleProcessNoLongerAlive(@NotNull final ExecutorDriver driver) {
    if (process == null)
        return;
    try {
        final int exitCode = process.exitValue();
        LOGGER.error("Cassandra process terminated unexpectedly with exit code {}", exitCode);

        if (serverTask != null) {
            final TaskStatus taskStatus =
                ExecutorUtils.slaveErrorDetails(serverTask, "process exited with exit code " + exitCode, null, SlaveErrorDetails.ErrorType.PROCESS_EXITED);
            driver.sendStatusUpdate(taskStatus);
        }

        safeShutdown();

        forceCurrentJobAbort();

        stopCheckingHealth();

    } catch (final IllegalThreadStateException e) {
        // ignore
    }
}
 
Example 3
Source File: HelloWorldExecutor.java    From tutorials with MIT License 6 votes vote down vote up
@Override
public void launchTask(ExecutorDriver driver, TaskInfo task) {

    Protos.TaskStatus status = Protos.TaskStatus.newBuilder().setTaskId(task.getTaskId())
            .setState(Protos.TaskState.TASK_RUNNING).build();
    driver.sendStatusUpdate(status);

    String myStatus = "Hello Framework";
    driver.sendFrameworkMessage(myStatus.getBytes());

    System.out.println("Hello World!!!");

    status = Protos.TaskStatus.newBuilder().setTaskId(task.getTaskId())
            .setState(Protos.TaskState.TASK_FINISHED).build();
    driver.sendStatusUpdate(status);
}
 
Example 4
Source File: ComposeExecutorPluginImpl.java    From docker-compose-executor with Apache License 2.0 6 votes vote down vote up
@Override
public List<String> launchTask(ExecutorDriver executorDriver, Protos.TaskInfo taskInfo) {

    if (log.isDebugEnabled()) {
        log.debug(" ######### ComposeExecutorPlugin launchTask #############");
        log.debug("  ExecutorDriver: " + executorDriver.toString());
        log.debug("  taskInfo: " + taskInfo.toString());
    }

    ComposeFileList composeFiles = new ComposeFileListImpl();
    Protos.TaskID taskId = taskInfo.getTaskId();

    try {
        return composeFiles.getFile(taskInfo);
    } catch (IOException e) {
        e.printStackTrace();
        Protos.TaskStatus taskStatus = Protos.TaskStatus.newBuilder().setTaskId(taskId).setState(Protos.TaskState.TASK_FAILED).build();
        executorDriver.sendStatusUpdate(taskStatus);
    }

    return null;
}
 
Example 5
Source File: BackupSnapshot.java    From dcos-cassandra-service with Apache License 2.0 5 votes vote down vote up
private void sendStatus(ExecutorDriver driver,
                        Protos.TaskState state,
                        String message) {
    final Protos.TaskStatus status =
    cassandraTask.createStatus(state,Optional.of(message)).getTaskStatus();
    driver.sendStatusUpdate(status);
}
 
Example 6
Source File: CassandraExecutor.java    From cassandra-mesos-deprecated with Apache License 2.0 5 votes vote down vote up
private void startJob(@NotNull final ExecutorDriver driver, @NotNull final TaskInfo task, @NotNull final TaskDetails taskDetails) {
    if (process == null) {
        ExecutorUtils.serverProcessNotRunning(driver, task);
        return;
    }

    final NodeJobTask nodeJob = taskDetails.getNodeJobTask();
    final AbstractNodeJob job;
    switch (nodeJob.getJobType()) {
        case REPAIR:
            job = new NodeRepairJob(task.getTaskId());
            break;
        case CLEANUP:
            job = new NodeCleanupJob(task.getTaskId(), executorService);
            break;
        case BACKUP:
            job = new NodeBackupJob(task.getTaskId(), nodeJob.getBackupDir(), executorService);
            break;
        case RESTORE:
            job = new NodeRestoreJob(task.getTaskId(), nodeJob.getBackupDir(), executorService);
            break;
        case TRUNCATE:
            job = new NodeTruncateJob(task.getTaskId(), executorService);
            break;
        default:
            return;
    }
    final TaskStatus taskStatus = startJob(task, job);
    driver.sendStatusUpdate(taskStatus);
}
 
Example 7
Source File: REEFExecutor.java    From reef with Apache License 2.0 5 votes vote down vote up
/**
 * We assume a long-running Mesos Task that manages a REEF Evaluator process, leveraging Mesos Executor's interface.
 */
@Override
public void launchTask(final ExecutorDriver driver, final TaskInfo task) {
  driver.sendStatusUpdate(TaskStatus.newBuilder()
      .setTaskId(TaskID.newBuilder().setValue(this.mesosExecutorId).build())
      .setState(TaskState.TASK_STARTING)
      .setSlaveId(task.getSlaveId())
      .setMessage(this.mesosRemoteManager.getMyIdentifier())
      .build());
}
 
Example 8
Source File: LogstashExecutor.java    From logstash with Apache License 2.0 5 votes vote down vote up
@Override
public void killTask(ExecutorDriver driver, Protos.TaskID taskId) {
    LOGGER.info("Kill task. taskId={}", taskId.getValue());

    driver.sendStatusUpdate(Protos.TaskStatus.newBuilder()
            .setTaskId(taskId)
            .setState(Protos.TaskState.TASK_KILLED).build());

    driver.stop();
}
 
Example 9
Source File: LogstashExecutor.java    From logstash with Apache License 2.0 5 votes vote down vote up
@Override
public void launchTask(final ExecutorDriver driver, final Protos.TaskInfo task) {
    LOGGER.info("Launching task taskId={}", task.getTaskId());

    ExecutorBootConfiguration bootConfiguration = SerializationUtils.deserialize(task.getData().toByteArray());

    final Thread thread = new Thread(() -> {
        LOGGER.info("Forked thread with LogstashService.run()");
        try {
            logstashService.run(bootConfiguration);
            LOGGER.info("LogstashService finished");
            driver.sendStatusUpdate(Protos.TaskStatus.newBuilder()
                    .setExecutorId(task.getExecutor().getExecutorId())
                    .setTaskId(task.getTaskId())
                    .setState(Protos.TaskState.TASK_FINISHED).build());
        } catch (Exception e) {
            LOGGER.error("Logstash service failed", e);
            driver.sendStatusUpdate(Protos.TaskStatus.newBuilder()
                    .setExecutorId(task.getExecutor().getExecutorId())
                    .setTaskId(task.getTaskId())
                    .setState(Protos.TaskState.TASK_FAILED)
                    .setMessage(e.getMessage()).build());
        }
        driver.stop();
    });
    thread.setDaemon(true);

    logstashService.addOnLogstashReadyListener(() -> driver.sendStatusUpdate(Protos.TaskStatus.newBuilder()
            .setExecutorId(task.getExecutor().getExecutorId())
            .setTaskId(task.getTaskId())
            .setState(Protos.TaskState.TASK_RUNNING).build()));

    thread.start();
}
 
Example 10
Source File: DockerComposeExecutor.java    From docker-compose-executor with Apache License 2.0 5 votes vote down vote up
private void sendTaskStatusUpdate(ExecutorDriver executorDriver, TaskID taskId, TaskState taskState) {
    if (taskId != null) {
        TaskStatus taskStatus = TaskStatus.newBuilder().setTaskId(taskId).setState(taskState).build();
        executorDriver.sendStatusUpdate(taskStatus);
    } else {
        log.error("taskId is null");
    }
}
 
Example 11
Source File: RestoreSnapshot.java    From dcos-cassandra-service with Apache License 2.0 5 votes vote down vote up
private void sendStatus(ExecutorDriver driver,
                        Protos.TaskState state,
                        String message) {
    Protos.TaskStatus status = cassandraTask
        .createStatus(state, Optional.of(message)).getTaskStatus();
    driver.sendStatusUpdate(status);
}
 
Example 12
Source File: DownloadSnapshot.java    From dcos-cassandra-service with Apache License 2.0 5 votes vote down vote up
private void sendStatus(ExecutorDriver driver,
                        Protos.TaskState state,
                        String message) {
    Protos.TaskStatus status = cassandraTask.createStatus(state,
        Optional.of(message)).getTaskStatus();
    driver.sendStatusUpdate(status);
}
 
Example 13
Source File: Repair.java    From dcos-cassandra-service with Apache License 2.0 5 votes vote down vote up
private void sendStatus(ExecutorDriver driver,
                        Protos.TaskState state,
                        String message) {
    Protos.TaskStatus status = task
        .createStatus(state, Optional.of(message))
        .getTaskStatus();
    driver.sendStatusUpdate(status);
}
 
Example 14
Source File: UploadSnapshot.java    From dcos-cassandra-service with Apache License 2.0 5 votes vote down vote up
private void sendStatus(ExecutorDriver driver,
                        Protos.TaskState state,
                        String message) {
    Protos.TaskStatus status = cassandraTask.createStatus(state,
        Optional.of(message)).getTaskStatus();
    driver.sendStatusUpdate(status);
}
 
Example 15
Source File: BackupSchema.java    From dcos-cassandra-service with Apache License 2.0 5 votes vote down vote up
private void sendStatus(ExecutorDriver driver,
                          Protos.TaskState state,
                          String message) {
      final Protos.TaskStatus status =
      cassandraTask.createStatus(state,Optional.of(message)).getTaskStatus();
      driver.sendStatusUpdate(status);
}
 
Example 16
Source File: MesosExecutorCallbackHandler.java    From mantis with Apache License 2.0 4 votes vote down vote up
private void sendLaunchError(ExecutorDriver driver, final TaskInfo task) {
    driver.sendStatusUpdate(Protos.TaskStatus.newBuilder()
            .setTaskId(task.getTaskId())
            .setState(Protos.TaskState.TASK_FAILED).build());
    waitAndExit();
}
 
Example 17
Source File: BdsMesosExecutor.java    From BigDataScript with Apache License 2.0 4 votes vote down vote up
/**
 * Change task state
 */
protected void changeTaskState(ExecutorDriver driver, TaskInfo task, TaskState state) {
	TaskStatus status = TaskStatus.newBuilder().setTaskId(task.getTaskId()).setState(state).build();
	driver.sendStatusUpdate(status);
	if (debug) Gpr.debug("Task " + task.getTaskId().getValue() + " is now '" + state + "'");
}
 
Example 18
Source File: ResourceExecutor.java    From oodt with Apache License 2.0 4 votes vote down vote up
@Override
public void launchTask(final ExecutorDriver driver, final TaskInfo info) {
    str.println(id+"Launch task!");
    try {
        JobSpec spec = MesosUtilities.byteStringToJobSpec(info.getData());
        final JobInstance exec = GenericResourceManagerObjectFactory
                .getJobInstanceFromClassName(spec.getJob().getJobInstanceClassName());
        final JobInput in = spec.getIn();
        Thread tmp = new Thread(new Runnable(){
                public void run() {
                    TaskStatus status = null;
                    try {
                        exec.execute(in);
                        status = TaskStatus.newBuilder().setTaskId(info.getTaskId())
                                .setState(TaskState.TASK_FINISHED).build();
                    } catch (JobInputException e) {
                        LOG.log(Level.SEVERE, e.getMessage());
                        status = TaskStatus.newBuilder().setTaskId(info.getTaskId())
                                .setState(TaskState.TASK_FAILED).build();
                    }
                    driver.sendStatusUpdate(status);
                }
        });
        driver.sendStatusUpdate(TaskStatus.newBuilder().setTaskId(info.getTaskId())
              .setState(TaskState.TASK_STARTING).build());
        tmp.start();
    } catch (ClassNotFoundException e1) {
        System.out.println("BAD DATA: ");
        e1.printStackTrace();
        driver.sendStatusUpdate(TaskStatus.newBuilder().setTaskId(info.getTaskId())
                .setState(TaskState.TASK_FAILED).build());
    } catch (InstantiationException e2) {
        System.out.println("BAD DATA: ");
        e2.printStackTrace();
        driver.sendStatusUpdate(TaskStatus.newBuilder().setTaskId(info.getTaskId())
                .setState(TaskState.TASK_FAILED).build());
    } catch (IllegalAccessException e3) {
        System.out.println("BAD DATA: ");
        e3.printStackTrace();
        driver.sendStatusUpdate(TaskStatus.newBuilder().setTaskId(info.getTaskId())
                .setState(TaskState.TASK_FAILED).build());
    }
}
 
Example 19
Source File: ExecutorUtils.java    From cassandra-mesos-deprecated with Apache License 2.0 4 votes vote down vote up
static void serverProcessNotRunning(@NotNull final ExecutorDriver driver, @NotNull final Protos.TaskInfo task) {
    final Protos.TaskStatus taskStatus =
        slaveErrorDetails(task, "cassandra server process not running", null, CassandraFrameworkProtos.SlaveErrorDetails.ErrorType.PROCESS_NOT_RUNNING);
    driver.sendStatusUpdate(taskStatus);
}
 
Example 20
Source File: TaskExecutor.java    From shardingsphere-elasticjob-cloud with Apache License 2.0 4 votes vote down vote up
@Override
public void killTask(final ExecutorDriver executorDriver, final Protos.TaskID taskID) {
    executorDriver.sendStatusUpdate(Protos.TaskStatus.newBuilder().setTaskId(taskID).setState(Protos.TaskState.TASK_KILLED).build());
    DaemonTaskScheduler.shutdown(taskID);
}