jules 2004/01/02 06:19:04
Modified: modules/clustering/src/java/org/apache/geronimo/clustering
LocalCluster.java Data.java AbstractCluster.java
modules/clustering/src/deploy clustering-service.xml
Added: modules/clustering/src/java/org/apache/geronimo/clustering/web
package.html HttpSessionManager.java
modules/clustering/src/java/org/apache/geronimo/clustering/ejb
package.html
Log:
create web and ejb packages
start work on HttpSessionManager
deploy a dummy HttpSessionManager
Revision Changes Path
1.1
incubator-geronimo/modules/clustering/src/java/org/apache/geronimo/clustering/web/package.html
Index: package.html
===================================================================
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<title></title>
</head>
<body>
The Geronimo Web Tier Clustering binding.
</body>
</html>
1.1
incubator-geronimo/modules/clustering/src/java/org/apache/geronimo/clustering/web/HttpSessionManager.java
Index: HttpSessionManager.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Geronimo" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Geronimo", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
package org.apache.geronimo.clustering.web;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.geronimo.clustering.Cluster;
import org.apache.geronimo.clustering.Data;
import org.apache.geronimo.kernel.service.GeronimoAttributeInfo;
import org.apache.geronimo.kernel.service.GeronimoMBeanContext;
import org.apache.geronimo.kernel.service.GeronimoMBeanInfo;
import org.apache.geronimo.kernel.service.GeronimoMBeanTarget;
/**
* An HttpSessionManager for <distributable/> webapps, which
* backs onto the generic Geronimo clustering framework.
*
* @version $Revision: 1.1 $ $Date: 2004/01/02 14:19:04 $
*/
public class
HttpSessionManager
implements GeronimoMBeanTarget
{
protected Log _log=LogFactory.getLog(HttpSessionManager.class);
//----------------------------------------
// HttpSessionManager
//----------------------------------------
protected Map _sessions=new HashMap();
public int getSize(){return _sessions.size();}
protected ObjectName _cluster;
public ObjectName getCluster(){return _cluster;}
protected String _clusterName;
public String getClusterName(){return _clusterName;}
public void setClusterName(String clusterName){_clusterName=clusterName;}
protected String _nodeName;
public String getNodeName(){return _nodeName;}
public void setNodeName(String nodeName){_nodeName=nodeName;}
protected String _contextPath;
public String getContextPath(){return _contextPath;}
public void setContextPath(String contextPath){_contextPath=contextPath;}
protected String _uid;
public String getUID(){return _uid;}
//----------------------------------------
// GeronimoMBeanTarget
//----------------------------------------
protected MBeanServer _server;
public boolean canStart() {return true;}
public boolean canStop() {return true;}
public void
doStart()
{
_uid=_contextPath; // TODO - what does Greg say ?
_log=LogFactory.getLog(getClass().getName()+"#"+getUID());
_log.info("starting");
// find our cluster
try
{
_cluster=new
ObjectName("geronimo.clustering:role=Cluster,name="+getClusterName()+",node="+getNodeName());
// TODO - should be a static in AbstractCluster
// register our session map with it's Data object
// perhaps we need an intermediate Object representing the WebTier here
// TODO - YES, abstract out..
Data data=(Data)_server.getAttribute(_cluster, "Data");
_log.info("Data:"+data);
// ensure web tier initialised...
Map tiers=data.getTiers(); // immutable, so doesn't need synchronisation
Map web=null;
synchronized (tiers)
{
web=(Map)tiers.get("web");
if (web==null)
{
web=new HashMap();
tiers.put("web", web);
}
// web tier storage now initialised...
}
// insert our own session list into cluster state...
synchronized (web) {web.put(getUID(), _sessions);}
// done !
}
catch (Exception e)
{
_log.error("could not retrieve Cluster state", e);
}
// test stuff
_sessions.put("aaa", new Object());
_sessions.put("bbb", new Object());
_sessions.put("ccc", new Object());
}
public void
doStop()
{
_log.info("stopping");
// TODO - remove our session map from cluster Data
// TODO - leave cluster
}
public void
doFail()
{
_log.info("failing");
// leave cluster ?
}
public void
setMBeanContext(GeronimoMBeanContext context)
{
// _objectName=(context==null)?null:context.getObjectName();
_server=(context==null)?null:context.getServer();
}
public static GeronimoMBeanInfo
getGeronimoMBeanInfo()
{
GeronimoMBeanInfo mbeanInfo=new GeronimoMBeanInfo();
mbeanInfo.setTargetClass(HttpSessionManager.class);
mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("Size", true,
false, "number of extant HttpSessions within this webapp"));
mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("UID", true,
false, "unique identity for this webapp within this vm"));
// TODO - these should probably become RO...
mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("ClusterName", true,
true, "name of Cluster upon which this webapp is deployed"));
mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("NodeName", true,
true, "name of Cluster Node upon which this webapp is deployed"));
mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("ContextPath", true,
true, "context path at which this webapp is deployed"));
return mbeanInfo;
}
}
1.1
incubator-geronimo/modules/clustering/src/java/org/apache/geronimo/clustering/ejb/package.html
Index: package.html
===================================================================
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<title></title>
</head>
<body>
The Geronimo EJB Tier Clustering binding.
</body>
</html>
1.8 +2 -1
incubator-geronimo/modules/clustering/src/java/org/apache/geronimo/clustering/LocalCluster.java
Index: LocalCluster.java
===================================================================
RCS file:
/home/cvs/incubator-geronimo/modules/clustering/src/java/org/apache/geronimo/clustering/LocalCluster.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- LocalCluster.java 31 Dec 2003 14:51:44 -0000 1.7
+++ LocalCluster.java 2 Jan 2004 14:19:04 -0000 1.8
@@ -174,6 +174,7 @@
GeronimoMBeanInfo mbeanInfo=AbstractCluster.getGeronimoMBeanInfo();
mbeanInfo.setTargetClass(LocalCluster.class);
mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("Members", true,
false, "List of cluster members"));
+ mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("Data", true,
false, "cluster state"));
return mbeanInfo;
}
}
1.2 +18 -6
incubator-geronimo/modules/clustering/src/java/org/apache/geronimo/clustering/Data.java
Index: Data.java
===================================================================
RCS file:
/home/cvs/incubator-geronimo/modules/clustering/src/java/org/apache/geronimo/clustering/Data.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Data.java 30 Dec 2003 15:32:20 -0000 1.1
+++ Data.java 2 Jan 2004 14:19:04 -0000 1.2
@@ -62,7 +62,21 @@
/**
* An object capable of holding the state of multiple applications and
- * tiers.
+ * tiers. This will be a Map of tiers (web, ejb, ...). Each tier may
+ * choose how to organise it's own Map. e.g. Web tier will use a Map
+ * of webapps. Each webapp being represented by a Map of
+ * HttpSessionID:HttpSession. Assuming that all IDs where GUIDs, it
+ * would be posible to collapse all webapps together (and maybe all
+ * tiers), thus avoiding dehashing overhead with each lookup coming
+ * over the Cluster. I've considered this and decided that the extra
+ * partitioning of the data that I am doing, will result in much less
+ * contention on the Map used (particularly upon e.g. session
+ * creation), furthermore, by retaining references into the
+ * above-described structure, and distributing e.g. deltas across
+ * e.g. webapp specific Channels, this dehashing overhead could be
+ * avoided.<p> By using a Map of tiers, we avoid closing the set of
+ * clusterable services, but incur a little more synchronisation
+ * overhead on lookups, consider...
*
* @version $Revision$ $Date$
*/
@@ -70,9 +84,7 @@
Data
{
protected static Log _log=LogFactory.getLog(Data.class);
+ protected Map _tiers=new HashMap();
- protected Map _web=new HashMap(); // Map of webapps context:sessioms
- protected Map _ejb=new HashMap(); // Map of ejb
?type?:[stateful]sessions
- protected Object _jndi; // ???
- //...
+ public Map getTiers(){return _tiers;};
}
1.6 +2 -2
incubator-geronimo/modules/clustering/src/java/org/apache/geronimo/clustering/AbstractCluster.java
Index: AbstractCluster.java
===================================================================
RCS file:
/home/cvs/incubator-geronimo/modules/clustering/src/java/org/apache/geronimo/clustering/AbstractCluster.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- AbstractCluster.java 31 Dec 2003 14:51:44 -0000 1.5
+++ AbstractCluster.java 2 Jan 2004 14:19:04 -0000 1.6
@@ -55,8 +55,8 @@
*/
package org.apache.geronimo.clustering;
-import javax.management.ObjectName;
+import javax.management.ObjectName;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.geronimo.kernel.service.GeronimoAttributeInfo;
1.4 +13 -0
incubator-geronimo/modules/clustering/src/deploy/clustering-service.xml
Index: clustering-service.xml
===================================================================
RCS file:
/home/cvs/incubator-geronimo/modules/clustering/src/deploy/clustering-service.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- clustering-service.xml 30 Dec 2003 21:16:03 -0000 1.3
+++ clustering-service.xml 2 Jan 2004 14:19:04 -0000 1.4
@@ -46,4 +46,17 @@
>
</mbean>
+ <!-- ============================================================ -->
+ <!-- Start a test distributable HttpSessionManager... -->
+ <!-- ============================================================ -->
+
+ <mbean
+ descriptor="org.apache.geronimo.clustering.web.HttpSessionManager"
+
name="geronimo.clustering:role=HttpSessionManager,context=/dummy,cluster=GERONIMO,node=0"
+ >
+ <attribute name="ClusterName">GERONIMO</attribute>
+ <attribute name="NodeName">0</attribute>
+ <attribute name="ContextPath">/dummy</attribute>
+ </mbean>
+
</components>