Can only sync from tiers that can export data.
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
string zone_name;
string source_str = "source: ";
string s = source_str + source_id;
- auto siter = store->zone_name_by_id.find(source_id);
- if (siter != store->zone_name_by_id.end()) {
- s += string(" (") + siter->second + ")";
+ auto siter = store->zone_by_id.find(source_id);
+ if (siter != store->zone_by_id.end()) {
+ s += string(" (") + siter->second.name + ")";
}
data_status.push_back(s);
get_data_sync_status(source_id, data_status, source_str.size());
int RGWDataSyncStatusManager::init()
{
+ auto zone_def_iter = store->zone_by_id.find(source_zone);
+ if (zone_def_iter == store->zone_by_id.end()) {
+ ldout(store->ctx(), 0) << "ERROR: failed to find zone config info for zone=" << source_zone << dendl;
+ return -EIO;
+ }
+
+ auto& zone_def = zone_def_iter->second;
+
+ map<string, string> sync_module_config;
+
+ if (!store->get_sync_modules_manager()->supports_data_export(zone_def.tier_type)) {
+ return -ENOTSUP;
+ }
+
+ int r = store->get_sync_modules_manager()->create_instance(zone_def.tier_type, sync_module_config, &sync_module);
+ if (r < 0) {
+ lderr(store->ctx()) << "ERROR: failed to init sync module instance, r=" << r << dendl;
+ finalize();
+ return r;
+ }
+
conn = store->get_zone_conn_by_id(source_zone);
if (!conn) {
ldout(store->ctx(), 0) << "connection object to zone " << source_zone << " does not exist" << dendl;
const char *log_pool = store->get_zone_params().log_pool.name.c_str();
librados::Rados *rados = store->get_rados_handle();
- int r = rados->ioctx_create(log_pool, ioctx);
+ r = rados->ioctx_create(log_pool, ioctx);
if (r < 0) {
lderr(store->ctx()) << "ERROR: failed to open log pool (" << store->get_zone_params().log_pool.name << " ret=" << r << dendl;
return r;
error_logger = new RGWSyncErrorLogger(store, RGW_SYNC_ERROR_LOG_SHARD_PREFIX, ERROR_LOGGER_SHARDS);
- map<string, string> sync_module_config;
- r = store->get_sync_modules_manager()->create_instance("default", sync_module_config, &sync_module);
- if (r < 0) {
- lderr(store->ctx()) << "ERROR: failed to init sync module instance, r=" << r << dendl;
- finalize();
- return r;
- }
-
r = source_log.init(source_zone, conn, error_logger, sync_module);
if (r < 0) {
lderr(store->ctx()) << "ERROR: failed to init remote log, r=" << r << dendl;
class RGWDefaultSyncModule : public RGWSyncModule {
public:
RGWDefaultSyncModule() {}
+ bool supports_data_export() override { return true; }
int create_instance(map<string, string>& config, RGWSyncModuleInstanceRef *instance) override;
};
encode_json("log_data", log_data, f);
encode_json("bucket_index_max_shards", bucket_index_max_shards, f);
encode_json("read_only", read_only, f);
+ encode_json("tier_type", tier_type, f);
}
void RGWZone::decode_json(JSONObj *obj)
JSONDecoder::decode_json("log_data", log_data, obj);
JSONDecoder::decode_json("bucket_index_max_shards", bucket_index_max_shards, obj);
JSONDecoder::decode_json("read_only", read_only, obj);
+ JSONDecoder::decode_json("tier_type", tier_type, obj);
}
void RGWZoneGroupPlacementTarget::dump(Formatter *f) const
sync_modules_manager = new RGWSyncModulesManager();
RGWSyncModuleRef default_module(new RGWDefaultSyncModule());
- sync_modules_manager->register_module("default", default_module);
+ sync_modules_manager->register_module("rgw", default_module, true);
auto crs = std::unique_ptr<RGWCoroutinesManagerRegistry>{
new RGWCoroutinesManagerRegistry(cct)};
const string& id = ziter->first;
RGWZone& z = ziter->second;
zone_id_by_name[z.name] = id;
- zone_name_by_id[id] = z.name;
+ zone_by_id[id] = z;
if (id != zone_id()) {
if (!z.endpoints.empty()) {
ldout(cct, 20) << "generating connection object for zone " << z.name << " id " << z.id << dendl;
bool log_meta;
bool log_data;
bool read_only;
+ string tier_type;
/**
* Represents the number of shards for the bucket index object, a value of zero
RGWZone() : log_meta(false), log_data(false), read_only(false), bucket_index_max_shards(0) {}
void encode(bufferlist& bl) const {
- ENCODE_START(4, 1, bl);
+ ENCODE_START(5, 1, bl);
::encode(name, bl);
::encode(endpoints, bl);
::encode(log_meta, bl);
::encode(bucket_index_max_shards, bl);
::encode(id, bl);
::encode(read_only, bl);
+ ::encode(tier_type, bl);
ENCODE_FINISH(bl);
}
void decode(bufferlist::iterator& bl) {
- DECODE_START(4, bl);
+ DECODE_START(5, bl);
::decode(name, bl);
if (struct_v < 4) {
id = name;
::decode(id, bl);
::decode(read_only, bl);
}
+ if (struct_v >= 5) {
+ ::decode(tier_type, bl);
+ }
DECODE_FINISH(bl);
}
void dump(Formatter *f) const;
map<string, RGWRESTConn *> zonegroup_conn_map;
map<string, string> zone_id_by_name;
- map<string, string> zone_name_by_id;
+ map<string, RGWZone> zone_by_id;
RGWRESTConn *get_zone_conn_by_id(const string& id) {
auto citer = zone_conn_map.find(id);
RGWSyncModule() {}
virtual ~RGWSyncModule() {}
+ virtual bool supports_data_export() = 0;
virtual int create_instance(map<string, string>& config, RGWSyncModuleInstanceRef *instance) = 0;
};
public:
RGWSyncModulesManager() : lock("RGWSyncModulesManager") {}
- void register_module(const string& name, RGWSyncModuleRef& module) {
+ void register_module(const string& name, RGWSyncModuleRef& module, bool is_default = false) {
Mutex::Locker l(lock);
modules[name] = module;
+ if (is_default) {
+ modules[string()] = module;
+ }
}
bool get_module(const string& name, RGWSyncModuleRef *module) {
}
+ int supports_data_export(const string& name) {
+ RGWSyncModuleRef module;
+ if (!get_module(name, &module)) {
+ return -ENOENT;
+ }
+
+ return module.get()->supports_data_export();
+ }
+
int create_instance(const string& name, map<string, string>& config, RGWSyncModuleInstanceRef *instance) {
RGWSyncModuleRef module;
if (!get_module(name, &module)) {