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

The following examples show how to use com.sun.jmx.snmp.SnmpStatusException#snmpRspWrongType() . 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: JvmClassLoadingMeta.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the value of a scalar variable
 */
public SnmpValue set(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int)var) {
        case 4:
            if (x instanceof SnmpInt) {
                try  {
                    node.setJvmClassesVerboseLevel( new EnumJvmClassesVerboseLevel (((SnmpInt)x).toInteger()));
                } catch(IllegalArgumentException e)  {
                    throw new SnmpStatusException(SnmpStatusException.snmpRspWrongValue);
                }
                return new SnmpInt(node.getJvmClassesVerboseLevel());
            } else {
                throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
            }

        case 3:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 2:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 1:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
}
 
Example 2
Source File: JvmClassLoadingMeta.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check the value of a scalar variable
 */
public void check(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int) var) {
        case 4:
            if (x instanceof SnmpInt) {
                try  {
                    node.checkJvmClassesVerboseLevel( new EnumJvmClassesVerboseLevel (((SnmpInt)x).toInteger()));
                } catch(IllegalArgumentException e)  {
                    throw new SnmpStatusException(SnmpStatusException.snmpRspWrongValue);
                }
            } else {
                throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
            }
            break;

        case 3:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 2:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 1:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        default:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
    }
}
 
Example 3
Source File: JvmClassLoadingMeta.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check the value of a scalar variable
 */
public void check(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int) var) {
        case 4:
            if (x instanceof SnmpInt) {
                try  {
                    node.checkJvmClassesVerboseLevel( new EnumJvmClassesVerboseLevel (((SnmpInt)x).toInteger()));
                } catch(IllegalArgumentException e)  {
                    throw new SnmpStatusException(SnmpStatusException.snmpRspWrongValue);
                }
            } else {
                throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
            }
            break;

        case 3:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 2:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 1:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        default:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
    }
}
 
Example 4
Source File: JvmClassLoadingMeta.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check the value of a scalar variable
 */
public void check(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int) var) {
        case 4:
            if (x instanceof SnmpInt) {
                try  {
                    node.checkJvmClassesVerboseLevel( new EnumJvmClassesVerboseLevel (((SnmpInt)x).toInteger()));
                } catch(IllegalArgumentException e)  {
                    throw new SnmpStatusException(SnmpStatusException.snmpRspWrongValue);
                }
            } else {
                throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
            }
            break;

        case 3:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 2:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 1:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        default:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
    }
}
 
Example 5
Source File: JvmClassLoadingMeta.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the value of a scalar variable
 */
public SnmpValue set(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int)var) {
        case 4:
            if (x instanceof SnmpInt) {
                try  {
                    node.setJvmClassesVerboseLevel( new EnumJvmClassesVerboseLevel (((SnmpInt)x).toInteger()));
                } catch(IllegalArgumentException e)  {
                    throw new SnmpStatusException(SnmpStatusException.snmpRspWrongValue);
                }
                return new SnmpInt(node.getJvmClassesVerboseLevel());
            } else {
                throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
            }

        case 3:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 2:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 1:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
}
 
Example 6
Source File: JvmClassLoadingMeta.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check the value of a scalar variable
 */
public void check(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int) var) {
        case 4:
            if (x instanceof SnmpInt) {
                try  {
                    node.checkJvmClassesVerboseLevel( new EnumJvmClassesVerboseLevel (((SnmpInt)x).toInteger()));
                } catch(IllegalArgumentException e)  {
                    throw new SnmpStatusException(SnmpStatusException.snmpRspWrongValue);
                }
            } else {
                throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
            }
            break;

        case 3:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 2:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 1:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        default:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
    }
}
 
Example 7
Source File: JvmMemPoolEntryMeta.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Check the value of a scalar variable
 */
