|
64 | 64 | import org.apache.bookkeeper.stats.Gauge; |
65 | 65 | import org.apache.bookkeeper.stats.NullStatsLogger; |
66 | 66 | import org.apache.bookkeeper.test.TestStatsProvider; |
| 67 | +import org.apache.bookkeeper.test.TestStatsProvider.TestOpStatsLogger; |
67 | 68 | import org.apache.bookkeeper.test.TestStatsProvider.TestStatsLogger; |
68 | 69 | import org.apache.bookkeeper.util.StaticDNSResolver; |
69 | 70 | import org.apache.commons.collections4.CollectionUtils; |
@@ -2359,6 +2360,44 @@ public void testNodeWithFailures() throws Exception { |
2359 | 2360 | StaticDNSResolver.reset(); |
2360 | 2361 | } |
2361 | 2362 |
|
| 2363 | + @Test |
| 2364 | + public void testSlowBookieInEnsembleOnly() throws Exception { |
| 2365 | + repp.uninitalize(); |
| 2366 | + updateMyRack("/r1/rack1"); |
| 2367 | + |
| 2368 | + TestStatsProvider statsProvider = new TestStatsProvider(); |
| 2369 | + TestStatsLogger statsLogger = statsProvider.getStatsLogger(""); |
| 2370 | + |
| 2371 | + repp = new RackawareEnsemblePlacementPolicy(); |
| 2372 | + repp.initialize(conf, Optional.<DNSToSwitchMapping>empty(), timer, |
| 2373 | + DISABLE_ALL, statsLogger, BookieSocketAddress.LEGACY_BOOKIEID_RESOLVER); |
| 2374 | + repp.withDefaultRack(NetworkTopology.DEFAULT_REGION_AND_RACK); |
| 2375 | + |
| 2376 | + TestOpStatsLogger readRequestsReorderedCounter = (TestOpStatsLogger) statsLogger |
| 2377 | + .getOpStatsLogger(BookKeeperClientStats.READ_REQUESTS_REORDERED); |
| 2378 | + |
| 2379 | + // Update cluster |
| 2380 | + Set<BookieId> addrs = new HashSet<BookieId>(); |
| 2381 | + addrs.add(addr1.toBookieId()); |
| 2382 | + addrs.add(addr2.toBookieId()); |
| 2383 | + addrs.add(addr3.toBookieId()); |
| 2384 | + addrs.add(addr4.toBookieId()); |
| 2385 | + repp.onClusterChanged(addrs, new HashSet<BookieId>()); |
| 2386 | + repp.registerSlowBookie(addr1.toBookieId(), 0L); |
| 2387 | + Map<BookieId, Long> bookiePendingMap = new HashMap<>(); |
| 2388 | + bookiePendingMap.put(addr1.toBookieId(), 1L); |
| 2389 | + repp.onClusterChanged(addrs, new HashSet<>()); |
| 2390 | + |
| 2391 | + DistributionSchedule.WriteSet writeSet = writeSetFromValues(1, 2, 3); |
| 2392 | + |
| 2393 | + DistributionSchedule.WriteSet reorderSet = repp.reorderReadSequence( |
| 2394 | + ensemble, getBookiesHealthInfo(new HashMap<>(), bookiePendingMap), writeSet); |
| 2395 | + |
| 2396 | + // If the slow bookie is only present in the ensemble, no reordering occurs. |
| 2397 | + assertEquals(writeSet, reorderSet); |
| 2398 | + assertEquals(0, readRequestsReorderedCounter.getSuccessCount()); |
| 2399 | + } |
| 2400 | + |
2362 | 2401 | @Test |
2363 | 2402 | public void testReplaceNotAvailableBookieWithDefaultRack() throws Exception { |
2364 | 2403 | repp.uninitalize(); |
|
0 commit comments