-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-27201 Clean up error-prone findings in hbase-backup #4622
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
Changes from all commits
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 |
|---|---|---|
|
|
@@ -19,6 +19,8 @@ | |
|
|
||
| import java.io.Closeable; | ||
| import java.io.IOException; | ||
| import java.io.InterruptedIOException; | ||
| import java.nio.charset.StandardCharsets; | ||
| import java.util.ArrayList; | ||
| import java.util.Arrays; | ||
| import java.util.Collections; | ||
|
|
@@ -237,6 +239,7 @@ private void waitForSystemTable(Admin admin, TableName tableName) throws IOExcep | |
| try { | ||
| Thread.sleep(100); | ||
| } catch (InterruptedException e) { | ||
| throw (IOException) new InterruptedIOException().initCause(e); | ||
| } | ||
| if (EnvironmentEdgeManager.currentTime() - startTime > TIMEOUT) { | ||
| throw new IOException( | ||
|
|
@@ -574,7 +577,7 @@ public String readBackupStartCode(String backupRoot) throws IOException { | |
| if (val.length == 0) { | ||
| return null; | ||
| } | ||
| return new String(val); | ||
| return new String(val, StandardCharsets.UTF_8); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -1639,7 +1642,7 @@ public String[] getListOfBackupIdsFromDeleteOperation() throws IOException { | |
| if (val.length == 0) { | ||
| return null; | ||
| } | ||
| return new String(val).split(","); | ||
| return new String(val, StandardCharsets.UTF_8).split(","); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -1654,7 +1657,7 @@ public boolean isMergeInProgress() throws IOException { | |
| Get get = new Get(MERGE_OP_ROW); | ||
| try (Table table = connection.getTable(tableName)) { | ||
| Result res = table.get(get); | ||
| return (!res.isEmpty()); | ||
| return !res.isEmpty(); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -1720,7 +1723,7 @@ public String[] getListOfBackupIdsFromMergeOperation() throws IOException { | |
| if (val.length == 0) { | ||
| return null; | ||
| } | ||
| return new String(val).split(","); | ||
| return new String(val, StandardCharsets.UTF_8).split(","); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does not produce a warning, because stringsplitter warnings are suppressed. |
||
| } | ||
| } | ||
|
|
||
|
|
@@ -1736,11 +1739,13 @@ static Scan createScanForOrigBulkLoadedFiles(TableName table) { | |
| return scan; | ||
| } | ||
|
|
||
| @SuppressWarnings("StringSplitter") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we have shaded guava, I think it is OK for use to make use of guava's Splitter. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's nothing wrong with string.split in these applications and when I used Splitter it caused more trouble than it was worth. |
||
| static String getTableNameFromOrigBulkLoadRow(String rowStr) { | ||
| String[] parts = rowStr.split(BLK_LD_DELIM); | ||
| return parts[1]; | ||
| } | ||
|
|
||
| @SuppressWarnings("StringSplitter") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. |
||
| static String getRegionNameFromOrigBulkLoadRow(String rowStr) { | ||
| // format is bulk : namespace : table : region : file | ||
| String[] parts = rowStr.split(BLK_LD_DELIM); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,7 +68,7 @@ | |
| */ | ||
| @InterfaceAudience.Private | ||
| public final class BackupUtils { | ||
| protected static final Logger LOG = LoggerFactory.getLogger(BackupUtils.class); | ||
| private static final Logger LOG = LoggerFactory.getLogger(BackupUtils.class); | ||
| public static final String LOGNAME_SEPARATOR = "."; | ||
| public static final int MILLISEC_IN_HOUR = 3600000; | ||
|
|
||
|
|
@@ -136,9 +136,10 @@ public static void copyTableRegionInfo(Connection conn, BackupInfo backupInfo, C | |
| // write a copy of descriptor to the target directory | ||
| Path target = new Path(backupInfo.getTableBackupDir(table)); | ||
| FileSystem targetFs = target.getFileSystem(conf); | ||
| FSTableDescriptors descriptors = | ||
| new FSTableDescriptors(targetFs, CommonFSUtils.getRootDir(conf)); | ||
| descriptors.createTableDescriptorForTableDirectory(target, orig, false); | ||
| try (FSTableDescriptors descriptors = | ||
| new FSTableDescriptors(targetFs, CommonFSUtils.getRootDir(conf))) { | ||
| descriptors.createTableDescriptorForTableDirectory(target, orig, false); | ||
| } | ||
| LOG.debug("Attempting to copy table info for:" + table + " target: " + target | ||
| + " descriptor: " + orig); | ||
| LOG.debug("Finished copying tableinfo."); | ||
|
|
@@ -275,12 +276,12 @@ public static List<String> getWALFilesOlderThan(final Configuration c, | |
| return logFiles; | ||
| } | ||
|
|
||
| @SuppressWarnings("StringSplitter") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DItto. |
||
| public static TableName[] parseTableNames(String tables) { | ||
| if (tables == null) { | ||
| return null; | ||
| } | ||
| String[] tableArray = tables.split(BackupRestoreConstants.TABLENAME_DELIMITER_IN_COMMAND); | ||
|
|
||
| TableName[] ret = new TableName[tableArray.length]; | ||
| for (int i = 0; i < tableArray.length; i++) { | ||
| ret[i] = TableName.valueOf(tableArray[i]); | ||
|
|
@@ -593,6 +594,7 @@ public int compare(BackupInfo o1, BackupInfo o2) { | |
| return ts1 < ts2 ? 1 : -1; | ||
| } | ||
|
|
||
| @SuppressWarnings("StringSplitter") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. |
||
| private long getTimestamp(String backupId) { | ||
| String[] split = backupId.split("_"); | ||
| return Long.parseLong(split[1]); | ||
|
|
@@ -731,6 +733,7 @@ public static BulkLoadHFiles createLoader(Configuration config) { | |
| return BulkLoadHFiles.create(conf); | ||
| } | ||
|
|
||
| @SuppressWarnings("StringSplitter") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. |
||
| public static String findMostRecentBackupId(String[] backupIds) { | ||
| long recentTimestamp = Long.MIN_VALUE; | ||
| for (String backupId : backupIds) { | ||
|
|
||
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.
I think this will introduce another error prone warning? Use guava's Splitter.on
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.
It does not.