Search in sources :

Example 1 with Scheduler

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());
                }
            };
        }
    });
}
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 2 with Scheduler

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());
                }
            };
        }
    });
}
Also used : UPID(com.groupon.mesos.util.UPID) Scheduler(org.apache.mesos.Scheduler) RescindResourceOfferMessage(mesos.internal.Messages.RescindResourceOfferMessage) SchedulerDriver(org.apache.mesos.SchedulerDriver) Subscribe(com.google.common.eventbus.Subscribe)

Example 3 with Scheduler

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);
                }
            };
        }
    });
}
Also used : UPID(com.groupon.mesos.util.UPID) Scheduler(org.apache.mesos.Scheduler) LostSlaveMessage(mesos.internal.Messages.LostSlaveMessage) SlaveID(org.apache.mesos.Protos.SlaveID) SchedulerDriver(org.apache.mesos.SchedulerDriver) Subscribe(com.google.common.eventbus.Subscribe)

Example 4 with Scheduler

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());
                }
            };
        }
    });
}
Also used : UPID(com.groupon.mesos.util.UPID) ExecutorToFrameworkMessage(mesos.internal.Messages.ExecutorToFrameworkMessage) Scheduler(org.apache.mesos.Scheduler) SchedulerDriver(org.apache.mesos.SchedulerDriver) Subscribe(com.google.common.eventbus.Subscribe)

Example 5 with Scheduler

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

Scheduler (org.apache.mesos.Scheduler)11 Subscribe (com.google.common.eventbus.Subscribe)8 SchedulerDriver (org.apache.mesos.SchedulerDriver)8 UPID (com.groupon.mesos.util.UPID)6 MesosSchedulerDriver (org.apache.mesos.MesosSchedulerDriver)3 FrameworkID (org.apache.mesos.Protos.FrameworkID)3 Protos (org.apache.mesos.Protos)2 JsonFactory (com.fasterxml.jackson.core.JsonFactory)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 GuavaModule (com.fasterxml.jackson.datatype.guava.GuavaModule)1 JacksonJaxbJsonProvider (com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider)1 ByteString (com.google.protobuf.ByteString)1 RemoteMessageEnvelope (com.groupon.mesos.scheduler.SchedulerMessageEnvelope.RemoteMessageEnvelope)1 ExternalDc (io.mesosphere.mesos.frameworks.cassandra.CassandraFrameworkProtos.ExternalDc)1 HealthReportService (io.mesosphere.mesos.frameworks.cassandra.scheduler.health.HealthReportService)1 Clock (io.mesosphere.mesos.util.Clock)1 SystemClock (io.mesosphere.mesos.util.SystemClock)1 URI (java.net.URI)1 Matcher (java.util.regex.Matcher)1 ExecutorToFrameworkMessage (mesos.internal.Messages.ExecutorToFrameworkMessage)1