diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 7e6370a6646..c463f12af0b 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -1205,6 +1205,8 @@ Release 2.7.2 - UNRELEASED HDFS-8852. HDFS architecture documentation of version 2.x is outdated about append write support. (Ajith S via aajisaka) + HDFS-8867. Enable optimized block reports. (Daryn Sharp via jing9) + Release 2.7.1 - 2015-07-06 INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/protocol/NamespaceInfo.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/protocol/NamespaceInfo.java index dfdf449e7d3..90d0aacc4fc 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/protocol/NamespaceInfo.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/protocol/NamespaceInfo.java @@ -47,18 +47,27 @@ public class NamespaceInfo extends StorageInfo { // only authoritative on the server-side to determine advertisement to // clients. enum will update the supported values - private static long CAPABILITIES_SUPPORTED = 0; + private static final long CAPABILITIES_SUPPORTED = getSupportedCapabilities(); + + private static long getSupportedCapabilities() { + long mask = 0; + for (Capability c : Capability.values()) { + if (c.supported) { + mask |= c.mask; + } + } + return mask; + } public enum Capability { UNKNOWN(false), STORAGE_BLOCK_REPORT_BUFFERS(true); // use optimized ByteString buffers + private final boolean supported; private final long mask; Capability(boolean isSupported) { + supported = isSupported; int bits = ordinal() - 1; mask = (bits < 0) ? 0 : (1L << bits); - if (isSupported) { - CAPABILITIES_SUPPORTED |= mask; - } } public long getMask() { return mask; diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/protocol/TestBlockListAsLongs.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/protocol/TestBlockListAsLongs.java index 9ead7656d07..bf293732ef7 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/protocol/TestBlockListAsLongs.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/protocol/TestBlockListAsLongs.java @@ -187,7 +187,14 @@ public class TestBlockListAsLongs { } assertTrue(reportReplicas.isEmpty()); } - + + @Test + public void testCapabilitiesInited() { + NamespaceInfo nsInfo = new NamespaceInfo(); + assertTrue( + nsInfo.isCapabilitySupported(Capability.STORAGE_BLOCK_REPORT_BUFFERS)); + } + @Test public void testDatanodeDetect() throws ServiceException, IOException { final AtomicReference request =