Class VersionManager
- java.lang.Object
-
- jetbrains.buildServer.serverSide.versioning.VersionManager
-
public class VersionManager extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static StringCONFIG_VERSION_FILE_NAMEstatic StringCONFIG_VERSION_TIMESTAMP_PROPERTYstatic StringCONFIG_VERSION_VERSION_PROPERTYstatic StringMAIN_CONFIG_FILE_NAMEstatic intMAIN_CONFIG_VERSION_SINCEstatic intMINIMAL_VERSION_WE_CAN_UPGRADE_FROM
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcheckVersionMatchingInCaseOfDataDirOnly(ServerPaths serverPaths)Checks that the version of data directory matches this siftware version.static voidcheckVersionsAndUpgradeSchemaIfNeeded(DBFunctions dbf, ServerPaths serverPaths)Upgrades an existance schema if needed.static voidensureActualDatabase(TeamCityDatabaseManager tcdbm, ServerPaths serverPaths)static booleanisDatabaseCreatedOnStartup()static intloadConsistentVersion(ServerPaths serverPaths, DBFunctions dbf)Loads versions for both configuration and database (if possible).static intloadVersionFromDisk(ServerPaths serverPaths)Loads data format version of the configuration.static intloadVersionFromFormerFile(String systemDirPath)static intloadVersionFromMainConfigFile(String configDirPath)static voidsetDatabaseCreatedOnStartup(boolean createdOnStartup)static voidupgradeIt(ServerPaths serverPaths, DBFunctions dbf, IntInterval upgradeRange)WARNING! - we're assume that upgradeRange.B will be exactly the current software version number.static voidwriteSoftwareVersionIntoMainConfigXml(org.jdom.Element rootElement)static voidwriteVersionIntoMainConfigFile(String configDirPath, int version)static voidwriteVersionToDisk(ServerPaths serverPaths, int version, Date time)
-
-
-
Field Detail
-
MAIN_CONFIG_FILE_NAME
public static final String MAIN_CONFIG_FILE_NAME
- See Also:
- Constant Field Values
-
CONFIG_VERSION_FILE_NAME
public static final String CONFIG_VERSION_FILE_NAME
- See Also:
- Constant Field Values
-
CONFIG_VERSION_VERSION_PROPERTY
public static final String CONFIG_VERSION_VERSION_PROPERTY
- See Also:
- Constant Field Values
-
CONFIG_VERSION_TIMESTAMP_PROPERTY
public static final String CONFIG_VERSION_TIMESTAMP_PROPERTY
- See Also:
- Constant Field Values
-
MINIMAL_VERSION_WE_CAN_UPGRADE_FROM
public static final int MINIMAL_VERSION_WE_CAN_UPGRADE_FROM
- See Also:
- Constant Field Values
-
MAIN_CONFIG_VERSION_SINCE
public static final int MAIN_CONFIG_VERSION_SINCE
- See Also:
- Constant Field Values
-
-
Method Detail
-
loadVersionFromDisk
public static int loadVersionFromDisk(ServerPaths serverPaths) throws DataDirectoryVersionException
Loads data format version of the configuration. This version is loaded from "main-config.xml" file or from "version.dat" file.- Parameters:
serverPaths-- Returns:
- the loaded version, or 0 if could not loaded.
- Throws:
DataDirectoryVersionException
-
loadVersionFromMainConfigFile
public static int loadVersionFromMainConfigFile(String configDirPath)
-
loadVersionFromFormerFile
public static int loadVersionFromFormerFile(String systemDirPath)
-
writeVersionToDisk
public static void writeVersionToDisk(@NotNull ServerPaths serverPaths, int version, Date time) throws IOException- Throws:
IOException
-
writeVersionIntoMainConfigFile
public static void writeVersionIntoMainConfigFile(String configDirPath, int version) throws IOException
- Throws:
IOException
-
writeSoftwareVersionIntoMainConfigXml
public static void writeSoftwareVersionIntoMainConfigXml(@NotNull org.jdom.Element rootElement)
-
checkVersionMatchingInCaseOfDataDirOnly
public static void checkVersionMatchingInCaseOfDataDirOnly(ServerPaths serverPaths) throws DatabaseVersionMismatchException
Checks that the version of data directory matches this siftware version. Assumed that there is no database.- Parameters:
systemDirPath- where to look for the 'version.dat' file.- Throws:
DatabaseVersionMismatchException
-
checkVersionsAndUpgradeSchemaIfNeeded
public static void checkVersionsAndUpgradeSchemaIfNeeded(@NotNull DBFunctions dbf, @NotNull ServerPaths serverPaths) throws ConvertException, DBException, DataPartsInconsistentException, DatabaseVersionMismatchExceptionUpgrades an existance schema if needed. Assumed that schema does exist.- Throws:
DBException- when DBExceptionDataPartsInconsistentException- when config files xor database exists.ConvertExceptionDatabaseVersionMismatchException
-
upgradeIt
public static void upgradeIt(@NotNull ServerPaths serverPaths, @NotNull DBFunctions dbf, @NotNull IntInterval upgradeRange) throws ConvertException, DBExceptionWARNING! - we're assume that upgradeRange.B will be exactly the current software version number.- Throws:
ConvertExceptionDBException
-
ensureActualDatabase
public static void ensureActualDatabase(@NotNull TeamCityDatabaseManager tcdbm, @NotNull ServerPaths serverPaths) throws DBException, DataPartsInconsistentException, DatabaseVersionMismatchException, IOException
-
loadConsistentVersion
public static int loadConsistentVersion(@Nullable ServerPaths serverPaths, @Nullable DBFunctions dbf)Loads versions for both configuration and database (if possible). Returns the version number if both loaded numbers are the same, or throws an exception when differ.- Parameters:
serverPaths-dbf-- Returns:
- consistent data format version number.
- Throws:
IllegalStateException- when the configuration version and the database version are not same.
-
isDatabaseCreatedOnStartup
public static boolean isDatabaseCreatedOnStartup()
-
setDatabaseCreatedOnStartup
public static void setDatabaseCreatedOnStartup(boolean createdOnStartup)
-
-