JBoss Cache SVN: r7239 - core/branches/flat/src/main/java/org/jboss/starobrno/context.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-12-02 12:06:52 -0500 (Tue, 02 Dec 2008)
New Revision: 7239
Modified:
core/branches/flat/src/main/java/org/jboss/starobrno/context/InvocationContextImpl.java
Log:
genericized
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/context/InvocationContextImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/context/InvocationContextImpl.java 2008-12-02 15:49:26 UTC (rev 7238)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/context/InvocationContextImpl.java 2008-12-02 17:06:52 UTC (rev 7239)
@@ -30,11 +30,7 @@
import org.jboss.starobrno.transaction.TransactionTable;
import javax.transaction.Transaction;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
/**
* // TODO: MANIK: Document this
@@ -277,7 +273,7 @@
* @return locks held in current scope.
*/
@SuppressWarnings("unchecked")
- public List getKeysLocked()
+ public List<Object> getKeysLocked()
{
// first check transactional scope
if (transactionContext != null) return transactionContext.getKeysLocked();
16 years
JBoss Cache SVN: r7238 - in core/branches/flat/src/main/java/org/jboss/starobrno: util and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-12-02 10:49:26 -0500 (Tue, 02 Dec 2008)
New Revision: 7238
Modified:
core/branches/flat/src/main/java/org/jboss/starobrno/tree/TreeCacheImpl.java
core/branches/flat/src/main/java/org/jboss/starobrno/tree/TreeStructureSupport.java
core/branches/flat/src/main/java/org/jboss/starobrno/util/Immutables.java
core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/locks/OwnableReentrantLock.java
Log:
Improved performance of tree struct
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/tree/TreeCacheImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/tree/TreeCacheImpl.java 2008-12-02 15:19:49 UTC (rev 7237)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/tree/TreeCacheImpl.java 2008-12-02 15:49:26 UTC (rev 7238)
@@ -26,6 +26,7 @@
import org.jboss.cache.Region;
import org.jboss.starobrno.Cache;
import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.atomic.AtomicMap;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.context.InvocationContext;
import org.jboss.starobrno.interceptors.base.CommandInterceptor;
@@ -79,13 +80,14 @@
put(Fqn.fromString(fqn), data);
}
+ @SuppressWarnings("unchecked")
public V remove(Fqn fqn, K key)
{
startAtomic();
try
{
- Node<K, V> n = getNode(fqn);
- return n == null ? null : n.remove(key);
+ AtomicMap map = atomicMapCache.getAtomicMap(new NodeKey(fqn, NodeKey.Type.DATA));
+ return map == null ? null : (V) map.remove(key);
}
finally
{
@@ -138,19 +140,12 @@
return getNode(Fqn.fromString(fqn));
}
+ @SuppressWarnings("unchecked")
public V get(Fqn fqn, K key)
{
- startAtomic();
- try
- {
- Node n = getNode(fqn);
-
- return (V) (n == null ? null : n.get(key));
- }
- finally
- {
- endAtomic();
- }
+ Map m = atomicMapCache.getAtomicMap(new NodeKey(fqn, NodeKey.Type.DATA));
+ if (m == null) return null;
+ return (V) m.get(key);
}
public boolean exists(String f)
@@ -288,13 +283,14 @@
}
}
+ @SuppressWarnings("unchecked")
public V put(Fqn fqn, K key, V value)
{
startAtomic();
try
{
createNodeInCache(fqn);
- return getNode(fqn).put(key, value);
+ return (V) atomicMapCache.getAtomicMap(new NodeKey(fqn, NodeKey.Type.DATA)).put(key, value);
}
finally
{
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/tree/TreeStructureSupport.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/tree/TreeStructureSupport.java 2008-12-02 15:19:49 UTC (rev 7237)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/tree/TreeStructureSupport.java 2008-12-02 15:49:26 UTC (rev 7238)
@@ -50,11 +50,18 @@
}
}
- void createNodeInCache(Fqn fqn)
+ /**
+ * @param fqn
+ * @return true if created, false if this was not necessary
+ */
+ boolean createNodeInCache(Fqn fqn)
{
startAtomic();
try
{
+ NodeKey dataKey = new NodeKey(fqn, NodeKey.Type.DATA);
+ NodeKey structureKey = new NodeKey(fqn, NodeKey.Type.STRUCTURE);
+ if (cache.containsKey(dataKey) && cache.containsKey(structureKey)) return false;
Fqn parent = fqn.getParent();
if (!fqn.isRoot())
{
@@ -67,13 +74,11 @@
parentStructure.put(fqn.getLastElement(), fqn);
// updateStructure(parent, parentStructure);
}
- NodeKey dataKey = new NodeKey(fqn, NodeKey.Type.DATA);
- NodeKey structureKey = new NodeKey(fqn, NodeKey.Type.STRUCTURE);
- if (cache.containsKey(dataKey) && cache.containsKey(structureKey)) return;
// FastCopyHashMap<Object, Fqn> structure = new FastCopyHashMap<Object, Fqn>();
// cache.put(structureKey, structure);
atomicMapCache.getAtomicMap(structureKey);
atomicMapCache.getAtomicMap(dataKey);
+ return true;
}
finally
{
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/util/Immutables.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/util/Immutables.java 2008-12-02 15:19:49 UTC (rev 7237)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/util/Immutables.java 2008-12-02 15:49:26 UTC (rev 7238)
@@ -21,24 +21,13 @@
*/
package org.jboss.starobrno.util;
-import org.jboss.starobrno.util.FastCopyHashMap;
import org.jboss.cache.util.ImmutableListCopy;
+import org.jboss.starobrno.atomic.AtomicHashMapProxy;
import java.io.Serializable;
import java.lang.reflect.Array;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import java.util.Map.Entry;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.TreeSet;
/**
* Factory for generating immutable type wrappers.
@@ -200,6 +189,8 @@
@SuppressWarnings("unchecked")
private static <T extends Map> T attemptKnownMapCopy(T map)
{
+ if (map instanceof AtomicHashMapProxy)
+ return map; // just a proxy!!
if (map instanceof FastCopyHashMap)
return (T) ((FastCopyHashMap) map).clone();
if (map instanceof HashMap)
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/locks/OwnableReentrantLock.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/locks/OwnableReentrantLock.java 2008-12-02 15:19:49 UTC (rev 7237)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/locks/OwnableReentrantLock.java 2008-12-02 15:49:26 UTC (rev 7238)
@@ -144,7 +144,9 @@
int c = getState() - releases;
if (!currentRequestor().equals(owner))
{
- throw new IllegalMonitorStateException(this.toString());
+ //throw new IllegalMonitorStateException(this.toString());
+ // lets be quiet about this
+ return false;
}
boolean free = false;
if (c == 0)
16 years
JBoss Cache SVN: r7237 - in searchable/trunk: src/main/java/org/jboss/cache/search and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: navssurtani
Date: 2008-12-02 10:19:49 -0500 (Tue, 02 Dec 2008)
New Revision: 7237
Modified:
searchable/trunk/TODO.txt
searchable/trunk/pom.xml
searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIteratorImpl.java
searchable/trunk/src/main/java/org/jboss/cache/search/SearchablePojoListener.java
Log:
Edited TODO
Modified: searchable/trunk/TODO.txt
===================================================================
--- searchable/trunk/TODO.txt 2008-12-02 15:18:48 UTC (rev 7236)
+++ searchable/trunk/TODO.txt 2008-12-02 15:19:49 UTC (rev 7237)
@@ -24,3 +24,5 @@
8. Publish CR4/GA.
By Friday (12 Dec)
+
+//For Later - Get a Version.java to make releasing easier
Modified: searchable/trunk/pom.xml
===================================================================
--- searchable/trunk/pom.xml 2008-12-02 15:18:48 UTC (rev 7236)
+++ searchable/trunk/pom.xml 2008-12-02 15:19:49 UTC (rev 7237)
@@ -25,29 +25,25 @@
<dependency>
<groupId>org.jboss.cache</groupId>
<artifactId>jbosscache-core</artifactId>
- <version>3.0.0.GA</version>
- <!-- TODO: change to 3.0.1.GA ASAP -->
+ <version>3.0.1.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search</artifactId>
- <version>3.1.0.Beta1</version>
- <!-- TODO: change to 3.1.0.GA , or at least a recent CR -->
+ <version>3.1.0.Beta2</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
- <version>1.0.4</version>
- <!-- TODO: change to 1.1.1 ASAP -->
+ <version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.jboss.cache</groupId>
<artifactId>jbosscache-pojo</artifactId>
- <version>2.2.0.CR7</version>
- <!-- TODO: change to 3.0.0.GA ASAP -->
+ <version>3.0.0.GA</version>
</dependency>
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIteratorImpl.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIteratorImpl.java 2008-12-02 15:18:48 UTC (rev 7236)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIteratorImpl.java 2008-12-02 15:19:49 UTC (rev 7237)
@@ -60,6 +60,8 @@
}
this.idList = idList;
+ System.out.println("idList size is " + idList.size());
+ System.out.println("idList object 1 is " + idList.get(0));
this.entityLoader = entityLoader;
upperLimit = idList.size() - 1;
this.fetchSize = fetchSize;
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchablePojoListener.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/SearchablePojoListener.java 2008-12-02 15:18:48 UTC (rev 7236)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchablePojoListener.java 2008-12-02 15:19:49 UTC (rev 7237)
@@ -126,8 +126,10 @@
CacheEntityId cacheEntityId = new CacheEntityId(fqn, pojoKey);
+ System.out.println("new CEI created" + cacheEntityId);
TransactionContext ctx = new PojoTransactionContext(event);
+ System.out.println("new ctx created" + ctx);
searchFactory.getWorker().performWork(new Work(added, cacheEntityId.getDocumentId(), WorkType.ADD), ctx);
}
16 years
JBoss Cache SVN: r7236 - searchable/trunk.
by jbosscache-commits@lists.jboss.org
Author: navssurtani
Date: 2008-12-02 10:18:48 -0500 (Tue, 02 Dec 2008)
New Revision: 7236
Added:
searchable/trunk/release.sh
Log:
Added release.sh
Added: searchable/trunk/release.sh
===================================================================
--- searchable/trunk/release.sh (rev 0)
+++ searchable/trunk/release.sh 2008-12-02 15:18:48 UTC (rev 7236)
@@ -0,0 +1,109 @@
+# Variables
+
+# SVN directory on repo: -
+svnRepo="https://svn.jboss.org/repos/jbosscache/searchable"
+
+# SVN tags on repo: -
+svnTags="tags"
+
+# Local tags dir
+localTags="/Users/Navin/Code/JBossCacheSearchable/tags"
+
+# Local maven2 repo
+localMvn="/Users/Navin/Code/maven2_repo/org/jboss/cache/jbosscache-searchable"
+
+# Docs
+docsDir="/Users/Navin/Code/ReleaseDocs"
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+
+# Functions that will be called
+
+help()
+{
+ echo 'How to use this script'
+ echo
+ echo 'Call $ release.sh <VersionOfJBCS>'
+ echo
+ echo 'Example: - $ release.sh 1.1.1.CR1'
+ echo
+}
+
+validate()
+{
+ if [ ! $ver ]
+ then
+ echo "Missing version number!"
+ help
+ exit 0
+ fi
+
+ if [[ $ver =~ ^[1-9]\.[0-9]\.[0-9]\.(GA|(ALPHA|BETA|CR|SP)[1-9][0-9]?)$ ]]
+ then
+ #matches!
+ echo "Releasing version $ver"
+ else
+ echo "Incorrect version format for version $ver!"
+ help
+ exit 0
+ fi
+ echo "validate() function run ok!"
+}
+
+
+tag()
+{
+ svn cp ${svnRepo}/trunk ${svnRepo}/${svnTags}/$ver -m "JBoss Cache Searchable Release Script: Tagging $ver"
+ cd $localTagsDir
+ svn co ${svnBase}/${svnTags}/$ver
+ cd $ver
+ echo "tag() function run ok!"
+}
+
+build()
+{
+ mvn clean deploy -Dmaven.test.skip.exec=True -PDocs
+ echo "build() function run ok!"
+}
+
+checkIntoRepo()
+{
+ cd $localMvn
+ svn add $ver
+ svn ci -m "JBoss Cache Release Script: Release $ver" $ver
+ echo "checkIntoRepo function run ok!"
+}
+
+docs()
+{
+ cd $docsDir
+ mkdir tempDocs
+ cd tempDocs
+ unzip -a $localMvn/$ver/jbosscache-searchable-$ver-doc.zip
+ mv jbosscache-searchable-$ver/doc ../$ver
+ cd ..
+ rm -rf tmpDocs
+ svn add $ver
+ svn ci -m "JBoss Cache Searchable Release Script: Docs for version $ver" $ver
+ echo "docs() function run ok!"
+
+}
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+
+# Script
+
+ver=${1}
+echo "This is the JBoss Cache Searchable release script"
+validate
+tag
+build
+checkIntoRepo
+docs
+echo 'Done!'
+echo 'Update www.jboss.org about new release'
+echo 'Update wiki'
+echo 'Update blog'
+echo
+
+
Property changes on: searchable/trunk/release.sh
___________________________________________________________________
Name: svn:executable
+ *
16 years
JBoss Cache SVN: r7235 - benchmarks/benchmark-fwk/trunk/cache-products/starobrno/lib.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-12-02 07:50:08 -0500 (Tue, 02 Dec 2008)
New Revision: 7235
Modified:
benchmarks/benchmark-fwk/trunk/cache-products/starobrno/lib/starobrno.jar
Log:
Modified: benchmarks/benchmark-fwk/trunk/cache-products/starobrno/lib/starobrno.jar
===================================================================
(Binary files differ)
16 years
JBoss Cache SVN: r7234 - in core/branches/flat/src: main/java/org/jboss/starobrno/container and 5 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-12-02 07:27:32 -0500 (Tue, 02 Dec 2008)
New Revision: 7234
Modified:
core/branches/flat/src/main/java/org/jboss/starobrno/atomic/AtomicHashMapProxy.java
core/branches/flat/src/main/java/org/jboss/starobrno/container/MVCCEntryCreator.java
core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/LockingInterceptor.java
core/branches/flat/src/main/java/org/jboss/starobrno/tree/TreeStructureSupport.java
core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/locks/OwnableReentrantLock.java
core/branches/flat/src/test/java/org/jboss/starobrno/api/tree/NodeMoveAPITest.java
core/branches/flat/src/test/java/org/jboss/starobrno/profiling/TreeProfileTest.java
Log:
Improved performance of tree struct
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/atomic/AtomicHashMapProxy.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/atomic/AtomicHashMapProxy.java 2008-12-02 11:00:56 UTC (rev 7233)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/atomic/AtomicHashMapProxy.java 2008-12-02 12:27:32 UTC (rev 7234)
@@ -58,11 +58,17 @@
else
{
// acquire WL
- cache.getInvocationContext().getOptionOverrides().setForceWriteLock(true);
+ boolean suppressLocks = cache.getInvocationContext().getOptionOverrides().isSuppressLocking();
+ if (!suppressLocks)
+ {
+ cache.getInvocationContext().getOptionOverrides().setForceWriteLock(true);
+ }
AtomicHashMap map = getDeltaMapForRead();
// copy for write
AtomicHashMap copy = map == null ? new AtomicHashMap() : map.copyForWrite();
copy.initForWriting();
+ // reinstate the option
+ cache.getInvocationContext().getOptionOverrides().setSuppressLocking(suppressLocks);
cache.put(deltaMapKey, copy);
return copy;
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/container/MVCCEntryCreator.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/container/MVCCEntryCreator.java 2008-12-02 11:00:56 UTC (rev 7233)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/container/MVCCEntryCreator.java 2008-12-02 12:27:32 UTC (rev 7234)
@@ -23,13 +23,13 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.starobrno.lock.TimeoutException;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.context.InvocationContext;
import org.jboss.starobrno.factories.EntryFactory;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.factories.annotations.Start;
import org.jboss.starobrno.lock.LockManager;
+import org.jboss.starobrno.lock.TimeoutException;
import org.jboss.starobrno.notifications.Notifier;
/**
@@ -161,7 +161,7 @@
* Attempts to lock a node if the lock isn't already held in the current scope, and records the lock in the context.
*
* @param ctx context
- * @param fqn Fqn to lock
+ * @param key Key to lock
* @return true if a lock was needed and acquired, false if it didn't need to acquire the lock (i.e., lock was already held)
* @throws InterruptedException if interrupted
* @throws org.jboss.starobrno.lock.TimeoutException
@@ -175,8 +175,13 @@
// Better to check our records and lock again if necessary.
if (!ctx.hasLockedKey(key))
{
- if (!lockManager.lockAndRecord(key, ctx))
+ if (ctx.getOptionOverrides().isSuppressLocking())
{
+ // just record this in the ctx and rtn
+ ctx.addKeyLocked(key);
+ }
+ else if (!lockManager.lockAndRecord(key, ctx))
+ {
Object owner = lockManager.getOwner(key);
throw new TimeoutException("Unable to acquire lock on key [" + key + "] after [" + ctx.getLockAcquisitionTimeout(defaultLockAcquisitionTimeout) + "] milliseconds for requestor [" + lockManager.getLockOwner(ctx) + "]! Lock held by [" + owner + "]");
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/LockingInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/LockingInterceptor.java 2008-12-02 11:00:56 UTC (rev 7233)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/LockingInterceptor.java 2008-12-02 12:27:32 UTC (rev 7234)
@@ -29,12 +29,7 @@
import org.jboss.starobrno.commands.tx.CommitCommand;
import org.jboss.starobrno.commands.tx.PrepareCommand;
import org.jboss.starobrno.commands.tx.RollbackCommand;
-import org.jboss.starobrno.commands.write.ClearCommand;
-import org.jboss.starobrno.commands.write.EvictCommand;
-import org.jboss.starobrno.commands.write.PutKeyValueCommand;
-import org.jboss.starobrno.commands.write.PutMapCommand;
-import org.jboss.starobrno.commands.write.RemoveCommand;
-import org.jboss.starobrno.commands.write.ReplaceCommand;
+import org.jboss.starobrno.commands.write.*;
import org.jboss.starobrno.container.DataContainer;
import org.jboss.starobrno.container.MVCCEntry;
import org.jboss.starobrno.container.MVCCEntryCreator;
@@ -80,10 +75,10 @@
@Override
protected boolean doBeforeCall(InvocationContext ctx, VisitableCommand command)
{
- if (ctx.getOptionOverrides().isSuppressLocking())
- {
- if (log.isWarnEnabled()) log.warn("Lock suppression not supported with MVCC!");
- }
+// if (ctx.getOptionOverrides().isSuppressLocking())
+// {
+// if (log.isWarnEnabled()) log.warn("Lock suppression not supported with MVCC!");
+// }
return true;
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/tree/TreeStructureSupport.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/tree/TreeStructureSupport.java 2008-12-02 11:00:56 UTC (rev 7233)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/tree/TreeStructureSupport.java 2008-12-02 12:27:32 UTC (rev 7234)
@@ -60,6 +60,10 @@
{
if (!exists(parent)) createNodeInCache(parent);
AtomicMap<Object, Fqn> parentStructure = getStructure(parent);
+ if (!cache.getConfiguration().isLockParentForChildInsertRemove())
+ {
+ cache.getInvocationContext().getOptionOverrides().setSuppressLocking(true);
+ }
parentStructure.put(fqn.getLastElement(), fqn);
// updateStructure(parent, parentStructure);
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/locks/OwnableReentrantLock.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/locks/OwnableReentrantLock.java 2008-12-02 11:00:56 UTC (rev 7233)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/locks/OwnableReentrantLock.java 2008-12-02 12:27:32 UTC (rev 7234)
@@ -102,7 +102,14 @@
public void unlock()
{
- release(1);
+ try
+ {
+ release(1);
+ }
+ catch (IllegalMonitorStateException imse)
+ {
+ // ignore?
+ }
}
public ConditionObject newCondition()
@@ -136,7 +143,9 @@
{
int c = getState() - releases;
if (!currentRequestor().equals(owner))
+ {
throw new IllegalMonitorStateException(this.toString());
+ }
boolean free = false;
if (c == 0)
{
Modified: core/branches/flat/src/test/java/org/jboss/starobrno/api/tree/NodeMoveAPITest.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/api/tree/NodeMoveAPITest.java 2008-12-02 11:00:56 UTC (rev 7233)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/api/tree/NodeMoveAPITest.java 2008-12-02 12:27:32 UTC (rev 7234)
@@ -584,15 +584,9 @@
{
TreeCache<Object, Object> tree = cacheTL.get();
Cache<Object, Object> cache = tree.getCache();
- ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache);
- LockManager lm = cr.getComponent(LockManager.class);
- InvocationContextContainer icc = cr.getComponent(InvocationContextContainer.class);
-// assert !TreeStructureSupport.isLocked(cache, A);
-// assert !TreeStructureSupport.isLocked(cache, Fqn.ROOT);
-
assert TreeStructureSupport.isLocked(cache, C);
- assert TreeStructureSupport.isLocked(cache, A_B);
+ assert !cache.getConfiguration().isLockParentForChildInsertRemove() || TreeStructureSupport.isLocked(cache, A_B);
assert TreeStructureSupport.isLocked(cache, A_B_C);
}
@@ -600,14 +594,7 @@
{
TreeCache<Object, Object> tree = cacheTL.get();
Cache<Object, Object> cache = tree.getCache();
- ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache);
- LockManager lm = cr.getComponent(LockManager.class);
- InvocationContextContainer icc = cr.getComponent(InvocationContextContainer.class);
-// assert !TreeStructureSupport.isLocked(cache, A);
-// assert !TreeStructureSupport.isLocked(cache, Fqn.ROOT);
-// assert !TreeStructureSupport.isLocked(cache, A_B_D);
-
// /a/b, /c, /c/e, /a/b/c and /a/b/c/e should all be locked.
assert TreeStructureSupport.isLocked(cache, A_B);
assert TreeStructureSupport.isLocked(cache, C);
Modified: core/branches/flat/src/test/java/org/jboss/starobrno/profiling/TreeProfileTest.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/profiling/TreeProfileTest.java 2008-12-02 11:00:56 UTC (rev 7233)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/profiling/TreeProfileTest.java 2008-12-02 12:27:32 UTC (rev 7234)
@@ -42,7 +42,7 @@
/*
Test configuration options
*/
- protected static final long NUM_OPERATIONS = 100000; // DURATION is replaced with a fixed number of operations instead.
+ protected static final long NUM_OPERATIONS = 1000000; // DURATION is replaced with a fixed number of operations instead.
protected static final int NUM_THREADS = 25;
protected static final int MAX_RANDOM_SLEEP_MILLIS = 1;
protected static final int MAX_OVERALL_FQNS = 2000;
16 years
JBoss Cache SVN: r7233 - in core/branches/flat/src: main/java/org/jboss/starobrno/util/concurrent/locks and 3 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-12-02 06:00:56 -0500 (Tue, 02 Dec 2008)
New Revision: 7233
Added:
core/branches/flat/src/test/java/org/jboss/starobrno/api/tree/TreeStructureHashCodeTest.java
core/branches/flat/src/test/java/org/jboss/starobrno/profiling/TreeProfileTest.java
Modified:
core/branches/flat/src/main/java/org/jboss/starobrno/tree/NodeKey.java
core/branches/flat/src/main/java/org/jboss/starobrno/tree/TreeCacheImpl.java
core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/locks/LockContainer.java
core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/locks/OwnableReentrantLockContainer.java
core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/locks/ReentrantLockContainer.java
core/branches/flat/src/test/java/org/jboss/starobrno/lock/LockContainerHashingTest.java
core/branches/flat/src/test/java/org/jboss/starobrno/profiling/ProfileTest.java
Log:
Fixed tree related stuff
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/tree/NodeKey.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/tree/NodeKey.java 2008-12-02 10:45:00 UTC (rev 7232)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/tree/NodeKey.java 2008-12-02 11:00:56 UTC (rev 7233)
@@ -37,7 +37,7 @@
Fqn fqn;
Type contents;
- enum Type
+ public static enum Type
{
DATA, STRUCTURE
}
@@ -63,9 +63,12 @@
public int hashCode()
{
- int hc = (contents != null ? contents.hashCode() : 1);
- hc = 31 * hc + fqn.hashCode();
- return hc;
+ int h = fqn != null ? fqn.hashCode() : 1;
+ h += ~(h << 9);
+ h ^= (h >>> 14);
+ h += (h << 4);
+ h ^= (h >>> 10);
+ return h;
}
public String toString()
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/tree/TreeCacheImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/tree/TreeCacheImpl.java 2008-12-02 10:45:00 UTC (rev 7232)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/tree/TreeCacheImpl.java 2008-12-02 11:00:56 UTC (rev 7233)
@@ -84,7 +84,8 @@
startAtomic();
try
{
- return getNode(fqn).remove(key);
+ Node<K, V> n = getNode(fqn);
+ return n == null ? null : n.remove(key);
}
finally
{
@@ -103,8 +104,8 @@
startAtomic();
try
{
- Node n = getNode(fqn.getParent());
- return n == null ? false : n.removeChild(fqn.getLastElement());
+ Node<K, V> n = getNode(fqn.getParent());
+ return n != null && n.removeChild(fqn.getLastElement());
}
finally
{
@@ -400,7 +401,7 @@
private void createRoot()
{
- createNodeInCache(Fqn.ROOT);
+ if (!exists(Fqn.ROOT)) createNodeInCache(Fqn.ROOT);
}
public String toString()
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/locks/LockContainer.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/locks/LockContainer.java 2008-12-02 10:45:00 UTC (rev 7232)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/locks/LockContainer.java 2008-12-02 11:00:56 UTC (rev 7233)
@@ -68,8 +68,15 @@
final int hash(E object)
{
int h = object.hashCode();
- h ^= (h >>> 20) ^ (h >>> 12);
- return h ^ (h >>> 7) ^ (h >>> 4);
+// h ^= (h >>> 20) ^ (h >>> 12);
+// return h ^ (h >>> 7) ^ (h >>> 4);
+
+ h += ~(h << 9);
+ h ^= (h >>> 14);
+ h += (h << 4);
+ h ^= (h >>> 10);
+ return h;
+
}
protected abstract void initLocks(int numLocks);
@@ -101,6 +108,11 @@
public abstract int getNumLocksHeld();
/**
+ * @return the size of the shared lock pool
+ */
+ public abstract int size();
+
+ /**
* Clears all locks held and re-initialises stripes.
*/
public abstract void reset();
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/locks/OwnableReentrantLockContainer.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/locks/OwnableReentrantLockContainer.java 2008-12-02 10:45:00 UTC (rev 7232)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/locks/OwnableReentrantLockContainer.java 2008-12-02 11:00:56 UTC (rev 7233)
@@ -98,4 +98,9 @@
{
initLocks(sharedLocks.length);
}
+
+ public int size()
+ {
+ return sharedLocks.length;
+ }
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/locks/ReentrantLockContainer.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/locks/ReentrantLockContainer.java 2008-12-02 10:45:00 UTC (rev 7232)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/locks/ReentrantLockContainer.java 2008-12-02 11:00:56 UTC (rev 7233)
@@ -66,6 +66,11 @@
return i;
}
+ public int size()
+ {
+ return sharedLocks.length;
+ }
+
public final boolean ownsLock(E object, Object owner)
{
ReentrantLock lock = getLock(object);
Added: core/branches/flat/src/test/java/org/jboss/starobrno/api/tree/TreeStructureHashCodeTest.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/api/tree/TreeStructureHashCodeTest.java (rev 0)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/api/tree/TreeStructureHashCodeTest.java 2008-12-02 11:00:56 UTC (rev 7233)
@@ -0,0 +1,64 @@
+package org.jboss.starobrno.api.tree;
+
+import org.jboss.starobrno.tree.Fqn;
+import org.jboss.starobrno.tree.NodeKey;
+import org.jboss.starobrno.util.concurrent.locks.LockContainer;
+import org.jboss.starobrno.util.concurrent.locks.ReentrantLockContainer;
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.locks.Lock;
+
+/**
+ * Tests the degree to which hash codes get spread
+ */
+@Test
+public class TreeStructureHashCodeTest
+{
+ public void testHashCodesAppendedCount()
+ {
+ List<Fqn> fqns = new ArrayList<Fqn>();
+ fqns.add(Fqn.ROOT);
+ for (int i = 0; i < 256; i++) fqns.add(Fqn.fromString("/fqn" + i));
+ doTest(fqns);
+ }
+
+ public void testHashCodesAlpha()
+ {
+ List<Fqn> fqns = new ArrayList<Fqn>();
+ fqns.add(Fqn.ROOT);
+ for (int i = 0; i < 256; i++) fqns.add(Fqn.fromString("/" + Integer.toString(i, 36)));
+ doTest(fqns);
+ }
+
+ private void doTest(List<Fqn> fqns)
+ {
+ LockContainer<NodeKey> container = new ReentrantLockContainer<NodeKey>(512);
+ Map<Lock, Integer> distribution = new HashMap<Lock, Integer>();
+ for (Fqn f : fqns)
+ {
+ NodeKey dataKey = new NodeKey(f, NodeKey.Type.DATA);
+ NodeKey structureKey = new NodeKey(f, NodeKey.Type.STRUCTURE);
+ addToDistribution(container.getLock(dataKey), distribution);
+ addToDistribution(container.getLock(structureKey), distribution);
+ }
+
+ System.out.println("Distribution: " + distribution);
+ assert distribution.size() <= container.size() : "Cannot have more locks than the container size!";
+ // assume at least a 2/3rd even distribution
+ // but also consider that data snd structure keys would typically provide the same hash code
+ // so we need to double this
+ assert distribution.size() * 1.5 * 2 >= container.size() : "Poorly distributed! Distribution size is just " + distribution.size() + " and there are " + container.size() + " shared locks";
+
+ }
+
+ private void addToDistribution(Lock lock, Map<Lock, Integer> map)
+ {
+ int count = 1;
+ if (map.containsKey(lock)) count = map.get(lock) + 1;
+ map.put(lock, count);
+ }
+}
Modified: core/branches/flat/src/test/java/org/jboss/starobrno/lock/LockContainerHashingTest.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/lock/LockContainerHashingTest.java 2008-12-02 10:45:00 UTC (rev 7232)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/lock/LockContainerHashingTest.java 2008-12-02 11:00:56 UTC (rev 7233)
@@ -26,11 +26,7 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
+import java.util.*;
import java.util.concurrent.locks.Lock;
@Test(groups = "unit")
@@ -69,10 +65,10 @@
// cannot be larger than the number of locks
System.out.println("dist size: " + distribution.size());
- System.out.println("num shared locks: " + stripedLock.getNumLocksHeld());
- assert distribution.size() <= stripedLock.getNumLocksHeld();
+ System.out.println("num shared locks: " + stripedLock.size());
+ assert distribution.size() <= stripedLock.size();
// assume at least a 2/3rd spread
- assert distribution.size() * 1.5 >= stripedLock.getNumLocksHeld();
+ assert distribution.size() * 1.5 >= stripedLock.size();
}
private List<String> createRandomKeys(int number)
Modified: core/branches/flat/src/test/java/org/jboss/starobrno/profiling/ProfileTest.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/profiling/ProfileTest.java 2008-12-02 10:45:00 UTC (rev 7232)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/profiling/ProfileTest.java 2008-12-02 11:00:56 UTC (rev 7233)
@@ -49,12 +49,12 @@
Log log = LogFactory.getLog(ProfileTest.class);
@Test(enabled = true)
- public void testLocalModePess() throws Exception
+ public void testLocalMode() throws Exception
{
Cache c = (Cache) cache;
c.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
c.getConfiguration().setConcurrencyLevel(2000);
- c.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+ c.getConfiguration().setIsolationLevel(IsolationLevel.READ_COMMITTED);
runCompleteTest();
}
@@ -208,7 +208,7 @@
double nOps = (double) (NUM_OPERATIONS / 3);
double avg = ((double) totalNanos) / nOps;
double avgMicros = avg / 1000;
- return avgMicros + " �s";
+ return avgMicros + " µs";
}
private double toMillis(long nanos)
Copied: core/branches/flat/src/test/java/org/jboss/starobrno/profiling/TreeProfileTest.java (from rev 7228, core/branches/flat/src/test/java/org/jboss/starobrno/profiling/ProfileTest.java)
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/profiling/TreeProfileTest.java (rev 0)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/profiling/TreeProfileTest.java 2008-12-02 11:00:56 UTC (rev 7233)
@@ -0,0 +1,338 @@
+package org.jboss.starobrno.profiling;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.lock.IsolationLevel;
+import org.jboss.starobrno.Cache;
+import org.jboss.starobrno.UnitTestCacheFactory;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.tree.Fqn;
+import org.jboss.starobrno.tree.TreeCache;
+import org.jboss.starobrno.tree.TreeCacheImpl;
+import org.jboss.starobrno.util.TestingUtil;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * Test to use with a profiler to profile replication. To be used in conjunction with ProfileSlaveTest.
+ * <p/>
+ * Typical usage pattern:
+ * <p/>
+ * 1. Start a single test method in ProfileSlaveTest. This will block until you kill it.
+ * 2. Start the corresponding test in this class, with the same name, in a different JVM, and attached to a profiler.
+ * 3. Profile away!
+ * <p/>
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 2.1.0
+ */
+@Test(groups = "profiling", sequential = true)
+public class TreeProfileTest
+{
+ /*
+ Test configuration options
+ */
+ protected static final long NUM_OPERATIONS = 100000; // DURATION is replaced with a fixed number of operations instead.
+ protected static final int NUM_THREADS = 25;
+ protected static final int MAX_RANDOM_SLEEP_MILLIS = 1;
+ protected static final int MAX_OVERALL_FQNS = 2000;
+ protected static final int TREE_DEPTH = 2;
+ protected static final int WARMUP_LOOPS = 20000;
+ protected static final boolean USE_SLEEP = false; // throttle generation a bit
+
+ protected TreeCache cache;
+
+ @BeforeTest
+ public void setUp()
+ {
+ Configuration cfg = new Configuration();
+ cfg.setInvocationBatchingEnabled(true);
+ cfg.setCacheMode(Configuration.CacheMode.LOCAL);
+ cfg.setConcurrencyLevel(2000);
+ cfg.setLockAcquisitionTimeout(60000);
+ cfg.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+ Cache c = new UnitTestCacheFactory().createCache(cfg);
+ cache = new TreeCacheImpl(c);
+ }
+
+ @AfterTest
+ public void tearDown()
+ {
+ TestingUtil.killTreeCaches(cache);
+ cache = null;
+ }
+
+ private List<Fqn> fqns = new ArrayList<Fqn>(MAX_OVERALL_FQNS);
+ private Random r = new Random();
+
+ Log log = LogFactory.getLog(TreeProfileTest.class);
+
+ @Test(enabled = true)
+ public void testLocalMode() throws Exception
+ {
+ runCompleteTest();
+ }
+
+ private void runCompleteTest() throws Exception
+ {
+ init();
+ startup();
+ warmup();
+ doTest();
+
+ // wait for user exit
+ System.in.read();
+ }
+
+ /**
+ * Thr following test phases can be profiled individually using triggers in JProfiler.
+ */
+
+ protected void init()
+ {
+ long startTime = System.currentTimeMillis();
+ log.warn("Starting init() phase");
+ fqns.clear();
+ for (int i = 0; i < MAX_OVERALL_FQNS; i++)
+ {
+ Fqn fqn = createRandomFqn(r);
+ while (fqns.contains(fqn)) fqn = createRandomFqn(r);
+ if (i % 100 == 0)
+ {
+ log.warn("Generated " + i + " fqns");
+ }
+ fqns.add(fqn);
+ }
+ System.gc();
+ long duration = System.currentTimeMillis() - startTime;
+ log.warn("Finished init() phase. " + printDuration(duration));
+ }
+
+ private Fqn createRandomFqn(Random r)
+ {
+ List<String> fqnElements = new ArrayList<String>(TREE_DEPTH);
+ for (int i = 0; i < TREE_DEPTH; i++) fqnElements.add(Integer.toHexString(r.nextInt(Integer.MAX_VALUE)));
+ return Fqn.fromList(fqnElements, true);
+ }
+
+
+ protected void startup()
+ {
+ long startTime = System.currentTimeMillis();
+ log.warn("Starting cache");
+ cache.start();
+ long duration = System.currentTimeMillis() - startTime;
+ log.warn("Started cache. " + printDuration(duration));
+ }
+
+ private void warmup() throws InterruptedException
+ {
+ long startTime = System.currentTimeMillis();
+ ExecutorService exec = Executors.newFixedThreadPool(NUM_THREADS);
+ log.warn("Starting warmup");
+ // creates all the Fqns since this can be expensive and we don't really want to measure this (for now)
+ for (final Fqn fqn : fqns)
+ {
+ exec.execute(new Runnable()
+ {
+ public void run()
+ {
+ // this will create the necessary nodes.
+ cache.put(fqn, "key", Collections.emptyMap());
+ }
+ });
+ }
+
+ // loop through WARMUP_LOOPS gets and puts for JVM optimisation
+ for (int i = 0; i < WARMUP_LOOPS; i++)
+ {
+ exec.execute(new Runnable()
+ {
+ public void run()
+ {
+ Fqn fqn = fqns.get(r.nextInt(MAX_OVERALL_FQNS));
+ cache.get(fqn, "key");
+ cache.put(fqn, "key", "Value");
+ cache.remove(fqn, "key");
+ }
+ });
+ }
+
+ exec.shutdown();
+ exec.awaitTermination(360, TimeUnit.SECONDS);
+
+ long duration = System.currentTimeMillis() - startTime;
+ log.warn("Finished warmup. " + printDuration(duration));
+ //cache.removeNode(Fqn.ROOT);
+ cache.stop();
+
+ startup();
+ }
+
+ private void doTest() throws Exception
+ {
+ ExecutorService exec = Executors.newFixedThreadPool(NUM_THREADS);
+ log.warn("Starting test");
+ int i;
+ long print = NUM_OPERATIONS / 10;
+
+ AtomicLong durationPuts = new AtomicLong();
+ AtomicLong durationGets = new AtomicLong();
+ AtomicLong durationRemoves = new AtomicLong();
+
+ long stElapsed = System.nanoTime();
+ for (i = 0; i < NUM_OPERATIONS; i++)
+ {
+ MyRunnable r = null;
+ switch (i % 3)
+ {
+ case 0:
+ r = new Putter(i, durationPuts);
+ break;
+ case 1:
+ r = new Getter(i, durationGets);
+ break;
+ case 2:
+ r = new Remover(i, durationRemoves);
+ break;
+ }
+ if (i % print == 0)
+ log.warn("processing iteration " + i);
+ exec.execute(r);
+// if (USE_SLEEP) TestingUtil.sleepRandom(MAX_RANDOM_SLEEP_MILLIS);
+ if (USE_SLEEP) TestingUtil.sleepThread(MAX_RANDOM_SLEEP_MILLIS);
+ }
+ log.warn("Finished generating runnables; awaiting executor completion");
+ // wait for executors to complete!
+ exec.shutdown();
+ while (!exec.awaitTermination(((long) i), TimeUnit.SECONDS))
+ {
+ Thread.sleep(1);
+ }
+
+ // wait up to 1 sec for each call?
+ long elapsedTimeNanos = System.nanoTime() - stElapsed;
+
+ log.warn("Finished test. " + printDuration((long) toMillis(elapsedTimeNanos)));
+ log.warn("Throughput: " + ((double) NUM_OPERATIONS * 1000 / toMillis(elapsedTimeNanos)) + " operations per second (roughly equal numbers of PUT, GET and REMOVE)");
+ log.warn("Average GET time: " + printAvg(durationGets.get()));
+ log.warn("Average PUT time: " + printAvg(durationPuts.get()));
+ log.warn("Average REMOVE time: " + printAvg(durationRemoves.get()));
+ }
+
+ private String printAvg(long totalNanos)
+ {
+ double nOps = (double) (NUM_OPERATIONS / 3);
+ double avg = ((double) totalNanos) / nOps;
+ double avgMicros = avg / 1000;
+ return avgMicros + " µs";
+ }
+
+ private double toMillis(long nanos)
+ {
+ return ((double) nanos / (double) 1000000);
+ }
+
+ enum Mode
+ {
+ PUT, GET, REMOVE
+ }
+
+ private abstract class MyRunnable implements Runnable
+ {
+ int id;
+ Mode mode;
+ AtomicLong duration;
+
+ public void run()
+ {
+ Fqn fqn = fqns.get(r.nextInt(MAX_OVERALL_FQNS));
+ long d = 0, st = 0;
+ switch (mode)
+ {
+ case PUT:
+ Object value = getRandomString();
+ st = System.nanoTime();
+ cache.put(fqn, "key", value);
+ d = System.nanoTime() - st;
+ break;
+ case GET:
+ st = System.nanoTime();
+ cache.get(fqn, "key");
+ d = System.nanoTime() - st;
+ break;
+ case REMOVE:
+ st = System.nanoTime();
+ cache.remove(fqn, "key");
+ d = System.nanoTime() - st;
+ break;
+ }
+ duration.getAndAdd(d);
+ }
+ }
+
+ private class Putter extends MyRunnable
+ {
+ private Putter(int id, AtomicLong duration)
+ {
+ this.id = id;
+ this.duration = duration;
+ mode = Mode.PUT;
+ }
+ }
+
+ private class Getter extends MyRunnable
+ {
+ private Getter(int id, AtomicLong duration)
+ {
+ this.id = id;
+ this.duration = duration;
+ mode = Mode.GET;
+ }
+ }
+
+ private class Remover extends MyRunnable
+ {
+ private Remover(int id, AtomicLong duration)
+ {
+ this.id = id;
+ this.duration = duration;
+ mode = Mode.REMOVE;
+ }
+ }
+
+ private String getRandomString()
+ {
+ StringBuilder sb = new StringBuilder();
+ int len = r.nextInt(10);
+
+ for (int i = 0; i < len; i++)
+ {
+ sb.append((char) (63 + r.nextInt(26)));
+ }
+ return sb.toString();
+ }
+
+ protected String printDuration(long duration)
+ {
+ if (duration > 2000)
+ {
+ double dSecs = ((double) duration / (double) 1000);
+ return "Duration: " + dSecs + " seconds";
+ }
+ else
+ {
+ return "Duration: " + duration + " millis";
+ }
+ }
+}
\ No newline at end of file
Property changes on: core/branches/flat/src/test/java/org/jboss/starobrno/profiling/TreeProfileTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
16 years
JBoss Cache SVN: r7232 - in searchable/trunk/src: test/java/org/jboss/cache/search/blackbox and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: navssurtani
Date: 2008-12-02 05:45:00 -0500 (Tue, 02 Dec 2008)
New Revision: 7232
Modified:
searchable/trunk/src/main/java/org/jboss/cache/search/SearchablePojoListener.java
searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalPOJOCacheTest.java
Log:
Only null objects are being put into the lists, iterators etc for pojo
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchablePojoListener.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/SearchablePojoListener.java 2008-12-02 10:00:49 UTC (rev 7231)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchablePojoListener.java 2008-12-02 10:45:00 UTC (rev 7232)
@@ -67,33 +67,35 @@
@NodeModified
public void handleNodeModified(NodeModifiedEvent nme)
{
- if (!nme.isPre()) return;
- Fqn f = nme.getFqn();
- System.out.println("Node modified called for Fqn " + f);
- if (InternalHelper.isInternalNode(f))
- {
- System.out.println("Is internal and I dont care");
- }
- else
- {
- savedFqn.set(f);
- }
+ if (!nme.isPre()) return;
+ Fqn f = nme.getFqn();
+ if(log.isDebugEnabled()) log.debug("Node modified called for Fqn " + f);
+ if (InternalHelper.isInternalNode(f))
+ {
+ if(log.isDebugEnabled()) log.debug("Is internal and I dont care");
+ }
+ else
+ {
+ savedFqn.set(f);
+ if(log.isDebugEnabled()) log.debug("Saved Fqn to ThreadLocal.");
+ }
}
- @NodeCreated
+ @NodeCreated
public void handleNodeKreated(NodeCreatedEvent nce)
{
- if (!nce.isPre()) return;
- Fqn f = nce.getFqn();
- System.out.println("Node kreated called for Fqn " + f);
- if (InternalHelper.isInternalNode(f))
- {
- System.out.println("Is internal and I dont care");
- }
- else
- {
- savedFqn.set(f);
- }
+ if (!nce.isPre()) return;
+ Fqn f = nce.getFqn();
+ if(log.isDebugEnabled()) log.debug("Node kreated called for Fqn " + f);
+ if (InternalHelper.isInternalNode(f))
+ {
+ if(log.isDebugEnabled()) log.debug("Is internal and I dont care");
+ }
+ else
+ {
+ savedFqn.set(f);
+ if(log.isDebugEnabled()) log.debug("savedFqn.set() called");
+ }
}
/**
@@ -118,8 +120,8 @@
System.out.println("pojo is " + pojo);
// Fqn fqn = pojo.getInternalFqn(added);
- Fqn fqn = savedFqn.get();
- savedFqn.remove();
+ Fqn fqn = savedFqn.get();
+ savedFqn.remove();
System.out.println("Fqn is " + fqn);
@@ -131,7 +133,7 @@
}
@Detached
- public void handleDetach (DetachedEvent event) throws InvalidKeyException
+ public void handleDetach(DetachedEvent event) throws InvalidKeyException
{
Object deleted = event.getSource();
Fqn fqn = event.getContext().getPojoCache().getInternalFqn(deleted);
@@ -143,7 +145,6 @@
searchFactory.getWorker().performWork(new Work(deleted, cacheEntityId.getDocumentId(), WorkType.DELETE), ctx);
}
-
//TODO: Sort out updating Lucene for the following annotations: -
// @FieldModified
// @ListModified
Modified: searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalPOJOCacheTest.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalPOJOCacheTest.java 2008-12-02 10:00:49 UTC (rev 7231)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalPOJOCacheTest.java 2008-12-02 10:45:00 UTC (rev 7232)
@@ -13,6 +13,7 @@
import org.jboss.cache.search.CacheQuery;
import org.jboss.cache.search.SearchableCache;
import org.jboss.cache.search.SearchableCacheFactory;
+import org.jboss.cache.search.QueryResultIterator;
import org.jboss.cache.search.helper.IndexCleanUp;
import org.jboss.cache.search.test.Person;
import org.testng.annotations.AfterMethod;
@@ -20,6 +21,7 @@
import org.testng.annotations.Test;
import java.util.List;
+import java.util.Iterator;
/**
* Same as LocalCacheTest except that you will use a POJO Cache instead and use pojoCache.attach() ad pojoCache.detach()
@@ -67,7 +69,7 @@
pojo.attach("/a/b/c", person1);
pojo.attach("/a/b/d", person2);
- pojo.attach("/a/b/c", person3);
+ pojo.attach("/c/a/t", person3);
}
@@ -86,8 +88,9 @@
luceneQuery = queryParser.parse("playing");
cacheQuery = searchableCache.createQuery(luceneQuery);
- found = cacheQuery.list();
-
+ QueryResultIterator found = cacheQuery.iterator();
+ found.first();
+ System.out.println("First object is " + found.next());
}
public void testMultipleResults() throws ParseException
@@ -97,7 +100,11 @@
cacheQuery = searchableCache.createQuery(luceneQuery);
found = cacheQuery.list();
+ System.out.println("size is " + found.size());
assert found.size() == 2;
+
+ System.out.println("object 0 is " + found.get(0));
+ System.out.println("object 1 is " + found.get(1));
assert !found.get(1).equals(person2);
assert !found.get(0).equals(person3);
16 years
JBoss Cache SVN: r7231 - benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/lib.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-12-02 05:00:49 -0500 (Tue, 02 Dec 2008)
New Revision: 7231
Modified:
benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/lib/jbosscache-core.jar
Log:
Updated to 3.0.1.GA
Modified: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/lib/jbosscache-core.jar
===================================================================
(Binary files differ)
16 years