public abstract class Platform extends Object
| Constructor and Description |
|---|
Platform() |
| Modifier and Type | Method and Description |
|---|---|
protected int |
bgexec(String[] cmdarray,
File workdir,
File logfile)
Starts execution of the specified command and arguments in a separate
detached process in the specified
working directory writing output to the specified log file.
|
protected int |
bgexec(String command,
File workdir,
File logfile)
Starts execution of the specified string command in a separate
detached process in the specified
working directory writing output to the specified log file.
|
protected abstract int |
bgexecInternal(String[] cmdarray,
String workdir,
String logfile)
Starts a background command writing its stdout and stderr to
the specified log file.
|
protected void |
checkPid(int pid)
Checks to make sure that we are operating on a valid process id.
|
protected abstract void |
dumpHeap(int pid,
String userDir,
String options)
Tells a process to dump heap
|
protected abstract boolean |
exists(int pid)
Find out if a process exists.
|
protected String |
fgexec(String[] command,
int maxWaitSec) |
protected int |
fgexec(String[] cmdArray,
String[] output,
File workdir)
Starts a foreground process, waits for it to complete,
and returns the exit status.
|
protected String |
fgexec(String command,
int maxWaitSec) |
protected String |
fgexec(String command,
String[] envp,
int maxWaitSec) |
protected abstract String |
getCommentPrefix()
Returns the comment prefix for shell scripts.
|
protected abstract String[] |
getDumpHeapCommand(int pid,
String userDir,
String options) |
protected abstract String |
getDumpLocksCommand(int pid) |
protected abstract String |
getFileExtension()
Returns the file extension for shell scripts.
|
protected static Platform |
getInstance() |
protected abstract String |
getKillCommand(int pid) |
protected abstract String |
getMemoryStatus(int maxWaitSec)
Returns the memory status.
|
protected abstract String |
getNetcontrolCommand(String target,
int op) |
protected abstract String |
getNetworkStatistics(int maxWaitSec)
Returns network statistics.
|
protected abstract String |
getPrintStacksCommand(int pid) |
protected abstract String |
getProcessStatus(int maxWaitSec)
Returns the process status.
|
protected abstract String |
getScriptHeader()
Returns the header for shell scripts.
|
protected abstract String |
getShutdownCommand(int pid) |
protected String |
getStackTrace(Throwable t) |
protected static String |
getString(String[] s) |
protected abstract void |
kill(int pid)
Kills a process.
|
protected abstract void |
printStacks(int pid)
Tells a process to print its stacks to its standard output
|
protected abstract void |
restartNTP()
Uses NTP to synchronize the local clock with the network time server.
|
protected abstract void |
setExecutePermission(String fn)
Gives user execute permission to the file.
|
protected abstract void |
setReadPermission(String dir)
Gives universal read permission to all files in the directory.
|
protected abstract void |
shutdown(int pid) |
protected static final String SSH
protected static Platform getInstance()
protected int fgexec(String[] cmdArray, String[] output, File workdir) throws IOException
cmdArray - the command to run.HydraRuntimeException - if a process cannot be created or
its exit code is non-zero.IOExceptionprotected int bgexec(String command, File workdir, File logfile) throws IOException
command - a specified system command.workdir - the current directory of the created process; null
causes working directory to default to the current directory.logfile - the file the created process will write
stdout and stderr to; null causes a default log file name
to be used.SecurityException - if the current thread cannot create a
subprocess.IOExceptionprotected int bgexec(String[] cmdarray, File workdir, File logfile) throws IOException
If there is a security manager, its checkExec method
is called with the first component of the array
cmdarray as its argument. This may result in a security
exception.
Given an array of strings cmdarray, representing the
tokens of a command line,
this method creates a new process in which to execute
the specified command.
cmdarray - array containing the command to call and its arguments.workdir - the current directory of the created process; null
causes working directory to default to the current directory.logfile - the file the created process will write
stdout and stderr to; null causes a default log file name
to be used.SecurityException - if the current thread cannot create a
subprocess.IOExceptionSecurityException,
SecurityManager.checkExec(java.lang.String)protected abstract int bgexecInternal(String[] cmdarray, String workdir, String logfile) throws IOException
cmdarray - An array of strings that specify the command to run.
The first element must be the executable.
Each additional command line argument should have its own entry
in the array.workdir - the current directory of the created processlogfile - the file the created process will write
stdout and stderr to.IOException - if a child process could not be created.protected void checkPid(int pid)
pid 0 or -1 can
have unintended consequences.IllegalArgumentException - If pid is not positiveprotected abstract boolean exists(int pid)
pid - the id of the process to check forprotected abstract void shutdown(int pid)
pid - the id of the process to shutdownprotected abstract void kill(int pid)
pid - the id of the process to shutdownprotected abstract void printStacks(int pid)
pid - the id of the process that will print its stacksprotected abstract void dumpHeap(int pid,
String userDir,
String options)
pid - the id of the process that will print its stacksprotected abstract String getNetworkStatistics(int maxWaitSec)
protected abstract String getShutdownCommand(int pid)
protected abstract String getKillCommand(int pid)
protected abstract String getDumpLocksCommand(int pid)
protected abstract String getPrintStacksCommand(int pid)
protected abstract String[] getDumpHeapCommand(int pid, String userDir, String options)
protected abstract void restartNTP()
protected abstract String getFileExtension()
protected abstract String getScriptHeader()
protected abstract String getCommentPrefix()
protected abstract void setExecutePermission(String fn)
protected abstract void setReadPermission(String dir)
protected abstract String getProcessStatus(int maxWaitSec)
protected abstract String getMemoryStatus(int maxWaitSec)
Copyright © 2010-2015 Pivotal Software, Inc. All rights reserved.