]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: data structures for new data/index placement rules
authorYehuda Sadeh <yehuda@inktank.com>
Fri, 21 Jun 2013 23:06:51 +0000 (16:06 -0700)
committerYehuda Sadeh <yehuda@inktank.com>
Fri, 21 Jun 2013 23:06:51 +0000 (16:06 -0700)
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/rgw/rgw_json_enc.cc
src/rgw/rgw_rados.h

index afdf1d6d8b34f8bacd8f9bb930492c0e988aa9c5..3dbd1e4207136ef6e332e1304842dee5b0fb23f5 100644 (file)
@@ -500,6 +500,7 @@ void RGWZoneParams::dump(Formatter *f) const
   encode_json("user_swift_pool", user_swift_pool.data_pool, f);
   encode_json("user_uid_pool ", user_uid_pool.data_pool, f);
   encode_json_plain("system_key", system_key, f);
+  encode_json("placement_pools ", placement_pools, f);
 }
 
 static void decode_json(const char *field, rgw_bucket& bucket, JSONObj *obj)
@@ -512,6 +513,18 @@ static void decode_json(const char *field, rgw_bucket& bucket, JSONObj *obj)
   bucket = rgw_bucket(pool.c_str());
 }
 
+void RGWZonePlacementInfo::dump(Formatter *f) const
+{
+  encode_json("index_pool", index_pool, f);
+  encode_json("data_pool", data_pool, f);
+}
+
+void RGWZonePlacementInfo::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("index_pool", index_pool, obj);
+  JSONDecoder::decode_json("data_pool", data_pool, obj);
+}
+
 void RGWZoneParams::decode_json(JSONObj *obj)
 {
   ::decode_json("domain_root", domain_root, obj);
@@ -525,6 +538,7 @@ void RGWZoneParams::decode_json(JSONObj *obj)
   ::decode_json("user_swift_pool", user_swift_pool, obj);
   ::decode_json("user_uid_pool ", user_uid_pool, obj);
   JSONDecoder::decode_json("system_key", system_key, obj);
+  JSONDecoder::decode_json("placement_pools", placement_pools, obj);
 }
 
 void RGWZone::dump(Formatter *f) const
@@ -539,6 +553,18 @@ void RGWZone::decode_json(JSONObj *obj)
   JSONDecoder::decode_json("endpoints", endpoints, obj);
 }
 
+void RGWRegionPlacementTarget::dump(Formatter *f) const
+{
+  encode_json("name", name, f);
+  encode_json("tags", tags, f);
+}
+
+void RGWRegionPlacementTarget::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("name", name, obj);
+  JSONDecoder::decode_json("tags", tags, obj);
+}
+
 void RGWRegion::dump(Formatter *f) const
 {
   encode_json("name", name, f);
@@ -547,6 +573,7 @@ void RGWRegion::dump(Formatter *f) const
   encode_json("endpoints", endpoints, f);
   encode_json("master_zone", master_zone, f);
   encode_json_map("zones", zones, f); /* more friendly representation */
+  encode_json_map("placement_targets", placement_targets, f); /* more friendly representation */
 }
 
 static void decode_zones(map<string, RGWZone>& zones, JSONObj *o)
@@ -556,6 +583,13 @@ static void decode_zones(map<string, RGWZone>& zones, JSONObj *o)
   zones[z.name] = z;
 }
 
+static void decode_placement_targets(map<string, RGWRegionPlacementTarget>& targets, JSONObj *o)
+{
+  RGWRegionPlacementTarget t;
+  t.decode_json(o);
+  targets[t.name] = t;
+}
+
 
 void RGWRegion::decode_json(JSONObj *obj)
 {
@@ -565,6 +599,7 @@ void RGWRegion::decode_json(JSONObj *obj)
   JSONDecoder::decode_json("endpoints", endpoints, obj);
   JSONDecoder::decode_json("master_zone", master_zone, obj);
   JSONDecoder::decode_json("zones", zones, decode_zones, obj);
+  JSONDecoder::decode_json("placement_targets", placement_targets, decode_placement_targets, obj);
 }
 
 
