Changes between Version 15 and Version 16 of Petascope_9.5


Ignore:
Timestamp:
Jul 3, 2017 12:58:38 PM (3 weeks ago)
Author:
dmisev
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Petascope_9.5

    v15 v16  
    4343== Developer's guide on update_petascopedb.sh
    4444
     45`update_petascopedb.sh` is a script that allows to manually apply changes to the schema of petascopedb, like add columns, tables, etc. Every change in petascopedb is marked as an update version (current version is 17). The bigest disadvantage is that it only supports postgresql and rollback to a previous schema version (e.g. 17 to 16) is not possible.
    4546
    46 Before version 9.5, update_petascopedb.sh is a script to update old petascopedb in Postgresql with some changes, such as: add some columns, tables, triggers, functions,...Every change in petascopedb was marked as a update version (current version is .17). This script cannot rollback to previous version of petascopedb (e.g: version .17 to version .8). This script has a big disadvantage is: it can only run and update to Postgresql as the SQL syntax are different from every Relational Database.
     47Petascope 9.5 uses Hibernate as ORM data model, and we cannot use `update_petascopedb.sh` with explicit SQL queries. To support different kinds of databases, we use the [http://www.liquibase.org/ Liquibase], which creates the changes for each update in XML and uses that to generate the SQL statements for the target database (e.g: Postgresql, MySql, HSQLDB, etc). A migration table is added in new Petascope database to lock the application when the process is running (to make sure multiple migrations are not happening at the same time).
    4748
    48 Therefore, in new Petascope with using Hibernate as ORM data model, we cannot add the SQL queries explicitly anymore. To support different kinds of Relation Database, we use the Liquibase which could create the changes for each version to XML and later on generated to target SQL syntax of the current database (e.g: Postgresql, MySql, HSQL,...). There is a migration table is added in new Petascope database to lock the application when the process is running (i.e: no multiple migrations are doing at the same time).
     49To perform migrations it is necessary to implement a small command-line java tool. This tool also uses Spring and Hibernate and can be invoked from the `update_petascopedb.sh` script. Below we outline the steps for migrating petascopedb.
    4950
    50 We will make a small Java Application to migrate from  old petascopedb to petascopedb_cis. This application also uses Spring and Hibernate and can be invoked from update_petascopedb.sh script (i.e: no expose the service to migrate in new Petascope).
     511. If using an embedded database like HSQLDB or H2, which does not support multiple connections from different applications, make sure that the (new) petascope 9.5 is stopped.
     521. Execute the migration script: `./update_petascopedb.sh`
     531. All coverages in pre 9.5 `petascopedb` will be read by the old `CoverageMetadata` model which is imported in the new petascope as a legacy package.
     541. If coverage id doesn't exist in the new `petascopedb_cis`, a process to translate from old `CoverageMetadata` model to CIS coverage data model is done and then persisted in `petascopedb_cis`.
     551. While running the migration, all services of the new petascope web application, such as: WCS, WCPS, WMS, and WCS-T, will not be available to make sure the data is migrated safely.
    5156
    52 Below are the description of the migration from old database to new database:
     57== Rollback ==
    5358
    54 NOTE: if you are using an embedded Database like HSQLDB, H2,... which does not support multiple connections from different application, you will need to stop the current running Petascope (either Tomcat external or embedded) first.
     59The following parts of petascope are saved to allow for rollback in the unlikely case of an unsuccessful migration.
    5560
    56 * User execute the update_petascopedb.sh script by:
    57 {{{
    58 ./update_petascopedb.sh
    59 }}}
    60 * All the imported coverages in old petascopedb will be read by old CoverageMetadata model which is imported to new Petascope as a legacy package.
    61 * The migration process will check if coverage id exists in new petascopedb_cis. If it does not, a process to translate from old CoverageMetadata model to CIS Coverage data model is done and then persist this new object to new database.
    62 * While running the migration, all the services to the new Petascope web application, such as: WCS, WCPS, WMS, WCST will not available to make sure data is migrated safely.
     61* The old `petascopedb` is preserved to allow the user to test the new petascope version first. It is their decision, ultimately, whether to drop the previous database or not.
     62* The old petascope web application will be moved from `rasdaman.war` to `rasdaman.war.old` in the Tomcat webapps directory
     63* The `petascope.properties` is backed up to `petascope.properties.DATE.bak` by the `update_properties.sh` script.
    6364
    64 NOTE: The old database is kept after the migration as if new Petascope might not work correctly, then user can switch back to old Petascope and old petascopedb.
    65 This could be done because, in version 9.5, old petascope deployed in old Tomcat will be renamed from rasdaman.war to rasdaman.war.bak, the petascope.properties is already backuped to petascope.properties.DATE.bak by update_properties.sh script. Then, user can rollback to use the old Petacope without any problem, just by renaming the new Petascope (rasdaman.war, petascope.properties to rasdaman.war.new and petascope.properties.new), then unrename the old ones (rasdaman.war.bak and petascope.properties.DATE.bak).
    66 
     65So to rollback:
     661. rename the new petascope (rasdaman.war and petascope.properties to rasdaman.war.new and petascope.properties.new)
     671. rename the old petascope back to the original (rasdaman.war.bak and petascope.properties.DATE.bak to rasdaman.war and petascope.properties).
     681. restart Tomcat
    6769
    6870= List of tested databases [=#list_jdbc]