dk.netarkivet.harvester.datamodel
Class PostgreSQLSpecifics

java.lang.Object
  extended by dk.netarkivet.common.utils.SettingsFactory<DBSpecifics>
      extended by dk.netarkivet.harvester.datamodel.DBSpecifics
          extended by dk.netarkivet.harvester.datamodel.PostgreSQLSpecifics

public class PostgreSQLSpecifics
extends DBSpecifics

PostgreSQL-specific implementation of DB methods. Intended for PostgreSQL 8.3 and above. PostgreSQL does not support the CLOB datatype but instead provides a "text" data type. See http://www.postgresql.org/docs/current/static/datatype-character.html.


Field Summary
(package private)  org.apache.commons.logging.Log log
          The log.
 
Fields inherited from class dk.netarkivet.harvester.datamodel.DBSpecifics
CONFIGPASSWORDS_TABLE, CONFIGPASSWORDS_TABLE_REQUIRED_VERSION, CONFIGSEEDLISTS_TABLE, CONFIGSEEDLISTS_TABLE_REQUIRED_VERSION, CONFIGURATIONS_TABLE, CONFIGURATIONS_TABLE_REQUIRED_VERSION, DOMAINS_TABLE, DOMAINS_TABLE_REQUIRED_VERSION, EXTENDEDFIELD_TABLE, EXTENDEDFIELD_TABLE_REQUIRED_VERSION, EXTENDEDFIELDTYPE_TABLE, EXTENDEDFIELDTYPE_TABLE_REQUIRED_VERSION, EXTENDEDFIELDVALUE_TABLE, EXTENDEDFIELDVALUE_TABLE_REQUIRED_VERSION, FRONTIERREPORTMONITOR_TABLE, FRONTIERREPORTMONITOR_TABLE_REQUIRED_VERSION, FULLHARVESTS_TABLE, FULLHARVESTS_TABLE_REQUIRED_VERSION, GLOBALCRAWLERTRAPEXPRESSIONS_TABLE, GLOBALCRAWLERTRAPEXPRESSIONS_TABLE_REQUIRED_VERSION, GLOBALCRAWLERTRAPLISTS_TABLE, GLOBALCRAWLERTRAPLISTS_TABLE_REQUIRED_VERSION, HARVESTCONFIGS_TABLE, HARVESTCONFIGS_TABLE_REQUIRED_VERSION, HARVESTDEFINITIONS_TABLE, HARVESTDEFINITIONS_TABLE_REQUIRED_VERSION, HISTORYINFO_TABLE, HISTORYINFO_TABLE_REQUIRED_VERSION, JOBCONFIGS_TABLE, JOBCONFIGS_TABLE_REQUIRED_VERSION, JOBS_TABLE, JOBS_TABLE_REQUIRED_VERSION, ORDERTEMPLATES_TABLE, ORDERTEMPLATES_TABLE_REQUIRED_VERSION, OWNERINFO_TABLE, OWNERINFO_TABLE_REQUIRED_VERSION, PARTIALHARVESTS_TABLE, PARTIALHARVESTS_TABLE_REQUIRED_VERSION, PASSWORDS_TABLE, PASSWORDS_TABLE_REQUIRED_VERSION, RUNNINGJOBSHISTORY_TABLE, RUNNINGJOBSHISTORY_TABLE_REQUIRED_VERSION, RUNNINGJOBSMONITOR_TABLE, RUNNINGJOBSMONITOR_TABLE_REQUIRED_VERSION, SCHEDULES_TABLE, SCHEDULES_TABLE_REQUIRED_VERSION, SEEDLISTS_TABLE, SEEDLISTS_TABLE_REQUIRED_VERSION
 
Constructor Summary
PostgreSQLSpecifics()
           
 
Method Summary
protected  void createExtendedFieldTable()
          Create the extendedfield table in the database.
protected  void createExtendedFieldTypeTable()
          Create the extendedfieldtype table in the database.
protected  void createExtendedFieldValueTable()
          Create the extendedfieldvalue table in the database.
 void createFrontierReportMonitorTable()
          Create the frontierReportMonitor table in the database.
protected  void createGlobalCrawlerTrapExpressions()
          Creates the initial (version 1) of table 'global_crawler_trap_expressions'.
