otp->init(zone.get(), meta.get(), meta_be_otp.get());
rados->init();
zone->init(sysobj.get(), radoshandle, sync_modules.get(), bucket_sync_sobj.get());
- zone_utils->init(rados.get(), zone.get());
+ zone_utils->init(radoshandle, zone.get());
quota->init(zone.get());
sync_modules->init(zone.get());
sysobj_core->core_init(rados.get(), zone.get());
#include "svc_rados.h"
#include "svc_zone.h"
+#undef FMT_HEADER_ONLY
+#define FMT_HEADER_ONLY 1
+#include <fmt/format.h>
+
#include "rgw_zone.h"
using namespace std;
string RGWSI_ZoneUtils::gen_host_id() {
/* uint64_t needs 16, two '-' separators and a trailing null */
- const string& zone_name = zone_svc->get_zone().name;
- const string& zonegroup_name = zone_svc->get_zonegroup().get_name();
- char charbuf[16 + zone_name.size() + zonegroup_name.size() + 2 + 1];
- snprintf(charbuf, sizeof(charbuf), "%llx-%s-%s", (unsigned long long)rados_svc->instance_id(), zone_name.c_str(), zonegroup_name.c_str());
- return string(charbuf);
+ return fmt::format("{}-{}-{}", rados->get_instance_id(),
+ zone_svc->get_zone().name,
+ zone_svc->get_zonegroup().get_name());
}
string RGWSI_ZoneUtils::unique_id(uint64_t unique_num)
{
- char buf[32];
- snprintf(buf, sizeof(buf), ".%llu.%llu", (unsigned long long)rados_svc->instance_id(), (unsigned long long)unique_num);
- string s = zone_svc->get_zone_params().get_id() + buf;
- return s;
+ return fmt::format("{}.{}.{}",
+ zone_svc->get_zone_params().get_id(),
+ rados->get_instance_id(),
+ unique_num);
}
void RGWSI_ZoneUtils::init_unique_trans_id_deps() {
- char buf[16 + 2 + 1]; /* uint64_t needs 16, 2 hyphens add further 2 */
-
- snprintf(buf, sizeof(buf), "-%llx-", (unsigned long long)rados_svc->instance_id());
- url_encode(string(buf) + zone_svc->get_zone().name, trans_id_suffix);
+ url_encode(fmt::format("-{}-{}",
+ rados->get_instance_id(),
+ zone_svc->get_zone().name),
+ trans_id_suffix);
}
/* In order to preserve compatibility with Swift API, transaction ID
#include "rgw_service.h"
-class RGWSI_RADOS;
class RGWSI_Zone;
class RGWSI_ZoneUtils : public RGWServiceInstance
{
friend struct RGWServices_Def;
- RGWSI_RADOS *rados_svc{nullptr};
+ librados::Rados* rados{nullptr};
RGWSI_Zone *zone_svc{nullptr};
std::string trans_id_suffix;
- void init(RGWSI_RADOS *_rados_svc,
+ void init(librados::Rados* rados_,
RGWSI_Zone *_zone_svc) {
- rados_svc = _rados_svc;
+ rados = rados_;
zone_svc = _zone_svc;
}