exo-jcr SVN: r1536 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-01-22 03:13:52 -0500 (Fri, 22 Jan 2010)
New Revision: 1536
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java
Log:
EXOJCR-424: Add comments
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java 2010-01-21 20:14:07 UTC (rev 1535)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java 2010-01-22 08:13:52 UTC (rev 1536)
@@ -56,6 +56,7 @@
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
+import org.jboss.cache.loader.CacheLoader;
import org.picocontainer.Startable;
import java.io.Serializable;
@@ -983,8 +984,10 @@
}
/**
- * Execute the given action outside a transaction
- * @throws LockException
+ * Execute the given action outside a transaction. This is needed since the {@link Cache} used by {@link CacheableLockManager}
+ * manages the persistence of its locks thanks to a {@link CacheLoader} and a {@link CacheLoader} lock the JBoss cache {@link Node}
+ * even for read operations which cause deadlock issue when a XA {@link Transaction} is already opened
+ * @throws LockException when a exception occurs
*/
private <R, A> R executeLockActionNonTxAware(LockActionNonTxAware<R, A> action, A arg) throws LockException
{
16 years, 5 months
exo-jcr SVN: r1535 - in jcr/trunk/exo.jcr.component.core/src: test/resources/conf/cluster and 1 other directories.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-01-21 15:14:07 -0500 (Thu, 21 Jan 2010)
New Revision: 1535
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-lock-config_db1_ws.xml
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-lock-config_db1_ws1.xml
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-lockconfig_db1_ws.xml
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-lockconfig_db1_ws1.xml
Log:
EXOJCR-424: Ensure that all the actions that not support transaction, will be executed outside a transaction and add preload in the config file
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java 2010-01-21 17:20:23 UTC (rev 1534)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java 2010-01-21 20:14:07 UTC (rev 1535)
@@ -72,6 +72,7 @@
import javax.jcr.RepositoryException;
import javax.jcr.lock.LockException;
+import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
/**
@@ -157,6 +158,11 @@
*/
private LockRemover lockRemover;
+ /**
+ * The current Transaction Manager
+ */
+ private TransactionManager tm;
+
private Cache<Serializable, Object> cache;
private final Fqn<String> lockRoot;
@@ -249,6 +255,7 @@
cache = factory.createCache(pathToConfig, false);
+ this.tm = transactionManager;
if (transactionManager != null)
{
cache.getConfiguration().getRuntimeConfig().setTransactionManager(transactionManager);
@@ -309,11 +316,27 @@
return lData;
}
+ private final LockActionNonTxAware<Integer, Object> getNumLocks = new LockActionNonTxAware<Integer, Object>()
+ {
+ public Integer execute(Object arg)
+ {
+ return cache.getChildrenNames(lockRoot).size();
+ }
+ };
+
@Managed
@ManagedDescription("The number of active locks")
public int getNumLocks()
{
- return cache.getChildrenNames(lockRoot).size();
+ try
+ {
+ return executeLockActionNonTxAware(getNumLocks, null);
+ }
+ catch (LockException e)
+ {
+ // ignore me will never occur
+ }
+ return -1;
}
/**
@@ -326,6 +349,19 @@
return sessionManager;
}
+ private final LockActionNonTxAware<Boolean, String> isLockLive = new LockActionNonTxAware<Boolean, String>()
+ {
+ public Boolean execute(String nodeId)
+ {
+ if (pendingLocks.containsKey(nodeId) || cache.getRoot().hasChild(makeLockFqn(nodeId)))
+ {
+ return true;
+ }
+
+ return false;
+ }
+ };
+
/**
* Check is LockManager contains lock. No matter it is in pending or persistent state.
*
@@ -334,11 +370,14 @@
*/
public boolean isLockLive(String nodeId)
{
- if (pendingLocks.containsKey(nodeId) || cache.getRoot().hasChild(makeLockFqn(nodeId)))
+ try
{
- return true;
+ return executeLockActionNonTxAware(isLockLive, nodeId);
}
-
+ catch (LockException e)
+ {
+ // ignore me will never occur
+ }
return false;
}
@@ -521,31 +560,40 @@
}
}
- /**
- * Refreshed lock data in cache
- *
- * @param newLockData
- */
- public void refresh(LockData newLockData) throws LockException
+ private final LockActionNonTxAware<Object, LockData> refresh = new LockActionNonTxAware<Object, LockData>()
{
- //first look pending locks
- if (pendingLocks.containsKey(newLockData.getNodeIdentifier()))
+ public Object execute(LockData newLockData) throws LockException
{
- pendingLocks.put(newLockData.getNodeIdentifier(), newLockData);
- }
- else
- {
- Fqn<String> fqn = makeLockFqn(newLockData.getNodeIdentifier());
- if (cache.getRoot().hasChild(fqn))
+ //first look pending locks
+ if (pendingLocks.containsKey(newLockData.getNodeIdentifier()))
{
- cache.getRoot().addChild(fqn);
+ pendingLocks.put(newLockData.getNodeIdentifier(), newLockData);
}
else
{
- throw new LockException("Can't refresh lock for node " + newLockData.getNodeIdentifier()
- + " since lock is not exist");
+ Fqn<String> fqn = makeLockFqn(newLockData.getNodeIdentifier());
+ if (cache.getRoot().hasChild(fqn))
+ {
+ cache.getRoot().addChild(fqn);
+ }
+ else
+ {
+ throw new LockException("Can't refresh lock for node " + newLockData.getNodeIdentifier()
+ + " since lock is not exist");
+ }
}
+ return null;
}
+ };
+
+ /**
+ * Refreshed lock data in cache
+ *
+ * @param newLockData
+ */
+ public void refresh(LockData newLockData) throws LockException
+ {
+ executeLockActionNonTxAware(refresh, newLockData);
}
/**
@@ -674,9 +722,25 @@
}
}
+ private final LockActionNonTxAware<Boolean, String> lockExist = new LockActionNonTxAware<Boolean, String>()
+ {
+ public Boolean execute(String nodeId) throws LockException
+ {
+ return cache.getRoot().hasChild(makeLockFqn(nodeId));
+ }
+ };
+
private boolean lockExist(String nodeId)
{
- return cache.getRoot().hasChild(makeLockFqn(nodeId));
+ try
+ {
+ return executeLockActionNonTxAware(lockExist, nodeId);
+ }
+ catch (LockException e)
+ {
+ // ignore me will never occur
+ }
+ return false;
}
/**
@@ -763,25 +827,57 @@
return retval;
}
+ private final LockActionNonTxAware<LockData, String> getLockDataById = new LockActionNonTxAware<LockData, String>()
+ {
+ public LockData execute(String nodeId) throws LockException
+ {
+ return (LockData)cache.get(makeLockFqn(nodeId), LOCK_DATA);
+ }
+ };
+
protected LockData getLockDataById(String nodeId)
{
- return (LockData)cache.get(makeLockFqn(nodeId), LOCK_DATA);
+ try
+ {
+ return executeLockActionNonTxAware(getLockDataById, nodeId);
+ }
+ catch (LockException e)
+ {
+ // ignore me will never occur
+ }
+ return null;
}
- protected synchronized List<LockData> getLockList()
+ private final LockActionNonTxAware<List<LockData>, Object> getLockList = new LockActionNonTxAware<List<LockData>, Object>()
{
- Set<Object> nodesId = cache.getChildrenNames(lockRoot);
+ public List<LockData> execute(Object arg) throws LockException
+ {
+ Set<Object> nodesId = cache.getChildrenNames(lockRoot);
- List<LockData> locksData = new ArrayList<LockData>();
- for (Object nodeId : nodesId)
- {
- LockData lockData = (LockData)cache.get(makeLockFqn((String)nodeId), LOCK_DATA);;
- if (lockData != null)
+ List<LockData> locksData = new ArrayList<LockData>();
+ for (Object nodeId : nodesId)
{
- locksData.add(lockData);
+ LockData lockData = (LockData)cache.get(makeLockFqn((String)nodeId), LOCK_DATA);
+ if (lockData != null)
+ {
+ locksData.add(lockData);
+ }
}
+ return locksData;
}
- return locksData;
+ };
+
+ protected synchronized List<LockData> getLockList()
+ {
+ try
+ {
+ return executeLockActionNonTxAware(getLockList, null);
+ }
+ catch (LockException e)
+ {
+ // ignore me will never occur
+ }
+ return null;
}
/**
@@ -885,4 +981,55 @@
}
node.setResident(true);
}
+
+ /**
+ * Execute the given action outside a transaction
+ * @throws LockException
+ */
+ private <R, A> R executeLockActionNonTxAware(LockActionNonTxAware<R, A> action, A arg) throws LockException
+ {
+ Transaction tx = null;
+ try
+ {
+ if (tm != null)
+ {
+ try
+ {
+ tx = tm.suspend();
+ }
+ catch (Exception e)
+ {
+ log.warn("Cannot suspend the current transaction", e);
+ }
+ }
+ return action.execute(arg);
+ }
+ finally
+ {
+ if (tx != null)
+ {
+ try
+ {
+ tm.resume(tx);
+ }
+ catch (Exception e)
+ {
+ log.warn("Cannot resume the current transaction", e);
+ }
+ }
+ }
+ }
+
+ /**
+ * Actions that are not supposed to be called within a transaction
+ *
+ * Created by The eXo Platform SAS
+ * Author : Nicolas Filotto
+ * nicolas.filotto(a)exoplatform.com
+ * 21 janv. 2010
+ */
+ private static interface LockActionNonTxAware<R, A>
+ {
+ R execute(A arg) throws LockException;
+ }
}
Modified: jcr/trunk/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-lock-config_db1_ws.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-lock-config_db1_ws.xml 2010-01-21 17:20:23 UTC (rev 1534)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-lock-config_db1_ws.xml 2010-01-21 20:14:07 UTC (rev 1535)
@@ -1,68 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.1">
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.2">
- <locking useLockStriping="false" concurrencyLevel="50000" lockParentForChildInsertRemove="false" lockAcquisitionTimeout="20000"/>
-
- <clustering mode="replication" clusterName="JBoss-Cache-Lock-Cluster_db1_ws">
- <stateRetrieval timeout="20000" fetchInMemoryState="false" nonBlocking="true"/>
- <jgroupsConfig >
+ <locking useLockStriping="false" concurrencyLevel="50000" lockParentForChildInsertRemove="false" lockAcquisitionTimeout="20000" />
- <TCP bind_addr="127.0.0.1" start_port="9800" loopback="true"
- recv_buf_size="20000000" send_buf_size="640000"
- discard_incompatible_packets="true" max_bundle_size="64000"
- max_bundle_timeout="30" use_incoming_packet_handler="true"
- enable_bundling="false" use_send_queues="false" sock_conn_timeout="300"
- skip_suspected_members="true" use_concurrent_stack="true"
- thread_pool.enabled="true" thread_pool.min_threads="1"
- thread_pool.max_threads="25" thread_pool.keep_alive_time="5000"
- thread_pool.queue_enabled="false" thread_pool.queue_max_size="100"
- thread_pool.rejection_policy="run" oob_thread_pool.enabled="true"
- oob_thread_pool.min_threads="1" oob_thread_pool.max_threads="8"
- oob_thread_pool.keep_alive_time="5000"
- oob_thread_pool.queue_enabled="false"
- oob_thread_pool.queue_max_size="100"
- oob_thread_pool.rejection_policy="run" />
- <MPING timeout="2000" num_initial_members="2" mcast_port="34540"
- bind_addr="127.0.0.1" mcast_addr="224.0.0.1" />
+ <clustering mode="replication" clusterName="JBoss-Cache-Lock-Cluster_db1_ws">
+ <stateRetrieval timeout="20000" fetchInMemoryState="false" nonBlocking="true" />
+ <jgroupsConfig>
+ <TCP bind_addr="127.0.0.1" start_port="9800" loopback="true" recv_buf_size="20000000" send_buf_size="640000" discard_incompatible_packets="true"
+ max_bundle_size="64000" max_bundle_timeout="30" use_incoming_packet_handler="true" enable_bundling="false" use_send_queues="false" sock_conn_timeout="300"
+ skip_suspected_members="true" use_concurrent_stack="true" thread_pool.enabled="true" thread_pool.min_threads="1" thread_pool.max_threads="25"
+ thread_pool.keep_alive_time="5000" thread_pool.queue_enabled="false" thread_pool.queue_max_size="100" thread_pool.rejection_policy="run"
+ oob_thread_pool.enabled="true" oob_thread_pool.min_threads="1" oob_thread_pool.max_threads="8" oob_thread_pool.keep_alive_time="5000"
+ oob_thread_pool.queue_enabled="false" oob_thread_pool.queue_max_size="100" oob_thread_pool.rejection_policy="run" />
+ <MPING timeout="2000" num_initial_members="2" mcast_port="34540" bind_addr="127.0.0.1" mcast_addr="224.0.0.1" />
- <MERGE2 max_interval="30000" min_interval="10000" />
- <FD_SOCK />
- <FD max_tries="5" shun="true" timeout="10000" />
- <VERIFY_SUSPECT timeout="1500" />
- <pbcast.NAKACK discard_delivered_msgs="true" gc_lag="0"
- retransmit_timeout="300,600,1200,2400,4800" use_mcast_xmit="false" />
- <UNICAST timeout="300,600,1200,2400,3600" />
- <pbcast.STABLE desired_avg_gossip="50000" max_bytes="400000"
- stability_delay="1000" />
- <pbcast.GMS join_timeout="5000" print_local_addr="true"
- shun="false" view_ack_collection_timeout="5000" view_bundling="true" />
- <FRAG2 frag_size="60000" />
- <pbcast.STREAMING_STATE_TRANSFER />
- <pbcast.FLUSH timeout="0" />
- </jgroupsConfig>
+ <MERGE2 max_interval="30000" min_interval="10000" />
+ <FD_SOCK />
+ <FD max_tries="5" shun="true" timeout="10000" />
+ <VERIFY_SUSPECT timeout="1500" />
+ <pbcast.NAKACK discard_delivered_msgs="true" gc_lag="0" retransmit_timeout="300,600,1200,2400,4800" use_mcast_xmit="false" />
+ <UNICAST timeout="300,600,1200,2400,3600" />
+ <pbcast.STABLE desired_avg_gossip="50000" max_bytes="400000" stability_delay="1000" />
+ <pbcast.GMS join_timeout="5000" print_local_addr="true" shun="false" view_ack_collection_timeout="5000" view_bundling="true" />
+ <FRAG2 frag_size="60000" />
+ <pbcast.STREAMING_STATE_TRANSFER />
+ <pbcast.FLUSH timeout="0" />
- <sync />
- </clustering>
-
- <loaders passivation="false" shared="true">
- <loader class="org.jboss.cache.loader.JDBCCacheLoader" async="false" fetchPersistentState="false"
- ignoreModifications="false" purgeOnStartup="false">
- <properties>
- cache.jdbc.table.name=jcrlocks_db1_ws
- cache.jdbc.table.create=true
- cache.jdbc.table.drop=false
- cache.jdbc.table.primarykey=jcrlocks_db1_ws_pk
- cache.jdbc.fqn.column=fqn
- cache.jdbc.fqn.type=VARCHAR(512)
- cache.jdbc.node.column=node
- cache.jdbc.node.type=LONGBLOB
- cache.jdbc.parent.column=parent
- cache.jdbc.datasource=jdbcjcr
+ </jgroupsConfig>
+
+ <sync />
+ </clustering>
+
+ <loaders passivation="false" shared="true">
+ <preload>
+ <node fqn="/" />
+ </preload>
+ <loader class="org.jboss.cache.loader.JDBCCacheLoader" async="false" fetchPersistentState="false" ignoreModifications="false" purgeOnStartup="false">
+ <properties>
+ cache.jdbc.table.name=jcrlocks_db1_ws
+ cache.jdbc.table.create=true
+ cache.jdbc.table.drop=false
+ cache.jdbc.table.primarykey=jcrlocks_db1_ws_pk
+ cache.jdbc.fqn.column=fqn
+ cache.jdbc.fqn.type=VARCHAR(512)
+ cache.jdbc.node.column=node
+ cache.jdbc.node.type=LONGBLOB
+ cache.jdbc.parent.column=parent
+ cache.jdbc.datasource=jdbcjcr
</properties>
- </loader>
-
- </loaders>
-
+ </loader>
+
+ </loaders>
+
</jbosscache>
Modified: jcr/trunk/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-lock-config_db1_ws1.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-lock-config_db1_ws1.xml 2010-01-21 17:20:23 UTC (rev 1534)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-lock-config_db1_ws1.xml 2010-01-21 20:14:07 UTC (rev 1535)
@@ -1,68 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.1">
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.2">
- <locking useLockStriping="false" concurrencyLevel="50000" lockParentForChildInsertRemove="false" lockAcquisitionTimeout="20000"/>
-
- <clustering mode="replication" clusterName="JBoss-Cache-Lock-Cluster_db1_ws1">
- <stateRetrieval timeout="20000" fetchInMemoryState="false" nonBlocking="true"/>
- <jgroupsConfig>
+ <locking useLockStriping="false" concurrencyLevel="50000" lockParentForChildInsertRemove="false" lockAcquisitionTimeout="20000" />
- <TCP bind_addr="127.0.0.1" start_port="9850" loopback="true"
- recv_buf_size="20000000" send_buf_size="640000"
- discard_incompatible_packets="true" max_bundle_size="64000"
- max_bundle_timeout="30" use_incoming_packet_handler="true"
- enable_bundling="false" use_send_queues="false" sock_conn_timeout="300"
- skip_suspected_members="true" use_concurrent_stack="true"
- thread_pool.enabled="true" thread_pool.min_threads="1"
- thread_pool.max_threads="25" thread_pool.keep_alive_time="5000"
- thread_pool.queue_enabled="false" thread_pool.queue_max_size="100"
- thread_pool.rejection_policy="run" oob_thread_pool.enabled="true"
- oob_thread_pool.min_threads="1" oob_thread_pool.max_threads="8"
- oob_thread_pool.keep_alive_time="5000"
- oob_thread_pool.queue_enabled="false"
- oob_thread_pool.queue_max_size="100"
- oob_thread_pool.rejection_policy="run" />
- <MPING timeout="2000" num_initial_members="2" mcast_port="34542"
- bind_addr="127.0.0.1" mcast_addr="224.0.0.1" />
+ <clustering mode="replication" clusterName="JBoss-Cache-Lock-Cluster_db1_ws1">
+ <stateRetrieval timeout="20000" fetchInMemoryState="false" nonBlocking="true" />
+ <jgroupsConfig>
+ <TCP bind_addr="127.0.0.1" start_port="9850" loopback="true" recv_buf_size="20000000" send_buf_size="640000" discard_incompatible_packets="true"
+ max_bundle_size="64000" max_bundle_timeout="30" use_incoming_packet_handler="true" enable_bundling="false" use_send_queues="false" sock_conn_timeout="300"
+ skip_suspected_members="true" use_concurrent_stack="true" thread_pool.enabled="true" thread_pool.min_threads="1" thread_pool.max_threads="25"
+ thread_pool.keep_alive_time="5000" thread_pool.queue_enabled="false" thread_pool.queue_max_size="100" thread_pool.rejection_policy="run"
+ oob_thread_pool.enabled="true" oob_thread_pool.min_threads="1" oob_thread_pool.max_threads="8" oob_thread_pool.keep_alive_time="5000"
+ oob_thread_pool.queue_enabled="false" oob_thread_pool.queue_max_size="100" oob_thread_pool.rejection_policy="run" />
+ <MPING timeout="2000" num_initial_members="2" mcast_port="34542" bind_addr="127.0.0.1" mcast_addr="224.0.0.1" />
- <MERGE2 max_interval="30000" min_interval="10000" />
- <FD_SOCK />
- <FD max_tries="5" shun="true" timeout="10000" />
- <VERIFY_SUSPECT timeout="1500" />
- <pbcast.NAKACK discard_delivered_msgs="true" gc_lag="0"
- retransmit_timeout="300,600,1200,2400,4800" use_mcast_xmit="false" />
- <UNICAST timeout="300,600,1200,2400,3600" />
- <pbcast.STABLE desired_avg_gossip="50000" max_bytes="400000"
- stability_delay="1000" />
- <pbcast.GMS join_timeout="5000" print_local_addr="true"
- shun="false" view_ack_collection_timeout="5000" view_bundling="true" />
- <FRAG2 frag_size="60000" />
- <pbcast.STREAMING_STATE_TRANSFER />
- <pbcast.FLUSH timeout="0" />
- </jgroupsConfig>
+ <MERGE2 max_interval="30000" min_interval="10000" />
+ <FD_SOCK />
+ <FD max_tries="5" shun="true" timeout="10000" />
+ <VERIFY_SUSPECT timeout="1500" />
+ <pbcast.NAKACK discard_delivered_msgs="true" gc_lag="0" retransmit_timeout="300,600,1200,2400,4800" use_mcast_xmit="false" />
+ <UNICAST timeout="300,600,1200,2400,3600" />
+ <pbcast.STABLE desired_avg_gossip="50000" max_bytes="400000" stability_delay="1000" />
+ <pbcast.GMS join_timeout="5000" print_local_addr="true" shun="false" view_ack_collection_timeout="5000" view_bundling="true" />
+ <FRAG2 frag_size="60000" />
+ <pbcast.STREAMING_STATE_TRANSFER />
+ <pbcast.FLUSH timeout="0" />
- <sync />
- </clustering>
-
- <loaders passivation="false" shared="true">
- <loader class="org.jboss.cache.loader.JDBCCacheLoader" async="false" fetchPersistentState="false"
- ignoreModifications="false" purgeOnStartup="false">
- <properties>
- cache.jdbc.table.name=jcrlocks_db1_ws1
- cache.jdbc.table.create=true
- cache.jdbc.table.drop=false
- cache.jdbc.table.primarykey=jcrlocks_db1_ws1_pk
- cache.jdbc.fqn.column=fqn
- cache.jdbc.fqn.type=VARCHAR(512)
- cache.jdbc.node.column=node
- cache.jdbc.node.type=LONGBLOB
- cache.jdbc.parent.column=parent
- cache.jdbc.datasource=jdbcjcr
+ </jgroupsConfig>
+
+ <sync />
+ </clustering>
+
+ <loaders passivation="false" shared="true">
+ <preload>
+ <node fqn="/" />
+ </preload>
+ <loader class="org.jboss.cache.loader.JDBCCacheLoader" async="false" fetchPersistentState="false" ignoreModifications="false" purgeOnStartup="false">
+ <properties>
+ cache.jdbc.table.name=jcrlocks_db1_ws1
+ cache.jdbc.table.create=true
+ cache.jdbc.table.drop=false
+ cache.jdbc.table.primarykey=jcrlocks_db1_ws1_pk
+ cache.jdbc.fqn.column=fqn
+ cache.jdbc.fqn.type=VARCHAR(512)
+ cache.jdbc.node.column=node
+ cache.jdbc.node.type=LONGBLOB
+ cache.jdbc.parent.column=parent
+ cache.jdbc.datasource=jdbcjcr
</properties>
- </loader>
-
- </loaders>
-
+ </loader>
+
+ </loaders>
+
</jbosscache>
Modified: jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-lockconfig_db1_ws.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-lockconfig_db1_ws.xml 2010-01-21 17:20:23 UTC (rev 1534)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-lockconfig_db1_ws.xml 2010-01-21 20:14:07 UTC (rev 1535)
@@ -1,26 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.1">
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.2">
- <locking useLockStriping="false" concurrencyLevel="50000" lockParentForChildInsertRemove="false" lockAcquisitionTimeout="20000"/>
-
- <loaders passivation="false" shared="true">
-
- <loader class="org.jboss.cache.loader.JDBCCacheLoader" async="false" fetchPersistentState="true"
- ignoreModifications="false" purgeOnStartup="false">
- <properties>
- cache.jdbc.table.name=jdbcjcr_db1_ws
- cache.jdbc.table.create=true
- cache.jdbc.table.drop=false
- cache.jdbc.table.primarykey=exojcr_pk
- cache.jdbc.fqn.column=fqn
- cache.jdbc.fqn.type=VARCHAR(512)
- cache.jdbc.node.column=node
- cache.jdbc.node.type=OBJECT
- cache.jdbc.parent.column=parent
- cache.jdbc.datasource=jdbcjcr
+ <locking useLockStriping="false" concurrencyLevel="50000" lockParentForChildInsertRemove="false" lockAcquisitionTimeout="20000" />
+
+ <loaders passivation="false" shared="true">
+ <preload>
+ <node fqn="/" />
+ </preload>
+ <loader class="org.jboss.cache.loader.JDBCCacheLoader" async="false" fetchPersistentState="true" ignoreModifications="false" purgeOnStartup="false">
+ <properties>
+ cache.jdbc.table.name=jdbcjcr_db1_ws
+ cache.jdbc.table.create=true
+ cache.jdbc.table.drop=false
+ cache.jdbc.table.primarykey=exojcr_pk
+ cache.jdbc.fqn.column=fqn
+ cache.jdbc.fqn.type=VARCHAR(512)
+ cache.jdbc.node.column=node
+ cache.jdbc.node.type=OBJECT
+ cache.jdbc.parent.column=parent
+ cache.jdbc.datasource=jdbcjcr
</properties>
- </loader>
-
- </loaders>
-
+ </loader>
+
+ </loaders>
+
</jbosscache>
Modified: jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-lockconfig_db1_ws1.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-lockconfig_db1_ws1.xml 2010-01-21 17:20:23 UTC (rev 1534)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-lockconfig_db1_ws1.xml 2010-01-21 20:14:07 UTC (rev 1535)
@@ -1,26 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.1">
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.2">
- <locking useLockStriping="false" concurrencyLevel="50000" lockParentForChildInsertRemove="false" lockAcquisitionTimeout="20000"/>
-
- <loaders passivation="false" shared="true">
-
- <loader class="org.jboss.cache.loader.JDBCCacheLoader" async="false" fetchPersistentState="true"
- ignoreModifications="false" purgeOnStartup="false">
- <properties>
- cache.jdbc.table.name=jdbcjcr_db1_ws1
- cache.jdbc.table.create=true
- cache.jdbc.table.drop=false
- cache.jdbc.table.primarykey=exojcr_pk
- cache.jdbc.fqn.column=fqn
- cache.jdbc.fqn.type=VARCHAR(512)
- cache.jdbc.node.column=node
- cache.jdbc.node.type=OBJECT
- cache.jdbc.parent.column=parent
- cache.jdbc.datasource=jdbcjcr
+ <locking useLockStriping="false" concurrencyLevel="50000" lockParentForChildInsertRemove="false" lockAcquisitionTimeout="20000" />
+
+ <loaders passivation="false" shared="true">
+ <preload>
+ <node fqn="/" />
+ </preload>
+ <loader class="org.jboss.cache.loader.JDBCCacheLoader" async="false" fetchPersistentState="true" ignoreModifications="false" purgeOnStartup="false">
+ <properties>
+ cache.jdbc.table.name=jdbcjcr_db1_ws1
+ cache.jdbc.table.create=true
+ cache.jdbc.table.drop=false
+ cache.jdbc.table.primarykey=exojcr_pk
+ cache.jdbc.fqn.column=fqn
+ cache.jdbc.fqn.type=VARCHAR(512)
+ cache.jdbc.node.column=node
+ cache.jdbc.node.type=OBJECT
+ cache.jdbc.parent.column=parent
+ cache.jdbc.datasource=jdbcjcr
</properties>
- </loader>
-
- </loaders>
-
+ </loader>
+ </loaders>
</jbosscache>
16 years, 5 months
exo-jcr SVN: r1534 - jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-01-21 12:20:23 -0500 (Thu, 21 Jan 2010)
New Revision: 1534
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java
Log:
EXOJCR-381 : Add call method RepositoryServiceConfigurationImpl.retain() after initialize worcspace in BackupManagerImpl.
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java 2010-01-21 17:12:07 UTC (rev 1533)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java 2010-01-21 17:20:23 UTC (rev 1534)
@@ -492,6 +492,8 @@
{
throw new BackupOperationException("Restore of full backup file I/O error " + e, e);
}
+
+ repoService.getConfig().retain(); // save configuration to persistence (file or persister)
}
else
{
16 years, 5 months
exo-jcr SVN: r1533 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-01-21 12:12:07 -0500 (Thu, 21 Jan 2010)
New Revision: 1533
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/RepositoryServiceConfigurationImpl.java
Log:
EXOJCR-381 : The create synchronization on method retain() in RepositoryServiceConfigurationImpl. This method maybe using at different threads.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/RepositoryServiceConfigurationImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/RepositoryServiceConfigurationImpl.java 2010-01-21 16:13:00 UTC (rev 1532)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/RepositoryServiceConfigurationImpl.java 2010-01-21 17:12:07 UTC (rev 1533)
@@ -148,7 +148,7 @@
*
* @throws RepositoryException
*/
- public void retain() throws RepositoryException
+ public synchronized void retain() throws RepositoryException
{
try
{
16 years, 5 months
exo-jcr SVN: r1532 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2010-01-21 11:13:00 -0500 (Thu, 21 Jan 2010)
New Revision: 1532
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java
Log:
EXOJCR-424: added sorting in onSaveItems() in cacheable Lock manager to avoid deadlocks.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java 2010-01-21 14:48:20 UTC (rev 1531)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java 2010-01-21 16:13:00 UTC (rev 1532)
@@ -44,7 +44,6 @@
import org.exoplatform.services.jcr.impl.core.lock.SessionLockManager;
import org.exoplatform.services.jcr.impl.dataflow.TransientItemData;
import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.TxIsolatedOperation;
import org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager;
import org.exoplatform.services.jcr.impl.storage.JCRInvalidItemStateException;
import org.exoplatform.services.jcr.observation.ExtendedEvent;
@@ -64,7 +63,6 @@
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -164,7 +162,7 @@
private final Fqn<String> lockRoot;
private Map<String, CacheableSessionLockManager> sessionLockManagers;
-
+
/**
* Constructor.
*
@@ -176,12 +174,11 @@
* @throws RepositoryConfigurationException
*/
public CacheableLockManager(WorkspacePersistentDataManager dataManager, WorkspaceEntry config,
- InitialContextInitializer context, TransactionService transactionService)
- throws RepositoryConfigurationException
+ InitialContextInitializer context, TransactionService transactionService) throws RepositoryConfigurationException
{
this(dataManager, config, context, transactionService.getTransactionManager());
}
-
+
/**
* Constructor.
*
@@ -191,12 +188,11 @@
* @throws RepositoryConfigurationException
*/
public CacheableLockManager(WorkspacePersistentDataManager dataManager, WorkspaceEntry config,
- InitialContextInitializer context)
- throws RepositoryConfigurationException
+ InitialContextInitializer context) throws RepositoryConfigurationException
{
this(dataManager, config, context, (TransactionManager)null);
}
-
+
/**
* Constructor.
*
@@ -211,7 +207,7 @@
InitialContextInitializer context, TransactionManager transactionManager) throws RepositoryConfigurationException
{
lockRoot = Fqn.fromElements(LOCKS);
-
+
List<SimpleParameterEntry> paramenerts = config.getLockManager().getParameters();
this.dataManager = dataManager;
@@ -252,15 +248,15 @@
CacheFactory<Serializable, Object> factory = new DefaultCacheFactory<Serializable, Object>();
cache = factory.createCache(pathToConfig, false);
-
+
if (transactionManager != null)
{
cache.getConfiguration().getRuntimeConfig().setTransactionManager(transactionManager);
}
-
+
cache.create();
cache.start();
-
+
createStructuredNode(lockRoot);
// Context recall is a workaround of JDBCCacheLoader starting.
@@ -338,7 +334,7 @@
*/
public boolean isLockLive(String nodeId)
{
- if (pendingLocks.containsKey(nodeId) || cache.getRoot().hasChild(makeLockFqn(nodeId)))
+ if (pendingLocks.containsKey(nodeId) || cache.getRoot().hasChild(makeLockFqn(nodeId)))
{
return true;
}
@@ -382,7 +378,9 @@
chengesLogList.add(iter.nextLog());
}
}
-
+
+ List<LockOperationContainer> containers = new ArrayList<LockOperationContainer>();
+
for (PlainChangesLog currChangesLog : chengesLogList)
{
String nodeIdentifier;
@@ -394,30 +392,31 @@
if (currChangesLog.getSize() < 2)
{
log.error("Incorrect changes log of type ExtendedEvent.LOCK size=" + currChangesLog.getSize()
- + "<2 \n" + currChangesLog.dump());
+ + "<2 \n" + currChangesLog.dump());
break;
}
nodeIdentifier = currChangesLog.getAllStates().get(0).getData().getParentIdentifier();
if (pendingLocks.containsKey(nodeIdentifier))
{
- internalLock(nodeIdentifier);
+ containers.add(new LockOperationContainer(nodeIdentifier, currChangesLog.getSessionId(),
+ ExtendedEvent.LOCK));
}
else
{
- throw new LockException("Lock must exist in pending locks.");
+ log.error("Lock must exist in pending locks.");
}
break;
case ExtendedEvent.UNLOCK :
if (currChangesLog.getSize() < 2)
{
log.error("Incorrect changes log of type ExtendedEvent.UNLOCK size=" + currChangesLog.getSize()
- + "<2 \n" + currChangesLog.dump());
+ + "<2 \n" + currChangesLog.dump());
break;
}
- internalUnLock(currChangesLog.getSessionId(), currChangesLog.getAllStates().get(0).getData()
- .getParentIdentifier());
+ containers.add(new LockOperationContainer(currChangesLog.getAllStates().get(0).getData()
+ .getParentIdentifier(), currChangesLog.getSessionId(), ExtendedEvent.UNLOCK));
break;
default :
HashSet<String> removedLock = new HashSet<String>();
@@ -439,23 +438,90 @@
}
for (String identifier : removedLock)
{
- internalUnLock(currChangesLog.getSessionId(), identifier);
+ containers.add(new LockOperationContainer(identifier, currChangesLog.getSessionId(),
+ ExtendedEvent.UNLOCK));
}
break;
}
}
- catch (LockException e)
+ catch (IllegalStateException e)
{
log.error(e.getLocalizedMessage(), e);
}
- catch (IllegalStateException e)
+ }
+
+ // sort locking and unlocking operations to avoid deadlocks in JBossCache
+ Collections.sort(containers);
+ for (LockOperationContainer container : containers)
+ {
+ try
{
- log.error(e.getLocalizedMessage(), e);
+ container.apply();
}
+ catch (LockException e)
+ {
+ log.error(e.getMessage(), e);
+ }
}
}
/**
+ * Class containing operation type (LOCK or UNLOCK) and all the needed information like node uuid and session id
+ */
+ private class LockOperationContainer implements Comparable<LockOperationContainer>
+ {
+
+ private String identifier;
+
+ private String sessionId;
+
+ private int type;
+
+ /**
+ * @param identifier node identifier
+ * @param sessionId id of session
+ * @param type ExtendedEvent type specifying the operation (LOCK or UNLOCK)
+ */
+ public LockOperationContainer(String identifier, String sessionId, int type)
+ {
+ super();
+ this.identifier = identifier;
+ this.sessionId = sessionId;
+ this.type = type;
+ }
+
+ /**
+ * @return node identifier
+ */
+ public String getIdentifier()
+ {
+ return identifier;
+ }
+
+ public void apply() throws LockException
+ {
+ // invoke internalLock in LOCK operation
+ if (type == ExtendedEvent.LOCK)
+ {
+ internalLock(identifier);
+ }
+ // invoke internalUnLock in UNLOCK operation
+ else if (type == ExtendedEvent.UNLOCK)
+ {
+ internalUnLock(sessionId, identifier);
+ }
+ }
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(LockOperationContainer o)
+ {
+ return identifier.compareTo(o.getIdentifier());
+ }
+ }
+
+ /**
* Refreshed lock data in cache
*
* @param newLockData
@@ -498,7 +564,7 @@
}
Collections.sort(removeLockList);
-
+
for (String rLock : removeLockList)
{
removeLock(rLock);
@@ -699,7 +765,7 @@
protected LockData getLockDataById(String nodeId)
{
- return (LockData) cache.get(makeLockFqn(nodeId), LOCK_DATA);
+ return (LockData)cache.get(makeLockFqn(nodeId), LOCK_DATA);
}
protected synchronized List<LockData> getLockList()
@@ -709,7 +775,7 @@
List<LockData> locksData = new ArrayList<LockData>();
for (Object nodeId : nodesId)
{
- LockData lockData = (LockData) cache.get(makeLockFqn((String) nodeId), LOCK_DATA);;
+ LockData lockData = (LockData)cache.get(makeLockFqn((String)nodeId), LOCK_DATA);;
if (lockData != null)
{
locksData.add(lockData);
@@ -728,14 +794,14 @@
try
{
NodeData nData = (NodeData)dataManager.getItemData(nodeIdentifier);
-
+
//TODO EXOJCR-412, should be refactored in future.
//Skip removing, because that node was removed in other node of cluster.
if (nData == null)
{
return;
}
-
+
PlainChangesLog changesLog =
new PlainChangesLogImpl(new ArrayList<ItemState>(), SystemIdentity.SYSTEM, ExtendedEvent.UNLOCK);
@@ -794,7 +860,7 @@
{
sessionLockManagers.remove(sessionID);
}
-
+
/**
* Make lock absolute Fqn, i.e. /$LOCKS/nodeID.
*
@@ -805,17 +871,18 @@
{
return Fqn.fromRelativeElements(lockRoot, nodeId);
}
-
+
/**
* Will be created structured node in cache, like /$LOCKS
*/
- private void createStructuredNode(Fqn fqn) {
- Node<Serializable, Object> node = cache.getRoot().getChild(fqn);
- if (node == null)
- {
- cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
- node = cache.getRoot().addChild(fqn);
- }
+ private void createStructuredNode(Fqn fqn)
+ {
+ Node<Serializable, Object> node = cache.getRoot().getChild(fqn);
+ if (node == null)
+ {
+ cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
+ node = cache.getRoot().addChild(fqn);
+ }
node.setResident(true);
}
}
16 years, 5 months
exo-jcr SVN: r1531 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-01-21 09:48:20 -0500 (Thu, 21 Jan 2010)
New Revision: 1531
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexInfos.java
Log:
EXOJCR-423: Manage the case the node already exists in JBossCacheIndexInfos
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexInfos.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexInfos.java 2010-01-21 14:39:48 UTC (rev 1530)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexInfos.java 2010-01-21 14:48:20 UTC (rev 1531)
@@ -108,6 +108,10 @@
cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
cacheRoot.addChild(namesFqn).setResident(true);
}
+ else
+ {
+ cache.getNode(namesFqn).setResident(true);
+ }
if (modeHandler.getMode() == IndexerIoMode.READ_ONLY)
{
// Currently READ_ONLY is set, so new lists should be fired to multiIndex.
16 years, 5 months
exo-jcr SVN: r1530 - in jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster: test and 1 other directory.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-01-21 09:39:48 -0500 (Thu, 21 Jan 2010)
New Revision: 1530
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/prepare/TestLoadIndexerWriter.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/prepare/TestLoadIndexerWriterWithModes.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/TestLoadIndexerQuery.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/TestLoadIndexerQueryWithModes.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/TestReadNWrite.java
Log:
EXOJCR-402: The memory leak of the test classes have been removed
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/prepare/TestLoadIndexerWriter.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/prepare/TestLoadIndexerWriter.java 2010-01-21 14:39:42 UTC (rev 1529)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/prepare/TestLoadIndexerWriter.java 2010-01-21 14:39:48 UTC (rev 1530)
@@ -26,6 +26,7 @@
import javax.jcr.Node;
import javax.jcr.RepositoryException;
+import javax.jcr.Session;
/**
* @author <a href="mailto:nikolazius@gmail.com">Nikolay Zamosenchuk</a>
@@ -77,12 +78,6 @@
private int id;
- private SessionImpl sessionLocal;
-
- private Node statisticNode;
-
- private Node contentNode;
-
private Random random;
public WriterTask(int id) throws RepositoryException
@@ -90,14 +85,16 @@
this.id = id;
// login
CredentialsImpl credentials = new CredentialsImpl("admin", "admin".toCharArray());
- sessionLocal = (SessionImpl)repository.login(credentials, "ws");
+ Session sessionLocal = (SessionImpl)repository.login(credentials, "ws");
// prepare nodes
Node root = sessionLocal.getRootNode();
Node threadNode = root.addNode("Thread" + id);
- statisticNode = threadNode.addNode(STATISTIC);
- contentNode = threadNode.addNode(CONTENT);
+ threadNode.addNode(STATISTIC);
+ threadNode.addNode(CONTENT);
random = new Random();
sessionLocal.save();
+ sessionLocal.logout();
+ sessionLocal = null;
}
/**
@@ -105,33 +102,45 @@
*/
public void run()
{
- try
+ while (!stop)
{
- while (!stop)
+ // get any word
+ int i = random.nextInt(WORDS.length);
+ String word = WORDS[i] + id; // "hello12" if thread#12 is creating it
+ Session sessionLocal = null;
+ try
{
- // get any word
- int i = random.nextInt(WORDS.length);
- String word = WORDS[i] + id; // "hello12" if thread#12 is creating it
+ CredentialsImpl credentials = new CredentialsImpl("admin", "admin".toCharArray());
+ sessionLocal = (SessionImpl)repository.login(credentials, "ws");
+ long time = System.currentTimeMillis();
// update statistic
- updateStatistic(word);
+ updateStatistic((Node)sessionLocal.getItem("/Thread" + id + "/" + STATISTIC),word);
// add actual node
- createTree().addNode(word);
+ createTree((Node)sessionLocal.getItem("/Thread" + id + "/" + CONTENT)).addNode(word);
sessionLocal.save();
- System.out.print("#");
-
- try
+ log.info("Time : " + (System.currentTimeMillis() - time));
+ }
+ catch (RepositoryException e)
+ {
+ log.error(e);
+ }
+ finally
+ {
+ if (sessionLocal != null)
{
- Thread.sleep(300);
+ sessionLocal.logout();
+ sessionLocal = null;
}
- catch (InterruptedException e)
- {
- }
}
+
+ try
+ {
+ Thread.sleep(300);
+ }
+ catch (InterruptedException e)
+ {
+ }
}
- catch (RepositoryException e)
- {
- log.error(e);
- }
}
/**
@@ -140,7 +149,7 @@
* @param word
* @throws RepositoryException
*/
- private void updateStatistic(String word) throws RepositoryException
+ private void updateStatistic(Node statisticNode, String word) throws RepositoryException
{
Node wordNode;
long count = 0;
@@ -163,7 +172,7 @@
* @return
* @throws RepositoryException
*/
- private Node createTree() throws RepositoryException
+ private Node createTree(Node contentNode) throws RepositoryException
{
// created node tree like: "./content/n123456/n1234567/n12345678"
Node end;
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/prepare/TestLoadIndexerWriterWithModes.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/prepare/TestLoadIndexerWriterWithModes.java 2010-01-21 14:39:42 UTC (rev 1529)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/prepare/TestLoadIndexerWriterWithModes.java 2010-01-21 14:39:48 UTC (rev 1530)
@@ -20,6 +20,8 @@
import org.exoplatform.services.jcr.JcrAPIBaseTest;
import org.exoplatform.services.jcr.core.CredentialsImpl;
+import org.exoplatform.services.jcr.core.WorkspaceContainerFacade;
+import org.exoplatform.services.jcr.dataflow.persistent.WorkspaceStorageCache;
import org.exoplatform.services.jcr.impl.core.SessionImpl;
import java.io.BufferedReader;
@@ -31,6 +33,7 @@
import javax.jcr.Node;
import javax.jcr.RepositoryException;
+import javax.jcr.Session;
/**
* @author <a href="mailto:nikolazius@gmail.com">Nikolay Zamosenchuk</a>
@@ -64,8 +67,12 @@
"exception", "cycle", "value", "index", "meaning", "strange", "words", "hello", "outline", "finest",
"basetest", "writer"};
+ private WorkspaceStorageCache cache;
+
public void testWrite() throws Exception
{
+ WorkspaceContainerFacade wsc = repository.getWorkspaceContainer("ws");
+ this.cache = (WorkspaceStorageCache)wsc.getComponent(WorkspaceStorageCache.class);
log.info("Skip (y/n) :");
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String line = reader.readLine();
@@ -115,12 +122,6 @@
private int id;
- private SessionImpl sessionLocal;
-
- private Node statisticNode;
-
- private Node contentNode;
-
private Random random;
public WriterTask(int id) throws RepositoryException
@@ -128,14 +129,16 @@
this.id = id;
// login
CredentialsImpl credentials = new CredentialsImpl("admin", "admin".toCharArray());
- sessionLocal = (SessionImpl)repository.login(credentials, "ws");
+ Session sessionLocal = (SessionImpl)repository.login(credentials, "ws");
// prepare nodes
Node root = sessionLocal.getRootNode();
Node threadNode = root.addNode("Thread" + id);
- statisticNode = threadNode.addNode(STATISTIC);
- contentNode = threadNode.addNode(CONTENT);
+ threadNode.addNode(STATISTIC);
+ threadNode.addNode(CONTENT);
random = new Random();
sessionLocal.save();
+ sessionLocal.logout();
+ sessionLocal = null;
}
/**
@@ -148,32 +151,45 @@
startSignal.await();
while (!stop)
{
- long time = System.currentTimeMillis();
// get any word
int i = random.nextInt(words.length);
String word = words[i] + id; // "hello12" if thread#12 is creating it
+ Session sessionLocal = null;
try
{
+ CredentialsImpl credentials = new CredentialsImpl("admin", "admin".toCharArray());
+ sessionLocal = (SessionImpl)repository.login(credentials, "ws");
+ long time = System.currentTimeMillis();
// update statistic
- updateStatistic(word);
+ updateStatistic((Node)sessionLocal.getItem("/Thread" + id + "/" + STATISTIC),word);
// add actual node
- createTree().addNode(word);
+ createTree((Node)sessionLocal.getItem("/Thread" + id + "/" + CONTENT)).addNode(word);
sessionLocal.save();
- System.out.println(Thread.currentThread() + " time : " + (System.currentTimeMillis() - time));
+ log.info("Time : " + (System.currentTimeMillis() - time));
}
catch (Exception e1)
{
- // discard session changes
- sessionLocal.refresh(false);
+ if (sessionLocal != null)
+ {
+ // discard session changes
+ sessionLocal.refresh(false);
+ }
log.error("An error occurs", e1);
}
-
+ finally
+ {
+ if (sessionLocal != null)
+ {
+ sessionLocal.logout();
+ sessionLocal = null;
+ }
+ }
try
{
if (makeThemWait.get())
{
barrier.await();
- log.info("The threads are waiting for the go signal");
+ log.info("The threads are waiting for the go signal, the current size of the cache is " + cache.getSize());
goSignal.await();
}
else
@@ -202,7 +218,7 @@
* @param word
* @throws RepositoryException
*/
- private void updateStatistic(String word) throws RepositoryException
+ private void updateStatistic(Node statisticNode, String word) throws RepositoryException
{
Node wordNode;
long count = 0;
@@ -225,7 +241,7 @@
* @return
* @throws RepositoryException
*/
- private Node createTree() throws RepositoryException
+ private Node createTree(Node contentNode) throws RepositoryException
{
// created node tree like: "./content/n123456/n1234567/n12345678"
Node end;
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/TestLoadIndexerQuery.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/TestLoadIndexerQuery.java 2010-01-21 14:39:42 UTC (rev 1529)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/TestLoadIndexerQuery.java 2010-01-21 14:39:48 UTC (rev 1530)
@@ -30,6 +30,7 @@
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.RepositoryException;
+import javax.jcr.Session;
import javax.jcr.query.Query;
import javax.jcr.query.QueryManager;
import javax.jcr.query.QueryResult;
@@ -73,19 +74,10 @@
private class QueryTask implements Runnable
{
- private SessionImpl sessionLocal;
-
- private Node rootLocal;
-
private Random random;
public QueryTask() throws RepositoryException
{
- // login
- CredentialsImpl credentials = new CredentialsImpl("admin", "admin".toCharArray());
- sessionLocal = (SessionImpl)repository.login(credentials, "ws");
- // prepare nodes
- rootLocal = sessionLocal.getRootNode();
random = new Random();
}
@@ -94,10 +86,16 @@
*/
public void run()
{
- try
+ while (!stop)
{
- while (!stop)
+ Session sessionLocal = null;
+ try
{
+ // login
+ CredentialsImpl credentials = new CredentialsImpl("admin", "admin".toCharArray());
+ sessionLocal = (SessionImpl)repository.login(credentials, "ws");
+ // prepare nodes
+ Node rootLocal = sessionLocal.getRootNode();
Node threadNode = getRandomChild(rootLocal, "Thread*");
if (threadNode != null)
{
@@ -116,7 +114,7 @@
catch (InterruptedException e1)
{
}
-
+ long time = System.currentTimeMillis();
QueryManager qman = sessionLocal.getWorkspace().getQueryManager();
Query q =
@@ -124,21 +122,23 @@
+ "/%' and fn:name() = '" + word + "'", Query.SQL);
QueryResult res = q.execute();
long sqlsize = res.getNodes().getSize();
- log.info("Exp: " + count + "\t found:" + sqlsize);
+ log.info("Exp: " + count + "\t found:" + sqlsize + " time: " + (System.currentTimeMillis() - time));
}
}
}
-
+ catch (Exception e)
+ {
+ log.error("An error occurs", e);
+ }
+ finally
+ {
+ if (sessionLocal != null)
+ {
+ sessionLocal.logout();
+ sessionLocal = null;
+ }
+ }
}
- catch (RepositoryException e)
- {
- log.error(e);
- }
- catch (Exception e)
- {
- log.error(e);
- }
-
}
private Node getRandomChild(Node parent, String pattern) throws RepositoryException
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/TestLoadIndexerQueryWithModes.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/TestLoadIndexerQueryWithModes.java 2010-01-21 14:39:42 UTC (rev 1529)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/TestLoadIndexerQueryWithModes.java 2010-01-21 14:39:48 UTC (rev 1530)
@@ -32,6 +32,7 @@
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.RepositoryException;
+import javax.jcr.Session;
import javax.jcr.query.Query;
import javax.jcr.query.QueryManager;
import javax.jcr.query.QueryResult;
@@ -86,19 +87,11 @@
private class QueryTask implements Runnable
{
- private SessionImpl sessionLocal;
- private Node rootLocal;
-
private Random random;
public QueryTask() throws RepositoryException
{
- // login
- CredentialsImpl credentials = new CredentialsImpl("admin", "admin".toCharArray());
- sessionLocal = (SessionImpl)repository.login(credentials, "ws");
- // prepare nodes
- rootLocal = sessionLocal.getRootNode();
random = new Random();
}
@@ -110,8 +103,14 @@
while (!stop)
{
+ Session sessionLocal = null;
try
{
+ // login
+ CredentialsImpl credentials = new CredentialsImpl("admin", "admin".toCharArray());
+ sessionLocal = (SessionImpl)repository.login(credentials, "ws");
+ // prepare nodes
+ Node rootLocal = sessionLocal.getRootNode();
Node threadNode = getRandomChild(rootLocal, "Thread*");
if (threadNode != null)
{
@@ -143,16 +142,19 @@
}
}
}
- catch (RepositoryException e)
+ catch (Exception e)
{
log.error(e);
}
- catch (Exception e)
+ finally
{
- log.error(e);
- }
+ if (sessionLocal != null)
+ {
+ sessionLocal.logout();
+ sessionLocal = null;
+ }
+ }
}
-
}
private Node getRandomChild(Node parent, String pattern) throws RepositoryException
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/TestReadNWrite.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/TestReadNWrite.java 2010-01-21 14:39:42 UTC (rev 1529)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/TestReadNWrite.java 2010-01-21 14:39:48 UTC (rev 1530)
@@ -30,6 +30,7 @@
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.RepositoryException;
+import javax.jcr.Session;
import javax.jcr.query.Query;
import javax.jcr.query.QueryManager;
import javax.jcr.query.QueryResult;
@@ -54,7 +55,7 @@
private int threadReaderCount = 20;
private final CountDownLatch doneSignal = new CountDownLatch(threadReaderCount + threadWriterCount);
-
+
private static final String[] words =
new String[]{"private", "branch", "final", "string", "logging", "bottle", "property", "node", "repository",
"exception", "cycle", "value", "index", "meaning", "strange", "words", "hello", "outline", "finest",
@@ -79,11 +80,13 @@
// wait 4 minutes
try
{
- //Thread.sleep(60000 * 4);
+ Thread.sleep(60000 * 4);
+ /*
synchronized (this)
{
wait();
}
+ */
}
catch (InterruptedException e)
{
@@ -92,7 +95,7 @@
stop = true;
doneSignal.await();
- System.exit(0);
+ System.exit(0);
}
private class WriterTask implements Runnable
@@ -100,12 +103,6 @@
private int id;
- private SessionImpl sessionLocal;
-
- private Node statisticNode;
-
- private Node contentNode;
-
private Random random;
public WriterTask(int id) throws RepositoryException
@@ -113,14 +110,16 @@
this.id = id;
// login
CredentialsImpl credentials = new CredentialsImpl("admin", "admin".toCharArray());
- sessionLocal = (SessionImpl)repository.login(credentials, "ws");
+ Session sessionLocal = (SessionImpl)repository.login(credentials, "ws");
// prepare nodes
Node root = sessionLocal.getRootNode();
Node threadNode = root.addNode("Thread" + id);
- statisticNode = threadNode.addNode(STATISTIC);
- contentNode = threadNode.addNode(CONTENT);
+ threadNode.addNode(STATISTIC);
+ threadNode.addNode(CONTENT);
random = new Random();
sessionLocal.save();
+ sessionLocal.logout();
+ sessionLocal = null;
}
/**
@@ -132,23 +131,34 @@
{
while (!stop)
{
- long time = System.currentTimeMillis();
// get any word
int i = random.nextInt(words.length);
String word = words[i] + id; // "hello12" if thread#12 is creating it
+ Session sessionLocal = null;
try
{
+ CredentialsImpl credentials = new CredentialsImpl("admin", "admin".toCharArray());
+ sessionLocal = (SessionImpl)repository.login(credentials, "ws");
+ long time = System.currentTimeMillis();
// update statistic
- updateStatistic(word);
+ updateStatistic((Node)sessionLocal.getItem("/Thread" + id + "/" + STATISTIC), word);
// add actual node
- createTree().addNode(word);
+ createTree((Node)sessionLocal.getItem("/Thread" + id + "/" + CONTENT)).addNode(word);
sessionLocal.save();
- System.out.println(Thread.currentThread() + " time : " + (System.currentTimeMillis() - time));
+ log.info("Time : " + (System.currentTimeMillis() - time));
}
- catch (Exception e1)
+ catch (RepositoryException e)
{
- log.error("An error occurs", e1);
+ log.error(e);
}
+ finally
+ {
+ if (sessionLocal != null)
+ {
+ sessionLocal.logout();
+ sessionLocal = null;
+ }
+ }
try
{
@@ -175,7 +185,7 @@
* @param word
* @throws RepositoryException
*/
- private void updateStatistic(String word) throws RepositoryException
+ private void updateStatistic(Node statisticNode, String word) throws RepositoryException
{
Node wordNode;
long count = 0;
@@ -198,7 +208,7 @@
* @return
* @throws RepositoryException
*/
- private Node createTree() throws RepositoryException
+ private Node createTree(Node contentNode) throws RepositoryException
{
// created node tree like: "./content/n123456/n1234567/n12345678"
Node end;
@@ -233,19 +243,11 @@
private class QueryTask implements Runnable
{
- private SessionImpl sessionLocal;
- private Node rootLocal;
-
private Random random;
public QueryTask() throws RepositoryException
{
- // login
- CredentialsImpl credentials = new CredentialsImpl("admin", "admin".toCharArray());
- sessionLocal = (SessionImpl)repository.login(credentials, "ws");
- // prepare nodes
- rootLocal = sessionLocal.getRootNode();
random = new Random();
}
@@ -256,8 +258,14 @@
{
while (!stop)
{
+ Session sessionLocal = null;
try
{
+ // login
+ CredentialsImpl credentials = new CredentialsImpl("admin", "admin".toCharArray());
+ sessionLocal = (SessionImpl)repository.login(credentials, "ws");
+ // prepare nodes
+ Node rootLocal = sessionLocal.getRootNode();
Node threadNode = getRandomChild(rootLocal, "Thread*");
if (threadNode != null)
{
@@ -284,14 +292,11 @@
try
{
assertTrue("Exp: " + count + "\t found:" + sqlsize, sqlsize >= count);
- System.out.println(Thread.currentThread() + " size : " + sqlsize + " time : "
- + (System.currentTimeMillis() - time));
+ log.info("Size : " + sqlsize + " time : " + (System.currentTimeMillis() - time));
}
catch (AssertionFailedError e)
{
- System.out
- .println((Thread.currentThread() + " error : " + e.getMessage() + " time : " + (System
- .currentTimeMillis() - time)));
+ log.info("Error : " + e.getMessage() + " time : " + (System.currentTimeMillis() - time));
}
}
}
@@ -300,6 +305,14 @@
{
log.error("An error occurs", e);
}
+ finally
+ {
+ if (sessionLocal != null)
+ {
+ sessionLocal.logout();
+ sessionLocal = null;
+ }
+ }
}
doneSignal.countDown();
}
16 years, 5 months
exo-jcr SVN: r1529 - in jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl: dataflow/persistent/jbosscache and 1 other directory.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2010-01-21 09:39:42 -0500 (Thu, 21 Jan 2010)
New Revision: 1529
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexUpdateMonitor.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
Log:
EXOJCR-423: Added setResident if JBC node was created previously.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexUpdateMonitor.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexUpdateMonitor.java 2010-01-21 14:08:44 UTC (rev 1528)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexUpdateMonitor.java 2010-01-21 14:39:42 UTC (rev 1529)
@@ -84,6 +84,10 @@
cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
cacheRoot.addChild(PARAMETER_ROOT).setResident(true);
}
+ else
+ {
+ cache.getNode(PARAMETER_ROOT).setResident(true);
+ }
if (IndexerIoMode.READ_WRITE == modeHandler.getMode())
{
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2010-01-21 14:08:44 UTC (rev 1528)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2010-01-21 14:39:42 UTC (rev 1529)
@@ -313,6 +313,11 @@
cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
cacheRoot.addChild(fqn).setResident(true);
}
+ else
+ {
+ cache.getNode(fqn).setResident(true);
+ }
+
}
protected static String readJBCConfig(final WorkspaceEntry wsConfig) throws RepositoryConfigurationException
16 years, 5 months
exo-jcr SVN: r1528 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-01-21 09:08:44 -0500 (Thu, 21 Jan 2010)
New Revision: 1528
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java
Log:
EXOJCR-332 : Add constructor without TransactionManager or TransactionService
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java 2010-01-21 13:59:14 UTC (rev 1527)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java 2010-01-21 14:08:44 UTC (rev 1528)
@@ -188,6 +188,21 @@
* @param dataManager - workspace persistent data manager
* @param config - workspace entry
* @param context InitialContextInitializer, needed to reload context after JBoss cache creation
+ * @throws RepositoryConfigurationException
+ */
+ public CacheableLockManager(WorkspacePersistentDataManager dataManager, WorkspaceEntry config,
+ InitialContextInitializer context)
+ throws RepositoryConfigurationException
+ {
+ this(dataManager, config, context, (TransactionManager)null);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param dataManager - workspace persistent data manager
+ * @param config - workspace entry
+ * @param context InitialContextInitializer, needed to reload context after JBoss cache creation
* @param transactionManager
* the transaction manager
* @throws RepositoryConfigurationException
@@ -215,7 +230,9 @@
}
else
+ {
lockTimeOut = DEFAULT_LOCK_TIMEOUT;
+ }
pendingLocks = new HashMap<String, LockData>();
sessionLockManagers = new HashMap<String, CacheableSessionLockManager>();
@@ -235,8 +252,12 @@
CacheFactory<Serializable, Object> factory = new DefaultCacheFactory<Serializable, Object>();
cache = factory.createCache(pathToConfig, false);
- cache.getConfiguration().getRuntimeConfig().setTransactionManager(transactionManager);
+ if (transactionManager != null)
+ {
+ cache.getConfiguration().getRuntimeConfig().setTransactionManager(transactionManager);
+ }
+
cache.create();
cache.start();
16 years, 5 months
exo-jcr SVN: r1527 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-01-21 08:59:14 -0500 (Thu, 21 Jan 2010)
New Revision: 1527
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java
Log:
EXOJCR-332 : Add constructor with TransactionManager
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java 2010-01-21 13:35:02 UTC (rev 1526)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java 2010-01-21 13:59:14 UTC (rev 1527)
@@ -171,11 +171,30 @@
* @param dataManager - workspace persistent data manager
* @param config - workspace entry
* @param context InitialContextInitializer, needed to reload context after JBoss cache creation
+ * @param transactionService
+ * the transaction service
* @throws RepositoryConfigurationException
*/
public CacheableLockManager(WorkspacePersistentDataManager dataManager, WorkspaceEntry config,
- InitialContextInitializer context, TransactionService transactionService) throws RepositoryConfigurationException
+ InitialContextInitializer context, TransactionService transactionService)
+ throws RepositoryConfigurationException
{
+ this(dataManager, config, context, transactionService.getTransactionManager());
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param dataManager - workspace persistent data manager
+ * @param config - workspace entry
+ * @param context InitialContextInitializer, needed to reload context after JBoss cache creation
+ * @param transactionManager
+ * the transaction manager
+ * @throws RepositoryConfigurationException
+ */
+ public CacheableLockManager(WorkspacePersistentDataManager dataManager, WorkspaceEntry config,
+ InitialContextInitializer context, TransactionManager transactionManager) throws RepositoryConfigurationException
+ {
lockRoot = Fqn.fromElements(LOCKS);
List<SimpleParameterEntry> paramenerts = config.getLockManager().getParameters();
@@ -216,19 +235,12 @@
CacheFactory<Serializable, Object> factory = new DefaultCacheFactory<Serializable, Object>();
cache = factory.createCache(pathToConfig, false);
+ cache.getConfiguration().getRuntimeConfig().setTransactionManager(transactionManager);
- if (transactionService.getTransactionManager() != null)
- {
- cache.getConfiguration().getRuntimeConfig().setTransactionManager(transactionService.getTransactionManager());
- }
-
cache.create();
cache.start();
- if (!cache.getRoot().hasChild(lockRoot))
- {
- cache.getRoot().addChild(lockRoot);
- }
+ createStructuredNode(lockRoot);
// Context recall is a workaround of JDBCCacheLoader starting.
context.recall();
@@ -772,4 +784,17 @@
{
return Fqn.fromRelativeElements(lockRoot, nodeId);
}
+
+ /**
+ * Will be created structured node in cache, like /$LOCKS
+ */
+ private void createStructuredNode(Fqn fqn) {
+ Node<Serializable, Object> node = cache.getRoot().getChild(fqn);
+ if (node == null)
+ {
+ cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
+ node = cache.getRoot().addChild(fqn);
+ }
+ node.setResident(true);
+ }
}
16 years, 5 months