some minimal trace logs

This commit is contained in:
Clebert Suconic 2016-06-01 18:04:56 -04:00
parent e64ea5278f
commit 13384f3113
2 changed files with 18 additions and 4 deletions

View File

@ -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);

View File

@ -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