|
17 | 17 | */ |
18 | 18 | package org.apache.hadoop.hbase.tool; |
19 | 19 |
|
| 20 | +import static org.hamcrest.Matchers.greaterThan; |
20 | 21 | import static org.junit.Assert.assertArrayEquals; |
21 | 22 | import static org.junit.Assert.assertEquals; |
22 | 23 | import static org.junit.Assert.assertThrows; |
|
61 | 62 | import org.apache.hadoop.hbase.util.Bytes; |
62 | 63 | import org.apache.hadoop.hbase.util.CommonFSUtils; |
63 | 64 | import org.apache.hadoop.hbase.util.HFileTestUtil; |
| 65 | +import org.hamcrest.MatcherAssert; |
64 | 66 | import org.junit.AfterClass; |
65 | 67 | import org.junit.BeforeClass; |
66 | 68 | import org.junit.ClassRule; |
@@ -568,6 +570,39 @@ public void testSplitStoreFile() throws IOException { |
568 | 570 | assertEquals(1000, rowCount); |
569 | 571 | } |
570 | 572 |
|
| 573 | + /** |
| 574 | + * This method tests that the create_time property of the HFile produced by the splitstorefile |
| 575 | + * method is greater than 0 HBASE-27688 |
| 576 | + */ |
| 577 | + @Test |
| 578 | + public void testSplitStoreFileWithCreateTimeTS() throws IOException { |
| 579 | + Path dir = util.getDataTestDirOnTestFS("testSplitStoreFileWithCreateTimeTS"); |
| 580 | + FileSystem fs = util.getTestFileSystem(); |
| 581 | + Path testIn = new Path(dir, "testhfile"); |
| 582 | + ColumnFamilyDescriptor familyDesc = ColumnFamilyDescriptorBuilder.of(FAMILY); |
| 583 | + HFileTestUtil.createHFile(util.getConfiguration(), fs, testIn, FAMILY, QUALIFIER, |
| 584 | + Bytes.toBytes("aaa"), Bytes.toBytes("zzz"), 1000); |
| 585 | + |
| 586 | + Path bottomOut = new Path(dir, "bottom.out"); |
| 587 | + Path topOut = new Path(dir, "top.out"); |
| 588 | + |
| 589 | + BulkLoadHFilesTool.splitStoreFile(util.getConfiguration(), testIn, familyDesc, |
| 590 | + Bytes.toBytes("ggg"), bottomOut, topOut); |
| 591 | + |
| 592 | + verifyHFileCreateTimeTS(bottomOut); |
| 593 | + verifyHFileCreateTimeTS(topOut); |
| 594 | + } |
| 595 | + |
| 596 | + private void verifyHFileCreateTimeTS(Path p) throws IOException { |
| 597 | + Configuration conf = util.getConfiguration(); |
| 598 | + |
| 599 | + try (HFile.Reader reader = |
| 600 | + HFile.createReader(p.getFileSystem(conf), p, new CacheConfig(conf), true, conf)) { |
| 601 | + long fileCreateTime = reader.getHFileInfo().getHFileContext().getFileCreateTime(); |
| 602 | + MatcherAssert.assertThat(fileCreateTime, greaterThan(0L)); |
| 603 | + } |
| 604 | + } |
| 605 | + |
571 | 606 | @Test |
572 | 607 | public void testSplitStoreFileWithNoneToNone() throws IOException { |
573 | 608 | testSplitStoreFileWithDifferentEncoding(DataBlockEncoding.NONE, DataBlockEncoding.NONE); |
|
0 commit comments