Search in sources :

Example 6 with Scheduler

use of org.apache.mesos.Scheduler in project alluxio by Alluxio.

the class AlluxioFramework method run.

/**
   * Runs the mesos framework.
   */
public void run() {
    Protos.FrameworkInfo.Builder frameworkInfo = Protos.FrameworkInfo.newBuilder().setName("alluxio").setCheckpoint(true);
    if (Configuration.containsKey(PropertyKey.INTEGRATION_MESOS_ROLE)) {
        frameworkInfo.setRole(Configuration.get(PropertyKey.INTEGRATION_MESOS_ROLE));
    }
    // Setting the user to an empty string will prompt Mesos to set it to the current user.
    if (Configuration.containsKey(PropertyKey.INTEGRATION_MESOS_USER)) {
        frameworkInfo.setUser(Configuration.get(PropertyKey.INTEGRATION_MESOS_USER));
    }
    if (Configuration.containsKey(PropertyKey.INTEGRATION_MESOS_PRINCIPAL)) {
        frameworkInfo.setPrincipal(Configuration.get(PropertyKey.INTEGRATION_MESOS_PRINCIPAL));
    }
    Scheduler scheduler = new AlluxioScheduler(mAlluxioMasterHostname);
    Protos.Credential cred = createCredential();
    MesosSchedulerDriver driver;
    if (cred == null) {
        driver = new MesosSchedulerDriver(scheduler, frameworkInfo.build(), mMesosMaster);
    } else {
        driver = new MesosSchedulerDriver(scheduler, frameworkInfo.build(), mMesosMaster, cred);
    }
    int status = driver.run() == Protos.Status.DRIVER_STOPPED ? 0 : 1;
    System.exit(status);
}
Also used : Protos(org.apache.mesos.Protos) Scheduler(org.apache.mesos.Scheduler) MesosSchedulerDriver(org.apache.mesos.MesosSchedulerDriver)

Example 7 with Scheduler

use of org.apache.mesos.Scheduler in project ignite by apache.

the class IgniteFramework method main.

/**
     * Main methods has only one optional parameter - path to properties files.
     *
     * @param args Args.
     * @throws Exception If failed.
     */
public static void main(String[] args) throws Exception {
    IgniteFramework igniteFramework = new IgniteFramework();
    ClusterProperties clusterProps = ClusterProperties.from(args.length >= 1 ? args[0] : null);
    String baseUrl = String.format("http://%s:%d", clusterProps.httpServerHost(), clusterProps.httpServerPort());
    JettyServer httpSrv = new JettyServer();
    httpSrv.start(new ResourceHandler(clusterProps.userLibs(), clusterProps.igniteCfg(), clusterProps.igniteWorkDir()), clusterProps);
    ResourceProvider provider = new ResourceProvider();
    IgniteProvider igniteProvider = new IgniteProvider(clusterProps.igniteWorkDir());
    provider.init(clusterProps, igniteProvider, baseUrl);
    // Create the scheduler.
    Scheduler scheduler = new IgniteScheduler(clusterProps, provider);
    // Create the driver.
    MesosSchedulerDriver driver;
    if (System.getenv(MESOS_AUTHENTICATE) != null) {
        log.info("Enabling authentication for the framework");
        if (System.getenv(DEFAULT_PRINCIPAL) == null) {
            log.log(Level.SEVERE, "Expecting authentication principal in the environment");
            System.exit(1);
        }
        if (System.getenv(DEFAULT_SECRET) == null) {
            log.log(Level.SEVERE, "Expecting authentication secret in the environment");
            System.exit(1);
        }
        Protos.Credential cred = Protos.Credential.newBuilder().setPrincipal(System.getenv(DEFAULT_PRINCIPAL)).setSecret(ByteString.copyFrom(System.getenv(DEFAULT_SECRET).getBytes())).build();
        driver = new MesosSchedulerDriver(scheduler, igniteFramework.getFrameworkInfo(), clusterProps.masterUrl(), cred);
    } else
        driver = new MesosSchedulerDriver(scheduler, igniteFramework.getFrameworkInfo(), clusterProps.masterUrl());
    int status = driver.run() == Protos.Status.DRIVER_STOPPED ? 0 : 1;
    httpSrv.stop();
    // Ensure that the driver process terminates.
    driver.stop();
    System.exit(status);
}
Also used : IgniteProvider(org.apache.ignite.mesos.resource.IgniteProvider) Scheduler(org.apache.mesos.Scheduler) ResourceHandler(org.apache.ignite.mesos.resource.ResourceHandler) ByteString(com.google.protobuf.ByteString) Protos(org.apache.mesos.Protos) ResourceProvider(org.apache.ignite.mesos.resource.ResourceProvider) JettyServer(org.apache.ignite.mesos.resource.JettyServer) MesosSchedulerDriver(org.apache.mesos.MesosSchedulerDriver)

