KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > clustering > Cluster


1 /**
2  *
3  * Copyright 2003-2004 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.geronimo.clustering;
19
20 import java.util.List JavaDoc;
21
22 import javax.management.ObjectName JavaDoc;
23
24 import org.apache.commons.logging.Log;
25 import org.apache.commons.logging.LogFactory;
26
27 /**
28  * A 'Cluster' is a point of connection between all 'Cluster's with
29  * the same name, running in other VMs. I hope to support different
30  * types of cluster including (initially) SimpleCluster, in which
31  * every node replicates every other node and CleverCluster, which
32  * automagically partitions data into SubClusters etc...
33  *
34  * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
35  */

36 public abstract class
37   Cluster
38   extends NamedMBeanImpl
39 {
40   protected Log _log=LogFactory.getLog(Cluster.class);
41
42   /**
43    * Makes an ObjectName for a Cluster MBean with the given parameters.
44    *
45    * @param clusterName a <code>String</code> value
46    * @return an <code>ObjectName</code> value
47    * @exception Exception if an error occurs
48    */

49   public static ObjectName JavaDoc
50     makeObjectName(String JavaDoc clusterName)
51     throws Exception JavaDoc
52   {
53     return new ObjectName JavaDoc("geronimo.clustering:role=Cluster,name="+clusterName);
54   }
55
56   /**
57    * Return current Cluster members.
58    *
59    * @return a <code>List</code> value
60    */

61   public abstract List JavaDoc getMembers();
62
63   /**
64    * Return the Object which this Cluster is responsible for
65    * maintaining via e.g. replication.
66    *
67    * @return a <code>Data</code> value
68    */

69   public abstract Data getData();
70
71   /**
72    * Add the given node to this Cluster.
73    *
74    * @param member an <code>Object</code> value
75    */

76   public abstract void join(Object JavaDoc member);
77
78   /**
79    * Remove the given node from this Cluster.
80    *
81    * @param member an <code>Object</code> value
82    */

83   public abstract void leave(Object JavaDoc member);
84
85   //----------------------------------------
86
// GeronimoMBeanTarget
87
//----------------------------------------
88

89   public void
90     doStart()
91   {
92     _log.debug("starting");
93   }
94
95   public void
96     doStop()
97   {
98     _log.debug("stopping");
99   }
100
101   public void
102     doFail()
103   {
104     _log.debug("failing");
105   }
106   /*
107   public void
108     setMBeanContext(GeronimoMBeanContext context)
109   {
110     super.setMBeanContext(context);
111     _log=LogFactory.getLog(Cluster.class.getName()+"#"+getName());
112   }
113   */

114     /*
115   public static GeronimoMBeanInfo
116     getGeronimoMBeanInfo()
117   {
118     GeronimoMBeanInfo mbeanInfo=MBeanImpl.getGeronimoMBeanInfo();
119     // set target class in concrete subclasses...
120     mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("Members", true, false, "Cluster's current membership"));
121     mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("Data", true, false, "Cluster's current state"));
122     return mbeanInfo;
123   }
124   */

125 }
126
Popular Tags