Interface ScriptExecHelper


  • public interface ScriptExecHelper
    Helper interface for ScriptExec utility. Created by greg on 1/23/15.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      ExecArgList createScriptArgList​(java.lang.String filepath, java.lang.String scriptargs, java.lang.String[] scriptargsarr, java.lang.String scriptinterpreter, boolean interpreterargsquoted)
      Generate argument array for a script file invocation
      java.lang.String[] createScriptArgs​(java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.String>> localDataContext, INodeEntry node, java.lang.String scriptargs, java.lang.String[] scriptargsarr, java.lang.String scriptinterpreter, boolean interpreterargsquoted, java.lang.String filepath)
      Generate argument array for a script file invocation on a specific node
      java.lang.String[] createScriptArgs​(java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.String>> localDataContext, java.lang.String scriptargs, java.lang.String[] scriptargsarr, java.lang.String scriptinterpreter, boolean interpreterargsquoted)
      Generate argument array for invocation without the filepath
      java.lang.String[] createScriptArgs​(java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.String>> localDataContext, java.lang.String scriptargs, java.lang.String[] scriptargsarr, java.lang.String scriptinterpreter, boolean interpreterargsquoted, java.lang.String filepath)
      Generate argument array for a script file invocation
      java.util.Map<java.lang.String,​java.lang.String> loadLocalEnvironment()  
      int runLocalCommand​(java.lang.String[] command, java.util.Map<java.lang.String,​java.lang.String> envMap, java.io.File workingdir, java.io.OutputStream outputStream, java.io.OutputStream errorStream)
      Run a command with environment variables in a working dir, and copy the streams
      int runLocalCommand​(java.lang.String osFamily, ExecArgList execArgList, java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.String>> dataContext, java.io.File workingdir, java.io.OutputStream outputStream, java.io.OutputStream errorStream)
      Run a command with environment variables in a working dir, and copy the streams
    • Method Detail

      • runLocalCommand

        int runLocalCommand​(java.lang.String osFamily,
                            ExecArgList execArgList,
                            java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.String>> dataContext,
                            java.io.File workingdir,
                            java.io.OutputStream outputStream,
                            java.io.OutputStream errorStream)
                     throws java.io.IOException,
                            java.lang.InterruptedException
        Run a command with environment variables in a working dir, and copy the streams
        Parameters:
        osFamily - local node os family
        execArgList - the ExecArgList to run
        workingdir - optional working dir location (or null)
        outputStream - stream for stdout
        errorStream - stream for stderr
        dataContext - data
        Returns:
        the exit code of the command
        Throws:
        java.io.IOException - if any IO exception occurs
        java.lang.InterruptedException - if interrupted while waiting for the command to finish
      • runLocalCommand

        int runLocalCommand​(java.lang.String[] command,
                            java.util.Map<java.lang.String,​java.lang.String> envMap,
                            java.io.File workingdir,
                            java.io.OutputStream outputStream,
                            java.io.OutputStream errorStream)
                     throws java.io.IOException,
                            java.lang.InterruptedException
        Run a command with environment variables in a working dir, and copy the streams
        Parameters:
        command - the command array to run
        envMap - the environment variables to pass in
        workingdir - optional working dir location (or null)
        outputStream - stream for stdout
        errorStream - stream for stderr
        Returns:
        the exit code of the command
        Throws:
        java.io.IOException - if any IO exception occurs
        java.lang.InterruptedException - if interrupted while waiting for the command to finish
      • createScriptArgs

        java.lang.String[] createScriptArgs​(java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.String>> localDataContext,
                                            java.lang.String scriptargs,
                                            java.lang.String[] scriptargsarr,
                                            java.lang.String scriptinterpreter,
                                            boolean interpreterargsquoted,
                                            java.lang.String filepath)
        Generate argument array for a script file invocation
        Parameters:
        localDataContext - data context properties to expand among the args
        scriptargs - arguments to the script file
        scriptargsarr - arguments to the script file as an array
        scriptinterpreter - interpreter invocation for the file, or null to invoke it directly
        interpreterargsquoted - if true, pass the script file and args as a single argument to the interpreter
        filepath - remote filepath for the script
        Returns:
        args
      • createScriptArgs

        java.lang.String[] createScriptArgs​(java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.String>> localDataContext,
                                            java.lang.String scriptargs,
                                            java.lang.String[] scriptargsarr,
                                            java.lang.String scriptinterpreter,
                                            boolean interpreterargsquoted)
        Generate argument array for invocation without the filepath
        Parameters:
        localDataContext - data context properties to expand among the args
        scriptargs - arguments to the script file
        scriptargsarr - arguments to the script file as an array
        scriptinterpreter - interpreter invocation for the file, or null to invoke it directly
        interpreterargsquoted - if true, pass the script file and args as a single argument to the interpreter
        Returns:
        args
      • createScriptArgs

        java.lang.String[] createScriptArgs​(java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.String>> localDataContext,
                                            INodeEntry node,
                                            java.lang.String scriptargs,
                                            java.lang.String[] scriptargsarr,
                                            java.lang.String scriptinterpreter,
                                            boolean interpreterargsquoted,
                                            java.lang.String filepath)
        Generate argument array for a script file invocation on a specific node
        Parameters:
        localDataContext - data context properties to expand among the args
        node - node to use for os-family argument quoting.
        scriptargs - arguments to the script file
        scriptargsarr - arguments to the script file as an array
        scriptinterpreter - interpreter invocation for the file, or null to invoke it directly
        interpreterargsquoted - if true, pass the script file and args as a single argument to the interpreter
        filepath - remote filepath for the script
        Returns:
        args
      • createScriptArgList

        ExecArgList createScriptArgList​(java.lang.String filepath,
                                        java.lang.String scriptargs,
                                        java.lang.String[] scriptargsarr,
                                        java.lang.String scriptinterpreter,
                                        boolean interpreterargsquoted)
        Generate argument array for a script file invocation
        Parameters:
        filepath - remote filepath for the script
        scriptargs - arguments to the script file
        scriptargsarr - arguments to the script file as an array
        scriptinterpreter - interpreter invocation for the file, or null to invoke it directly, can include ${scriptfile}
        interpreterargsquoted - if true, pass the script file and args as a single argument to the interpreter
        Returns:
        arg list
      • loadLocalEnvironment

        java.util.Map<java.lang.String,​java.lang.String> loadLocalEnvironment()