|
38 | 38 | import org.apache.hadoop.hbase.io.hfile.HFileBlock; |
39 | 39 | import org.apache.hadoop.hbase.io.hfile.HFileContext; |
40 | 40 | import org.apache.hadoop.hbase.io.hfile.HFileContextBuilder; |
| 41 | +import org.apache.hadoop.hbase.io.hfile.PrefetchExecutor; |
41 | 42 | import org.apache.hadoop.hbase.io.hfile.RandomKeyValueUtil; |
42 | 43 | import org.apache.hadoop.hbase.regionserver.StoreFileWriter; |
43 | 44 | import org.apache.hadoop.hbase.testclassification.IOTests; |
@@ -119,21 +120,36 @@ public void testPrefetchPersistenceCrash() throws Exception { |
119 | 120 |
|
120 | 121 | @Test |
121 | 122 | public void testPrefetchPersistenceCrashNegative() throws Exception { |
122 | | - long bucketCachePersistInterval = 3000; |
| 123 | + long bucketCachePersistInterval = Long.MAX_VALUE; |
123 | 124 | Configuration conf = setupBucketCacheConfig(bucketCachePersistInterval); |
124 | 125 | BucketCache bucketCache = setupBucketCache(conf); |
125 | 126 | CacheConfig cacheConf = new CacheConfig(conf, bucketCache); |
126 | 127 | FileSystem fs = HFileSystem.get(conf); |
127 | 128 | // Load Cache |
128 | 129 | Path storeFile = writeStoreFile("TestPrefetch2", conf, cacheConf, fs); |
129 | | - Path storeFile2 = writeStoreFile("TestPrefetch3", conf, cacheConf, fs); |
130 | 130 | readStoreFile(storeFile, 0, fs, cacheConf, conf, bucketCache); |
131 | | - readStoreFile(storeFile2, 0, fs, cacheConf, conf, bucketCache); |
132 | 131 | assertFalse(new File(testDir + "/prefetch.persistence").exists()); |
133 | 132 | assertFalse(new File(testDir + "/bucket.persistence").exists()); |
134 | 133 | cleanupBucketCache(bucketCache); |
135 | 134 | } |
136 | 135 |
|
| 136 | + @Test |
| 137 | + public void testPrefetchListUponBlockEviction() throws Exception { |
| 138 | + Configuration conf = setupBucketCacheConfig(200); |
| 139 | + BucketCache bucketCache1 = setupBucketCache(conf); |
| 140 | + CacheConfig cacheConf = new CacheConfig(conf, bucketCache1); |
| 141 | + FileSystem fs = HFileSystem.get(conf); |
| 142 | + // Load Blocks in cache |
| 143 | + Path storeFile = writeStoreFile("TestPrefetch3", conf, cacheConf, fs); |
| 144 | + readStoreFile(storeFile, 0, fs, cacheConf, conf, bucketCache1); |
| 145 | + Thread.sleep(500); |
| 146 | + // Evict Blocks from cache |
| 147 | + BlockCacheKey bucketCacheKey = bucketCache1.backingMap.entrySet().iterator().next().getKey(); |
| 148 | + assertTrue(PrefetchExecutor.isFilePrefetched(storeFile.getName())); |
| 149 | + bucketCache1.evictBlock(bucketCacheKey); |
| 150 | + assertFalse(PrefetchExecutor.isFilePrefetched(storeFile.getName())); |
| 151 | + } |
| 152 | + |
137 | 153 | public void readStoreFile(Path storeFilePath, long offset, FileSystem fs, CacheConfig cacheConf, |
138 | 154 | Configuration conf, BucketCache bucketCache) throws Exception { |
139 | 155 | // Open the file |
|
0 commit comments