Skip to content

Commit a756f53

Browse files
author
Ray Mattingly
committed
clearer naming
1 parent 63e5cde commit a756f53

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/master/BackupLogCleaner.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,16 @@ public void init(Map<String, Object> params) {
8181
}
8282
}
8383

84-
private Map<Address, Long> getServerToLastBackupTs(List<BackupInfo> backups) throws IOException {
84+
private Map<Address, Long> getServerToNewestBackupTs(List<BackupInfo> backups)
85+
throws IOException {
8586
if (LOG.isDebugEnabled()) {
8687
LOG.debug(
87-
"Cleaning WALs if they are older than the latest backups. "
88+
"Cleaning WALs if they are older than the newest backups. "
8889
+ "Checking WALs against {} backups: {}",
8990
backups.size(),
9091
backups.stream().map(BackupInfo::getBackupId).sorted().collect(Collectors.joining(", ")));
9192
}
92-
Map<Address, Long> serverAddressToLastBackupMap = new HashMap<>();
93+
Map<Address, Long> serverAddressToNewestBackupMap = new HashMap<>();
9394

9495
Map<TableName, Long> tableNameBackupInfoMap = new HashMap<>();
9596
for (BackupInfo backupInfo : backups) {
@@ -99,19 +100,20 @@ private Map<Address, Long> getServerToLastBackupTs(List<BackupInfo> backups) thr
99100
tableNameBackupInfoMap.put(table, backupInfo.getStartTs());
100101
for (Map.Entry<String, Long> entry : backupInfo.getTableSetTimestampMap().get(table)
101102
.entrySet()) {
102-
serverAddressToLastBackupMap.put(Address.fromString(entry.getKey()), entry.getValue());
103+
serverAddressToNewestBackupMap.put(Address.fromString(entry.getKey()),
104+
entry.getValue());
103105
}
104106
}
105107
}
106108
}
107109

108110
if (LOG.isDebugEnabled()) {
109-
for (Map.Entry<Address, Long> entry : serverAddressToLastBackupMap.entrySet()) {
110-
LOG.debug("Server: {}, Last Backup: {}", entry.getKey().getHostName(), entry.getValue());
111+
for (Map.Entry<Address, Long> entry : serverAddressToNewestBackupMap.entrySet()) {
112+
LOG.debug("Server: {}, Newest Backup: {}", entry.getKey().getHostName(), entry.getValue());
111113
}
112114
}
113115

114-
return serverAddressToLastBackupMap;
116+
return serverAddressToNewestBackupMap;
115117
}
116118

117119
@Override
@@ -126,18 +128,18 @@ public Iterable<FileStatus> getDeletableFiles(Iterable<FileStatus> files) {
126128
return files;
127129
}
128130

129-
Map<Address, Long> addressToLastBackupMap;
131+
Map<Address, Long> addressToNewestBackupMap;
130132
try {
131133
try (BackupManager backupManager = new BackupManager(conn, getConf())) {
132-
addressToLastBackupMap = getServerToLastBackupTs(backupManager.getBackupHistory(true));
134+
addressToNewestBackupMap = getServerToNewestBackupTs(backupManager.getBackupHistory(true));
133135
}
134136
} catch (IOException ex) {
135137
LOG.error("Failed to analyse backup history with exception: {}. Retaining all logs",
136138
ex.getMessage(), ex);
137139
return Collections.emptyList();
138140
}
139141
for (FileStatus file : files) {
140-
if (canDeleteFile(addressToLastBackupMap, file.getPath())) {
142+
if (canDeleteFile(addressToNewestBackupMap, file.getPath())) {
141143
filteredFiles.add(file);
142144
}
143145
}
@@ -172,7 +174,7 @@ public boolean isStopped() {
172174
return this.stopped;
173175
}
174176

175-
protected static boolean canDeleteFile(Map<Address, Long> addressToLastBackupMap, Path path) {
177+
protected static boolean canDeleteFile(Map<Address, Long> addressToNewestBackupMap, Path path) {
176178
if (isHMasterWAL(path)) {
177179
return true;
178180
}
@@ -188,15 +190,15 @@ protected static boolean canDeleteFile(Map<Address, Long> addressToLastBackupMap
188190
Address walServerAddress = Address.fromString(hostname);
189191
long walTimestamp = AbstractFSWALProvider.getTimestamp(path.getName());
190192

191-
if (!addressToLastBackupMap.containsKey(walServerAddress)) {
193+
if (!addressToNewestBackupMap.containsKey(walServerAddress)) {
192194
if (LOG.isDebugEnabled()) {
193195
LOG.debug("No backup found for server: {}. Deleting file: {}",
194196
walServerAddress.getHostName(), path);
195197
}
196198
return true;
197199
}
198200

199-
Long lastBackupTs = addressToLastBackupMap.get(walServerAddress);
201+
Long lastBackupTs = addressToNewestBackupMap.get(walServerAddress);
200202
if (lastBackupTs >= walTimestamp) {
201203
if (LOG.isDebugEnabled()) {
202204
LOG.debug(

0 commit comments

Comments
 (0)