public void run() { while (true) { Thread orderingCustomer = getCustomer(); if (orderingCustomer == null) { logger.info("Waiting for timer request."); } else { logger.info("Received timer request: " + getTimeLimit() + " ms."); } doWait(getTimeLimit()); if (shouldExit()) { logger.info("Exiting."); return; } if (getCustomer() == null) { // timer was reset before timeout logger.info("Normal operation, timer stopped."); } else if (getCustomer() == orderingCustomer) { logger.info("Timeout occurred. Destroying Process."); // OK, the serious case doDestroy(); doResetTimeLimit(); } // Else, a different customer. Just forget about old request, // and deal with new one. } } }
public ProcessTimeoutDestroyer(ExternalModule module) { this.module = module; logger = MaryUtils.getLogger(module.name() + " timer"); // The timer threads must have a higher priority than the // normal threads, in order to make sure they are processed // before any other. setPriority(getPriority() + 1); }
private synchronized void doDestroy() { Process process = getProcess(); if (process != null) { try { process.getOutputStream().close(); process.getInputStream().close(); process.getErrorStream().close(); } catch (IOException e) { logger.info("Problems destroying process: ", e); } process.destroy(); } // If process is null, it has already been destroyed. didDestroy = true; }
/** * Reset the time limit to 0. Only the thread who initiated the latest time limit can also take it back. If another thread * tries to reset the time limit, it is ignored. */ public synchronized void resetTimeLimit() { if (customer == Thread.currentThread()) { // whoever set the time limit doResetTimeLimit(); notify(); } // Any other thread trying to reset the time limit // is ignored. }
/** * Reset the time limit to 0. Only the thread who initiated the latest time limit can also take it back. If another thread * tries to reset the time limit, it is ignored. */ public synchronized void resetTimeLimit() { if (customer == Thread.currentThread()) { // whoever set the time limit doResetTimeLimit(); notify(); } // Any other thread trying to reset the time limit // is ignored. }
public void run() { while (true) { Thread orderingCustomer = getCustomer(); if (orderingCustomer == null) { logger.info("Waiting for timer request."); } else { logger.info("Received timer request: " + getTimeLimit() + " ms."); } doWait(getTimeLimit()); if (shouldExit()) { logger.info("Exiting."); return; } if (getCustomer() == null) { // timer was reset before timeout logger.info("Normal operation, timer stopped."); } else if (getCustomer() == orderingCustomer) { logger.info("Timeout occurred. Destroying Process."); // OK, the serious case doDestroy(); doResetTimeLimit(); } // Else, a different customer. Just forget about old request, // and deal with new one. } } }
public ProcessTimeoutDestroyer(ExternalModule module) { this.module = module; logger = MaryUtils.getLogger(module.name() + " timer"); // The timer threads must have a higher priority than the // normal threads, in order to make sure they are processed // before any other. setPriority(getPriority() + 1); }
/** * Reset the time limit to 0. Only the thread who initiated the latest time limit can also take it back. If another thread * tries to reset the time limit, it is ignored. */ public synchronized void resetTimeLimit() { if (customer == Thread.currentThread()) { // whoever set the time limit doResetTimeLimit(); notify(); } // Any other thread trying to reset the time limit // is ignored. }
private synchronized void doDestroy() { Process process = getProcess(); if (process != null) { try { process.getOutputStream().close(); process.getInputStream().close(); process.getErrorStream().close(); } catch (IOException e) { logger.info("Problems destroying process: ", e); } process.destroy(); } // If process is null, it has already been destroyed. didDestroy = true; }
public void run() { while (true) { Thread orderingCustomer = getCustomer(); if (orderingCustomer == null) { logger.info("Waiting for timer request."); } else { logger.info("Received timer request: " + getTimeLimit() + " ms."); } doWait(getTimeLimit()); if (shouldExit()) { logger.info("Exiting."); return; } if (getCustomer() == null) { // timer was reset before timeout logger.info("Normal operation, timer stopped."); } else if (getCustomer() == orderingCustomer) { logger.info("Timeout occurred. Destroying Process."); // OK, the serious case doDestroy(); doResetTimeLimit(); } // Else, a different customer. Just forget about old request, // and deal with new one. } } }
public ProcessTimeoutDestroyer(ExternalModule module) { this.module = module; logger = MaryUtils.getLogger(module.name() + " timer"); // The timer threads must have a higher priority than the // normal threads, in order to make sure they are processed // before any other. setPriority(getPriority() + 1); }
private synchronized void doDestroy() { Process process = getProcess(); if (process != null) { try { process.getOutputStream().close(); process.getInputStream().close(); process.getErrorStream().close(); } catch (IOException e) { logger.info("Problems destroying process: ", e); } process.destroy(); } // If process is null, it has already been destroyed. didDestroy = true; }