| 14461 |
danesa |
1 |
/**
|
|
|
2 |
* JOnAS: Java(TM) Open Application Server
|
| 16123 |
eyindanga |
3 |
* Copyright (C) 2009 Bull S.A.S
|
| 14461 |
danesa |
4 |
* Contact: jonas-team@ow2.org
|
|
|
5 |
*
|
|
|
6 |
* This library is free software; you can redistribute it and/or
|
|
|
7 |
* modify it under the terms of the GNU Lesser General Public
|
|
|
8 |
* License as published by the Free Software Foundation; either
|
|
|
9 |
* version 2.1 of the License, or any later version.
|
|
|
10 |
*
|
|
|
11 |
* This library is distributed in the hope that it will be useful,
|
|
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
14 |
* Lesser General Public License for more details.
|
|
|
15 |
*
|
|
|
16 |
* You should have received a copy of the GNU Lesser General Public
|
|
|
17 |
* License along with this library; if not, write to the Free Software
|
|
|
18 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
19 |
* USA
|
|
|
20 |
*
|
|
|
21 |
* --------------------------------------------------------------------------
|
| 15428 |
sauthieg |
22 |
* $Id: AdminHelper.java 18142 2009-08-01 10:32:17Z loverad $
|
| 14461 |
danesa |
23 |
* --------------------------------------------------------------------------
|
|
|
24 |
*/
|
|
|
25 |
package org.ow2.jonas.lib.management.extensions.base;
|
|
|
26 |
|
| 16123 |
eyindanga |
27 |
import java.util.ArrayList;
|
|
|
28 |
import java.util.Hashtable;
|
|
|
29 |
|
|
|
30 |
import javax.management.MBeanServerConnection;
|
|
|
31 |
import javax.management.ObjectName;
|
|
|
32 |
|
|
|
33 |
import org.ow2.jonas.lib.management.extensions.server.ServerItem;
|
|
|
34 |
import org.ow2.jonas.lib.util.JonasObjectName;
|
| 18142 |
loverad |
35 |
|
| 14461 |
danesa |
36 |
/**
|
| 18142 |
loverad |
37 |
* Helper class providing basic info about the current server. Used by
|
|
|
38 |
* management tools.
|
| 14461 |
danesa |
39 |
* @author Adriana Danes
|
|
|
40 |
*/
|
| 16123 |
eyindanga |
41 |
public class AdminHelper {
|
| 18142 |
loverad |
42 |
// --------------------------------------------------------- Public
|
|
|
43 |
// Constants
|
| 16123 |
eyindanga |
44 |
|
|
|
45 |
// Deployment identification number
|
|
|
46 |
public final static int DEPLOYMENT = 0;
|
| 18142 |
loverad |
47 |
|
| 16123 |
eyindanga |
48 |
public final static int DEPLOYMENT_EAR = 1;
|
| 18142 |
loverad |
49 |
|
| 16123 |
eyindanga |
50 |
public final static int DEPLOYMENT_JAR = 2;
|
| 18142 |
loverad |
51 |
|
| 16123 |
eyindanga |
52 |
public final static int DEPLOYMENT_WAR = 3;
|
| 18142 |
loverad |
53 |
|
| 16123 |
eyindanga |
54 |
public final static int DEPLOYMENT_RAR = 4;
|
| 18142 |
loverad |
55 |
|
| 16123 |
eyindanga |
56 |
public final static int DEPLOYMENT_DATASOURCE = 5;
|
| 18142 |
loverad |
57 |
|
| 16123 |
eyindanga |
58 |
public final static int DEPLOYMENT_JMS = 6;
|
| 18142 |
loverad |
59 |
|
| 16123 |
eyindanga |
60 |
public final static int DEPLOYMENT_MAIL = 7;
|
|
|
61 |
|
|
|
62 |
// Deployment identification number for domain management
|
|
|
63 |
public final static int DOMAIN_DEPLOYMENT_EAR = 8;
|
| 18142 |
loverad |
64 |
|
| 16123 |
eyindanga |
65 |
public final static int DOMAIN_DEPLOYMENT_JAR = 9;
|
| 18142 |
loverad |
66 |
|
| 16123 |
eyindanga |
67 |
public final static int DOMAIN_DEPLOYMENT_WAR = 10;
|
| 18142 |
loverad |
68 |
|
| 16123 |
eyindanga |
69 |
public final static int DOMAIN_DEPLOYMENT_RAR = 11;
|
| 18142 |
loverad |
70 |
|
| 17372 |
loverad |
71 |
public final static int DOMAIN_DEPLOYMENT = 12;
|
| 16123 |
eyindanga |
72 |
|
|
|
73 |
// Deployment identification string
|
|
|
74 |
public final static String DEPLOYMENT_STRING_EAR = "ear";
|
| 18142 |
loverad |
75 |
|
| 16123 |
eyindanga |
76 |
public final static String DEPLOYMENT_STRING_JAR = "jar";
|
| 18142 |
loverad |
77 |
|
| 16123 |
eyindanga |
78 |
public final static String DEPLOYMENT_STRING_WAR = "war";
|
| 18142 |
loverad |
79 |
|
| 16123 |
eyindanga |
80 |
public final static String DEPLOYMENT_STRING_RAR = "rar";
|
| 18142 |
loverad |
81 |
|
| 16123 |
eyindanga |
82 |
public final static String DEPLOYMENT_STRING = "*";
|
| 18142 |
loverad |
83 |
|
| 16123 |
eyindanga |
84 |
public final static String DEPLOYMENT_STRING_DATASOURCE = "datasource";
|
| 18142 |
loverad |
85 |
|
| 16123 |
eyindanga |
86 |
public final static String DEPLOYMENT_STRING_JMS = "jms";
|
| 18142 |
loverad |
87 |
|
| 16123 |
eyindanga |
88 |
public final static String DEPLOYMENT_STRING_MAILFACTORY = "mail";
|
|
|
89 |
|
| 18142 |
loverad |
90 |
// Deployment identification strings for domain management
|
| 16123 |
eyindanga |
91 |
public final static String DOMAIN_DEPLOYMENT_STRING_EAR = "domain-ear";
|
| 18142 |
loverad |
92 |
|
| 16123 |
eyindanga |
93 |
public final static String DOMAIN_DEPLOYMENT_STRING_JAR = "domain-jar";
|
| 18142 |
loverad |
94 |
|
| 16123 |
eyindanga |
95 |
public final static String DOMAIN_DEPLOYMENT_STRING_WAR = "domain-war";
|
| 18142 |
loverad |
96 |
|
| 16123 |
eyindanga |
97 |
public final static String DOMAIN_DEPLOYMENT_STRING_RAR = "domain-rar";
|
| 18142 |
loverad |
98 |
|
| 17459 |
loverad |
99 |
public final static String DOMAIN_DEPLOYMENT_STRING = "**";
|
| 16123 |
eyindanga |
100 |
|
| 18142 |
loverad |
101 |
// ------------- protected fields
|
| 16482 |
benoitf |
102 |
protected int applicationServerPort = 0;
|
| 18142 |
loverad |
103 |
|
| 16482 |
benoitf |
104 |
protected String applicationContextPath = null;
|
|
|
105 |
|
|
|
106 |
protected boolean catalinaServer = false;
|
| 18142 |
loverad |
107 |
|
| 16482 |
benoitf |
108 |
protected String currentCatalinaDomainName = null;
|
| 18142 |
loverad |
109 |
|
| 16482 |
benoitf |
110 |
protected String currentCatalinaServiceName = null;
|
| 18142 |
loverad |
111 |
|
| 16482 |
benoitf |
112 |
protected String currentCatalinaEngineName = null;
|
| 18142 |
loverad |
113 |
|
| 16482 |
benoitf |
114 |
protected String currentCatalinaDefaultHostName = null;
|
| 18142 |
loverad |
115 |
|
| 16482 |
benoitf |
116 |
protected boolean jettyServer = false;
|
|
|
117 |
|
| 16123 |
eyindanga |
118 |
// J2EE Management information (used in construction of JSR77 ObjectNames)
|
|
|
119 |
// These names correspond to the server being currently managed
|
|
|
120 |
protected ObjectName currentDomain = null;
|
| 18142 |
loverad |
121 |
|
| 16123 |
eyindanga |
122 |
protected ObjectName currentJonasServer = null;
|
| 18142 |
loverad |
123 |
|
|
|
124 |
// the current jonas node server selected from the treecontrol
|
|
|
125 |
// this var is used for when plotting current server graphs.
|
|
|
126 |
// its creation is due to ambiguous meaning of currentJonasServerName
|
| 16123 |
eyindanga |
127 |
/**
|
| 18142 |
loverad |
128 |
* @uml.property name="currentClusterDaemon"
|
| 16123 |
eyindanga |
129 |
*/
|
|
|
130 |
protected ObjectName currentClusterDaemon = null;
|
| 18142 |
loverad |
131 |
|
|
|
132 |
// before adding a server to a clusterd supervivion, the server to be added
|
|
|
133 |
// should be configured
|
|
|
134 |
// to set infos that are neede by this operation
|
|
|
135 |
// this var is the name of the server to be configured.
|
| 16123 |
eyindanga |
136 |
protected String currentSrvToConfigure = null;
|
|
|
137 |
|
|
|
138 |
/**
|
| 18142 |
loverad |
139 |
* @uml.property name="currentDomainName"
|
| 16123 |
eyindanga |
140 |
*/
|
|
|
141 |
protected String currentDomainName = null;
|
| 18142 |
loverad |
142 |
|
| 16123 |
eyindanga |
143 |
protected String currentJonasServerName = null;
|
| 18142 |
loverad |
144 |
|
|
|
145 |
// the current cluster daemon name
|
| 16123 |
eyindanga |
146 |
/**
|
| 18142 |
loverad |
147 |
* @uml.property name="currentClusterDaemonName"
|
| 16123 |
eyindanga |
148 |
*/
|
|
|
149 |
protected String currentClusterDaemonName = null;
|
|
|
150 |
|
|
|
151 |
// The server hosting JonasAdmin application
|
|
|
152 |
protected String adminJonasServerName = null;
|
| 18142 |
loverad |
153 |
|
| 16123 |
eyindanga |
154 |
// The hosting server's configuration directory
|
|
|
155 |
protected String adminJonasServerConfDir = null;
|
| 18142 |
loverad |
156 |
|
| 16123 |
eyindanga |
157 |
protected boolean theCurrentJonasServer = false;
|
| 18142 |
loverad |
158 |
|
| 16123 |
eyindanga |
159 |
/**
|
|
|
160 |
* Type of deployment in progress : JAR, EAR, WAR, RAR, DATASOURCE.
|
|
|
161 |
*/
|
|
|
162 |
protected int currentJonasDeploymentType = 0;
|
|
|
163 |
|
|
|
164 |
/**
|
| 18142 |
loverad |
165 |
* Hashtable to store cluster daemons attributes. key: clusterd name, value:
|
|
|
166 |
* an attribute
|
| 16123 |
eyindanga |
167 |
*/
|
|
|
168 |
protected Hashtable<String, Hashtable<String, Integer>> clusterdGraphAttributes = null;
|
| 18142 |
loverad |
169 |
|
| 16123 |
eyindanga |
170 |
/**
|
| 18142 |
loverad |
171 |
* List of servers that are already configured for cluster daemon
|
|
|
172 |
* affactation that means they have jonasBase, JavaHome...(cf clusterd.xml)
|
| 16123 |
eyindanga |
173 |
*/
|
|
|
174 |
protected Hashtable<String, ServerItem> configuredServerForClusterDaemonList = null;
|
| 18142 |
loverad |
175 |
|
| 16123 |
eyindanga |
176 |
/**
|
| 18142 |
loverad |
177 |
* new cmi Mbeanserver TODO: Remove this before integfrating newCmi to jons.
|
| 16123 |
eyindanga |
178 |
*/
|
|
|
179 |
protected MBeanServerConnection newCmiMbeanServerConnection = null;
|
| 18142 |
loverad |
180 |
|
| 16123 |
eyindanga |
181 |
/**
|
| 18142 |
loverad |
182 |
* Removed servers for each clusterd used if user did not choose to save
|
|
|
183 |
* server remove operation in clusted.xml
|
| 16123 |
eyindanga |
184 |
*/
|
|
|
185 |
protected Hashtable<String, ArrayList<String>> removedServersPerClusterd = null;
|
|
|
186 |
|
|
|
187 |
protected Hashtable<String, String> variables = new Hashtable();
|
|
|
188 |
|
|
|
189 |
/**
|
|
|
190 |
* Return the current Jonas server name.
|
|
|
191 |
* @return The name
|
|
|
192 |
*/
|
|
|
193 |
public String getCurrentJonasServerName() {
|
|
|
194 |
return currentJonasServerName;
|
|
|
195 |
}
|
|
|
196 |
|
|
|
197 |
/**
|
| 18142 |
loverad |
198 |
* Return the ObjectName of the MBean associated to the current Jonas
|
|
|
199 |
* server.
|
| 16123 |
eyindanga |
200 |
* @return The ObjectName
|
|
|
201 |
*/
|
|
|
202 |
public ObjectName getCurrentJonasServer() {
|
|
|
203 |
return currentJonasServer;
|
|
|
204 |
}
|
|
|
205 |
|
|
|
206 |
/**
|
|
|
207 |
* Return the current J2EE domain ObjectName.
|
|
|
208 |
* @return The ObjectName
|
|
|
209 |
*/
|
|
|
210 |
public ObjectName getCurrentDomain() {
|
|
|
211 |
return currentDomain;
|
|
|
212 |
}
|
|
|
213 |
|
|
|
214 |
/**
|
|
|
215 |
* Return the current J2EE domain name.
|
|
|
216 |
* @return The name
|
|
|
217 |
*/
|
|
|
218 |
public String getCurrentDomainName() {
|
|
|
219 |
return currentDomainName;
|
|
|
220 |
}
|
|
|
221 |
|
| 16482 |
benoitf |
222 |
/**
|
|
|
223 |
* Return the name of the servlet server.
|
|
|
224 |
* @return The name of the servlet server.
|
|
|
225 |
*/
|
|
|
226 |
protected String getServletServerName(final String domainName) throws ManagementException {
|
|
|
227 |
String servletServerName = null;
|
|
|
228 |
ObjectName on = JonasObjectName.webContainerService(domainName);
|
|
|
229 |
if (JonasManagementRepr.isRegistered(on, currentJonasServerName)) {
|
|
|
230 |
servletServerName = (String) JonasManagementRepr.getAttribute(on, "ServerName", currentJonasServerName);
|
|
|
231 |
}
|
|
|
232 |
return servletServerName;
|
|
|
233 |
}
|
| 16123 |
eyindanga |
234 |
|
|
|
235 |
/**
|
| 16482 |
benoitf |
236 |
* Reset the Catalina server properties.
|
|
|
237 |
*/
|
|
|
238 |
protected void resetCatalina() {
|
|
|
239 |
catalinaServer = false;
|
|
|
240 |
currentCatalinaServiceName = null;
|
|
|
241 |
}
|
|
|
242 |
|
|
|
243 |
/**
|
|
|
244 |
* Reset the Jetty server properties.
|
|
|
245 |
*/
|
|
|
246 |
protected void resetJetty() {
|
|
|
247 |
jettyServer = false;
|
|
|
248 |
}
|
|
|
249 |
|
|
|
250 |
/**
|
| 16123 |
eyindanga |
251 |
* Reset the JOnAS server properties.
|
|
|
252 |
*/
|
|
|
253 |
protected void resetJonas() {
|
|
|
254 |
theCurrentJonasServer = false;
|
|
|
255 |
currentJonasServer = null;
|
|
|
256 |
currentJonasServerName = null;
|
|
|
257 |
}
|
|
|
258 |
|
|
|
259 |
/**
|
|
|
260 |
* Reset the domain properties.
|
|
|
261 |
*/
|
|
|
262 |
protected void resetDomain() {
|
|
|
263 |
currentDomain = null;
|
|
|
264 |
currentDomainName = null;
|
|
|
265 |
}
|
|
|
266 |
|
| 18142 |
loverad |
267 |
// -----------------------------misc
|
| 16123 |
eyindanga |
268 |
|
| 16482 |
benoitf |
269 |
public boolean isCatalinaServer() {
|
|
|
270 |
return catalinaServer;
|
| 16123 |
eyindanga |
271 |
}
|
|
|
272 |
|
| 16482 |
benoitf |
273 |
public String getCurrentCatalinaServiceName() {
|
|
|
274 |
return currentCatalinaServiceName;
|
|
|
275 |
}
|
|
|
276 |
|
| 16123 |
eyindanga |
277 |
public boolean isCurrentJonasServer() {
|
|
|
278 |
return theCurrentJonasServer;
|
|
|
279 |
}
|
|
|
280 |
|
|
|
281 |
public int getCurrentJonasDeploymentType() {
|
|
|
282 |
return currentJonasDeploymentType;
|
|
|
283 |
}
|
|
|
284 |
|
|
|
285 |
public void setCurrentJonasDeploymentType(final int currentJonasDeploymentType) {
|
|
|
286 |
this.currentJonasDeploymentType = currentJonasDeploymentType;
|
|
|
287 |
}
|
|
|
288 |
|
| 16482 |
benoitf |
289 |
public int getApplicationServerPort() {
|
|
|
290 |
return applicationServerPort;
|
|
|
291 |
}
|
|
|
292 |
|
|
|
293 |
public String getApplicationContextPath() {
|
|
|
294 |
return applicationContextPath;
|
|
|
295 |
}
|
|
|
296 |
|
|
|
297 |
public String getCurrentCatalinaDefaultHostName() {
|
|
|
298 |
return currentCatalinaDefaultHostName;
|
|
|
299 |
}
|
|
|
300 |
|
|
|
301 |
public String getCurrentCatalinaEngineName() {
|
|
|
302 |
return currentCatalinaEngineName;
|
|
|
303 |
}
|
|
|
304 |
|
|
|
305 |
public String getCurrentCatalinaDomainName() {
|
|
|
306 |
return currentCatalinaDomainName;
|
|
|
307 |
}
|
|
|
308 |
|
|
|
309 |
public boolean isJettyServer() {
|
|
|
310 |
return jettyServer;
|
|
|
311 |
}
|
| 18142 |
loverad |
312 |
|
| 16123 |
eyindanga |
313 |
/**
|
|
|
314 |
* @return Returns the adminJonasServerName.
|
|
|
315 |
*/
|
| 18142 |
loverad |
316 |
public String getAdminJonasServerName() {
|
| 16123 |
eyindanga |
317 |
return adminJonasServerName;
|
|
|
318 |
}
|
|
|
319 |
|
|
|
320 |
public String getAdminJonasServerConfDir() {
|
|
|
321 |
return adminJonasServerConfDir;
|
|
|
322 |
}
|
|
|
323 |
|
|
|
324 |
/**
|
|
|
325 |
* @return
|
| 18142 |
loverad |
326 |
* @uml.property name="currentClusterDaemon"
|
| 16123 |
eyindanga |
327 |
*/
|
|
|
328 |
public ObjectName getCurrentClusterDaemon() {
|
|
|
329 |
return currentClusterDaemon;
|
|
|
330 |
}
|
|
|
331 |
|
|
|
332 |
/**
|
|
|
333 |
* @param currentClusterDaemon
|
| 18142 |
loverad |
334 |
* @uml.property name="currentClusterDaemon"
|
| 16123 |
eyindanga |
335 |
*/
|
|
|
336 |
public void setCurrentClusterDaemon(final ObjectName currentClusterDaemon) {
|
|
|
337 |
this.currentClusterDaemon = currentClusterDaemon;
|
|
|
338 |
}
|
|
|
339 |
|
|
|
340 |
/**
|
|
|
341 |
* @return
|
| 18142 |
loverad |
342 |
* @uml.property name="currentClusterDaemonName"
|
| 16123 |
eyindanga |
343 |
*/
|
|
|
344 |
public String getCurrentClusterDaemonName() {
|
|
|
345 |
return currentClusterDaemonName;
|
|
|
346 |
}
|
|
|
347 |
|
|
|
348 |
/**
|
|
|
349 |
* @param currentClusterDaemonName
|
| 18142 |
loverad |
350 |
* @uml.property name="currentClusterDaemonName"
|
| 16123 |
eyindanga |
351 |
*/
|
|
|
352 |
public void setCurrentClusterDaemonName(final String currentClusterDaemonName) {
|
|
|
353 |
this.currentClusterDaemonName = currentClusterDaemonName;
|
|
|
354 |
}
|
| 18142 |
loverad |
355 |
|
| 16123 |
eyindanga |
356 |
/**
|
|
|
357 |
* @return hashtable containing cluster daemons attributes for graphs
|
|
|
358 |
*/
|
|
|
359 |
public Hashtable<String, ?> getClusterdGraphAttributes() {
|
|
|
360 |
return clusterdGraphAttributes;
|
|
|
361 |
}
|
|
|
362 |
|
| 18142 |
loverad |
363 |
public void setClusterdGraphAttributes(final Hashtable<String, Hashtable<String, Integer>> clusterdGraphAttribute) {
|
|
|
364 |
this.clusterdGraphAttributes = clusterdGraphAttribute;
|
| 16123 |
eyindanga |
365 |
}
|
|
|
366 |
|
|
|
367 |
/**
|
|
|
368 |
*Get a value of given attribute for given cluster daemon
|
|
|
369 |
* @param clusterd the cluster daemon name
|
|
|
370 |
* @param attKey get value of this attribute
|
|
|
371 |
* @return Value of the given attribute for the given cluster daemon -1 else
|
|
|
372 |
* @throws Exception
|
|
|
373 |
*/
|
| 18142 |
loverad |
374 |
public int getClusterdGraphAttribute(final String clusterd, final String attKey) throws Exception {
|
| 16123 |
eyindanga |
375 |
int ret = -1;
|
|
|
376 |
try {
|
|
|
377 |
Hashtable<String, Integer> myHash = clusterdGraphAttributes.get(clusterd);
|
|
|
378 |
if (myHash != null) {
|
|
|
379 |
ret = myHash.get(attKey);
|
|
|
380 |
}
|
|
|
381 |
} catch (Exception e) {
|
| 18142 |
loverad |
382 |
throw new Exception("Cannot find value for attribute " + attKey + " from the cluster daemon named " + clusterd + e);
|
| 16123 |
eyindanga |
383 |
}
|
|
|
384 |
return ret;
|
|
|
385 |
}
|
| 18142 |
loverad |
386 |
|
| 16123 |
eyindanga |
387 |
/**
|
|
|
388 |
*Set given value of given attribute for given cluster daemon
|
|
|
389 |
* @param clusterd the cluster daemon name
|
|
|
390 |
* @param attKey set value of this attribute
|
|
|
391 |
* @param Val the value to set
|
|
|
392 |
* @throws Exception
|
|
|
393 |
*/
|
| 18142 |
loverad |
394 |
public void setClusterdGraphAttribute(final String clusterd, final String attKey, final Integer val) throws Exception {
|
| 16123 |
eyindanga |
395 |
try {
|
| 18142 |
loverad |
396 |
Hashtable<String, Integer> myHash = clusterdGraphAttributes.get(clusterd);
|
|
|
397 |
if (myHash != null) {
|
|
|
398 |
// there is already a valur for this key .
|
|
|
399 |
myHash.remove(attKey);
|
|
|
400 |
myHash.put(attKey, val);
|
|
|
401 |
} else {
|
|
|
402 |
// create the hashtable for the clusterd attributes
|
|
|
403 |
clusterdGraphAttributes.put(clusterd, new Hashtable<String, Integer>());
|
|
|
404 |
// and put the given attribute value
|
|
|
405 |
clusterdGraphAttributes.get(clusterd).put(attKey, val);
|
|
|
406 |
}
|
| 16123 |
eyindanga |
407 |
|
|
|
408 |
} catch (Exception e) {
|
| 18142 |
loverad |
409 |
throw new Exception("Cannot put value for attribute " + attKey + "for the cluster daemon named " + clusterd + e);
|
|
|
410 |
}
|
| 16123 |
eyindanga |
411 |
|
|
|
412 |
}
|
|
|
413 |
|
|
|
414 |
/**
|
|
|
415 |
* @return the currentSrvToConfigure
|
|
|
416 |
*/
|
|
|
417 |
public String getCurrentSrvToConfigure() {
|
|
|
418 |
return currentSrvToConfigure;
|
|
|
419 |
}
|
|
|
420 |
|
|
|
421 |
/**
|
|
|
422 |
* @param currentSrvToConfigure the currentSrvToConfigure to set
|
|
|
423 |
*/
|
|
|
424 |
public void setCurrentSrvToConfigure(final String currentSrvToConfigure) {
|
|
|
425 |
this.currentSrvToConfigure = currentSrvToConfigure;
|
|
|
426 |
}
|
|
|
427 |
|
|
|
428 |
/**
|
|
|
429 |
* The given server has been configuered to be affected to a clusterd.
|
|
|
430 |
* @param srv
|
|
|
431 |
* @throws Exception if the ServerItem parameter is null
|
|
|
432 |
*/
|
|
|
433 |
@SuppressWarnings("unchecked")
|
| 18142 |
loverad |
434 |
public void addSrvConfiguredForClusterd(final ServerItem srv) throws Exception {
|
| 16123 |
eyindanga |
435 |
try {
|
|
|
436 |
if (configuredServerForClusterDaemonList == null) {
|
|
|
437 |
configuredServerForClusterDaemonList = new Hashtable();
|
|
|
438 |
}
|
| 18142 |
loverad |
439 |
configuredServerForClusterDaemonList.remove(srv.getName());
|
| 16123 |
eyindanga |
440 |
configuredServerForClusterDaemonList.put(srv.getName(), srv);
|
|
|
441 |
} catch (NullPointerException e) {
|
|
|
442 |
// TODO: handle exception
|
| 18142 |
loverad |
443 |
throw new Exception("Server item must not be null" + e);
|
| 16123 |
eyindanga |
444 |
}
|
|
|
445 |
}
|
|
|
446 |
|
|
|
447 |
/**
|
| 18142 |
loverad |
448 |
* Gets a server item for the given key. this server has been configured for
|
|
|
449 |
* clusterd affectation.
|
| 16123 |
eyindanga |
450 |
* @param key
|
|
|
451 |
* @return ServerItem corresponding to the given key. null if not found
|
|
|
452 |
* @throws Exception if the ServerItem parameter is null
|
|
|
453 |
*/
|
| 18142 |
loverad |
454 |
public ServerItem getSrvConfiguredForClusterd(final String key) throws Exception {
|
| 16123 |
eyindanga |
455 |
ServerItem ret = null;
|
|
|
456 |
try {
|
|
|
457 |
ret = configuredServerForClusterDaemonList.get(key);
|
|
|
458 |
} catch (NullPointerException e) {
|
| 18142 |
loverad |
459 |
throw new Exception("Server item name must not be Null " + e);
|
|
|
460 |
} finally {
|
| 16123 |
eyindanga |
461 |
return ret;
|
|
|
462 |
}
|
|
|
463 |
|
|
|
464 |
}
|
|
|
465 |
|
|
|
466 |
/**
|
| 18142 |
loverad |
467 |
* Checks if the given server is already configured for being affected to a
|
|
|
468 |
* cluster daemon.
|
| 16123 |
eyindanga |
469 |
* @param srvName the server to find
|
| 18142 |
loverad |
470 |
* @return true if the server is already configured for clusterd
|
|
|
471 |
* affectation.
|
| 16123 |
eyindanga |
472 |
* @throws Exception
|
|
|
473 |
*/
|
| 18142 |
loverad |
474 |
// TODO Remove this method. getSrvConfiguredForClusterd should return Null
|
|
|
475 |
// if serverItem not found.
|
| 16123 |
eyindanga |
476 |
public boolean isConfiguredForClusterd(final String srvName) throws Exception {
|
| 18142 |
loverad |
477 |
// ret == true : the server is already configured for clusterd
|
|
|
478 |
// affectation
|
| 16123 |
eyindanga |
479 |
boolean ret = false;
|
|
|
480 |
try {
|
| 18142 |
loverad |
481 |
ret = configuredServerForClusterDaemonList.containsKey(srvName);
|
| 16123 |
eyindanga |
482 |
} catch (Exception e) {
|
| 18142 |
loverad |
483 |
throw new Exception("Server name or configuredServerForClusterDaemonList attribute is null " + e);
|
| 16123 |
eyindanga |
484 |
}
|
|
|
485 |
return ret;
|
|
|
486 |
}
|
|
|
487 |
|
|
|
488 |
/**
|
|
|
489 |
*clears the configuredServerForClusterDaemonList list
|
|
|
490 |
*/
|
|
|
491 |
public void clearConfigureForClusterList() {
|
|
|
492 |
if (configuredServerForClusterDaemonList != null) {
|
|
|
493 |
configuredServerForClusterDaemonList.clear();
|
|
|
494 |
}
|
|
|
495 |
}
|
|
|
496 |
|
|
|
497 |
/**
|
|
|
498 |
* @param newCmiMbeanServerConnection the newCmiMbeanServerConnection to set
|
|
|
499 |
*/
|
| 18142 |
loverad |
500 |
public void setNewCmiMbeanServerConnection(final MBeanServerConnection newCmiMbeanServerConnection) {
|
| 16123 |
eyindanga |
501 |
this.newCmiMbeanServerConnection = newCmiMbeanServerConnection;
|
|
|
502 |
}
|
| 18142 |
loverad |
503 |
|
|
|
504 |
/**
|
|
|
505 |
* Called when substracting a server to clusterd supervision
|
|
|
506 |
* @param clusterdName the cluster daemon name
|
|
|
507 |
* @param srvName the server to remove
|
|
|
508 |
*/
|
| 16123 |
eyindanga |
509 |
public void addRemovedServer(final String clusterdName, final String srvName) {
|
|
|
510 |
ArrayList<String> removedServers = removedServersPerClusterd.get(clusterdName);
|
|
|
511 |
if (removedServers == null) {
|
|
|
512 |
removedServers = new ArrayList();
|
|
|
513 |
removedServers.add(srvName);
|
|
|
514 |
removedServersPerClusterd.put(clusterdName, removedServers);
|
| 18142 |
loverad |
515 |
} else {
|
| 16123 |
eyindanga |
516 |
removedServers.add(srvName);
|
|
|
517 |
}
|
|
|
518 |
}
|
|
|
519 |
|
| 18142 |
loverad |
520 |
/**
|
|
|
521 |
* Checks if the given server has been removed from clusterd affectation
|
|
|
522 |
* @param clusterdName
|
|
|
523 |
* @param srvName
|
|
|
524 |
* @return
|
|
|
525 |
*/
|
|
|
526 |
|
| 16123 |
eyindanga |
527 |
public boolean isSrvRemovedFromClusterd(final String clusterdName, final String srvName) {
|
|
|
528 |
ArrayList<String> removedServers = removedServersPerClusterd.get(clusterdName);
|
|
|
529 |
if (removedServers != null) {
|
| 18142 |
loverad |
530 |
return removedServers.contains(srvName);
|
| 16123 |
eyindanga |
531 |
}
|
|
|
532 |
return false;
|
|
|
533 |
}
|
|
|
534 |
|
|
|
535 |
/**
|
|
|
536 |
* Called when substracting a server to clusterd supervision
|
|
|
537 |
* @param clusterdName the cluster daemon name
|
|
|
538 |
* @param srvName the server to remove
|
|
|
539 |
*/
|
| 18142 |
loverad |
540 |
public void rmvFromClusterdRemovedList(final String clusterdName, final String srvName) {
|
|
|
541 |
ArrayList<String> removedServers = removedServersPerClusterd.get(clusterdName);
|
|
|
542 |
if (removedServers != null) {
|
|
|
543 |
removedServers.remove(srvName);
|
| 16123 |
eyindanga |
544 |
}
|
| 18142 |
loverad |
545 |
}
|
|
|
546 |
|
|
|
547 |
/**
|
| 16123 |
eyindanga |
548 |
* Add a value for the given key
|
|
|
549 |
* @param key the key to add
|
|
|
550 |
* @param value to add
|
|
|
551 |
*/
|
|
|
552 |
public void addVar(final String key, final String value) {
|
| 18142 |
loverad |
553 |
variables.remove(key);
|
|
|
554 |
variables.put(key, value);
|
| 16123 |
eyindanga |
555 |
}
|
|
|
556 |
|
| 18142 |
loverad |
557 |
/**
|
| 16123 |
eyindanga |
558 |
* Remove a variable
|
|
|
559 |
* @param key the variable key
|
|
|
560 |
*/
|
|
|
561 |
public void removeVar(final String key) {
|
| 18142 |
loverad |
562 |
variables.remove(key);
|
| 16123 |
eyindanga |
563 |
}
|
|
|
564 |
|
|
|
565 |
/**
|
|
|
566 |
* Remove a variable
|
|
|
567 |
* @param key the variable key
|
|
|
568 |
*/
|
|
|
569 |
public String getVar(final String key) {
|
| 18142 |
loverad |
570 |
return variables.get(key);
|
| 16123 |
eyindanga |
571 |
}
|
|
|
572 |
|
| 14461 |
danesa |
573 |
}
|