use of org.apache.mesos.Scheduler 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());
}
};
}
});
}
use of org.apache.mesos.Scheduler in project jesos by groupon.
the class LocalSchedulerMessageProcessor method frameworkRescindOffer.
@Subscribe
public void frameworkRescindOffer(final RescindResourceOfferMessageEnvelope envelope) {
checkState(envelope.getRecipient().equals(context.getDriverUPID()), "Received a remote message for local delivery");
final UPID sender = envelope.getSender();
if (!driverIsConnected(sender)) {
return;
}
final RescindResourceOfferMessage rescindResourceOfferMessage = envelope.getMessage();
context.removeAllOffers(rescindResourceOfferMessage.getOfferId());
eventBus.post(new SchedulerCallback() {
@Override
public Runnable getCallback(final Scheduler scheduler, final SchedulerDriver schedulerDriver) {
return new Runnable() {
@Override
public void run() {
scheduler.offerRescinded(schedulerDriver, rescindResourceOfferMessage.getOfferId());
}
};
}
});
}
use of org.apache.mesos.Scheduler in project jesos by groupon.
the class LocalSchedulerMessageProcessor method frameworkLostSlave.
@Subscribe
public void frameworkLostSlave(final LostSlaveMessageEnvelope envelope) {
checkState(envelope.getRecipient().equals(context.getDriverUPID()), "Received a remote message for local delivery");
final UPID sender = envelope.getSender();
if (!driverIsConnected(sender)) {
return;
}
final LostSlaveMessage lostSlaveMessage = envelope.getMessage();
final SlaveID slaveId = lostSlaveMessage.getSlaveId();
context.removeSlave(slaveId);
eventBus.post(new SchedulerCallback() {
@Override
public Runnable getCallback(final Scheduler scheduler, final SchedulerDriver schedulerDriver) {
return new Runnable() {
@Override
public void run() {
scheduler.slaveLost(schedulerDriver, slaveId);
}
};
}
});
}
use of org.apache.mesos.Scheduler in project jesos by groupon.
the class LocalSchedulerMessageProcessor method frameworkFrameworkMessage.
@Subscribe
public void frameworkFrameworkMessage(final ExecutorToFrameworkMessageEnvelope envelope) {
checkState(envelope.getRecipient().equals(context.getDriverUPID()), "Received a remote message for local delivery");
final UPID sender = envelope.getSender();
if (!driverIsConnected(sender)) {
return;
}
final ExecutorToFrameworkMessage executorToFrameworkMessage = envelope.getMessage();
eventBus.post(new SchedulerCallback() {
@Override
public Runnable getCallback(final Scheduler scheduler, final SchedulerDriver schedulerDriver) {
return new Runnable() {
@Override
public void run() {
scheduler.frameworkMessage(schedulerDriver, executorToFrameworkMessage.getExecutorId(), executorToFrameworkMessage.getSlaveId(), executorToFrameworkMessage.getData().toByteArray());
}
};
}
});
}
use of org.apache.mesos.Scheduler 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