HDFS-7144. Fix findbugs warnings in RamDiskReplicaTracker. (Contributed by Tsz Wo Nicholas Sze)

This commit is contained in:
arp 2014-09-25 11:14:24 -07:00
parent e9edafc731
commit 364e60b169
3 changed files with 26 additions and 9 deletions

View File

@ -77,4 +77,7 @@
HDFS-6932. Balancer and Mover tools should ignore replicas on RAM_DISK. HDFS-6932. Balancer and Mover tools should ignore replicas on RAM_DISK.
(Xiaoyu Yao via Arpit Agarwal) (Xiaoyu Yao via Arpit Agarwal)
HDFS-7144. Fix findbugs warnings in RamDiskReplicaTracker. (szetszwo via
Arpit Agarwal)

View File

@ -40,6 +40,16 @@ public class RamDiskReplicaLruTracker extends RamDiskReplicaTracker {
private RamDiskReplicaLru(String bpid, long blockId, FsVolumeImpl ramDiskVolume) { private RamDiskReplicaLru(String bpid, long blockId, FsVolumeImpl ramDiskVolume) {
super(bpid, blockId, ramDiskVolume); super(bpid, blockId, ramDiskVolume);
} }
@Override
public int hashCode() {
return super.hashCode();
}
@Override
public boolean equals(Object other) {
return super.equals(other);
}
} }
/** /**

View File

@ -19,6 +19,9 @@
package org.apache.hadoop.hdfs.server.datanode.fsdataset.impl; package org.apache.hadoop.hdfs.server.datanode.fsdataset.impl;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
@ -31,6 +34,7 @@ import java.io.File;
@InterfaceAudience.Private @InterfaceAudience.Private
@InterfaceStability.Unstable @InterfaceStability.Unstable
public abstract class RamDiskReplicaTracker { public abstract class RamDiskReplicaTracker {
static final Log LOG = LogFactory.getLog(RamDiskReplicaTracker.class);
FsDatasetImpl fsDataset; FsDatasetImpl fsDataset;
@ -117,18 +121,18 @@ public abstract class RamDiskReplicaTracker {
// Delete the saved meta and block files. Failure to delete can be // Delete the saved meta and block files. Failure to delete can be
// ignored, the directory scanner will retry the deletion later. // ignored, the directory scanner will retry the deletion later.
void deleteSavedFiles() { void deleteSavedFiles() {
try { if (savedBlockFile != null) {
if (savedBlockFile != null) { if (!savedBlockFile.delete()) {
savedBlockFile.delete(); LOG.warn("Failed to delete block file " + savedBlockFile);
savedBlockFile = null;
} }
savedBlockFile = null;
}
if (savedMetaFile != null) { if (savedMetaFile != null) {
savedMetaFile.delete(); if (!savedMetaFile.delete()) {
savedMetaFile = null; LOG.warn("Failed to delete meta file " + savedMetaFile);
} }
} catch (Throwable t) { savedMetaFile = null;
// Ignore any exceptions.
} }
} }