From 13384f311375a8a0cb63cfe9ebf770a87549389c Mon Sep 17 00:00:00 2001 From: Clebert Suconic Date: Wed, 1 Jun 2016 18:04:56 -0400 Subject: [PATCH] some minimal trace logs --- .../activemq/artemis/jdbc/store/JDBCUtils.java | 12 ++++++++++++ .../artemis/jdbc/store/journal/JDBCJournalImpl.java | 10 ++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/JDBCUtils.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/JDBCUtils.java index 8ce08c64e3..c63e3233e8 100644 --- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/JDBCUtils.java +++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/JDBCUtils.java @@ -30,9 +30,11 @@ import org.apache.activemq.artemis.jdbc.store.drivers.postgres.PostgresSequentia import org.apache.activemq.artemis.jdbc.store.file.JDBCSequentialFileFactoryDriver; import org.apache.activemq.artemis.jdbc.store.sql.GenericSQLProvider; import org.apache.activemq.artemis.jdbc.store.sql.SQLProvider; +import org.jboss.logging.Logger; public class JDBCUtils { + private static final Logger logger = Logger.getLogger(JDBCUtils.class); public static Driver getDriver(String className) throws Exception { try { @@ -62,8 +64,10 @@ public class JDBCUtils { } public static void createTableIfNotExists(Connection connection, String tableName, String sql) throws SQLException { + logger.tracef("Validating if table %s didn't exist before creating", tableName); ResultSet rs = connection.getMetaData().getTables(null, null, tableName, null); if (!rs.next()) { + logger.tracef("Table %s did not exist, creating it with SQL=%s", tableName, sql); Statement statement = connection.createStatement(); statement.executeUpdate(sql); } @@ -71,15 +75,19 @@ public class JDBCUtils { public static SQLProvider getSQLProvider(String driverClass, String tableName) { if (driverClass.contains("derby")) { + logger.tracef("getSQLProvider Returning Derby SQL provider for driver::%s, tableName::%s", driverClass, tableName); return new DerbySQLProvider(tableName); } else if (driverClass.contains("postgres")) { + logger.tracef("getSQLProvider Returning postgres SQL provider for driver::%s, tableName::%s", driverClass, tableName); return new PostgresSQLProvider(tableName); } else if (driverClass.contains("mysql")) { + logger.tracef("getSQLProvider Returning mysql SQL provider for driver::%s, tableName::%s", driverClass, tableName); return new MySQLSQLProvider(tableName); } else { + logger.tracef("getSQLProvider Returning generic SQL provider for driver::%s, tableName::%s", driverClass, tableName); return new GenericSQLProvider(tableName); } } @@ -89,24 +97,28 @@ public class JDBCUtils { String jdbcConnectionUrl) throws SQLException { JDBCSequentialFileFactoryDriver dbDriver; if (driverClass.contains("derby")) { + logger.tracef("getDBFileDriver Returning Derby SQL provider for driver::%s, tableName::%s", driverClass, tableName); dbDriver = new JDBCSequentialFileFactoryDriver(); dbDriver.setSqlProvider(new DerbySQLProvider(tableName)); dbDriver.setJdbcConnectionUrl(jdbcConnectionUrl); dbDriver.setJdbcDriverClass(driverClass); } else if (driverClass.contains("postgres")) { + logger.tracef("getDBFileDriver Returning postgres SQL provider for driver::%s, tableName::%s", driverClass, tableName); dbDriver = new PostgresSequentialSequentialFileDriver(); dbDriver.setSqlProvider(new PostgresSQLProvider(tableName)); dbDriver.setJdbcConnectionUrl(jdbcConnectionUrl); dbDriver.setJdbcDriverClass(driverClass); } else if (driverClass.contains("mysql")) { + logger.tracef("getDBFileDriver Returning mysql SQL provider for driver::%s, tableName::%s", driverClass, tableName); dbDriver = new JDBCSequentialFileFactoryDriver(); dbDriver.setSqlProvider(new MySQLSQLProvider(tableName)); dbDriver.setJdbcConnectionUrl(jdbcConnectionUrl); dbDriver.setJdbcDriverClass(driverClass); } else { + logger.tracef("getDBFileDriver generic mysql SQL provider for driver::%s, tableName::%s", driverClass, tableName); dbDriver = new JDBCSequentialFileFactoryDriver(); dbDriver.setSqlProvider(new GenericSQLProvider(tableName)); dbDriver.setJdbcConnectionUrl(jdbcConnectionUrl); diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalImpl.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalImpl.java index 6c051125ed..81fd6832db 100644 --- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalImpl.java +++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalImpl.java @@ -44,6 +44,9 @@ import org.jboss.logging.Logger; public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { + + private static final Logger logger = Logger.getLogger(JDBCJournalImpl.class); + // Sync Delay in ms public static final int SYNC_DELAY = 5; @@ -75,8 +78,6 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { // Sequence ID for journal records private AtomicLong seq = new AtomicLong(0); - private Logger logger = Logger.getLogger(this.getClass()); - public JDBCJournalImpl(String jdbcUrl, String tableName, String jdbcDriverClass) { super(tableName, jdbcUrl, jdbcDriverClass); timerThread = "Timer JDBC Journal(" + tableName + ")"; @@ -97,6 +98,7 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { @Override protected void prepareStatements() throws SQLException { + logger.tracef("preparing statements"); insertJournalRecords = connection.prepareStatement(sqlProvider.getInsertJournalRecordsSQL()); selectJournalRecords = connection.prepareStatement(sqlProvider.getSelectJournalRecordsSQL()); countJournalRecords = connection.prepareStatement(sqlProvider.getCountJournalRecordsSQL()); @@ -676,12 +678,12 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { @Override public final void synchronizationLock() { - logger.error("Replication is not supported with JDBC Store"); + logger.error("Replication is not supported with JDBC Store", new Exception("trace")); } @Override public final void synchronizationUnlock() { - logger.error("Replication is not supported with JDBC Store"); + logger.error("Replication is not supported with JDBC Store", new Exception("trace")); } @Override