[Groonga-commit] droonga/fluent-plugin-droonga at 716d330 [master] Raise "unknown dataset" error by Catalog

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Dec 26 15:56:11 JST 2013


YUKI Hiroshi	2013-12-26 15:56:11 +0900 (Thu, 26 Dec 2013)

  New Revision: 716d3301a1b91255e888b33c02203356b3752994
  https://github.com/droonga/fluent-plugin-droonga/commit/716d3301a1b91255e888b33c02203356b3752994

  Message:
    Raise "unknown dataset" error by Catalog

  Modified files:
    lib/droonga/catalog.rb
    lib/droonga/dispatcher.rb

  Modified: lib/droonga/catalog.rb (+12 -2)
===================================================================
--- lib/droonga/catalog.rb    2013-12-26 15:47:57 +0900 (b1e58f0)
+++ lib/droonga/catalog.rb    2013-12-26 15:56:11 +0900 (8b7f2af)
@@ -17,6 +17,7 @@
 
 require "digest/sha1"
 require "zlib"
+require "droonga/message_processing_error"
 
 module Droonga
   class << self
@@ -26,6 +27,14 @@ module Droonga
   end
 
   class Catalog
+    class UnknownDataset < StandardError
+      attr_reader :dataset
+
+      def initialize(dataset)
+        @dataset = dataset
+      end
+    end
+
     CATALOG_FILE_PATH = "catalog.json"
 
     attr_reader :path
@@ -93,7 +102,6 @@ module Droonga
     def get_routes(name, args)
       routes = []
       dataset = dataset(name)
-      return routes unless dataset
       case args["type"]
       when "broadcast"
         dataset["ring"].each do |key, partition|
@@ -127,7 +135,9 @@ module Droonga
     end
 
     def dataset(name)
-      @catalog["datasets"][name]
+      dataset = @catalog["datasets"][name]
+      raise UnknownDataset.new(dataset) unless dataset
+      dataset
     end
 
     def select_range_and_replicas(partition, args, routes)

  Modified: lib/droonga/dispatcher.rb (+2 -1)
===================================================================
--- lib/droonga/dispatcher.rb    2013-12-26 15:47:57 +0900 (9224cfc)
+++ lib/droonga/dispatcher.rb    2013-12-26 15:56:11 +0900 (17d3041)
@@ -163,7 +163,6 @@ module Droonga
         dataset = component["dataset"]
         if dataset
           routes = Droonga.catalog.get_routes(dataset, component)
-          raise UnknownDataset.new(dataset) if routes.empty?
           component["routes"] = routes
         else
           component["routes"] ||= [id]
@@ -218,6 +217,8 @@ module Droonga
     def process_input_message(message)
       adapted_message = @input_adapter.adapt(message)
       @distributor.process(adapted_message["type"], adapted_message)
+    rescue Droonga::Catalog::UnknownDataset => error
+      raise UnknownDataset.new(error.dataset)
     rescue Droonga::Pluggable::UnknownPlugin => error
       raise UnknownCommand.new(error.command, message["dataset"])
     end
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index