Revision: 17942
Author:   emmartins
Date:     Sun Apr 17 08:05:48 2011
Log:      minor child sbb entity creation/retrieval fixes
http://code.google.com/p/mobicents/source/detail?r=17942

Modified:
/trunk/servers/jain-slee/core/router/src/main/java/org/mobicents/slee/runtime/eventrouter/routingtask/HandleSbbRollback.java /trunk/servers/jain-slee/core/services/src/main/java/org/mobicents/slee/runtime/sbbentity/ChildRelationImpl.java /trunk/servers/jain-slee/core/services/src/main/java/org/mobicents/slee/runtime/sbbentity/NonRootSbbEntityID.java /trunk/servers/jain-slee/core/services/src/main/java/org/mobicents/slee/runtime/sbbentity/SbbEntityFactoryImpl.java

=======================================
--- /trunk/servers/jain-slee/core/router/src/main/java/org/mobicents/slee/runtime/eventrouter/routingtask/HandleSbbRollback.java Thu Apr 14 05:41:03 2011 +++ /trunk/servers/jain-slee/core/router/src/main/java/org/mobicents/slee/runtime/eventrouter/routingtask/HandleSbbRollback.java Sun Apr 17 08:05:48 2011
@@ -86,6 +86,8 @@
sbbEntityReloaded = sleeContainer.getSbbEntityFactory().createRootSbbEntity(sbbEntityID.getServiceID(), sbbEntityID.getServiceConvergenceName());
                                        }
                                        else {
+                                               // load the parent first to get 
lock
+ sleeContainer.getSbbEntityFactory().getSbbEntity(sbbEntityID.getParentSBBEntityID(),true); sbbEntityReloaded = sleeContainer.getSbbEntityFactory().createNonRootSbbEntity(sbbEntityID.getParentSBBEntityID(),sbbEntityID.getParentChildRelation(),sbbEntityID.getName());
                                        }
                                        
sbbEntityReloaded.setPriority(sbbEntity.getPriority());
=======================================
--- /trunk/servers/jain-slee/core/services/src/main/java/org/mobicents/slee/runtime/sbbentity/ChildRelationImpl.java Fri Apr 15 18:54:57 2011 +++ /trunk/servers/jain-slee/core/services/src/main/java/org/mobicents/slee/runtime/sbbentity/ChildRelationImpl.java Sun Apr 17 08:05:48 2011
@@ -414,6 +414,9 @@
                        IllegalArgumentException, NullPointerException,
                        TransactionRequiredLocalException, SLEEException {

+               if (logger.isDebugEnabled())
+ logger.debug("Creating child "+childName+" from relation "+getChildRelationMethod.getChildRelationMethodName()+" of entity "+sbbEntity.getSbbEntityId());
+
                validateChildName(childName);

                SleeTransactionManager sleeTransactionManager = sleeContainer
@@ -427,7 +430,7 @@
                                                childName);

                if (logger.isDebugEnabled())
-                       logger.debug("ChildRelation.create() : Created Sbb Entity: 
"
+                       logger.debug("Created child Sbb Entity: "
                                        + childSbbEntity.getSbbEntityId());

                
childSbbEntity.setPriority(getChildRelationMethod.getDefaultPriority());
@@ -492,6 +495,9 @@
                        throws IllegalArgumentException, NullPointerException,
                        TransactionRequiredLocalException, SLEEException {

+               if (logger.isTraceEnabled())
+ logger.trace("Retreiving child "+childName+" from relation "+getChildRelationMethod.getChildRelationMethodName()+" of entity "+sbbEntity.getSbbEntityId());
+
                validateChildName(childName);

                SleeTransactionManager sleeTransactionManager = sleeContainer
@@ -506,6 +512,10 @@
                                                                                
.getChildRelationMethodName(),
                                                                childName), 
false);

+               if (logger.isDebugEnabled())
+ logger.debug("Retrieved child "+childName+" from relation "+getChildRelationMethod.getChildRelationMethodName()+" of entity "+sbbEntity.getSbbEntityId()+" -> "+childSbbEntity);
+
+
                return childSbbEntity == null ? null : childSbbEntity
                                .getSbbLocalObject();
        }
