com.ibm.di.api.tm
Class TombstoneManager

java.lang.Object
  extended by com.ibm.di.api.tm.TombstoneManager

public class TombstoneManager
extends Object

This class is used to manage Tombstone objects. It contains methods to retrieve and delete tombstone objects on a specific criteria.


Field Summary
static int COMPONENT_TYPE_ASSEMBLY_LINE
          This constant could be used as value for the Tombstone.PROPERTY_NAME_COMPONENT_TYPE_ID property.
static int COMPONENT_TYPE_CONFIG_INSTANCE
          This constant could be used as value for the Tombstone.PROPERTY_NAME_COMPONENT_TYPE_ID property.
static int COMPONENT_TYPE_EVENT_HANDLER
          This constant could be used as value for the Tombstone.PROPERTY_NAME_COMPONENT_TYPE_ID property.
static 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.
static 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.
static 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".
static 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.
static String PROP_CREATE_TABLE
          This property is used to override the default "CREATE TABLE..." SQL statement.
static String PROP_FIELD_COMPONENT_NAME
          A constant for the column "COMPONENT_NAME"
static String PROP_FIELD_COMPONENT_TYPE_ID
          A constant for the column "COMPONENT_TYPE_ID"
static String PROP_FIELD_CONFIGURATION
          A constant for the column "CONFIGURATION"
static String PROP_FIELD_CREATED_ON
          A constant for the column "CREATED_ON"
static String PROP_FIELD_ERROR_DESCR
          A constant for the column "ERROR_DESCR"
static String PROP_FIELD_EVENT_TYPE_ID
          A constant for the column "EVENT_TYPE_ID"
static String PROP_FIELD_EXIT_CODE
          A constant for the column "EXIT_CODE"
static String PROP_FIELD_GUID
          A constant for the column "GUID"
static String PROP_FIELD_ID
          A constant for the column - ID
static String PROP_FIELD_START_TIME
          A constant for the column "START_TIME"
static String PROP_FIELD_STATS
          A constant for the column "STATS"
static String PROP_FIELD_USER_MESSAGE
          A constant for the column "USER_MESSAGE"
static String TABLE_NAME
          This constant has the name of the table that will be created/queried.
 
Constructor Summary
TombstoneManager()
          Default constructor for this object.
 
Method Summary
 int deleteALTombstones(String aAssemblyLineName, String aConfigID)
          Deletes all Tombstone objects created for the specified AssemblyLine.
 int deleteALTombstones(String aAssemblyLineName, String aConfigID, Date olderThanDate)
          Deletes all Tombstone objects for a specified AssemblyLine that are older than the specified date.
 int deleteALTombstones(String aAssemblyLineName, String aConfigID, Date startDate, Date endDate)
          Deletes all Tombstone objects for a specified AssemblyLine that are in the specified Date range.
 int deleteALTombstones(String aAssemblyLineName, String aConfigID, int aDays)
          Deletes all Tombstone objects for a specified AssemblyLine that are older than the specified number of days.
 int deleteCITombstones(String aConfigID)
          Deletes all tombstones for a specified Config Instance.
 int deleteCITombstones(String aConfigID, int aDays)
          Deletes all Tombstone objects for a specified Config Instance that are older than the specified number of days.
 boolean deleteTombstone(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, String aComponentName, String aConfiguration, int aExitCode, String aErrorDescr, String aGUID, byte[] aStats, String aUserMessage)
          Inserts a tombstone record in the back-end database.
