Search in sources :

Example 6 with KyloVersion

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

the class AboutKyloController method getKyloVersion.

/**
 * Get Kylo Version for showing in UI About Dialog Box.
 */
@GET
@Path("/version")
@Produces(MediaType.TEXT_PLAIN)
@ApiOperation("Gets the version number of Kylo.")
@ApiResponses(@ApiResponse(code = 200, message = "Returns the version number.", response = String.class))
public Response getKyloVersion() {
    final String VERSION_NOT_AVAILABLE = "Not Available";
    KyloVersion kyloVersion = kyloVersionProvider.getCurrentVersion();
    if (kyloVersion != null) {
        return Response.ok(kyloVersion.getVersion()).build();
    } else {
        return Response.ok(VERSION_NOT_AVAILABLE).build();
    }
}
Also used : KyloVersion(com.thinkbiganalytics.KyloVersion) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 7 with KyloVersion

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

the class KyloServerApplication method main.

public static void main(String[] args) {
    SLF4JBridgeHandler.install();
    KyloUpgrader upgrader = new KyloUpgrader();
    if (upgrader.isUpgradeRequired()) {
        KyloVersion currentVersion = upgrader.getCurrentVersion();
        log.info("*****  Upgrade required - this may take some time  *****");
        log.info("Beginning upgrade from version {} ...", currentVersion == null ? "unknown" : currentVersion);
        upgrader.upgrade();
        log.info("*****  Upgrading complete  *****");
    } else {
        log.info("Kylo v{} is up to date.  Starting the application.", KyloVersionUtil.getBuildVersion());
    }
    System.setProperty(SpringApplication.BANNER_LOCATION_PROPERTY, "banner.txt");
    SpringApplication.run("classpath:application-context.xml", args);
}
Also used : KyloVersion(com.thinkbiganalytics.KyloVersion) KyloUpgrader(com.thinkbiganalytics.server.upgrade.KyloUpgrader)

Example 8 with KyloVersion

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

the class JpaKyloVersionProvider method isUpToDate.

@Override
public boolean isUpToDate() {
    KyloVersion buildVer = KyloVersionUtil.getBuildVersion();
    KyloVersion currentVer = getCurrentVersion();
    return currentVer != null && buildVer.matches(currentVer.getMajorVersion(), currentVer.getMinorVersion(), currentVer.getPointVersion());
}
Also used : KyloVersion(com.thinkbiganalytics.KyloVersion)

Example 9 with KyloVersion

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

the class KyloUpgradeDatabaseVersionChecker method getDatabaseVersion.

/**
 * Query the Database for the Kylo Version
 *
 * @return the KyloVersion from the database, or null if not found or if an error occurs
 */
public KyloVersion getDatabaseVersion() {
    KyloVersion version = null;
    Connection connection = null;
    Statement statement = null;
    ResultSet rs = null;
    try {
        String user = environmentProperties.getPropertyValueAsString("spring.datasource.username");
        String password = environmentProperties.getPropertyValueAsString("spring.datasource.password");
        password = encryptionService.isEncrypted(password) ? encryptionService.decrypt(password) : password;
        String uri = environmentProperties.getPropertyValueAsString("spring.datasource.url");
        String driverClassName = environmentProperties.getPropertyValueAsString("spring.datasource.driverClassName");
        boolean testOnBorrow = BooleanUtils.toBoolean(environmentProperties.getPropertyValueAsString("spring.datasource.testOnBorrow"));
        String validationQuery = environmentProperties.getPropertyValueAsString("spring.datasource.validationQuery");
        PoolingDataSourceService.DataSourceProperties dataSourceProperties = new PoolingDataSourceService.DataSourceProperties(user, password, uri, driverClassName, testOnBorrow, validationQuery);
        DataSource dataSource = PoolingDataSourceService.getDataSource(dataSourceProperties);
        connection = dataSource.getConnection();
        String query = "SELECT * FROM KYLO_VERSION ORDER BY MAJOR_VERSION DESC, MINOR_VERSION DESC, POINT_VERSION DESC, TAG DESC";
        statement = connection.createStatement();
        rs = statement.executeQuery(query);
        if (rs.next()) {
            String majorVersion = rs.getString("MAJOR_VERSION");
            String minorVersion = rs.getString("MINOR_VERSION");
            String pointVersion = rs.getString("POINT_VERSION");
            String tag = rs.getString("TAG");
            version = new KyloVersionUtil.Version(majorVersion, minorVersion, pointVersion, tag);
        }
    } catch (SQLException e) {
        // this is ok.. If an error happens assume the upgrade is needed.  The method will return a null value if errors occur and the upgrade app will start.
        log.error("Error has occurred so upgrade is needed", e);
    } finally {
        JdbcUtils.closeStatement(statement);
        JdbcUtils.closeResultSet(rs);
        JdbcUtils.closeConnection(connection);
    }
    return version;
}
Also used : KyloVersion(com.thinkbiganalytics.KyloVersion) PoolingDataSourceService(com.thinkbiganalytics.db.PoolingDataSourceService) SQLException(java.sql.SQLException) Statement(java.sql.Statement) Connection(java.sql.Connection) DataSource(javax.sql.DataSource) KyloVersionUtil(com.thinkbiganalytics.KyloVersionUtil) ResultSet(java.sql.ResultSet)

Example 10 with KyloVersion

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

the class KyloUpgradeService method main.

public static void main(String... args) {
    try {
        if (args.length < 2) {
            throw new IllegalArgumentException("Current source directory and build version required as arguments");
        }
        String resourcesDir = args[0];
        Resource versionsResource = new FileSystemResource(new File(resourcesDir, UPGRADE_VERSIONS_FILE));
        KyloVersion projectVersion = KyloVersionUtil.parseVersion(args[1]).withoutTag();
        List<KyloVersion> upgradeVersions = Stream.concat(readUpgradeVersions(versionsResource).stream(), Stream.of(projectVersion)).sorted().distinct().collect(Collectors.toList());
        writeUpgradeVersions(upgradeVersions, versionsResource.getFile());
    } catch (Exception e) {
        throw new UpgradeException("Failed to update versions file: " + UPGRADE_VERSIONS_FILE, e);
    }
}
Also used : KyloVersion(com.thinkbiganalytics.KyloVersion) ClassPathResource(org.springframework.core.io.ClassPathResource) Resource(org.springframework.core.io.Resource) FileSystemResource(org.springframework.core.io.FileSystemResource) FileSystemResource(org.springframework.core.io.FileSystemResource) File(java.io.File) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

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