diff options
author | Yehuda Sadeh <yehuda@inktank.com> | 2013-06-21 16:06:51 -0700 |
---|---|---|
committer | Yehuda Sadeh <yehuda@inktank.com> | 2013-06-21 16:06:51 -0700 |
commit | e5e924ca710f1012051fa398fb22225f18167f52 (patch) | |
tree | 006bc8ed71fb6c3efff0ed68e2d18946eb39240a | |
parent | 241ad07394f40eb39646e270a9f534a4bb031666 (diff) | |
download | ceph-e5e924ca710f1012051fa398fb22225f18167f52.tar.gz |
rgw: data structures for new data/index placement rules
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r-- | src/rgw/rgw_json_enc.cc | 35 | ||||
-rw-r--r-- | src/rgw/rgw_rados.h | 57 |
2 files changed, 90 insertions, 2 deletions
diff --git a/src/rgw/rgw_json_enc.cc b/src/rgw/rgw_json_enc.cc index afdf1d6d8b3..3dbd1e42071 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<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); } diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 1a78c6d6a9f..5c48df9d809 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<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; |