| 217 | } |
| 218 | |
| 219 | void LogSet::getPushLocations(VectorRef<Tag> tags, std::vector<int>& locations, int locationOffset, bool allLocations) { |
| 220 | if (locality == tagLocalitySatellite) { |
| 221 | for (auto& t : tags) { |
| 222 | if (t == txsTag || t.locality == tagLocalityTxs || t.locality == tagLocalityLogRouter) { |
| 223 | for (int loc : satelliteTagLocations[t == txsTag ? 0 : t.id + 1]) { |
| 224 | locations.push_back(locationOffset + loc); |
| 225 | } |
| 226 | } |
| 227 | } |
| 228 | uniquify(locations); |
| 229 | return; |
| 230 | } |
| 231 | |
| 232 | newLocations.clear(); |
| 233 | alsoServers.clear(); |
| 234 | resultEntries.clear(); |
| 235 | |
| 236 | if (allLocations) { |
| 237 | // special handling for allLocations |
| 238 | TraceEvent("AllLocationsSet").log(); |
| 239 | for (int i = 0; i < logServers.size(); i++) { |
| 240 | newLocations.push_back(i); |
| 241 | } |
| 242 | } else { |
| 243 | for (auto& t : tags) { |
| 244 | if (locality == tagLocalitySpecial || t.locality == locality || t.locality < 0) { |
| 245 | newLocations.push_back(bestLocationFor(t)); |
| 246 | } |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | uniquify(newLocations); |
| 251 | |
| 252 | if (newLocations.size()) |
| 253 | alsoServers.reserve(newLocations.size()); |
| 254 | |
| 255 | // Convert locations to the also servers |
| 256 | for (auto location : newLocations) { |
| 257 | locations.push_back(locationOffset + location); |
| 258 | alsoServers.push_back(logEntryArray[location]); |
| 259 | } |
| 260 | |
| 261 | // Run the policy, assert if unable to satify |
| 262 | bool result = logServerSet->selectReplicas(tLogPolicy, alsoServers, resultEntries); |
| 263 | ASSERT(result); |
| 264 | |
| 265 | // Add the new servers to the location array |
| 266 | LocalityMap<int>* logServerMap = (LocalityMap<int>*)logServerSet.getPtr(); |
| 267 | for (auto entry : resultEntries) { |
| 268 | locations.push_back(locationOffset + *logServerMap->getObject(entry)); |
| 269 | } |
| 270 | //TraceEvent("GetPushLocations").detail("Policy", tLogPolicy->info()) |
| 271 | // .detail("Results", locations.size()).detail("Selection", logServerSet->size()) |
| 272 | // .detail("Included", alsoServers.size()).detail("Duration", timer() - t); |
| 273 | } |
| 274 | |
| 275 | LogPushData::LogPushData(Reference<ILogSystem> logSystem, int tlogCount) : logSystem(logSystem), subsequence(1) { |
| 276 | ASSERT(tlogCount > 0); |
no test coverage detected