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