Java Code Examples for com.sun.jmx.snmp.SnmpStatusException

The following examples show how to use com.sun.jmx.snmp.SnmpStatusException. These examples are extracted from open source projects. 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
/**
 * Set the value of a scalar variable
 */
public SnmpValue set(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int)var) {
        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
/**
 * Check the value of a scalar variable
 */
public void check(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int) var) {
        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 Project: TencentKona-8   Source File: JvmOSMeta.java    License: 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 4:
            return new SnmpInt(node.getJvmOSProcessorCount());

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

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

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

        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.noSuchObject);
}
 
Example 4
@Override
public void registerCheckException(SnmpVarBind var,
                                   SnmpStatusException exception)
    throws SnmpStatusException {
    // The index in the exception must correspond to
    // the SNMP index ...
    //
    // We throw the exception in order to abort the SET operation
    // in an atomic way.
    final int errorCode = exception.getStatus();
    final int mappedErrorCode = mapSetException(errorCode,
                                                version);

    if (errorCode != mappedErrorCode)
        throw new
            SnmpStatusException(mappedErrorCode, getVarIndex(var)+1);
    else
        throw new SnmpStatusException(exception, getVarIndex(var)+1);
}
 
Example 5
public final boolean contains(SnmpOid index) {
    int pos = 0;

    try {
        pos = (int) index.getOidArc(0);
    }catch(SnmpStatusException e) {
        return false;
    }

    return (pos < datas.length);
}
 
Example 6
public void set(SnmpMibSubRequest req, SnmpOid rowOid, int depth)
    throws SnmpStatusException {
    if (req.getSize() == 0) return;

    JvmRTClassPathEntryMBean entry = (JvmRTClassPathEntryMBean) getEntry(rowOid);
    synchronized (this) {
        node.setInstance(entry);
        node.set(req,depth);
    }
}
 
Example 7
public void createNewEntry(SnmpMibSubRequest req, SnmpOid rowOid, int depth)
    throws SnmpStatusException {
    if (factory != null)
        factory.createNewEntry(req, rowOid, depth, this);
    else
        throw new SnmpStatusException(
            SnmpStatusException.snmpRspNoAccess);
}
 
Example 8
public void get(SnmpMibSubRequest req, SnmpOid rowOid, int depth)
    throws SnmpStatusException {
    JvmThreadInstanceEntryMBean entry = (JvmThreadInstanceEntryMBean) getEntry(rowOid);
    synchronized (this) {
        node.setInstance(entry);
        node.get(req,depth);
    }
}
 
Example 9
public void createNewEntry(SnmpMibSubRequest req, SnmpOid rowOid, int depth)
    throws SnmpStatusException {
    if (factory != null)
        factory.createNewEntry(req, rowOid, depth, this);
    else
        throw new SnmpStatusException(
            SnmpStatusException.snmpRspNoAccess);
}
 
Example 10
Source Project: hottub   Source File: JvmMemPoolTableMeta.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void createNewEntry(SnmpMibSubRequest req, SnmpOid rowOid, int depth)
    throws SnmpStatusException {
    if (factory != null)
        factory.createNewEntry(req, rowOid, depth, this);
    else
        throw new SnmpStatusException(
            SnmpStatusException.snmpRspNoAccess);
}
 
Example 11
public synchronized void addEntry(SnmpOid rowOid, ObjectName objname,
             Object entry)
    throws SnmpStatusException {
    if (! (entry instanceof JvmRTLibraryPathEntryMBean) )
        throw new ClassCastException("Entries for Table \"" +
                       "JvmRTLibraryPathTable" + "\" must implement the \"" +
                       "JvmRTLibraryPathEntryMBean" + "\" interface.");
    super.addEntry(rowOid, objname, entry);
}
 
Example 12
Source Project: JDKSourceCode1.8   Source File: SnmpMibTable.java    License: MIT License 5 votes vote down vote up
/**
 * Search the position at which the given oid should be inserted
 * in the OID table (tableoids).
 *
 * <p>
 * @param oid The OID we would like to insert.
 *
 * @param fail Tells whether a SnmpStatusException must be generated
 *             if the given OID is already present in the table.
 *
 * @return The position at which the OID should be inserted in
 *         the table. When the OID is found, it returns the next
 *         position. Note that it is not valid to insert twice the
 *         same OID. This feature is only an optimization to improve
 *         the getNextOid() behaviour.
 *
 * @exception SnmpStatusException if the OID is already present in the
 *            table and <code>fail</code> is <code>true</code>.
 *
 **/
private int getInsertionPoint(SnmpOid oid, boolean fail)
    throws SnmpStatusException {

    final int failStatus = SnmpStatusException.snmpRspNotWritable;
    int low= 0;
    int max= size - 1;
    SnmpOid pos;
    int comp;
    int curr= low + (max-low)/2;
    while (low <= max) {

        // XX pos= (SnmpOid) oids.elementAt(curr);
        pos= tableoids[curr];

        // never know ...we might find something ...
        //
        comp= oid.compareTo(pos);

        if (comp == 0) {
            if (fail)
                throw new SnmpStatusException(failStatus,curr);
            else
                return curr+1;
        }

        if (comp>0) {
            low= curr +1;
        } else {
            max= curr -1;
        }
        curr= low + (max-low)/2;
    }
    return curr;
}
 
Example 13
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 14
public synchronized void addEntry(SnmpOid rowOid, ObjectName objname,
             Object entry)
    throws SnmpStatusException {
    if (! (entry instanceof JvmRTLibraryPathEntryMBean) )
        throw new ClassCastException("Entries for Table \"" +
                       "JvmRTLibraryPathTable" + "\" must implement the \"" +
                       "JvmRTLibraryPathEntryMBean" + "\" interface.");
    super.addEntry(rowOid, objname, entry);
}
 
