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.SnmpMibNode; 58 import com.sun.jmx.snmp.agent.SnmpMib; 59 import com.sun.jmx.snmp.agent.SnmpMibEntry; 60 import com.sun.jmx.snmp.agent.SnmpStandardObjectServer; 61 import com.sun.jmx.snmp.agent.SnmpStandardMetaServer; 62 import com.sun.jmx.snmp.agent.SnmpMibSubRequest; 63 import com.sun.jmx.snmp.agent.SnmpMibTable; 64 import com.sun.jmx.snmp.EnumRowStatus; 65 import com.sun.jmx.snmp.SnmpDefinitions; 66 67 /** 68 * The class is used for representing SNMP metadata for the "JvmMemGCEntry" group. 69 * The group is defined with the following oid: 1.3.6.1.4.1.42.2.145.3.163.1.1.2.101.1. 70 */ 71 public class JvmMemGCEntryMeta extends SnmpMibEntry 72 implements Serializable, SnmpStandardMetaServer { 73 74 static final long serialVersionUID = 6082082529298387063L; 75 /** 76 * Constructor for the metadata associated to "JvmMemGCEntry". 77 */ 78 public JvmMemGCEntryMeta(SnmpMib myMib, SnmpStandardObjectServer objserv) { 79 objectserver = objserv; 80 varList = new int[2]; 81 varList[0] = 3; 82 varList[1] = 2; 83 SnmpMibNode.sort(varList); 84 } 85 86 /** 87 * Get the value of a scalar variable 88 */ 89 public SnmpValue get(long var, Object data) 90 throws SnmpStatusException { 91 switch((int)var) { 92 case 3: 93 return new SnmpCounter64(node.getJvmMemGCTimeMs()); 94 95 case 2: 96 return new SnmpCounter64(node.getJvmMemGCCount()); 97 98 default: 99 break; 100 } 101 throw new SnmpStatusException(SnmpStatusException.noSuchObject); 102 } 103 104 /** 105 * Set the value of a scalar variable 106 */ 107 public SnmpValue set(SnmpValue x, long var, Object data) 108 throws SnmpStatusException { 109 switch((int)var) { 110 case 3: 111 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); 112 113 case 2: 114 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); 115 116 default: 117 break; 118 } 119 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); 120 } 121 122 /** 123 * Check the value of a scalar variable 124 */ 125 public void check(SnmpValue x, long var, Object data) 126 throws SnmpStatusException { 127 switch((int) var) { 128 case 3: 129 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); 130 131 case 2: 132 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); 133 134 default: 135 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); 136 } 137 } 138 139 /** 140 * Allow to bind the metadata description to a specific object. 141 */ 142 protected void setInstance(JvmMemGCEntryMBean var) { 143 node = var; 144 } 145 146 147 // ------------------------------------------------------------ 148 // 149 // Implements the "get" method defined in "SnmpMibEntry". 150 // See the "SnmpMibEntry" Javadoc API for more details. 151 // 152 // ------------------------------------------------------------ 153 154 public void get(SnmpMibSubRequest req, int depth) 155 throws SnmpStatusException { 156 objectserver.get(this,req,depth); 157 } 158 159 160 // ------------------------------------------------------------ 161 // 162 // Implements the "set" method defined in "SnmpMibEntry". 163 // See the "SnmpMibEntry" Javadoc API for more details. 164 // 165 // ------------------------------------------------------------ 166 167 public void set(SnmpMibSubRequest req, int depth) 168 throws SnmpStatusException { 169 objectserver.set(this,req,depth); 170 } 171 172 173 // ------------------------------------------------------------ 174 // 175 // Implements the "check" method defined in "SnmpMibEntry". 176 // See the "SnmpMibEntry" Javadoc API for more details. 177 // 178 // ------------------------------------------------------------ 179 180 public void check(SnmpMibSubRequest req, int depth) 181 throws SnmpStatusException { 182 objectserver.check(this,req,depth); 183 } 184 185 /** 186 * Returns true if "arc" identifies a scalar object. 187 */ 188 public boolean isVariable(long arc) { 189 190 switch((int)arc) { 191 case 3: 192 case 2: 193 return true; 194 default: 195 break; 196 } 197 return false; 198 } 199 200 /** 201 * Returns true if "arc" identifies a readable scalar object. 202 */ 203 public boolean isReadable(long arc) { 204 205 switch((int)arc) { 206 case 3: 207 case 2: 208 return true; 209 default: 210 break; 211 } 212 return false; 213 } 214 215 216 // ------------------------------------------------------------ 217 // 218 // Implements the "skipVariable" method defined in "SnmpMibEntry". 219 // See the "SnmpMibEntry" Javadoc API for more details. 220 // 221 // ------------------------------------------------------------ 222 223 public boolean skipVariable(long var, Object data, int pduVersion) { 224 switch((int)var) { 225 case 3: 226 case 2: 227 if (pduVersion==SnmpDefinitions.snmpVersionOne) return true; 228 break; 229 default: 230 break; 231 } 232 return super.skipVariable(var,data,pduVersion); 233 } 234 235 /** 236 * Return the name of the attribute corresponding to the SNMP variable identified by "id". 237 */ 238 public String getAttributeName(long id) 239 throws SnmpStatusException { 240 switch((int)id) { 241 case 3: 242 return "JvmMemGCTimeMs"; 243 244 case 2: 245 return "JvmMemGCCount"; 246 247 default: 248 break; 249 } 250 throw new SnmpStatusException(SnmpStatusException.noSuchObject); 251 } 252 253 protected JvmMemGCEntryMBean node; 254 protected SnmpStandardObjectServer objectserver = null; 255 }