public boolean allocateSlot ( int index , JobID jobId , AllocationID allocationId , Time slotTimeout ) { checkInit ( ) ; TaskSlot taskSlot = taskSlots . get ( index ) ; boolean result = taskSlot . allocate ( jobId , allocationId ) ; if ( result ) { // update the allocation id to task slot map allocationIDTaskSlotMap . put ( allocationId , taskSlot ) ; // register a timeout for this slot since it's in state allocated timerService . registerTimeout ( allocationId , slotTimeout . getSize ( ) , slotTimeout . getUnit ( ) ) ; // add this slot to the set of job slots Set < AllocationID > slots = slotsPerJob . get ( jobId ) ; if ( slots == null ) { slots = new HashSet <> ( 4 ) ; slotsPerJob . put ( jobId , slots ) ; } slots . add ( allocationId ) ; } return result ; }
Allocate the slot with the given index for the given job and allocation id . Returns true if the slot could be allocated . Otherwise it returns false .