Package com.sun.jmx.snmp

Examples of com.sun.jmx.snmp.SnmpStatusException


                                       SnmpInformHandler cb,
                                       SnmpVarBindList vblst, int port)
        throws SnmpStatusException {

        if (!isSessionActive()) {
            throw new SnmpStatusException("SNMP adaptor server not ONLINE");
        }
        SnmpInformRequest snmpreq = new SnmpInformRequest(this, adaptor, addr, cs, port, cb);
        snmpreq.start(vblst);
        return snmpreq;
    }
View Full Code Here


    synchronized void addInformRequest(SnmpInformRequest snmpreq) throws SnmpStatusException {

        // If the adaptor is not ONLINE, stop adding requests.
        //
        if (!isSessionActive()) {
            throw new SnmpStatusException("SNMP adaptor is not ONLINE or session is dead...") ;
        }
        informRequestList.put(snmpreq, snmpreq);
    }
View Full Code Here

     * @param table The table to be removed.
     * @exception SnmpStatusException The specified <CODE>SnmpOidTable</CODE> does not exist in this <CODE>SnmpOidDatabase</CODE>.
     */
    public void remove(SnmpOidTable table) throws SnmpStatusException {
        if (!tables.contains(table)) {
            throw new SnmpStatusException("The specified SnmpOidTable does not exist in this SnmpOidDatabase");
        }
        tables.removeElement(table);
    }
View Full Code Here

            try {
                return (tables.elementAt(i).resolveVarName(name));
            }
            catch (SnmpStatusException e) {
                if (i==tables.size()-1) {
                    throw new SnmpStatusException(e.getMessage());
                }
            }
        }
        return null;
    }
View Full Code Here

            try {
                return tables.elementAt(i).resolveVarOid(oid);
            }
            catch (SnmpStatusException e) {
                if (i==tables.size()-1) {
                    throw new SnmpStatusException(e.getMessage());
                }
            }
        }
        return null;
    }
View Full Code Here

     *    group, throws an SnmpStatusException.
     */
    public void validateVarId(long arc, Object userData)
        throws SnmpStatusException {
        if (isVariable(arc) == false) {
            throw new SnmpStatusException(SnmpStatusException.noSuchObject);
        }
    }
