def perform_manual_failover
      @lock.synchronize do
        return unless running? && @master_manager && @zk_lock
        @zk_lock.assert!
        new_master = @zk.get(manual_failover_path, :watch => true).first
        return unless new_master && new_master.size > 0
        logger.info("Received manual failover request for: #{new_master}")
        logger.info("Current nodes: #{current_nodes.inspect}")
        snapshots = current_node_snapshots

        node = if new_master == ManualFailover::ANY_SLAVE
          failover_strategy_candidate(snapshots)
        else
          node_from(new_master)
        end

        if node
          handle_manual_failover(node, snapshots)
        else
          logger.error('Failed to perform manual failover, no candidate found.')
        end
      end
    rescue => ex
      logger.error("Error handling manual failover: #{ex.inspect}")
      logger.error(ex.backtrace.join("\n"))
    ensure
      @zk.stat(manual_failover_path, :watch => true)
    end
def perform_manual_failover
      @lock.synchronize do
        return unless running? && @master_manager && @zk_lock
        @zk_lock.assert!
        new_master = @zk.get(manual_failover_path, :watch => true).first
        return unless new_master && new_master.size > 0
        logger.info("Received manual failover request for: #{new_master}")
        logger.info("Current nodes: #{current_nodes.inspect}")
        snapshots = current_node_snapshots

        node = if new_master == ManualFailover::ANY_SLAVE
          failover_strategy_candidate(snapshots)
        else
          node_from(new_master)
        end

        if node
          handle_manual_failover(node, snapshots)
        else
          logger.error('Failed to perform manual failover, no candidate found.')
        end
      end
    rescue => ex
      logger.error("Error handling manual failover: #{ex.inspect}")
      logger.error(ex.backtrace.join("\n"))
    ensure
      @zk.stat(manual_failover_path, :watch => true)
    end
Perform a manual failover to a redis node.