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 ; }
Preempt a session .