geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject cvs commit: incubator-geronimo/modules/clustering/src/deploy clustering-service.xml
Date Fri, 02 Jan 2004 17:52:30 GMT
jules       2004/01/02 09:52:30

  Modified:    modules/clustering/src/java/org/apache/geronimo/clustering/web
                        HttpSessionManager.java
               modules/clustering/src/deploy clustering-service.xml
  Added:       modules/clustering/src/java/org/apache/geronimo/clustering/web
                        WebTier.java
               modules/clustering/src/java/org/apache/geronimo/clustering/ejb
                        EJBTier.java
               modules/clustering/src/java/org/apache/geronimo/clustering
                        AbstractTier.java
  Log:
  split out Tier abstraction
  provide basic web and ejb tier impls...
  integrate with existing HttpSessionManager
  
  Revision  Changes    Path
  1.2       +7 -30     incubator-geronimo/modules/clustering/src/java/org/apache/geronimo/clustering/web/HttpSessionManager.java
  
  Index: HttpSessionManager.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/clustering/src/java/org/apache/geronimo/clustering/web/HttpSessionManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HttpSessionManager.java	2 Jan 2004 14:19:04 -0000	1.1
  +++ HttpSessionManager.java	2 Jan 2004 17:52:30 -0000	1.2
  @@ -89,8 +89,8 @@
   
     public int getSize(){return _sessions.size();}
   
  -  protected ObjectName _cluster;
  -  public ObjectName getCluster(){return _cluster;}
  +  protected ObjectName _tier;
  +  public ObjectName getTier(){return _tier;}
   
     protected String _clusterName;
     public String getClusterName(){return _clusterName;}
  @@ -122,36 +122,13 @@
       _uid=_contextPath;		// TODO - what does Greg say ?
       _log=LogFactory.getLog(getClass().getName()+"#"+getUID());
       _log.info("starting");
  -    // find our cluster
  -
  +    // find our tier
   
       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 !
  +      _tier=new ObjectName("geronimo.clustering:role=Tier,name=web,cluster="+getClusterName()+",node="+getNodeName());
