Class: Droonga::Command::Remote::AbsorbData

Inherits:
Base
  • Object
show all
Defined in:
lib/droonga/command/remote.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#response

Instance Method Summary collapse

Methods inherited from Base

#initialize, #should_process?

Constructor Details

This class inherits a constructor from Droonga::Command::Remote::Base

Instance Attribute Details

#dataset_name=(value) ⇒ Object

Sets the attribute dataset_name

Parameters:

  • value

    the value to set the attribute dataset_name to.



242
243
244
# File 'lib/droonga/command/remote.rb', line 242

def dataset_name=(value)
  @dataset_name = value
end

#port=(value) ⇒ Object

Sets the attribute port

Parameters:

  • value

    the value to set the attribute port to.



242
243
244
# File 'lib/droonga/command/remote.rb', line 242

def port=(value)
  @port = value
end

#tag=(value) ⇒ Object

Sets the attribute tag

Parameters:

  • value

    the value to set the attribute tag to.



242
243
244
# File 'lib/droonga/command/remote.rb', line 242

def tag=(value)
  @tag = value
end

Instance Method Details

#processObject



244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
# File 'lib/droonga/command/remote.rb', line 244

def process
  return unless source

  log("start to absorb data from #{source}")

  if dataset_name.nil? or port.nil? or tag.nil?
    current_catalog = JSON.parse(Path.catalog.read)
    generator = CatalogGenerator.new
    generator.load(current_catalog)

    dataset = generator.dataset_for_host(source)
    return unless dataset

    self.dataset_name = dataset.name
    self.port         = dataset.replicas.port
    self.tag          = dataset.replicas.tag
  end

  log("dataset = #{dataset_name}")
  log("port    = #{port}")
  log("tag     = #{tag}")

  status = NodeStatus.new
  status.set(:absorbing, true)
  DataAbsorber.absorb(:dataset          => dataset_name,
                      :source_host      => source,
                      :destination_host => host,
                      :port             => port,
                      :tag              => tag,
                      :messages_per_second => messages_per_second,
                      :client           => "droonga-send")
  status.delete(:absorbing)
end