Search in sources :

Example 6 with SchedulerDriver

use of org.apache.mesos.SchedulerDriver 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)

Example 7 with SchedulerDriver

use of org.apache.mesos.SchedulerDriver in project heron by twitter.

the class MesosSchedulerTest method before.

@Before
public void before() throws Exception {
    Config config = Mockito.mock(Config.class);
    Mockito.when(config.getStringValue(Key.TOPOLOGY_NAME)).thenReturn(TOPOLOGY_NAME);
    Mockito.when(config.getStringValue(Key.ROLE)).thenReturn(ROLE);
    Mockito.when(config.getStringValue(Key.CORE_PACKAGE_URI)).thenReturn(CORE_PACKAGE_URI);
    Config runtime = Mockito.mock(Config.class);
    Mockito.when(runtime.getLongValue(Key.NUM_CONTAINERS)).thenReturn(NUM_CONTAINER);
    Properties properties = new Properties();
    properties.put(Key.TOPOLOGY_PACKAGE_URI.value(), TOPOLOGY_PACKAGE_URI);
    Mockito.when(runtime.get(Key.SCHEDULER_PROPERTIES)).thenReturn(properties);
    mesosFramework = Mockito.mock(MesosFramework.class);
    SchedulerDriver driver = Mockito.mock(SchedulerDriver.class);
    baseContainer = Mockito.mock(BaseContainer.class);
    scheduler = Mockito.spy(MesosScheduler.class);
    Mockito.doReturn(mesosFramework).when(scheduler).getMesosFramework();
    Mockito.doReturn(driver).when(scheduler).getSchedulerDriver(Mockito.anyString(), Mockito.eq(mesosFramework));
    Mockito.doNothing().when(scheduler).startSchedulerDriver();
    scheduler.initialize(config, runtime);
}
Also used : BaseContainer(com.twitter.heron.scheduler.mesos.framework.BaseContainer) MesosFramework(com.twitter.heron.scheduler.mesos.framework.MesosFramework) Config(com.twitter.heron.spi.common.Config) Properties(java.util.Properties) SchedulerDriver(org.apache.mesos.SchedulerDriver) Before(org.junit.Before)

Example 8 with SchedulerDriver

use of org.apache.mesos.SchedulerDriver in project heron by twitter.

the class MesosFrameworkTest method before.

@Before
public void before() throws Exception {
    config = Mockito.mock(Config.class);
    Mockito.when(config.getStringValue(Key.TOPOLOGY_NAME)).thenReturn(TOPOLOGY_NAME);
    Mockito.when(config.getStringValue(Key.ROLE)).thenReturn(ROLE);
    Mockito.when(config.getStringValue(Key.CORE_PACKAGE_URI)).thenReturn(CORE_PACKAGE_URI);
    runtime = Mockito.mock(Config.class);
    Mockito.when(runtime.getLongValue(Key.NUM_CONTAINERS)).thenReturn(NUM_CONTAINER);
    Properties properties = new Properties();
    properties.put(Key.TOPOLOGY_PACKAGE_URI.value(), TOPOLOGY_PACKAGE_URI);
    Mockito.when(runtime.get(Key.SCHEDULER_PROPERTIES)).thenReturn(properties);
    mesosFramework = Mockito.spy(new MesosFramework(config, runtime));
    SchedulerDriver driver = Mockito.mock(SchedulerDriver.class);
    // Register the mesos framework
    Protos.FrameworkID frameworkID = Protos.FrameworkID.newBuilder().setValue("framework-id").build();
    mesosFramework.registered(driver, frameworkID, Protos.MasterInfo.getDefaultInstance());
}
Also used : Protos(org.apache.mesos.Protos) Config(com.twitter.heron.spi.common.Config) Properties(java.util.Properties) SchedulerDriver(org.apache.mesos.SchedulerDriver) Before(org.junit.Before)

Example 9 with SchedulerDriver

use of org.apache.mesos.SchedulerDriver in project elastic-job by dangdangdotcom.

the class AbstractCloudRestfulApiTest method setUpClass.

