Class TombstoneManager


  • public class TombstoneManager
    extends java.lang.Object
    This class is used to manage Tombstone objects. It contains methods to retrieve and delete tombstone objects on a specific criteria.
    • Constructor Summary

      Constructors 
      Constructor Description
      TombstoneManager()
      Default constructor for this object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int deleteALTombstones​(java.lang.String aAssemblyLineName, java.lang.String aConfigID)
      Deletes all Tombstone objects created for the specified AssemblyLine.
      int deleteALTombstones​(java.lang.String aAssemblyLineName, java.lang.String aConfigID, int aDays)
      Deletes all Tombstone objects for a specified AssemblyLine that are older than the specified number of days.
      int deleteALTombstones​(java.lang.String aAssemblyLineName, java.lang.String aConfigID, java.util.Date olderThanDate)
      Deletes all Tombstone objects for a specified AssemblyLine that are older than the specified date.
      int deleteALTombstones​(java.lang.String aAssemblyLineName, java.lang.String aConfigID, java.util.Date startDate, java.util.Date endDate)
      Deletes all Tombstone objects for a specified AssemblyLine that are in the specified Date range.
      int deleteCITombstones​(java.lang.String aConfigID)
      Deletes all tombstones for a specified Config Instance.
      int deleteCITombstones​(java.lang.String aConfigID, int aDays)
      Deletes all Tombstone objects for a specified Config Instance that are older than the specified number of days.
      boolean deleteTombstone​(java.lang.String aGUID)
      Deletes a tombstone.
      int deleteTombstones​(int aDaysCount)
      Deletes all Tombstone objects that are older than the specified number of days.
      protected void doInsert​(int aComponentTypeID, int aEventTypeID, long aStartTime, long aCreatedOn, java.lang.String aComponentName, java.lang.String aConfiguration, int aExitCode, java.lang.String aErrorDescr, java.lang.String aGUID, byte[] aStats, java.lang.String aUserMessage)
      Inserts a tombstone record in the back-end database.
      protected void finalize()
      Close the prepared statement.
      java.util.List<java.lang.String> getAssemblyLineNames​(java.lang.String configInstanceId)  
      Tombstone[] getAssemblyLineTombstones​(java.lang.String aAssemblyLineName, java.lang.String aConfigID)
      Get all available tombstones for a specified AssemblyLine.
      Tombstone[] getAssemblyLineTombstones​(java.lang.String assemblyLineName, java.lang.String configID, int recentNumberOfTombstones)
      Gets the recent n number of tombstones for a specified AssemblyLine
      Tombstone[] getAssemblyLineTombstones​(java.lang.String aAssemblyLineName, java.lang.String aConfigID, java.util.Date aStartTime, java.util.Date aEndTime)
      Get all available tombstones for a specified AssemblyLine with timestamps in the interval specified by aStartTime and aEndTime.
      java.util.List<java.lang.String> getConfigInstanceIDs()  
      Tombstone[] getConfigInstanceTombstones​(java.lang.String aConfigID)
      Get all available tombstones for a specified Configuration Instance.
      Tombstone[] getConfigInstanceTombstones​(java.lang.String aConfigID, java.util.Date aStartTime, java.util.Date aEndTime)
      Get all available tombstones for a specified ConfigInstance with timestamps in the interval specified by aStartTime and aEndTime.
      java.sql.Connection getConnection()
      Gets the JDBC connection.
      Tombstone getTombstone​(java.lang.String aGUID)
      Get single tombstone object, uniquely identified by the specified GUID
      Tombstone[] getTombstones​(java.util.Date aStartTime, java.util.Date aEndTime)
      Get all available tombstones with timestamps in the interval specified by aStartTime and aEndTime.
      int getTombstonesCount()  
      boolean hasTombstones​(java.lang.String configInstanceId)  
      boolean hasTombstones​(java.lang.String configInstanceId, java.lang.String alName)  
      int keepMostRecentALTombstones​(java.lang.String aAssemblyLineName, java.lang.String aConfigID, int aRecentTombstonesToKeep)
      Deletes all tombstones for a specified AssemblyLine except a specified number of most recently created ones.
      int keepMostRecentCITombstones​(java.lang.String aConfigID, int aRecentTombstonesToKeep)
      Deletes all tombstones for a Config Instance except a specified number of recently created ones.
      int keepMostRecentTombstones​(int aRecentTombstonesToKeep)
      Deletes all tombstone object records except a specified number of most recently created ones.
      void setConnection​(java.sql.Connection aConnection)
      Sets the JDBC connection.
      void startAutoCleaner()
      Starts a new thread for the TombstoneAutoCleaner
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • PROP_AUTODEL_AGE

        public static final java.lang.String PROP_AUTODEL_AGE
        When this property is present and contains an integer value greater than 0 the Tombstone Manager will automatically delete all tombstone records that are older than the specified number of days. The logic for tombstone record deletion is triggered on TDI Server startup and once a day on a long running TDI Server.

        The default value for this property is "0".
        See Also:
        Constant Field Values
      • PROP_AUTODEL_RECORDS_TRIGGER

        public static final java.lang.String PROP_AUTODEL_RECORDS_TRIGGER
        This property specifies the total number of tombstone records that will trigger the logic for leveling the number of tombstone records to a certain number.

        The default value for this property is "10000".
        See Also:
        Constant Field Values
      • PROP_AUTODEL_RECORDS_MAX

        public static final java.lang.String PROP_AUTODEL_RECORDS_MAX
        This property specifies the number of tombstone records to keep when the logic for leveling is triggered as per the PROP_AUTODEL_RECORDS_TRIGGER property. Alter the cleanup only the most recent (the value of this property) number of records will be kept.

        The default value for this property is "5000".
        See Also:
        Constant Field Values
      • PROP_CREATE_ALL

        public static final java.lang.String PROP_CREATE_ALL
        When this property is set to "true" the Tombstone Manager will create tombstones for every AssemblyLine and Config Instance regardless of the values specified in the configurations. This is useful to turn on tombstone creation for pre-6.1 configurations that do not have tombstone values without modifying the configurations.

        The default value for this property is "false".
        See Also:
        Constant Field Values
      • PROP_CREATE_TABLE

        public static final java.lang.String PROP_CREATE_TABLE
        This property is used to override the default "CREATE TABLE..." SQL statement. Use it if you want to add more records in the new table.
        See Also:
        Constant Field Values
      • PROP_UPDATE_TABLE

        public static final java.lang.String PROP_UPDATE_TABLE
        This property is used to override the default "INSERT INTO..." SQL statement. Use it if you want to add more records in the new table.
        See Also:
        Constant Field Values
      • TABLE_NAME

        public static final java.lang.String TABLE_NAME
        This constant has the name of the table that will be created/queried.
        See Also:
        Constant Field Values
      • PROP_FIELD_ID

        public static final java.lang.String PROP_FIELD_ID
        A constant for the column - ID
        See Also:
        Constant Field Values
      • PROP_FIELD_COMPONENT_TYPE_ID

        public static final java.lang.String PROP_FIELD_COMPONENT_TYPE_ID
        A constant for the column "COMPONENT_TYPE_ID"
        See Also:
        Constant Field Values
      • PROP_FIELD_EVENT_TYPE_ID

        public static final java.lang.String PROP_FIELD_EVENT_TYPE_ID
        A constant for the column "EVENT_TYPE_ID"
        See Also:
        Constant Field Values
      • PROP_FIELD_START_TIME

        public static final java.lang.String PROP_FIELD_START_TIME
        A constant for the column "START_TIME"
        See Also:
        Constant Field Values
      • PROP_FIELD_CREATED_ON

        public static final java.lang.String PROP_FIELD_CREATED_ON
        A constant for the column "CREATED_ON"
        See Also:
        Constant Field Values
      • PROP_FIELD_COMPONENT_NAME

        public static final java.lang.String PROP_FIELD_COMPONENT_NAME
        A constant for the column "COMPONENT_NAME"
        See Also:
        Constant Field Values
      • PROP_FIELD_CONFIGURATION

        public static final java.lang.String PROP_FIELD_CONFIGURATION
        A constant for the column "CONFIGURATION"
        See Also:
        Constant Field Values
      • PROP_FIELD_EXIT_CODE

        public static final java.lang.String PROP_FIELD_EXIT_CODE
        A constant for the column "EXIT_CODE"
        See Also:
        Constant Field Values
      • PROP_FIELD_ERROR_DESCR

        public static final java.lang.String PROP_FIELD_ERROR_DESCR
        A constant for the column "ERROR_DESCR"
        See Also:
        Constant Field Values
      • PROP_FIELD_GUID

        public static final java.lang.String PROP_FIELD_GUID
        A constant for the column "GUID"
        See Also:
        Constant Field Values
      • PROP_FIELD_STATS

        public static final java.lang.String PROP_FIELD_STATS
        A constant for the column "STATS"
        See Also:
        Constant Field Values
      • PROP_FIELD_USER_MESSAGE

        public static final java.lang.String PROP_FIELD_USER_MESSAGE
        A constant for the column "USER_MESSAGE"
        See Also:
        Constant Field Values
    • Constructor Detail

      • TombstoneManager

        public TombstoneManager()
                         throws DIException
        Default constructor for this object. Constructing this object will try to create a new table in the back-end store, if the table does not already exist.

        From 7.0 the cleaning process will not be triggered in the constructor but should be started immediately after that using startAutoCleaner() method.

        Throws:
        DIException
    • Method Detail

      • startAutoCleaner

        public void startAutoCleaner()
        Starts a new thread for the TombstoneAutoCleaner
      • getTombstone

        public Tombstone getTombstone​(java.lang.String aGUID)
                               throws DIException
        Get single tombstone object, uniquely identified by the specified GUID
        Parameters:
        aGUID - The GUID of the requested tombstone
        Returns:
        Tombstone object
        Throws:
        DIException
      • getAssemblyLineTombstones

        public Tombstone[] getAssemblyLineTombstones​(java.lang.String assemblyLineName,
                                                     java.lang.String configID,
                                                     int recentNumberOfTombstones)
                                              throws DIException
        Gets the recent n number of tombstones for a specified AssemblyLine
        Parameters:
        assemblyLineName - The name of the AssemblyLine.
        configID - The name of the AssmeblyLine's configuration.
        recentNumberOfTombstones - The recent n number of tombstones to be returned.
        Returns:
        an array of Tombstone objects.
        Throws:
        DIException
        Since:
        6.1.1
      • getAssemblyLineTombstones

        public Tombstone[] getAssemblyLineTombstones​(java.lang.String aAssemblyLineName,
                                                     java.lang.String aConfigID)
                                              throws DIException
        Get all available tombstones for a specified AssemblyLine.
        Parameters:
        aAssemblyLineName - The name of the AssemblyLine whose tombstones will be extracted.
        aConfigID - The AssemblyLine's configuration.
        Returns:
        An array of Tombstone objects for the specified AssemblyLine.
        Throws:
        DIException
      • getAssemblyLineTombstones

        public Tombstone[] getAssemblyLineTombstones​(java.lang.String aAssemblyLineName,
                                                     java.lang.String aConfigID,
                                                     java.util.Date aStartTime,
                                                     java.util.Date aEndTime)
                                              throws DIException
        Get all available tombstones for a specified AssemblyLine with timestamps in the interval specified by aStartTime and aEndTime.
        Parameters:
        aAssemblyLineName - The name of the AssemblyLine whose tombstones will be extracted.
        aConfigID - The AssemblyLine's configuration.
        aStartTime - The start time of the period for which tombstones are retrieved.
        aEndTime - The end time of the period for which tombstones are retrieved.
        Returns:
        An array of Tombstone objects for the specified AssemblyLine.
        Throws:
        DIException
      • getConfigInstanceTombstones

        public Tombstone[] getConfigInstanceTombstones​(java.lang.String aConfigID)
                                                throws DIException
        Get all available tombstones for a specified Configuration Instance.
        Parameters:
        aConfigID - The configuration ID.
        Returns:
        An array of Config Instance Tombstone objects.
        Throws:
        DIException
      • getConfigInstanceTombstones

        public Tombstone[] getConfigInstanceTombstones​(java.lang.String aConfigID,
                                                       java.util.Date aStartTime,
                                                       java.util.Date aEndTime)
                                                throws DIException
        Get all available tombstones for a specified ConfigInstance with timestamps in the interval specified by aStartTime and aEndTime.
        Parameters:
        aConfigID - The configuration ID.
        aStartTime - The start time of the period for which tombstone records are retrieved.
        aEndTime - The end time of the period for which tombstone records are retrieved.
        Returns:
        An array of Config Instance Tombstone objects.
        Throws:
        DIException
      • getTombstones

        public Tombstone[] getTombstones​(java.util.Date aStartTime,
                                         java.util.Date aEndTime)
                                  throws DIException
        Get all available tombstones with timestamps in the interval specified by aStartTime and aEndTime.
        Parameters:
        aStartTime - The start time of the period for which tombstone records are retrieved.
        aEndTime - The end time of the period for which tombstone records are retrieved.
        Returns:
        An array of Tombstone objects.
        Throws:
        DIException
      • deleteTombstones

        public int deleteTombstones​(int aDaysCount)
                             throws DIException
        Deletes all Tombstone objects that are older than the specified number of days.
        Parameters:
        aDaysCount - Number of days.
        Returns:
        The number of deleted tombstone records.
        Throws:
        DIException - if an error occurs.
      • keepMostRecentTombstones

        public int keepMostRecentTombstones​(int aRecentTombstonesToKeep)
                                     throws DIException
        Deletes all tombstone object records except a specified number of most recently created ones.
        Parameters:
        aRecentTombstonesToKeep - number of recent tombstones to keep.
        Returns:
        The number of deleted tombstone records.
        Throws:
        DIException
      • deleteALTombstones

        public int deleteALTombstones​(java.lang.String aAssemblyLineName,
                                      java.lang.String aConfigID)
                               throws DIException
        Deletes all Tombstone objects created for the specified AssemblyLine.
        Parameters:
        aAssemblyLineName - The name of the AssemblyLine.
        aConfigID - The AssmeblyLine configuration.
        Returns:
        The number of deleted records.
        Throws:
        DIException - if an error occurs.
      • deleteALTombstones

        public int deleteALTombstones​(java.lang.String aAssemblyLineName,
                                      java.lang.String aConfigID,
                                      int aDays)
                               throws DIException
        Deletes all Tombstone objects for a specified AssemblyLine that are older than the specified number of days.
        Parameters:
        aAssemblyLineName - The name of the AssemblyLine.
        aConfigID - The AssemblyLine configuration.
        aDays - Number of days.
        Returns:
        The number of deleted tombstone records.
        Throws:
        DIException - if an error occurs.
      • deleteALTombstones

        public int deleteALTombstones​(java.lang.String aAssemblyLineName,
                                      java.lang.String aConfigID,
                                      java.util.Date olderThanDate)
                               throws DIException
        Deletes all Tombstone objects for a specified AssemblyLine that are older than the specified date.
        Parameters:
        aAssemblyLineName - The name of the AssemblyLine.
        aConfigID - The AssemblyLine configuration.
        olderThanDate - Date
        Returns:
        The number of deleted tombstone records.
        Throws:
        DIException - if an error occurs.
      • deleteALTombstones

        public int deleteALTombstones​(java.lang.String aAssemblyLineName,
                                      java.lang.String aConfigID,
                                      java.util.Date startDate,
                                      java.util.Date endDate)
                               throws DIException
        Deletes all Tombstone objects for a specified AssemblyLine that are in the specified Date range.
        Parameters:
        aAssemblyLineName - The name of the AssemblyLine.
        aConfigID - The AssemblyLine configuration.
        startDate - Date
        endDate - Date
        Returns:
        The number of deleted tombstone records.
        Throws:
        DIException - if an error occurs.
      • keepMostRecentALTombstones

        public int keepMostRecentALTombstones​(java.lang.String aAssemblyLineName,
                                              java.lang.String aConfigID,
                                              int aRecentTombstonesToKeep)
                                       throws DIException
        Deletes all tombstones for a specified AssemblyLine except a specified number of most recently created ones.
        Parameters:
        aAssemblyLineName - The name of the AssemblyLine whose tombstone records will be deleted.
        aConfigID - The AssemblyLine configuration.
        aRecentTombstonesToKeep - Number of recent tombstones to keep.
        Returns:
        The number of deleted records.
        Throws:
        DIException
      • deleteCITombstones

        public int deleteCITombstones​(java.lang.String aConfigID)
                               throws DIException
        Deletes all tombstones for a specified Config Instance.
        Parameters:
        aConfigID - The configuration ID.
        Returns:
        The number of deleted tombstone records.
        Throws:
        DIException - if an error occurs.
      • deleteCITombstones

        public int deleteCITombstones​(java.lang.String aConfigID,
                                      int aDays)
                               throws DIException
        Deletes all Tombstone objects for a specified Config Instance that are older than the specified number of days.
        Parameters:
        aConfigID - The configuration ID.
        aDays - Number of days.
        Returns:
        The number of deleted tombstone records.
        Throws:
        DIException - if an error occurs.
      • keepMostRecentCITombstones

        public int keepMostRecentCITombstones​(java.lang.String aConfigID,
                                              int aRecentTombstonesToKeep)
                                       throws DIException
        Deletes all tombstones for a Config Instance except a specified number of recently created ones.
        Parameters:
        aConfigID - The configuration ID.
        aRecentTombstonesToKeep - The number of most recent tombstones to keep.
        Returns:
        The number of deleted records.
        Throws:
        DIException
      • deleteTombstone

        public boolean deleteTombstone​(java.lang.String aGUID)
                                throws DIException
        Deletes a tombstone.
        Parameters:
        aGUID - The GUID of the tombstone to delete.
        Returns:
        true only when the tombstone with the specified GUID is found and deleted.
        Throws:
        DIException - if an error occurs.
      • setConnection

        public void setConnection​(java.sql.Connection aConnection)
        Sets the JDBC connection.
        Parameters:
        aConnection - the connection to use.
      • getConnection

        public java.sql.Connection getConnection()
        Gets the JDBC connection.
        Returns:
        the connection to the database.
      • getTombstonesCount

        public int getTombstonesCount()
                               throws DIException
        Returns:
        the number of Tombstones in the back-end store.
        Throws:
        DIException - if an error occurs.
      • doInsert

        protected void doInsert​(int aComponentTypeID,
                                int aEventTypeID,
                                long aStartTime,
                                long aCreatedOn,
                                java.lang.String aComponentName,
                                java.lang.String aConfiguration,
                                int aExitCode,
                                java.lang.String aErrorDescr,
                                java.lang.String aGUID,
                                byte[] aStats,
                                java.lang.String aUserMessage)
                         throws DIException
        Inserts a tombstone record in the back-end database.
        Parameters:
        aComponentTypeID - the type of the component.
        aEventTypeID - the type of the event.
        aStartTime - the time the component was started.
        aCreatedOn - the time the component was created.
        aComponentName - the name of the component.
        aConfiguration - the configuration id of the configInstance the AL was started in.
        aExitCode - the code the component exited with.
        aErrorDescr - the description of the error (if any) the component ended with.
        aGUID - the globally unique identifier of the tombstone.
        aStats - the statistics as a serialized Entry object.
        aUserMessage - the user message.
        Throws:
        DIException - if an error occurs.
      • finalize

        protected void finalize()
                         throws java.lang.Throwable
        Close the prepared statement.
        Overrides:
        finalize in class java.lang.Object
        Throws:
        java.lang.Throwable
      • getConfigInstanceIDs

        public java.util.List<java.lang.String> getConfigInstanceIDs()
                                                              throws DIException
        Throws:
        DIException
      • hasTombstones

        public boolean hasTombstones​(java.lang.String configInstanceId)
                              throws DIException
        Throws:
        DIException
      • getAssemblyLineNames

        public java.util.List<java.lang.String> getAssemblyLineNames​(java.lang.String configInstanceId)
                                                              throws DIException
        Throws:
        DIException
      • hasTombstones

        public boolean hasTombstones​(java.lang.String configInstanceId,
                                     java.lang.String alName)
                              throws DIException
        Throws:
        DIException