Search in sources :

Example 11 with ServiceStateException

use of org.apache.hadoop.service.ServiceStateException in project hadoop by apache.

the class TestHistoryServerLeveldbStateStoreService method testCheckVersion.

@Test
public void testCheckVersion() throws IOException {
    HistoryServerLeveldbStateStoreService store = new HistoryServerLeveldbStateStoreService();
    store.init(conf);
    store.start();
    // default version
    Version defaultVersion = store.getCurrentVersion();
    assertEquals(defaultVersion, store.loadVersion());
    // compatible version
    Version compatibleVersion = Version.newInstance(defaultVersion.getMajorVersion(), defaultVersion.getMinorVersion() + 2);
    store.dbStoreVersion(compatibleVersion);
    assertEquals(compatibleVersion, store.loadVersion());
    store.close();
    store = new HistoryServerLeveldbStateStoreService();
    store.init(conf);
    store.start();
    // overwrite the compatible version
    assertEquals(defaultVersion, store.loadVersion());
    // incompatible version
    Version incompatibleVersion = Version.newInstance(defaultVersion.getMajorVersion() + 1, defaultVersion.getMinorVersion());
    store.dbStoreVersion(incompatibleVersion);
    store.close();
    store = new HistoryServerLeveldbStateStoreService();
    try {
        store.init(conf);
        store.start();
        fail("Incompatible version, should have thrown before here.");
    } catch (ServiceStateException e) {
        assertTrue("Exception message mismatch", e.getMessage().contains("Incompatible version for state:"));
    }
    store.close();
}
Also used : Version(org.apache.hadoop.yarn.server.records.Version) ServiceStateException(org.apache.hadoop.service.ServiceStateException) Test(org.junit.Test)

Aggregations

ServiceStateException (org.apache.hadoop.service.ServiceStateException)11 Test (org.junit.Test)9 Version (org.apache.hadoop.yarn.server.records.Version)7 Configuration (org.apache.hadoop.conf.Configuration)5 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)3 File (java.io.File)2 IOException (java.io.IOException)2 Path (org.apache.hadoop.fs.Path)2 DataOutputBuffer (org.apache.hadoop.io.DataOutputBuffer)2 Text (org.apache.hadoop.io.Text)2 Token (org.apache.hadoop.security.token.Token)2 JvmPauseMonitor (org.apache.hadoop.util.JvmPauseMonitor)2 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)2 ApplicationInitializationContext (org.apache.hadoop.yarn.server.api.ApplicationInitializationContext)2 JobTokenIdentifier (org.apache.hadoop.mapreduce.security.token.JobTokenIdentifier)1 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)1 JobTokenIdentifier (org.apache.tez.common.security.JobTokenIdentifier)1 ACL (org.apache.zookeeper.data.ACL)1