Repository: karaf-cellar
Updated Branches:
  refs/heads/master 227badab2 -> 47498a08a


[KARAF-2489] Add documentation and sample about HTTP Session Replication on the 
cluster


Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/47498a08
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/47498a08
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/47498a08

Branch: refs/heads/master
Commit: 47498a08ab182b42c9d2165cf6961a8b511dd542
Parents: 227bada
Author: Jean-Baptiste Onofré <[email protected]>
Authored: Fri Sep 18 10:36:57 2015 +0200
Committer: Jean-Baptiste Onofré <[email protected]>
Committed: Fri Sep 18 10:36:57 2015 +0200

----------------------------------------------------------------------
 http/balancer/NOTICE                            | 39 ++++++++++
 http/pom.xml                                    |  1 -
 manual/src/main/webapp/manual.conf              |  1 +
 .../main/webapp/user-guide/http-session.conf    | 77 ++++++++++++++++++++
 manual/src/main/webapp/user-guide/index.conf    |  1 +
 samples/http-session-replication/NOTICE         | 39 ++++++++++
 samples/http-session-replication/pom.xml        | 51 +++++++++++++
 .../src/main/webapp/WEB-INF/web.xml             | 46 ++++++++++++
 samples/pom.xml                                 |  1 +
 9 files changed, 255 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/47498a08/http/balancer/NOTICE
