From 02c549484a4fe6215c7f1a18d89389dbba6ea723 Mon Sep 17 00:00:00 2001 From: Xiao Chen Date: Thu, 16 Feb 2017 18:07:55 -0800 Subject: [PATCH] HDFS-11410. Use the cached instance when edit logging SetAclOp, SetXAttrOp and RemoveXAttrOp. --- .../hdfs/server/namenode/FSEditLog.java | 6 +++--- .../hdfs/server/namenode/FSEditLogOp.java | 21 ++++++++----------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java index 8454a46eeb..d3f4447c2c 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java @@ -1206,14 +1206,14 @@ void logFinalizeRollingUpgrade(long finalizeTime) { } void logSetAcl(String src, List entries) { - SetAclOp op = SetAclOp.getInstance(); + final SetAclOp op = SetAclOp.getInstance(cache.get()); op.src = src; op.aclEntries = entries; logEdit(op); } void logSetXAttrs(String src, List xAttrs, boolean toLogRpcIds) { - final SetXAttrOp op = SetXAttrOp.getInstance(); + final SetXAttrOp op = SetXAttrOp.getInstance(cache.get()); op.src = src; op.xAttrs = xAttrs; logRpcIds(op, toLogRpcIds); @@ -1221,7 +1221,7 @@ void logSetXAttrs(String src, List xAttrs, boolean toLogRpcIds) { } void logRemoveXAttrs(String src, List xAttrs, boolean toLogRpcIds) { - final RemoveXAttrOp op = RemoveXAttrOp.getInstance(); + final RemoveXAttrOp op = RemoveXAttrOp.getInstance(cache.get()); op.src = src; op.xAttrs = xAttrs; logRpcIds(op, toLogRpcIds); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java index a3285a948a..6293557630 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java @@ -3745,8 +3745,7 @@ public AddCacheDirectiveInfoOp() { } static AddCacheDirectiveInfoOp getInstance(OpInstanceCache cache) { - return (AddCacheDirectiveInfoOp) cache - .get(OP_ADD_CACHE_DIRECTIVE); + return (AddCacheDirectiveInfoOp) cache.get(OP_ADD_CACHE_DIRECTIVE); } @Override @@ -3816,8 +3815,7 @@ public ModifyCacheDirectiveInfoOp() { } static ModifyCacheDirectiveInfoOp getInstance(OpInstanceCache cache) { - return (ModifyCacheDirectiveInfoOp) cache - .get(OP_MODIFY_CACHE_DIRECTIVE); + return (ModifyCacheDirectiveInfoOp) cache.get(OP_MODIFY_CACHE_DIRECTIVE); } @Override @@ -3893,8 +3891,7 @@ public RemoveCacheDirectiveInfoOp() { } static RemoveCacheDirectiveInfoOp getInstance(OpInstanceCache cache) { - return (RemoveCacheDirectiveInfoOp) cache - .get(OP_REMOVE_CACHE_DIRECTIVE); + return (RemoveCacheDirectiveInfoOp) cache.get(OP_REMOVE_CACHE_DIRECTIVE); } @Override @@ -4146,8 +4143,8 @@ static class RemoveXAttrOp extends FSEditLogOp { super(OP_REMOVE_XATTR); } - static RemoveXAttrOp getInstance() { - return new RemoveXAttrOp(); + static RemoveXAttrOp getInstance(OpInstanceCache cache) { + return (RemoveXAttrOp) cache.get(OP_REMOVE_XATTR); } @Override @@ -4199,8 +4196,8 @@ static class SetXAttrOp extends FSEditLogOp { super(OP_SET_XATTR); } - static SetXAttrOp getInstance() { - return new SetXAttrOp(); + static SetXAttrOp getInstance(OpInstanceCache cache) { + return (SetXAttrOp) cache.get(OP_SET_XATTR); } @Override @@ -4252,8 +4249,8 @@ static class SetAclOp extends FSEditLogOp { super(OP_SET_ACL); } - static SetAclOp getInstance() { - return new SetAclOp(); + static SetAclOp getInstance(OpInstanceCache cache) { + return (SetAclOp) cache.get(OP_SET_ACL); } @Override