Search in sources :

Example 66 with Config

use of com.twitter.heron.spi.common.Config in project incubator-heron by apache.

the class LauncherUtilsTest method generatesPackingPlan.

@Test
public void generatesPackingPlan() throws Exception {
    final String PACKING_CLASS = "nonExistingTestPackingClass";
    final PackingPlan mockPackingPlan = Mockito.mock(PackingPlan.class);
    IPacking mockPacking = Mockito.mock(IPacking.class);
    Mockito.when(mockPacking.pack()).thenReturn(mockPackingPlan);
    PowerMockito.spy(ReflectionUtils.class);
    PowerMockito.doReturn(mockPacking).when(ReflectionUtils.class, "newInstance", PACKING_CLASS);
    TopologyAPI.Topology mockTopology = PowerMockito.mock(TopologyAPI.Topology.class);
    Config mockConfig = Mockito.mock(Config.class);
    Mockito.when(mockConfig.getStringValue(Key.PACKING_CLASS)).thenReturn(PACKING_CLASS);
    Mockito.when(mockConfig.get(Key.TOPOLOGY_DEFINITION)).thenReturn(mockTopology);
    PackingPlan resultPacking = LauncherUtils.getInstance().createPackingPlan(mockConfig, mockConfig);
    Assert.assertEquals(mockPackingPlan, resultPacking);
    Mockito.verify(mockPacking).initialize(Mockito.any(Config.class), Mockito.eq(mockTopology));
    Mockito.verify(mockPacking).pack();
    Mockito.verify(mockPacking).close();
}
Also used : IPacking(com.twitter.heron.spi.packing.IPacking) Config(com.twitter.heron.spi.common.Config) PackingPlan(com.twitter.heron.spi.packing.PackingPlan) TopologyAPI(com.twitter.heron.api.generated.TopologyAPI) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 67 with Config

use of com.twitter.heron.spi.common.Config in project incubator-heron by apache.

the class AuroraScheduler method getController.

/**
 * Get an AuroraController based on the config and runtime
 *
 * @return AuroraController
 */
protected AuroraController getController() throws ClassNotFoundException, InstantiationException, IllegalAccessException {
    Boolean cliController = config.getBooleanValue(Key.AURORA_CONTROLLER_CLASS);
    Config localConfig = Config.toLocalMode(this.config);
    if (cliController) {
        return new AuroraCLIController(Runtime.topologyName(runtime), Context.cluster(localConfig), Context.role(localConfig), Context.environ(localConfig), AuroraContext.getHeronAuroraPath(localConfig), Context.verbose(localConfig));
    } else {
        return new AuroraHeronShellController(Runtime.topologyName(runtime), Context.cluster(localConfig), Context.role(localConfig), Context.environ(localConfig), AuroraContext.getHeronAuroraPath(localConfig), Context.verbose(localConfig), localConfig);
    }
}
Also used : Config(com.twitter.heron.spi.common.Config)

Example 68 with Config

use of com.twitter.heron.spi.common.Config 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);
}
Also used : Config(com.twitter.heron.spi.common.Config) LauncherUtils(com.twitter.heron.scheduler.utils.LauncherUtils)

Example 69 with Config

use of com.twitter.heron.spi.common.Config in project incubator-heron by apache.

the class SubmitterMainTest method setUp.

@Before
public void setUp() throws Exception {
    // Mock objects to be verified
    IPacking packing = mock(IPacking.class);
    statemgr = mock(IStateManager.class);
    launcher = mock(ILauncher.class);
    uploader = mock(IUploader.class);
    // Mock ReflectionUtils stuff
    PowerMockito.spy(ReflectionUtils.class);
    PowerMockito.doReturn(statemgr).when(ReflectionUtils.class, "newInstance", STATE_MANAGER_CLASS);
    PowerMockito.doReturn(launcher).when(ReflectionUtils.class, "newInstance", LAUNCHER_CLASS);
    PowerMockito.doReturn(packing).when(ReflectionUtils.class, "newInstance", PACKING_CLASS);
    PowerMockito.doReturn(uploader).when(ReflectionUtils.class, "newInstance", UPLOADER_CLASS);
    config = mock(Config.class);
    when(config.getStringValue(Key.STATE_MANAGER_CLASS)).thenReturn(STATE_MANAGER_CLASS);
    when(config.getStringValue(Key.LAUNCHER_CLASS)).thenReturn(LAUNCHER_CLASS);
    when(config.getStringValue(Key.PACKING_CLASS)).thenReturn(PACKING_CLASS);
    when(config.getStringValue(Key.UPLOADER_CLASS)).thenReturn(UPLOADER_CLASS);
    when(packing.pack()).thenReturn(PackingTestUtils.testPackingPlan(TOPOLOGY_NAME, new RoundRobinPacking()));
    topology = TopologyAPI.Topology.getDefaultInstance();
}
Also used : IStateManager(com.twitter.heron.spi.statemgr.IStateManager) IUploader(com.twitter.heron.spi.uploader.IUploader) IPacking(com.twitter.heron.spi.packing.IPacking) ILauncher(com.twitter.heron.spi.scheduler.ILauncher) RoundRobinPacking(com.twitter.heron.packing.roundrobin.RoundRobinPacking) Config(com.twitter.heron.spi.common.Config) Before(org.junit.Before)

Example 70 with Config

use of com.twitter.heron.spi.common.Config in project incubator-heron by apache.

the class SchedulerClientFactoryTest method testGetLibrarySchedulerClient.

@Test
@PrepareForTest(ReflectionUtils.class)
public void testGetLibrarySchedulerClient() throws Exception {
    // Instantiate mock objects
    Config config = Mockito.mock(Config.class);
    Config runtime = Mockito.mock(Config.class);
    // Return a MockScheduler
    Mockito.when(config.getStringValue(Key.SCHEDULER_CLASS)).thenReturn(IScheduler.class.getName());
    PowerMockito.mockStatic(ReflectionUtils.class);
    PowerMockito.doReturn(Mockito.mock(IScheduler.class)).when(ReflectionUtils.class, "newInstance", Mockito.eq(IScheduler.class.getName()));
    // Get a LibrarySchedulerClient
    Mockito.when(config.getBooleanValue(Key.SCHEDULER_IS_SERVICE)).thenReturn(false);
    Assert.assertNotNull(new SchedulerClientFactory(config, runtime).getSchedulerClient());
}
Also used : Config(com.twitter.heron.spi.common.Config) IScheduler(com.twitter.heron.spi.scheduler.IScheduler) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

Config (com.twitter.heron.spi.common.Config)211 Test (org.junit.Test)125 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)60 PackingPlan (com.twitter.heron.spi.packing.PackingPlan)53 TopologyAPI (com.twitter.heron.api.generated.TopologyAPI)43 SchedulerStateManagerAdaptor (com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor)35 LauncherUtils (com.twitter.heron.scheduler.utils.LauncherUtils)19 IStateManager (com.twitter.heron.spi.statemgr.IStateManager)18 IScheduler (com.twitter.heron.spi.scheduler.IScheduler)17 HashMap (java.util.HashMap)16 Before (org.junit.Before)16 ILauncher (com.twitter.heron.spi.scheduler.ILauncher)14 IOException (java.io.IOException)13 Resource (com.twitter.heron.spi.packing.Resource)12 URI (java.net.URI)12 HashSet (java.util.HashSet)11 CommandLine (org.apache.commons.cli.CommandLine)10 ByteAmount (com.twitter.heron.common.basics.ByteAmount)9 ISchedulerClient (com.twitter.heron.scheduler.client.ISchedulerClient)9 File (java.io.File)9