// TODO - should be a static in AbstractTier
  +      _server.invoke(_tier, "registerData", new Object[]{getUID(),_sessions}, new String[]{String.class.getName(),Object.class.getName()});
  +      _log.info("sessions registered: "+getUID());
       }
       catch (Exception e)
       {
  
  
  
  1.1                  incubator-geronimo/modules/clustering/src/java/org/apache/geronimo/clustering/web/WebTier.java
  
  Index: WebTier.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 apache@apache.org.
   *
   * 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.Iterator;
  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.AbstractTier;
  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;
  
  /**
   * Responsible for maintaining state stored in the Web tier -
   * i.e. HttpSessions.
   *
   * @version $Revision: 1.1 $ $Date: 2004/01/02 17:52:30 $
   */
  public class
    WebTier
    extends AbstractTier
    implements GeronimoMBeanTarget
  {
    protected Log _log=LogFactory.getLog(WebTier.class);
  
    //----------------------------------------
    // WebTier
    //----------------------------------------
  
    protected Object alloc(){return new HashMap();}
    public Object registerData(String uid, Object data) {synchronized (_tier) {return ((Map)_tier).put(uid,
data);}}
    public Object deregisterData(String uid) {synchronized (_tier){return ((Map)_tier).remove(uid);}}
  
    public int
      getWebAppCount()
    {
      return ((Map)_tier).size();
    }
  
    public int
      getHttpSessionCount()
    {
      int count=0;
      synchronized (_tier)	// values() returns a view, so we need to hold a lock...
      {
        for (Iterator i=((Map)_tier).values().iterator(); i.hasNext();)
        {
  	Map webapp=(Map)i.next();
  	// TODO - how we synchronise here depends on the webapps locking strategy - NYI...
  	synchronized (webapp){count+=webapp.size();}
        }
      }
      return count;
    }
  
    //----------------------------------------
    // GeronimoMBeanTarget
    //----------------------------------------
    public static GeronimoMBeanInfo
      getGeronimoMBeanInfo()
    {
      GeronimoMBeanInfo mbeanInfo=AbstractTier.getGeronimoMBeanInfo();
      mbeanInfo.setTargetClass(WebTier.class);
      mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("WebAppCount", true, false, "Number
of WebApps deployed in this Tier"));
      mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("HttpSessionCount", true, false,
"Number of HttpSessions stored in this Tier"));
      return mbeanInfo;
    }
  }
  
  
  
  1.1                  incubator-geronimo/modules/clustering/src/java/org/apache/geronimo/clustering/ejb/EJBTier.java
  
  Index: EJBTier.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 apache@apache.org.
   *
   * 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.ejb;
  
  import java.util.HashMap;
  import java.util.Iterator;
  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.AbstractTier;
  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;
  
  /**
   * Responsible for maintaining state stored in the EJB tier -
   * i.e. StatefulSessions.
   *
   * @version $Revision: 1.1 $ $Date: 2004/01/02 17:52:30 $
   */
  public class
    EJBTier
    extends AbstractTier
    implements GeronimoMBeanTarget
  {
    protected Log _log=LogFactory.getLog(EJBTier.class);
  
    //----------------------------------------
    // EJBTier
    //----------------------------------------
  
    protected Object alloc(){return new HashMap();}
    public Object registerData(String uid, Object data) {synchronized (_tier) {return ((Map)_tier).put(uid,
data);}}
    public Object deregisterData(String uid) {synchronized (_tier){return ((Map)_tier).remove(uid);}}
  
    public int
      getAppCount()
    {
      return ((Map)_tier).size();
    }
  
    public int
      getStatefulSessionCount()
    {
      int count=0;
      synchronized (_tier)	// values() returns a view, so we need to hold a lock...
      {
        for (Iterator i=((Map)_tier).values().iterator(); i.hasNext();)
        {
  	Map app=(Map)i.next();
  	// TODO - how we synchronise here depends on the apps locking strategy - NYI...
  	synchronized (app){count+=app.size();}
        }
      }
      return count;
    }
  
    //----------------------------------------
    // GeronimoMBeanTarget
    //----------------------------------------
    public static GeronimoMBeanInfo
      getGeronimoMBeanInfo()
    {
      GeronimoMBeanInfo mbeanInfo=AbstractTier.getGeronimoMBeanInfo();
      mbeanInfo.setTargetClass(EJBTier.class);
      mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("AppCount", true, false, "Number
of Apps deployed in this Tier"));
      mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("StatefulSessionCount", true, false,
"Number of Stateful Sessions stored in this Tier"));
      return mbeanInfo;
    }
  }
  
  
  
  1.1                  incubator-geronimo/modules/clustering/src/java/org/apache/geronimo/clustering/AbstractTier.java
  
  Index: AbstractTier.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 apache@apache.org.
   *
   * 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;
  
  import java.util.HashMap;
  import java.util.Map;
  import javax.management.MBeanOperationInfo;
  import javax.management.MBeanServer;
  import javax.management.ObjectName;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  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;
  import org.apache.geronimo.kernel.service.GeronimoOperationInfo;
  import org.apache.geronimo.kernel.service.GeronimoParameterInfo;
  
  /**
   * AbstractTier abstracts code common to different 'Cluster' impls
   * into the same abstract base.
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/01/02 17:52:30 $
   */
  public abstract class
    AbstractTier
    implements GeronimoMBeanTarget
  {
    protected static Log  _log=LogFactory.getLog(AbstractTier.class);
    protected ObjectName  _objectName;
    protected ObjectName  _cluster;
    protected MBeanServer _server;
    protected Data        _data;
    protected Map         _tiers;
    protected Object      _tier;
  
    //----------------------------------------
    // Tier
    //----------------------------------------
  
    // share with other classes ?
    protected String
      getKeyProperty(String key, String dft)
    {
      String value=_objectName.getKeyProperty(key);
  
      if (value==null)
      {
        value=dft;
        _log.warn("MBean name should contain '"+key+"' property - defaulting to: "+value);
      }
  
      return value;
    }
  
    public String getClusterName() {return getKeyProperty("cluster", "GERONIMO");}
    public String getNodeName() {return getKeyProperty("node", "0");}
    public String getName() {return getKeyProperty("name", "unknown_tier");}
  
    protected abstract Object alloc();
    public abstract Object registerData(String uid, Object data);
    public abstract Object deregisterData(String uid);
  
    //----------------------------------------
    // GeronimoMBeanTarget
    //----------------------------------------
  
    public boolean canStart() {return true;}
  
    public synchronized void
      doStart()
    {
      _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);
        _tiers=data.getTiers(); // immutable, so doesn't need synchronisation
      }
      catch (Exception e)
      {
        _log.error("could not retrieve Cluster state", e);
      }
  
      _tier=null;
      synchronized (_tiers)
      {
        _tier=_tiers.get(getName());
        if (_tier==null)
        {
  	_tier=alloc();
  	_tiers.put(getName(), _tier);
        }
        // tier storage now initialised...
      }
    }
  
  
    public boolean canStop() {return true;}
    public void doStop() {}
    public void doFail() {}
  
    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();
      //set target class in concrete subclass
      mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("Name",        true, false, "Name
of this Tier"));
      mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("NodeName",    true, false, "Name
of this Tier's Node"));
      mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("ClusterName", true, false, "Name
of this Tier's Node's Cluster"));
      mbeanInfo.addOperationInfo(new GeronimoOperationInfo("registerData",
  							 new GeronimoParameterInfo[] {new GeronimoParameterInfo("uid", String.class, "uid
of webapp"),new GeronimoParameterInfo("data", Object.class, "data to be held")},
  							 MBeanOperationInfo.ACTION,
  							 "Register data with Tier state manager"));
      return mbeanInfo;
    }
  }
  
  
  
  1.5       +21 -1     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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- clustering-service.xml	2 Jan 2004 14:19:04 -0000	1.4
  +++ clustering-service.xml	2 Jan 2004 17:52:30 -0000	1.5
  @@ -13,7 +13,7 @@
       </class-space>
   
     <!-- ============================================================ -->
  -  <!-- Sets up the Cluster                                          -->
  +  <!-- Start two Clusters containing 5 nodes (all Local)            -->
     <!-- ============================================================ -->
   
     <mbean
  @@ -47,6 +47,25 @@
     </mbean>
   
     <!-- ============================================================ -->
  +  <!-- Web Tier Manager                                             -->
  +  <!-- ============================================================ -->
  +  <mbean
  +    descriptor="org.apache.geronimo.clustering.web.WebTier"
  +    name="geronimo.clustering:role=Tier,name=web,cluster=GERONIMO,node=0"
  +    >
  +  </mbean>
  +
  +  <!-- ============================================================ -->
  +  <!-- EJB Tier Manager                                             -->
  +  <!-- ============================================================ -->
  +
  +  <mbean
  +    descriptor="org.apache.geronimo.clustering.ejb.EJBTier"
  +    name="geronimo.clustering:role=Tier,name=ejb,cluster=GERONIMO,node=0"
  +    >
  +  </mbean>
  +
  +  <!-- ============================================================ -->
     <!-- Start a test distributable HttpSessionManager...             -->
     <!-- ============================================================ -->
   
  @@ -54,6 +73,7 @@
       descriptor="org.apache.geronimo.clustering.web.HttpSessionManager"
       name="geronimo.clustering:role=HttpSessionManager,context=/dummy,cluster=GERONIMO,node=0"
       >
  +        <!-- I use attributes here because these Objects will be created dynamically
insinde the WebContainer -->
           <attribute name="ClusterName">GERONIMO</attribute>
           <attribute name="NodeName">0</attribute>
           <attribute name="ContextPath">/dummy</attribute>
  
  
  

Mime
View raw message