Example 8 with Scheduler

use of org.apache.mesos.Scheduler in project jesos by groupon.

the class LocalSchedulerMessageProcessor method frameworkError.

@Subscribe
public void frameworkError(final FrameworkErrorMessageEnvelope envelope) {
    checkState(envelope.getRecipient().equals(context.getDriverUPID()), "Received a remote message for local delivery");
    final UPID sender = envelope.getSender();
    if (!driverIsConnected(sender)) {
        return;
    }
    final FrameworkErrorMessage frameworkErrorMessage = envelope.getMessage();
    eventBus.post(new SchedulerCallback() {

        @Override
        public Runnable getCallback(final Scheduler scheduler, final SchedulerDriver schedulerDriver) {
            return new Runnable() {

                @Override
                public void run() {
                    schedulerDriver.abort();
                    scheduler.error(schedulerDriver, frameworkErrorMessage.getMessage());
                }
            };
        }
    });
}
Also used : UPID(com.groupon.mesos.util.UPID) Scheduler(org.apache.mesos.Scheduler) FrameworkErrorMessage(mesos.internal.Messages.FrameworkErrorMessage) SchedulerDriver(org.apache.mesos.SchedulerDriver) Subscribe(com.google.common.eventbus.Subscribe)

Example 9 with Scheduler

use of org.apache.mesos.Scheduler in project jesos by groupon.

the class LocalSchedulerMessageProcessor method frameworkStatusUpdate.

@Subscribe
public void frameworkStatusUpdate(final StatusUpdateMessageEnvelope envelope) throws IOException {
    checkState(envelope.getRecipient().equals(context.getDriverUPID()), "Received a remote message for local delivery");
    final UPID sender = envelope.getSender();
    if (!driverIsConnected(sender)) {
        return;
    }
    final StatusUpdateMessage statusUpdateMessage = envelope.getMessage();
    final FrameworkID frameworkId = context.getFrameworkId();
    final FrameworkID messageFrameworkId = statusUpdateMessage.getUpdate().getFrameworkId();
    checkState(frameworkId.equals(messageFrameworkId), "Received Message for framework %s, but local id is %s", messageFrameworkId, frameworkId);
    final TaskStatus.Builder taskStatusBuilder = TaskStatus.newBuilder(statusUpdateMessage.getUpdate().getStatus());
    final TaskStatus taskStatus;
    // If the update is driver-generated or master-generated, it does not require acknowledgement (from Mesos source code, sched.cpp).
    final Optional<UPID> pid = statusUpdateMessage.hasPid() ? Optional.of(UPID.create(statusUpdateMessage.getPid())) : Optional.<UPID>absent();
    final boolean noAckRequired = envelope.getSender().equals(context.getDriverUPID()) || pid.isPresent() && pid.get().equals(context.getDriverUPID());
    if (noAckRequired) {
        taskStatus = taskStatusBuilder.clearUuid().build();
    } else {
        taskStatus = taskStatusBuilder.setUuid(statusUpdateMessage.getUpdate().getUuid()).build();
    }
    eventBus.post(new SchedulerCallback() {

        @Override
        public Runnable getCallback(final Scheduler scheduler, final SchedulerDriver schedulerDriver) {
            return new Runnable() {

                @Override
                public void run() {
                    scheduler.statusUpdate(schedulerDriver, taskStatus);
                }
            };
        }
    });
    if (implicitAcknowledgements && !noAckRequired) {
        final StatusUpdateAcknowledgementMessage statusUpdateAcknowledgementMessage = StatusUpdateAcknowledgementMessage.newBuilder().setFrameworkId(frameworkId).setSlaveId(statusUpdateMessage.getUpdate().getSlaveId()).setTaskId(taskStatus.getTaskId()).setUuid(statusUpdateMessage.getUpdate().getUuid()).build();
        eventBus.post(new RemoteMessageEnvelope(context.getDriverUPID(), context.getMasterUPID(), statusUpdateAcknowledgementMessage));
    }
}
Also used : Scheduler(org.apache.mesos.Scheduler) TaskStatus(org.apache.mesos.Protos.TaskStatus) UPID(com.groupon.mesos.util.UPID) RemoteMessageEnvelope(com.groupon.mesos.scheduler.SchedulerMessageEnvelope.RemoteMessageEnvelope) StatusUpdateAcknowledgementMessage(mesos.internal.Messages.StatusUpdateAcknowledgementMessage) StatusUpdateMessage(mesos.internal.Messages.StatusUpdateMessage) FrameworkID(org.apache.mesos.Protos.FrameworkID) SchedulerDriver(org.apache.mesos.SchedulerDriver) Subscribe(com.google.common.eventbus.Subscribe)

