[jboss-cvs] JBossCache/src-50/org/jboss/cache/pojo/impl ...
Ben Wang
bwang at jboss.com
Fri Dec 29 21:53:07 EST 2006
User: bwang
Date: 06/12/29 21:53:07
Modified: src-50/org/jboss/cache/pojo/impl PojoCacheDelegate.java
Log:
JBCACHE-919 Optimize __JBossInternal__ access.
Revision Changes Path
1.17 +33 -5 JBossCache/src-50/org/jboss/cache/pojo/impl/PojoCacheDelegate.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: PojoCacheDelegate.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src-50/org/jboss/cache/pojo/impl/PojoCacheDelegate.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- PojoCacheDelegate.java 13 Oct 2006 10:30:24 -0000 1.16
+++ PojoCacheDelegate.java 30 Dec 2006 02:53:07 -0000 1.17
@@ -18,6 +18,7 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Node;
import org.jboss.cache.Cache;
+import org.jboss.cache.config.Option;
import org.jboss.cache.pojo.interceptors.dynamic.AbstractCollectionInterceptor;
import org.jboss.cache.pojo.memory.FieldPersistentReference;
import org.jboss.cache.pojo.util.AopUtil;
@@ -155,7 +156,12 @@
}
// This create a PojoReference to store a pointer to the real fqn.
- Fqn internalFqn = createPojoReference(fqn, obj);
+ Fqn internalFqn = createInternalFqn(fqn, obj);
+ setPojoReference(fqn, obj, internalFqn);
+ // creates the internal node first without going thru the interceptor.
+ // This way we don't block on __JBossInternal__ node.
+ createChildNodeFirstWithoutLocking(internalFqn);
+
if (log.isDebugEnabled())
{
log.debug("putObject(): id: " + fqn + " will store the pojo in the internal area: "
@@ -182,15 +188,20 @@
return oldValue;
}
- Fqn createPojoReference(Fqn fqn, Object obj) throws CacheException
+ Fqn createInternalFqn(Fqn fqn, Object obj) throws CacheException
+ {
+ // Create an internal Fqn name
+ Fqn internalFqn = AopUtil.createInternalFqn(fqn, (Cache)cache_);
+ return internalFqn;
+ }
+
+ Fqn setPojoReference(Fqn fqn, Object obj, Fqn internalFqn) throws CacheException
{
// Create PojoReference
CachedType type = pCache_.getCachedType(obj.getClass());
PojoReference pojoReference = new PojoReference();
pojoReference.setPojoClass(type.getType());
- // Create an internal Fqn name
- Fqn internalFqn = AopUtil.createInternalFqn(fqn, (Cache)cache_);
// store PojoReference
pojoReference.setFqn(internalFqn);
internal_.putPojoReference(fqn, pojoReference);
@@ -202,6 +213,22 @@
return internalFqn;
}
+ private void createChildNodeFirstWithoutLocking(Fqn internalFqn)
+ {
+ int size = internalFqn.size();
+ Fqn f = internalFqn.getFqnChild(0, size-1);
+ Fqn child = internalFqn.getFqnChild(size-1, size);
+ Node base = cache_.getRoot().getChild(f);
+ if(base == null)
+ {
+ log.debug("The node retrieved is null from fqn: " +f);
+ return;
+ }
+ Option option = cache_.getInvocationContext().getOptionOverrides();
+ option.setBypassInterceptorChain(true);
+ base.addChild(child);
+ }
+
/**
* Note that caller of this method will take care of synchronization within the <code>fqn</code> sub-tree.
*
@@ -308,7 +335,8 @@
PojoInstance pojoInstance = internal_.getAopInstance(internalFqn);
if (pojoInstance == null)
{
- throw new RuntimeException("PojoCacheDelegate.getObjectInternal(): null PojoInstance.");
+ throw new RuntimeException("PojoCacheDelegate.getObjectInternal(): null PojoInstance for fqn: " +
+ internalFqn);
}
// Check for both Advised and Collection classes for object graph.
More information about the jboss-cvs-commits
mailing list