protected  void createGlobalCrawlerTrapLists()
          Creates the initial (version 1) of table 'global_crawler_trap_lists'.
 void createRunningJobsHistoryTable()
          Create the frontierReportMonitor table in the database.
 void createRunningJobsMonitorTable()
          Create the frontierReportMonitor table in the database.
 void dropJobConfigsTmpTable(java.sql.Connection c, java.lang.String tableName)
          Dispose of a temporary table created with getTemporaryTable.
 java.lang.String getDriverClassName()
          Get the name of the JDBC driver class that handles interfacing to this server.
static DBSpecifics getInstance()
          Get an instance of the PostgreSQL specifics class.
 java.lang.String getJobConfigsTmpTable(java.sql.Connection c)
          Get a temporary table for short-time use.
 java.lang.String getOrderByLimitAndOffsetSubClause(long limit, long offset)
          Formats the LIMIT sub-clause of an SQL order clause.
protected  void migrateConfigurationsv3ov4()
          Migrates the 'configurations' table from version 3 to version 4.
protected  void migrateConfigurationsv4tov5()
          Migrates the 'configurations' table from version 4 to version 5.
protected  void migrateFullharvestsv2tov3()
          Migrates the 'fullharvests' table from version 2 to version 3.
protected  void migrateFullharvestsv3tov4()
          Migrates the 'fullharvests' table from version 3 to version 4.
protected  void migrateFullharvestsv4tov5()
          Migrates the 'fullharvests' table from version 4 to version 5.
protected  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.
protected  void migrateJobsv4tov5()
          Migrates the 'jobs' table from version 4 to version 5 consisting of adding new fields 'resubmitted_as_job' and 'submittedDate'.
protected  void migrateJobsv5tov6()
          Migrates the 'jobs' table from version 5 to version 6.
protected  void migrateRunningJobsHistoryTableV1ToV2()
          Migrates the 'runningjobshistory' table from version 1 to version 2.
protected  void migrateRunningJobsMonitorTableV1ToV2()
          Migrates the 'runningjobsmonitor' table from version 1 to version 2.
 boolean supportsClob()
          Returns true if the target RDBMS supports CLOBs.
 
Methods inherited from class dk.netarkivet.harvester.datamodel.DBSpecifics
updateTable
 
Methods inherited from class dk.netarkivet.common.utils.SettingsFactory
getInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

org.apache.commons.logging.Log log
The log.

Constructor Detail

PostgreSQLSpecifics

public PostgreSQLSpecifics()
Method Detail

getInstance

public static DBSpecifics getInstance()
Get an instance of the PostgreSQL specifics class.

Returns:
Instance of the PostgreSQL specifics class.

getJobConfigsTmpTable

public java.lang.String getJobConfigsTmpTable(java.sql.Connection c)
                                       throws java.sql.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)

Specified by:
getJobConfigsTmpTable in class DBSpecifics
Parameters:
c - The DB connection to use.
Returns:
The name of the created table
Throws:
java.sql.SQLException - if there is a problem getting the table.

dropJobConfigsTmpTable

public void dropJobConfigsTmpTable(java.sql.Connection c,
                                   java.lang.String tableName)
Dispose of a temporary table created with getTemporaryTable. This can be expected to be called from within a finally clause, so it mustn't throw exceptions.

Specified by:
dropJobConfigsTmpTable in class DBSpecifics
Parameters:
c - The DB connection to use.
tableName - The name of the temporary table

getDriverClassName

public java.lang.String getDriverClassName()
Get the name of the JDBC driver class that handles interfacing to this server.

Specified by:
getDriverClassName in class DBSpecifics
Returns:
The name of a JDBC driver class

getOrderByLimitAndOffsetSubClause

public java.lang.String getOrderByLimitAndOffsetSubClause(long limit,
                                                          long offset)
Description copied from class: DBSpecifics
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

Specified by:
getOrderByLimitAndOffsetSubClause in class DBSpecifics
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 boolean supportsClob()
Description copied from class: DBSpecifics
Returns true if the target RDBMS supports CLOBs. If possible seedlists will be stored as CLOBs.

Specified by:
supportsClob in class DBSpecifics
Returns:
true if CLOBs are supported, false otherwise.

