Class: Droonga::Serf::RemoteCommand::AddReplicas

Inherits:
ModifyReplicasBase show all
Defined in:
lib/droonga/serf/remote_command.rb

Instance Attribute Summary

Attributes inherited from Base

#response

Instance Method Summary collapse

Methods inherited from Base

#initialize, #log, #should_process?

Constructor Details

This class inherits a constructor from Droonga::Serf::RemoteCommand::Base

Instance Method Details

#processObject



280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# File 'lib/droonga/serf/remote_command.rb', line 280

def process
  return if dataset.nil? or hosts.nil?

  added_hosts = hosts - [host]
  log("adding replicas: #{added_hosts.join(",")}")
  return if added_hosts.empty?

  log("joining to the cluster")
  @serf.join(*added_hosts)

  log("adding replicas to the cluster")
  Catalog::Modifier.new(catalog).modify do |modifier, file|
    modifier.datasets[dataset].replicas.hosts += added_hosts
    modifier.datasets[dataset].replicas.hosts.uniq!
    @service_installation.ensure_correct_file_permission(file)
  end
  log("done")
end