337270 Shared Timer for session management
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2798 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
cc3d015e60
commit
93c9c181a0
|
@ -6,6 +6,8 @@ jetty-7.3.1-SNAPSHOT
|
|||
+ 336793 Tee data filled and flushed from endpoint
|
||||
+ 337258 Scanner start and end cycle notification
|
||||
+ 337268 Allow specifying alias of a certificate to be used by SSL connector
|
||||
+ 337270 Shared Timer for session management
|
||||
+ 337271 Flush SSL endpoint when dispatch thread held forever
|
||||
|
||||
jetty-7.3.0.v20110203 3 February 2011
|
||||
+ JETTY-1259 NullPointerException in JDBCSessionIdManager when invalidating session (further update)
|
||||
|
|
|
@ -36,6 +36,7 @@ import java.util.concurrent.ConcurrentMap;
|
|||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.eclipse.jetty.util.LazyList;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
@ -46,12 +47,16 @@ import org.eclipse.jetty.util.log.Log;
|
|||
* <p>
|
||||
* This manager supports saving sessions to disk, either periodically or at shutdown.
|
||||
* Sessions can also have their content idle saved to disk to reduce the memory overheads of large idle sessions.
|
||||
* <p>
|
||||
* This manager will create it's own Timer instance to scavenge threads, unless it discovers a shared Timer instance
|
||||
* set as the "org.eclipse.jetty.server.session.timer" attribute of the Server.
|
||||
*
|
||||
*/
|
||||
public class HashSessionManager extends AbstractSessionManager
|
||||
{
|
||||
private static int __id;
|
||||
private Timer _timer;
|
||||
private boolean _timerStop=false;
|
||||
private TimerTask _task;
|
||||
private int _scavengePeriodMs=30000;
|
||||
private int _savePeriodMs=0; //don't do period saves by default
|
||||
|
@ -78,7 +83,13 @@ public class HashSessionManager extends AbstractSessionManager
|
|||
_sessions=new ConcurrentHashMap<String,HashedSession>();
|
||||
super.doStart();
|
||||
|
||||
_timer=new Timer("HashSessionScavenger-"+__id++, true);
|
||||
_timerStop=false;
|
||||
_timer=(Timer)getSessionHandler().getServer().getAttribute("org.eclipse.jetty.server.session.timer");
|
||||
if (_timer==null)
|
||||
{
|
||||
_timerStop=true;
|
||||
_timer=new Timer("HashSessionScavenger-"+__id++, true);
|
||||
}
|
||||
|
||||
setScavengePeriod(getScavengePeriod());
|
||||
|
||||
|
@ -118,7 +129,7 @@ public class HashSessionManager extends AbstractSessionManager
|
|||
if (_task!=null)
|
||||
_task.cancel();
|
||||
_task=null;
|
||||
if (_timer!=null)
|
||||
if (_timer!=null && _timerStop)
|
||||
_timer.cancel();
|
||||
_timer=null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue