summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@inktank.com>2013-02-11 16:41:28 -0800
committerYehuda Sadeh <yehuda@inktank.com>2013-02-25 14:59:37 -0800
commitc0f64730cb133e27c65b51046fe874184cc4687c (patch)
tree240b1a1072c9d8c82528137d4596838e43a2f622
parent6c7611993e1006687b6f8e2f9a866701250fc90b (diff)
downloadceph-c0f64730cb133e27c65b51046fe874184cc4687c.tar.gz
rgw: define region/zone data structures
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r--src/rgw/rgw_rados.cc68
-rw-r--r--src/rgw/rgw_rados.h73
2 files changed, 141 insertions, 0 deletions
diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc
index d9753f8f596..f8fe3848a41 100644
--- a/src/rgw/rgw_rados.cc
+++ b/src/rgw/rgw_rados.cc
@@ -148,6 +148,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 1deb2ac1487..f6d1480f980 100644
--- a/src/rgw/rgw_rados.h
+++ b/src/rgw/rgw_rados.h
@@ -288,6 +288,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
{