encode_json("time_to_live", time_to_live!=DEFAULT_GLOBAL_VALUE? std::to_string(time_to_live): DEFAULT_CONFIG, f);
encode_json("max_retries", max_retries!=DEFAULT_GLOBAL_VALUE? std::to_string(max_retries): DEFAULT_CONFIG, f);
encode_json("retry_sleep_duration", retry_sleep_duration!=DEFAULT_GLOBAL_VALUE? std::to_string(retry_sleep_duration): DEFAULT_CONFIG, f);
+ encode_json("num_shards", num_shards, f);
}
void rgw_pubsub_dest::dump_xml(Formatter *f) const
retry_sleep_duration = sleep_dur == DEFAULT_CONFIG ? DEFAULT_GLOBAL_VALUE
: std::stoul(sleep_dur);
+ // if no "num_shards" field found in the JSON blob, num_shards defaults to 1
+ // (in the member initializer) for backward compatibility with pre-sharding
+ // persistent topics. Non-persistent topics don't use "num_shards".
+ JSONDecoder::decode_json("num_shards", num_shards, f);
}
ShardNamesView rgw_pubsub_dest::get_shard_names() const {
uint32_t max_retries;
uint32_t retry_sleep_duration;
// naming convention of sharded queues in the 'notif' pool -> persistent_queue, persistent_queue.1, persistent_queue.(num_shards -1)...
- uint64_t num_shards; //defaults to a single shard for now, for backward compatibility
+ uint64_t num_shards = 1; // Default to 1 shard for backward compatibility with pre-sharding persistent topics.
void encode(bufferlist& bl) const {
if (struct_v >= 5) {
decode(persistent, bl);
}
- else {
- num_shards = persistent ? 1 : 0; //defaults to a single shard for backward compatibility
- }
if (struct_v >= 6) {
decode(time_to_live, bl);
decode(max_retries, bl);
// continue to use 'arn_topic' alone as the queue's rados object name
persistent_queue = arn_topic;
}
- if (struct_v >= 8) {
+ if (struct_v >= 8) {
+ // for struct_v < 8, num_shards defaults to 1 (single shard for pre-sharding persistent topics)
decode(num_shards, bl);
}