Search in sources :

Example 1 with FrameworkID

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

the class TestObjectFactory method getOffer.

public static Offer getOffer(String host, String slaveId, String frameworkId, String offerId, double cpuCores, double memory) {
    Protos.SlaveID sid = SlaveID.newBuilder().setValue(slaveId).build();
    Protos.FrameworkID fid = FrameworkID.newBuilder().setValue(frameworkId).build();
    Protos.Value.Scalar cores = Protos.Value.Scalar.newBuilder().setValue(cpuCores).build();
    Protos.Value.Scalar mem = Protos.Value.Scalar.newBuilder().setValue(memory).build();
    Protos.Resource cpuResource = Protos.Resource.newBuilder().setName("cpus").setScalar(cores).setType(Type.SCALAR).build();
    Protos.Resource memResource = Protos.Resource.newBuilder().setName("mem").setScalar(mem).setType(Type.SCALAR).build();
    return Protos.Offer.newBuilder().setHostname(host).setId(OfferID.newBuilder().setValue(offerId)).setSlaveId(sid).setFrameworkId(fid).addResources(cpuResource).addResources(memResource).build();
}
Also used : SlaveID(org.apache.mesos.Protos.SlaveID) Protos(org.apache.mesos.Protos) FrameworkID(org.apache.mesos.Protos.FrameworkID)

Example 2 with FrameworkID

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

the class ByteBufferSupportTest method getExecutorInfo.

private ExecutorInfo getExecutorInfo() {
    FrameworkID id = Protos.FrameworkID.newBuilder().setValue("framework1").build();
    ExecutorID eid = Protos.ExecutorID.newBuilder().setValue("executor1").build();
    CommandInfo cm = Protos.CommandInfo.newBuilder().setValue("command").build();
    return ExecutorInfo.newBuilder().setFrameworkId(id).setExecutorId(eid).setCommand(cm).build();
}
Also used : ExecutorID(org.apache.mesos.Protos.ExecutorID) CommandInfo(org.apache.mesos.Protos.CommandInfo) FrameworkID(org.apache.mesos.Protos.FrameworkID)

Example 3 with FrameworkID

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

the class LocalSchedulerMessageProcessor method frameworkReregistered.

