class Kafkat::Command::Describe

Public Instance Methods

run() click to toggle source
# File lib/kafkat/command/partitions.rb, line 13
def run
  topic_name = ARGV.shift unless ARGV[0] && ARGV[0].start_with?('--')
  topic_names = topic_name && [topic_name]

  @options = Trollop.options do
    opt :under_replicated, "only under-replicated"
    opt :unavailable, "only unavailable"
  end

  brokers = zookeeper.get_brokers
  topics = zookeeper.get_topics(topic_names)

  print_partition_header
  topics.each do |name, t|
    t.partitions.each do |p|
      print_partition(p) if selected?(p, brokers)
    end
  end
end

Private Instance Methods

only_unavailable?() click to toggle source
# File lib/kafkat/command/partitions.rb, line 45
def only_unavailable?
  !!@options[:unavailable]
end
only_under_replicated?() click to toggle source
# File lib/kafkat/command/partitions.rb, line 41
def only_under_replicated?
  !!@options[:under_replicated]
end
selected?(partition, brokers) click to toggle source
# File lib/kafkat/command/partitions.rb, line 35
def selected?(partition, brokers)
  return partition.under_replicated? if only_under_replicated?
  return !partition.has_leader?(brokers) if only_unavailable?
  true
end