Revision: 15680
Author: [email protected]
Date: Wed Dec  8 10:09:53 2010
Log: Update Issue 1875

Fixing memory leak issue in the cache by converting to lower case early and replicating only INVITE client tx
http://code.google.com/p/mobicents/source/detail?r=15680

Modified:
/trunk/servers/jain-sip-ha/core/src/main/java/gov/nist/javax/sip/stack/MobicentsHASIPClientTransaction.java /trunk/servers/jain-sip-ha/core/src/main/java/org/mobicents/ha/javax/sip/ClusteredSipStackImpl.java /trunk/servers/jain-sip-ha/jboss-5/src/main/java/org/mobicents/ha/javax/sip/cache/ClientTransactionCacheData.java /trunk/servers/jain-sip-ha/jboss-5/src/main/java/org/mobicents/ha/javax/sip/cache/ServerTransactionCacheData.java

=======================================
--- /trunk/servers/jain-sip-ha/core/src/main/java/gov/nist/javax/sip/stack/MobicentsHASIPClientTransaction.java Mon Dec 6 10:09:13 2010 +++ /trunk/servers/jain-sip-ha/core/src/main/java/gov/nist/javax/sip/stack/MobicentsHASIPClientTransaction.java Wed Dec 8 10:09:53 2010
@@ -112,7 +112,7 @@
        @Override
        public void setState(int newState) {
                super.setState(newState);
- if(newState == TransactionState._TRYING || newState == TransactionState._PROCEEDING && Request.INVITE.equalsIgnoreCase(getMethod()) && lastResponse == null || (lastResponse != null && lastResponseStatusCode < lastResponse.getStatusCode())) { + if(Request.INVITE.equalsIgnoreCase(getMethod()) && (newState == TransactionState._TRYING || newState == TransactionState._PROCEEDING) && (lastResponse == null || (lastResponse != null && lastResponseStatusCode < lastResponse.getStatusCode()))) {
                        if(lastResponse != null) {
                                this.localDialogId = 
lastResponse.getDialogId(false);
                                if 
(logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
=======================================
--- /trunk/servers/jain-sip-ha/core/src/main/java/org/mobicents/ha/javax/sip/ClusteredSipStackImpl.java Mon Dec 6 10:09:13 2010 +++ /trunk/servers/jain-sip-ha/core/src/main/java/org/mobicents/ha/javax/sip/ClusteredSipStackImpl.java Wed Dec 8 10:09:53 2010
@@ -436,53 +436,54 @@
         */
        @Override
public SIPTransaction findTransaction(String transactionId, boolean isServer) { - SIPTransaction sipTransaction = super.findTransaction(transactionId, isServer);
+               final String txId = transactionId.toLowerCase();
+               SIPTransaction sipTransaction = super.findTransaction(txId, 
isServer);
if(sipTransaction == null && transactionFactory != null && replicationStrategy == ReplicationStrategy.EarlyDialog) {
                        
if(getStackLogger().isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
- getStackLogger().logDebug("local transaction " + transactionId + " server = " + isServer + " is null, checking in the distributed cache"); + getStackLogger().logDebug("local transaction " + txId + " server = " + isServer + " is null, checking in the distributed cache");
                        }
                        
if(getStackLogger().isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
- getStackLogger().logDebug("sipStack " + this + " checking if the transaction " + transactionId + " server = " + isServer + " is present in the distributed cache"); + getStackLogger().logDebug("sipStack " + this + " checking if the transaction " + txId + " server = " + isServer + " is present in the distributed cache");
                        }
                        if(isServer) {
                                // fetch the corresponding server transaction 
from the cache instance
                                try {
-                                       sipTransaction = 
sipCache.getServerTransaction(transactionId);
+                                       sipTransaction = 
sipCache.getServerTransaction(txId);
                                        if(sipTransaction != null) {
                                                
if(getStackLogger().isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
- getStackLogger().logDebug("sipStack " + this + " transaction " + transactionId + " server = " + isServer + " is present in the distributed cache");
-                                               }
- SIPServerTransaction retval = serverTransactionTable.putIfAbsent(sipTransaction.getTransactionId(), (SIPServerTransaction) sipTransaction); + getStackLogger().logDebug("sipStack " + this + " transaction " + txId + " server = " + isServer + " is present in the distributed cache");
+                                               }
+ SIPServerTransaction retval = serverTransactionTable.putIfAbsent(txId, (SIPServerTransaction) sipTransaction);
                                                if(retval != null) {
                                                        sipTransaction = retval;
                                                }
                                        } else {
                                                
if(getStackLogger().isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
- getStackLogger().logDebug("sipStack " + this + " transaction " + transactionId + " server = " + isServer + " is not present in the distributed cache"); + getStackLogger().logDebug("sipStack " + this + " transaction " + txId + " server = " + isServer + " is not present in the distributed cache");
                                                }
                                        }
                                } catch (SipCacheException e) {
- getStackLogger().logError("sipStack " + this + " problem getting transaction " + transactionId + " server = " + isServer + " from the distributed cache", e); + getStackLogger().logError("sipStack " + this + " problem getting transaction " + txId + " server = " + isServer + " from the distributed cache", e);
                                }
                        } else {
                                // fetch the corresponding client transaction 
from the cache instance
                                try {
-                                       sipTransaction = 
sipCache.getClientTransaction(transactionId);
+                                       sipTransaction = 
sipCache.getClientTransaction(txId);
                                        if(sipTransaction != null) {
                                                
if(getStackLogger().isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
- getStackLogger().logDebug("sipStack " + this + " transaction " + transactionId + " server = " + isServer + " is present in the distributed cache");
-                                               }
- SIPClientTransaction retval = clientTransactionTable.putIfAbsent(transactionId, (SIPClientTransaction) sipTransaction); + getStackLogger().logDebug("sipStack " + this + " transaction " + txId + " server = " + isServer + " is present in the distributed cache");
+                                               }
+ SIPClientTransaction retval = clientTransactionTable.putIfAbsent(txId, (SIPClientTransaction) sipTransaction);
                                                if(retval != null) {
                                                        sipTransaction = retval;
                                                }
                                        } else {
                                                
if(getStackLogger().isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
- getStackLogger().logDebug("sipStack " + this + " transaction " + transactionId + " server = " + isServer + " is not present in the distributed cache"); + getStackLogger().logDebug("sipStack " + this + " transaction " + txId + " server = " + isServer + " is not present in the distributed cache");
                                                }
                                        }
                                } catch (SipCacheException e) {
- getStackLogger().logError("sipStack " + this + " problem getting transaction " + transactionId + " server = " + isServer + " from the distributed cache", e); + getStackLogger().logError("sipStack " + this + " problem getting transaction " + txId + " server = " + isServer + " from the distributed cache", e);
                                }
                        }
                }
@@ -625,14 +626,15 @@
* @see org.mobicents.ha.javax.sip.ClusteredSipStack#remoteServerTransactionRemoval(java.lang.String)
         */
        public void remoteServerTransactionRemoval(String transactionId) {
+               final String txId = transactionId.toLowerCase();
// note we don't want a dialog terminated event, thus we need to go directly to map removal // assuming it's a confirmed dialog there is no chance it is on early dialogs too
                if (getStackLogger().isLoggingEnabled(StackLogger.TRACE_DEBUG)) 
{
                        getStackLogger().logDebug("sipStack " + this +
- " remote Server Transaction Removal of transaction Id : " + transactionId);
+                                       " remote Server Transaction Removal of 
transaction Id : " + txId);
                }
// the transaction id is set to lower case in the cache so it might not remove it correctly - SIPServerTransaction sipServerTransaction = super.serverTransactionTable.remove(transactionId); + SIPServerTransaction sipServerTransaction = super.serverTransactionTable.remove(txId);
                if (sipServerTransaction != null) {
                        super.removeFromMergeTable(sipServerTransaction);
                        super.removePendingTransaction(sipServerTransaction);
@@ -644,13 +646,14 @@
* @see org.mobicents.ha.javax.sip.ClusteredSipStack#remoteClientTransactionRemoval(java.lang.String)
         */
        public void remoteClientTransactionRemoval(String transactionId) {
+               final String txId = transactionId.toLowerCase();
// note we don't want a dialog terminated event, thus we need to go directly to map removal // assuming it's a confirmed dialog there is no chance it is on early dialogs too
                if (getStackLogger().isLoggingEnabled(StackLogger.TRACE_DEBUG)) 
{
                        getStackLogger().logDebug("sipStack " + this +
- " remote Client Transaction Removal of transaction Id : " + transactionId);
+                                       " remote Client Transaction Removal of 
transaction Id : " + txId);
                }
// the transaction id is set to lower case in the cache so it might not remove it correctly - SIPClientTransaction sipClientTransaction = super.clientTransactionTable.remove(transactionId); + SIPClientTransaction sipClientTransaction = super.clientTransactionTable.remove(txId);
        }
 }
=======================================
--- /trunk/servers/jain-sip-ha/jboss-5/src/main/java/org/mobicents/ha/javax/sip/cache/ClientTransactionCacheData.java Mon Dec 6 10:09:13 2010 +++ /trunk/servers/jain-sip-ha/jboss-5/src/main/java/org/mobicents/ha/javax/sip/cache/ClientTransactionCacheData.java Wed Dec 8 10:09:53 2010
@@ -89,8 +89,7 @@
                                }
jbossCache.getInvocationContext().getOptionOverrides().setForceDataGravitation(true);
                        }
- // not sure why but whatever we do the transactionId is always set to lower case in the cache - final Node<String,Object> childNode = getNode().getChild(txId.toLowerCase());
+            final Node<String,Object> childNode = getNode().getChild(txId);
                        if(childNode != null) {
                                try {
                                        final Map<String, Object> 
transactionMetaData = childNode.getData();
@@ -239,8 +238,7 @@
                                transactionManager.begin();
                                doTx = true;
                }
- // not sure why but whatever we do the transactionId is always set to lower case in the cache - final Node childNode = getNode().addChild(Fqn.fromElements(transactionId.toLowerCase())); + final Node childNode = getNode().addChild(Fqn.fromElements(transactionId)); for (Entry<String, Object> metaData : haClientTransaction.getMetaDataToReplicate().entrySet()) {
                                childNode.put(metaData.getKey(), 
metaData.getValue());
                        }
@@ -309,8 +307,10 @@
                                transactionManager.begin();
                                doTx = true;
                }
- // not sure why but whatever we do the transactionId is always set to lower case in the cache
-                       succeeded = 
getNode().removeChild(transactionId.toLowerCase());
+                       succeeded = getNode().removeChild(transactionId);
+                       if(logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
+                               logger.logDebug("removed HA SIP Client Transaction ? 
" + succeeded);
+                       }
                } catch (Exception ex) {
                        try {
                                if(transactionManager != null) {
=======================================
--- /trunk/servers/jain-sip-ha/jboss-5/src/main/java/org/mobicents/ha/javax/sip/cache/ServerTransactionCacheData.java Sun Dec 5 17:05:09 2010 +++ /trunk/servers/jain-sip-ha/jboss-5/src/main/java/org/mobicents/ha/javax/sip/cache/ServerTransactionCacheData.java Wed Dec 8 10:09:53 2010
@@ -87,9 +87,8 @@
clusteredlogger.logDebug("forcing data gravitation since buddy replication is enabled");
                                }
jbossCache.getInvocationContext().getOptionOverrides().setForceDataGravitation(true);
-                       }
- // not sure why but whatever we do the transactionId is always set to lower case in the cache - final Node<String,Object> childNode = getNode().getChild(txId.toLowerCase());
+                       }
+            final Node<String,Object> childNode = getNode().getChild(txId);
                        if(childNode != null) {
                                try {
                                        final Map<String, Object> 
transactionMetaData = childNode.getData();
@@ -234,9 +233,8 @@
                                }
                                transactionManager.begin();
                                doTx = true;
-               }
- // not sure why but whatever we do the transactionId is always set to lower case in the cache - final Node childNode = getNode().addChild(Fqn.fromElements(transactionId.toLowerCase()));
+               }
+ final Node childNode = getNode().addChild(Fqn.fromElements(transactionId)); for (Entry<String, Object> metaData : haServerTransaction.getMetaDataToReplicate().entrySet()) {
                                childNode.put(metaData.getKey(), 
metaData.getValue());
                        }
@@ -302,8 +300,10 @@
                                transactionManager.begin();
                                doTx = true;
                }
- // not sure why but whatever we do the transactionId is always set to lower case in the cache
-                       succeeded = 
getNode().removeChild(transactionId.toLowerCase());
+                       succeeded = getNode().removeChild(transactionId);
+                       
if(clusteredlogger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
+ clusteredlogger.logDebug("removed HA SIP Server Transaction ? " + succeeded);
+                       }
                } catch (Exception ex) {
                        try {
                                if(transactionManager != null) {

Reply via email to