geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject cvs commit: incubator-geronimo/modules/clustering/src/java/org/apache/geronimo/clustering AbstractCluster.java Cluster.java LocalCluster.java
Date Tue, 30 Dec 2003 21:16:03 GMT
djencks     2003/12/30 13:16:03

  Modified:    modules/clustering maven.xml project.xml
               modules/clustering/src/deploy clustering-service.xml
               modules/clustering/src/java/org/apache/geronimo/clustering
                        AbstractCluster.java Cluster.java LocalCluster.java
  Log:
  Convert clustering to geronimo mbeans and, partly, geronimo code style
  
  Revision  Changes    Path
  1.2       +1 -5      incubator-geronimo/modules/clustering/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/clustering/maven.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- maven.xml	28 Dec 2003 16:10:19 -0000	1.1
  +++ maven.xml	30 Dec 2003 21:16:03 -0000	1.2
  @@ -12,8 +12,4 @@
       <attainGoal name="html2xdoc"/>
     </preGoal>
   
  -  <preGoal name="java:compile">
  -    <attainGoal name="xdoclet:jmxdoclet:compile"/>
  -  </preGoal>
  -
   </project>
  
  
  
  1.2       +1 -32     incubator-geronimo/modules/clustering/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/clustering/project.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- project.xml	28 Dec 2003 16:10:19 -0000	1.1
  +++ project.xml	30 Dec 2003 21:16:03 -0000	1.2
  @@ -111,37 +111,6 @@
       </dependency>
   
   
  -    <dependency>
  -      <id>xdoclet</id>
  -      <version>1.2b2</version>
  -      <properties>
  -        <runtime>false</runtime>
  -      </properties>
  -    </dependency>
  -
  -    <dependency>
  -      <id>xdoclet+xdoclet-module</id>
  -      <version>1.2b2</version>
  -      <properties>
  -        <runtime>false</runtime>
  -      </properties>
  -    </dependency>
  -
  -    <dependency>
  -      <id>xdoclet+jmx-module</id>
  -      <version>1.2b2</version>
  -      <properties>
  -        <runtime>false</runtime>
  -      </properties>
  -    </dependency>
  -
  -    <dependency>
  -      <id>xdoclet+xjavadoc</id>
  -      <version>1.2b2</version>
  -      <properties>
  -        <runtime>false</runtime>
  -      </properties>
  -    </dependency>
   
       <dependency>
         <id>mx4j</id>
  
  
  
  1.3       +5 -5      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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- clustering-service.xml	29 Dec 2003 18:50:11 -0000	1.2
  +++ clustering-service.xml	30 Dec 2003 21:16:03 -0000	1.3
  @@ -17,31 +17,31 @@
     <!-- ============================================================ -->
   
     <mbean
  -    code="org.apache.geronimo.clustering.LocalCluster"
  +    descriptor="org.apache.geronimo.clustering.LocalCluster"
       name="geronimo.clustering:role=Cluster,name=GERONIMO,node=0"
       >
     </mbean>
   
     <mbean
  -    code="org.apache.geronimo.clustering.LocalCluster"
  +    descriptor="org.apache.geronimo.clustering.LocalCluster"
       name="geronimo.clustering:role=Cluster,name=GERONIMO,node=1"
       >
     </mbean>
   
     <mbean
  -    code="org.apache.geronimo.clustering.LocalCluster"
  +    descriptor="org.apache.geronimo.clustering.LocalCluster"
       name="geronimo.clustering:role=Cluster,name=GERONIMO,node=2"
       >
     </mbean>
   
     <mbean
  -    code="org.apache.geronimo.clustering.LocalCluster"
  +    descriptor="org.apache.geronimo.clustering.LocalCluster"
       name="geronimo.clustering:role=Cluster,name=GERONIMO2,node=0"
       >
     </mbean>
   
     <mbean
  -    code="org.apache.geronimo.clustering.LocalCluster"
  +    descriptor="org.apache.geronimo.clustering.LocalCluster"
       name="geronimo.clustering:role=Cluster,name=GERONIMO2,node=1"
       >
     </mbean>
  
  
  
  1.4       +59 -43    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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractCluster.java	29 Dec 2003 18:50:11 -0000	1.3
  +++ AbstractCluster.java	30 Dec 2003 21:16:03 -0000	1.4
  @@ -56,10 +56,13 @@
   package org.apache.geronimo.clustering;
   
   import javax.management.ObjectName;
  +
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  -import org.apache.geronimo.core.service.AbstractManagedComponent;
  -import org.apache.geronimo.core.service.ManagedComponent;
  +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;
   
   /**
    * AbstractCluster abstracts code common to different 'Cluster' impls
  @@ -67,47 +70,60 @@
    *
    *
    * @version $Revision$ $Date$
  - * @jmx:mbean extends="org.apache.geronimo.clustering.Cluster, org.apache.geronimo.kernel.management.StateManageable"
    */
  -public abstract class
  -  AbstractCluster
  -  extends AbstractManagedComponent
  -  implements Cluster, AbstractClusterMBean
  -{
  -  protected static  Log _log=LogFactory.getLog(AbstractCluster.class);
  -
  -  //----------------------------------------
  -  /**
  -   * @jmx.managed-attribute
  -   */
  -  public String
  -    getName()
  -    {
  -      String name=objectName.getKeyProperty("name");
  -
  -      if (name==null)
  -      {
  -	name="GERONIMO";
  -	_log.warn("MBean name should contain 'name' property - defaulting to: "+name);
  -      }
  -
  -      return name;
  -    }
  -
  -  /**
  -   * @jmx.managed-attribute
  -   */
  -  public String
  -    getNode()
  -    {
  -      String node=objectName.getKeyProperty("node");
  -
  -      if (node==null)
  -      {
  -	node="0";
  -	_log.warn("MBean name should contain 'node' property - defaulting to: "+node);
  -      }
  +public abstract class AbstractCluster implements Cluster, GeronimoMBeanTarget {
  +    protected static Log _log = LogFactory.getLog(AbstractCluster.class);
  +    private ObjectName objectName;
  +
  +    public String getName() {
  +        String name = objectName.getKeyProperty("name");
  +
  +        if (name == null) {
  +            name = "GERONIMO";
  +            _log.warn("MBean name should contain 'name' property - defaulting to: " + name);
  +        }
  +
  +        return name;
  +    }
  +
  +    public String getNode() {
  +        String node = objectName.getKeyProperty("node");
  +
  +        if (node == null) {
  +            node = "0";
  +            _log.warn("MBean name should contain 'node' property - defaulting to: " + node);
  +        }
  +
  +        return node;
  +    }
  +
  +    public void setMBeanContext(GeronimoMBeanContext context) {
  +        objectName = (context == null)? null:context.getObjectName();
  +    }
  +
  +    public boolean canStart() {
  +        return true;
  +    }
  +
  +    public void doStart() {
  +    }
  +
  +    public boolean canStop() {
  +        return true;
  +    }
  +
  +    public void doStop() {
  +    }
  +
  +    public void doFail() {
  +    }
  +
  +    public static GeronimoMBeanInfo getGeronimoMBeanInfo() {
  +        GeronimoMBeanInfo mbeanInfo = new GeronimoMBeanInfo();
  +        //set target class in concrete subclass
  +        mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("Name", true, false, "Name
of cluster we are a part of"));
  +        mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("Node", true, false, "Node
id within the cluster"));
  +        return mbeanInfo;
   
  -      return node;
       }
   }
  
  
  
  1.3       +2 -5      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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Cluster.java	28 Dec 2003 19:12:51 -0000	1.2
  +++ Cluster.java	30 Dec 2003 21:16:03 -0000	1.3
  @@ -64,9 +64,6 @@
    *
    * @version $Revision$ $Date$
    */
  -public interface
  -  Cluster
  -  extends ManagedComponent
  -{
  +public interface Cluster {
     public String getName();
   }
  
  
  
  1.6       +85 -94    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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- LocalCluster.java	30 Dec 2003 15:32:20 -0000	1.5
  +++ LocalCluster.java	30 Dec 2003 21:16:03 -0000	1.6
  @@ -55,107 +55,98 @@
    */
   package org.apache.geronimo.clustering;
   
  +import java.util.List;
  +
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  -
  -import java.util.Vector;
  -import java.util.List;
  -import java.util.Collections;
  +import org.apache.geronimo.kernel.service.GeronimoAttributeInfo;
  +import org.apache.geronimo.kernel.service.GeronimoMBeanInfo;
   
   /**
    * An initial Cluster impl, which only clusters within a single
    * VM. Thus development on Clustering can start before an inter-vm
    * transport layer has been put in place...
    *
  - * @jmx:mbean extends="org.apache.geronimo.clustering.AbstractClusterMBean"
    * @version $Revision$ $Date$
    */
  -public class
  -  LocalCluster
  -  extends AbstractCluster
  -  implements LocalClusterMBean, MetaDataListener, DataListener, DataDeltaListener
  -{
  -  protected Log _log=LogFactory.getLog(LocalCluster.class);
  -
  -  // LocalCluster
  -
  -  protected LocalChannel _channel;
  -
  -  /**
  -   * @jmx.managed-attribute
  -   */
  -  public List getMembers(){return _channel.getMembers();}
  -
  -  public void join()  {_channel.join(this);}
  -  public void leave() {_channel.leave(this);}
  -
  -  // StateManageable
  -  public boolean canStart() {return true;}
  -  public boolean canStop()  {return true;}
  -
  -  public void
  -    doStart()
  -  {
  -    _log=LogFactory.getLog(getClass().getName()+"#"+getName()+"/"+getNode());
  -    _log.info("starting");
  -    _channel=LocalChannel.find(getName());
  -    synchronized (_channel)
  -    {
  -      setData(_channel.getData());
  -      join();
  -    }
  -  }
  -
  -  public void
  -    doStop()
  -  {
  -    _log.info("stopping");
  -    leave();
  -  }
  -
  -  public void
  -    doFail()
  -  {
  -    _log.info("failing");
  -    leave();			// ??
  -  }
  -
  -  // MetaDataListener
  -  public void
  -    setMetaData(List members)
  -  {
  -    _log.info("membership changed: "+members);
  -  }
  -
  -  // DataListener
  -  protected Data _data;
  -
  -  // TODO - should probably return byte[] - needs renaming
  -  public Data getData() {return _data;}
  -
  -  // TODO - should probably expect byte[] - needs renaming
  -  public void
  -    setData(Data data)
  -  {
  -    String xtra="we must be the first node up";
  -
  -    if (data!=null)
  -    {
  -      xtra="we are joining an extant cluster";
  -      _data=data;
  -    }
  -    else
  -    {
  -      _data=new Data();
  -    }
  -
  -    _log.debug("initialising data - "+xtra);
  -  }
  -
  -  // DataDeltaListener
  -  public void
  -    applyDataDelta(DataDelta delta)
  -  {
  -    _log.trace("applying data delta - "+delta);
  -  }
  +public class LocalCluster
  +        extends AbstractCluster
  +        implements MetaDataListener, DataListener, DataDeltaListener {
  +    protected Log log = LogFactory.getLog(LocalCluster.class);
  +
  +    // LocalCluster
  +
  +    protected LocalChannel channel;
  +
  +    public List getMembers() {
  +        return channel.getMembers();
  +    }
  +
  +    public void join() {
  +        channel.join(this);
  +    }
  +
  +    public void leave() {
  +        channel.leave(this);
  +    }
  +
  +    public void doStart() {
  +        log = LogFactory.getLog(getClass().getName() + "#" + getName() + "/" + getNode());
  +        log.info("starting");
  +        channel = LocalChannel.find(getName());
  +        synchronized (channel) {
  +            setData(channel.getData());
  +            join();
  +        }
  +    }
  +
  +    public void doStop() {
  +        log.info("stopping");
  +        leave();
  +    }
  +
  +    public void doFail() {
  +        log.info("failing");
  +        leave();			// ??
  +    }
  +
  +    // MetaDataListener
  +    public void setMetaData(List members) {
  +        log.info("membership changed: " + members);
  +    }
  +
  +    // DataListener
  +    protected Data _data;
  +
  +    // TODO - should probably return byte[] - needs renaming
  +    public Data getData() {
  +        return _data;
  +    }
  +
  +    // TODO - should probably expect byte[] - needs renaming
  +    public void
  +            setData(Data data) {
  +        String xtra = "we must be the first node up";
  +
  +        if (data != null) {
  +            xtra = "we are joining an extant cluster";
  +            _data = data;
  +        } else {
  +            _data = new Data();
  +        }
  +
  +        log.debug("initialising data - " + xtra);
  +    }
  +
  +    // DataDeltaListener
  +    public void applyDataDelta(DataDelta delta) {
  +        log.trace("applying data delta - " + delta);
  +    }
  +
  +    public static GeronimoMBeanInfo getGeronimoMBeanInfo() {
  +        GeronimoMBeanInfo mbeanInfo = AbstractCluster.getGeronimoMBeanInfo();
  +        mbeanInfo.setTargetClass(LocalCluster.class);
  +        mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("Members", true, false, "List
of cluster members"));
  +        return mbeanInfo;
  +    }
   }
  
  
  

Mime
View raw message