@BeforeClass
public static void setUpClass() throws Exception {
    regCenter = mock(CoordinatorRegistryCenter.class);
    jobEventRdbSearch = mock(JobEventRdbSearch.class);
    SchedulerDriver schedulerDriver = mock(SchedulerDriver.class);
    ProducerManager producerManager = new ProducerManager(schedulerDriver, regCenter);
    producerManager.startup();
    restfulService = new RestfulService(regCenter, new RestfulServerConfiguration(19000), producerManager);
    restfulService.start();
}
Also used : JobEventRdbSearch(com.dangdang.ddframe.job.event.rdb.JobEventRdbSearch) ProducerManager(com.dangdang.ddframe.job.cloud.scheduler.producer.ProducerManager) RestfulServerConfiguration(com.dangdang.ddframe.job.cloud.scheduler.env.RestfulServerConfiguration) SchedulerDriver(org.apache.mesos.SchedulerDriver) CoordinatorRegistryCenter(com.dangdang.ddframe.job.reg.base.CoordinatorRegistryCenter) BeforeClass(org.junit.BeforeClass)

Example 10 with SchedulerDriver

use of org.apache.mesos.SchedulerDriver in project jesos by groupon.

the class LocalSchedulerMessageProcessor method frameworkError.

@Subscribe
public void frameworkError(final FrameworkErrorMessageEnvelope envelope) {
    checkState(envelope.getRecipient().equals(context.getDriverUPID()), "Received a remote message for local delivery");
    final UPID sender = envelope.getSender();
    if (!driverIsConnected(sender)) {
        return;
    }
    final FrameworkErrorMessage frameworkErrorMessage = envelope.getMessage();
    eventBus.post(new SchedulerCallback() {

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

                @Override
                public void run() {
                    schedulerDriver.abort();
                    scheduler.error(schedulerDriver, frameworkErrorMessage.getMessage());
                }
            };
        }
    });
}
Also used : UPID(com.groupon.mesos.util.UPID) Scheduler(org.apache.mesos.Scheduler) FrameworkErrorMessage(mesos.internal.Messages.FrameworkErrorMessage) SchedulerDriver(org.apache.mesos.SchedulerDriver) Subscribe(com.google.common.eventbus.Subscribe)

Aggregations

SchedulerDriver (org.apache.mesos.SchedulerDriver)12 Subscribe (com.google.common.eventbus.Subscribe)8 Scheduler (org.apache.mesos.Scheduler)8 UPID (com.groupon.mesos.util.UPID)6 FrameworkID (org.apache.mesos.Protos.FrameworkID)3 Config (com.twitter.heron.spi.common.Config)2 Properties (java.util.Properties)2 Before (org.junit.Before)2 RestfulServerConfiguration (com.dangdang.ddframe.job.cloud.scheduler.env.RestfulServerConfiguration)1 ProducerManager (com.dangdang.ddframe.job.cloud.scheduler.producer.ProducerManager)1 JobEventRdbSearch (com.dangdang.ddframe.job.event.rdb.JobEventRdbSearch)1 CoordinatorRegistryCenter (com.dangdang.ddframe.job.reg.base.CoordinatorRegistryCenter)1 RemoteMessageEnvelope (com.groupon.mesos.scheduler.SchedulerMessageEnvelope.RemoteMessageEnvelope)1 BaseContainer (com.twitter.heron.scheduler.mesos.framework.BaseContainer)1 MesosFramework (com.twitter.heron.scheduler.mesos.framework.MesosFramework)1 ExecutorToFrameworkMessage (mesos.internal.Messages.ExecutorToFrameworkMessage)1 FrameworkErrorMessage (mesos.internal.Messages.FrameworkErrorMessage)1 FrameworkRegisteredMessage (mesos.internal.Messages.FrameworkRegisteredMessage)1 FrameworkReregisteredMessage (mesos.internal.Messages.FrameworkReregisteredMessage)1 LostSlaveMessage (mesos.internal.Messages.LostSlaveMessage)1