@@ -108,7 +108,8 @@ public void testRetrieveFromFile() throws Exception {
108108 bucketCache = new BucketCache ("file:" + testDir + "/bucket.cache" , capacitySize ,
109109 constructedBlockSize , constructedBlockSizes , writeThreads , writerQLen ,
110110 testDir + "/bucket.persistence" , DEFAULT_ERROR_TOLERATION_DURATION , conf );
111- assertTrue (bucketCache .waitForCacheInitialization (10000 ));long usedSize = bucketCache .getAllocator ().getUsedSize ();
111+ assertTrue (bucketCache .waitForCacheInitialization (10000 ));
112+ long usedSize = bucketCache .getAllocator ().getUsedSize ();
112113 assertEquals (0 , usedSize );
113114 CacheTestUtils .HFileBlockPair [] blocks =
114115 CacheTestUtils .generateHFileBlocks (constructedBlockSize , 1 );
@@ -125,30 +126,30 @@ public void testRetrieveFromFile() throws Exception {
125126 constructedBlockSize , constructedBlockSizes , writeThreads , writerQLen ,
126127 testDir + "/bucket.persistence" , DEFAULT_ERROR_TOLERATION_DURATION , conf );
127128 waitPersistentCacheValidation (conf , bucketCache );
128- assertTrue (bucketCache .waitForCacheInitialization (10000 ));
129+ assertTrue (bucketCache .waitForCacheInitialization (10000 ));
129130 assertEquals (usedSize , bucketCache .getAllocator ().getUsedSize ());
130131 // persist cache to file
131132 bucketCache .shutdown ();
132133
133- // 2.delete bucket cache file
134- final java .nio .file .Path cacheFile =
135- FileSystems .getDefault ().getPath (testDir .toString (), "bucket.cache" );
136- assertTrue (Files .deleteIfExists (cacheFile ));
137- // can't restore cache from file
138- bucketCache =
139- new BucketCache ("file:" + testDir + "/bucket.cache" , capacitySize , constructedBlockSize ,
140- constructedBlockSizes , writeThreads , writerQLen , testDir + "/bucket.persistence" );
141- assertTrue (bucketCache .waitForCacheInitialization (10000 ));
142- assertEquals (0 , bucketCache .getAllocator ().getUsedSize ());
143- assertEquals (0 , bucketCache .backingMap .size ());
144- // Add blocks
145- for (CacheTestUtils .HFileBlockPair block : blocks ) {
146- cacheAndWaitUntilFlushedToBucket (bucketCache , block .getBlockName (), block .getBlock ());
147- }
148- usedSize = bucketCache .getAllocator ().getUsedSize ();
149- assertNotEquals (0 , usedSize );
150- // persist cache to file
151- bucketCache .shutdown ();
134+ // 2.delete bucket cache file
135+ final java .nio .file .Path cacheFile =
136+ FileSystems .getDefault ().getPath (testDir .toString (), "bucket.cache" );
137+ assertTrue (Files .deleteIfExists (cacheFile ));
138+ // can't restore cache from file
139+ bucketCache =
140+ new BucketCache ("file:" + testDir + "/bucket.cache" , capacitySize , constructedBlockSize ,
141+ constructedBlockSizes , writeThreads , writerQLen , testDir + "/bucket.persistence" );
142+ assertTrue (bucketCache .waitForCacheInitialization (10000 ));
143+ assertEquals (0 , bucketCache .getAllocator ().getUsedSize ());
144+ assertEquals (0 , bucketCache .backingMap .size ());
145+ // Add blocks
146+ for (CacheTestUtils .HFileBlockPair block : blocks ) {
147+ cacheAndWaitUntilFlushedToBucket (bucketCache , block .getBlockName (), block .getBlock ());
148+ }
149+ usedSize = bucketCache .getAllocator ().getUsedSize ();
150+ assertNotEquals (0 , usedSize );
151+ // persist cache to file
152+ bucketCache .shutdown ();
152153
153154 // 3.delete backingMap persistence file
154155 final java .nio .file .Path mapFile =
@@ -186,7 +187,8 @@ public void testRetrieveFromFileAfterDelete() throws Exception {
186187 bucketCache = new BucketCache ("file:" + testDir + "/bucket.cache" , capacitySize ,
187188 constructedBlockSize , constructedBlockSizes , writeThreads , writerQLen , mapFileName ,
188189 DEFAULT_ERROR_TOLERATION_DURATION , conf );
189- assertTrue (bucketCache .waitForCacheInitialization (10000 )); long usedSize = bucketCache .getAllocator ().getUsedSize ();
190+ assertTrue (bucketCache .waitForCacheInitialization (10000 ));
191+ long usedSize = bucketCache .getAllocator ().getUsedSize ();
190192 assertEquals (0 , usedSize );
191193 CacheTestUtils .HFileBlockPair [] blocks =
192194 CacheTestUtils .generateHFileBlocks (constructedBlockSize , 1 );
@@ -238,7 +240,8 @@ public void testModifiedBucketCacheFileData() throws Exception {
238240 bucketCache = new BucketCache ("file:" + testDir + "/bucket.cache" , capacitySize ,
239241 constructedBlockSize , constructedBlockSizes , writeThreads , writerQLen ,
240242 testDir + "/bucket.persistence" , DEFAULT_ERROR_TOLERATION_DURATION , conf );
241- assertTrue (bucketCache .waitForCacheInitialization (10000 ));long usedSize = bucketCache .getAllocator ().getUsedSize ();
243+ assertTrue (bucketCache .waitForCacheInitialization (10000 ));
244+ long usedSize = bucketCache .getAllocator ().getUsedSize ();
242245 assertEquals (0 , usedSize );
243246
244247 CacheTestUtils .HFileBlockPair [] blocks =
@@ -300,7 +303,8 @@ public void testModifiedBucketCacheFileTime() throws Exception {
300303 bucketCache = new BucketCache ("file:" + testDir + "/bucket.cache" , capacitySize ,
301304 constructedBlockSize , constructedBlockSizes , writeThreads , writerQLen ,
302305 testDir + "/bucket.persistence" , DEFAULT_ERROR_TOLERATION_DURATION , conf );
303- assertTrue (bucketCache .waitForCacheInitialization (10000 ));long usedSize = bucketCache .getAllocator ().getUsedSize ();
306+ assertTrue (bucketCache .waitForCacheInitialization (10000 ));
307+ long usedSize = bucketCache .getAllocator ().getUsedSize ();
304308 assertEquals (0 , usedSize );
305309
306310 Pair <String , Long > myPair = new Pair <>();
@@ -327,7 +331,8 @@ public void testModifiedBucketCacheFileTime() throws Exception {
327331 constructedBlockSize , constructedBlockSizes , writeThreads , writerQLen ,
328332 testDir + "/bucket.persistence" , DEFAULT_ERROR_TOLERATION_DURATION , conf );
329333 waitPersistentCacheValidation (conf , bucketCache );
330- assertTrue (bucketCache .waitForCacheInitialization (10000 ));assertEquals (usedSize , bucketCache .getAllocator ().getUsedSize ());
334+ assertTrue (bucketCache .waitForCacheInitialization (10000 ));
335+ assertEquals (usedSize , bucketCache .getAllocator ().getUsedSize ());
331336 assertEquals (blockCount , bucketCache .backingMap .size ());
332337 } finally {
333338 if (bucketCache != null ) {
@@ -360,7 +365,7 @@ public void testBucketCacheRecovery() throws Exception {
360365 bucketCache = new BucketCache ("file:" + testDir + "/bucket.cache" , capacitySize ,
361366 constructedBlockSize , constructedBlockSizes , writeThreads , writerQLen , mapFileName ,
362367 DEFAULT_ERROR_TOLERATION_DURATION , conf );
363- assertTrue (bucketCache .waitForCacheInitialization (10000 ));
368+ assertTrue (bucketCache .waitForCacheInitialization (10000 ));
364369
365370 CacheTestUtils .HFileBlockPair [] blocks =
366371 CacheTestUtils .generateHFileBlocks (constructedBlockSize , 4 );
@@ -428,7 +433,7 @@ private void testChunkedBackingMapRecovery(int chunkSize, int numBlocks) throws
428433 bucketCache = new BucketCache ("file:" + testDir + "/bucket.cache" , capacitySize ,
429434 constructedBlockSize , constructedBlockSizes , writeThreads , writerQLen , mapFileName ,
430435 DEFAULT_ERROR_TOLERATION_DURATION , conf );
431- assertTrue (bucketCache .waitForCacheInitialization (10000 ));
436+ assertTrue (bucketCache .waitForCacheInitialization (10000 ));
432437
433438 CacheTestUtils .HFileBlockPair [] blocks =
434439 CacheTestUtils .generateHFileBlocks (constructedBlockSize , numBlocks );
0 commit comments