code: @Override
    public void cancelFlow(final ExecutableFlow exFlow, final String userId)
        throws ExecutorManagerException {
      synchronized (exFlow) {
        if (this.runningExecutions.get().containsKey(exFlow.getExecutionId())) {
          final Pair<ExecutionReference, ExecutableFlow> pair =
              this.runningExecutions.get().get(exFlow.getExecutionId());
          this.apiGateway.callWithReferenceByUser(pair.getFirst(), ConnectorParams.CANCEL_ACTION,
              userId);
        } else if (this.queuedFlows.hasExecution(exFlow.getExecutionId())) {
          this.queuedFlows.dequeue(exFlow.getExecutionId());
          this.executionFinalizer
              .finalizeFlow(exFlow, "Cancelled before dispatching to executor", null);
        } else {
          throw new ExecutorManagerException("Execution "
              + exFlow.getExecutionId() + " of flow " + exFlow.getFlowId()
              + " isn't running.");
        }
      }
    }
docs: if flows was dispatched to an executor, cancel by calling Executor else if flow is still in
  queue, remove from queue and finalize {@inheritDoc}
  
  @see azkaban.executor.ExecutorManagerAdapter#cancelFlow(azkaban.executor.ExecutableFlow,
  java.lang.String)