org.apache.hcatalog.templeton
Class ExecServiceImpl

Object
  extended by ExecServiceImpl
All Implemented Interfaces:
ExecService

public class ExecServiceImpl
extends Object
implements ExecService

Execute a local program. This is a singleton service that will execute programs as non-privileged users on the local box. See ExecService.run and ExecService.runUnlimited for details.


Method Summary
 Map<String,String> execEnv(Map<String,String> env)
          Build the environment used for all exec calls.
static ExecServiceImpl getInstance()
          Retrieve the singleton.
 ExecBean run(String program, List<String> args, Map<String,String> env)
          Run the program synchronously as the given user.
 ExecBean runUnlimited(String program, List<String> args, Map<String,String> env)
          Run the program synchronously as the given user.
 String validateProgram(String path)
          Given a program name, lookup the fully qualified path.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ExecServiceImpl getInstance()
Retrieve the singleton.


run

public ExecBean run(String program,
                    List<String> args,
                    Map<String,String> env)
             throws NotAuthorizedException,
                    BusyException,
                    ExecuteException,
                    IOException
Run the program synchronously as the given user. We rate limit the number of processes that can simultaneously created for this instance.

Specified by:
run in interface ExecService
Parameters:
program - The program to run
args - Arguments to pass to the program
env - Any extra environment variables to set
Returns:
The result of the run.
Throws:
NotAuthorizedException
BusyException
ExecuteException
IOException

runUnlimited

public ExecBean runUnlimited(String program,
                             List<String> args,
                             Map<String,String> env)
                      throws NotAuthorizedException,
                             ExecuteException,
                             IOException
Run the program synchronously as the given user. Warning: CommandLine will trim the argument strings.

Specified by:
runUnlimited in interface ExecService
Parameters:
program - The program to run.
args - Arguments to pass to the program
env - Any extra environment variables to set
Returns:
The result of the run.
Throws:
NotAuthorizedException
ExecuteException
IOException

execEnv

public Map<String,String> execEnv(Map<String,String> env)
Build the environment used for all exec calls.

Returns:
The environment variables.

validateProgram

public String validateProgram(String path)
                       throws NotAuthorizedException,
                              IOException
Given a program name, lookup the fully qualified path. Throws an exception if the program is missing or not authorized.

Parameters:
path - The path of the program.
Returns:
The path of the validated program.
Throws:
NotAuthorizedException
IOException