Example usage for org.apache.hadoop.yarn.server.records Version isCompatibleTo

List of usage examples for org.apache.hadoop.yarn.server.records Version isCompatibleTo

Introduction

In this page you can find the example usage for org.apache.hadoop.yarn.server.records Version isCompatibleTo.

Prototype

public boolean isCompatibleTo(Version version) 

Source Link

Usage

From source file:org.apache.tez.auxservices.ShuffleHandler.java

License:Apache License

/**
 * 1) Versioning scheme: major.minor. For e.g. 1.0, 1.1, 1.2...1.25, 2.0 etc.
 * 2) Any incompatible change of DB schema is a major upgrade, and any
 *    compatible change of DB schema 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 shuffle info or remove incompatible old state.
 *//* ww w .j a  va  2s .co m*/
private void checkVersion() throws IOException {
    Version loadedVersion = loadVersion();
    LOG.info("Loaded state DB schema version info " + loadedVersion);
    if (loadedVersion.equals(getCurrentVersion())) {
        return;
    }
    if (loadedVersion.isCompatibleTo(getCurrentVersion())) {
        LOG.info("Storing state DB schedma version info " + getCurrentVersion());
        storeVersion();
    } else {
        throw new IOException("Incompatible version for state DB schema: expecting DB schema version "
                + getCurrentVersion() + ", but loading version " + loadedVersion);
    }
}