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