Revision: 15607
Author: [email protected]
Date: Thu Dec  2 08:11:40 2010
Log: Update Issue 1874

non regression B2BUA test case for early dialog failover working
http://code.google.com/p/mobicents/source/detail?r=15607

Modified:
 /trunk/servers/sip-servlets/sip-servlets-impl/.classpath
/trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/dispatchers/ResponseDispatcher.java /trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/session/SessionManagerUtil.java /trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/message/SipServletMessageImpl.java /trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/message/SipServletRequestImpl.java /trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/message/SipServletResponseImpl.java /trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/startup/SipStandardService.java /trunk/servers/sip-servlets/sip-servlets-jboss5/src/main/java/org/jboss/web/tomcat/service/session/ClusteredSipSession.java /trunk/servers/sip-servlets/sip-servlets-jboss5/src/main/java/org/jboss/web/tomcat/service/session/JBossCacheSipManager.java

=======================================
--- /trunk/servers/sip-servlets/sip-servlets-impl/.classpath Wed Aug 11 02:43:49 2010 +++ /trunk/servers/sip-servlets/sip-servlets-impl/.classpath Thu Dec 2 08:11:40 2010
@@ -16,7 +16,7 @@
<classpathentry kind="var" path="M2_REPO/org/dnsjava/dnsjava/2.0.6/dnsjava-2.0.6.jar"/> <classpathentry kind="var" path="M2_REPO/javax/sip/jain-sip-api/1.2/jain-sip-api-1.2.jar"/> <classpathentry kind="var" path="M2_REPO/javax/sip/jain-sip-ri/1.2.X-SNAPSHOT/jain-sip-ri-1.2.X-SNAPSHOT.jar"/> - <classpathentry kind="var" path="M2_REPO/org/mobicents/ha/javax/sip/mobicents-jain-sip-ha-core/0.7-SNAPSHOT/mobicents-jain-sip-ha-core-0.7-SNAPSHOT.jar"/> + <classpathentry kind="var" path="M2_REPO/org/mobicents/ha/javax/sip/mobicents-jain-sip-ha-core/0.14-SNAPSHOT/mobicents-jain-sip-ha-core-0.14-SNAPSHOT.jar"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry combineaccessrules="false" kind="src" path="/sip-servlets-annotations"/> <classpathentry combineaccessrules="false" kind="src" path="/sip-servlets-spec"/>
=======================================
--- /trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/dispatchers/ResponseDispatcher.java Thu Oct 21 20:28:27 2010 +++ /trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/dispatchers/ResponseDispatcher.java Thu Dec 2 08:11:40 2010
@@ -37,8 +37,11 @@
 import org.apache.log4j.Logger;
 import org.mobicents.servlet.sip.JainSipUtils;
 import org.mobicents.servlet.sip.annotation.ConcurrencyControlMode;
+import org.mobicents.servlet.sip.core.session.DistributableSipManager;
+import org.mobicents.servlet.sip.core.session.MobicentsSipApplicationSession;
 import org.mobicents.servlet.sip.core.session.MobicentsSipSession;
 import org.mobicents.servlet.sip.core.session.SessionManagerUtil;
+import org.mobicents.servlet.sip.core.session.SipApplicationSessionKey;
 import org.mobicents.servlet.sip.core.session.SipManager;
 import org.mobicents.servlet.sip.core.session.SipSessionKey;
 import org.mobicents.servlet.sip.message.SipFactoryImpl;
@@ -176,17 +179,26 @@
SipSessionKey sessionKey = SessionManagerUtil.getSipSessionKey(appId, appName, response, inverted);
                        if(logger.isDebugEnabled()) {
logger.debug("Trying to find session with following session key " + sessionKey);
-                       }
+                       }
+ final SipApplicationSessionKey sipApplicationSessionKey = SessionManagerUtil.getSipApplicationSessionKey(
+                                       appName,
+                                       appId);
+
+                       MobicentsSipApplicationSession sipApplicationSession = 
null;
+                       // needed only for failover (early) dialog recovery
+                       if(sipManager instanceof DistributableSipManager) {
+ sipApplicationSession = sipManager.getSipApplicationSession(sipApplicationSessionKey, false);
+                       }
                        MobicentsSipSession tmpSession = null;

