Repository: hbase Updated Branches: refs/heads/master e83ac38d6 -> 000a84cb4
Revert "HBASE-20181 Logging and minor logic improvements in BackupLogCleaner" - missed author This reverts commit 5bfc5745ab8e94d09851980dce2e243620f412ff. Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/810567f6 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/810567f6 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/810567f6 Branch: refs/heads/master Commit: 810567f65abde105ec55c4337c68c350e353b2bc Parents: e83ac38 Author: Apekshit Sharma <[email protected]> Authored: Wed Mar 14 12:28:50 2018 +0530 Committer: Apekshit Sharma <[email protected]> Committed: Wed Mar 14 12:29:24 2018 +0530 ---------------------------------------------------------------------- .../hbase/backup/master/BackupLogCleaner.java | 35 +++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/810567f6/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/master/BackupLogCleaner.java ---------------------------------------------------------------------- diff --git a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/master/BackupLogCleaner.java b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/master/BackupLogCleaner.java index 093ef76..bd13d6e 100644 --- a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/master/BackupLogCleaner.java +++ b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/master/BackupLogCleaner.java @@ -20,11 +20,9 @@ package org.apache.hadoop.hbase.backup.master; import java.io.IOException; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Map; -import org.apache.commons.collections.MapUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.hbase.HBaseInterfaceAudience; @@ -38,7 +36,6 @@ import org.apache.hadoop.hbase.master.HMaster; import org.apache.hadoop.hbase.master.MasterServices; import org.apache.hadoop.hbase.master.cleaner.BaseLogCleanerDelegate; import org.apache.yetus.audience.InterfaceAudience; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -58,9 +55,8 @@ public class BackupLogCleaner extends BaseLogCleanerDelegate { @Override public void init(Map<String, Object> params) { - MasterServices master = (MasterServices) MapUtils.getObject(params, - HMaster.MASTER); - if (master != null) { + if (params != null && params.containsKey(HMaster.MASTER)) { + MasterServices master = (MasterServices) params.get(HMaster.MASTER); conn = master.getConnection(); if (getConf() == null) { super.setConf(conn.getConfiguration()); @@ -80,11 +76,14 @@ public class BackupLogCleaner extends BaseLogCleanerDelegate { // all members of this class are null if backup is disabled, // so we cannot filter the files if (this.getConf() == null || !BackupManager.isBackupEnabled(getConf())) { - LOG.debug("Backup is not enabled. Check your {} setting", - BackupRestoreConstants.BACKUP_ENABLE_KEY); + if (LOG.isDebugEnabled()) { + LOG.debug("Backup is not enabled. Check your " + + BackupRestoreConstants.BACKUP_ENABLE_KEY + " setting"); + } return files; } + List<FileStatus> list = new ArrayList<>(); try (final BackupSystemTable table = new BackupSystemTable(conn)) { // If we do not have recorded backup sessions try { @@ -93,28 +92,31 @@ public class BackupLogCleaner extends BaseLogCleanerDelegate { return files; } } catch (TableNotFoundException tnfe) { - LOG.warn("Backup system table is not available: {}", tnfe.getMessage()); + LOG.warn("backup system table is not available" + tnfe.getMessage()); return files; } - List<FileStatus> list = new ArrayList<>(); Map<FileStatus, Boolean> walFilesDeletableMap = table.areWALFilesDeletable(files); for (Map.Entry<FileStatus, Boolean> entry: walFilesDeletableMap.entrySet()) { FileStatus file = entry.getKey(); String wal = file.getPath().toString(); boolean deletable = entry.getValue(); if (deletable) { - LOG.debug("Found log file in backup system table, deleting: {}", wal); + if (LOG.isDebugEnabled()) { + LOG.debug("Found log file in backup system table, deleting: " + wal); + } list.add(file); } else { - LOG.debug("Did not find this log in backup system table, keeping: {}", wal); + if (LOG.isDebugEnabled()) { + LOG.debug("Didn't find this log in backup system table, keeping: " + wal); + } } } return list; } catch (IOException e) { LOG.error("Failed to get backup system table table, therefore will keep all files", e); // nothing to delete - return Collections.emptyList(); + return new ArrayList<>(); } } @@ -130,10 +132,11 @@ public class BackupLogCleaner extends BaseLogCleanerDelegate { @Override public void stop(String why) { - if (!this.stopped) { - this.stopped = true; - LOG.info("Stopping BackupLogCleaner"); + if (this.stopped) { + return; } + this.stopped = true; + LOG.info("Stopping BackupLogCleaner"); } @Override
