Java Code Examples for com.sun.jmx.snmp.SnmpStatusException#noSuchInstance()

The following examples show how to use com.sun.jmx.snmp.SnmpStatusException#noSuchInstance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JvmMemManagerEntryMeta.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get the value of a scalar variable
 */
public SnmpValue get(long var, Object data)
    throws SnmpStatusException {
    switch((int)var) {
        case 3:
            return new SnmpInt(node.getJvmMemManagerState());

        case 2:
            return new SnmpString(node.getJvmMemManagerName());

        case 1:
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.noSuchObject);
}
 
Example 2
Source File: JvmMemGCTableMetaImpl.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
protected SnmpOid getNextOid(SnmpOid oid, Object userData)
    throws SnmpStatusException {
    final boolean dbg = log.isDebugOn();
    try {
        if (dbg) log.debug("getNextOid", "previous=" + oid);

        // Get the data handler.
        //
        SnmpTableHandler handler = getHandler(userData);
        if (handler == null) {
            // This should never happen.
            // If we get here it's a bug.
            //
            if (dbg) log.debug("getNextOid", "handler is null!");
            throw new
                SnmpStatusException(SnmpStatusException.noSuchInstance);
        }


        // Get the next oid, using the GC filter.
        //
        final SnmpOid next = filter.getNext(handler,oid);
        if (dbg) log.debug("getNextOid", "next=" + next);

        // if next is null: we reached the end of the table.
        //
        if (next == null)
            throw new
                SnmpStatusException(SnmpStatusException.noSuchInstance);

        return next;
    } catch (RuntimeException x) {
        // debug. This should never happen.
        //
        if (dbg) log.debug("getNextOid",x);
        throw x;
    }
}
 
Example 3
Source File: SnmpMibOid.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
void findHandlingNode(SnmpVarBind varbind,
                      long[] oid, int depth,
                      SnmpRequestTree handlers)
    throws SnmpStatusException {


    final int length = oid.length;
    SnmpMibNode node = null;

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

    if (depth > length) {
        // Nothing is left... the oid is not valid
        throw new SnmpStatusException(SnmpStatusException.noSuchObject);
    } else if (depth == length) {
        // The oid is not complete...
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
    } else {
        // Some children variable or subobject is being querried
        // getChild() will raise an exception if no child is found.
        //
        final SnmpMibNode child= getChild(oid[depth]);

        // XXXX zzzz : what about null children?
        //             (variables for nested groups)
        // if child==null, then we're dealing with a variable or
        // a table: we register this node.
        // This behaviour should be overriden in subclasses,
        // in particular in group meta classes: the group
        // meta classes that hold tables should take care
        // of forwarding this call to all the tables involved.
        //
        if (child == null)
            handlers.add(this,depth,varbind);
        else
            child.findHandlingNode(varbind,oid,depth+1,handlers);
    }
}
 
Example 4
Source File: JvmRTBootClassPathEntryMeta.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the value of a scalar variable
 */
public SnmpValue get(long var, Object data)
    throws SnmpStatusException {
    switch((int)var) {
        case 2:
            return new SnmpString(node.getJvmRTBootClassPathItem());

        case 1:
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.noSuchObject);
}
 
Example 5
Source File: JvmMemManagerTableMetaImpl.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
protected SnmpOid getNextOid(SnmpOid oid, Object userData)
    throws SnmpStatusException {
    final boolean dbg = log.isDebugOn();
    if (dbg) log.debug("getNextOid", "previous=" + oid);


    // Get the data handler.
    //
    SnmpTableHandler handler = getHandler(userData);
    if (handler == null) {
        // This should never happen.
        // If we get here it's a bug.
        //
        if (dbg) log.debug("getNextOid", "handler is null!");
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
    }

    // Get the next oid
    //
    final SnmpOid next = handler.getNext(oid);
    if (dbg) log.debug("getNextOid", "next=" + next);

    // if next is null: we reached the end of the table.
    //
    if (next == null)
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);

    return next;
}
 
Example 6
Source File: JvmRTBootClassPathEntryMeta.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the value of a scalar variable
 */
