private Object handleAll(InvocationContext ctx, VisitableCommand command) throws Throwable {
    boolean suppressExceptions = false;
    try {
      ComponentStatus status = componentRegistry.getStatus();
      if (command.ignoreCommandOnStatus(status)) {
        log.debugf("Status: %s : Ignoring %s command", status, command);
        return null;
      }

      if (status.isTerminated()) {
        throw new IllegalStateException(
            String.format(
                "%s is in 'TERMINATED' state and so it does not accept new invocations. "
                    + "Either restart it or recreate the cache container.",
                getCacheNamePrefix()));
      } else if (stoppingAndNotAllowed(status, ctx)) {
        throw new IllegalStateException(
            String.format(
                "%s is in 'STOPPING' state and this is an invocation not belonging to an on-going transaction, so it does not accept new invocations. "
                    + "Either restart it or recreate the cache container.",
                getCacheNamePrefix()));
      }

      LogFactory.pushNDC(componentRegistry.getCacheName(), trace);

      try {
        if (trace) log.tracef("Invoked with command %s and InvocationContext [%s]", command, ctx);
        if (ctx == null) throw new IllegalStateException("Null context not allowed!!");

        if (ctx.hasFlag(Flag.FAIL_SILENTLY)) {
          suppressExceptions = true;
        }

        try {
          return invokeNextInterceptor(ctx, command);
        } catch (Throwable th) {
          // If we are shutting down there is every possibility that the invocation fails.
          suppressExceptions = suppressExceptions || shuttingDown;
          if (suppressExceptions) {
            if (shuttingDown)
              log.trace(
                  "Exception while executing code, but we're shutting down so failing silently.");
            else log.trace("Exception while executing code, failing silently...", th);
            return null;
          } else {
            // HACK: There are way too many StateTransferInProgressExceptions on remote nodes during
            // state transfer
            // and they not really exceptional (the originator will retry the command)
            boolean logAsError =
                !(th instanceof StateTransferInProgressException && !ctx.isOriginLocal());
            if (logAsError) {
              log.executionError(th);
            } else {
              log.trace("Exception while executing code", th);
            }
            if (ctx.isInTxScope() && ctx.isOriginLocal()) {
              if (trace) log.trace("Transaction marked for rollback as exception was received.");
              markTxForRollbackAndRethrow(ctx, th);
              throw new IllegalStateException("This should not be reached");
            }
            throw th;
          }
        } finally {
          ctx.reset();
        }
      } finally {
        LogFactory.popNDC(trace);
      }
    } finally {
      invocationContextContainer.clearThreadLocal();
    }
  }
  private Object handleAll(InvocationContext ctx, VisitableCommand command) throws Throwable {
    try {
      ComponentStatus status = componentRegistry.getStatus();
      if (command.ignoreCommandOnStatus(status)) {
        log.debugf("Status: %s : Ignoring %s command", status, command);
        return null;
      }

      if (status.isTerminated()) {
        throw log.cacheIsTerminated(getCacheNamePrefix());
      } else if (stoppingAndNotAllowed(status, ctx)) {
        throw log.cacheIsStopping(getCacheNamePrefix());
      }

      LogFactory.pushNDC(componentRegistry.getCacheName(), trace);

      invocationContextContainer.setThreadLocal(ctx);
      try {
        if (trace) log.tracef("Invoked with command %s and InvocationContext [%s]", command, ctx);
        if (ctx == null) throw new IllegalStateException("Null context not allowed!!");

        try {
          return invokeNextInterceptor(ctx, command);
        } catch (InvalidCacheUsageException ex) {
          throw ex; // Propagate back client usage errors regardless of flag
        } catch (Throwable th) {
          // Only check for fail silently if there's a failure :)
          boolean suppressExceptions =
              (command instanceof FlagAffectedCommand)
                  && ((FlagAffectedCommand) command).hasFlag(Flag.FAIL_SILENTLY);
          // If we are shutting down there is every possibility that the invocation fails.
          suppressExceptions = suppressExceptions || shuttingDown;
          if (suppressExceptions) {
            if (shuttingDown)
              log.trace(
                  "Exception while executing code, but we're shutting down so failing silently.",
                  th);
            else log.trace("Exception while executing code, failing silently...", th);
            return null;
          } else {
            if (th instanceof WriteSkewException) {
              // We log this as DEBUG rather than ERROR - see ISPN-2076
              log.debug("Exception executing call", th);
            } else if (th instanceof OutdatedTopologyException) {
              log.outdatedTopology(th);
            } else {
              Collection<Object> affectedKeys = extractWrittenKeys(ctx, command);
              log.executionError(command.getClass().getSimpleName(), affectedKeys, th);
            }
            if (ctx.isInTxScope() && ctx.isOriginLocal()) {
              if (trace) log.trace("Transaction marked for rollback as exception was received.");
              markTxForRollbackAndRethrow(ctx, th);
              throw new IllegalStateException("This should not be reached");
            }
            throw th;
          }
        }
      } finally {
        LogFactory.popNDC(trace);
      }
    } finally {
      invocationContextContainer.clearThreadLocal();
    }
  }