Support local reads in client
This commit is contained in:
@@ -91,7 +91,7 @@ std::string validate_pool_config(json11::Json::object & new_cfg, json11::Json ol
|
||||
}
|
||||
else if (key == "name" || key == "scheme" || key == "immediate_commit" ||
|
||||
key == "failure_domain" || key == "root_node" || key == "scrub_interval" || key == "used_for_app" ||
|
||||
key == "used_for_fs" || key == "raw_placement")
|
||||
key == "used_for_fs" || key == "raw_placement" || key == "local_reads")
|
||||
{
|
||||
if (!value.is_string())
|
||||
{
|
||||
@@ -165,6 +165,10 @@ std::string validate_pool_config(json11::Json::object & new_cfg, json11::Json ol
|
||||
new_cfg["used_for_app"] = "fs:"+new_cfg["used_for_fs"].string_value();
|
||||
new_cfg.erase("used_for_fs");
|
||||
}
|
||||
if (new_cfg.find("local_reads") != new_cfg.end() && new_cfg["local_reads"].string_value() == "primary")
|
||||
{
|
||||
new_cfg.erase("local_reads");
|
||||
}
|
||||
|
||||
// Prevent autovivification of object keys. Now we don't modify the config, we just check it
|
||||
json11::Json cfg = new_cfg;
|
||||
@@ -340,5 +344,19 @@ std::string validate_pool_config(json11::Json::object & new_cfg, json11::Json ol
|
||||
}
|
||||
}
|
||||
|
||||
// local_reads
|
||||
if (!cfg["local_reads"].is_null())
|
||||
{
|
||||
auto lr = cfg["local_reads"].string_value();
|
||||
if (lr != "" && lr != "primary" && lr != "nearest" && lr != "random")
|
||||
{
|
||||
return "local_reads must be '', 'primary', 'nearest' or 'random', but it is "+cfg["local_reads"].string_value();
|
||||
}
|
||||
if (lr != "" && lr != "primary" && scheme != POOL_SCHEME_REPLICATED)
|
||||
{
|
||||
return "EC pools don't support localized reads, please clear local_reads or set it to 'primary'";
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user