droonga-engine 1.0.4 → 1.0.5
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/.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
|
@@ -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 "groonga/command/column-list"
|
|
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 "groonga/command/column-remove"
|
|
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 "groonga/command/column-rename"
|
|
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 "groonga/command/delete"
|
|
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 "groonga"
|
|
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/plugin"
|
|
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/plugin"
|
|
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 "groonga/command/table-create"
|
|
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/plugin"
|
|
17
17
|
require "droonga/plugins/groonga/generic_command"
|
|
@@ -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 "groonga/command/table-remove"
|
|
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/plugin"
|
|
17
17
|
|
|
@@ -13,7 +13,7 @@
|
|
|
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
18
|
require "droonga/searcher"
|
|
19
19
|
require "droonga/distributed_command_planner"
|
|
@@ -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/plugin"
|
|
17
17
|
require "droonga/searcher"
|
|
@@ -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/plugin"
|
|
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/plugin"
|
|
17
17
|
require "droonga/watcher"
|
|
@@ -11,10 +11,10 @@
|
|
|
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
|
-
module
|
|
17
|
+
module ProcessControlProtocol
|
|
18
18
|
module Messages
|
|
19
19
|
STOP_GRACEFUL = "stop-graceful\n"
|
|
20
20
|
STOP_IMMEDIATELY = "stop-immediately\n"
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Copyright (C) 2014 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
|
+
require "coolio"
|
|
17
|
+
|
|
18
|
+
require "droonga/process_control_protocol"
|
|
19
|
+
require "droonga/line_buffer"
|
|
20
|
+
|
|
21
|
+
module Droonga
|
|
22
|
+
class ProcessSupervisor
|
|
23
|
+
include ProcessControlProtocol
|
|
24
|
+
|
|
25
|
+
def initialize(loop, input, output)
|
|
26
|
+
@loop = loop
|
|
27
|
+
@input = create_input(input)
|
|
28
|
+
@output = create_output(output)
|
|
29
|
+
@on_ready = nil
|
|
30
|
+
@on_finish = nil
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def start
|
|
34
|
+
@loop.attach(@input)
|
|
35
|
+
@loop.attach(@output)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def stop
|
|
39
|
+
@input.close
|
|
40
|
+
@output.close
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def stop_gracefully
|
|
44
|
+
@output.write(Messages::STOP_GRACEFUL)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def stop_immediately
|
|
48
|
+
@output.write(Messages::STOP_IMMEDIATELY)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def on_ready=(callback)
|
|
52
|
+
@on_ready = callback
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def on_finish=(callback)
|
|
56
|
+
@on_finish = callback
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
private
|
|
60
|
+
def create_input(raw_input)
|
|
61
|
+
input = Coolio::IO.new(raw_input)
|
|
62
|
+
line_buffer = LineBuffer.new
|
|
63
|
+
on_read = lambda do |data|
|
|
64
|
+
line_buffer.feed(data) do |line|
|
|
65
|
+
case line
|
|
66
|
+
when Messages::READY
|
|
67
|
+
on_ready
|
|
68
|
+
when Messages::FINISH
|
|
69
|
+
on_finish
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
input.on_read do |data|
|
|
74
|
+
on_read.call(data)
|
|
75
|
+
end
|
|
76
|
+
input
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def create_output(raw_output)
|
|
80
|
+
Coolio::IO.new(raw_output)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def on_ready
|
|
84
|
+
@on_ready.call if @on_ready
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def on_finish
|
|
88
|
+
@on_finish.call if @on_finish
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
data/lib/droonga/processor.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/loggable"
|
|
17
17
|
require "droonga/handler_runner"
|
data/lib/droonga/reducer.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
|
module Droonga
|
|
17
17
|
class Reducer
|
data/lib/droonga/replier.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/loggable"
|
|
17
17
|
require "droonga/status_code"
|
|
@@ -43,7 +43,7 @@ module Droonga
|
|
|
43
43
|
|
|
44
44
|
private
|
|
45
45
|
def log_tag
|
|
46
|
-
"[#{Process.ppid}]
|
|
46
|
+
"[#{Process.ppid}] replier"
|
|
47
47
|
end
|
|
48
48
|
end
|
|
49
49
|
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 "pathname"
|
|
17
17
|
require "fileutils"
|
|
@@ -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
|
|
|
@@ -13,7 +13,7 @@
|
|
|
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
18
|
require "MeCab"
|
|
19
19
|
|
data/lib/droonga/searcher.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 "English"
|
|
17
17
|
require "tsort"
|
|
@@ -139,7 +139,7 @@ module Droonga
|
|
|
139
139
|
end
|
|
140
140
|
|
|
141
141
|
def log_tag
|
|
142
|
-
"[#{Process.ppid}]
|
|
142
|
+
"[#{Process.ppid}] searcher"
|
|
143
143
|
end
|
|
144
144
|
|
|
145
145
|
class QuerySorter
|
|
@@ -448,7 +448,7 @@ module Droonga
|
|
|
448
448
|
end
|
|
449
449
|
|
|
450
450
|
def log_tag
|
|
451
|
-
"[#{Process.ppid}]
|
|
451
|
+
"[#{Process.ppid}] query_searcher"
|
|
452
452
|
end
|
|
453
453
|
end
|
|
454
454
|
|
|
@@ -529,6 +529,21 @@ module Droonga
|
|
|
529
529
|
end
|
|
530
530
|
|
|
531
531
|
module RecordsFormattable
|
|
532
|
+
def format(output_target_attributes, records, output_limit, output_offset)
|
|
533
|
+
cursor_options = {
|
|
534
|
+
:offset => output_offset,
|
|
535
|
+
:limit => output_limit
|
|
536
|
+
}
|
|
537
|
+
formatted_records = nil
|
|
538
|
+
records.open_cursor(cursor_options) do |cursor|
|
|
539
|
+
formatted_records = cursor.collect do |record|
|
|
540
|
+
format_record(output_target_attributes, record)
|
|
541
|
+
end
|
|
542
|
+
end
|
|
543
|
+
formatted_records
|
|
544
|
+
end
|
|
545
|
+
|
|
546
|
+
private
|
|
532
547
|
def record_value(record, attribute)
|
|
533
548
|
if attribute[:source] == "_subrecs"
|
|
534
549
|
if record.table.is_a?(Groonga::Array)
|
|
@@ -547,34 +562,30 @@ module Droonga
|
|
|
547
562
|
variable.value = record
|
|
548
563
|
expression.execute
|
|
549
564
|
else
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
value.record_id
|
|
553
|
-
else
|
|
554
|
-
value
|
|
555
|
-
end
|
|
565
|
+
column_value = record[attribute[:source]]
|
|
566
|
+
format_column_value(column_value)
|
|
556
567
|
end
|
|
557
568
|
end
|
|
558
569
|
end
|
|
559
570
|
|
|
560
|
-
def
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
formatted_records = cursor.collect do |record|
|
|
568
|
-
format_record(output_target_attributes, record)
|
|
571
|
+
def format_column_value(column_value)
|
|
572
|
+
case column_value
|
|
573
|
+
when Groonga::Record
|
|
574
|
+
column_value.record_id
|
|
575
|
+
when Array
|
|
576
|
+
column_value.collect do |sub_column_value|
|
|
577
|
+
format_column_value(sub_column_value)
|
|
569
578
|
end
|
|
579
|
+
else
|
|
580
|
+
column_value
|
|
570
581
|
end
|
|
571
|
-
formatted_records
|
|
572
582
|
end
|
|
573
583
|
end
|
|
574
584
|
|
|
575
585
|
class SimpleRecordsFormatter
|
|
576
586
|
include RecordsFormattable
|
|
577
587
|
|
|
588
|
+
private
|
|
578
589
|
def format_record(attributes, record)
|
|
579
590
|
attributes.collect do |attribute|
|
|
580
591
|
record_value(record, attribute)
|
|
@@ -585,6 +596,7 @@ module Droonga
|
|
|
585
596
|
class ComplexRecordsFormatter
|
|
586
597
|
include RecordsFormattable
|
|
587
598
|
|
|
599
|
+
private
|
|
588
600
|
def format_record(attributes, record)
|
|
589
601
|
values = {}
|
|
590
602
|
attributes.each do |attribute|
|
data/lib/droonga/serf.rb
CHANGED
|
@@ -11,12 +11,13 @@
|
|
|
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
|
|
|
18
18
|
require "json"
|
|
19
19
|
require "coolio"
|
|
20
|
+
require "open3"
|
|
20
21
|
|
|
21
22
|
require "droonga/path"
|
|
22
23
|
require "droonga/loggable"
|
|
@@ -57,13 +58,17 @@ module Droonga
|
|
|
57
58
|
{}
|
|
58
59
|
end
|
|
59
60
|
|
|
60
|
-
def
|
|
61
|
-
|
|
61
|
+
def status(key)
|
|
62
|
+
load_status[key]
|
|
62
63
|
end
|
|
63
64
|
|
|
64
65
|
def send_query(name, query, payload)
|
|
65
66
|
new(nil, name).send_query(query, payload)
|
|
66
67
|
end
|
|
68
|
+
|
|
69
|
+
def live_nodes(name)
|
|
70
|
+
new(nil, name).live_nodes
|
|
71
|
+
end
|
|
67
72
|
end
|
|
68
73
|
|
|
69
74
|
include Loggable
|
|
@@ -98,22 +103,49 @@ module Droonga
|
|
|
98
103
|
@agent and @agent.running?
|
|
99
104
|
end
|
|
100
105
|
|
|
101
|
-
def
|
|
102
|
-
logger.trace("
|
|
103
|
-
run("leave").
|
|
104
|
-
@agent.
|
|
106
|
+
def stop
|
|
107
|
+
logger.trace("stop: start")
|
|
108
|
+
run("leave").stop
|
|
109
|
+
@agent.stop
|
|
105
110
|
@agent = nil
|
|
106
|
-
logger.trace("
|
|
111
|
+
logger.trace("stop: done")
|
|
107
112
|
end
|
|
108
113
|
|
|
109
|
-
def
|
|
114
|
+
def send_query(query, payload)
|
|
110
115
|
ensure_serf
|
|
111
|
-
|
|
116
|
+
options = ["-format", "json"] + additional_options_from_payload(payload)
|
|
117
|
+
options += [query, JSON.generate(payload)]
|
|
118
|
+
result = run_once("query", *options)
|
|
119
|
+
if payload["node"]
|
|
120
|
+
responses = result[:result]["Responses"]
|
|
121
|
+
response = responses[payload["node"]]
|
|
122
|
+
if response.is_a?(String)
|
|
123
|
+
begin
|
|
124
|
+
result[:response] = JSON.parse(response)
|
|
125
|
+
rescue JSON::ParserError
|
|
126
|
+
result[:response] = response
|
|
127
|
+
end
|
|
128
|
+
else
|
|
129
|
+
result[:response] = response
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
result
|
|
112
133
|
end
|
|
113
134
|
|
|
114
|
-
def
|
|
135
|
+
def live_nodes
|
|
115
136
|
ensure_serf
|
|
116
|
-
|
|
137
|
+
nodes = {}
|
|
138
|
+
result= run_once("members", "-format", "json")
|
|
139
|
+
members = result[:result]
|
|
140
|
+
members["members"].each do |member|
|
|
141
|
+
if member["status"] == "alive"
|
|
142
|
+
nodes[member["name"]] = {
|
|
143
|
+
"serfAddress" => member["addr"],
|
|
144
|
+
"tags" => member["tags"],
|
|
145
|
+
}
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
nodes
|
|
117
149
|
end
|
|
118
150
|
|
|
119
151
|
private
|
|
@@ -145,6 +177,21 @@ module Droonga
|
|
|
145
177
|
process
|
|
146
178
|
end
|
|
147
179
|
|
|
180
|
+
def run_once(command, *options)
|
|
181
|
+
process = SerfProcess.new(@loop, @serf, command,
|
|
182
|
+
"-rpc-addr", rpc_address,
|
|
183
|
+
*options)
|
|
184
|
+
process.run_once
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
def additional_options_from_payload(payload)
|
|
188
|
+
options = []
|
|
189
|
+
if payload.is_a?(Hash) and payload.include?("node")
|
|
190
|
+
options += ["-node", payload["node"]]
|
|
191
|
+
end
|
|
192
|
+
options
|
|
193
|
+
end
|
|
194
|
+
|
|
148
195
|
def extract_host(node_name)
|
|
149
196
|
node_name.split(":").first
|
|
150
197
|
end
|
|
@@ -220,7 +267,7 @@ module Droonga
|
|
|
220
267
|
end
|
|
221
268
|
end
|
|
222
269
|
|
|
223
|
-
def
|
|
270
|
+
def stop
|
|
224
271
|
return if @pid.nil?
|
|
225
272
|
Process.waitpid(@pid)
|
|
226
273
|
@output_io.close
|
|
@@ -232,6 +279,15 @@ module Droonga
|
|
|
232
279
|
not @pid.nil?
|
|
233
280
|
end
|
|
234
281
|
|
|
282
|
+
def run_once
|
|
283
|
+
stdout, stderror, status = Open3.capture3(@serf, @command, *@options, :pgroup => true)
|
|
284
|
+
{
|
|
285
|
+
:result => JSON.parse(stdout),
|
|
286
|
+
:error => stderror,
|
|
287
|
+
:status => status,
|
|
288
|
+
}
|
|
289
|
+
end
|
|
290
|
+
|
|
235
291
|
private
|
|
236
292
|
def capture_output
|
|
237
293
|
result = nil
|
|
@@ -290,7 +346,8 @@ module Droonga
|
|
|
290
346
|
hour, minute, second = $4, $5, $6
|
|
291
347
|
level = $7
|
|
292
348
|
content = $POSTMATCH
|
|
293
|
-
|
|
349
|
+
level = normalize_level(level)
|
|
350
|
+
logger.send(level, content)
|
|
294
351
|
else
|
|
295
352
|
logger.info(content)
|
|
296
353
|
end
|
|
@@ -300,6 +357,16 @@ module Droonga
|
|
|
300
357
|
end
|
|
301
358
|
end
|
|
302
359
|
|
|
360
|
+
def normalize_level(level)
|
|
361
|
+
level = level.downcase
|
|
362
|
+
case level
|
|
363
|
+
when "err"
|
|
364
|
+
"error"
|
|
365
|
+
else
|
|
366
|
+
level
|
|
367
|
+
end
|
|
368
|
+
end
|
|
369
|
+
|
|
303
370
|
def on_error_output(line_buffer, data)
|
|
304
371
|
line_buffer.feed(data) do |line|
|
|
305
372
|
line = line.chomp
|
|
@@ -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 "stringio"
|
|
17
17
|
require "tmpdir"
|
|
@@ -33,7 +33,7 @@ module Droonga
|
|
|
33
33
|
|
|
34
34
|
def download
|
|
35
35
|
detect_platform
|
|
36
|
-
version = "0.6.
|
|
36
|
+
version = "0.6.3"
|
|
37
37
|
url_base = "https://dl.bintray.com/mitchellh/serf"
|
|
38
38
|
base_name = "#{version}_#{@os}_#{@architecture}.zip"
|
|
39
39
|
connection = Faraday.new(url_base) do |builder|
|
data/lib/droonga/session.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
|
module Droonga
|
|
17
17
|
class Session
|
data/lib/droonga/single_step.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/planner"
|
|
17
17
|
require "droonga/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
|
class SingleStepDefinition
|