View Full Code Here

        throws SnmpStatusException {

        int length = oid.length;

        if (handlers == null)
            throw new SnmpStatusException(SnmpStatusException.snmpRspGenErr);

        final Object data = handlers.getUserData();

        if (depth >= length) {
            // Nothing is left... the oid is not valid
            throw new SnmpStatusException(SnmpStatusException.noAccess);
        }

        long arc = oid[depth];

        if (isNestedArc(arc)) {
            // This arc leads to a subgroup: delegates the search to the
            // method defined in SnmpMibOid
            super.findHandlingNode(varbind,oid,depth,handlers);
        } else if (isTable(arc)) {
            // This arc leads to a table: forward the search to the table.

            // Gets the table
            SnmpMibTable table = getTable(arc);

            // Forward the search to the table
            table.findHandlingNode(varbind,oid,depth+1,handlers);

        } else {
            // If it's not a variable, throws an exception
            validateVarId(arc, data);

            // The trailing .0 is missing in the OID
            if (depth+2 > length) {
                throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
            }

            // There are too many arcs left in the OID (there should remain
            // a single trailing .0)
            if (depth+2 < length) {
                throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
            }

            // The last trailing arc is not .0
            if (oid[depth+1] != 0L) {
                throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
            }

            // It's one of our variable, register this node.
            handlers.add(this,depth,varbind);
        }
View Full Code Here

        if (handlers == null) {
            // This should be considered as a genErr, but we do not want to
            // abort the whole request, so we're going to throw
            // a noSuchObject...
            //
            throw new SnmpStatusException(SnmpStatusException.noSuchObject);
        }

        final Object data = handlers.getUserData();
        final int pduVersion = handlers.getRequestPduVersion();


        // The generic case where the end of the OID has been reached is
        // handled in the superclass
        // XXX Revisit: this works but it is somewhat convoluted. Just setting
        //              arc to -1 would work too.
        if (pos >= length)
            return super.findNextHandlingNode(varbind,oid,pos,depth,
                                              handlers, checker);

        // Ok, we've got the arc.
        long arc = oid[pos];

        long[] result = null;

        // We have a recursive logic. Should we have a loop instead?
        try {

            if (isTable(arc)) {
                // If the arc identifies a table, then we need to forward
                // the search to the table.

                // Gets the table identified by `arc'
                SnmpMibTable table = getTable(arc);

                // Forward to the table
                checker.add(depth, arc);
                try {
                    result = table.findNextHandlingNode(varbind,oid,pos+1,
                                                        depth+1,handlers,
                                                        checker);
                }catch(SnmpStatusException ex) {
                    throw new SnmpStatusException(SnmpStatusException.noSuchObject);
                } finally {
                    checker.remove(depth);
                }
                // Build up the leaf OID
                result[depth] = arc;
                return result;
            } else if (isReadable(arc)) {
                // If the arc identifies a readable variable, then two cases:

                if (pos == (length - 1)) {
                    // The end of the OID is reached, so we return the leaf
                    // corresponding to the variable identified by `arc'

                    // Build up the OID
                    // result = new SnmpOid(0);
                    // result.insert((int)arc);
                    result = new long[depth+2];
                    result[depth+1] = 0L;
                    result[depth] = arc;

                    checker.add(depth, result, depth, 2);
                    try {
                        checker.checkCurrentOid();
                    } catch(SnmpStatusException e) {
                        throw new SnmpStatusException(SnmpStatusException.noSuchObject);
                    } finally {
                        checker.remove(depth,2);
                    }

                    // Registers this node
                    handlers.add(this,depth,varbind);
                    return result;
                }

                // The end of the OID is not yet reached, so we must return
                // the next leaf following the variable identified by `arc'.
                // We cannot return the variable because whatever follows in
                // the OID will be greater or equals to 0, and 0 identifies
                // the variable itself - so we have indeed to return the
                // next object.
                // So we do nothing, because this case is handled at the
                // end of the if ... else if ... else ... block.

            } else if (isNestedArc(arc)) {
                // Now if the arc leads to a subgroup, we delegate the
                // search to the child, just as done in SnmpMibNode.
                //

                // get the child ( = nested arc node).
                //
                final SnmpMibNode child = getChild(arc);

                if (child != null) {
                    checker.add(depth, arc);
                    try {
                        result = child.findNextHandlingNode(varbind,oid,pos+1,
                                                            depth+1,handlers,
                                                            checker);
                        result[depth] = arc;
                        return result;
                    } finally {
                        checker.remove(depth);
                    }
                }
            }

            // The oid is not valid, we will throw an exception in order
            // to try with the next valid identifier...
            //
            throw new SnmpStatusException(SnmpStatusException.noSuchObject);

        } catch (SnmpStatusException e) {
            // We didn't find anything at the given arc, so we're going
            // to try with the next valid arc
            //
View Full Code Here

            throws SnmpStatusException {
            // The index in the exception must correspond to
            // the SNMP index ...
            //
            if (version == SnmpDefinitions.snmpVersionOne)
                throw new SnmpStatusException(exception, getVarIndex(var)+1);

            if (var == null)
                throw exception;

            // If we're doing a getnext ==> endOfMibView
            if (getnextflag) {
                var.value = SnmpVarBind.endOfMibView;
                return;
            }

            final int errorCode = mapGetException(exception.getStatus(),
                                                  version);

            // Now take care of V2 errorCodes that can be stored
            // in the varbind itself:
            if (errorCode ==
                SnmpStatusException.noSuchObject)
                // noSuchObject => noSuchObject
                var.value= SnmpVarBind.noSuchObject;

            else if (errorCode ==
                     SnmpStatusException.noSuchInstance)
                // noSuchInstance => noSuchInstance
                var.value= SnmpVarBind.noSuchInstance;

            else
                throw new SnmpStatusException(errorCode, getVarIndex(var)+1);

        }
View Full Code Here

            throws SnmpStatusException {
            // The index in the exception must correspond to
            // the SNMP index ...
            //
            if (version == SnmpDefinitions.snmpVersionOne)
                throw new SnmpStatusException(exception, getVarIndex(var)+1);

            // Although the first pass of check() did not fail,
            // the set() phase could not be carried out correctly.
            // Since we don't know how to make an "undo", and some
            // assignation may already have been performed, we're going
            // to throw an snmpRspUndoFailed.
            //
            throw new SnmpStatusException(SnmpDefinitions.snmpRspUndoFailed,
                                          getVarIndex(var)+1);
        }
View Full Code Here

TOP

Related Classes of com.sun.jmx.snmp.SnmpStatusException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.