protected  void finalize()
          Close the prepared statement.
 Tombstone[] getAssemblyLineTombstones(String aAssemblyLineName, String aConfigID)
          Get all available tombstones for a specified AssemblyLine.
 Tombstone[] getAssemblyLineTombstones(String aAssemblyLineName, String aConfigID, Date aStartTime, Date aEndTime)
          Get all available tombstones for a specified AssemblyLine with timestamps in the interval specified by aStartTime and aEndTime.
 Tombstone[] getAssemblyLineTombstones(String assemblyLineName, String configID, int recentNumberOfTombstones)
          Gets the recent n number of tombstones for a specified AssemblyLine
 Tombstone[] getConfigInstanceTombstones(String aConfigID)
          Get all available tombstones for a specified Configuration Instance.
 Tombstone[] getConfigInstanceTombstones(String aConfigID, Date aStartTime, Date aEndTime)
          Get all available tombstones for a specified ConfigInstance with timestamps in the interval specified by aStartTime and aEndTime.
 Connection getConnection()
          Gets the JDBC connection.
 Tombstone getTombstone(String aGUID)
          Get single tombstone object, uniquely identified by the specified GUID
 Tombstone[] getTombstones(Date aStartTime, Date aEndTime)
          Get all available tombstones with timestamps in the interval specified by aStartTime and aEndTime.
 int getTombstonesCount()
           
 int keepMostRecentALTombstones(String aAssemblyLineName, String aConfigID, int aRecentTombstonesToKeep)
          Deletes all tombstones for a specified AssemblyLine except a specified number of most recently created ones.
 int keepMostRecentCITombstones(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(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 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 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 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 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 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

COMPONENT_TYPE_CONFIG_INSTANCE

public static final int COMPONENT_TYPE_CONFIG_INSTANCE
This constant could be used as value for the Tombstone.PROPERTY_NAME_COMPONENT_TYPE_ID property.
The value of this constant is: 0

See Also:
Constant Field Values

COMPONENT_TYPE_ASSEMBLY_LINE

public static final int COMPONENT_TYPE_ASSEMBLY_LINE
This constant could be used as value for the Tombstone.PROPERTY_NAME_COMPONENT_TYPE_ID property.
The value of this constant is: 1

See Also:
Constant Field Values

COMPONENT_TYPE_EVENT_HANDLER

public static final int COMPONENT_TYPE_EVENT_HANDLER
This constant could be used as value for the Tombstone.PROPERTY_NAME_COMPONENT_TYPE_ID property.
The value of this constant is: 2

See Also:
Constant Field Values

TABLE_NAME

public static final 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 String PROP_FIELD_ID
A constant for the column - ID

See Also:
Constant Field Values

PROP_FIELD_COMPONENT_TYPE_ID

public static final 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 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 String PROP_FIELD_START_TIME
A constant for the column "START_TIME"

See Also:
Constant Field Values

PROP_FIELD_CREATED_ON

public static final String PROP_FIELD_CREATED_ON
A constant for the column "CREATED_ON"

See Also:
Constant Field Values

PROP_FIELD_COMPONENT_NAME

public static final String PROP_FIELD_COMPONENT_NAME
A constant for the column "COMPONENT_NAME"

See Also:
Constant Field Values

PROP_FIELD_CONFIGURATION

public static final String PROP_FIELD_CONFIGURATION
A constant for the column "CONFIGURATION"

See Also:
Constant Field Values

PROP_FIELD_EXIT_CODE

public static final String PROP_FIELD_EXIT_CODE
A constant for the column "EXIT_CODE"

See Also:
Constant Field Values

PROP_FIELD_ERROR_DESCR

public static final String PROP_FIELD_ERROR_DESCR
A constant for the column "ERROR_DESCR"

See Also:
Constant Field Values

PROP_FIELD_GUID

public static final String PROP_FIELD_GUID
A constant for the column "GUID"

See Also:
Constant Field Values

PROP_FIELD_STATS

public static final String PROP_FIELD_STATS
A constant for the column "STATS"

See Also:
Constant Field Values

PROP_FIELD_USER_MESSAGE

public static final 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(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(String assemblyLineName,
                                             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(String aAssemblyLineName,
                                             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(String aAssemblyLineName,
                                             String aConfigID,
                                             Date aStartTime,
                                             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(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(String aConfigID,
                                               Date aStartTime,
                                               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(Date aStartTime,
                                 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(String aAssemblyLineName,
                              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(String aAssemblyLineName,
                              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(String aAssemblyLineName,
                              String aConfigID,
                              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(String aAssemblyLineName,
                              String aConfigID,
                              Date startDate,
                              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(String aAssemblyLineName,
                                      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(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(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(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(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(Connection aConnection)
Sets the JDBC connection.

Parameters:
aConnection - the connection to use.

getConnection

public 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,
                        String aComponentName,
                        String aConfiguration,
                        int aExitCode,
                        String aErrorDescr,
                        String aGUID,
                        byte[] aStats,
                        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 Throwable
Close the prepared statement.

Overrides:
finalize in class Object
Throws:
Throwable