Changeset 303022f


Ignore:
Timestamp:
Aug 16, 2017 8:37:49 AM (5 weeks ago)
Author:
www-data <www-data@…>
Branches:
master
Children:
002daed
Parents:
5090df5
git-author:
Bang Pham Huu <b.phamhuu@…> (08/15/17 15:06:42)
git-committer:
www-data <www-data@…> (08/16/17 08:37:49)
Message:

ticket:502 - fix problem with migration application to load GDAL native library

Summary:
Migration application should invoke the method to load GDAL native library before starting
or later, it will throw exception when using crs projection from GDAL Java library. Also fix migrate_petascopedb.sh script to
get the correct exit code when Java migration application throws exception.

Test Plan: Tested by running migrate_petascopdb.sh from old petascopedb to migrate to new petascopedb.

Reviewers: dmisev

Differential Revision: http://codereview.rasdaman.org/D449

Location:
applications/petascope
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • applications/petascope/migrate_petascopedb.sh.in

    r901a413 r303022f  
    7777    # No output log4j, grpc to user's console
    7878    java -jar "$PETASCOPE_MIGRATION_JAR" 2>&1 |  grep -v --line-buffered -e 'grpc' -e 'log4j'
    79     if [ "$?" -eq 0 ]; then
     79    # NOTE: $? always return 0 even when first command returns 1 (exception in migration application), must get exit code from correct variable.
     80    if [ ${PIPESTATUS[0]} -eq 0 ]; then
    8081        log "Migration completted successfully; petascope can be started again."
    8182    else
  • applications/petascope/petascope_migration/src/main/java/org/rasdaman/ApplicationMigration.java

    r7d15c94 r303022f  
    3838import petascope.util.DatabaseUtil;
    3939
    40 
    4140@SpringBootApplication
    4241@ComponentScan({"org.rasdaman", "petascope"})
    4342@PropertySource({"classpath:application.properties"})
    44 @EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
     43@EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class})
    4544/**
    4645 * Main class of migration application.
     
    7473    }
    7574
    76     public static void main(String[] args) throws Exception {       
    77         SpringApplication.run(ApplicationMigration.class, args);
     75    public static void main(String[] args) throws Exception {
     76        try {
     77            SpringApplication.run(ApplicationMigration.class, args);
     78        } catch (Exception ex) {
     79            // NOTE: always return error code or migrate_petascopedb.sh script will notice it migrated successfully.
     80            log.error("An error occured while migrating, aborting the migration process.", ex);           
     81            System.exit(ExitCode.FAILURE.getExitCode());                   
     82        }
    7883    }
    7984
    8085    @Override
    8186    public void run(String... args) throws Exception {
    82 
    8387        log.info("Migrating petascopedb from JDBC URL '" + ConfigManager.LEGACY_DATASOURCE_URL + "' to JDBC URL '" + ConfigManager.PETASCOPE_DATASOURCE_URL + "'...");
    8488        // First, check if old JDBC URL can be connected
     
    9094
    9195        /*
    92         NOTE: Hibernate already connected when migration application starts,
    93         so With the embedded database, if another connection tries to connect, it will return exception.
     96            NOTE: Hibernate already connected when migration application starts,
     97            so With the embedded database, if another connection tries to connect, it will return exception.
    9498         */
    9599        // Then, check what kind of migration should be done
     
    100104                System.exit(ExitCode.FAILURE.getExitCode());
    101105            }
    102            
     106
    103107            // NOTE: There are 2 types of migration:
    104108            // + From legacy petascopedb prior version 9.5, it checks if petascopedb contains a legacy table name then it migrates to new petascopedb version 9.5.
     
    114118                }
    115119                // Just do one migration
    116                 break;   
     120                break;
    117121            }
    118122        }
  • applications/petascope/petascope_migration/src/main/java/org/rasdaman/InitializeApplication.java

    r901a413 r303022f  
    2929import java.util.Properties;
    3030import static org.rasdaman.InitAllConfigurationsApplicationService.APPLICATION_PROPERTIES_FILE;
     31import static org.rasdaman.InitAllConfigurationsApplicationService.KEY_GDAL_JAVA_DIR;
    3132import org.rasdaman.config.ConfigManager;
    3233import static org.rasdaman.InitAllConfigurationsApplicationService.KEY_PETASCOPE_CONF_DIR;
     34import static org.rasdaman.InitAllConfigurationsApplicationService.addLibraryPath;
    3335import org.slf4j.Logger;
    3436import org.slf4j.LoggerFactory;
     
    6769     */
    6870    @Bean
    69     public PropertySourcesPlaceholderConfigurer placeholderConfigurer() throws FileNotFoundException, IOException, SQLException, ClassNotFoundException, PetascopeException {
     71    public PropertySourcesPlaceholderConfigurer placeholderConfigurer() throws FileNotFoundException, IOException, SQLException, ClassNotFoundException, PetascopeException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
    7072        String resourceName = APPLICATION_PROPERTIES_FILE; // could also be a constant
    7173        Properties properties = new Properties();
     
    9496     * OGC WCS XML Schema
    9597     */
    96     private void initConfigurations(Properties properties) throws SQLException, ClassNotFoundException, PetascopeException {
     98    private void initConfigurations(Properties properties) throws SQLException, ClassNotFoundException, PetascopeException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException, IOException {
     99        String GDAL_JAVA_DIR = properties.getProperty(KEY_GDAL_JAVA_DIR);
    97100        String CONF_DIR = properties.getProperty(KEY_PETASCOPE_CONF_DIR);
    98101        try {
    99             // Load the GDAL native libraries (no need to set in IDE with VM options: -Djava.library.path="/usr/lib/java/gdal/")       
     102            // Load the GDAL native libraries (no need to set in IDE with VM options: -Djava.library.path="/usr/lib/java/gdal/")           
     103            addLibraryPath("gdal_java", GDAL_JAVA_DIR);
    100104            // Load properties for Spring, Hibernate from external petascope.properties
    101105            ConfigManager.init(CONF_DIR);
Note: See TracChangeset for help on using the changeset viewer.