-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-26246 Persist the StoreFileTracker configurations to TableDescriptor when creating table #3666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HBASE-26246 Persist the StoreFileTracker configurations to TableDescriptor when creating table #3666
Changes from 5 commits
ee80c28
af73bec
cf55d0e
4f4358c
21a6ebd
106e9b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ | |
| import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor; | ||
| import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder; | ||
| import org.apache.hadoop.hbase.client.TableDescriptor; | ||
| import org.apache.hadoop.hbase.client.TableDescriptorBuilder; | ||
| import org.apache.hadoop.hbase.regionserver.HRegionFileSystem; | ||
| import org.apache.hadoop.hbase.regionserver.StoreContext; | ||
| import org.apache.hadoop.hbase.util.Bytes; | ||
|
|
@@ -40,10 +41,13 @@ public final class StoreFileTrackerFactory { | |
| public static final String TRACK_IMPL = "hbase.store.file-tracker.impl"; | ||
| private static final Logger LOG = LoggerFactory.getLogger(StoreFileTrackerFactory.class); | ||
|
|
||
| public static Class<? extends StoreFileTracker> getStoreFileTrackerImpl(Configuration conf){ | ||
|
||
| return conf.getClass(TRACK_IMPL, DefaultStoreFileTracker.class, StoreFileTracker.class); | ||
| } | ||
|
|
||
| public static StoreFileTracker create(Configuration conf, boolean isPrimaryReplica, | ||
| StoreContext ctx) { | ||
| Class<? extends StoreFileTracker> tracker = | ||
| conf.getClass(TRACK_IMPL, DefaultStoreFileTracker.class, StoreFileTracker.class); | ||
| StoreContext ctx) { | ||
| Class<? extends StoreFileTracker> tracker = getStoreFileTrackerImpl(conf); | ||
| LOG.info("instantiating StoreFileTracker impl {}", tracker.getName()); | ||
| return ReflectionUtils.newInstance(tracker, conf, isPrimaryReplica, ctx); | ||
| } | ||
|
|
@@ -76,4 +80,12 @@ static StoreFileTrackerBase create(Configuration conf, String configName, | |
| LOG.info("instantiating StoreFileTracker impl {} as {}", tracker.getName(), configName); | ||
| return ReflectionUtils.newInstance(tracker, conf, isPrimaryReplica, ctx); | ||
| } | ||
|
|
||
| public static void persistTrackerConfig(Configuration conf, TableDescriptorBuilder builder) { | ||
| TableDescriptor tableDescriptor = builder.build(); | ||
| ColumnFamilyDescriptor cfDesc = tableDescriptor.getColumnFamilies()[0]; | ||
| StoreContext context = StoreContext.getBuilder().withColumnFamilyDescriptor(cfDesc).build(); | ||
| StoreFileTracker tracker = StoreFileTrackerFactory.create(conf, true, context); | ||
| tracker.persistConfiguration(builder); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
| package org.apache.hadoop.hbase.client; | ||
|
|
||
| import static org.apache.hadoop.hbase.HBaseTestingUtil.countRows; | ||
| import static org.apache.hadoop.hbase.regionserver.storefiletracker.StoreFileTrackerFactory.TRACK_IMPL; | ||
| import static org.junit.Assert.assertEquals; | ||
| import static org.junit.Assert.assertFalse; | ||
| import static org.junit.Assert.assertNotEquals; | ||
|
|
@@ -39,6 +40,7 @@ | |
| import org.apache.hadoop.hbase.TableExistsException; | ||
| import org.apache.hadoop.hbase.TableName; | ||
| import org.apache.hadoop.hbase.TableNotFoundException; | ||
| import org.apache.hadoop.hbase.regionserver.storefiletracker.StoreFileTrackerFactory; | ||
| import org.apache.hadoop.hbase.testclassification.ClientTests; | ||
| import org.apache.hadoop.hbase.testclassification.LargeTests; | ||
| import org.apache.hadoop.hbase.util.Bytes; | ||
|
|
@@ -423,6 +425,10 @@ private void testCloneTableSchema(final TableName tableName, final TableName new | |
| assertEquals(BLOCK_SIZE, newTableDesc.getColumnFamily(FAMILY_1).getBlocksize()); | ||
| assertEquals(BLOCK_CACHE, newTableDesc.getColumnFamily(FAMILY_1).isBlockCacheEnabled()); | ||
| assertEquals(TTL, newTableDesc.getColumnFamily(FAMILY_1).getTimeToLive()); | ||
| //HBASE-26246 introduced persist of store file tracker into table descriptor | ||
|
||
| tableDesc = TableDescriptorBuilder.newBuilder(tableDesc).setValue(TRACK_IMPL, | ||
| StoreFileTrackerFactory.getStoreFileTrackerImpl(TEST_UTIL.getConfiguration()).getName()). | ||
| build(); | ||
| TEST_UTIL.verifyTableDescriptorIgnoreTableName(tableDesc, newTableDesc); | ||
|
|
||
| if (preserveSplits) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
|
|
||
| package org.apache.hadoop.hbase.master.procedure; | ||
|
|
||
| import static org.apache.hadoop.hbase.regionserver.storefiletracker.StoreFileTrackerFactory.TRACK_IMPL; | ||
| import static org.junit.Assert.assertEquals; | ||
| import static org.junit.Assert.assertFalse; | ||
| import static org.junit.Assert.assertTrue; | ||
|
|
@@ -60,6 +61,7 @@ | |
| import org.apache.hadoop.hbase.procedure2.ProcedureExecutor; | ||
| import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility; | ||
| import org.apache.hadoop.hbase.procedure2.StateMachineProcedure; | ||
| import org.apache.hadoop.hbase.regionserver.storefiletracker.StoreFileTrackerFactory; | ||
| import org.apache.hadoop.hbase.util.Bytes; | ||
| import org.apache.hadoop.hbase.util.CommonFSUtils; | ||
| import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; | ||
|
|
@@ -226,6 +228,11 @@ public static void validateTableCreation(final HMaster master, final TableName t | |
| assertTrue("family not found " + family[i], htd.getColumnFamily(Bytes.toBytes(family[i])) != null); | ||
| } | ||
| assertEquals(family.length, htd.getColumnFamilyCount()); | ||
|
|
||
| //checks store file tracker impl has been properly set in htd | ||
|
||
| String storeFileTrackerImpl = | ||
| StoreFileTrackerFactory.getStoreFileTrackerImpl(master.getConfiguration()).getName(); | ||
| assertEquals(storeFileTrackerImpl, htd.getValue(TRACK_IMPL)); | ||
| } | ||
|
|
||
| public static void validateTableDeletion( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: space after 'if' and before '{'