HDFS-5974. Fix compilation error, NameNodeLayoutVersion and DataNodeLayoutVersion after merge from trunk.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-5535@1569931 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
72c214c89b
commit
d69985d90b
@ -49,3 +49,6 @@ HDFS-5535 subtasks:
|
|||||||
|
|
||||||
HDFS-5966. Fix rollback of rolling upgrade in NameNode HA setup. (jing9
|
HDFS-5966. Fix rollback of rolling upgrade in NameNode HA setup. (jing9
|
||||||
via szetszwo)
|
via szetszwo)
|
||||||
|
|
||||||
|
HDFS-5974. Fix compilation error, NameNodeLayoutVersion and
|
||||||
|
DataNodeLayoutVersion after merge from trunk. (szetszwo)
|
||||||
|
@ -44,7 +44,6 @@
|
|||||||
*/
|
*/
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
public class LayoutVersion {
|
public class LayoutVersion {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Version in which HDFS-2991 was fixed. This bug caused OP_ADD to
|
* Version in which HDFS-2991 was fixed. This bug caused OP_ADD to
|
||||||
* sometimes be skipped for append() calls. If we see such a case when
|
* sometimes be skipped for append() calls. If we see such a case when
|
||||||
@ -279,12 +278,15 @@ public static boolean supports(Map<Integer, SortedSet<LayoutFeature>> map,
|
|||||||
/**
|
/**
|
||||||
* Get the current layout version
|
* Get the current layout version
|
||||||
*/
|
*/
|
||||||
public static int getCurrentLayoutVersion(
|
public static int getCurrentLayoutVersion(LayoutFeature[] features) {
|
||||||
Map<Integer, SortedSet<LayoutFeature>> map, LayoutFeature[] values) {
|
return getLastNonReservedFeature(features).getInfo().getLayoutVersion();
|
||||||
for (int i = values.length -1; i >= 0; i--) {
|
}
|
||||||
final FeatureInfo info = values[i].getInfo();
|
|
||||||
|
static LayoutFeature getLastNonReservedFeature(LayoutFeature[] features) {
|
||||||
|
for (int i = features.length -1; i >= 0; i--) {
|
||||||
|
final FeatureInfo info = features[i].getInfo();
|
||||||
if (!info.isReservedForOldRelease()) {
|
if (!info.isReservedForOldRelease()) {
|
||||||
return info.getLayoutVersion();
|
return features[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new AssertionError("All layout versions are reserved.");
|
throw new AssertionError("All layout versions are reserved.");
|
||||||
|
@ -33,7 +33,7 @@ public class DataNodeLayoutVersion {
|
|||||||
new HashMap<Integer, SortedSet<LayoutFeature>>();
|
new HashMap<Integer, SortedSet<LayoutFeature>>();
|
||||||
|
|
||||||
public static final int CURRENT_LAYOUT_VERSION
|
public static final int CURRENT_LAYOUT_VERSION
|
||||||
= LayoutVersion.getCurrentLayoutVersion(FEATURES, Feature.values());
|
= LayoutVersion.getCurrentLayoutVersion(Feature.values());
|
||||||
|
|
||||||
static{
|
static{
|
||||||
LayoutVersion.updateMap(FEATURES, LayoutVersion.Feature.values());
|
LayoutVersion.updateMap(FEATURES, LayoutVersion.Feature.values());
|
||||||
@ -62,7 +62,7 @@ public static boolean supports(final LayoutFeature f, final int lv) {
|
|||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
public static enum Feature implements LayoutFeature {
|
public static enum Feature implements LayoutFeature {
|
||||||
FIRST_LAYOUT(-52, "First datenode layout");
|
FIRST_LAYOUT(-55, -53, "First datenode layout", false);
|
||||||
|
|
||||||
private final FeatureInfo info;
|
private final FeatureInfo info;
|
||||||
|
|
||||||
|
@ -93,6 +93,7 @@
|
|||||||
import org.apache.hadoop.hdfs.protocol.ClientProtocol;
|
import org.apache.hadoop.hdfs.protocol.ClientProtocol;
|
||||||
import org.apache.hadoop.hdfs.protocol.HdfsConstants;
|
import org.apache.hadoop.hdfs.protocol.HdfsConstants;
|
||||||
import org.apache.hadoop.hdfs.protocol.LayoutVersion;
|
import org.apache.hadoop.hdfs.protocol.LayoutVersion;
|
||||||
|
import org.apache.hadoop.hdfs.protocol.LayoutVersion.Feature;
|
||||||
import org.apache.hadoop.hdfs.protocol.proto.AclProtos.AclEditLogProto;
|
import org.apache.hadoop.hdfs.protocol.proto.AclProtos.AclEditLogProto;
|
||||||
import org.apache.hadoop.hdfs.protocolPB.PBHelper;
|
import org.apache.hadoop.hdfs.protocolPB.PBHelper;
|
||||||
import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier;
|
import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier;
|
||||||
@ -319,7 +320,7 @@ private static final class AclEditLogUtil {
|
|||||||
|
|
||||||
private static List<AclEntry> read(DataInputStream in, int logVersion)
|
private static List<AclEntry> read(DataInputStream in, int logVersion)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
if (!LayoutVersion.supports(Feature.EXTENDED_ACL, logVersion)) {
|
if (!NameNodeLayoutVersion.supports(Feature.EXTENDED_ACL, logVersion)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ public class NameNodeLayoutVersion {
|
|||||||
= new HashMap<Integer, SortedSet<LayoutFeature>>();
|
= new HashMap<Integer, SortedSet<LayoutFeature>>();
|
||||||
|
|
||||||
public static final int CURRENT_LAYOUT_VERSION
|
public static final int CURRENT_LAYOUT_VERSION
|
||||||
= LayoutVersion.getCurrentLayoutVersion(FEATURES, Feature.values());
|
= LayoutVersion.getCurrentLayoutVersion(Feature.values());
|
||||||
|
|
||||||
static {
|
static {
|
||||||
LayoutVersion.updateMap(FEATURES, LayoutVersion.Feature.values());
|
LayoutVersion.updateMap(FEATURES, LayoutVersion.Feature.values());
|
||||||
@ -63,7 +63,7 @@ public static boolean supports(final LayoutFeature f, final int lv) {
|
|||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
public static enum Feature implements LayoutFeature {
|
public static enum Feature implements LayoutFeature {
|
||||||
ROLLING_UPGRADE(-52, "Support rolling upgrade");
|
ROLLING_UPGRADE(-55, -53, "Support rolling upgrade", false);
|
||||||
|
|
||||||
private final FeatureInfo info;
|
private final FeatureInfo info;
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
|
|
||||||
@ -33,6 +34,13 @@
|
|||||||
* Test for {@link LayoutVersion}
|
* Test for {@link LayoutVersion}
|
||||||
*/
|
*/
|
||||||
public class TestLayoutVersion {
|
public class TestLayoutVersion {
|
||||||
|
public static final LayoutFeature LAST_NON_RESERVED_COMMON_FEATURE;
|
||||||
|
public static final LayoutFeature LAST_COMMON_FEATURE;
|
||||||
|
static {
|
||||||
|
final Feature[] features = Feature.values();
|
||||||
|
LAST_COMMON_FEATURE = features[features.length - 1];
|
||||||
|
LAST_NON_RESERVED_COMMON_FEATURE = LayoutVersion.getLastNonReservedFeature(features);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests to make sure a given layout version supports all the
|
* Tests to make sure a given layout version supports all the
|
||||||
@ -77,8 +85,11 @@ public void testRelease1_2_0() {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testNameNodeFeature() {
|
public void testNameNodeFeature() {
|
||||||
assertTrue(NameNodeLayoutVersion.supports(LayoutVersion.Feature.CACHING,
|
final LayoutFeature first = NameNodeLayoutVersion.Feature.ROLLING_UPGRADE;
|
||||||
NameNodeLayoutVersion.Feature.ROLLING_UPGRADE.getInfo().getLayoutVersion()));
|
assertTrue(NameNodeLayoutVersion.supports(LAST_NON_RESERVED_COMMON_FEATURE,
|
||||||
|
first.getInfo().getLayoutVersion()));
|
||||||
|
assertEquals(LAST_COMMON_FEATURE.getInfo().getLayoutVersion() - 1,
|
||||||
|
first.getInfo().getLayoutVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -86,8 +97,11 @@ public void testNameNodeFeature() {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testDataNodeFeature() {
|
public void testDataNodeFeature() {
|
||||||
assertTrue(DataNodeLayoutVersion.supports(LayoutVersion.Feature.CACHING,
|
final LayoutFeature first = DataNodeLayoutVersion.Feature.FIRST_LAYOUT;
|
||||||
DataNodeLayoutVersion.Feature.FIRST_LAYOUT.getInfo().getLayoutVersion()));
|
assertTrue(DataNodeLayoutVersion.supports(LAST_NON_RESERVED_COMMON_FEATURE,
|
||||||
|
first.getInfo().getLayoutVersion()));
|
||||||
|
assertEquals(LAST_COMMON_FEATURE.getInfo().getLayoutVersion() - 1,
|
||||||
|
first.getInfo().getLayoutVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user