public SnmpValue get(long var, Object data)
    throws SnmpStatusException {
    switch((int)var) {
        case 2:
            return new SnmpString(node.getJvmRTBootClassPathItem());

        case 1:
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.noSuchObject);
}
 
Example 7
Source File: SnmpMibOid.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
void findHandlingNode(SnmpVarBind varbind,
                      long[] oid, int depth,
                      SnmpRequestTree handlers)
    throws SnmpStatusException {


    final int length = oid.length;
    SnmpMibNode node = null;

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

    if (depth > length) {
        // Nothing is left... the oid is not valid
        throw new SnmpStatusException(SnmpStatusException.noSuchObject);
    } else if (depth == length) {
        // The oid is not complete...
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
    } else {
        // Some children variable or subobject is being querried
        // getChild() will raise an exception if no child is found.
        //
        final SnmpMibNode child= getChild(oid[depth]);

        // XXXX zzzz : what about null children?
        //             (variables for nested groups)
        // if child==null, then we're dealing with a variable or
        // a table: we register this node.
        // This behaviour should be overriden in subclasses,
        // in particular in group meta classes: the group
        // meta classes that hold tables should take care
        // of forwarding this call to all the tables involved.
        //
        if (child == null)
            handlers.add(this,depth,varbind);
        else
            child.findHandlingNode(varbind,oid,depth+1,handlers);
    }
}
 
Example 8
Source File: JvmThreadingMeta.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the name of the attribute corresponding to the SNMP variable identified by "id".
 */
public String getAttributeName(long id)
    throws SnmpStatusException {
    switch((int)id) {
        case 6:
            return "JvmThreadCpuTimeMonitoring";

        case 5:
            return "JvmThreadContentionMonitoring";

        case 4:
            return "JvmThreadTotalStartedCount";

        case 3:
            return "JvmThreadPeakCount";

        case 2:
            return "JvmThreadDaemonCount";

        case 1:
            return "JvmThreadCount";

        case 10: {
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
            }

        case 7:
            return "JvmThreadPeakCountReset";

        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.noSuchObject);
}
 
Example 9
Source File: JvmRTClassPathEntryMeta.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the value of a scalar variable
 */
public SnmpValue get(long var, Object data)
    throws SnmpStatusException {
    switch((int)var) {
        case 2:
            return new SnmpString(node.getJvmRTClassPathItem());

        case 1:
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.noSuchObject);
}
 
Example 10
Source File: JvmRTInputArgsEntryMeta.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the value of a scalar variable
 */
public SnmpValue get(long var, Object data)
    throws SnmpStatusException {
    switch((int)var) {
        case 2:
            return new SnmpString(node.getJvmRTInputArgsItem());

        case 1:
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.noSuchObject);
}
 
Example 11
Source File: JvmRTLibraryPathTableMetaImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
protected SnmpOid getNextOid(SnmpOid oid, Object userData)
    throws SnmpStatusException {
    final boolean dbg = log.isDebugOn();
    if (dbg) log.debug("getNextOid", "previous=" + oid);


    // Get the data handler.
    //
    SnmpTableHandler handler = getHandler(userData);
    if (handler == null) {
        // This should never happen.
        // If we get here it's a bug.
        //
        if (dbg) log.debug("getNextOid", "handler is null!");
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
    }

    // Get the next oid
    //
    final SnmpOid next = handler.getNext(oid);
    if (dbg) log.debug("*** **** **** **** getNextOid", "next=" + next);

    // if next is null: we reached the end of the table.
    //
    if (next == null)
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);

    return next;
}
 
Example 12
Source File: JvmThreadInstanceTableMetaImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public Object getEntry(SnmpOid oid)
    throws SnmpStatusException {
    log.debug("*** **** **** **** getEntry", "oid [" + oid + "]");
    if (oid == null || oid.getLength() != 8) {
        log.debug("getEntry", "Invalid oid [" + oid + "]");
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
    }

    // Get the request contextual cache (userData).
    //
    final Map<Object,Object> m = JvmContextFactory.getUserData();

    // Get the handler.
    //
    SnmpTableHandler handler = getHandler(m);

    // handler should never be null.
    //
    if (handler == null || !handler.contains(oid))
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);

    final JvmThreadInstanceEntryImpl entry = getJvmThreadInstance(m,oid);

    if (entry == null)
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);

    return entry;
}
 
