public long getExpirationTime() { if(!isValid()) { throw new IllegalStateException("this sip application session is not valid anymore"); } if(expirationTimerTask == null) { return 0; } long delay = expirationTimerTask.getDelay(); if(delay <= 0) { return 0; } if(expired) { return Long.MIN_VALUE; } return this.expirationTime; }
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; }
private void cancelExpirationTimer() { if(expirationTimerTask != null) { // http://code.google.com/p/mobicents/issues/detail?id=2322 : Race condition can occur so making sure the expiration timer task is not null sipContext.getSipApplicationSessionTimerService().cancel(expirationTimerTask); } if(expirationTimerTask != null) { // http://code.google.com/p/mobicents/issues/detail?id=2322 : expiration Timer task can be null after calling cancel above due to Race condition expirationTimerTask.setSipApplicationSession(null); expirationTimerTask = null; } }
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; } }