use of org.apache.hadoop.hdfs.protocol.LayoutVersion.LayoutFeature in project hadoop by apache.
the class TestLayoutVersion method testNameNodeFeatureMinimumCompatibleLayoutVersions.
/**
* Tests expected values for minimum compatible layout version in NameNode
* features. TRUNCATE, APPEND_NEW_BLOCK and QUOTA_BY_STORAGE_TYPE are all
* features that launched in the same release. TRUNCATE was added first, so
* we expect all 3 features to have a minimum compatible layout version equal
* to TRUNCATE's layout version. All features older than that existed prior
* to the concept of a minimum compatible layout version, so for each one, the
* minimum compatible layout version must be equal to itself.
*/
@Test
public void testNameNodeFeatureMinimumCompatibleLayoutVersions() {
int baseLV = NameNodeLayoutVersion.Feature.TRUNCATE.getInfo().getLayoutVersion();
EnumSet<NameNodeLayoutVersion.Feature> compatibleFeatures = EnumSet.of(NameNodeLayoutVersion.Feature.TRUNCATE, NameNodeLayoutVersion.Feature.APPEND_NEW_BLOCK, NameNodeLayoutVersion.Feature.QUOTA_BY_STORAGE_TYPE, NameNodeLayoutVersion.Feature.ERASURE_CODING);
for (LayoutFeature f : compatibleFeatures) {
assertEquals(String.format("Expected minimum compatible layout version " + "%d for feature %s.", baseLV, f), baseLV, f.getInfo().getMinimumCompatibleLayoutVersion());
}
List<LayoutFeature> features = new ArrayList<>();
features.addAll(EnumSet.allOf(LayoutVersion.Feature.class));
features.addAll(EnumSet.allOf(NameNodeLayoutVersion.Feature.class));
for (LayoutFeature f : features) {
if (!compatibleFeatures.contains(f)) {
assertEquals(String.format("Expected feature %s to have minimum " + "compatible layout version set to itself.", f), f.getInfo().getLayoutVersion(), f.getInfo().getMinimumCompatibleLayoutVersion());
}
}
}
use of org.apache.hadoop.hdfs.protocol.LayoutVersion.LayoutFeature in project hadoop by apache.
the class TestLayoutVersion method testNameNodeFeature.
/**
* Test to make sure NameNode.Feature support previous features
*/
@Test
public void testNameNodeFeature() {
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());
}
use of org.apache.hadoop.hdfs.protocol.LayoutVersion.LayoutFeature in project hadoop by apache.
the class TestLayoutVersion method testNameNodeFeatureMinimumCompatibleLayoutVersionOutOfOrder.
/**
* Tests that attempting to add a new NameNode feature out of order with
* respect to minimum compatible layout version will fail fast.
*/
@Test(expected = AssertionError.class)
public void testNameNodeFeatureMinimumCompatibleLayoutVersionOutOfOrder() {
FeatureInfo ancestorF = LayoutVersion.Feature.RESERVED_REL2_4_0.getInfo();
LayoutFeature f = mock(LayoutFeature.class);
when(f.getInfo()).thenReturn(new FeatureInfo(ancestorF.getLayoutVersion() - 1, ancestorF.getLayoutVersion(), ancestorF.getMinimumCompatibleLayoutVersion() + 1, "Invalid feature.", false));
Map<Integer, SortedSet<LayoutFeature>> features = new HashMap<>();
LayoutVersion.updateMap(features, LayoutVersion.Feature.values());
LayoutVersion.updateMap(features, new LayoutFeature[] { f });
}
use of org.apache.hadoop.hdfs.protocol.LayoutVersion.LayoutFeature in project hadoop by apache.
the class TestLayoutVersion method validateFeatureList.
/**
* Given feature {@code f}, ensures the layout version of that feature
* supports all the features supported by it's ancestor.
*/
private void validateFeatureList(LayoutFeature f) {
final FeatureInfo info = f.getInfo();
int lv = info.getLayoutVersion();
int ancestorLV = info.getAncestorLayoutVersion();
SortedSet<LayoutFeature> ancestorSet = NameNodeLayoutVersion.getFeatures(ancestorLV);
assertNotNull(ancestorSet);
for (LayoutFeature feature : ancestorSet) {
assertTrue("LV " + lv + " does nto support " + feature + " supported by the ancestor LV " + info.getAncestorLayoutVersion(), NameNodeLayoutVersion.supports(feature, lv));
}
}
use of org.apache.hadoop.hdfs.protocol.LayoutVersion.LayoutFeature in project hadoop by apache.
the class TestLayoutVersion method testDataNodeFeature.
/**
* Test to make sure DataNode.Feature support previous features
*/
@Test
public void testDataNodeFeature() {
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());
}
Aggregations