-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-26707: Reduce number of renames during bulkload #4066
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
2 commits
Select commit
Hold shift + click to select a range
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
166 changes: 166 additions & 0 deletions
166
.../src/test/java/org/apache/hadoop/hbase/mapreduce/IntegrationTestFileBasedSFTBulkLoad.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,166 @@ | ||
| /** | ||
| * | ||
| * 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.mapreduce; | ||
|
|
||
| import org.apache.commons.lang3.RandomStringUtils; | ||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.apache.hadoop.fs.Path; | ||
| import org.apache.hadoop.hbase.Cell; | ||
| import org.apache.hadoop.hbase.CellUtil; | ||
| import org.apache.hadoop.hbase.HBaseConfiguration; | ||
| import org.apache.hadoop.hbase.HBaseTestingUtil; | ||
| import org.apache.hadoop.hbase.IntegrationTestBase; | ||
| import org.apache.hadoop.hbase.IntegrationTestingUtility; | ||
| import org.apache.hadoop.hbase.KeyValue; | ||
| import org.apache.hadoop.hbase.TableName; | ||
| import org.apache.hadoop.hbase.client.Admin; | ||
| import org.apache.hadoop.hbase.client.Connection; | ||
| import org.apache.hadoop.hbase.client.ConnectionFactory; | ||
| import org.apache.hadoop.hbase.client.Consistency; | ||
| import org.apache.hadoop.hbase.client.RegionLocator; | ||
| import org.apache.hadoop.hbase.client.Result; | ||
| import org.apache.hadoop.hbase.client.Scan; | ||
| import org.apache.hadoop.hbase.client.TableDescriptor; | ||
| import org.apache.hadoop.hbase.client.TableDescriptorBuilder; | ||
| import org.apache.hadoop.hbase.coprocessor.ObserverContext; | ||
| import org.apache.hadoop.hbase.coprocessor.RegionCoprocessor; | ||
| import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment; | ||
| import org.apache.hadoop.hbase.coprocessor.RegionObserver; | ||
| import org.apache.hadoop.hbase.io.ImmutableBytesWritable; | ||
| import org.apache.hadoop.hbase.regionserver.InternalScanner; | ||
| import org.apache.hadoop.hbase.regionserver.storefiletracker.StoreFileTrackerFactory; | ||
| import org.apache.hadoop.hbase.testclassification.IntegrationTests; | ||
| import org.apache.hadoop.hbase.tool.BulkLoadHFiles; | ||
| import org.apache.hadoop.hbase.util.Bytes; | ||
| import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; | ||
| import org.apache.hadoop.hbase.util.RegionSplitter; | ||
| import org.apache.hadoop.io.LongWritable; | ||
| import org.apache.hadoop.io.NullWritable; | ||
| import org.apache.hadoop.io.Writable; | ||
| import org.apache.hadoop.io.WritableComparable; | ||
| import org.apache.hadoop.io.WritableComparator; | ||
| import org.apache.hadoop.io.WritableUtils; | ||
| import org.apache.hadoop.mapreduce.InputFormat; | ||
| import org.apache.hadoop.mapreduce.InputSplit; | ||
| import org.apache.hadoop.mapreduce.Job; | ||
| import org.apache.hadoop.mapreduce.JobContext; | ||
| import org.apache.hadoop.mapreduce.Mapper; | ||
| import org.apache.hadoop.mapreduce.Partitioner; | ||
| import org.apache.hadoop.mapreduce.RecordReader; | ||
| import org.apache.hadoop.mapreduce.Reducer; | ||
| import org.apache.hadoop.mapreduce.TaskAttemptContext; | ||
| import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; | ||
| import org.apache.hadoop.util.StringUtils; | ||
| import org.apache.hadoop.util.ToolRunner; | ||
| import org.apache.hbase.thirdparty.com.google.common.base.Joiner; | ||
| import org.apache.hbase.thirdparty.com.google.common.collect.Sets; | ||
| import org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine; | ||
| import org.junit.Test; | ||
| import org.junit.experimental.categories.Category; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
| import java.io.DataInput; | ||
| import java.io.DataOutput; | ||
| import java.io.IOException; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Optional; | ||
| import java.util.Random; | ||
| import java.util.Set; | ||
| import java.util.concurrent.atomic.AtomicLong; | ||
| import static org.junit.Assert.assertEquals; | ||
|
|
||
| /** | ||
| * Test Bulk Load and MR on a distributed cluster. | ||
| * With FileBased StorefileTracker enabled. | ||
| * It starts an MR job that creates linked chains | ||
| * | ||
| * The format of rows is like this: | ||
| * Row Key -> Long | ||
| * | ||
| * L:<< Chain Id >> -> Row Key of the next link in the chain | ||
| * S:<< Chain Id >> -> The step in the chain that his link is. | ||
| * D:<< Chain Id >> -> Random Data. | ||
| * | ||
| * All chains start on row 0. | ||
| * All rk's are > 0. | ||
| * | ||
| * After creating the linked lists they are walked over using a TableMapper based Mapreduce Job. | ||
| * | ||
| * There are a few options exposed: | ||
| * | ||
| * hbase.IntegrationTestBulkLoad.chainLength | ||
| * The number of rows that will be part of each and every chain. | ||
| * | ||
| * hbase.IntegrationTestBulkLoad.numMaps | ||
| * The number of mappers that will be run. Each mapper creates on linked list chain. | ||
| * | ||
| * hbase.IntegrationTestBulkLoad.numImportRounds | ||
| * How many jobs will be run to create linked lists. | ||
| * | ||
| * hbase.IntegrationTestBulkLoad.tableName | ||
| * The name of the table. | ||
| * | ||
| * hbase.IntegrationTestBulkLoad.replicaCount | ||
| * How many region replicas to configure for the table under test. | ||
| */ | ||
| @Category(IntegrationTests.class) | ||
| public class IntegrationTestFileBasedSFTBulkLoad extends IntegrationTestBulkLoad { | ||
|
|
||
| private static final Logger LOG = LoggerFactory.getLogger(IntegrationTestFileBasedSFTBulkLoad.class); | ||
|
|
||
| private static String NUM_MAPS_KEY = "hbase.IntegrationTestBulkLoad.numMaps"; | ||
| private static String NUM_IMPORT_ROUNDS_KEY = "hbase.IntegrationTestBulkLoad.numImportRounds"; | ||
| private static String NUM_REPLICA_COUNT_KEY = "hbase.IntegrationTestBulkLoad.replicaCount"; | ||
| private static int NUM_REPLICA_COUNT_DEFAULT = 1; | ||
|
|
||
| @Test | ||
| public void testFileBasedSFTBulkLoad() throws Exception { | ||
| super.testBulkLoad(); | ||
| } | ||
|
|
||
| @Override | ||
| public void setUpCluster() throws Exception { | ||
| util = getTestingUtil(getConf()); | ||
| util.getConfiguration().set(StoreFileTrackerFactory.TRACKER_IMPL, | ||
| "org.apache.hadoop.hbase.regionserver.storefiletracker.FileBasedStoreFileTracker"); | ||
| util.initializeCluster(1); | ||
| int replicaCount = getConf().getInt(NUM_REPLICA_COUNT_KEY, NUM_REPLICA_COUNT_DEFAULT); | ||
| if (LOG.isDebugEnabled() && replicaCount != NUM_REPLICA_COUNT_DEFAULT) { | ||
| LOG.debug("Region Replicas enabled: " + replicaCount); | ||
| } | ||
|
|
||
| // Scale this up on a real cluster | ||
| if (util.isDistributedCluster()) { | ||
| util.getConfiguration().setIfUnset(NUM_MAPS_KEY, | ||
| Integer.toString(util.getAdmin().getRegionServers().size() * 10)); | ||
| util.getConfiguration().setIfUnset(NUM_IMPORT_ROUNDS_KEY, "5"); | ||
| } else { | ||
| util.startMiniMapReduceCluster(); | ||
| } | ||
| } | ||
|
|
||
| public static void main(String[] args) throws Exception { | ||
| Configuration conf = HBaseConfiguration.create(); | ||
| IntegrationTestingUtility.setUseDistributedCluster(conf); | ||
| int status = ToolRunner.run(conf, new IntegrationTestFileBasedSFTBulkLoad(), args); | ||
| System.exit(status); | ||
| } | ||
| } |
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
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
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
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
Oops, something went wrong.
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.