private static void deleteFiles(final File workingDir, final ProcessType processType) { deleteFile(workingDir, processType.getStatusRequestFileName()); deleteFile(workingDir, processType.getStatusFileName()); deleteFile(workingDir, processType.getStopRequestFileName()); }
/** * A helper method to ensure the same sequence of actions are taken when the Server fails to start * caused by some exception. * * @param cause the Throwable thrown during the startup operation on the Server. */ private void failOnStart(final Throwable cause) { if (this.cache != null) { this.cache.close(); this.cache = null; } if (this.process != null) { this.process.stop(); this.process = null; } INSTANCE.compareAndSet(this, null); this.running.set(false); }
private void work() throws IOException { try { // always delete file after invoking handler this.requestHandler.handleRequest(); } finally { try { this.file.delete(); } catch (SecurityException e) { ControllableProcess.getOrCreateLogWriter().warning("Unable to delete " + this.file, e); } } }
this.process = new ControllableProcess(this.controlHandler, new File(getWorkingDirectory()), ProcessType.LOCATOR, isForcing());
this.pidFile = new File(this.workingDir, processType.getPidFileName()); deleteFiles(this.workingDir, processType);
this.process = new ControllableProcess(this.controlHandler, new File(getWorkingDirectory()), ProcessType.SERVER, isForcing());
this.pidFile = new File(this.workingDir, processType.getPidFileName()); deleteFiles(this.workingDir, processType);
/** * A helper method to ensure the same sequence of actions are taken when the Locator fails to start * caused by some exception. * * @param cause the Throwable thrown during the startup or wait operation on the Locator. */ private void failOnStart(final Throwable cause) { if (this.locator != null) { this.locator.stop(); this.locator = null; } if (this.process != null) { this.process.stop(); this.process = null; } INSTANCE.compareAndSet(this, null); this.running.set(false); }
this.process = new ControllableProcess(this.controlHandler, new File(getWorkingDirectory()), ProcessType.LOCATOR, isForcing());
private static void deleteFiles(final File workingDir, final ProcessType processType) { deleteFile(workingDir, processType.getStatusRequestFileName()); deleteFile(workingDir, processType.getStatusFileName()); deleteFile(workingDir, processType.getStopRequestFileName()); }
public void stop() { try { this.statusRequestFileWatchdog.stop(); } catch (InterruptedException e) { getOrCreateLogWriter().warning("Interrupted while stopping status handler for controllable process.", e); } finally { try { this.stopRequestFileWatchdog.stop(); } catch (InterruptedException e) { getOrCreateLogWriter().warning("Interrupted while stopping stop handler for controllable process.", e); } this.launcher.close(); } }
/** * A helper method to ensure the same sequence of actions are taken when the Locator fails to start * caused by some exception. * * @param cause the Throwable thrown during the startup or wait operation on the Locator. */ private void failOnStart(final Throwable cause) { if (this.locator != null) { this.locator.stop(); this.locator = null; } if (this.process != null) { this.process.stop(); this.process = null; } INSTANCE.compareAndSet(this, null); this.running.set(false); }
process = new ControllableProcess(this.controlHandler, new File(getWorkingDirectory()), ProcessType.SERVER, isForcing());
statusFileWatchdog.stop(); } catch (InterruptedException e) { ControllableProcess.getOrCreateLogWriter().info("Interrupted while stopping status file watchdog.", e); } catch (RuntimeException e) { ControllableProcess.getOrCreateLogWriter().info("Unexpected failure while stopping status file watchdog.", e);
/** * A helper method to ensure the same sequence of actions are taken when the Server fails to start * caused by some exception. * * @param cause the Throwable thrown during the startup operation on the Server. */ private void failOnStart(final Throwable cause) { if (this.cache != null) { this.cache.close(); this.cache = null; } if (this.process != null) { this.process.stop(); this.process = null; } INSTANCE.compareAndSet(this, null); this.running.set(false); }
@Override public void run() { try { // always set this.alive before stopping while (isAlive()) { try { // handle handle exceptions Thread.sleep(SLEEP_MILLIS); if (this.file.exists()) { try { // always check stopAfterRequest after main work work(); } finally { if (this.stopAfterRequest) { stopMe(); } } } } catch (InterruptedException e) { Thread.currentThread().interrupt(); // allow to loop around and check isAlive() } catch (IOException e) { ControllableProcess.getOrCreateLogWriter().error("Unable to control process with " + this.file + ". Please add tools.jar from JDK to classpath for improved process control."); // allow to loop around and check isAlive() } } } finally { synchronized (this) { this.alive = false; } } }
private LocatorState stopInProcess() { if (isStoppable()) { this.locator.stop(); this.locator = null; this.process.stop(); this.process = null; INSTANCE.compareAndSet(this, null); // note: other thread may return Status.NOT_RESPONDING now this.running.set(false); return new LocatorState(this, Status.STOPPED); } else { return new LocatorState(this, Status.NOT_RESPONDING); } }
private ServerState stopInProcess() { if (isStoppable()) { this.cache.close(); this.cache = null; this.process.stop(); this.process = null; INSTANCE.compareAndSet(this, null); // note: other thread may return Status.NOT_RESPONDING now this.running.set(false); return new ServerState(this, Status.STOPPED); } else { return new ServerState(this, Status.NOT_RESPONDING); } }
private ServerState stopInProcess() { if (isStoppable()) { this.cache.close(); this.cache = null; this.process.stop(); this.process = null; INSTANCE.compareAndSet(this, null); // note: other thread may return Status.NOT_RESPONDING now this.running.set(false); return new ServerState(this, Status.STOPPED); } else { return new ServerState(this, Status.NOT_RESPONDING); } }
private LocatorState stopInProcess() { if (isStoppable()) { this.locator.stop(); this.locator = null; this.process.stop(); this.process = null; INSTANCE.compareAndSet(this, null); // note: other thread may return Status.NOT_RESPONDING now this.running.set(false); return new LocatorState(this, Status.STOPPED); } else { return new LocatorState(this, Status.NOT_RESPONDING); } }