com.sun.faban.harness.agent
Interface CmdAgent

All Superinterfaces:
Remote
All Known Implementing Classes:
CmdAgentImpl

public interface CmdAgent
extends Remote

The methods in this interface are the public face of CmdAgent They are used by the CmdService class in the Engine. There should be no requirement for a benchmark to access the CmdAgent object directly and thus this interface is not public.

Author:
Ramesh Ramachandran
See Also:
CmdService, CmdAgentImpl, GenericBenchmark

Method Summary
 void downloadServices(List<String> pathList)
          Downloads the files used by services and tools to the remote agent system.
<V extends Serializable>
V
exec(RemoteCallable<V> callable, String contextLocation)
          Executes the RemoteCallable on the target instance.
 CommandHandle execute(Command c, String svcPath)
          Executes a command from the remote command agent.
 String getHostName()
          Return the hostname of this machine as known to this machine itself.
 long getTime()
          Gets the time on the agent host, in millis.
 String getTmpDir()
          Obtains the tmp directory of a remote host.
 CommandHandle java(Command c, String svcPath)
          Executes a java command from the remote command agent.
 void kill()
          This method is responsible for aborting a running command.
 void setLogLevel(String name, Level level)
          Set the logging level of the Agents.
 void setTime(String gmtTimeString)
          Sets the time on the agent host, in GMT.
 boolean startAgent(Class agentClass, String ident)
          This method creates the Agent class and registers it with the registry using ident@ name.
 void updatePaths(List<String> pathList)
          Updates the paths, usually in the local command agent.
 String which(String cmd, String svcPath)
          Similar to the which shell command, 'which' returns the actual path to the given command.
 

Method Detail

getHostName

String getHostName()
                   throws RemoteException
Return the hostname of this machine as known to this machine itself. This method is included in order to solve a naming conflict related to the names of the result files to be transferred to the the master machine.

Returns:
The host name on this agent
Throws:
RemoteException - A communications error occurred

getTmpDir

String getTmpDir()
                 throws RemoteException
Obtains the tmp directory of a remote host.

Returns:
The tmp directory.
Throws:
RemoteException - A communications error occurred

setLogLevel

void setLogLevel(String name,
                 Level level)
                 throws RemoteException
Set the logging level of the Agents.

Parameters:
name - The name of the logger
level - The log level
Throws:
RemoteException - A communications error occurred

updatePaths

void updatePaths(List<String> pathList)
                 throws RemoteException
Updates the paths, usually in the local command agent.

Parameters:
pathList - The list of paths to download
Throws:
RemoteException - If there is an error updating the paths

downloadServices

void downloadServices(List<String> pathList)
                      throws RemoteException
Downloads the files used by services and tools to the remote agent system.

Parameters:
pathList - The list of service bundle paths
Throws:
RemoteException - If there is an error downloading

which

String which(String cmd,
             String svcPath)
             throws RemoteException
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 for
svcPath - 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

execute

CommandHandle execute(Command c,
                      String svcPath)
                      throws IOException,
                             InterruptedException,
                             RemoteException
Executes a command from the remote command agent.

Parameters:
c - The command to be executed
svcPath -
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

CommandHandle java(Command c,
                   String svcPath)
                   throws IOException,
                          InterruptedException,
                          RemoteException
Executes a java command from the remote command agent.

Parameters:
c - The command containing the main class
svcPath -
Returns:
A handle to the command
Throws:
IOException - Error communicating with resulting process
InterruptedException - Thread got interrupted waiting
RemoteException

exec

<V extends Serializable> V exec(RemoteCallable<V> callable,
                                String contextLocation)
                            throws Exception
Executes the RemoteCallable on the target instance.

Parameters:
callable - The callable to execute
contextLocation - The context location of the invoker
Returns:
The type specified at creation of the callable.
Throws:
Exception - Any exception from the callable

startAgent

boolean startAgent(Class agentClass,
                   String ident)
                   throws Exception
This method creates the Agent class and registers it with the registry using ident@ name.

Parameters:
agentClass - Impl class of the Agent to be started
ident - Identifier to be used
Returns:
true if the initialization was successful
Throws:
Exception - An error occurred

kill

void kill()
          throws RemoteException
This method is responsible for aborting a running command.

Throws:
RemoteException - A communications error occurred

setTime

void setTime(String gmtTimeString)
             throws IOException
Sets the time on the agent host, in GMT.

Parameters:
gmtTimeString -
Throws:
IOException - A I/O error occurred

getTime

long getTime()
             throws RemoteException
Gets the time on the agent host, in millis.

Returns:
The time on the remote system.
Throws:
RemoteException - A communications error occurred