Search in sources :

Example 1 with TraceLevel

use of com.ibm.streams.operator.logging.TraceLevel 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

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