#define dout_subsys ceph_subsys_rgw
+string rgw_sync_bucket_entity::bucket_key() const
+{
+ return rgw_sync_bucket_entities::bucket_key(bucket);
+}
+
void rgw_sync_bucket_entities::add_zones(const std::vector<string>& new_zones) {
for (auto& z : new_zones) {
if (z == "*") {
return m.find(rgw_bucket());
}
-
+#warning cleanup
+#if 0
void RGWBucketSyncFlowManager::update_flow_maps(const rgw_sync_bucket_pipes& pipe) {
auto source_bucket = pipe.source.get_bucket();
auto dest_bucket = pipe.dest.get_bucket();
}
#endif
}
+#endif
void RGWBucketSyncFlowManager::init(const rgw_sync_policy_info& sync_policy) {
- rgw_sync_bucket_entities entity;
- entity.zones = std::set<string>( { zone_name } );
- entity.bucket = bucket;
+ rgw_sync_bucket_entity entity;
+ entity.zone = zone_name;
+ entity.bucket = bucket.value_or(rgw_bucket());
for (auto& item : sync_policy.groups) {
auto& group = item.second;
});
for (auto& entry : flow_group_map.sources) {
- rgw_sync_bucket_pipes pipe;
- rgw_sync_bucket_entities source;
- pipe.source.zones = std::set<string>( { entry.first.zone } );
+ rgw_sync_bucket_pipe pipe;
+ rgw_sync_bucket_entity source;
+ pipe.source.zone = entry.first.zone;
pipe.source.bucket = entry.first.bucket;
pipe.dest = entity;
- auto& by_source = flow_by_source[pipe.source.get_bucket()];
+ auto& by_source = flow_by_source[pipe.source.bucket];
by_source.pipe.push_back(pipe);
}
for (auto& entry : flow_group_map.dests) {
- rgw_sync_bucket_pipes pipe;
- rgw_sync_bucket_entities dest;
- pipe.dest.zones = std::set<string>( { entry.first.zone } );
+ rgw_sync_bucket_pipe pipe;
+ rgw_sync_bucket_entity dest;
+ pipe.dest.zone = entry.first.zone;
pipe.dest.bucket = entry.first.bucket;
pipe.source = entity;
- auto& by_dest = flow_by_source[pipe.dest.get_bucket()];
+ auto& by_dest = flow_by_source[pipe.dest.bucket];
by_dest.pipe.push_back(pipe);
}
}
class RGWBucketSyncFlowManager {
public:
struct pipe_flow {
- std::vector<rgw_sync_bucket_pipes> pipe;
+ std::vector<rgw_sync_bucket_pipe> pipe;
void dump(ceph::Formatter *f) const;
};
JSONDecoder::decode_json("zones", zones, obj);
}
+void rgw_sync_bucket_entity::dump(Formatter *f) const
+{
+ encode_json("zone", zone, f);
+ encode_json("bucket", bucket_key(), f);
+}
+
+void rgw_sync_bucket_entity::decode_json(JSONObj *obj)
+{
+ JSONDecoder::decode_json("zone", zone, obj);
+ string s;
+ JSONDecoder::decode_json("bucket", s, obj);
+ int ret = rgw_bucket_parse_bucket_key(nullptr, s, &bucket, nullptr);
+ if (ret < 0) {
+ bucket = rgw_bucket();
+ }
+}
void rgw_sync_bucket_entities::dump(Formatter *f) const
{
encode_json("bucket", rgw_sync_bucket_entities::bucket_key(bucket), f);
JSONDecoder::decode_json("zones", zones, obj);
}
+void rgw_sync_bucket_pipe::dump(Formatter *f) const
+{
+ encode_json("source", source, f);
+ encode_json("dest", dest, f);
+}
+
+void rgw_sync_bucket_pipe::decode_json(JSONObj *obj)
+{
+ JSONDecoder::decode_json("source", source, obj);
+ JSONDecoder::decode_json("dest", dest, obj);
+}
+
void rgw_sync_bucket_pipes::dump(Formatter *f) const
{
encode_json("id", id, f);
};
WRITE_CLASS_ENCODER(rgw_sync_directional_rule)
+struct rgw_sync_bucket_entity {
+ string zone; /* define specific zones */
+ rgw_bucket bucket; /* define specific bucket */
+
+ void encode(bufferlist& bl) const {
+ ENCODE_START(1, 1, bl);
+ encode(zone, bl);
+ encode(bucket, bl);
+ ENCODE_FINISH(bl);
+ }
+
+ void decode(bufferlist::const_iterator& bl) {
+ DECODE_START(1, bl);
+ decode(zone, bl);
+ decode(bucket, bl);
+ DECODE_FINISH(bl);
+ }
+
+ void dump(ceph::Formatter *f) const;
+ void decode_json(JSONObj *obj);
+
+ string bucket_key() const;
+
+ const bool operator<(const rgw_sync_bucket_entity& e) const {
+ if (zone < e.zone) {
+ return true;
+ }
+ if (zone > e.zone) {
+ return false;
+ }
+ return (bucket < e.bucket);
+ }
+};
+WRITE_CLASS_ENCODER(rgw_sync_bucket_entity)
+
+struct rgw_sync_bucket_pipe {
+public:
+ rgw_sync_bucket_entity source;
+ rgw_sync_bucket_entity dest;
+
+ void encode(bufferlist& bl) const {
+ ENCODE_START(1, 1, bl);
+ encode(source, bl);
+ encode(dest, bl);
+ ENCODE_FINISH(bl);
+ }
+
+ void decode(bufferlist::const_iterator& bl) {
+ DECODE_START(1, bl);
+ decode(source, bl);
+ decode(dest, bl);
+ DECODE_FINISH(bl);
+ }
+
+ void dump(ceph::Formatter *f) const;
+ void decode_json(JSONObj *obj);
+};
+WRITE_CLASS_ENCODER(rgw_sync_bucket_pipe)
+
struct rgw_sync_bucket_entities {
private:
bool match_str(const string& s1, const string& s2) const { /* empty string is wildcard */