@ Override public Optional < ResourceID > failAllocation ( final AllocationID allocationID , final Exception cause ) { componentMainThreadExecutor . assertRunningInMainThread ( ) ; final PendingRequest pendingRequest = pendingRequests . removeKeyB ( allocationID ) ; if ( pendingRequest != null ) { // request was still pending failPendingRequest ( pendingRequest , cause ) ; return Optional . empty ( ) ; } else { return tryFailingAllocatedSlot ( allocationID , cause ) ; } // TODO: add some unit tests when the previous two are ready, the allocation may failed at any phase }
Fail the specified allocation and release the corresponding slot if we have one . This may triggered by JobManager when some slot allocation failed with rpcTimeout . Or this could be triggered by TaskManager when it finds out something went wrong with the slot and decided to take it back .