rgw: store cluster params in a special object

We now have a cluster root pool that should hold the
cluster params. The cluster params are now read from
this object on startup, if object does not exist we
set its defaults and write it.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
This commit is contained in:
Yehuda Sadeh 2012-08-29 15:34:17 -07:00
parent ac481e8ed5
commit ff0f88a6ce
3 changed files with 67 additions and 1 deletions

View File

@ -411,6 +411,7 @@ OPTION(rgw_num_control_oids, OPT_INT, 8)
OPTION(rgw_maintenance_tick_interval, OPT_DOUBLE, 10.0)
OPTION(rgw_pools_preallocate_max, OPT_INT, 100)
OPTION(rgw_pools_preallocate_threshold, OPT_INT, 70)
OPTION(rgw_cluster_root_pool, OPT_STR, ".rgw.root")
OPTION(rgw_log_nonexistent_bucket, OPT_BOOL, false)
OPTION(rgw_log_object_name, OPT_STR, "%Y-%m-%d-%H-%i-%n") // man date to see codes (a subset are supported)
OPTION(rgw_log_object_name_utc, OPT_BOOL, false)

View File

@ -43,12 +43,16 @@ static string dir_oid_prefix = ".dir.";
static string default_storage_pool = ".rgw.buckets";
static string avail_pools = ".pools.avail";
static string cluster_info_oid = "cluster_info";
static RGWObjCategory shadow_category = RGW_OBJ_CATEGORY_SHADOW;
static RGWObjCategory main_category = RGW_OBJ_CATEGORY_MAIN;
#define RGW_USAGE_OBJ_PREFIX "usage."
#define RGW_DEFAULT_CLUSTER_ROOT_POOL ".rgw.root"
#define dout_subsys ceph_subsys_rgw
@ -66,6 +70,35 @@ void RGWRadosParams::init_default()
user_uid_pool = ".users.uid";
}
int RGWRadosParams::init(CephContext *cct, RGWRados *store)
{
string pool_name = cct->_conf->rgw_cluster_root_pool;
if (pool_name.empty())
pool_name = RGW_DEFAULT_CLUSTER_ROOT_POOL;
rgw_bucket pool(pool_name.c_str());
bufferlist bl;
int ret = rgw_get_obj(store, NULL, pool, cluster_info_oid, bl);
if (ret == -ENOENT) {
init_default();
::encode(*this, bl);
ret = rgw_put_system_obj(store, pool, cluster_info_oid, bl.c_str(), bl.length(), true, NULL);
return ret;
}
if (ret < 0)
return ret;
try {
bufferlist::iterator iter = bl.begin();
::decode(*this, iter);
} catch (buffer::error& err) {
ldout(cct, 0) << "ERROR: failed to decode cluster info from " << pool << ":" << cluster_info_oid << dendl;
return -EIO;
}
return 0;
}
class RGWWatcher : public librados::WatchCtx {
RGWRados *rados;
@ -130,7 +163,7 @@ int RGWRados::initialize()
if (ret < 0)
return ret;
params.init_default();
params.init(cct, this);
ret = open_root_pool_ctx();
if (ret < 0)

View File

@ -195,8 +195,40 @@ struct RGWRadosParams {
rgw_bucket user_swift_pool;
rgw_bucket user_uid_pool;
int init(CephContext *cct, RGWRados *store);
void init_default();
void encode(bufferlist& bl) const {
ENCODE_START(1, 1, bl);
::encode(domain_root, bl);
::encode(control_pool, bl);
::encode(gc_pool, bl);
::encode(log_pool, bl);
::encode(intent_log_pool, bl);
::encode(usage_log_pool, bl);
::encode(user_keys_pool, bl);
::encode(user_email_pool, bl);
::encode(user_swift_pool, bl);
::encode(user_uid_pool, bl);
ENCODE_FINISH(bl);
}
void decode(bufferlist::iterator& bl) {
DECODE_START(1, bl);
::decode(domain_root, bl);
::decode(control_pool, bl);
::decode(gc_pool, bl);
::decode(log_pool, bl);
::decode(intent_log_pool, bl);
::decode(usage_log_pool, bl);
::decode(user_keys_pool, bl);
::decode(user_email_pool, bl);
::decode(user_swift_pool, bl);
::decode(user_uid_pool, bl);
DECODE_FINISH(bl);
}
};
WRITE_CLASS_ENCODER(RGWRadosParams);
class RGWRados
{