atg.service.datacollection
Class JTSQLTableLogger

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.service.datacollection.JTSQLTableLogger
All Implemented Interfaces:
atg.naming.AbsoluteNameable, NameContextBindingListener, NameContextElement, atg.naming.NameContextParentable, NameResolver, AdminableService, atg.nucleus.Configured, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, LogListener, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, DataCollector, DataListener, atg.service.jdbc.DataSourceShutdownListener, Schedulable, java.util.EventListener
Direct Known Subclasses:
JTSQLTableSummaryLogger

public class JTSQLTableLogger
extends GenericService
implements DataCollector, Schedulable, LogListener, atg.service.jdbc.DataSourceShutdownListener

A DataCollector that logs items to an SQL table. This collector supports receiving data from a DataListenerQueue. It supports flushing its data either based on a schedule (via the Schedulable interface) or an item threshold. For production systems it is recommended that a DataListerQueue and schedule based flushing be used.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
JTSQLTableLogger()
          Construct an JTSQLTableLogger
 
Method Summary
 void addDataItem(java.lang.Object pDataItem)
          Add the given data item to the aggregate
 void dataSourceShutdown(atg.service.jdbc.DataSourceShutdownEvent pEvent)
          Method called before a DataSource is stopped.
 void doStartService()
          Perform any necessary initializations to startup service.
If a schedule is provided, then it is started.
 void doStopService()
          Performs tasks required to shutdown service.
 void flush()
          Flush our data buffer by writing all of the data to the SQL table and resetting our internal state accordingly.
 int getBufferSize()
          Get property BufferSize
 long getConnectRetryInterval()
          Get property ConnectRetryInterval
 int getDataItemCount()
          Returns property DataItemCount
 int getDataItemThreshold()
          Returns property DataItemThreshold
 javax.sql.DataSource getDataSource()
          Returns property DataSource
 java.lang.String getInsertSQL()
          Returns property InsertSQL
 java.lang.String getJobDescription()
          Returns property JobDescription
 java.lang.String getJobName()
          Returns property JobName
 boolean getLocalTransactionModeInitialization()
          Get property localTransactionModeInitialization
 java.lang.String getMetaDataCatalogName()
          Get the catalog name
 java.lang.String getMetaDataSchemaPattern()
          Get the schema name
 long getMinimumErrorReportInterval()
          Get property MinimumErrorReportInterval
protected  java.lang.String getQualifiedTableName()
          A convenience method to set and retrieve the qualified table name.
 Schedule getSchedule()
          Returns property Schedule
 Scheduler getScheduler()
          Returns property Scheduler
 SQLColumnMapping[] getSQLColumnMappings()
          Returns property SQLColumnMappings
 int[] getSQLColumnSizes()
          Returns property SQLColumnSizes
 java.lang.String getTableName()
          Returns property TableName
 java.lang.String getTablePrefix()
          Returns property TablePrefix
 javax.transaction.TransactionManager getTransactionManager()
          Returns property TransactionManager
 int getTransactionSize()
          Get property TransactionSize
protected  java.lang.Object[] getValueArray(java.lang.Object pDataItem, java.lang.Object[] buffer)
           
 boolean isAutoCommitInitialization()
          Returns property AutoCommitInitialization
 boolean isBlocking()
          Get property Blocking
 boolean isEnableSQLbatch()
          Returns property EnableSQLbatch
 boolean isEnableTruncation()
          Returns property EnableTruncation
 boolean isLocalTransactionModeInitialization()
          Test property localTransactionModeInitialization
 boolean isSetAutoCommit()
          Returns property SetAutoCommit
 void logEvent(LogEvent pLogEvent)
          Log an event.
 void performScheduledTask(Scheduler pScheduler, ScheduledJob pJob)
          Callback method for the scheduler.
 void sanitizeSQLColumnMappings()
          Filter out invalid column mappings
 void setAutoCommitInitialization(boolean pAutoCommitInitialization)
          Sets property AutoCommitInitialization
 void setBlocking(boolean pBlocking)
          Set property Blocking
 void setBufferSize(int pBufferSize)
          Set property BufferSize, which may cause the buffer to be flushed and reconstructed.
 void setConnectRetryInterval(long pConnectRetryInterval)
          Set property ConnectRetryInterval
 void setDataItemThreshold(int pDataItemThreshold)
          Sets property DataItemThreshold
 void setDataSource(javax.sql.DataSource pDataSource)
          Sets property DataSource
 void setEnableSQLbatch(boolean pEnableSQLbatch)
          Sets property EnableSQLbatch
 void setEnableTruncation(boolean pEnableTruncation)
          Sets property EnableTruncation
 void setJobDescription(java.lang.String pJobDescription)
          Sets property JobDescription
 void setJobName(java.lang.String pJobName)
          Sets property JobName
 void setLocalTransactionModeInitialization(boolean pLocalTransactionModeInitialization)
          Set property localTransactionModeInitialization
 void setMetaDataCatalogName(java.lang.String pMetaDataCatalogName)
          The name of a catalog
 void setMetaDataSchemaPattern(java.lang.String pMetaDataSchemaPattern)
          Set the schema name
 void setMinimumErrorReportInterval(long pMinimumErrorReportInterval)
          Set property MinimumErrorReportInterval
 void setSchedule(Schedule pSchedule)
          Sets property Schedule
 void setScheduler(Scheduler pScheduler)
          Sets property Scheduler
 void setSetAutoCommit(boolean pSetAutoCommit)
          Sets property SetAutoCommit
 void setSQLColumnMappings(SQLColumnMapping[] pSQLColumnMappings)
          Sets property SQLColumnMappings
 void setSQLColumnSizes(int[] pSQLColumnSizes)
          Sets property SQLColumnSizes
 void setTableName(java.lang.String pTableName)
          Sets property TableName
 void setTablePrefix(java.lang.String pTablePrefix)
          Sets property TablePrefix
 void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
          Sets property TransactionManager
 void setTransactionSize(int pTransactionSize)
          Set property TransactionSize
