@Override
  protected void shutDown() throws Exception {
    LOG.debug("Stopping InputSetupService");
    eventBus.unregister(this);

    for (InputState state : inputRegistry.getRunningInputs()) {
      MessageInput input = state.getMessageInput();

      LOG.info(
          "Attempting to close input <{}> [{}].", input.getUniqueReadableId(), input.getName());

      Stopwatch s = Stopwatch.createStarted();
      try {
        input.stop();

        LOG.info(
            "Input <{}> closed. Took [{}ms]",
            input.getUniqueReadableId(),
            s.elapsed(TimeUnit.MILLISECONDS));
      } catch (Exception e) {
        LOG.error(
            "Unable to stop input <{}> [{}]: " + e.getMessage(),
            input.getUniqueReadableId(),
            input.getName());
      } finally {
        s.stop();
      }
    }
    LOG.debug("Stopped InputSetupService");
  }
Ejemplo n.º 2
0
  public InputState stop(MessageInput input) {
    InputState inputState = getRunningInputState(input.getId());

    if (inputState != null) {
      try {
        input.stop();
      } catch (Exception e) {
        LOG.warn("Stopping input <{}> failed, removing anyway: {}", input.getId(), e);
      }
      removeFromRunning(input);
      inputState.setState(InputState.InputStateType.STOPPED);
      finishedStop(inputState);
    }

    return inputState;
  }