com.metamatrix.dqp.spi.basic
Class FileCommandLogger

java.lang.Object
  extended by com.metamatrix.dqp.spi.basic.FileCommandLogger
All Implemented Interfaces:
CommandLoggerSPI

public class FileCommandLogger
extends java.lang.Object
implements CommandLoggerSPI

Command logger service provider which logs to a file. The filename must be supplied as a DQP property, see LOG_FILE_NAME_PROPERTY.

This implementation is intended purely as an example. It is not intended for a heavy, enterprise load. It is built using an internal java.io.BufferedWriter. Each log entry will be on a new line, and the BufferedWriter is flushed after each line is written. Timestamps are included for each log entry.


Field Summary
static java.lang.String LOG_FILE_NAME_PROPERTY
          The property name of the log filename property; name and value must be supplied in DQP properties.
 
Constructor Summary
FileCommandLogger()
           
 
Method Summary
 void close()
          This method causes the internal java.io.BufferedWriter to be closed.
 void dataSourceCommandEnd(long timestamp, java.lang.String requestID, long sourceCommandID, java.lang.String subTransactionID, java.lang.String modelName, java.lang.String connectorBindingName, java.lang.String sessionID, java.lang.String principal, int finalRowCount, boolean isCancelled, boolean errorOccurred, ExecutionContext context)
          Logs an entry for data source command ending.
 void dataSourceCommandStart(long timestamp, java.lang.String requestID, long sourceCommandID, java.lang.String subTransactionID, java.lang.String modelName, java.lang.String connectorBindingName, java.lang.String sessionID, java.lang.String principal, java.lang.String sql, ExecutionContext context)
          Logs an entry for data source command starting.
 void initialize(java.util.Properties props)
          Initialize this command logger.
 void transactionEnd(long timestamp, java.lang.String transactionID, java.lang.String sessionID, java.lang.String principal, java.lang.String vdbName, java.lang.String vdbVersion, boolean isCommit)
          Logs an entry for transaction ending.
 void transactionStart(long timestamp, java.lang.String transactionID, java.lang.String sessionID, java.lang.String principal, java.lang.String vdbName, java.lang.String vdbVersion)
          Logs an entry for transaction starting.
 void userCommandEnd(long timestamp, java.lang.String requestID, java.lang.String transactionID, java.lang.String sessionID, java.lang.String principal, java.lang.String vdbName, java.lang.String vdbVersion, int finalRowCount, boolean isCancelled, boolean errorOccurred)
          Logs an entry for user command ending.
 void userCommandStart(long timestamp, java.lang.String requestID, java.lang.String transactionID, java.lang.String sessionID, java.lang.String applicationName, java.lang.String principal, java.lang.String vdbName, java.lang.String vdbVersion, java.lang.String sql)
          Logs an entry for user command starting.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG_FILE_NAME_PROPERTY

public static final java.lang.String LOG_FILE_NAME_PROPERTY
The property name of the log filename property; name and value must be supplied in DQP properties. The value should be a String file name suitable for instantiating a java.io.BufferedWriter instance.

See Also:
Constant Field Values
Constructor Detail

FileCommandLogger

public FileCommandLogger()
Method Detail

initialize

public void initialize(java.util.Properties props)
Initialize this command logger. This requires the LOG_FILE_NAME_PROPERTY property. After this method is called, a java.io.BufferedWriter will be opened to the file. Any exception in opening the BufferedWriter will be printed to System.out.

Specified by:
initialize in interface CommandLoggerSPI
Parameters:
props - Initialialization properties
See Also:
LOG_FILE_NAME_PROPERTY, CommandLoggerSPI.initialize(java.util.Properties)

close

public void close()
This method causes the internal java.io.BufferedWriter to be closed.

Specified by:
close in interface CommandLoggerSPI
See Also:
CommandLoggerSPI.close()

userCommandStart

public void userCommandStart(long timestamp,
                             java.lang.String requestID,
                             java.lang.String transactionID,
                             java.lang.String sessionID,
                             java.lang.String applicationName,
                             java.lang.String principal,
                             java.lang.String vdbName,
                             java.lang.String vdbVersion,
                             java.lang.String sql)
Logs an entry for user command starting.

