1 package org.csc.phynixx.watchdog.jmx;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 import org.csc.phynixx.watchdog.IWatchdog;
25 import org.csc.phynixx.watchdog.WatchdogInfo;
26 import org.csc.phynixx.watchdog.WatchdogRegistry;
27
28 public class WatchdogManagement implements WatchdogManagementMBean {
29
30 public int getCountWatchDogs() throws Exception {
31 return WatchdogRegistry.getTheRegistry().getCountWatchdogs();
32 }
33
34 public void restart() throws Exception {
35
36 WatchdogRegistry.getTheRegistry().restart();
37 }
38
39 public void stop() throws Exception {
40 WatchdogRegistry.getTheRegistry().stop();
41 }
42
43
44 public String[] getWatchdogInfos() throws Exception {
45 WatchdogInfo[] infos = WatchdogRegistry.getTheRegistry().getWatchdogInfos();
46 String[] wds = new String[infos.length];
47 for (int j = 0; j < infos.length; j++) {
48 wds[j] = infos[j].getWatchdogInfo();
49 }
50 return wds;
51 }
52
53
54 public String[][] showWatchdogInfos() {
55 return WatchdogRegistry.getTheRegistry().showWatchdogInfos();
56 }
57
58 public String[] showWatchdogInfo(long id) throws Exception {
59 IWatchdog wd = WatchdogRegistry.getTheRegistry().resolveWatchdogId(new Long(id));
60 if (wd == null) {
61 throw new IllegalArgumentException("ID=" + id + " could not be resolved -> no valid ID");
62 }
63 return new WatchdogInfo(wd).getWatchdogInfos();
64 }
65
66
67 public void restart(long id) throws Exception {
68
69 IWatchdog wd = WatchdogRegistry.getTheRegistry().resolveWatchdogId(new Long(id));
70 if (wd == null) {
71 throw new IllegalArgumentException("ID=" + id + " could not be resolved -> no valid ID");
72 }
73 WatchdogRegistry.getTheRegistry().restart(wd.getId());
74
75
76 }
77
78 public void stop(long id) throws Exception {
79
80 IWatchdog wd = WatchdogRegistry.getTheRegistry().resolveWatchdogId(new Long(id));
81 if (wd == null) {
82 throw new IllegalArgumentException("ID=" + id + " could not be resolved -> no valid ID");
83 }
84
85 WatchdogRegistry.getTheRegistry().stop(wd.getId());
86
87 }
88
89 public void shutdown(long id) throws Exception {
90
91 IWatchdog wd = WatchdogRegistry.getTheRegistry().resolveWatchdogId(new Long(id));
92 if (wd == null) {
93 throw new IllegalArgumentException("ID=" + id + " could not be resolved -> no valid ID");
94 }
95
96 WatchdogRegistry.getTheRegistry().shutdown(wd.getId());
97
98 }
99
100 public void activate(long id) throws Exception {
101
102 IWatchdog wd = WatchdogRegistry.getTheRegistry().resolveWatchdogId(new Long(id));
103 if (wd == null) {
104 throw new IllegalArgumentException("ID=" + id + " could not be resolved -> no valid ID");
105 }
106
107 WatchdogRegistry.getTheRegistry().activate(wd.getId());
108
109 }
110
111 public void deactivate(long id) throws Exception {
112
113 IWatchdog wd = WatchdogRegistry.getTheRegistry().resolveWatchdogId(new Long(id));
114 if (wd == null) {
115 throw new IllegalArgumentException("ID=" + id + " could not be resolved -> no valid ID");
116 }
117
118 WatchdogRegistry.getTheRegistry().deactivate(wd.getId());
119
120 }
121
122
123 }