Class Postgres_StateDBConnector

  • All Implemented Interfaces:
    IISDStateDBConnector

    public class Postgres_StateDBConnector
    extends Object
    implements IISDStateDBConnector
    A connection class to test and update various pieces of information in a database to determine if this process can do its thing and to inform other processes that it is.
    Author:
    Dustin Kempton, Surabhi Priya, Data Mining Lab, Georgia State University
    • Constructor Detail

      • Postgres_StateDBConnector

        public Postgres_StateDBConnector​(DataSource dsourc,
                                         List<String> blockingProcesses,
                                         org.joda.time.DateTime defaultTime,
                                         String processName,
                                         org.slf4j.Logger logger)
        Constructor
        Parameters:
        dsourc - The data source used to connect to the database.
        blockingProcesses - A list of process names that will block this process in the state table. If empty, then it is assumed that no processes will block the processing of EventTypes in this process
        defaultTime - The default time returned for the last processed time entry of the state table when this process has not previously had an entry
        processName - The name of the process to use when accessing the state table
        logger - The SLF4J logging object used to log errors that occur in this object.
    • Method Detail

      • checkOKToProcess

        public boolean checkOKToProcess​(EventType type)
                                 throws SQLException
        Description copied from interface: IISDStateDBConnector
        Checks if this part of the processing pipeline is cleared to run its operations again.
        Specified by:
        checkOKToProcess in interface IISDStateDBConnector
        Parameters:
        type - The ISD Solar Event type that the processing flag is to be checked for.
        Returns:
        True if this part of the processing pipeline is cleared to run.
        Throws:
        SQLException - If there was an SQLException that occurred while attempting to execute.
      • setIsProcessing

        public boolean setIsProcessing​(EventType type)
                                throws SQLException
        Description copied from interface: IISDStateDBConnector
        Sets a processing flag to keep other parts of the processing pipeline from executing while this part is still performing its operations.
        Specified by:
        setIsProcessing in interface IISDStateDBConnector
        Parameters:
        type - The ISD Solar Event type that the is processing flag is to be set for.
        Returns:
        True if successfully set the processing flag, False otherwise.
        Throws:
        SQLException - If there was an SQLException that occurred while attempting to execute.
      • setFinishedProcessing

        public boolean setFinishedProcessing​(EventType type)
                                      throws SQLException,
                                             IllegalAccessException
        Description copied from interface: IISDStateDBConnector
        Sets a processing flag to allow other parts of the processing pipeline to execute since this process has finished its operations.
        Specified by:
        setFinishedProcessing in interface IISDStateDBConnector
        Parameters:
        type - The ISD Solar Event type that the is processing flag is to be set for.
        Returns:
        True if successfully set the processing flag, False otherwise.
        Throws:
        SQLException - If there was an SQLException that occurred while attempting to execute.
        IllegalAccessException - If this is called for a process that has not been working on the given table. So, the state is not being set to 'FALSE' to avoid some possible mistakes.
      • updateLastProcessedTime

        public boolean updateLastProcessedTime​(EventType type,
                                               org.joda.time.DateTime processedTime)
                                        throws SQLException
        Description copied from interface: IISDStateDBConnector
        Updates the state table with the passed in datetime to indicate the last report time this part of the processing pipeline successfully executed.
        Specified by:
        updateLastProcessedTime in interface IISDStateDBConnector
        Parameters:
        type - The ISD Solar Event type that the processed time is to be updated for.
        processedTime - The time to update the database with.
        Returns:
        True if update was successful, False otherwise.
        Throws:
        SQLException - If there was an SQLException that occurred while attempting to execute.
      • getLastProcessedTime

        public org.joda.time.DateTime getLastProcessedTime​(EventType type)
                                                    throws SQLException
        Description copied from interface: IISDStateDBConnector
        Gets the last report time this part of the processing pipeline successfully executed its operations on. This is to know what data to process in HEK and update in the ISD database.
        Specified by:
        getLastProcessedTime in interface IISDStateDBConnector
        Parameters:
        type - The ISD Solar Event type that the processed time is to be checked for.
        Returns:
        The date and time of the last time this part of the processing pipeline executed its operations.
        Throws:
        SQLException - If there was an SQLException that occurred while attempting to execute.