/**
  * Convenience method for logging and safely shutting down so that we don't throw an exception up
  * to the KCL on accident.
  *
  * @param message The reason we are stopping processing.
  * @param reason An exception that caused us to want to stop processing.
  */
 private void stopProcessing(String message, Throwable reason) {
   try {
     LOG.error(message, reason);
     if (!state.equals(ProcessState.SHUTDOWN)) {
       childProcessShutdownSequence();
     }
   } catch (Throwable t) {
     LOG.error("Encountered error while trying to shutdown", t);
   }
   exit();
 }
  public ProcessState commit(final ProcessState next) throws ReportProcessingException {
    next.setInItemGroup(true);

    // fast forward to the end of the facts ..
    while (true) {
      final DefaultFlowController fc = next.getFlowController().performAdvance();
      final Group group = next.getReport().getGroup(next.getCurrentGroupIndex());
      final DefaultFlowController cfc = fc.performCommit();
      if (ProcessState.isLastItemInGroup(group, fc.getMasterRow(), cfc.getMasterRow())) {
        next.setFlowController(fc);
        next.setAdvanceHandler(PrintSummaryEndCrosstabColumnAxisHandler.HANDLER);
        break;
      } else {
        next.setFlowController(cfc);
        next.setAdvanceHandler(PrintSummaryProcessCrosstabFactHandler.HANDLER);
      }
    }

    next.setInItemGroup(false);
    return next;
  }
 public ProcessState commit(final ProcessState next) throws ReportProcessingException {
   next.setAdvanceHandler(JoinEndCrosstabColumnAxisHandler.HANDLER);
   return next;
 }
 public ProcessState advance(final ProcessState state) throws ReportProcessingException {
   final ProcessState next = state.deriveForAdvance();
   next.fireReportEvent();
   return next;
 }
 public ProcessState advance(final ProcessState state) throws ReportProcessingException {
   return state.deriveForAdvance();
 }