protected  void startScheduledJob()
          If we have a schedule, start scheduled job
 java.lang.String toString()
           
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static final java.lang.String CLASS_VERSION
Class version string

See Also:
Constant Field Values
Constructor Detail

JTSQLTableLogger

public JTSQLTableLogger()
Construct an JTSQLTableLogger

Method Detail

setLocalTransactionModeInitialization

public void setLocalTransactionModeInitialization(boolean pLocalTransactionModeInitialization)
Set property localTransactionModeInitialization

Parameters:
pLocalTransactionModeInitialization - new value to set

getLocalTransactionModeInitialization

public boolean getLocalTransactionModeInitialization()
Get property localTransactionModeInitialization

Returns:
localTransactionModeInitialization

isLocalTransactionModeInitialization

public boolean isLocalTransactionModeInitialization()
Test property localTransactionModeInitialization

Returns:
localTransactionModeInitialization

setSQLColumnSizes

public void setSQLColumnSizes(int[] pSQLColumnSizes)
Sets property SQLColumnSizes


getSQLColumnSizes

public int[] getSQLColumnSizes()
Returns property SQLColumnSizes


setScheduler

public void setScheduler(Scheduler pScheduler)
Sets property Scheduler


getScheduler

public Scheduler getScheduler()
Returns property Scheduler


setSchedule

public void setSchedule(Schedule pSchedule)
Sets property Schedule


getSchedule

public Schedule getSchedule()
Returns property Schedule


setJobName

public void setJobName(java.lang.String pJobName)
Sets property JobName


getJobName

public java.lang.String getJobName()
Returns property JobName


setJobDescription

public void setJobDescription(java.lang.String pJobDescription)
Sets property JobDescription


getJobDescription

public java.lang.String getJobDescription()
Returns property JobDescription


setDataSource

public void setDataSource(javax.sql.DataSource pDataSource)
Sets property DataSource


getDataSource

public javax.sql.DataSource getDataSource()
Returns property DataSource


getDataItemCount

public int getDataItemCount()
Returns property DataItemCount


setDataItemThreshold

public void setDataItemThreshold(int pDataItemThreshold)
Sets property DataItemThreshold


getDataItemThreshold

public int getDataItemThreshold()
Returns property DataItemThreshold


getInsertSQL

public java.lang.String getInsertSQL()
Returns property InsertSQL


setTableName

public void setTableName(java.lang.String pTableName)
Sets property TableName


getTableName

public java.lang.String getTableName()
Returns property TableName


setSQLColumnMappings

public void setSQLColumnMappings(SQLColumnMapping[] pSQLColumnMappings)
Sets property SQLColumnMappings


getSQLColumnMappings

public SQLColumnMapping[] getSQLColumnMappings()
Returns property SQLColumnMappings


setBufferSize

public void setBufferSize(int pBufferSize)
Set property BufferSize, which may cause the buffer to be flushed and reconstructed.

Parameters:
pBufferSize - new value to set

getBufferSize

public int getBufferSize()
Get property BufferSize

Returns:
BufferSize

setTransactionManager

public void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
Sets property TransactionManager


getTransactionManager

public javax.transaction.TransactionManager getTransactionManager()
Returns property TransactionManager


setTransactionSize

public void setTransactionSize(int pTransactionSize)
Set property TransactionSize

Parameters:
pTransactionSize - new value to set

getTransactionSize

public int getTransactionSize()
Get property TransactionSize

Returns:
TransactionSize

setBlocking

public void setBlocking(boolean pBlocking)
Set property Blocking

