public class ProcessMgr extends Object
| Constructor and Description |
|---|
ProcessMgr() |
| Modifier and Type | Method and Description |
|---|---|
static int |
bgexec(String command)
Starts a background process on the local host and returns the PID.
|
static int |
bgexec(String host,
String command)
Starts a background process on the specified host and returns the PID.
|
static int |
bgexec(String command,
String workdir,
String logfile)
Starts a background process on the local host and returns the PID.
|
static int |
bgexec(String host,
String command,
String workdir,
String logfile)
Starts a background process on the specified host and returns the PID.
|
static void |
dumpHeap(String host,
int pid,
String userDir,
String options)
Does a heap dump on a process.
|
static String |
fgexec(String[] command,
int maxWaitSec)
Starts a foreground process on the local host, waits for it to complete,
and returns the output.
|
static String |
fgexec(String command,
int maxWaitSec)
Starts a foreground process on the local host, waits for it to complete,
and returns the output.
|
static String |
fgexec(String command,
String[] envp,
int maxWaitSec)
Starts a foreground process on the local host, waits for it to complete,
and returns the output.
|
static String |
fgexec(String host,
String command,
int maxWaitSec)
Starts a foreground process on the specified host, waits for it to complete,
and returns the output.
|
static String |
fgexec(String host,
String command,
String[] envp,
int maxWaitSec)
Starts a foreground process on the specified host, waits for it to complete,
and returns the output.
|
static String |
getMemoryStatus(int maxWaitSec)
Returns the memory usage for the local host.
|
static int |
getProcessId()
Returns the process ID for this process.
|
static String |
getProcessStatus(int maxWaitSec)
Returns the process status for the local host (for all users).
|
static String |
getProcessStatus(String host,
int maxWaitSec)
Returns the process status for the given host (for all users).
|
static void |
killProcess(String host,
int pid)
Kills a process without warning.
|
static boolean |
killProcessWait(String host,
int pid,
int maxWaitSec)
Kills a process without warning and waits up to
maxWaitSec for this
to occur. |
static void |
logNetworkStatistics()
Logs network statistics.
|
static void |
printProcessStacks(String host,
int pid)
Does a thread stack dump on a process.
|
static String |
processAndBuildInfoString()
Returns a formatted
String containing various information about
the runtime environment of this process: host, PID, user name, user.name,
user.home, user.dir, os.name, os.arch, os.version, java.version,
java.vm.vendor, java.home, java.class.path, and java.library.path. |
static boolean |
processExists(String host,
int pid)
Tests whether a process exists.
|
static void |
setReadPermission(String dir)
Gives read permission on all files in the given directory to all users.
|
static void |
shutdownProcess(String host,
int pid)
Tells a process to shut down.
|
static boolean |
shutdownProcessWait(String host,
int pid,
int maxWaitSec)
Tells a process to shut down and waits up to
maxWaitSec for this
to occur. |
static boolean |
waitForDeath(String host,
int pid,
int maxWaitSec)
Waits up to
maxWaitSec for a process to die. |
static boolean |
waitForLife(String host,
int pid,
int maxWaitSec)
Waits up to
maxWaitSec for a process to live. |
public static int getProcessId()
Uses the RuntimeMXBean. There is no guarantee that this returns a PID, but it currently works on all platforms supported by hydra.
HydraRuntimeException - if there is a problem getting the PID
from the RuntimeMXBeanpublic static String fgexec(String command, int maxWaitSec)
host - the host on which to start the process.command - the command to run.maxWaitSec - the maximum amount of time to wait before timing out.HydraRuntimeException - if the process cannot be created
or its exit code is non-zero.HydraTimeoutException - if the command times out.public static String fgexec(String command, String[] envp, int maxWaitSec)
host - the host on which to start the process.command - the command to run.envp - the environment for the command.maxWaitSec - the maximum amount of time to wait before timing out.HydraRuntimeException - if the process cannot be created
or its exit code is non-zero.HydraTimeoutException - if the command times out.public static String fgexec(String[] command, int maxWaitSec)
host - the host on which to start the process.command - the command to run.maxWaitSec - the maximum amount of time to wait before timing out.HydraRuntimeException - if the process cannot be created
or its exit code is non-zero.HydraTimeoutException - if the command times out.public static String fgexec(String host, String command, int maxWaitSec)
host - the host on which to start the process.command - the command to run.maxWaitSec - the maximum amount of time to wait before timing out.HydraRuntimeException - if the process cannot be created
or its exit code is non-zero.HydraTimeoutException - if the command times out.public static String fgexec(String host, String command, String[] envp, int maxWaitSec)
host - the host on which to start the process.command - the command to run.envp - the environment for the command.maxWaitSec - the maximum amount of time to wait before timing out.HydraRuntimeException - if the process cannot be created
or its exit code is non-zero.HydraTimeoutException - if the command times out.public static int bgexec(String command)
bgexec_.log .command - the command to run.HydraRuntimeException - if the process cannot be created.public static int bgexec(String host, String command)
bgexec_.log .host - the host on which to start the process.command - the command to run.HydraRuntimeException - if the process cannot be created.public static int bgexec(String command, String workdir, String logfile)
command - the command to run.workdir - the user directory for the process.logfile - the name of the file containing process output.HydraRuntimeException - if the process cannot be created.public static int bgexec(String host, String command, String workdir, String logfile)
host - the host on which to start the process.command - the command to run.workdir - the user directory for the process.logfile - the name of the file containing process output.HydraRuntimeException - if the process cannot be created.public static boolean processExists(String host, int pid)
host - the host the process is running on.pid - its PID.true if the process exists.public static void shutdownProcess(String host, int pid)
host - the host the process is running on.pid - its PID.public static void killProcess(String host, int pid)
host - the host the process is running on.pid - its PID.public static void printProcessStacks(String host, int pid)
host - the host the process is running on.pid - its PID.public static void dumpHeap(String host, int pid, String userDir, String options)
host - the host the process is running on.pid - its PID.public static void logNetworkStatistics()
public static boolean shutdownProcessWait(String host, int pid, int maxWaitSec)
maxWaitSec for this
to occur. Returns false if the process still exists after this time
limit has expired, otherwise it returns true.host - the host the process is running on.pid - its PID.maxWaitSec - the maximum number of seconds to wait for the process to shut down.true if the process no longer existspublic static boolean killProcessWait(String host, int pid, int maxWaitSec)
maxWaitSec for this
to occur. Returns false if the process still exists after this time
limit has expired, otherwise it returns true.host - the host the process is running on.pid - its PID.maxWaitSec - the maximum number of seconds to wait for the process to shut down.true if the process no longer existspublic static boolean waitForDeath(String host, int pid, int maxWaitSec)
maxWaitSec for a process to die. Returns
false if the process still exists after this time limit has
expired, otherwise it returns true. The process is assumed
to have been shut down or killed elsewhere.host - the host the process is running on.pid - its PID.maxWaitSec - the maximum number of seconds to wait for the process to shut down.true if the process no longer existspublic static boolean waitForLife(String host, int pid, int maxWaitSec)
maxWaitSec for a process to live. Returns
false if the process does not exist after this time limit has
expired, otherwise it returns true. The process is assumed
to have been created elsewhere.host - the host the process is running on.pid - its PID.maxWaitSec - the maximum number of seconds to wait for the process to wake up.true if the process is alive.public static String processAndBuildInfoString()
String containing various information about
the runtime environment of this process: host, PID, user name, user.name,
user.home, user.dir, os.name, os.arch, os.version, java.version,
java.vm.vendor, java.home, java.class.path, and java.library.path.
Also includes information about the GemFire build: product version, when
it was built, who built it, what directory it was built from, the platform
it was built on, and the JDK it was build with. Most importantly, it
gives the date of the last SVN update to use in bug reports.String of information about this process.public static String getProcessStatus(int maxWaitSec)
maxWaitSec - the maximum number of seconds to wait for status.HydraRuntimeException - if the status cannot be determined.HydraTimeoutException - if the attempt to get status times out.public static String getProcessStatus(String host, int maxWaitSec)
maxWaitSec - the maximum number of seconds to wait for status.HydraRuntimeException - if the status cannot be determined.HydraTimeoutException - if the attempt to get status times out.public static String getMemoryStatus(int maxWaitSec)
maxWaitSec - the maximum number of seconds to wait for status.HydraRuntimeException - if the status cannot be determined.HydraTimeoutException - if the attempt to get status times out.public static void setReadPermission(String dir)
HydraRuntimeException - if a suitable command cannot be found.Copyright © 2010-2015 Pivotal Software, Inc. All rights reserved.