Class: Kafkat::Command::ElectLeaders
- Defined in:
- lib/kafkat/command/elect-leaders.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#admin, #initialize, #kafka_logs, register_as, usage, usages, #zookeeper
Methods included from Logging
Methods included from Kafkat::CommandIO
#prompt_and_execute_assignments
Methods included from Formatting
#justify, #print_assignment, #print_assignment_header, #print_broker, #print_broker_header, #print_partition, #print_partition_header, #print_topic, #print_topic_header, #print_topic_name
Constructor Details
This class inherits a constructor from Kafkat::Command::Base
Instance Method Details
#run ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/kafkat/command/elect-leaders.rb', line 9 def run topic_name = ARGV[0] && ARGV.shift topic_names = topic_name && [topic_name] topics = zookeeper.get_topics(topic_names) partitions = topics.values.map(&:partitions).flatten topics_s = topic_name ? "'#{topic_name}'" : "all topics" print "This operation elects the preferred replicas for #{topics_s}.\n" return unless agree("Proceed (y/n)?") result = nil begin print "\nBeginning.\n" result = admin.elect_leaders!(partitions) print "Started.\n" rescue Interface::Admin::ExecutionFailedError print result end end |