Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ updates:
interval: "daily"
ignore:
# Ignore all these until we move to JDK >= 21
- dependency-name: 'org.apache.derby:*'
versions: '>= 10.16'
- dependency-name: 'com.puppycrawl.tools:*'
versions: '>= 13'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ public Object run(ActionContext context) throws Exception {

if (jdbc) {
if (jdbcURL == null) {
jdbcURL = "jdbc:derby:" + getInstance().getAbsolutePath() + "/data/derby/db;create=true";
jdbcURL = "jdbc:hsqldb:file:" + getInstance().getAbsolutePath() + "/data/hsqldb/db;hsqldb.write_delay=false";
}
filters.put("${jdbcBindings}", jdbcBindings);
filters.put("${jdbcMessages}", jdbcMessages);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- The most efficient persistent layer for Artemis is the file-store,
however if you require a database please refer to your database provider
for any database specific questions.
We don't endorse any specific JDBC provider. Derby is provided by default for demonstration purposes. -->
We don't endorse any specific JDBC provider. HSQLDB is provided by default for demonstration purposes. -->
<jdbc-driver-class-name>${jdbcClassName}</jdbc-driver-class-name>
<jdbc-connection-url>${jdbcURL}</jdbc-connection-url>
<message-table-name>${jdbcMessages}</message-table-name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,11 +464,11 @@ public static String getDefaultHapolicyBackupStrategy() {
// Which store type to use, options are FILE or DATABASE, FILE is default.
private static String DEFAULT_STORE_TYPE = "FILE";

// Default database url. Derby database is used by default.
// Default database url. HSQLDB is used by default.
private static String DEFAULT_DATABASE_URL = null;

// Default JDBC Driver class name, derby by default just for demo purposes
private static String DEFAULT_JDBC_DRIVER_CLASS_NAME = "org.apache.derby.jdbc.EmbeddedDriver";
// Default JDBC Driver class name, HSQLDB by default just for demo purposes
private static String DEFAULT_JDBC_DRIVER_CLASS_NAME = "org.hsqldb.jdbc.JDBCDriver";

// Default JDBC Driver class name. DBCP2 BasicDataSource is used by default.
private static String DEFAULT_JDBC_DATA_SOURCE_CLASS_NAME = "org.apache.commons.dbcp2.BasicDataSource";
Expand Down
9 changes: 2 additions & 7 deletions artemis-jdbc-store/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,8 @@

<!-- Database driver support -->
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbytools</artifactId>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,10 @@

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;

import org.apache.activemq.artemis.jdbc.store.logging.LoggingConnection;
import org.apache.activemq.artemis.jdbc.store.sql.PropertySQLProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.invoke.MethodHandles;
Expand All @@ -50,7 +47,6 @@ public JDBCConnectionProvider(DataSource dataSource, String user, String passwor
this.supportNetworkTimeout = true;
this.user = user;
this.password = password;
addDerbyShutdownHook();
}

public synchronized Connection getConnection() throws SQLException {
Expand Down Expand Up @@ -91,32 +87,6 @@ public synchronized Connection getConnection() throws SQLException {
return connection;
}

private static AtomicBoolean shutAdded = new AtomicBoolean(false);

private static class ShutdownDerby extends Thread {
@Override
public void run() {
try {
DriverManager.getConnection("jdbc:derby:;shutdown=true");
} catch (Exception e) { }
}

}

public void addDerbyShutdownHook() {
// Shutdown the derby if using the derby embedded driver.
try (Connection connection = getConnection()) {
PropertySQLProvider.Factory.SQLDialect sqlDialect = PropertySQLProvider.Factory.investigateDialect(connection);
if (sqlDialect == PropertySQLProvider.Factory.SQLDialect.DERBY) {
if (shutAdded.compareAndSet(false, true)) {
Runtime.getRuntime().addShutdownHook(new ShutdownDerby());
}
}
} catch (SQLException e) {
logger.error(JDBCUtils.appendSQLExceptionDetails(new StringBuilder(), e).toString());
}
}

public int getNetworkTimeoutMillis() {
return networkTimeoutMillis;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ public synchronized int sync() {

connection.setAutoCommit(false);

boolean batchInsertRecord = false;
boolean batchDeleteRecord = false;
boolean batchRollbackRecord = false;
for (JDBCJournalRecord record : recordRef) {

logger.trace("sync::preparing JDBC statement for {}", record);
Expand All @@ -232,11 +235,13 @@ public synchronized int sync() {
// Standard SQL Delete Record, Non transactional delete
deletedRecords.add(record.getId());
record.writeDeleteRecord(deleteJournalRecords);
batchDeleteRecord = true;
break;
case JDBCJournalRecord.ROLLBACK_RECORD:
// Roll back we remove all records associated with this TX ID. This query is always performed last.
deleteJournalTxRecords.setLong(1, record.getTxId());
deleteJournalTxRecords.addBatch();
batchRollbackRecord = true;
break;
case JDBCJournalRecord.COMMIT_RECORD:
// We perform all the deletes and add the commit record in the same Database TX
Expand All @@ -246,20 +251,29 @@ public synchronized int sync() {
deletedRecords.add(info.id);
deleteJournalRecords.setLong(1, info.id);
deleteJournalRecords.addBatch();
batchDeleteRecord = true;
}
record.writeRecord(insertJournalRecords);
batchInsertRecord = true;
committedTransactions.add(record.getTxId());
break;
default:
// Default we add a new record to the DB
record.writeRecord(insertJournalRecords);
batchInsertRecord = true;
break;
}
}

insertJournalRecords.executeBatch();
deleteJournalRecords.executeBatch();
deleteJournalTxRecords.executeBatch();
if (batchInsertRecord) {
insertJournalRecords.executeBatch();
}
if (batchDeleteRecord) {
deleteJournalRecords.executeBatch();
}
if (batchRollbackRecord) {
deleteJournalTxRecords.executeBatch();
}

connection.commit();
logger.trace("JDBC commit worked");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,9 @@ public static final class Factory implements SQLProvider.Factory {
public enum SQLDialect {
ORACLE("oracle", "oracle"),
POSTGRESQL("postgresql", "postgres"),
DERBY("derby", "derby"),
HSQL("hsql", "hsql", "hypersonic"),
MYSQL("mysql", "mysql", "mariadb"),
DB2("db2", "db2"),
HSQL("hsql", "hsql", "hypersonic"),
H2("h2", "h2"),
MSSQL("mssql", "microsoft"),
SYBASE("jconnect", "jconnect");
Expand Down
9 changes: 4 additions & 5 deletions artemis-jdbc-store/src/main/resources/journal-sql.properties
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,10 @@ close-connection-on-shutdown=true
# none|lower|upper
table-names-case=none

# Derby SQL statements
close-connection-on-shutdown.derby=false
create-file-table.derby=CREATE TABLE %s (ID BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),FILENAME VARCHAR(255), EXTENSION VARCHAR(10), DATA BLOB, PRIMARY KEY(ID))
max-blob-size.derby=2147483647
table-names-case.derby=upper
# HSQLDB SQL statements
create-file-table.hsql=CREATE TABLE IF NOT EXISTS %s (ID BIGINT GENERATED BY DEFAULT AS IDENTITY,FILENAME VARCHAR(255), EXTENSION VARCHAR(10), DATA BLOB, PRIMARY KEY(ID))
max-blob-size.hsql=2147483647
table-names-case.hsql=upper

# PostgreSQL SQL statements
create-file-table.postgresql=CREATE TABLE %s (ID BIGSERIAL, FILENAME VARCHAR(255), EXTENSION VARCHAR(10), DATA OID, PRIMARY KEY(ID))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import static org.junit.jupiter.api.Assertions.fail;

import java.nio.ByteBuffer;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -52,8 +51,9 @@
import org.apache.activemq.artemis.tests.extensions.parameterized.Parameter;
import org.apache.activemq.artemis.tests.extensions.parameterized.Parameters;
import org.apache.activemq.artemis.tests.util.ArtemisTestCase;
import org.apache.activemq.artemis.tests.util.DBSupportUtil;
import org.apache.activemq.artemis.utils.ActiveMQThreadFactory;
import org.apache.derby.jdbc.EmbeddedDriver;
import org.hsqldb.jdbc.JDBCDriver;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestTemplate;
Expand All @@ -62,7 +62,7 @@
@ExtendWith(ParameterizedTestExtension.class)
public class JDBCSequentialFileFactoryTest extends ArtemisTestCase {

private static String className = EmbeddedDriver.class.getCanonicalName();
private static String className = JDBCDriver.class.getCanonicalName();

private JDBCSequentialFileFactory factory;

Expand All @@ -89,12 +89,13 @@ public void setup() throws Exception {
if (useAuthentication) {
user = "testuser";
password = "testpassword";
System.setProperty("derby.connection.requireAuthentication", "true");
System.setProperty("derby.user." + user, password);
dataSourceProperties.put("username", user);
dataSourceProperties.put("password", password);
} else {
dataSourceProperties.put("username", "SA");
dataSourceProperties.put("password", "");
}
dataSourceProperties.put("url", "jdbc:derby:target/data;create=true");
dataSourceProperties.put("url", "jdbc:hsqldb:mem:filetest");
dataSourceProperties.put("driverClassName", className);
String tableName = "FILES";
String jdbcDatasourceClass = ActiveMQDefaultConfiguration.getDefaultDataSourceClassName();
Expand All @@ -110,23 +111,17 @@ public void tearDown() throws Exception {
scheduledExecutorService.shutdown();
factory.destroy();
} finally {
shutdownDerby();
shutdownHSQL();
}
}

private void shutdownDerby() {
private void shutdownHSQL() {
try {
if (useAuthentication) {
DriverManager.getConnection("jdbc:derby:;shutdown=true", user, password);
} else {
DriverManager.getConnection("jdbc:derby:;shutdown=true");
}
String hsqlUser = useAuthentication ? user : "SA";
String hsqlPassword = useAuthentication ? password : "";
DBSupportUtil.shutdownHSQL("jdbc:hsqldb:mem:filetest", hsqlUser, hsqlPassword);
} catch (Exception ignored) {
}
if (useAuthentication) {
System.clearProperty("derby.connection.requireAuthentication");
System.clearProperty("derby.user." + user);
}
}

@TestTemplate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.sql.DriverManager;
import java.util.ArrayList;
import java.util.List;

import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo;
import org.apache.activemq.artemis.core.journal.RecordInfo;
import org.apache.activemq.artemis.core.journal.TransactionFailureCallback;
import org.apache.activemq.artemis.tests.util.ArtemisTestCase;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;

public class JDBCJournalLoaderCallbackTest extends ArtemisTestCase {
Expand All @@ -51,12 +49,4 @@ public void testAddDeleteRecord() throws Exception {
assertTrue(committedRecords.isEmpty());
}

@AfterEach
public void shutdownDerby() {
try {
DriverManager.getConnection("jdbc:derby:;shutdown=true");
} catch (Exception ignored) {
}
}

}
13 changes: 4 additions & 9 deletions artemis-pom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,11 @@
<!-- Apache v2.0 License -->
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>${apache.derby.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbytools</artifactId>
<version>${apache.derby.version}</version>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>${hsqldb.version}</version>
<scope>test</scope>
<!-- BSD License -->
</dependency>
<dependency>
<groupId>org.eclipse.paho</groupId>
Expand Down
9 changes: 2 additions & 7 deletions artemis-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,8 @@
</dependency>
<!-- db test -->
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbytools</artifactId>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,8 +517,8 @@ public void testStoreConfiguration() {
assertEquals("FULL_LARGE_MESSAGES", dbStore.getLargeMessageTableName());
assertEquals("FULL_PAGE_STORE", dbStore.getPageStoreTableName());
assertEquals("FULL_NODE_MANAGER", dbStore.getNodeManagerStoreTableName());
assertEquals("jdbc:derby:target/full-test-store;create=true", dbStore.getJdbcConnectionUrl());
assertEquals("org.apache.derby.jdbc.EmbeddedDriver", dbStore.getJdbcDriverClassName());
assertEquals("jdbc:hsqldb:mem:full-test-store", dbStore.getJdbcConnectionUrl());
assertEquals("org.hsqldb.jdbc.JDBCDriver", dbStore.getJdbcDriverClassName());
assertEquals(30000, dbStore.getJdbcNetworkTimeout());
assertEquals(3000, dbStore.getJdbcLockRenewPeriodMillis());
assertEquals(20000, dbStore.getJdbcLockExpirationMillis());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public class HAPolicyConfigurationTest extends ServerTestBase {
public void tearDown() throws Exception {
super.tearDown();

shutdownDerby();
shutdownEmbeddedDatabases();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ public static Collection<Object[]> data() {

@BeforeEach
public void configure() {
if (useAuthentication) {
System.setProperty("derby.connection.requireAuthentication", "true");
System.setProperty("derby.user." + getJDBCUser(), getJDBCPassword());
}
dbConf = createDefaultDatabaseStorageConfiguration();
dbConf.setJdbcUser(getJDBCUser());
dbConf.setJdbcPassword(getJDBCPassword());
Expand Down
Loading
Loading