svn merge -c 1579670 from trunk for HDFS-6129. When a replica is not found for deletion, do not throw an exception.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1579671 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d955e84f39
commit
f94a9c0bd0
|
@ -180,6 +180,9 @@ Release 2.4.0 - UNRELEASED
|
||||||
HDFS-6123. Do not log stack trace for ReplicaAlreadyExistsException and
|
HDFS-6123. Do not log stack trace for ReplicaAlreadyExistsException and
|
||||||
SocketTimeoutException. (szetszwo)
|
SocketTimeoutException. (szetszwo)
|
||||||
|
|
||||||
|
HDFS-6129. When a replica is not found for deletion, do not throw an
|
||||||
|
exception. (szetszwo)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
HDFS-5790. LeaseManager.findPath is very slow when many leases need recovery
|
HDFS-5790. LeaseManager.findPath is very slow when many leases need recovery
|
||||||
|
|
|
@ -1152,43 +1152,39 @@ class FsDatasetImpl implements FsDatasetSpi<FsVolumeImpl> {
|
||||||
*/
|
*/
|
||||||
@Override // FsDatasetSpi
|
@Override // FsDatasetSpi
|
||||||
public void invalidate(String bpid, Block invalidBlks[]) throws IOException {
|
public void invalidate(String bpid, Block invalidBlks[]) throws IOException {
|
||||||
boolean error = false;
|
final List<String> errors = new ArrayList<String>();
|
||||||
for (int i = 0; i < invalidBlks.length; i++) {
|
for (int i = 0; i < invalidBlks.length; i++) {
|
||||||
final File f;
|
final File f;
|
||||||
final FsVolumeImpl v;
|
final FsVolumeImpl v;
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
f = getFile(bpid, invalidBlks[i].getBlockId());
|
final ReplicaInfo info = volumeMap.get(bpid, invalidBlks[i]);
|
||||||
ReplicaInfo info = volumeMap.get(bpid, invalidBlks[i]);
|
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
LOG.warn("Failed to delete replica " + invalidBlks[i]
|
// It is okay if the block is not found -- it may be deleted earlier.
|
||||||
|
LOG.info("Failed to delete replica " + invalidBlks[i]
|
||||||
+ ": ReplicaInfo not found.");
|
+ ": ReplicaInfo not found.");
|
||||||
error = true;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (info.getGenerationStamp() != invalidBlks[i].getGenerationStamp()) {
|
if (info.getGenerationStamp() != invalidBlks[i].getGenerationStamp()) {
|
||||||
LOG.warn("Failed to delete replica " + invalidBlks[i]
|
errors.add("Failed to delete replica " + invalidBlks[i]
|
||||||
+ ": GenerationStamp not matched, info=" + info);
|
+ ": GenerationStamp not matched, info=" + info);
|
||||||
error = true;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
f = info.getBlockFile();
|
||||||
v = (FsVolumeImpl)info.getVolume();
|
v = (FsVolumeImpl)info.getVolume();
|
||||||
if (f == null) {
|
if (f == null) {
|
||||||
LOG.warn("Failed to delete replica " + invalidBlks[i]
|
errors.add("Failed to delete replica " + invalidBlks[i]
|
||||||
+ ": File not found, volume=" + v);
|
+ ": File not found, volume=" + v);
|
||||||
error = true;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (v == null) {
|
if (v == null) {
|
||||||
LOG.warn("Failed to delete replica " + invalidBlks[i]
|
errors.add("Failed to delete replica " + invalidBlks[i]
|
||||||
+ ". No volume for this replica, file=" + f + ".");
|
+ ". No volume for this replica, file=" + f);
|
||||||
error = true;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
File parent = f.getParentFile();
|
File parent = f.getParentFile();
|
||||||
if (parent == null) {
|
if (parent == null) {
|
||||||
LOG.warn("Failed to delete replica " + invalidBlks[i]
|
errors.add("Failed to delete replica " + invalidBlks[i]
|
||||||
+ ". Parent not found for file " + f + ".");
|
+ ". Parent not found for file " + f);
|
||||||
error = true;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ReplicaState replicaState = info.getState();
|
ReplicaState replicaState = info.getState();
|
||||||
|
@ -1210,8 +1206,14 @@ class FsDatasetImpl implements FsDatasetSpi<FsVolumeImpl> {
|
||||||
new ExtendedBlock(bpid, invalidBlks[i]),
|
new ExtendedBlock(bpid, invalidBlks[i]),
|
||||||
dataStorage.getTrashDirectoryForBlockFile(bpid, f));
|
dataStorage.getTrashDirectoryForBlockFile(bpid, f));
|
||||||
}
|
}
|
||||||
if (error) {
|
if (!errors.isEmpty()) {
|
||||||
throw new IOException("Error in deleting blocks.");
|
StringBuilder b = new StringBuilder("Failed to delete ")
|
||||||
|
.append(errors.size()).append(" (out of ").append(invalidBlks.length)
|
||||||
|
.append(") replica(s):");
|
||||||
|
for(int i = 0; i < errors.size(); i++) {
|
||||||
|
b.append("\n").append(i).append(") ").append(errors.get(i));
|
||||||
|
}
|
||||||
|
throw new IOException(b.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue