ARTEMIS-1084 Throw RunTime on bad Oracle table size
(cherry picked from commit aa9ac4a914
)
This commit is contained in:
parent
65481ef46a
commit
c35960f6a4
|
@ -34,8 +34,8 @@ public class Oracle12CSQLProvider extends GenericSQLProvider {
|
||||||
|
|
||||||
protected Oracle12CSQLProvider(String tableName, DatabaseStoreType databaseStoreType) {
|
protected Oracle12CSQLProvider(String tableName, DatabaseStoreType databaseStoreType) {
|
||||||
super(tableName.toUpperCase(), databaseStoreType);
|
super(tableName.toUpperCase(), databaseStoreType);
|
||||||
if (tableName.length() > 10 && databaseStoreType == DatabaseStoreType.PAGE) {
|
if (tableName.length() > 30) {
|
||||||
throw new RuntimeException("The maximum name size for the paging store table, when using Oracle12C is 10 characters.");
|
throw new RuntimeException("The maximum name size for the " + databaseStoreType.name().toLowerCase() + " store table, when using Oracle12C is 30 characters.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,15 +99,20 @@ public class PagingStoreFactoryDatabase implements PagingStoreFactory {
|
||||||
|
|
||||||
public synchronized void start() throws Exception {
|
public synchronized void start() throws Exception {
|
||||||
if (!started) {
|
if (!started) {
|
||||||
|
//fix to prevent page table names to be longer than 30 chars (upper limit for Oracle12c identifiers length)
|
||||||
|
final String pageStoreTableNamePrefix = dbConf.getPageStoreTableName();
|
||||||
|
if (pageStoreTableNamePrefix.length() > 10) {
|
||||||
|
throw new IllegalStateException("The maximum name size for the page store table prefix is 10 characters: THE PAGING STORE CAN'T START");
|
||||||
|
}
|
||||||
if (dbConf.getDataSource() != null) {
|
if (dbConf.getDataSource() != null) {
|
||||||
SQLProvider.Factory sqlProviderFactory = dbConf.getSqlProviderFactory();
|
SQLProvider.Factory sqlProviderFactory = dbConf.getSqlProviderFactory();
|
||||||
if (sqlProviderFactory == null) {
|
if (sqlProviderFactory == null) {
|
||||||
sqlProviderFactory = new GenericSQLProvider.Factory();
|
sqlProviderFactory = new GenericSQLProvider.Factory();
|
||||||
}
|
}
|
||||||
pagingFactoryFileFactory = new JDBCSequentialFileFactory(dbConf.getDataSource(), sqlProviderFactory.create(dbConf.getPageStoreTableName(), SQLProvider.DatabaseStoreType.PAGE), executorFactory.getExecutor());
|
pagingFactoryFileFactory = new JDBCSequentialFileFactory(dbConf.getDataSource(), sqlProviderFactory.create(pageStoreTableNamePrefix, SQLProvider.DatabaseStoreType.PAGE), executorFactory.getExecutor());
|
||||||
} else {
|
} else {
|
||||||
String driverClassName = dbConf.getJdbcDriverClassName();
|
String driverClassName = dbConf.getJdbcDriverClassName();
|
||||||
pagingFactoryFileFactory = new JDBCSequentialFileFactory(dbConf.getJdbcConnectionUrl(), driverClassName, JDBCUtils.getSQLProvider(driverClassName, dbConf.getPageStoreTableName(), SQLProvider.DatabaseStoreType.PAGE), executorFactory.getExecutor());
|
pagingFactoryFileFactory = new JDBCSequentialFileFactory(dbConf.getJdbcConnectionUrl(), driverClassName, JDBCUtils.getSQLProvider(driverClassName, pageStoreTableNamePrefix, SQLProvider.DatabaseStoreType.PAGE), executorFactory.getExecutor());
|
||||||
}
|
}
|
||||||
pagingFactoryFileFactory.start();
|
pagingFactoryFileFactory.start();
|
||||||
started = true;
|
started = true;
|
||||||
|
|
|
@ -36,15 +36,17 @@ public class DatabaseStoreConfigurationTest extends ActiveMQTestBase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOracle12TableSize() {
|
public void testOracle12TableSize() {
|
||||||
|
for (SQLProvider.DatabaseStoreType storeType : SQLProvider.DatabaseStoreType.values()) {
|
||||||
Throwable rte = null;
|
Throwable rte = null;
|
||||||
try {
|
try {
|
||||||
new Oracle12CSQLProvider.Factory().create("A_TABLE_NAME_THAT_IS_TOO_LONG", SQLProvider.DatabaseStoreType.PAGE);
|
new Oracle12CSQLProvider.Factory().create("_A_TABLE_NAME_THAT_IS_TOO_LONG_", storeType);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
rte = t;
|
rte = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
assertNotNull(rte);
|
assertNotNull(rte);
|
||||||
assertTrue(rte.getMessage().contains("The maximum name size for the paging store table, when using Oracle12C is 10 characters."));
|
assertTrue(rte.getMessage().contains("The maximum name size for the " + storeType.name().toLowerCase() + " store table, when using Oracle12C is 30 characters."));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Configuration createConfiguration(String fileName) throws Exception {
|
protected Configuration createConfiguration(String fileName) throws Exception {
|
||||||
|
|
|
@ -54,6 +54,7 @@ import org.apache.activemq.artemis.core.client.impl.ClientConsumerInternal;
|
||||||
import org.apache.activemq.artemis.core.config.Configuration;
|
import org.apache.activemq.artemis.core.config.Configuration;
|
||||||
import org.apache.activemq.artemis.core.config.DivertConfiguration;
|
import org.apache.activemq.artemis.core.config.DivertConfiguration;
|
||||||
import org.apache.activemq.artemis.core.config.StoreConfiguration;
|
import org.apache.activemq.artemis.core.config.StoreConfiguration;
|
||||||
|
import org.apache.activemq.artemis.core.config.storage.DatabaseStorageConfiguration;
|
||||||
import org.apache.activemq.artemis.core.filter.Filter;
|
import org.apache.activemq.artemis.core.filter.Filter;
|
||||||
import org.apache.activemq.artemis.core.io.IOCallback;
|
import org.apache.activemq.artemis.core.io.IOCallback;
|
||||||
import org.apache.activemq.artemis.core.journal.Journal;
|
import org.apache.activemq.artemis.core.journal.Journal;
|
||||||
|
@ -144,6 +145,28 @@ public class PagingTest extends ActiveMQTestBase {
|
||||||
locator = createInVMNonHALocator();
|
locator = createInVMNonHALocator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTooLongPageStoreTableNamePrefix() throws Exception {
|
||||||
|
if (storeType == StoreConfiguration.StoreType.DATABASE) {
|
||||||
|
final Configuration config = createDefaultInVMConfig();
|
||||||
|
final DatabaseStorageConfiguration storageConfiguration = (DatabaseStorageConfiguration) config.getStoreConfiguration();
|
||||||
|
//set the page store table to be longer than 10 chars -> the paging manager initialization will fail
|
||||||
|
storageConfiguration.setPageStoreTableName("PAGE_STORE_");
|
||||||
|
|
||||||
|
final int PAGE_MAX = 20 * 1024;
|
||||||
|
|
||||||
|
final int PAGE_SIZE = 10 * 1024;
|
||||||
|
|
||||||
|
final ActiveMQServer server = createServer(true, config, PAGE_SIZE, PAGE_MAX);
|
||||||
|
server.start();
|
||||||
|
|
||||||
|
//due to a failed initialisation of the paging manager, it must be null
|
||||||
|
Assert.assertNull(server.getPagingManager());
|
||||||
|
|
||||||
|
server.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPageOnLargeMessageMultipleQueues() throws Exception {
|
public void testPageOnLargeMessageMultipleQueues() throws Exception {
|
||||||
Configuration config = createDefaultInVMConfig();
|
Configuration config = createDefaultInVMConfig();
|
||||||
|
|
Loading…
Reference in New Issue