Search in sources :

Example 6 with FrameworkID

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

the class ByteBufferSupportTest method testFrameworkIDToFromByteBuffer.

@Test
public void testFrameworkIDToFromByteBuffer() throws Exception {
    ByteBuffer bb = ByteBufferSupport.toByteBuffer(getExecutorInfo().getFrameworkId());
    FrameworkID id = ByteBufferSupport.toFrameworkID(bb);
    assertEquals(getExecutorInfo().getFrameworkId(), id);
}
Also used : FrameworkID(org.apache.mesos.Protos.FrameworkID) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 7 with FrameworkID

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

the class OfferUtilsTest method generateOffers.

private List<Offer> generateOffers(List<Resource> resources) {
    FrameworkID fidOne = Protos.FrameworkID.newBuilder().setValue("framework-1").build();
    FrameworkID fidTwo = Protos.FrameworkID.newBuilder().setValue("framework-2").build();
    FrameworkID fidThree = Protos.FrameworkID.newBuilder().setValue("framework-3").build();
    FrameworkID fidFour = Protos.FrameworkID.newBuilder().setValue("framework-4").build();
    OfferID oidOne = Protos.OfferID.newBuilder().setValue("offer-1").build();
    OfferID oidTwo = Protos.OfferID.newBuilder().setValue("offer-2").build();
    OfferID oidThree = Protos.OfferID.newBuilder().setValue("offer-3").build();
    OfferID oidFour = Protos.OfferID.newBuilder().setValue("offer-4").build();
    SlaveID sidOne = Protos.SlaveID.newBuilder().setValue("slave-1").build();
    SlaveID sidTwo = Protos.SlaveID.newBuilder().setValue("slave-2").build();
    SlaveID sidThree = Protos.SlaveID.newBuilder().setValue("slave-3").build();
    SlaveID sidFour = Protos.SlaveID.newBuilder().setValue("slave-4").build();
    Offer offerOne = Protos.Offer.newBuilder().setFrameworkId(fidOne).setHostname("10.0.0.1").setId(oidOne).setSlaveId(sidOne).addResources(resources.get(0)).addResources(resources.get(1)).build();
    Offer offerTwo = Protos.Offer.newBuilder().setFrameworkId(fidTwo).setHostname("10.0.0.2").setId(oidTwo).setSlaveId(sidTwo).addResources(resources.get(2)).addResources(resources.get(3)).build();
    Offer offerThree = Protos.Offer.newBuilder().setFrameworkId(fidThree).setHostname("10.0.0.3").setId(oidThree).setSlaveId(sidThree).addResources(resources.get(0)).addResources(resources.get(3)).build();
    Offer offerFour = Protos.Offer.newBuilder().setFrameworkId(fidFour).setHostname("10.0.0.4").setId(oidFour).setSlaveId(sidFour).addResources(resources.get(2)).addResources(resources.get(1)).build();
    return Lists.newArrayList(offerOne, offerTwo, offerThree, offerFour);
}
Also used : OfferID(org.apache.mesos.Protos.OfferID) Offer(org.apache.mesos.Protos.Offer) FrameworkID(org.apache.mesos.Protos.FrameworkID) SlaveID(org.apache.mesos.Protos.SlaveID)

Example 8 with FrameworkID

use of org.apache.mesos.Protos.FrameworkID 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 9 with FrameworkID

use of org.apache.mesos.Protos.FrameworkID 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

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