]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
nightly push to local repo
authorcaleb miles <caleb.miles@inktank.com>
Thu, 14 Jun 2012 23:38:51 +0000 (16:38 -0700)
committercaleb miles <caleb.miles@inktank.com>
Thu, 14 Jun 2012 23:38:51 +0000 (16:38 -0700)
src/crush/CrushTester.cc
src/crush/CrushTester.h
src/crush/CrushWrapper.cc
src/crush/CrushWrapper.h

index e3ecfea570d432d19dc75bfb620bad980230e972..a76f6bfa99ef52c4419dfcf325650df0d76b6ab4 100644 (file)
@@ -45,6 +45,26 @@ void CrushTester::set_device_weight(int dev, float f)
   device_weight[dev] = w;
 }
 
+vector <__u32> CrushTester::compact_device_weights(vector <__u32> weight)
+{
+  vector<__u32> compact_weight;
+  __u32 num_to_check = weight.size();
+  int last_id_used = 0;
+
+  for (__u32 i = 0; i < num_to_check; i++){
+    if (weight[i] > 0){
+      compact_weight.push_back( weight[i]);
+    }
+    else if (weight[i] == 0){
+
+    }
+  }
+
+  return compact_weight;
+}
+
+
+
 void CrushTester::adjust_weights(vector<__u32>& weight)
 {
 #ifdef HAVE_BOOST_RANDOM_DISCRETE_DISTRIBUTION
@@ -103,7 +123,7 @@ void CrushTester::adjust_weights(vector<__u32>& weight)
       for (int o = 0; o < local_devices_to_visit; o++){
         int item = crush.get_bucket_item(id, o);
        //err << "device " << item << " in bucket " << id << " weight " << crush.get_bucket_item_weight(id, o) << std::endl;
-       weight[item] = 10;
+       weight[item] = 0;  // changed from "10" possible bug?
       }
     }
   }
@@ -137,9 +157,17 @@ int CrushTester::test()
   if (output_utilization_all)
     err << "devices weights (hex): " << hex << weight << dec << std::endl;
 
+  // test ability to retrieve item parent information
+  if (output_utilization_all)
+    for (int j = 0; j < weight.size(); j++)
+      err << "device " << j << " is located at " << crush.get_loc(j) << endl;
+
   // make adjustments
   adjust_weights(weight);
 
+  // create a temporary vector to hold a weight vector with no devices marked out
+  vector<__u32> compacted_weight = compact_device_weights(weight);
+
   int num_devices_active = 0;
   for (vector<__u32>::iterator p = weight.begin(); p != weight.end(); ++p)
     num_devices_active++;
@@ -253,7 +281,7 @@ int CrushTester::test()
           if (use_crush) {
             if (output_statistics)
               err << "CRUSH"; // prepend CRUSH to placement output
-            crush.do_rule(r, x, out, nr, weight);
+            crush.do_rule(r, x, out, nr, compacted_weight);
           } else {
             if (output_statistics)
               err << "RNG"; // prepend RNG to placement output to denote simulation
index c96ba8cb0c67340c23669178af0c94ef9c4f31b7..30fce00451de93c92512cb90e8ea9625381f5cbd 100644 (file)
@@ -32,6 +32,7 @@ class CrushTester {
 
 
   void adjust_weights(vector<__u32>& weight);
+  vector<__u32> compact_device_weights(vector <__u32> weight);
 
 public:
   CrushTester(CrushWrapper& c, ostream& eo, int verbosity=0)
index 15d5e140ee11b5736b1eb6157a8e2a8d9dacf640..49bcdfe6e18e9204e0db32f0ebbfb1b17610d673 100644 (file)
@@ -256,6 +256,34 @@ bool CrushWrapper::check_item_present(int id)
 }
 
 
+map<string,string> CrushWrapper::get_loc(int id)
+{
+  map <string, string> loc;
+
+  if (id < 0){
+    loc["device"] = "0"; // add an actual error condition FIXME
+    return loc;
+  }
+
+  else if (id >= 0){
+    for (int bidx = 0; bidx < crush->max_buckets; bidx++) {
+      crush_bucket *b = crush->buckets[bidx];
+      if (b == 0)
+        continue;
+      for (unsigned i = 0; i < b->size; i++)
+        if (b->items[i] == id){
+          string parent_id = name_map[b->id];
+          string parent_bucket_type = type_map[b->type];
+          loc[parent_bucket_type] = parent_id;
+        }
+    }
+  }
+
+  return loc;
+}
+
+
+
 void CrushWrapper::reweight(CephContext *cct)
 {
   set<int> roots;
index 82b9e4b2de29f862ea255b90a224a866f832a6e2..6e67d3f181082015b7b2e8ab590504327424da0e 100644 (file)
@@ -216,6 +216,10 @@ public:
     return ret;
   }
 
+
+  map<string,string> get_loc(int id);
+
+
   /**
    * insert an item into the map at a specific position
    *