From: Yehuda Sadeh Date: Fri, 21 Jun 2013 23:06:51 +0000 (-0700) Subject: rgw: data structures for new data/index placement rules X-Git-Tag: v0.67-rc1~128^2~65 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e5e924ca710f1012051fa398fb22225f18167f52;p=ceph.git rgw: data structures for new data/index placement rules Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_json_enc.cc b/src/rgw/rgw_json_enc.cc index afdf1d6d8b34..3dbd1e420713 100644 --- a/src/rgw/rgw_json_enc.cc +++ b/src/rgw/rgw_json_enc.cc @@ -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& zones, JSONObj *o) @@ -556,6 +583,13 @@ static void decode_zones(map& zones, JSONObj *o) zones[z.name] = z; } +static void decode_placement_targets(map& 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); } diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 1a78c6d6a9f9..5c48df9d8095 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -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 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 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 zones; + map placement_targets; + CephContext *cct; RGWRados *store;