Task getTaskSpecRawDriver(Task task, String taskName, int containerIndex) {
    String executorBinary = Context.executorBinary(this.clusterConfig);
    // get arguments for heron executor command
    String[] executorArgs = SchedulerUtils.executorCommandArgs(
        this.clusterConfig, this.runtimeConfig, NomadConstants.EXECUTOR_PORTS,
        String.valueOf(containerIndex));
    // get complete heron executor command
    String executorCmd = executorBinary + " " + String.join(" ", executorArgs);
    // get heron_downloader command for downloading topology package
    String topologyDownloadCmd = getFetchCommand(this.localConfig,
        this.clusterConfig, this.runtimeConfig);
    // read nomad heron executor start up script from file
    String heronNomadScript = getHeronNomadScript(this.localConfig);

    task.setName(taskName);
    // use raw_exec driver
    task.setDriver(NomadConstants.NomadDriver.RAW_EXEC.getName());
    // call nomad heron start up script
    task.addConfig(NomadConstants.NOMAD_TASK_COMMAND, NomadConstants.SHELL_CMD);
    String[] args = {NomadConstants.NOMAD_HERON_SCRIPT_NAME};
    task.addConfig(NomadConstants.NOMAD_TASK_COMMAND_ARGS, args);
    Template template = new Template();
    template.setEmbeddedTmpl(heronNomadScript);
    template.setDestPath(NomadConstants.NOMAD_HERON_SCRIPT_NAME);
    task.addTemplates(template);

    // configure nomad to allocate dynamic ports
    Port[] ports = new Port[NomadConstants.EXECUTOR_PORTS.size()];
    int i = 0;
    for (SchedulerUtils.ExecutorPort port : NomadConstants.EXECUTOR_PORTS.keySet()) {
      ports[i] = new Port().setLabel(port.getName().replace("-", "_"));
      i++;
    }

    // set enviroment variables used int the heron nomad start up script
    Map<String, String> envVars = new HashMap<>();
    envVars.put(NomadConstants.HERON_NOMAD_WORKING_DIR,
        NomadContext.workingDirectory(this.localConfig) + "/container-"
            + String.valueOf(containerIndex));

    if (NomadContext.useCorePackageUri(this.localConfig)) {
      envVars.put(NomadConstants.HERON_USE_CORE_PACKAGE_URI, "true");
      envVars.put(NomadConstants.HERON_CORE_PACKAGE_URI,
          NomadContext.corePackageUri(this.localConfig));
    } else {
      envVars.put(NomadConstants.HERON_USE_CORE_PACKAGE_URI, "false");
      envVars.put(NomadConstants.HERON_CORE_PACKAGE_DIR,
          NomadContext.corePackageDirectory(this.localConfig));
    }

    envVars.put(NomadConstants.HERON_TOPOLOGY_DOWNLOAD_CMD, topologyDownloadCmd);
    envVars.put(NomadConstants.HERON_EXECUTOR_CMD, executorCmd);
    task.setEnv(envVars);
    return task;
  }
Task getTaskSpecRawDriver ( Task task , String taskName , int containerIndex ) { String executorBinary = Context . executorBinary ( this . clusterConfig ) ; String [ ] executorArgs = SchedulerUtils . executorCommandArgs ( this . clusterConfig , this . runtimeConfig , NomadConstants . EXECUTOR_PORTS , String . valueOf ( containerIndex ) ) ; String executorCmd = executorBinary + " " + String . join ( " " , executorArgs ) ; String topologyDownloadCmd = getFetchCommand ( this . localConfig , this . clusterConfig , this . runtimeConfig ) ; String heronNomadScript = getHeronNomadScript ( this . localConfig ) ; task . setName ( taskName ) ; task . setDriver ( NomadConstants . NomadDriver . RAW_EXEC . getName ( ) ) ; task . addConfig ( NomadConstants . NOMAD_TASK_COMMAND , NomadConstants . SHELL_CMD ) ; String [ ] args = { NomadConstants . NOMAD_HERON_SCRIPT_NAME } ; task . addConfig ( NomadConstants . NOMAD_TASK_COMMAND_ARGS , args ) ; Template template = new Template ( ) ; template . setEmbeddedTmpl ( heronNomadScript ) ; template . setDestPath ( NomadConstants . NOMAD_HERON_SCRIPT_NAME ) ; task . addTemplates ( template ) ; Port [ ] ports = new Port [ NomadConstants . EXECUTOR_PORTS . size ( ) ] ; int i = 0 ; for ( SchedulerUtils . ExecutorPort port : NomadConstants . EXECUTOR_PORTS . keySet ( ) ) { ports [ i ] = new Port ( ) . setLabel ( port . getName ( ) . replace ( "-" , "_" ) ) ; i ++ ; } Map < String , String > envVars = new HashMap < > ( ) ; envVars . put ( NomadConstants . HERON_NOMAD_WORKING_DIR , NomadContext . workingDirectory ( this . localConfig ) + "/container-" + String . valueOf ( containerIndex ) ) ; if ( NomadContext . useCorePackageUri ( this . localConfig ) ) { envVars . put ( NomadConstants . HERON_USE_CORE_PACKAGE_URI , "true" ) ; envVars . put ( NomadConstants . HERON_CORE_PACKAGE_URI , NomadContext . corePackageUri ( this . localConfig ) ) ; } else { envVars . put ( NomadConstants . HERON_USE_CORE_PACKAGE_URI , "false" ) ; envVars . put ( NomadConstants . HERON_CORE_PACKAGE_DIR , NomadContext . corePackageDirectory ( this . localConfig ) ) ; } envVars . put ( NomadConstants . HERON_TOPOLOGY_DOWNLOAD_CMD , topologyDownloadCmd ) ; envVars . put ( NomadConstants . HERON_EXECUTOR_CMD , executorCmd ) ; task . setEnv ( envVars ) ; return task ; }
Get the task spec for using raw_exec driver in Nomad
In raw exec mode, Heron will be run directly on the machine