Search in sources :

Example 6 with ServiceStateException

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

the class TestLeveldbTimelineStore method testCheckVersion.

@Test
public void testCheckVersion() throws IOException {
    LeveldbTimelineStore dbStore = (LeveldbTimelineStore) store;
    // default version
    Version defaultVersion = dbStore.getCurrentVersion();
    Assert.assertEquals(defaultVersion, dbStore.loadVersion());
    // compatible version
    Version compatibleVersion = Version.newInstance(defaultVersion.getMajorVersion(), defaultVersion.getMinorVersion() + 2);
    dbStore.storeVersion(compatibleVersion);
    Assert.assertEquals(compatibleVersion, dbStore.loadVersion());
    restartTimelineStore();
    dbStore = (LeveldbTimelineStore) store;
    // overwrite the compatible version
    Assert.assertEquals(defaultVersion, dbStore.loadVersion());
    // incompatible version
    Version incompatibleVersion = Version.newInstance(defaultVersion.getMajorVersion() + 1, defaultVersion.getMinorVersion());
    dbStore.storeVersion(incompatibleVersion);
    try {
        restartTimelineStore();
        Assert.fail("Incompatible version, should expect fail here.");
    } catch (ServiceStateException e) {
        Assert.assertTrue("Exception message mismatch", e.getMessage().contains("Incompatible version for timeline store"));
    }
}
Also used : Version(org.apache.hadoop.yarn.server.records.Version) ServiceStateException(org.apache.hadoop.service.ServiceStateException) Test(org.junit.Test)

Example 7 with ServiceStateException

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

the class TestRollingLevelDBTimelineStore method testCheckVersion.

@Test
public void testCheckVersion() throws IOException {
    RollingLevelDBTimelineStore dbStore = (RollingLevelDBTimelineStore) store;
    // default version
    Version defaultVersion = dbStore.getCurrentVersion();
    Assert.assertEquals(defaultVersion, dbStore.loadVersion());
    // compatible version
    Version compatibleVersion = Version.newInstance(defaultVersion.getMajorVersion(), defaultVersion.getMinorVersion() + 2);
    dbStore.storeVersion(compatibleVersion);
    Assert.assertEquals(compatibleVersion, dbStore.loadVersion());
    restartTimelineStore();
    dbStore = (RollingLevelDBTimelineStore) store;
    // overwrite the compatible version
    Assert.assertEquals(defaultVersion, dbStore.loadVersion());
    // incompatible version
    Version incompatibleVersion = Version.newInstance(defaultVersion.getMajorVersion() + 1, defaultVersion.getMinorVersion());
    dbStore.storeVersion(incompatibleVersion);
    try {
        restartTimelineStore();
        Assert.fail("Incompatible version, should expect fail here.");
    } catch (ServiceStateException e) {
        Assert.assertTrue("Exception message mismatch", e.getMessage().contains("Incompatible version for timeline store"));
    }
}
Also used : Version(org.apache.hadoop.yarn.server.records.Version) ServiceStateException(org.apache.hadoop.service.ServiceStateException) Test(org.junit.Test)

Example 8 with ServiceStateException

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

the class TestScriptBasedNodeLabelsProvider method initilizeServiceFailTest.

private void initilizeServiceFailTest(String message, ScriptBasedNodeLabelsProvider nodeLabelsProvider) {
    try {
        nodeLabelsProvider.init(new Configuration());
        Assert.fail(message);
    } catch (ServiceStateException ex) {
        Assert.assertEquals("IOException was expected", IOException.class, ex.getCause().getClass());
    }
}
Also used : YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Configuration(org.apache.hadoop.conf.Configuration) ServiceStateException(org.apache.hadoop.service.ServiceStateException) IOException(java.io.IOException)

Example 9 with ServiceStateException

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

the class TestNMLeveldbStateStoreService method testCheckVersion.

@Test
public void testCheckVersion() throws IOException {
    // default version
    Version defaultVersion = stateStore.getCurrentVersion();
    Assert.assertEquals(defaultVersion, stateStore.loadVersion());
    // compatible version
    Version compatibleVersion = Version.newInstance(defaultVersion.getMajorVersion(), defaultVersion.getMinorVersion() + 2);
    stateStore.storeVersion(compatibleVersion);
    Assert.assertEquals(compatibleVersion, stateStore.loadVersion());
    restartStateStore();
    // overwrite the compatible version
    Assert.assertEquals(defaultVersion, stateStore.loadVersion());
    // incompatible version
    Version incompatibleVersion = Version.newInstance(defaultVersion.getMajorVersion() + 1, defaultVersion.getMinorVersion());
    stateStore.storeVersion(incompatibleVersion);
    try {
        restartStateStore();
        Assert.fail("Incompatible version, should expect fail here.");
    } catch (ServiceStateException e) {
        Assert.assertTrue("Exception message mismatch", e.getMessage().contains("Incompatible version for NM state:"));
    }
}
Also used : Version(org.apache.hadoop.yarn.server.records.Version) ServiceStateException(org.apache.hadoop.service.ServiceStateException) Test(org.junit.Test)

Example 10 with ServiceStateException

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

the class TestJvmMetrics method testStopBeforeStart.

@Test
public void testStopBeforeStart() throws Throwable {
    pauseMonitor = new JvmPauseMonitor();
    try {
        pauseMonitor.init(new Configuration());
        pauseMonitor.stop();
        pauseMonitor.start();
        Assert.fail("Expected an exception, got " + pauseMonitor);
    } catch (ServiceStateException e) {
        GenericTestUtils.assertExceptionContains("cannot enter state", e);
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) ServiceStateException(org.apache.hadoop.service.ServiceStateException) JvmPauseMonitor(org.apache.hadoop.util.JvmPauseMonitor) 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