diff options
author | Yehuda Sadeh <yehuda@inktank.com> | 2013-02-11 16:41:28 -0800 |
---|---|---|
committer | Yehuda Sadeh <yehuda@inktank.com> | 2013-02-12 14:51:24 -0800 |
commit | 2fd2eae3632023045fc85b52e3f46ad93f5028b8 (patch) | |
tree | e014958e45285855585ba7f981b302990d9f0db0 | |
parent | 1ce4a558205313b952225dfea47747783fb96b49 (diff) | |
download | ceph-2fd2eae3632023045fc85b52e3f46ad93f5028b8.tar.gz |
rgw: define region/zone data structures
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r-- | src/rgw/rgw_rados.cc | 68 | ||||
-rw-r--r-- | src/rgw/rgw_rados.h | 73 |
2 files changed, 141 insertions, 0 deletions
diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 00af91bda4c..9b8495229b8 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -147,6 +147,74 @@ int RGWZoneParams::store_info(CephContext *cct, RGWRados *store) return ret; } +void RGWZone::dump(Formatter *f) const +{ + f->dump_string("name", name); + f->open_array_section("endpoints"); + for (list<string>::const_iterator iter = endpoints.begin(); iter != endpoints.end(); ++iter) { + f->dump_string("endpoint", *iter); + } + f->close_section(); +} + +void RGWZone::decode_json(JSONObj *obj) +{ + JSONDecoder::decode_json("name", name, obj); + JSONDecoder::decode_json("endpoints", endpoints, obj); +} + +void RGWRegion::dump(Formatter *f) const +{ + f->dump_string("name", name); + f->open_array_section("endpoints"); + for (list<string>::const_iterator iter = endpoints.begin(); iter != endpoints.end(); ++iter) { + f->dump_string("endpoint", *iter); + } + f->close_section(); + f->dump_string("master_zone", master_zone); + f->open_array_section("zones"); + for (list<RGWZone>::const_iterator iter = zones.begin(); iter != zones.end(); ++iter) { + const RGWZone& zone = *iter; + f->open_object_section("zone"); + zone.dump(f); + f->close_section(); + } + f->close_section(); +} + +void RGWRegion::decode_json(JSONObj *obj) +{ + JSONDecoder::decode_json("name", name, obj); + JSONDecoder::decode_json("endpoints", endpoints, obj); + JSONDecoder::decode_json("master_zone", master_zone, obj); + JSONDecoder::decode_json("zones", zones, obj); +} + + +void RGWRegionMap::dump(Formatter *f) const +{ + f->open_array_section("regions"); + for (map<string, RGWRegion>::const_iterator iter = regions.begin(); iter != regions.end(); ++iter) { + const RGWRegion& region = iter->second; + f->open_object_section("region"); + region.dump(f); + f->close_section(); + } + f->close_section(); + f->dump_string("master_region", master_region); +} + +void RGWRegionMap::decode_json(JSONObj *obj) +{ + list<RGWRegion> regions_list; + JSONDecoder::decode_json("regions", regions_list, obj); + + for (list<RGWRegion>::iterator iter = regions_list.begin(); iter != regions_list.end(); ++iter) { + RGWRegion& region = *iter; + regions[region.name] = region; + } +} + void RGWObjManifest::append(RGWObjManifest& m) { map<uint64_t, RGWObjManifestPart>::iterator iter; diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 68cfcc76a2a..dec71bf98d3 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -281,6 +281,79 @@ struct RGWZoneParams { void decode_json(JSONObj *obj); }; WRITE_CLASS_ENCODER(RGWZoneParams); + +struct RGWZone { + string name; + list<string> endpoints; + + void encode(bufferlist& bl) const { + ENCODE_START(1, 1, bl); + ::encode(name, bl); + ::encode(endpoints, bl); + ENCODE_FINISH(bl); + } + + void decode(bufferlist::iterator& bl) { + DECODE_START(1, bl); + ::decode(name, bl); + ::decode(endpoints, bl); + DECODE_FINISH(bl); + } + void dump(Formatter *f) const; + void decode_json(JSONObj *obj); +}; +WRITE_CLASS_ENCODER(RGWZone); + +struct RGWRegion { + string name; + list<string> endpoints; + + string master_zone; + list<RGWZone> zones; + + void encode(bufferlist& bl) const { + ENCODE_START(1, 1, bl); + ::encode(endpoints, bl); + ::encode(master_zone, bl); + ::encode(zones, bl); + ENCODE_FINISH(bl); + } + + void decode(bufferlist::iterator& bl) { + DECODE_START(1, bl); + ::decode(endpoints, bl); + ::decode(master_zone, bl); + ::decode(zones, bl); + DECODE_FINISH(bl); + } + void dump(Formatter *f) const; + void decode_json(JSONObj *obj); +}; +WRITE_CLASS_ENCODER(RGWRegion); + +struct RGWRegionMap { + map<string, RGWRegion> regions; + + string master_region; + + void encode(bufferlist& bl) const { + ENCODE_START(1, 1, bl); + ::encode(regions, bl); + ENCODE_FINISH(bl); + } + + void decode(bufferlist::iterator& bl) { + DECODE_START(1, bl); + ::decode(regions, bl); + DECODE_FINISH(bl); + } + + void dump(Formatter *f) const; + void decode_json(JSONObj *obj); +}; +WRITE_CLASS_ENCODER(RGWRegionMap); + + class RGWRados { |