KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > common > monitor > DataCollectionNames


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2002-2005 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Contact: c-jdbc@objectweb.org
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation; either version 2.1 of the License, or any later
10  * version.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20  *
21  * Initial developer(s): Nicolas Modrzyk.
22  * Contributor(s): Emmanuel Cecchet.
23  */

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

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

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

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

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

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

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

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

116       case DataCollection.CLIENT_TIME_ACTIVE :
117         return Translate.get("monitoring.client.time.active");
118
119       /*
120        * Unknown collector
121        */

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

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

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

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

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

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

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

234     else if (command.equalsIgnoreCase(Translate
235         .get("monitoring.client.time.active")))
236       return DataCollection.CLIENT_TIME_ACTIVE;
237
238     else
239       return 0;
240   }
241 }
242
Popular Tags