jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpMib.java
author dfuchs
Wed, 28 Nov 2012 15:14:47 +0100
changeset 14677 1607f4cfc506
parent 14342 8435a30053c1
child 21291 64a9ea14762c
permissions -rw-r--r--
8003476: Cleanup warnings in com.sun.jmx.snmp code Reviewed-by: alanb, smarks
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
14342
8435a30053c1 7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents: 14335
diff changeset
     2
 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package com.sun.jmx.snmp.agent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.Serializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.util.Enumeration;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.util.logging.Level;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.Vector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import javax.management.ObjectName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import javax.management.MBeanServer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import javax.management.MalformedObjectNameException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import javax.management.InstanceAlreadyExistsException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import javax.management.MBeanRegistrationException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import javax.management.NotCompliantMBeanException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import static com.sun.jmx.defaults.JmxProperties.SNMP_ADAPTOR_LOGGER;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import com.sun.jmx.snmp.SnmpOid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import com.sun.jmx.snmp.SnmpVarBind;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import com.sun.jmx.snmp.SnmpDefinitions;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import com.sun.jmx.snmp.SnmpStatusException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * Abstract class for representing an SNMP MIB.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * When compiling a SNMP MIB, among all the classes generated by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * <CODE>mibgen</CODE>, there is one which extends <CODE>SnmpMib</CODE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * for representing a whole MIB.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * <BR>The class is used by the SNMP protocol adaptor as the entry point in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * the MIB.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * <p>This generated class can be subclassed in your code in order to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * plug in your own specific behaviour.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * <p><b>This API is a Sun Microsystems internal API  and is subject
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * to change without notice.</b></p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
public abstract class SnmpMib extends SnmpMibAgent implements Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * Default constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * Initializes the OID tree.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    public SnmpMib() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        root= new SnmpMibOid();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    // --------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    // POLYMORHIC METHODS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    // --------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * This callback should return the OID associated to the group
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * identified by the given <code>groupName</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * This method is provided as a hook to plug-in some custom
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * specific behavior. Although doing so is discouraged you might
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * want to subclass this method in order to store & provide more metadata
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * information (mapping OID <-> symbolic name) within the agent,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * or to "change" the root of the MIB OID by prefixing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * defaultOid by an application dependant OID string, for instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * The default implementation of this method is to return the given
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * <code>defaultOid</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * @param groupName   The java-ized name of the SNMP group.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * @param defaultOid  The OID defined in the MIB for that group
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     *                    (in dot notation).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * @return The OID of the group identified by <code>groupName</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     *         in dot-notation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    protected String getGroupOid(String groupName, String defaultOid) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        return defaultOid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * This callback should return the ObjectName associated to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * group identified by the given <code>groupName</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * This method is provided as a hook to plug-in some custom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * specific behavior. You might want to override this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * in order to provide a different object naming scheme than
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * that proposed by default by <code>mibgen</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * This method is only meaningful if the MIB is registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * in the MBeanServer, otherwise, it will not be called.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * The default implementation of this method is to return an ObjectName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * built from the given <code>defaultName</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * @param name  The java-ized name of the SNMP group.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * @param oid   The OID returned by getGroupOid() - in dot notation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * @param defaultName The name by default generated by <code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     *                    mibgen</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * @return The ObjectName of the group identified by <code>name</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    protected ObjectName getGroupObjectName(String name, String oid,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                                            String defaultName)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        throws MalformedObjectNameException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        return new ObjectName(defaultName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * Register an SNMP group and its metadata node in the MIB.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * This method is provided as a hook to plug-in some custom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * specific behavior. You might want to override this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * if you want to set special links between the MBean, its metadata
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * node, its OID or ObjectName etc..
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * If the MIB is not registered in the MBeanServer, the <code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * server</code> and <code>groupObjName</code> parameters will be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * <code>null</code>.<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * If the given group MBean is not <code>null</code>, and if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * <code>server</code> and <code>groupObjName</code> parameters are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * not null, then this method will also automatically register the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * group MBean with the given MBeanServer <code>server</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * @param groupName  The java-ized name of the SNMP group.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * @param groupOid   The OID as returned by getGroupOid() - in dot
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     *                   notation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * @param groupObjName The ObjectName as returned by getGroupObjectName().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     *                   This parameter may be <code>null</code> if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     *                   MIB is not registered in the MBeanServer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * @param node       The metadata node, as returned by the metadata
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     *                   factory method for this group.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * @param group      The MBean for this group, as returned by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     *                   MBean factory method for this group.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * @param server     The MBeanServer in which the groups are to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     *                   registered. This parameter will be <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     *                   if the MIB is not registered, otherwise it is a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     *                   reference to the MBeanServer in which the MIB is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     *                   registered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    protected void registerGroupNode(String groupName,   String groupOid,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                                     ObjectName groupObjName, SnmpMibNode node,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                                     Object group, MBeanServer server)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        throws NotCompliantMBeanException, MBeanRegistrationException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        InstanceAlreadyExistsException, IllegalAccessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        root.registerNode(groupOid,node);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        if (server != null && groupObjName != null && group != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            server.registerMBean(group,groupObjName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * Register an SNMP Table metadata node in the MIB.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * <b><i>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * This method is used internally and you should never need to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * call it directly.</i></b><br> It is used to establish the link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * between an SNMP table metadata node and its bean-like counterpart.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * <br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * The group metadata nodes will create and register their
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * underlying table metadata nodes in the MIB using this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * method. <br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * The metadata nodes will be later retrieved from the MIB by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * bean-like table objects using the getRegisterTableMeta() method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * @param name      The java-ized name of the SNMP table.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * @param table     The SNMP table metadata node - usually this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     *                  corresponds to a <code>mibgen</code> generated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     *                  object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    public abstract void registerTableMeta(String name, SnmpMibTable table);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * Returns a registered SNMP Table metadata node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * <p><b><i>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * This method is used internally and you should never need to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * call it directly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * </i></b></p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    public abstract SnmpMibTable getRegisteredTableMeta(String name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    // --------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    // PUBLIC METHODS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    // --------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * Processes a <CODE>get</CODE> operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    // Implements the method defined in SnmpMibAgent. See SnmpMibAgent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    // for java-doc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    //
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   240
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    public void get(SnmpMibRequest req) throws SnmpStatusException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        // Builds the request tree: creation is not allowed, operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        // is not atomic.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        final int reqType = SnmpDefinitions.pduGetRequestPdu;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        SnmpRequestTree handlers = getHandlers(req,false,false,reqType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        SnmpRequestTree.Handler h = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        SnmpMibNode meta = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpMib.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
                    "get", "Processing handlers for GET... ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        // For each sub-request stored in the request-tree, invoke the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        // get() method.
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   259
        for (Enumeration<SnmpRequestTree.Handler> eh=handlers.getHandlers();eh.hasMoreElements();) {
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   260
            h = eh.nextElement();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
            // Gets the Meta node. It can be either a Group Meta or a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
            // Table Meta.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
            meta = handlers.getMetaNode(h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
            // Gets the depth of the Meta node in the OID tree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
            final int depth = handlers.getOidDepth(h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   270
            for (Enumeration<SnmpMibSubRequest> rqs=handlers.getSubRequests(h);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                 rqs.hasMoreElements();) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
                // Invoke the get() operation.
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   274
                meta.get(rqs.nextElement(),depth);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * Processes a <CODE>set</CODE> operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    // Implements the method defined in SnmpMibAgent. See SnmpMibAgent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    // for java-doc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    //
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   286
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    public void set(SnmpMibRequest req) throws SnmpStatusException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        SnmpRequestTree handlers = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        // Optimization: we're going to get the whole SnmpRequestTree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        // built in the "check" method, so that we don't have to rebuild
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        // it here.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        if (req instanceof SnmpMibRequestImpl)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
            handlers = ((SnmpMibRequestImpl)req).getRequestTree();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        // Optimization didn't work: we have to rebuild the tree.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        // Builds the request tree: creation is not allowed, operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        // is atomic.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        final int reqType = SnmpDefinitions.pduSetRequestPdu;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        if (handlers == null) handlers = getHandlers(req,false,true,reqType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        handlers.switchCreationFlag(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        handlers.setPduType(reqType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   308
        SnmpRequestTree.Handler h;
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   309
        SnmpMibNode meta;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
            SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpMib.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
                    "set", "Processing handlers for SET... ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        // For each sub-request stored in the request-tree, invoke the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        // get() method.
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   318
        for (Enumeration<SnmpRequestTree.Handler> eh=handlers.getHandlers();eh.hasMoreElements();) {
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   319
            h = eh.nextElement();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
            // Gets the Meta node. It can be either a Group Meta or a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
            // Table Meta.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
            meta = handlers.getMetaNode(h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
            // Gets the depth of the Meta node in the OID tree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
            final int depth = handlers.getOidDepth(h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   329
            for (Enumeration<SnmpMibSubRequest> rqs=handlers.getSubRequests(h);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
                 rqs.hasMoreElements();) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
                // Invoke the set() operation
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   333
                meta.set(rqs.nextElement(),depth);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * Checks if a <CODE>set</CODE> operation can be performed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * If the operation cannot be performed, the method will raise a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * <CODE>SnmpStatusException</CODE>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
    // Implements the method defined in SnmpMibAgent. See SnmpMibAgent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
    // for java-doc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    //
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   347
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    public void check(SnmpMibRequest req) throws SnmpStatusException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
        final int reqType = SnmpDefinitions.pduWalkRequest;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        // Builds the request tree: creation is allowed, operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
        // is atomic.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        SnmpRequestTree handlers = getHandlers(req,true,true,reqType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   355
        SnmpRequestTree.Handler h;
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   356
        SnmpMibNode meta;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
            SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpMib.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
                    "check", "Processing handlers for CHECK... ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        // For each sub-request stored in the request-tree, invoke the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        // check() method.
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   365
        for (Enumeration<SnmpRequestTree.Handler> eh=handlers.getHandlers();eh.hasMoreElements();) {
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   366
            h = eh.nextElement();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
            // Gets the Meta node. It can be either a Group Meta or a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
            // Table Meta.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
            meta = handlers.getMetaNode(h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
            // Gets the depth of the Meta node in the OID tree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
            final int depth = handlers.getOidDepth(h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   376
            for (Enumeration<SnmpMibSubRequest> rqs=handlers.getSubRequests(h);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
                 rqs.hasMoreElements();) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
                // Invoke the check() operation
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   380
                meta.check(rqs.nextElement(),depth);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        // Optimization: we're going to pass the whole SnmpRequestTree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        // to the "set" method, so that we don't have to rebuild it there.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
        if (req instanceof SnmpMibRequestImpl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
            ((SnmpMibRequestImpl)req).setRequestTree(handlers);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     * Processes a <CODE>getNext</CODE> operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    // Implements the method defined in SnmpMibAgent. See SnmpMibAgent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    // for java-doc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    //
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   400
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    public void getNext(SnmpMibRequest req) throws SnmpStatusException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        // Build the request tree for the operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        // The subrequest stored in the request tree are valid GET requests
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        SnmpRequestTree handlers = getGetNextHandlers(req);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   406
        SnmpRequestTree.Handler h;
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   407
        SnmpMibNode meta;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
            SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpMib.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
                    "getNext", "Processing handlers for GET-NEXT... ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
        // Now invoke get() for each subrequest of the request tree.
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   415
        for (Enumeration<SnmpRequestTree.Handler> eh=handlers.getHandlers();eh.hasMoreElements();) {
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   416
            h = eh.nextElement();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
            // Gets the Meta node. It can be either a Group Meta or a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
            // Table Meta.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
            meta = handlers.getMetaNode(h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
            // Gets the depth of the Meta node in the OID tree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
            int depth = handlers.getOidDepth(h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   426
            for (Enumeration<SnmpMibSubRequest> rqs=handlers.getSubRequests(h);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
                 rqs.hasMoreElements();) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
                // Invoke the get() operation
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   430
                meta.get(rqs.nextElement(),depth);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     * Processes a <CODE>getBulk</CODE> operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     * The method implements the <CODE>getBulk</CODE> operation by calling
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     * appropriately the <CODE>getNext</CODE> method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
    // Implements the method defined in SnmpMibAgent. See SnmpMibAgent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
    // for java-doc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    //
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   445
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
    public void getBulk(SnmpMibRequest req, int nonRepeat, int maxRepeat)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        throws SnmpStatusException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
        getBulkWithGetNext(req, nonRepeat, maxRepeat);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     * Gets the root object identifier of the MIB.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     * <P>In order to be accurate, the method should be called once the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * MIB is fully initialized (that is, after a call to <CODE>init</CODE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * or <CODE>preRegister</CODE>).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     * @return The root object identifier.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     */
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   460
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    public long[] getRootOid() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        if( rootOid == null) {
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   464
            Vector<Integer> list= new Vector<>(10);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
            // Ask the tree to do the job !
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
            root.getRootOid(list);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
            // Now format the result
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
            rootOid= new long[list.size()];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
            int i=0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
            for(Enumeration<Integer> e= list.elements(); e.hasMoreElements(); ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
                Integer val= e.nextElement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
                rootOid[i++]= val.longValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
        return rootOid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
    // --------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
    // PRIVATE METHODS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
    //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     * This method builds the temporary request-tree that will be used to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     * perform the SNMP request associated with the given vector of varbinds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     * `list'.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     * @param req The SnmpMibRequest object holding the varbind list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     *             concerning this MIB.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     * @param createflag Indicates whether the operation allow for creation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     *        of new instances (ie: it is a SET).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     * @param atomic Indicates whether the operation is atomic or not.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     * @param type Request type (from SnmpDefinitions).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     * @return The request-tree where the original varbind list has been
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     *         dispatched to the appropriate nodes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
    private SnmpRequestTree getHandlers(SnmpMibRequest req,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
                                        boolean createflag, boolean atomic,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
                                        int type)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
        throws SnmpStatusException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
        // Build an empty request tree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        SnmpRequestTree handlers =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
            new SnmpRequestTree(req,createflag,type);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
        int index=0;
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   512
        SnmpVarBind var;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
        final int ver= req.getVersion();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
        // For each varbind in the list finds its handling node.
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   516
        for (Enumeration<SnmpVarBind> e= req.getElements(); e.hasMoreElements(); index++) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   518
            var= e.nextElement();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
                // Find the handling node for this varbind.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
                root.findHandlingNode(var,var.oid.longValue(false),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
                                      0,handlers);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
            } catch(SnmpStatusException x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
                if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
                    SNMP_ADAPTOR_LOGGER.logp(Level.FINEST,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
                            SnmpMib.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
                            "getHandlers",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
                            "Couldn't find a handling node for " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
                            var.oid.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
                // If the operation is atomic (Check/Set) or the version
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
                // is V1 we must generate an exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
                //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
                if (ver == SnmpDefinitions.snmpVersionOne) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
                    if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
                        SNMP_ADAPTOR_LOGGER.logp(Level.FINEST,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
                                SnmpMib.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
                                "getHandlers", "\tV1: Throwing exception");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
                    // The index in the exception must correspond to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
                    // SNMP index ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
                    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
                    final SnmpStatusException sse =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
                        new SnmpStatusException(x, index + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
                    sse.initCause(x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
                    throw sse;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
                } else if ((type == SnmpDefinitions.pduWalkRequest)   ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
                           (type == SnmpDefinitions.pduSetRequestPdu)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
                    final int status =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
                        SnmpRequestTree.mapSetException(x.getStatus(),ver);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
                    if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
                        SNMP_ADAPTOR_LOGGER.logp(Level.FINEST,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
                                SnmpMib.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
                                "getHandlers", "\tSET: Throwing exception");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
                    final SnmpStatusException sse =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
                        new SnmpStatusException(status, index + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
                    sse.initCause(x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
                    throw sse;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
                } else if (atomic) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
                    // Should never come here...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
                    if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
                        SNMP_ADAPTOR_LOGGER.logp(Level.FINEST,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
                                SnmpMib.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
                                "getHandlers", "\tATOMIC: Throwing exception");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
                    final SnmpStatusException sse =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
                        new SnmpStatusException(x, index + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
                    sse.initCause(x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
                    throw sse;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
                final int status =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
                    SnmpRequestTree.mapGetException(x.getStatus(),ver);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
                if (status == SnmpStatusException.noSuchInstance) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
                    if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
                        SNMP_ADAPTOR_LOGGER.logp(Level.FINEST,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
                                SnmpMib.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
                                "getHandlers",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                                "\tGET: Registering noSuchInstance");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
                    var.value= SnmpVarBind.noSuchInstance;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
                } else if (status == SnmpStatusException.noSuchObject) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
                    if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
                        SNMP_ADAPTOR_LOGGER.logp(Level.FINEST,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
                                SnmpMib.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
                                "getHandlers",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
                                "\tGET: Registering noSuchObject");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
                        var.value= SnmpVarBind.noSuchObject;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
                    if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
                        SNMP_ADAPTOR_LOGGER.logp(Level.FINEST,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
                                SnmpMib.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
                                "getHandlers",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
                                "\tGET: Registering global error: " + status);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
                    final SnmpStatusException sse =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
                        new SnmpStatusException(status, index + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
                    sse.initCause(x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
                    throw sse;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
        return handlers;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
     * This method builds the temporary request-tree that will be used to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
     * perform the SNMP GET-NEXT request associated with the given vector
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
     * of varbinds `list'.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     * @param req The SnmpMibRequest object holding the varbind list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
     *             concerning this MIB.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
     * @return The request-tree where the original varbind list has been
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
     *         dispatched to the appropriate nodes, and where the original
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
     *         OIDs have been replaced with the correct "next" OID.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
    private SnmpRequestTree getGetNextHandlers(SnmpMibRequest req)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
        throws SnmpStatusException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
        // Creates an empty request tree, no entry creation is allowed (false)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
        SnmpRequestTree handlers = new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
            SnmpRequestTree(req,false,SnmpDefinitions.pduGetNextRequestPdu);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
        // Sets the getNext flag: if version=V2, status exception are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
        // transformed in  endOfMibView
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
        handlers.setGetNextFlag();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
        if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
            SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpMib.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
                    "getGetNextHandlers", "Received MIB request : " + req);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
        AcmChecker checker = new AcmChecker(req);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
        int index=0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
        SnmpVarBind var = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
        final int ver= req.getVersion();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
        SnmpOid original = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
        // For each varbind, finds the handling node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
        // This function has the side effect of transforming a GET-NEXT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
        // request into a valid GET request, replacing the OIDs in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
        // original GET-NEXT request with the OID of the first leaf that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
        // follows.
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   662
        for (Enumeration<SnmpVarBind> e= req.getElements(); e.hasMoreElements(); index++) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   664
            var = e.nextElement();
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 14342
diff changeset
   665
            SnmpOid result;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
                // Find the node handling the OID that follows the varbind
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
                // OID. `result' contains this next leaf OID.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
                //ACM loop.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
                if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
                    SNMP_ADAPTOR_LOGGER.logp(Level.FINEST,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
                            SnmpMib.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
                            "getGetNextHandlers", " Next OID of : " + var.oid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
                result = new SnmpOid(root.findNextHandlingNode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
                                     (var,var.oid.longValue(false),0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
                                      0,handlers, checker));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
                if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
                    SNMP_ADAPTOR_LOGGER.logp(Level.FINEST,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
                            SnmpMib.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
                            "getGetNextHandlers", " is : " + result);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
                // We replace the varbind original OID with the OID of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
                // leaf object we have to return.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
                var.oid = result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
            } catch(SnmpStatusException x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
                // if (isDebugOn())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
                //    debug("getGetNextHandlers",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
                //        "Couldn't find a handling node for "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
                //        + var.oid.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
                if (ver == SnmpDefinitions.snmpVersionOne) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
                    if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
                        SNMP_ADAPTOR_LOGGER.logp(Level.FINEST,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
                                SnmpMib.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
                                "getGetNextHandlers",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
                                "\tThrowing exception " + x.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
                    // The index in the exception must correspond to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
                    // SNMP index ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
                    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
                    throw new SnmpStatusException(x, index + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
                if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
                    SNMP_ADAPTOR_LOGGER.logp(Level.FINEST,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
                            SnmpMib.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
                            "getGetNextHandlers",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
                            "Exception : " + x.getStatus());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
                var.setSnmpValue(SnmpVarBind.endOfMibView);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
        return handlers;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
    // --------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
    // PROTECTED VARIABLES
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
    // --------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
     * The top element in the Mib tree.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
    protected SnmpMibOid root;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
    // --------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
    // PRIVATE VARIABLES
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
    // --------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
     * The root object identifier of the MIB.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
    private transient long[] rootOid= null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
}