Hibernate SVN: r14255 - core/trunk/cache-jbosscache2/src/main/resources/org/hibernate/cache/jbc2/builder.
by hibernate-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2007-12-21 14:51:44 -0500 (Fri, 21 Dec 2007)
New Revision: 14255
Modified:
core/trunk/cache-jbosscache2/src/main/resources/org/hibernate/cache/jbc2/builder/jgroups-stacks.xml
Log:
Add some properties that testsuite can set for faster test execution
Remove unsupported TCP_NIO configs
Modified: core/trunk/cache-jbosscache2/src/main/resources/org/hibernate/cache/jbc2/builder/jgroups-stacks.xml
===================================================================
--- core/trunk/cache-jbosscache2/src/main/resources/org/hibernate/cache/jbc2/builder/jgroups-stacks.xml 2007-12-21 19:49:29 UTC (rev 14254)
+++ core/trunk/cache-jbosscache2/src/main/resources/org/hibernate/cache/jbc2/builder/jgroups-stacks.xml 2007-12-21 19:51:44 UTC (rev 14255)
@@ -47,7 +47,7 @@
max_bundle_timeout="30"
use_incoming_packet_handler="true"
ip_ttl="${jgroups.udp.ip_ttl:2}"
- enable_bundling="true"
+ enable_bundling="${jgroup.udp.enable_bundling:true}"
use_concurrent_stack="true"
@@ -66,8 +66,8 @@
oob_thread_pool.queue_enabled="false"
oob_thread_pool.queue_max_size="100"
oob_thread_pool.rejection_policy="Run"/>
- <PING timeout="2000"
- num_initial_members="3"/>
+ <PING timeout="${jgroups.ping.timeout:2000}"
+ num_initial_members="${jgroups.ping.num_initial_members:3}"/>
<MERGE2 max_interval="100000"
min_interval="20000"/>
<FD_SOCK/>
@@ -115,7 +115,7 @@
max_bundle_timeout="30"
use_incoming_packet_handler="true"
ip_ttl="${jgroups.udp.ip_ttl:2}"
- enable_bundling="true"
+ enable_bundling="${jgroup.udp.enable_bundling:true}"
use_concurrent_stack="true"
@@ -133,9 +133,9 @@
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"/>
- <PING timeout="2000"
- num_initial_members="3"/>
+ oob_thread_pool.rejection_policy="Run"/>
+ <PING timeout="${jgroups.ping.timeout:2000}"
+ num_initial_members="${jgroups.ping.num_initial_members:3}"/>
<MERGE2 max_interval="100000"
min_interval="20000"/>
<FD_SOCK/>
@@ -283,112 +283,6 @@
</config>
</stack>
-
- <stack name="tcp-nio"
- description="TCP based stack, with flow control and message bundling. This is usually used when IP
- multicasting cannot be used in a network, e.g. because it is disabled (routers discard multicast).
- Note that TCP.bind_addr and TCPPING.initial_hosts should be set, possibly via system properties, e.g.
- -Djgroups.bind_addr=192.168.5.2 and -Djgroups.tcpping.initial_hosts=192.168.5.2[7800]
- We currently require use_incoming_packet_handler=true (release 2.4 will support use_incoming_packet_handler=false
- due to threadless stack support).">
- <config>
- <TCP_NIO
- recv_buf_size="20000000"
- send_buf_size="640000"
- loopback="true"
- discard_incompatible_packets="true"
- max_bundle_size="64000"
- max_bundle_timeout="30"
- use_incoming_packet_handler="true"
- enable_bundling="true"
- start_port="7800"
- use_send_queues="false"
- sock_conn_timeout="300" skip_suspected_members="true"
- reader_threads="8"
- writer_threads="8"
- processor_threads="8"
- processor_minThreads="8"
- processor_maxThreads="8"
- processor_queueSize="100"
- processor_keepAliveTime="-1"/>
- <TCPPING timeout="3000"
- initial_hosts="${jgroups.tcpping.initial_hosts:localhost[7800],localhost[7801]}"
- port_range="1"
- num_initial_members="3"/>
- <MERGE2 max_interval="100000"
- min_interval="20000"/>
- <FD_SOCK/>
- <FD timeout="10000" max_tries="5" shun="true"/>
- <VERIFY_SUSPECT timeout="1500" />
- <pbcast.NAKACK
- use_mcast_xmit="false" gc_lag="0"
- retransmit_timeout="300,600,1200,2400,4800"
- discard_delivered_msgs="false"/>
- <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
- max_bytes="400000"/>
- <pbcast.GMS print_local_addr="true" join_timeout="3000"
- join_retry_timeout="2000" shun="false"
- view_bundling="true"/>
- <FC max_credits="2000000"
- min_threshold="0.10"/>
- <FRAG2 frag_size="60000" />
- <pbcast.STREAMING_STATE_TRANSFER/>
- <!-- <pbcast.STATE_TRANSFER/> -->
- <pbcast.FLUSH timeout="0"/>
- </config>
- </stack>
-
-
- <stack name="tcp-nio-sync"
- description="TCP based stack, without flow control and without message bundling. This is usually used when IP
- multicasting cannot be used in a network, e.g. because it is disabled (routers discard multicast). This
- configuration should be used instead of tcp when (1) synchronous calls are used and (2) the message volume
- (rate and size) is not that large">
- <config>
- <TCP_NIO
- recv_buf_size="20000000"
- send_buf_size="640000"
- loopback="true"
- discard_incompatible_packets="true"
- max_bundle_size="64000"
- max_bundle_timeout="30"
- use_incoming_packet_handler="true"
- enable_bundling="true"
- start_port="7900"
- use_send_queues="false"
- sock_conn_timeout="300" skip_suspected_members="true"
- reader_threads="8"
- writer_threads="8"
- processor_threads="8"
- processor_minThreads="8"
- processor_maxThreads="8"
- processor_queueSize="100"
- processor_keepAliveTime="-1"/>
- <TCPPING timeout="3000"
- initial_hosts="${jgroups.tcpping.initial_hosts:localhost[7900],localhost[7901]}"
- port_range="1"
- num_initial_members="3"/>
- <MERGE2 max_interval="100000"
- min_interval="20000"/>
- <FD_SOCK/>
- <FD timeout="10000" max_tries="5" shun="true"/>
- <VERIFY_SUSPECT timeout="1500" />
- <pbcast.NAKACK
- use_mcast_xmit="false" gc_lag="0"
- retransmit_timeout="300,600,1200,2400,4800"
- discard_delivered_msgs="false"/>
- <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
- max_bytes="400000"/>
- <pbcast.GMS print_local_addr="true" join_timeout="3000"
- join_retry_timeout="2000" shun="false"
- view_bundling="true"/>
- <pbcast.STREAMING_STATE_TRANSFER/>
- <!-- <pbcast.STATE_TRANSFER/> -->
- <pbcast.FLUSH timeout="0"/>
- </config>
- </stack>
-
-
<stack name="tunnel"
description="Used with a GossipRouter">
<config>
17 years
Hibernate SVN: r14254 - in core/trunk/cache-jbosscache2/src: test/java/org/hibernate/test/cache/jbc2/timestamp and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2007-12-21 14:49:29 -0500 (Fri, 21 Dec 2007)
New Revision: 14254
Added:
core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/timestamp/ClusteredConcurrentTimestampsRegionImpl.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/timestamp/ClusteredConcurrentTimestampRegionTestCase.java
Log:
Put prototype of a next-gen TimestampsRegion impl under src control
Added: core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/timestamp/ClusteredConcurrentTimestampsRegionImpl.java
===================================================================
--- core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/timestamp/ClusteredConcurrentTimestampsRegionImpl.java (rev 0)
+++ core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/timestamp/ClusteredConcurrentTimestampsRegionImpl.java 2007-12-21 19:49:29 UTC (rev 14254)
@@ -0,0 +1,363 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A 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, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Brian Stansberry
+ */
+
+package org.hibernate.cache.jbc2.timestamp;
+
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Semaphore;
+
+import javax.transaction.Transaction;
+
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.TimestampsRegion;
+import org.hibernate.cache.jbc2.TransactionalDataRegionAdapter;
+import org.hibernate.cache.jbc2.util.CacheHelper;
+import org.jboss.cache.Cache;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.config.Option;
+import org.jboss.cache.notifications.annotation.CacheListener;
+import org.jboss.cache.notifications.annotation.NodeModified;
+import org.jboss.cache.notifications.annotation.NodeRemoved;
+import org.jboss.cache.notifications.event.NodeModifiedEvent;
+import org.jboss.cache.notifications.event.NodeRemovedEvent;
+
+/**
+ * Prototype of a clustered timestamps cache region impl usable if the
+ * TimestampsRegion API is changed.
+ * <p>
+ * Maintains a local (authoritative) cache of timestamps along with the
+ * distributed cache held in JBoss Cache. Listens for changes in the distributed
+ * cache and updates the local cache accordingly. Ensures that any changes in
+ * the local cache represent either 1) an increase in the timestamp or
+ * 2) a stepback in the timestamp by the caller that initially increased
+ * it as part of a pre-invalidate call. This approach allows
+ * timestamp changes to be replicated asynchronously by JBoss Cache while still
+ * preventing invalid backward changes in timestamps.
+ * </p>
+ *
+ * NOTE: This is just a prototype!!! Only useful if we change the
+ * TimestampsRegion API.
+ *
+ * @author Brian Stansberry
+ * @version $Revision: 14106 $
+ */
+@CacheListener
+public class ClusteredConcurrentTimestampsRegionImpl extends TransactionalDataRegionAdapter implements TimestampsRegion {
+
+ public static final String TYPE = "TS";
+
+ private final ConcurrentHashMap localCache = new ConcurrentHashMap();
+
+ /**
+ * Create a new ClusteredConccurentTimestampsRegionImpl.
+ *
+ * @param jbcCache
+ * @param regionName
+ * @param regionPrefix
+ * TODO
+ * @param metadata
+ */
+ public ClusteredConcurrentTimestampsRegionImpl(Cache jbcCache, String regionName, String regionPrefix, Properties properties) {
+ super(jbcCache, regionName, regionPrefix, null);
+
+ jbcCache.addCacheListener(this);
+
+ populateLocalCache();
+ }
+
+ @Override
+ protected Fqn<String> createRegionFqn(String regionName, String regionPrefix) {
+ return getTypeFirstRegionFqn(regionName, regionPrefix, TYPE);
+ }
+
+ public void evict(Object key) throws CacheException {
+ Option opt = getNonLockingDataVersionOption(true);
+ CacheHelper.removeNode(getCacheInstance(), getRegionFqn(), key, opt);
+ }
+
+ public void evictAll() throws CacheException {
+ Option opt = getNonLockingDataVersionOption(true);
+ CacheHelper.removeAll(getCacheInstance(), getRegionFqn(), opt);
+ // Restore the region root node
+ CacheHelper.addNode(getCacheInstance(), getRegionFqn(), false, true, null);
+ }
+
+ public Object get(Object key) throws CacheException {
+ Entry entry = getLocalEntry(key);
+ Object timestamp = entry.getCurrent();
+ if (timestamp == null) {
+ // Double check the distributed cache
+ Object[] vals = (Object[]) suspendAndGet(key, null, false);
+ if (vals != null) {
+ storeDataFromJBC(key, vals);
+ timestamp = entry.getCurrent();
+ }
+ }
+ return timestamp;
+ }
+
+ public void put(Object key, Object value) throws CacheException {
+
+ throw new UnsupportedOperationException("Prototype only; Hibernate core must change the API before really using");
+ }
+
+ public void preInvalidate(Object key, Object value) throws CacheException {
+
+ Entry entry = getLocalEntry(key);
+ if (entry.preInvalidate(value)) {
+ putInJBossCache(key, entry);
+ }
+ }
+
+ public void invalidate(Object key, Object value, Object preInvalidateValue) throws CacheException {
+
+ Entry entry = getLocalEntry(key);
+ if (entry.invalidate(value, preInvalidateValue)) {
+ putInJBossCache(key, entry);
+ }
+ }
+
+ private void putInJBossCache(Object key, Entry entry) {
+
+ // Get an exclusive right to update JBC for this key from this node.
+ boolean locked = false;
+ try {
+ entry.acquireJBCWriteMutex();
+ locked = true;
+ // We have the JBCWriteMutex, so no other *local* thread will
+ // be trying to write this key.
+ // It's possible here some remote thread has come in and
+ // changed the values again, but since we are reading the
+ // values to write to JBC right now, we know we are writing
+ // the latest values; i.e. we don't assume that what we cached
+ // in entry.update() above is what we should write to JBC *now*.
+ // Our write could be redundant, i.e. we are writing what
+ // some remote thread just came in an wrote. There is a chance
+ // that yet another remote thread will update us, and we'll then
+ // overwrite that later data in JBC. But, all remote nodes will
+ // ignore that change in their localCache; the only place it
+ // will live will be in JBC, where it can only effect the
+ // initial state transfer values on newly joined nodes
+ // (i.e. populateLocalCache()).
+
+ // Don't hold the JBC node lock throughout the tx, as that
+ // prevents reads and other updates
+ Transaction tx = suspend();
+ try {
+ Option opt = getNonLockingDataVersionOption(false);
+ // We ensure ASYNC semantics (JBCACHE-1175)
+ opt.setForceAsynchronous(true);
+ CacheHelper.put(getCacheInstance(), getRegionFqn(), key, entry.getJBCUpdateValues(), opt);
+ }
+ finally {
+ resume(tx);
+ }
+ }
+ catch (InterruptedException e) {
+ throw new CacheException("Interrupted while acquiring right to update " + key, e);
+ }
+ finally {
+ if (locked) {
+ entry.releaseJBCWriteMutex();
+ }
+ }
+ }
+
+ @Override
+ public void destroy() throws CacheException {
+
+ getCacheInstance().removeCacheListener(this);
+ super.destroy();
+ localCache.clear();
+ }
+
+ /**
+ * Monitors cache events and updates the local cache
+ *
+ * @param event
+ */
+ @NodeModified
+ public void nodeModified(NodeModifiedEvent event) {
+ if (event.isOriginLocal() || event.isPre())
+ return;
+
+ Fqn fqn = event.getFqn();
+ Fqn regFqn = getRegionFqn();
+ if (fqn.size() == regFqn.size() + 1 && fqn.isChildOf(regFqn)) {
+ Object key = fqn.get(regFqn.size());
+ Object[] vals = (Object[]) event.getData().get(ITEM);
+ storeDataFromJBC(key, vals);
+ // TODO consider this hack instead of the simple entry.update above:
+// if (!entry.update(vals[0], vals[1])) {
+// // Hack! Use the fact that the Object[] stored in JBC is
+// // mutable to correct our local JBC state in this callback
+// Object[] correct = entry.getJBCUpdateValues();
+// vals[0] = correct[0];
+// vals[1] = correct[1];
+// }
+ }
+ }
+
+ private void storeDataFromJBC(Object key, Object[] vals) {
+ Entry entry = getLocalEntry(key);
+ if (vals[0].equals(vals[1])) {
+ entry.preInvalidate(vals[0]);
+ }
+ else {
+ entry.invalidate(vals[0], vals[1]);
+ }
+ }
+
+ /**
+ * Monitors cache events and updates the local cache
+ *
+ * @param event
+ */
+ @NodeRemoved
+ public void nodeRemoved(NodeRemovedEvent event) {
+ if (event.isOriginLocal() || event.isPre())
+ return;
+
+ Fqn fqn = event.getFqn();
+ Fqn regFqn = getRegionFqn();
+ if (fqn.isChildOrEquals(regFqn)) {
+ if (fqn.size() == regFqn.size()) {
+ localCache.clear();
+ }
+ else {
+ Object key = fqn.get(regFqn.size());
+ localCache.remove(key);
+ }
+ }
+ }
+
+ /**
+ * Brings all data from the distributed cache into our local cache.
+ */
+ private void populateLocalCache() {
+ Set children = CacheHelper.getChildrenNames(getCacheInstance(), getRegionFqn());
+ for (Object key : children) {
+ Object[] vals = (Object[]) suspendAndGet(key, null, false);
+ if (vals != null) {
+ storeDataFromJBC(key, vals);
+ }
+ }
+ }
+
+ private Entry getLocalEntry(Object key) {
+
+ Entry entry = new Entry();
+ Entry oldEntry = (Entry) localCache.putIfAbsent(key, entry);
+ return (oldEntry == null ? entry : oldEntry);
+ }
+
+ private class Entry {
+
+ private Semaphore writeMutex = new Semaphore(1);
+ private boolean preInvalidated = false;
+ private Object preInval = null;
+ private Object current = null;
+
+ void acquireJBCWriteMutex() throws InterruptedException {
+ writeMutex.acquire();
+ }
+
+ void releaseJBCWriteMutex() {
+ writeMutex.release();
+ }
+
+ synchronized boolean preInvalidate(Object newVal) {
+
+ boolean result = false;
+ if (newVal instanceof Comparable) {
+ if (current == null || ((Comparable) newVal).compareTo(current) > 0) {
+ preInval = current = newVal;
+ preInvalidated = true;
+ result = true;
+ }
+ }
+ else {
+ preInval = current = newVal;
+ result = true;
+ }
+
+ return result;
+ }
+
+ synchronized boolean invalidate(Object newVal, Object preInvalidateValue) {
+
+ boolean result = false;
+
+ if (current == null) {
+ // Initial load from JBC
+ current = newVal;
+ preInval = preInvalidateValue;
+ preInvalidated = false;
+ result = true;
+ }
+ else if (preInvalidated) {
+ if (newVal instanceof Comparable) {
+ if (safeEquals(preInvalidateValue, this.preInval)
+ || ((Comparable) newVal).compareTo(preInval) > 0) {
+ current = newVal;
+ preInval = preInvalidateValue;
+ preInvalidated = false;
+ result = true;
+ }
+ }
+ else {
+ current = newVal;
+ preInval = preInvalidateValue;
+ result = true;
+ }
+ }
+ else if (newVal instanceof Comparable) {
+ // See if we had a 2nd invalidation from the same initial
+ // preinvalidation timestamp. If so, only increment
+ // if the new current value is an increase
+ if (safeEquals(preInvalidateValue, this.preInval)
+ && ((Comparable) newVal).compareTo(current) > 0) {
+ current = newVal;
+ preInval = preInvalidateValue;
+ result = true;
+ }
+ }
+
+ return result;
+ }
+
+ synchronized Object getCurrent() {
+ return current;
+ }
+
+ synchronized Object getPreInval() {
+ return preInval;
+ }
+
+ synchronized Object[] getJBCUpdateValues() {
+ return new Object[] {current, preInval};
+ }
+
+ private boolean safeEquals(Object a, Object b) {
+ return (a == b || (a != null && a.equals(b)));
+ }
+ }
+
+
+
+}
Added: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/timestamp/ClusteredConcurrentTimestampRegionTestCase.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/timestamp/ClusteredConcurrentTimestampRegionTestCase.java (rev 0)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/timestamp/ClusteredConcurrentTimestampRegionTestCase.java 2007-12-21 19:49:29 UTC (rev 14254)
@@ -0,0 +1,281 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A 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, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Brian Stansberry
+ */
+
+package org.hibernate.test.cache.jbc2.timestamp;
+
+import java.util.Properties;
+import java.util.Random;
+
+import junit.framework.AssertionFailedError;
+
+import org.hibernate.cache.UpdateTimestampsCache;
+import org.hibernate.cache.jbc2.CacheInstanceManager;
+import org.hibernate.cache.jbc2.JBossCacheRegionFactory;
+import org.hibernate.cache.jbc2.MultiplexedJBossCacheRegionFactory;
+import org.hibernate.cache.jbc2.timestamp.ClusteredConcurrentTimestampsRegionImpl;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.test.cache.jbc2.AbstractJBossCacheTestCase;
+import org.hibernate.test.util.CacheTestUtil;
+import org.jboss.cache.Cache;
+
+/**
+ * A ClusteredConcurrentTimestampCacheTestCase.
+ *
+ * @author <a href="brian.stansberry(a)jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1 $
+ */
+public class ClusteredConcurrentTimestampRegionTestCase extends AbstractJBossCacheTestCase {
+
+ private static final String KEY1 = "com.foo.test.Entity1";
+ private static final String KEY2 = "com.foo.test.Entity2";
+
+ private static final Long ONE = new Long(1);
+ private static final Long TWO = new Long(2);
+ private static final Long THREE = new Long(3);
+ private static final Long TEN = new Long(10);
+ private static final Long ELEVEN = new Long(11);
+
+ private static Cache cache;
+ private static Properties properties;
+ private ClusteredConcurrentTimestampsRegionImpl region;
+
+ /**
+ * Create a new ClusteredConcurrentTimestampCacheTestCase.
+ *
+ * @param name
+ */
+ public ClusteredConcurrentTimestampRegionTestCase(String name) {
+ super(name);
+ }
+
+
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ if (cache == null) {
+ Configuration cfg = CacheTestUtil.buildConfiguration("test", MultiplexedJBossCacheRegionFactory.class, false, true);
+ properties = cfg.getProperties();
+ cache = createCache();
+
+ // Sleep a bit to avoid concurrent FLUSH problem
+ avoidConcurrentFlush();
+ }
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+
+ if (region != null) {
+ region.destroy();
+ }
+ }
+
+ private Cache createCache() throws Exception {
+ Configuration cfg = CacheTestUtil.buildConfiguration("test", MultiplexedJBossCacheRegionFactory.class, false, true);
+ JBossCacheRegionFactory regionFactory = CacheTestUtil.startRegionFactory(cfg);
+ CacheInstanceManager mgr = regionFactory.getCacheInstanceManager();
+ return mgr.getTimestampsCacheInstance();
+ }
+
+ protected ClusteredConcurrentTimestampsRegionImpl getTimestampRegion(Cache cache) throws Exception {
+
+ return new ClusteredConcurrentTimestampsRegionImpl(cache, "test/" + UpdateTimestampsCache.class.getName(), "test", properties);
+ }
+
+ public void testSimplePreinvalidate() throws Exception {
+
+ region = getTimestampRegion(cache);
+
+ assertEquals(null, region.get(KEY1));
+ region.preInvalidate(KEY1, TWO);
+ assertEquals(TWO, region.get(KEY1));
+ region.preInvalidate(KEY1, ONE);
+ assertEquals(TWO, region.get(KEY1));
+ region.preInvalidate(KEY1, TWO);
+ assertEquals(TWO, region.get(KEY1));
+ region.preInvalidate(KEY1, THREE);
+ assertEquals(THREE, region.get(KEY1));
+ }
+
+ public void testInitialState() throws Exception {
+
+ region = getTimestampRegion(cache);
+ region.preInvalidate(KEY1, TEN);
+ region.preInvalidate(KEY2, ELEVEN);
+ region.invalidate(KEY1, ONE, TEN);
+
+ Cache cache2 = createCache();
+ registerCache(cache2);
+
+ // Sleep a bit to avoid concurrent FLUSH problem
+ avoidConcurrentFlush();
+
+ ClusteredConcurrentTimestampsRegionImpl region2 = getTimestampRegion(cache2);
+ assertEquals(ONE, region2.get(KEY1));
+ assertEquals(ELEVEN, region2.get(KEY2));
+ }
+
+ public void testSimpleInvalidate() throws Exception {
+
+ region = getTimestampRegion(cache);
+
+ assertEquals(null, region.get(KEY1));
+ region.preInvalidate(KEY1, TWO);
+ assertEquals(TWO, region.get(KEY1));
+ region.invalidate(KEY1, ONE, TWO);
+ assertEquals(ONE, region.get(KEY1));
+ region.preInvalidate(KEY1, TEN);
+ region.preInvalidate(KEY1, ELEVEN);
+ assertEquals(ELEVEN, region.get(KEY1));
+ region.invalidate(KEY1, TWO, TEN);
+ assertEquals(ELEVEN, region.get(KEY1));
+ region.invalidate(KEY1, TWO, ELEVEN);
+ assertEquals(TWO, region.get(KEY1));
+ region.preInvalidate(KEY1, TEN);
+ assertEquals(TEN, region.get(KEY1));
+ region.invalidate(KEY1, THREE, TEN);
+ assertEquals(THREE, region.get(KEY1));
+ }
+
+ public void testConcurrentActivityClustered() throws Exception {
+ concurrentActivityTest(true);
+ }
+
+ public void testConcurrentActivityNonClustered() throws Exception {
+ concurrentActivityTest(false);
+ }
+
+ private void concurrentActivityTest(boolean clustered) throws Exception {
+
+ region = getTimestampRegion(cache);
+ ClusteredConcurrentTimestampsRegionImpl region2 = region;
+
+ if (clustered) {
+ Cache cache2 = createCache();
+ registerCache(cache2);
+
+ // Sleep a bit to avoid concurrent FLUSH problem
+ avoidConcurrentFlush();
+
+ region2 = getTimestampRegion(cache2);
+ }
+
+ Tester[] testers = new Tester[20];
+ for (int i = 0; i < testers.length; i++) {
+ testers[i] = new Tester((i % 2 == 0) ? region : region2);
+ testers[i].start();
+ }
+
+ for (int j = 0; j < 10; j++) {
+ sleep(2000);
+
+ log.info("Running for " + ((j + 1) * 2) + " seconds");
+
+ for (int i = 0; i < testers.length; i++) {
+ if (testers[i].assertionFailure != null)
+ throw testers[i].assertionFailure;
+ }
+
+ for (int i = 0; i < testers.length; i++) {
+ if (testers[i].exception != null)
+ throw testers[i].exception;
+ }
+ }
+
+ for (int i = 0; i < testers.length; i++) {
+ testers[i].stop();
+ }
+
+ for (int i = 0; i < testers.length; i++) {
+ if (testers[i].assertionFailure != null)
+ throw testers[i].assertionFailure;
+ }
+
+ for (int i = 0; i < testers.length; i++) {
+ if (testers[i].exception != null)
+ throw testers[i].exception;
+ }
+ }
+
+
+
+ private class Tester implements Runnable {
+
+ ClusteredConcurrentTimestampsRegionImpl region;
+ Exception exception;
+ AssertionFailedError assertionFailure;
+ boolean stopped = true;
+ Thread thread;
+ Random random = new Random();
+
+ Tester(ClusteredConcurrentTimestampsRegionImpl region) {
+ this.region = region;
+ }
+
+ public void run() {
+ stopped = false;
+
+ while (!stopped) {
+ try {
+ Long pre = new Long(region.nextTimestamp() + region.getTimeout());
+ region.preInvalidate(KEY1, pre);
+ sleep(random.nextInt(1));
+ Long post = new Long(region.nextTimestamp());
+ region.invalidate(KEY1, post, pre);
+ Long ts = (Long) region.get(KEY1);
+ assertTrue(ts + " >= " + post, ts.longValue() >= post.longValue());
+ sleep(random.nextInt(1));
+ }
+ catch (AssertionFailedError e) {
+ assertionFailure = e;
+ }
+ catch (Exception e) {
+ if (!stopped)
+ exception = e;
+ }
+ finally {
+ stopped = true;
+ }
+ }
+ }
+
+ void start() {
+ if (stopped) {
+ if (thread == null) {
+ thread = new Thread(this);
+ thread.setDaemon(true);
+ }
+ thread.start();
+ }
+ }
+
+ void stop() {
+ if (!stopped) {
+ stopped = true;
+ try {
+ thread.join(100);
+ }
+ catch (InterruptedException ignored) {}
+
+ if (thread.isAlive())
+ thread.interrupt();
+ }
+ }
+ }
+}
17 years
Hibernate SVN: r14253 - in core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2: entity and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2007-12-21 14:48:42 -0500 (Fri, 21 Dec 2007)
New Revision: 14253
Modified:
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/AbstractCollectionRegionAccessStrategyTestCase.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/AbstractEntityRegionAccessStrategyTestCase.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/AbstractReadOnlyAccessTestCase.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/AbstractTransactionalAccessTestCase.java
Log:
Add workaround to avoid delays from concurrent FLUSH calls in JGroups 2.6.1
Use different "entity keys" per test to avoid cross-test pollution
Modified: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/AbstractCollectionRegionAccessStrategyTestCase.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/AbstractCollectionRegionAccessStrategyTestCase.java 2007-12-21 19:47:30 UTC (rev 14252)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/AbstractCollectionRegionAccessStrategyTestCase.java 2007-12-21 19:48:42 UTC (rev 14253)
@@ -64,10 +64,12 @@
public abstract class AbstractCollectionRegionAccessStrategyTestCase extends AbstractJBossCacheTestCase {
public static final String REGION_NAME = "test/com.foo.test";
- public static final String KEY = "KEY";
+ public static final String KEY_BASE = "KEY";
public static final String VALUE1 = "VALUE1";
public static final String VALUE2 = "VALUE2";
+ protected static int testCount;
+
protected static Configuration localCfg;
protected static JBossCacheRegionFactory localRegionFactory;
protected static Cache localCache;
@@ -114,12 +116,18 @@
protected void setUp() throws Exception {
super.setUp();
+ // Sleep a bit to avoid concurrent FLUSH problem
+ avoidConcurrentFlush();
+
invalidation = CacheHelper.isClusteredInvalidation(localCache);
synchronous = CacheHelper.isSynchronous(localCache);
optimistic = localCache.getConfiguration().getNodeLockingScheme() == org.jboss.cache.config.Configuration.NodeLockingScheme.OPTIMISTIC;
localCollectionRegion = localRegionFactory.buildCollectionRegion(REGION_NAME, localCfg.getProperties(), getCacheDataDescription());
localAccessStrategy = localCollectionRegion.buildAccessStrategy(getAccessType());
+ // Sleep a bit to avoid concurrent FLUSH problem
+ avoidConcurrentFlush();
+
remoteCollectionRegion = remoteRegionFactory.buildCollectionRegion(REGION_NAME, remoteCfg.getProperties(), getCacheDataDescription());
remoteAccessStrategy = remoteCollectionRegion.buildAccessStrategy(getAccessType());
@@ -229,6 +237,8 @@
*/
private void putFromLoadTest(final boolean useMinimalAPI) throws Exception {
+ final String KEY = KEY_BASE + testCount++;
+
final CountDownLatch writeLatch1 = new CountDownLatch(1);
final CountDownLatch writeLatch2 = new CountDownLatch(1);
final CountDownLatch completionLatch = new CountDownLatch(2);
@@ -400,6 +410,9 @@
}
private void evictOrRemoveTest(boolean evict) {
+
+ final String KEY = KEY_BASE + testCount++;
+
assertNull("local is clean", localAccessStrategy.get(KEY, System.currentTimeMillis()));
assertNull("remote is clean", remoteAccessStrategy.get(KEY, System.currentTimeMillis()));
@@ -422,6 +435,8 @@
}
private void evictOrRemoveAllTest(boolean evict) {
+
+ final String KEY = KEY_BASE + testCount++;
Fqn regionFqn = getRegionFqn(REGION_NAME, REGION_PREFIX);
Modified: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/AbstractEntityRegionAccessStrategyTestCase.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/AbstractEntityRegionAccessStrategyTestCase.java 2007-12-21 19:47:30 UTC (rev 14252)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/AbstractEntityRegionAccessStrategyTestCase.java 2007-12-21 19:48:42 UTC (rev 14253)
@@ -64,10 +64,12 @@
public abstract class AbstractEntityRegionAccessStrategyTestCase extends AbstractJBossCacheTestCase {
public static final String REGION_NAME = "test/com.foo.test";
- public static final String KEY = "KEY";
+ public static final String KEY_BASE = "KEY";
public static final String VALUE1 = "VALUE1";
public static final String VALUE2 = "VALUE2";
+ protected static int testCount;
+
protected static Configuration localCfg;
protected static JBossCacheRegionFactory localRegionFactory;
protected static Cache localCache;
@@ -116,9 +118,15 @@
protected void setUp() throws Exception {
super.setUp();
+ // Sleep a bit to avoid concurrent FLUSH problem
+ avoidConcurrentFlush();
+
localEntityRegion = localRegionFactory.buildEntityRegion(REGION_NAME, localCfg.getProperties(), getCacheDataDescription());
localAccessStrategy = localEntityRegion.buildAccessStrategy(getAccessType());
+ // Sleep a bit to avoid concurrent FLUSH problem
+ avoidConcurrentFlush();
+
remoteEntityRegion = remoteRegionFactory.buildEntityRegion(REGION_NAME, remoteCfg.getProperties(), getCacheDataDescription());
remoteAccessStrategy = remoteEntityRegion.buildAccessStrategy(getAccessType());
@@ -186,6 +194,24 @@
protected Fqn getRegionFqn(String regionName, String regionPrefix) {
return BasicRegionAdapter.getTypeLastRegionFqn(regionName, regionPrefix, EntityRegionImpl.TYPE);
}
+
+ protected void assertThreadsRanCleanly()
+ {
+ if (node1Failure != null)
+ throw node1Failure;
+ if (node2Failure != null)
+ throw node2Failure;
+
+ if (node1Exception != null) {
+ log.error("node1 saw an exception", node1Exception);
+ assertEquals("node1 saw no exceptions", null, node1Exception);
+ }
+
+ if (node2Exception != null) {
+ log.error("node2 saw an exception", node2Exception);
+ assertEquals("node2 saw no exceptions", null, node2Exception);
+ }
+ }
/**
* This is just a setup test where we assert that the cache config is
@@ -220,7 +246,7 @@
* Second tries to do a putFromLoad with stale data (i.e. it took
* longer to read from the db). Both commit their tx. Then
* both start a new tx and get. First should see the updated data;
- * second should either see the updated data (isInvalidation()( == false)
+ * second should either see the updated data (isInvalidation() == false)
* or null (isInvalidation() == true).
*
* @param useMinimalAPI
@@ -228,6 +254,8 @@
*/
private void putFromLoadTest(final boolean useMinimalAPI) throws Exception {
+ final String KEY = KEY_BASE + testCount++;
+
final CountDownLatch writeLatch1 = new CountDownLatch(1);
final CountDownLatch writeLatch2 = new CountDownLatch(1);
final CountDownLatch completionLatch = new CountDownLatch(2);
@@ -319,14 +347,8 @@
assertTrue("Threads completed", completionLatch.await(2, TimeUnit.SECONDS));
- if (node1Failure != null)
- throw node1Failure;
- if (node2Failure != null)
- throw node2Failure;
+ assertThreadsRanCleanly();
- assertEquals("node1 saw no exceptions", null, node1Exception);
- assertEquals("node2 saw no exceptions", null, node2Exception);
-
long txTimestamp = System.currentTimeMillis();
assertEquals("Correct node1 value", VALUE2, localAccessStrategy.get(KEY, txTimestamp));
@@ -349,6 +371,8 @@
* Test method for {@link TransactionalAccess#insert(java.lang.Object, java.lang.Object, java.lang.Object)}.
*/
public void testInsert() throws Exception {
+
+ final String KEY = KEY_BASE + testCount++;
final CountDownLatch readLatch = new CountDownLatch(1);
final CountDownLatch commitLatch = new CountDownLatch(1);
@@ -431,14 +455,8 @@
assertTrue("Threads completed", completionLatch.await(1, TimeUnit.SECONDS));
}
- if (node1Failure != null)
- throw node1Failure;
- if (node2Failure != null)
- throw node2Failure;
+ assertThreadsRanCleanly();
- assertEquals("node1 saw no exceptions", null, node1Exception);
- assertEquals("node2 saw no exceptions", null, node2Exception);
-
long txTimestamp = System.currentTimeMillis();
assertEquals("Correct node1 value", VALUE1, localAccessStrategy.get(KEY, txTimestamp));
Object expected = isUsingInvalidation() ? null : VALUE1;
@@ -449,6 +467,8 @@
* Test method for {@link TransactionalAccess#update(java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object)}.
*/
public void testUpdate() throws Exception {
+
+ final String KEY = KEY_BASE + testCount++;
// Set up initial state
localAccessStrategy.putFromLoad(KEY, VALUE1, System.currentTimeMillis(), new Integer(1));
@@ -542,14 +562,8 @@
assertTrue(completionLatch.await(1, TimeUnit.SECONDS));
}
- if (node1Failure != null)
- throw node1Failure;
- if (node2Failure != null)
- throw node2Failure;
+ assertThreadsRanCleanly();
- assertEquals("node1 saw no exceptions", null, node1Exception);
- assertEquals("node2 saw no exceptions", null, node2Exception);
-
long txTimestamp = System.currentTimeMillis();
assertEquals("Correct node1 value", VALUE2, localAccessStrategy.get(KEY, txTimestamp));
Object expected = isUsingInvalidation() ? null : VALUE2;
@@ -591,6 +605,9 @@
}
private void evictOrRemoveTest(boolean evict) {
+
+ final String KEY = KEY_BASE + testCount++;
+
assertNull("local is clean", localAccessStrategy.get(KEY, System.currentTimeMillis()));
assertNull("remote is clean", remoteAccessStrategy.get(KEY, System.currentTimeMillis()));
@@ -615,6 +632,8 @@
}
private void evictOrRemoveAllTest(boolean evict) {
+
+ final String KEY = KEY_BASE + testCount++;
Fqn regionFqn = getRegionFqn(REGION_NAME, REGION_PREFIX);
@@ -641,14 +660,16 @@
localAccessStrategy.putFromLoad(KEY, VALUE1, System.currentTimeMillis(), new Integer(1));
assertEquals(VALUE1, localAccessStrategy.get(KEY, System.currentTimeMillis()));
+
+ // Wait for async propagation
+ sleep(250);
+
remoteAccessStrategy.putFromLoad(KEY, VALUE1, System.currentTimeMillis(), new Integer(1));
assertEquals(VALUE1, remoteAccessStrategy.get(KEY, System.currentTimeMillis()));
// Wait for async propagation
sleep(250);
-
-
if (isUsingOptimisticLocking()) {
regionRoot = localCache.getRoot().getChild(regionFqn);
assertEquals(NonLockingDataVersion.class, ((NodeSPI) regionRoot).getVersion().getClass());
Modified: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/AbstractReadOnlyAccessTestCase.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/AbstractReadOnlyAccessTestCase.java 2007-12-21 19:47:30 UTC (rev 14252)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/AbstractReadOnlyAccessTestCase.java 2007-12-21 19:48:42 UTC (rev 14253)
@@ -58,6 +58,9 @@
}
private void putFromLoadTest(boolean minimal) throws Exception {
+
+ final String KEY = KEY_BASE + testCount++;
+
long txTimestamp = System.currentTimeMillis();
BatchModeTransactionManager.getInstance().begin();
assertNull(localAccessStrategy.get(KEY, System.currentTimeMillis()));
@@ -77,6 +80,9 @@
@Override
public void testUpdate() throws Exception {
+
+ final String KEY = KEY_BASE + testCount++;
+
try {
localAccessStrategy.update(KEY, VALUE2, new Integer(2), new Integer(1));
fail("Call to update did not throw exception");
Modified: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/AbstractTransactionalAccessTestCase.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/AbstractTransactionalAccessTestCase.java 2007-12-21 19:47:30 UTC (rev 14252)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/AbstractTransactionalAccessTestCase.java 2007-12-21 19:48:42 UTC (rev 14253)
@@ -53,6 +53,8 @@
}
public void testContestedPutFromLoad() throws Exception {
+
+ final String KEY = KEY_BASE + testCount++;
localAccessStrategy.putFromLoad(KEY, VALUE1, System.currentTimeMillis(), new Integer(1));
@@ -129,14 +131,8 @@
assertTrue("Threads completed", completionLatch.await(1, TimeUnit.SECONDS));
- if (node1Failure != null)
- throw node1Failure;
- if (node2Failure != null)
- throw node2Failure;
+ assertThreadsRanCleanly();
- assertEquals("node1 saw no exceptions", null, node1Exception);
- assertEquals("node2 saw no exceptions", null, node2Exception);
-
long txTimestamp = System.currentTimeMillis();
assertEquals("Correct node1 value", VALUE2, localAccessStrategy.get(KEY, txTimestamp));
}
17 years
Hibernate SVN: r14252 - in core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test: cache/jbc2/collection and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2007-12-21 14:47:30 -0500 (Fri, 21 Dec 2007)
New Revision: 14252
Modified:
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/AbstractGeneralDataRegionTestCase.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/AbstractJBossCacheTestCase.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/JBossCacheComplianceTest.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/OptimisticTransactionalExtraAPITestCase.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/OptimisticTransactionalExtraAPITestCase.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/query/QueryRegionImplTestCase.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/util/CacheTestSupport.java
Log:
Add workaround to avoid delays from concurrent FLUSH calls in JGroups 2.6.1
Modified: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/AbstractGeneralDataRegionTestCase.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/AbstractGeneralDataRegionTestCase.java 2007-12-21 16:34:30 UTC (rev 14251)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/AbstractGeneralDataRegionTestCase.java 2007-12-21 19:47:30 UTC (rev 14252)
@@ -95,6 +95,9 @@
Cache localCache = getJBossCache(regionFactory);
boolean invalidation = CacheHelper.isClusteredInvalidation(localCache);
+ // Sleep a bit to avoid concurrent FLUSH problem
+ avoidConcurrentFlush();
+
GeneralDataRegion localRegion = (GeneralDataRegion) createRegion(regionFactory, getStandardRegionName(REGION_PREFIX), cfg.getProperties(), null);
cfg = createConfiguration(configName);
@@ -149,12 +152,18 @@
Cache localCache = getJBossCache(regionFactory);
boolean optimistic = "OPTIMISTIC".equals(localCache.getConfiguration().getNodeLockingSchemeString());
boolean invalidation = CacheHelper.isClusteredInvalidation(localCache);
+
+ // Sleep a bit to avoid concurrent FLUSH problem
+ avoidConcurrentFlush();
GeneralDataRegion localRegion = (GeneralDataRegion) createRegion(regionFactory, getStandardRegionName(REGION_PREFIX), cfg.getProperties(), null);
cfg = createConfiguration(configName);
regionFactory = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport());
Cache remoteCache = getJBossCache(regionFactory);
+
+ // Sleep a bit to avoid concurrent FLUSH problem
+ avoidConcurrentFlush();
GeneralDataRegion remoteRegion = (GeneralDataRegion) createRegion(regionFactory, getStandardRegionName(REGION_PREFIX), cfg.getProperties(), null);
Fqn regionFqn = getRegionFqn(getStandardRegionName(REGION_PREFIX), REGION_PREFIX);
Modified: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/AbstractJBossCacheTestCase.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/AbstractJBossCacheTestCase.java 2007-12-21 16:34:30 UTC (rev 14251)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/AbstractJBossCacheTestCase.java 2007-12-21 19:47:30 UTC (rev 14252)
@@ -48,11 +48,12 @@
public static final String REGION_PREFIX = "test";
- private CacheTestSupport testSupport = new CacheTestSupport();
+ private CacheTestSupport testSupport;
protected final Logger log = LoggerFactory.getLogger(getClass());
public AbstractJBossCacheTestCase(String name) {
super(name);
+ testSupport = new CacheTestSupport(log);
}
@Override
@@ -97,6 +98,10 @@
log.warn("Interrupted during sleep", e);
}
}
+
+ protected void avoidConcurrentFlush() {
+ testSupport.avoidConcurrentFlush();
+ }
/**
Modified: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/JBossCacheComplianceTest.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/JBossCacheComplianceTest.java 2007-12-21 16:34:30 UTC (rev 14251)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/JBossCacheComplianceTest.java 2007-12-21 19:47:30 UTC (rev 14252)
@@ -39,6 +39,8 @@
import org.jboss.cache.config.Option;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.BatchModeTransactionManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Tests that JBC itself functions as expected in certain areas where there
@@ -51,11 +53,13 @@
*/
public class JBossCacheComplianceTest extends TestCase {
- private CacheTestSupport testSupport = new CacheTestSupport();
+ private CacheTestSupport testSupport;
+ protected final Logger log = LoggerFactory.getLogger(getClass());
public JBossCacheComplianceTest(String x) {
super(x);
+ testSupport = new CacheTestSupport(log);
}
protected String getConfigResourceKey() {
Modified: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/OptimisticTransactionalExtraAPITestCase.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/OptimisticTransactionalExtraAPITestCase.java 2007-12-21 16:34:30 UTC (rev 14251)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/OptimisticTransactionalExtraAPITestCase.java 2007-12-21 19:47:30 UTC (rev 14252)
@@ -75,6 +75,10 @@
JBossCacheRegionFactory rf = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport());
Cache localCache = rf.getCacheInstanceManager().getEntityCacheInstance();
optimistic = localCache.getConfiguration().getNodeLockingScheme() == org.jboss.cache.config.Configuration.NodeLockingScheme.OPTIMISTIC;
+
+ // Sleep a bit to avoid concurrent FLUSH problem
+ avoidConcurrentFlush();
+
CollectionRegion localCollectionRegion = rf.buildCollectionRegion(REGION_NAME, cfg.getProperties(), null);
setCollectionAccessStrategy(localCollectionRegion.buildAccessStrategy(getAccessType()));
}
Modified: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/OptimisticTransactionalExtraAPITestCase.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/OptimisticTransactionalExtraAPITestCase.java 2007-12-21 16:34:30 UTC (rev 14251)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/OptimisticTransactionalExtraAPITestCase.java 2007-12-21 19:47:30 UTC (rev 14252)
@@ -75,6 +75,10 @@
JBossCacheRegionFactory rf = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport());
Cache localCache = rf.getCacheInstanceManager().getEntityCacheInstance();
optimistic = localCache.getConfiguration().getNodeLockingScheme() == org.jboss.cache.config.Configuration.NodeLockingScheme.OPTIMISTIC;
+
+ // Sleep a bit to avoid concurrent FLUSH problem
+ avoidConcurrentFlush();
+
EntityRegion localEntityRegion = rf.buildEntityRegion(REGION_NAME, cfg.getProperties(), null);
setEntityRegionAccessStrategy(localEntityRegion.buildAccessStrategy(getAccessType()));
}
Modified: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/query/QueryRegionImplTestCase.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/query/QueryRegionImplTestCase.java 2007-12-21 16:34:30 UTC (rev 14251)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/query/QueryRegionImplTestCase.java 2007-12-21 19:47:30 UTC (rev 14252)
@@ -99,6 +99,9 @@
Configuration cfg = createConfiguration(configName);
JBossCacheRegionFactory regionFactory = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport());
+ // Sleep a bit to avoid concurrent FLUSH problem
+ avoidConcurrentFlush();
+
final QueryResultsRegion region = regionFactory.buildQueryResultsRegion(getStandardRegionName(REGION_PREFIX), cfg.getProperties());
region.put(KEY, VALUE1);
@@ -187,6 +190,9 @@
Configuration cfg = createConfiguration(configName);
JBossCacheRegionFactory regionFactory = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport());
+ // Sleep a bit to avoid concurrent FLUSH problem
+ avoidConcurrentFlush();
+
final QueryResultsRegion region = regionFactory.buildQueryResultsRegion(getStandardRegionName(REGION_PREFIX), cfg.getProperties());
region.put(KEY, VALUE1);
Modified: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/util/CacheTestSupport.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/util/CacheTestSupport.java 2007-12-21 16:34:30 UTC (rev 14251)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/util/CacheTestSupport.java 2007-12-21 19:47:30 UTC (rev 14252)
@@ -28,6 +28,7 @@
import java.util.Set;
import org.jboss.cache.Cache;
+import org.slf4j.Logger;
import org.hibernate.cache.RegionFactory;
@@ -41,11 +42,17 @@
private static final String PREFER_IPV4STACK = "java.net.preferIPv4Stack";
+ private Logger log;
+
private Set<Cache> caches = new HashSet();
private Set<RegionFactory> factories = new HashSet();
private Exception exception;
private String preferIPv4Stack;
+ public CacheTestSupport(Logger log) {
+ this.log = log;
+ }
+
public void registerCache(Cache cache) {
caches.add(cache);
}
@@ -82,6 +89,21 @@
cleanUp();
throwStoredException();
}
+
+ public void avoidConcurrentFlush() {
+ // JG 2.6.1 has a problem where calling flush more than once too quickly
+ // can result in several second delays
+ sleep(100);
+ }
+
+ private void sleep(long ms) {
+ try {
+ Thread.sleep(ms);
+ }
+ catch (InterruptedException e) {
+ log.warn("Interrupted during sleep", e);
+ }
+ }
private void cleanUp() {
for (Iterator it = factories.iterator(); it.hasNext(); ) {
@@ -109,6 +131,7 @@
finally {
it.remove();
}
+ avoidConcurrentFlush();
}
caches.clear();
}
17 years
Hibernate SVN: r14250 - core/trunk/core/src/main/java/org/hibernate/stat.
by hibernate-commits@lists.jboss.org
Author: d.plentz
Date: 2007-12-19 22:05:05 -0500 (Wed, 19 Dec 2007)
New Revision: 14250
Modified:
core/trunk/core/src/main/java/org/hibernate/stat/QueryStatistics.java
Log:
[HHH-2948] QueryStatistics.executionMinTime always = 0
Modified: core/trunk/core/src/main/java/org/hibernate/stat/QueryStatistics.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/stat/QueryStatistics.java 2007-12-20 03:04:08 UTC (rev 14249)
+++ core/trunk/core/src/main/java/org/hibernate/stat/QueryStatistics.java 2007-12-20 03:05:05 UTC (rev 14250)
@@ -18,7 +18,7 @@
private long executionRowCount;
private long executionAvgTime;
private long executionMaxTime;
- private long executionMinTime;
+ private long executionMinTime = Long.MAX_VALUE;
QueryStatistics(String query) {
super(query);
17 years
Hibernate SVN: r14249 - core/branches/Branch_3_2/src/org/hibernate/stat.
by hibernate-commits@lists.jboss.org
Author: d.plentz
Date: 2007-12-19 22:04:08 -0500 (Wed, 19 Dec 2007)
New Revision: 14249
Modified:
core/branches/Branch_3_2/src/org/hibernate/stat/QueryStatistics.java
Log:
[HHH-2948] QueryStatistics.executionMinTime always = 0
Modified: core/branches/Branch_3_2/src/org/hibernate/stat/QueryStatistics.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/stat/QueryStatistics.java 2007-12-18 09:53:54 UTC (rev 14248)
+++ core/branches/Branch_3_2/src/org/hibernate/stat/QueryStatistics.java 2007-12-20 03:04:08 UTC (rev 14249)
@@ -18,7 +18,7 @@
private long executionRowCount;
private long executionAvgTime;
private long executionMaxTime;
- private long executionMinTime;
+ private long executionMinTime = Long.MAX_VALUE;
QueryStatistics(String query) {
super(query);
17 years
Hibernate SVN: r14248 - in annotations/branches/v3_2_1_GA_CP/src: test/org/hibernate/test/annotations/onetoone and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: anthonyHib
Date: 2007-12-18 04:53:54 -0500 (Tue, 18 Dec 2007)
New Revision: 14248
Modified:
annotations/branches/v3_2_1_GA_CP/src/java/org/hibernate/cfg/AnnotationBinder.java
annotations/branches/v3_2_1_GA_CP/src/java/org/hibernate/cfg/AnnotationConfiguration.java
annotations/branches/v3_2_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/Party.java
annotations/branches/v3_2_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/PartyAffiliate.java
Log:
ANN-556 fix
Modified: annotations/branches/v3_2_1_GA_CP/src/java/org/hibernate/cfg/AnnotationBinder.java
===================================================================
--- annotations/branches/v3_2_1_GA_CP/src/java/org/hibernate/cfg/AnnotationBinder.java 2007-12-17 13:12:58 UTC (rev 14247)
+++ annotations/branches/v3_2_1_GA_CP/src/java/org/hibernate/cfg/AnnotationBinder.java 2007-12-18 09:53:54 UTC (rev 14248)
@@ -1902,7 +1902,7 @@
}
else {
mappings.addSecondPass(
- secondPass
+ secondPass, BinderHelper.isDefault( mappedBy )
);
}
}
Modified: annotations/branches/v3_2_1_GA_CP/src/java/org/hibernate/cfg/AnnotationConfiguration.java
===================================================================
--- annotations/branches/v3_2_1_GA_CP/src/java/org/hibernate/cfg/AnnotationConfiguration.java 2007-12-17 13:12:58 UTC (rev 14247)
+++ annotations/branches/v3_2_1_GA_CP/src/java/org/hibernate/cfg/AnnotationConfiguration.java 2007-12-18 09:53:54 UTC (rev 14248)
@@ -293,6 +293,17 @@
iter.remove();
}
}
+ //process OneToManySecondPass in order: first
+ iter = secondPasses.iterator();
+ while ( iter.hasNext() ) {
+ SecondPass sp = (SecondPass) iter.next();
+
+ if ( sp instanceof CreateKeySecondPass ) {
+ sp.doSecondPass( classes );
+ iter.remove();
+ }
+ }
+
super.secondPassCompile();
inSecondPass = false;
Iterator tables = (Iterator<Map.Entry<Table, List<String[]>>>) tableUniqueConstraints.entrySet().iterator();
Modified: annotations/branches/v3_2_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/Party.java
===================================================================
--- annotations/branches/v3_2_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/Party.java 2007-12-17 13:12:58 UTC (rev 14247)
+++ annotations/branches/v3_2_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/Party.java 2007-12-18 09:53:54 UTC (rev 14248)
@@ -4,6 +4,7 @@
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToOne;
+import javax.persistence.PrimaryKeyJoinColumn;
/**
* @author Emmanuel Bernard
@@ -13,6 +14,7 @@
@Id
String partyId;
- @OneToOne(mappedBy = "party")
+ @OneToOne
+ @PrimaryKeyJoinColumn
PartyAffiliate partyAffiliate;
}
Modified: annotations/branches/v3_2_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/PartyAffiliate.java
===================================================================
--- annotations/branches/v3_2_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/PartyAffiliate.java 2007-12-17 13:12:58 UTC (rev 14247)
+++ annotations/branches/v3_2_1_GA_CP/src/test/org/hibernate/test/annotations/onetoone/PartyAffiliate.java 2007-12-18 09:53:54 UTC (rev 14248)
@@ -4,7 +4,6 @@
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToOne;
-import javax.persistence.PrimaryKeyJoinColumn;
/**
* @author Emmanuel Bernard
@@ -14,8 +13,7 @@
@Id
String partyId;
- @OneToOne
- @PrimaryKeyJoinColumn
+ @OneToOne(mappedBy="partyAffiliate")
Party party;
String affiliateName;
17 years
Hibernate SVN: r14247 - annotations/branches.
by hibernate-commits@lists.jboss.org
Author: anthonyHib
Date: 2007-12-17 08:12:58 -0500 (Mon, 17 Dec 2007)
New Revision: 14247
Added:
annotations/branches/v3_2_1_GA_CP/
Log:
Copied: annotations/branches/v3_2_1_GA_CP (from rev 14246, annotations/tags/v3_2_1_GA)
17 years
Hibernate SVN: r14246 - validator/trunk/src/java/org/hibernate/validator/resources.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-12-15 19:51:58 -0500 (Sat, 15 Dec 2007)
New Revision: 14246
Added:
validator/trunk/src/java/org/hibernate/validator/resources/DefaultValidatorMessages_cs.properties
Log:
HV-49 Czech translation
Added: validator/trunk/src/java/org/hibernate/validator/resources/DefaultValidatorMessages_cs.properties
===================================================================
--- validator/trunk/src/java/org/hibernate/validator/resources/DefaultValidatorMessages_cs.properties (rev 0)
+++ validator/trunk/src/java/org/hibernate/validator/resources/DefaultValidatorMessages_cs.properties 2007-12-16 00:51:58 UTC (rev 14246)
@@ -0,0 +1,16 @@
+validator.assertFalse=p\u0159edpoklad neplat\u00ed
+validator.assertTrue=p\u0159edpoklad neplat\u00ed
+validator.future=mus\u00ed b\u00fdt datum v budoucnosti
+validator.length=d\u00e9lka mus\u00ed b\u00fdt mezi {min} a {max}
+validator.max=mus\u00ed b\u00fdt men\u0161\u00ed nebo rovno {value}
+validator.min=mus\u00e1 b\u00fdt men\u0161\u00ed nebo rovno {value}
+validator.notNull=nesm\u00ed b\u00fdt pr\u00e1zdn\u00e9
+validator.past=mus\u00ed b\u00fdt datum v minulosti
+validator.pattern=mus\u00ed odpov\u00eddat "{regex}"
+validator.range=mus\u00ed b\u00fdt v rozmez\u00ed od {min} do {max}
+validator.size=d\u00e9lka mus\u00ed b\u00fdt mezi {min} a {max}
+validator.email=nen\u00ed spr\u00e1vn\u011b zapsan\u00e1 emailov\u00e1 adresa
+validator.notEmpty=nesm\u00ed b\u00fdt pr\u00e1zdn\u00e9
+validator.digits=\u010c\u00edseln\u00e1 hodnota je mimo rozsah (o\u010dek\u00e1v\u00e1no <{integerDigits} \u010d\u00edsel>,<{fractionalDigits} \u010d\u00edsel>)
+validator.creditCard=Nen\u00ed platn\u00e9 \u010d\u00edslo kreditn\u00ed karty
+validator.ean=Nen\u00ed platn\u00e9 EAN
\ No newline at end of file
17 years
Hibernate SVN: r14245 - entitymanager/trunk/src/java/org/hibernate/ejb.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-12-14 12:18:12 -0500 (Fri, 14 Dec 2007)
New Revision: 14245
Modified:
entitymanager/trunk/src/java/org/hibernate/ejb/Ejb3Configuration.java
Log:
doc
Modified: entitymanager/trunk/src/java/org/hibernate/ejb/Ejb3Configuration.java
===================================================================
--- entitymanager/trunk/src/java/org/hibernate/ejb/Ejb3Configuration.java 2007-12-13 17:09:58 UTC (rev 14244)
+++ entitymanager/trunk/src/java/org/hibernate/ejb/Ejb3Configuration.java 2007-12-14 17:18:12 UTC (rev 14245)
@@ -189,6 +189,8 @@
* the peristence.xml file.
* If the persistence unit name is not found or does not match the Persistence Provider, null is returned
*
+ * This method is used in a non managed environment
+ *
* @param persistenceUnitName persistence unit name
* @param integration properties passed to the persistence provider
* @return configured Ejb3Configuration or null if no persistence unit match
@@ -256,6 +258,7 @@
}
}
+ //method used in a non managed environment
private JarVisitor getMainJarVisitor(URL url, PersistenceMetadata metadata, Map integration) {
URL jarURL = JarVisitor.getJarURLFromURLEntry( url, "/META-INF/persistence.xml" );
JarVisitor.Filter[] persistenceXmlFilter = getFilters( metadata, integration, metadata.getExcludeUnlistedClasses() );
17 years