KickJava   Java API By Example, From Geeks To Geeks.

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


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 Scott Ferguson
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.ServerConnectorMXBean;
36
37 import java.util.Date JavaDoc;
38
39 /**
40  * Implementation of the ClusterClient's administration mbean.
41  */

42 public class ServerConnectorAdmin extends AbstractManagedObject
43   implements ServerConnectorMXBean
44 {
45   private final ClusterClient _client;
46
47   public ServerConnectorAdmin(ClusterClient client)
48   {
49     _client = client;
50   }
51
52   /**
53    * Returns the -server id.
54    */

55   public String JavaDoc getName()
56   {
57     return _client.getServer().getId();
58   }
59
60   public String JavaDoc getType()
61   {
62     return "ServerConnector";
63   }
64
65   /**
66    * Returns the owning cluster's object name.
67    */

68   public ClusterMXBean getCluster()
69   {
70     return _client.getServer().getCluster().getAdmin();
71   }
72
73   /**
74    * Returns the cluster index.
75    */

76   public int getClusterIndex()
77   {
78     return _client.getServer().getIndex();
79   }
80
81   /**
82    * Returns the server's IP address.
83    */

84   public String JavaDoc getAddress()
85   {
86     return _client.getServer().getAddress();
87   }
88
89   /**
90    * Returns the server's port.
91    */

92   public int getPort()
93   {
94     return _client.getServer().getPort();
95   }
96
97   //
98
// Client connection/load-balancing parameters
99
//
100

101   /**
102    * Returns the time the client will consider the connection dead
103    * before retrying.
104    */

105   public long getRecoverTime()
106   {
107     return _client.getServer().getLoadBalanceRecoverTime();
108   }
109
110   /**
111    * Returns the maximum time a socket can remain idle in the pool.
112    */

113   public long getIdleTime()
114   {
115     return _client.getServer().getLoadBalanceIdleTime();
116   }
117
118   /**
119    * Returns the connect timeout for a client.
120    */

121   public long getConnectTimeout()
122   {
123     return _client.getServer().getLoadBalanceConnectTimeout();
124   }
125
126   /**
127    * Returns the socket timeout for a client.
128    */

129   public long getSocketTimeout()
130   {
131     return _client.getServer().getSocketTimeout();
132   }
133
134   /**
135    * Returns the warmup time in milliseconds.
136    */

137   public long getWarmupTime()
138   {
139     return _client.getServer().getLoadBalanceWarmupTime();
140   }
141
142   /**
143    * Returns the load-balance weight.
144    */

145   public int getWeight()
146   {
147     return _client.getServer().getLoadBalanceWeight();
148   }
149
150   //
151
// State
152
//
153

154   public String JavaDoc getState()
155   {
156     return _client.getState();
157   }
158
159   public int getConnectionActiveCount()
160   {
161     return _client.getActiveCount();
162   }
163
164   public int getConnectionIdleCount()
165   {
166     return _client.getIdleCount();
167   }
168
169   public long getConnectionNewCountTotal()
170   {
171     return _client.getConnectCountTotal();
172   }
173
174   public long getConnectionFailCountTotal()
175   {
176     return _client.getFailCountTotal();
177   }
178
179   public Date JavaDoc getLastFailTime()
180   {
181     return _client.getLastFailTime();
182   }
183
184   public long getConnectionBusyCountTotal()
185   {
186     return _client.getBusyCountTotal();
187   }
188
189   public Date JavaDoc getLastBusyTime()
190   {
191     return _client.getLastBusyTime();
192   }
193
194   public long getConnectionKeepaliveCountTotal()
195   {
196     return _client.getServer().getClient().getKeepaliveCountTotal();
197   }
198
199   public double getServerCpuLoadAvg()
200   {
201     return _client.getServer().getClient().getCpuLoadAvg();
202   }
203
204   public void start()
205   {
206     _client.start();
207   }
208
209   public void stop()
210   {
211     _client.stop();
212   }
213
214   public void enableSessionOnly()
215   {
216     _client.enableSessionOnly();
217   }
218
219   public boolean ping()
220   {
221     return _client.getServer().canConnect();
222   }
223
224   protected void register()
225   {
226     registerSelf();
227   }
228
229   public String JavaDoc toString()
230   {
231     return "ClusterClientAdmin[" + getObjectName() + "]";
232   }
233 }
234
Popular Tags