Search in sources :

Example 11 with KyloVersion

use of com.thinkbiganalytics.KyloVersion in project kylo by Teradata.

the class KyloUpgradeService method getNextVersion.

private KyloVersion getNextVersion() {
    init();
    KyloVersion current = versionProvider.getCurrentVersion();
    // If there are no recorded versions then this is a fresh install so the next version is the actual build version.
    if (current == null) {
        return this.buildVersion;
    } else {
        int idx = IntStream.range(0, upgradeSequence.size()).filter(i -> upgradeSequence.get(i).matches(current.getMajorVersion(), current.getMinorVersion(), current.getPointVersion()) || upgradeSequence.get(i).compareTo(current) > 0).findFirst().orElseThrow(() -> new IllegalStateException("The current Kylo version is unrecognized: " + current));
        // If the current version is not the last one in the upgrade sequence then return it, otherwise return null.
        if (upgradeSequence.get(idx).compareTo(current) > 0) {
            return upgradeSequence.get(idx);
        } else if (idx < upgradeSequence.size() - 1) {
            return upgradeSequence.get(idx + 1);
        } else {
            return null;
        }
    }
}
Also used : KyloVersion(com.thinkbiganalytics.KyloVersion)

Example 12 with KyloVersion

use of com.thinkbiganalytics.KyloVersion in project kylo by Teradata.

the class KyloUpgrader method getCurrentVersion.

/**
 * Return the database version for Kylo.
 *
 * @return the version of Kylo stored in the database
 */
public KyloVersion getCurrentVersion() {
    String profiles = System.getProperty("spring.profiles.active", "");
    if (!profiles.contains("native")) {
        profiles = StringUtils.isEmpty(profiles) ? "native" : profiles + ",native";
        System.setProperty("spring.profiles.active", profiles);
    }
    // Spring is needed to load the Spring Cloud context so we can decrypt the passwords for the database connection
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("kylo-upgrade-check-application-context.xml");
    loadProfileProperties(ctx);
    ctx.refresh();
    KyloUpgradeDatabaseVersionChecker upgradeDatabaseVersionChecker = (KyloUpgradeDatabaseVersionChecker) ctx.getBean("kyloUpgradeDatabaseVersionChecker");
    KyloVersion kyloVersion = upgradeDatabaseVersionChecker.getDatabaseVersion();
    ctx.close();
    return kyloVersion;
}
Also used : KyloVersion(com.thinkbiganalytics.KyloVersion) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext)

Aggregations

KyloVersion (com.thinkbiganalytics.KyloVersion)12 KyloUpgrader (com.thinkbiganalytics.server.upgrade.KyloUpgrader)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 ClassPathResource (org.springframework.core.io.ClassPathResource)3 KyloVersionUtil (com.thinkbiganalytics.KyloVersionUtil)2 UpgradeState (com.thinkbiganalytics.server.upgrade.UpgradeState)2 File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 List (java.util.List)2 Optional (java.util.Optional)2 Collectors (java.util.stream.Collectors)2 Inject (javax.inject.Inject)2 Profile (org.springframework.context.annotation.Profile)2 Component (org.springframework.stereotype.Component)2 Resources (com.google.common.io.Resources)1 PoolingDataSourceService (com.thinkbiganalytics.db.PoolingDataSourceService)1 TableSchema (com.thinkbiganalytics.discovery.schema.TableSchema)1