Parameters:
pBlocking - new value to set

isBlocking

public boolean isBlocking()
Get property Blocking

Returns:
Blocking

setConnectRetryInterval

public void setConnectRetryInterval(long pConnectRetryInterval)
Set property ConnectRetryInterval

Parameters:
pConnectRetryInterval - new value to set

getConnectRetryInterval

public long getConnectRetryInterval()
Get property ConnectRetryInterval

Returns:
ConnectRetryInterval

setMinimumErrorReportInterval

public void setMinimumErrorReportInterval(long pMinimumErrorReportInterval)
Set property MinimumErrorReportInterval

Parameters:
pMinimumErrorReportInterval - new value to set

getMinimumErrorReportInterval

public long getMinimumErrorReportInterval()
Get property MinimumErrorReportInterval

Returns:
MinimumErrorReportInterval

setEnableTruncation

public void setEnableTruncation(boolean pEnableTruncation)
Sets property EnableTruncation


isEnableTruncation

public boolean isEnableTruncation()
Returns property EnableTruncation


setEnableSQLbatch

public void setEnableSQLbatch(boolean pEnableSQLbatch)
Sets property EnableSQLbatch


isEnableSQLbatch

public boolean isEnableSQLbatch()
Returns property EnableSQLbatch


setMetaDataCatalogName

public void setMetaDataCatalogName(java.lang.String pMetaDataCatalogName)
The name of a catalog

Parameters:
String - the name of a catalog

getMetaDataCatalogName

public java.lang.String getMetaDataCatalogName()
Get the catalog name

Returns:
the catalog name

setMetaDataSchemaPattern

public void setMetaDataSchemaPattern(java.lang.String pMetaDataSchemaPattern)
Set the schema name

Parameters:
String - the schema name

getMetaDataSchemaPattern

public java.lang.String getMetaDataSchemaPattern()
Get the schema name

Returns:
the schema name

setTablePrefix

public void setTablePrefix(java.lang.String pTablePrefix)
Sets property TablePrefix


getTablePrefix

public java.lang.String getTablePrefix()
Returns property TablePrefix


getQualifiedTableName

protected java.lang.String getQualifiedTableName()
A convenience method to set and retrieve the qualified table name.

Returns:
either the simple table name, or "schemaName"+"tableName", or null if tableName is null.

setSetAutoCommit

public void setSetAutoCommit(boolean pSetAutoCommit)
Sets property SetAutoCommit


isSetAutoCommit

public boolean isSetAutoCommit()
Returns property SetAutoCommit


setAutoCommitInitialization

public void setAutoCommitInitialization(boolean pAutoCommitInitialization)
Sets property AutoCommitInitialization


isAutoCommitInitialization

public boolean isAutoCommitInitialization()
Returns property AutoCommitInitialization


logEvent

public void logEvent(LogEvent pLogEvent)
Log an event. This is a convenience method. We just pass this through to addDataItem.

Specified by:
logEvent in interface LogListener
Parameters:
pLogEvent - the log event

addDataItem

public void addDataItem(java.lang.Object pDataItem)
Add the given data item to the aggregate

Specified by:
addDataItem in interface DataListener
Parameters:
pDataItem -

getValueArray

protected java.lang.Object[] getValueArray(java.lang.Object pDataItem,
                                           java.lang.Object[] buffer)

sanitizeSQLColumnMappings

public void sanitizeSQLColumnMappings()
Filter out invalid column mappings


doStartService

public void doStartService()
                    throws ServiceException
Perform any necessary initializations to startup service.
If a schedule is provided, then it is started.

Overrides:
doStartService in class GenericService
Throws:
ServiceException - if the Service had a problem starting up

doStopService

public void doStopService()
                   throws ServiceException
Performs tasks required to shutdown service.

Overrides:
doStopService in class GenericService
Throws:
ServiceException - if the Service had a problem shutting down

dataSourceShutdown

public void dataSourceShutdown(atg.service.jdbc.DataSourceShutdownEvent pEvent)
Method called before a DataSource is stopped.

Specified by:
dataSourceShutdown in interface atg.service.jdbc.DataSourceShutdownListener
Parameters:
pEvent - event containing the shutting down DataSource

startScheduledJob

protected void startScheduledJob()
If we have a schedule, start scheduled job


performScheduledTask

public void performScheduledTask(Scheduler pScheduler,
                                 ScheduledJob pJob)
Callback method for the scheduler. Flush out our summarized data.

Specified by:
performScheduledTask in interface Schedulable
Parameters:
pScheduler - calling the job
pJob - the ScheduledJob

flush

public void flush()
Flush our data buffer by writing all of the data to the SQL table and resetting our internal state accordingly. This method can be called even if there is no data or no data buffer, in which case it will do nothing.

Specified by:
flush in interface DataCollector

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object