Search in sources :

Example 1 with FeatureInfo

use of org.apache.hadoop.hdfs.protocol.LayoutVersion.FeatureInfo 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 });
}
Also used : HashMap(java.util.HashMap) FeatureInfo(org.apache.hadoop.hdfs.protocol.LayoutVersion.FeatureInfo) LayoutFeature(org.apache.hadoop.hdfs.protocol.LayoutVersion.LayoutFeature) SortedSet(java.util.SortedSet) Test(org.junit.Test)

Example 2 with FeatureInfo

use of org.apache.hadoop.hdfs.protocol.LayoutVersion.FeatureInfo 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));
    }
}
Also used : FeatureInfo(org.apache.hadoop.hdfs.protocol.LayoutVersion.FeatureInfo) LayoutFeature(org.apache.hadoop.hdfs.protocol.LayoutVersion.LayoutFeature)

Aggregations

FeatureInfo (org.apache.hadoop.hdfs.protocol.LayoutVersion.FeatureInfo)2 LayoutFeature (org.apache.hadoop.hdfs.protocol.LayoutVersion.LayoutFeature)2 HashMap (java.util.HashMap)1 SortedSet (java.util.SortedSet)1 Test (org.junit.Test)1