some minimal trace logs
This commit is contained in:
parent
e64ea5278f
commit
13384f3113
|
@ -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.file.JDBCSequentialFileFactoryDriver;
|
||||||
import org.apache.activemq.artemis.jdbc.store.sql.GenericSQLProvider;
|
import org.apache.activemq.artemis.jdbc.store.sql.GenericSQLProvider;
|
||||||
import org.apache.activemq.artemis.jdbc.store.sql.SQLProvider;
|
import org.apache.activemq.artemis.jdbc.store.sql.SQLProvider;
|
||||||
|
import org.jboss.logging.Logger;
|
||||||
|
|
||||||
public class JDBCUtils {
|
public class JDBCUtils {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(JDBCUtils.class);
|
||||||
public static Driver getDriver(String className) throws Exception {
|
public static Driver getDriver(String className) throws Exception {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -62,8 +64,10 @@ public class JDBCUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void createTableIfNotExists(Connection connection, String tableName, String sql) throws SQLException {
|
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);
|
ResultSet rs = connection.getMetaData().getTables(null, null, tableName, null);
|
||||||
if (!rs.next()) {
|
if (!rs.next()) {
|
||||||
|
logger.tracef("Table %s did not exist, creating it with SQL=%s", tableName, sql);
|
||||||
Statement statement = connection.createStatement();
|
Statement statement = connection.createStatement();
|
||||||
statement.executeUpdate(sql);
|
statement.executeUpdate(sql);
|
||||||
}
|
}
|
||||||
|
@ -71,15 +75,19 @@ public class JDBCUtils {
|
||||||
|
|
||||||
public static SQLProvider getSQLProvider(String driverClass, String tableName) {
|
public static SQLProvider getSQLProvider(String driverClass, String tableName) {
|
||||||
if (driverClass.contains("derby")) {
|
if (driverClass.contains("derby")) {
|
||||||
|
logger.tracef("getSQLProvider Returning Derby SQL provider for driver::%s, tableName::%s", driverClass, tableName);
|
||||||
return new DerbySQLProvider(tableName);
|
return new DerbySQLProvider(tableName);
|
||||||
}
|
}
|
||||||
else if (driverClass.contains("postgres")) {
|
else if (driverClass.contains("postgres")) {
|
||||||
|
logger.tracef("getSQLProvider Returning postgres SQL provider for driver::%s, tableName::%s", driverClass, tableName);
|
||||||
return new PostgresSQLProvider(tableName);
|
return new PostgresSQLProvider(tableName);
|
||||||
}
|
}
|
||||||
else if (driverClass.contains("mysql")) {
|
else if (driverClass.contains("mysql")) {
|
||||||
|
logger.tracef("getSQLProvider Returning mysql SQL provider for driver::%s, tableName::%s", driverClass, tableName);
|
||||||
return new MySQLSQLProvider(tableName);
|
return new MySQLSQLProvider(tableName);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
logger.tracef("getSQLProvider Returning generic SQL provider for driver::%s, tableName::%s", driverClass, tableName);
|
||||||
return new GenericSQLProvider(tableName);
|
return new GenericSQLProvider(tableName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,24 +97,28 @@ public class JDBCUtils {
|
||||||
String jdbcConnectionUrl) throws SQLException {
|
String jdbcConnectionUrl) throws SQLException {
|
||||||
JDBCSequentialFileFactoryDriver dbDriver;
|
JDBCSequentialFileFactoryDriver dbDriver;
|
||||||
if (driverClass.contains("derby")) {
|
if (driverClass.contains("derby")) {
|
||||||
|
logger.tracef("getDBFileDriver Returning Derby SQL provider for driver::%s, tableName::%s", driverClass, tableName);
|
||||||
dbDriver = new JDBCSequentialFileFactoryDriver();
|
dbDriver = new JDBCSequentialFileFactoryDriver();
|
||||||
dbDriver.setSqlProvider(new DerbySQLProvider(tableName));
|
dbDriver.setSqlProvider(new DerbySQLProvider(tableName));
|
||||||
dbDriver.setJdbcConnectionUrl(jdbcConnectionUrl);
|
dbDriver.setJdbcConnectionUrl(jdbcConnectionUrl);
|
||||||
dbDriver.setJdbcDriverClass(driverClass);
|
dbDriver.setJdbcDriverClass(driverClass);
|
||||||
}
|
}
|
||||||
else if (driverClass.contains("postgres")) {
|
else if (driverClass.contains("postgres")) {
|
||||||
|
logger.tracef("getDBFileDriver Returning postgres SQL provider for driver::%s, tableName::%s", driverClass, tableName);
|
||||||
dbDriver = new PostgresSequentialSequentialFileDriver();
|
dbDriver = new PostgresSequentialSequentialFileDriver();
|
||||||
dbDriver.setSqlProvider(new PostgresSQLProvider(tableName));
|
dbDriver.setSqlProvider(new PostgresSQLProvider(tableName));
|
||||||
dbDriver.setJdbcConnectionUrl(jdbcConnectionUrl);
|
dbDriver.setJdbcConnectionUrl(jdbcConnectionUrl);
|
||||||
dbDriver.setJdbcDriverClass(driverClass);
|
dbDriver.setJdbcDriverClass(driverClass);
|
||||||
}
|
}
|
||||||
else if (driverClass.contains("mysql")) {
|
else if (driverClass.contains("mysql")) {
|
||||||
|
logger.tracef("getDBFileDriver Returning mysql SQL provider for driver::%s, tableName::%s", driverClass, tableName);
|
||||||
dbDriver = new JDBCSequentialFileFactoryDriver();
|
dbDriver = new JDBCSequentialFileFactoryDriver();
|
||||||
dbDriver.setSqlProvider(new MySQLSQLProvider(tableName));
|
dbDriver.setSqlProvider(new MySQLSQLProvider(tableName));
|
||||||
dbDriver.setJdbcConnectionUrl(jdbcConnectionUrl);
|
dbDriver.setJdbcConnectionUrl(jdbcConnectionUrl);
|
||||||
dbDriver.setJdbcDriverClass(driverClass);
|
dbDriver.setJdbcDriverClass(driverClass);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
logger.tracef("getDBFileDriver generic mysql SQL provider for driver::%s, tableName::%s", driverClass, tableName);
|
||||||
dbDriver = new JDBCSequentialFileFactoryDriver();
|
dbDriver = new JDBCSequentialFileFactoryDriver();
|
||||||
dbDriver.setSqlProvider(new GenericSQLProvider(tableName));
|
dbDriver.setSqlProvider(new GenericSQLProvider(tableName));
|
||||||
dbDriver.setJdbcConnectionUrl(jdbcConnectionUrl);
|
dbDriver.setJdbcConnectionUrl(jdbcConnectionUrl);
|
||||||
|
|
|
@ -44,6 +44,9 @@ import org.jboss.logging.Logger;
|
||||||
|
|
||||||
public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal {
|
public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal {
|
||||||
|
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(JDBCJournalImpl.class);
|
||||||
|
|
||||||
// Sync Delay in ms
|
// Sync Delay in ms
|
||||||
public static final int SYNC_DELAY = 5;
|
public static final int SYNC_DELAY = 5;
|
||||||
|
|
||||||
|
@ -75,8 +78,6 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal {
|
||||||
// Sequence ID for journal records
|
// Sequence ID for journal records
|
||||||
private AtomicLong seq = new AtomicLong(0);
|
private AtomicLong seq = new AtomicLong(0);
|
||||||
|
|
||||||
private Logger logger = Logger.getLogger(this.getClass());
|
|
||||||
|
|
||||||
public JDBCJournalImpl(String jdbcUrl, String tableName, String jdbcDriverClass) {
|
public JDBCJournalImpl(String jdbcUrl, String tableName, String jdbcDriverClass) {
|
||||||
super(tableName, jdbcUrl, jdbcDriverClass);
|
super(tableName, jdbcUrl, jdbcDriverClass);
|
||||||
timerThread = "Timer JDBC Journal(" + tableName + ")";
|
timerThread = "Timer JDBC Journal(" + tableName + ")";
|
||||||
|
@ -97,6 +98,7 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void prepareStatements() throws SQLException {
|
protected void prepareStatements() throws SQLException {
|
||||||
|
logger.tracef("preparing statements");
|
||||||
insertJournalRecords = connection.prepareStatement(sqlProvider.getInsertJournalRecordsSQL());
|
insertJournalRecords = connection.prepareStatement(sqlProvider.getInsertJournalRecordsSQL());
|
||||||
selectJournalRecords = connection.prepareStatement(sqlProvider.getSelectJournalRecordsSQL());
|
selectJournalRecords = connection.prepareStatement(sqlProvider.getSelectJournalRecordsSQL());
|
||||||
countJournalRecords = connection.prepareStatement(sqlProvider.getCountJournalRecordsSQL());
|
countJournalRecords = connection.prepareStatement(sqlProvider.getCountJournalRecordsSQL());
|
||||||
|
@ -676,12 +678,12 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void synchronizationLock() {
|
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
|
@Override
|
||||||
public final void synchronizationUnlock() {
|
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
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue