def update_current_state(node, state, latency = nil)
      old_unavailable = @monitored_unavailable.dup
      old_available = @monitored_available.dup

      case state
      when :unavailable
        unless @monitored_unavailable.include?(node)
          @monitored_unavailable << node
          @monitored_available.delete(node)
          write_current_monitored_state
        end
      when :available
        last_latency = @monitored_available[node]
        if last_latency.nil? || (latency - last_latency) > LATENCY_THRESHOLD
          @monitored_available[node] = latency
          @monitored_unavailable.delete(node)
          write_current_monitored_state
        end
      else
        raise InvalidNodeStateError.new(node, state)
      end
    rescue => ex
      # if an error occurs, make sure that we rollback to the old state
      @monitored_unavailable = old_unavailable
      @monitored_available = old_available
      raise
    end
def update_current_state(node, state, latency = nil)
      old_unavailable = @monitored_unavailable.dup
      old_available = @monitored_available.dup

      case state
      when :unavailable
        unless @monitored_unavailable.include?(node)
          @monitored_unavailable << node
          @monitored_available.delete(node)
          write_current_monitored_state
        end
      when :available
        last_latency = @monitored_available[node]
        if last_latency.nil? || (latency - last_latency) > LATENCY_THRESHOLD
          @monitored_available[node] = latency
          @monitored_unavailable.delete(node)
          write_current_monitored_state
        end
      else
        raise InvalidNodeStateError.new(node, state)
      end
    rescue => ex
      # if an error occurs, make sure that we rollback to the old state
      @monitored_unavailable = old_unavailable
      @monitored_available = old_available
      raise
    end
Updates the current view of the world for this particular node
 manager instance. All node managers write this state regardless
 of whether they are the master manager or not.

 @param [Node] node the node to handle
 @param [Symbol] state the node state
 @param [Integer] latency an optional latency