droonga-engine 1.0.9 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/benchmark/timer-watcher/benchmark.rb +44 -0
- data/bin/droonga-engine-absorb-data +246 -187
- data/bin/droonga-engine-catalog-generate +12 -12
- data/bin/droonga-engine-catalog-modify +4 -4
- data/bin/droonga-engine-join +352 -171
- data/bin/droonga-engine-set-role +54 -0
- data/bin/droonga-engine-unjoin +107 -112
- data/droonga-engine.gemspec +3 -3
- data/install.sh +55 -36
- data/install/centos/functions.sh +2 -2
- data/install/debian/functions.sh +2 -2
- data/lib/droonga/address.rb +26 -24
- data/lib/droonga/buffered_tcp_socket.rb +65 -10
- data/lib/droonga/catalog/base.rb +9 -6
- data/lib/droonga/catalog/dataset.rb +17 -41
- data/lib/droonga/catalog/fetcher.rb +64 -0
- data/lib/droonga/catalog/generator.rb +245 -0
- data/lib/droonga/catalog/loader.rb +66 -0
- data/lib/droonga/{catalog_modifier.rb → catalog/modifier.rb} +11 -18
- data/lib/droonga/catalog/replicas_volume.rb +123 -0
- data/lib/droonga/catalog/schema.rb +37 -37
- data/lib/droonga/catalog/single_volume.rb +11 -3
- data/lib/droonga/catalog/slice.rb +10 -6
- data/lib/droonga/catalog/{collection_volume.rb → slices_volume.rb} +47 -11
- data/lib/droonga/catalog/version1.rb +47 -19
- data/lib/droonga/catalog/version2.rb +11 -10
- data/lib/droonga/catalog/version2_validator.rb +4 -4
- data/lib/droonga/catalog/volume.rb +17 -5
- data/lib/droonga/changable.rb +25 -0
- data/lib/droonga/cluster.rb +237 -0
- data/lib/droonga/collector_runner.rb +4 -0
- data/lib/droonga/collectors.rb +2 -1
- data/lib/droonga/collectors/recursive_sum.rb +26 -0
- data/lib/droonga/command/droonga_engine.rb +404 -127
- data/lib/droonga/command/droonga_engine_service.rb +47 -11
- data/lib/droonga/command/droonga_engine_worker.rb +21 -1
- data/lib/droonga/command/remote_command_base.rb +78 -0
- data/lib/droonga/command/serf_event_handler.rb +29 -20
- data/lib/droonga/data_absorber_client.rb +222 -0
- data/lib/droonga/database_scanner.rb +106 -0
- data/lib/droonga/{live_nodes_list_loader.rb → deferrable.rb} +11 -24
- data/lib/droonga/differ.rb +58 -0
- data/lib/droonga/dispatcher.rb +155 -32
- data/lib/droonga/distributed_command_planner.rb +9 -11
- data/lib/droonga/engine.rb +83 -78
- data/lib/droonga/engine/version.rb +1 -1
- data/lib/droonga/engine_node.rb +301 -0
- data/lib/droonga/engine_state.rb +62 -40
- data/lib/droonga/farm.rb +44 -5
- data/lib/droonga/file_observer.rb +16 -12
- data/lib/droonga/fluent_message_receiver.rb +98 -29
- data/lib/droonga/fluent_message_sender.rb +30 -23
- data/lib/droonga/forward_buffer.rb +160 -0
- data/lib/droonga/forwarder.rb +73 -40
- data/lib/droonga/handler.rb +7 -6
- data/lib/droonga/handler_messenger.rb +15 -6
- data/lib/droonga/handler_runner.rb +6 -1
- data/lib/droonga/internal_fluent_message_receiver.rb +28 -8
- data/lib/droonga/job_pusher.rb +10 -7
- data/lib/droonga/job_receiver.rb +6 -4
- data/lib/droonga/logger.rb +7 -1
- data/lib/droonga/node_name.rb +90 -0
- data/lib/droonga/node_role.rb +72 -0
- data/lib/droonga/path.rb +34 -9
- data/lib/droonga/planner.rb +73 -7
- data/lib/droonga/plugin/async_command.rb +154 -0
- data/lib/droonga/plugins/catalog.rb +1 -0
- data/lib/droonga/plugins/crud.rb +22 -6
- data/lib/droonga/plugins/dump.rb +66 -135
- data/lib/droonga/plugins/groonga/delete.rb +13 -0
- data/lib/droonga/plugins/search/distributed_search_planner.rb +4 -4
- data/lib/droonga/plugins/system.rb +5 -26
- data/lib/droonga/plugins/system/absorb_data.rb +405 -0
- data/lib/droonga/plugins/system/statistics.rb +71 -0
- data/lib/droonga/plugins/system/status.rb +53 -0
- data/lib/droonga/process_control_protocol.rb +3 -1
- data/lib/droonga/process_supervisor.rb +32 -15
- data/lib/droonga/reducer.rb +69 -0
- data/lib/droonga/safe_file_writer.rb +1 -1
- data/lib/droonga/serf.rb +207 -276
- data/lib/droonga/serf/agent.rb +228 -0
- data/lib/droonga/serf/command.rb +94 -0
- data/lib/droonga/serf/downloader.rb +120 -0
- data/lib/droonga/serf/remote_command.rb +348 -0
- data/lib/droonga/serf/tag.rb +56 -0
- data/lib/droonga/service_installation.rb +2 -2
- data/lib/droonga/session.rb +49 -1
- data/lib/droonga/single_step.rb +6 -11
- data/lib/droonga/single_step_definition.rb +32 -1
- data/lib/droonga/slice.rb +14 -9
- data/lib/droonga/supervisor.rb +27 -20
- data/lib/droonga/test/stub_handler_messenger.rb +2 -1
- data/lib/droonga/timestamp.rb +69 -0
- data/lib/droonga/worker_process_agent.rb +33 -15
- data/sample/cluster-state.json +8 -0
- data/sample/cluster/Rakefile +30 -6
- data/test/command/fixture/integer-key-table.jsons +11 -0
- data/test/command/fixture/string-key-table.jsons +11 -0
- data/test/command/run-test.rb +4 -0
- data/test/command/suite/add/error/invalid-integer.expected +3 -3
- data/test/command/suite/add/error/invalid-time.expected +3 -3
- data/test/command/suite/add/{minimum.expected → key-integer.expected} +0 -0
- data/test/command/suite/add/{minimum.test → key-integer.test} +0 -0
- data/test/command/suite/add/key-string.expected +6 -0
- data/test/command/suite/add/key-string.test +9 -0
- data/test/command/suite/add/mismatched-key-type/acceptable/integer-for-string.expected +6 -0
- data/test/command/suite/add/mismatched-key-type/acceptable/integer-for-string.test +9 -0
- data/test/command/suite/add/mismatched-key-type/acceptable/string-for-integer.expected +6 -0
- data/test/command/suite/add/mismatched-key-type/acceptable/string-for-integer.test +9 -0
- data/test/command/suite/add/without-values.expected +6 -0
- data/test/command/suite/add/without-values.test +11 -0
- data/test/command/suite/dump/column/index.expected +33 -1
- data/test/command/suite/dump/column/index.test +1 -0
- data/test/command/suite/dump/column/scalar.expected +29 -1
- data/test/command/suite/dump/column/scalar.test +1 -0
- data/test/command/suite/dump/column/vector.expected +29 -1
- data/test/command/suite/dump/column/vector.test +1 -0
- data/test/command/suite/dump/record/scalar.catalog.json +12 -0
- data/test/command/suite/dump/record/scalar.expected +84 -0
- data/test/command/suite/dump/record/scalar.test +16 -0
- data/test/command/suite/dump/record/vector/reference.expected +83 -1
- data/test/command/suite/dump/record/vector/reference.test +1 -0
- data/test/command/suite/dump/table/array.expected +27 -1
- data/test/command/suite/dump/table/array.test +1 -0
- data/test/command/suite/dump/table/double_array_trie.expected +27 -1
- data/test/command/suite/dump/table/double_array_trie.test +1 -0
- data/test/command/suite/dump/table/hash.expected +27 -1
- data/test/command/suite/dump/table/hash.test +1 -0
- data/test/command/suite/dump/table/patricia_trie.expected +27 -1
- data/test/command/suite/dump/table/patricia_trie.test +1 -0
- data/test/command/suite/groonga/delete/{success.expected → key-integer.expected} +0 -0
- data/test/command/suite/groonga/delete/key-integer.test +17 -0
- data/test/command/suite/groonga/delete/key-string.expected +19 -0
- data/test/command/suite/groonga/delete/{success.test → key-string.test} +4 -6
- data/test/command/suite/groonga/delete/mismatched-type-key/acceptable/integer-for-string.expected +19 -0
- data/test/command/suite/groonga/delete/mismatched-type-key/acceptable/integer-for-string.test +17 -0
- data/test/command/suite/groonga/delete/mismatched-type-key/acceptable/string-for-integer.expected +19 -0
- data/test/command/suite/groonga/delete/mismatched-type-key/acceptable/string-for-integer.test +17 -0
- data/test/command/suite/message/error/missing-dataset.test +1 -0
- data/test/command/suite/system/absorb-data/records.catalog.json +58 -0
- data/test/command/suite/system/absorb-data/records.expected +32 -0
- data/test/command/suite/system/absorb-data/records.test +24 -0
- data/test/command/suite/system/statistics/object/count/empty.expected +11 -0
- data/test/command/suite/system/statistics/object/count/empty.test +12 -0
- data/test/command/suite/system/statistics/object/count/per-volume/empty.catalog.json +36 -0
- data/test/command/suite/system/statistics/object/count/per-volume/empty.expected +19 -0
- data/test/command/suite/system/statistics/object/count/per-volume/empty.test +12 -0
- data/test/command/suite/system/statistics/object/count/per-volume/record.catalog.json +40 -0
- data/test/command/suite/system/statistics/object/count/per-volume/record.expected +19 -0
- data/test/command/suite/system/statistics/object/count/per-volume/record.test +23 -0
- data/test/command/suite/system/statistics/object/count/per-volume/schema.catalog.json +40 -0
- data/test/command/suite/system/statistics/object/count/per-volume/schema.expected +19 -0
- data/test/command/suite/system/statistics/object/count/per-volume/schema.test +13 -0
- data/test/command/suite/system/statistics/object/count/record.catalog.json +12 -0
- data/test/command/suite/system/statistics/object/count/record.expected +11 -0
- data/test/command/suite/system/statistics/object/count/record.test +23 -0
- data/test/command/suite/system/statistics/object/count/schema.catalog.json +12 -0
- data/test/command/suite/system/statistics/object/count/schema.expected +11 -0
- data/test/command/suite/system/statistics/object/count/schema.test +13 -0
- data/test/command/suite/system/status.expected +3 -2
- data/test/unit/catalog/test_dataset.rb +4 -1
- data/test/unit/{test_catalog_generator.rb → catalog/test_generator.rb} +2 -2
- data/test/unit/catalog/test_replicas_volume.rb +79 -0
- data/test/unit/catalog/test_single_volume.rb +2 -2
- data/test/unit/catalog/test_slice.rb +33 -1
- data/test/unit/catalog/{test_collection_volume.rb → test_slices_volume.rb} +72 -11
- data/test/unit/catalog/test_version2.rb +3 -0
- data/test/unit/helper/distributed_search_planner_helper.rb +2 -2
- data/test/unit/plugins/catalog/test_fetch.rb +4 -4
- data/test/unit/plugins/crud/test_add.rb +44 -4
- data/test/unit/plugins/groonga/test_column_create.rb +4 -4
- data/test/unit/plugins/groonga/test_column_list.rb +4 -4
- data/test/unit/plugins/groonga/test_column_remove.rb +4 -4
- data/test/unit/plugins/groonga/test_column_rename.rb +4 -4
- data/test/unit/plugins/groonga/test_delete.rb +73 -10
- data/test/unit/plugins/groonga/test_table_create.rb +4 -4
- data/test/unit/plugins/groonga/test_table_list.rb +4 -4
- data/test/unit/plugins/groonga/test_table_remove.rb +4 -4
- data/test/unit/plugins/search/test_handler.rb +4 -4
- data/test/unit/plugins/search/test_planner.rb +4 -2
- data/test/unit/plugins/system/test_status.rb +31 -15
- data/test/unit/plugins/test_watch.rb +16 -16
- data/test/unit/test_address.rb +4 -4
- metadata +134 -35
- data/lib/droonga/catalog/volume_collection.rb +0 -79
- data/lib/droonga/catalog_fetcher.rb +0 -53
- data/lib/droonga/catalog_generator.rb +0 -243
- data/lib/droonga/catalog_loader.rb +0 -56
- data/lib/droonga/command/remote.rb +0 -404
- data/lib/droonga/data_absorber.rb +0 -264
- data/lib/droonga/node_status.rb +0 -71
- data/lib/droonga/serf_downloader.rb +0 -115
- data/test/unit/catalog/test_volume_collection.rb +0 -78
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Copyright (C) 2015 Droonga Project
|
|
2
|
+
#
|
|
3
|
+
# This library is free software; you can redistribute it and/or
|
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
5
|
+
# License version 2.1 as published by the Free Software Foundation.
|
|
6
|
+
#
|
|
7
|
+
# This library is distributed in the hope that it will be useful,
|
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
10
|
+
# Lesser General Public License for more details.
|
|
11
|
+
#
|
|
12
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
13
|
+
# License along with this library; if not, write to the Free Software
|
|
14
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
15
|
+
|
|
16
|
+
module Droonga
|
|
17
|
+
class Serf
|
|
18
|
+
module Tag
|
|
19
|
+
class << self
|
|
20
|
+
def node_type
|
|
21
|
+
"type"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def node_role
|
|
25
|
+
"role"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def internal_node_name
|
|
29
|
+
"internal-name"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def cluster_id
|
|
33
|
+
"cluster_id"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def accept_messages_newer_than
|
|
37
|
+
"accept-newer-than"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
HAVE_UNPROCESSED_MESSAGES_TAG_PREFIX = "buffered-for-"
|
|
41
|
+
|
|
42
|
+
def have_unprocessed_messages_tag_for(node_name)
|
|
43
|
+
"#{HAVE_UNPROCESSED_MESSAGES_TAG_PREFIX}#{node_name}"
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def have_unprocessed_messages_tag?(tag)
|
|
47
|
+
tag.start_with?(HAVE_UNPROCESSED_MESSAGES_TAG_PREFIX)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def extract_node_name_from_have_unprocessed_messages_tag(tag)
|
|
51
|
+
tag.sub(HAVE_UNPROCESSED_MESSAGES_TAG_PREFIX, "")
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -47,7 +47,7 @@ module Droonga
|
|
|
47
47
|
test_file = Path.config
|
|
48
48
|
begin
|
|
49
49
|
test_file.read
|
|
50
|
-
rescue Errno::EACCES
|
|
50
|
+
rescue Errno::EACCES
|
|
51
51
|
return false
|
|
52
52
|
end
|
|
53
53
|
true
|
|
@@ -58,7 +58,7 @@ module Droonga
|
|
|
58
58
|
begin
|
|
59
59
|
FileUtils.mkdir_p(Path.base)
|
|
60
60
|
FileUtils.touch(test_file.to_s)
|
|
61
|
-
rescue Errno::EACCES
|
|
61
|
+
rescue Errno::EACCES
|
|
62
62
|
end
|
|
63
63
|
unless test_file.exist?
|
|
64
64
|
return false
|
data/lib/droonga/session.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (C) 2013-
|
|
1
|
+
# Copyright (C) 2013-2015 Droonga Project
|
|
2
2
|
#
|
|
3
3
|
# This library is free software; you can redistribute it and/or
|
|
4
4
|
# modify it under the terms of the GNU Lesser General Public
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
# License along with this library; if not, write to the Free Software
|
|
14
14
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
15
15
|
|
|
16
|
+
require "coolio"
|
|
17
|
+
|
|
16
18
|
require "droonga/loggable"
|
|
17
19
|
|
|
18
20
|
module Droonga
|
|
@@ -26,26 +28,57 @@ module Droonga
|
|
|
26
28
|
@tasks = tasks
|
|
27
29
|
@n_dones = 0
|
|
28
30
|
@inputs = inputs
|
|
31
|
+
logger.trace("initialized", :tasks => tasks, :inputs => inputs)
|
|
29
32
|
end
|
|
30
33
|
|
|
31
34
|
def done?
|
|
32
35
|
@n_dones == @tasks.size
|
|
33
36
|
end
|
|
34
37
|
|
|
38
|
+
#TODO: We don't have to wait results if no collection step is
|
|
39
|
+
# in the list of tasks, because:
|
|
40
|
+
#
|
|
41
|
+
# * Currently the "super step" mecahnism is not
|
|
42
|
+
# implemented yet.
|
|
43
|
+
# * So, results won't be used by other handlers directly.
|
|
44
|
+
# Results will be used only for the "response" for the
|
|
45
|
+
# sender.
|
|
46
|
+
# * So, if there is no collection step, no-one requires
|
|
47
|
+
# results and there is no need to wait for results.
|
|
48
|
+
#
|
|
49
|
+
# However, in the future after the "super step" mechanism
|
|
50
|
+
# is introduced, results can be used by other handlers
|
|
51
|
+
# even if there is no collection step.
|
|
52
|
+
# Then we must update this logic.
|
|
53
|
+
def need_result?
|
|
54
|
+
@tasks.any? do |task|
|
|
55
|
+
@collector_runner.collectable?("task" => task)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
35
59
|
def start
|
|
36
60
|
tasks = @inputs[nil] || []
|
|
61
|
+
logger.trace("start: no task!") if tasks.empty?
|
|
37
62
|
tasks.each do |task|
|
|
38
63
|
local_message = {
|
|
39
64
|
"id" => @id,
|
|
40
65
|
"task" => task,
|
|
41
66
|
}
|
|
67
|
+
logger.trace("start: dispatching local message", :message => local_message)
|
|
42
68
|
@dispatcher.process_local_message(local_message)
|
|
43
69
|
@n_dones += 1
|
|
44
70
|
end
|
|
45
71
|
end
|
|
46
72
|
|
|
73
|
+
def finish
|
|
74
|
+
@timeout_timer.detach if @timeout_timer
|
|
75
|
+
@timeout_timer = nil
|
|
76
|
+
end
|
|
77
|
+
|
|
47
78
|
def receive(name, value)
|
|
48
79
|
tasks = @inputs[name]
|
|
80
|
+
logger.trace("receive: process response",
|
|
81
|
+
:name => name, :value => value, :task => tasks)
|
|
49
82
|
unless tasks
|
|
50
83
|
#TODO: result arrived before its query
|
|
51
84
|
return
|
|
@@ -82,6 +115,17 @@ module Droonga
|
|
|
82
115
|
end
|
|
83
116
|
end
|
|
84
117
|
|
|
118
|
+
def set_timeout(loop, timeout, &block)
|
|
119
|
+
@timeout_timer = Coolio::TimerWatcher.new(timeout)
|
|
120
|
+
@timeout_timer.on_timer do
|
|
121
|
+
@timeout_timer.detach
|
|
122
|
+
@timeout_timer = nil
|
|
123
|
+
report_timeout_error
|
|
124
|
+
yield
|
|
125
|
+
end
|
|
126
|
+
loop.attach(@timeout_timer)
|
|
127
|
+
end
|
|
128
|
+
|
|
85
129
|
private
|
|
86
130
|
def send_to_descendantas(descendantas, result)
|
|
87
131
|
descendantas.each do |name, routes|
|
|
@@ -96,6 +140,10 @@ module Droonga
|
|
|
96
140
|
end
|
|
97
141
|
end
|
|
98
142
|
|
|
143
|
+
def report_timeout_error
|
|
144
|
+
#TODO: implement me!
|
|
145
|
+
end
|
|
146
|
+
|
|
99
147
|
def log_tag
|
|
100
148
|
"session"
|
|
101
149
|
end
|
data/lib/droonga/single_step.rb
CHANGED
|
@@ -32,23 +32,18 @@ module Droonga
|
|
|
32
32
|
|
|
33
33
|
# XXX: Re-implement me.
|
|
34
34
|
planner = Planner.new(@dataset)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
reduce_key = "result"
|
|
40
|
-
options[:reduce] = {
|
|
41
|
-
reduce_key => collector_class.operator,
|
|
42
|
-
}
|
|
43
|
-
end
|
|
35
|
+
planner.write = @definition.write?
|
|
36
|
+
planner.single_operation = @definition.single_operation?
|
|
37
|
+
planner.use_all_replicas = @definition.use_all_replicas?
|
|
38
|
+
planner.collector_class = @definition.collector_class
|
|
44
39
|
|
|
45
40
|
body = message["body"]
|
|
46
41
|
fact_input = find_fact_input(@definition.inputs, @dataset.fact, body)
|
|
47
42
|
if fact_input
|
|
48
43
|
record = body[fact_input[:filter]]
|
|
49
|
-
planner.
|
|
44
|
+
planner.plan(message, :record => record)
|
|
50
45
|
else
|
|
51
|
-
planner.
|
|
46
|
+
planner.plan(message)
|
|
52
47
|
end
|
|
53
48
|
end
|
|
54
49
|
|
|
@@ -18,7 +18,9 @@ module Droonga
|
|
|
18
18
|
attr_accessor :name
|
|
19
19
|
attr_accessor :handler
|
|
20
20
|
attr_accessor :collector
|
|
21
|
-
attr_writer :write
|
|
21
|
+
attr_writer :write, :single_operation
|
|
22
|
+
attr_writer :use_all_replicas
|
|
23
|
+
attr_writer :timeout_calculator
|
|
22
24
|
attr_accessor :inputs
|
|
23
25
|
attr_accessor :output
|
|
24
26
|
def initialize(plugin_module)
|
|
@@ -27,6 +29,17 @@ module Droonga
|
|
|
27
29
|
@handler = nil
|
|
28
30
|
@collector = nil
|
|
29
31
|
@write = false
|
|
32
|
+
@single_operation = false
|
|
33
|
+
@use_all_replicas = false
|
|
34
|
+
@timeout_calculator = lambda do |step|
|
|
35
|
+
if step["timeout"]
|
|
36
|
+
return step["timeout"]
|
|
37
|
+
elsif step["body"]
|
|
38
|
+
return step["body"]["timeout"] if step["body"]["timeout"]
|
|
39
|
+
end
|
|
40
|
+
nil
|
|
41
|
+
end
|
|
42
|
+
|
|
30
43
|
@inputs = []
|
|
31
44
|
@output = {}
|
|
32
45
|
yield(self)
|
|
@@ -36,6 +49,24 @@ module Droonga
|
|
|
36
49
|
@write
|
|
37
50
|
end
|
|
38
51
|
|
|
52
|
+
def single_operation?
|
|
53
|
+
return false if @write
|
|
54
|
+
@single_operation
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def use_all_replicas?
|
|
58
|
+
return true if @write
|
|
59
|
+
@use_all_replicas
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def timeout_for_step(step)
|
|
63
|
+
if @timeout_calculator
|
|
64
|
+
@timeout_calculator.call(step)
|
|
65
|
+
else
|
|
66
|
+
nil
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
39
70
|
def handler_class
|
|
40
71
|
resolve_class(@handler)
|
|
41
72
|
end
|
data/lib/droonga/slice.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (C) 2013-
|
|
1
|
+
# Copyright (C) 2013-2015 Droonga Project
|
|
2
2
|
#
|
|
3
3
|
# This library is free software; you can redistribute it and/or
|
|
4
4
|
# modify it under the terms of the GNU Lesser General Public
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
15
15
|
|
|
16
16
|
require "droonga/loggable"
|
|
17
|
+
require "droonga/deferrable"
|
|
17
18
|
require "droonga/supervisor"
|
|
18
19
|
require "droonga/event_loop"
|
|
19
20
|
require "droonga/job_pusher"
|
|
@@ -23,9 +24,10 @@ require "droonga/schema_applier"
|
|
|
23
24
|
module Droonga
|
|
24
25
|
class Slice
|
|
25
26
|
include Loggable
|
|
27
|
+
include Deferrable
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
def initialize(label, dataset, loop, options={})
|
|
30
|
+
@label = label
|
|
29
31
|
@dataset = dataset
|
|
30
32
|
@loop = loop
|
|
31
33
|
@options = options
|
|
@@ -34,7 +36,6 @@ module Droonga
|
|
|
34
36
|
@job_pusher = JobPusher.new(@loop, @database_path)
|
|
35
37
|
@processor = Processor.new(@loop, @job_pusher, @options)
|
|
36
38
|
@supervisor = nil
|
|
37
|
-
@on_ready = nil
|
|
38
39
|
end
|
|
39
40
|
|
|
40
41
|
def start
|
|
@@ -50,6 +51,7 @@ module Droonga
|
|
|
50
51
|
@job_pusher.shutdown
|
|
51
52
|
@processor.shutdown
|
|
52
53
|
yield if block_given?
|
|
54
|
+
logger.trace("stop_gracefully: done")
|
|
53
55
|
end
|
|
54
56
|
if @supervisor
|
|
55
57
|
@supervisor.stop_gracefully do
|
|
@@ -58,7 +60,6 @@ module Droonga
|
|
|
58
60
|
else
|
|
59
61
|
on_stop.call
|
|
60
62
|
end
|
|
61
|
-
logger.trace("stop_gracefully: done")
|
|
62
63
|
end
|
|
63
64
|
|
|
64
65
|
def stop_immediately
|
|
@@ -69,6 +70,12 @@ module Droonga
|
|
|
69
70
|
logger.trace("stop_immediately: done")
|
|
70
71
|
end
|
|
71
72
|
|
|
73
|
+
def refresh_node_reference
|
|
74
|
+
logger.trace("refresh_node_reference: start")
|
|
75
|
+
@supervisor.refresh_node_reference if @supervisor
|
|
76
|
+
logger.trace("refresh_node_reference: done")
|
|
77
|
+
end
|
|
78
|
+
|
|
72
79
|
def process(message)
|
|
73
80
|
logger.trace("process: start")
|
|
74
81
|
@processor.process(message)
|
|
@@ -112,10 +119,12 @@ module Droonga
|
|
|
112
119
|
|
|
113
120
|
config = Supervisor::WorkerConfiguration.new
|
|
114
121
|
config.name = @options[:name]
|
|
122
|
+
config.label = @label
|
|
115
123
|
config.dataset = @dataset
|
|
116
124
|
config.database_path = @database_path
|
|
117
125
|
config.plugins = @options[:plugins]
|
|
118
126
|
config.job_pusher = @job_pusher
|
|
127
|
+
config.internal_connection_lifetime = @options[:internal_connection_lifetime]
|
|
119
128
|
@supervisor = Supervisor.new(@loop, @n_workers, config)
|
|
120
129
|
@supervisor.on_ready = lambda do
|
|
121
130
|
on_ready
|
|
@@ -123,10 +132,6 @@ module Droonga
|
|
|
123
132
|
@supervisor.start
|
|
124
133
|
end
|
|
125
134
|
|
|
126
|
-
def on_ready
|
|
127
|
-
@on_ready.call if @on_ready
|
|
128
|
-
end
|
|
129
|
-
|
|
130
135
|
def log_tag
|
|
131
136
|
"slice"
|
|
132
137
|
end
|
data/lib/droonga/supervisor.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (C) 2014 Droonga Project
|
|
1
|
+
# Copyright (C) 2014-2015 Droonga Project
|
|
2
2
|
#
|
|
3
3
|
# This library is free software; you can redistribute it and/or
|
|
4
4
|
# modify it under the terms of the GNU Lesser General Public
|
|
@@ -14,18 +14,18 @@
|
|
|
14
14
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
15
15
|
|
|
16
16
|
require "droonga/loggable"
|
|
17
|
+
require "droonga/deferrable"
|
|
17
18
|
require "droonga/process_supervisor"
|
|
18
19
|
|
|
19
20
|
module Droonga
|
|
20
21
|
class Supervisor
|
|
21
22
|
include Loggable
|
|
23
|
+
include Deferrable
|
|
22
24
|
|
|
23
|
-
attr_writer :on_ready
|
|
24
25
|
def initialize(loop, n_workers, config)
|
|
25
26
|
@loop = loop
|
|
26
27
|
@n_workers = n_workers
|
|
27
28
|
@config = config
|
|
28
|
-
@on_ready = nil
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
def start
|
|
@@ -35,7 +35,7 @@ module Droonga
|
|
|
35
35
|
worker_runner.on_ready = lambda do
|
|
36
36
|
n_ready_workers += 1
|
|
37
37
|
if n_ready_workers == @n_workers
|
|
38
|
-
|
|
38
|
+
on_ready
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
41
|
worker_runner.start
|
|
@@ -53,10 +53,10 @@ module Droonga
|
|
|
53
53
|
n_done_worker_runners += 1
|
|
54
54
|
if n_done_worker_runners == n_worker_runners
|
|
55
55
|
yield if block_given?
|
|
56
|
+
logger.trace("stop_gracefully: done")
|
|
56
57
|
end
|
|
57
58
|
end
|
|
58
59
|
end
|
|
59
|
-
logger.trace("stop_gracefully: done")
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
def stop_immediately
|
|
@@ -65,6 +65,12 @@ module Droonga
|
|
|
65
65
|
end
|
|
66
66
|
end
|
|
67
67
|
|
|
68
|
+
def refresh_node_reference
|
|
69
|
+
@worker_runners.each do |worker_runner|
|
|
70
|
+
worker_runner.refresh_node_reference
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
68
74
|
private
|
|
69
75
|
def log_tag
|
|
70
76
|
"supervisor"
|
|
@@ -72,30 +78,31 @@ module Droonga
|
|
|
72
78
|
|
|
73
79
|
class WorkerConfiguration
|
|
74
80
|
attr_accessor :name
|
|
81
|
+
attr_accessor :label
|
|
75
82
|
attr_accessor :dataset
|
|
76
83
|
attr_accessor :database_path
|
|
77
84
|
attr_accessor :plugins
|
|
78
85
|
attr_accessor :job_pusher
|
|
86
|
+
attr_accessor :internal_connection_lifetime
|
|
79
87
|
def initialize
|
|
80
88
|
@name = nil
|
|
89
|
+
@label = nil
|
|
81
90
|
@dataset = nil
|
|
82
91
|
@database_path = nil
|
|
83
92
|
@plugins = []
|
|
84
93
|
@job_pusher = nil
|
|
94
|
+
@internal_connection_lifetime = nil
|
|
85
95
|
end
|
|
86
96
|
end
|
|
87
97
|
|
|
88
98
|
class WorkerRunner
|
|
89
99
|
include Loggable
|
|
100
|
+
include Deferrable
|
|
90
101
|
|
|
91
|
-
attr_writer :on_ready
|
|
92
|
-
attr_writer :on_failure
|
|
93
102
|
def initialize(loop, id, config)
|
|
94
103
|
@loop = loop
|
|
95
104
|
@id = id
|
|
96
105
|
@config = config
|
|
97
|
-
@on_ready = nil
|
|
98
|
-
@on_failure = nil
|
|
99
106
|
@stop_gracefully_callback = nil
|
|
100
107
|
end
|
|
101
108
|
|
|
@@ -111,9 +118,12 @@ module Droonga
|
|
|
111
118
|
"--control-write-fd", control_read_out.fileno.to_s,
|
|
112
119
|
"--job-queue-socket-path", @config.job_pusher.socket_path.to_s,
|
|
113
120
|
"--pid-file", pid_path.to_s,
|
|
121
|
+
"--label", @config.label,
|
|
114
122
|
"--dataset", @config.dataset.name,
|
|
115
123
|
"--database-path", @config.database_path.to_s,
|
|
116
124
|
"--plugins", @config.plugins.join(","),
|
|
125
|
+
"--internal-connection-lifetime",
|
|
126
|
+
@config.internal_connection_lifetime.to_s,
|
|
117
127
|
]
|
|
118
128
|
options = {
|
|
119
129
|
control_write_in => control_write_in,
|
|
@@ -130,14 +140,20 @@ module Droonga
|
|
|
130
140
|
def stop_gracefully(&block)
|
|
131
141
|
logger.trace("stop_gracefully: start")
|
|
132
142
|
@supervisor.stop_gracefully
|
|
133
|
-
@stop_gracefully_callback =
|
|
134
|
-
|
|
143
|
+
@stop_gracefully_callback = lambda do
|
|
144
|
+
yield if block_given?
|
|
145
|
+
logger.trace("stop_gracefully: done")
|
|
146
|
+
end
|
|
135
147
|
end
|
|
136
148
|
|
|
137
149
|
def stop_immediately
|
|
138
150
|
@supervisor.stop_immediately
|
|
139
151
|
end
|
|
140
152
|
|
|
153
|
+
def refresh_node_reference
|
|
154
|
+
@supervisor.refresh_node_reference
|
|
155
|
+
end
|
|
156
|
+
|
|
141
157
|
def success?
|
|
142
158
|
@success
|
|
143
159
|
end
|
|
@@ -158,15 +174,6 @@ module Droonga
|
|
|
158
174
|
supervisor
|
|
159
175
|
end
|
|
160
176
|
|
|
161
|
-
def on_ready
|
|
162
|
-
@on_ready.call if @on_ready
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
def on_failure
|
|
166
|
-
# TODO: log
|
|
167
|
-
@on_failure.call if @on_failure
|
|
168
|
-
end
|
|
169
|
-
|
|
170
177
|
def on_finish
|
|
171
178
|
_, status = Process.waitpid2(@pid)
|
|
172
179
|
@success = status.success?
|