Пример #1
0
 private void stopIfAnyProcessDidNotStart() {
   if (!lifecycle.tryToMoveTo(State.STARTED)) {
     // stopping or stopped during startup, for instance :
     // 1. A is started
     // 2. B starts
     // 3. A crashes while B is starting
     // 4. if B was not monitored during Terminator execution, then it's an alive orphan
     stop();
     throw new IllegalStateException("Stopped during startup");
   }
 }
Пример #2
0
 private void cleanAfterTermination() {
   trace("go to STOPPED...");
   if (lifecycle.tryToMoveTo(State.STOPPED)) {
     trace("await termination of restartWatcher and hardStopWatcher...");
     // wait for restartWatcher and hardStopWatcher to cleanly stop
     awaitTermination(restartWatcher, hardStopWatcher);
     trace("restartWatcher done");
     // removing shutdown hook to avoid called stop() unnecessarily unless already in shutdownHook
     if (!systemExit.isInShutdownHook()) {
       trace("removing shutdown hook...");
       Runtime.getRuntime().removeShutdownHook(shutdownHook);
     }
     // cleanly close JavaLauncher
     closeJavaLauncher();
   }
 }
Пример #3
0
  private void startProcesses() {
    // do no start any child process if not in state INIT or RESTARTING (a stop could be in progress
    // too)
    if (lifecycle.tryToMoveTo(State.STARTING)) {
      resetFileSystem();

      // start watching for stop requested by other process (eg. orchestrator) if enabled and not
      // started yet
      if (watchForHardStop && hardStopWatcher == null) {
        hardStopWatcher = new HardStopWatcherThread();
        hardStopWatcher.start();
      }

      startAndMonitorProcesses();
      stopIfAnyProcessDidNotStart();
    }
  }
Пример #4
0
 public void restartAsync() {
   if (lifecycle.tryToMoveTo(State.RESTARTING)) {
     restartor = new RestartorThread();
     restartor.start();
   }
 }
Пример #5
0
 private void stopAsync(State stoppingState) {
   assert stoppingState == State.STOPPING || stoppingState == State.HARD_STOPPING;
   if (lifecycle.tryToMoveTo(stoppingState)) {
     terminator.start();
   }
 }