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());
}
};
}
});
}
Aggregations