|
@@ -292,6 +292,8 @@ public interface HdfsServerConstants {
|
|
|
/** Temporary replica: created for replication and relocation only. */
|
|
|
TEMPORARY(4);
|
|
|
|
|
|
+ private static final ReplicaState[] cachedValues = ReplicaState.values();
|
|
|
+
|
|
|
private final int value;
|
|
|
|
|
|
ReplicaState(int v) {
|
|
@@ -303,12 +305,12 @@ public interface HdfsServerConstants {
|
|
|
}
|
|
|
|
|
|
public static ReplicaState getState(int v) {
|
|
|
- return ReplicaState.values()[v];
|
|
|
+ return cachedValues[v];
|
|
|
}
|
|
|
|
|
|
/** Read from in */
|
|
|
public static ReplicaState read(DataInput in) throws IOException {
|
|
|
- return values()[in.readByte()];
|
|
|
+ return cachedValues[in.readByte()];
|
|
|
}
|
|
|
|
|
|
/** Write to out */
|