use of com.twitter.heron.scheduler.utils.LauncherUtils in project heron by twitter.
the class LaunchRunnerTest method createRunnerRuntime.
private static Config createRunnerRuntime(com.twitter.heron.api.Config topologyConfig) throws Exception {
Config runtime = spy(Config.newBuilder().build());
ILauncher launcher = mock(ILauncher.class);
IPacking packing = mock(IPacking.class);
SchedulerStateManagerAdaptor adaptor = mock(SchedulerStateManagerAdaptor.class);
TopologyAPI.Topology topology = createTopology(topologyConfig);
doReturn(launcher).when(runtime).get(Key.LAUNCHER_CLASS_INSTANCE);
doReturn(adaptor).when(runtime).get(Key.SCHEDULER_STATE_MANAGER_ADAPTOR);
doReturn(topology).when(runtime).get(Key.TOPOLOGY_DEFINITION);
PackingPlan packingPlan = mock(PackingPlan.class);
when(packingPlan.getContainers()).thenReturn(new HashSet<ContainerPlan>());
when(packingPlan.getComponentRamDistribution()).thenReturn("ramdist");
when(packingPlan.getId()).thenReturn("packing_plan_id");
Set<ContainerPlan> containerPlans = new HashSet<>();
// just need it to be of size 1
containerPlans.add(PackingTestUtils.testContainerPlan(1));
when(packingPlan.getContainers()).thenReturn(containerPlans);
when(packing.pack()).thenReturn(packingPlan);
LauncherUtils mockLauncherUtils = mock(LauncherUtils.class);
when(mockLauncherUtils.createPackingPlan(any(Config.class), any(Config.class))).thenReturn(packingPlan);
PowerMockito.spy(LauncherUtils.class);
PowerMockito.doReturn(mockLauncherUtils).when(LauncherUtils.class, "getInstance");
return runtime;
}
use of com.twitter.heron.scheduler.utils.LauncherUtils in project heron by twitter.
the class SlurmLauncher method launch.
@Override
public boolean launch(PackingPlan packing) {
LOG.log(Level.FINE, "Launching topology for local cluster {0}", SlurmContext.cluster(config));
// this working directory is a shared directory among the nodes
if (!setupWorkingDirectory()) {
LOG.log(Level.SEVERE, "Failed to download the core and topology packages");
return false;
}
LauncherUtils launcherUtils = LauncherUtils.getInstance();
Config ytruntime = launcherUtils.createConfigWithPackingDetails(runtime, packing);
return launcherUtils.onScheduleAsLibrary(config, ytruntime, new SlurmScheduler(topologyWorkingDirectory), packing);
}
use of com.twitter.heron.scheduler.utils.LauncherUtils in project heron by twitter.
the class MarathonLauncherTest method testLaunch.
@Test
public void testLaunch() throws Exception {
Config config = Config.newBuilder().build();
MarathonLauncher launcher = Mockito.spy(MarathonLauncher.class);
launcher.initialize(config, config);
LauncherUtils mockLauncherUtils = Mockito.mock(LauncherUtils.class);
PowerMockito.spy(LauncherUtils.class);
PowerMockito.doReturn(mockLauncherUtils).when(LauncherUtils.class, "getInstance");
// Launched successfully
Mockito.when(mockLauncherUtils.onScheduleAsLibrary(Mockito.any(Config.class), Mockito.any(Config.class), Mockito.any(IScheduler.class), Mockito.any(PackingPlan.class))).thenReturn(true);
Assert.assertTrue(launcher.launch(Mockito.mock(PackingPlan.class)));
Mockito.verify(mockLauncherUtils).onScheduleAsLibrary(Mockito.any(Config.class), Mockito.any(Config.class), Mockito.any(IScheduler.class), Mockito.any(PackingPlan.class));
// Failed to launch
Mockito.when(mockLauncherUtils.onScheduleAsLibrary(Mockito.any(Config.class), Mockito.any(Config.class), Mockito.any(IScheduler.class), Mockito.any(PackingPlan.class))).thenReturn(false);
Assert.assertFalse(launcher.launch(Mockito.mock(PackingPlan.class)));
Mockito.verify(mockLauncherUtils, Mockito.times(2)).onScheduleAsLibrary(Mockito.any(Config.class), Mockito.any(Config.class), Mockito.any(IScheduler.class), Mockito.any(PackingPlan.class));
launcher.close();
}
use of com.twitter.heron.scheduler.utils.LauncherUtils in project incubator-heron by apache.
the class LaunchRunnerTest method createRunnerRuntime.
private static Config createRunnerRuntime(com.twitter.heron.api.Config topologyConfig) throws Exception {
Config runtime = spy(Config.newBuilder().build());
ILauncher launcher = mock(ILauncher.class);
IPacking packing = mock(IPacking.class);
SchedulerStateManagerAdaptor adaptor = mock(SchedulerStateManagerAdaptor.class);
TopologyAPI.Topology topology = createTopology(topologyConfig);
doReturn(launcher).when(runtime).get(Key.LAUNCHER_CLASS_INSTANCE);
doReturn(adaptor).when(runtime).get(Key.SCHEDULER_STATE_MANAGER_ADAPTOR);
doReturn(topology).when(runtime).get(Key.TOPOLOGY_DEFINITION);
PackingPlan packingPlan = mock(PackingPlan.class);
when(packingPlan.getContainers()).thenReturn(new HashSet<ContainerPlan>());
when(packingPlan.getComponentRamDistribution()).thenReturn("ramdist");
when(packingPlan.getId()).thenReturn("packing_plan_id");
Set<ContainerPlan> containerPlans = new HashSet<>();
// just need it to be of size 1
containerPlans.add(PackingTestUtils.testContainerPlan(1));
when(packingPlan.getContainers()).thenReturn(containerPlans);
when(packing.pack()).thenReturn(packingPlan);
LauncherUtils mockLauncherUtils = mock(LauncherUtils.class);
when(mockLauncherUtils.createPackingPlan(any(Config.class), any(Config.class))).thenReturn(packingPlan);
PowerMockito.spy(LauncherUtils.class);
PowerMockito.doReturn(mockLauncherUtils).when(LauncherUtils.class, "getInstance");
return runtime;
}
use of com.twitter.heron.scheduler.utils.LauncherUtils in project incubator-heron by apache.
the class KubernetesLauncher method launch.
@Override
public boolean launch(PackingPlan packing) {
LauncherUtils launcherUtils = LauncherUtils.getInstance();
Config ytruntime = launcherUtils.createConfigWithPackingDetails(runtime, packing);
return launcherUtils.onScheduleAsLibrary(config, ytruntime, getScheduler(), packing);
}
Aggregations