code: private int preemptSession(SessionSchedulable schedulable,
        int maxToPreemt, long maxRunningTime) throws InvalidSessionHandle {
      Session session = schedulable.getSession();
      List<Integer> grantIds;
      synchronized (session) {
        grantIds = session.getGrantsToPreempt(maxToPreemt, maxRunningTime, type);
      }
      List<ResourceGrant> revokedGrants =
        sessionManager.revokeResource(session.getHandle(), grantIds);
      for (ResourceGrant grant : revokedGrants) {
        nodeManager.cancelGrant(
            grant.nodeName, session.getSessionId(), grant.getId());
      }
      sessionNotifier.notifyRevokeResource(
          session.getHandle(), revokedGrants, true);
      int preempted = revokedGrants.size();
      LOG.info("Preempt " + preempted + " " + type +
          " tasks for Session:" + session.getHandle());
      return preempted;
    }
docs: Preempt a session.
  @param schedulable The session.
  @param maxToPreemt Maximum number of resources to preempt.
  @param maxRunningTime Running time threshold for preemption.
  @return The number of preempted resources.
  @throws InvalidSessionHandle