Kouhei Sutou
null+****@clear*****
Mon Feb 3 17:50:25 JST 2014
Kouhei Sutou 2014-02-03 17:50:25 +0900 (Mon, 03 Feb 2014) New Revision: b0830a9704562f628409e1eb24d46a755f196e55 https://github.com/droonga/fluent-plugin-droonga/commit/b0830a9704562f628409e1eb24d46a755f196e55 Message: catalog: put handler plugins configuration under "handler" key Before: { "datasets": { "DATASET": { "plugins": ["serach", "groonga", "add"] } } } After: { "datasets": { "DATASET": { "handler": { "plugins": ["serach", "groonga", "add"] } } } } The old syntax is old available. Modified files: lib/droonga/catalog/base.rb sample/cluster/catalog.json test/command/config/default/catalog.json test/unit/catalog/test_version1.rb Modified: lib/droonga/catalog/base.rb (+2 -1) =================================================================== --- lib/droonga/catalog/base.rb 2014-02-03 17:02:04 +0900 (e5325a4) +++ lib/droonga/catalog/base.rb 2014-02-03 17:50:25 +0900 (b97e38f) @@ -62,7 +62,8 @@ module Droonga results = {} @data["datasets"].each do |key, dataset| workers = dataset["workers"] - plugins = dataset["plugins"] + handler = dataset["handler"] || {} + plugins = handler["plugins"] || dataset["plugins"] dataset["ring"].each do |key, part| part["partitions"].each do |range, partitions| partitions.each do |partition| Modified: sample/cluster/catalog.json (+3 -1) =================================================================== --- sample/cluster/catalog.json 2014-02-03 17:02:04 +0900 (fb5d014) +++ sample/cluster/catalog.json 2014-02-03 17:50:25 +0900 (0aa10fd) @@ -11,7 +11,9 @@ "datasets": { "Droonga": { "workers": 2, - "plugins": ["search", "groonga", "add"], + "handler": { + "plugins": ["search", "groonga", "add"] + }, "number_of_replicas": 2, "number_of_partitions": 2, "partition_key": "_key", Modified: test/command/config/default/catalog.json (+6 -2) =================================================================== --- test/command/config/default/catalog.json 2014-02-03 17:02:04 +0900 (7e285da) +++ test/command/config/default/catalog.json 2014-02-03 17:50:25 +0900 (4464b03) @@ -10,7 +10,9 @@ "datasets": { "Droonga": { "workers": 2, - "plugins": ["search", "groonga", "add"], + "handler": { + "plugins": ["search", "groonga", "add"] + }, "number_of_replicas": 2, "number_of_partitions": 2, "partition_key": "_key", @@ -38,7 +40,9 @@ }, "Watch": { "workers": 2, - "plugins": ["search", "groonga", "add", "watch"], + "handler": { + "plugins": ["search", "groonga", "add", "watch"] + }, "number_of_replicas": 1, "number_of_partitions": 1, "partition_key": "_key", Modified: test/unit/catalog/test_version1.rb (+54 -0) =================================================================== --- test/unit/catalog/test_version1.rb 2014-02-03 17:02:04 +0900 (17991ec) +++ test/unit/catalog/test_version1.rb 2014-02-03 17:50:25 +0900 (c92fba8) @@ -88,6 +88,60 @@ class CatalogTest < Test::Unit::TestCase def base_path File.dirname(catalog_path) end + + class HandlersTest < self + def setup + @data = { + "farms" => { + farm_name => { + "device" => ".", + }, + }, + "datasets" => { + "Droonga" => { + "number_of_partitions" => 1, + "ring" => { + "localhost:23041" => { + "weight" => 50, + "partitions" => { + "2014-02-09" => [ + "#{farm_name}.000", + ], + }, + }, + }, + }, + }, + } + end + + def farm_name + "localhost:23041/droonga" + end + + def handlers(data) + catalog = create_catalog(data, base_path) + catalog.get_partitions(farm_name).collect do |partition, options| + options[:handlers] + end + end + + def test_plugins + @data["datasets"]["Droonga"]["plugins"] = ["search", "groonga", "add"] + assert_equal([["search", "groonga", "add"]], + handlers(@data)) + + end + + def test_handler_plugins + @data["datasets"]["Droonga"]["handler"] = { + "plugins" => ["search", "groonga", "add"], + } + assert_equal([["search", "groonga", "add"]], + handlers(@data)) + + end + end end class DataSetTest < self -------------- next part -------------- HTML����������������������������... Télécharger