/** * Delegates to {@link #apply()} method. * <p> * {@inheritDoc} */ @Override public final void run() { apply(); } }
/** * Starts the ProcessStreamGrabber. */ @Override public void run() { try { BufferedReader br = new BufferedReader(new InputStreamReader(streamToGrab)); String line; while ((line = br.readLine()) != null && !isInterrupted()) { if (line.startsWith(PID_MSG_PREFIX)) pid = line.substring(PID_MSG_PREFIX.length()); else if (printC != null) printC.apply(line); } } catch (IOException e) { U.error(log, "Caught IOException while grabbing stream", e); try { // Check if process is still alive. proc.exitValue(); if (procKilledC != null) procKilledC.apply(); } catch (IllegalThreadStateException e1) { if (!interrupted()) U.error(log, "Failed to get exit value from process.", e1); } } }
/** * Kills the java process. * * @throws Exception If any problem occurred. */ public void kill() throws Exception { Process killProc = U.isWindows() ? Runtime.getRuntime().exec(new String[] {"taskkill", "/pid", pid, "/f", "/t"}) : Runtime.getRuntime().exec(new String[] {"kill", "-9", pid}); killProc.waitFor(); int exitVal = killProc.exitValue(); if (exitVal != 0) log.info(String.format("Abnormal exit value of %s for pid %s", exitVal, pid)); if (procKilledC != null) procKilledC.apply(); U.interrupt(osGrabber); U.interrupt(esGrabber); U.join(osGrabber, log); U.join(esGrabber, log); }
/** * Kills process using {@link Process#destroy()}. */ public void killProcess() { proc.destroy(); if (procKilledC != null) procKilledC.apply(); U.interrupt(osGrabber); U.interrupt(esGrabber); U.join(osGrabber, log); U.join(esGrabber, log); }
/** * Tries few times to perform some assertion. In the worst case * {@code assertion} closure will be executed {@code retries} + 1 times and * thread will spend approximately {@code retries} * {@code retryInterval} sleeping. * * @param log Log. * @param retries Number of retries. * @param retryInterval Interval between retries in milliseconds. * @param c Closure with assertion. All {@link AssertionError}s thrown * from this closure will be ignored {@code retries} times. * @throws org.apache.ignite.internal.IgniteInterruptedCheckedException If interrupted. */ @SuppressWarnings("ErrorNotRethrown") public static void retryAssert(@Nullable IgniteLogger log, int retries, long retryInterval, GridAbsClosure c) throws IgniteInterruptedCheckedException { for (int i = 0; i < retries; i++) { try { c.apply(); return; } catch (AssertionError e) { U.warn(log, "Check failed (will retry in " + retryInterval + "ms).", e); U.sleep(retryInterval); } } // Apply the last time without guarding try. c.apply(); }
/** * Delegates to {@link #apply()} method. * <p> * {@inheritDoc} */ @Override public final void run() { apply(); } }
/** * Kills the java process. * * @throws Exception If any problem occurred. */ public void kill() throws Exception { Process killProc = U.isWindows() ? Runtime.getRuntime().exec(new String[] {"taskkill", "/pid", pid, "/f", "/t"}) : Runtime.getRuntime().exec(new String[] {"kill", "-9", pid}); killProc.waitFor(); int exitVal = killProc.exitValue(); if (exitVal != 0) log.info(String.format("Abnormal exit value of %s for pid %s", exitVal, pid)); if (procKilledC != null) procKilledC.apply(); U.interrupt(osGrabber); U.interrupt(esGrabber); U.join(osGrabber, log); U.join(esGrabber, log); }
/** * Kills process using {@link Process#destroy()}. */ public void killProcess() { proc.destroy(); if (procKilledC != null) procKilledC.apply(); U.interrupt(osGrabber); U.interrupt(esGrabber); U.join(osGrabber, log); U.join(esGrabber, log); }
/** * Starts the ProcessStreamGrabber. */ @Override public void run() { try { BufferedReader br = new BufferedReader(new InputStreamReader(streamToGrab)); String line; while ((line = br.readLine()) != null && !isInterrupted()) { if (line.startsWith(PID_MSG_PREFIX)) pid = line.substring(PID_MSG_PREFIX.length()); else if (printC != null) printC.apply(line); } } catch (IOException e) { U.error(log, "Caught IOException while grabbing stream", e); try { // Check if process is still alive. proc.exitValue(); if (procKilledC != null) procKilledC.apply(); } catch (IllegalThreadStateException e1) { if (!interrupted()) U.error(log, "Failed to get exit value from process.", e1); } } }