Revision: 15469
Author: [email protected]
Date: Wed Nov 24 02:57:27 2010
Log: Update Issue 1873
Fixing TCK regression caused by passivation changes on the servlet timers +
adding logging
http://code.google.com/p/mobicents/source/detail?r=15469
Modified:
/trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/timers/ServletTimerImpl.java
/trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/timers/TimerServiceImpl.java
=======================================
---
/trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/timers/ServletTimerImpl.java
Thu Nov 18 06:05:14 2010
+++
/trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/timers/ServletTimerImpl.java
Wed Nov 24 02:57:27 2010
@@ -25,12 +25,15 @@
import org.apache.log4j.Logger;
import
org.mobicents.servlet.sip.core.session.MobicentsSipApplicationSession;
+import org.mobicents.servlet.sip.core.session.SipApplicationSessionKey;
+import org.mobicents.servlet.sip.core.session.SipManager;
import org.mobicents.servlet.sip.startup.SipContext;
public class ServletTimerImpl implements ServletTimer, Runnable {
private static final Logger logger =
Logger.getLogger(ServletTimerImpl.class);
- private MobicentsSipApplicationSession appSession;
+ private SipApplicationSessionKey appSessionKey;
+ private SipManager sipManager;
/**
* Logger for this class
*/
@@ -152,7 +155,8 @@
this.fixedDelay = fixedDelay;
this.period = period;
this.listener = listener;
- this.appSession = appSession;
+ this.appSessionKey = appSession.getKey();
+ this.sipManager= appSession.getSipContext().getSipManager();
}
public void cancel() {
@@ -178,14 +182,13 @@
// kan be kept in production code since object
should
// be due for gc anyway....
isCanceled = Boolean.valueOf(res);
- appSessionToCancelThisTimersFrom = appSession;
+ appSessionToCancelThisTimersFrom =
getApplicationSession();
future = null;
}
}
if (appSessionToCancelThisTimersFrom != null) {
appSessionToCancelThisTimersFrom.removeServletTimer(this);
}
- appSession = null;
}
/**
@@ -209,15 +212,16 @@
public MobicentsSipApplicationSession getApplicationSession() {
synchronized (TIMER_LOCK) {
- return this.appSession;
+ return
sipManager.getSipApplicationSession(appSessionKey, false);
}
}
public void setApplicationSession(MobicentsSipApplicationSession
sipApplicationSession) {
-
- synchronized (TIMER_LOCK) {
- this.appSession = sipApplicationSession;
+ if(sipApplicationSession != null) {
+ synchronized (TIMER_LOCK) {
+ this.appSessionKey =
sipApplicationSession.getKey();
+ }
}
}
@@ -258,7 +262,7 @@
.append('\n');
sb.append("Time now = ").append(System.currentTimeMillis())
.append('\n');
- sb.append("SipApplicationSession =
").append(appSession).append('\n');
+ sb.append("SipApplicationSession =
").append(appSessionKey).append('\n');
sb.append("ScheduledFuture = ").append(future).append('\n');
sb.append("Delay = ").append(delay).append('\n');
return sb.toString();
@@ -269,20 +273,21 @@
*/
public void run() {
- SipContext sipContext = appSession.getSipContext();
+ final MobicentsSipApplicationSession sipApplicationSession =
getApplicationSession();
+ SipContext sipContext = sipApplicationSession.getSipContext();
ClassLoader oldClassLoader =
Thread.currentThread().getContextClassLoader();
try {
ClassLoader cl =
sipContext.getLoader().getClassLoader();
Thread.currentThread().setContextClassLoader(cl);
- sipContext.enterSipApp(appSession, null);
+ sipContext.enterSipApp(sipApplicationSession, null);
sipContext.enterSipAppHa(true);
listener.timeout(this);
} catch(Throwable t) {
logger.error("An unexpected exception happened in the timer
callback!",t);
} finally {
sipContext.exitSipAppHa(null, null);
- sipContext.exitSipApp(appSession, null);
+ sipContext.exitSipApp(sipApplicationSession, null);
Thread.currentThread().setContextClassLoader(oldClassLoader);
if (isRepeatingTimer) {
estimateNextExecution();
=======================================
---
/trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/timers/TimerServiceImpl.java
Thu May 6 13:18:33 2010
+++
/trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/timers/TimerServiceImpl.java
Wed Nov 24 02:57:27 2010
@@ -103,8 +103,11 @@
private ServletTimerImpl createTimerLocaly(TimerListener listener, long
delay,
boolean isPersistent, Serializable info, MobicentsSipApplicationSession
sipApplicationSession) {
ServletTimerImpl servletTimer = new ServletTimerImpl(info, delay,
listener, sipApplicationSession);
- // logger.log(Level.FINE, "starting timer
- // at:"+System.currentTimeMillis());
+
+ if(logger.isDebugEnabled()) {
+ logger.debug("Scheduling Timer "+ servletTimer.getId() +" to expire
in " + delay + " ms");
+ }
+
ScheduledFuture<?> future = scheduledExecutor.schedule(servletTimer,
delay, TimeUnit.MILLISECONDS);
servletTimer.setFuture(future);
// sipApplicationSession.timerScheduled(st);
@@ -132,9 +135,17 @@
info, delay, fixedDelay, period, listener,
sipApplicationSession);
ScheduledFuture<?> future = null;
if (fixedDelay) {
+ if(logger.isDebugEnabled()) {
+ logger.debug("Scheduling Timer "+ servletTimer.getId() +" to expire
in " + delay + " ms" + " with fixed delay of " + period);
+ }
+
future = scheduledExecutor.scheduleWithFixedDelay(servletTimer, delay,
period,
TimeUnit.MILLISECONDS);
} else {
+ if(logger.isDebugEnabled()) {
+ logger.debug("Scheduling Timer "+ servletTimer.getId() +" to expire
in " + delay + " ms" + " at fixed rate of " + period);
+ }
+
future = scheduledExecutor.scheduleAtFixedRate(servletTimer, delay,
period,
TimeUnit.MILLISECONDS);
}