]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
erasure-code: ErasureCodeShec update default values to string 4710/head
authorLoic Dachary <ldachary@redhat.com>
Sun, 17 May 2015 16:09:21 +0000 (18:09 +0200)
committerLoic Dachary <ldachary@redhat.com>
Sat, 30 May 2015 22:01:34 +0000 (00:01 +0200)
Update the ErasureCodeShec::init function to use string default
values. The default profile values for technique, ruleset-root and
ruleset-failure-domain are set for the user to see.

The error message when an invalid technique is provided is written to
the error stream to be returned to the user instead of being written to
the OSD log.

Updating other values from the profile would require deeper changes and
is left for later.

http://tracker.ceph.com/issues/9589 Fixes: #9589

Signed-off-by: Loic Dachary <ldachary@redhat.com>
src/erasure-code/shec/ErasureCodePluginShec.cc
src/erasure-code/shec/ErasureCodeShec.cc
src/erasure-code/shec/ErasureCodeShec.h

index d581e5d73c4de756c4ba63bca120231c1d71d485..a56f2fbdc87c656d0851eb9a8f5b500b17310330 100644 (file)
@@ -41,21 +41,19 @@ public:
                      ErasureCodeInterfaceRef *erasure_code,
                      ostream *ss) {
     ErasureCodeShec *interface;
-    std::string t = "multiple";
 
-    if (profile.find("technique") != profile.end()){
-      t = profile.find("technique")->second;
-    }
+    if (profile.find("technique") == profile.end())
+      profile["technique"] = "multiple";
+    std::string t = profile.find("technique")->second;
 
     if (t == "single"){
       interface = new ErasureCodeShecReedSolomonVandermonde(tcache, ErasureCodeShec::SINGLE);
     } else if (t == "multiple"){
       interface = new ErasureCodeShecReedSolomonVandermonde(tcache, ErasureCodeShec::MULTIPLE);
     } else {
-      derr << "technique=" << t << " is not a valid coding technique. "
-          << " Choose one of the following: "
-          << "single, multiple"
-          << dendl;
+      *ss << "technique=" << t << " is not a valid coding technique. "
+         << "Choose one of the following: "
+         << "single, multiple ";
       return -ENOENT;
     }
     int r = interface->init(profile, ss);
index 4283ce0f705fb510c4e6aa30e9b65c7e2764faa3..c60a9562a6eb717813713f8085332055e89ead12 100644 (file)
@@ -58,13 +58,12 @@ int ErasureCodeShec::init(ErasureCodeProfile &profile,
                          ostream *ss)
 {
   int err = 0;
-  map<string,string>::const_iterator parameter;
-  parameter = profile.find("ruleset-root");
-  if (parameter != profile.end())
-    ruleset_root = parameter->second;
-  parameter = profile.find("ruleset-failure-domain");
-  if (parameter != profile.end())
-    ruleset_failure_domain = parameter->second;
+  err |= to_string("ruleset-root", profile,
+                  &ruleset_root,
+                  DEFAULT_RULESET_ROOT, ss);
+  err |= to_string("ruleset-failure-domain", profile,
+                  &ruleset_failure_domain,
+                  DEFAULT_RULESET_FAILURE_DOMAIN, ss);
   err |= parse(profile);
   if (err)
     return err;
index 680fd255c4803bf831d0866028f8f71ae4d5d7ec..672e0fa44fad1333d8d633ab4879f5973caf149f 100644 (file)
@@ -26,6 +26,9 @@
 #include "ErasureCodeShecTableCache.h"
 #include <list>
 
+#define DEFAULT_RULESET_ROOT "default"
+#define DEFAULT_RULESET_FAILURE_DOMAIN "host"
+
 class ErasureCodeShec : public ErasureCode {
 
 public:
@@ -60,8 +63,8 @@ public:
     w(0),
     DEFAULT_W(8),
     technique(_technique),
-    ruleset_root("default"),
-    ruleset_failure_domain("host"),
+    ruleset_root(DEFAULT_RULESET_ROOT),
+    ruleset_failure_domain(DEFAULT_RULESET_FAILURE_DOMAIN),
     matrix(0)
   {}