=======================================
--- /trunk/servers/jain-slee/core/services/src/main/java/org/mobicents/slee/runtime/sbbentity/NonRootSbbEntityID.java Thu Apr 14 05:41:03 2011 +++ /trunk/servers/jain-slee/core/services/src/main/java/org/mobicents/slee/runtime/sbbentity/NonRootSbbEntityID.java Sun Apr 17 08:05:48 2011
@@ -74,8 +74,8 @@
        @Override
        public int hashCode() {
                int result = childID.hashCode();
-               //result = result*31 + parentChildRelation.hashCode();
-               //result = result*31 + parentSbbEntityID.hashCode();
+               result = result*31 + parentChildRelation.hashCode();
+               result = result*31 + parentSbbEntityID.hashCode();
                return result;
        }

@@ -88,12 +88,12 @@
                if (getClass() != obj.getClass())
                        return false;
                final NonRootSbbEntityID other = (NonRootSbbEntityID) obj;
-               if (!childID.equals(other.childID))
+               if (!parentSbbEntityID.equals(other.parentSbbEntityID))
                        return false;
-               /*if (!parentChildRelation.equals(other.parentChildRelation))
+               if (!parentChildRelation.equals(other.parentChildRelation))
                        return false;
-               if (!parentSbbEntityID.equals(other.parentSbbEntityID))
-                       return false;*/
+               if (!childID.equals(other.childID))
+                       return false;
                return true;
        }

=======================================
--- /trunk/servers/jain-slee/core/services/src/main/java/org/mobicents/slee/runtime/sbbentity/SbbEntityFactoryImpl.java Thu Apr 14 05:41:03 2011 +++ /trunk/servers/jain-slee/core/services/src/main/java/org/mobicents/slee/runtime/sbbentity/SbbEntityFactoryImpl.java Sun Apr 17 08:05:48 2011
@@ -51,14 +51,9 @@

        @Override
public SbbEntity createNonRootSbbEntity(SbbEntityID parentSbbEntityID,String parentChildRelation, String childName) throws CreateException {
-
- final TransactionContext txContext = sleeContainer.getTransactionManager().getTransactionContext();
-
-               // get lock
- final ReentrantLock lock = lockFacility.get(parentSbbEntityID.getRootSBBEntityID());
-               lockOrFail(lock,parentSbbEntityID.getRootSBBEntityID());
-               // we hold the lock now
-
+
+ // it is assumed that parent root sbb entity is loaded, thus no lock needed
+
                // create sbb entity
final NonRootSbbEntityID sbbeId = new NonRootSbbEntityID(parentSbbEntityID, parentChildRelation, childName); final SbbEntityCacheData cacheData = new SbbEntityCacheData(sbbeId,sleeContainer.getCluster().getMobicentsCache());
@@ -71,17 +66,7 @@

                // store it in the tx, we need to do it due to sbb local object 
and
                // current storing in sbb entity per tx
-               storeSbbEntityInTx(sbbEntity, txContext);
-
-               // add tx actions to unlock root when the tx ends
-               final TransactionalAction txAction = new TransactionalAction() {
-                       @Override
-                       public void execute() {
-                               lock.unlock();
-                       }
-               };
-               txContext.getAfterRollbackActions().add(txAction);
-               txContext.getAfterCommitActions().add(txAction);
+ storeSbbEntityInTx(sbbEntity, sleeContainer.getTransactionManager().getTransactionContext());

                return sbbEntity;

@@ -192,9 +177,11 @@

                        // get sbb entity data from cache
final SbbEntityCacheData cacheData = new SbbEntityCacheData(sbbeId,sleeContainer.getCluster().getMobicentsCache());
-                       if (!cacheData.exists() && lock != null) {
-                               lockFacility.remove(lockedSbbEntityID);
-                               lock.unlock();
+                       if (!cacheData.exists()) {
+                               if(lock != null) {
+                                       lockFacility.remove(lockedSbbEntityID);
+                                       lock.unlock();
+                               }
                                return null;
                        }

Reply via email to