Skip to content

Commit

Permalink
review enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
rda3mon committed Jan 19, 2023
1 parent 8bc9fce commit 4ccda54
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion hbase-backup/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-build-configuration</artifactId>
<version>2.6.0-SNAPSHOT</version>
<version>${revision}</version>
<relativePath>../hbase-build-configuration</relativePath>
</parent>
<artifactId>hbase-backup</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.apache.hadoop.hbase.backup.util.BackupUtils;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.mapreduce.HFileOutputFormat2;
import org.apache.hadoop.hbase.mapreduce.WALPlayer;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.CommonFSUtils;
Expand Down Expand Up @@ -397,6 +398,7 @@ protected void walToHFiles(List<String> dirPaths, List<String> tableList) throws
Path bulkOutputPath = getBulkOutputDir();
conf.set(WALPlayer.BULK_OUTPUT_CONF_KEY, bulkOutputPath.toString());
conf.set(WALPlayer.INPUT_FILES_SEPARATOR_KEY, ";");
conf.setBoolean(HFileOutputFormat2.TABLE_NAME_WITH_NAMESPACE_INCLUSIVE_KEY, true);
conf.setBoolean(WALPlayer.MULTI_TABLES_SUPPORT, true);
conf.set(JOB_NAME_CONF_KEY, jobname);
String[] playerArgs = { dirs, StringUtils.join(tableList, ",") };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ protected static byte[] combineTableNameSuffix(byte[] tableName, byte[] suffix)
static final String BLOCK_SIZE_FAMILIES_CONF_KEY = "hbase.mapreduce.hfileoutputformat.blocksize";
static final String DATABLOCK_ENCODING_FAMILIES_CONF_KEY =
"hbase.mapreduce.hfileoutputformat.families.datablock.encoding";
public static final String TABLE_NAME_WITH_NAMESPACE_INCLUSIVE_KEY =
"hbase.hfileoutputformat.tablename.namespace.inclusive";

private static final boolean TABLE_NAME_WITH_NAMESPACE_INCLUSIVE_DEFAULT_VALUE = false;

// This constant is public since the client can modify this when setting
// up their conf object and thus refer to this symbol.
Expand Down Expand Up @@ -202,6 +206,8 @@ static <V extends Cell> RecordWriter<ImmutableBytesWritable, V> createRecordWrit
final Configuration conf = context.getConfiguration();
final boolean writeMultipleTables =
conf.getBoolean(MULTI_TABLE_HFILEOUTPUTFORMAT_CONF_KEY, false);
final boolean writeToTableWithNamespace = conf.getBoolean(
TABLE_NAME_WITH_NAMESPACE_INCLUSIVE_KEY, TABLE_NAME_WITH_NAMESPACE_INCLUSIVE_DEFAULT_VALUE);
final String writeTableNames = conf.get(OUTPUT_TABLE_NAME_CONF_KEY);
if (writeTableNames == null || writeTableNames.isEmpty()) {
throw new IllegalArgumentException("" + OUTPUT_TABLE_NAME_CONF_KEY + " cannot be empty");
Expand Down Expand Up @@ -255,8 +261,10 @@ public void write(ImmutableBytesWritable row, V cell) throws IOException {
byte[] tableNameBytes = null;
if (writeMultipleTables) {
tableNameBytes = MultiTableHFileOutputFormat.getTableName(row.get());
tableNameBytes = TableName.valueOf(tableNameBytes).getNameWithNamespaceInclAsString()
.getBytes(Charset.defaultCharset());
tableNameBytes = (writeToTableWithNamespace) ?
TableName.valueOf(tableNameBytes).getNameWithNamespaceInclAsString()
.getBytes(Charset.defaultCharset()) :
TableName.valueOf(tableNameBytes).toBytes();
if (!allTableNames.contains(Bytes.toString(tableNameBytes))) {
throw new IllegalArgumentException(
"TableName " + Bytes.toString(tableNameBytes) + " not expected");
Expand Down Expand Up @@ -614,6 +622,9 @@ static void configureIncrementalLoad(Job job, List<TableInfo> multiTableInfo,
job.setOutputValueClass(MapReduceExtendedCell.class);
job.setOutputFormatClass(cls);

final boolean writeToTableWithNamespace = conf.getBoolean(
TABLE_NAME_WITH_NAMESPACE_INCLUSIVE_KEY, TABLE_NAME_WITH_NAMESPACE_INCLUSIVE_DEFAULT_VALUE);

if (multiTableInfo.stream().distinct().count() != multiTableInfo.size()) {
throw new IllegalArgumentException("Duplicate entries found in TableInfo argument");
}
Expand Down Expand Up @@ -653,10 +664,9 @@ static void configureIncrementalLoad(Job job, List<TableInfo> multiTableInfo,

for (TableInfo tableInfo : multiTableInfo) {
regionLocators.add(tableInfo.getRegionLocator());
String tn = writeMultipleTables
? tableInfo.getRegionLocator().getName().getNameWithNamespaceInclAsString()
: tableInfo.getRegionLocator().getName().getNameAsString();
allTableNames.add(tn);
allTableNames.add(writeToTableWithNamespace ?
tableInfo.getRegionLocator().getName().getNameWithNamespaceInclAsString() :
tableInfo.getRegionLocator().getName().getNameAsString());
tableDescriptors.add(tableInfo.getTableDescriptor());
}
// Record tablenames for creating writer by favored nodes, and decoding compression,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -616,9 +616,6 @@ private void doIncrementalLoadTest(boolean shouldChangeRegions, boolean shouldKe
Path testDir = util.getDataTestDirOnTestFS("testLocalMRIncrementalLoad");
// Generate the bulk load files
runIncrementalPELoad(conf, tableInfo, testDir, putSortReducer);
if (writeMultipleTables) {
testDir = new Path(testDir, "default");
}

for (Table tableSingle : allTables.values()) {
// This doesn't write into the table, just makes files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -651,9 +651,6 @@ private void doIncrementalLoadTest(boolean shouldChangeRegions, boolean shouldKe
Path testDir = util.getDataTestDirOnTestFS("testLocalMRIncrementalLoad");
// Generate the bulk load files
runIncrementalPELoad(conf, tableInfo, testDir, putSortReducer);
if (writeMultipleTables) {
testDir = new Path(testDir, "default");
}

for (Table tableSingle : allTables.values()) {
// This doesn't write into the table, just makes files
Expand Down

0 comments on commit 4ccda54

Please sign in to comment.