KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > server > cluster > ClusterAdmin


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Sam
28  */

29
30
31 package com.caucho.server.cluster;
32
33 import com.caucho.management.server.AbstractManagedObject;
34 import com.caucho.management.server.ClusterMXBean;
35 import com.caucho.management.server.HostMXBean;
36 import com.caucho.management.server.PersistentStoreMXBean;
37 import com.caucho.management.server.PortMXBean;
38 import com.caucho.management.server.ServerConnectorMXBean;
39
40 public class ClusterAdmin extends AbstractManagedObject
41   implements ClusterMXBean
42 {
43   private final Cluster _cluster;
44
45   public ClusterAdmin(Cluster cluster)
46   {
47     _cluster = cluster;
48   }
49
50   public String JavaDoc getName()
51   {
52     return _cluster.getId();
53   }
54
55   public PortMXBean getPort()
56   {
57     ClusterServer clusterServer = _cluster.getSelfServer();
58
59     if (clusterServer == null)
60       return null;
61
62      return clusterServer.getClusterPort().getAdmin();
63   }
64
65   public PersistentStoreMXBean getPersistentStore()
66   {
67     return null;
68   }
69
70   public HostMXBean []getHosts()
71   {
72     return new HostMXBean[0];
73   }
74
75   public ServerConnectorMXBean []getServers()
76   {
77     ClusterServer selfServer = _cluster.getSelfServer();
78
79     ClusterServer[] serverList = _cluster.getServerList();
80
81     int len = serverList.length;
82
83     if (selfServer != null)
84       len--;
85
86     ServerConnectorMXBean []serverMBeans = new ServerConnectorMXBean[len];
87
88     int j = 0;
89
90     for (int i = 0; i < serverList.length; i++) {
91       ClusterServer server = serverList[i];
92
93       if (server != selfServer)
94         serverMBeans[j++] = server.getServerConnector().getAdmin();
95     }
96
97     return serverMBeans;
98   }
99
100   public String JavaDoc toString()
101   {
102     return "ClusterAdmin[" + getObjectName() + "]";
103   }
104 }
105
Popular Tags