Package com.sun.jmx.snmp

Examples of com.sun.jmx.snmp.SnmpStatusException


     */
    public synchronized Object getEntry(SnmpOid rowOid)
        throws SnmpStatusException {
        int pos= findObject(rowOid);
        if (pos == -1)
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
        return entries.elementAt(pos);
    }
View Full Code Here


    public synchronized ObjectName getEntryName(SnmpOid rowOid)
        throws SnmpStatusException {
        int pos = findObject(rowOid);
        if (entrynames == null) return null;
        if (pos == -1 || pos >= entrynames.size())
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
        return entrynames.elementAt(pos);
    }
View Full Code Here

        final SnmpValue rsvalue = vbstatus.value;

        if (rsvalue instanceof SnmpInt)
            return ((SnmpInt)rsvalue).intValue();
        else
            throw new SnmpStatusException(
                       SnmpStatusException.snmpRspInconsistentValue);
    }
View Full Code Here

     */
    protected SnmpOid getNextOid(SnmpOid oid, Object userData)
        throws SnmpStatusException {

        if (size == 0) {
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
        }

        final SnmpOid resOid = oid;

        // Just a simple check to speed up retrieval of last element ...
        //
        // XX SnmpOid last= (SnmpOid) oids.lastElement();
        SnmpOid last= tableoids[tablecount-1];
        if (last.equals(resOid)) {
            // Last element of the table ...
            //
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
        }

        // First find the oid. This will allow to speed up retrieval process
        // during smart discovery of table (using the getNext) as the
        // management station will use the valid index returned during a
        // previous getNext ...
        //

        // Returns the position following the position at which resOid
        // is found, or the position at which resOid should be inserted.
        //
        final int newPos = getInsertionPoint(resOid,false);

        // If the position returned is not out of bound, we will find
        // the next element in the array.
        //
        if (newPos > -1 && newPos < size) {
            try {
                // XX last = (SnmpOid) oids.elementAt(newPos);
                last = tableoids[newPos];
            } catch(ArrayIndexOutOfBoundsException e) {
                throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
            }
        } else {
            // We are dealing with the last element of the table ..
            //
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
        }


        return last;
    }
View Full Code Here

     * @exception SnmpStatusException If the table is empty.
     */
    protected SnmpOid getNextOid(Object userData)
        throws SnmpStatusException {
        if (size == 0) {
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
        }
        // XX return (SnmpOid) oids.firstElement();
        return tableoids[0];
    }
View Full Code Here

    static void checkRowStatusFail(SnmpMibSubRequest req, int errorStatus)
        throws SnmpStatusException {

        final SnmpVarBind statusvb  = req.getRowStatusVarBind();
        final SnmpStatusException x = new SnmpStatusException(errorStatus);
        req.registerCheckException(statusvb,x);
    }
View Full Code Here

    static void setRowStatusFail(SnmpMibSubRequest req, int errorStatus)
        throws SnmpStatusException {

        final SnmpVarBind statusvb  = req.getRowStatusVarBind();
        final SnmpStatusException x = new SnmpStatusException(errorStatus);
        req.registerSetException(statusvb,x);
    }
View Full Code Here

        throws SnmpStatusException {

        final int  length = oid.length;

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

        if (depth >= length)
            throw new SnmpStatusException(SnmpStatusException.noAccess);

        if (oid[depth] != nodeId)
            throw new SnmpStatusException(SnmpStatusException.noAccess);

        if (depth+2 >= length)
            throw new SnmpStatusException(SnmpStatusException.noAccess);

        // Checks that the oid is valid
        // validateOid(oid,depth);

        // Gets the part of the OID that identifies the entry
        final SnmpOid entryoid = new SnmpEntryOid(oid, depth+2);

        // Finds the entry: false means that the entry does not exists
        final Object data = handlers.getUserData();
        final boolean hasEntry = contains(entryoid, data);

        // Fails if the entry is not found and the table does not
        // not support creation.
        // We know that the entry does not exists if (isentry == false).
        if (!hasEntry) {
            if (!handlers.isCreationAllowed()) {
                // we're not doing a set
                throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
            } else if (!isCreationEnabled())
                // we're doing a set but creation is disabled.
                throw new
                    SnmpStatusException(SnmpStatusException.snmpRspNoAccess);
        }

        final long   var  = oid[depth+1];
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();

            long var= -1;

            // If the querried oid contains less arcs than the OID of the
            // xxxEntry object, we must return the first leaf under the
            // first columnar object: the best way to do that is to reset
            // the queried oid:
            //   oid[0] = nodeId (arc of the xxxEntry object)
            //   pos    = 0 (points to the arc of the xxxEntry object)
            // then we just have to proceed...
            //
            if (pos >= length) {
                // this will have the side effect to set
                //    oid[pos] = nodeId
                // and
                //    (pos+1) = length
                // so we won't fall into the "else if" cases below -
                // so using "else if" rather than "if ..." is guaranteed
                // to be safe.
                //
                oid = new long[1];
                oid[0] = nodeId;
                pos = 0;
                length = 1;
            } else if (oid[pos] > nodeId) {
                // oid[pos] is expected to be the id of the xxxEntry ...
                // The id requested is greater than the id of the xxxEntry,
                // so we won't find the next element in this table... (any
                // element in this table will have a smaller OID)
                //
                throw new SnmpStatusException(SnmpStatusException.noSuchObject);
            } else if (oid[pos] < nodeId) {
                // we must return the first leaf under the first columnar
                // object, so we are back to our first case where pos was
                // out of bounds... => reset the oid to contain only the
                // arc of the xxxEntry object.
                //
                oid = new long[1];
                oid[0] = nodeId;
                pos = 0;
                length = 0;
            } else if ((pos + 1) < length) {
                // The arc at the position "pos+1" is the id of the columnar
                // object (ie: the id of the variable in the table entry)
                //
                var = oid[pos+1];
            }

            // Now that we've got everything right we can begin.
            SnmpOid entryoid;

            if (pos == (length - 1)) {
                // pos points to the last arc in the oid, and this arc is
                // guaranteed to be the xxxEntry id (we have handled all
                // the other possibilities before)
                //
                // We must therefore return the first leaf below the first
                // columnar object in the table.
                //
                // Get the first index. If an exception is raised,
                // then it means that the table is empty. We thus do not
                // have to catch the exception - we let it propagate to
                // the caller.
                //
                entryoid = getNextOid(data);
                var = getNextVarEntryId(entryoid,var,data,pduVersion);
            } else if ( pos == (length-2)) {
                // In that case we have (pos+1) = (length-1), so pos
                // points to the arc of the querried variable (columnar object).
                // Since the requested oid stops there, it means we have
                // to return the first leaf under this columnar object.
                //
                // So we first get the first index:
                // Note: if this raises an exception, this means that the table
                // is empty, so we can let the exception propagate to the caller.
                //
                entryoid = getNextOid(data);

                // XXX revisit: not exactly perfect:
                //     a specific row could be empty.. But we don't know
                //     how to make the difference! => tradeoff holes
                //     in tables can't be properly supported (all rows
                //     must have the same holes)
                //
                if (skipEntryVariable(entryoid,var,data,pduVersion)) {
                    var = getNextVarEntryId(entryoid,var,data,pduVersion);
                }
            } else {

                // So now there remain one last case, namely: some part of the
                // index is provided by the oid...
                // We build a possibly incomplete and invalid index from
                // the OID.
                // The piece of index provided should begin at pos+2
                //   oid[pos]   = id of the xxxEntry object,
                //   oid[pos+1] = id of the columnar object,
                //   oid[pos+2] ... oid[length-1] = piece of index.
                //

                // We get the next index following the provided index.
                // If this raises an exception, then it means that we have
                // reached the last index in the table, and we must then
                // try with the next columnar object.
                //
                // Bug fix 4269251
                // The SnmpIndex is defined to contain a valid oid:
                // this is not an SNMP requirement for the getNext request.
                // So we no more use the SnmpIndex but directly the SnmpOid.
                //
                try {
                    entryoid = getNextOid(oid, pos + 2, data);

                    // If the variable must ne skipped, fall through...
                    //
                    // XXX revisit: not exactly perfect:
                    //     a specific row could be empty.. But we don't know
                    //     how to make the difference! => tradeoff holes
                    //     in tables can't be properly supported (all rows
                    //     must have the same holes)
                    //
                    if (skipEntryVariable(entryoid,var,data,pduVersion)) {
                        throw new SnmpStatusException(SnmpStatusException.noSuchObject);
                    }
                } catch(SnmpStatusException se) {
                    entryoid = getNextOid(data);
                    var = getNextVarEntryId(entryoid,var,data,pduVersion);
                }
View Full Code Here

            // it probably means that there is nothing to return anyway.
            // So we throw the exception.
            // => will skip to next node in the MIB tree.
            //
            if (entryoid == null || var == -1 ) {
                throw new SnmpStatusException(SnmpStatusException.noSuchObject);
            }

            // So here we know both the row (entryoid) and the column (var)
            //

            try {
                // Raising an exception here will make the catch() clause
                // switch to the next variable. If `var' is not readable
                // for this specific entry, it is not readable for any
                // other entry => skip to next column.
                //
                if (!isReadableEntryId(entryoid,var,data)) {
                    throw new SnmpStatusException(SnmpStatusException.noSuchObject);
                }

                // Prepare the result and the ACM checker.
                //
                final long[] etable  = entryoid.longValue(false);
                final int    elength = etable.length;
                final long[] result  = new long[depth + 2 + elength];
                result[0] = -1 ; // Bug detector!

                // Copy the entryOid at the end of `result'
                //
                java.lang.System.arraycopy(etable, 0, result,
                                           depth+2, elength);

                // Set the node Id and var Id in result.
                //
                result[depth] = nodeId;
                result[depth+1] = var;

                // Append nodeId.varId.<rowOid> to ACM checker.
                //
                checker.add(depth,result,depth,elength+2);

                // No we're going to ACM check our OID.
                try {
                    checker.checkCurrentOid();

                    // No exception thrown by checker => this is all OK!
                    // we have it: register the handler and return the
                    // result.
                    //
                    handlers.add(this,depth,entryoid,varbind,false);
                    return result;
                } catch(SnmpStatusException e) {
                    // Skip to the next entry. If an exception is
                    // thrown, will be catch by enclosing catch
                    // and a skip is done to the next var.
                    //
                    entryoid = getNextOid(entryoid, data);
                } finally {
                    // Clean the checker.
                    //
                    checker.remove(depth,elength+2);
                }
            } catch(SnmpStatusException e) {
                // Catching an exception here means we have to skip to the
                // next column.
                //
                // Back to the first row.
                entryoid = getNextOid(data);

                // Find out the next column.
                //
                var = getNextVarEntryId(entryoid,var,data,pduVersion);

            }

            // This should not happen. If it happens, (bug, or customized
            // methods returning garbage instead of raising an exception),
            // it probably means that there is nothing to return anyway.
            // No need to continue, we throw an exception.
            // => will skip to next node in the MIB tree.
            //
            if (entryoid == null || var == -1 ) {
                throw new SnmpStatusException(SnmpStatusException.noSuchObject);
            }
        }
    }
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.