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