Example 13
Source File: JvmThreadingMeta.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the name of the attribute corresponding to the SNMP variable identified by "id".
 */
public String getAttributeName(long id)
    throws SnmpStatusException {
    switch((int)id) {
        case 6:
            return "JvmThreadCpuTimeMonitoring";

        case 5:
            return "JvmThreadContentionMonitoring";

        case 4:
            return "JvmThreadTotalStartedCount";

        case 3:
            return "JvmThreadPeakCount";

        case 2:
            return "JvmThreadDaemonCount";

        case 1:
            return "JvmThreadCount";

        case 10: {
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
            }

        case 7:
            return "JvmThreadPeakCountReset";

        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.noSuchObject);
}
 
Example 14
Source File: JvmRuntimeMeta.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Return the name of the attribute corresponding to the SNMP variable identified by "id".
 */
public String getAttributeName(long id)
    throws SnmpStatusException {
    switch((int)id) {
        case 23: {
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
            }

        case 22: {
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
            }

        case 21: {
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
            }

        case 9:
            return "JvmRTBootClassPathSupport";

        case 20: {
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
            }

        case 8:
            return "JvmRTManagementSpecVersion";

        case 7:
            return "JvmRTSpecVersion";

        case 6:
            return "JvmRTSpecVendor";

        case 5:
            return "JvmRTSpecName";

        case 4:
            return "JvmRTVMVersion";

        case 3:
            return "JvmRTVMVendor";

        case 12:
            return "JvmRTStartTimeMs";

        case 11:
            return "JvmRTUptimeMs";

        case 2:
            return "JvmRTVMName";

        case 1:
            return "JvmRTName";

        case 10:
            return "JvmRTInputArgsCount";

        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.noSuchObject);
}
 
Example 15
Source File: SnmpMibTable.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Override
final synchronized void findHandlingNode(SnmpVarBind varbind,
                                         long[] oid, int depth,
                                         SnmpRequestTree handlers)
    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];

    // Validate the entry id
    if (hasEntry) {
        // The entry already exists - validate the id
        validateVarEntryId(entryoid,var,data);
    }

    // Registers this node for the identified entry.
    //
    if (handlers.isSetRequest() && isRowStatus(entryoid,var,data))

        // We only try to identify the RowStatus for SET operations
        //
        handlers.add(this,depth,entryoid,varbind,(!hasEntry),varbind);

    else
        handlers.add(this,depth,entryoid,varbind,(!hasEntry));
}
 
Example 16
Source File: SnmpMibTable.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Get the <CODE>SnmpOid</CODE> index of the row that follows
 * the given <CODE>oid</CODE> in the table. The given <CODE>
 * oid</CODE> does not need to be a valid row OID index.
 *
 * <p>
 * @param oid The OID from which the search will begin.
 *
 * @param userData A contextual object containing user-data.
 *        This object is allocated through the <code>
 *        {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}</code>
 *        for each incoming SNMP request.
 *
 * @return The next <CODE>SnmpOid</CODE> index.
 *
 * @exception SnmpStatusException There is no index following the
 *     specified <CODE>oid</CODE> in the table.
 */
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;
}
 
Example 17
Source File: JvmRuntimeMeta.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Get the value of a scalar variable
 */
public SnmpValue get(long var, Object data)
    throws SnmpStatusException {
    switch((int)var) {
        case 23: {
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
            }

        case 22: {
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
            }

        case 21: {
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
            }

        case 9:
            return new SnmpInt(node.getJvmRTBootClassPathSupport());

        case 20: {
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
            }

        case 8:
            return new SnmpString(node.getJvmRTManagementSpecVersion());

        case 7:
            return new SnmpString(node.getJvmRTSpecVersion());

        case 6:
            return new SnmpString(node.getJvmRTSpecVendor());

        case 5:
            return new SnmpString(node.getJvmRTSpecName());

        case 4:
            return new SnmpString(node.getJvmRTVMVersion());

        case 3:
            return new SnmpString(node.getJvmRTVMVendor());

        case 12:
            return new SnmpCounter64(node.getJvmRTStartTimeMs());

        case 11:
            return new SnmpCounter64(node.getJvmRTUptimeMs());

        case 2:
            return new SnmpString(node.getJvmRTVMName());

        case 1:
            return new SnmpString(node.getJvmRTName());

        case 10:
            return new SnmpInt(node.getJvmRTInputArgsCount());

        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.noSuchObject);
}
 
