jdk/src/share/classes/com/sun/jmx/snmp/daemon/SnmpSubNextRequestHandler.java
author malenkov
Tue, 29 Oct 2013 17:01:06 +0400
changeset 21278 ef8a3a2a72f2
parent 5506 202f599c92aa
child 21591 35320b590d9b
permissions -rw-r--r--
8022746: List of spelling errors in API doc Reviewed-by: alexsch, smarks
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1998, 2006, 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.daemon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
// java imports
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
//
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
// jmx imports
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import com.sun.jmx.snmp.SnmpEngine;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import com.sun.jmx.snmp.SnmpPdu;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import com.sun.jmx.snmp.SnmpValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import com.sun.jmx.snmp.SnmpVarBind;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import com.sun.jmx.snmp.SnmpVarBindList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import com.sun.jmx.snmp.SnmpOid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import com.sun.jmx.snmp.SnmpDefinitions;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import com.sun.jmx.snmp.SnmpStatusException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
// SNMP Runtime import
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import static com.sun.jmx.defaults.JmxProperties.SNMP_ADAPTOR_LOGGER;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import com.sun.jmx.snmp.agent.SnmpMibAgent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
import com.sun.jmx.snmp.agent.SnmpMibRequest;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
import com.sun.jmx.snmp.daemon.SnmpAdaptorServer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
import com.sun.jmx.snmp.internal.SnmpIncomingRequest;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
/* NPCTE fix for bugId 4492741, esc 0 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
import com.sun.jmx.snmp.ThreadContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
/* end of NPCTE fix for bugId 4492741 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
class SnmpSubNextRequestHandler extends SnmpSubRequestHandler {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    private SnmpAdaptorServer server = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    /**
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 5506
diff changeset
    58
     * The constructor initialize the subrequest with the whole varbind
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * list contained in the original request.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    protected SnmpSubNextRequestHandler(SnmpAdaptorServer server,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
                                        SnmpMibAgent agent,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
                                        SnmpPdu req) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        super(agent,req);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        init(req, server);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    protected SnmpSubNextRequestHandler(SnmpEngine engine,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
                                        SnmpAdaptorServer server,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
                                        SnmpIncomingRequest incRequest,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
                                        SnmpMibAgent agent,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
                                        SnmpPdu req) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        super(engine, incRequest, agent, req);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        init(req, server);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
            SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpSubNextRequestHandler.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
                "SnmpSubNextRequestHandler", "Constructor : " + this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    private void init(SnmpPdu req, SnmpAdaptorServer server) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        this.server = server;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        // The translation table is easy in this case ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        final int max= translation.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        final SnmpVarBind[] list= req.varBindList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        final NonSyncVector<SnmpVarBind> nonSyncVarBind =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
                ((NonSyncVector<SnmpVarBind>)varBind);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        for(int i=0; i < max; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
            translation[i]= i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            // we need to allocate a new SnmpVarBind. Otherwise the first
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
            // sub request will modify the list...
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
            final SnmpVarBind newVarBind =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
                new SnmpVarBind(list[i].oid, list[i].value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
            nonSyncVarBind.addNonSyncElement(newVarBind);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
            /* NPCTE fix for bugId 4492741, esc 0, 16-August-2001 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            final ThreadContext oldContext =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                ThreadContext.push("SnmpUserData",data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
                if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
                    SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
                        "run", "[" + Thread.currentThread() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
                          "]:getNext operation on " + agent.getMibName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
                // Always call with V2. So the merge of the responses will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
                // be easier.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
                //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
                agent.getNext(createMibRequest(varBind, snmpVersionTwo, data));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                ThreadContext.restore(oldContext);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            /* end of NPCTE fix for bugId 4492741 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        } catch(SnmpStatusException x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            errorStatus = x.getStatus() ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            errorIndex=  x.getErrorIndex();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
            if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpSubRequestHandler.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                    "run", "[" + Thread.currentThread() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                      "]:an Snmp error occured during the operation", x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        catch(Exception x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
            errorStatus = SnmpDefinitions.snmpRspGenErr ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpSubRequestHandler.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                    "run", "[" + Thread.currentThread() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                      "]:a generic error occured during the operation", x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                "run", "[" + Thread.currentThread() +  "]:operation completed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * The method updates the varbind list of the subrequest.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    protected  void updateRequest(SnmpVarBind var, int pos) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpSubRequestHandler.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                "updateRequest", "Copy :" + var);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        int size= varBind.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        translation[size]= pos;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        final SnmpVarBind newVarBind =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            new SnmpVarBind(var.oid, var.value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
            SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpSubRequestHandler.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                "updateRequest", "Copied :" + newVarBind);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        varBind.addElement(newVarBind);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * The method updates a given var bind list with the result of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * previsouly invoked operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * Prior to calling the method, one must make sure that the operation was
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * successful. As such the method getErrorIndex or getErrorStatus should be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * called.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    protected void updateResult(SnmpVarBind[] result) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        final int max=varBind.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        for(int i= 0; i< max ; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
            // May be we should control the position ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            final int index= translation[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            final SnmpVarBind elmt=
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                (SnmpVarBind)((NonSyncVector)varBind).elementAtNonSync(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            final SnmpVarBind vb= result[index];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            if (vb == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                result[index]= elmt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                /* NPCTE fix for bugid 4381195 esc 0. <J.C.> < 17-Oct-2000> */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                // if ((elmt != null) &&  (elmt.value == null) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                //    (version == snmpVersionTwo))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                //    elmt.value = SnmpVarBind.endOfMibView;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                /* end of NPCTE fix for bugid 4381195 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            final SnmpValue val= vb.value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            if ((val == null)|| (val == SnmpVarBind.endOfMibView)){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                /* NPCTE fix for bugid 4381195 esc 0. <J.C.> < 17-Oct-2000> */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                if ((elmt != null) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                    (elmt.value != SnmpVarBind.endOfMibView))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                    result[index]= elmt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                // else if ((val == null) && (version == snmpVersionTwo))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                //    vb.value = SnmpVarBind.endOfMibView;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                /* end of NPCTE fix for bugid 4381195 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            /* NPCTE fix for bugid 4381195 esc 0. <J.C.> < 17-Oct-2000> */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            if (elmt == null) continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            /* end of NPCTE fix for bugid 4381195 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            if (elmt.value == SnmpVarBind.endOfMibView) continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            // Now we need to take the smallest oid ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            int comp = elmt.oid.compareTo(vb.oid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
            if (comp < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
              // Take the smallest (lexicographically)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                result[index]= elmt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                if(comp == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                    // Must compare agent used for reply
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                    // Take the deeper within the reply
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                    if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                        SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                            "updateResult"," oid overlapping. Oid : " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                              elmt.oid + "value :" + elmt.value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                        SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                            "updateResult","Already present varBind : " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                              vb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
                    SnmpOid oid = vb.oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
                    SnmpMibAgent deeperAgent = server.getAgentMib(oid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                    if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                        SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                            "updateResult","Deeper agent : " + deeperAgent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                    if(deeperAgent == agent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                        if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                            SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                                "updateResult","The current agent is the deeper one. Update the value with the current one");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                        result[index].value = elmt.value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
                      Vector v = new Vector();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                      SnmpMibRequest getReq = createMibRequest(v,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                      version,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                      null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
                      SnmpVarBind realValue = new SnmpVarBind(oid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                      getReq.addVarBind(realValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                      try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
                      deeperAgent.get(getReq);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
                      } catch(SnmpStatusException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                      e.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
                      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                      if(isDebugOn())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
                      trace("updateResult", "Biggest priority value is : " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                      realValue.value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                      result[index].value = realValue.value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
}