Search in sources :

Example 1 with SubmissionParameter

use of com.ibm.streamsx.topology.jobconfig.SubmissionParameter in project streamsx.topology by IBMStreams.

the class InvokeSubmit method explicitJobConfig.

/**
     * Set the job configuration as explicit streamtool submitjob arguments.
     * Used for 4.1 and older.
     */
private void explicitJobConfig(List<String> commands, final JobConfig jobConfig) {
    if (jobConfig.getTracing() != null) {
        commands.add("--config");
        commands.add("tracing=" + jobConfig.getStreamsTracing());
    }
    if (jobConfig.getJobName() != null) {
        commands.add("--jobname");
        commands.add(jobConfig.getJobName());
    }
    if (jobConfig.getJobGroup() != null) {
        commands.add("--jobgroup");
        commands.add(jobConfig.getJobGroup());
    }
    if (jobConfig.getPreloadApplicationBundles() != null) {
        commands.add("--config");
        commands.add("preloadApplicationBundles=" + jobConfig.getPreloadApplicationBundles());
    }
    if (jobConfig.getDataDirectory() != null) {
        commands.add("--config");
        commands.add("data-directory=" + jobConfig.getDataDirectory());
    }
    if (jobConfig.hasSubmissionParameters()) {
        for (SubmissionParameter param : jobConfig.getSubmissionParameters()) {
            // note: this "streamtool" execution path does NOT correctly
            // handle / preserve the semantics of escaped \t and \n.
            // e.g., "\\n" is treated as a newline 
            // rather than the two char '\','n'
            // This seems to be happening internal to streamtool.
            // Adjust accordingly.
            commands.add("-P");
            commands.add(param.getName() + "=" + param.getValue().replace("\\", "\\\\\\"));
        }
    }
}
Also used : SubmissionParameter(com.ibm.streamsx.topology.jobconfig.SubmissionParameter)

Example 2 with SubmissionParameter

use of com.ibm.streamsx.topology.jobconfig.SubmissionParameter in project streamsx.topology by IBMStreams.

the class InvokeStandalone method invoke.

public Future<Integer> invoke(JsonObject deploy) throws Exception, InterruptedException {
    String si = System.getProperty("java.home");
    File jvm = new File(si, "bin/java");
    JobConfig jc = JobConfigOverlay.fromFullOverlay(deploy);
    List<String> commands = new ArrayList<>();
    commands.add(jvm.getAbsolutePath());
    commands.add("-jar");
    commands.add(bundle.getAbsolutePath());
    Level traceLevel = jc.getTracing();
    if (traceLevel != null) {
        commands.add("-t");
        // -t, --trace-level=INT Trace level: 0 - OFF, 1 - ERROR, 2 - WARN,
        // 3 - INFO, 4 - DEBUG, 5 - TRACE.
        int tli = traceLevel.intValue();
        String tls;
        if (tli == Level.OFF.intValue())
            tls = "0";
        else if (tli == Level.ALL.intValue())
            tls = "5";
        else if (tli >= TraceLevel.ERROR.intValue())
            tls = "1";
        else if (tli >= TraceLevel.WARN.intValue())
            tls = "2";
        else if (tli >= TraceLevel.INFO.intValue())
            tls = "3";
        else if (tli >= TraceLevel.DEBUG.intValue())
            tls = "4";
        else
            tls = "5";
        commands.add(tls);
    }
    if (jc.hasSubmissionParameters()) {
        for (SubmissionParameter param : jc.getSubmissionParameters()) {
            // note: this execution path does correctly
            // handle / preserve the semantics of escaped \t and \n.
            // e.g., "\\n" is NOT treated as a newline 
            // rather it's the two char '\','n'
            commands.add(param.getName() + "=" + param.getValue());
        }
    }
    trace.info("Invoking standalone application");
    trace.info(Util.concatenate(commands));
    ProcessBuilder pb = new ProcessBuilder(commands);
    pb.inheritIO();
    for (Entry<String, String> ev : envVars.entrySet()) {
        trace.fine("Setting environment variable for standalone: " + ev.getKey() + "=" + ev.getValue());
        pb.environment().put(ev.getKey(), ev.getValue());
    }
    Process standaloneProcess = pb.start();
    return new ProcessFuture(standaloneProcess, keepBundle ? null : bundle);
}
Also used : SubmissionParameter(com.ibm.streamsx.topology.jobconfig.SubmissionParameter) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) TraceLevel(com.ibm.streams.operator.logging.TraceLevel) File(java.io.File) JobConfig(com.ibm.streamsx.topology.jobconfig.JobConfig)

Aggregations

SubmissionParameter (com.ibm.streamsx.topology.jobconfig.SubmissionParameter)2 TraceLevel (com.ibm.streams.operator.logging.TraceLevel)1 JobConfig (com.ibm.streamsx.topology.jobconfig.JobConfig)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 Level (java.util.logging.Level)1