excludes localities by setting the keys in api version below 7.0
| 1378 | |
| 1379 | // excludes localities by setting the keys in api version below 7.0 |
| 1380 | void excludeLocalities(Transaction& tr, std::unordered_set<std::string> localities, bool failed) { |
| 1381 | tr.setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); |
| 1382 | tr.setOption(FDBTransactionOptions::PRIORITY_SYSTEM_IMMEDIATE); |
| 1383 | tr.setOption(FDBTransactionOptions::LOCK_AWARE); |
| 1384 | tr.setOption(FDBTransactionOptions::USE_PROVISIONAL_PROXIES); |
| 1385 | std::string excludeVersionKey = deterministicRandom()->randomUniqueID().toString(); |
| 1386 | auto localityVersionKey = failed ? failedLocalityVersionKey : excludedLocalityVersionKey; |
| 1387 | tr.addReadConflictRange(singleKeyRange(localityVersionKey)); // To conflict with parallel includeLocalities |
| 1388 | tr.set(localityVersionKey, excludeVersionKey); |
| 1389 | for (const auto& l : localities) { |
| 1390 | if (failed) { |
| 1391 | tr.set(encodeFailedLocalityKey(l), StringRef()); |
| 1392 | } else { |
| 1393 | tr.set(encodeExcludedLocalityKey(l), StringRef()); |
| 1394 | } |
| 1395 | } |
| 1396 | TraceEvent("ExcludeLocalitiesCommit").detail("Localities", describe(localities)).detail("ExcludeFailed", failed); |
| 1397 | } |
| 1398 | |
| 1399 | // Exclude the servers matching the given set of localities from use as state servers. |
| 1400 | // excludes localities by setting the keys. |