Revision: 15622
Author: [email protected]
Date: Fri Dec 3 10:02:24 2010
Log: Update Issue 1874
for non regression B2BUA test case forwarding ACK => working
http://code.google.com/p/mobicents/source/detail?r=15622
Modified:
/trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/dispatchers/SubsequentRequestDispatcher.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/SipServletResponseImpl.java
/trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/message/TransactionApplicationData.java
/trunk/servers/sip-servlets/sip-servlets-jboss5-ha-server-cache/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/DistributedCacheConvergedSipManagerDelegate.java
/trunk/servers/sip-servlets/sip-servlets-jboss5-ha-server-cache/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/SipCacheListener.java
=======================================
---
/trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/dispatchers/SubsequentRequestDispatcher.java
Thu Oct 28 09:49:13 2010
+++
/trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/dispatchers/SubsequentRequestDispatcher.java
Fri Dec 3 10:02:24 2010
@@ -414,7 +414,7 @@
SipServletRequestImpl correspondingInviteRequest =
(SipServletRequestImpl)sipServletMessage;
final SipServletResponse lastFinalResponse =
correspondingInviteRequest.getLastFinalResponse();
if(logger.isDebugEnabled()) {
- logger.debug("last final response " +
lastFinalResponse);
+ logger.debug("last final response " +
lastFinalResponse + " for original request " + correspondingInviteRequest);
}
if(lastFinalResponse != null &&
lastFinalResponse.getStatus() >= 300) {
=======================================
---
/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
+++
/trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/session/SessionManagerUtil.java
Fri Dec 3 10:02:24 2010
@@ -185,7 +185,7 @@
String sipSessionKey, String sipAppSessionId, String
sipApplicationName) throws ParseException {
if(logger.isDebugEnabled()) {
- logger.debug("sipSession key to parse " + sipSessionKey
);
+ logger.debug("sipSession ha key to parse " +
sipSessionKey );
}
StringTokenizer stringTokenizer = new StringTokenizer(sipSessionKey,
SESSION_KEY_SEPARATOR);
String fromTag = stringTokenizer.nextToken();
=======================================
---
/trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/message/SipServletMessageImpl.java
Fri Dec 3 05:02:55 2010
+++
/trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/message/SipServletMessageImpl.java
Fri Dec 3 10:02:24 2010
@@ -126,6 +126,9 @@
// Made it transient for Issue 1523 :
http://code.google.com/p/mobicents/issues/detail?id=1523
// NotSerializableException happens if a message is stored in the sip
session during HA
private transient Transaction transaction;
+ // used for failover to recover the transaction
+ private String transactionId;
+ private boolean transactionType;
// We need this object separate from transaction.getApplicationData,
because the actualy transaction
// may be create later and we still need to accumulate useful data. Also
the transaction might be
@@ -773,7 +776,7 @@
// AddressImpl enforces immutability!!
FromHeader from = (FromHeader) this.message
.getHeader(getCorrectHeaderName(FromHeader.NAME));
- AddressImpl address = new AddressImpl(from.getAddress(),
AddressImpl.getParameters((Parameters)from), transaction == null ? true :
false);
+ AddressImpl address = new AddressImpl(from.getAddress(),
AddressImpl.getParameters((Parameters)from), getTransaction() == null ?
true : false);
return address;
}
@@ -1066,7 +1069,7 @@
public Address getTo() {
ToHeader to = (ToHeader) this.message
.getHeader(getCorrectHeaderName(ToHeader.NAME));
- return new AddressImpl(to.getAddress(),
AddressImpl.getParameters((Parameters)to), transaction == null ? true :
false);
+ return new AddressImpl(to.getAddress(),
AddressImpl.getParameters((Parameters)to), getTransaction() == null ?
true : false);
}
/*
@@ -1534,6 +1537,11 @@
}
public Transaction getTransaction() {
+ if(transaction == null && transactionId != null) {
+ // used for early dialog failover purposes, lazily load
the transaction
+
setTransaction(((ClusteredSipStack)StaticServiceHolder.sipStandardService.getSipStack()).findTransaction(transactionId,
transactionType));
+ transactionApplicationData = (TransactionApplicationData)
transaction.getApplicationData();
+ }
return this.transaction;
}
@@ -1568,8 +1576,8 @@
if (this.dialog != null) {
return dialog;
}
- if (this.transaction != null) {
- return this.transaction.getDialog();
+ if (this.getTransaction() != null) {
+ return this.getTransaction().getDialog();
}
return null;
}
@@ -1579,6 +1587,8 @@
* the transaction to set
*/
public void setTransaction(Transaction transaction) {
+ if (logger.isDebugEnabled())
+ logger.debug("Setting transaction " + transaction + " on message " +
this);
this.transaction = transaction;
}
@@ -1760,10 +1770,13 @@
}
isMessageSent = in.readBoolean();
if(((ClusteredSipStack)StaticServiceHolder.sipStandardService.getSipStack()).getReplicationStrategy()
== ReplicationStrategy.EarlyDialog) {
- String transactionId = in.readUTF();
+ transactionId = in.readUTF();
if(transactionId != null) {
- boolean isServerTx = in.readBoolean();
- transaction =
((ClusteredSipStack)StaticServiceHolder.sipStandardService.getSipStack()).findTransaction(transactionId,
isServerTx);
+ if(transactionId.equals("")) {
+ transactionId = null;
+ } else {
+ transactionType = in.readBoolean();
+ }
}
}
}
@@ -1773,9 +1786,6 @@
* @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());
=======================================
---
/trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/message/SipServletResponseImpl.java
Thu Dec 2 08:11:40 2010
+++
/trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/message/SipServletResponseImpl.java
Fri Dec 3 10:02:24 2010
@@ -574,7 +574,11 @@
originalRequest.setRoutingState(RoutingState.FINAL_RESPONSE_SENT);
}
if(originalRequest != null) {
- originalRequest.setResponse(this);
+ originalRequest.setResponse(this);
+ if(originalRequest.getTransaction() != null &&
originalRequest.getTransaction().getApplicationData() != null &&
((TransactionApplicationData)originalRequest.getTransaction().getApplicationData()).getSipServletMessage() !=
null) {
+ // used for early dialog failover
purposes
+
((SipServletRequestImpl)((TransactionApplicationData)originalRequest.getTransaction().getApplicationData()).getSipServletMessage()).setResponse(this);
+ }
}
//updating the last accessed times
session.access();
=======================================
---
/trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/message/TransactionApplicationData.java
Thu Dec 2 13:36:06 2010
+++
/trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/message/TransactionApplicationData.java
Fri Dec 3 10:02:24 2010
@@ -25,7 +25,6 @@
import javax.sip.Transaction;
import org.apache.log4j.Logger;
-import org.mobicents.servlet.sip.core.session.SipSessionKey;
import org.mobicents.servlet.sip.proxy.ProxyBranchImpl;
/**
@@ -40,7 +39,7 @@
private ProxyBranchImpl proxyBranch;
private SipServletMessageImpl sipServletMessage;
// private SipSessionKey sipSessionKey;
- private transient Set<SipServletResponseImpl> sipServletResponses;
+ private Set<SipServletResponseImpl> sipServletResponses;
private transient Transaction transaction;
private transient String initialRemoteHostAddress;
private transient int initialRemotePort;
@@ -233,6 +232,42 @@
transaction = null;
rseqNumber = null;
}
+
+// public void readExternal(ObjectInput in) throws IOException,
+// ClassNotFoundException {
+// sipServletMessage = (SipServletMessageImpl) in.readObject();
+//
if(((ClusteredSipStack)StaticServiceHolder.sipStandardService.getSipStack()).getReplicationStrategy()
== ReplicationStrategy.EarlyDialog) {
+// boolean proxyBranchSerialized = in.readBoolean();
+// if(proxyBranchSerialized) {
+// proxyBranch = (ProxyBranchImpl) in.readObject();
+// }
+// int size = in.readInt();
+// if(size > 0) {
+// SipServletResponseImpl[] sipServletResponseImpls =
(SipServletResponseImpl[])in.readObject();
+// for (SipServletResponseImpl sipServletResponseImpl :
sipServletResponseImpls) {
+//
addSipServletResponse(sipServletResponseImpl);
+// }
+// }
+// }
+// }
+//
+// public void writeExternal(ObjectOutput out) throws IOException {
+// out.writeObject(sipServletMessage);
+//
if(((ClusteredSipStack)StaticServiceHolder.sipStandardService.getSipStack()).getReplicationStrategy()
== ReplicationStrategy.EarlyDialog) {
+// if(proxyBranch != null) {
+// out.writeBoolean(true);
+// out.writeObject(proxyBranch);
+// } else {
+// out.writeBoolean(false);
+// }
+// if(sipServletResponses != null) {
+// out.writeInt(sipServletResponses.size());
+// out.writeObject(sipServletResponses.toArray(new
SipServletResponseImpl[sipServletResponses.size()]));
+// } else {
+// out.writeInt(0);
+// }
+// }
+// }
// /**
// * @return the sipSessionKey
=======================================
---
/trunk/servers/sip-servlets/sip-servlets-jboss5-ha-server-cache/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/DistributedCacheConvergedSipManagerDelegate.java
Mon Nov 15 08:57:08 2010
+++
/trunk/servers/sip-servlets/sip-servlets-jboss5-ha-server-cache/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/DistributedCacheConvergedSipManagerDelegate.java
Fri Dec 3 10:02:24 2010
@@ -172,7 +172,10 @@
log_.debug("getSipSessionData(): fqn " + Fqn.fromString(fqn.toString()
+ "/" + AbstractJBossCacheService.ATTRIBUTE_KEY) + " key=" + entry.getKey()
+ ", value=" + entry.getValue());
}
}
-
+
+ Map<Object, Object> versionData =
+ jBossCacheService.cacheWrapper_.getData(Fqn.fromString(fqn.toString()
+ "/" + AbstractJBossCacheService.VERSION_KEY), true);
+
if (initialLoad) {
jBossCacheService.setupSessionRegion(fqn);
}
@@ -180,7 +183,7 @@
IncomingDistributableSessionData dsd = null;
try {
- dsd = getDistributableSipSessionData(key, sessionData,
sessionAttributesData);
+ dsd = getDistributableSipSessionData(key, versionData, sessionData,
sessionAttributesData);
// From Sip Session
DistributableSipSessionMetadata metaData =
(DistributableSipSessionMetadata)jBossCacheService.getUnMarshalledValue(dsd.getMetadata());
metaData.setMetaData(sipSessionMetaData);
@@ -243,6 +246,10 @@
log_.debug("getSipApplicationSessionData(): fqn " +
Fqn.fromString(fqn.toString() + "/" +
AbstractJBossCacheService.ATTRIBUTE_KEY) + " key=" + entry.getKey() + ",
value=" + entry.getValue());
}
}
+
+ Map<Object, Object> versionData =
+ jBossCacheService.cacheWrapper_.getData(Fqn.fromString(fqn.toString()
+ "/" + AbstractJBossCacheService.VERSION_KEY), true);
+
if (initialLoad) {
jBossCacheService.setupSessionRegion(fqn);
}
@@ -250,7 +257,7 @@
IncomingDistributableSessionData dsd = null;
try {
- dsd = getDistributableSipSessionData(key, sessionData,
sessionAttributesData);
+ dsd = getDistributableSipSessionData(key, versionData, sessionData,
sessionAttributesData);
// From Sip Application Session
DistributableSipApplicationSessionMetadata metaData =
(DistributableSipApplicationSessionMetadata)jBossCacheService.getUnMarshalledValue(dsd.getMetadata());
metaData.setMetaData(sipAppSessionMetaData);
@@ -272,9 +279,9 @@
* passed in map. If this is unacceptable, pass in a defensive copy.
*/
protected IncomingDistributableSessionData
getDistributableSipSessionData(
- String realId, Map<Object, Object> distributedCacheData,
+ String realId, Map<Object, Object> versionCacheData, Map<Object,
Object> distributedCacheData,
Map<Object, Object> attrs) {
- Integer version = (Integer)
distributedCacheData.get(AbstractJBossCacheService.VERSION_KEY.toString());
+ Integer version = (Integer)
versionCacheData.get(AbstractJBossCacheService.VERSION_KEY.toString());
Long timestamp = (Long)
distributedCacheData.get(AbstractJBossCacheService.TIMESTAMP_KEY.toString());
DistributableSessionMetadata metadata = (DistributableSessionMetadata)
distributedCacheData
.get(AbstractJBossCacheService.METADATA_KEY.toString());
@@ -549,7 +556,7 @@
jBossCacheService.cacheWrapper_.put(fqn,
AbstractJBossCacheService.TIMESTAMP_KEY.toString(), timestamp.longValue());
}
- jBossCacheService.cacheWrapper_.put(fqn,
AbstractJBossCacheService.VERSION_KEY.toString(),
sipApplicationSessionData.getVersion());
+ jBossCacheService.cacheWrapper_.put(Fqn.fromString(fqn.toString() + "/"
+ AbstractJBossCacheService.VERSION_KEY.toString()),
AbstractJBossCacheService.VERSION_KEY.toString(),
sipApplicationSessionData.getVersion());
}
public void storeSipSessionData(
@@ -604,6 +611,6 @@
jBossCacheService.cacheWrapper_.put(fqn,
AbstractJBossCacheService.TIMESTAMP_KEY.toString(), timestamp.longValue());
}
- jBossCacheService.cacheWrapper_.put(fqn,
AbstractJBossCacheService.VERSION_KEY.toString(),
sipSessionData.getVersion());
+ jBossCacheService.cacheWrapper_.put(Fqn.fromString(fqn.toString() + "/"
+ AbstractJBossCacheService.VERSION_KEY.toString()),
AbstractJBossCacheService.VERSION_KEY.toString(),
sipSessionData.getVersion());
}
}
=======================================
---
/trunk/servers/sip-servlets/sip-servlets-jboss5-ha-server-cache/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/SipCacheListener.java
Thu Jul 15 07:43:29 2010
+++
/trunk/servers/sip-servlets/sip-servlets-jboss5-ha-server-cache/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/SipCacheListener.java
Fri Dec 3 10:02:24 2010
@@ -43,7 +43,7 @@
* @author Brian Stansberry
* @author <A HREF="mailto:[email protected]">Jean Deruelle</A>
*/
[email protected]
[email protected](sync=false)
public class SipCacheListener extends CacheListenerBase
{
protected static Logger logger =
Logger.getLogger(SipCacheListener.class);
@@ -190,11 +190,7 @@
@NodeModified
public void nodeModified(NodeModifiedEvent event) {
if (event.isPre())
- return;
-
- if(logger.isDebugEnabled()) {
- logger.debug("following node modified " +
event.getFqn().toString());
- }
+ return;
boolean local = event.isOriginLocal();
if (!fieldBased_ && local)
@@ -209,78 +205,83 @@
&& isFqnForOurSipapp(fqn, isBuddy)) {
// Query if we have version value in the distributed cache.
// If we have a version value, compare the version and invalidate
if necessary.
- @SuppressWarnings("unchecked")
- Map<Object, Object> data = event.getData();
- Integer version = (Integer)
data.get(AbstractJBossCacheService.VERSION_KEY.toString());
- if(version != null) {
+ if((fqn.size() == 6 &&
fqn.get(5).toString().equals(AbstractJBossCacheService.VERSION_KEY.toString()))
|| (fqn.size() == 5 &&
fqn.get(4).toString().equals(AbstractJBossCacheService.VERSION_KEY.toString())))
{
if(logger.isDebugEnabled()) {
- logger.debug("version attribute found " + version + " in " + fqn
);
- }
- String sipAppSessionId = getSipApplicationSessionIdFromFqn(fqn,
isBuddy);
- String sipSessionId = null;
- boolean isSipApplicationSession = true;
- if(!isFqnSipApplicationSessionRootSized(fqn.size(), isBuddy))
{
- sipSessionId = getSipSessionIdFromFqn(fqn,
isBuddy);
- isSipApplicationSession = false;
- }
- if(logger.isDebugEnabled()) {
- logger.debug("isSipAppSession " + isSipApplicationSession + "
in " + fqn);
- }
- String owner = null;
-// String owner = isBuddy ? getBuddyOwner(fqn) : null;
-// @SuppressWarnings("unchecked")
-// Fqn<String> ancestor = fqn.getAncestor(1);
- Long timestamp = Long.valueOf(-1);
-// Long timestamp = (Long) wrapper.get(ancestor,
AbstractJBossCacheService.TIMESTAMP_KEY.toString());
-// if (timestamp == null) {
-// log_.warn("No timestamp attribute found in " + fqn);
-// } else {
- boolean updated = false;
- if(isSipApplicationSession) {
- // Notify the manager that a session has been
updated
- updated = ((LocalDistributableConvergedSessionManager)
manager_).sipApplicationSessionChangedInDistributedCache(sipAppSessionId,
owner,
- version.intValue(),
- timestamp,
- null);
-// timestamp.longValue(),
-//
(DistributableSessionMetadata) wrapper.get(ancestor,
AbstractJBossCacheService.METADATA_KEY.toString()));
- } else {
- // Notify the manager that a session has been
updated
- updated = ((LocalDistributableConvergedSessionManager)
manager_).sipSessionChangedInDistributedCache(sipAppSessionId,
sipSessionId, owner,
- version.intValue(),
- timestamp,
- null);
-// timestamp.longValue(),
-//
(DistributableSessionMetadata) wrapper.get(ancestor,
AbstractJBossCacheService.METADATA_KEY.toString()));
- }
- if (!updated && !isBuddy) {
- logger.warn("Possible concurrency problem: Replicated version
id " +
- version + " is less than or equal to in-memory
version for session app id " + sipAppSessionId + " and session id " +
sipSessionId);
- }
- /*else
- {
- We have a local session but got a modification for the
buddy tree.
- This means another node is in the process of taking
over the session;
- we don't worry about it
- }
- */
-// }
- }
- // commented out since this is not true, due to optimizations for
better perf and
- // network data replication version, timestamp, metadata and
attributes are serialized
- // separately
-// else if (!attributeBased_) {// other granularities can modify
attributes only
-// log_.debug("No version attribute found in " + fqn);
-// }
+ logger.debug("following node modified " +
event.getFqn().toString());
+ }
+ @SuppressWarnings("unchecked")
+ Map<Object, Object> data = event.getData();
+ Integer version = (Integer)
data.get(AbstractJBossCacheService.VERSION_KEY.toString());
+ if(version != null) {
+ if(logger.isDebugEnabled()) {
+ logger.debug("version attribute found " + version + " in " + fqn
+ " using parent fqn " + fqn.getParent());
+ }
+ String sipAppSessionId =
getSipApplicationSessionIdFromFqn(fqn.getParent(), isBuddy);
+ String sipSessionId = null;
+ boolean isSipApplicationSession = true;
+ if(!isFqnSipApplicationSessionRootSized(fqn.getParent().size(),
isBuddy)) {
+ sipSessionId = getSipSessionIdFromFqn(fqn.getParent(),
isBuddy);
+ isSipApplicationSession = false;
+ }
+ if(logger.isDebugEnabled()) {
+ logger.debug("isSipAppSession " + isSipApplicationSession + "
in " + fqn.getParent());
+ }
+ String owner = null;
+ // String owner = isBuddy ? getBuddyOwner(fqn) : null;
+ // @SuppressWarnings("unchecked")
+ // Fqn<String> ancestor = fqn.getAncestor(1);
+ Long timestamp = Long.valueOf(-1);
+ // Long timestamp = (Long) wrapper.get(ancestor,
AbstractJBossCacheService.TIMESTAMP_KEY.toString());
+ // if (timestamp == null) {
+ // log_.warn("No timestamp attribute found in " + fqn);
+ // } else {
+ boolean updated = false;
+ if(isSipApplicationSession) {
+ // Notify the manager that a session
has been updated
+ updated = ((LocalDistributableConvergedSessionManager)
manager_).sipApplicationSessionChangedInDistributedCache(sipAppSessionId,
owner,
+ version.intValue(),
+ timestamp,
+ null);
+ //
timestamp.longValue(),
+ //
(DistributableSessionMetadata) wrapper.get(ancestor,
AbstractJBossCacheService.METADATA_KEY.toString()));
+ } else {
+ // Notify the manager that a session
has been updated
+ updated = ((LocalDistributableConvergedSessionManager)
manager_).sipSessionChangedInDistributedCache(sipAppSessionId,
sipSessionId, owner,
+ version.intValue(),
+ timestamp,
+ null);
+ //
timestamp.longValue(),
+ //
(DistributableSessionMetadata) wrapper.get(ancestor,
AbstractJBossCacheService.METADATA_KEY.toString()));
+ }
+ if (!updated && !isBuddy) {
+ logger.warn("Possible concurrency problem: Replicated version
id " +
+ version + " is less than or equal to
in-memory version for session app id " + sipAppSessionId + " and session
id " + sipSessionId);
+ }
+ /*else
+ {
+ We have a local session but got a modification for the
buddy tree.
+ This means another node is in the process of taking
over the session;
+ we don't worry about it
+ }
+ */
+ // }
+ }
+ // commented out since this is not true, due to optimizations for
better perf and
+ // network data replication version, timestamp, metadata and
attributes are serialized
+ // separately
+ // else if (!attributeBased_) {// other granularities can modify
attributes only
+ // log_.debug("No version attribute found in " + fqn);
+ // }
+ }
}
else if (local && !isBuddy
&& (isPossibleSipApplicationSessionInternalPojoFqn(fqn) ||
isPossibleSipSessionInternalPojoFqn(fqn))
- && isFqnForOurSipapp(fqn, isBuddy)) {
+ && isFqnForOurSipapp(fqn, isBuddy)) {
// One of our sessions' pojos is modified; need to inform
// the manager so it can mark the session dirty
String sipAppSessId = getSipApplicationSessionIdFromFqn(fqn,
isBuddy);
String sessId = null;
- if (isFqnSipApplicationSessionRootSized(fqn.size(), isBuddy))
{
+ if (isFqnSipApplicationSessionRootSized(fqn.size(), isBuddy))
{
((LocalDistributableConvergedSessionManager) manager_)
.notifySipApplicationSessionLocalAttributeModification(sipAppSessId);
} else {