Methods Summary |
---|
public abstract void | check(SnmpMibRequest req)Checks if a set operation can be performed.
If the operation can not be performed, the method should throw an
SnmpStatusException .
This method is called during the first phase of the SET two-phase
commit.
|
private void | concatVector(SnmpMibRequest req, java.util.Vector source)
for(Enumeration e= source.elements(); e.hasMoreElements(); ) {
SnmpVarBind var= (SnmpVarBind) e.nextElement();
// We need to duplicate the SnmpVarBind otherwise it is going
// to be overloaded by the next get Next ...
req.addVarBind(new SnmpVarBind(var.oid, var.value));
}
|
private void | concatVector(java.util.Vector target, java.util.Vector source)
for(Enumeration e= source.elements(); e.hasMoreElements(); ) {
SnmpVarBind var= (SnmpVarBind) e.nextElement();
// We need to duplicate the SnmpVarBind otherwise it is going
// to be overloaded by the next get Next ...
target.addElement(new SnmpVarBind(var.oid, var.value));
}
|
public abstract void | get(SnmpMibRequest req)Processes a get operation.
This method must update the SnmpVarBinds contained in the
{@link SnmpMibRequest} req parameter.
|
public boolean | getBindingState()Indicates whether or not the MIB module is bound to a SNMP protocol
adaptor.
As a reminder, only bound MIBs can be accessed through SNMP protocol
adaptor.
if (adaptor == null)
return false;
else
return true;
|
public abstract void | getBulk(SnmpMibRequest req, int nonRepeat, int maxRepeat)Processes a getBulk operation.
This method must update the SnmpVarBinds contained in the
{@link SnmpMibRequest} req parameter.
|
void | getBulkWithGetNext(SnmpMibRequest req, int nonRepeat, int maxRepeat)Processes a getBulk operation using call to
getNext .
The method implements the getBulk operation by calling
appropriately the getNext method.
final Vector list = req.getSubList();
// RFC 1905, Section 4.2.3, p14
final int L = list.size() ;
final int N = Math.max(Math.min(nonRepeat, L), 0) ;
final int M = Math.max(maxRepeat, 0) ;
final int R = L - N ;
// Let's build the varBindList for the response pdu
//
// int errorStatus = SnmpDefinitions.snmpRspNoError ;
// int errorIndex = 0 ;
if (L != 0) {
// Non-repeaters and first row of repeaters
//
getNext(req);
// Now the remaining repeaters
//
Vector repeaters= splitFrom(list, N);
SnmpMibRequestImpl repeatedReq =
new SnmpMibRequestImpl(req.getEngine(),
req.getPdu(),
repeaters,
SnmpDefinitions.snmpVersionTwo,
req.getUserData(),
req.getPrincipal(),
req.getSecurityLevel(),
req.getSecurityModel(),
req.getContextName(),
req.getAccessContextName());
for (int i = 2 ; i <= M ; i++) {
getNext(repeatedReq);
concatVector(req, repeaters);
}
}
|
public javax.management.MBeanServer | getMBeanServer()Gets the reference to the MBean server in which the SNMP MIB is
registered.
return server;
|
public java.lang.String | getMibName()Gets the MIB name.
return mibName;
|
public abstract void | getNext(SnmpMibRequest req)Processes a getNext operation.
This method must update the SnmpVarBinds contained in the
{@link SnmpMibRequest} req parameter.
|
public abstract long[] | getRootOid()Gets the root object identifier of the MIB.
The root object identifier is the object identifier uniquely
identifying the MIB.
|
private static int | getSecurityModel(int version)
switch(version) {
case SnmpDefinitions.snmpVersionOne:
return SnmpDefinitions.snmpV1SecurityModel;
default:
return SnmpDefinitions.snmpV2SecurityModel;
}
|
public SnmpMibHandler | getSnmpAdaptor()Gets the reference to the SNMP protocol adaptor to which the MIB is
bound.
return adaptor;
|
public javax.management.ObjectName | getSnmpAdaptorName()Gets the object name of the SNMP protocol adaptor to which the MIB
is bound.
return adaptorName;
|
public abstract void | init()Initializes the MIB (with no registration of the MBeans into the
MBean server).
|
public static SnmpMibRequest | newMibRequest(com.sun.jmx.snmp.SnmpPdu reqPdu, java.util.Vector vblist, int version, java.lang.Object userData)This is a factory method for creating new SnmpMibRequest objects.
return new SnmpMibRequestImpl(null,
reqPdu,
vblist,
version,
userData,
null,
SnmpDefinitions.noAuthNoPriv,
getSecurityModel(version),
null,null);
|
public static SnmpMibRequest | newMibRequest(com.sun.jmx.snmp.SnmpEngine engine, com.sun.jmx.snmp.SnmpPdu reqPdu, java.util.Vector vblist, int version, java.lang.Object userData, java.lang.String principal, int securityLevel, int securityModel, byte[] contextName, byte[] accessContextName)This is a factory method for creating new SnmpMibRequest objects.
return new SnmpMibRequestImpl(engine,
reqPdu,
vblist,
version,
userData,
principal,
securityLevel,
securityModel,
contextName,
accessContextName);
|
public void | postDeregister()Not used in this context.
|
public void | postRegister(java.lang.Boolean registrationDone)Not used in this context.
|
public void | preDeregister()Not used in this context.
|
public abstract javax.management.ObjectName | preRegister(javax.management.MBeanServer server, javax.management.ObjectName name)Initializes the MIB but each single MBean representing the MIB
is inserted into the MBean server.
|
public abstract void | set(SnmpMibRequest req)Processes a set operation.
This method must update the SnmpVarBinds contained in the
{@link SnmpMibRequest} req parameter.
This method is called during the second phase of the SET two-phase
commit.
|
public void | setSnmpAdaptor(SnmpMibHandler stack)Sets the reference to the SNMP protocol adaptor through which the MIB
will be SNMP accessible and add this new MIB in the SNMP MIB handler.
if (adaptor != null) {
adaptor.removeMib(this);
}
adaptor = stack;
if (adaptor != null) {
adaptor.addMib(this);
}
|
public void | setSnmpAdaptor(SnmpMibHandler stack, com.sun.jmx.snmp.SnmpOid[] oids)Sets the reference to the SNMP protocol adaptor through which the MIB
will be SNMP accessible and add this new MIB in the SNMP MIB handler.
This method is to be called to set a specific agent to a specific OID. This can be useful when dealing with MIB overlapping.
Some OID can be implemented in more than one MIB. In this case, the OID nearest the agent will be used on SNMP operations.
if (adaptor != null) {
adaptor.removeMib(this);
}
adaptor = stack;
if (adaptor != null) {
adaptor.addMib(this, oids);
}
|
public void | setSnmpAdaptor(SnmpMibHandler stack, java.lang.String contextName)Sets the reference to the SNMP protocol adaptor through which the MIB
will be SNMP accessible and adds this new MIB in the SNMP MIB handler.
Adds a new contextualized MIB in the SNMP MIB handler.
if (adaptor != null) {
adaptor.removeMib(this, contextName);
}
adaptor = stack;
if (adaptor != null) {
adaptor.addMib(this, contextName);
}
|
public void | setSnmpAdaptor(SnmpMibHandler stack, java.lang.String contextName, com.sun.jmx.snmp.SnmpOid[] oids)Sets the reference to the SNMP protocol adaptor through which the MIB
will be SNMP accessible and adds this new MIB in the SNMP MIB handler.
Adds a new contextualized MIB in the SNMP MIB handler.
if (adaptor != null) {
adaptor.removeMib(this, contextName);
}
adaptor = stack;
if (adaptor != null) {
adaptor.addMib(this, contextName, oids);
}
|
public void | setSnmpAdaptorName(javax.management.ObjectName name)Sets the reference to the SNMP protocol adaptor through which the MIB
will be SNMP accessible and add this new MIB in the SNMP MIB handler
associated to the specified name .
if (server == null) {
throw new ServiceNotFoundException(mibName + " is not registered in the MBean server");
}
// First remove the reference on the old adaptor server.
//
if (adaptor != null) {
adaptor.removeMib(this);
}
// Then update the reference to the new adaptor server.
//
Object[] params = {this};
String[] signature = {"com.sun.jmx.snmp.agent.SnmpMibAgent"};
try {
adaptor = (SnmpMibHandler)(server.invoke(name, "addMib", params,
signature));
} catch (InstanceNotFoundException e) {
throw new InstanceNotFoundException(name.toString());
} catch (ReflectionException e) {
throw new ServiceNotFoundException(name.toString());
} catch (MBeanException e) {
// Should never occur...
}
adaptorName = name;
|
public void | setSnmpAdaptorName(javax.management.ObjectName name, com.sun.jmx.snmp.SnmpOid[] oids)Sets the reference to the SNMP protocol adaptor through which the MIB
will be SNMP accessible and add this new MIB in the SNMP MIB handler
associated to the specified name .
This method is to be called to set a specific agent to a specific OID. This can be useful when dealing with MIB overlapping.
Some OID can be implemented in more than one MIB. In this case, the OID nearer agent will be used on SNMP operations.
if (server == null) {
throw new ServiceNotFoundException(mibName + " is not registered in the MBean server");
}
// First remove the reference on the old adaptor server.
//
if (adaptor != null) {
adaptor.removeMib(this);
}
// Then update the reference to the new adaptor server.
//
Object[] params = {this, oids};
String[] signature = {"com.sun.jmx.snmp.agent.SnmpMibAgent",
oids.getClass().getName()};
try {
adaptor = (SnmpMibHandler)(server.invoke(name, "addMib", params,
signature));
} catch (InstanceNotFoundException e) {
throw new InstanceNotFoundException(name.toString());
} catch (ReflectionException e) {
throw new ServiceNotFoundException(name.toString());
} catch (MBeanException e) {
// Should never occur...
}
adaptorName = name;
|
public void | setSnmpAdaptorName(javax.management.ObjectName name, java.lang.String contextName)Sets the reference to the SNMP protocol adaptor through which the MIB
will be SNMP accessible and add this new MIB in the SNMP MIB handler
associated to the specified name .
if (server == null) {
throw new ServiceNotFoundException(mibName + " is not registered in the MBean server");
}
// First remove the reference on the old adaptor server.
//
if (adaptor != null) {
adaptor.removeMib(this, contextName);
}
// Then update the reference to the new adaptor server.
//
Object[] params = {this, contextName};
String[] signature = {"com.sun.jmx.snmp.agent.SnmpMibAgent", "java.lang.String"};
try {
adaptor = (SnmpMibHandler)(server.invoke(name, "addMib", params,
signature));
} catch (InstanceNotFoundException e) {
throw new InstanceNotFoundException(name.toString());
} catch (ReflectionException e) {
throw new ServiceNotFoundException(name.toString());
} catch (MBeanException e) {
// Should never occur...
}
adaptorName = name;
|
public void | setSnmpAdaptorName(javax.management.ObjectName name, java.lang.String contextName, com.sun.jmx.snmp.SnmpOid[] oids)Sets the reference to the SNMP protocol adaptor through which the MIB
will be SNMP accessible and add this new MIB in the SNMP MIB handler
associated to the specified name .
if (server == null) {
throw new ServiceNotFoundException(mibName + " is not registered in the MBean server");
}
// First remove the reference on the old adaptor server.
//
if (adaptor != null) {
adaptor.removeMib(this, contextName);
}
// Then update the reference to the new adaptor server.
//
Object[] params = {this, contextName, oids};
String[] signature = {"com.sun.jmx.snmp.agent.SnmpMibAgent", "java.lang.String", oids.getClass().getName()};
try {
adaptor = (SnmpMibHandler)(server.invoke(name, "addMib", params,
signature));
} catch (InstanceNotFoundException e) {
throw new InstanceNotFoundException(name.toString());
} catch (ReflectionException e) {
throw new ServiceNotFoundException(name.toString());
} catch (MBeanException e) {
// Should never occur...
}
adaptorName = name;
|
private java.util.Vector | splitFrom(java.util.Vector original, int limit)This method creates a new Vector which does not contain the first
element up to the specified limit.
int max= original.size();
Vector result= new Vector(max - limit);
int i= limit;
// Ok the loop looks a bit strange. But in order to improve the
// perf, we try to avoid reference to the limit variable from
// within the loop ...
//
for(Enumeration e= original.elements(); e.hasMoreElements(); --i) {
SnmpVarBind var= (SnmpVarBind) e.nextElement();
if (i >0)
continue;
result.addElement(new SnmpVarBind(var.oid, var.value));
}
return result;
|
private static java.util.Vector | vector(java.util.Enumeration e)
if (e == null) return null;
Vector v = new Vector();
while (e.hasMoreElements()) v.addElement(e.nextElement());
return v;
|