Class DBSpecifics

    • Constructor Detail

      • DBSpecifics

        public DBSpecifics()
    • Method Detail

      • getInstance

        public static DBSpecifics getInstance()
        Get the singleton instance of the DBSpecifics implementation class.
        Returns:
        An instance of DBSpecifics with implementations for a given DB.
      • getJobConfigsTmpTable

        public abstract String getJobConfigsTmpTable​(Connection c)
                                              throws SQLException
        Get a temporary table for short-time use. The table should be disposed of with dropTemporaryTable. The table has two columns domain_name varchar(Constants.MAX_NAME_SIZE) + config_name varchar(Constants.MAX_NAME_SIZE) All rows in the table must be deleted at commit or rollback.
        Parameters:
        c - The DB connection to use.
        Returns:
        The name of the created table
        Throws:
        SQLException - if there is a problem getting the table.
      • dropJobConfigsTmpTable

        public abstract void dropJobConfigsTmpTable​(Connection c,
                                                    String tableName)
        Dispose of a temporary table gotten with getTemporaryTable. This can be expected to be called from within a finally clause, so it mustn't throw exceptions.
        Parameters:
        c - The DB connection to use.
        tableName - The name of the temporarily created table.
      • getDriverClassName

        public abstract String getDriverClassName()
        Get the name of the JDBC driver class that handles interfacing to this server.
        Returns:
        The name of a JDBC driver class
      • updateTable

        public void updateTable​(String tableName,
                                int toVersion)
        Update a table to a newer version, if necessary. This will check the schemaversions table to see the current version and perform a table-specific update if required.
        Parameters:
        tableName - The table to update
        toVersion - The version to update the table to.
        Throws:
        IllegalState - If the table is an unsupported version, and the toVersion is less than the current version of the table
        NotImplementedException - If no method exists for migration from current version of the table to the toVersion of the table.
        IOFailure - in case of problems in interacting with the database
      • createHarvestChannelTable

        protected abstract void createHarvestChannelTable()
      • migrateJobsv3tov4

        protected abstract void migrateJobsv3tov4()
        Migrates the 'jobs' table from version 3 to version 4 consisting of a change of the field forcemaxbytes from int to bigint and setting its default to -1. Furthermore the default value for field num_configs is set to 0.
        Throws:
        IOFailure - in case of problems in interacting with the database
      • migrateJobsv4tov5

        protected abstract void migrateJobsv4tov5()
        Migrates the 'jobs' table from version 4 to version 5 consisting of adding new fields 'resubmitted_as_job' and 'submittedDate'.
        Throws:
        IOFailure - in case of problems in interacting with the database
      • migrateConfigurationsv3ov4

        protected abstract void migrateConfigurationsv3ov4()
        Migrates the 'configurations' table from version 3 to version 4. This consists of altering the default value of field 'maxbytes' to -1.
      • migrateFullharvestsv2tov3

        protected abstract void migrateFullharvestsv2tov3()
        Migrates the 'fullharvests' table from version 2 to version 3. This consists of altering the default value of field 'maxbytes' to -1.
      • migrateRunningJobsHistoryTableV1ToV2

        protected abstract void migrateRunningJobsHistoryTableV1ToV2()
        Migrates the 'runningjobshistory' table from version 1 to version 2. This consists of adding the new column 'retiredQueuesCount'.
      • migrateRunningJobsMonitorTableV1ToV2

        protected abstract void migrateRunningJobsMonitorTableV1ToV2()
        Migrates the 'runningjobsmonitor' table from version 1 to version 2. This consists of adding the new column 'retiredQueuesCount'.
      • migrateDomainsv2tov3

        protected abstract void migrateDomainsv2tov3()
        Migrates the 'domains' table from version 2 to version 3. This consists of altering the type of the crawlertraps column to "text" in postgres, and noop in derbyDB
      • createGlobalCrawlerTrapLists

        protected abstract void createGlobalCrawlerTrapLists()
        Creates the initial (version 1) of table 'global_crawler_trap_lists'.
      • createGlobalCrawlerTrapExpressions

        protected abstract void createGlobalCrawlerTrapExpressions()
        Creates the initial (version 1) of table 'global_crawler_trap_expressions'.
      • getOrderByLimitAndOffsetSubClause

        public abstract String getOrderByLimitAndOffsetSubClause​(long limit,
                                                                 long offset)
        Formats the LIMIT sub-clause of an SQL order clause. This sub-clause allows to paginate query results and its syntax might be dependant on the target RDBMS
        Parameters:
        limit - the maximum number of rows to fetch.
        offset - the starting offset in the full query results.
        Returns:
        the proper sub-clause.
      • supportsClob

        public abstract boolean supportsClob()
        Returns true if the target RDBMS supports CLOBs. If possible seedlists will be stored as CLOBs.
        Returns:
        true if CLOBs are supported, false otherwise.
      • createFrontierReportMonitorTable

        public abstract void createFrontierReportMonitorTable()
        Create the frontierReportMonitor table in the database.
      • createRunningJobsHistoryTable

        public abstract void createRunningJobsHistoryTable()
        Create the frontierReportMonitor table in the database.
      • createRunningJobsMonitorTable

        public abstract void createRunningJobsMonitorTable()
        Create the frontierReportMonitor table in the database.
      • migrateJobsv5tov6

        protected abstract void migrateJobsv5tov6()
        Migrates the 'jobs' table from version 5 to version 6. Adds the field 'forcemaxrunningtime'.
        Throws:
        IOFailure - in case of problems in interacting with the database
      • migrateConfigurationsv4tov5

        protected abstract void migrateConfigurationsv4tov5()
        Migrates the 'configurations' table from version 4 to version 5. This consists of altering the field 'maxobjects' from being an int to a bigint.
      • migrateFullharvestsv3tov4

        protected abstract void migrateFullharvestsv3tov4()
        Migrates the 'fullharvests' table from version 3 to version 4. This consists of adding the field 'maxjobrunningtime'.
      • migrateFullharvestsv4tov5

        protected abstract void migrateFullharvestsv4tov5()
        Migrates the 'fullharvests' table from version 4 to version 5. This consists of adding the field 'isindexready'.
      • createExtendedFieldTypeTable

        protected abstract void createExtendedFieldTypeTable()
        Create the extendedfieldtype table in the database.
      • createExtendedFieldTable

        protected abstract void createExtendedFieldTable()
        Create the extendedfield table in the database.
      • createExtendedFieldValueTable

        protected abstract void createExtendedFieldValueTable()
        Create the extendedfieldvalue table in the database.
      • migrateJobsv6tov7

        protected abstract void migrateJobsv6tov7()
        Migrates the 'jobs' table from version 6 to version 7 consisting of adding the bigint fieldcontinuationof with null as default.
      • migrateJobsv7tov8

        protected abstract void migrateJobsv7tov8()
        Migrates the 'jobs' table from version 7 to version 8 consisting of adding the date creationdate with null as default.
      • migrateJobsv8tov9

        protected abstract void migrateJobsv8tov9()
        Migrates the 'jobs' table from version 8 to version 9 consisting of adding the string harvestname_prefix with null as default.
      • migrateHarvestdefinitionsv2tov3

        protected abstract void migrateHarvestdefinitionsv2tov3()
        Migrates the 'harvestdefinitions' table from version 2 to version 3 consisting of adding the string audience with null as default.
      • migrateHarvestdefinitionsv3tov4

        protected abstract void migrateHarvestdefinitionsv3tov4()
        Migrates the 'harvestdefinitions' table from version 3 to version 4 consisting of adding the bigint channel_id field.
      • migrateJobsv9tov10

        protected abstract void migrateJobsv9tov10()
        Migrates the 'jobs' table from version 9 to version 10 consisting of adding the channel (varchar 300) and a 'snapshot'
      • migrateExtendedFieldTableV1toV2

        protected abstract void migrateExtendedFieldTableV1toV2()
        Migrates the 'ExtendedFieldTable' from version 1 to version 2 consisting of adding the maxlen field
      • migrateExtendedFieldTableValueV1toV2

        protected abstract void migrateExtendedFieldTableValueV1toV2()
        Migrates the 'ExtendedFieldValueTable' from version 1 to version 2 changing the maxlen of content to 30000
      • migrateOrderTemplatesTablev1tov2

        protected abstract void migrateOrderTemplatesTablev1tov2()
        Migrates the table 'ordertemplates' from version 1 to version 2, adding a boolean 'isActive" flag.
      • updateTables

        public void updateTables()
        Update all tables in the enum class HarvesterDatabaseTables to the required version. There is no attempt to undo the update.
      • upgradeEavTypeAttributeTable

        public void upgradeEavTypeAttributeTable​(int currentVersion,
                                                 int toVersion)
        Migrate the eavtypeattribute table.
        Parameters:
        currentVersion - the current version of the eavtypeattribute table
        toVersion - the required version of the eavtypeattribute table
      • createEavTypeAttributeTable

        public abstract void createEavTypeAttributeTable​(int toVersion)
        Create the EavTypeAttribute table in the database.
      • upgradeEavAttributeTable

        public void upgradeEavAttributeTable​(int currentVersion,
                                             int toVersion)
        Migrate the eavattribute table.
        Parameters:
        currentVersion - the current version of the eavattribute table
        toVersion - the required version of the eavattribute table
      • createEavAttributeTable

        public abstract void createEavAttributeTable​(int toVersion)
        Create the EavAttributeTable table in the database.