Example 15
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 16
/**
 * 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 17
static void checkRowStatusFail(SnmpMibSubRequest req, int errorStatus)
    throws SnmpStatusException {

    final SnmpVarBind statusvb  = req.getRowStatusVarBind();
    final SnmpStatusException x = new SnmpStatusException(errorStatus);
    req.registerCheckException(statusvb,x);
}
 
Example 18
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 19
/**
 * Getter for the "JvmMemPoolCollectThreshdCount" variable.
 */
public Long getJvmMemPoolCollectThreshdCount()
    throws SnmpStatusException {
    if (!pool.isCollectionUsageThresholdSupported())
        return JvmMemoryImpl.Long0;
    final long val = pool.getCollectionUsageThresholdCount();
    if (val > -1) return  new Long(val);
    else return JvmMemoryImpl.Long0;
}
 
Example 20
public static String getJvmThreadInstIndexOid()
    throws SnmpStatusException {
    if (jvmThreadInstIndexOid == null) {
        final SnmpOidTable  table = new JVM_MANAGEMENT_MIBOidTable();
        final SnmpOidRecord record =
            table.resolveVarName("jvmThreadInstIndex");
        jvmThreadInstIndexOid = record.getOid();
    }
    return jvmThreadInstIndexOid;
}
 
Example 21
public void check(SnmpMibSubRequest req, int depth)
    throws SnmpStatusException {
    objectserver.check(this,req,depth);
}
 
Example 22
Source Project: jdk8u-jdk   Source File: JvmRuntimeMeta.java    License: 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 23
protected SnmpOid getNextOid(Object userData)
    throws SnmpStatusException {
    // null means get the first OID.
    return getNextOid(null,userData);
}
 
Example 24
public void check(SnmpMibSubRequest req, int depth)
    throws SnmpStatusException {
    objectserver.check(this,req,depth);
}
 
Example 25
Source Project: TencentKona-8   Source File: JvmRuntimeImpl.java    License: GNU General Public License v2.0 4 votes vote down vote up
/**
 * Getter for the "JvmRTSpecVendor" variable.
 */
public String getJvmRTSpecVendor() throws SnmpStatusException {
    return validDisplayStringTC(getRuntimeMXBean().getSpecVendor());
}
 
Example 26
public void set(SnmpMibSubRequest req, int depth)
    throws SnmpStatusException {
    objectserver.set(this,req,depth);
}
 
Example 27
/**
 * Returns true if "var" identifies a readable scalar object.
 */
public boolean isReadableEntryId( SnmpOid rowOid, long var, Object data )
    throws SnmpStatusException {
    return node.isReadable(var);
}
 
Example 28
Source Project: jdk8u60   Source File: SnmpRequestTree.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void addVarbind(SnmpVarBind varbind, SnmpOid entryoid,
                               boolean isnew, SnmpVarBind statusvb)
            throws SnmpStatusException {
            Vector<SnmpVarBind> v = null;
            SnmpVarBind rs = statusvb;

            if (entryoids == null) {
//              entryoids = new ArrayList();
//              entrylists = new ArrayList();
//              isentrynew = new ArrayList();
                v = new Vector<>();
//              entryoids.add(entryoid);
//              entrylists.add(v);
//              isentrynew.add(new Boolean(isnew));
                add(0,entryoid,v,isnew,rs);
            } else {
                // int pos = findOid(entryoids,entryoid);
                // int pos = findOid(entryoids,entrycount,entryoid);
                final int pos =
                    getInsertionPoint(entryoids,entrycount,entryoid);
                if (pos > -1 && pos < entrycount &&
                    entryoid.compareTo(entryoids[pos]) == 0) {
                    v  = entrylists[pos];
                    rs = rowstatus[pos];
                } else {
                    // if (pos == -1 || pos >= entryoids.size() ) {
                    // if (pos == -1 || pos >= entrycount ) {
                    // pos = getInsertionPoint(entryoids,entryoid);
                    // pos = getInsertionPoint(entryoids,entrycount,entryoid);
                    v = new Vector<>();
//                  entryoids.add(pos,entryoid);
//                  entrylists.add(pos,v);
//                  isentrynew.add(pos,new Boolean(isnew));
                    add(pos,entryoid,v,isnew,rs);
                }
//              } else v = (Vector) entrylists.get(pos);
                    // } else v = entrylists[pos];
                if (statusvb != null) {
                    if ((rs != null) && (rs != statusvb) &&
                        ((type == SnmpDefinitions.pduWalkRequest) ||
                         (type == SnmpDefinitions.pduSetRequestPdu))) {
                        throw new SnmpStatusException(
                              SnmpStatusException.snmpRspInconsistentValue);
                    }
                    rowstatus[pos] = statusvb;
                }
            }

            // We do not include the status variable in the varbind,
            // because we're going to set it separately...
            //
            if (statusvb != varbind)
                v.addElement(varbind);
        }
 
Example 29
/**
 * Getter for the "JvmMemPoolUsed" variable.
 */
public Long getJvmMemPoolUsed() throws SnmpStatusException {
    final long val = getMemoryUsage().getUsed();
    if (val > -1) return  new Long(val);
    else return JvmMemoryImpl.Long0;
}
 
Example 30
/**
 * Getter for the "JvmMemPoolUsed" variable.
 */
public Long getJvmMemPoolUsed() throws SnmpStatusException {
    final long val = getMemoryUsage().getUsed();
    if (val > -1) return  new Long(val);
    else return JvmMemoryImpl.Long0;
}