In RM side, it will keep tracking on resource request status, such as how many containers that AM has requested, how many containers that RM has assigned to AM, how many containers that is pending, etc.
In AM side, it is user's code. It should keep tracking on the similar resource request status, too. If AM keeps asking the resource, eventually it will hit the queue limit/user limit, and the resources will not be allocated. Also, the allocate is a blocking call.
It will always get something back (could be nothing, some of the request resources, all request resources). AM should use this information to update the resource request status.