private static void validateTimeoutConfiguration(DatabaseStorageConfiguration configuration) { final long lockExpiration = configuration.getJdbcLockExpirationMillis(); if (lockExpiration <= 0) { throw new IllegalArgumentException("jdbc-lock-expiration should be positive"); } final long lockRenewPeriod = configuration.getJdbcLockRenewPeriodMillis(); if (lockRenewPeriod <= 0) { throw new IllegalArgumentException("jdbc-lock-renew-period should be positive"); } if (lockRenewPeriod >= lockExpiration) { throw new IllegalArgumentException("jdbc-lock-renew-period should be < jdbc-lock-expiration"); } final int networkTimeout = configuration.getJdbcNetworkTimeout(); if (networkTimeout >= 0) { if (networkTimeout > lockExpiration) { LOGGER.warn("jdbc-network-timeout isn't properly configured: the recommended value is <= jdbc-lock-expiration"); } } else { LOGGER.warn("jdbc-network-timeout isn't properly configured: the recommended value is <= jdbc-lock-expiration"); } }
configuration.getJdbcNetworkTimeout(), configuration.getJdbcLockExpirationMillis(), configuration.getJdbcLockRenewPeriodMillis(), final String brokerId = java.util.UUID.randomUUID().toString(); return usingConnectionUrl(brokerId, configuration.getJdbcNetworkTimeout(), configuration.getJdbcLockExpirationMillis(), configuration.getJdbcLockRenewPeriodMillis(),
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 PropertySQLProvider.Factory(dbConf.getDataSource()); } pagingFactoryFileFactory = new JDBCSequentialFileFactory(dbConf.getDataSource(), sqlProviderFactory.create(pageStoreTableNamePrefix, SQLProvider.DatabaseStoreType.PAGE), executorFactory.getExecutor(), criticalErrorListener); } else { String driverClassName = dbConf.getJdbcDriverClassName(); pagingFactoryFileFactory = new JDBCSequentialFileFactory(dbConf.getJdbcConnectionUrl(), driverClassName, JDBCUtils.getSQLProvider(driverClassName, pageStoreTableNamePrefix, SQLProvider.DatabaseStoreType.PAGE), executorFactory.getExecutor(), criticalErrorListener); } final int jdbcNetworkTimeout = dbConf.getJdbcNetworkTimeout(); if (jdbcNetworkTimeout >= 0) { pagingFactoryFileFactory.setNetworkTimeout(this.executorFactory.getExecutor(), jdbcNetworkTimeout); } pagingFactoryFileFactory.start(); started = true; } } // Public --------------------------------------------------------
private synchronized SequentialFileFactory newFileFactory(final String directoryName, boolean writeToDirectory) throws Exception { JDBCSequentialFile directoryList = (JDBCSequentialFile) pagingFactoryFileFactory.createSequentialFile(DIRECTORY_NAME); directoryList.open(); SimpleString simpleString = SimpleString.toSimpleString(directoryName); ActiveMQBuffer buffer = ActiveMQBuffers.fixedBuffer(simpleString.sizeof()); buffer.writeSimpleString(simpleString); if (writeToDirectory) directoryList.write(buffer, true); directoryList.close(); final SQLProvider sqlProvider; if (dbConf.getDataSource() != null) { final SQLProvider.Factory sqlProviderFactory; if (dbConf.getSqlProviderFactory() != null) { sqlProviderFactory = dbConf.getSqlProviderFactory(); } else { sqlProviderFactory = new PropertySQLProvider.Factory(dbConf.getDataSource()); } sqlProvider = sqlProviderFactory.create(getTableNameForGUID(directoryName), SQLProvider.DatabaseStoreType.PAGE); } else { sqlProvider = JDBCUtils.getSQLProvider(dbConf.getJdbcDriverClassName(), getTableNameForGUID(directoryName), SQLProvider.DatabaseStoreType.PAGE); } final JDBCSequentialFileFactory fileFactory = new JDBCSequentialFileFactory(pagingFactoryFileFactory.getDbDriver().getConnection(), sqlProvider, executorFactory.getExecutor(), criticalErrorListener); final int jdbcNetworkTimeout = dbConf.getJdbcNetworkTimeout(); if (jdbcNetworkTimeout >= 0) { fileFactory.setNetworkTimeout(this.executorFactory.getExecutor(), jdbcNetworkTimeout); } factoryToTableName.put(fileFactory, directoryName); return fileFactory; }
private DatabaseStorageConfiguration createDatabaseStoreConfig(Element storeNode) { DatabaseStorageConfiguration conf = new DatabaseStorageConfiguration(); conf.setBindingsTableName(getString(storeNode, "bindings-table-name", conf.getBindingsTableName(), Validators.NO_CHECK)); conf.setMessageTableName(getString(storeNode, "message-table-name", conf.getMessageTableName(), Validators.NO_CHECK)); conf.setLargeMessageTableName(getString(storeNode, "large-message-table-name", conf.getJdbcConnectionUrl(), Validators.NO_CHECK)); conf.setPageStoreTableName(getString(storeNode, "page-store-table-name", conf.getPageStoreTableName(), Validators.NO_CHECK)); conf.setNodeManagerStoreTableName(getString(storeNode, "node-manager-store-table-name", conf.getNodeManagerStoreTableName(), Validators.NO_CHECK)); conf.setJdbcConnectionUrl(getString(storeNode, "jdbc-connection-url", conf.getJdbcConnectionUrl(), Validators.NO_CHECK)); conf.setJdbcDriverClassName(getString(storeNode, "jdbc-driver-class-name", conf.getJdbcDriverClassName(), Validators.NO_CHECK)); conf.setJdbcNetworkTimeout(getInteger(storeNode, "jdbc-network-timeout", conf.getJdbcNetworkTimeout(), Validators.NO_CHECK)); conf.setJdbcLockRenewPeriodMillis(getLong(storeNode, "jdbc-lock-renew-period", conf.getJdbcLockRenewPeriodMillis(), Validators.NO_CHECK)); conf.setJdbcLockExpirationMillis(getLong(storeNode, "jdbc-lock-expiration", conf.getJdbcLockExpirationMillis(), Validators.NO_CHECK)); conf.setJdbcJournalSyncPeriodMillis(getLong(storeNode, "jdbc-journal-sync-period", conf.getJdbcJournalSyncPeriodMillis(), Validators.NO_CHECK)); return conf; }
largeMessagesFactory = new JDBCSequentialFileFactory(dbConf.getJdbcConnectionUrl(), driverClassName, JDBCUtils.getSQLProvider(driverClassName, dbConf.getLargeMessageTableName(), SQLProvider.DatabaseStoreType.LARGE_MESSAGE), executorFactory.getExecutor(), criticalErrorListener); final int networkTimeout = dbConf.getJdbcNetworkTimeout(); if (networkTimeout >= 0) { bindingsJournal.setNetworkTimeout(executorFactory.getExecutor(), networkTimeout);