index 1a78c6d6a9f9c8d4e3239cd69a4e21b028eea954..5c48df9d80956f6ee6ec88e18d0f789d8797cf5f 100644 (file)
@@ -388,6 +388,29 @@ struct RGWListRawObjsCtx {
 
 struct RGWRegion;
 
+
+struct RGWZonePlacementInfo {
+  string index_pool;
+  string data_pool;
+
+  void encode(bufferlist& bl) const {
+    ENCODE_START(3, 1, bl);
+    ::encode(index_pool, bl);
+    ::encode(data_pool, bl);
+    ENCODE_FINISH(bl);
+  }
+
+  void decode(bufferlist::iterator& bl) {
+    DECODE_START(1, bl);
+    ::decode(index_pool, bl);
+    ::decode(data_pool, bl);
+    DECODE_FINISH(bl);
+  }
+  void dump(Formatter *f) const;
+  void decode_json(JSONObj *obj);
+};
+WRITE_CLASS_ENCODER(RGWZonePlacementInfo);
+
 struct RGWZoneParams {
   rgw_bucket domain_root;
   rgw_bucket control_pool;
@@ -405,6 +428,8 @@ struct RGWZoneParams {
 
   RGWAccessKey system_key;
 
+  map<string, RGWZonePlacementInfo> placement_pools;
+
   static string get_pool_name(CephContext *cct);
   void init_name(CephContext *cct, RGWRegion& region);
   int init(CephContext *cct, RGWRados *store, RGWRegion& region);
@@ -412,7 +437,7 @@ struct RGWZoneParams {
   int store_info(CephContext *cct, RGWRados *store, RGWRegion& region);
 
   void encode(bufferlist& bl) const {
-    ENCODE_START(3, 1, bl);
+    ENCODE_START(4, 1, bl);
     ::encode(domain_root, bl);
     ::encode(control_pool, bl);
     ::encode(gc_pool, bl);
@@ -425,11 +450,12 @@ struct RGWZoneParams {
     ::encode(user_uid_pool, bl);
     ::encode(name, bl);
     ::encode(system_key, bl);
+    ::encode(placement_pools, bl);
     ENCODE_FINISH(bl);
   }
 
   void decode(bufferlist::iterator& bl) {
-     DECODE_START(3, bl);
+     DECODE_START(4, bl);
     ::decode(domain_root, bl);
     ::decode(control_pool, bl);
     ::decode(gc_pool, bl);
@@ -444,6 +470,8 @@ struct RGWZoneParams {
       ::decode(name, bl);
     if (struct_v >= 3)
       ::decode(system_key, bl);
+    if (struct_v >= 4)
+      ::decode(placement_pools, bl);
     DECODE_FINISH(bl);
   }
   void dump(Formatter *f) const;
@@ -492,6 +520,29 @@ struct RGWDefaultRegionInfo {
 };
 WRITE_CLASS_ENCODER(RGWDefaultRegionInfo);
 
+struct RGWRegionPlacementTarget {
+  string name;
+  list<string> tags;
+
+  void encode(bufferlist& bl) const {
+    ENCODE_START(1, 1, bl);
+    ::encode(name, bl);
+    ::encode(tags, bl);
+    ENCODE_FINISH(bl);
+  }
+
+  void decode(bufferlist::iterator& bl) {
+    DECODE_START(1, bl);
+    ::decode(name, bl);
+    ::decode(tags, bl);
+    DECODE_FINISH(bl);
+  }
+  void dump(Formatter *f) const;
+  void decode_json(JSONObj *obj);
+};
+WRITE_CLASS_ENCODER(RGWRegionPlacementTarget);
+
+
 struct RGWRegion {
   string name;
   string api_name;
@@ -501,6 +552,8 @@ struct RGWRegion {
   string master_zone;
   map<string, RGWZone> zones;
 
+  map<string, RGWRegionPlacementTarget> placement_targets;
+
   CephContext *cct;
   RGWRados *store;