/** {@inheritDoc} */ @Override public String makeEscapedCompactString() { return toEscapedCompactString(new HadoopV2Counter(cntr)); }
@Override public ProcResourceValues getProcResourceValues() { pTree = pTree.getProcessTree(); long cpuTime = pTree.getCumulativeCpuTime(); long pMem = pTree.getCumulativeRssmem(); long vMem = pTree.getCumulativeVmem(); return new ProcResourceValues(cpuTime, pMem, vMem); } }
private static void maybeSignalProcessGroup(String pgrpId, int signalNum, String signalName, boolean alwaysSignal) { if (alwaysSignal || ProcessTree.isProcessGroupAlive(pgrpId)) { // signaling a process group means using a negative pid. sendSignal("-" + pgrpId, signalNum, signalName); } }
/** Destroy the process group. * @param pgrpId Process group id of to-be-killed-processes * @param sleeptimeBeforeSigkill The time to wait before sending SIGKILL * after sending SIGTERM * @param inBackground Process group is to be killed in the back ground with * a separate thread */ protected static void destroyProcessGroup(String pgrpId, long sleeptimeBeforeSigkill, boolean inBackground) { terminateProcessGroup(pgrpId); sigKill(pgrpId, true, sleeptimeBeforeSigkill, inBackground); }
/** * Sends terminate signal to all the process belonging to the passed process * group, allowing the group to gracefully exit. * * @param pgrpId process group id */ public static void terminateProcessGroup(String pgrpId) { maybeSignalProcessGroup(pgrpId, SIGTERM, SIGTERM_STR, true); }
/** * Sends terminate signal to the process, allowing it to gracefully exit. * * @param pid pid of the process to be sent SIGTERM */ public static void terminateProcess(String pid) { maybeSignalProcess(pid, SIGTERM, SIGTERM_STR, true); }
/** * Get the counter display name * @param group the counter group name for the counter * @param counter the counter name to lookup * @param defaultValue of the counter * @return the counter display name */ public static String getCounterName(String group, String counter, String defaultValue) { return getValue(group, counter, ".name", defaultValue); } }
/** * Destroy the process-tree. */ public void destroy() { destroy(true); }
/** * Return the CPU usage in % of this TaskTracker * @return CPU usage in % */ float getCpuUsageOnTT() { float cpuUsage = TaskTrackerStatus.UNAVAILABLE; if (resourceCalculatorPlugin != null) { cpuUsage = resourceCalculatorPlugin.getCpuUsage(); } return cpuUsage; }
/** {@inheritDoc} */ @Override public long getVirtualMemorySize() { readProcMemInfoFile(); return (ramSize + swapSize) * 1024; }
/** {@inheritDoc} */ @Override public long getCumulativeCpuTime() { readProcStatFile(); return cumulativeCpuTime; }
/** Destroy the process group. * @param pgrpId Process group id of to-be-killed-processes * @param sleeptimeBeforeSigkill The time to wait before sending SIGKILL * after sending SIGTERM * @param inBackground Process group is to be killed in the back ground with * a separate thread */ protected static void destroyProcessGroup(String pgrpId, long sleeptimeBeforeSigkill, boolean inBackground) { terminateProcessGroup(pgrpId); sigKill(pgrpId, true, sleeptimeBeforeSigkill, inBackground); }
/** * @return the compact stringified version of the group in the format * {(actual-name)(display-name)(value)[][][]} where [] are compact strings * for the counters within. */ public String makeEscapedCompactString() { return toEscapedCompactString(realGroup); }
/** * Sends kill signal to all process belonging to same process group, * forcefully terminating the process group. * * @param pgrpId process group id */ public static void killProcessGroup(String pgrpId) { maybeSignalProcessGroup(pgrpId, SIGKILL, SIGKILL_STR, false); }
/** * Sends SIGQUIT to process; Java programs will dump their stack to * stdout. * * @param pid process id */ public static void sigQuitProcess(String pid) { maybeSignalProcess(pid, SIGQUIT, SIGQUIT_STR, false); }
/** * Returns the compact stringified version of the counter in the format * [(actual-name)(display-name)(value)] * @return the stringified result */ public String makeEscapedCompactString() { return toEscapedCompactString(realCounter); }
/** * Sends terminate signal to all the process belonging to the passed process * group, allowing the group to gracefully exit. * * @param pgrpId process group id */ public static void terminateProcessGroup(String pgrpId) { maybeSignalProcessGroup(pgrpId, SIGTERM, SIGTERM_STR, true); }
/** * Returns the compact stringified version of the counter in the format * [(actual-name)(display-name)(value)] * @return the stringified result */ public String makeEscapedCompactString() { return toEscapedCompactString(realCounter); }
/** * Sends kill signal to all process belonging to same process group, * forcefully terminating the process group. * * @param pgrpId process group id */ public static void killProcessGroup(String pgrpId) { maybeSignalProcessGroup(pgrpId, SIGKILL, SIGKILL_STR, false); }
/** * @return the compact stringified version of the group in the format * {(actual-name)(display-name)(value)[][][]} where [] are compact strings * for the counters within. */ public String makeEscapedCompactString() { return toEscapedCompactString(realGroup); }