Browse Source

HDFS-13363. Record file path when FSDirAclOp throws AclException. Contributed by Gabor Bota.

Xiao Chen 7 years ago
parent
commit
e76c2aeb28

+ 10 - 0
hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/AclException.java

@@ -36,4 +36,14 @@ public class AclException extends IOException {
   public AclException(String message) {
   public AclException(String message) {
     super(message);
     super(message);
   }
   }
+
+  /**
+   * Creates a new AclException.
+   *
+   * @param message String message
+   * @param cause The cause of the exception
+   */
+  public AclException(String message, Throwable cause) {
+    super(message, cause);
+  }
 }
 }

+ 12 - 0
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirAclOp.java

@@ -53,6 +53,8 @@ class FSDirAclOp {
           existingAcl, aclSpec);
           existingAcl, aclSpec);
       AclStorage.updateINodeAcl(inode, newAcl, snapshotId);
       AclStorage.updateINodeAcl(inode, newAcl, snapshotId);
       fsd.getEditLog().logSetAcl(src, newAcl);
       fsd.getEditLog().logSetAcl(src, newAcl);
+    } catch (AclException e){
+      throw new AclException(e.getMessage() + " Path: " + src, e);
     } finally {
     } finally {
       fsd.writeUnlock();
       fsd.writeUnlock();
     }
     }
@@ -77,6 +79,8 @@ class FSDirAclOp {
         existingAcl, aclSpec);
         existingAcl, aclSpec);
       AclStorage.updateINodeAcl(inode, newAcl, snapshotId);
       AclStorage.updateINodeAcl(inode, newAcl, snapshotId);
       fsd.getEditLog().logSetAcl(src, newAcl);
       fsd.getEditLog().logSetAcl(src, newAcl);
+    } catch (AclException e){
+      throw new AclException(e.getMessage() + " Path: " + src, e);
     } finally {
     } finally {
       fsd.writeUnlock();
       fsd.writeUnlock();
     }
     }
@@ -100,6 +104,8 @@ class FSDirAclOp {
         existingAcl);
         existingAcl);
       AclStorage.updateINodeAcl(inode, newAcl, snapshotId);
       AclStorage.updateINodeAcl(inode, newAcl, snapshotId);
       fsd.getEditLog().logSetAcl(src, newAcl);
       fsd.getEditLog().logSetAcl(src, newAcl);
+    } catch (AclException e){
+      throw new AclException(e.getMessage() + " Path: " + src, e);
     } finally {
     } finally {
       fsd.writeUnlock();
       fsd.writeUnlock();
     }
     }
@@ -117,6 +123,8 @@ class FSDirAclOp {
       src = iip.getPath();
       src = iip.getPath();
       fsd.checkOwner(pc, iip);
       fsd.checkOwner(pc, iip);
       unprotectedRemoveAcl(fsd, iip);
       unprotectedRemoveAcl(fsd, iip);
+    } catch (AclException e){
+      throw new AclException(e.getMessage() + " Path: " + src, e);
     } finally {
     } finally {
       fsd.writeUnlock();
       fsd.writeUnlock();
     }
     }
@@ -136,6 +144,8 @@ class FSDirAclOp {
       fsd.checkOwner(pc, iip);
       fsd.checkOwner(pc, iip);
       List<AclEntry> newAcl = unprotectedSetAcl(fsd, iip, aclSpec, false);
       List<AclEntry> newAcl = unprotectedSetAcl(fsd, iip, aclSpec, false);
       fsd.getEditLog().logSetAcl(iip.getPath(), newAcl);
       fsd.getEditLog().logSetAcl(iip.getPath(), newAcl);
+    } catch (AclException e){
+      throw new AclException(e.getMessage() + " Path: " + src, e);
     } finally {
     } finally {
       fsd.writeUnlock();
       fsd.writeUnlock();
     }
     }
@@ -162,6 +172,8 @@ class FSDirAclOp {
           .stickyBit(fsPermission.getStickyBit())
           .stickyBit(fsPermission.getStickyBit())
           .setPermission(fsPermission)
           .setPermission(fsPermission)
           .addEntries(acl).build();
           .addEntries(acl).build();
+    } catch (AclException e){
+      throw new AclException(e.getMessage() + " Path: " + src, e);
     } finally {
     } finally {
       fsd.readUnlock();
       fsd.readUnlock();
     }
     }