| 77 | } |
| 78 | |
| 79 | Optional<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 | |
| 120 | bool LatencyBandConfig::operator==(LatencyBandConfig const& r) const { |
| 121 | return grvConfig == r.grvConfig && readConfig == r.readConfig && commitConfig == r.commitConfig; |
nothing calls this directly
no test coverage detected