Skip to content

Commit

Permalink
Export volume address as the label of worker
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 29, 2015
1 parent bfb048e commit 8a757f8
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 14 deletions.
1 change: 1 addition & 0 deletions lib/droonga/catalog/version2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def slices(node)
migrate_database_location(path, device, local_name)

options = {
:label => volume_address.to_s,
:dataset => dataset_name,
:database => path.to_s,
:n_workers => n_workers,
Expand Down
6 changes: 6 additions & 0 deletions lib/droonga/command/droonga_engine_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def initialize
@contrtol_read_fd = nil
@contrtol_write_fd = nil
@pid_file_path = nil
@label = nil
@dataset = nil
@database_path = nil
@plugins = []
Expand Down Expand Up @@ -91,6 +92,10 @@ def add_internal_options(parser)
"Put PID to PATH") do |path|
@pid_file_path = Pathname.new(path)
end
parser.on("--label=LABEL",
"Use given value as the label") do |label|
@label = label
end
parser.on("--dataset=DATASET",
"Process DATASET") do |dataset|
@dataset = dataset
Expand Down Expand Up @@ -181,6 +186,7 @@ def stop_forwarder

def start_handler_runner
options = {
:label => @label,
:forwarder => @forwarder,
:dataset => @dataset,
:database => @database_path.to_s,
Expand Down
2 changes: 1 addition & 1 deletion lib/droonga/farm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def initialize(name, catalog, loop, options={})
slices = @catalog.slices(name)
slices.each do |slice_name, slice_options|
dataset = @catalog.datasets[slice_options[:dataset]]
slice = Droonga::Slice.new(dataset,
slice = Droonga::Slice.new(slice_name, dataset,
@loop,
@options.merge(slice_options))
@slices[slice_name] = slice
Expand Down
5 changes: 3 additions & 2 deletions lib/droonga/handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ def action
end
end

attr_reader :messenger, :loop
def initialize(name, context, messenger, loop)
attr_reader :label, :messenger, :loop
def initialize(name, label, context, messenger, loop)
@name = name
@label = label
@context = context
@messenger = messenger
@loop = loop
Expand Down
3 changes: 2 additions & 1 deletion lib/droonga/handler_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def initialize(loop, options={})
@loop = loop
@options = options
@name = options[:name]
@label = options[:label]
@dataset_name = options[:dataset]
@database_name = options[:database]
prepare
Expand Down Expand Up @@ -112,7 +113,7 @@ def process_type(handler_class, type, raw_message)
handler_message.validate

messenger = HandlerMessenger.new(@forwarder, handler_message, @options)
handler = handler_class.new(@name, @context, messenger, @loop)
handler = handler_class.new(@name, @label, @context, messenger, @loop)
begin
result = handler.handle(handler_message)
unless result.nil?
Expand Down
10 changes: 1 addition & 9 deletions lib/droonga/plugins/system/statistics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,9 @@ def counts(output)
class StatisticsObjectCountPerVolumeHandler < StatisticsObjectCountHandler
def handle(message)
{
replica_name => counts(message.request["output"]),
label => counts(message.request["output"]),
}
end

def replica_name
my_node_name
end

def my_node_name
ENV["DROONGA_ENGINE_NAME"]
end
end

define_single_step do |step|
Expand Down
4 changes: 3 additions & 1 deletion lib/droonga/slice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class Slice
include Loggable
include Deferrable

def initialize(dataset, loop, options={})
def initialize(label, dataset, loop, options={})
@label = label
@dataset = dataset
@loop = loop
@options = options
Expand Down Expand Up @@ -118,6 +119,7 @@ def start_supervisor

config = Supervisor::WorkerConfiguration.new
config.name = @options[:name]
config.label = @label
config.dataset = @dataset
config.database_path = @database_path
config.plugins = @options[:plugins]
Expand Down
3 changes: 3 additions & 0 deletions lib/droonga/supervisor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,15 @@ def log_tag

class WorkerConfiguration
attr_accessor :name
attr_accessor :label
attr_accessor :dataset
attr_accessor :database_path
attr_accessor :plugins
attr_accessor :job_pusher
attr_accessor :internal_connection_lifetime
def initialize
@name = nil
@label = nil
@dataset = nil
@database_path = nil
@plugins = []
Expand Down Expand Up @@ -116,6 +118,7 @@ def start
"--control-write-fd", control_read_out.fileno.to_s,
"--job-queue-socket-path", @config.job_pusher.socket_path.to_s,
"--pid-file", pid_path.to_s,
"--label", @config.label,
"--dataset", @config.dataset.name,
"--database-path", @config.database_path.to_s,
"--plugins", @config.plugins.join(","),
Expand Down

0 comments on commit 8a757f8

Please sign in to comment.