001: /**
002: * Sequoia: Database clustering technology.
003: * Copyright (C) 2002-2004 French National Institute For Research In Computer
004: * Science And Control (INRIA).
005: * Copyright (C) 2005 AmicoSoft, Inc. dba Emic Networks
006: * Contact: sequoia@continuent.org
007: *
008: * Licensed under the Apache License, Version 2.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: * Initial developer(s): Nicolas Modrzyk.
021: * Contributor(s): Emmanuel Cecchet.
022: */package org.continuent.sequoia.common.jmx.monitoring;
023:
024: import org.continuent.sequoia.common.i18n.Translate;
025:
026: /**
027: * Name convertions for data collection types.
028: *
029: * @author <a href="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk </a>
030: * @author <a href="mailto:emmanuel.cecchet@emicnetworks.com">Emmanuel Cecchet
031: * </a>
032: */
033: public final class DataCollectionNames {
034: /**
035: * Convert the type reference of a collector into a <code>String</code>
036: *
037: * @param dataType see DataCollection
038: * @return a <code>String</code> that describes the collector
039: */
040: public static String get(int dataType) {
041: switch (dataType) {
042: /*
043: * Controller Collectors
044: */
045: case DataCollection.CONTROLLER_TOTAL_MEMORY:
046: return Translate.get("monitoring.controller.total.memory"); //$NON-NLS-1$
047: case DataCollection.CONTROLLER_USED_MEMORY:
048: return Translate.get("monitoring.controller.used.memory"); //$NON-NLS-1$
049: case DataCollection.CONTROLLER_WORKER_PENDING_QUEUE:
050: return Translate.get("monitoring.controller.pending.queue"); //$NON-NLS-1$
051: case DataCollection.CONTROLLER_THREADS_NUMBER:
052: return Translate
053: .get("monitoring.controller.threads.number"); //$NON-NLS-1$
054: case DataCollection.CONTROLLER_IDLE_WORKER_THREADS:
055: return Translate
056: .get("monitoring.controller.idle.worker.threads"); //$NON-NLS-1$
057: /*
058: * Backend collectors
059: */
060: case DataCollection.BACKEND_ACTIVE_TRANSACTION:
061: return Translate
062: .get("monitoring.backend.active.transactions"); //$NON-NLS-1$
063: case DataCollection.BACKEND_PENDING_REQUESTS:
064: return Translate.get("monitoring.backend.pending.requests"); //$NON-NLS-1$
065: case DataCollection.BACKEND_TOTAL_ACTIVE_CONNECTIONS:
066: return Translate
067: .get("monitoring.backend.active.connections"); //$NON-NLS-1$
068: case DataCollection.BACKEND_TOTAL_REQUEST:
069: return Translate.get("monitoring.backend.total.requests"); //$NON-NLS-1$
070: case DataCollection.BACKEND_TOTAL_READ_REQUEST:
071: return Translate
072: .get("monitoring.backend.total.read.requests"); //$NON-NLS-1$
073: case DataCollection.BACKEND_TOTAL_WRITE_REQUEST:
074: return Translate
075: .get("monitoring.backend.total.write.requests"); //$NON-NLS-1$
076: case DataCollection.BACKEND_TOTAL_TRANSACTIONS:
077: return Translate
078: .get("monitoring.backend.total.transactions"); //$NON-NLS-1$
079: /*
080: * VirtualDatabase collectors
081: */
082: case DataCollection.DATABASES_ACTIVE_THREADS:
083: return Translate
084: .get("monitoring.virtualdatabase.active.threads"); //$NON-NLS-1$
085: case DataCollection.DATABASES_PENDING_CONNECTIONS:
086: return Translate
087: .get("monitoring.virtualdatabase.pending.connections"); //$NON-NLS-1$
088: case DataCollection.DATABASES_NUMBER_OF_THREADS:
089: return Translate
090: .get("monitoring.virtualdatabase.threads.count"); //$NON-NLS-1$
091: /*
092: * Cache stats collectors
093: */
094: case DataCollection.CACHE_STATS_COUNT_HITS:
095: return Translate.get("monitoring.cache.count.hits"); //$NON-NLS-1$
096: case DataCollection.CACHE_STATS_COUNT_INSERT:
097: return Translate.get("monitoring.cache.count.insert"); //$NON-NLS-1$
098: case DataCollection.CACHE_STATS_COUNT_SELECT:
099: return Translate.get("monitoring.cache.count.select"); //$NON-NLS-1$
100: case DataCollection.CACHE_STATS_HITS_PERCENTAGE:
101: return Translate.get("monitoring.cache.hits.ratio"); //$NON-NLS-1$
102: case DataCollection.CACHE_STATS_NUMBER_ENTRIES:
103: return Translate.get("monitoring.cache.number.entries"); //$NON-NLS-1$
104: /*
105: * Scheduler collectors
106: */
107: case DataCollection.SCHEDULER_NUMBER_READ:
108: return Translate.get("monitoring.scheduler.number.read"); //$NON-NLS-1$
109: case DataCollection.SCHEDULER_NUMBER_REQUESTS:
110: return Translate
111: .get("monitoring.scheduler.number.requests"); //$NON-NLS-1$
112: case DataCollection.SCHEDULER_NUMBER_WRITES:
113: return Translate.get("monitoring.scheduler.number.writes"); //$NON-NLS-1$
114: case DataCollection.SCHEDULER_PENDING_TRANSACTIONS:
115: return Translate
116: .get("monitoring.scheduler.pending.transactions"); //$NON-NLS-1$
117: case DataCollection.SCHEDULER_PENDING_WRITES:
118: return Translate.get("monitoring.scheduler.pending.writes"); //$NON-NLS-1$
119: /*
120: * Client collectors
121: */
122: case DataCollection.CLIENT_TIME_ACTIVE:
123: return Translate.get("monitoring.client.active.time"); //$NON-NLS-1$
124:
125: /*
126: * Unknown collector
127: */
128: default:
129: return "";
130: }
131: }
132:
133: /**
134: * Return the type of the collector corresponding to the command
135: *
136: * @param command to get type form
137: * @return an <code>int</code>
138: */
139: public static int getTypeFromCommand(String command) {
140: command = command.replace('_', ' ');
141: /*
142: * Controller Collectors
143: */
144: if (command.equalsIgnoreCase(Translate
145: .get("monitoring.controller.total.memory"))) //$NON-NLS-1$
146: return DataCollection.CONTROLLER_TOTAL_MEMORY;
147: else if (command.equalsIgnoreCase(Translate
148: .get("monitoring.controller.used.memory"))) //$NON-NLS-1$
149: return DataCollection.CONTROLLER_USED_MEMORY;
150: else if (command.equalsIgnoreCase(Translate
151: .get("monitoring.controller.pending.queue"))) //$NON-NLS-1$
152: return DataCollection.CONTROLLER_WORKER_PENDING_QUEUE;
153: else if (command.equalsIgnoreCase(Translate
154: .get("monitoring.controller.threads.number"))) //$NON-NLS-1$
155: return DataCollection.CONTROLLER_THREADS_NUMBER;
156: else if (command.equalsIgnoreCase(Translate
157: .get("monitoring.controller.idle.worker.threads"))) //$NON-NLS-1$
158: return DataCollection.CONTROLLER_IDLE_WORKER_THREADS;
159:
160: /*
161: * Backend collectors
162: */
163: else if (command.equalsIgnoreCase(Translate
164: .get("monitoring.backend.active.transactions"))) //$NON-NLS-1$
165: return DataCollection.BACKEND_ACTIVE_TRANSACTION;
166: else if (command.equalsIgnoreCase(Translate
167: .get("monitoring.backend.pending.requests"))) //$NON-NLS-1$
168: return DataCollection.BACKEND_PENDING_REQUESTS;
169: else if (command.equalsIgnoreCase(Translate
170: .get("monitoring.backend.active.connections"))) //$NON-NLS-1$
171: return DataCollection.BACKEND_TOTAL_ACTIVE_CONNECTIONS;
172: else if (command.equalsIgnoreCase(Translate
173: .get("monitoring.backend.total.read.requests"))) //$NON-NLS-1$
174: return DataCollection.BACKEND_TOTAL_READ_REQUEST;
175: else if (command.equalsIgnoreCase(Translate
176: .get("monitoring.backend.total.write.requests"))) //$NON-NLS-1$
177: return DataCollection.BACKEND_TOTAL_WRITE_REQUEST;
178: else if (command.equalsIgnoreCase(Translate
179: .get("monitoring.backend.total.requests"))) //$NON-NLS-1$
180: return DataCollection.BACKEND_TOTAL_REQUEST;
181: else if (command.equalsIgnoreCase(Translate
182: .get("monitoring.backend.total.transactions"))) //$NON-NLS-1$
183: return DataCollection.BACKEND_TOTAL_TRANSACTIONS;
184:
185: /*
186: * VirtualDatabase collectors
187: */
188: else if (command.equalsIgnoreCase(Translate
189: .get("monitoring.virtualdatabase.active.threads"))) //$NON-NLS-1$
190: return DataCollection.DATABASES_ACTIVE_THREADS;
191: else if (command.equalsIgnoreCase(Translate
192: .get("monitoring.virtualdatabase.pending.connections"))) //$NON-NLS-1$
193: return DataCollection.DATABASES_PENDING_CONNECTIONS;
194: else if (command.equalsIgnoreCase(Translate
195: .get("monitoring.virtualdatabase.threads.count"))) //$NON-NLS-1$
196: return DataCollection.DATABASES_NUMBER_OF_THREADS;
197:
198: /*
199: * Cache stats collectors
200: */
201: else if (command.equalsIgnoreCase(Translate
202: .get("monitoring.cache.count.hits"))) //$NON-NLS-1$
203: return DataCollection.CACHE_STATS_COUNT_HITS;
204: else if (command.equalsIgnoreCase(Translate
205: .get("monitoring.cache.count.insert"))) //$NON-NLS-1$
206: return DataCollection.CACHE_STATS_COUNT_INSERT;
207: else if (command.equalsIgnoreCase(Translate
208: .get("monitoring.cache.count.select"))) //$NON-NLS-1$
209: return DataCollection.CACHE_STATS_COUNT_SELECT;
210: else if (command.equalsIgnoreCase(Translate
211: .get("monitoring.cache.hits.ratio"))) //$NON-NLS-1$
212: return DataCollection.CACHE_STATS_HITS_PERCENTAGE;
213: else if (command.equalsIgnoreCase(Translate
214: .get("monitoring.cache.number.entries"))) //$NON-NLS-1$
215: return DataCollection.CACHE_STATS_NUMBER_ENTRIES;
216:
217: /*
218: * Scheduler collectors
219: */
220: else if (command.equalsIgnoreCase(Translate
221: .get("monitoring.scheduler.number.read"))) //$NON-NLS-1$
222: return DataCollection.SCHEDULER_NUMBER_READ;
223: else if (command.equalsIgnoreCase(Translate
224: .get("monitoring.scheduler.number.requests"))) //$NON-NLS-1$
225: return DataCollection.SCHEDULER_NUMBER_REQUESTS;
226: else if (command.equalsIgnoreCase(Translate
227: .get("monitoring.scheduler.number.writes"))) //$NON-NLS-1$
228: return DataCollection.SCHEDULER_NUMBER_WRITES;
229: else if (command.equalsIgnoreCase(Translate
230: .get("monitoring.scheduler.pending.transactions"))) //$NON-NLS-1$
231: return DataCollection.SCHEDULER_PENDING_TRANSACTIONS;
232: else if (command.equalsIgnoreCase(Translate
233: .get("monitoring.scheduler.pending.writes"))) //$NON-NLS-1$
234: return DataCollection.SCHEDULER_PENDING_WRITES;
235:
236: /*
237: * Client collectors
238: */
239: else if (command.equalsIgnoreCase(Translate
240: .get("monitoring.client.active.time"))) //$NON-NLS-1$
241: return DataCollection.CLIENT_TIME_ACTIVE;
242:
243: else
244: return 0;
245: }
246: }
|