| 1213 | } |
| 1214 | |
| 1215 | Reference<ILogSystem::IPeekCursor> TagPartitionedLogSystem::peekLogRouter(UID dbgid, Version begin, Tag tag) { |
| 1216 | bool found = false; |
| 1217 | for (const auto& log : tLogs) { |
| 1218 | found = log->hasLogRouter(dbgid) || log->hasBackupWorker(dbgid); |
| 1219 | if (found) { |
| 1220 | break; |
| 1221 | } |
| 1222 | } |
| 1223 | if (found) { |
| 1224 | if (stopped) { |
| 1225 | std::vector<Reference<LogSet>> localSets; |
| 1226 | int bestPrimarySet = 0; |
| 1227 | int bestSatelliteSet = -1; |
| 1228 | for (auto& log : tLogs) { |
| 1229 | if (log->isLocal && log->logServers.size()) { |
| 1230 | TraceEvent("TLogPeekLogRouterLocalSet", dbgid) |
| 1231 | .detail("Tag", tag.toString()) |
| 1232 | .detail("Begin", begin) |
| 1233 | .detail("LogServers", log->logServerString()); |
| 1234 | localSets.push_back(log); |
| 1235 | if (log->locality == tagLocalitySatellite) { |
| 1236 | bestSatelliteSet = localSets.size() - 1; |
| 1237 | } else { |
| 1238 | bestPrimarySet = localSets.size() - 1; |
| 1239 | } |
| 1240 | } |
| 1241 | } |
| 1242 | int bestSet = bestPrimarySet; |
| 1243 | if (SERVER_KNOBS->LOG_ROUTER_PEEK_FROM_SATELLITES_PREFERRED && bestSatelliteSet != -1 && |
| 1244 | tLogs[bestSatelliteSet]->tLogVersion >= TLogVersion::V4) { |
| 1245 | bestSet = bestSatelliteSet; |
| 1246 | } |
| 1247 | |
| 1248 | TraceEvent("TLogPeekLogRouterSets", dbgid).detail("Tag", tag.toString()).detail("Begin", begin); |
| 1249 | // FIXME: do this merge on one of the logs in the other data center to avoid sending multiple copies |
| 1250 | // across the WAN |
| 1251 | return makeReference<ILogSystem::SetPeekCursor>( |
| 1252 | localSets, bestSet, localSets[bestSet]->bestLocationFor(tag), tag, begin, getPeekEnd(), true); |
| 1253 | } else { |
| 1254 | int bestPrimarySet = -1; |
| 1255 | int bestSatelliteSet = -1; |
| 1256 | for (int i = 0; i < tLogs.size(); i++) { |
| 1257 | const auto& log = tLogs[i]; |
| 1258 | if (log->logServers.size() && log->isLocal) { |
| 1259 | if (log->locality == tagLocalitySatellite) { |
| 1260 | bestSatelliteSet = i; |
| 1261 | break; |
| 1262 | } else { |
| 1263 | if (bestPrimarySet == -1) |
| 1264 | bestPrimarySet = i; |
| 1265 | } |
| 1266 | } |
| 1267 | } |
| 1268 | int bestSet = bestPrimarySet; |
| 1269 | if (SERVER_KNOBS->LOG_ROUTER_PEEK_FROM_SATELLITES_PREFERRED && bestSatelliteSet != -1 && |
| 1270 | tLogs[bestSatelliteSet]->tLogVersion >= TLogVersion::V4) { |
| 1271 | bestSet = bestSatelliteSet; |
| 1272 | } |
no test coverage detected