public class RunContext extends Object
Constructor and Description |
---|
RunContext() |
Modifier and Type | Method and Description |
---|---|
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 <V extends Serializable> |
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 <V extends Serializable> |
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 String |
which(String c)
Returns the location of this command on the local system.
|
static String[] |
which(String[] hosts,
String c)
Returns the location of this command on the target systems.
|
static String |
which(String host,
String c)
Returns the location of this command on the target system.
|
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.
|
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 JVMpublic static ParamRepository getParamRepository()
public static String getParamFile()
public static String which(String c) throws IOException
c
- The command to search forIOException
- If there is a communication error to the
remote agentpublic static String which(String host, String c) throws IOException
host
- The host to searchc
- The command to search forIOException
- If there is a communication error to the
remote agentpublic static String[] which(String[] hosts, String c)
hosts
- The hosts to searchc
- The command to search forpublic static CommandHandle exec(Command c) throws IOException, InterruptedException
c
- The command to be executedIOException
- Error communicating with resulting processInterruptedException
- 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 executedIOException
- Error communicating with resulting processInterruptedException
- 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 executedIOException
- Error communicating with resulting processInterruptedException
- Thread got interrupted waitingpublic static CommandHandle java(Command java) throws IOException, InterruptedException
java
- The command to be executedIOException
- Error communicating with resulting processInterruptedException
- 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 executedIOException
- Error communicating with resulting processInterruptedException
- 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 executedIOException
- Error communicating with resulting processInterruptedException
- 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 blockException
- 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 blockException
- An error occurred making the callpublic static String getMaster()
public static String getMasterIP()
public static String getMasterIP(String agentHost)
agentHost
- The target hostpublic static String getHostName(String host)
host
- The known host namepublic static boolean pushFile(String fileName, String destHost, String destFile)
fileName
- The source file namedestHost
- The destination machinedestFile
- The destination file namepublic static boolean deleteFile(String hostName, String fileName)
hostName
- The remote host namefileName
- The file namepublic static boolean deleteFiles(String hostName, String dir, FileFilter filter)
hostName
- The remote host namedir
- The file namefilter
- The file name filterpublic static boolean truncateFile(String hostName, String fileName)
hostName
- The remote host namefileName
- The file namepublic 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 hostpublic 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