Search in sources :

Example 1 with ResourceOffersMessage

use of mesos.internal.Messages.ResourceOffersMessage in project jesos by groupon.

the class LocalSchedulerMessageProcessor method frameworkResourceOffers.

@Subscribe
public void frameworkResourceOffers(final ResourceOffersMessageEnvelope envelope) {
    checkState(envelope.getRecipient().equals(context.getDriverUPID()), "Received a remote message for local delivery");
    final UPID sender = envelope.getSender();
    if (!driverIsConnected(sender)) {
        return;
    }
    final ResourceOffersMessage resourceOffersMessage = envelope.getMessage();
    final List<Offer> offers = resourceOffersMessage.getOffersList();
    final List<UPID> pids = ImmutableList.copyOf(Lists.transform(resourceOffersMessage.getPidsList(), UPID.getCreateFunction()));
    checkState(offers.size() == pids.size(), "Received %s offers but only %s pids!", offers.size(), pids.size());
    int pidIndex = 0;
    for (final Offer offer : offers) {
        context.addOffer(offer.getId(), offer.getSlaveId(), pids.get(pidIndex++));
    }
    eventBus.post(new SchedulerCallback() {

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

                @Override
                public void run() {
                    scheduler.resourceOffers(schedulerDriver, resourceOffersMessage.getOffersList());
                }
            };
        }
    });
}
Also used : UPID(com.groupon.mesos.util.UPID) Offer(org.apache.mesos.Protos.Offer) Scheduler(org.apache.mesos.Scheduler) ResourceOffersMessage(mesos.internal.Messages.ResourceOffersMessage) SchedulerDriver(org.apache.mesos.SchedulerDriver) Subscribe(com.google.common.eventbus.Subscribe)

Aggregations

Subscribe (com.google.common.eventbus.Subscribe)1 UPID (com.groupon.mesos.util.UPID)1 ResourceOffersMessage (mesos.internal.Messages.ResourceOffersMessage)1 Offer (org.apache.mesos.Protos.Offer)1 Scheduler (org.apache.mesos.Scheduler)1 SchedulerDriver (org.apache.mesos.SchedulerDriver)1