|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.faban.harness.RunContext
public class RunContext
The RunContext provides callbacks into the harness and the run environment. All methods are static and it is suitable for static imports making calls much shorter and easier. RunContext calls are available during a run on the master. With exception to two methods, calling RunContext methods from tools or inside RemoteCallable.call() will result in a NullPointerException. The two methods callable from the agent are the local versions of RunContext.exec() and RunContext.java(). These are the signatures without a host name.
Constructor Summary | |
---|---|
RunContext()
|
Method Summary | ||
---|---|---|
static boolean |
deleteFile(String hostName,
String fileName)
Deletes a file on a remote host. |
|
static boolean |
deleteFiles(String hostName,
String dir,
FileFilter filter)
Deletes files on a target remote host. |
|
static CommandHandle |
exec(Command c)
Executes a command on the local system. |
|
static CommandHandle[] |
exec(String[] hosts,
Command c)
Executes a command on a set of remote hosts. |
|
static
|
exec(String[] hosts,
RemoteCallable<V> callable)
Execute a code block defined as a RemoteCallable on a set of remote hosts. |
|
static CommandHandle |
exec(String host,
Command c)
Executes a command on a remote host. |
|
static
|
exec(String host,
RemoteCallable<V> callable)
Execute a code block defined as a RemoteCallable on a remote host. |
|
static boolean |
exists(String hostName,
String fileName)
Checks whether the given remote file exists. |
|
static String |
getBenchmarkDir()
Obtains the benchmark deployment directory. |
|
static boolean |
getFile(String hostName,
String fileName,
String localFileName)
Gets/copies a file from a remote host. |
|
static String |
getHostName(String host)
Obtains the actual host name of a host. |
|
static String |
getMaster()
Obtains the name of the master machine. |
|
static String |
getMasterIP()
Returns the ip address of the master. |
|
static String |
getMasterIP(String agentHost)
Returns the ip address of the master's interface best used for communicating with the target host. |
|
static String |
getOutDir()
Obtains the output directory for this run. |
|
static String |
getParamFile()
Obtains the parameter/config file path for this run. |
|
static ParamRepository |
getParamRepository()
Obtains the param repository for this run. |
|
static String |
getRunId()
Obtains the full name of the run in the form benchmark.id. |
|
static String |
getRunSeq()
Obtains the sequence part of the run id. |
|
static String |
getTmpDir(String host)
Obtains the tmp directory used by Faban on the target host. |
|
static boolean |
isDirectory(String hostName,
String fileName)
Checks whether the given remote file exists and is a directory. |
|
static boolean |
isFile(String hostName,
String fileName)
Checks whether the given remote file exists and is a normal file. |
|
static CommandHandle |
java(Command java)
Executes a java command on the local system. |
|
static CommandHandle[] |
java(String[] hosts,
Command java)
Executes a java command on a set of remote hosts. |
|
static CommandHandle |
java(String host,
Command java)
Executes a java command on a remote host. |
|
static boolean |
pushFile(String fileName,
String destHost,
String destFile)
Pushes a local file on the Faban master to the remote host. |
|
static boolean |
truncateFile(String hostName,
String fileName)
Truncates a file on a remote host. |
|
static boolean |
writeFileToStream(String hostName,
String fileName,
OutputStream stream)
Reads a file from a remote host and writes the contents to a given output stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RunContext()
Method Detail |
---|
public static String getBenchmarkDir()
public static String getRunSeq()
public static String getRunId()
public static String getOutDir()
public static String getTmpDir(String host)
host
- The host to obtain the tmp dir, or null for local JVM
public static ParamRepository getParamRepository()
public static String getParamFile()
public static CommandHandle exec(Command c) throws IOException, InterruptedException
c
- The command to be executed
IOException
- Error communicating with resulting process
InterruptedException
- Thread got interrupted waitingpublic static CommandHandle exec(String host, Command c) throws IOException, InterruptedException
host
- The target machine to execute the commandc
- The command to be executed
IOException
- Error communicating with resulting process
InterruptedException
- Thread got interrupted waitingpublic static CommandHandle[] exec(String[] hosts, Command c) throws IOException, InterruptedException
hosts
- The target machines to execute the commandc
- The command to be executed
IOException
- Error communicating with resulting process
InterruptedException
- Thread got interrupted waitingpublic static CommandHandle java(Command java) throws IOException, InterruptedException
java
- The command to be executed
IOException
- Error communicating with resulting process
InterruptedException
- Thread got interrupted waitingpublic static CommandHandle java(String host, Command java) throws IOException, InterruptedException
host
- The target machine to execute the commandjava
- The command to be executed
IOException
- Error communicating with resulting process
InterruptedException
- Thread got interrupted waitingpublic static CommandHandle[] java(String[] hosts, Command java) throws IOException, InterruptedException
hosts
- The target machines to execute the commandjava
- The command to be executed
IOException
- Error communicating with resulting process
InterruptedException
- Thread got interrupted waitingpublic static <V extends Serializable> V exec(String host, RemoteCallable<V> callable) throws Exception
host
- The remote hostcallable
- The callable defining the code block
Exception
- An error occurred making the callpublic static <V extends Serializable> List<V> exec(String[] hosts, RemoteCallable<V> callable) throws Exception
hosts
- The remote hostscallable
- The callable defining the code block
Exception
- An error occurred making the callpublic static String getMaster()
public static String getMasterIP()
public static String getMasterIP(String agentHost)
agentHost
- The target host
public static String getHostName(String host)
host
- The known host name
public static boolean pushFile(String fileName, String destHost, String destFile)
fileName
- The source file namedestHost
- The destination machinedestFile
- The destination file name
public static boolean deleteFile(String hostName, String fileName)
hostName
- The remote host namefileName
- The file name
public static boolean deleteFiles(String hostName, String dir, FileFilter filter)
hostName
- The remote host namedir
- The file namefilter
- The file name filter
public static boolean truncateFile(String hostName, String fileName)
hostName
- The remote host namefileName
- The file name
public static boolean getFile(String hostName, String fileName, String localFileName)
hostName
- The remote host namefileName
- The file name on the remote hostlocalFileName
- The target file name on the local host
public static boolean exists(String hostName, String fileName)
hostName
- The host name to check.fileName
- The file name to test.
public static boolean isFile(String hostName, String fileName)
hostName
- The host name to check.fileName
- The file name to test.
public static boolean isDirectory(String hostName, String fileName)
hostName
- The host name to check.fileName
- The file name to test.
public static boolean writeFileToStream(String hostName, String fileName, OutputStream stream)
hostName
- The remote host namefileName
- The file name on the remote hoststream
- The stream to output the data to
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |