Now if possible, can you provide an example how we will use AtomicLongMap here as well just for my learning purpose? is there any advantage with this as compared to what we are doing as of now?
Simply getAndAdd(hostname, 1) in on failure and get(hostname) in isBlocked. It doesn't save much, but it's better to use it than write own code.
calling onSuccess: I guess you have no choice. Note that the method is most probably orders of magnitude faster than accessing a remote host.
That's called premature optimization... you're supposing it could be a bottleneck and you may be right or wrong. So keep it simple and stupid and then it's easy to analyse and easy to fix.