@Subscribe
public void frameworkReregistered(final FrameworkReregisteredMessageEnvelope envelope) {
    checkState(envelope.getRecipient().equals(context.getDriverUPID()), "Received a remote message for local delivery");
    final FrameworkReregisteredMessage frameworkReregisteredMessage = envelope.getMessage();
    if (!masterIsValid(frameworkReregisteredMessage.getMasterInfo())) {
        return;
    }
    final FrameworkID frameworkId = frameworkReregisteredMessage.getFrameworkId();
    checkState(frameworkId != null, "Received null framework reregistration message!");
    checkState(frameworkId.equals(context.getFrameworkId()), "Received framework reregistration for %s but expected %s", frameworkId.getValue(), context.getFrameworkId().getValue());
    context.connected();
    context.setFailover(false);
    eventBus.post(new SchedulerCallback() {

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

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

Example 4 with FrameworkID

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

the class InternalSchedulerDriver method doLaunchTasks.

// 
// Launch Tasks processing
// 
private void doLaunchTasks(final LaunchTasksMessage message) {
    final MasterInfo masterInfo = context.connectedMaster();
    if (masterInfo == null) {
        loseAllTasks(message.getTasksList(), "Master disconnected");
        return;
    }
    final ImmutableList.Builder<TaskInfo> builder = ImmutableList.builder();
    for (TaskInfo taskInfo : message.getTasksList()) {
        if (taskInfo.hasExecutor() == taskInfo.hasCommand()) {
            loseTask(taskInfo, "TaskInfo must have either an 'executor' or a 'command'");
            // for(...
            continue;
        }
        if (taskInfo.hasExecutor()) {
            if (taskInfo.getExecutor().hasFrameworkId()) {
                final FrameworkID executorFrameworkId = taskInfo.getExecutor().getFrameworkId();
                if (!executorFrameworkId.equals(context.getFrameworkId())) {
                    loseTask(taskInfo, format("ExecutorInfo has an invalid FrameworkID (Actual: %s vs Expected: %s)", executorFrameworkId.getValue(), context.getFrameworkId().getValue()));
                    // for(...
                    continue;
                }
            } else {
                // Executor present but not framework id. Set the framework id.
                taskInfo = TaskInfo.newBuilder(taskInfo).setExecutor(ExecutorInfo.newBuilder(taskInfo.getExecutor()).setFrameworkId(context.getFrameworkId())).build();
            }
        }
        builder.add(taskInfo);
    }
    final List<TaskInfo> launchTasks = builder.build();
    for (final OfferID offer : message.getOfferIdsList()) {
        if (!context.hasOffers(offer)) {
            LOG.warn("Unknown offer %s ignored!", offer.getValue());
        }
        for (final TaskInfo launchTask : launchTasks) {
            if (context.hasOffer(offer, launchTask.getSlaveId())) {
                context.addSlave(launchTask.getSlaveId(), context.getOffer(offer, launchTask.getSlaveId()));
            }
        }
        context.removeAllOffers(offer);
    }
    final LaunchTasksMessage launchMessage = LaunchTasksMessage.newBuilder(message).setFrameworkId(context.getFrameworkId()).clearTasks().addAllTasks(launchTasks).build();
    eventBus.post(new RemoteMessageEnvelope(context.getDriverUPID(), context.getMasterUPID(), launchMessage));
}
Also used : TaskInfo(org.apache.mesos.Protos.TaskInfo) OfferID(org.apache.mesos.Protos.OfferID) MasterInfo(org.apache.mesos.Protos.MasterInfo) RemoteMessageEnvelope(com.groupon.mesos.scheduler.SchedulerMessageEnvelope.RemoteMessageEnvelope) ImmutableList(com.google.common.collect.ImmutableList) FrameworkID(org.apache.mesos.Protos.FrameworkID) LaunchTasksMessage(mesos.internal.Messages.LaunchTasksMessage)

Example 5 with FrameworkID

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

the class MesosModule method providesSchedulerDriver.

@Provides
@Singleton
SchedulerDriver providesSchedulerDriver(MyriadScheduler scheduler, MyriadConfiguration cfg, SchedulerState schedulerState) {
    Builder frameworkInfoBuilder = FrameworkInfo.newBuilder().setUser("").setName(cfg.getFrameworkName()).setCheckpoint(cfg.isCheckpoint()).setFailoverTimeout(cfg.getFrameworkFailoverTimeout());
    frameworkInfoBuilder.setRole(cfg.getFrameworkRole());
    Optional<FrameworkID> optFrameId = schedulerState.getFrameworkID();
    if (optFrameId.isPresent()) {
        FrameworkID frameworkId = optFrameId.get();
        LOGGER.info("Attempting to re-register with frameworkId: {}", frameworkId.getValue());
        frameworkInfoBuilder.setId(frameworkId);
    }
    String mesosAuthenticationPrincipal = cfg.getMesosAuthenticationPrincipal();
    String mesosAuthenticationSecretFilename = cfg.getMesosAuthenticationSecretFilename();
    if (StringUtils.isNotEmpty(mesosAuthenticationPrincipal)) {
        frameworkInfoBuilder.setPrincipal(mesosAuthenticationPrincipal);
        Credential.Builder credentialBuilder = Credential.newBuilder();
        credentialBuilder.setPrincipal(mesosAuthenticationPrincipal);
        if (StringUtils.isNotEmpty(mesosAuthenticationSecretFilename)) {
            try {
                credentialBuilder.setSecretBytes(ByteString.readFrom(new FileInputStream(mesosAuthenticationSecretFilename)));
            } catch (FileNotFoundException ex) {
                LOGGER.error("Mesos authentication secret file was not found", ex);
                throw new RuntimeException(ex);
            } catch (IOException ex) {
                LOGGER.error("Error reading Mesos authentication secret file", ex);
                throw new RuntimeException(ex);
            }
        }
        return new MesosSchedulerDriver(scheduler, frameworkInfoBuilder.build(), cfg.getMesosMaster(), credentialBuilder.build());
    } else {
        return new MesosSchedulerDriver(scheduler, frameworkInfoBuilder.build(), cfg.getMesosMaster());
    }
}
Also used : Credential(org.apache.mesos.Protos.Credential) Builder(org.apache.mesos.Protos.FrameworkInfo.Builder) FileNotFoundException(java.io.FileNotFoundException) FrameworkID(org.apache.mesos.Protos.FrameworkID) ByteString(com.google.protobuf.ByteString) IOException(java.io.IOException) MesosSchedulerDriver(org.apache.mesos.MesosSchedulerDriver) FileInputStream(java.io.FileInputStream) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Aggregations

FrameworkID (org.apache.mesos.Protos.FrameworkID)9 Subscribe (com.google.common.eventbus.Subscribe)3 Scheduler (org.apache.mesos.Scheduler)3 SchedulerDriver (org.apache.mesos.SchedulerDriver)3 RemoteMessageEnvelope (com.groupon.mesos.scheduler.SchedulerMessageEnvelope.RemoteMessageEnvelope)2 OfferID (org.apache.mesos.Protos.OfferID)2 SlaveID (org.apache.mesos.Protos.SlaveID)2 ImmutableList (com.google.common.collect.ImmutableList)1 Provides (com.google.inject.Provides)1 Singleton (com.google.inject.Singleton)1 ByteString (com.google.protobuf.ByteString)1 UPID (com.groupon.mesos.util.UPID)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 ByteBuffer (java.nio.ByteBuffer)1 FrameworkRegisteredMessage (mesos.internal.Messages.FrameworkRegisteredMessage)1 FrameworkReregisteredMessage (mesos.internal.Messages.FrameworkReregisteredMessage)1 LaunchTasksMessage (mesos.internal.Messages.LaunchTasksMessage)1 StatusUpdateAcknowledgementMessage (mesos.internal.Messages.StatusUpdateAcknowledgementMessage)1