📄 snmpmibtable.java
字号:
"Setting RowStatus to `notInService'" + " for row[" + rowOid + "] : requested RowStatus = " + "notInService"); value = setRowStatus(oid,EnumRowStatus.notInService,data); break; case EnumRowStatus.notReady: default: if (isDebugOn()) debug("endRowAction","Invalid RowStatus value for row[" + rowOid + "] : specified RowStatus = " + action); setRowStatusFail(req, SnmpStatusException.snmpRspInconsistentValue); } if (value != null) { final SnmpVarBind vb = req.getRowStatusVarBind(); if (vb != null) vb.value = value; } } // ------------------------------------------------------------------- // PROTECTED METHODS - get next // ------------------------------------------------------------------- /** * Return the next OID arc corresponding to a readable columnar * object in the underlying entry OBJECT-TYPE, possibly skipping over * those objects that must not or cannot be returned. * Calls {@link * #getNextVarEntryId(com.sun.jmx.snmp.SnmpOid,long,java.lang.Object)}, * until * {@link #skipEntryVariable(com.sun.jmx.snmp.SnmpOid,long, * java.lang.Object,int)} returns false. * * * @param rowOid The OID index of the row involved in the operation. * * @param var Id of the variable we start from, looking for the next. * * @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. * * @param pduVersion Protocol version of the original request PDU. * * @return The next columnar object id which can be returned using * the given PDU's protocol version. * * @exception SnmpStatusException If no id is found after the given id. * **/ protected long getNextVarEntryId(SnmpOid rowOid, long var, Object userData, int pduVersion) throws SnmpStatusException { long varid=var; do { varid = getNextVarEntryId(rowOid,varid,userData); } while (skipEntryVariable(rowOid,varid,userData,pduVersion)); return varid; } /** * Hook for subclasses. * The default implementation of this method is to always return * false. Subclasses should redefine this method so that it returns * true when: * <ul><li>the variable is a leaf that is not instantiated,</li> * <li>or the variable is a leaf whose type cannot be returned by that * version of the protocol (e.g. an Counter64 with SNMPv1).</li> * </ul> * * @param rowOid The OID index of the row involved in the operation. * * @param var Id of the variable we start from, looking for the next. * * @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. * * @param pduVersion Protocol version of the original request PDU. * * @return true if the variable must be skipped by the get-next * algorithm. */ protected boolean skipEntryVariable(SnmpOid rowOid, long var, Object userData, int pduVersion) { return false; } /** * 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 noSuchInstanceException; 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 noSuchInstanceException; } // 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 noSuchInstanceException; } } else { // We are dealing with the last element of the table .. // throw noSuchInstanceException; } return last; } /** * 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 noSuchInstanceException; // XX return (SnmpOid) oids.firstElement(); return tableoids[0]; } // ------------------------------------------------------------------- // Abstract Protected Methods // ------------------------------------------------------------------- /** * This method is used internally and is implemented by the * <CODE>SnmpMibTable</CODE> subclasses generated by <CODE>mibgen</CODE>. * * <p> Return the next OID arc corresponding to a readable columnar * object in the underlying entry OBJECT-TYPE.</p> * * <p> * @param rowOid The OID index of the row involved in the operation. * * @param var Id of the variable we start from, looking for the next. * * @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 columnar object id. * * @exception SnmpStatusException If no id is found after the given id. * **/ abstract protected long getNextVarEntryId(SnmpOid rowOid, long var, Object userData) throws SnmpStatusException; /** * This method is used internally and is implemented by the * <CODE>SnmpMibTable</CODE> subclasses generated by <CODE>mibgen</CODE>. * * <p> * @param rowOid The OID index of the row involved in the operation. * * @param var The var we want to validate. * * @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. * * @exception SnmpStatusException If this id is not valid. * */ abstract protected void validateVarEntryId(SnmpOid rowOid, long var, Object userData) throws SnmpStatusException; /** * * This method is used internally and is implemented by the * <CODE>SnmpMibTable</CODE> subclasses generated by <CODE>mibgen</CODE>. * * <p> * @param rowOid The OID index of the row involved in the operation. * * @param var The OID arc. * * @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. * * @exception SnmpStatusException If this id is not valid. * */ abstract protected boolean isReadableEntryId(SnmpOid rowOid, long var, Object userData) throws SnmpStatusException; /** * This method is used internally and is implemented by the * <CODE>SnmpMibTable</CODE> subclasses generated by <CODE>mibgen</CODE>. */ abstract protected void get(SnmpMibSubRequest req, SnmpOid rowOid, int depth) throws SnmpStatusException; /** * This method is used internally and is implemented by the * <CODE>SnmpMibTable</CODE> subclasses generated by <CODE>mibgen</CODE>. */ abstract protected void check(SnmpMibSubRequest req, SnmpOid rowOid, int depth) throws SnmpStatusException; /** * This method is used internally and is implemented by the * <CODE>SnmpMibTable</CODE> subclasses generated by <CODE>mibgen</CODE>. */ abstract protected void set(SnmpMibSubRequest req, SnmpOid rowOid, int depth) throws SnmpStatusException; // ---------------------------------------------------------------------- // PACKAGE METHODS // ---------------------------------------------------------------------- /** * Get the <CODE>SnmpOid</CODE> index of the row that follows the * index extracted from the specified OID array. * Builds the SnmpOid corresponding to the row OID and calls * <code>getNextOid(oid,userData)</code>; * * <p> * @param oid The OID array. * * @param pos The position in the OID array at which the index starts. * * @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>. * * @exception SnmpStatusException There is no index following the * specified one in the table. */ SnmpOid getNextOid(long[] oid, int pos, Object userData) throws SnmpStatusException { // Construct the sub-oid starting at pos. // This sub-oid correspond to the oid part just after the entry // variable oid. // final SnmpOid resOid = new SnmpEntryOid(oid,pos); return getNextOid(resOid,userData); } // --------------------------------------------------------------------- // // Register an exception when checking the RowStatus variable // // --------------------------------------------------------------------- final static void checkRowStatusFail(SnmpMibSubRequest req, int errorStatus) throws SnmpStatusException { final SnmpVarBind statusvb = req.getRowStatusVarBind(); final SnmpStatusException x = new SnmpStatusException(errorStatus); req.registerCheckException(statusvb,x); } // --------------------------------------------------------------------- // // Register an exception when checking the RowStatus variable // // --------------------------------------------------------------------- final static void setRowStatusFail(SnmpMibSubRequest req, int errorStatus) throws SnmpStatusException { final SnmpVarBind statusvb = req.getRowStatusVarBind(); final SnmpStatusException x = new SnmpStatusException(errorStatus); req.registerSetException(statusvb,x); } // --------------------------------------------------------------------- // // Implements the method defined in SnmpMibNode. // // --------------------------------------------------------------------- final synchronized void findHandlingNode(SnmpVarBind varbin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -