@@ -81,15 +81,16 @@ public void init(Map<String, Object> params) {
81
81
}
82
82
}
83
83
84
- private Map <Address , Long > getServerToLastBackupTs (List <BackupInfo > backups ) throws IOException {
84
+ private Map <Address , Long > getServerToNewestBackupTs (List <BackupInfo > backups )
85
+ throws IOException {
85
86
if (LOG .isDebugEnabled ()) {
86
87
LOG .debug (
87
- "Cleaning WALs if they are older than the latest backups. "
88
+ "Cleaning WALs if they are older than the newest backups. "
88
89
+ "Checking WALs against {} backups: {}" ,
89
90
backups .size (),
90
91
backups .stream ().map (BackupInfo ::getBackupId ).sorted ().collect (Collectors .joining (", " )));
91
92
}
92
- Map <Address , Long > serverAddressToLastBackupMap = new HashMap <>();
93
+ Map <Address , Long > serverAddressToNewestBackupMap = new HashMap <>();
93
94
94
95
Map <TableName , Long > tableNameBackupInfoMap = new HashMap <>();
95
96
for (BackupInfo backupInfo : backups ) {
@@ -99,19 +100,20 @@ private Map<Address, Long> getServerToLastBackupTs(List<BackupInfo> backups) thr
99
100
tableNameBackupInfoMap .put (table , backupInfo .getStartTs ());
100
101
for (Map .Entry <String , Long > entry : backupInfo .getTableSetTimestampMap ().get (table )
101
102
.entrySet ()) {
102
- serverAddressToLastBackupMap .put (Address .fromString (entry .getKey ()), entry .getValue ());
103
+ serverAddressToNewestBackupMap .put (Address .fromString (entry .getKey ()),
104
+ entry .getValue ());
103
105
}
104
106
}
105
107
}
106
108
}
107
109
108
110
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 ());
111
113
}
112
114
}
113
115
114
- return serverAddressToLastBackupMap ;
116
+ return serverAddressToNewestBackupMap ;
115
117
}
116
118
117
119
@ Override
@@ -126,18 +128,18 @@ public Iterable<FileStatus> getDeletableFiles(Iterable<FileStatus> files) {
126
128
return files ;
127
129
}
128
130
129
- Map <Address , Long > addressToLastBackupMap ;
131
+ Map <Address , Long > addressToNewestBackupMap ;
130
132
try {
131
133
try (BackupManager backupManager = new BackupManager (conn , getConf ())) {
132
- addressToLastBackupMap = getServerToLastBackupTs (backupManager .getBackupHistory (true ));
134
+ addressToNewestBackupMap = getServerToNewestBackupTs (backupManager .getBackupHistory (true ));
133
135
}
134
136
} catch (IOException ex ) {
135
137
LOG .error ("Failed to analyse backup history with exception: {}. Retaining all logs" ,
136
138
ex .getMessage (), ex );
137
139
return Collections .emptyList ();
138
140
}
139
141
for (FileStatus file : files ) {
140
- if (canDeleteFile (addressToLastBackupMap , file .getPath ())) {
142
+ if (canDeleteFile (addressToNewestBackupMap , file .getPath ())) {
141
143
filteredFiles .add (file );
142
144
}
143
145
}
@@ -172,7 +174,7 @@ public boolean isStopped() {
172
174
return this .stopped ;
173
175
}
174
176
175
- protected static boolean canDeleteFile (Map <Address , Long > addressToLastBackupMap , Path path ) {
177
+ protected static boolean canDeleteFile (Map <Address , Long > addressToNewestBackupMap , Path path ) {
176
178
if (isHMasterWAL (path )) {
177
179
return true ;
178
180
}
@@ -188,15 +190,15 @@ protected static boolean canDeleteFile(Map<Address, Long> addressToLastBackupMap
188
190
Address walServerAddress = Address .fromString (hostname );
189
191
long walTimestamp = AbstractFSWALProvider .getTimestamp (path .getName ());
190
192
191
- if (!addressToLastBackupMap .containsKey (walServerAddress )) {
193
+ if (!addressToNewestBackupMap .containsKey (walServerAddress )) {
192
194
if (LOG .isDebugEnabled ()) {
193
195
LOG .debug ("No backup found for server: {}. Deleting file: {}" ,
194
196
walServerAddress .getHostName (), path );
195
197
}
196
198
return true ;
197
199
}
198
200
199
- Long lastBackupTs = addressToLastBackupMap .get (walServerAddress );
201
+ Long lastBackupTs = addressToNewestBackupMap .get (walServerAddress );
200
202
if (lastBackupTs >= walTimestamp ) {
201
203
if (LOG .isDebugEnabled ()) {
202
204
LOG .debug (
0 commit comments