HBASE-4591 TTL for old HLogs should be calculated from last modification time.

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1188390 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nicolas Spiegelberg 2011-10-24 21:24:00 +00:00
parent 7d8b58c361
commit a165e6cd59
2 changed files with 10 additions and 6 deletions

View File

@ -393,6 +393,7 @@ Release 0.92.0 - Unreleased
configurations need to be done as integers (dhruba)
HBASE-4647 RAT finds about 40 files missing licenses
HBASE-4642 Add Apache License Header
HBASE-4591 TTL for old HLogs should be calculated from last modification time.
TESTS
HBASE-4450 test for number of blocks read: to serve as baseline for expected

View File

@ -19,6 +19,9 @@
*/
package org.apache.hadoop.hbase.master;
import java.io.IOException;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.conf.Configuration;
import org.apache.commons.logging.Log;
@ -39,13 +42,13 @@ public class TimeToLiveLogCleaner implements LogCleanerDelegate {
public boolean isLogDeletable(Path filePath) {
long time = 0;
long currentTime = System.currentTimeMillis();
String[] parts = filePath.getName().split("\\.");
try {
time = Long.parseLong(parts[parts.length-1]);
} catch (NumberFormatException e) {
LOG.error("Unable to parse the timestamp in " + filePath.getName() +
", deleting it since it's invalid and may not be a hlog", e);
return true;
FileStatus fStat = filePath.getFileSystem(conf).getFileStatus(filePath);
time = fStat.getModificationTime();
} catch (IOException e) {
LOG.error("Unable to get modification time of file " + filePath.getName() +
", not deleting it.", e);
return false;
}
long life = currentTime - time;
if (life < 0) {