Author: sergiykarpenko
Date: 2010-03-22 08:11:01 -0400 (Mon, 22 Mar 2010)
New Revision: 2091
Modified:
jcr/trunk/exo.jcr.component.core/pom.xml
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainer.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DefaultOracleConnectionFactory.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleConnectionFactory.java
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration-sjdbc.xml
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config-sjdbc.xml
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml
Log:
EXOJCR-598: force.query.hints config parameter added
Modified: jcr/trunk/exo.jcr.component.core/pom.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/pom.xml 2010-03-22 09:54:46 UTC (rev 2090)
+++ jcr/trunk/exo.jcr.component.core/pom.xml 2010-03-22 12:11:01 UTC (rev 2091)
@@ -31,7 +31,8 @@
<name>eXo JCR :: Component :: Core Service</name>
<description>eXo JCR Service core component</description>
<properties>
-
<jcr.test.configuration.file>/conf/standalone/test-configuration.xml</jcr.test.configuration.file>
+
<!--jcr.test.configuration.file>/conf/standalone/test-configuration.xml</jcr.test.configuration.file-->
+
<jcr.test.configuration.file>/conf/standalone/test-configuration-sjdbc.xml</jcr.test.configuration.file>
</properties>
<dependencies>
<dependency>
@@ -214,7 +215,7 @@
<scope>test</scope>
</dependency>
<!-- For Oracle 10g support (local-jcr repository) -->
- <!-- dependency>
+ <dependency>
<groupId>ojdbc</groupId>
<artifactId>ojdbc</artifactId>
<version>14</version>
@@ -225,7 +226,7 @@
<artifactId>orai18n</artifactId>
<version>14</version>
<scope>test</scope>
- </dependency -->
+ </dependency>
<!-- For IBM DB2 support (local-jcr repository) -->
<!-- dependency>
<groupId>com.ibm.db2</groupId>
@@ -358,11 +359,11 @@
<property>
<name>emma.coverage.out.file</name>
<value>target/emma/coverage.ec</value>
- </property>
- <!-- Uncomment the line below if you want to enable the statistics -->
- <!--property>
- <name>JDBCWorkspaceDataContainer.statistics.enabled</name>
- <value>true</value>
+ </property>
+ <!-- Uncomment the line below if you want to enable the statistics -->
+ <!--property>
+ <name>JDBCWorkspaceDataContainer.statistics.enabled</name>
+ <value>true</value>
</property-->
</systemProperties>
<includes>
@@ -548,11 +549,11 @@
org.apache.jackrabbit.test.api.nodetype.PredefinedNodeTypeTest#testVersionable
org.apache.jackrabbit.test.api.nodetype.PredefinedNodeTypeTest#testVersion
org.apache.jackrabbit.test.api.NamespaceRegistryTest#testRegisterNamespace</value>
- </property>
- <!-- Uncomment the line below if you want to enable the
statistics -->
- <!--property>
-
<name>JDBCWorkspaceDataContainer.statistics.enabled</name>
- <value>true</value>
+ </property>
+ <!-- Uncomment the line below if you want to enable the
statistics -->
+ <!--property>
+
<name>JDBCWorkspaceDataContainer.statistics.enabled</name>
+ <value>true</value>
</property-->
</systemProperties>
<includes>
@@ -620,11 +621,11 @@
org.apache.jackrabbit.test.api.nodetype.PredefinedNodeTypeTest#testVersionable
org.apache.jackrabbit.test.api.nodetype.PredefinedNodeTypeTest#testVersion
org.apache.jackrabbit.test.api.NamespaceRegistryTest#testRegisterNamespace</value>
- </property>
- <!-- Uncomment the line below if you want to enable the
statistics -->
- <!--property>
-
<name>JDBCWorkspaceDataContainer.statistics.enabled</name>
- <value>true</value>
+ </property>
+ <!-- Uncomment the line below if you want to enable the
statistics -->
+ <!--property>
+
<name>JDBCWorkspaceDataContainer.statistics.enabled</name>
+ <value>true</value>
</property-->
</systemProperties>
<includes>
@@ -698,11 +699,11 @@
<property>
<name>jcr.test.configuration.file</name>
<value>${jcr.test.configuration.file}</value>
- </property>
- <!-- Uncomment the line below if you want to enable the
statistics -->
- <!--property>
-
<name>JDBCWorkspaceDataContainer.statistics.enabled</name>
- <value>true</value>
+ </property>
+ <!-- Uncomment the line below if you want to enable the
statistics -->
+ <!--property>
+
<name>JDBCWorkspaceDataContainer.statistics.enabled</name>
+ <value>true</value>
</property-->
</systemProperties>
<includes>
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java 2010-03-22
09:54:46 UTC (rev 2090)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java 2010-03-22
12:11:01 UTC (rev 2091)
@@ -68,7 +68,8 @@
/**
* Indicates if the statistics has to be enabled.
*/
- public static final boolean STATISTICS_ENABLED =
Boolean.valueOf(System.getProperty("JDBCWorkspaceDataContainer.statistics.enabled"));
+ public static final boolean STATISTICS_ENABLED =
+
Boolean.valueOf(System.getProperty("JDBCWorkspaceDataContainer.statistics.enabled"));
static
{
if (STATISTICS_ENABLED)
@@ -76,7 +77,7 @@
LOG.info("The statistics of the component JDBCWorkspaceDataContainer has
been enabled");
}
}
-
+
//configuration params
public final static String SOURCE_NAME = "source-name";
@@ -98,6 +99,8 @@
public final static String DB_PASSWORD = "password";
+ public final static String DB_FORCE_QUERY_HINTS = "force.query.hints";
+
protected final String containerName;
protected final String dbSourceName;
@@ -129,6 +132,12 @@
protected GenericConnectionFactory connFactory;
/**
+ * Some DataBases supports query hints, that may improve query performance.
+ * For default hints are enabled.
+ */
+ protected boolean useQueryHints;
+
+ /**
* Shared connection factory.
*
* Issued to share JDBC connection between system and regular workspace in case of
same database
@@ -346,6 +355,9 @@
}
LOG.info("Using a dialect '" + this.dbDialect + "'");
+ // check is there DB_FORCE_QUERY_HINTS parameter - by default its enabled
+ useQueryHints = wsConfig.getContainer().getParameterBoolean(DB_FORCE_QUERY_HINTS,
true);
+
try
{
this.checkSNSNewConnection =
wsConfig.getContainer().getParameterBoolean(CHECK_SNS_NEW_CONNECTION);
@@ -767,14 +779,15 @@
{
original =
((StatisticsJDBCStorageConnection)original).getNestedWorkspaceStorageConnection();
}
-
+
if (original instanceof JDBCStorageConnection)
{
WorkspaceStorageConnectionFactory cFactory =
new
SharedConnectionFactory(((JDBCStorageConnection)original).getJdbcConnection(),
containerName, multiDb,
valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
- return STATISTICS_ENABLED ? new
StatisticsJDBCStorageConnection(cFactory.openConnection()) : cFactory.openConnection();
+ return STATISTICS_ENABLED ? new
StatisticsJDBCStorageConnection(cFactory.openConnection()) : cFactory
+ .openConnection();
}
else
{
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainer.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainer.java 2010-03-22
09:54:46 UTC (rev 2090)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainer.java 2010-03-22
12:11:01 UTC (rev 2091)
@@ -28,10 +28,10 @@
import org.exoplatform.services.jcr.impl.storage.jdbc.init.OracleDBInitializer;
import org.exoplatform.services.jcr.impl.storage.jdbc.init.PgSQLDBInitializer;
import org.exoplatform.services.jcr.impl.storage.jdbc.init.StorageDBInitializer;
+import
org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.DefaultOracleConnectionFactory;
import
org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.GenericCQConnectionFactory;
import
org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.HSQLDBConnectionFactory;
import
org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.MySQLConnectionFactory;
-import
org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.DefaultOracleConnectionFactory;
import
org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.OracleConnectionFactory;
import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializerException;
import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
@@ -93,19 +93,19 @@
LOG.warn(DBConstants.DB_DIALECT_ORACLEOCI + " dialect is
experimental!");
// sample of connection factory customization
if (dbSourceName != null)
- {
+ {
DataSource ds = (DataSource)new InitialContext().lookup(dbSourceName);
if (ds != null)
this.connFactory =
new DefaultOracleConnectionFactory(ds, containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ swapDirectory, swapCleaner, useQueryHints);
else
throw new RepositoryException("Datasource '" + dbSourceName
+ "' is not bound in this context.");
- }
+ }
else
this.connFactory =
new OracleConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword,
containerName, multiDb,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner,
useQueryHints);
sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.ora.sql";
@@ -121,14 +121,14 @@
if (ds != null)
this.connFactory =
new DefaultOracleConnectionFactory(ds, containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ swapDirectory, swapCleaner, useQueryHints);
else
throw new RepositoryException("Datasource '" + dbSourceName
+ "' is not bound in this context.");
}
else
this.connFactory =
new DefaultOracleConnectionFactory(dbDriver, dbUrl, dbUserName,
dbPassword, containerName, multiDb,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner,
useQueryHints);
sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.ora.sql";
dbInitilizer = new OracleDBInitializer(containerName,
this.connFactory.getJdbcConnection(), sqlPath, multiDb);
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DefaultOracleConnectionFactory.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DefaultOracleConnectionFactory.java 2010-03-22
09:54:46 UTC (rev 2090)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DefaultOracleConnectionFactory.java 2010-03-22
12:11:01 UTC (rev 2091)
@@ -34,6 +34,9 @@
*/
public class DefaultOracleConnectionFactory extends GenericCQConnectionFactory
{
+
+ protected boolean forceQueryHints;
+
/**
* DefaultOracleConnectionFactory constructor.
*
@@ -51,12 +54,15 @@
* - Swap directory (see configuration)
* @param swapCleaner
* - Swap cleaner (internal FileCleaner).
+ * @param forceQueryHints
+ * - use Oracle queries with query hints
*/
public DefaultOracleConnectionFactory(DataSource dataSource, String containerName,
boolean multiDb,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner,
+ boolean forceQueryHints)
{
-
super(dataSource, containerName, multiDb, valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ this.forceQueryHints = forceQueryHints;
}
/**
@@ -84,18 +90,21 @@
* - Swap directory (see configuration)
* @param swapCleaner
* - Swap cleaner (internal FileCleaner).
+ * @param forceQueryHints
+ * - use Oracle queries with query hints
* @throws RepositoryException
* if error eccurs
*/
public DefaultOracleConnectionFactory(String dbDriver, String dbUrl, String
dbUserName, String dbPassword,
String containerName, boolean multiDb, ValueStoragePluginProvider
valueStorageProvider, int maxBufferSize,
- File swapDirectory, FileCleaner swapCleaner) throws RepositoryException
+ File swapDirectory, FileCleaner swapCleaner, boolean forceQueryHints) throws
RepositoryException
{
super(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
valueStorageProvider, maxBufferSize,
swapDirectory, swapCleaner);
+ this.forceQueryHints = forceQueryHints;
}
-
+
/**
* {@inheritDoc}
*/
@@ -104,20 +113,27 @@
{
try
{
+ if (forceQueryHints)
+ {
+ if (multiDb)
+ {
+ return new OracleMultiDbJDBCConnection(getJdbcConnection(readOnly),
readOnly, containerName,
+ valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ }
- if (multiDb)
- {
- return new OracleMultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerName,
+ return new OracleSingleDbJDBCConnection(getJdbcConnection(readOnly),
readOnly, containerName,
valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
}
+ else
+ {
+ // use common CQ queries, since Oracle[Multi/Single]DbJDBCConnection contains
only queries with hints
+ return super.openConnection(readOnly);
+ }
- return new OracleSingleDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerName,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
-
}
catch (SQLException e)
{
throw new RepositoryException(e);
}
- }
+ }
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleConnectionFactory.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleConnectionFactory.java 2010-03-22
09:54:46 UTC (rev 2090)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleConnectionFactory.java 2010-03-22
12:11:01 UTC (rev 2091)
@@ -77,12 +77,14 @@
* - Swap directory (see configuration)
* @param swapCleaner
* - Swap cleaner (internal FileCleaner).
+ * @param forceQueryHints
+ * - use Oracle queries with query hints
* @throws RepositoryException
* if error occurs
*/
public OracleConnectionFactory(String dbDriver, String dbUrl, String dbUserName,
String dbPassword,
String containerName, boolean multiDb, ValueStoragePluginProvider
valueStorageProvider, int maxBufferSize,
- File swapDirectory, FileCleaner swapCleaner) throws RepositoryException
+ File swapDirectory, FileCleaner swapCleaner, boolean forceQueryHints) throws
RepositoryException
{
// ;D:\Devel\oracle_instantclient_10_2\;C:\oracle\ora92\bin;
@@ -111,7 +113,7 @@
*/
super(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ swapDirectory, swapCleaner, forceQueryHints);
Object cds = null;
try
Modified:
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration-sjdbc.xml
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration-sjdbc.xml 2010-03-22
09:54:46 UTC (rev 2090)
+++
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration-sjdbc.xml 2010-03-22
12:11:01 UTC (rev 2091)
@@ -244,10 +244,13 @@
<properties-param>
<name>ref-addresses</name>
<description>ref-addresses</description>
- <property name="driverClassName"
value="org.hsqldb.jdbcDriver"/>
- <property name="url"
value="jdbc:hsqldb:file:target/temp/data/portal"/>
- <property name="username" value="sa"/>
- <property name="password" value=""/>
+ <property name="driverClassName"
value="oracle.jdbc.OracleDriver" />
+ <property name="url"
value="jdbc:oracle:thin:@db2.exoua-int:1521:orclvm" />
+ <property name="username" value="exoperf" />
+ <property name="password" value="exo12321" />
+ <property name="maxActive" value="600" />
+ <property name="maxIdle" value="50" />
+ <property name="initialSize" value="5" />
</properties-param>
</init-params>
</component-plugin>
Modified:
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config-sjdbc.xml
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config-sjdbc.xml 2010-03-22
09:54:46 UTC (rev 2090)
+++
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config-sjdbc.xml 2010-03-22
12:11:01 UTC (rev 2091)
@@ -38,6 +38,7 @@
<property name="update-storage" value="false"
/>
<property name="max-buffer-size" value="200k"
/>
<property name="swap-directory"
value="target/temp/swap/ws" />
+ <property name="force.query.hints"
value="true" />
</properties>
<value-storages>
<value-storage id="ws"
class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
Modified:
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml 2010-03-22
09:54:46 UTC (rev 2090)
+++
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml 2010-03-22
12:11:01 UTC (rev 2091)
@@ -36,6 +36,7 @@
<property name="dialect" value="auto" />
<property name="multi-db" value="true" />
<property name="update-storage" value="false"
/>
+
<property name="max-buffer-size" value="200k"
/>
<property name="swap-directory"
value="target/temp/swap/ws" />
</properties>