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/java/org/apache/geronimo/clustering Tier.java Node.java LocalCluster.java Cluster.java
Date Sun, 04 Jan 2004 14:18:06 GMT
jules       2004/01/04 06:18:06

  Modified:    modules/clustering/src/java/org/apache/geronimo/clustering/web
                        WebTier.java HttpSessionManager.java
               modules/clustering/src/java/org/apache/geronimo/clustering/ejb
                        EJBTier.java
               modules/clustering/src/java/org/apache/geronimo/clustering
                        Tier.java Node.java LocalCluster.java Cluster.java
  Log:
  decided to have Cluster, Node, and Tier statically deployed and how to
  hook them up.
  
  Revision  Changes    Path
  1.3       +1 -2      incubator-geronimo/modules/clustering/src/java/org/apache/geronimo/clustering/web/WebTier.java
  
  Index: WebTier.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/clustering/src/java/org/apache/geronimo/clustering/web/WebTier.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WebTier.java	3 Jan 2004 01:42:56 -0000	1.2
  +++ WebTier.java	4 Jan 2004 14:18:06 -0000	1.3
  @@ -79,7 +79,6 @@
   public class
     WebTier
     extends Tier
  -  implements GeronimoMBeanTarget
   {
     protected Log _log=LogFactory.getLog(WebTier.class);
   
  
  
  
  1.4       +24 -18    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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- HttpSessionManager.java	3 Jan 2004 01:42:56 -0000	1.3
  +++ HttpSessionManager.java	4 Jan 2004 14:18:06 -0000	1.4
  @@ -78,7 +78,7 @@
    */
   public class
     HttpSessionManager
  - implements GeronimoMBeanTarget
  +  implements GeronimoMBeanTarget
   {
     protected Log _log=LogFactory.getLog(HttpSessionManager.class);
   
  @@ -90,8 +90,8 @@
   
     public int getSize(){return _sessions.size();}
   
  -  protected ObjectName _tier;
  -  public ObjectName getTier(){return _tier;}
  +  protected Tier _tier;
  +  public Tier getTier(){return _tier;}
   
     protected String _clusterName;
     public String getClusterName(){return _clusterName;}
  @@ -114,7 +114,23 @@
   
     protected MBeanServer _server;
   
  -  public boolean canStart() {return true;}
  +  public boolean
  +    canStart()
  +  {
  +    try
  +    {
  +      // find our tier
  +      _tier=(Tier)_server.getAttribute(Tier.makeObjectName(getClusterName(), getNodeName(),
"web"), "Reference");
  +    }
  +    catch (Exception e)
  +    {
  +      _log.error("could not find Tier", e);
  +      return false;
  +    }
  +
  +    return true;
  +  }
  +
     public boolean canStop() {return true;}
   
     public void
  @@ -123,18 +139,8 @@
       _uid=_contextPath;		// TODO - what does Greg say ?
       _log=LogFactory.getLog(getClass().getName()+"#"+getUID());
       _log.info("starting");
  -    // find our tier
  -
  -    try
  -    {
  -      _tier=Tier.makeObjectName(getClusterName(), getNodeName(), "web");
  -      _server.invoke(_tier, "registerData", new Object[]{getUID(),_sessions}, new String[]{String.class.getName(),Object.class.getName()});
  -      _log.info("sessions registered: "+getUID());
  -    }
  -    catch (Exception e)
  -    {
  -      _log.error("could not retrieve Tier state", e);
  -    }
  +    _tier.registerData(getUID(),_sessions);
  +    _log.info("sessions registered: "+getUID());
   
         // test stuff
       _sessions.put("aaa", new Object());
  @@ -147,7 +153,7 @@
     {
       _log.info("stopping");
   
  -    // TODO - remove our session map from cluster Data
  +    _tier.deregisterData(getUID());
       // TODO - leave cluster
     }
   
  
  
  
  1.3       +1 -2      incubator-geronimo/modules/clustering/src/java/org/apache/geronimo/clustering/ejb/EJBTier.java
  
  Index: EJBTier.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/clustering/src/java/org/apache/geronimo/clustering/ejb/EJBTier.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EJBTier.java	3 Jan 2004 01:42:56 -0000	1.2
  +++ EJBTier.java	4 Jan 2004 14:18:06 -0000	1.3
  @@ -79,7 +79,6 @@
   public class
     EJBTier
     extends Tier
  -  implements GeronimoMBeanTarget
   {
     protected Log _log=LogFactory.getLog(EJBTier.class);
   
  
  
  
  1.2       +25 -16    incubator-geronimo/modules/clustering/src/java/org/apache/geronimo/clustering/Tier.java
  
  Index: Tier.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/clustering/src/java/org/apache/geronimo/clustering/Tier.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Tier.java	3 Jan 2004 01:42:56 -0000	1.1
  +++ Tier.java	4 Jan 2004 14:18:06 -0000	1.2
  @@ -82,7 +82,7 @@
   {
     protected static Log  _log=LogFactory.getLog(Tier.class);
     protected ObjectName  _objectName;
  -  protected ObjectName  _node;
  +  protected Node        _node;
     protected MBeanServer _server;
     protected Data        _data;
     protected Map         _tiers;
  @@ -107,6 +107,14 @@
       return new ObjectName("geronimo.clustering:role=Tier,name="+tierName+",node="+nodeName+",cluster="+clusterName);
     }
   
  +  /**
  +   * Return a local reference to this Object. For tight coupling via
  +   * JMX (bad idea?).
  +   *
  +   * @return a <code>Tier</code> value
  +   */
  +  public Tier getReference(){return this;}
  +
     //----------------------------------------
     // GeronimoMBeanTarget
     //----------------------------------------
  @@ -132,6 +140,16 @@
         return false;
       }
   
  +    try
  +    {
  +      _node=(Node)_server.getAttribute(Node.makeObjectName(getClusterName(), getNodeName()),
"Reference");
  +    }
  +    catch (Exception e)
  +    {
  +      _log.error("could not find Node", e);
  +      return false;
  +    }
  +
       return true;
     }
   
  @@ -142,20 +160,10 @@
     {
       _log.info("starting");
   
  -    // find our node
  -    try
  -    {
  -      _node=Node.makeObjectName(getClusterName(), getNodeName());
  -      // register our session map with it's Data object
  -      Data data=(Data)_server.getAttribute(_node, "Data");
  -      _log.info("Data:"+data);
  -      _tiers=data.getTiers(); // immutable, so doesn't need synchronisation
  -    }
  -    catch (Exception e)
  -    {
  -      _log.error("could not retrieve Node state", e);
  -    }
  -
  +    // register our session map with it's Data object
  +    Data data=_node.getData();
  +    _log.info("Data:"+data);
  +    _tiers=data.getTiers(); // immutable, so doesn't need synchronisation
       _tier=null;
       synchronized (_tiers)
       {
  @@ -189,6 +197,7 @@
     {
       GeronimoMBeanInfo mbeanInfo=new GeronimoMBeanInfo();
       //set target class in concrete subclass
  +    mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("Reference",   true, false, "a
local reference to this Tier"));
       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"));
  
  
  
  1.2       +26 -6     incubator-geronimo/modules/clustering/src/java/org/apache/geronimo/clustering/Node.java
  
  Index: Node.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/clustering/src/java/org/apache/geronimo/clustering/Node.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Node.java	3 Jan 2004 01:42:56 -0000	1.1
  +++ Node.java	4 Jan 2004 14:18:06 -0000	1.2
  @@ -117,6 +117,14 @@
       return new ObjectName("geronimo.clustering:role=Node,name="+nodeName+",cluster="+clusterName);
     }
   
  +  /**
  +   * Return a local reference to this Object. For tight coupling via
  +   * JMX (bad idea?).
  +   *
  +   * @return a <code>Node</code> value
  +   */
  +  public Node getReference(){return this;}
  +
     //----------------------------------------
     // MetaDataListener
     //----------------------------------------
  @@ -182,6 +190,17 @@
         return false;
       }
   
  +    // should we really be altering our state in this method ?
  +    try
  +    {
  +      _cluster=(Cluster)_server.getAttribute(Cluster.makeObjectName(_objectName.getKeyProperty("cluster")),
"Reference");
  +    }
  +    catch (Exception e)
  +    {
  +      _log.error("could not find Cluster", e);
  +      return false;
  +    }
  +
       return true;
     }
   
  @@ -192,7 +211,7 @@
     {
       _log=LogFactory.getLog(getClass().getName()+"#"+getCluster()+"/"+getName());
       _log.info("starting");
  -    _cluster=LocalCluster.find(getCluster()); // TODO abstract out
  +
       synchronized (_cluster)
       {
         Data data=_cluster.getData();
  @@ -228,10 +247,11 @@
     {
       GeronimoMBeanInfo mbeanInfo=new GeronimoMBeanInfo();
       mbeanInfo.setTargetClass(Node.class);
  -    mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("Name",    true, false, "unique
identifier for this Node (within it's Cluster)"));
  -    mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("Cluster", true, false, "unique
identifier for this Node's Cluster"));
  -    mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("Members", true, false, "list
of cluster members"));
  -    mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("Data",    true, false, "cluster
state"));
  +    mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("Reference", true, false, "a local
reference to this Node"));
  +    mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("Name",      true, false, "unique
identifier for this Node (within it's Cluster)"));
  +    mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("Cluster",   true, false, "unique
identifier for this Node's Cluster"));
  +    mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("Members",   true, false, "list
of cluster members"));
  +    mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("Data",      true, false, "cluster
state"));
       return mbeanInfo;
     }
   }
  
  
  
  1.11      +1 -34     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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- LocalCluster.java	3 Jan 2004 01:42:56 -0000	1.10
  +++ LocalCluster.java	4 Jan 2004 14:18:06 -0000	1.11
  @@ -81,39 +81,8 @@
   {
     // class
     protected static Log _log=LogFactory.getLog(LocalCluster.class);
  -  protected static Map _map=new HashMap();
  -
  -  /**
  -   * Return either an existing Cluster, or a freshly created one.
  -   *
  -   * @param name a <code>String</code> value
  -   * @return a <code>LocalCluster</code> value
  -   */
  -  public static LocalCluster
  -    find(String name)
  -  {
  -    synchronized (_map)
  -    {
  -      LocalCluster cluster=(LocalCluster)_map.get(name);
  -
  -      if (cluster==null)
  -      {
  -	cluster=new LocalCluster(name);
  -	_map.put(name, cluster);
  -
  -	_log.trace("created cluster: "+name);
  -      }
  -      else
  -      {
  -	_log.trace("found cluster: "+name);
  -      }
  -
  -      return cluster;
  -    }
  -  }
   
     // instance
  -  protected String _name;
     protected List   _members=new Vector();
   
   
  @@ -122,8 +91,6 @@
      *
      * @param name a <code>String</code> value
      */
  -  protected LocalCluster(String name) {_name=name;}
  -
     public List getMembers(){synchronized (_members){return Collections.unmodifiableList(_members);}}
   
     // MetaData
  
  
  
  1.6       +56 -7     incubator-geronimo/modules/clustering/src/java/org/apache/geronimo/clustering/Cluster.java
  
  Index: Cluster.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/clustering/src/java/org/apache/geronimo/clustering/Cluster.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Cluster.java	3 Jan 2004 01:42:56 -0000	1.5
  +++ Cluster.java	4 Jan 2004 14:18:06 -0000	1.6
  @@ -56,7 +56,10 @@
   package org.apache.geronimo.clustering;
   
   import java.util.List;
  +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;
  @@ -76,6 +79,8 @@
     Cluster
     implements GeronimoMBeanTarget
   {
  +  protected Log _log=LogFactory.getLog(Cluster.class);
  +
     public static ObjectName
       makeObjectName(String clusterName)
       throws Exception
  @@ -83,6 +88,9 @@
       return new ObjectName("geronimo.clustering:role=Cluster,name="+clusterName);
     }
   
  +  protected ObjectName 	_objectName;
  +  protected MBeanServer _server;
  +
     /**
      * Return current Cluster members.
      *
  @@ -99,7 +107,6 @@
      */
     public abstract void join(Object member);
   
  -
     /**
      * Remove the given node from this Cluster.
      *
  @@ -107,22 +114,64 @@
      */
     public abstract void leave(Object member);
   
  +  /**
  +   * Return a local reference to this Object. For tight coupling via
  +   * JMX (bad idea?).
  +   *
  +   * @return a <code>Cluster</code> value
  +   */
  +  public Cluster getReference(){return this;}
  +
     //----------------------------------------
     // GeronimoMBeanTarget
     //----------------------------------------
   
  -  public boolean canStart(){return true;}
  +  public boolean
  +    canStart()
  +  {
  +    if (_objectName.getKeyProperty("name")==null)
  +    {
  +      _log.warn("ClusterMBean name must contain a 'name' property");
  +      return false;
  +    }
  +
  +    return true;
  +  }
  +
     public boolean canStop(){return true;}
  -  public void doStart(){}
  -  public void doStop(){}
  -  public void doFail(){}
  -  public void setMBeanContext(GeronimoMBeanContext context){}
  +
  +  public void
  +    doStart()
  +  {
  +    _log=LogFactory.getLog(Cluster.class.getName()+"#"+_objectName.getKeyProperty("name"));
  +    _log.debug("starting");
  +  }
  +
  +  public void
  +    doStop()
  +  {
  +    _log.debug("stopping");
  +  }
  +
  +  public void
  +    doFail()
  +  {
  +    _log.debug("failing");
  +  }
  +
  +  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 subclasses...
  +    mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("Reference", true, false, "a local
reference to this Cluster"));
       return mbeanInfo;
     }
   }
  
  
  

Mime
View raw message