rgw: write multi shard markers on replica_log appropriately

When getting a list of shard_id#marker, iterate through the shards and
write each as needed.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
This commit is contained in:
Yehuda Sadeh 2014-12-08 15:44:09 -08:00
parent 15703cf9f9
commit 9536f74ac6
2 changed files with 38 additions and 4 deletions

View File

@ -14,8 +14,10 @@
#include "rgw_replica_log.h"
#include "cls/replica_log/cls_replica_log_client.h"
#include "cls/rgw/cls_rgw_client.h"
#include "rgw_rados.h"
#define dout_subsys ceph_subsys_rgw
void RGWReplicaBounds::dump(Formatter *f) const
{
@ -144,3 +146,38 @@ string RGWReplicaBucketLogger::obj_name(const rgw_bucket& bucket, int shard_id)
}
return s;
}
int RGWReplicaBucketLogger::update_bound(const rgw_bucket& bucket, int shard_id, const string& daemon_id,
const string& marker, const utime_t& time,
const list<RGWReplicaItemMarker> *entries)
{
if (shard_id >= 0 ||
!BucketIndexShardsManager::is_shards_marker(marker)) {
return RGWReplicaLogger::update_bound(obj_name(bucket, shard_id), pool,
daemon_id, marker, time, entries);
}
BucketIndexShardsManager sm;
int ret = sm.from_string(marker, true);
if (ret < 0) {
ldout(cct, 0) << "ERROR: could not parse shards marker: " << marker << dendl;
return ret;
}
map<int, string>& vals = sm.get();
ret = 0;
map<int, string>::iterator iter;
for (iter = vals.begin(); iter != vals.end(); ++iter) {
ldout(cct, 20) << "updating bound: bucket=" << bucket << " shard=" << iter->first << " marker=" << marker << dendl;
int r = RGWReplicaLogger::update_bound(obj_name(bucket, iter->first), pool,
daemon_id, iter->second, time, entries);
if (r < 0) {
ldout(cct, 0) << "failed to update bound: bucket=" << bucket << " shard=" << iter->first << " marker=" << marker << dendl;
ret = r;
}
}
return ret;
}

View File

@ -103,10 +103,7 @@ public:
RGWReplicaBucketLogger(RGWRados *_store);
int update_bound(const rgw_bucket& bucket, int shard_id, const string& daemon_id,
const string& marker, const utime_t& time,
const list<RGWReplicaItemMarker> *entries) {
return RGWReplicaLogger::update_bound(obj_name(bucket, shard_id), pool,
daemon_id, marker, time, entries);
}
const list<RGWReplicaItemMarker> *entries);
int delete_bound(const rgw_bucket& bucket, int shard_id, const string& daemon_id) {
return RGWReplicaLogger::delete_bound(obj_name(bucket, shard_id), pool,
daemon_id);