Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rda3mon committed Aug 21, 2022
1 parent ef01948 commit e99a08a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,7 @@ private int parseAndRun(String[] args) throws IOException {
return 0;
}

private String getTablesForSet(Connection conn, String name)
throws IOException {
private String getTablesForSet(Connection conn, String name) throws IOException {
try (final BackupSystemTable table = new BackupSystemTable(conn)) {
List<TableName> tables = table.describeBackupSet(name);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,7 @@ private void createAndRestoreTable(Connection conn, TableName tableName, TableNa
+ ", will only create table");
}
tableDescriptor = TableDescriptorBuilder.copy(newTableName, tableDescriptor);
checkAndCreateTable(conn, newTableName, null, tableDescriptor,
truncateIfExists);
checkAndCreateTable(conn, newTableName, null, tableDescriptor, truncateIfExists);
return;
} else {
throw new IllegalStateException(
Expand All @@ -347,8 +346,7 @@ private void createAndRestoreTable(Connection conn, TableName tableName, TableNa

// should only try to create the table with all region informations, so we could pre-split
// the regions in fine grain
checkAndCreateTable(conn, newTableName, regionPathList,
tableDescriptor, truncateIfExists);
checkAndCreateTable(conn, newTableName, regionPathList, tableDescriptor, truncateIfExists);
RestoreJob restoreService = BackupRestoreFactory.getRestoreJob(conf);
Path[] paths = new Path[regionPathList.size()];
regionPathList.toArray(paths);
Expand Down Expand Up @@ -466,9 +464,9 @@ byte[][] generateBoundaryKeys(ArrayList<Path> regionDirList) throws IOException
* @param truncateIfExists truncates table if exists
* @throws IOException exception
*/
private void checkAndCreateTable(Connection conn,
TableName targetTableName, ArrayList<Path> regionDirList, TableDescriptor htd,
boolean truncateIfExists) throws IOException {
private void checkAndCreateTable(Connection conn, TableName targetTableName,
ArrayList<Path> regionDirList, TableDescriptor htd, boolean truncateIfExists)
throws IOException {
try (Admin admin = conn.getAdmin()) {
boolean createNew = false;
if (admin.tableExists(targetTableName)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.net.InetSocketAddress;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -254,15 +255,15 @@ public void write(ImmutableBytesWritable row, V cell) throws IOException {
byte[] tableNameBytes = null;
if (writeMultipleTables) {
tableNameBytes = MultiTableHFileOutputFormat.getTableName(row.get());
tableNameBytes = TableName.valueOf(tableNameBytes).toBytes();
tableNameBytes = TableName.valueOf(tableNameBytes).getNameWithNamespaceInclAsString()
.getBytes(Charset.defaultCharset());
if (!allTableNames.contains(Bytes.toString(tableNameBytes))) {
throw new IllegalArgumentException(
"TableName " + Bytes.toString(tableNameBytes) + " not expected");
}
} else {
tableNameBytes = Bytes.toBytes(writeTableNames);
}
String tableName = Bytes.toString(tableNameBytes);
Path tableRelPath = getTableRelativePath(tableNameBytes);
byte[] tableAndFamily = getTableNameSuffixedWithFamily(tableNameBytes, family);

Expand Down Expand Up @@ -293,6 +294,7 @@ public void write(ImmutableBytesWritable row, V cell) throws IOException {
if (conf.getBoolean(LOCALITY_SENSITIVE_CONF_KEY, DEFAULT_LOCALITY_SENSITIVE)) {
HRegionLocation loc = null;

String tableName = Bytes.toString(tableNameBytes);
if (tableName != null) {
try (
Connection connection =
Expand Down Expand Up @@ -651,7 +653,10 @@ static void configureIncrementalLoad(Job job, List<TableInfo> multiTableInfo,

for (TableInfo tableInfo : multiTableInfo) {
regionLocators.add(tableInfo.getRegionLocator());
allTableNames.add(tableInfo.getRegionLocator().getName().getNameAsString());
String tn = writeMultipleTables
? tableInfo.getRegionLocator().getName().getNameWithNamespaceInclAsString()
: tableInfo.getRegionLocator().getName().getNameAsString();
allTableNames.add(tn);
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 @@ -651,15 +651,18 @@ 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
assertEquals("HFOF should not touch actual table", 0, util.countRows(tableSingle));
}
int numTableDirs = 0;
for (FileStatus tf : testDir.getFileSystem(conf).listStatus(testDir)) {
FileStatus[] fss = testDir.getFileSystem(conf).listStatus(testDir);
for (FileStatus tf : fss) {
Path tablePath = testDir;

if (writeMultipleTables) {
if (allTables.containsKey(tf.getPath().getName())) {
++numTableDirs;
Expand All @@ -671,7 +674,8 @@ private void doIncrementalLoadTest(boolean shouldChangeRegions, boolean shouldKe

// Make sure that a directory was created for every CF
int dir = 0;
for (FileStatus f : tablePath.getFileSystem(conf).listStatus(tablePath)) {
fss = tablePath.getFileSystem(conf).listStatus(tablePath);
for (FileStatus f : fss) {
for (byte[] family : FAMILIES) {
if (Bytes.toString(family).equals(f.getPath().getName())) {
++dir;
Expand Down

0 comments on commit e99a08a

Please sign in to comment.