After master slave switch of YarnRM, an ApplicationNotRegisteredException will be thrown from the new YarnRM. AM will re-regsiter and reset the responseId to zero. AMRMClientRelayer inside FederationInterceptor follows the same protocol, and does the automatic re-register and responseId resync. However, when exceptions or temporary network issue happens in the allocate call after re-register, the resync logic might be broken. This patch improves the robustness of the process by parsing the expected repsonseId from YarnRM exception message. So that whenever the responseId is out of sync for whatever reason, we can automatically resync and move on.