] [> out]".
IMPORTANT: There should be a single CmdService object in the
entire framework or else multiple copies of the CmdAgent
application will be spawned on the target machines.
Therefore, this class is implemented as a Singleton.
No public constructors are defined and the object cannot be cloned.
- Author:
- Ramesh Ramachandran
- See Also:
CmdAgent
,
GenericBenchmark
Field Summary |
static int |
PARALLEL
Parallel flag in FG mode. |
static int |
SEQUENTIAL
Sequential flag in FG mode. |
Method Summary |
boolean |
copy(String srcmachine,
String destmachine,
String srcfile,
String destfile,
boolean append)
Deprecated. |
boolean |
copyToStream(String srcmachine,
String srcfile,
OutputStream stream)
Copy a file from one remote machine to a stream on the master. |
boolean |
delete(String srcmachine,
String srcfile)
Deletes the file from the machine. |
boolean |
delete(String srcmachine,
String dir,
FileFilter filter)
Deletes the file from the machine based on the filter provided. |
boolean |
doesFileExist(String hostName,
String fileName)
Checks whether the given remote file exists. |
void |
downloadServices(String machine,
List<String> pathList)
Downloads files used by deploy images, especially services and tools. |
CommandHandle |
execute(Command c,
String svcPath)
Executes a command from the master's command agent. |
CommandHandle[] |
execute(String[] machines,
Command c,
String svcPath)
Executes a command from the remote command agent. |
|
execute(String[] machines,
RemoteCallable<V> callable,
String svcPath)
Executes a job on remote command agents on a list of systems. |
CommandHandle |
execute(String machine,
Command c,
String svcPath)
Executes a command from the remote command agent. |
|
execute(String machine,
RemoteCallable<V> callable,
String svcPath)
Executes a job in a remote command agent. |
boolean |
get(String srcmachine,
String srcfile,
String destfile)
Gets a remote file to the Faban master. |
static CmdService |
getHandle()
This method is the only way that an external object
can get a reference to the singleton CmdService. |
String |
getHostName(String machineName)
Returns the hostname of this machine as known to the machine
itself. |
HostRoles |
getHostRoles()
Obtains the cached HostType object. |
String |
getMaster()
Obtains the name of the master machine. |
String |
getMasterIP()
Returns the ip address of the master. |
String |
getMasterIP(String agentHost)
Returns the ip address of the master's interface best used for
communicating with the target host. |
String |
getProperty(String machine,
String propFile,
String propName)
Gets a property from a given file. |
Registry |
getRegistry()
Obtains the registry. |
String |
getTmpDir(String machine)
Obtains the temporary dircteroy for the given machine. |
void |
init()
This method is called after every run to re-initialize the data
structures that need to change from one run to another. |
boolean |
isDirectory(String hostName,
String fileName)
Checks whether the given remote file exists and is a directory. |
boolean |
isFile(String hostName,
String fileName)
Checks whether the given remote file exists and is a normal file. |
CommandHandle |
java(Command c,
String svcPath)
Executes a java command from the master's command agent. |
CommandHandle[] |
java(String[] machines,
Command c,
String svcPath)
Executes a java command from the remote command agent. |
CommandHandle |
java(String machine,
Command c,
String svcPath)
Executes a java command from the remote command agent. |
void |
kill()
Kill all commands currently running and cleanup. |
boolean |
push(String srcfile,
String destmachine,
String destfile)
Pushes a local file on the Faban master to the remote host. |
void |
setLogLevel(String name,
Level level)
Set the Log level for Agents. |
boolean |
setup(String benchName,
ParamRepository par)
This method initializes the CmdAgent RMI server processes
on the specified set of machines. |
boolean |
startAgent(String[] machines,
Class agentClass,
String identifier)
Start Agent in the specified machines. |
boolean |
startAgent(String machine,
Class agentClass,
String identifier)
Start the agent on a single machine. |
boolean |
truncate(String srcmachine,
String srcfile)
Truncates the file from the machine. |
void |
updatePaths(List<String> pathList)
Updates the paths in the local command agent. |
String[] |
which(String[] machines,
String cmd,
String svcPath)
Returns the location of this command on the target systems. |
String |
which(String cmd,
String svcPath)
Returns the location of this command on the master system. |
String |
which(String machine,
String cmd,
String svcPath)
Returns the location of this command on the target system. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SEQUENTIAL
public static final int SEQUENTIAL
- Sequential flag in FG mode.
- See Also:
- Constant Field Values
PARALLEL
public static final int PARALLEL
- Parallel flag in FG mode.
- See Also:
- Constant Field Values
getHandle
public static CmdService getHandle()
- This method is the only way that an external object
can get a reference to the singleton CmdService.
This method should not be used outside engine.
- Returns:
- reference to the single CmdService
getMaster
public String getMaster()
- Obtains the name of the master machine.
- Returns:
- The master machine name
getMasterIP
public String getMasterIP()
- Returns the ip address of the master.
- Returns:
- The ip address of the master
getMasterIP
public String getMasterIP(String agentHost)
- Returns the ip address of the master's interface best used for
communicating with the target host.
- Parameters:
agentHost
- The target host
- Returns:
- The ip address of the master
init
public void init()
- This method is called after every run to re-initialize the data
structures that need to change from one run to another.
setup
public boolean setup(String benchName,
ParamRepository par)
- This method initializes the CmdAgent RMI server processes
on the specified set of machines.
This method can be called multiple times to initialize multiple
classes of machines.
- Parameters:
benchName
- The name of the benchmarkpar
- The parameter repository
- Returns:
- true if successful, false if setup failed
getHostRoles
public HostRoles getHostRoles()
- Obtains the cached HostType object. Note that this is not a public API.
- Returns:
- The cached HostType object;
getHostName
public String getHostName(String machineName)
- Returns the hostname of this machine as known to the machine
itself. This method is included in order to solve a Naming problem
related to the names of the tpcw result files to be transferred to the
the master machine.
- Parameters:
machineName
- The target machine to check the host name
- Returns:
- The host name of the remote machine
updatePaths
public void updatePaths(List<String> pathList)
throws RemoteException
- Updates the paths in the local command agent.
- Parameters:
pathList
- The list of paths to download
- Throws:
RemoteException
- If there is a communication error to the
remote agent
downloadServices
public void downloadServices(String machine,
List<String> pathList)
throws RemoteException
- Downloads files used by deploy images, especially services and tools.
The pathList contains a list of resources in the form type/resource.
- Parameters:
machine
- The host name to initiate the downloadpathList
- The list of paths to download
- Throws:
RemoteException
- If there is a communication error to the
remote agent
which
public String which(String cmd,
String svcPath)
throws RemoteException
- Returns the location of this command on the master system.
Similar to the which shell command, 'which' returns the actual path
to the given command. If it maps to a series of commands, they will
be returned as a single string separated by spaces. Note that 'which'
does not actually try to check the underlying system for commands
in the search path. It only checks the Faban infrastructure for
existence of such a command.
- Parameters:
cmd
- The command to search forsvcPath
- The service path, if any
- Returns:
- The actual command to execute, or null if not found.
- Throws:
RemoteException
- If there is a communication error to the
remote agent
which
public String which(String machine,
String cmd,
String svcPath)
throws RemoteException
- Returns the location of this command on the target system.
Similar to the which shell command, 'which' returns the actual path
to the given command. If it maps to a series of commands, they will
be returned as a single string separated by spaces. Note that 'which'
does not actually try to check the underlying system for commands
in the search path. It only checks the Faban infrastructure for
existence of such a command.
- Parameters:
machine
- The machine to searchcmd
- The command to search forsvcPath
- The service path, if any
- Returns:
- The actual command to execute, or null if not found.
- Throws:
RemoteException
- If there is a communication error to the
remote agent
which
public String[] which(String[] machines,
String cmd,
String svcPath)
- Returns the location of this command on the target systems.
Similar to the which shell command, 'which' returns the actual path
to the given command. If it maps to a series of commands, they will
be returned as a single string separated by spaces. Note that 'which'
does not actually try to check the underlying system for commands
in the search path. It only checks the Faban infrastructure for
existence of such a command.
- Parameters:
machines
- The machines to searchcmd
- The command to search forsvcPath
- The service path, if any
- Returns:
- The actual command paths to execute, or null elements if not found.
execute
public CommandHandle execute(Command c,
String svcPath)
throws IOException,
InterruptedException
- Executes a command from the master's command agent.
- Parameters:
c
- The command to be executedsvcPath
-
- Returns:
- A handle to the command
- Throws:
IOException
- Error communicating with resulting process
InterruptedException
- Thread got interrupted waiting
RemoteException
- If there is a communication error to the
remote agent
execute
public CommandHandle execute(String machine,
Command c,
String svcPath)
throws IOException,
InterruptedException
- Executes a command from the remote command agent.
- Parameters:
machine
- The target machine to execute the commandc
- The command to be executedsvcPath
- The location of the invoking service, if any
- Returns:
- A handle to the command
- Throws:
IOException
- Error communicating with resulting process
InterruptedException
- Thread got interrupted waiting
RemoteException
- If there is a communication error to the
remote agent
execute
public CommandHandle[] execute(String[] machines,
Command c,
String svcPath)
throws IOException,
InterruptedException
- Executes a command from the remote command agent.
- Parameters:
machines
- The target machines to execute the commandc
- The command to be executedsvcPath
- The location of the invoking service, if any
- Returns:
- Handles to the command on each of the target machines
- Throws:
IOException
- Error communicating with resulting process
InterruptedException
- Thread got interrupted waiting
RemoteException
- If there is a communication error to the
remote agent
java
public CommandHandle java(Command c,
String svcPath)
throws IOException,
InterruptedException
- Executes a java command from the master's command agent.
- Parameters:
c
- The command to be executedsvcPath
- The location of the invoking service, if any
- Returns:
- A handle to the command
- Throws:
IOException
- Error communicating with resulting process
InterruptedException
- Thread got interrupted waiting
RemoteException
- If there is a communication error to the
remote agent
java
public CommandHandle java(String machine,
Command c,
String svcPath)
throws IOException,
InterruptedException
- Executes a java command from the remote command agent.
- Parameters:
machine
- The target machine to execute the commandc
- The command to be executedsvcPath
- The location of the invoking service, if any
- Returns:
- A handle to the command
- Throws:
IOException
- Error communicating with resulting process
InterruptedException
- Thread got interrupted waiting
RemoteException
- If there is a communication error to the
remote agent
java
public CommandHandle[] java(String[] machines,
Command c,
String svcPath)
throws IOException,
InterruptedException
- Executes a java command from the remote command agent.
- Parameters:
machines
- The target machines to execute the commandc
- The command to be executedsvcPath
- The location of the invoking service, if any
- Returns:
- Handles to the command on each of the target machines
- Throws:
IOException
- Error communicating with resulting process
InterruptedException
- Thread got interrupted waiting
RemoteException
- If there is a communication error to the
remote agent
execute
public <V extends Serializable> V execute(String machine,
RemoteCallable<V> callable,
String svcPath)
throws Exception
- Executes a job in a remote command agent.
- Parameters:
machine
- The host to execute the commandcallable
- The jobsvcPath
- The location of the invoking service, if any
- Returns:
- The return value of the job
- Throws:
Exception
- An error occured executing the remote job
execute
public <V extends Serializable> List<V> execute(String[] machines,
RemoteCallable<V> callable,
String svcPath)
throws Exception
- Executes a job on remote command agents on a list of systems.
- Parameters:
machines
- The host names to execute the jobcallable
- The jobsvcPath
- The location of the invoking service, if any
- Returns:
- The return values of the job, in sequence
- Throws:
Exception
- An error occurred executing the job
startAgent
public boolean startAgent(String machine,
Class agentClass,
String identifier)
throws Exception
- Start the agent on a single machine.
- Parameters:
machine
- on which command should be startedagentClass
- Impl Class of the agent to be startedidentifier
- to identify this agent later
- Returns:
- true if the command completed successfully, else false
- Throws:
Exception
- An error occurred starting the command
startAgent
public boolean startAgent(String[] machines,
Class agentClass,
String identifier)
throws Exception
- Start Agent in the specified machines.
- Parameters:
machines
- on which command should be startedagentClass
- Impl Class of the agent to be startedidentifier
- to identify this agent later
- Returns:
- true if all commands completed successfully, else false
- Throws:
Exception
- An error occurred starting the commands
getProperty
public String getProperty(String machine,
String propFile,
String propName)
throws IOException
- Gets a property from a given file.
- Parameters:
machine
- The machine namepropFile
- The property file namepropName
- The property key name
- Returns:
- The property value
- Throws:
IOException
- If there is an error accessing the config file
kill
public void kill()
- Kill all commands currently running and cleanup.
This method is called when a run must be aborted
or at the end of a benchmark run.
push
public boolean push(String srcfile,
String destmachine,
String destfile)
- Pushes a local file on the Faban master to the remote host.
- Parameters:
srcfile
- The source file name, relative to the out dirdestmachine
- The destination machinedestfile
- The destination file name
- Returns:
- true if successful, false otherwise
get
public boolean get(String srcmachine,
String srcfile,
String destfile)
- Gets a remote file to the Faban master.
- Parameters:
srcmachine
- The source machinesrcfile
- The source file namedestfile
- The destination file name, always full path
- Returns:
- true if successful, false otherwise
copy
@Deprecated
public boolean copy(String srcmachine,
String destmachine,
String srcfile,
String destfile,
boolean append)
- Deprecated.
- Copy a file from one remote machine to another
This method essentially does the work of 'rcp'
using the FileAgents on the machines.
- Parameters:
srcmachine
- - Name of source machinedestmachine
- - Name of destination machinesrcfile
- - Name of source filedestfile
- - Name of destination fileappend
- to dest file or overwrite it
- Returns:
- true/false if copy was successful/failed
getTmpDir
public String getTmpDir(String machine)
- Obtains the temporary dircteroy for the given machine.
- Parameters:
machine
- The machine name
- Returns:
- The temporary directory to use on the machine
delete
public boolean delete(String srcmachine,
String srcfile)
- Deletes the file from the machine.
- Parameters:
srcmachine
- The machine namesrcfile
- The file name
- Returns:
- true if the file has been deleted, false otherwise
delete
public boolean delete(String srcmachine,
String dir,
FileFilter filter)
- Deletes the file from the machine based on the filter provided.
- Parameters:
srcmachine
- The machine namedir
- The directory namefilter
- The file filter to use
- Returns:
- true if akk files selected by the filter has been removed
truncate
public boolean truncate(String srcmachine,
String srcfile)
- Truncates the file from the machine.
- Parameters:
srcmachine
- The machine namesrcfile
- The file name
- Returns:
- true if the file has been deleted, false otherwise
copyToStream
public boolean copyToStream(String srcmachine,
String srcfile,
OutputStream stream)
- Copy a file from one remote machine to a stream on the master.
This method essentially does the work of 'rcp'
using the FileAgents on the machines.
- Parameters:
srcmachine
- - Name of source machinesrcfile
- - Name of source filestream
- The stream to copy the content to
- Returns:
- true/false if copy was successful/failed
setLogLevel
public void setLogLevel(String name,
Level level)
- Set the Log level for Agents.
- Parameters:
name
- Logger namelevel
- Log level
getRegistry
public Registry getRegistry()
- Obtains the registry.
- Returns:
- The registry
doesFileExist
public boolean doesFileExist(String hostName,
String fileName)
- Checks whether the given remote file exists.
- Parameters:
hostName
- The host name to check.fileName
- The file name to test.
- Returns:
- true if exists, false otherwise.
isFile
public boolean isFile(String hostName,
String fileName)
- Checks whether the given remote file exists and is a normal file.
- Parameters:
hostName
- The host name to check.fileName
- The file name to test.
- Returns:
- true if file is a normal file, false otherwise.
isDirectory
public boolean isDirectory(String hostName,
String fileName)
- Checks whether the given remote file exists and is a directory.
- Parameters:
hostName
- The host name to check.fileName
- The file name to test.
- Returns:
- true if file is a directory, false otherwise.