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 Scott Ferguson
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.ServerConnectorMXBean;
035:
036: import java.util.Date;
037:
038: /**
039: * Implementation of the ClusterClient's administration mbean.
040: */
041: public class ServerConnectorAdmin extends AbstractManagedObject
042: implements ServerConnectorMXBean {
043: private final ServerConnector _client;
044:
045: public ServerConnectorAdmin(ServerConnector client) {
046: _client = client;
047: }
048:
049: /**
050: * Returns the -server id.
051: */
052: public String getName() {
053: return _client.getId();
054: }
055:
056: public String getType() {
057: return "ServerConnector";
058: }
059:
060: /**
061: * Returns the owning cluster's object name.
062: */
063: public ClusterMXBean getCluster() {
064: return _client.getCluster().getAdmin();
065: }
066:
067: /**
068: * Returns the cluster index.
069: */
070: public int getClusterIndex() {
071: return _client.getIndex();
072: }
073:
074: /**
075: * Returns the server's IP address.
076: */
077: public String getAddress() {
078: return _client.getAddress();
079: }
080:
081: /**
082: * Returns the server's port.
083: */
084: public int getPort() {
085: return _client.getPort();
086: }
087:
088: //
089: // Client connection/load-balancing parameters
090: //
091:
092: /**
093: * Returns the time the client will consider the connection dead
094: * before retrying.
095: */
096: public long getRecoverTime() {
097: return _client.getLoadBalanceRecoverTime();
098: }
099:
100: /**
101: * Returns the maximum time a socket can remain idle in the pool.
102: */
103: public long getIdleTime() {
104: return _client.getLoadBalanceIdleTime();
105: }
106:
107: /**
108: * Returns the connect timeout for a client.
109: */
110: public long getConnectTimeout() {
111: return _client.getLoadBalanceConnectTimeout();
112: }
113:
114: /**
115: * Returns the socket timeout for a client.
116: */
117: public long getSocketTimeout() {
118: return _client.getLoadBalanceSocketTimeout();
119: }
120:
121: /**
122: * Returns the warmup time in milliseconds.
123: */
124: public long getWarmupTime() {
125: return _client.getLoadBalanceWarmupTime();
126: }
127:
128: /**
129: * Returns the load-balance weight.
130: */
131: public int getWeight() {
132: return _client.getLoadBalanceWeight();
133: }
134:
135: //
136: // State
137: //
138:
139: public String getState() {
140: return _client.getState();
141: }
142:
143: public int getConnectionActiveCount() {
144: return _client.getActiveCount();
145: }
146:
147: public int getConnectionIdleCount() {
148: return _client.getIdleCount();
149: }
150:
151: public long getConnectionNewCountTotal() {
152: return _client.getConnectCountTotal();
153: }
154:
155: public long getConnectionFailCountTotal() {
156: return _client.getFailCountTotal();
157: }
158:
159: public Date getLastFailTime() {
160: return _client.getLastFailTime();
161: }
162:
163: public Date getLastSuccessTime() {
164: return new Date(_client.getLastSuccessTime());
165: }
166:
167: public double getLatencyFactor() {
168: return _client.getLatencyFactor();
169: }
170:
171: public long getConnectionBusyCountTotal() {
172: return _client.getBusyCountTotal();
173: }
174:
175: public Date getLastBusyTime() {
176: return _client.getLastBusyTime();
177: }
178:
179: public long getConnectionKeepaliveCountTotal() {
180: return _client.getKeepaliveCountTotal();
181: }
182:
183: public double getServerCpuLoadAvg() {
184: return _client.getCpuLoadAvg();
185: }
186:
187: public void start() {
188: _client.start();
189: }
190:
191: public void stop() {
192: _client.stop();
193: }
194:
195: public void enableSessionOnly() {
196: _client.enableSessionOnly();
197: }
198:
199: public boolean ping() {
200: return _client.canConnect();
201: }
202:
203: protected void register() {
204: registerSelf();
205: }
206:
207: public String toString() {
208: return "ClusterClientAdmin[" + getObjectName() + "]";
209: }
210: }
|