-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-26263 [Rolling Upgrading] Persist the StoreFileTracker configur… #3700
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
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
d75b0ce
HBASE-26064 Introduce a StoreFileTracker to abstract the store file t…
Apache9 cab6140
HBASE-25988 Store the store file list by a file (#3578)
Apache9 708b7c1
HBASE-26079 Use StoreFileTracker when splitting and merging (#3617)
wchevreuil 41ed7e2
HBASE-26224 Introduce a MigrationStoreFileTracker to support migratin…
Apache9 f2addb1
HBASE-26246 Persist the StoreFileTracker configurations to TableDescr…
wchevreuil 5c35744
HBASE-26248 Should find a suitable way to let users specify the store…
Apache9 767a3e1
HBASE-26264 Add more checks to prevent misconfiguration on store file…
Apache9 be5a148
HBASE-26280 Use store file tracker when snapshoting (#3685)
Apache9 d3556bf
HBASE-26326 CreateTableProcedure fails when FileBasedStoreFileTracker…
wchevreuil 36a4846
HBASE-26263 [Rolling Upgrading] Persist the StoreFileTracker configur…
GeorryHuang b633a52
modification
GeorryHuang d2fece5
typo
GeorryHuang de2d050
limit the count of table
GeorryHuang e1ede25
Merge branch 'HBASE-26067' into HBASE-26263
GeorryHuang a2bed30
Update MigrationStoreFileTracker.java
GeorryHuang 144a29d
Modify according to comments
GeorryHuang 3d05b10
Remove empty line
GeorryHuang 5dfd1c3
Add unit to conf string
GeorryHuang ffdff2f
Added UT
GeorryHuang f84ea4a
Fixed Checkstyle
GeorryHuang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
130 changes: 130 additions & 0 deletions
130
hbase-server/src/main/java/org/apache/hadoop/hbase/master/migrate/RollingUpgradeChore.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.hadoop.hbase.master.migrate; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.stream.Collectors; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.apache.hadoop.conf.Configuration; | ||
import org.apache.hadoop.hbase.ScheduledChore; | ||
import org.apache.hadoop.hbase.Stoppable; | ||
import org.apache.hadoop.hbase.TableDescriptors; | ||
import org.apache.hadoop.hbase.client.TableDescriptor; | ||
import org.apache.hadoop.hbase.master.MasterServices; | ||
import org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv; | ||
import org.apache.hadoop.hbase.procedure2.ProcedureExecutor; | ||
import org.apache.hadoop.hbase.regionserver.storefiletracker.MigrateStoreFileTrackerProcedure; | ||
import org.apache.hadoop.hbase.regionserver.storefiletracker.StoreFileTrackerFactory; | ||
import org.apache.yetus.audience.InterfaceAudience; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* To avoid too many migrating/upgrade threads to be submitted at the time during master | ||
* initialization, RollingUpgradeChore handles all rolling-upgrade tasks. | ||
* */ | ||
@InterfaceAudience.Private | ||
public class RollingUpgradeChore extends ScheduledChore { | ||
|
||
static final String ROLLING_UPGRADE_CHORE_PERIOD_SECONDS_KEY = | ||
"hbase.master.rolling.upgrade.chore.period.secs"; | ||
static final int DFAULT_ROLLING_UPGRADE_CHORE_PERIOD_SECONDS = 10; // 10 seconds by default | ||
|
||
static final String ROLLING_UPGRADE_CHORE_DELAY_SECONDS_KEY = | ||
"hbase.master.rolling.upgrade.chore.delay.secs"; | ||
static final long DEFAULT_ROLLING_UPGRADE_CHORE_DELAY_SECONDS = 30; // 30 seconds | ||
|
||
static final int CONCURRENT_PROCEDURES_COUNT = 5; | ||
|
||
private final static Logger LOG = LoggerFactory.getLogger(RollingUpgradeChore.class); | ||
ProcedureExecutor<MasterProcedureEnv> procedureExecutor; | ||
private TableDescriptors tableDescriptors; | ||
private List<MigrateStoreFileTrackerProcedure> processingProcs = new ArrayList<>(); | ||
|
||
public RollingUpgradeChore(MasterServices masterServices) { | ||
this(masterServices.getConfiguration(), masterServices.getMasterProcedureExecutor(), | ||
masterServices.getTableDescriptors(), masterServices); | ||
} | ||
|
||
private RollingUpgradeChore(Configuration conf, | ||
ProcedureExecutor<MasterProcedureEnv> procedureExecutor, TableDescriptors tableDescriptors, | ||
Stoppable stopper) { | ||
super(RollingUpgradeChore.class.getSimpleName(), stopper, conf | ||
.getInt(ROLLING_UPGRADE_CHORE_PERIOD_SECONDS_KEY, | ||
DFAULT_ROLLING_UPGRADE_CHORE_PERIOD_SECONDS), conf | ||
.getLong(ROLLING_UPGRADE_CHORE_DELAY_SECONDS_KEY, | ||
DEFAULT_ROLLING_UPGRADE_CHORE_DELAY_SECONDS), | ||
TimeUnit.SECONDS); | ||
this.procedureExecutor = procedureExecutor; | ||
this.tableDescriptors = tableDescriptors; | ||
} | ||
|
||
@Override | ||
protected void chore() { | ||
if (isCompletelyMigrateSFT(CONCURRENT_PROCEDURES_COUNT)) { | ||
LOG.info("All Rolling-Upgrade tasks are complete, shutdown RollingUpgradeChore!"); | ||
shutdown(); | ||
} | ||
} | ||
|
||
private boolean isCompletelyMigrateSFT(int concurrentCount){ | ||
Iterator<MigrateStoreFileTrackerProcedure> iter = processingProcs.iterator(); | ||
while(iter.hasNext()){ | ||
MigrateStoreFileTrackerProcedure proc = iter.next(); | ||
if(procedureExecutor.isFinished(proc.getProcId())){ | ||
iter.remove(); | ||
} | ||
} | ||
// No new migration procedures will be submitted until | ||
// all procedures executed last time are completed. | ||
if (!processingProcs.isEmpty()) { | ||
return false; | ||
} | ||
|
||
Map<String, TableDescriptor> migrateSFTTables; | ||
try { | ||
migrateSFTTables = tableDescriptors.getAll().entrySet().stream().filter(entry -> { | ||
TableDescriptor td = entry.getValue(); | ||
return StringUtils.isEmpty(td.getValue(StoreFileTrackerFactory.TRACKER_IMPL)); | ||
}).limit(concurrentCount).collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue())); | ||
} catch (IOException e) { | ||
LOG.warn("Failed to migrate StoreFileTracker", e); | ||
return false; | ||
} | ||
|
||
if (migrateSFTTables.isEmpty()) { | ||
LOG.info("There is no table to migrate StoreFileTracker!"); | ||
return true; | ||
} | ||
|
||
for (Map.Entry<String, TableDescriptor> entry : migrateSFTTables.entrySet()) { | ||
TableDescriptor tableDescriptor = entry.getValue(); | ||
MigrateStoreFileTrackerProcedure proc = | ||
new MigrateStoreFileTrackerProcedure(procedureExecutor.getEnvironment(), tableDescriptor); | ||
procedureExecutor.submitProcedure(proc); | ||
processingProcs.add(proc); | ||
} | ||
return false; | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...g/apache/hadoop/hbase/regionserver/storefiletracker/MigrateStoreFileTrackerProcedure.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.hadoop.hbase.regionserver.storefiletracker; | ||
|
||
import java.util.Optional; | ||
import org.apache.hadoop.hbase.client.TableDescriptor; | ||
import org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv; | ||
import org.apache.hadoop.hbase.master.procedure.ModifyTableDescriptorProcedure; | ||
import org.apache.hadoop.hbase.procedure2.util.StringUtils; | ||
import org.apache.yetus.audience.InterfaceAudience; | ||
|
||
/** | ||
* Procedure for migrating StoreFileTracker information to table descriptor. | ||
*/ | ||
@InterfaceAudience.Private | ||
public class MigrateStoreFileTrackerProcedure extends ModifyTableDescriptorProcedure { | ||
|
||
public MigrateStoreFileTrackerProcedure(){} | ||
|
||
public MigrateStoreFileTrackerProcedure(MasterProcedureEnv env, TableDescriptor unmodified) { | ||
super(env, unmodified); | ||
} | ||
|
||
@Override | ||
protected Optional<TableDescriptor> modify(MasterProcedureEnv env, TableDescriptor current) { | ||
if (StringUtils.isEmpty(current.getValue(StoreFileTrackerFactory.TRACKER_IMPL))) { | ||
TableDescriptor td = | ||
StoreFileTrackerFactory.updateWithTrackerConfigs(env.getMasterConfiguration(), current); | ||
return Optional.of(td); | ||
} | ||
return Optional.empty(); | ||
} | ||
} |
107 changes: 107 additions & 0 deletions
107
...ver/src/test/java/org/apache/hadoop/hbase/master/migrate/TestMigrateStoreFileTracker.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.hadoop.hbase.master.migrate; | ||
|
||
import java.io.IOException; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.apache.hadoop.conf.Configuration; | ||
import org.apache.hadoop.hbase.HBaseClassTestRule; | ||
import org.apache.hadoop.hbase.HBaseConfiguration; | ||
import org.apache.hadoop.hbase.HBaseTestingUtil; | ||
import org.apache.hadoop.hbase.TableDescriptors; | ||
import org.apache.hadoop.hbase.TableName; | ||
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.storefiletracker.StoreFileTrackerFactory; | ||
import org.apache.hadoop.hbase.testclassification.MediumTests; | ||
import org.apache.hadoop.hbase.util.Bytes; | ||
import org.junit.After; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.ClassRule; | ||
import org.junit.Test; | ||
import org.junit.experimental.categories.Category; | ||
|
||
@Category(MediumTests.class) | ||
public class TestMigrateStoreFileTracker { | ||
@ClassRule | ||
public static final HBaseClassTestRule CLASS_RULE = | ||
HBaseClassTestRule.forClass(TestMigrateStoreFileTracker.class); | ||
private final static String[] tables = new String[] { "t1", "t2", "t3", "t4", "t5", "t6" }; | ||
private final static String famStr = "f1"; | ||
private final static byte[] fam = Bytes.toBytes(famStr); | ||
|
||
private HBaseTestingUtil HTU; | ||
private Configuration conf; | ||
private TableDescriptor tableDescriptor; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
conf = HBaseConfiguration.create(); | ||
//Speed up the launch of RollingUpgradeChore | ||
conf.setInt(RollingUpgradeChore.ROLLING_UPGRADE_CHORE_PERIOD_SECONDS_KEY, 1); | ||
conf.setLong(RollingUpgradeChore.ROLLING_UPGRADE_CHORE_DELAY_SECONDS_KEY, 1); | ||
HTU = new HBaseTestingUtil(conf); | ||
HTU.startMiniCluster(); | ||
} | ||
|
||
@After | ||
public void tearDown() throws Exception { | ||
HTU.shutdownMiniCluster(); | ||
} | ||
|
||
@Test | ||
public void testMigrateStoreFileTracker() throws IOException, InterruptedException { | ||
//create tables to test | ||
for (int i = 0; i < tables.length; i++) { | ||
tableDescriptor = HTU.createModifyableTableDescriptor(tables[i]) | ||
.setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(fam).build()).build(); | ||
HTU.createTable(tableDescriptor, null); | ||
} | ||
TableDescriptors tableDescriptors = HTU.getMiniHBaseCluster().getMaster().getTableDescriptors(); | ||
for (int i = 0; i < tables.length; i++) { | ||
TableDescriptor tdAfterCreated = tableDescriptors.get(TableName.valueOf(tables[i])); | ||
//make sure that TRACKER_IMPL was set by default after tables have been created. | ||
Assert.assertNotNull(tdAfterCreated.getValue(StoreFileTrackerFactory.TRACKER_IMPL)); | ||
//Remove StoreFileTracker impl from tableDescriptor | ||
TableDescriptor tdRemovedSFT = TableDescriptorBuilder.newBuilder(tdAfterCreated) | ||
.removeValue(StoreFileTrackerFactory.TRACKER_IMPL).build(); | ||
tableDescriptors.update(tdRemovedSFT); | ||
} | ||
HTU.getMiniHBaseCluster().stopMaster(0).join(); | ||
HTU.getMiniHBaseCluster().startMaster(); | ||
HTU.getMiniHBaseCluster().waitForActiveAndReadyMaster(30000); | ||
//wait until all tables have been migrated | ||
TableDescriptors tds = HTU.getMiniHBaseCluster().getMaster().getTableDescriptors(); | ||
HTU.waitFor(30000, () -> { | ||
try { | ||
for (int i = 0; i < tables.length; i++) { | ||
TableDescriptor td = tds.get(TableName.valueOf(tables[i])); | ||
if (StringUtils.isEmpty(td.getValue(StoreFileTrackerFactory.TRACKER_IMPL))) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} catch (IOException e) { | ||
return false; | ||
} | ||
}); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.