droonga-engine 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -2
- data/Gemfile +1 -1
- data/LICENSE.txt +1 -1
- data/Rakefile +1 -1
- data/benchmark/benchmark.rb +1 -1
- data/benchmark/utils.rb +1 -1
- data/benchmark/watch/benchmark-notify.rb +1 -1
- data/benchmark/watch/benchmark-publish.rb +1 -1
- data/benchmark/watch/benchmark-scan.rb +1 -1
- data/bin/droonga-engine +1 -1
- data/bin/droonga-engine-absorb-data +48 -8
- data/bin/droonga-engine-catalog-generate +1 -1
- data/bin/droonga-engine-catalog-modify +1 -1
- data/bin/droonga-engine-data-publisher +66 -0
- data/bin/droonga-engine-join +72 -17
- data/bin/droonga-engine-serf-event-handler +1 -1
- data/bin/droonga-engine-service +1 -1
- data/bin/droonga-engine-unjoin +11 -4
- data/bin/droonga-engine-worker +20 -0
- data/doc/text/news.md +8 -0
- data/droonga-engine.gemspec +3 -3
- data/lib/droonga/adapter.rb +1 -1
- data/lib/droonga/adapter_runner.rb +1 -1
- data/lib/droonga/address.rb +69 -0
- data/lib/droonga/buffered_tcp_socket.rb +44 -22
- data/lib/droonga/catalog/base.rb +1 -1
- data/lib/droonga/catalog/collection_volume.rb +1 -1
- data/lib/droonga/catalog/dataset.rb +8 -8
- data/lib/droonga/catalog/errors.rb +1 -1
- data/lib/droonga/catalog/schema.rb +1 -1
- data/lib/droonga/catalog/single_volume.rb +6 -8
- data/lib/droonga/catalog/slice.rb +1 -1
- data/lib/droonga/catalog/version1.rb +2 -2
- data/lib/droonga/catalog/version2.rb +6 -6
- data/lib/droonga/catalog/version2_validator.rb +1 -1
- data/lib/droonga/catalog/volume.rb +1 -1
- data/lib/droonga/catalog/volume_collection.rb +2 -2
- data/lib/droonga/catalog_generator.rb +49 -53
- data/lib/droonga/catalog_loader.rb +1 -1
- data/lib/droonga/collector.rb +1 -1
- data/lib/droonga/collector_message.rb +1 -1
- data/lib/droonga/collector_runner.rb +1 -1
- data/lib/droonga/collectors/and.rb +1 -1
- data/lib/droonga/collectors/or.rb +1 -1
- data/lib/droonga/collectors/sum.rb +1 -1
- data/lib/droonga/collectors.rb +1 -1
- data/lib/droonga/command/droonga_engine.rb +103 -55
- data/lib/droonga/command/droonga_engine_service.rb +22 -67
- data/lib/droonga/command/droonga_engine_worker.rb +232 -0
- data/lib/droonga/command/serf_event_handler.rb +126 -46
- data/lib/droonga/data_absorber.rb +32 -14
- data/lib/droonga/dispatcher.rb +15 -11
- data/lib/droonga/distributed_command_planner.rb +1 -1
- data/lib/droonga/distributor.rb +1 -1
- data/lib/droonga/engine/version.rb +2 -2
- data/lib/droonga/engine.rb +8 -3
- data/lib/droonga/engine_state.rb +15 -6
- data/lib/droonga/error.rb +1 -1
- data/lib/droonga/error_messages.rb +1 -1
- data/lib/droonga/event_loop.rb +1 -1
- data/lib/droonga/farm.rb +9 -1
- data/lib/droonga/file_observer.rb +1 -1
- data/lib/droonga/fluent_message_receiver.rb +11 -5
- data/lib/droonga/fluent_message_sender.rb +14 -17
- data/lib/droonga/forwarder.rb +23 -13
- data/lib/droonga/handler.rb +1 -1
- data/lib/droonga/handler_message.rb +1 -1
- data/lib/droonga/handler_messenger.rb +2 -2
- data/lib/droonga/handler_runner.rb +2 -2
- data/lib/droonga/input_message.rb +1 -1
- data/lib/droonga/internal_fluent_message_receiver.rb +3 -2
- data/lib/droonga/job_protocol.rb +1 -1
- data/lib/droonga/job_pusher.rb +1 -1
- data/lib/droonga/job_receiver.rb +1 -1
- data/lib/droonga/line_buffer.rb +1 -1
- data/lib/droonga/live_nodes_list_loader.rb +1 -1
- data/lib/droonga/loggable.rb +1 -1
- data/lib/droonga/logger.rb +3 -3
- data/lib/droonga/message_matcher.rb +1 -1
- data/lib/droonga/output_message.rb +1 -1
- data/lib/droonga/path.rb +5 -1
- data/lib/droonga/planner.rb +1 -1
- data/lib/droonga/pluggable.rb +1 -1
- data/lib/droonga/plugin/metadata/adapter_input_message.rb +1 -1
- data/lib/droonga/plugin/metadata/adapter_output_message.rb +1 -1
- data/lib/droonga/plugin/metadata/collector_message.rb +1 -1
- data/lib/droonga/plugin/metadata/handler_action.rb +1 -1
- data/lib/droonga/plugin/metadata/input_message.rb +1 -1
- data/lib/droonga/plugin.rb +2 -1
- data/lib/droonga/plugin_loader.rb +1 -1
- data/lib/droonga/plugin_registry.rb +3 -1
- data/lib/droonga/plugins/basic.rb +1 -1
- data/lib/droonga/plugins/crud.rb +1 -1
- data/lib/droonga/plugins/dump.rb +13 -2
- data/lib/droonga/plugins/error.rb +1 -1
- data/lib/droonga/plugins/groonga/column_create.rb +1 -1
- data/lib/droonga/plugins/groonga/column_list.rb +1 -1
- data/lib/droonga/plugins/groonga/column_remove.rb +1 -1
- data/lib/droonga/plugins/groonga/column_rename.rb +1 -1
- data/lib/droonga/plugins/groonga/delete.rb +1 -1
- data/lib/droonga/plugins/groonga/generic_command.rb +1 -1
- data/lib/droonga/plugins/groonga/generic_response.rb +1 -1
- data/lib/droonga/plugins/groonga/select.rb +1 -1
- data/lib/droonga/plugins/groonga/table_create.rb +1 -1
- data/lib/droonga/plugins/groonga/table_list.rb +1 -1
- data/lib/droonga/plugins/groonga/table_remove.rb +1 -1
- data/lib/droonga/plugins/groonga.rb +1 -1
- data/lib/droonga/plugins/search/distributed_search_planner.rb +1 -1
- data/lib/droonga/plugins/search.rb +1 -1
- data/lib/droonga/plugins/system.rb +1 -1
- data/lib/droonga/plugins/watch.rb +1 -1
- data/lib/droonga/{service_control_protocol.rb → process_control_protocol.rb} +2 -2
- data/lib/droonga/process_supervisor.rb +91 -0
- data/lib/droonga/processor.rb +1 -1
- data/lib/droonga/reducer.rb +1 -1
- data/lib/droonga/replier.rb +2 -2
- data/lib/droonga/safe_file_writer.rb +1 -1
- data/lib/droonga/schema_applier.rb +1 -1
- data/lib/droonga/searcher/mecab_filter.rb +1 -1
- data/lib/droonga/searcher.rb +31 -19
- data/lib/droonga/serf.rb +81 -14
- data/lib/droonga/serf_downloader.rb +2 -2
- data/lib/droonga/session.rb +1 -1
- data/lib/droonga/single_step.rb +1 -1
- data/lib/droonga/single_step_definition.rb +1 -1
- data/lib/droonga/slice.rb +30 -28
- data/lib/droonga/status_code.rb +1 -1
- data/lib/droonga/step_runner.rb +1 -1
- data/lib/droonga/supervisor.rb +170 -0
- data/lib/droonga/sweeper.rb +1 -1
- data/lib/droonga/test/stub_handler.rb +1 -1
- data/lib/droonga/test/stub_handler_message.rb +1 -1
- data/lib/droonga/test/stub_handler_messenger.rb +1 -1
- data/lib/droonga/test/stub_planner.rb +1 -1
- data/lib/droonga/test.rb +1 -1
- data/lib/droonga/watch_schema.rb +2 -2
- data/lib/droonga/watcher.rb +1 -1
- data/lib/droonga/worker_process_agent.rb +111 -0
- data/sample/cluster/Rakefile +150 -0
- data/test/command/config/default/catalog.json +1 -34
- data/test/command/config/version1/catalog.json +3 -12
- data/test/command/run-test.rb +1 -1
- data/test/command/suite/dump/column/index.expected +19 -82
- data/test/command/suite/dump/column/scalar.expected +5 -36
- data/test/command/suite/dump/column/vector.expected +5 -39
- data/test/command/suite/dump/record/vector/reference.expected +24 -93
- data/test/command/suite/dump/table/array.expected +0 -19
- data/test/command/suite/dump/table/double_array_trie.expected +0 -20
- data/test/command/suite/dump/table/hash.expected +0 -20
- data/test/command/suite/dump/table/patricia_trie.expected +0 -20
- data/test/command/suite/search/condition/query/nonexistent_column.expected +0 -11
- data/test/command/suite/search/condition/query/syntax_error.expected +0 -11
- data/test/command/suite/search/error/unknown-source.expected +0 -12
- data/test/command/suite/search/output/attributes/invalid.expected +0 -10
- data/test/command/suite/search/output/attributes/reference_vector.catalog.json +27 -0
- data/test/command/suite/search/output/attributes/reference_vector.expected +30 -0
- data/test/command/suite/search/output/attributes/reference_vector.test +32 -0
- data/test/command/suite/watch/subscribe.catalog.json +23 -0
- data/test/command/suite/watch/subscribe.test +2 -0
- data/test/command/suite/watch/unsubscribe.catalog.json +23 -0
- data/test/command/suite/watch/unsubscribe.test +2 -0
- data/test/performance/run-test.rb +1 -1
- data/test/unit/catalog/test_collection_volume.rb +1 -1
- data/test/unit/catalog/test_dataset.rb +1 -1
- data/test/unit/catalog/test_schema.rb +1 -1
- data/test/unit/catalog/test_single_volume.rb +27 -19
- data/test/unit/catalog/test_slice.rb +2 -2
- data/test/unit/catalog/test_version1.rb +1 -1
- data/test/unit/catalog/test_version2.rb +1 -1
- data/test/unit/catalog/test_version2_validator.rb +1 -1
- data/test/unit/catalog/test_volume_collection.rb +1 -1
- data/test/unit/helper/distributed_search_planner_helper.rb +1 -1
- data/test/unit/helper/fixture.rb +1 -1
- data/test/unit/helper/plugin_helper.rb +1 -1
- data/test/unit/helper/sandbox.rb +1 -1
- data/test/unit/helper/stub_worker.rb +1 -1
- data/test/unit/helper/watch_helper.rb +1 -1
- data/test/unit/helper.rb +1 -1
- data/test/unit/plugins/crud/test_add.rb +1 -1
- data/test/unit/plugins/groonga/select/test_adapter_input.rb +1 -1
- data/test/unit/plugins/groonga/select/test_adapter_output.rb +1 -1
- data/test/unit/plugins/groonga/test_column_create.rb +1 -1
- data/test/unit/plugins/groonga/test_column_list.rb +1 -1
- data/test/unit/plugins/groonga/test_column_remove.rb +1 -1
- data/test/unit/plugins/groonga/test_column_rename.rb +1 -1
- data/test/unit/plugins/groonga/test_delete.rb +1 -1
- data/test/unit/plugins/groonga/test_table_create.rb +1 -1
- data/test/unit/plugins/groonga/test_table_list.rb +1 -1
- data/test/unit/plugins/groonga/test_table_remove.rb +1 -1
- data/test/unit/plugins/search/planner/test_basic.rb +1 -1
- data/test/unit/plugins/search/planner/test_group_by.rb +1 -1
- data/test/unit/plugins/search/planner/test_output.rb +1 -1
- data/test/unit/plugins/search/planner/test_sort_by.rb +1 -1
- data/test/unit/plugins/search/test_collector.rb +1 -1
- data/test/unit/plugins/search/test_handler.rb +1 -1
- data/test/unit/plugins/search/test_planner.rb +1 -1
- data/test/unit/plugins/system/test_status.rb +1 -1
- data/test/unit/plugins/test_basic.rb +1 -1
- data/test/unit/plugins/test_groonga.rb +1 -1
- data/test/unit/plugins/test_watch.rb +1 -1
- data/test/unit/run-test.rb +1 -1
- data/test/unit/test_address.rb +53 -0
- data/test/unit/test_catalog_generator.rb +59 -1
- data/test/unit/test_line_buffer.rb +1 -1
- data/test/unit/test_message_matcher.rb +1 -1
- data/test/unit/test_schema_applier.rb +1 -1
- data/test/unit/test_sweeper.rb +1 -1
- data/test/unit/test_watch_schema.rb +1 -1
- data/test/unit/test_watcher.rb +1 -1
- metadata +39 -24
- data/lib/droonga/server.rb +0 -45
- data/lib/droonga/worker.rb +0 -66
- data/sample/cluster/catalog.json +0 -42
- data/test/command/config/default/fluentd.conf +0 -11
- data/test/command/config/version1/fluentd.conf +0 -11
@@ -13,9 +13,9 @@
|
|
13
13
|
#
|
14
14
|
# You should have received a copy of the GNU Lesser General Public
|
15
15
|
# License along with this library; if not, write to the Free Software
|
16
|
-
# Foundation, Inc.,
|
16
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
17
17
|
|
18
|
-
require "
|
18
|
+
require "coolio"
|
19
19
|
|
20
20
|
require "droonga/loggable"
|
21
21
|
|
@@ -34,32 +34,32 @@ module Droonga
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def write(data)
|
37
|
-
reserve_write(data)
|
38
|
-
schedule_write
|
39
|
-
data.bytesize
|
40
|
-
end
|
41
|
-
|
42
|
-
def reserve_write(data)
|
43
37
|
chunk = Chunk.new(@data_directory, data, Time.now, 0)
|
44
38
|
chunk.buffering
|
45
39
|
@_write_buffer << chunk
|
40
|
+
schedule_write
|
46
41
|
data.bytesize
|
47
42
|
end
|
48
43
|
|
49
44
|
def on_writable
|
50
|
-
|
45
|
+
until @_write_buffer.empty?
|
51
46
|
chunk = @_write_buffer.shift
|
52
|
-
|
53
|
-
|
54
|
-
chunk.
|
55
|
-
|
56
|
-
|
47
|
+
begin
|
48
|
+
written_size = @_io.write_nonblock(chunk.data)
|
49
|
+
if written_size == chunk.data.bytesize
|
50
|
+
chunk.written
|
51
|
+
else
|
52
|
+
chunk.written_partial(written_size)
|
53
|
+
@_write_buffer.unshift(chunk)
|
54
|
+
break
|
55
|
+
end
|
56
|
+
rescue Errno::EINTR
|
57
57
|
@_write_buffer.unshift(chunk)
|
58
|
+
return
|
59
|
+
rescue SystemCallError, IOError, SocketError
|
60
|
+
@_write_buffer.unshift(chunk)
|
61
|
+
return close
|
58
62
|
end
|
59
|
-
rescue Errno::EINTR
|
60
|
-
return
|
61
|
-
rescue SystemCallError, IOError, SocketError
|
62
|
-
return close
|
63
63
|
end
|
64
64
|
|
65
65
|
if @_write_buffer.empty?
|
@@ -77,16 +77,38 @@ module Droonga
|
|
77
77
|
private
|
78
78
|
def load_chunks
|
79
79
|
FileUtils.mkdir_p(@data_directory.to_s)
|
80
|
-
|
81
|
-
|
82
|
-
end
|
80
|
+
chunk_loader = ChunkLoader.new(@data_directory)
|
81
|
+
chunk_loader.load
|
83
82
|
end
|
84
83
|
|
85
84
|
def log_tag
|
86
|
-
"[#{Process.ppid}]
|
85
|
+
"[#{Process.ppid}] buffered-tcp-socket"
|
86
|
+
end
|
87
|
+
|
88
|
+
class ChunkLoader
|
89
|
+
def initialize(path)
|
90
|
+
@path = path
|
91
|
+
end
|
92
|
+
|
93
|
+
def have_any_chunk?
|
94
|
+
@path.opendir do |dir|
|
95
|
+
dir.each do |entry|
|
96
|
+
return true if entry.end_with?(Chunk::SUFFIX)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
false
|
100
|
+
end
|
101
|
+
|
102
|
+
def load
|
103
|
+
Pathname.glob("#{@path}/*#{Chunk::SUFFIX}").collect do |chunk_path|
|
104
|
+
Chunk.load(chunk_path)
|
105
|
+
end
|
106
|
+
end
|
87
107
|
end
|
88
108
|
|
89
109
|
class Chunk
|
110
|
+
SUFFIX = ".chunk"
|
111
|
+
|
90
112
|
class << self
|
91
113
|
def load(path)
|
92
114
|
data_directory = path.dirname
|
data/lib/droonga/catalog/base.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# You should have received a copy of the GNU Lesser General Public
|
13
13
|
# License along with this library; if not, write to the Free Software
|
14
|
-
# Foundation, Inc.,
|
14
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
15
15
|
|
16
16
|
require "digest/sha1"
|
17
17
|
require "zlib"
|
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# You should have received a copy of the GNU Lesser General Public
|
13
13
|
# License along with this library; if not, write to the Free Software
|
14
|
-
# Foundation, Inc.,
|
14
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
15
15
|
|
16
16
|
require "digest/sha1"
|
17
17
|
require "zlib"
|
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# You should have received a copy of the GNU Lesser General Public
|
13
13
|
# License along with this library; if not, write to the Free Software
|
14
|
-
# Foundation, Inc.,
|
14
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
15
15
|
|
16
16
|
require "droonga/catalog/schema"
|
17
17
|
require "droonga/catalog/volume"
|
@@ -62,22 +62,22 @@ module Droonga
|
|
62
62
|
@all_nodes ||= replicas.all_nodes
|
63
63
|
end
|
64
64
|
|
65
|
-
def
|
65
|
+
def compute_routes(message, live_nodes)
|
66
66
|
routes = []
|
67
|
-
case
|
67
|
+
case message["type"]
|
68
68
|
when "broadcast"
|
69
|
-
volumes = replicas.select(
|
69
|
+
volumes = replicas.select(message["replica"].to_sym, live_nodes)
|
70
70
|
volumes.each do |volume|
|
71
71
|
slices = volume.select_slices
|
72
72
|
slices.each do |slice|
|
73
|
-
routes << slice.volume.address
|
73
|
+
routes << slice.volume.address.to_s
|
74
74
|
end
|
75
75
|
end
|
76
76
|
when "scatter"
|
77
|
-
volumes = replicas.select(
|
77
|
+
volumes = replicas.select(message["replica"].to_sym, live_nodes)
|
78
78
|
volumes.each do |volume|
|
79
|
-
slice = volume.choose_slice(
|
80
|
-
routes << slice.volume.address
|
79
|
+
slice = volume.choose_slice(message["record"])
|
80
|
+
routes << slice.volume.address.to_s
|
81
81
|
end
|
82
82
|
end
|
83
83
|
routes
|
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# You should have received a copy of the GNU Lesser General Public
|
13
13
|
# License along with this library; if not, write to the Free Software
|
14
|
-
# Foundation, Inc.,
|
14
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
15
15
|
|
16
16
|
require "droonga/error"
|
17
17
|
|
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# You should have received a copy of the GNU Lesser General Public
|
13
13
|
# License along with this library; if not, write to the Free Software
|
14
|
-
# Foundation, Inc.,
|
14
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
15
15
|
|
16
16
|
require "tsort"
|
17
17
|
|
@@ -11,23 +11,21 @@
|
|
11
11
|
#
|
12
12
|
# You should have received a copy of the GNU Lesser General Public
|
13
13
|
# License along with this library; if not, write to the Free Software
|
14
|
-
# Foundation, Inc.,
|
14
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
15
|
+
|
16
|
+
require "droonga/address"
|
15
17
|
|
16
18
|
module Droonga
|
17
19
|
module Catalog
|
18
20
|
class SingleVolume
|
21
|
+
attr_reader :address
|
19
22
|
def initialize(data)
|
20
23
|
@data = data
|
21
|
-
|
22
|
-
|
23
|
-
def address
|
24
|
-
@data["address"]
|
24
|
+
@address = Address.parse(@data["address"])
|
25
25
|
end
|
26
26
|
|
27
27
|
def node
|
28
|
-
|
29
|
-
tag = path.split(".").first
|
30
|
-
"#{ip_address_and_port}/#{tag}"
|
28
|
+
@address.node
|
31
29
|
end
|
32
30
|
|
33
31
|
def all_nodes
|
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# You should have received a copy of the GNU Lesser General Public
|
13
13
|
# License along with this library; if not, write to the Free Software
|
14
|
-
# Foundation, Inc.,
|
14
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
15
15
|
|
16
16
|
module Droonga
|
17
17
|
module Catalog
|
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# You should have received a copy of the GNU Lesser General Public
|
13
13
|
# License along with this library; if not, write to the Free Software
|
14
|
-
# Foundation, Inc.,
|
14
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
15
15
|
|
16
16
|
require "English"
|
17
17
|
|
@@ -385,7 +385,7 @@ module Droonga
|
|
385
385
|
end
|
386
386
|
|
387
387
|
class Dataset < Catalog::Dataset
|
388
|
-
def
|
388
|
+
def compute_routes(args, live_nodes=nil)
|
389
389
|
routes = []
|
390
390
|
case args["type"]
|
391
391
|
when "broadcast"
|
@@ -11,8 +11,9 @@
|
|
11
11
|
#
|
12
12
|
# You should have received a copy of the GNU Lesser General Public
|
13
13
|
# License along with this library; if not, write to the Free Software
|
14
|
-
# Foundation, Inc.,
|
14
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
15
15
|
|
16
|
+
require "droonga/address"
|
16
17
|
require "droonga/catalog/base"
|
17
18
|
require "droonga/catalog/dataset"
|
18
19
|
require "droonga/catalog/version2_validator"
|
@@ -30,9 +31,8 @@ module Droonga
|
|
30
31
|
@datasets
|
31
32
|
end
|
32
33
|
|
33
|
-
def slices(
|
34
|
+
def slices(node)
|
34
35
|
device = "."
|
35
|
-
pattern = Regexp.new("^#{name}\.")
|
36
36
|
results = {}
|
37
37
|
@datasets.each do |dataset_name, dataset|
|
38
38
|
n_workers = dataset.n_workers
|
@@ -40,8 +40,8 @@ module Droonga
|
|
40
40
|
dataset.replicas.each do |volume|
|
41
41
|
volume.slices.each do |slice|
|
42
42
|
volume_address = slice.volume.address
|
43
|
-
if
|
44
|
-
path = File.join([device,
|
43
|
+
if volume_address.node == node
|
44
|
+
path = File.join([device, volume_address.name, "db"])
|
45
45
|
path = File.expand_path(path, base_path)
|
46
46
|
options = {
|
47
47
|
:dataset => dataset_name,
|
@@ -49,7 +49,7 @@ module Droonga
|
|
49
49
|
:n_workers => n_workers,
|
50
50
|
:plugins => plugins
|
51
51
|
}
|
52
|
-
results[volume_address] = options
|
52
|
+
results[volume_address.to_s] = options
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# You should have received a copy of the GNU Lesser General Public
|
13
13
|
# License along with this library; if not, write to the Free Software
|
14
|
-
# Foundation, Inc.,
|
14
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
15
15
|
|
16
16
|
require "droonga/catalog/errors"
|
17
17
|
|
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# You should have received a copy of the GNU Lesser General Public
|
13
13
|
# License along with this library; if not, write to the Free Software
|
14
|
-
# Foundation, Inc.,
|
14
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
15
15
|
|
16
16
|
require "droonga/catalog/single_volume"
|
17
17
|
require "droonga/catalog/collection_volume"
|
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# You should have received a copy of the GNU Lesser General Public
|
13
13
|
# License along with this library; if not, write to the Free Software
|
14
|
-
# Foundation, Inc.,
|
14
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
15
15
|
|
16
16
|
module Droonga
|
17
17
|
module Catalog
|
@@ -47,7 +47,7 @@ module Droonga
|
|
47
47
|
when :random
|
48
48
|
[volumes.sample]
|
49
49
|
when :all
|
50
|
-
volumes
|
50
|
+
@volumes
|
51
51
|
else
|
52
52
|
super
|
53
53
|
end
|
@@ -11,10 +11,12 @@
|
|
11
11
|
#
|
12
12
|
# You should have received a copy of the GNU Lesser General Public
|
13
13
|
# License along with this library; if not, write to the Free Software
|
14
|
-
# Foundation, Inc.,
|
14
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
15
15
|
|
16
16
|
require "time"
|
17
17
|
|
18
|
+
require "droonga/catalog/dataset"
|
19
|
+
|
18
20
|
module Droonga
|
19
21
|
class CatalogGenerator
|
20
22
|
DEFAULT_DATASET = "Default"
|
@@ -56,8 +58,8 @@ module Droonga
|
|
56
58
|
end
|
57
59
|
|
58
60
|
def load(catalog)
|
59
|
-
catalog["datasets"].each do |name,
|
60
|
-
|
61
|
+
catalog["datasets"].each do |name, catalog_dataset|
|
62
|
+
load_dataset(name, catalog_dataset)
|
61
63
|
end
|
62
64
|
self
|
63
65
|
end
|
@@ -102,6 +104,16 @@ module Droonga
|
|
102
104
|
catalog_datasets
|
103
105
|
end
|
104
106
|
|
107
|
+
def load_dataset(name, catalog_dataset)
|
108
|
+
options = {}
|
109
|
+
options[:n_workers] = catalog_dataset["nWorkers"]
|
110
|
+
options[:plugins] = catalog_dataset["plugins"]
|
111
|
+
options[:schema] = catalog_dataset["schema"]
|
112
|
+
options[:fact] = catalog_dataset["fact"]
|
113
|
+
options[:replicas] = catalog_dataset["replicas"]
|
114
|
+
add_dataset(name, options)
|
115
|
+
end
|
116
|
+
|
105
117
|
class Dataset
|
106
118
|
attr_reader :name
|
107
119
|
|
@@ -127,8 +139,7 @@ module Droonga
|
|
127
139
|
end
|
128
140
|
|
129
141
|
def replicas
|
130
|
-
|
131
|
-
@generated_replicas ||= Replicas.new(@options)
|
142
|
+
@replicas ||= create_replicas
|
132
143
|
end
|
133
144
|
|
134
145
|
def to_catalog
|
@@ -136,13 +147,23 @@ module Droonga
|
|
136
147
|
"nWorkers" => n_workers,
|
137
148
|
"plugins" => plugins,
|
138
149
|
"schema" => schema,
|
139
|
-
"replicas" => replicas.
|
150
|
+
"replicas" => replicas.to_catalog,
|
140
151
|
}
|
141
152
|
catalog["fact"] = fact if fact
|
142
153
|
catalog
|
143
154
|
end
|
144
155
|
|
145
156
|
private
|
157
|
+
def create_replicas
|
158
|
+
catalog_replicas = @options[:replicas]
|
159
|
+
if catalog_replicas
|
160
|
+
replicas = Replicas.new
|
161
|
+
replicas.load(catalog_replicas)
|
162
|
+
replicas
|
163
|
+
else
|
164
|
+
Replicas.new(@options)
|
165
|
+
end
|
166
|
+
end
|
146
167
|
end
|
147
168
|
|
148
169
|
class Replicas
|
@@ -156,20 +177,29 @@ module Droonga
|
|
156
177
|
@n_slices = options[:n_slices]
|
157
178
|
end
|
158
179
|
|
159
|
-
def
|
160
|
-
|
180
|
+
def load(catalog_replicas)
|
181
|
+
dataset = Catalog::Dataset.new("temporary",
|
182
|
+
"replicas" => catalog_replicas)
|
183
|
+
@hosts = dataset.replicas.collect do |replica|
|
184
|
+
replica.slices.first.volume.address.host
|
185
|
+
end
|
186
|
+
collection_volume = dataset.replicas.first
|
187
|
+
slices = collection_volume.slices
|
188
|
+
@n_slices = slices.size
|
189
|
+
single_volume_address = slices.first.volume.address
|
190
|
+
@port = single_volume_address.port
|
191
|
+
@tag = single_volume_address.tag
|
161
192
|
end
|
162
193
|
|
163
|
-
|
164
|
-
|
165
|
-
replicas = []
|
194
|
+
def to_catalog
|
195
|
+
catalog_replicas = []
|
166
196
|
@hosts.each do |host|
|
167
197
|
replica = Replica.new(host, :port => @port,
|
168
198
|
:tag => @tag,
|
169
199
|
:n_slices => @n_slices)
|
170
|
-
|
200
|
+
catalog_replicas << replica.to_catalog
|
171
201
|
end
|
172
|
-
|
202
|
+
catalog_replicas
|
173
203
|
end
|
174
204
|
end
|
175
205
|
|
@@ -179,19 +209,12 @@ module Droonga
|
|
179
209
|
@port = options[:port] || DEFAULT_PORT
|
180
210
|
@tag = options[:tag] || DEFAULT_TAG
|
181
211
|
@n_slices = options[:n_slices] || DEFAULT_N_SLICES
|
182
|
-
|
183
|
-
@n_volumes = 0
|
184
|
-
end
|
185
|
-
|
186
|
-
def to_json
|
187
|
-
@json ||= generate_json
|
188
212
|
end
|
189
213
|
|
190
|
-
|
191
|
-
def generate_json
|
214
|
+
def to_catalog
|
192
215
|
slices = []
|
193
|
-
@n_slices.times do |
|
194
|
-
slices <<
|
216
|
+
@n_slices.times do |i|
|
217
|
+
slices << catalog_slice(i)
|
195
218
|
end
|
196
219
|
{
|
197
220
|
"dimension" => "_key",
|
@@ -200,9 +223,9 @@ module Droonga
|
|
200
223
|
}
|
201
224
|
end
|
202
225
|
|
203
|
-
|
204
|
-
|
205
|
-
|
226
|
+
private
|
227
|
+
def catalog_slice(nth_slice)
|
228
|
+
name = "%03d" % nth_slice
|
206
229
|
{
|
207
230
|
"weight" => weight,
|
208
231
|
"volume" => {
|
@@ -215,32 +238,5 @@ module Droonga
|
|
215
238
|
@weight ||= 100 / @n_slices
|
216
239
|
end
|
217
240
|
end
|
218
|
-
|
219
|
-
ADDRESS_MATCHER = /\A(.*):(\d+)\/([^\.]+)\.(.+)\z/
|
220
|
-
|
221
|
-
def dataset_to_params(dataset)
|
222
|
-
params = {}
|
223
|
-
params[:n_workers] = dataset["nWorkers"]
|
224
|
-
params[:n_slices] = dataset["replicas"].first["slices"].size
|
225
|
-
params[:plugins] = dataset["plugins"]
|
226
|
-
params[:schema] = dataset["schema"] if dataset["schema"]
|
227
|
-
params[:fact] = dataset["fact"] if dataset["fact"]
|
228
|
-
|
229
|
-
nodes = dataset["replicas"].collect do |replica|
|
230
|
-
ADDRESS_MATCHER =~ replica["slices"].first["volume"]["address"]
|
231
|
-
{
|
232
|
-
:host => $1,
|
233
|
-
:port => $2.to_i,
|
234
|
-
:tag => $3,
|
235
|
-
:path => $4,
|
236
|
-
}
|
237
|
-
end
|
238
|
-
params[:tag] = nodes.first[:tag]
|
239
|
-
params[:port] = nodes.first[:port].to_i
|
240
|
-
params[:hosts] = nodes.collect do |node|
|
241
|
-
node[:host]
|
242
|
-
end
|
243
|
-
params
|
244
|
-
end
|
245
241
|
end
|
246
242
|
end
|
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# You should have received a copy of the GNU Lesser General Public
|
13
13
|
# License along with this library; if not, write to the Free Software
|
14
|
-
# Foundation, Inc.,
|
14
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
15
15
|
|
16
16
|
require "json"
|
17
17
|
|
data/lib/droonga/collector.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# You should have received a copy of the GNU Lesser General Public
|
13
13
|
# License along with this library; if not, write to the Free Software
|
14
|
-
# Foundation, Inc.,
|
14
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
15
15
|
|
16
16
|
require "droonga/pluggable"
|
17
17
|
require "droonga/plugin/metadata/collector_message"
|
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# You should have received a copy of the GNU Lesser General Public
|
13
13
|
# License along with this library; if not, write to the Free Software
|
14
|
-
# Foundation, Inc.,
|
14
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
15
15
|
|
16
16
|
module Droonga
|
17
17
|
class CollectorMessage
|
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# You should have received a copy of the GNU Lesser General Public
|
13
13
|
# License along with this library; if not, write to the Free Software
|
14
|
-
# Foundation, Inc.,
|
14
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
15
15
|
|
16
16
|
require "droonga/loggable"
|
17
17
|
require "droonga/message_matcher"
|
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# You should have received a copy of the GNU Lesser General Public
|
13
13
|
# License along with this library; if not, write to the Free Software
|
14
|
-
# Foundation, Inc.,
|
14
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
15
15
|
|
16
16
|
module Droonga
|
17
17
|
module Collectors
|
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# You should have received a copy of the GNU Lesser General Public
|
13
13
|
# License along with this library; if not, write to the Free Software
|
14
|
-
# Foundation, Inc.,
|
14
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
15
15
|
|
16
16
|
module Droonga
|
17
17
|
module Collectors
|
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# You should have received a copy of the GNU Lesser General Public
|
13
13
|
# License along with this library; if not, write to the Free Software
|
14
|
-
# Foundation, Inc.,
|
14
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
15
15
|
|
16
16
|
module Droonga
|
17
17
|
module Collectors
|
data/lib/droonga/collectors.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# You should have received a copy of the GNU Lesser General Public
|
13
13
|
# License along with this library; if not, write to the Free Software
|
14
|
-
# Foundation, Inc.,
|
14
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
15
15
|
|
16
16
|
require "droonga/collectors/and"
|
17
17
|
require "droonga/collectors/or"
|