migrateJobsv3tov4

protected 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.

Specified by:
migrateJobsv3tov4 in class DBSpecifics
Throws:
IOFailure - in case of problems in interacting with the database

migrateJobsv4tov5

protected void migrateJobsv4tov5()
Migrates the 'jobs' table from version 4 to version 5 consisting of adding new fields 'resubmitted_as_job' and 'submittedDate'.

Specified by:
migrateJobsv4tov5 in class DBSpecifics
Throws:
IOFailure - in case of problems in interacting with the database

migrateConfigurationsv3ov4

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

Specified by:
migrateConfigurationsv3ov4 in class DBSpecifics

migrateFullharvestsv2tov3

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

Specified by:
migrateFullharvestsv2tov3 in class DBSpecifics

createGlobalCrawlerTrapExpressions

protected void createGlobalCrawlerTrapExpressions()
Description copied from class: DBSpecifics
Creates the initial (version 1) of table 'global_crawler_trap_expressions'.

Specified by:
createGlobalCrawlerTrapExpressions in class DBSpecifics

createGlobalCrawlerTrapLists

protected void createGlobalCrawlerTrapLists()
Description copied from class: DBSpecifics
Creates the initial (version 1) of table 'global_crawler_trap_lists'.

Specified by:
createGlobalCrawlerTrapLists in class DBSpecifics

createFrontierReportMonitorTable

public void createFrontierReportMonitorTable()
Description copied from class: DBSpecifics
Create the frontierReportMonitor table in the database.

Specified by:
createFrontierReportMonitorTable in class DBSpecifics

createRunningJobsHistoryTable

public void createRunningJobsHistoryTable()
Description copied from class: DBSpecifics
Create the frontierReportMonitor table in the database.

Specified by:
createRunningJobsHistoryTable in class DBSpecifics

createRunningJobsMonitorTable

public void createRunningJobsMonitorTable()
Description copied from class: DBSpecifics
Create the frontierReportMonitor table in the database.

Specified by:
createRunningJobsMonitorTable in class DBSpecifics

migrateRunningJobsHistoryTableV1ToV2

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

Specified by:
migrateRunningJobsHistoryTableV1ToV2 in class DBSpecifics

migrateRunningJobsMonitorTableV1ToV2

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

Specified by:
migrateRunningJobsMonitorTableV1ToV2 in class DBSpecifics

migrateConfigurationsv4tov5

protected void migrateConfigurationsv4tov5()
Description copied from class: DBSpecifics
Migrates the 'configurations' table from version 4 to version 5. This consists of altering the field 'maxobjects' from being an int to a bigint.

Specified by:
migrateConfigurationsv4tov5 in class DBSpecifics

migrateFullharvestsv3tov4

protected void migrateFullharvestsv3tov4()
Description copied from class: DBSpecifics
Migrates the 'fullharvests' table from version 3 to version 4. This consists of adding the field 'maxjobrunningtime'.

Specified by:
migrateFullharvestsv3tov4 in class DBSpecifics

migrateJobsv5tov6

protected void migrateJobsv5tov6()
Description copied from class: DBSpecifics
Migrates the 'jobs' table from version 5 to version 6. Adds the field 'forcemaxrunningtime'.

Specified by:
migrateJobsv5tov6 in class DBSpecifics

migrateFullharvestsv4tov5

protected void migrateFullharvestsv4tov5()
Description copied from class: DBSpecifics
Migrates the 'fullharvests' table from version 4 to version 5. This consists of adding the field 'isindexready'.

Specified by:
migrateFullharvestsv4tov5 in class DBSpecifics

createExtendedFieldTypeTable

protected void createExtendedFieldTypeTable()
Description copied from class: DBSpecifics
Create the extendedfieldtype table in the database.

Specified by:
createExtendedFieldTypeTable in class DBSpecifics

createExtendedFieldTable

protected void createExtendedFieldTable()
Description copied from class: DBSpecifics
Create the extendedfield table in the database.

Specified by:
createExtendedFieldTable in class DBSpecifics

createExtendedFieldValueTable

protected void createExtendedFieldValueTable()
Description copied from class: DBSpecifics
Create the extendedfieldvalue table in the database.

Specified by:
createExtendedFieldValueTable in class DBSpecifics