protected TaskManagerSlot findMatchingSlot ( ResourceProfile requestResourceProfile ) { Iterator < Map . Entry < SlotID , TaskManagerSlot > > iterator = freeSlots . entrySet ( ) . iterator ( ) ; while ( iterator . hasNext ( ) ) { TaskManagerSlot taskManagerSlot = iterator . next ( ) . getValue ( ) ; // sanity check Preconditions . checkState ( taskManagerSlot . getState ( ) == TaskManagerSlot . State . FREE , "TaskManagerSlot %s is not in state FREE but %s." , taskManagerSlot . getSlotId ( ) , taskManagerSlot . getState ( ) ) ; if ( taskManagerSlot . getResourceProfile ( ) . isMatching ( requestResourceProfile ) ) { iterator . remove ( ) ; return taskManagerSlot ; } } return null ; }
Finds a matching slot for a given resource profile . A matching slot has at least as many resources available as the given resource profile . If there is no such slot available then the method returns null .