{
encode_json("id", id, f);
encode_json_map("zonegroups", zonegroups, f);
+ encode_json("short_zone_ids", short_zone_ids, f);
}
static void decode_zonegroups(map<string, RGWZoneGroup>& zonegroups, JSONObj *o)
if (master_zonegroup.empty()) {
JSONDecoder::decode_json("master_region", master_zonegroup, obj);
}
+ JSONDecoder::decode_json("short_zone_ids", short_zone_ids, obj);
}
}
void RGWPeriodMap::encode(bufferlist& bl) const {
- ENCODE_START(1, 1, bl);
+ ENCODE_START(2, 1, bl);
::encode(id, bl);
::encode(zonegroups, bl);
::encode(master_zonegroup, bl);
+ ::encode(short_zone_ids, bl);
ENCODE_FINISH(bl);
}
void RGWPeriodMap::decode(bufferlist::iterator& bl) {
- DECODE_START(1, bl);
+ DECODE_START(2, bl);
::decode(id, bl);
::decode(zonegroups, bl);
::decode(master_zonegroup, bl);
+ if (struct_v >= 2) {
+ ::decode(short_zone_ids, bl);
+ }
DECODE_FINISH(bl);
zonegroups_by_api.clear();
master_zonegroup = "";
}
+ for (auto iter : zonegroups) {
+ for (auto i : iter.second.zones) {
+ string& zone_id = i.second.id;
+ if (short_zone_ids.find(zone_id) == short_zone_ids.end()) {
+ uint32_t short_id;
+
+ unsigned char md5[CEPH_CRYPTO_MD5_DIGESTSIZE];
+ MD5 hash;
+ hash.Update((const byte *)zone_id.c_str(), zone_id.size());
+ hash.Final(md5);
+ memcpy((char *)&short_id, md5, sizeof(short_id));
+
+ short_zone_ids[i.second.id] = short_id;
+ }
+ }
+ }
+
return 0;
}
+uint32_t RGWPeriodMap::get_zone_short_id(const string& zone_id) const
+{
+ auto i = short_zone_ids.find(zone_id);
+ if (i == short_zone_ids.end()) {
+ return 0;
+ }
+ return i->second;
+}
+
int RGWZoneGroupMap::read(CephContext *cct, RGWRados *store)
{
return -EINVAL;
}
+ zone_short_id = current_period.get_map().get_zone_short_id(zone_params.get_id());
+
init_unique_trans_id_deps();
finisher = new Finisher(cct);
string id;
map<string, RGWZoneGroup> zonegroups;
map<string, RGWZoneGroup> zonegroups_by_api;
+ map<string, uint32_t> short_zone_ids;
string master_zonegroup;
zonegroups.clear();
zonegroups_by_api.clear();
}
+
+ uint32_t get_zone_short_id(const string& zone_id) const;
};
WRITE_CLASS_ENCODER(RGWPeriodMap)
RGWZoneGroup zonegroup;
RGWZone zone_public_config; /* external zone params, e.g., entrypoints, log flags, etc. */
RGWZoneParams zone_params; /* internal zone params, e.g., rados pools */
+ uint32_t zone_short_id;
RGWPeriod current_period;
public:
quota_handler(NULL),
finisher(NULL),
cr_registry(NULL),
+ zone_short_id(0),
rest_master_conn(NULL),
meta_mgr(NULL), data_log(NULL) {}
return zone_public_config;
}
+ uint32_t get_zone_short_id() const {
+ return zone_short_id;
+ }
+
const RGWQuotaInfo& get_bucket_quota() {
return current_period.get_config().bucket_quota;
}