[Groonga-commit] droonga/droonga-engine at ee3849f [master] Validate options

Back to archive index

YUKI Hiroshi null+****@clear*****
Sat Jun 28 03:12:35 JST 2014


YUKI Hiroshi	2014-06-28 03:12:35 +0900 (Sat, 28 Jun 2014)

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

  Message:
    Validate options

  Modified files:
    bin/droonga-engine-join
    bin/droonga-engine-unjoin

  Modified: bin/droonga-engine-join (+21 -1)
===================================================================
--- bin/droonga-engine-join    2014-06-28 03:02:21 +0900 (3e4f682)
+++ bin/droonga-engine-join    2014-06-28 03:12:35 +0900 (82b15ba)
@@ -71,10 +71,24 @@ parser.parse!(ARGV)
 base_dir = Pathname(options.base_dir).expand_path
 ENV[Droonga::Path::BASE_DIR_ENV_NAME] = base_dir.to_s
 
-catalog_path = Droonga::Path.base + "catalog.json"
+catalog_path = Droonga::Path.catalog
+unless catalog_path.exist?
+  raise "Cannot load 'catalog.json'. You must specify correct path " +
+          "to the base directory via --base-dir option."
+end
 source_catalog = JSON.parse(catalog_path.read)
 
 
+unless options.replica_source_host
+  raise "You must specify the host name or the IP address of a node " +
+           "of an existing cluster via --replica-source-host option."
+end
+unless options.my_host
+  raise "You must specify the host name or the IP address of this node " +
+          "via --my-host option."
+end
+
+
 generator = Droonga::CatalogGenerator.new
 dataset_params = generator.catalog_to_params(source_catalog)
 dataset_params.each do |name, dataset|
@@ -86,6 +100,12 @@ dataset_params.each do |name, dataset|
   options.other_hosts = dataset[:hosts]
 end
 
+unless options.dataset
+  raise "Specified source host #{options.replica_source_host} is not a " +
+          "member of the cluster. You must specify correct host via " +
+          "--replica-source-host option."
+end
+
 puts "Initializing new replica..."
 
 absorb_destination_params = Marshal.load(Marshal.dump(dataset_params))

  Modified: bin/droonga-engine-unjoin (+17 -1)
===================================================================
--- bin/droonga-engine-unjoin    2014-06-28 03:02:21 +0900 (4158eeb)
+++ bin/droonga-engine-unjoin    2014-06-28 03:12:35 +0900 (3e2ce47)
@@ -51,10 +51,20 @@ parser.parse!(ARGV)
 base_dir = Pathname(options.base_dir).expand_path
 ENV[Droonga::Path::BASE_DIR_ENV_NAME] = base_dir.to_s
 
-catalog_path = Droonga::Path.base + "catalog.json"
+catalog_path = Droonga::Path.catalog
+unless catalog_path.exist?
+  raise "Cannot load 'catalog.json'. You must specify correct path " +
+          "to the base directory via --base-dir option."
+end
 source_catalog = JSON.parse(catalog_path.read)
 
 
+unless options.replica_remove_host
+  raise "You must specify the host name or the IP address of a node to " +
+          "be removed from the cluster via --replica-remove-host option."
+end
+
+
 generator = Droonga::CatalogGenerator.new
 dataset_params = generator.catalog_to_params(source_catalog)
 dataset_params.each do |name, dataset|
@@ -66,6 +76,12 @@ dataset_params.each do |name, dataset|
   options.other_hosts = dataset[:hosts]
 end
 
+unless options.dataset
+  raise "Specified host #{options.replica_remove_host} is not a member of "+
+          "the cluster. You must specify correct host via --replica-remove-host " +
+          "option."
+end
+
 sleep(1) # wait for restart
 
 puts "Unjoining from the cluster..."
-------------- next part --------------
HTML����������������������������...
Download 



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