/**
     * {@inheritDoc}
     *
     * <p>The service event queue request is enqueued in the given channel's coordinator task queue
     * so that the requests can be performed serially, rather than concurrently. If tasks to service
     * a given channel's event queue were processed concurrently, there would be many transaction
     * conflicts because servicing a channel event accesses a single per-channel data structure (the
     * channel's event queue).
     */
    public void serviceEventQueue(final byte[] channelId) {
      callStarted();
      try {
        if (logger.isLoggable(Level.FINEST)) {
          logger.log(
              Level.FINEST, "serviceEventQueue channelId:{0}", HexDumper.toHexString(channelId));
        }

        BigInteger channelIdRef = new BigInteger(1, channelId);
        TaskQueue taskQueue = coordinatorTaskQueues.get(channelIdRef);
        if (taskQueue == null) {
          TaskQueue newTaskQueue = transactionScheduler.createTaskQueue();
          taskQueue = coordinatorTaskQueues.putIfAbsent(channelIdRef, newTaskQueue);
          if (taskQueue == null) {
            taskQueue = newTaskQueue;
          }
        }
        taskQueue.addTask(
            new AbstractKernelRunnable() {
              public void run() {
                ChannelImpl.serviceEventQueue(channelId);
              }
            },
            taskOwner);

      } finally {
        callFinished();
      }
    }
    /** {@inheritDoc} */
    public void serviceEventQueue(final byte[] sessionId) {
      callStarted();
      try {
        if (logger.isLoggable(Level.FINEST)) {
          logger.log(
              Level.FINEST, "serviceEventQueue sessionId:{0}", HexDumper.toHexString(sessionId));
        }

        BigInteger sessionRefId = new BigInteger(1, sessionId);
        TaskQueue taskQueue = sessionTaskQueues.get(sessionRefId);
        if (taskQueue == null) {
          TaskQueue newTaskQueue = transactionScheduler.createTaskQueue();
          taskQueue = sessionTaskQueues.putIfAbsent(sessionRefId, newTaskQueue);
          if (taskQueue == null) {
            taskQueue = newTaskQueue;
          }
        }
        taskQueue.addTask(
            new AbstractKernelRunnable() {
              public void run() {
                ClientSessionImpl.serviceEventQueue(sessionId);
              }
            },
            taskOwner);
      } finally {
        callFinished();
      }
    }
  /**
   * Adds the tasks in the specified {@code taskList} to the specified channel's task queue. This
   * method is invoked when a context is flushed during transaction commit.
   */
  private void flushTasks(BigInteger channelId, List<KernelRunnable> taskList) {

    assert Thread.holdsLock(contextList);
    TaskQueue taskQueue = channelTaskQueues.get(channelId);
    if (taskQueue == null) {
      taskQueue = taskScheduler.createTaskQueue();
      channelTaskQueues.put(channelId, taskQueue);
    }
    for (KernelRunnable task : taskList) {
      taskQueue.addTask(task, taskOwner);
    }
  }