[Groonga-commit] droonga/droonga-engine at 6d3cbe5 [master] Add validation of absorb options

Back to archive index

YUKI Hiroshi null+****@clear*****
Wed Apr 15 13:55:24 JST 2015


YUKI Hiroshi	2015-04-15 13:55:24 +0900 (Wed, 15 Apr 2015)

  New Revision: 6d3cbe5bf5ede3d467f81e372a4da5f6f253ec99
  https://github.com/droonga/droonga-engine/commit/6d3cbe5bf5ede3d467f81e372a4da5f6f253ec99

  Message:
    Add validation of absorb options

  Modified files:
    lib/droonga/data_absorber_client.rb

  Modified: lib/droonga/data_absorber_client.rb (+24 -0)
===================================================================
--- lib/droonga/data_absorber_client.rb    2015-04-15 13:54:58 +0900 (550f1e1)
+++ lib/droonga/data_absorber_client.rb    2015-04-15 13:55:24 +0900 (f65fd28)
@@ -24,6 +24,12 @@ module Droonga
   class DataAbsorberClient
     include Loggable
 
+    class DestinationEqualsToSource < StandardError
+      def initialize(params)
+        super("The source and the destination are same", params)
+      end
+    end
+
     DEFAULT_MESSAGES_PER_SECOND = 100
     DEFAULT_PROGRESS_INTERVAL_SECONDS = 3
 
@@ -57,6 +63,8 @@ module Droonga
       @client_options = @params[:client_options] || {}
 
       @error_message = nil
+
+      validate_params
     end
 
     def run
@@ -119,6 +127,22 @@ module Droonga
     end
 
     private
+    def validate_params
+      source_node_name = NodeName.new(:host => @source_host,
+                                      :port => @source_port,
+                                      :tag  => @source_tag)
+      destination_node_name = NodeName.new(:host => @host,
+                                           :port => @port,
+                                           :tag  => @tag)
+      if source_node_name == destination_node_name and
+           @source_dataset == @dataset
+        raise DestinationEqualsToSource.new(:host    => @host,
+                                            :port    => @port,
+                                            :tag     => @tag,
+                                            :dataset => @dataset)
+      end
+    end
+
     def source_replica_hosts
       @source_replica_hosts ||= get_source_replica_hosts
     end
-------------- next part --------------
HTML����������������������������...
Descargar 



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