| 157 | static const Key CLIENT_LATENCY_INFO_CTR_PREFIX = LiteralStringRef("client_latency_counter/"); |
| 158 | |
| 159 | void DatabaseContext::addTssMapping(StorageServerInterface const& ssi, StorageServerInterface const& tssi) { |
| 160 | auto result = tssMapping.find(ssi.id()); |
| 161 | // Update tss endpoint mapping if ss isn't in mapping, or the interface it mapped to changed |
| 162 | if (result == tssMapping.end() || |
| 163 | result->second.getValue.getEndpoint().token.first() != tssi.getValue.getEndpoint().token.first()) { |
| 164 | Reference<TSSMetrics> metrics; |
| 165 | if (result == tssMapping.end()) { |
| 166 | // new TSS pairing |
| 167 | metrics = makeReference<TSSMetrics>(); |
| 168 | tssMetrics[tssi.id()] = metrics; |
| 169 | tssMapping[ssi.id()] = tssi; |
| 170 | } else { |
| 171 | if (result->second.id() == tssi.id()) { |
| 172 | metrics = tssMetrics[tssi.id()]; |
| 173 | } else { |
| 174 | CODE_PROBE(true, "SS now maps to new TSS! This will probably never happen in practice"); |
| 175 | tssMetrics.erase(result->second.id()); |
| 176 | metrics = makeReference<TSSMetrics>(); |
| 177 | tssMetrics[tssi.id()] = metrics; |
| 178 | } |
| 179 | result->second = tssi; |
| 180 | } |
| 181 | |
| 182 | // data requests duplicated for load and data comparison |
| 183 | queueModel.updateTssEndpoint(ssi.getValue.getEndpoint().token.first(), |
| 184 | TSSEndpointData(tssi.id(), tssi.getValue.getEndpoint(), metrics)); |
| 185 | queueModel.updateTssEndpoint(ssi.getKey.getEndpoint().token.first(), |
| 186 | TSSEndpointData(tssi.id(), tssi.getKey.getEndpoint(), metrics)); |
| 187 | queueModel.updateTssEndpoint(ssi.getKeyValues.getEndpoint().token.first(), |
| 188 | TSSEndpointData(tssi.id(), tssi.getKeyValues.getEndpoint(), metrics)); |
| 189 | queueModel.updateTssEndpoint(ssi.getMappedKeyValues.getEndpoint().token.first(), |
| 190 | TSSEndpointData(tssi.id(), tssi.getMappedKeyValues.getEndpoint(), metrics)); |
| 191 | queueModel.updateTssEndpoint(ssi.getKeyValuesStream.getEndpoint().token.first(), |
| 192 | TSSEndpointData(tssi.id(), tssi.getKeyValuesStream.getEndpoint(), metrics)); |
| 193 | |
| 194 | // non-data requests duplicated for load |
| 195 | queueModel.updateTssEndpoint(ssi.watchValue.getEndpoint().token.first(), |
| 196 | TSSEndpointData(tssi.id(), tssi.watchValue.getEndpoint(), metrics)); |
| 197 | queueModel.updateTssEndpoint(ssi.splitMetrics.getEndpoint().token.first(), |
| 198 | TSSEndpointData(tssi.id(), tssi.splitMetrics.getEndpoint(), metrics)); |
| 199 | queueModel.updateTssEndpoint(ssi.getReadHotRanges.getEndpoint().token.first(), |
| 200 | TSSEndpointData(tssi.id(), tssi.getReadHotRanges.getEndpoint(), metrics)); |
| 201 | queueModel.updateTssEndpoint(ssi.getRangeSplitPoints.getEndpoint().token.first(), |
| 202 | TSSEndpointData(tssi.id(), tssi.getRangeSplitPoints.getEndpoint(), metrics)); |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | void DatabaseContext::removeTssMapping(StorageServerInterface const& ssi) { |
| 207 | auto result = tssMapping.find(ssi.id()); |
no test coverage detected