blob: 0f2a78c11946078878b5405ecb5768a2ba652088 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26package sun.management.snmp.jvmmib;
27
28//
29// Generated by mibgen version 5.0 (06/02/03) when compiling JVM-MANAGEMENT-MIB in standard metadata mode.
30//
31
32// java imports
33//
34import java.io.Serializable;
35
36// jmx imports
37//
38import javax.management.MBeanServer;
39import com.sun.jmx.snmp.SnmpCounter;
40import com.sun.jmx.snmp.SnmpCounter64;
41import com.sun.jmx.snmp.SnmpGauge;
42import com.sun.jmx.snmp.SnmpInt;
43import com.sun.jmx.snmp.SnmpUnsignedInt;
44import com.sun.jmx.snmp.SnmpIpAddress;
45import com.sun.jmx.snmp.SnmpTimeticks;
46import com.sun.jmx.snmp.SnmpOpaque;
47import com.sun.jmx.snmp.SnmpString;
48import com.sun.jmx.snmp.SnmpStringFixed;
49import com.sun.jmx.snmp.SnmpOid;
50import com.sun.jmx.snmp.SnmpNull;
51import com.sun.jmx.snmp.SnmpValue;
52import com.sun.jmx.snmp.SnmpVarBind;
53import com.sun.jmx.snmp.SnmpStatusException;
54
55// jdmk imports
56//
57import com.sun.jmx.snmp.agent.SnmpMib;
58import com.sun.jmx.snmp.agent.SnmpMibGroup;
59import com.sun.jmx.snmp.agent.SnmpStandardObjectServer;
60import com.sun.jmx.snmp.agent.SnmpStandardMetaServer;
61import com.sun.jmx.snmp.agent.SnmpMibSubRequest;
62import com.sun.jmx.snmp.agent.SnmpMibTable;
63import com.sun.jmx.snmp.EnumRowStatus;
64import com.sun.jmx.snmp.SnmpDefinitions;
65
66/**
67 * The class is used for representing SNMP metadata for the "JvmThreading" group.
68 * The group is defined with the following oid: 1.3.6.1.4.1.42.2.145.3.163.1.1.3.
69 */
70public class JvmThreadingMeta extends SnmpMibGroup
71 implements Serializable, SnmpStandardMetaServer {
72
73 /**
74 * Constructor for the metadata associated to "JvmThreading".
75 */
76 public JvmThreadingMeta(SnmpMib myMib, SnmpStandardObjectServer objserv) {
77 objectserver = objserv;
78 try {
79 registerObject(6);
80 registerObject(5);
81 registerObject(4);
82 registerObject(3);
83 registerObject(2);
84 registerObject(1);
85 registerObject(10);
86 registerObject(7);
87 } catch (IllegalAccessException e) {
88 throw new RuntimeException(e.getMessage());
89 }
90 }
91
92 /**
93 * Get the value of a scalar variable
94 */
95 public SnmpValue get(long var, Object data)
96 throws SnmpStatusException {
97 switch((int)var) {
98 case 6:
99 return new SnmpInt(node.getJvmThreadCpuTimeMonitoring());
100
101 case 5:
102 return new SnmpInt(node.getJvmThreadContentionMonitoring());
103
104 case 4:
105 return new SnmpCounter64(node.getJvmThreadTotalStartedCount());
106
107 case 3:
108 return new SnmpCounter(node.getJvmThreadPeakCount());
109
110 case 2:
111 return new SnmpGauge(node.getJvmThreadDaemonCount());
112
113 case 1:
114 return new SnmpGauge(node.getJvmThreadCount());
115
116 case 10: {
117 throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
118 }
119
120 case 7:
121 return new SnmpCounter64(node.getJvmThreadPeakCountReset());
122
123 default:
124 break;
125 }
126 throw new SnmpStatusException(SnmpStatusException.noSuchObject);
127 }
128
129 /**
130 * Set the value of a scalar variable
131 */
132 public SnmpValue set(SnmpValue x, long var, Object data)
133 throws SnmpStatusException {
134 switch((int)var) {
135 case 6:
136 if (x instanceof SnmpInt) {
137 try {
138 node.setJvmThreadCpuTimeMonitoring( new EnumJvmThreadCpuTimeMonitoring (((SnmpInt)x).toInteger()));
139 } catch(IllegalArgumentException e) {
140 throw new SnmpStatusException(SnmpStatusException.snmpRspWrongValue);
141 }
142 return new SnmpInt(node.getJvmThreadCpuTimeMonitoring());
143 } else {
144 throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
145 }
146
147 case 5:
148 if (x instanceof SnmpInt) {
149 try {
150 node.setJvmThreadContentionMonitoring( new EnumJvmThreadContentionMonitoring (((SnmpInt)x).toInteger()));
151 } catch(IllegalArgumentException e) {
152 throw new SnmpStatusException(SnmpStatusException.snmpRspWrongValue);
153 }
154 return new SnmpInt(node.getJvmThreadContentionMonitoring());
155 } else {
156 throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
157 }
158
159 case 4:
160 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
161
162 case 3:
163 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
164
165 case 2:
166 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
167
168 case 1:
169 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
170
171 case 10: {
172 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
173 }
174
175 case 7:
176 if (x instanceof SnmpCounter64) {
177 node.setJvmThreadPeakCountReset(((SnmpCounter64)x).toLong());
178 return new SnmpCounter64(node.getJvmThreadPeakCountReset());
179 } else {
180 throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
181 }
182
183 default:
184 break;
185 }
186 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
187 }
188
189 /**
190 * Check the value of a scalar variable
191 */
192 public void check(SnmpValue x, long var, Object data)
193 throws SnmpStatusException {
194 switch((int) var) {
195 case 6:
196 if (x instanceof SnmpInt) {
197 try {
198 node.checkJvmThreadCpuTimeMonitoring( new EnumJvmThreadCpuTimeMonitoring (((SnmpInt)x).toInteger()));
199 } catch(IllegalArgumentException e) {
200 throw new SnmpStatusException(SnmpStatusException.snmpRspWrongValue);
201 }
202 } else {
203 throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
204 }
205 break;
206
207 case 5:
208 if (x instanceof SnmpInt) {
209 try {
210 node.checkJvmThreadContentionMonitoring( new EnumJvmThreadContentionMonitoring (((SnmpInt)x).toInteger()));
211 } catch(IllegalArgumentException e) {
212 throw new SnmpStatusException(SnmpStatusException.snmpRspWrongValue);
213 }
214 } else {
215 throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
216 }
217 break;
218
219 case 4:
220 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
221
222 case 3:
223 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
224
225 case 2:
226 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
227
228 case 1:
229 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
230
231 case 10: {
232 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
233 }
234
235 case 7:
236 if (x instanceof SnmpCounter64) {
237 node.checkJvmThreadPeakCountReset(((SnmpCounter64)x).toLong());
238 } else {
239 throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
240 }
241 break;
242
243 default:
244 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
245 }
246 }
247
248 /**
249 * Allow to bind the metadata description to a specific object.
250 */
251 protected void setInstance(JvmThreadingMBean var) {
252 node = var;
253 }
254
255
256 // ------------------------------------------------------------
257 //
258 // Implements the "get" method defined in "SnmpMibGroup".
259 // See the "SnmpMibGroup" Javadoc API for more details.
260 //
261 // ------------------------------------------------------------
262
263 public void get(SnmpMibSubRequest req, int depth)
264 throws SnmpStatusException {
265 objectserver.get(this,req,depth);
266 }
267
268
269 // ------------------------------------------------------------
270 //
271 // Implements the "set" method defined in "SnmpMibGroup".
272 // See the "SnmpMibGroup" Javadoc API for more details.
273 //
274 // ------------------------------------------------------------
275
276 public void set(SnmpMibSubRequest req, int depth)
277 throws SnmpStatusException {
278 objectserver.set(this,req,depth);
279 }
280
281
282 // ------------------------------------------------------------
283 //
284 // Implements the "check" method defined in "SnmpMibGroup".
285 // See the "SnmpMibGroup" Javadoc API for more details.
286 //
287 // ------------------------------------------------------------
288
289 public void check(SnmpMibSubRequest req, int depth)
290 throws SnmpStatusException {
291 objectserver.check(this,req,depth);
292 }
293
294 /**
295 * Returns true if "arc" identifies a scalar object.
296 */
297 public boolean isVariable(long arc) {
298
299 switch((int)arc) {
300 case 6:
301 case 5:
302 case 4:
303 case 3:
304 case 2:
305 case 1:
306 case 7:
307 return true;
308 default:
309 break;
310 }
311 return false;
312 }
313
314 /**
315 * Returns true if "arc" identifies a readable scalar object.
316 */
317 public boolean isReadable(long arc) {
318
319 switch((int)arc) {
320 case 6:
321 case 5:
322 case 4:
323 case 3:
324 case 2:
325 case 1:
326 case 7:
327 return true;
328 default:
329 break;
330 }
331 return false;
332 }
333
334
335 // ------------------------------------------------------------
336 //
337 // Implements the "skipVariable" method defined in "SnmpMibGroup".
338 // See the "SnmpMibGroup" Javadoc API for more details.
339 //
340 // ------------------------------------------------------------
341
342 public boolean skipVariable(long var, Object data, int pduVersion) {
343 switch((int)var) {
344 case 4:
345 case 7:
346 if (pduVersion==SnmpDefinitions.snmpVersionOne) return true;
347 break;
348 default:
349 break;
350 }
351 return super.skipVariable(var,data,pduVersion);
352 }
353
354 /**
355 * Return the name of the attribute corresponding to the SNMP variable identified by "id".
356 */
357 public String getAttributeName(long id)
358 throws SnmpStatusException {
359 switch((int)id) {
360 case 6:
361 return "JvmThreadCpuTimeMonitoring";
362
363 case 5:
364 return "JvmThreadContentionMonitoring";
365
366 case 4:
367 return "JvmThreadTotalStartedCount";
368
369 case 3:
370 return "JvmThreadPeakCount";
371
372 case 2:
373 return "JvmThreadDaemonCount";
374
375 case 1:
376 return "JvmThreadCount";
377
378 case 10: {
379 throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
380 }
381
382 case 7:
383 return "JvmThreadPeakCountReset";
384
385 default:
386 break;
387 }
388 throw new SnmpStatusException(SnmpStatusException.noSuchObject);
389 }
390
391 /**
392 * Returns true if "arc" identifies a table object.
393 */
394 public boolean isTable(long arc) {
395
396 switch((int)arc) {
397 case 10:
398 return true;
399 default:
400 break;
401 }
402 return false;
403 }
404
405 /**
406 * Returns the table object identified by "arc".
407 */
408 public SnmpMibTable getTable(long arc) {
409
410 switch((int)arc) {
411 case 10:
412 return tableJvmThreadInstanceTable;
413 default:
414 break;
415 }
416 return null;
417 }
418
419 /**
420 * Register the group's SnmpMibTable objects with the meta-data.
421 */
422 public void registerTableNodes(SnmpMib mib, MBeanServer server) {
423 tableJvmThreadInstanceTable = createJvmThreadInstanceTableMetaNode("JvmThreadInstanceTable", "JvmThreading", mib, server);
424 if ( tableJvmThreadInstanceTable != null) {
425 tableJvmThreadInstanceTable.registerEntryNode(mib,server);
426 mib.registerTableMeta("JvmThreadInstanceTable", tableJvmThreadInstanceTable);
427 }
428
429 }
430
431
432 /**
433 * Factory method for "JvmThreadInstanceTable" table metadata class.
434 *
435 * You can redefine this method if you need to replace the default
436 * generated metadata class with your own customized class.
437 *
438 * @param tableName Name of the table object ("JvmThreadInstanceTable")
439 * @param groupName Name of the group to which this table belong ("JvmThreading")
440 * @param mib The SnmpMib object in which this table is registered
441 * @param server MBeanServer for this table entries (may be null)
442 *
443 * @return An instance of the metadata class generated for the
444 * "JvmThreadInstanceTable" table (JvmThreadInstanceTableMeta)
445 *
446 **/
447 protected JvmThreadInstanceTableMeta createJvmThreadInstanceTableMetaNode(String tableName, String groupName, SnmpMib mib, MBeanServer server) {
448 return new JvmThreadInstanceTableMeta(mib, objectserver);
449 }
450
451 protected JvmThreadingMBean node;
452 protected SnmpStandardObjectServer objectserver = null;
453 protected JvmThreadInstanceTableMeta tableJvmThreadInstanceTable = null;
454}