public void check(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int) var) {
        case 33:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 32:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 31:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 133:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 132:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 131:
            if (x instanceof SnmpCounter64) {
                node.checkJvmMemPoolCollectThreshold(((SnmpCounter64)x).toLong());
            } else {
                throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
            }
            break;

        case 13:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 12:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 11:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 10:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 112:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 111:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 110:
            if (x instanceof SnmpCounter64) {
                node.checkJvmMemPoolThreshold(((SnmpCounter64)x).toLong());
            } else {
                throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
            }
            break;

        case 5:
            if (x instanceof SnmpCounter64) {
                node.checkJvmMemPoolPeakReset(((SnmpCounter64)x).toLong());
            } else {
                throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
            }
            break;

        case 4:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 3:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 2:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 23:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 1:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 22:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 21:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        default:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
    }
}
 
Example 8
Source File: JvmMemPoolEntryMeta.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Check the value of a scalar variable
 */
public void check(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int) var) {
        case 33:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 32:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 31:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 133:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 132:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 131:
            if (x instanceof SnmpCounter64) {
                node.checkJvmMemPoolCollectThreshold(((SnmpCounter64)x).toLong());
            } else {
                throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
            }
            break;

        case 13:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 12:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 11:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 10:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 112:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 111:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 110:
            if (x instanceof SnmpCounter64) {
                node.checkJvmMemPoolThreshold(((SnmpCounter64)x).toLong());
            } else {
                throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
            }
            break;

        case 5:
            if (x instanceof SnmpCounter64) {
                node.checkJvmMemPoolPeakReset(((SnmpCounter64)x).toLong());
            } else {
                throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
            }
            break;

        case 4:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 3:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 2:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 23:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 1:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 22:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 21:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        default:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
    }
}
 
Example 9
Source File: JvmMemPoolEntryMeta.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Set the value of a scalar variable
 */
public SnmpValue set(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int)var) {
        case 33:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 32:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 31:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 133:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 132:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 131:
            if (x instanceof SnmpCounter64) {
                node.setJvmMemPoolCollectThreshold(((SnmpCounter64)x).toLong());
                return new SnmpCounter64(node.getJvmMemPoolCollectThreshold());
            } else {
                throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
            }

        case 13:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 12:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 11:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 10:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 112:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 111:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 110:
            if (x instanceof SnmpCounter64) {
                node.setJvmMemPoolThreshold(((SnmpCounter64)x).toLong());
                return new SnmpCounter64(node.getJvmMemPoolThreshold());
            } else {
                throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
            }

        case 5:
            if (x instanceof SnmpCounter64) {
                node.setJvmMemPoolPeakReset(((SnmpCounter64)x).toLong());
                return new SnmpCounter64(node.getJvmMemPoolPeakReset());
            } else {
                throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
            }

        case 4:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 3:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 2:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 23:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 1:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 22:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 21:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
}
 
Example 10
Source File: SnmpRequestTree.java    From openjdk-jdk8u-backup 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 11
Source File: JvmMemPoolEntryMeta.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Set the value of a scalar variable
 */
public SnmpValue set(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int)var) {
        case 33:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 32:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 31:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 133:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 132:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 131:
            if (x instanceof SnmpCounter64) {
                node.setJvmMemPoolCollectThreshold(((SnmpCounter64)x).toLong());
                return new SnmpCounter64(node.getJvmMemPoolCollectThreshold());
            } else {
                throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
            }

        case 13:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 12:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 11:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 10:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 112:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 111:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 110:
            if (x instanceof SnmpCounter64) {
                node.setJvmMemPoolThreshold(((SnmpCounter64)x).toLong());
                return new SnmpCounter64(node.getJvmMemPoolThreshold());
            } else {
                throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
            }

        case 5:
            if (x instanceof SnmpCounter64) {
                node.setJvmMemPoolPeakReset(((SnmpCounter64)x).toLong());
                return new SnmpCounter64(node.getJvmMemPoolPeakReset());
            } else {
                throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
            }

        case 4:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 3:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 2:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 23:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 1:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 22:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 21:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
}
 
Example 12
Source File: JvmMemPoolEntryMeta.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Check the value of a scalar variable
 */
