exo-jcr SVN: r5262 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms.
by do-not-reply@jboss.org
Author: tolusha
Date: 2011-12-05 05:38:30 -0500 (Mon, 05 Dec 2011)
New Revision: 5262
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleanService.java
Log:
EXOJCR-1603: some refactoring, drop indexes for Sybase have been moved to getRemoveIndexesScripts()
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleanService.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleanService.java 2011-12-05 10:00:55 UTC (rev 5261)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleanService.java 2011-12-05 10:38:30 UTC (rev 5262)
@@ -261,6 +261,11 @@
dropScript.add("ALTER TABLE JCR_" + multiDb + "VALUE DROP CONSTRAINT JCR_FK_" + multiDb + "VALUE_PROPERTY");
dropScript.add("ALTER TABLE JCR_" + multiDb + "ITEM DROP CONSTRAINT JCR_PK_" + multiDb + "ITEM");
dropScript.add("ALTER TABLE JCR_" + multiDb + "VALUE DROP CONSTRAINT JCR_PK_" + multiDb + "VALUE");
+ dropScript.add("DROP INDEX JCR_" + multiDb + "ITEM.JCR_IDX_" + multiDb + "ITEM_PARENT");
+ dropScript.add("DROP INDEX JCR_" + multiDb + "ITEM.JCR_IDX_" + multiDb + "ITEM_PARENT_NAME");
+ dropScript.add("DROP INDEX JCR_" + multiDb + "ITEM.JCR_IDX_" + multiDb + "ITEM_PARENT_ID");
+ dropScript.add("DROP INDEX JCR_" + multiDb + "VALUE.JCR_IDX_" + multiDb + "VALUE_PROPERTY");
+ dropScript.add("DROP INDEX JCR_" + multiDb + "REF.JCR_IDX_" + multiDb + "REF_PROPERTY");
}
return dropScript;
@@ -773,6 +778,9 @@
String query = scripts.get(i);
if (query.contains("JCR_PK_" + multiDb + "ITEM PRIMARY KEY(ID),"))
{
+ // removing foreign key creation from initialization scripts for table JCR_S(M)ITEM
+ // it is not possible to create table with such foreign key if the same key exists in
+ // another table of database
query =
query.replace("JCR_PK_" + multiDb + "ITEM PRIMARY KEY(ID),", "JCR_PK_" + multiDb
+ "ITEM PRIMARY KEY(ID)");
@@ -783,6 +791,9 @@
}
else if (query.contains("CONSTRAINT JCR_PK_" + multiDb + "VALUE PRIMARY KEY(ID),"))
{
+ // removing foreign key creation for table JCR_S(M)VALUE
+ // it is not possible to create table with such foreign key if the same key exists in
+ // another table of database
query =
query.replace("CONSTRAINT JCR_PK_" + multiDb + "VALUE PRIMARY KEY(ID),", "CONSTRAINT JCR_PK_"
+ multiDb + "VALUE PRIMARY KEY(ID)");
@@ -793,22 +804,6 @@
}
}
}
- else if (dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_SYBASE))
- {
- for (int i = 0; i < scripts.size(); i++)
- {
- String query = scripts.get(i);
- if (query.contains("JCR_IDX_" + multiDb + "ITEM_PARENT")
- || query.contains("JCR_IDX_" + multiDb + "ITEM_PARENT_NAME")
- || query.contains("JCR_IDX_" + multiDb + "ITEM_PARENT_ID")
- || query.contains("JCR_IDX_" + multiDb + "VALUE_PROPERTY")
- || query.contains("JCR_IDX_" + multiDb + "REF_PROPERTY"))
- {
- scripts.remove(i);
- i--;
- }
- }
- }
return scripts;
}
14 years, 5 months
exo-jcr SVN: r5261 - core/trunk/exo.core.component.organization.api/src/main/java/org/exoplatform/services/organization.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2011-12-05 05:00:55 -0500 (Mon, 05 Dec 2011)
New Revision: 5261
Modified:
core/trunk/exo.core.component.organization.api/src/main/java/org/exoplatform/services/organization/CacheHandler.java
Log:
EXOJCR-1663 : allow descendant CacheHandler classes to expose prefixes into cacheKeys
Modified: core/trunk/exo.core.component.organization.api/src/main/java/org/exoplatform/services/organization/CacheHandler.java
===================================================================
--- core/trunk/exo.core.component.organization.api/src/main/java/org/exoplatform/services/organization/CacheHandler.java 2011-12-05 09:58:13 UTC (rev 5260)
+++ core/trunk/exo.core.component.organization.api/src/main/java/org/exoplatform/services/organization/CacheHandler.java 2011-12-05 10:00:55 UTC (rev 5261)
@@ -19,13 +19,37 @@
package org.exoplatform.services.organization;
import org.exoplatform.services.cache.CacheService;
+import org.exoplatform.services.cache.CachedObjectSelector;
import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.ObjectCacheInfo;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
/**
+ * Cache handler is an entity used to organize access to underlying {@link ExoCache} from Organization Service.
+ * It manages caches for each type of Organization Service entries internally.
+ * <p>
+ * Some organization services relies on multiple data-sources, like JCROrgService.
+ * The last one can use multiple repositories. For this case, CacheHandler provides a way for customizing access
+ * to underlying caches for managing multiple sources of data. Caches for data-sources are isolated using key's
+ * prefixes. Providing an isolation, CacheHandler doesn't create additional cache instances offering better
+ * memory usage.
+ * <p>
+ * Descendant CacheHandler classes that requires caches for multiple data-sources must override following
+ * protected internal menthods:
+ * <ul>
+ * <li>{@link CacheHandler#createCacheKey(Serializable)}<p>- Taking OrgService key as an argument, it generates
+ * a key, that contains data-source identifier. This key is used as cache key. I.e. it takes "user1" and
+ * produces "repository2:user1";</li>
+ * <li>{@link CacheHandler#createOrgServiceKey(Serializable)}<p>
+ * - This is an opposite operation to createCacheKey(Serializable), it produces OrgService key trimming
+ * data-source metadata. I.e. taking "repostiory2:user1" it returns "user1";</li>
+ * <li>{@link CacheHandler#matchKey(Serializable)}<p> - checks if key provided as argument corresponds to
+ * current cacheHandler instance. I.e. checks if key starts with current prefix.</li>
+ * </ul>
+ *
* @author <a href="abazko(a)exoplatform.com">Anatoliy Bazko</a>
* @version $Id: CacheHandler.java 34360 2009-07-22 23:58:59Z tolusha $
*/
@@ -79,7 +103,7 @@
public void put(Serializable key, Object value, CacheType cacheType)
{
- key = createInternalKey(key);
+ key = createCacheKey(key);
if (cacheType == CacheType.USER)
{
@@ -106,7 +130,7 @@
public Object get(Serializable key, CacheType cacheType)
{
Object obj = null;
- key = createInternalKey(key);
+ key = createCacheKey(key);
if (cacheType == CacheType.USER)
{
@@ -142,14 +166,24 @@
{
try
{
- for (Membership m : membershipCache.getCachedObjects())
+ membershipCache.select(new CachedObjectSelector<Serializable, Membership>()
{
- String mkey = getMembershipKey(m);
- if (mkey.indexOf((String)key) >= 0)
+ public boolean select(Serializable cacheKey, ObjectCacheInfo<? extends Membership> ocinfo)
{
- membershipCache.remove(createInternalKey(mkey));
+ return matchKey(cacheKey);
}
- }
+
+ public void onSelect(ExoCache<? extends Serializable, ? extends Membership> cache,
+ Serializable cacheKey, ObjectCacheInfo<? extends Membership> ocinfo) throws Exception
+ {
+ String mkey = getMembershipKey(ocinfo.get());
+ String key = (String)createOrgServiceKey(cacheKey);
+ if ((mkey.indexOf(key) >= 0))
+ {
+ cache.remove(cacheKey);
+ }
+ }
+ });
}
catch (Exception e)
{
@@ -157,7 +191,7 @@
}
else
{
- key = createInternalKey(key);
+ key = createCacheKey(key);
if (cacheType == CacheType.USER)
{
@@ -182,19 +216,31 @@
{
if (cacheType == CacheType.MEMBERSHIP)
{
+
try
{
- Map<Serializable, Membership> wait4Adding = new HashMap<Serializable, Membership>();
-
- for (Membership m : membershipCache.getCachedObjects())
+ final Map<Serializable, Membership> wait4Adding = new HashMap<Serializable, Membership>();
+ final Serializable finalNewKey = newKey;
+ membershipCache.select(new CachedObjectSelector<Serializable, Membership>()
{
- String mkey = getMembershipKey(m);
- if (mkey.indexOf((String)oldKey) >= 0)
+ public boolean select(Serializable cacheKey, ObjectCacheInfo<? extends Membership> ocinfo)
{
- wait4Adding.put(createInternalKey(mkey.replace((String)oldKey, (String)newKey)),
- membershipCache.remove(createInternalKey(mkey)));
+ return matchKey(cacheKey);
}
- }
+
+ public void onSelect(ExoCache<? extends Serializable, ? extends Membership> cache,
+ Serializable cacheKey, ObjectCacheInfo<? extends Membership> ocinfo) throws Exception
+ {
+ String mkey = getMembershipKey(ocinfo.get());
+ String key = (String)createOrgServiceKey(cacheKey);
+ if ((mkey.indexOf(key) >= 0))
+ {
+ wait4Adding.put(createCacheKey(mkey.replace(key, (String)finalNewKey)),
+ cache.remove(createCacheKey(mkey)));
+ }
+ }
+
+ });
membershipCache.putMap(wait4Adding);
}
catch (Exception e)
@@ -203,8 +249,8 @@
}
else
{
- oldKey = createInternalKey(oldKey);
- newKey = createInternalKey(newKey);
+ oldKey = createCacheKey(oldKey);
+ newKey = createCacheKey(newKey);
if (cacheType == CacheType.USER)
{
@@ -252,9 +298,35 @@
/**
* Provide a way of defining cache prefixes for descendant classes.
* This factory method is executed for each cache operation (put, get, remove)
+ *
+ * @param orgServiceKey - key used by Organization Service;
+ * @return key, used to define cache item.
*/
- protected Serializable createInternalKey(Serializable key)
+ protected Serializable createCacheKey(Serializable orgServiceKey)
{
- return key;
+ return orgServiceKey;
}
+
+ /**
+ * Asserts whether key is managed by current CacheHandler
+ *
+ * @param cacheKey
+ * @return
+ */
+ protected boolean matchKey(Serializable cacheKey)
+ {
+ return true;
+ }
+
+ /**
+ * Opposite to createCacheKey(Serializable), retrieving Organization Service key from
+ * Cache key, trimming all data-source metadata.
+ *
+ * @param cacheKey
+ * @return
+ */
+ protected Serializable createOrgServiceKey(Serializable cacheKey)
+ {
+ return cacheKey;
+ }
}
14 years, 5 months
exo-jcr SVN: r5259 - jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/configuration.
by do-not-reply@jboss.org
Author: dkuleshov
Date: 2011-12-05 04:48:13 -0500 (Mon, 05 Dec 2011)
New Revision: 5259
Modified:
jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/configuration/jdbc-data-container-config.xml
Log:
EXOJCR-1668: docbook modified
Modified: jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/configuration/jdbc-data-container-config.xml
===================================================================
--- jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/configuration/jdbc-data-container-config.xml 2011-12-02 15:43:25 UTC (rev 5258)
+++ jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/configuration/jdbc-data-container-config.xml 2011-12-05 09:48:13 UTC (rev 5259)
@@ -83,36 +83,11 @@
</listitem>
</itemizedlist></para>
- <para><note>
- <para>Please note, that JCR requires at least READ_COMMITED isolation
- level and other RDBMS configurations can cause some side-effects and
- issues. So, please, make sure proper isolation level is configured on
- database server side.</para>
- </note><note>
- <para>One more mandatory JCR requirement for underlying databases is a
- case sensitive collation. Microsoft SQL Server both 2005 and 2008
- customers must configure their server with collation corresponding to
- personal needs and requirements, but obligatorily case sensitive. For
- more information please refer to Microsoft SQL Server documentation
- page "Selecting a SQL Server Collation" <ulink
- url="http://msdn.microsoft.com/en-us/library/ms144250.aspx">here.</ulink></para>
- </note><note>
- <para>Be aware that MyISAM is not supported due to its lack of
- transaction support and integrity check, so use it only if you don't
- expect any support and if performances in read accesses are more
- important than the consistency in your use-case. This dialect is only
- dedicated to the community.</para>
- </note><note>
- <para>RDBMS reindexing feature use queries based on LIMIT and OFFSET
- clauses which are not enabled by default for DB2. However, you can
- ensure they are enabled by executing the following <programlisting>$ db2set DB2_COMPATIBILITY_VECTOR=MYS
-$ db2stop
-$ db2start</programlisting></para>
- </note> Each database software supports ANSI SQL standards but also has
- its own specifics. So, each database has its own configuration in eXo JCR
- as a database dialect parameter. If you need a more detailed configuration
- of the database, it's possible to do that by editing the metadata
- SQL-script files.</para>
+ <para>Each database software supports ANSI SQL standards but also has its
+ own specifics. So, each database has its own configuration in eXo JCR as a
+ database dialect parameter. If you need a more detailed configuration of
+ the database, it's possible to do that by editing the metadata SQL-script
+ files.</para>
<para>SQL-scripts you can obtain from jar-file
exo.jcr.component.core-XXX.XXX.jar:conf/storage/. They also can be found
@@ -250,14 +225,6 @@
</tr>
</table>
- <note>
- <para>* MyISAM is not supported due to its lack of transaction support
- and integrity check, so use it only if you don't expect any support and
- if performances in read accesses are more important than the consistency
- in your use-case. This dialect is only dedicated to the
- community.</para>
- </note>
-
<para>In case the non-ANSI node name is used, it's necessary to use a
database with MultiLanguage support[TODO link to MultiLanguage]. Some JDBC
drivers need additional parameters for establishing a Unicode friendly
@@ -284,6 +251,81 @@
</section>
<section>
+ <title>General recommendations for database configuration</title>
+
+ <itemizedlist>
+ <listitem>
+ <para>Please note, that JCR requires at least READ_COMMITED isolation
+ level and other RDBMS configurations can cause some side-effects and
+ issues. So, please, make sure proper isolation level is configured on
+ database server side.</para>
+ </listitem>
+ </itemizedlist>
+
+ <section>
+ <title>DB2 configuration</title>
+
+ <itemizedlist>
+ <listitem>
+ <para>RDBMS reindexing feature use queries based on LIMIT and OFFSET
+ clauses which are not enabled by default. However, you can ensure
+ they are enabled by executing the following <programlisting>$ db2set DB2_COMPATIBILITY_VECTOR=MYS
+$ db2stop
+$ db2start</programlisting></para>
+ </listitem>
+ <listitem>
+ <para>Be aware, when using RDBMS for reindexing need to run
+ "RUNSTATS ON TABLE <scheme>.<table> WITH DISTRIBUTION
+ AND INDEXES ALL" for JCR_SITEM (or JCR_MITEM) and JCR_SVALUE (or
+ JCR_MVALUE) tables.</para>
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section>
+ <title>MySQL configuration</title>
+
+ <itemizedlist>
+ <listitem>
+ <para>MyISAM is not supported due to its lack of transaction support
+ and integrity check, so use it only if you don't expect any support
+ and if performances in read accesses are more important than the
+ consistency in your use-case. This dialect is only dedicated to the
+ community.</para>
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section>
+ <title>PostgresSQL configuration</title>
+
+ <itemizedlist>
+ <listitem>
+ <para>Be aware, when using RDBMS for reindexing need to set
+ "enable_seqscan" to "off" or "default_statistics_target" at least
+ "50"</para>
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section>
+ <title>MS SQL configuration</title>
+
+ <itemizedlist>
+ <listitem>
+ <para>One more mandatory JCR requirement for underlying databases is
+ a case sensitive collation. Microsoft SQL Server both 2005 and 2008
+ customers must configure their server with collation corresponding
+ to personal needs and requirements, but obligatorily case sensitive.
+ For more information please refer to Microsoft SQL Server
+ documentation page "Selecting a SQL Server Collation" <ulink
+ url="http://msdn.microsoft.com/en-us/library/ms144250.aspx">here.</ulink></para>
+ </listitem>
+ </itemizedlist>
+ </section>
+ </section>
+
+ <section>
<title>Multi-database Configuration</title>
<para>You need to configure each workspace in a repository. You may have
14 years, 5 months
exo-jcr SVN: r5258 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms.
by do-not-reply@jboss.org
Author: tolusha
Date: 2011-12-02 10:43:25 -0500 (Fri, 02 Dec 2011)
New Revision: 5258
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleanService.java
Log:
EXOJCR-1603: use rename approach for HSQLDB
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleanService.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleanService.java 2011-12-02 13:48:01 UTC (rev 5257)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleanService.java 2011-12-02 15:43:25 UTC (rev 5258)
@@ -881,7 +881,7 @@
"CONSTRAINT " + constraintName + " FOREIGN KEY(PARENT_ID) REFERENCES JCR_" + multiDb + "ITEM(ID)";
commitScripts.add("ALTER TABLE JCR_" + multiDb + "ITEM ADD " + constraint);
- // PostgreSQL, DB2 on connection.rollback() restore all removed constrains
+ // PostgreSQL, DB2 and MSSQL on connection.rollback() will restore all removed constrains
if (!dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_PGSQL)
&& !dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_DB2)
&& !dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_DB2V8)
@@ -915,14 +915,23 @@
}
else
{
- if (dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_ORACLE)
- || dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_ORACLEOCI)
- || dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_MYSQL)
- || dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_MYSQL_UTF8)
- || dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_MYSQL_MYISAM)
- || dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_MYSQL_MYISAM_UTF8)
- || dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_SYBASE))
+ // PostgreSQL, DB2 and MSSQL on connection.rollback() will restore all removed tables
+ if (dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_DB2)
+ || dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_DB2V8)
+ || dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_MSSQL)
+ || dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_PGSQL))
{
+ List<String> cleanScripts = new ArrayList<String>();
+
+ cleanScripts.addAll(getDropTableScripts(isMultiDB, dialect));
+ cleanScripts.addAll(getInitializationDBScripts(isMultiDB, dialect));
+ cleanScripts.addAll(getRemoveIndexesScripts(isMultiDB, dialect));
+
+ return new DBCleaner(jdbcConn, cleanScripts, new ArrayList<String>(), getRestoreIndexesScripts(isMultiDB,
+ dialect), false);
+ }
+ else
+ {
ArrayList<String> cleanScripts = new ArrayList<String>();
cleanScripts.addAll(getRenameScripts(isMultiDB, dialect));
cleanScripts.addAll(getInitializationDBScripts(isMultiDB, dialect));
@@ -935,17 +944,6 @@
return new DBCleaner(jdbcConn, cleanScripts, getRollbackScripts(isMultiDB, dialect), commitScript,
dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_SYBASE));
}
- else
- {
- List<String> cleanScripts = new ArrayList<String>();
-
- cleanScripts.addAll(getDropTableScripts(isMultiDB, dialect));
- cleanScripts.addAll(getInitializationDBScripts(isMultiDB, dialect));
- cleanScripts.addAll(getRemoveIndexesScripts(isMultiDB, dialect));
-
- return new DBCleaner(jdbcConn, cleanScripts, new ArrayList<String>(), getRestoreIndexesScripts(isMultiDB,
- dialect), dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_SYBASE));
- }
}
}
}
14 years, 5 months
exo-jcr SVN: r5257 - in jcr/trunk: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms and 2 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2011-12-02 08:48:01 -0500 (Fri, 02 Dec 2011)
New Revision: 5257
Removed:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/rdbms/SybaseDBRestore.java
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/rdbms/DBRestore.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleanService.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleaner.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DummyDBCleaner.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingRepositorySameConfigRestore.java
Log:
EXOJCR-1603: moved setAutoCommit(true) for Sybase db from DBCleanerService to DBCleaner
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/rdbms/DBRestore.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/rdbms/DBRestore.java 2011-12-02 13:29:16 UTC (rev 5256)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/rdbms/DBRestore.java 2011-12-02 13:48:01 UTC (rev 5257)
@@ -126,15 +126,15 @@
protected List<String> successfulExecuted;
/**
- * Constructor DBRestor.
+ * Constructor DBRestore.
*
* @throws NamingException
* @throws SQLException
* @throws RepositoryConfigurationException
*/
public DBRestore(File storageDir, Connection jdbcConn, Map<String, RestoreTableRule> tables,
- WorkspaceEntry wsConfig, FileCleaner fileCleaner, DBCleaner dbCleaner) throws NamingException, SQLException,
- RepositoryConfigurationException
+ WorkspaceEntry wsConfig, FileCleaner fileCleaner, DBCleaner dbCleaner) throws NamingException,
+ SQLException, RepositoryConfigurationException
{
this.jdbcConn = jdbcConn;
this.fileCleaner = fileCleaner;
@@ -565,6 +565,11 @@
*/
protected void commitBatch() throws SQLException
{
+ // commit every batch for sybase
+ if (dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_SYBASE))
+ {
+ jdbcConn.commit();
+ }
}
/**
Deleted: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/rdbms/SybaseDBRestore.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/rdbms/SybaseDBRestore.java 2011-12-02 13:29:16 UTC (rev 5256)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/rdbms/SybaseDBRestore.java 2011-12-02 13:48:01 UTC (rev 5257)
@@ -1,160 +0,0 @@
-/*
- * Copyright (C) 2003-2011 eXo Platform SAS.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see<http://www.gnu.org/licenses/>.
- */
-package org.exoplatform.services.jcr.impl.backup.rdbms;
-
-import org.exoplatform.services.database.utils.ExceptionManagementHelper;
-import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
-import org.exoplatform.services.jcr.config.WorkspaceEntry;
-import org.exoplatform.services.jcr.impl.backup.BackupException;
-import org.exoplatform.services.jcr.impl.clean.rdbms.DBCleaner;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-
-import java.io.File;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.Map;
-
-import javax.naming.NamingException;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * <br/>Date: 2011
- *
- * @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex Reshetnyak</a>
- * @version $Id: SybaseDBRestore.java 111 2011-11-11 11:11:11Z rainf0x $
- */
-public class SybaseDBRestore extends DBRestore
-{
- private final Boolean isMultiDb;
-
- /**
- * Constructor SybaseDBRestore.
- */
- public SybaseDBRestore(File storageDir, Connection jdbcConn, Map<String, RestoreTableRule> tables,
- WorkspaceEntry wsConfig, FileCleaner fileCleaner, DBCleaner dbCleaner) throws NamingException, SQLException,
- RepositoryConfigurationException
- {
- super(storageDir, jdbcConn, tables, wsConfig, fileCleaner, dbCleaner);
- this.isMultiDb = tables.entrySet().iterator().next().getValue().getDstMultiDb();
- }
-
- /**
- * {@inheritDoc}
- */
- public void clean() throws BackupException
- {
- try
- {
- // the Sybase is not allowed DDL query (CREATE TABLE, DROP TABLE, etc. ) within a multi-statement transaction
- if (!jdbcConn.getAutoCommit())
- {
- jdbcConn.setAutoCommit(true);
- }
-
- super.clean();
- }
- catch (SQLException e)
- {
- throw new BackupException(ExceptionManagementHelper.getFullSQLExceptionMessage(e), e);
- }
- finally
- {
- try
- {
- jdbcConn.setAutoCommit(false);
- }
- catch (SQLException e)
- {
- LOG.warn("Can't set auto commit to \"false\"", e);
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void commit() throws BackupException
- {
- try
- {
- // the Sybase is not allowed DDL query (CREATE TABLE, DROP TABLE, etc. ) within a multi-statement transaction
- if (!jdbcConn.getAutoCommit())
- {
- jdbcConn.setAutoCommit(true);
- }
-
- super.commit();
- }
- catch (SQLException e)
- {
- throw new BackupException(ExceptionManagementHelper.getFullSQLExceptionMessage(e), e);
- }
- finally
- {
- try
- {
- jdbcConn.setAutoCommit(false);
- }
- catch (SQLException e)
- {
- LOG.warn("Can't set auto commit to \"false\"", e);
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void rollback() throws BackupException
- {
- try
- {
- // the Sybase is not allowed DDL query (CREATE TABLE, DROP TABLE, etc. ) within a multi-statement transaction
- if (!jdbcConn.getAutoCommit())
- {
- jdbcConn.setAutoCommit(true);
- }
-
- super.rollback();
- }
- catch (SQLException e)
- {
- throw new BackupException(ExceptionManagementHelper.getFullSQLExceptionMessage(e), e);
- }
- finally
- {
- try
- {
- jdbcConn.setAutoCommit(false);
- }
- catch (SQLException e)
- {
- LOG.warn("Can't set auto commit to \"false\"", e);
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- protected void commitBatch() throws SQLException
- {
- jdbcConn.commit();
- }
-}
-
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleanService.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleanService.java 2011-12-02 13:29:16 UTC (rev 5256)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleanService.java 2011-12-02 13:48:01 UTC (rev 5257)
@@ -176,15 +176,6 @@
dialect = DialectDetecter.detect(jdbcConn.getMetaData());
}
- // Sybase doesn't allow DDL scripts inside transaction
- if (dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_SYBASE))
- {
- if (!jdbcConn.getAutoCommit())
- {
- jdbcConn.setAutoCommit(true);
- }
- }
-
if (dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_ORACLE)
|| dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_ORACLEOCI)
|| dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_MYSQL)
@@ -194,26 +185,26 @@
|| dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_SYBASE)
|| dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_HSQLDB))
{
- ArrayList<String> dbCleanerScripts = new ArrayList<String>();
+ List<String> dbCleanerScripts = new ArrayList<String>();
dbCleanerScripts.addAll(getRenameScripts(isMultiDB, dialect));
dbCleanerScripts.addAll(getInitializationDBScripts(isMultiDB, dialect));
dbCleanerScripts.addAll(getRemoveIndexesScripts(isMultiDB, dialect));
- ArrayList<String> afterRestoreScript = new ArrayList<String>();
+ List<String> afterRestoreScript = new ArrayList<String>();
afterRestoreScript.addAll(getRemoveOldObjectsScripts(isMultiDB, dialect));
afterRestoreScript.addAll(getRestoreIndexesScripts(isMultiDB, dialect));
- return new DBCleaner(jdbcConn, dbCleanerScripts, getRollbackScripts(isMultiDB, dialect),
- afterRestoreScript);
+ return new DBCleaner(jdbcConn, dbCleanerScripts, getRollbackScripts(isMultiDB, dialect), afterRestoreScript,
+ dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_SYBASE));
}
- ArrayList<String> dbCleanerScripts = new ArrayList<String>();
+ List<String> dbCleanerScripts = new ArrayList<String>();
dbCleanerScripts.addAll(getDropTableScripts(isMultiDB, dialect));
dbCleanerScripts.addAll(getInitializationDBScripts(isMultiDB, dialect));
dbCleanerScripts.addAll(getRemoveIndexesScripts(isMultiDB, dialect));
return new DBCleaner(jdbcConn, dbCleanerScripts, new ArrayList<String>(), getRestoreIndexesScripts(isMultiDB,
- dialect));
+ dialect), dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_SYBASE));
}
@@ -847,15 +838,6 @@
dialect = DialectDetecter.detect(jdbcConn.getMetaData());
}
- // Sybase doesn't allow DDL scripts inside transaction
- if (dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_SYBASE))
- {
- if (!jdbcConn.getAutoCommit())
- {
- jdbcConn.setAutoCommit(true);
- }
- }
-
if (!isMultiDB)
{
boolean cleanWithHelper = false;
@@ -923,12 +905,13 @@
String deleteItems =
"delete from JCR_SITEM where I_CLASS=1 and CONTAINER_NAME='" + containerName + "' and PARENT_ID=?";
- return new DBCleaner(jdbcConn, cleanScripts, rollbackScripts, commitScripts,
- new RecursiveDBCleanHelper(jdbcConn, selectItems, deleteItems));
+ return new DBCleaner(jdbcConn, cleanScripts, rollbackScripts, commitScripts, new RecursiveDBCleanHelper(
+ jdbcConn, selectItems, deleteItems), dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_SYBASE));
}
cleanScripts.add("delete from JCR_SITEM where CONTAINER_NAME='" + containerName + "'");
- return new DBCleaner(jdbcConn, cleanScripts, rollbackScripts, commitScripts);
+ return new DBCleaner(jdbcConn, cleanScripts, rollbackScripts, commitScripts,
+ dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_SYBASE));
}
else
{
@@ -949,7 +932,8 @@
commitScript.addAll(getRemoveOldObjectsScripts(isMultiDB, dialect));
commitScript.addAll(getRestoreIndexesScripts(isMultiDB, dialect));
- return new DBCleaner(jdbcConn, cleanScripts, getRollbackScripts(isMultiDB, dialect), commitScript);
+ return new DBCleaner(jdbcConn, cleanScripts, getRollbackScripts(isMultiDB, dialect), commitScript,
+ dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_SYBASE));
}
else
{
@@ -960,7 +944,7 @@
cleanScripts.addAll(getRemoveIndexesScripts(isMultiDB, dialect));
return new DBCleaner(jdbcConn, cleanScripts, new ArrayList<String>(), getRestoreIndexesScripts(isMultiDB,
- dialect));
+ dialect), dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_SYBASE));
}
}
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleaner.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleaner.java 2011-12-02 13:29:16 UTC (rev 5256)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleaner.java 2011-12-02 13:48:01 UTC (rev 5257)
@@ -18,7 +18,6 @@
import org.exoplatform.commons.utils.SecurityHelper;
import org.exoplatform.services.jcr.core.security.JCRRuntimePermissions;
-import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializer;
import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializerHelper;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -29,7 +28,6 @@
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
-import java.util.regex.Pattern;
/**
* The goal of this class is removing workspace data from database.
@@ -50,11 +48,6 @@
protected final Connection connection;
/**
- * Pattern for JCR tables.
- */
- protected final Pattern dbObjectNamePattern;
-
- /**
* Common clean scripts for database.
*/
protected final List<String> cleanScripts = new ArrayList<String>();
@@ -75,17 +68,9 @@
protected final DBCleanHelper dbCleanHelper;
/**
- * DBCleaner constructor.
- *
- * @param connection
- * connection to database where workspace tables is placed
- * @param cleanScripts
- * scripts for cleaning database
+ * Idicates if executing scripts should be done in autoCommit mode.
*/
- public DBCleaner(Connection connection, List<String> cleanScripts)
- {
- this(connection, cleanScripts, null);
- }
+ protected final boolean autoCommit;
/**
* DBCleaner constructor.
@@ -93,24 +78,6 @@
* @param connection
* connection to database where workspace tables is placed
* @param cleanScripts
- * scripts for cleaning database
- * @param dbCleanHelper
- * class which help to clean database by executing special queries
- */
- public DBCleaner(Connection connection, List<String> cleanScripts, DBCleanHelper dbCleanHelper)
- {
- this.dbObjectNamePattern = Pattern.compile(DBInitializer.SQL_OBJECTNAME, Pattern.CASE_INSENSITIVE);
- this.connection = connection;
- this.cleanScripts.addAll(cleanScripts);
- this.dbCleanHelper = dbCleanHelper;
- }
-
- /**
- * DBCleaner constructor.
- *
- * @param connection
- * connection to database where workspace tables is placed
- * @param cleanScripts
* scripts for cleaning database
* @param rollbackScripts
* scripts for execution when something failed
@@ -118,13 +85,18 @@
* scripts for removing temporary objects
* @param dbCleanHelper
* class which help to clean database by executing special queries
+ * @param autoCommit
+ * indicates if executing scripts should be done in autoCommit mode
*/
public DBCleaner(Connection connection, List<String> cleanScripts, List<String> rollbackScripts,
- List<String> commitScripts, DBCleanHelper cleanHelper)
+ List<String> commitScripts, DBCleanHelper dbCleanHelper, boolean autoCommit)
{
- this(connection, cleanScripts, cleanHelper);
+ this.connection = connection;
+ this.cleanScripts.addAll(cleanScripts);
this.rollbackScripts.addAll(rollbackScripts);
this.commitScripts.addAll(commitScripts);
+ this.dbCleanHelper = dbCleanHelper;
+ this.autoCommit = autoCommit;
}
/**
@@ -137,12 +109,14 @@
* @param rollbackScripts
* scripts for execution when something failed
* @param commitScripts
- * scripts for removing temporary objects
+ * scripts for removing temporary objects
+ * @param autoCommit
+ * indicates if executing scripts should be done in autoCommit mode
*/
public DBCleaner(Connection connection, List<String> cleanScripts, List<String> rollbackScripts,
- List<String> commitScripts)
+ List<String> commitScripts, boolean autoCommit)
{
- this(connection, cleanScripts, rollbackScripts, commitScripts, null);
+ this(connection, cleanScripts, rollbackScripts, commitScripts, null, autoCommit);
}
/**
@@ -201,6 +175,14 @@
security.checkPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION);
}
+ // set the new autoCommit mode if need
+ // for example, the Sybase is not allowed DDL query (CREATE TABLE, DROP TABLE, etc. ) within a multi-statement transaction
+ boolean autoCommit = connection.getAutoCommit();
+ if (this.autoCommit != autoCommit)
+ {
+ connection.setAutoCommit(this.autoCommit);
+ }
+
Statement st = connection.createStatement();
try
{
@@ -228,6 +210,12 @@
{
LOG.error("Can't close the Statement." + e);
}
+
+ // restore previous autoCommit mode
+ if (this.autoCommit != autoCommit)
+ {
+ connection.setAutoCommit(autoCommit);
+ }
}
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DummyDBCleaner.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DummyDBCleaner.java 2011-12-02 13:29:16 UTC (rev 5256)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DummyDBCleaner.java 2011-12-02 13:48:01 UTC (rev 5257)
@@ -16,9 +16,8 @@
*/
package org.exoplatform.services.jcr.impl.clean.rdbms;
-import java.sql.Connection;
import java.sql.SQLException;
-import java.util.List;
+import java.util.ArrayList;
/**
* Created by The eXo Platform SAS.
@@ -34,20 +33,12 @@
/**
* DummyDBCleaner constructor.
*/
- public DummyDBCleaner(Connection connection, List<String> cleanScripts)
+ public DummyDBCleaner()
{
- super(connection, cleanScripts);
+ super(null, new ArrayList<String>(), new ArrayList<String>(), new ArrayList<String>(), null, false);
}
/**
- * DummyDBCleaner constructor.
- */
- public DummyDBCleaner(Connection connection, List<String> cleanScripts, DBCleanHelper dbCleanHelper)
- {
- super(connection, cleanScripts, dbCleanHelper);
- }
-
- /**
* {@inheritDoc}
*/
public void executeCleanScripts() throws SQLException
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 2011-12-02 13:29:16 UTC (rev 5256)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java 2011-12-02 13:48:01 UTC (rev 5257)
@@ -38,7 +38,6 @@
import org.exoplatform.services.jcr.impl.backup.rdbms.DataRestoreContext;
import org.exoplatform.services.jcr.impl.backup.rdbms.DirectoryRestore;
import org.exoplatform.services.jcr.impl.backup.rdbms.RestoreTableRule;
-import org.exoplatform.services.jcr.impl.backup.rdbms.SybaseDBRestore;
import org.exoplatform.services.jcr.impl.clean.rdbms.DBCleanService;
import org.exoplatform.services.jcr.impl.clean.rdbms.DBCleaner;
import org.exoplatform.services.jcr.impl.core.lock.cacheable.AbstractCacheableLockManager;
@@ -1291,17 +1290,9 @@
dbCleaner = DBCleanService.getWorkspaceDBCleaner(jdbcConn, wsConfig);
}
- if (dbDialect == DBConstants.DB_DIALECT_SYBASE)
- {
- restorers.add(new SybaseDBRestore(storageDir, jdbcConn, tables, wsConfig, swapCleaner, dbCleaner));
- }
- else
- {
- restorers.add(new DBRestore(storageDir, jdbcConn, tables, wsConfig, swapCleaner, dbCleaner));
- }
+ restorers.add(new DBRestore(storageDir, jdbcConn, tables, wsConfig, swapCleaner, dbCleaner));
// prepare value storage restorer
- File backupValueStorageDir = new File(storageDir, "values");
if (wsConfig.getContainer().getValueStorages() != null)
{
List<File> dataDirs = new ArrayList<File>();
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingRepositorySameConfigRestore.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingRepositorySameConfigRestore.java 2011-12-02 13:29:16 UTC (rev 5256)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingRepositorySameConfigRestore.java 2011-12-02 13:48:01 UTC (rev 5257)
@@ -155,7 +155,7 @@
new Object[]{
fullBackupDir,
jdbcConn,
- new DummyDBCleaner(jdbcConn, new ArrayList<String>())});
+ new DummyDBCleaner()});
}
else
{
14 years, 5 months
exo-jcr SVN: r5256 - core/trunk/exo.core.component.organization.api/src/main/java/org/exoplatform/services/organization.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2011-12-02 08:29:16 -0500 (Fri, 02 Dec 2011)
New Revision: 5256
Modified:
core/trunk/exo.core.component.organization.api/src/main/java/org/exoplatform/services/organization/CacheHandler.java
Log:
EXOJCR-1663 : CacheHandler extended with prefix cache-key feture.
Modified: core/trunk/exo.core.component.organization.api/src/main/java/org/exoplatform/services/organization/CacheHandler.java
===================================================================
--- core/trunk/exo.core.component.organization.api/src/main/java/org/exoplatform/services/organization/CacheHandler.java 2011-12-02 09:43:18 UTC (rev 5255)
+++ core/trunk/exo.core.component.organization.api/src/main/java/org/exoplatform/services/organization/CacheHandler.java 2011-12-02 13:29:16 UTC (rev 5256)
@@ -61,7 +61,7 @@
* Cache for Groups.
*/
protected final ExoCache<Serializable, Group> groupCache;
-
+
/**
* Constructor CacheHandler.
*
@@ -79,6 +79,8 @@
public void put(Serializable key, Object value, CacheType cacheType)
{
+ key = createInternalKey(key);
+
if (cacheType == CacheType.USER)
{
userCache.put(key, (User)value);
@@ -104,6 +106,8 @@
public Object get(Serializable key, CacheType cacheType)
{
Object obj = null;
+ key = createInternalKey(key);
+
if (cacheType == CacheType.USER)
{
obj = userCache.get(key);
@@ -134,16 +138,8 @@
public void remove(Serializable key, CacheType cacheType)
{
- if (cacheType == CacheType.USER)
+ if (cacheType == CacheType.MEMBERSHIP)
{
- userCache.remove(key);
- }
- else if (cacheType == CacheType.GROUP)
- {
- groupCache.remove(key);
- }
- else if (cacheType == CacheType.MEMBERSHIP)
- {
try
{
for (Membership m : membershipCache.getCachedObjects())
@@ -151,7 +147,7 @@
String mkey = getMembershipKey(m);
if (mkey.indexOf((String)key) >= 0)
{
- membershipCache.remove(mkey);
+ membershipCache.remove(createInternalKey(mkey));
}
}
}
@@ -159,28 +155,33 @@
{
}
}
- else if (cacheType == CacheType.MEMBERSHIPTYPE)
+ else
{
- membershipTypeCache.remove(key);
+ key = createInternalKey(key);
+
+ if (cacheType == CacheType.USER)
+ {
+ userCache.remove(key);
+ }
+ else if (cacheType == CacheType.GROUP)
+ {
+ groupCache.remove(key);
+ }
+ else if (cacheType == CacheType.MEMBERSHIPTYPE)
+ {
+ membershipTypeCache.remove(key);
+ }
+ else if (cacheType == CacheType.USER_PROFILE)
+ {
+ userProfileCache.remove(key);
+ }
}
- else if (cacheType == CacheType.USER_PROFILE)
- {
- userProfileCache.remove(key);
- }
}
public void move(Serializable oldKey, Serializable newKey, CacheType cacheType)
{
- if (cacheType == CacheType.USER)
+ if (cacheType == CacheType.MEMBERSHIP)
{
- userCache.put(newKey, userCache.remove(oldKey));
- }
- else if (cacheType == CacheType.GROUP)
- {
- groupCache.put(newKey, groupCache.remove(oldKey));
- }
- else if (cacheType == CacheType.MEMBERSHIP)
- {
try
{
Map<Serializable, Membership> wait4Adding = new HashMap<Serializable, Membership>();
@@ -190,24 +191,38 @@
String mkey = getMembershipKey(m);
if (mkey.indexOf((String)oldKey) >= 0)
{
- wait4Adding.put(mkey.replace((String)oldKey, (String)newKey), membershipCache.remove(mkey));
+ wait4Adding.put(createInternalKey(mkey.replace((String)oldKey, (String)newKey)),
+ membershipCache.remove(createInternalKey(mkey)));
}
}
-
membershipCache.putMap(wait4Adding);
}
catch (Exception e)
{
}
}
- else if (cacheType == CacheType.MEMBERSHIPTYPE)
+ else
{
- membershipTypeCache.put(newKey, membershipTypeCache.remove(oldKey));
+ oldKey = createInternalKey(oldKey);
+ newKey = createInternalKey(newKey);
+
+ if (cacheType == CacheType.USER)
+ {
+ userCache.put(newKey, userCache.remove(oldKey));
+ }
+ else if (cacheType == CacheType.GROUP)
+ {
+ groupCache.put(newKey, groupCache.remove(oldKey));
+ }
+ else if (cacheType == CacheType.MEMBERSHIPTYPE)
+ {
+ membershipTypeCache.put(newKey, membershipTypeCache.remove(oldKey));
+ }
+ else if (cacheType == CacheType.USER_PROFILE)
+ {
+ userProfileCache.put(newKey, userProfileCache.remove(oldKey));
+ }
}
- else if (cacheType == CacheType.USER_PROFILE)
- {
- userProfileCache.put(newKey, userProfileCache.remove(oldKey));
- }
}
public String getMembershipKey(Membership m)
@@ -230,8 +245,16 @@
return key.toString();
}
- public static enum CacheType
- {
+ public static enum CacheType {
USER, GROUP, MEMBERSHIP, MEMBERSHIPTYPE, USER_PROFILE
}
+
+ /**
+ * Provide a way of defining cache prefixes for descendant classes.
+ * This factory method is executed for each cache operation (put, get, remove)
+ */
+ protected Serializable createInternalKey(Serializable key)
+ {
+ return key;
+ }
}
14 years, 5 months
exo-jcr SVN: r5254 - jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl.
by do-not-reply@jboss.org
Author: tolusha
Date: 2011-12-02 02:36:09 -0500 (Fri, 02 Dec 2011)
New Revision: 5254
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingWorkspaceRestore.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingWorkspaceSameConfigRestore.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobRepositoryRestore.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobWorkspaceRestore.java
Log:
EXOJCR-1631: Restore state is not managed properly by restore jobs in some cases
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingWorkspaceRestore.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingWorkspaceRestore.java 2011-12-01 15:24:02 UTC (rev 5253)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingWorkspaceRestore.java 2011-12-02 07:36:09 UTC (rev 5254)
@@ -61,7 +61,7 @@
* {@inheritDoc}
*/
@Override
- protected void restore() throws WorkspaceRestoreException
+ protected void restoreWorkspace() throws WorkspaceRestoreException
{
try
{
@@ -99,7 +99,7 @@
component.clean();
}
- super.restore();
+ super.restoreWorkspace();
}
catch (Throwable t)
{
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingWorkspaceSameConfigRestore.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingWorkspaceSameConfigRestore.java 2011-12-01 15:24:02 UTC (rev 5253)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingWorkspaceSameConfigRestore.java 2011-12-02 07:36:09 UTC (rev 5254)
@@ -68,7 +68,7 @@
* {@inheritDoc}
*/
@Override
- protected void restore() throws WorkspaceRestoreException
+ protected void restoreWorkspace() throws WorkspaceRestoreException
{
// list of data restorers
List<DataRestore> dataRestorer = new ArrayList<DataRestore>();
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobRepositoryRestore.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobRepositoryRestore.java 2011-12-01 15:24:02 UTC (rev 5253)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobRepositoryRestore.java 2011-12-02 07:36:09 UTC (rev 5254)
@@ -16,8 +16,6 @@
*/
package org.exoplatform.services.jcr.ext.backup.impl;
-
-
import org.exoplatform.services.jcr.RepositoryService;
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.config.RepositoryEntry;
@@ -131,7 +129,7 @@
* @throws RepositoryRestoreExeption
* if exception occurred during restore
*/
- protected void restore() throws RepositoryRestoreExeption
+ final protected void restore() throws RepositoryRestoreExeption
{
try
{
@@ -162,7 +160,7 @@
* will be generated the Throwable
*/
protected void restoreRepository() throws RepositoryRestoreExeption, BackupOperationException,
- ClassNotFoundException
+ ClassNotFoundException
{
List<WorkspaceEntry> originalWorkspaceEntrys = repositoryEntry.getWorkspaceEntries();
@@ -182,7 +180,7 @@
//getting backup chail log to system workspace.
BackupChainLog systemBackupChainLog = workspacesMapping.get(systemWorkspaceEntry.getName());
-
+
WorkspaceInitializerEntry wiEntry = getWorkspaceInitializerEntry(systemBackupChainLog);
// set initializer
@@ -223,8 +221,9 @@
{
restored = false;
- log.error("Can not restore workspace \"" + currennWorkspaceName + " in repository \""
- + repositoryEntry.getName() + "\".", e);
+ log.error(
+ "Can not restore workspace \"" + currennWorkspaceName + " in repository \"" + repositoryEntry.getName()
+ + "\".", e);
throw new RepositoryRestoreExeption("Can not restore workspace \"" + currennWorkspaceName
+ " in repository \"" + repositoryEntry.getName() + "\"." + " There was database error.", e);
@@ -234,8 +233,9 @@
{
restored = false;
- log.error("Can not restore workspace \"" + currennWorkspaceName + " in repository \""
- + repositoryEntry.getName() + "\".", t);
+ log.error(
+ "Can not restore workspace \"" + currennWorkspaceName + " in repository \"" + repositoryEntry.getName()
+ + "\".", t);
throw new RepositoryRestoreExeption("Can not restore workspace \"" + currennWorkspaceName
+ " in repository \"" + repositoryEntry.getName() + "\".", t);
@@ -377,19 +377,10 @@
{
try
{
- stateRestore = REPOSITORY_RESTORE_STARTED;
- startTime = Calendar.getInstance();
-
- restoreRepository();
-
- stateRestore = REPOSITORY_RESTORE_SUCCESSFUL;
- endTime = Calendar.getInstance();
+ restore();
}
catch (Throwable t)
{
- stateRestore = REPOSITORY_RESTORE_FAIL;
- restoreException = t;
-
log.error("The restore was fail", t);
}
}
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobWorkspaceRestore.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobWorkspaceRestore.java 2011-12-01 15:24:02 UTC (rev 5253)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobWorkspaceRestore.java 2011-12-02 07:36:09 UTC (rev 5254)
@@ -25,6 +25,7 @@
import org.exoplatform.services.jcr.core.WorkspaceContainerFacade;
import org.exoplatform.services.jcr.ext.backup.BackupChainLog;
import org.exoplatform.services.jcr.ext.backup.BackupManager;
+import org.exoplatform.services.jcr.ext.backup.RepositoryRestoreExeption;
import org.exoplatform.services.jcr.ext.backup.server.WorkspaceRestoreExeption;
import org.exoplatform.services.jcr.impl.core.RepositoryImpl;
import org.exoplatform.services.jcr.impl.core.SessionRegistry;
@@ -151,10 +152,28 @@
{
try
{
+ restore();
+ }
+ catch (Throwable t)
+ {
+ log.error("The restore was fail", t);
+ }
+ }
+
+ /**
+ * Will be restored the workspace.
+ *
+ * @throws Throwable
+ * will be generated the Throwable
+ */
+ final protected void restore() throws Throwable
+ {
+ try
+ {
stateRestore = RESTORE_STARTED;
startTime = Calendar.getInstance();
- restore();
+ restoreWorkspace();
stateRestore = RESTORE_SUCCESSFUL;
endTime = Calendar.getInstance();
@@ -164,7 +183,7 @@
stateRestore = RESTORE_FAIL;
restoreException = t;
- log.error("The restore was fail", t);
+ throw new RepositoryRestoreExeption(t.getMessage(), t);
}
}
@@ -174,7 +193,7 @@
* @throws Throwable
* will be generated the Throwable
*/
- protected void restore() throws Throwable
+ protected void restoreWorkspace() throws Throwable
{
boolean restored = true;
RepositoryImpl repository = (RepositoryImpl)repositoryService.getRepository(repositoryName);
14 years, 5 months
exo-jcr SVN: r5253 - in jcr/trunk: exo.jcr.component.ext and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2011-12-01 10:24:02 -0500 (Thu, 01 Dec 2011)
New Revision: 5253
Modified:
jcr/trunk/exo.jcr.component.core/pom.xml
jcr/trunk/exo.jcr.component.ext/pom.xml
Log:
EXOJCR-1669: Clean up pom.xml
Modified: jcr/trunk/exo.jcr.component.core/pom.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/pom.xml 2011-12-01 15:02:40 UTC (rev 5252)
+++ jcr/trunk/exo.jcr.component.core/pom.xml 2011-12-01 15:24:02 UTC (rev 5253)
@@ -246,26 +246,6 @@
<artifactId>hsqldb</artifactId>
<scope>test</scope>
</dependency>
- <!-- For Apache Derby support (aka JavaDB) -->
- <!-- dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- <version>10.2.2.0</version>
- <scope>test</scope>
- </dependency -->
- <!-- H2 Database (not supported now) -->
- <!-- dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- <version>1.2.132</version>
- </dependency-->
- <!-- Ingres Database (local repository) -->
- <!-- dependency>
- <groupId>com.ingres.jdbc</groupId>
- <artifactId>iijdbc</artifactId>
- <version>9.2</version>
- <scope>test</scope>
- </dependency -->
</dependencies>
<!-- ======================================================================= -->
<build>
@@ -715,77 +695,6 @@
</plugins>
</build>
</profile>
- <profile>
- <id>run-devtests</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <phase>test</phase>
- <forkMode>never</forkMode>
- <!-- argLine>${env.MAVEN_OPTS}</argLine -->
- <goals>
- <goal>test</goal>
- </goals>
- <systemProperties>
- <property>
- <name>jcr.test.configuration.file</name>
- <value>${jcr.test.configuration.file}</value>
- </property>
- <property>
- <name>jbosscache-shareable</name>
- <value>${jbosscache.shareable}</value>
- </property>
- <property>
- <name>cache-enabled</name>
- <value>${cache.enabled}</value>
- </property>
- <property>
- <name>value-storage-enabled</name>
- <value>${value.storage.enabled}</value>
- </property>
- <property>
- <name>JDBCWorkspaceDataContainer.statistics.enabled</name>
- <value>${statistics.enabled}</value>
- </property>
- <property>
- <name>exo.properties.url</name>
- <value>${properties.url.prefix}${properties.url.suffix}</value>
- </property>
- <!-- We add this system property due to some incompatibility between IPv6 and
- some JVM of Linux distributions such as Ubuntu and Fedora-->
- <property>
- <name>java.net.preferIPv4Stack</name>
- <value>true</value>
- </property>
- <!-- Avoid the firewall -->
- <property>
- <name>bind.address</name>
- <value>127.0.0.1</value>
- </property>
- <property>
- <name>jgroups.stack</name>
- <value>udp</value>
- </property>
- </systemProperties>
- <includes>
- <include>**/**/reading_/Test*.java</include>
- <include>**/**/writing_/Test*.java</include>
- <include>**/**/TestJBossCacheWorkspaceStorageCache_.java</include>
- <exclude>**/**/TestCleanableFileStreamValueData.java</exclude>
- <include>**/**/TestSVNodeDataOptimization_.java</include>
- <include>**/**/TestValueConstraints.java</include>
- </includes>
- <excludes>
- <exclude>org/exoplatform/services/jcr/impl/core/security/Test*.java</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
<!-- We define one profile per driver -->
<profile>
<id>oracle-10G-R2</id>
Modified: jcr/trunk/exo.jcr.component.ext/pom.xml
===================================================================
--- jcr/trunk/exo.jcr.component.ext/pom.xml 2011-12-01 15:02:40 UTC (rev 5252)
+++ jcr/trunk/exo.jcr.component.ext/pom.xml 2011-12-01 15:24:02 UTC (rev 5253)
@@ -316,7 +316,7 @@
</build>
</profile>
<profile>
- <id>oracle</id>
+ <id>oracle-10G-R2</id>
<properties>
<jcr.test.configuration.file>/conf/standalone/test-configuration-backup-oracle.xml</jcr.test.configuration.file>
</properties>
@@ -324,19 +324,19 @@
<dependency>
<groupId>ojdbc</groupId>
<artifactId>ojdbc</artifactId>
- <version>14</version>
+ <version>10.2.0.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ojdbc</groupId>
<artifactId>orai18n</artifactId>
- <version>14</version>
+ <version>10.2.0.4</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
<profile>
- <id>mysql</id>
+ <id>mysql-5.1</id>
<properties>
<jcr.test.configuration.file>/conf/standalone/test-configuration-backup-mysql.xml</jcr.test.configuration.file>
</properties>
@@ -398,7 +398,7 @@
</dependencies>
</profile>
<profile>
- <id>pgsql</id>
+ <id>pgsql-8.3</id>
<properties>
<jcr.test.configuration.file>/conf/standalone/test-configuration-backup-pgsql.xml</jcr.test.configuration.file>
</properties>
14 years, 5 months
exo-jcr SVN: r5252 - in jcr/trunk/exo.jcr.component.core/src: test/java/org/exoplatform/services/jcr/impl and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2011-12-01 10:02:40 -0500 (Thu, 01 Dec 2011)
New Revision: 5252
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/TestRepositoryCheckController.java
Log:
EXOJCR-1664: Added the ability to check if an item is its own parent to the JCRConsistencyTool
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java 2011-12-01 13:27:39 UTC (rev 5251)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java 2011-12-01 15:02:40 UTC (rev 5252)
@@ -19,6 +19,7 @@
package org.exoplatform.services.jcr.impl.storage.jdbc;
import org.exoplatform.commons.utils.SecurityHelper;
+import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.InspectionLog;
import org.exoplatform.services.jcr.impl.InspectionLog.InspectionStatus;
import org.exoplatform.services.jcr.impl.storage.value.ValueDataNotFoundException;
@@ -203,6 +204,14 @@
DBConstants.COLUMN_VORDERNUM},
"Reference records that linked to unexisted nodes. Can be normal for some usecases.", InspectionStatus.WARN));
+ // an item is its own parent.
+ queries.add(new InspectionQuery(jdbcDataContainer.multiDb
+ ? "select * from JCR_MITEM I where I.ID = I.PARENT_ID and I.NAME <> '" + Constants.ROOT_PARENT_NAME + "'"
+ : "select * from JCR_SITEM I where I.ID = I.PARENT_ID and I.CONTAINER_NAME='"
+ + jdbcDataContainer.containerName + "' and I.NAME <> '" + Constants.ROOT_PARENT_NAME + "'", new String[]{
+ DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME}, "An item is its own parent.",
+ InspectionStatus.ERR));
+
// using existing DataSource to get a JDBC Connection.
Connection jdbcConn = jdbcDataContainer.getConnectionFactory().getJdbcConnection();
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/TestRepositoryCheckController.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/TestRepositoryCheckController.java 2011-12-01 13:27:39 UTC (rev 5251)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/TestRepositoryCheckController.java 2011-12-01 15:02:40 UTC (rev 5252)
@@ -309,8 +309,61 @@
checkController.getLastLogFile().delete();
}
+ /**
+ * Usecase: property doens't have have parent node.
+ */
+ public void testDBUsecasesTheParentIdIsIdOfThisNodeSingleDB() throws Exception
+ {
+ checkDBUsecasesTheParentIdIsIdOfThisNode(helper.createRepository(container, false, false));
+ }
/**
+ * Usecase: property doens't have have parent node.
+ */
+ public void testDBUsecasesTheParentIdIsIdOfThisNodeMultiDB() throws Exception
+ {
+ checkDBUsecasesTheParentIdIsIdOfThisNode(helper.createRepository(container, true, false));
+ }
+
+ private void checkDBUsecasesTheParentIdIsIdOfThisNode(ManageableRepository repository) throws Exception
+ {
+ // create repository and add property
+ SessionImpl session =
+ (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
+ NodeImpl node = (NodeImpl)session.getRootNode().addNode("testNode");
+ PropertyImpl prop = (PropertyImpl)node.setProperty("prop", "test");
+ session.save();
+ session.logout();
+
+ // repository is consistent
+ checkController = new RepositoryCheckController(repository);
+ assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith("Repository data is consistent"));
+ checkController.getLastLogFile().delete();
+
+ WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
+ boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
+
+ // change ITEM table
+ String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
+
+ Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
+
+ conn.prepareStatement("DROP INDEX JCR_IDX_" + (isMultiDb ? "M" : "S") + "ITEM_PARENT").execute();
+ conn.prepareStatement("DROP INDEX JCR_IDX_" + (isMultiDb ? "M" : "S") + "ITEM_PARENT_NAME").execute();
+ conn.prepareStatement(
+ "UPDATE JCR_" + (isMultiDb ? "M" : "S") + "ITEM SET PARENT_ID = '" + (isMultiDb ? "" : wsEntry.getName())
+ + node.getInternalIdentifier() + "' WHERE ID='" + (isMultiDb ? "" : wsEntry.getName())
+ + node.getInternalIdentifier() + "'").execute();
+
+ conn.commit();
+ conn.close();
+
+ // repository is inconsistent
+ assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith("Repository data is inconsistent"));
+ checkController.getLastLogFile().delete();
+ }
+
+ /**
* Usecase: property doens't have have parent node.
*/
public void testDBUsecasesPropertyWithoutParentSingleDB() throws Exception
14 years, 5 months