- tmpSession = sipManager.getSipSession(sessionKey, false, sipFactoryImpl, null); + tmpSession = sipManager.getSipSession(sessionKey, false, sipFactoryImpl, sipApplicationSession);
                        //needed in the case of RE-INVITE by example
                        if(tmpSession == null) {
sessionKey = SessionManagerUtil.getSipSessionKey(appId, appName, response, !inverted);
                                if(logger.isDebugEnabled()) {
logger.debug("Trying to find session with following session key " + sessionKey);
                                }
- tmpSession = sipManager.getSipSession(sessionKey, false, sipFactoryImpl, null); + tmpSession = sipManager.getSipSession(sessionKey, false, sipFactoryImpl, sipApplicationSession);
                        }
                        if(logger.isDebugEnabled()) {
                                logger.debug("session found is " + tmpSession);
=======================================
--- /trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/session/SessionManagerUtil.java Thu Jul 15 07:43:29 2010 +++ /trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/session/SessionManagerUtil.java Thu Dec 2 08:11:40 2010
@@ -16,10 +16,6 @@
  */
 package org.mobicents.servlet.sip.core.session;

-import gov.nist.core.Separators;
-import gov.nist.javax.sip.address.Authority;
-import gov.nist.javax.sip.address.SipUri;
-
 import java.text.ParseException;
 import java.util.StringTokenizer;

=======================================
--- /trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/message/SipServletMessageImpl.java Wed Aug 18 09:15:50 2010 +++ /trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/message/SipServletMessageImpl.java Thu Dec 2 08:11:40 2010
@@ -56,6 +56,7 @@
 import javax.sip.Dialog;
 import javax.sip.InvalidArgumentException;
 import javax.sip.ListeningPoint;
+import javax.sip.ServerTransaction;
 import javax.sip.SipFactory;
 import javax.sip.Transaction;
 import javax.sip.header.AcceptLanguageHeader;
@@ -77,6 +78,8 @@

 import org.apache.catalina.realm.GenericPrincipal;
 import org.apache.log4j.Logger;
+import org.mobicents.ha.javax.sip.ClusteredSipStack;
+import org.mobicents.ha.javax.sip.ReplicationStrategy;
 import org.mobicents.servlet.sip.JainSipUtils;
 import org.mobicents.servlet.sip.SipFactories;
 import org.mobicents.servlet.sip.address.AddressImpl;
@@ -89,6 +92,7 @@
 import org.mobicents.servlet.sip.core.session.SipManager;
 import org.mobicents.servlet.sip.core.session.SipSessionKey;
 import org.mobicents.servlet.sip.startup.SipContext;
+import org.mobicents.servlet.sip.startup.StaticServiceHolder;

 /**
  * Implementation of SipServletMessage
@@ -1726,7 +1730,7 @@
         * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
         */
        public void readExternal(ObjectInput in) throws IOException,
-                       ClassNotFoundException {
+                       ClassNotFoundException {
                sipFactoryImpl = (SipFactoryImpl) in.readObject();
                String sessionKeyString = in.readUTF();
                try {
@@ -1749,6 +1753,13 @@
                        currentApplicationName = null;
                }
                isMessageSent = in.readBoolean();
+ if(((ClusteredSipStack)StaticServiceHolder.sipStandardService.getSipStack()).getReplicationStrategy() == ReplicationStrategy.EarlyDialog) {
+                       String transactionId = in.readUTF();
+                       if(transactionId != null) {
+                               boolean isServerTx = in.readBoolean();
+ transaction = ((ClusteredSipStack)StaticServiceHolder.sipStandardService.getSipStack()).findTransaction(transactionId, isServerTx);
+                       }
+               }
        }

        /*
@@ -1756,6 +1767,9 @@
         * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
         */
        public void writeExternal(ObjectOutput out) throws IOException {
+               if (logger.isDebugEnabled()) {
+                       logger.debug("sipServletMessage.writeExternal");
+               }
                out.writeObject(sipFactoryImpl);
                if(sessionKey != null) {
                        out.writeUTF(sessionKey.toString());
@@ -1779,6 +1793,14 @@
                        out.writeUTF("");
                }
                out.writeBoolean(isMessageSent);
+ if(((ClusteredSipStack)StaticServiceHolder.sipStandardService.getSipStack()).getReplicationStrategy() == ReplicationStrategy.EarlyDialog) {
+                       if(transaction == null) {
+                               out.writeUTF("");
+                       } else {
+                               out.writeUTF(transaction.getBranchId());
+                               out.writeBoolean(transaction instanceof 
ServerTransaction);
+                       }
+               }
                out.writeUTF(message.toString());
        }
 //     public void cleanUp() {
=======================================
--- /trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/message/SipServletRequestImpl.java Tue Nov 30 14:56:02 2010 +++ /trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/message/SipServletRequestImpl.java Thu Dec 2 08:11:40 2010
@@ -1040,7 +1040,7 @@
final SipProvider sipProvider = sipNetworkInterfaceManager.findMatchingListeningPoint(
                                                        transport, 
false).getSipProvider();
// Issue 1468 : to handle forking, we shouldn't cleanup the app data since it is needed for the forked responses
-                                       
if(((SipStackImpl)sipProvider.getSipStack()).getMaxForkTime() == 0) {
+ if(((SipStackImpl)sipProvider.getSipStack()).getMaxForkTime() == 0 && transaction != null) {
                                                
transaction.setApplicationData(null);
                                        }
                                        return;
=======================================
--- /trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/message/SipServletResponseImpl.java Tue Oct 12 07:44:10 2010 +++ /trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/message/SipServletResponseImpl.java Thu Dec 2 08:11:40 2010
@@ -17,6 +17,7 @@
 package org.mobicents.servlet.sip.message;

 import gov.nist.javax.sip.DialogExt;
+import gov.nist.javax.sip.message.ResponseExt;
 import gov.nist.javax.sip.stack.SIPClientTransaction;
 import gov.nist.javax.sip.stack.SIPTransaction;

=======================================
--- /trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/startup/SipStandardService.java Tue Oct 12 07:59:03 2010 +++ /trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/startup/SipStandardService.java Thu Dec 2 08:11:40 2010
@@ -53,6 +53,7 @@
 import org.mobicents.ha.javax.sip.LoadBalancerHeartBeatingListener;
 import org.mobicents.ha.javax.sip.LoadBalancerHeartBeatingService;
 import org.mobicents.ha.javax.sip.LoadBalancerHeartBeatingServiceImpl;
+import org.mobicents.ha.javax.sip.ReplicationStrategy;
 import org.mobicents.servlet.sip.JainSipUtils;
 import org.mobicents.servlet.sip.SipConnector;
 import org.mobicents.servlet.sip.SipFactories;
@@ -448,10 +449,7 @@
                                }
UserAgentHeader userAgentHeader = SipFactories.headerFactory.createUserAgentHeader(userAgentList); ((MessageFactoryExt)SipFactories.messageFactory).setDefaultUserAgentHeader(userAgentHeader);
-                       }
-                       if(logger.isInfoEnabled()) {
- logger.info("Mobicents Sip Servlets sip stack properties : " + sipStackProperties);
-                       }
+                       }
                        if(balancers != null) {
if(sipStackProperties.get(LoadBalancerHeartBeatingService.LB_HB_SERVICE_CLASS_NAME) == null) { sipStackProperties.put(LoadBalancerHeartBeatingService.LB_HB_SERVICE_CLASS_NAME, LoadBalancerHeartBeatingServiceImpl.class.getCanonicalName());
@@ -460,7 +458,19 @@
sipStackProperties.put(LoadBalancerHeartBeatingService.BALANCERS, balancers);
                                }
                        }
