[exo-jcr-commits] exo-jcr SVN: r1540 - in jcr/trunk/exo.jcr.component.core/src/test: resources/conf/cluster and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Jan 22 06:45:45 EST 2010


Author: nzamosenchuk
Date: 2010-01-22 06:45:45 -0500 (Fri, 22 Jan 2010)
New Revision: 1540

Added:
   jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cache/TestCacheReplicationDeadLock.java
   jcr/trunk/exo.jcr.component.core/src/test/resources/conf/cluster/test-replication-deadlock.xml
Log:


Added: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cache/TestCacheReplicationDeadLock.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cache/TestCacheReplicationDeadLock.java	                        (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cache/TestCacheReplicationDeadLock.java	2010-01-22 11:45:45 UTC (rev 1540)
@@ -0,0 +1,142 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.lab.cache;
+
+import junit.framework.TestCase;
+
+import org.jboss.cache.CacheFactory;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.DefaultCacheFactory;
+
+import java.io.Serializable;
+import java.util.concurrent.CyclicBarrier;
+
+import javax.transaction.TransactionManager;
+
+/**
+ * This test created two caches with replication between them. Then two different thread
+ * are writing to the same FQN some values. Then they commit transactions (in the same 
+ * time).
+ * Wait for 20s and you'll get:
+ * org.jboss.cache.lock.TimeoutException: Unable to acquire lock on Fqn [/fqn] after [20000] milliseconds for requestor 
+ *          [GlobalTransaction:<127.0.0.1:9601>:1]! Lock held by [GlobalTransaction:<127.0.0.1:9600>:0]
+ *          
+ * org.jboss.cache.lock.TimeoutException: Unable to acquire lock on Fqn [/fqn] after [20000] milliseconds for requestor 
+ *          [GlobalTransaction:<127.0.0.1:9600>:0]! Lock held by [GlobalTransaction:<127.0.0.1:9601>:1]
+ * 
+ * @author <a href="mailto:nikolazius at gmail.com">Nikolay Zamosenchuk</a>
+ * @version $Id: Test.java 34360 2009-07-22 23:58:59Z nzamosenchuk $
+ *
+ */
+public class TestCacheReplicationDeadLock extends TestCase
+{
+
+   int threadCount = 2;
+
+   private final CyclicBarrier barrier = new CyclicBarrier(threadCount);
+
+   private final static String LONG_TEXT =
+      "Compared to OHV pushrod (or I-Head) "
+         + "systems with the same number of valves the reciprocating components of "
+         + "the OHC system are fewer and have a lower total mass. Though the system"
+         + " that drives the cams may become more complex, most engine manufacturer"
+         + "s easily accept that added complexity in trade for better engine perfor"
+         + "mance and greater design flexibility. Another performance advantage is "
+         + "gained as a result of the better optimized port configurations made pos"
+         + "sible with overhead camshaft designs. With no intrusive pushrods the ov"
+         + "erhead camshaft cylinder head design can use straighter ports of more a"
+         + "dvantageous crossection and length.";
+
+   public void testDeadLock()
+   {
+      // create cache
+      CacheFactory<Serializable, Object> factory = new DefaultCacheFactory<Serializable, Object>();
+      final CacheSPI<Serializable, Object> cache1 =
+         (CacheSPI<Serializable, Object>)factory.createCache("conf/cluster/test-replication-deadlock.xml", false);
+      final CacheSPI<Serializable, Object> cache2 =
+         (CacheSPI<Serializable, Object>)factory.createCache("conf/cluster/test-replication-deadlock.xml", false);
+
+      cache1.create();
+      cache2.create();
+
+      cache1.start();
+      cache2.start();
+      // create threads
+      for (int i = 0; i < threadCount; i++)
+      {
+         new Thread(new WritingTask(barrier, i, i % 2 == 0 ? cache1 : cache2)).start();
+      }
+
+      // wait a minute and tear down
+      try
+      {
+         Thread.sleep(60000);
+      }
+      catch (InterruptedException e)
+      {
+         e.printStackTrace();
+      }
+
+      cache1.stop();
+      cache1.destroy();
+      cache2.stop();
+      cache2.destroy();
+   }
+
+   class WritingTask implements Runnable
+   {
+
+      private CyclicBarrier barrier;
+
+      private int index;
+
+      private CacheSPI<Serializable, Object> cache;
+
+      public WritingTask(CyclicBarrier barrier, int index, CacheSPI<Serializable, Object> cache)
+      {
+         super();
+         this.barrier = barrier;
+         this.index = index;
+         this.cache = cache;
+      }
+
+      public void run()
+      {
+         try
+         {
+            while (true)
+            {
+               TransactionManager mgr = cache.getTransactionManager();
+               mgr.begin();
+               cache.put("fqn", "key", LONG_TEXT + index);
+               // make them save in one moment
+               barrier.await();
+               mgr.commit();
+               System.out.print(index + " ");
+            }
+         }
+         catch (Exception e)
+         {
+            e.printStackTrace();
+         }
+      }
+
+   }
+
+}


Property changes on: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cache/TestCacheReplicationDeadLock.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: jcr/trunk/exo.jcr.component.core/src/test/resources/conf/cluster/test-replication-deadlock.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/resources/conf/cluster/test-replication-deadlock.xml	                        (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/conf/cluster/test-replication-deadlock.xml	2010-01-22 11:45:45 UTC (rev 1540)
@@ -0,0 +1,90 @@
+<?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">
+
+	<locking useLockStriping="false" concurrencyLevel="50000" lockParentForChildInsertRemove="false" lockAcquisitionTimeout="20000" /> 
+
+	<transaction transactionManagerLookupClass="org.jboss.cache.transaction.JBossStandaloneJTAManagerLookup" />
+
+	<clustering mode="replication" clusterName="JBoss-Cache-Cluster_db1_ws">
+		<!--
+			Fetch in memory state is enable, because second cluster-node
+			currently doesn't work properly on clear cache
+		-->
+		<stateRetrieval timeout="20000" fetchInMemoryState="false"  nonBlocking="true"/>
+		<!--
+			This JGroups configuration is taken from JBC branch, but
+			"enable_bundling" is set to false, because of notice, that appeared
+			during running
+      multiplexerStack="fc-fast-minimalthreads"   
+		-->
+		<jgroupsConfig>
+			<!--
+				UDP discard_incompatible_packets="true" enable_bundling="false"
+				enable_diagnostics="false" ip_ttl="2" loopback="false"
+				max_bundle_size="64000" max_bundle_timeout="30"
+				mcast_addr="228.10.10.10" mcast_port="45588"
+				mcast_recv_buf_size="25000000" mcast_send_buf_size="640000"
+				oob_thread_pool.enabled="true"
+				oob_thread_pool.keep_alive_time="10000"
+				oob_thread_pool.max_threads="4" oob_thread_pool.min_threads="1"
+				oob_thread_pool.queue_enabled="true"
+				oob_thread_pool.queue_max_size="10"
+				oob_thread_pool.rejection_policy="Run" thread_naming_pattern="pl"
+				thread_pool.enabled="true" thread_pool.keep_alive_time="30000"
+				thread_pool.max_threads="25" thread_pool.min_threads="1"
+				thread_pool.queue_enabled="true" thread_pool.queue_max_size="10"
+				thread_pool.rejection_policy="Run" tos="8"
+				ucast_recv_buf_size="20000000" ucast_send_buf_size="640000"
+				use_concurrent_stack="true" use_incoming_packet_handler="true" />
+				<PING num_initial_members="3" timeout="2000" /
+			-->
+
+			<TCP bind_addr="127.0.0.1" start_port="9600" 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="34521"
+				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>
+
+		<sync />
+
+	</clustering>
+
+   <!-- Eviction configuration -->
+   <eviction wakeUpInterval="5000">
+      <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="1000000">
+         <property name="maxNodes" value="10000" />
+         <property name="timeToLive" value="120000" />
+      </default>
+   </eviction>
+</jbosscache>


Property changes on: jcr/trunk/exo.jcr.component.core/src/test/resources/conf/cluster/test-replication-deadlock.xml
___________________________________________________________________
Name: svn:mime-type
   + text/plain



More information about the exo-jcr-commits mailing list