Add module for session data cache

This commit is contained in:
Jan Bartel 2016-06-08 15:00:32 +10:00
parent 64e8d1ff5d
commit d52a1701ad
13 changed files with 94 additions and 8 deletions

View File

@ -793,5 +793,10 @@
<artifactId>jetty-nosql</artifactId> <artifactId>jetty-nosql</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.eclipse.jetty.memcached</groupId>
<artifactId>jetty-memcached-sessions</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -9,7 +9,7 @@
<!-- ===================================================================== --> <!-- ===================================================================== -->
<Call name="addBean"> <Call name="addBean">
<Arg> <Arg>
<New class="org.eclipse.jetty.gcloud.session.GCloudSessionDataStoreFactory"> <New id="sessionDataStoreFactory" class="org.eclipse.jetty.gcloud.session.GCloudSessionDataStoreFactory">
<Set name="gCloudConfiguration"><Ref id="gconf"/></Set> <Set name="gCloudConfiguration"><Ref id="gconf"/></Set>
<Set name="gracePeriodSec"><Property name="jetty.session.gracePeriod.seconds" default="3600" /></Set> <Set name="gracePeriodSec"><Property name="jetty.session.gracePeriod.seconds" default="3600" /></Set>
<Set name="maxRetries"><Property name="jetty.gcloudSession.maxRetries" default="5"/></Set> <Set name="maxRetries"><Property name="jetty.gcloudSession.maxRetries" default="5"/></Set>

View File

@ -18,7 +18,7 @@
<!-- ===================================================================== --> <!-- ===================================================================== -->
<Call name="addBean"> <Call name="addBean">
<Arg> <Arg>
<New class="org.eclipse.jetty.server.session.InfinispanSessionStoreFactory"> <New id="sessionDataStoreFactory" class="org.eclipse.jetty.server.session.InfinispanSessionStoreFactory">
<Set name="cache"><Ref id="cache"/></Set> <Set name="cache"><Ref id="cache"/></Set>
<Set name="infinispanIdleTimeoutSec"><Property name="jetty.session.infinispanIdleTimeout.seconds" default="0" /></Set> <Set name="infinispanIdleTimeoutSec"><Property name="jetty.session.infinispanIdleTimeout.seconds" default="0" /></Set>
<Set name="gracePeriod"><Property name="jetty.session.gracePeriod.seconds" default="3600" /></Set> <Set name="gracePeriod"><Property name="jetty.session.gracePeriod.seconds" default="3600" /></Set>

View File

@ -20,7 +20,7 @@
<!-- ===================================================================== --> <!-- ===================================================================== -->
<Call name="addBean"> <Call name="addBean">
<Arg> <Arg>
<New class="org.eclipse.jetty.server.session.InfinispanSessionStoreFactory"> <New id="sessionDataStoreFactory" class="org.eclipse.jetty.server.session.InfinispanSessionStoreFactory">
<Set name="cache"><Ref id="remoteCache"/></Set> <Set name="cache"><Ref id="remoteCache"/></Set>
<Set name="infinispanIdleTimeoutSec"><Property name="jetty.session.infinispanIdleTimeout.seconds" default="0" /></Set> <Set name="infinispanIdleTimeoutSec"><Property name="jetty.session.infinispanIdleTimeout.seconds" default="0" /></Set>
<Set name="gracePeriod"><Property name="jetty.session.gracePeriod.seconds" default="3600" /></Set> <Set name="gracePeriod"><Property name="jetty.session.gracePeriod.seconds" default="3600" /></Set>

View File

@ -25,6 +25,7 @@
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId> <artifactId>slf4j-simple</artifactId>
<version>1.7.9</version> <version>1.7.9</version>
<scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.eclipse.jetty</groupId> <groupId>org.eclipse.jetty</groupId>

View File

@ -0,0 +1,10 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<New id="sessionDataMapFactory" class="org.eclipse.jetty.memcached.session.MemcachedSessionDataMapFactory">
<Set name="host"><Property name="jetty.session.memcache.host" default="localhost"/></Set>
<Set name="port"><Property name="jetty.session.memcache.port" default="11211"/></Set>
<Set name="expirySec"><Property name="etty.session.memcache.expirySec" default="0"/></Set>
</New>
</Configure>

View File

