|
60 | 60 | import org.apache.bookkeeper.stats.Gauge; |
61 | 61 | import org.apache.bookkeeper.stats.NullStatsLogger; |
62 | 62 | import org.apache.bookkeeper.test.TestStatsProvider; |
| 63 | +import org.apache.bookkeeper.test.TestStatsProvider.TestOpStatsLogger; |
63 | 64 | import org.apache.bookkeeper.test.TestStatsProvider.TestStatsLogger; |
64 | 65 | import org.apache.bookkeeper.util.StaticDNSResolver; |
65 | 66 | import org.apache.commons.collections4.CollectionUtils; |
@@ -2267,6 +2268,44 @@ public void testNodeWithFailures() throws Exception { |
2267 | 2268 | StaticDNSResolver.reset(); |
2268 | 2269 | } |
2269 | 2270 |
|
| 2271 | + @Test |
| 2272 | + public void testSlowBookieInEnsembleOnly() throws Exception { |
| 2273 | + repp.uninitalize(); |
| 2274 | + updateMyRack("/r1/rack1"); |
| 2275 | + |
| 2276 | + TestStatsProvider statsProvider = new TestStatsProvider(); |
| 2277 | + TestStatsLogger statsLogger = statsProvider.getStatsLogger(""); |
| 2278 | + |
| 2279 | + repp = new RackawareEnsemblePlacementPolicy(); |
| 2280 | + repp.initialize(conf, Optional.<DNSToSwitchMapping>empty(), timer, |
| 2281 | + DISABLE_ALL, statsLogger, BookieSocketAddress.LEGACY_BOOKIEID_RESOLVER); |
| 2282 | + repp.withDefaultRack(NetworkTopology.DEFAULT_REGION_AND_RACK); |
| 2283 | + |
| 2284 | + TestOpStatsLogger readRequestsReorderedCounter = (TestOpStatsLogger) statsLogger |
| 2285 | + .getOpStatsLogger(BookKeeperClientStats.READ_REQUESTS_REORDERED); |
| 2286 | + |
| 2287 | + // Update cluster |
| 2288 | + Set<BookieId> addrs = new HashSet<BookieId>(); |
| 2289 | + addrs.add(addr1.toBookieId()); |
| 2290 | + addrs.add(addr2.toBookieId()); |
| 2291 | + addrs.add(addr3.toBookieId()); |
| 2292 | + addrs.add(addr4.toBookieId()); |
| 2293 | + repp.onClusterChanged(addrs, new HashSet<BookieId>()); |
| 2294 | + repp.registerSlowBookie(addr1.toBookieId(), 0L); |
| 2295 | + Map<BookieId, Long> bookiePendingMap = new HashMap<>(); |
| 2296 | + bookiePendingMap.put(addr1.toBookieId(), 1L); |
| 2297 | + repp.onClusterChanged(addrs, new HashSet<>()); |
| 2298 | + |
| 2299 | + DistributionSchedule.WriteSet writeSet = writeSetFromValues(1, 2, 3); |
| 2300 | + |
| 2301 | + DistributionSchedule.WriteSet reorderSet = repp.reorderReadSequence( |
| 2302 | + ensemble, getBookiesHealthInfo(new HashMap<>(), bookiePendingMap), writeSet); |
| 2303 | + |
| 2304 | + // If the slow bookie is only present in the ensemble, no reordering occurs. |
| 2305 | + assertEquals(writeSet, reorderSet); |
| 2306 | + assertEquals(0, readRequestsReorderedCounter.getSuccessCount()); |
| 2307 | + } |
| 2308 | + |
2270 | 2309 | @Test |
2271 | 2310 | public void testReplaceNotAvailableBookieWithDefaultRack() throws Exception { |
2272 | 2311 | repp.uninitalize(); |
|
0 commit comments