Search in sources :

Example 11 with Status

use of org.apache.mesos.Protos.Status in project incubator-myriad by apache.

the class MyriadDriverTest method testStop.

@Test
public void testStop() throws Exception {
    MyriadDriver driver = new MyriadDriver(new MockSchedulerDriver());
    Status status = driver.stop(true);
    assertEquals(Protos.Status.DRIVER_STOPPED_VALUE, status.getNumber());
}
Also used : Status(org.apache.mesos.Protos.Status) Test(org.junit.Test)

Example 12 with Status

use of org.apache.mesos.Protos.Status in project incubator-myriad by apache.

the class TaskTerminator method run.

/**
 * Encapsulates logic that retrieves the collection of killable tasks from the
 * SchedulerState object. If a task is in pending state, the task is simply
 * removed from SchedulerState. Any tasks in a running state were not successfully
 * killed by Mesos or the callback failed, so the another kill attempt is made.
 */
@Override
public void run() {
    // If there are 1..n killable tasks, proceed; otherwise, simply return
    if (CollectionUtils.isNotEmpty(schedulerState.getKillableTaskIds())) {
        /*
       * Clone the killable task collection, iterate through all tasks, and 
       * process any pending and/or non-pending tasks
       */
        Set<TaskID> killableTasks = Sets.newHashSet(schedulerState.getKillableTaskIds());
        Status driverStatus = driverManager.getDriverStatus();
        // TODO (hokiegeek2) Can the DriverManager be restarted? If not, should the ResourceManager stop?
        if (Status.DRIVER_RUNNING != driverStatus) {
            LOGGER.warn("Cannot kill tasks because Mesos Driver is not running. Status: {}", driverStatus);
            return;
        }
        for (TaskID taskIdToKill : killableTasks) {
            LOGGER.info("Received task kill request for task: {}", taskIdToKill);
            if (isPendingTask(taskIdToKill)) {
                handlePendingTask(taskIdToKill);
            } else {
                handleNonPendingTask(taskIdToKill);
            }
        }
    }
}
Also used : Status(org.apache.mesos.Protos.Status) TaskID(org.apache.mesos.Protos.TaskID)

Example 13 with Status

use of org.apache.mesos.Protos.Status in project incubator-myriad by apache.

the class MyriadDriver method start.

/**
 * Starts the underlying Mesos SchedulerDriver. Note: this method must
 * be called before any other MyriadDriver methods are invoked.
 *
 * @return The state of the driver after the call.
 *
 * @see Status
 */
public Status start() {
    LOGGER.info("Starting driver");
    Status status = driver.start();
    LOGGER.info("Driver started with status: {}", status);
    return status;
}
Also used : Status(org.apache.mesos.Protos.Status)

Example 14 with Status

use of org.apache.mesos.Protos.Status in project jesos by groupon.

the class ExecutorDriverContext method setStateMachine.

// 
// State machine management
// 
synchronized void setStateMachine(final Status status) {
    final Status oldStatus = stateMachine.getAndSet(status);
    if (status != oldStatus) {
        final List<SettableFuture<Status>> settableFutures = new ArrayList<>(stateMachineFutures.size());
        stateMachineFutures.drainTo(settableFutures);
        for (final SettableFuture<Status> future : settableFutures) {
            future.set(status);
        }
    }
}
Also used : Status(org.apache.mesos.Protos.Status) SettableFuture(com.google.common.util.concurrent.SettableFuture) ArrayList(java.util.ArrayList)

Example 15 with Status

use of org.apache.mesos.Protos.Status in project Singularity by HubSpot.

the class SingularityExecutorMonitor method shutdown.

public void shutdown(ExecutorDriver driver) {
    if (!alreadyShutDown.compareAndSet(false, true)) {
        LOG.info("Already ran shut down process");
        return;
    }
    LOG.info("Shutdown requested with driver {}", driver);
    threadChecker.getExecutorService().shutdown();
    processBuilderPool.shutdown();
    runningProcessPool.shutdown();
    cgroupCfsWatcherService.shutdown();
    for (SingularityExecutorTask task : tasks.values()) {
        if (!task.wasKilled()) {
            task.getLog().info("Executor shutting down - requested task kill with state: {}", requestKill(task.getTaskId()));
        }
    }
    processKiller.getExecutorService().shutdown();
    for (Entry<String, ListeningExecutorService> taskIdToShellCommandPool : taskToShellCommandPool.entrySet()) {
        // in case
        LOG.warn("Shutting down abandoned pool for {}", taskIdToShellCommandPool.getKey());
        taskIdToShellCommandPool.getValue().shutdown();
    }
    cgroupCheckers.values().forEach(SingularityExecutorCgroupCfsChecker::close);
    exitChecker.shutdown();
    final long start = System.currentTimeMillis();
    JavaUtils.awaitTerminationWithLatch(latch, "threadChecker", threadChecker.getExecutorService(), configuration.getShutdownTimeoutWaitMillis());
    JavaUtils.awaitTerminationWithLatch(latch, "processBuilder", processBuilderPool, configuration.getShutdownTimeoutWaitMillis());
    JavaUtils.awaitTerminationWithLatch(latch, "runningProcess", runningProcessPool, configuration.getShutdownTimeoutWaitMillis());
    JavaUtils.awaitTerminationWithLatch(latch, "processKiller", processKiller.getExecutorService(), configuration.getShutdownTimeoutWaitMillis());
    LOG.info("Awaiting shutdown of all thread pools for a max of {}", JavaUtils.durationFromMillis(configuration.getShutdownTimeoutWaitMillis()));
    try {
        latch.await();
    } catch (InterruptedException e) {
        LOG.warn("While awaiting shutdown of executor services", e);
    }
    LOG.info("Waited {} for shutdown of thread pools, now waiting {} before exiting...", JavaUtils.duration(start), JavaUtils.durationFromMillis(configuration.getStopDriverAfterMillis()));
    try {
        Thread.sleep(configuration.getStopDriverAfterMillis());
    } catch (Throwable t) {
        LOG.warn("While waiting to exit", t);
    }
    LOG.info("Stopping driver {}", driver);
    Status status = driver.stop();
    LOG.info("Driver stopped with status {}", status);
}
Also used : Status(org.apache.mesos.Protos.Status) SingularityExecutorTask(com.hubspot.singularity.executor.task.SingularityExecutorTask) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService)

Aggregations

Status (org.apache.mesos.Protos.Status)15 Test (org.junit.Test)3 SettableFuture (com.google.common.util.concurrent.SettableFuture)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 TaskStatus (org.apache.mesos.Protos.TaskStatus)2 ListeningExecutorService (com.google.common.util.concurrent.ListeningExecutorService)1 RemoteMessageEnvelope (com.groupon.mesos.scheduler.SchedulerMessageEnvelope.RemoteMessageEnvelope)1 SingularityExecutorTask (com.hubspot.singularity.executor.task.SingularityExecutorTask)1 UnregisterFrameworkMessage (mesos.internal.Messages.UnregisterFrameworkMessage)1 TaskID (org.apache.mesos.Protos.TaskID)1 MyriadBadConfigurationException (org.apache.myriad.configuration.MyriadBadConfigurationException)1 NodeTask (org.apache.myriad.state.NodeTask)1