private boolean setAvailable ( NodeStatus nodeStatus , boolean isAvailable ) { synchronized ( nodeStatus ) { boolean previous = nodeStatus . isAvailable ( ) ; nodeStatus . setAvailable ( isAvailable ) ; nodeStatus . setLastChecked ( getConfig ( ) . getTime ( ) . getMilliseconds ( ) ) ; return previous ; } }
We need to distinguish the case where we re newly available and the case where we re already available . So we check the node status before we update it and return it to the caller .