MCPcopy Create free account
hub / github.com/apple/foundationdb / parse

Method parse

fdbserver/LatencyBandConfig.cpp:79–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79Optional<LatencyBandConfig> LatencyBandConfig::parse(ValueRef configurationString) {
80 Optional<LatencyBandConfig> config;
81 if (configurationString.size() == 0) {
82 return config;
83 }
84
85 json_spirit::mValue parsedConfig;
86 if (!json_spirit::read_string(configurationString.toString(), parsedConfig)) {
87 TraceEvent(SevWarnAlways, "InvalidLatencyBandConfiguration")
88 .detail("Reason", "InvalidJSON")
89 .detail("Configuration", configurationString);
90 return config;
91 }
92
93 json_spirit::mObject configJson = parsedConfig.get_obj();
94
95 json_spirit::mValue schema;
96 if (!json_spirit::read_string(JSONSchemas::latencyBandConfigurationSchema.toString(), schema)) {
97 ASSERT(false);
98 }
99
100 std::string errorStr;
101 if (!schemaMatch(schema.get_obj(), configJson, errorStr)) {
102 TraceEvent(SevWarnAlways, "InvalidLatencyBandConfiguration")
103 .detail("Reason", "SchemaMismatch")
104 .detail("Configuration", configurationString)
105 .detail("Error", errorStr);
106 return config;
107 }
108
109 JSONDoc configDoc(configJson);
110
111 config = LatencyBandConfig();
112
113 config.get().grvConfig.fromJson(configDoc.subDoc("get_read_version"));
114 config.get().readConfig.fromJson(configDoc.subDoc("read"));
115 config.get().commitConfig.fromJson(configDoc.subDoc("commit"));
116
117 return config;
118}
119
120bool LatencyBandConfig::operator==(LatencyBandConfig const& r) const {
121 return grvConfig == r.grvConfig && readConfig == r.readConfig && commitConfig == r.commitConfig;

Callers

nothing calls this directly

Calls 10

read_stringFunction · 0.85
TraceEventClass · 0.85
schemaMatchFunction · 0.85
LatencyBandConfigClass · 0.85
detailMethod · 0.80
fromJsonMethod · 0.80
subDocMethod · 0.80
getMethod · 0.65
sizeMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected