]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crushtool: allow user to select output reporting in blocks
authorcaleb miles <caleb.miles@inktank.com>
Tue, 5 Jun 2012 22:50:54 +0000 (15:50 -0700)
committerSage Weil <sage@inktank.com>
Wed, 6 Jun 2012 18:07:00 +0000 (11:07 -0700)
Signed-off-by: caleb miles <caleb.miles@inktank.com>
.gitignore
src/crush/CrushTester.cc
src/crush/CrushTester.h
src/crushtool.cc

index 595364b60cbd78e2c4ec2d4085f52cbd665735ba..129ce282a7a665ba1bb83071dcfb58450ce83ad7 100644 (file)
@@ -63,3 +63,4 @@ src/omapbench
 
 # temporary directory used by e.g. "make distcheck", e.g. ceph-0.42
 /ceph-[0-9]*/
+/nbproject/private/
\ No newline at end of file
index 8813baecc15f7d55a9c1fd6a8b85173bca2b7c95..f7d1c64e4e8aacbbc145bd3792b656e86198db03 100644 (file)
@@ -198,11 +198,11 @@ int CrushTester::test()
          vector<int> out;
           
           if (use_crush) {
-           if (verbose > 2)
+           if (output_statistics)
              err << "CRUSH"; // prepend CRUSH to placement output
            crush.do_rule(r, x, out, nr, weight);
          } else {
-           if (verbose > 2)
+           if (output_statistics)
              err << "RNG"; // prepend RNG to placement output to denote simulation
 
 #ifdef HAVE_BOOST_RANDOM_DISCRETE_DISTRIBUTION
@@ -213,9 +213,9 @@ int CrushTester::test()
 #endif
           }
          
-         if (verbose)
-           if (verbose>1 )
-             err << " rule " << r << " x " << x << " " << out << std::endl;
+
+          if (output_statistics)
+            err << " rule " << r << " x " << x << " " << out << std::endl;
          for (unsigned i = 0; i < out.size(); i++) {
            per[out[i]]++;
            temporary_per[out[i]]++;
@@ -234,7 +234,7 @@ int CrushTester::test()
       }
       
       for (unsigned i = 0; i < per.size(); i++)
-       if (verbose>1 )
+       if (output_utilization && !output_statistics)
          err << "  device " << i 
              << ":\t" << per[i] 
              << std::endl;
@@ -262,9 +262,9 @@ int CrushTester::test()
       }
 #endif      
 
-      if (verbose > 1)
+      if (output_statistics)
        for (unsigned i = 0; i < per.size(); i++) {
-         if (verbose < 5 ){
+         if (output_utilization && num_batches > 1){
            if (num_objects_expected[i] > 0 && per[i] > 0) {
              err << "  device " << i << ":\t"
                  << "\t" << " stored " << ": " << per[i]
@@ -276,7 +276,7 @@ int CrushTester::test()
 #endif
                  << std::endl;
            }
-         } else {
+         } else if (output_utilization_all && num_batches > 1) {
            err << "  device " << i << ":\t"
                << "\t" << " stored " << ": " << per[i]
                << "\t" << " expected " << ": " << num_objects_expected[i]
@@ -297,7 +297,7 @@ int CrushTester::test()
       //err << " total system weight (dec) = " << (total_weight / (float) 0x10000) << std::endl;
       //err << " number of buckets = " << num_buckets << std::endl;
 
-      if (num_batches > 1) {
+      if (num_batches > 1 && output_statistics) {
        err << " " << num_devices_failing_at_five_percent << "/" << num_devices_active << " ("
            << (100.0*((float) num_devices_failing_at_five_percent / (float) num_devices_active)) 
            << "%) devices failed testing at 5% confidence level" << std::endl;
index dc554fc5e8db8eba6f7ad48c7d3f0347669e184a..1974d10d15310bb727adee9ec7f93a6d4e8412ba 100644 (file)
@@ -25,6 +25,9 @@ class CrushTester {
   float mark_down_percentage;
   int mark_down_start;
   int down_range;
+  bool output_utilization;
+  bool output_utilization_all;
+  bool output_statistics;
 
 public:
   CrushTester(CrushWrapper& c, ostream& eo, int verbosity=0)
@@ -42,8 +45,10 @@ public:
       down_range(1)
   { }
 
-  void set_verbosity(int v) {
-    verbose = v;
+  void set_output(bool set_output_utilization, bool set_output_utilization_all, bool set_output_statistics) {
+    output_utilization = set_output_utilization;
+    output_utilization_all = set_output_utilization_all;
+    output_statistics = set_output_statistics;
   }
   void set_batches(int b) {
     num_batches = b;
index d90ee1e7183e533b6a6cdddd8eac874f4015308b..e55338e52585630339d3708ef6f73949dca96b9c 100644 (file)
@@ -59,7 +59,7 @@ void usage()
   cout << "      [--min-rule r] [--max-rule r] [--rule r]\n";
   cout << "      [--num-rep n]\n";
   cout << "      [--batches b]\n";
-  cout << "      [--simulate]\n";
+  cout << "    --simulate           simulate placements using a RNG\n";
   cout << "      [--weight|-w devno weight]\n";
   cout << "                         where weight is 0 to 1.0\n";
   cout << "   -i mapfn --add-item id weight name [--loc type name ...]\n";
@@ -74,6 +74,9 @@ void usage()
   cout << "                         reweight a given item (and adjust ancestor\n"
        << "                         weights as needed)\n";
   cout << "   -i mapfn --reweight   recalculate all bucket weights\n";
+  cout << "   --output-utilization       output OSD usage\n";
+  cout << "   --output utilization-all   include zero weight items\n";
+  cout << "   --output-statistics        output chi squared statistics\n";
   exit(1);
 }
 
@@ -105,6 +108,9 @@ int main(int argc, const char **argv)
   bool decompile = false;
   bool test = false;
   bool verbose = false;
+  bool output_utilization = false;
+  bool output_utilization_all = false;
+  bool output_statistics = false;
 
   bool reweight = false;
   int add_item = -1;
@@ -144,12 +150,12 @@ int main(int argc, const char **argv)
       outfn = val;
     } else if (ceph_argparse_flag(args, i, "-v", "--verbose", (char*)NULL)) {
       verbose = true;
-    } else if (ceph_argparse_withint(args, i, &x, &err, "-vl", "--verbose-level", (char*)NULL)) {
-      if (!err.str().empty()) {
-       cerr << err.str() << std::endl;
-       exit(EXIT_FAILURE);
-      }
-      tester.set_verbosity(x);
+    } else if (ceph_argparse_flag(args, i, "--output_utilization", (char*)NULL)) {
+      output_utilization = true;
+    } else if (ceph_argparse_flag(args, i, "--output_utilization_all", (char*)NULL)) {
+      output_utilization_all = true;
+    } else if (ceph_argparse_flag(args, i, "--output_statistics", (char*)NULL)) {
+      output_statistics = true;
     } else if (ceph_argparse_witharg(args, i, &val, "-c", "--compile", (char*)NULL)) {
       srcfn = val;
       compile = true;
@@ -552,6 +558,7 @@ int main(int argc, const char **argv)
   }
 
   if (test) {
+    tester.set_output(output_utilization, output_utilization_all, output_statistics);
     int r = tester.test();
     if (r < 0)
       exit(1);