You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-commits@hadoop.apache.org by ji...@apache.org on 2014/01/27 20:05:05 UTC
svn commit: r1561796 - in
/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs: CHANGES.txt
src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOpCodes.java
Author: jing9
Date: Mon Jan 27 19:05:04 2014
New Revision: 1561796
URL: http://svn.apache.org/r1561796
Log:
HDFS-5781. Merge change r1561788 from trunk.
Modified:
hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOpCodes.java
Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1561796&r1=1561795&r2=1561796&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original)
+++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Mon Jan 27 19:05:04 2014
@@ -215,6 +215,9 @@ Release 2.4.0 - UNRELEASED
HDFS-5788. listLocatedStatus response can be very large. (Nathan Roberts
via kihwal)
+ HDFS-5781. Use an array to record the mapping between FSEditLogOpCode and
+ the corresponding byte value. (jing9)
+
OPTIMIZATIONS
HDFS-5239. Allow FSNamesystem lock fairness to be configurable (daryn)
Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOpCodes.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOpCodes.java?rev=1561796&r1=1561795&r2=1561796&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOpCodes.java (original)
+++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOpCodes.java Mon Jan 27 19:05:04 2014
@@ -68,7 +68,7 @@ public enum FSEditLogOpCodes {
OP_REMOVE_CACHE_POOL ((byte) 38),
OP_MODIFY_CACHE_DIRECTIVE ((byte) 39),
- // Note that fromByte(..) depends on OP_INVALID being at the last position.
+ // Note that the current range of the valid OP code is 0~127
OP_INVALID ((byte) -1);
private final byte opCode;
@@ -91,7 +91,22 @@ public enum FSEditLogOpCodes {
return opCode;
}
- private static final FSEditLogOpCodes[] VALUES = FSEditLogOpCodes.values();
+ private static FSEditLogOpCodes[] VALUES;
+
+ static {
+ byte max = 0;
+ for (FSEditLogOpCodes code : FSEditLogOpCodes.values()) {
+ if (code.getOpCode() > max) {
+ max = code.getOpCode();
+ }
+ }
+ VALUES = new FSEditLogOpCodes[max + 1];
+ for (FSEditLogOpCodes code : FSEditLogOpCodes.values()) {
+ if (code.getOpCode() >= 0) {
+ VALUES[code.getOpCode()] = code;
+ }
+ }
+ }
/**
* Converts byte to FSEditLogOpCodes enum value
@@ -100,12 +115,9 @@ public enum FSEditLogOpCodes {
* @return enum with byte value of opCode
*/
public static FSEditLogOpCodes fromByte(byte opCode) {
- if (opCode == -1) {
- return OP_INVALID;
- }
- if (opCode >= 0 && opCode < OP_INVALID.ordinal()) {
+ if (opCode >= 0 && opCode < VALUES.length) {
return VALUES[opCode];
}
- return null;
+ return opCode == -1 ? OP_INVALID : null;
}
}