| 134 | } |
| 135 | |
| 136 | LogRouterData(UID dbgid, const InitializeLogRouterRequest& req) |
| 137 | : dbgid(dbgid), logSystem(new AsyncVar<Reference<ILogSystem>>()), version(req.startVersion - 1), minPopped(0), |
| 138 | startVersion(req.startVersion), minKnownCommittedVersion(0), poppedVersion(0), routerTag(req.routerTag), |
| 139 | allowPops(false), foundEpochEnd(false), generation(req.recoveryCount), |
| 140 | peekLatencyDist(Histogram::getHistogram(LiteralStringRef("LogRouter"), |
| 141 | LiteralStringRef("PeekTLogLatency"), |
| 142 | Histogram::Unit::microseconds)), |
| 143 | cc("LogRouter", dbgid.toString()), getMoreCount("GetMoreCount", cc), |
| 144 | getMoreBlockedCount("GetMoreBlockedCount", cc) { |
| 145 | // setup just enough of a logSet to be able to call getPushLocations |
| 146 | logSet.logServers.resize(req.tLogLocalities.size()); |
| 147 | logSet.tLogPolicy = req.tLogPolicy; |
| 148 | logSet.locality = req.locality; |
| 149 | logSet.updateLocalitySet(req.tLogLocalities); |
| 150 | |
| 151 | for (int i = 0; i < req.tLogLocalities.size(); i++) { |
| 152 | Tag tag(tagLocalityRemoteLog, i); |
| 153 | auto tagData = getTagData(tag); |
| 154 | if (!tagData) { |
| 155 | tagData = createTagData(tag, 0, 0); |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | eventCacheHolder = makeReference<EventCacheHolder>(dbgid.shortString() + ".PeekLocation"); |
| 160 | |
| 161 | // FetchedVersions: How many version of mutations buffered at LR and have not been popped by remote tLogs |
| 162 | specialCounter(cc, "Version", [this]() { return this->version.get(); }); |
| 163 | specialCounter(cc, "MinPopped", [this]() { return this->minPopped.get(); }); |
| 164 | // TODO: Add minPopped locality and minPoppedId, similar as tLog Metrics |
| 165 | specialCounter(cc, "FetchedVersions", [this]() { |
| 166 | return std::max<Version>(0, |
| 167 | std::min<Version>(SERVER_KNOBS->MAX_READ_TRANSACTION_LIFE_VERSIONS, |
| 168 | this->version.get() - this->minPopped.get())); |
| 169 | }); |
| 170 | specialCounter(cc, "MinKnownCommittedVersion", [this]() { return this->minKnownCommittedVersion; }); |
| 171 | specialCounter(cc, "PoppedVersion", [this]() { return this->poppedVersion; }); |
| 172 | specialCounter(cc, "FoundEpochEnd", [this]() { return this->foundEpochEnd; }); |
| 173 | specialCounter(cc, "WaitForVersionMS", [this]() { |
| 174 | double val = this->waitForVersionTime; |
| 175 | this->waitForVersionTime = 0; |
| 176 | return int64_t(1000 * val); |
| 177 | }); |
| 178 | specialCounter(cc, "WaitForVersionMaxMS", [this]() { |
| 179 | double val = this->maxWaitForVersionTime; |
| 180 | this->maxWaitForVersionTime = 0; |
| 181 | return int64_t(1000 * val); |
| 182 | }); |
| 183 | specialCounter(cc, "GetMoreMS", [this]() { |
| 184 | double val = this->getMoreTime; |
| 185 | this->getMoreTime = 0; |
| 186 | return int64_t(1000 * val); |
| 187 | }); |
| 188 | specialCounter(cc, "GetMoreMaxMS", [this]() { |
| 189 | double val = this->maxGetMoreTime; |
| 190 | this->maxGetMoreTime = 0; |
| 191 | return int64_t(1000 * val); |
| 192 | }); |
| 193 | specialCounter(cc, "Generation", [this]() { return this->generation; }); |
nothing calls this directly
no test coverage detected