Class: Kazoo::CLI::Cluster

Inherits:
Thor
  • Object
show all
Includes:
Common
Defined in:
lib/kazoo/cli/cluster.rb

Instance Method Summary collapse

Methods included from Common

included

Instance Method Details

#brokersObject



7
8
9
10
11
12
13
# File 'lib/kazoo/cli/cluster.rb', line 7

def brokers
  validate_class_options!

  kafka_cluster.brokers.values.sort_by(&:id).each do |broker|
    $stdout.puts "#{broker.id}:\t#{broker.addr}\t(hosts #{broker.replicated_partitions.length} partitions, leads #{broker.led_partitions.length})"
  end
end

#critical(broker_name) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/kazoo/cli/cluster.rb', line 17

def critical(broker_name)
  validate_class_options!

  if broker(broker_name).critical?(replicas: options[:replicas])
    raise Thor::Error, "WARNING: broker #{broker_name} is critical and cannot be stopped safely!"
  else
    $stdout.puts "Broker #{broker_name} is non-critical and can be stopped safely."
  end
end

#electionObject



28
29
30
31
32
# File 'lib/kazoo/cli/cluster.rb', line 28

def election
  validate_class_options!

  kafka_cluster.preferred_leader_election
end