Example 10 with Scheduler

use of org.apache.mesos.Scheduler in project jesos by groupon.

the class LocalSchedulerMessageProcessor method frameworkRegistered.

@Subscribe
public void frameworkRegistered(final FrameworkRegisteredMessageEnvelope envelope) {
    checkState(envelope.getRecipient().equals(context.getDriverUPID()), "Received a remote message for local delivery");
    final FrameworkRegisteredMessage frameworkRegisteredMessage = envelope.getMessage();
    if (!masterIsValid(frameworkRegisteredMessage.getMasterInfo())) {
        return;
    }
    final FrameworkID frameworkId = frameworkRegisteredMessage.getFrameworkId();
    context.connected();
    context.setFailover(false);
    context.setFrameworkId(frameworkId);
    eventBus.post(new SchedulerCallback() {

        @Override
        public Runnable getCallback(final Scheduler scheduler, final SchedulerDriver schedulerDriver) {
            return new Runnable() {

                @Override
                public void run() {
                    scheduler.registered(schedulerDriver, frameworkId, context.getMaster());
                }
            };
        }
    });
}
Also used : Scheduler(org.apache.mesos.Scheduler) FrameworkRegisteredMessage(mesos.internal.Messages.FrameworkRegisteredMessage) FrameworkID(org.apache.mesos.Protos.FrameworkID) SchedulerDriver(org.apache.mesos.SchedulerDriver) Subscribe(com.google.common.eventbus.Subscribe)

Aggregations

Scheduler (org.apache.mesos.Scheduler)11 Subscribe (com.google.common.eventbus.Subscribe)8 SchedulerDriver (org.apache.mesos.SchedulerDriver)8 UPID (com.groupon.mesos.util.UPID)6 MesosSchedulerDriver (org.apache.mesos.MesosSchedulerDriver)3 FrameworkID (org.apache.mesos.Protos.FrameworkID)3 Protos (org.apache.mesos.Protos)2 JsonFactory (com.fasterxml.jackson.core.JsonFactory)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 GuavaModule (com.fasterxml.jackson.datatype.guava.GuavaModule)1 JacksonJaxbJsonProvider (com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider)1 ByteString (com.google.protobuf.ByteString)1 RemoteMessageEnvelope (com.groupon.mesos.scheduler.SchedulerMessageEnvelope.RemoteMessageEnvelope)1 ExternalDc (io.mesosphere.mesos.frameworks.cassandra.CassandraFrameworkProtos.ExternalDc)1 HealthReportService (io.mesosphere.mesos.frameworks.cassandra.scheduler.health.HealthReportService)1 Clock (io.mesosphere.mesos.util.Clock)1 SystemClock (io.mesosphere.mesos.util.SystemClock)1 URI (java.net.URI)1 Matcher (java.util.regex.Matcher)1 ExecutorToFrameworkMessage (mesos.internal.Messages.ExecutorToFrameworkMessage)1