Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id D807E200C79 for ; Fri, 14 Apr 2017 01:17:20 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id D68AC160B98; Thu, 13 Apr 2017 23:17:20 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 0316D160BA7 for ; Fri, 14 Apr 2017 01:17:19 +0200 (CEST) Received: (qmail 36834 invoked by uid 500); 13 Apr 2017 23:17:19 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 36823 invoked by uid 99); 13 Apr 2017 23:17:18 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Apr 2017 23:17:18 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id A4444E0061; Thu, 13 Apr 2017 23:17:18 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: clebertsuconic@apache.org To: commits@activemq.apache.org Date: Thu, 13 Apr 2017 23:17:19 -0000 Message-Id: <2dffcbbdfd634976a6cf2407a1e0245f@git.apache.org> In-Reply-To: <192397c01c4a4515873e1ed532eb9ea7@git.apache.org> References: <192397c01c4a4515873e1ed532eb9ea7@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/2] activemq-artemis git commit: ARTEMIS-1084 Throw RunTime on bad Oracle table size archived-at: Thu, 13 Apr 2017 23:17:21 -0000 ARTEMIS-1084 Throw RunTime on bad Oracle table size Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/aa9ac4a9 Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/aa9ac4a9 Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/aa9ac4a9 Branch: refs/heads/master Commit: aa9ac4a914c18ef9421c769f8cb40e1a6b3b9972 Parents: f609884 Author: Francesco Nigro Authored: Tue Apr 11 16:14:54 2017 +0200 Committer: Clebert Suconic Committed: Thu Apr 13 19:17:10 2017 -0400 ---------------------------------------------------------------------- .../drivers/oracle/Oracle12CSQLProvider.java | 4 ++-- .../paging/impl/PagingStoreFactoryDatabase.java | 9 ++++++-- .../impl/DatabaseStoreConfigurationTest.java | 18 ++++++++------- .../tests/integration/paging/PagingTest.java | 23 ++++++++++++++++++++ 4 files changed, 42 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/aa9ac4a9/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/oracle/Oracle12CSQLProvider.java ---------------------------------------------------------------------- diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/oracle/Oracle12CSQLProvider.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/oracle/Oracle12CSQLProvider.java index ac58bd3..c9f661d 100644 --- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/oracle/Oracle12CSQLProvider.java +++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/oracle/Oracle12CSQLProvider.java @@ -29,8 +29,8 @@ public class Oracle12CSQLProvider extends GenericSQLProvider { protected Oracle12CSQLProvider(String tableName, DatabaseStoreType databaseStoreType) { super(tableName.toUpperCase(), databaseStoreType); - if (tableName.length() > 10 && databaseStoreType == DatabaseStoreType.PAGE) { - throw new RuntimeException("The maximum name size for the paging store table, when using Oracle12C is 10 characters."); + if (tableName.length() > 30) { + throw new RuntimeException("The maximum name size for the " + databaseStoreType.name().toLowerCase() + " store table, when using Oracle12C is 30 characters."); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/aa9ac4a9/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreFactoryDatabase.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreFactoryDatabase.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreFactoryDatabase.java index 31fc729..3177b6e 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreFactoryDatabase.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreFactoryDatabase.java @@ -109,15 +109,20 @@ public class PagingStoreFactoryDatabase implements PagingStoreFactory { public synchronized void start() throws Exception { 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) { SQLProvider.Factory sqlProviderFactory = dbConf.getSqlProviderFactory(); if (sqlProviderFactory == null) { 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 { 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(); started = true; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/aa9ac4a9/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/DatabaseStoreConfigurationTest.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/DatabaseStoreConfigurationTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/DatabaseStoreConfigurationTest.java index 27e3593..58745a2 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/DatabaseStoreConfigurationTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/DatabaseStoreConfigurationTest.java @@ -36,15 +36,17 @@ public class DatabaseStoreConfigurationTest extends ActiveMQTestBase { @Test public void testOracle12TableSize() { - Throwable rte = null; - try { - new Oracle12CSQLProvider.Factory().create("A_TABLE_NAME_THAT_IS_TOO_LONG", SQLProvider.DatabaseStoreType.PAGE); - } catch (Throwable t) { - rte = t; - } + for (SQLProvider.DatabaseStoreType storeType : SQLProvider.DatabaseStoreType.values()) { + Throwable rte = null; + try { + new Oracle12CSQLProvider.Factory().create("_A_TABLE_NAME_THAT_IS_TOO_LONG_", storeType); + } catch (Throwable t) { + rte = t; + } - assertNotNull(rte); - assertTrue(rte.getMessage().contains("The maximum name size for the paging store table, when using Oracle12C is 10 characters.")); + assertNotNull(rte); + 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 { http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/aa9ac4a9/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingTest.java ---------------------------------------------------------------------- diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingTest.java index 48127d2..ddabf1b 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingTest.java @@ -55,6 +55,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.DivertConfiguration; 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.io.IOCallback; import org.apache.activemq.artemis.core.journal.Journal; @@ -151,6 +152,28 @@ public class PagingTest extends ActiveMQTestBase { } @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 public void testPageOnLargeMessageMultipleQueues() throws Exception { Configuration config = createDefaultInVMConfig();