- sipStackProperties.put("org.mobicents.ha.javax.sip.REPLICATION_STRATEGY", "ConfirmedDialogNoApplicationData"); + String replicationStrategy = sipStackProperties.getProperty(ClusteredSipStack.REPLICATION_STRATEGY_PROPERTY);
+                       if(replicationStrategy == null) {
+                               replicationStrategy = 
ReplicationStrategy.ConfirmedDialog.toString();
+                       }
+                       boolean replicateApplicationData = false;
+ if(replicationStrategy.equals(ReplicationStrategy.EarlyDialog.toString())) {
+                               replicateApplicationData = true;
+                       }
+ sipStackProperties.put(ClusteredSipStack.REPLICATION_STRATEGY_PROPERTY, replicationStrategy); + sipStackProperties.put(ClusteredSipStack.REPLICATE_APPLICATION_DATA, Boolean.valueOf(replicateApplicationData).toString());
+                       if(logger.isInfoEnabled()) {
+ logger.info("Mobicents Sip Servlets sip stack properties : " + sipStackProperties);
+                       }
                        // Create SipStack object
                        sipStack = 
SipFactories.sipFactory.createSipStack(sipStackProperties);
                        LoadBalancerHeartBeatingService 
loadBalancerHeartBeatingService = null;
=======================================
--- /trunk/servers/sip-servlets/sip-servlets-jboss5/src/main/java/org/jboss/web/tomcat/service/session/ClusteredSipSession.java Mon Nov 22 09:01:53 2010 +++ /trunk/servers/sip-servlets/sip-servlets-jboss5/src/main/java/org/jboss/web/tomcat/service/session/ClusteredSipSession.java Thu Dec 2 08:11:40 2010
@@ -16,8 +16,6 @@
  */
 package org.jboss.web.tomcat.service.session;

-import gov.nist.javax.sip.SipStackImpl;
-
 import java.beans.PropertyChangeSupport;
 import java.io.Serializable;
 import java.lang.reflect.Method;
@@ -52,7 +50,6 @@
 import org.apache.catalina.Engine;
 import org.apache.catalina.Globals;
 import org.apache.catalina.Service;
