[exo-jcr-commits] exo-jcr SVN: r1348 - in jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl: storage/jbosscache and 1 other directory.
do-not-reply at jboss.org
do-not-reply at jboss.org
Mon Jan 11 11:32:33 EST 2010
Author: nfilotto
Date: 2010-01-11 11:32:32 -0500 (Mon, 11 Jan 2010)
New Revision: 1348
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexChangesFilter.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexInfos.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexUpdateMonitor.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java
Log:
EXOJCR-382: The bug was due to the Transaction creation within the CacheLoader call
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java 2010-01-11 16:18:42 UTC (rev 1347)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java 2010-01-11 16:32:32 UTC (rev 1348)
@@ -23,8 +23,8 @@
import org.exoplatform.services.jcr.impl.storage.jbosscache.AbstractWriteOnlyCacheLoader;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
+import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
-import org.jboss.cache.Modification.ModificationType;
import java.io.IOException;
import java.util.List;
@@ -75,33 +75,24 @@
this.handler = handler;
this.parentHandler = parentHandler;
}
-
+
/**
- * @see org.jboss.cache.loader.AbstractCacheLoader#prepare(java.lang.Object, java.util.List, boolean)
+ * @see org.jboss.cache.loader.CacheLoader#put(org.jboss.cache.Fqn, java.lang.Object, java.lang.Object)
*/
- @Override
- public void prepare(Object tx, List<Modification> modifications, boolean onePhase) throws Exception
+ public Object put(Fqn name, Object key, Object value) throws Exception
{
- // update index on prepare phase
- for (Modification m : modifications)
+ if (key.equals(JbossCacheIndexChangesFilter.LISTWRAPPER) && value instanceof ChangesFilterListsWrapper)
{
- // this is put-key-value modification
- if (m.getType() == ModificationType.PUT_KEY_VALUE)
+ if (log.isDebugEnabled())
{
- if (m.getKey().equals(JbossCacheIndexChangesFilter.LISTWRAPPER)
- && m.getValue() instanceof ChangesFilterListsWrapper)
- {
- if (log.isDebugEnabled())
- {
- log.info("Received list wrapper, start indexing...");
- }
- // updating index
- ChangesFilterListsWrapper wrapper = (ChangesFilterListsWrapper)m.getValue();
- updateIndex(wrapper.getAddedNodes(), wrapper.getRemovedNodes(), wrapper.getParentAddedNodes(), wrapper
- .getParentRemovedNodes());
- }
+ log.info("Received list wrapper, start indexing...");
}
+ // updating index
+ ChangesFilterListsWrapper wrapper = (ChangesFilterListsWrapper)value;
+ updateIndex(wrapper.getAddedNodes(), wrapper.getRemovedNodes(), wrapper.getParentAddedNodes(), wrapper
+ .getParentRemovedNodes());
}
+ return null;
}
/**
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexChangesFilter.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexChangesFilter.java 2010-01-11 16:18:42 UTC (rev 1347)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexChangesFilter.java 2010-01-11 16:32:32 UTC (rev 1348)
@@ -43,9 +43,6 @@
import java.util.Set;
import javax.jcr.RepositoryException;
-import javax.transaction.RollbackException;
-import javax.transaction.Status;
-import javax.transaction.TransactionManager;
/**
* @author <a href="mailto:Sergey.Kabashnyuk at exoplatform.org">Sergey Kabashnyuk</a>
@@ -82,7 +79,7 @@
// initialize IndexerCacheLoader
IndexerCacheLoader indexerCacheLoader = new IndexerCacheLoader();
// inject dependencies
- indexerCacheLoader.init(searchManager, parentSearchManager, handler, parentHandler);
+ indexerCacheLoader.init(searchManager, parentSearchManager, handler, parentHandler);
// set SingltonStoreCacheLoader
SingletonStoreConfig singletonStoreConfig = new SingletonStoreConfig();
singletonStoreConfig.setSingletonStoreClass(IndexerSingletonStoreCacheLoader.class.getName());
@@ -91,7 +88,7 @@
singletonStoreProperties.setProperty("pushStateWhenCoordinator", "false");
singletonStoreProperties.setProperty("pushStateWhenCoordinatorTimeout", "10000");
singletonStoreConfig.setProperties(singletonStoreProperties);
- singletonStoreConfig.setSingletonStoreEnabled(true);
+ singletonStoreConfig.setSingletonStoreEnabled(true);
// create CacheLoaderConfig
IndividualCacheLoaderConfig individualCacheLoaderConfig = new IndividualCacheLoaderConfig();
// set SingletonStoreConfig
@@ -144,43 +141,7 @@
Set<String> parentAddedNodes)
{
String id = IdGenerator.generate();
- // get TransactionManager
- TransactionManager tm = ((CacheSPI<Serializable, Object>)cache).getTransactionManager();
- try
- {
- // if any active transaction, use it
- if (tm.getStatus() == Status.STATUS_ACTIVE)
- {
- cache.put(id, LISTWRAPPER, new ChangesFilterListsWrapper(addedNodes, removedNodes, parentAddedNodes,
- parentRemovedNodes));
- }
- else if (tm.getStatus() == Status.STATUS_NO_TRANSACTION)
- {
- // no active transaction, creating new one
- tm.begin();
- cache.put(id, LISTWRAPPER, new ChangesFilterListsWrapper(addedNodes, removedNodes, parentAddedNodes,
- parentRemovedNodes));
- tm.commit();
- }
- }
- catch (RollbackException e)
- {
- // Indicate that the transaction has been rolled back rather than committed.
- log.error(e.getMessage(), e.getCause());
- }
- catch (Exception e)
- {
- try
- {
- tm.rollback();
- }
- catch (Exception e1)
- {
- // Treat the exception
- log.error(e.getMessage(), e.getCause());
- }
- }
-
+ cache.put(id, LISTWRAPPER, new ChangesFilterListsWrapper(addedNodes, removedNodes, parentAddedNodes,
+ parentRemovedNodes));
}
-
}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexInfos.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexInfos.java 2010-01-11 16:18:42 UTC (rev 1347)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexInfos.java 2010-01-11 16:32:32 UTC (rev 1348)
@@ -24,7 +24,6 @@
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.jboss.cache.Cache;
-import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.notifications.annotation.CacheListener;
import org.jboss.cache.notifications.annotation.NodeModified;
@@ -34,10 +33,6 @@
import java.io.Serializable;
import java.util.Set;
-import javax.transaction.RollbackException;
-import javax.transaction.Status;
-import javax.transaction.TransactionManager;
-
/**
* List of indexes is stored in FS and all operations with it are wrapped by IndexInfos class. In
* standalone mode index and so the list of indexes are managed by indexer and can't be changed
@@ -145,41 +140,7 @@
// write to FS
super.write();
// write to cache
- // cache.put(namesFqn, LIST_KEY, getNames());
- // get transaction manager
- TransactionManager tm = ((CacheSPI<Serializable, Object>)cache).getTransactionManager();
- try
- {
- // if any active transaction, use it
- if (tm.getStatus() == Status.STATUS_ACTIVE)
- {
- cache.put(namesFqn, LIST_KEY, getNames());
- }
- else if (tm.getStatus() == Status.STATUS_NO_TRANSACTION)
- {
- // no active transaction, creating new one
- tm.begin();
- cache.put(namesFqn, LIST_KEY, getNames());
- tm.commit();
- }
- }
- catch (RollbackException e)
- {
- // Indicate that the transaction has been rolled back rather than committed.
- log.error(e.getMessage(), e.getCause());
- }
- catch (Exception e)
- {
- try
- {
- tm.rollback();
- }
- catch (Exception e1)
- {
- // Treat the exception
- log.error(e.getMessage(), e.getCause());
- }
- }
+ cache.put(namesFqn, LIST_KEY, getNames());
}
}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexUpdateMonitor.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexUpdateMonitor.java 2010-01-11 16:18:42 UTC (rev 1347)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexUpdateMonitor.java 2010-01-11 16:32:32 UTC (rev 1348)
@@ -31,10 +31,6 @@
import java.io.IOException;
import java.io.Serializable;
-import javax.transaction.RollbackException;
-import javax.transaction.Status;
-import javax.transaction.TransactionManager;
-
/**
* @author <a href="mailto:Sergey.Kabashnyuk at exoplatform.org">Sergey Kabashnyuk</a>
* @version $Id: exo-jboss-codetemplates.xml 34360 2009-07-22 23:58:59Z ksm $
@@ -131,42 +127,7 @@
{
throw new IllegalStateException("Unable to set updateInProgress value in IndexerIoMode.READ_ONLY mode");
}
-
- // log.info("setUpdateInProgress=" + updateInProgress);
- TransactionManager tm = ((CacheSPI<Serializable, Object>)cache).getTransactionManager();
- try
- {
- // if any active transaction, use it
- if (tm.getStatus() == Status.STATUS_ACTIVE)
- {
- cache.put(PARAMETER_ROOT, PARAMETER_NAME, new Boolean(updateInProgress));
- }
- else if (tm.getStatus() == Status.STATUS_NO_TRANSACTION)
- {
- // no active transaction, creating new one
- tm.begin();
- cache.put(PARAMETER_ROOT, PARAMETER_NAME, new Boolean(updateInProgress));
- tm.commit();
- }
- }
- catch (RollbackException e)
- {
- // Indicate that the transaction has been rolled back rather than committed.
- log.error(e.getMessage(), e.getCause());
- }
- catch (Exception e)
- {
- try
- {
- tm.rollback();
- }
- catch (Exception e1)
- {
- // Treat the exception
- log.error(e.getMessage(), e.getCause());
- }
- }
-
+ cache.put(PARAMETER_ROOT, PARAMETER_NAME, new Boolean(updateInProgress));
}
/**
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java 2010-01-11 16:18:42 UTC (rev 1347)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java 2010-01-11 16:32:32 UTC (rev 1348)
@@ -75,17 +75,17 @@
/**
* {@inheritDoc}
*/
- public void put(Fqn arg0, Map<Object, Object> arg1) throws Exception
+ public void prepare(Object tx, List<Modification> modifications, boolean onePhase) throws Exception
{
- throw new WriteOnlyCacheLoaderException("The method 'put(Fqn arg0, Map<Object, Object> arg1))' should not be called.");
+ throw new WriteOnlyCacheLoaderException("The method 'prepare(Object tx, List<Modification> modifications, boolean onePhase)' should not be called.");
}
/**
* {@inheritDoc}
*/
- public Object put(Fqn arg0, Object arg1, Object arg2) throws Exception
+ public void put(Fqn arg0, Map<Object, Object> arg1) throws Exception
{
- throw new WriteOnlyCacheLoaderException("The method 'put(Fqn arg0, Object arg1, Object arg2)' should not be called.");
+ throw new WriteOnlyCacheLoaderException("The method 'put(Fqn arg0, Map<Object, Object> arg1))' should not be called.");
}
/**
More information about the exo-jcr-commits
mailing list