use of com.sun.jmx.snmp.SnmpStatusException in project jdk8u_jdk by JetBrains.
the class SnmpMibOid method get.
// PUBLIC METHODS
//---------------
/**
* Generic handling of the <CODE>get</CODE> operation.
*
* <p> This method should be overridden in subclasses.
* <p>
*
* @param req The sub-request that must be handled by this node.
*
* @param depth The depth reached in the OID tree.
*
* @exception SnmpStatusException The default implementation (if not
* overridden) is to generate a SnmpStatusException.
*/
@Override
public void get(SnmpMibSubRequest req, int depth) throws SnmpStatusException {
for (Enumeration<SnmpVarBind> e = req.getElements(); e.hasMoreElements(); ) {
SnmpVarBind var = e.nextElement();
SnmpStatusException x = new SnmpStatusException(SnmpStatusException.noSuchObject);
req.registerGetException(var, x);
}
}
use of com.sun.jmx.snmp.SnmpStatusException in project jdk8u_jdk by JetBrains.
the class SnmpMibOid method findHandlingNode.
// ---------------------------------------------------------------------
//
// Implements the method defined in SnmpMibNode.
//
// ---------------------------------------------------------------------
//
@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]);
//
if (child == null)
handlers.add(this, depth, varbind);
else
child.findHandlingNode(varbind, oid, depth + 1, handlers);
}
}
use of com.sun.jmx.snmp.SnmpStatusException in project jdk8u_jdk by JetBrains.
the class SnmpMibOid method set.
/**
* Generic handling of the <CODE>set</CODE> operation.
*
* <p> This method should be overridden in subclasses.
* <p>
*
* @param req The sub-request that must be handled by this node.
*
* @param depth The depth reached in the OID tree.
*
* @exception SnmpStatusException The default implementation (if not
* overridden) is to generate a SnmpStatusException.
*/
@Override
public void set(SnmpMibSubRequest req, int depth) throws SnmpStatusException {
for (Enumeration<SnmpVarBind> e = req.getElements(); e.hasMoreElements(); ) {
SnmpVarBind var = e.nextElement();
SnmpStatusException x = new SnmpStatusException(SnmpStatusException.noAccess);
req.registerSetException(var, x);
}
}
use of com.sun.jmx.snmp.SnmpStatusException in project jdk8u_jdk by JetBrains.
the class SnmpMibTable method addEntry.
/**
* Add a new entry in this <CODE>SnmpMibTable</CODE>.
* Also triggers the addEntryCB() callback of the
* {@link com.sun.jmx.snmp.agent.SnmpTableEntryFactory} interface
* if this node is bound to a factory.
*
* <p>
* @param oid The <CODE>SnmpOid</CODE> identifying the table
* row to be added.
*
* @param name The ObjectName with which this entry is registered.
* This parameter can be omitted if isRegistrationRequired()
* return false.
*
* @param entry The entry to add.
*
* @exception SnmpStatusException The entry couldn't be added
* at the position identified by the given
* <code>rowOid</code>, or if this version of the metadata
* requires ObjectName's, and the given name is null.
*/
// protected synchronized void addEntry(SnmpIndex index, ObjectName name,
// Object entry)
public synchronized void addEntry(SnmpOid oid, ObjectName name, Object entry) throws SnmpStatusException {
if (isRegistrationRequired() == true && name == null)
throw new SnmpStatusException(SnmpStatusException.badValue);
if (size == 0) {
// indexes.addElement(index);
// XX oids.addElement(oid);
insertOid(0, oid);
if (entries != null)
entries.addElement(entry);
if (entrynames != null)
entrynames.addElement(name);
size++;
//
if (factory != null) {
try {
factory.addEntryCb(0, oid, name, entry, this);
} catch (SnmpStatusException x) {
removeOid(0);
if (entries != null)
entries.removeElementAt(0);
if (entrynames != null)
entrynames.removeElementAt(0);
throw x;
}
}
// sends the notifications
//
sendNotification(SnmpTableEntryNotification.SNMP_ENTRY_ADDED, (new Date()).getTime(), entry, name);
return;
}
// Get the insertion position ...
//
int pos = 0;
// bug jaw.00356.B : use oid rather than index to get the
// insertion point.
//
pos = getInsertionPoint(oid, true);
if (pos == size) {
// Add a new element in the vectors ...
//
// indexes.addElement(index);
// XX oids.addElement(oid);
insertOid(tablecount, oid);
if (entries != null)
entries.addElement(entry);
if (entrynames != null)
entrynames.addElement(name);
size++;
} else {
//
try {
// indexes.insertElementAt(index, pos);
// XX oids.insertElementAt(oid, pos);
insertOid(pos, oid);
if (entries != null)
entries.insertElementAt(entry, pos);
if (entrynames != null)
entrynames.insertElementAt(name, pos);
size++;
} catch (ArrayIndexOutOfBoundsException e) {
}
}
//
if (factory != null) {
try {
factory.addEntryCb(pos, oid, name, entry, this);
} catch (SnmpStatusException x) {
removeOid(pos);
if (entries != null)
entries.removeElementAt(pos);
if (entrynames != null)
entrynames.removeElementAt(pos);
throw x;
}
}
// sends the notifications
//
sendNotification(SnmpTableEntryNotification.SNMP_ENTRY_ADDED, (new Date()).getTime(), entry, name);
}
use of com.sun.jmx.snmp.SnmpStatusException in project jdk8u_jdk by JetBrains.
the class SnmpMibTable method get.
// ---------------------------------------------------------------------
//
// Implements the method defined in SnmpMibNode.
//
// ---------------------------------------------------------------------
/**
* Generic handling of the <CODE>get</CODE> operation.
* <p> The default implementation of this method is to
* <ul>
* <li> check whether the entry exists, and if not register an
* exception for each varbind in the list.
* <li> call the generated
* <CODE>get(req,oid,depth+1)</CODE> method. </li>
* </ul>
* <p>
* <pre>
* public void get(SnmpMibSubRequest req, int depth)
* throws SnmpStatusException {
* boolean isnew = req.isNewEntry();
*
* // if the entry does not exists, then registers an error for
* // each varbind involved (nb: this should not happen, since
* // the error should already have been detected earlier)
* //
* if (isnew) {
* SnmpVarBind var = null;
* for (Enumeration e= req.getElements(); e.hasMoreElements();) {
* var = (SnmpVarBind) e.nextElement();
* req.registerGetException(var,noSuchNameException);
* }
* }
*
* final SnmpOid oid = req.getEntryOid();
* get(req,oid,depth+1);
* }
* </pre>
* <p> You should not need to override this method in any cases, because
* it will eventually call
* <CODE>get(SnmpMibSubRequest req, int depth)</CODE> on the generated
* derivative of <CODE>SnmpMibEntry</CODE>. If you need to implement
* specific policies for minimizing the accesses made to some remote
* underlying resources, or if you need to implement some consistency
* checks between the different values provided in the varbind list,
* you should then rather override
* <CODE>get(SnmpMibSubRequest req, int depth)</CODE> on the generated
* derivative of <CODE>SnmpMibEntry</CODE>.
* <p>
*
*/
@Override
public void get(SnmpMibSubRequest req, int depth) throws SnmpStatusException {
final boolean isnew = req.isNewEntry();
final SnmpMibSubRequest r = req;
// should have been registered earlier)
if (isnew) {
SnmpVarBind var;
for (Enumeration<SnmpVarBind> e = r.getElements(); e.hasMoreElements(); ) {
var = e.nextElement();
r.registerGetException(var, new SnmpStatusException(SnmpStatusException.noSuchInstance));
}
}
final SnmpOid oid = r.getEntryOid();
// SnmpIndex index = buildSnmpIndex(oid.longValue(false), 0);
// get(req,index,depth+1);
//
get(req, oid, depth + 1);
}
Aggregations