jdk/src/share/classes/com/sun/jmx/snmp/daemon/SnmpSubBulkRequestHandler.java
author malenkov
Tue, 29 Oct 2013 17:01:06 +0400
changeset 21278 ef8a3a2a72f2
parent 14677 1607f4cfc506
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
package com.sun.jmx.snmp.daemon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
// java import
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.util.Enumeration;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.util.logging.Level;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
// jmx imports
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import com.sun.jmx.snmp.SnmpPdu;
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.SnmpOid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import com.sun.jmx.snmp.SnmpValue;
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
import com.sun.jmx.snmp.SnmpEngine;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
// SNMP Runtime import
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import static com.sun.jmx.defaults.JmxProperties.SNMP_ADAPTOR_LOGGER;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
import com.sun.jmx.snmp.agent.SnmpMibAgent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
import com.sun.jmx.snmp.internal.SnmpIncomingRequest;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
import com.sun.jmx.snmp.ThreadContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
class SnmpSubBulkRequestHandler extends SnmpSubRequestHandler {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    private SnmpAdaptorServer server = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    /**
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 14677
diff changeset
    55
     * The constructor initialize the subrequest with the whole varbind list contained
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * in the original request.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    protected SnmpSubBulkRequestHandler(SnmpEngine engine,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
                                        SnmpAdaptorServer server,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
                                        SnmpIncomingRequest incRequest,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
                                        SnmpMibAgent agent,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
                                        SnmpPdu req,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
                                        int nonRepeat,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
                                        int maxRepeat,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
                                        int R) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        super(engine, incRequest, agent, req);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        init(server, req, nonRepeat, maxRepeat, R);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    /**
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 14677
diff changeset
    71
     * The constructor initialize the subrequest with the whole varbind list contained
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * in the original request.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    protected SnmpSubBulkRequestHandler(SnmpAdaptorServer server,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
                                        SnmpMibAgent agent,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
                                        SnmpPdu req,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
                                        int nonRepeat,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
                                        int maxRepeat,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
                                        int R) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        super(agent, req);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        init(server, req, nonRepeat, maxRepeat, R);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 5506
diff changeset
    84
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        size= varBind.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
            // Invoke a getBulk operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            /* NPCTE fix for bugId 4492741, esc 0, 16-August-2001 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
            final ThreadContext oldContext =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
                ThreadContext.push("SnmpUserData",data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
                if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
                    SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
                        "run", "[" + Thread.currentThread() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                        "]:getBulk operation on " + agent.getMibName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
                agent.getBulk(createMibRequest(varBind,version,data),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
                              nonRepeat, maxRepeat);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
                ThreadContext.restore(oldContext);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            /* end of NPCTE fix for bugId 4492741 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        } catch(SnmpStatusException x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            errorStatus = x.getStatus() ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            errorIndex=  x.getErrorIndex();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
                SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpSubRequestHandler.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
                    "run", "[" + Thread.currentThread() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
                    "]:an Snmp error occured during the operation", x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        catch(Exception x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            errorStatus = SnmpDefinitions.snmpRspGenErr ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpSubRequestHandler.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                    "run", "[" + Thread.currentThread() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                    "]:a generic error occured during the operation", x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                "run", "[" + Thread.currentThread() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                  "]:operation completed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    private void init(SnmpAdaptorServer server,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                      SnmpPdu req,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                      int nonRepeat,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                      int maxRepeat,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                      int R) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        this.server = server;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        this.nonRepeat= nonRepeat;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        this.maxRepeat= maxRepeat;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        this.globalR= R;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        final int max= translation.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        final SnmpVarBind[] list= req.varBindList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        final NonSyncVector<SnmpVarBind> nonSyncVarBind =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                ((NonSyncVector<SnmpVarBind>)varBind);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        for(int i=0; i < max; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            translation[i]= i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            // we need to allocate a new SnmpVarBind. Otherwise the first
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            // sub request will modify the list...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            final SnmpVarBind newVarBind =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                new SnmpVarBind(list[i].oid, list[i].value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
            nonSyncVarBind.addNonSyncElement(newVarBind);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * The method updates find out which element to use at update time. Handle oid overlapping as well
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    private SnmpVarBind findVarBind(SnmpVarBind element,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                                    SnmpVarBind result) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        if (element == null) return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        if (result.oid == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
             return element;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        if (element.value == SnmpVarBind.endOfMibView) return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        if (result.value == SnmpVarBind.endOfMibView) return element;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        final SnmpValue val = result.value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        int comp = element.oid.compareTo(result.oid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
            SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                "findVarBind","Comparing OID element : " + element.oid +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                  " with result : " + result.oid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                "findVarBind","Values element : " + element.value +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                  " result : " + result.value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        if (comp < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            // Take the smallest (lexicographically)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            return element;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            if(comp == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                // Must compare agent used for reply
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                // Take the deeper within the reply
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                    SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                        "findVarBind"," oid overlapping. Oid : " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                          element.oid + "value :" + element.value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                    SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                         "findVarBind","Already present varBind : " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                          result);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                SnmpOid oid = result.oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                SnmpMibAgent deeperAgent = server.getAgentMib(oid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                    SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                        "findVarBind","Deeper agent : " + deeperAgent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                if(deeperAgent == agent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                    if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                        SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                            "findVarBind","The current agent is the deeper one. Update the value with the current one");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                    return element;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                    if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                        SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                            "findVarBind","The current agent is not the deeper one. return the previous one.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                    return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                   Vector v = new Vector();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                   SnmpMibRequest getReq = createMibRequest(v,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                   version,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                   null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                   SnmpVarBind realValue = new SnmpVarBind(oid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                   getReq.addVarBind(realValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                   try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                   deeperAgent.get(getReq);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                   } catch(SnmpStatusException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                   e.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                   }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
                   if(isDebugOn())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                   trace("findVarBind", "Biggest priority value is : " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                   realValue.value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                   return realValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
                    SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                        "findVarBind","The right varBind is the already present one");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * The method updates a given var bind list with the result of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * previsouly invoked operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * Prior to calling the method, one must make sure that the operation was
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * successful. As such the method getErrorIndex or getErrorStatus should be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * called.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     */
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 5506
diff changeset
   259
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    protected void updateResult(SnmpVarBind[] result) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        // we can assume that the run method is over ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 5506
diff changeset
   264
        final Enumeration<SnmpVarBind> e= varBind.elements();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        final int max= result.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        // First go through all the values once ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        for(int i=0; i < size; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            // May be we should control the position ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
            if (e.hasMoreElements() == false)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
            // bugId 4641694: must check position in order to avoid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            //       ArrayIndexOutOfBoundException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
            final int pos=translation[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
            if (pos >= max) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
                if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
                    SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpSubRequestHandler.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
                        "updateResult","Position '"+pos+"' is out of bound...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
                continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 5506
diff changeset
   285
            final SnmpVarBind element= e.nextElement();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
            if (element == null) continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
            if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
                SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
                    "updateResult","Non repeaters Current element : " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
                      element + " from agent : " + agent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
            final SnmpVarBind res = findVarBind(element,result[pos]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
            if(res == null) continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
            result[pos] = res;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        // Now update the values which have been repeated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        // more than once.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        int localR= size - nonRepeat;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        for (int i = 2 ; i <= maxRepeat ; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
            for (int r = 0 ; r < localR ; r++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
                final int pos = (i-1)* globalR + translation[nonRepeat + r] ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
                if (pos >= max)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
                    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
                if (e.hasMoreElements() ==false)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
                    return;
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 5506
diff changeset
   310
                final SnmpVarBind element= e.nextElement();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
                if (element == null) continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
                if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
                    SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpSubRequestHandler.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
                        "updateResult","Repeaters Current element : " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
                          element + " from agent : " + agent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
                final SnmpVarBind res = findVarBind(element, result[pos]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
                if(res == null) continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
                result[pos] = res;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    // PROTECTED VARIABLES
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    //------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * Specific to the sub request
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    protected int nonRepeat=0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    protected int maxRepeat=0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * R as defined in RCF 1902 for the global request the sub-request is associated to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    protected int globalR=0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    protected int size=0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
}