public void check(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int) var) {
        case 33:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 32:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 31:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 133:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 132:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 131:
            if (x instanceof SnmpCounter64) {
                node.checkJvmMemPoolCollectThreshold(((SnmpCounter64)x).toLong());
            } else {
                throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
            }
            break;

        case 13:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 12:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 11:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 10:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 112:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 111:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 110:
            if (x instanceof SnmpCounter64) {
                node.checkJvmMemPoolThreshold(((SnmpCounter64)x).toLong());
            } else {
                throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
            }
            break;

        case 5:
            if (x instanceof SnmpCounter64) {
                node.checkJvmMemPoolPeakReset(((SnmpCounter64)x).toLong());
            } else {
                throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
            }
            break;

        case 4:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 3:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 2:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 23:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 1:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 22:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 21:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        default:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
    }
}
 
Example 13
Source File: SnmpRequestTree.java    From jdk1.8-source-analysis with Apache License 2.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 14
Source File: SnmpRequestTree.java    From jdk8u-jdk 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 15
Source File: JvmMemPoolEntryMeta.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Check the value of a scalar variable
 */
public void check(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int) var) {
        case 33:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 32:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 31:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 133:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 132:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 131:
            if (x instanceof SnmpCounter64) {
                node.checkJvmMemPoolCollectThreshold(((SnmpCounter64)x).toLong());
            } else {
                throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
            }
            break;

        case 13:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 12:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 11:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 10:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 112:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 111:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 110:
            if (x instanceof SnmpCounter64) {
                node.checkJvmMemPoolThreshold(((SnmpCounter64)x).toLong());
            } else {
                throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
            }
            break;

        case 5:
            if (x instanceof SnmpCounter64) {
                node.checkJvmMemPoolPeakReset(((SnmpCounter64)x).toLong());
            } else {
                throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
            }
            break;

        case 4:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 3:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 2:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 23:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 1:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 22:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 21:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        default:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
    }
}
 
Example 16
Source File: SnmpRequestTree.java    From jdk8u-jdk 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 17
Source File: SnmpRequestTree.java    From jdk8u_jdk 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 18
Source File: SnmpRequestTree.java    From openjdk-8-source 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: JvmMemPoolEntryMeta.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Set the value of a scalar variable
 */
public SnmpValue set(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int)var) {
        case 33:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 32:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 31:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 133:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 132:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 131:
            if (x instanceof SnmpCounter64) {
                node.setJvmMemPoolCollectThreshold(((SnmpCounter64)x).toLong());
                return new SnmpCounter64(node.getJvmMemPoolCollectThreshold());
            } else {
                throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
            }

        case 13:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 12:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 11:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 10:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 112:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 111:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 110:
            if (x instanceof SnmpCounter64) {
                node.setJvmMemPoolThreshold(((SnmpCounter64)x).toLong());
                return new SnmpCounter64(node.getJvmMemPoolThreshold());
            } else {
                throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
            }

        case 5:
            if (x instanceof SnmpCounter64) {
                node.setJvmMemPoolPeakReset(((SnmpCounter64)x).toLong());
                return new SnmpCounter64(node.getJvmMemPoolPeakReset());
            } else {
                throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
            }

        case 4:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 3:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 2:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 23:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 1:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 22:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 21:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
}
 
Example 20
Source File: JvmMemPoolEntryMeta.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Set the value of a scalar variable
 */
public SnmpValue set(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int)var) {
        case 33:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 32:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 31:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 133:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 132:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 131:
            if (x instanceof SnmpCounter64) {
                node.setJvmMemPoolCollectThreshold(((SnmpCounter64)x).toLong());
                return new SnmpCounter64(node.getJvmMemPoolCollectThreshold());
            } else {
                throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
            }

        case 13:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 12:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 11:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 10:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 112:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 111:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 110:
            if (x instanceof SnmpCounter64) {
                node.setJvmMemPoolThreshold(((SnmpCounter64)x).toLong());
                return new SnmpCounter64(node.getJvmMemPoolThreshold());
            } else {
                throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
            }

        case 5:
            if (x instanceof SnmpCounter64) {
                node.setJvmMemPoolPeakReset(((SnmpCounter64)x).toLong());
                return new SnmpCounter64(node.getJvmMemPoolPeakReset());
            } else {
                throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
            }

        case 4:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 3:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 2:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 23:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 1:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 22:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 21:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
}