001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Sam
028: */
029:
030: package com.caucho.server.cluster;
031:
032: import com.caucho.management.server.AbstractManagedObject;
033: import com.caucho.management.server.ClusterMXBean;
034: import com.caucho.management.server.HostMXBean;
035: import com.caucho.management.server.PersistentStoreMXBean;
036: import com.caucho.management.server.PortMXBean;
037: import com.caucho.management.server.ResinMXBean;
038: import com.caucho.management.server.ServerConnectorMXBean;
039:
040: public class ClusterAdmin extends AbstractManagedObject implements
041: ClusterMXBean {
042: private final Cluster _cluster;
043:
044: public ClusterAdmin(Cluster cluster) {
045: _cluster = cluster;
046: }
047:
048: public String getName() {
049: return _cluster.getId();
050: }
051:
052: public PortMXBean getPort() {
053: ClusterServer clusterServer = _cluster.getSelfServer();
054:
055: if (clusterServer == null)
056: return null;
057:
058: return clusterServer.getClusterPort().getAdmin();
059: }
060:
061: public ResinMXBean getResin() {
062: return _cluster.getResin().getAdmin();
063: }
064:
065: public PersistentStoreMXBean getPersistentStore() {
066: return null;
067: }
068:
069: public HostMXBean[] getHosts() {
070: return new HostMXBean[0];
071: }
072:
073: public ServerConnectorMXBean[] getServers() {
074: ClusterServer selfServer = _cluster.getSelfServer();
075:
076: ClusterServer[] serverList = _cluster.getServerList();
077:
078: int len = serverList.length;
079:
080: if (selfServer != null)
081: len--;
082:
083: ServerConnectorMXBean[] serverMBeans = new ServerConnectorMXBean[len];
084:
085: int j = 0;
086:
087: for (int i = 0; i < serverList.length; i++) {
088: ClusterServer server = serverList[i];
089:
090: if (server != selfServer)
091: serverMBeans[j++] = server.getServerConnector()
092: .getAdmin();
093: }
094:
095: return serverMBeans;
096: }
097:
098: public String toString() {
099: return "ClusterAdmin[" + getObjectName() + "]";
100: }
101: }
|