Example 18
Source File: SnmpRequestTree.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public static int mapGetException(int errorStatus, int version)
    throws SnmpStatusException {

    final int errorCode = errorStatus;
    if (version == SnmpDefinitions.snmpVersionOne)
        return errorCode;

    int mappedErrorCode = errorCode;

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

    else if (errorCode ==
             SnmpStatusException.noSuchInstance)
        // noSuchInstance => noSuchInstance
        mappedErrorCode = errorCode;

    // Now we're going to try to transform every other
    // global code in either noSuchInstance or noSuchObject,
    // so that the get can return a partial result.
    //
    // Only noSuchInstance or noSuchObject can be stored
    // in the varbind itself.
    //

    // According to RFC 1905: noAccess is emitted when the
    // the access is denied because it is not in the MIB view...
    //
    else if (errorCode ==
             SnmpStatusException.noAccess)
        // noAccess => noSuchInstance
        mappedErrorCode = SnmpStatusException.noSuchInstance;

    // According to RFC 1905: (my interpretation because it is not
    // really clear) The specified variable name exists - but the
    // variable does not exists and cannot be created under the
    // present circumstances (probably because the request specifies
    // another variable/value which is incompatible, or because the
    // value of some other variable in the MIB prevents the creation)
    //
    // Note that this error should never be raised in a GET context
    // but who knows?
    //
    else if (errorCode == SnmpStatusException.snmpRspInconsistentName)
        // inconsistentName => noSuchInstance
        mappedErrorCode = SnmpStatusException.noSuchInstance;

    // All the errors comprised between snmpRspWrongType and
    // snmpRspInconsistentValue concern values: so we're going
    // to assume the OID was correct, and reply with noSuchInstance.
    //
    // Note that this error should never be raised in a GET context
    // but who knows?
    //
    else if ((errorCode >= SnmpStatusException.snmpRspWrongType) &&
             (errorCode <= SnmpStatusException.snmpRspInconsistentValue))
        mappedErrorCode = SnmpStatusException.noSuchInstance;

    // We're going to assume the OID was correct, and reply
    // with noSuchInstance.
    //
    else if (errorCode == SnmpStatusException.readOnly)
        mappedErrorCode = SnmpStatusException.noSuchInstance;

    // For all other errors but genErr, we're going to reply with
    // noSuchObject
    //
    else if (errorCode != SnmpStatusException.snmpRspAuthorizationError &&
             errorCode != SnmpStatusException.snmpRspGenErr)
        mappedErrorCode = SnmpStatusException.noSuchObject;

    // Only genErr will abort the GET and be returned as global
    // error.
    //
    return mappedErrorCode;

}
 
Example 19
Source File: SnmpMibTable.java    From jdk1.8-source-analysis with Apache License 2.0 3 votes vote down vote up
/**
 * Return the first entry OID registered in the table.
 *
 * <p>
 * @param userData A contextual object containing user-data.
 *        This object is allocated through the <code>
 *        {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}</code>
 *        for each incoming SNMP request.
 *
 * @return The <CODE>SnmpOid</CODE> of the first entry in the table.
 *
 * @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];
}
 
Example 20
Source File: SnmpMibTable.java    From TencentKona-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Get the ObjectName of the entry corresponding to the
 * specified rowOid.
 * The result of this method is only meaningful if
 * isRegistrationRequired() yields true.
 *
 * <p>
 * @param rowOid The <CODE>SnmpOid</CODE> identifying the table
 *        row whose ObjectName we want to retrieve.
 *
 * @return The object name of the entry.
 *
 * @exception SnmpStatusException There is no entry with the specified
 *      <code>rowOid</code> in the table.
 */
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);
}