Specified by:
userCommandStart in interface CommandLoggerSPI
Parameters:
timestamp - time in milliseconds marking the start of the command
requestID - Unique command ID.
transactionID - Unique transaction ID (optional, may be null)
sessionID - Session ID.
applicationName - name of the user application
principal - User name.
vdbName - VDB name.
vdbVersion - VDB version.
sql - SQL for the command.
See Also:
com.metamatrix.dqp.spi.CommandLoggerSPI#userCommandStart(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)

userCommandEnd

public void userCommandEnd(long timestamp,
                           java.lang.String requestID,
                           java.lang.String transactionID,
                           java.lang.String sessionID,
                           java.lang.String principal,
                           java.lang.String vdbName,
                           java.lang.String vdbVersion,
                           int finalRowCount,
                           boolean isCancelled,
                           boolean errorOccurred)
Logs an entry for user command ending.

Specified by:
userCommandEnd in interface CommandLoggerSPI
Parameters:
timestamp - time in milliseconds marking the end of the command.
requestID - Unique command ID.
transactionID - Unique transaction ID (optional, may be null)
sessionID - Session ID.
principal - User name.
vdbName - VDB name.
vdbVersion - VDB version.
finalRowCount - total rows returned to the user.
isCancelled - true if command was requested to be cancelled, false otherwise.
errorOccurred - true if error occurred, false if status is okay.
See Also:
com.metamatrix.dqp.spi.CommandLoggerSPI#userCommandEnd(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean, boolean)

dataSourceCommandStart

public void dataSourceCommandStart(long timestamp,
                                   java.lang.String requestID,
                                   long sourceCommandID,
                                   java.lang.String subTransactionID,
                                   java.lang.String modelName,
                                   java.lang.String connectorBindingName,
                                   java.lang.String sessionID,
                                   java.lang.String principal,
                                   java.lang.String sql,
                                   ExecutionContext context)
Logs an entry for data source command starting.

Specified by:
dataSourceCommandStart in interface CommandLoggerSPI
Parameters:
timestamp - time in milliseconds marking the start of the source command.
requestID - Unique command ID.
sourceCommandID - unique ID of source command, which is also the ID of the plan node representing that source command.
subTransactionID - Unique subtransaction ID (optional, may be null).
modelName - Name of model.
connectorBindingName - Connector binding name.
sessionID - Session ID.
principal - User name.
sql - SQL for the command.
See Also:
com.metamatrix.dqp.spi.CommandLoggerSPI#dataSourceCommandStart(java.lang.String, long, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)

dataSourceCommandEnd

public void dataSourceCommandEnd(long timestamp,
                                 java.lang.String requestID,
                                 long sourceCommandID,
                                 java.lang.String subTransactionID,
                                 java.lang.String modelName,
                                 java.lang.String connectorBindingName,
                                 java.lang.String sessionID,
                                 java.lang.String principal,
                                 int finalRowCount,
                                 boolean isCancelled,
                                 boolean errorOccurred,
                                 ExecutionContext context)
Logs an entry for data source command ending.

Specified by:
dataSourceCommandEnd in interface CommandLoggerSPI
Parameters:
timestamp - time in milliseconds marking the end of the source command.
requestID - Unique command ID.
sourceCommandID - unique ID of source command, which is also the ID of the plan node representing that source command.
subTransactionID - Unique subtransaction ID (optional, may be null).
modelName - Name of model.
connectorBindingName - Connector binding name.
sessionID - Session ID.
principal - User name.
finalRowCount - Final row count.
isCancelled - true if command was requested to be cancelled, false otherwise.
errorOccurred - true if error occurred, false if status is okay.
See Also:
com.metamatrix.dqp.spi.CommandLoggerSPI#dataSourceCommandEnd(java.lang.String, long, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, int, boolean, boolean)

transactionStart

public void transactionStart(long timestamp,
                             java.lang.String transactionID,
                             java.lang.String sessionID,
                             java.lang.String principal,
                             java.lang.String vdbName,
                             java.lang.String vdbVersion)
Logs an entry for transaction starting.

See Also:
com.metamatrix.dqp.spi.CommandLoggerSPI#transactionStart(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)

transactionEnd

public void transactionEnd(long timestamp,
                           java.lang.String transactionID,
                           java.lang.String sessionID,
                           java.lang.String principal,
                           java.lang.String vdbName,
                           java.lang.String vdbVersion,
                           boolean isCommit)
Logs an entry for transaction ending.

See Also:
com.metamatrix.dqp.spi.CommandLoggerSPI#transactionEnd(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean)


Copyright © 2009. All Rights Reserved.