From d9f38fa18b3f7c4f1bb0cd90e7a45f4851d177ef Mon Sep 17 00:00:00 2001 From: alanzhao Date: Mon, 27 Feb 2023 19:42:19 +0800 Subject: [PATCH 01/11] JIRAID:HBASE-27670 Improve FSUtils to directly obtain FSDataOutputStream --- .../org/apache/hadoop/hbase/util/FSUtils.java | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java index a3b1e375fbbf..b8f07ebf0fef 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java @@ -203,20 +203,19 @@ public static FSDataOutputStream create(Configuration conf, FileSystem fs, Path short replication = Short.parseShort(conf.get(ColumnFamilyDescriptorBuilder.DFS_REPLICATION, String.valueOf(ColumnFamilyDescriptorBuilder.DEFAULT_DFS_REPLICATION))); try { - return (FSDataOutputStream) (DistributedFileSystem.class - .getDeclaredMethod("create", Path.class, FsPermission.class, boolean.class, int.class, - short.class, long.class, Progressable.class, InetSocketAddress[].class) - .invoke(backingFs, path, perm, true, CommonFSUtils.getDefaultBufferSize(backingFs), - replication > 0 ? replication : CommonFSUtils.getDefaultReplication(backingFs, path), - CommonFSUtils.getDefaultBlockSize(backingFs, path), null, favoredNodes)); - } catch (InvocationTargetException ite) { - // Function was properly called, but threw it's own exception. - throw new IOException(ite.getCause()); - } catch (NoSuchMethodException e) { + DistributedFileSystem dfs = (DistributedFileSystem) backingFs; + DistributedFileSystem.HdfsDataOutputStreamBuilder builder = + dfs.createFile(path).permission(perm).create() + .overwrite(true) + .bufferSize(CommonFSUtils.getDefaultBufferSize(backingFs)) + .replication(replication > 0 ? replication : CommonFSUtils.getDefaultReplication(backingFs, path)) + .blockSize(CommonFSUtils.getDefaultBlockSize(backingFs, path)) + .favoredNodes(favoredNodes) + .recursive(); + return builder.build(); + }catch (IllegalArgumentException | SecurityException e) { LOG.debug("DFS Client does not support most favored nodes create; using default create"); LOG.trace("Ignoring; use default create", e); - } catch (IllegalArgumentException | SecurityException | IllegalAccessException e) { - LOG.debug("Ignoring (most likely Reflection related exception) " + e); } } } From d82743ae7d67cfcf1180ff7e028575563fb15aa2 Mon Sep 17 00:00:00 2001 From: alanzhao Date: Tue, 28 Feb 2023 10:06:14 +0800 Subject: [PATCH 02/11] JIRAID:HBASE-27670 Improve FSUtils to directly obtain FSDataOutputStream fix style error --- .../org/apache/hadoop/hbase/util/FSUtils.java | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java index b8f07ebf0fef..7b006dc59b56 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java @@ -85,7 +85,6 @@ import org.apache.hadoop.hdfs.protocol.LocatedBlock; import org.apache.hadoop.io.IOUtils; import org.apache.hadoop.ipc.RemoteException; -import org.apache.hadoop.util.Progressable; import org.apache.yetus.audience.InterfaceAudience; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -203,17 +202,16 @@ public static FSDataOutputStream create(Configuration conf, FileSystem fs, Path short replication = Short.parseShort(conf.get(ColumnFamilyDescriptorBuilder.DFS_REPLICATION, String.valueOf(ColumnFamilyDescriptorBuilder.DEFAULT_DFS_REPLICATION))); try { - DistributedFileSystem dfs = (DistributedFileSystem) backingFs; - DistributedFileSystem.HdfsDataOutputStreamBuilder builder = - dfs.createFile(path).permission(perm).create() - .overwrite(true) - .bufferSize(CommonFSUtils.getDefaultBufferSize(backingFs)) - .replication(replication > 0 ? replication : CommonFSUtils.getDefaultReplication(backingFs, path)) - .blockSize(CommonFSUtils.getDefaultBlockSize(backingFs, path)) - .favoredNodes(favoredNodes) - .recursive(); - return builder.build(); - }catch (IllegalArgumentException | SecurityException e) { + DistributedFileSystem dfs = (DistributedFileSystem) backingFs; + DistributedFileSystem.HdfsDataOutputStreamBuilder builder = dfs.createFile(path) + .permission(perm).create().overwrite(true) + .bufferSize(CommonFSUtils.getDefaultBufferSize(backingFs)) + .replication( + replication > 0 ? replication : CommonFSUtils.getDefaultReplication(backingFs, path)) + .blockSize(CommonFSUtils.getDefaultBlockSize(backingFs, path)) + .favoredNodes(favoredNodes).recursive(); + return builder.build(); + } catch (IllegalArgumentException | SecurityException e) { LOG.debug("DFS Client does not support most favored nodes create; using default create"); LOG.trace("Ignoring; use default create", e); } From c5c0a247bc4fd8b3001af18d21ae5712c5494aef Mon Sep 17 00:00:00 2001 From: alanzhao Date: Tue, 28 Feb 2023 18:31:50 +0800 Subject: [PATCH 03/11] JIRAID:HBASE-27670 Improve FSUtils to directly obtain FSDataOutputStream fix npe --- .../main/java/org/apache/hadoop/hbase/util/FSUtils.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java index 7b006dc59b56..10aff762d0ec 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java @@ -208,8 +208,11 @@ public static FSDataOutputStream create(Configuration conf, FileSystem fs, Path .bufferSize(CommonFSUtils.getDefaultBufferSize(backingFs)) .replication( replication > 0 ? replication : CommonFSUtils.getDefaultReplication(backingFs, path)) - .blockSize(CommonFSUtils.getDefaultBlockSize(backingFs, path)) - .favoredNodes(favoredNodes).recursive(); + .blockSize(CommonFSUtils.getDefaultBlockSize(backingFs, path)); + if (favoredNodes != null) { + builder.favoredNodes(favoredNodes); + } + builder.recursive(); return builder.build(); } catch (IllegalArgumentException | SecurityException e) { LOG.debug("DFS Client does not support most favored nodes create; using default create"); From 61e6d91a7ceb28681278e61fb3c1f4e48a3c5a5f Mon Sep 17 00:00:00 2001 From: alanzhao Date: Wed, 1 Mar 2023 23:54:13 +0800 Subject: [PATCH 04/11] JIRAID:HBASE-27670 Improve FSUtils to directly obtain FSDataOutputStream do not catch RuntimeException --- .../org/apache/hadoop/hbase/util/FSUtils.java | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java index 10aff762d0ec..29cad2de43ef 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java @@ -201,23 +201,17 @@ public static FSDataOutputStream create(Configuration conf, FileSystem fs, Path // compatibility. short replication = Short.parseShort(conf.get(ColumnFamilyDescriptorBuilder.DFS_REPLICATION, String.valueOf(ColumnFamilyDescriptorBuilder.DEFAULT_DFS_REPLICATION))); - try { - DistributedFileSystem dfs = (DistributedFileSystem) backingFs; - DistributedFileSystem.HdfsDataOutputStreamBuilder builder = dfs.createFile(path) - .permission(perm).create().overwrite(true) + DistributedFileSystem dfs = (DistributedFileSystem) backingFs; + DistributedFileSystem.HdfsDataOutputStreamBuilder builder = + dfs.createFile(path).recursive().permission(perm).create().overwrite(true) .bufferSize(CommonFSUtils.getDefaultBufferSize(backingFs)) .replication( replication > 0 ? replication : CommonFSUtils.getDefaultReplication(backingFs, path)) .blockSize(CommonFSUtils.getDefaultBlockSize(backingFs, path)); - if (favoredNodes != null) { - builder.favoredNodes(favoredNodes); - } - builder.recursive(); - return builder.build(); - } catch (IllegalArgumentException | SecurityException e) { - LOG.debug("DFS Client does not support most favored nodes create; using default create"); - LOG.trace("Ignoring; use default create", e); + if (favoredNodes != null) { + builder.favoredNodes(favoredNodes); } + return builder.build(); } } return CommonFSUtils.create(fs, path, perm, true); From 87fbf183112c70062f65a105f9331d84ec596abe Mon Sep 17 00:00:00 2001 From: alanzhao Date: Fri, 3 Mar 2023 09:59:07 +0800 Subject: [PATCH 05/11] JIRAID:HBASE-27670 fix --- .../main/java/org/apache/hadoop/hbase/util/FSUtils.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java index 29cad2de43ef..059f6ce127b9 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java @@ -197,14 +197,11 @@ public static FSDataOutputStream create(Configuration conf, FileSystem fs, Path if (fs instanceof HFileSystem) { FileSystem backingFs = ((HFileSystem) fs).getBackingFs(); if (backingFs instanceof DistributedFileSystem) { - // Try to use the favoredNodes version via reflection to allow backwards- - // compatibility. short replication = Short.parseShort(conf.get(ColumnFamilyDescriptorBuilder.DFS_REPLICATION, String.valueOf(ColumnFamilyDescriptorBuilder.DEFAULT_DFS_REPLICATION))); - DistributedFileSystem dfs = (DistributedFileSystem) backingFs; DistributedFileSystem.HdfsDataOutputStreamBuilder builder = - dfs.createFile(path).recursive().permission(perm).create().overwrite(true) - .bufferSize(CommonFSUtils.getDefaultBufferSize(backingFs)) + ((DistributedFileSystem) backingFs).createFile(path).recursive().permission(perm).create() + .overwrite(true).bufferSize(CommonFSUtils.getDefaultBufferSize(backingFs)) .replication( replication > 0 ? replication : CommonFSUtils.getDefaultReplication(backingFs, path)) .blockSize(CommonFSUtils.getDefaultBlockSize(backingFs, path)); @@ -213,6 +210,7 @@ public static FSDataOutputStream create(Configuration conf, FileSystem fs, Path } return builder.build(); } + } return CommonFSUtils.create(fs, path, perm, true); } From 0c27d84ef39c8fed9b902807c781a44ba43d8cca Mon Sep 17 00:00:00 2001 From: alanzhao Date: Sat, 4 Mar 2023 16:53:01 +0800 Subject: [PATCH 06/11] JIRAID:HBASE-27670 fix --- .../java/org/apache/hadoop/hbase/util/FSUtils.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java index 059f6ce127b9..e84e9bf3a81f 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java @@ -200,14 +200,14 @@ public static FSDataOutputStream create(Configuration conf, FileSystem fs, Path short replication = Short.parseShort(conf.get(ColumnFamilyDescriptorBuilder.DFS_REPLICATION, String.valueOf(ColumnFamilyDescriptorBuilder.DEFAULT_DFS_REPLICATION))); DistributedFileSystem.HdfsDataOutputStreamBuilder builder = - ((DistributedFileSystem) backingFs).createFile(path).recursive().permission(perm).create() - .overwrite(true).bufferSize(CommonFSUtils.getDefaultBufferSize(backingFs)) - .replication( - replication > 0 ? replication : CommonFSUtils.getDefaultReplication(backingFs, path)) - .blockSize(CommonFSUtils.getDefaultBlockSize(backingFs, path)); + ((DistributedFileSystem) backingFs).createFile(path).recursive().permission(perm) + .create(); if (favoredNodes != null) { builder.favoredNodes(favoredNodes); } + if (replication > 0) { + builder.replication(replication); + } return builder.build(); } From f99b0b2bb06ffd84454056ea3596c0f958427d75 Mon Sep 17 00:00:00 2001 From: alanzhao Date: Mon, 6 Mar 2023 11:09:56 +0800 Subject: [PATCH 07/11] JIRAID:HBASE-27688 HFile splitting occurs during bulkload, the CREATE_TIME_TS of hfileinfo is 0 --- .../java/org/apache/hadoop/hbase/tool/BulkLoadHFilesTool.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/BulkLoadHFilesTool.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/BulkLoadHFilesTool.java index e1bea90f49d9..d4f546237d54 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/BulkLoadHFilesTool.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/BulkLoadHFilesTool.java @@ -88,6 +88,7 @@ import org.apache.hadoop.hbase.security.UserProvider; import org.apache.hadoop.hbase.security.token.FsDelegationToken; import org.apache.hadoop.hbase.util.Bytes; +import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; import org.apache.hadoop.hbase.util.FSVisitor; import org.apache.hadoop.hbase.util.FutureUtils; import org.apache.hadoop.hbase.util.Pair; @@ -577,6 +578,7 @@ private String getUniqueName() { return UUID.randomUUID().toString().replaceAll("-", ""); } + private List splitStoreFile(LoadQueueItem item, TableDescriptor tableDesc, byte[] splitKey) throws IOException { Path hfilePath = item.getFilePath(); @@ -767,7 +769,7 @@ private static void copyHFileHalf(Configuration conf, Path inFile, Path outFile, .withChecksumType(StoreUtils.getChecksumType(conf)) .withBytesPerCheckSum(StoreUtils.getBytesPerChecksum(conf)).withBlockSize(blocksize) .withDataBlockEncoding(familyDescriptor.getDataBlockEncoding()).withIncludesTags(true) - .build(); + .withCreateTime(EnvironmentEdgeManager.currentTime()).build(); halfWriter = new StoreFileWriter.Builder(conf, cacheConf, fs).withFilePath(outFile) .withBloomType(bloomFilterType).withFileContext(hFileContext).build(); HFileScanner scanner = halfReader.getScanner(false, false, false); From 3e3deb59aafeb51feb7c79cdc0ce223e83e5825e Mon Sep 17 00:00:00 2001 From: alanzhao Date: Mon, 6 Mar 2023 15:52:03 +0800 Subject: [PATCH 08/11] JIRAID:HBASE-27688 HFile splitting occurs during bulkload, the CREATE_TIME_TS of hfileinfo is 0 --- .../java/org/apache/hadoop/hbase/tool/BulkLoadHFilesTool.java | 1 - 1 file changed, 1 deletion(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/BulkLoadHFilesTool.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/BulkLoadHFilesTool.java index d4f546237d54..e54de3403e7a 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/BulkLoadHFilesTool.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/BulkLoadHFilesTool.java @@ -578,7 +578,6 @@ private String getUniqueName() { return UUID.randomUUID().toString().replaceAll("-", ""); } - private List splitStoreFile(LoadQueueItem item, TableDescriptor tableDesc, byte[] splitKey) throws IOException { Path hfilePath = item.getFilePath(); From a5300f1f49e7ff74f141469ef97392ae1e4b6158 Mon Sep 17 00:00:00 2001 From: alanzhao Date: Mon, 6 Mar 2023 19:57:45 +0800 Subject: [PATCH 09/11] JIRAID:HBASE-27688 HFile splitting occurs during bulkload, the CREATE_TIME_TS of hfileinfo is 0 --- .../hadoop/hbase/tool/TestBulkLoadHFiles.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/tool/TestBulkLoadHFiles.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/tool/TestBulkLoadHFiles.java index 591d807c0da4..5d7708a8e925 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/tool/TestBulkLoadHFiles.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/tool/TestBulkLoadHFiles.java @@ -56,6 +56,7 @@ import org.apache.hadoop.hbase.io.encoding.DataBlockEncoding; import org.apache.hadoop.hbase.io.hfile.CacheConfig; import org.apache.hadoop.hbase.io.hfile.HFile; +import org.apache.hadoop.hbase.io.hfile.HFileInfo; import org.apache.hadoop.hbase.io.hfile.HFileScanner; import org.apache.hadoop.hbase.regionserver.BloomType; import org.apache.hadoop.hbase.testclassification.LargeTests; @@ -567,6 +568,25 @@ public void testSplitStoreFile() throws IOException { assertEquals(1000, rowCount); } + @Test + public void testSplitStoreFileWithCreateTimeTS() throws IOException { + Path dir = util.getDataTestDirOnTestFS("testSplitStoreFileWithCreateTimeTS"); + FileSystem fs = util.getTestFileSystem(); + Path testIn = new Path(dir, "testhfile"); + ColumnFamilyDescriptor familyDesc = ColumnFamilyDescriptorBuilder.of(FAMILY); + HFileTestUtil.createHFile(util.getConfiguration(), fs, testIn, FAMILY, QUALIFIER, + Bytes.toBytes("aaa"), Bytes.toBytes("zzz"), 1000); + + Path bottomOut = new Path(dir, "bottom.out"); + Path topOut = new Path(dir, "top.out"); + + BulkLoadHFilesTool.splitStoreFile(util.getConfiguration(), testIn, familyDesc, + Bytes.toBytes("ggg"), bottomOut, topOut); + + verifyHFileCreateTimeTS(bottomOut); + verifyHFileCreateTimeTS(topOut); + } + @Test public void testSplitStoreFileWithNoneToNone() throws IOException { testSplitStoreFileWithDifferentEncoding(DataBlockEncoding.NONE, DataBlockEncoding.NONE); @@ -623,6 +643,17 @@ private int verifyHFile(Path p) throws IOException { return count; } + private void verifyHFileCreateTimeTS(Path p) throws IOException { + Configuration conf = util.getConfiguration(); + HFile.Reader reader = + HFile.createReader(p.getFileSystem(conf), p, new CacheConfig(conf), true, conf); + final HFileInfo hFileInfo = reader.getHFileInfo(); + final long fileCreateTime = hFileInfo.getHFileContext().getFileCreateTime(); + reader.close(); + assertTrue(fileCreateTime != 0); + + } + private void addStartEndKeysForTest(TreeMap map, byte[] first, byte[] last) { Integer value = map.containsKey(first) ? map.get(first) : 0; map.put(first, value + 1); From 7c477e8ec044d2d140f5386d8f2fee1d4e471214 Mon Sep 17 00:00:00 2001 From: alanzhao Date: Tue, 7 Mar 2023 00:21:15 +0800 Subject: [PATCH 10/11] JIRAID:HBASE-27688 HFile splitting occurs during bulkload, the CREATE_TIME_TS of hfileinfo is 0 --- .../apache/hadoop/hbase/tool/TestBulkLoadHFiles.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/tool/TestBulkLoadHFiles.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/tool/TestBulkLoadHFiles.java index 5d7708a8e925..ad25bf1be242 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/tool/TestBulkLoadHFiles.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/tool/TestBulkLoadHFiles.java @@ -18,6 +18,7 @@ package org.apache.hadoop.hbase.tool; import static org.apache.hadoop.hbase.HBaseTestingUtil.countRows; +import static org.hamcrest.Matchers.greaterThan; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThrows; @@ -64,6 +65,7 @@ import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.CommonFSUtils; import org.apache.hadoop.hbase.util.HFileTestUtil; +import org.hamcrest.MatcherAssert; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.ClassRule; @@ -649,8 +651,12 @@ private void verifyHFileCreateTimeTS(Path p) throws IOException { HFile.createReader(p.getFileSystem(conf), p, new CacheConfig(conf), true, conf); final HFileInfo hFileInfo = reader.getHFileInfo(); final long fileCreateTime = hFileInfo.getHFileContext().getFileCreateTime(); - reader.close(); - assertTrue(fileCreateTime != 0); + try { + reader.close(); + MatcherAssert.assertThat(fileCreateTime, greaterThan(0L)); + } catch (IOException e) { + fail("Failed due to exception"); + } } From b6d818641bb9487963141c4b7695892ce74e6ec8 Mon Sep 17 00:00:00 2001 From: alanzhao Date: Tue, 7 Mar 2023 19:00:39 +0800 Subject: [PATCH 11/11] JIRAID:HBASE-27688 HFile splitting occurs during bulkload, the CREATE_TIME_TS of hfileinfo is 0 --- .../hadoop/hbase/tool/TestBulkLoadHFiles.java | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/tool/TestBulkLoadHFiles.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/tool/TestBulkLoadHFiles.java index ad25bf1be242..fecf4c7ec2c2 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/tool/TestBulkLoadHFiles.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/tool/TestBulkLoadHFiles.java @@ -57,7 +57,6 @@ import org.apache.hadoop.hbase.io.encoding.DataBlockEncoding; import org.apache.hadoop.hbase.io.hfile.CacheConfig; import org.apache.hadoop.hbase.io.hfile.HFile; -import org.apache.hadoop.hbase.io.hfile.HFileInfo; import org.apache.hadoop.hbase.io.hfile.HFileScanner; import org.apache.hadoop.hbase.regionserver.BloomType; import org.apache.hadoop.hbase.testclassification.LargeTests; @@ -647,17 +646,12 @@ private int verifyHFile(Path p) throws IOException { private void verifyHFileCreateTimeTS(Path p) throws IOException { Configuration conf = util.getConfiguration(); - HFile.Reader reader = - HFile.createReader(p.getFileSystem(conf), p, new CacheConfig(conf), true, conf); - final HFileInfo hFileInfo = reader.getHFileInfo(); - final long fileCreateTime = hFileInfo.getHFileContext().getFileCreateTime(); - try { - reader.close(); + + try (HFile.Reader reader = + HFile.createReader(p.getFileSystem(conf), p, new CacheConfig(conf), true, conf)) { + long fileCreateTime = reader.getHFileInfo().getHFileContext().getFileCreateTime(); MatcherAssert.assertThat(fileCreateTime, greaterThan(0L)); - } catch (IOException e) { - fail("Failed due to exception"); } - } private void addStartEndKeysForTest(TreeMap map, byte[] first, byte[] last) {