|
27 | 27 | import org.apache.hadoop.conf.Configuration; |
28 | 28 | import org.apache.hadoop.fs.Path; |
29 | 29 | import org.apache.hadoop.hbase.HBaseTestingUtil; |
| 30 | +import org.apache.hadoop.hbase.ServerName; |
30 | 31 | import org.apache.hadoop.hbase.SingleProcessHBaseCluster; |
31 | 32 | import org.apache.hadoop.hbase.StartTestingClusterOption; |
32 | 33 | import org.apache.hadoop.hbase.TableName; |
@@ -126,20 +127,26 @@ public void testBlockEvictionOnGracefulStop() throws Exception { |
126 | 127 | : cluster.getRegionServer(0); |
127 | 128 |
|
128 | 129 | assertTrue(regionServingRS.getBlockCache().isPresent()); |
129 | | - long oldUsedCacheSize = |
130 | | - regionServingRS.getBlockCache().get().getBlockCaches()[1].getCurrentSize(); |
131 | | - assertNotEquals(0, regionServingRS.getBlockCache().get().getBlockCaches()[1].getBlockCount()); |
132 | | - |
133 | | - cluster.stopRegionServer(regionServingRS.getServerName()); |
134 | | - Thread.sleep(500); |
135 | | - cluster.startRegionServer(); |
136 | | - Thread.sleep(500); |
137 | | - |
138 | | - regionServingRS.getBlockCache().get().waitForCacheInitialization(10000); |
139 | | - long newUsedCacheSize = |
140 | | - regionServingRS.getBlockCache().get().getBlockCaches()[1].getCurrentSize(); |
141 | | - assertEquals(oldUsedCacheSize, newUsedCacheSize); |
142 | | - assertNotEquals(0, regionServingRS.getBlockCache().get().getBlockCaches()[1].getBlockCount()); |
| 130 | + BlockCache oldBucketCache = regionServingRS.getBlockCache().get().getBlockCaches()[1]; |
| 131 | + long oldUsedCacheSize = oldBucketCache.getCurrentSize(); |
| 132 | + assertNotEquals(0, oldUsedCacheSize); |
| 133 | + assertNotEquals(0, oldBucketCache.getBlockCount()); |
| 134 | + |
| 135 | + ServerName serverName = regionServingRS.getServerName(); |
| 136 | + cluster.stopRegionServer(serverName); |
| 137 | + cluster.waitForRegionServerToStop(serverName, 10000); |
| 138 | + |
| 139 | + // Persistent state is restored into a new cache; the stopped cache must release its |
| 140 | + // references. |
| 141 | + assertEquals(0, oldBucketCache.getCurrentSize()); |
| 142 | + |
| 143 | + HRegionServer restartedRegionServer = cluster.startRegionServer().getRegionServer(); |
| 144 | + assertTrue(restartedRegionServer.getBlockCache().isPresent()); |
| 145 | + BlockCache restoredBucketCache = |
| 146 | + restartedRegionServer.getBlockCache().get().getBlockCaches()[1]; |
| 147 | + assertTrue(restoredBucketCache.waitForCacheInitialization(10000)); |
| 148 | + assertEquals(oldUsedCacheSize, restoredBucketCache.getCurrentSize()); |
| 149 | + assertNotEquals(0, restoredBucketCache.getBlockCount()); |
143 | 150 | } |
144 | 151 |
|
145 | 152 | public TableName writeDataToTable(String testName) throws IOException, InterruptedException { |
|
0 commit comments