use of org.apache.hadoop.yarn.server.records.Version in project hadoop by apache.
the class HistoryServerLeveldbStateStoreService method checkVersion.
/**
* 1) Versioning scheme: major.minor. For e.g. 1.0, 1.1, 1.2...1.25, 2.0 etc.
* 2) Any incompatible change of state-store is a major upgrade, and any
* compatible change of state-store is a minor upgrade.
* 3) Within a minor upgrade, say 1.1 to 1.2:
* overwrite the version info and proceed as normal.
* 4) Within a major upgrade, say 1.2 to 2.0:
* throw exception and indicate user to use a separate upgrade tool to
* upgrade state or remove incompatible old state.
*/
private void checkVersion() throws IOException {
Version loadedVersion = loadVersion();
LOG.info("Loaded state version info " + loadedVersion);
if (loadedVersion.equals(getCurrentVersion())) {
return;
}
if (loadedVersion.isCompatibleTo(getCurrentVersion())) {
LOG.info("Storing state version info " + getCurrentVersion());
storeVersion();
} else {
throw new IOException("Incompatible version for state: expecting state version " + getCurrentVersion() + ", but loading version " + loadedVersion);
}
}
use of org.apache.hadoop.yarn.server.records.Version 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();
}
use of org.apache.hadoop.yarn.server.records.Version in project hadoop by apache.
the class ShuffleHandler method loadVersion.
@VisibleForTesting
Version loadVersion() throws IOException {
byte[] data = stateDb.get(bytes(STATE_DB_SCHEMA_VERSION_KEY));
// if version is not stored previously, treat it as CURRENT_VERSION_INFO.
if (data == null || data.length == 0) {
return getCurrentVersion();
}
Version version = new VersionPBImpl(VersionProto.parseFrom(data));
return version;
}
Aggregations