-import org.apache.catalina.connector.Connector;
 import org.apache.catalina.util.Enumerator;
 import org.apache.catalina.util.StringManager;
 import org.apache.log4j.Logger;
=======================================
--- /trunk/servers/sip-servlets/sip-servlets-jboss5/src/main/java/org/jboss/web/tomcat/service/session/JBossCacheSipManager.java Mon Nov 22 09:01:53 2010 +++ /trunk/servers/sip-servlets/sip-servlets-jboss5/src/main/java/org/jboss/web/tomcat/service/session/JBossCacheSipManager.java Thu Dec 2 08:11:40 2010
@@ -77,6 +77,8 @@
 import org.mobicents.cluster.DefaultMobicentsCluster;
 import org.mobicents.cluster.MobicentsCluster;
 import org.mobicents.cluster.election.DefaultClusterElector;
+import org.mobicents.ha.javax.sip.ClusteredSipStack;
+import org.mobicents.ha.javax.sip.ReplicationStrategy;
import org.mobicents.servlet.sip.core.session.MobicentsSipApplicationSession;
 import org.mobicents.servlet.sip.core.session.MobicentsSipSession;
 import org.mobicents.servlet.sip.core.session.SessionManagerUtil;
@@ -85,6 +87,7 @@
 import org.mobicents.servlet.sip.core.session.SipSessionKey;
 import org.mobicents.servlet.sip.message.SipFactoryImpl;
 import org.mobicents.servlet.sip.startup.SipContext;
+import org.mobicents.servlet.sip.startup.StaticServiceHolder;

 /**
  * Implementation of a converged clustered session manager for
@@ -2155,12 +2158,15 @@
                        synchronized (session) {
                                if (logger.isDebugEnabled()) {
                                        logger.debug("check to see if needs to store 
and replicate "
-                                                       + "session with id " + 
session.getId());
+ + "session with id " + session.getId() + " isValid " + session.isValidInternal() + + " getMustReplicateTimestamp " + session.getMustReplicateTimestamp() +
+                                                       " session state " + 
session.getState());
                                }

                                if (session.isValidInternal()
-                                               && (session.isSessionDirty() || 
session
- .getMustReplicateTimestamp()) && State.CONFIRMED.equals(session.getState())) { + && (session.isSessionDirty() || session.getMustReplicateTimestamp()) &&
+                                                               
(State.CONFIRMED.equals(session.getState()) ||
+ (((ClusteredSipStack)StaticServiceHolder.sipStandardService.getSipStack()).getReplicationStrategy().equals(ReplicationStrategy.EarlyDialog) && State.EARLY.equals(session.getState())))) {
                                        final String realId = session.getId();
                                        if(logger.isDebugEnabled()) {
                                                logger.debug("replicating following 
sip session " + session.getId());
@@ -2477,18 +2483,27 @@
                        if(logger.isDebugEnabled()) {
logger.debug("data for sip session " + key + " found in the distributed cache");
                                }
-                       if (session == null && sipApplicationSessionImpl != 
null) {
- // This is either the first time we've seen this session on this
-                                       // server, or we previously expired it 
and have since gotten
-                                       // a replication message from another 
server
-                                       mustAdd = true;
-                                       initialLoad = true;
- session = (ClusteredSipSession<? extends OutgoingDistributableSessionData>) - ((ClusteredSipManagerDelegate)sipManagerDelegate).getNewMobicentsSipSession(key, sipFactory, sipApplicationSessionImpl, true);
-                                       OwnedSessionUpdate osu = 
unloadedSipSessions_.get(key);
-                               passivated = (osu != null && osu.passivated);
-                               }
-                       if(session != null) {
+                       if (session == null) {
+                               if(sipApplicationSessionImpl != null) {
+                                       if(logger.isDebugEnabled()) {
+ logger.debug("parent sip application is " + sipApplicationSessionImpl.getId());
+                                       }
+ // This is either the first time we've seen this session on this
+                                               // server, or we previously 
expired it and have since gotten
+                                               // a replication message from 
another server
+                                               mustAdd = true;
+                                               initialLoad = true;
+ session = (ClusteredSipSession<? extends OutgoingDistributableSessionData>) + ((ClusteredSipManagerDelegate)sipManagerDelegate).getNewMobicentsSipSession(key, sipFactory, sipApplicationSessionImpl, true);
+                                               OwnedSessionUpdate osu = 
unloadedSipSessions_.get(key);
+                                       passivated = (osu != null && 
osu.passivated);
+                               } else {
+                                       if(logger.isDebugEnabled()) {
+ logger.debug("beware null parent sip application for session " + key);
+                                       }
+                               }
+                       }
+                       if(session!= null) {
                                                session.update(data);
                        }
                    } else if(logger.isDebugEnabled()) {

Reply via email to