def build_clients
      @lock.synchronize do
        begin
          nodes = fetch_nodes
          return unless nodes_changed?(nodes)

          purge_clients
          logger.info("Building new clients for nodes #{nodes.inspect}")
          new_master = new_clients_for(nodes[:master]).first if nodes[:master]
          new_slaves = new_clients_for(*nodes[:slaves])
          @master = new_master
          @slaves = new_slaves
        rescue
          purge_clients
          raise
        ensure
          if should_notify?
           @on_node_change.call(current_master, current_slaves)
           @last_notified_master = current_master
           @last_notified_slaves = current_slaves
          end
        end
      end
    end
def build_clients
      @lock.synchronize do
        begin
          nodes = fetch_nodes
          return unless nodes_changed?(nodes)

          purge_clients
          logger.info("Building new clients for nodes #{nodes.inspect}")
          new_master = new_clients_for(nodes[:master]).first if nodes[:master]
          new_slaves = new_clients_for(*nodes[:slaves])
          @master = new_master
          @slaves = new_slaves
        rescue
          purge_clients
          raise
        ensure
          if should_notify?
           @on_node_change.call(current_master, current_slaves)
           @last_notified_master = current_master
           @last_notified_slaves = current_slaves
          end
        end
      end
    end
Builds the Redis clients for the currently known master/slaves.
 The current master/slaves are fetched via ZooKeeper.