Class: Kafkat::ClusterRestart::Subcommands::Good

Inherits:
Kafkat::Command::Base show all
Defined in:
lib/kafkat/command/cluster_restart.rb

Instance Attribute Summary collapse

Attributes inherited from Kafkat::Command::Base

#config

Instance Method Summary collapse

Methods inherited from Kafkat::Command::Base

#admin, #initialize, #kafka_logs, register_as, usage, usages, #zookeeper

Methods included from Logging

#print_err

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 Attribute Details

#sessionObject (readonly)

Returns the value of attribute session.



143
144
145
# File 'lib/kafkat/command/cluster_restart.rb', line 143

def session
  @session
end

Instance Method Details

#restart(broker_id) ⇒ Object



162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/kafkat/command/cluster_restart.rb', line 162

def restart(broker_id)
  @session = Session.load!
  begin
    if session.pending?(broker_id)
      session.update_states!(Session::STATE_RESTARTED, [broker_id])
      session.save!
    else
      puts "ERROR Broker state is #{session.state(broker_id)}"
      exit 1
    end
  rescue UnknownBrokerError => e
    puts "ERROR #{e.to_s}"
    exit 1
  end
end

#runObject



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/kafkat/command/cluster_restart.rb', line 145

def run
  unless Session.exists?
    puts "ERROR: no session in progress"
    puts "\n[Action] Please run 'start' command"
    exit 1
  end

  broker_id = ARGV[0]
  if broker_id.nil?
    puts "ERROR You must specify a broker id"
    exit 1
  end
  restart(broker_id)
  puts "Broker #{broker_id} has been marked as restarted"
  puts "\n[Action] Please run 'next' to select the broker with lowest restarting cost"
end