void releaseSimpleSlot ( SimpleSlot simpleSlot ) { synchronized ( lock ) { // try to transition to the CANCELED state. That state marks // that the releasing is in progress if ( simpleSlot . markCancelled ( ) ) { // sanity checks if ( simpleSlot . isAlive ( ) ) { throw new IllegalStateException ( "slot is still alive" ) ; } // check whether the slot is already released if ( simpleSlot . markReleased ( ) ) { LOG . debug ( "Release simple slot {}." , simpleSlot ) ; AbstractID groupID = simpleSlot . getGroupID ( ) ; SharedSlot parent = simpleSlot . getParent ( ) ; // if we have a group ID, then our parent slot is tracked here if ( groupID != null && ! allSlots . contains ( parent ) ) { throw new IllegalArgumentException ( "Slot was not associated with this SlotSharingGroup before." ) ; } int parentRemaining = parent . removeDisposedChildSlot ( simpleSlot ) ; if ( parentRemaining > 0 ) { // the parent shared slot is still alive. make sure we make it // available again to the group of the just released slot if ( groupID != null ) { // if we have a group ID, then our parent becomes available // for that group again. otherwise, the slot is part of a // co-location group and nothing becomes immediately available Map < ResourceID , List < SharedSlot > > slotsForJid = availableSlotsPerJid . get ( groupID ) ; // sanity check if ( slotsForJid == null ) { throw new IllegalStateException ( "Trying to return a slot for group " + groupID + " when available slots indicated that all slots were available." ) ; } putIntoMultiMap ( slotsForJid , parent . getTaskManagerID ( ) , parent ) ; } } else { // the parent shared slot is now empty and can be released parent . markCancelled ( ) ; internalDisposeEmptySharedSlot ( parent ) ; } } } } }
Releases the simple slot from the assignment group .