KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > continuent > sequoia > common > jmx > monitoring > DataCollectionNames


1 /**
2  * Sequoia: Database clustering technology.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Copyright (C) 2005 AmicoSoft, Inc. dba Emic Networks
6  * Contact: sequoia@continuent.org
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  * Initial developer(s): Nicolas Modrzyk.
21  * Contributor(s): Emmanuel Cecchet.
22  */

23
24 package org.continuent.sequoia.common.jmx.monitoring;
25
26 import org.continuent.sequoia.common.i18n.Translate;
27
28 /**
29  * Name convertions for data collection types.
30  *
31  * @author <a HREF="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk </a>
32  * @author <a HREF="mailto:emmanuel.cecchet@emicnetworks.com">Emmanuel Cecchet
33  * </a>
34  */

35 public final class DataCollectionNames
36 {
37   /**
38    * Convert the type reference of a collector into a <code>String</code>
39    *
40    * @param dataType see DataCollection
41    * @return a <code>String</code> that describes the collector
42    */

43   public static String JavaDoc get(int dataType)
44   {
45     switch (dataType)
46     {
47       /*
48        * Controller Collectors
49        */

50       case DataCollection.CONTROLLER_TOTAL_MEMORY :
51         return Translate.get("monitoring.controller.total.memory"); //$NON-NLS-1$
52
case DataCollection.CONTROLLER_USED_MEMORY :
53         return Translate.get("monitoring.controller.used.memory"); //$NON-NLS-1$
54
case DataCollection.CONTROLLER_WORKER_PENDING_QUEUE :
55         return Translate.get("monitoring.controller.pending.queue"); //$NON-NLS-1$
56
case DataCollection.CONTROLLER_THREADS_NUMBER :
57         return Translate.get("monitoring.controller.threads.number"); //$NON-NLS-1$
58
case DataCollection.CONTROLLER_IDLE_WORKER_THREADS :
59         return Translate.get("monitoring.controller.idle.worker.threads"); //$NON-NLS-1$
60
/*
61        * Backend collectors
62        */

63       case DataCollection.BACKEND_ACTIVE_TRANSACTION :
64         return Translate.get("monitoring.backend.active.transactions"); //$NON-NLS-1$
65
case DataCollection.BACKEND_PENDING_REQUESTS :
66         return Translate.get("monitoring.backend.pending.requests"); //$NON-NLS-1$
67
case DataCollection.BACKEND_TOTAL_ACTIVE_CONNECTIONS :
68         return Translate.get("monitoring.backend.active.connections"); //$NON-NLS-1$
69
case DataCollection.BACKEND_TOTAL_REQUEST :
70         return Translate.get("monitoring.backend.total.requests"); //$NON-NLS-1$
71
case DataCollection.BACKEND_TOTAL_READ_REQUEST :
72         return Translate.get("monitoring.backend.total.read.requests"); //$NON-NLS-1$
73
case DataCollection.BACKEND_TOTAL_WRITE_REQUEST :
74         return Translate.get("monitoring.backend.total.write.requests"); //$NON-NLS-1$
75
case DataCollection.BACKEND_TOTAL_TRANSACTIONS :
76         return Translate.get("monitoring.backend.total.transactions"); //$NON-NLS-1$
77
/*
78        * VirtualDatabase collectors
79        */

80       case DataCollection.DATABASES_ACTIVE_THREADS :
81         return Translate.get("monitoring.virtualdatabase.active.threads"); //$NON-NLS-1$
82
case DataCollection.DATABASES_PENDING_CONNECTIONS :
83         return Translate.get("monitoring.virtualdatabase.pending.connections"); //$NON-NLS-1$
84
case DataCollection.DATABASES_NUMBER_OF_THREADS :
85         return Translate.get("monitoring.virtualdatabase.threads.count"); //$NON-NLS-1$
86
/*
87        * Cache stats collectors
88        */

89       case DataCollection.CACHE_STATS_COUNT_HITS :
90         return Translate.get("monitoring.cache.count.hits"); //$NON-NLS-1$
91
case DataCollection.CACHE_STATS_COUNT_INSERT :
92         return Translate.get("monitoring.cache.count.insert"); //$NON-NLS-1$
93
case DataCollection.CACHE_STATS_COUNT_SELECT :
94         return Translate.get("monitoring.cache.count.select"); //$NON-NLS-1$
95
case DataCollection.CACHE_STATS_HITS_PERCENTAGE :
96         return Translate.get("monitoring.cache.hits.ratio"); //$NON-NLS-1$
97
case DataCollection.CACHE_STATS_NUMBER_ENTRIES :
98         return Translate.get("monitoring.cache.number.entries"); //$NON-NLS-1$
99
/*
100        * Scheduler collectors
101        */

102       case DataCollection.SCHEDULER_NUMBER_READ :
103         return Translate.get("monitoring.scheduler.number.read"); //$NON-NLS-1$
104
case DataCollection.SCHEDULER_NUMBER_REQUESTS :
105         return Translate.get("monitoring.scheduler.number.requests"); //$NON-NLS-1$
106
case DataCollection.SCHEDULER_NUMBER_WRITES :
107         return Translate.get("monitoring.scheduler.number.writes"); //$NON-NLS-1$
108
case DataCollection.SCHEDULER_PENDING_TRANSACTIONS :
109         return Translate.get("monitoring.scheduler.pending.transactions"); //$NON-NLS-1$
110
case DataCollection.SCHEDULER_PENDING_WRITES :
111         return Translate.get("monitoring.scheduler.pending.writes"); //$NON-NLS-1$
112
/*
113        * Client collectors
114        */

115       case DataCollection.CLIENT_TIME_ACTIVE :
116         return Translate.get("monitoring.client.active.time"); //$NON-NLS-1$
117

118       /*
119        * Unknown collector
120        */

121       default :
122         return "";
123     }
124   }
125
126   /**
127    * Return the type of the collector corresponding to the command
128    *
129    * @param command to get type form
130    * @return an <code>int</code>
131    */

132   public static int getTypeFromCommand(String JavaDoc command)
133   {
134     command = command.replace('_', ' ');
135     /*
136      * Controller Collectors
137      */

138     if (command.equalsIgnoreCase(Translate
139         .get("monitoring.controller.total.memory"))) //$NON-NLS-1$
140
return DataCollection.CONTROLLER_TOTAL_MEMORY;
141     else if (command.equalsIgnoreCase(Translate
142         .get("monitoring.controller.used.memory"))) //$NON-NLS-1$
143
return DataCollection.CONTROLLER_USED_MEMORY;
144     else if (command.equalsIgnoreCase(Translate
145         .get("monitoring.controller.pending.queue"))) //$NON-NLS-1$
146
return DataCollection.CONTROLLER_WORKER_PENDING_QUEUE;
147     else if (command.equalsIgnoreCase(Translate
148         .get("monitoring.controller.threads.number"))) //$NON-NLS-1$
149
return DataCollection.CONTROLLER_THREADS_NUMBER;
150     else if (command.equalsIgnoreCase(Translate
151         .get("monitoring.controller.idle.worker.threads"))) //$NON-NLS-1$
152
return DataCollection.CONTROLLER_IDLE_WORKER_THREADS;
153
154     /*
155      * Backend collectors
156      */

157     else if (command.equalsIgnoreCase(Translate
158         .get("monitoring.backend.active.transactions"))) //$NON-NLS-1$
159
return DataCollection.BACKEND_ACTIVE_TRANSACTION;
160     else if (command.equalsIgnoreCase(Translate
161         .get("monitoring.backend.pending.requests"))) //$NON-NLS-1$
162
return DataCollection.BACKEND_PENDING_REQUESTS;
163     else if (command.equalsIgnoreCase(Translate
164         .get("monitoring.backend.active.connections"))) //$NON-NLS-1$
165
return DataCollection.BACKEND_TOTAL_ACTIVE_CONNECTIONS;
166     else if (command.equalsIgnoreCase(Translate
167         .get("monitoring.backend.total.read.requests"))) //$NON-NLS-1$
168
return DataCollection.BACKEND_TOTAL_READ_REQUEST;
169     else if (command.equalsIgnoreCase(Translate
170         .get("monitoring.backend.total.write.requests"))) //$NON-NLS-1$
171
return DataCollection.BACKEND_TOTAL_WRITE_REQUEST;
172     else if (command.equalsIgnoreCase(Translate
173         .get("monitoring.backend.total.requests"))) //$NON-NLS-1$
174
return DataCollection.BACKEND_TOTAL_REQUEST;
175     else if (command.equalsIgnoreCase(Translate
176         .get("monitoring.backend.total.transactions"))) //$NON-NLS-1$
177
return DataCollection.BACKEND_TOTAL_TRANSACTIONS;
178
179     /*
180      * VirtualDatabase collectors
181      */

182     else if (command.equalsIgnoreCase(Translate
183         .get("monitoring.virtualdatabase.active.threads"))) //$NON-NLS-1$
184
return DataCollection.DATABASES_ACTIVE_THREADS;
185     else if (command.equalsIgnoreCase(Translate
186         .get("monitoring.virtualdatabase.pending.connections"))) //$NON-NLS-1$
187
return DataCollection.DATABASES_PENDING_CONNECTIONS;
188     else if (command.equalsIgnoreCase(Translate
189         .get("monitoring.virtualdatabase.threads.count"))) //$NON-NLS-1$
190
return DataCollection.DATABASES_NUMBER_OF_THREADS;
191
192     /*
193      * Cache stats collectors
194      */

195     else if (command.equalsIgnoreCase(Translate
196         .get("monitoring.cache.count.hits"))) //$NON-NLS-1$
197
return DataCollection.CACHE_STATS_COUNT_HITS;
198     else if (command.equalsIgnoreCase(Translate
199         .get("monitoring.cache.count.insert"))) //$NON-NLS-1$
200
return DataCollection.CACHE_STATS_COUNT_INSERT;
201     else if (command.equalsIgnoreCase(Translate
202         .get("monitoring.cache.count.select"))) //$NON-NLS-1$
203
return DataCollection.CACHE_STATS_COUNT_SELECT;
204     else if (command.equalsIgnoreCase(Translate
205         .get("monitoring.cache.hits.ratio"))) //$NON-NLS-1$
206
return DataCollection.CACHE_STATS_HITS_PERCENTAGE;
207     else if (command.equalsIgnoreCase(Translate
208         .get("monitoring.cache.number.entries"))) //$NON-NLS-1$
209
return DataCollection.CACHE_STATS_NUMBER_ENTRIES;
210
211     /*
212      * Scheduler collectors
213      */

214     else if (command.equalsIgnoreCase(Translate
215         .get("monitoring.scheduler.number.read"))) //$NON-NLS-1$
216
return DataCollection.SCHEDULER_NUMBER_READ;
217     else if (command.equalsIgnoreCase(Translate
218         .get("monitoring.scheduler.number.requests"))) //$NON-NLS-1$
219
return DataCollection.SCHEDULER_NUMBER_REQUESTS;
220     else if (command.equalsIgnoreCase(Translate
221         .get("monitoring.scheduler.number.writes"))) //$NON-NLS-1$
222
return DataCollection.SCHEDULER_NUMBER_WRITES;
223     else if (command.equalsIgnoreCase(Translate
224         .get("monitoring.scheduler.pending.transactions"))) //$NON-NLS-1$
225
return DataCollection.SCHEDULER_PENDING_TRANSACTIONS;
226     else if (command.equalsIgnoreCase(Translate
227         .get("monitoring.scheduler.pending.writes"))) //$NON-NLS-1$
228
return DataCollection.SCHEDULER_PENDING_WRITES;
229
230     /*
231      * Client collectors
232      */

233     else if (command.equalsIgnoreCase(Translate
234         .get("monitoring.client.active.time"))) //$NON-NLS-1$
235
return DataCollection.CLIENT_TIME_ACTIVE;
236
237     else
238       return 0;
239   }
240 }
241
Popular Tags