use of com.axway.ats.log.autodb.exceptions.DatabaseAccessException in project ats-framework by Axway.
the class AbstractDbAppender method activateOptions.
/* (non-Javadoc)
* @see org.apache.log4j.AppenderSkeleton#activateOptions()
*/
@Override
public void activateOptions() {
//check whether the configuration is valid first
try {
appenderConfig.validate();
} catch (InvalidAppenderConfigurationException iace) {
throw new DbAppenederException(iace);
}
//set the threshold if there is such
appenderConfig.setLoggingThreshold(getThreshold());
//the logging queue
queue = new ArrayBlockingQueue<LogEventRequest>(getMaxNumberLogEvents());
// enable batch mode at ATS Agent side only
boolean isWorkingAtAgentSide = this instanceof PassiveDbAppender;
boolean isBatchMode = false;
if (isWorkingAtAgentSide) {
isBatchMode = isBatchMode();
}
//create new event processor
try {
eventProcessor = new DbEventRequestProcessor(appenderConfig, layout, getEventRequestProcessorListener(), isBatchMode);
} catch (DatabaseAccessException e) {
throw new RuntimeException("Unable to create DB event processor", e);
}
//start the logging thread
queueLogger = new QueueLoggerThread(queue, eventProcessor, isBatchMode);
queueLogger.setDaemon(true);
queueLogger.start();
}
use of com.axway.ats.log.autodb.exceptions.DatabaseAccessException in project ats-framework by Axway.
the class DbAccessFactory method getNewDbWriteAccessObject.
/**
* Retrieves the DB info from the log4j system
* and then creates a new instance for writing into the DB
*
* @return
* @throws DatabaseAccessException
*/
public DbWriteAccess getNewDbWriteAccessObject() throws DatabaseAccessException {
// Our DB appender keeps the DB connection info
ActiveDbAppender loggingAppender = ActiveDbAppender.getCurrentInstance();
if (loggingAppender == null) {
throw new DatabaseAccessException("Unable to initialize connection to the logging database as the ATS ActiveDbAppender is not attached to log4j system");
}
// Create DB connection based on the log4j system settings
DbConnection dbConnection = new DbConnSQLServer(loggingAppender.getHost(), loggingAppender.getDatabase(), loggingAppender.getUser(), loggingAppender.getPassword());
// Create the database access layer
return new DbWriteAccess(dbConnection, false);
}
Aggregations