public void grantResource ( ResourceRequestInfo req , ResourceGrant grant ) { if ( deleted ) { throw new RuntimeException ( "Session: " + sessionId + " has been deleted" ) ; } removePendingRequest ( req ) ; idToGrant . put ( req . getId ( ) , grant ) ; addGrantedRequest ( req ) ; // Handle the first wait metrics synchronized ( typeToFirstWait ) { if ( ! typeToFirstWait . containsKey ( req . getType ( ) ) ) { throw new IllegalStateException ( "Impossible to get a grant prior to requesting a resource." ) ; } Long firstWait = typeToFirstWait . get ( req . getType ( ) ) ; if ( firstWait == null ) { firstWait = new Long ( ClusterManager . clock . getTime ( ) - startTime ) ; typeToFirstWait . put ( req . getType ( ) , firstWait ) ; } } }
Grant a resource to a session to satisfy a request . Update the finalized first resource type times if not already set