Search in sources :

Example 1 with Topology

use of com.twitter.heron.api.generated.TopologyAPI.Topology in project heron by twitter.

the class HeronExecutorTask method getExecutorCommand.

String[] getExecutorCommand() {
    String topologyDefFile = getTopologyDefnFile();
    Topology topology = getTopology(topologyDefFile);
    Config config = SchedulerConfigUtils.loadConfig(cluster, role, env, topologyJar, topologyDefFile, verboseMode, topology);
    List<Integer> freePorts = new ArrayList<>(SchedulerUtils.PORTS_REQUIRED_FOR_EXECUTOR);
    for (int i = 0; i < SchedulerUtils.PORTS_REQUIRED_FOR_EXECUTOR; i++) {
        freePorts.add(SysUtils.getFreePort());
    }
    Config runtime = Config.newBuilder().put(Key.COMPONENT_RAMMAP, componentRamMap).put(Key.TOPOLOGY_DEFINITION, topology).build();
    String[] executorCmd = SchedulerUtils.executorCommand(config, runtime, heronExecutorId, freePorts);
    LOG.info("Executor command line: " + Arrays.toString(executorCmd));
    return executorCmd;
}
Also used : Config(com.twitter.heron.spi.common.Config) ArrayList(java.util.ArrayList) Topology(com.twitter.heron.api.generated.TopologyAPI.Topology)

Example 2 with Topology

use of com.twitter.heron.api.generated.TopologyAPI.Topology in project heron by twitter.

the class HeronExecutorTaskTest method providesConfigsNeededForExecutorCmd.

@Test
public void providesConfigsNeededForExecutorCmd() throws Exception {
    Topology testTopology = createTestTopology("testTopology");
    HeronExecutorTask spyTask = getSpyOnHeronExecutorTask(null);
    Mockito.doReturn("file").when(spyTask).getTopologyDefnFile();
    Mockito.doReturn(testTopology).when(spyTask).getTopology("file");
    String[] command = spyTask.getExecutorCommand();
    // only two configs; state manager root and url should be null.
    int nullCounter = 2;
    for (String subCommand : command) {
        if (subCommand == null) {
            nullCounter--;
        }
    }
    Assert.assertEquals(0, nullCounter);
}
Also used : HeronTopology(com.twitter.heron.api.HeronTopology) Topology(com.twitter.heron.api.generated.TopologyAPI.Topology) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

Topology (com.twitter.heron.api.generated.TopologyAPI.Topology)2 HeronTopology (com.twitter.heron.api.HeronTopology)1 Config (com.twitter.heron.spi.common.Config)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1