Package com.seeq.utilities
Class VersionNumber
java.lang.Object
com.seeq.utilities.VersionNumber
- All Implemented Interfaces:
Comparable<VersionNumber>
A utility class that understands semantic versioning for comparisons. While this is
based on a SemanticVersion class that came from cassandra 2.0, an external library could be used if needed.
Feel free to add other methods to expose the actual major.minor.patch if you need them.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
assertUpgradeAllowed
(RuntimeVersion buildVersion, Path versionPath) Asserts that upgrades from the current version (as determined by the version.txt file atversionPath
) are supported.static void
assertUpgradeAllowed
(Optional<VersionNumber> maybeFrom, VersionNumber to) Asserts that upgrades from the specified 'from' version to the specified 'to' version are supported.int
compareTo
(VersionNumber other) static Optional<VersionNumber>
static String
removeMarketingPrefix
(String versionString) Strip the RXX.static boolean
shouldUpgrade
(VersionNumber upgradeAtVersion, VersionNumber fromVersion, VersionNumber toVersion) Default method to test whether an upgrade should apply.toString()
-
Constructor Details
-
VersionNumber
-
-
Method Details
-
removeMarketingPrefix
Strip the RXX. prefix. So for a version like R19.0.36.03, pull out "R19." and leave just 0.36.03. For a version like R50.0.1, pull out "R" and leave just 50.0.1.- Parameters:
versionString
- The version string to strip the prefix from.- Returns:
- The version string with the prefix removed, if necessary.
-
shouldUpgrade
public static boolean shouldUpgrade(VersionNumber upgradeAtVersion, VersionNumber fromVersion, VersionNumber toVersion) Default method to test whether an upgrade should apply. The function returns true if 'upgradeAtVersion' is greater than 'fromVersion' and less than or equal to 'toVersion'.- Parameters:
upgradeAtVersion
- the first version of Seeq where the upgrade should applyfromVersion
- the previously-installed version of SeeqtoVersion
- the current version of Seeq- Returns:
- true if the upgrade should be applied
-
compareTo
- Specified by:
compareTo
in interfaceComparable<VersionNumber>
-
toString
-
readVersionNumberFromFile
- Throws:
IOException
-
assertUpgradeAllowed
public static void assertUpgradeAllowed(RuntimeVersion buildVersion, Path versionPath) throws IOException Asserts that upgrades from the current version (as determined by the version.txt file atversionPath
) are supported.- Parameters:
buildVersion
- - The current build versionversionPath
- - The path to version.txt- Throws:
IOException
- - If the version.txt can't be read
-
assertUpgradeAllowed
Asserts that upgrades from the specified 'from' version to the specified 'to' version are supported. The logic here must be kept in sync with the logic in _check_upgrade_compatibility from common/migrations/_impl.py.- Parameters:
maybeFrom
- The 'from' version. If empty, this signifies that the current version is unknown (i.e., there is no version.txt file) and calculates an upgrade path starting at 0.37.XX.to
- The 'to' version.
-