droonga-engine 1.0.1
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.
- data/.dir-locals.el +3 -0
- data/.gitignore +6 -0
- data/.travis.yml +15 -0
- data/.yardopts +7 -0
- data/Gemfile +66 -0
- data/LICENSE.txt +14 -0
- data/README.md +17 -0
- data/Rakefile +64 -0
- data/benchmark/benchmark.rb +123 -0
- data/benchmark/utils.rb +246 -0
- data/benchmark/watch/benchmark-notify.rb +143 -0
- data/benchmark/watch/benchmark-notify.sh +20 -0
- data/benchmark/watch/benchmark-publish.rb +120 -0
- data/benchmark/watch/benchmark-scan.rb +213 -0
- data/bin/droonga-catalog-generate +103 -0
- data/bin/droonga-engine +20 -0
- data/bin/droonga-engine-service +20 -0
- data/doc/text/news.md +106 -0
- data/droonga-engine.gemspec +52 -0
- data/lib/droonga/adapter.rb +48 -0
- data/lib/droonga/adapter_runner.rb +104 -0
- data/lib/droonga/catalog/base.rb +41 -0
- data/lib/droonga/catalog/collection_volume.rb +106 -0
- data/lib/droonga/catalog/dataset.rb +69 -0
- data/lib/droonga/catalog/errors.rb +113 -0
- data/lib/droonga/catalog/schema.rb +186 -0
- data/lib/droonga/catalog/single_volume.rb +28 -0
- data/lib/droonga/catalog/slice.rb +41 -0
- data/lib/droonga/catalog/version1.rb +427 -0
- data/lib/droonga/catalog/version2.rb +96 -0
- data/lib/droonga/catalog/version2_validator.rb +63 -0
- data/lib/droonga/catalog/volume.rb +33 -0
- data/lib/droonga/catalog/volume_collection.rb +56 -0
- data/lib/droonga/catalog_generator.rb +156 -0
- data/lib/droonga/catalog_loader.rb +56 -0
- data/lib/droonga/catalog_observer.rb +83 -0
- data/lib/droonga/collector.rb +38 -0
- data/lib/droonga/collector_message.rb +71 -0
- data/lib/droonga/collector_runner.rb +64 -0
- data/lib/droonga/collectors/and.rb +26 -0
- data/lib/droonga/collectors/or.rb +26 -0
- data/lib/droonga/collectors/sum.rb +26 -0
- data/lib/droonga/collectors.rb +18 -0
- data/lib/droonga/dispatcher.rb +326 -0
- data/lib/droonga/distributed_command_planner.rb +179 -0
- data/lib/droonga/distributor.rb +87 -0
- data/lib/droonga/engine/command/droonga_engine.rb +441 -0
- data/lib/droonga/engine/version.rb +20 -0
- data/lib/droonga/engine.rb +80 -0
- data/lib/droonga/engine_state.rb +79 -0
- data/lib/droonga/error.rb +73 -0
- data/lib/droonga/error_messages.rb +33 -0
- data/lib/droonga/event_loop.rb +46 -0
- data/lib/droonga/farm.rb +58 -0
- data/lib/droonga/fluent_message_receiver.rb +191 -0
- data/lib/droonga/fluent_message_sender.rb +140 -0
- data/lib/droonga/forwarder.rb +119 -0
- data/lib/droonga/handler.rb +49 -0
- data/lib/droonga/handler_message.rb +61 -0
- data/lib/droonga/handler_messenger.rb +119 -0
- data/lib/droonga/handler_runner.rb +125 -0
- data/lib/droonga/input_message.rb +51 -0
- data/lib/droonga/job_protocol.rb +20 -0
- data/lib/droonga/job_pusher.rb +179 -0
- data/lib/droonga/job_receiver.rb +70 -0
- data/lib/droonga/loggable.rb +29 -0
- data/lib/droonga/logger.rb +142 -0
- data/lib/droonga/message_matcher.rb +109 -0
- data/lib/droonga/output_message.rb +55 -0
- data/lib/droonga/planner.rb +47 -0
- data/lib/droonga/pluggable.rb +31 -0
- data/lib/droonga/plugin/metadata/adapter_input_message.rb +39 -0
- data/lib/droonga/plugin/metadata/adapter_output_message.rb +39 -0
- data/lib/droonga/plugin/metadata/collector_message.rb +39 -0
- data/lib/droonga/plugin/metadata/handler_action.rb +39 -0
- data/lib/droonga/plugin/metadata/input_message.rb +54 -0
- data/lib/droonga/plugin.rb +43 -0
- data/lib/droonga/plugin_loader.rb +63 -0
- data/lib/droonga/plugin_registry.rb +66 -0
- data/lib/droonga/plugins/basic.rb +54 -0
- data/lib/droonga/plugins/crud.rb +145 -0
- data/lib/droonga/plugins/dump.rb +97 -0
- data/lib/droonga/plugins/error.rb +51 -0
- data/lib/droonga/plugins/groonga/column_create.rb +123 -0
- data/lib/droonga/plugins/groonga/column_list.rb +124 -0
- data/lib/droonga/plugins/groonga/column_remove.rb +65 -0
- data/lib/droonga/plugins/groonga/column_rename.rb +67 -0
- data/lib/droonga/plugins/groonga/delete.rb +117 -0
- data/lib/droonga/plugins/groonga/generic_command.rb +105 -0
- data/lib/droonga/plugins/groonga/generic_response.rb +43 -0
- data/lib/droonga/plugins/groonga/select.rb +236 -0
- data/lib/droonga/plugins/groonga/table_create.rb +111 -0
- data/lib/droonga/plugins/groonga/table_list.rb +120 -0
- data/lib/droonga/plugins/groonga/table_remove.rb +57 -0
- data/lib/droonga/plugins/groonga.rb +37 -0
- data/lib/droonga/plugins/search/distributed_search_planner.rb +407 -0
- data/lib/droonga/plugins/search.rb +146 -0
- data/lib/droonga/plugins/watch.rb +178 -0
- data/lib/droonga/processor.rb +63 -0
- data/lib/droonga/reducer.rb +169 -0
- data/lib/droonga/replier.rb +49 -0
- data/lib/droonga/schema_applier.rb +167 -0
- data/lib/droonga/searcher/mecab_filter.rb +67 -0
- data/lib/droonga/searcher.rb +733 -0
- data/lib/droonga/server.rb +45 -0
- data/lib/droonga/session.rb +99 -0
- data/lib/droonga/single_step.rb +68 -0
- data/lib/droonga/single_step_definition.rb +54 -0
- data/lib/droonga/slice.rb +122 -0
- data/lib/droonga/status_code.rb +25 -0
- data/lib/droonga/step_runner.rb +64 -0
- data/lib/droonga/sweeper.rb +42 -0
- data/lib/droonga/test/stub_handler.rb +37 -0
- data/lib/droonga/test/stub_handler_message.rb +35 -0
- data/lib/droonga/test/stub_handler_messenger.rb +34 -0
- data/lib/droonga/test/stub_planner.rb +31 -0
- data/lib/droonga/test.rb +21 -0
- data/lib/droonga/watch_schema.rb +92 -0
- data/lib/droonga/watcher.rb +257 -0
- data/lib/droonga/worker.rb +61 -0
- data/sample/cluster/catalog.json +42 -0
- data/sample/mecab_filter/data.grn +7 -0
- data/sample/mecab_filter/ddl.grn +7 -0
- data/sample/mecab_filter/search_with_mecab_filter.json +21 -0
- data/sample/mecab_filter/search_without_mecab_filter.json +21 -0
- data/test/command/config/default/catalog.json +85 -0
- data/test/command/config/default/fluentd.conf +11 -0
- data/test/command/config/version1/catalog.json +68 -0
- data/test/command/config/version1/fluentd.conf +11 -0
- data/test/command/fixture/documents.jsons +208 -0
- data/test/command/fixture/event.jsons +41 -0
- data/test/command/fixture/user-table-array.jsons +38 -0
- data/test/command/fixture/user-table.jsons +47 -0
- data/test/command/run-test.rb +34 -0
- data/test/command/suite/add/dimension/column.catalog.json +28 -0
- data/test/command/suite/add/dimension/column.expected +41 -0
- data/test/command/suite/add/dimension/column.test +51 -0
- data/test/command/suite/add/dimension/integer.catalog.json +19 -0
- data/test/command/suite/add/dimension/integer.expected +41 -0
- data/test/command/suite/add/dimension/integer.test +51 -0
- data/test/command/suite/add/error/invalid-integer.expected +46 -0
- data/test/command/suite/add/error/invalid-integer.test +12 -0
- data/test/command/suite/add/error/invalid-time.expected +46 -0
- data/test/command/suite/add/error/invalid-time.test +12 -0
- data/test/command/suite/add/error/missing-key.expected +25 -0
- data/test/command/suite/add/error/missing-key.test +16 -0
- data/test/command/suite/add/error/missing-table.expected +25 -0
- data/test/command/suite/add/error/missing-table.test +16 -0
- data/test/command/suite/add/error/unknown-column.expected +46 -0
- data/test/command/suite/add/error/unknown-column.test +12 -0
- data/test/command/suite/add/error/unknown-table.expected +25 -0
- data/test/command/suite/add/error/unknown-table.test +17 -0
- data/test/command/suite/add/minimum.expected +6 -0
- data/test/command/suite/add/minimum.test +11 -0
- data/test/command/suite/add/with-values.expected +6 -0
- data/test/command/suite/add/with-values.test +17 -0
- data/test/command/suite/add/without-key.expected +6 -0
- data/test/command/suite/add/without-key.test +16 -0
- data/test/command/suite/groonga/column_create/scalar.expected +26 -0
- data/test/command/suite/groonga/column_create/scalar.test +17 -0
- data/test/command/suite/groonga/column_create/unknown-table.expected +14 -0
- data/test/command/suite/groonga/column_create/unknown-table.test +7 -0
- data/test/command/suite/groonga/column_create/vector.expected +26 -0
- data/test/command/suite/groonga/column_create/vector.test +18 -0
- data/test/command/suite/groonga/column_list/success.expected +86 -0
- data/test/command/suite/groonga/column_list/success.test +24 -0
- data/test/command/suite/groonga/column_list/unknown-table.expected +13 -0
- data/test/command/suite/groonga/column_list/unknown-table.test +7 -0
- data/test/command/suite/groonga/column_remove/success.expected +39 -0
- data/test/command/suite/groonga/column_remove/success.test +25 -0
- data/test/command/suite/groonga/column_remove/unknown-column.expected +27 -0
- data/test/command/suite/groonga/column_remove/unknown-column.test +16 -0
- data/test/command/suite/groonga/column_remove/unknown-table.expected +14 -0
- data/test/command/suite/groonga/column_remove/unknown-table.test +7 -0
- data/test/command/suite/groonga/column_rename/success.expected +39 -0
- data/test/command/suite/groonga/column_rename/success.test +26 -0
- data/test/command/suite/groonga/column_rename/unknown-column.expected +27 -0
- data/test/command/suite/groonga/column_rename/unknown-column.test +16 -0
- data/test/command/suite/groonga/column_rename/unknown-table.expected +14 -0
- data/test/command/suite/groonga/column_rename/unknown-table.test +7 -0
- data/test/command/suite/groonga/delete/duplicated-identifiers.expected +27 -0
- data/test/command/suite/groonga/delete/duplicated-identifiers.test +17 -0
- data/test/command/suite/groonga/delete/filter.expected +19 -0
- data/test/command/suite/groonga/delete/filter.test +19 -0
- data/test/command/suite/groonga/delete/invalid-filter.expected +14 -0
- data/test/command/suite/groonga/delete/invalid-filter.test +9 -0
- data/test/command/suite/groonga/delete/no-identifier.expected +27 -0
- data/test/command/suite/groonga/delete/no-identifier.test +15 -0
- data/test/command/suite/groonga/delete/success.expected +19 -0
- data/test/command/suite/groonga/delete/success.test +19 -0
- data/test/command/suite/groonga/delete/unknown-table.expected +14 -0
- data/test/command/suite/groonga/delete/unknown-table.test +7 -0
- data/test/command/suite/groonga/select/minimum.expected +22 -0
- data/test/command/suite/groonga/select/minimum.test +8 -0
- data/test/command/suite/groonga/table_create/array.expected +14 -0
- data/test/command/suite/groonga/table_create/array.test +8 -0
- data/test/command/suite/groonga/table_create/hash.expected +13 -0
- data/test/command/suite/groonga/table_create/hash.test +8 -0
- data/test/command/suite/groonga/table_list/success.expected +71 -0
- data/test/command/suite/groonga/table_list/success.test +15 -0
- data/test/command/suite/groonga/table_remove/success.expected +13 -0
- data/test/command/suite/groonga/table_remove/success.test +8 -0
- data/test/command/suite/groonga/table_remove/unknown-table.expected +14 -0
- data/test/command/suite/groonga/table_remove/unknown-table.test +7 -0
- data/test/command/suite/message/error/missing-dataset.expected +9 -0
- data/test/command/suite/message/error/missing-dataset.test +5 -0
- data/test/command/suite/message/error/unknown-dataset.expected +9 -0
- data/test/command/suite/message/error/unknown-dataset.test +6 -0
- data/test/command/suite/message/error/unknown-type.expected +9 -0
- data/test/command/suite/message/error/unknown-type.test +6 -0
- data/test/command/suite/search/adjusters/multiple.catalog.json +38 -0
- data/test/command/suite/search/adjusters/multiple.expected +19 -0
- data/test/command/suite/search/adjusters/multiple.test +75 -0
- data/test/command/suite/search/adjusters/one.catalog.json +38 -0
- data/test/command/suite/search/adjusters/one.expected +19 -0
- data/test/command/suite/search/adjusters/one.test +66 -0
- data/test/command/suite/search/attributes/array.expected +21 -0
- data/test/command/suite/search/attributes/array.test +28 -0
- data/test/command/suite/search/attributes/hash.expected +30 -0
- data/test/command/suite/search/attributes/hash.test +36 -0
- data/test/command/suite/search/complex.expected +48 -0
- data/test/command/suite/search/complex.test +23 -0
- data/test/command/suite/search/condition/nested.expected +15 -0
- data/test/command/suite/search/condition/nested.test +27 -0
- data/test/command/suite/search/condition/query/nonexistent_column.catalog.json +37 -0
- data/test/command/suite/search/condition/query/nonexistent_column.expected +48 -0
- data/test/command/suite/search/condition/query/nonexistent_column.test +33 -0
- data/test/command/suite/search/condition/query/syntax_error.catalog.json +36 -0
- data/test/command/suite/search/condition/query/syntax_error.expected +48 -0
- data/test/command/suite/search/condition/query/syntax_error.test +33 -0
- data/test/command/suite/search/condition/query.expected +24 -0
- data/test/command/suite/search/condition/query.test +23 -0
- data/test/command/suite/search/condition/script.expected +24 -0
- data/test/command/suite/search/condition/script.test +26 -0
- data/test/command/suite/search/error/cyclic-source.expected +14 -0
- data/test/command/suite/search/error/cyclic-source.test +12 -0
- data/test/command/suite/search/error/deeply-cyclic-source.expected +17 -0
- data/test/command/suite/search/error/deeply-cyclic-source.test +15 -0
- data/test/command/suite/search/error/missing-source-parameter.expected +13 -0
- data/test/command/suite/search/error/missing-source-parameter.test +11 -0
- data/test/command/suite/search/error/no-query.expected +9 -0
- data/test/command/suite/search/error/no-query.test +7 -0
- data/test/command/suite/search/error/unknown-source.expected +52 -0
- data/test/command/suite/search/error/unknown-source.test +12 -0
- data/test/command/suite/search/group/count.expected +10 -0
- data/test/command/suite/search/group/count.test +18 -0
- data/test/command/suite/search/group/limit.expected +15 -0
- data/test/command/suite/search/group/limit.test +20 -0
- data/test/command/suite/search/group/string.expected +32 -0
- data/test/command/suite/search/group/string.test +40 -0
- data/test/command/suite/search/group/subrecord/with-sort.catalog.json +33 -0
- data/test/command/suite/search/group/subrecord/with-sort.expected +30 -0
- data/test/command/suite/search/group/subrecord/with-sort.test +81 -0
- data/test/command/suite/search/multiple/chained.expected +41 -0
- data/test/command/suite/search/multiple/chained.test +39 -0
- data/test/command/suite/search/multiple/parallel.expected +35 -0
- data/test/command/suite/search/multiple/parallel.test +35 -0
- data/test/command/suite/search/output/attributes/invalid.catalog.json +13 -0
- data/test/command/suite/search/output/attributes/invalid.expected +44 -0
- data/test/command/suite/search/output/attributes/invalid.test +28 -0
- data/test/command/suite/search/range/only-output.expected +24 -0
- data/test/command/suite/search/range/only-output.test +23 -0
- data/test/command/suite/search/range/only-sort.expected +24 -0
- data/test/command/suite/search/range/only-sort.test +26 -0
- data/test/command/suite/search/range/sort-and-output.expected +21 -0
- data/test/command/suite/search/range/sort-and-output.test +27 -0
- data/test/command/suite/search/range/too-large-output-offset.expected +12 -0
- data/test/command/suite/search/range/too-large-output-offset.test +23 -0
- data/test/command/suite/search/range/too-large-sort-offset.expected +12 -0
- data/test/command/suite/search/range/too-large-sort-offset.test +26 -0
- data/test/command/suite/search/response/elapsed_time.catalog.json +13 -0
- data/test/command/suite/search/response/elapsed_time.expected +11 -0
- data/test/command/suite/search/response/elapsed_time.test +26 -0
- data/test/command/suite/search/response/records/value/time.expected +20 -0
- data/test/command/suite/search/response/records/value/time.test +22 -0
- data/test/command/suite/search/simple.expected +48 -0
- data/test/command/suite/search/simple.test +22 -0
- data/test/command/suite/search/sort/default-offset-limit.expected +39 -0
- data/test/command/suite/search/sort/default-offset-limit.test +24 -0
- data/test/command/suite/search/sort/invisible-column.expected +24 -0
- data/test/command/suite/search/sort/invisible-column.test +26 -0
- data/test/command/suite/watch/subscribe.expected +6 -0
- data/test/command/suite/watch/subscribe.test +9 -0
- data/test/command/suite/watch/unsubscribe.expected +6 -0
- data/test/command/suite/watch/unsubscribe.test +9 -0
- data/test/performance/run-test.rb +56 -0
- data/test/performance/watch/catalog.json +33 -0
- data/test/performance/watch/feed.json +9 -0
- data/test/performance/watch/fluentd.conf +11 -0
- data/test/performance/watch/subscribe.json +3 -0
- data/test/unit/catalog/test_collection_volume.rb +103 -0
- data/test/unit/catalog/test_dataset.rb +104 -0
- data/test/unit/catalog/test_schema.rb +226 -0
- data/test/unit/catalog/test_single_volume.rb +31 -0
- data/test/unit/catalog/test_slice.rb +92 -0
- data/test/unit/catalog/test_version1.rb +361 -0
- data/test/unit/catalog/test_version2.rb +124 -0
- data/test/unit/catalog/test_version2_validator.rb +66 -0
- data/test/unit/catalog/test_volume_collection.rb +50 -0
- data/test/unit/fixtures/array.grn +18 -0
- data/test/unit/fixtures/catalog/version1.json +40 -0
- data/test/unit/fixtures/catalog/version2.json +62 -0
- data/test/unit/fixtures/document.grn +34 -0
- data/test/unit/fixtures/reference/array.grn +11 -0
- data/test/unit/fixtures/reference/hash.grn +7 -0
- data/test/unit/helper/distributed_search_planner_helper.rb +83 -0
- data/test/unit/helper/fixture.rb +28 -0
- data/test/unit/helper/plugin_helper.rb +38 -0
- data/test/unit/helper/sandbox.rb +86 -0
- data/test/unit/helper/stub_worker.rb +27 -0
- data/test/unit/helper/watch_helper.rb +23 -0
- data/test/unit/helper.rb +28 -0
- data/test/unit/plugins/crud/test_add.rb +190 -0
- data/test/unit/plugins/groonga/select/test_adapter_input.rb +510 -0
- data/test/unit/plugins/groonga/select/test_adapter_output.rb +201 -0
- data/test/unit/plugins/groonga/test_column_create.rb +171 -0
- data/test/unit/plugins/groonga/test_column_list.rb +170 -0
- data/test/unit/plugins/groonga/test_column_remove.rb +98 -0
- data/test/unit/plugins/groonga/test_column_rename.rb +105 -0
- data/test/unit/plugins/groonga/test_delete.rb +127 -0
- data/test/unit/plugins/groonga/test_table_create.rb +147 -0
- data/test/unit/plugins/groonga/test_table_list.rb +184 -0
- data/test/unit/plugins/groonga/test_table_remove.rb +61 -0
- data/test/unit/plugins/search/planner/test_basic.rb +120 -0
- data/test/unit/plugins/search/planner/test_group_by.rb +573 -0
- data/test/unit/plugins/search/planner/test_output.rb +388 -0
- data/test/unit/plugins/search/planner/test_sort_by.rb +938 -0
- data/test/unit/plugins/search/test_collector.rb +806 -0
- data/test/unit/plugins/search/test_handler.rb +930 -0
- data/test/unit/plugins/search/test_planner.rb +174 -0
- data/test/unit/plugins/test_basic.rb +510 -0
- data/test/unit/plugins/test_groonga.rb +70 -0
- data/test/unit/plugins/test_watch.rb +211 -0
- data/test/unit/run-test.rb +56 -0
- data/test/unit/test_catalog_generator.rb +93 -0
- data/test/unit/test_message_matcher.rb +160 -0
- data/test/unit/test_schema_applier.rb +59 -0
- data/test/unit/test_sweeper.rb +95 -0
- data/test/unit/test_watch_schema.rb +57 -0
- data/test/unit/test_watcher.rb +336 -0
- metadata +759 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Copyright (C) 2013-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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
15
|
+
|
|
16
|
+
require "droonga/catalog/base"
|
|
17
|
+
require "droonga/catalog/dataset"
|
|
18
|
+
require "droonga/catalog/version2_validator"
|
|
19
|
+
|
|
20
|
+
module Droonga
|
|
21
|
+
module Catalog
|
|
22
|
+
class Version2 < Base
|
|
23
|
+
def initialize(data, path)
|
|
24
|
+
super
|
|
25
|
+
validate
|
|
26
|
+
prepare_data
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def datasets
|
|
30
|
+
@datasets
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def slices(name)
|
|
34
|
+
device = "."
|
|
35
|
+
pattern = Regexp.new("^#{name}\.")
|
|
36
|
+
results = {}
|
|
37
|
+
@datasets.each do |dataset_name, dataset|
|
|
38
|
+
n_workers = dataset.n_workers
|
|
39
|
+
plugins = dataset.plugins
|
|
40
|
+
dataset.replicas.each do |volume|
|
|
41
|
+
volume.slices.each do |slice|
|
|
42
|
+
volume_address = slice.volume.address
|
|
43
|
+
if pattern =~ volume_address
|
|
44
|
+
path = File.join([device, $POSTMATCH, "db"])
|
|
45
|
+
path = File.expand_path(path, base_path)
|
|
46
|
+
options = {
|
|
47
|
+
:dataset => dataset_name,
|
|
48
|
+
:database => path,
|
|
49
|
+
:n_workers => n_workers,
|
|
50
|
+
:plugins => plugins
|
|
51
|
+
}
|
|
52
|
+
results[volume_address] = options
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
results
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def get_routes(name, args)
|
|
61
|
+
routes = []
|
|
62
|
+
dataset = dataset(name)
|
|
63
|
+
case args["type"]
|
|
64
|
+
when "broadcast"
|
|
65
|
+
volumes = dataset.replicas.select(args["replica"].to_sym)
|
|
66
|
+
volumes.each do |volume|
|
|
67
|
+
slices = volume.select_slices
|
|
68
|
+
slices.each do |slice|
|
|
69
|
+
routes << slice.volume.address
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
when "scatter"
|
|
73
|
+
volumes = dataset.replicas.select(args["replica"].to_sym)
|
|
74
|
+
volumes.each do |volume|
|
|
75
|
+
slice = volume.choose_slice(args["record"])
|
|
76
|
+
routes << slice.volume.address
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
routes
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
private
|
|
83
|
+
def validate
|
|
84
|
+
validator = Version2Validator.new(@data, @path)
|
|
85
|
+
validator.validate
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def prepare_data
|
|
89
|
+
@datasets = {}
|
|
90
|
+
@data["datasets"].each do |name, dataset|
|
|
91
|
+
@datasets[name] = Dataset.new(name, dataset)
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
15
|
+
|
|
16
|
+
require "droonga/catalog/errors"
|
|
17
|
+
|
|
18
|
+
module Droonga
|
|
19
|
+
module Catalog
|
|
20
|
+
class Version2Validator
|
|
21
|
+
def initialize(data, path)
|
|
22
|
+
@data = data
|
|
23
|
+
@path = path
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def validate
|
|
27
|
+
@details = []
|
|
28
|
+
|
|
29
|
+
validate_datasets
|
|
30
|
+
|
|
31
|
+
unless @details.empty?
|
|
32
|
+
raise ValidationError.new(@path, @details)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
def validate_datasets
|
|
38
|
+
unless @data.key?("datasets")
|
|
39
|
+
required_parameter_is_missing("datasets")
|
|
40
|
+
return
|
|
41
|
+
end
|
|
42
|
+
@data["datasets"].each do |name, dataset|
|
|
43
|
+
validate_dataset(name, dataset)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def validate_dataset(name, dataset)
|
|
48
|
+
unless dataset.key?("replicas")
|
|
49
|
+
required_parameter_is_missing("datasets.#{name}.replicas")
|
|
50
|
+
return
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def add_detail(value_path, message)
|
|
55
|
+
@details << ValidationError::Detail.new(value_path, message)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def required_parameter_is_missing(value_path)
|
|
59
|
+
add_detail(value_path, "required parameter is missing")
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
15
|
+
|
|
16
|
+
require "droonga/catalog/single_volume"
|
|
17
|
+
require "droonga/catalog/collection_volume"
|
|
18
|
+
|
|
19
|
+
module Droonga
|
|
20
|
+
module Catalog
|
|
21
|
+
module Volume
|
|
22
|
+
class << self
|
|
23
|
+
def create(dataset, raw_volume)
|
|
24
|
+
if raw_volume.key?("address")
|
|
25
|
+
SingleVolume.new(raw_volume)
|
|
26
|
+
else
|
|
27
|
+
CollectionVolume.new(dataset, raw_volume)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
15
|
+
|
|
16
|
+
module Droonga
|
|
17
|
+
module Catalog
|
|
18
|
+
class VolumeCollection
|
|
19
|
+
include Enumerable
|
|
20
|
+
|
|
21
|
+
def initialize(volumes)
|
|
22
|
+
@volumes = volumes
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def each(&block)
|
|
26
|
+
@volumes.each(&block)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def ==(other)
|
|
30
|
+
other.is_a?(self.class) and
|
|
31
|
+
to_a == other.to_a
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def eql?(other)
|
|
35
|
+
self == other
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def hash
|
|
39
|
+
to_a.hash
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def select(how=nil)
|
|
43
|
+
case how
|
|
44
|
+
when :top
|
|
45
|
+
[@volumes.first]
|
|
46
|
+
when :random
|
|
47
|
+
[@volumes.sample]
|
|
48
|
+
when :all
|
|
49
|
+
@volumes
|
|
50
|
+
else
|
|
51
|
+
super
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,156 @@
|
|
|
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
15
|
+
|
|
16
|
+
require "time"
|
|
17
|
+
|
|
18
|
+
module Droonga
|
|
19
|
+
class CatalogGenerator
|
|
20
|
+
def initialize
|
|
21
|
+
@version = 2
|
|
22
|
+
@effective_date = Time.now
|
|
23
|
+
@datasets = {}
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def add_dataset(name, options)
|
|
27
|
+
@datasets[name] = Dataset.new(name, options)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def generate
|
|
31
|
+
{
|
|
32
|
+
"version" => @version,
|
|
33
|
+
"effectiveDate" => @effective_date.iso8601,
|
|
34
|
+
"datasets" => catalog_datasets,
|
|
35
|
+
}
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
private
|
|
39
|
+
def catalog_datasets
|
|
40
|
+
catalog_datasets = {}
|
|
41
|
+
@datasets.each do |name, dataset|
|
|
42
|
+
catalog_datasets[name] = dataset.to_catalog
|
|
43
|
+
end
|
|
44
|
+
catalog_datasets
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
class Dataset
|
|
48
|
+
def initialize(name, options)
|
|
49
|
+
@name = name
|
|
50
|
+
@options = options
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def n_workers
|
|
54
|
+
@options[:n_workers] || 4
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def plugins
|
|
58
|
+
@options[:plugins] || ["groonga", "search", "crud"]
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def schema
|
|
62
|
+
@options[:schema] || {}
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def fact
|
|
66
|
+
@options[:fact]
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def replicas
|
|
70
|
+
return @options[:replicas] if @options[:replicas]
|
|
71
|
+
@generated_replicas ||= Replicas.new(@options).to_json
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def to_catalog
|
|
75
|
+
catalog = {
|
|
76
|
+
"nWorkers" => n_workers,
|
|
77
|
+
"plugins" => plugins,
|
|
78
|
+
"schema" => schema,
|
|
79
|
+
"replicas" => replicas,
|
|
80
|
+
}
|
|
81
|
+
catalog["fact"] = fact if fact
|
|
82
|
+
catalog
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
private
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
class Replicas
|
|
89
|
+
def initialize(options={})
|
|
90
|
+
@hosts = options[:hosts] || ["127.0.0.1"]
|
|
91
|
+
@port = options[:port]
|
|
92
|
+
@tag = options[:tag]
|
|
93
|
+
@n_slices = options[:n_slices]
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def to_json
|
|
97
|
+
@json ||= generate_json
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
private
|
|
101
|
+
def generate_json
|
|
102
|
+
replicas = []
|
|
103
|
+
@hosts.each do |host|
|
|
104
|
+
replica = Replica.new(host, :port => @port,
|
|
105
|
+
:tag => @tag,
|
|
106
|
+
:n_slices => @n_slices)
|
|
107
|
+
replicas << replica.to_json
|
|
108
|
+
end
|
|
109
|
+
replicas
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
class Replica
|
|
114
|
+
def initialize(host, options={})
|
|
115
|
+
@host = host
|
|
116
|
+
@port = options[:port] || 10031
|
|
117
|
+
@tag = options[:tag] || "droonga"
|
|
118
|
+
@n_slices = options[:n_slices] || 1
|
|
119
|
+
|
|
120
|
+
@n_volumes = 0
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def to_json
|
|
124
|
+
@json ||= generate_json
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
private
|
|
128
|
+
def generate_json
|
|
129
|
+
slices = []
|
|
130
|
+
@n_slices.times do |index|
|
|
131
|
+
slices << generate_slice
|
|
132
|
+
end
|
|
133
|
+
{
|
|
134
|
+
"dimension" => "_key",
|
|
135
|
+
"slicer" => "hash",
|
|
136
|
+
"slices" => slices,
|
|
137
|
+
}
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def generate_slice
|
|
141
|
+
name = sprintf('%03d', @n_volumes)
|
|
142
|
+
@n_volumes += 1
|
|
143
|
+
{
|
|
144
|
+
"weight" => weight,
|
|
145
|
+
"volume" => {
|
|
146
|
+
"address" => "#{@host}:#{@port}/#{@tag}.#{name}",
|
|
147
|
+
},
|
|
148
|
+
}
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
def weight
|
|
152
|
+
@weight ||= 100 / @n_slices
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Copyright (C) 2013-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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
15
|
+
|
|
16
|
+
require "json"
|
|
17
|
+
|
|
18
|
+
require "droonga/catalog/version1"
|
|
19
|
+
require "droonga/catalog/version2"
|
|
20
|
+
|
|
21
|
+
module Droonga
|
|
22
|
+
class CatalogLoader
|
|
23
|
+
def initialize(path)
|
|
24
|
+
@path = path
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def load
|
|
28
|
+
data = nil
|
|
29
|
+
begin
|
|
30
|
+
data = File.open(@path) do |file|
|
|
31
|
+
JSON.parse(file.read)
|
|
32
|
+
end
|
|
33
|
+
rescue Errno::ENOENT => error
|
|
34
|
+
raise Error.new("Missing catalog file #{@path}")
|
|
35
|
+
rescue JSON::ParserError => error
|
|
36
|
+
raise Error.new("Syntax error in #{@path}:\n#{error.to_s}")
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
unless data.is_a?(Hash)
|
|
40
|
+
raise Error.new("Root element of catalog must be an object in #{@path}")
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
version = data["version"]
|
|
44
|
+
case version
|
|
45
|
+
when 1
|
|
46
|
+
Catalog::Version1.new(data, @path)
|
|
47
|
+
when 2
|
|
48
|
+
Catalog::Version2.new(data, @path)
|
|
49
|
+
when nil
|
|
50
|
+
raise Error.new("Catalog version must be specified in #{@path}")
|
|
51
|
+
else
|
|
52
|
+
raise Error.new("Unsupported catalog version <#{version}> is specified in #{@path}")
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Copyright (C) 2014 Droonga Project
|
|
4
|
+
#
|
|
5
|
+
# This library is free software; you can redistribute it and/or
|
|
6
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
7
|
+
# License version 2.1 as published by the Free Software Foundation.
|
|
8
|
+
#
|
|
9
|
+
# This library is distributed in the hope that it will be useful,
|
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
12
|
+
# Lesser General Public License for more details.
|
|
13
|
+
#
|
|
14
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
15
|
+
# License along with this library; if not, write to the Free Software
|
|
16
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
17
|
+
|
|
18
|
+
require "droonga/loggable"
|
|
19
|
+
require "droonga/catalog_loader"
|
|
20
|
+
|
|
21
|
+
module Droonga
|
|
22
|
+
class CatalogObserver
|
|
23
|
+
include Loggable
|
|
24
|
+
|
|
25
|
+
DEFAULT_CATALOG_PATH = "catalog.json"
|
|
26
|
+
CHECK_INTERVAL = 1
|
|
27
|
+
|
|
28
|
+
attr_reader :catalog
|
|
29
|
+
attr_accessor :on_reload
|
|
30
|
+
|
|
31
|
+
def initialize(loop)
|
|
32
|
+
@loop = loop
|
|
33
|
+
@catalog_path = catalog_path
|
|
34
|
+
load_catalog!
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def start
|
|
38
|
+
@watcher = Cool.io::TimerWatcher.new(CHECK_INTERVAL, true)
|
|
39
|
+
observer = self
|
|
40
|
+
@watcher.on_timer do
|
|
41
|
+
observer.ensure_latest_catalog_loaded
|
|
42
|
+
end
|
|
43
|
+
@loop.attach(@watcher)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def stop
|
|
47
|
+
@watcher.detach
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def ensure_latest_catalog_loaded
|
|
51
|
+
if catalog_updated?
|
|
52
|
+
begin
|
|
53
|
+
load_catalog!
|
|
54
|
+
on_reload.call(catalog) if on_reload
|
|
55
|
+
rescue Droonga::Error => error
|
|
56
|
+
logger.warn("reload: fail", :path => @catalog_path, :error => error)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def catalog_path
|
|
62
|
+
path = ENV["DROONGA_CATALOG"] || DEFAULT_CATALOG_PATH
|
|
63
|
+
File.expand_path(path)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def catalog_updated?
|
|
67
|
+
File.mtime(catalog_path) > @catalog_mtime
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def load_catalog!
|
|
71
|
+
loader = CatalogLoader.new(@catalog_path)
|
|
72
|
+
@catalog = loader.load
|
|
73
|
+
logger.info("loaded", :path => @catalog_path, :mtime => @catalog_mtime)
|
|
74
|
+
ensure
|
|
75
|
+
@catalog_mtime = File.mtime(@catalog_path)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
private
|
|
79
|
+
def log_tag
|
|
80
|
+
"catalog-observer"
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Copyright (C) 2013-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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
15
|
+
|
|
16
|
+
require "droonga/pluggable"
|
|
17
|
+
require "droonga/plugin/metadata/collector_message"
|
|
18
|
+
require "droonga/error_messages"
|
|
19
|
+
|
|
20
|
+
module Droonga
|
|
21
|
+
class Collector
|
|
22
|
+
extend Pluggable
|
|
23
|
+
include ErrorMessages
|
|
24
|
+
|
|
25
|
+
class << self
|
|
26
|
+
def message
|
|
27
|
+
Plugin::Metadata::CollectorMessage.new(self)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def initialize
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def collect(message)
|
|
35
|
+
raise NotImplemented, "#{self.class.name}\##{__method__} must implement."
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,71 @@
|
|
|
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
15
|
+
|
|
16
|
+
module Droonga
|
|
17
|
+
class CollectorMessage
|
|
18
|
+
attr_reader :raw
|
|
19
|
+
def initialize(raw)
|
|
20
|
+
@raw = raw
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def valid?
|
|
24
|
+
task and step and values
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def [](key)
|
|
28
|
+
@raw[key]
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def task
|
|
32
|
+
@raw["task"]
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def step
|
|
36
|
+
task["step"]
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def type
|
|
40
|
+
step["type"]
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def values
|
|
44
|
+
task["values"]
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def body
|
|
48
|
+
step["body"]
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def input
|
|
52
|
+
if body
|
|
53
|
+
body[name]
|
|
54
|
+
else
|
|
55
|
+
nil
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def outputs
|
|
60
|
+
step["outputs"]
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def name
|
|
64
|
+
@raw["name"]
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def value
|
|
68
|
+
@raw["value"]
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|