----------------------------------------------------------------------
diff --git a/http/balancer/NOTICE b/http/balancer/NOTICE
new file mode 100644
index 0000000..64cb235
--- /dev/null
+++ b/http/balancer/NOTICE
@@ -0,0 +1,39 @@
+Apache Karaf Cellar
+Copyright 2011-2015 The Apache Software Foundation
+
+I. Used Software
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+The OSGi Alliance (http://www.osgi.org/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+Hazelcast (http://www.hazelcast.com/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+OPS4J (http://www.ops4j.org/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+FUSE Source (http://www.fusesource.org/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+JClouds (http://www.jclouds.org/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+SLF4J (http://www.slf4j.org/).
+Licensed under the MIT License.
+
+This product includes software from http://www.json.org.
+Copyright (c) 2002 JSON.org
+
+II. License Summary
+- Apache License 2.0
+- MIT License

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/47498a08/http/pom.xml
----------------------------------------------------------------------
diff --git a/http/pom.xml b/http/pom.xml
index 10f0ae4..ee59c29 100644
--- a/http/pom.xml
+++ b/http/pom.xml
@@ -35,7 +35,6 @@
 
     <modules>
         <module>balancer</module>
-        <!-- <module>session-replicator</module> -->
     </modules>
 
 </project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/47498a08/manual/src/main/webapp/manual.conf
----------------------------------------------------------------------
diff --git a/manual/src/main/webapp/manual.conf 
b/manual/src/main/webapp/manual.conf
index c239705..3e3959d 100644
--- a/manual/src/main/webapp/manual.conf
+++ b/manual/src/main/webapp/manual.conf
@@ -37,6 +37,7 @@ h1. User Guide
 {include:user-guide/obr.conf}
 {include:user-guide/event.conf}
 {include:user-guide/http-balancer.conf}
+{include:user-guide/http-session.conf}
 {include:user-guide/transport.conf}
 {include:user-guide/cloud.conf}
 

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/47498a08/manual/src/main/webapp/user-guide/http-session.conf
----------------------------------------------------------------------
diff --git a/manual/src/main/webapp/user-guide/http-session.conf 
b/manual/src/main/webapp/user-guide/http-session.conf
new file mode 100644
index 0000000..b87a069
--- /dev/null
+++ b/manual/src/main/webapp/user-guide/http-session.conf
@@ -0,0 +1,77 @@
+h1. HTTP Session Replication
+
+Apache Karaf Cellar supports replication of the HTTP sessions on the cluster.
+
+It means that the same web application deployed on multiple nodes in the 
cluster will share the same HTTP sessions
+pool, allowing clients to transparently connect to any node, without loosing 
any session state.
+
+h2. Enable Cluster HTTP Session Replication
+
+In order to be able to be stored on the cluster, all HTTP Sessions used in 
your web application have to implement
+Serializable interface. Any non-serializable attribute has to be flagged as 
transient.
+
+You have to enable a specific filter in your application to enable the 
replication. See next chapter for details.
+
+At runtime level, you just have to install http, http-whiteboard, and cellar 
features:
+
+{code}
+karaf@root()> feature:install http
+karaf@root()> feature:install http-whiteboard
+karaf@root()> feature:repo-add cellar 4.0.0
+karaf@root()> feature:install cellar
+{code}
+
+h2. Web Application Session Replication
+
+In order to use HTTP session replication on the cluster, you just have to add 
a filter in your web application.
+
+Basically, the WEB-INF/web.xml file of your web application should look like 
this:
+
+{code}
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd";
+       version="3.0">
+
+       <filter>
+               <filter-name>hazelcast-filter</filter-name>
+               <filter-class>com.hazelcast.web.WebFilter</filter-class>
+           <!--
+               Name of the distributed map storing
+               your web session objects
+           -->
+               <init-param>
+                       <param-name>map-name</param-name>
+                       <param-value>my-sessions</param-value>
+               </init-param>
+           <!-- How is your load-balancer configured? stick-session means all 
requests of
+               a session is routed to the node where the session is first 
created. This is
+               excellent for performance. If sticky-session is set to false, 
when a session
+                is updated on a node, entry for this session on all other 
nodes is invalidated.
+                You have to know how your load-balancer is configured before 
setting this
+                parameter. Default is true. -->
+               <init-param>
+                       <param-name>sticky-session</param-name>
+                       <param-value>false</param-value>
+               </init-param>
+           <!--
+               Are you debugging? Default is false.
+           -->
+               <init-param>
+                       <param-name>debug</param-name>
+                       <param-value>false</param-value>
+               </init-param>
+       </filter>
+       <filter-mapping>
+               <filter-name>hazelcast-filter</filter-name>
+               <url-pattern>/*</url-pattern>
+               <dispatcher>FORWARD</dispatcher>
+               <dispatcher>INCLUDE</dispatcher>
+               <dispatcher>REQUEST</dispatcher>
+       </filter-mapping>
+       <listener>
+               
<listener-class>com.hazelcast.web.SessionListener</listener-class>
+       </listener>
+
+</web-app>
+{code}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/47498a08/manual/src/main/webapp/user-guide/index.conf
----------------------------------------------------------------------
diff --git a/manual/src/main/webapp/user-guide/index.conf 
b/manual/src/main/webapp/user-guide/index.conf
index 0e7fd5d..19de361 100644
--- a/manual/src/main/webapp/user-guide/index.conf
+++ b/manual/src/main/webapp/user-guide/index.conf
@@ -9,5 +9,6 @@ h1. Karaf Cellar User Guide
 * [OBR in Karaf Cellar|/user-guide/obr]
 * [OSGi Event broadcast with Karaf Cellar|/user-guide/event]
 * [HTTP Balancer|/user-guide/http-balancer]
+* [HTTP Session Replication|/user-guide/http-session]
 * [DOSGi and Transport|/user-guide/transport]
 * [Discovery Services|/user-guide/cloud]

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/47498a08/samples/http-session-replication/NOTICE
----------------------------------------------------------------------
diff --git a/samples/http-session-replication/NOTICE 
b/samples/http-session-replication/NOTICE
new file mode 100644
index 0000000..64cb235
--- /dev/null
+++ b/samples/http-session-replication/NOTICE
@@ -0,0 +1,39 @@
+Apache Karaf Cellar
+Copyright 2011-2015 The Apache Software Foundation
+
+I. Used Software
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+The OSGi Alliance (http://www.osgi.org/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+Hazelcast (http://www.hazelcast.com/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+OPS4J (http://www.ops4j.org/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+FUSE Source (http://www.fusesource.org/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+JClouds (http://www.jclouds.org/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+SLF4J (http://www.slf4j.org/).
+Licensed under the MIT License.
+
+This product includes software from http://www.json.org.
+Copyright (c) 2002 JSON.org
+
+II. License Summary
+- Apache License 2.0
+- MIT License

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/47498a08/samples/http-session-replication/pom.xml
----------------------------------------------------------------------
diff --git a/samples/http-session-replication/pom.xml 
b/samples/http-session-replication/pom.xml
new file mode 100644
index 0000000..6c42940
--- /dev/null
+++ b/samples/http-session-replication/pom.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+
+    <!--
+
+        Licensed to the Apache Software Foundation (ASF) under one or more
+        contributor license agreements.  See the NOTICE file distributed with
+        this work for additional information regarding copyright ownership.
+        The ASF licenses this file to You under the Apache License, Version 2.0
+        (the "License"); you may not use this file except in compliance with
+        the License.  You may obtain a copy of the License at
+
+           http://www.apache.org/licenses/LICENSE-2.0
+
+        Unless required by applicable law or agreed to in writing, software
+        distributed under the License is distributed on an "AS IS" BASIS,
+        WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
implied.
+        See the License for the specific language governing permissions and
+        limitations under the License.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.karaf.cellar</groupId>
+        <artifactId>samples</artifactId>
+        <version>4.0.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <groupId>org.apache.karaf.cellar.samples</groupId>
+    <artifactId>http-session-replication</artifactId>
+    <name>Apache Karaf :: Cellar :: Samples :: HTTP Session Replication</name>
+    <packaging>bundle</packaging>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <_wab>src/main/webapp</_wab>
+                        
<Web-ContextPath>cellar-session-sample</Web-ContextPath>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/47498a08/samples/http-session-replication/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/samples/http-session-replication/src/main/webapp/WEB-INF/web.xml 
b/samples/http-session-replication/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..0657f5d
--- /dev/null
+++ b/samples/http-session-replication/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd";
+         version="3.0">
+
+    <filter>
+        <filter-name>hazelcast-filter</filter-name>
+        <filter-class>com.hazelcast.web.WebFilter</filter-class>
+        <!--
+            Name of the distributed map storing
+            your web session objects
+        -->
+        <init-param>
+            <param-name>map-name</param-name>
+            <param-value>my-sessions</param-value>
+        </init-param>
+        <!-- How is your load-balancer configured? stick-session means all 
requests of
+            a session is routed to the node where the session is first 
created. This is
+            excellent for performance. If sticky-session is set to false, when 
a session
+             is updated on a node, entry for this session on all other nodes 
is invalidated.
+             You have to know how your load-balancer is configured before 
setting this
+             parameter. Default is true. -->
+        <init-param>
+            <param-name>sticky-session</param-name>
+            <param-value>false</param-value>
+        </init-param>
+        <!--
+            Are you debugging? Default is false.
+        -->
+        <init-param>
+            <param-name>debug</param-name>
+            <param-value>false</param-value>
+        </init-param>
+    </filter>
+    <filter-mapping>
+        <filter-name>hazelcast-filter</filter-name>
+        <url-pattern>/*</url-pattern>
+        <dispatcher>FORWARD</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
+        <dispatcher>REQUEST</dispatcher>
+    </filter-mapping>
+    <listener>
+        <listener-class>com.hazelcast.web.SessionListener</listener-class>
+    </listener>
+
+</web-app>

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/47498a08/samples/pom.xml
----------------------------------------------------------------------
diff --git a/samples/pom.xml b/samples/pom.xml
index 84aefe3..0f32356 100644
--- a/samples/pom.xml
+++ b/samples/pom.xml
@@ -35,6 +35,7 @@
 
     <modules>
         <module>dosgi-greeter</module>
+        <module>http-session-replication</module>
         <module>hazelcast-app</module>
         <module>camel-hazelcast-app</module>
     </modules>

Reply via email to