public SipApplicationSessionTimerTask schedule( SipApplicationSessionTimerTask expirationTimerTask, long delay, TimeUnit unit) { if(logger.isDebugEnabled()) { logger.debug("Scheduling sip application session "+ expirationTimerTask.getSipApplicationSession().getKey() +" to expire in " + (delay / (double) 1000 / (double) 60) + " minutes"); } super.schedule(((StandardSasTimerTask)expirationTimerTask), delay); return expirationTimerTask; }
public SipApplicationSessionTimerTask schedule( SipApplicationSessionTimerTask expirationTimerTask, long delay, TimeUnit unit) { if(logger.isDebugEnabled()) { logger.debug("Scheduling sip application session "+ expirationTimerTask.getSipApplicationSession().getKey() +" to expire in " + (delay / (double) 1000 / (double) 60) + " minutes"); } ((DefaultSasTimerTask)expirationTimerTask).setScheduledFuture((ScheduledFuture<MobicentsSipApplicationSession>)super.schedule(expirationTimerTask, delay, unit)); return expirationTimerTask; }
public boolean cancel(SipApplicationSessionTimerTask expirationTimerTask) { //CANCEL needs to remove the shceduled timer see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6602600 //to improve perf ScheduledFuture<MobicentsSipApplicationSession> future = ((DefaultSasTimerTask)expirationTimerTask).getScheduledFuture(); if(future != null) { boolean removed = super.remove((Runnable) future); if(logger.isDebugEnabled()) { logger.debug("expiration timer on sip application session " + expirationTimerTask.getSipApplicationSession().getKey() + " removed : " + removed); } boolean cancelled = future.cancel(true); if(logger.isDebugEnabled()) { logger.debug("expiration timer on sip application session " + expirationTimerTask.getSipApplicationSession().getKey() + " Cancelled : " + cancelled); } future = null; // Purge is expensive when called frequently, only call it every now and then. // We do not sync the numCancelled variable. We dont care about correctness of // the number, and we will still call purge rought once on every 25 cancels. numCancelled++; if(numCancelled % 100 == 0) { super.purge(); } return cancelled; } else { if(logger.isDebugEnabled()) { logger.debug("expiration timer future is null, thus cannot be Cancelled"); } return false; } }