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:
Tsz-wo Sze 2014-02-19 21:40:42 +00:00
parent 72c214c89b
commit d69985d90b
6 changed files with 35 additions and 15 deletions

View File

@ -49,3 +49,6 @@ HDFS-5535 subtasks:
HDFS-5966. Fix rollback of rolling upgrade in NameNode HA setup. (jing9
via szetszwo)
HDFS-5974. Fix compilation error, NameNodeLayoutVersion and
DataNodeLayoutVersion after merge from trunk. (szetszwo)

View File

@ -44,7 +44,6 @@ import org.apache.hadoop.classification.InterfaceAudience;
*/
@InterfaceAudience.Private
public class LayoutVersion {
/**
* 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
@ -279,12 +278,15 @@ public class LayoutVersion {
/**
* Get the current layout version
*/
public static int getCurrentLayoutVersion(
Map<Integer, SortedSet<LayoutFeature>> map, LayoutFeature[] values) {
for (int i = values.length -1; i >= 0; i--) {
final FeatureInfo info = values[i].getInfo();
public static int getCurrentLayoutVersion(LayoutFeature[] features) {
return getLastNonReservedFeature(features).getInfo().getLayoutVersion();
}
static LayoutFeature getLastNonReservedFeature(LayoutFeature[] features) {
for (int i = features.length -1; i >= 0; i--) {
final FeatureInfo info = features[i].getInfo();
if (!info.isReservedForOldRelease()) {
return info.getLayoutVersion();
return features[i];
}
}
throw new AssertionError("All layout versions are reserved.");

View File

@ -33,7 +33,7 @@ public class DataNodeLayoutVersion {
new HashMap<Integer, SortedSet<LayoutFeature>>();
public static final int CURRENT_LAYOUT_VERSION
= LayoutVersion.getCurrentLayoutVersion(FEATURES, Feature.values());
= LayoutVersion.getCurrentLayoutVersion(Feature.values());
static{
LayoutVersion.updateMap(FEATURES, LayoutVersion.Feature.values());
@ -62,7 +62,7 @@ public class DataNodeLayoutVersion {
* </ul>
*/
public static enum Feature implements LayoutFeature {
FIRST_LAYOUT(-52, "First datenode layout");
FIRST_LAYOUT(-55, -53, "First datenode layout", false);
private final FeatureInfo info;

View File

@ -93,6 +93,7 @@ import org.apache.hadoop.hdfs.protocol.CachePoolInfo;
import org.apache.hadoop.hdfs.protocol.ClientProtocol;
import org.apache.hadoop.hdfs.protocol.HdfsConstants;
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.protocolPB.PBHelper;
import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier;
@ -319,7 +320,7 @@ public abstract class FSEditLogOp {
private static List<AclEntry> read(DataInputStream in, int logVersion)
throws IOException {
if (!LayoutVersion.supports(Feature.EXTENDED_ACL, logVersion)) {
if (!NameNodeLayoutVersion.supports(Feature.EXTENDED_ACL, logVersion)) {
return null;
}

View File

@ -34,7 +34,7 @@ public class NameNodeLayoutVersion {
= new HashMap<Integer, SortedSet<LayoutFeature>>();
public static final int CURRENT_LAYOUT_VERSION
= LayoutVersion.getCurrentLayoutVersion(FEATURES, Feature.values());
= LayoutVersion.getCurrentLayoutVersion(Feature.values());
static {
LayoutVersion.updateMap(FEATURES, LayoutVersion.Feature.values());
@ -63,7 +63,7 @@ public class NameNodeLayoutVersion {
* </ul>
*/
public static enum Feature implements LayoutFeature {
ROLLING_UPGRADE(-52, "Support rolling upgrade");
ROLLING_UPGRADE(-55, -53, "Support rolling upgrade", false);
private final FeatureInfo info;

View File

@ -19,6 +19,7 @@ package org.apache.hadoop.hdfs.protocol;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import java.util.SortedSet;
@ -33,6 +34,13 @@ import org.junit.Test;
* Test for {@link LayoutVersion}
*/
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
@ -77,8 +85,11 @@ public class TestLayoutVersion {
*/
@Test
public void testNameNodeFeature() {
assertTrue(NameNodeLayoutVersion.supports(LayoutVersion.Feature.CACHING,
NameNodeLayoutVersion.Feature.ROLLING_UPGRADE.getInfo().getLayoutVersion()));
final LayoutFeature first = NameNodeLayoutVersion.Feature.ROLLING_UPGRADE;
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 class TestLayoutVersion {
*/
@Test
public void testDataNodeFeature() {
assertTrue(DataNodeLayoutVersion.supports(LayoutVersion.Feature.CACHING,
DataNodeLayoutVersion.Feature.FIRST_LAYOUT.getInfo().getLayoutVersion()));
final LayoutFeature first = DataNodeLayoutVersion.Feature.FIRST_LAYOUT;
assertTrue(DataNodeLayoutVersion.supports(LAST_NON_RESERVED_COMMON_FEATURE,
first.getInfo().getLayoutVersion()));
assertEquals(LAST_COMMON_FEATURE.getInfo().getLayoutVersion() - 1,
first.getInfo().getLayoutVersion());
}
/**