1 /* 2 * Copyright (c) 2003, 2006, 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 "JvmMemory" group. 68 * The group is defined with the following oid: 1.3.6.1.4.1.42.2.145.3.163.1.1.2. 69 */ 70 public class JvmMemoryMeta extends SnmpMibGroup 71 implements Serializable, SnmpStandardMetaServer { 72 private static final long serialVersionUID = 9047644262627149214L; 73 74 /** 75 * Constructor for the metadata associated to "JvmMemory". 76 */ 77 public JvmMemoryMeta(SnmpMib myMib, SnmpStandardObjectServer objserv) { 78 objectserver = objserv; 79 try { 80 registerObject(120); 81 registerObject(23); 82 registerObject(22); 83 registerObject(21); 84 registerObject(110); 85 registerObject(20); 86 registerObject(13); 87 registerObject(12); 88 registerObject(3); 89 registerObject(11); 90 registerObject(2); 91 registerObject(101); 92 registerObject(10); 93 registerObject(1); 94 registerObject(100); 95 } catch (IllegalAccessException e) { 96 throw new RuntimeException(e.getMessage()); 97 } 98 } 99 100 /** 101 * Get the value of a scalar variable 102 */ 103 public SnmpValue get(long var, Object data) 104 throws SnmpStatusException { 105 switch((int)var) { 106 case 120: { 107 throw new SnmpStatusException(SnmpStatusException.noSuchInstance); 108 } 109 110 case 23: 111 return new SnmpCounter64(node.getJvmMemoryNonHeapMaxSize()); 112 113 case 22: 114 return new SnmpCounter64(node.getJvmMemoryNonHeapCommitted()); 115 116 case 21: 117 return new SnmpCounter64(node.getJvmMemoryNonHeapUsed()); 118 119 case 110: { 120 throw new SnmpStatusException(SnmpStatusException.noSuchInstance); 121 } 122 123 case 20: 124 return new SnmpCounter64(node.getJvmMemoryNonHeapInitSize()); 125 126 case 13: 127 return new SnmpCounter64(node.getJvmMemoryHeapMaxSize()); 128 129 case 12: 130 return new SnmpCounter64(node.getJvmMemoryHeapCommitted()); 131 132 case 3: 133 return new SnmpInt(node.getJvmMemoryGCCall()); 134 135 case 11: 136 return new SnmpCounter64(node.getJvmMemoryHeapUsed()); 137 138 case 2: 139 return new SnmpInt(node.getJvmMemoryGCVerboseLevel()); 140 141 case 101: { 142 throw new SnmpStatusException(SnmpStatusException.noSuchInstance); 143 } 144 145 case 10: 146 return new SnmpCounter64(node.getJvmMemoryHeapInitSize()); 147 148 case 1: 149 return new SnmpGauge(node.getJvmMemoryPendingFinalCount()); 150 151 case 100: { 152 throw new SnmpStatusException(SnmpStatusException.noSuchInstance); 153 } 154 155 default: 156 break; 157 } 158 throw new SnmpStatusException(SnmpStatusException.noSuchObject); 159 } 160 161 /** 162 * Set the value of a scalar variable 163 */ 164 public SnmpValue set(SnmpValue x, long var, Object data) 165 throws SnmpStatusException { 166 switch((int)var) { 167 case 120: { 168 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); 169 } 170 171 case 23: 172 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); 173 174 case 22: 175 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); 176 177 case 21: 178 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); 179 180 case 110: { 181 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); 182 } 183 184 case 20: 185 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); 186 187 case 13: 188 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); 189 190 case 12: 191 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); 192 193 case 3: 194 if (x instanceof SnmpInt) { 195 try { 196 node.setJvmMemoryGCCall( new EnumJvmMemoryGCCall (((SnmpInt)x).toInteger())); 197 } catch(IllegalArgumentException e) { 198 throw new SnmpStatusException(SnmpStatusException.snmpRspWrongValue); 199 } 200 return new SnmpInt(node.getJvmMemoryGCCall()); 201 } else { 202 throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType); 203 } 204 205 case 11: 206 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); 207 208 case 2: 209 if (x instanceof SnmpInt) { 210 try { 211 node.setJvmMemoryGCVerboseLevel( new EnumJvmMemoryGCVerboseLevel (((SnmpInt)x).toInteger())); 212 } catch(IllegalArgumentException e) { 213 throw new SnmpStatusException(SnmpStatusException.snmpRspWrongValue); 214 } 215 return new SnmpInt(node.getJvmMemoryGCVerboseLevel()); 216 } else { 217 throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType); 218 } 219 220 case 101: { 221 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); 222 } 223 224 case 10: 225 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); 226 227 case 1: 228 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); 229 230 case 100: { 231 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); 232 } 233 234 default: 235 break; 236 } 237 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); 238 } 239 240 /** 241 * Check the value of a scalar variable 242 */ 243 public void check(SnmpValue x, long var, Object data) 244 throws SnmpStatusException { 245 switch((int) var) { 246 case 120: { 247 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); 248 } 249 250 case 23: 251 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); 252 253 case 22: 254 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); 255 256 case 21: 257 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); 258 259 case 110: { 260 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); 261 } 262 263 case 20: 264 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); 265 266 case 13: 267 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); 268 269 case 12: 270 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); 271 272 case 3: 273 if (x instanceof SnmpInt) { 274 try { 275 node.checkJvmMemoryGCCall( new EnumJvmMemoryGCCall (((SnmpInt)x).toInteger())); 276 } catch(IllegalArgumentException e) { 277 throw new SnmpStatusException(SnmpStatusException.snmpRspWrongValue); 278 } 279 } else { 280 throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType); 281 } 282 break; 283 284 case 11: 285 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); 286 287 case 2: 288 if (x instanceof SnmpInt) { 289 try { 290 node.checkJvmMemoryGCVerboseLevel( new EnumJvmMemoryGCVerboseLevel (((SnmpInt)x).toInteger())); 291 } catch(IllegalArgumentException e) { 292 throw new SnmpStatusException(SnmpStatusException.snmpRspWrongValue); 293 } 294 } else { 295 throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType); 296 } 297 break; 298 299 case 101: { 300 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); 301 } 302 303 case 10: 304 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); 305 306 case 1: 307 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); 308 309 case 100: { 310 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); 311 } 312 313 default: 314 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); 315 } 316 } 317 318 /** 319 * Allow to bind the metadata description to a specific object. 320 */ 321 protected void setInstance(JvmMemoryMBean var) { 322 node = var; 323 } 324 325 326 // ------------------------------------------------------------ 327 // 328 // Implements the "get" method defined in "SnmpMibGroup". 329 // See the "SnmpMibGroup" Javadoc API for more details. 330 // 331 // ------------------------------------------------------------ 332 333 public void get(SnmpMibSubRequest req, int depth) 334 throws SnmpStatusException { 335 objectserver.get(this,req,depth); 336 } 337 338 339 // ------------------------------------------------------------ 340 // 341 // Implements the "set" method defined in "SnmpMibGroup". 342 // See the "SnmpMibGroup" Javadoc API for more details. 343 // 344 // ------------------------------------------------------------ 345 346 public void set(SnmpMibSubRequest req, int depth) 347 throws SnmpStatusException { 348 objectserver.set(this,req,depth); 349 } 350 351 352 // ------------------------------------------------------------ 353 // 354 // Implements the "check" method defined in "SnmpMibGroup". 355 // See the "SnmpMibGroup" Javadoc API for more details. 356 // 357 // ------------------------------------------------------------ 358 359 public void check(SnmpMibSubRequest req, int depth) 360 throws SnmpStatusException { 361 objectserver.check(this,req,depth); 362 } 363 364 /** 365 * Returns true if "arc" identifies a scalar object. 366 */ 367 public boolean isVariable(long arc) { 368 369 switch((int)arc) { 370 case 23: 371 case 22: 372 case 21: 373 case 20: 374 case 13: 375 case 12: 376 case 3: 377 case 11: 378 case 2: 379 case 10: 380 case 1: 381 return true; 382 default: 383 break; 384 } 385 return false; 386 } 387 388 /** 389 * Returns true if "arc" identifies a readable scalar object. 390 */ 391 public boolean isReadable(long arc) { 392 393 switch((int)arc) { 394 case 23: 395 case 22: 396 case 21: 397 case 20: 398 case 13: 399 case 12: 400 case 3: 401 case 11: 402 case 2: 403 case 10: 404 case 1: 405 return true; 406 default: 407 break; 408 } 409 return false; 410 } 411 412 413 // ------------------------------------------------------------ 414 // 415 // Implements the "skipVariable" method defined in "SnmpMibGroup". 416 // See the "SnmpMibGroup" Javadoc API for more details. 417 // 418 // ------------------------------------------------------------ 419 420 public boolean skipVariable(long var, Object data, int pduVersion) { 421 switch((int)var) { 422 case 23: 423 case 22: 424 case 21: 425 case 20: 426 case 13: 427 case 12: 428 case 11: 429 case 10: 430 if (pduVersion==SnmpDefinitions.snmpVersionOne) return true; 431 break; 432 default: 433 break; 434 } 435 return super.skipVariable(var,data,pduVersion); 436 } 437 438 /** 439 * Return the name of the attribute corresponding to the SNMP variable identified by "id". 440 */ 441 public String getAttributeName(long id) 442 throws SnmpStatusException { 443 switch((int)id) { 444 case 120: { 445 throw new SnmpStatusException(SnmpStatusException.noSuchInstance); 446 } 447 448 case 23: 449 return "JvmMemoryNonHeapMaxSize"; 450 451 case 22: 452 return "JvmMemoryNonHeapCommitted"; 453 454 case 21: 455 return "JvmMemoryNonHeapUsed"; 456 457 case 110: { 458 throw new SnmpStatusException(SnmpStatusException.noSuchInstance); 459 } 460 461 case 20: 462 return "JvmMemoryNonHeapInitSize"; 463 464 case 13: 465 return "JvmMemoryHeapMaxSize"; 466 467 case 12: 468 return "JvmMemoryHeapCommitted"; 469 470 case 3: 471 return "JvmMemoryGCCall"; 472 473 case 11: 474 return "JvmMemoryHeapUsed"; 475 476 case 2: 477 return "JvmMemoryGCVerboseLevel"; 478 479 case 101: { 480 throw new SnmpStatusException(SnmpStatusException.noSuchInstance); 481 } 482 483 case 10: 484 return "JvmMemoryHeapInitSize"; 485 486 case 1: 487 return "JvmMemoryPendingFinalCount"; 488 489 case 100: { 490 throw new SnmpStatusException(SnmpStatusException.noSuchInstance); 491 } 492 493 default: 494 break; 495 } 496 throw new SnmpStatusException(SnmpStatusException.noSuchObject); 497 } 498 499 /** 500 * Returns true if "arc" identifies a table object. 501 */ 502 public boolean isTable(long arc) { 503 504 switch((int)arc) { 505 case 120: 506 return true; 507 case 110: 508 return true; 509 case 101: 510 return true; 511 case 100: 512 return true; 513 default: 514 break; 515 } 516 return false; 517 } 518 519 /** 520 * Returns the table object identified by "arc". 521 */ 522 public SnmpMibTable getTable(long arc) { 523 524 switch((int)arc) { 525 case 120: 526 return tableJvmMemMgrPoolRelTable; 527 case 110: 528 return tableJvmMemPoolTable; 529 case 101: 530 return tableJvmMemGCTable; 531 case 100: 532 return tableJvmMemManagerTable; 533 default: 534 break; 535 } 536 return null; 537 } 538 539 /** 540 * Register the group's SnmpMibTable objects with the meta-data. 541 */ 542 public void registerTableNodes(SnmpMib mib, MBeanServer server) { 543 tableJvmMemMgrPoolRelTable = createJvmMemMgrPoolRelTableMetaNode("JvmMemMgrPoolRelTable", "JvmMemory", mib, server); 544 if ( tableJvmMemMgrPoolRelTable != null) { 545 tableJvmMemMgrPoolRelTable.registerEntryNode(mib,server); 546 mib.registerTableMeta("JvmMemMgrPoolRelTable", tableJvmMemMgrPoolRelTable); 547 } 548 549 tableJvmMemPoolTable = createJvmMemPoolTableMetaNode("JvmMemPoolTable", "JvmMemory", mib, server); 550 if ( tableJvmMemPoolTable != null) { 551 tableJvmMemPoolTable.registerEntryNode(mib,server); 552 mib.registerTableMeta("JvmMemPoolTable", tableJvmMemPoolTable); 553 } 554 555 tableJvmMemGCTable = createJvmMemGCTableMetaNode("JvmMemGCTable", "JvmMemory", mib, server); 556 if ( tableJvmMemGCTable != null) { 557 tableJvmMemGCTable.registerEntryNode(mib,server); 558 mib.registerTableMeta("JvmMemGCTable", tableJvmMemGCTable); 559 } 560 561 tableJvmMemManagerTable = createJvmMemManagerTableMetaNode("JvmMemManagerTable", "JvmMemory", mib, server); 562 if ( tableJvmMemManagerTable != null) { 563 tableJvmMemManagerTable.registerEntryNode(mib,server); 564 mib.registerTableMeta("JvmMemManagerTable", tableJvmMemManagerTable); 565 } 566 567 } 568 569 570 /** 571 * Factory method for "JvmMemMgrPoolRelTable" table metadata class. 572 * 573 * You can redefine this method if you need to replace the default 574 * generated metadata class with your own customized class. 575 * 576 * @param tableName Name of the table object ("JvmMemMgrPoolRelTable") 577 * @param groupName Name of the group to which this table belong ("JvmMemory") 578 * @param mib The SnmpMib object in which this table is registered 579 * @param server MBeanServer for this table entries (may be null) 580 * 581 * @return An instance of the metadata class generated for the 582 * "JvmMemMgrPoolRelTable" table (JvmMemMgrPoolRelTableMeta) 583 * 584 **/ 585 protected JvmMemMgrPoolRelTableMeta createJvmMemMgrPoolRelTableMetaNode(String tableName, String groupName, SnmpMib mib, MBeanServer server) { 586 return new JvmMemMgrPoolRelTableMeta(mib, objectserver); 587 } 588 589 590 /** 591 * Factory method for "JvmMemPoolTable" table metadata class. 592 * 593 * You can redefine this method if you need to replace the default 594 * generated metadata class with your own customized class. 595 * 596 * @param tableName Name of the table object ("JvmMemPoolTable") 597 * @param groupName Name of the group to which this table belong ("JvmMemory") 598 * @param mib The SnmpMib object in which this table is registered 599 * @param server MBeanServer for this table entries (may be null) 600 * 601 * @return An instance of the metadata class generated for the 602 * "JvmMemPoolTable" table (JvmMemPoolTableMeta) 603 * 604 **/ 605 protected JvmMemPoolTableMeta createJvmMemPoolTableMetaNode(String tableName, String groupName, SnmpMib mib, MBeanServer server) { 606 return new JvmMemPoolTableMeta(mib, objectserver); 607 } 608 609 610 /** 611 * Factory method for "JvmMemGCTable" table metadata class. 612 * 613 * You can redefine this method if you need to replace the default 614 * generated metadata class with your own customized class. 615 * 616 * @param tableName Name of the table object ("JvmMemGCTable") 617 * @param groupName Name of the group to which this table belong ("JvmMemory") 618 * @param mib The SnmpMib object in which this table is registered 619 * @param server MBeanServer for this table entries (may be null) 620 * 621 * @return An instance of the metadata class generated for the 622 * "JvmMemGCTable" table (JvmMemGCTableMeta) 623 * 624 **/ 625 protected JvmMemGCTableMeta createJvmMemGCTableMetaNode(String tableName, String groupName, SnmpMib mib, MBeanServer server) { 626 return new JvmMemGCTableMeta(mib, objectserver); 627 } 628 629 630 /** 631 * Factory method for "JvmMemManagerTable" table metadata class. 632 * 633 * You can redefine this method if you need to replace the default 634 * generated metadata class with your own customized class. 635 * 636 * @param tableName Name of the table object ("JvmMemManagerTable") 637 * @param groupName Name of the group to which this table belong ("JvmMemory") 638 * @param mib The SnmpMib object in which this table is registered 639 * @param server MBeanServer for this table entries (may be null) 640 * 641 * @return An instance of the metadata class generated for the 642 * "JvmMemManagerTable" table (JvmMemManagerTableMeta) 643 * 644 **/ 645 protected JvmMemManagerTableMeta createJvmMemManagerTableMetaNode(String tableName, String groupName, SnmpMib mib, MBeanServer server) { 646 return new JvmMemManagerTableMeta(mib, objectserver); 647 } 648 649 protected JvmMemoryMBean node; 650 protected SnmpStandardObjectServer objectserver = null; 651 protected JvmMemMgrPoolRelTableMeta tableJvmMemMgrPoolRelTable = null; 652 protected JvmMemPoolTableMeta tableJvmMemPoolTable = null; 653 protected JvmMemGCTableMeta tableJvmMemGCTable = null; 654 protected JvmMemManagerTableMeta tableJvmMemManagerTable = null; 655 }