@ -0,0 +1,22 @@
[description]
Memcache cache for SessionData
[depends]
session-store
[files]
maven://com.googlecode.xmemcached/xmemcached/2.0.0|lib/xmemcached/xmemcached-2.0.0.jar
maven://org.slf4j/slf4j-api/1.6.6|lib/xmemcached/slf4j-api-1.6.6.jar
[lib]
lib/jetty-memcached-sessions-${jetty.version}.jar
lib/xmemcached
[license]
Xmemcached is an open source project hosted on Github and released under the Apache 2.0 license.
https://github.com/killme2008/xmemcached
http://www.apache.org/licenses/LICENSE-2.0.html
[xml]
etc/sessions/session-data-cache/xmemcached.xml

View File

@ -60,13 +60,13 @@ public class MemcachedSessionDataMapFactory implements SessionDataMapFactory
public int getExpiry() public int getExpirySec()
{ {
return _expiry; return _expiry;
} }
public void setExpiry(int expiry) public void setExpirySec(int expiry)
{ {
_expiry = expiry; _expiry = expiry;
} }

View File

@ -9,7 +9,7 @@
<!-- ===================================================================== --> <!-- ===================================================================== -->
<Call name="addBean"> <Call name="addBean">
<Arg> <Arg>
<New class="org.eclipse.jetty.server.session.MongoSessionStoreFactory"> <New id="sessionDataStoreFactory" class="org.eclipse.jetty.server.session.MongoSessionStoreFactory">
<Set name="dbName"><Property name="jetty.session.dbName" default="HttpSessions" /></Set> <Set name="dbName"><Property name="jetty.session.dbName" default="HttpSessions" /></Set>
<Set name="collectionName"><Property name="jetty.session.collectionName" default="jettySessions" /></Set> <Set name="collectionName"><Property name="jetty.session.collectionName" default="jettySessions" /></Set>
<Set name="gracePeriod"><Property name="jetty.session.gracePeriod.seconds" default="3600" /></Set> <Set name="gracePeriod"><Property name="jetty.session.gracePeriod.seconds" default="3600" /></Set>

View File

@ -9,7 +9,7 @@
<!-- ===================================================================== --> <!-- ===================================================================== -->
<Call name="addBean"> <Call name="addBean">
<Arg> <Arg>
<New class="org.eclipse.jetty.server.session.FileSessionDataStoreFactory"> <New id="sessionDataStoreFactory" class="org.eclipse.jetty.server.session.FileSessionDataStoreFactory">
<Set name="deleteUnrestorableFiles"><Property name="jetty.session.deleteUnrestorableFiles" default="false" /></Set> <Set name="deleteUnrestorableFiles"><Property name="jetty.session.deleteUnrestorableFiles" default="false" /></Set>
<Set name="storeDir"><Property name="jetty.session.storeDir"/></Set> <Set name="storeDir"><Property name="jetty.session.storeDir"/></Set>
</New> </New>

View File

@ -9,7 +9,7 @@
<!-- ===================================================================== --> <!-- ===================================================================== -->
<Call name="addBean"> <Call name="addBean">
<Arg> <Arg>
<New class="org.eclipse.jetty.server.session.JDBCSessionDataStoreFactory"> <New id="sessionDataStoreFactory" class="org.eclipse.jetty.server.session.JDBCSessionDataStoreFactory">
<Set name="gracePeriodSec"><Property name="jetty.session.gracePeriod.seconds" default="3600" /></Set> <Set name="gracePeriodSec"><Property name="jetty.session.gracePeriod.seconds" default="3600" /></Set>
<Set name="databaseAdaptor"> <Set name="databaseAdaptor">
<Ref id="databaseAdaptor"/> <Ref id="databaseAdaptor"/>

View File

@ -0,0 +1,24 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<!-- ===================================================================== -->
<!-- Configure a factory for CachingSessionDataStores -->
<!-- ===================================================================== -->
<Call name="removeBean">
<Ref id="sessionDataStoreFactory"/>
</Call>
<Call name="addBean">
<Arg>
<New class="org.eclipse.jetty.server.session.CachingSessionDataStoreFactory">
<Set name="sessionStoreFactory"><Ref id="sessionDataStoreFactory"/></Set>
<Set name="sessionDataMapFactory"><Ref id="sessionDataMapFatory"/></Set>
</New>
</Arg>
</Configure>

View File

@ -0,0 +1,24 @@
[description]
Enables caching of SessionData in front of a SessionDataStore.
[depend]
session-store
sessions/session-data-cache/${session-data-cache}
[xml]
etc/sessions/session-data-cache/session-caching-store.xml
[ini]
session-data-cache=xmemcached
[ini-template]
## Session Data Cache type: xmemcached
session-data-cache=xmemcached
#jetty.session.memcached.host=localhost
#jetty.session.memcached.port=11211
#jetty.session.memcached.expirySec=