Search in sources :

Example 6 with Status

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

the class MyriadOperations method shutdownFramework.

/**
 * Shutdown framework means the Mesos driver is stopped taking down the executors and associated tasks
 */
public void shutdownFramework() {
    LOGGER.info("Received request to shutdown Myriad Framework..");
    Status driverStatus = driverManager.getDriverStatus();
    if (Status.DRIVER_RUNNING != driverStatus) {
        LOGGER.warn("Driver is not running. Status: " + driverStatus);
    } else {
        // Stop the driver, tasks, and executor.
        driverStatus = driverManager.stopDriver(false);
        LOGGER.info("Myriad driver was shutdown with status " + driverStatus);
    }
    try {
        myriadWebServer.stop();
        LOGGER.info("Myriad webserver was shutdown successfully");
    } catch (Exception e) {
        LOGGER.info("Failed to shutdown Myriad webserver: " + e.getMessage());
    }
    if (myriadStateStore != null) {
        try {
            myriadStateStore.removeMyriadState();
            LOGGER.info("Myriad State store was removed successfully.");
        } catch (Exception e) {
            LOGGER.info("Failed to remove Myriad state store: " + e.getMessage());
        }
    }
}
Also used : Status(org.apache.mesos.Protos.Status) MyriadBadConfigurationException(org.apache.myriad.configuration.MyriadBadConfigurationException)

Example 7 with Status

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

the class TaskTerminator method handleNonPendingTask.

private void handleNonPendingTask(TaskID taskId) {
    /*
     * Kill the task and decline additional offers for it, but hold off removing from SchedulerState. 
     * Removal of the killable task must be done following invocation of statusUpdate callback method
     * which constitutes acknowledgement from Mesos that the kill task request succeeded.
     */
    Status status = this.driverManager.kill(taskId);
    NodeTask task = schedulerState.getTask(taskId);
    if (task != null) {
        offerLifeCycleManager.declineOutstandingOffers(task.getHostname());
    }
    if (status.equals(Status.DRIVER_RUNNING)) {
        LOGGER.info("Kill request for {} was submitted to a running SchedulerDriver", taskId);
    } else {
        LOGGER.warn("Kill task request for {} submitted to non-running SchedulerDriver, may fail", taskId);
    }
}
Also used : Status(org.apache.mesos.Protos.Status) NodeTask(org.apache.myriad.state.NodeTask)

Example 8 with Status

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

the class InternalExecutorDriver method stop.

@Override
public Status stop() {
    Status status = context.getStateMachine();
    if (!context.isStateMachine(DRIVER_RUNNING, DRIVER_ABORTED)) {
        return status;
    }
    try {
        closer.close();
    } catch (final IOException e) {
        LOG.warn(e, "While stopping");
    }
    context.setStateMachine(DRIVER_STOPPED);
    // state on the return.
    if (status != DRIVER_ABORTED) {
        status = DRIVER_STOPPED;
    }
    return status;
}
Also used : Status(org.apache.mesos.Protos.Status) TaskStatus(org.apache.mesos.Protos.TaskStatus) IOException(java.io.IOException)

Example 9 with Status

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

the class InternalSchedulerDriver method stop.

@Override
public Status stop(final boolean failover) {
    Status status = context.getStateMachine();
    if (!context.isStateMachine(DRIVER_RUNNING, DRIVER_ABORTED)) {
        return status;
    }
    if (context.isConnected() && !failover) {
        final UnregisterFrameworkMessage message = UnregisterFrameworkMessage.newBuilder().setFrameworkId(context.getFrameworkId()).build();
        eventBus.post(new RemoteMessageEnvelope(context.getDriverUPID(), context.getMasterUPID(), message));
    }
    try {
        closer.close();
    } catch (final IOException e) {
        LOG.warn(e, "While stopping");
    }
    context.setStateMachine(DRIVER_STOPPED);
    // state on the return.
    if (status != DRIVER_ABORTED) {
        status = DRIVER_STOPPED;
    }
    return status;
}
Also used : Status(org.apache.mesos.Protos.Status) TaskStatus(org.apache.mesos.Protos.TaskStatus) UnregisterFrameworkMessage(mesos.internal.Messages.UnregisterFrameworkMessage) RemoteMessageEnvelope(com.groupon.mesos.scheduler.SchedulerMessageEnvelope.RemoteMessageEnvelope) IOException(java.io.IOException)

Example 10 with Status

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

the class SchedulerDriverContext method setStateMachine.

// 
// State machine management
// 
synchronized void setStateMachine(final Status status) {
    final Status oldStatus = stateMachine.getAndSet(status);
    if (status != oldStatus) {
        // Fire all the futures waiting for a status change.
        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)

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