本文整理汇总了Java中org.snmp4j.smi.Variable.isException方法的典型用法代码示例。如果您正苦于以下问题:Java Variable.isException方法的具体用法?Java Variable.isException怎么用?Java Variable.isException使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.snmp4j.smi.Variable
的用法示例。
在下文中一共展示了Variable.isException方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAvailability
import org.snmp4j.smi.Variable; //导入方法依赖的package包/类
/**
* Returns UP if able to obtain one of the defined measurement mib.
*/
@Override
public AvailabilityType getAvailability() {
Set<MeasurementDefinition> mds = this.definitions;
if (!mds.isEmpty()) {
MeasurementDefinition md = mds.iterator().next();
OID oid = index.getNameRecord(md.getName()).getOid0();
try {
Variable variable = snmp.get(oid);
if (variable.isException())
return DOWN;
} catch (IOException e) {
return DOWN;
}
}
return UP;
}
示例2: getAvailability
import org.snmp4j.smi.Variable; //导入方法依赖的package包/类
/**
* Returns DOWN if the table row no longer exists or can be read.
*/
@Override
public AvailabilityType getAvailability() {
Set<MeasurementDefinition> mds = this.definitions;
if (!mds.isEmpty()) {
MeasurementDefinition md = mds.iterator().next();
OID oid = oid(md.getName());
try {
Variable variable = snmp.get(oid);
if (variable.isException())
return DOWN;
} catch (IOException e) {
return DOWN;
}
}
return UP;
}
示例3: getVariable
import org.snmp4j.smi.Variable; //导入方法依赖的package包/类
private Variable getVariable() throws SnmpException {
Variable variable = delegate.getVariable();
if (variable.isException()) {
throw new SnmpException(String.format("%s %s: %s",
getName(), getOid(), variable.toString()));
}
return variable;
}
示例4: discoverResources
import org.snmp4j.smi.Variable; //导入方法依赖的package包/类
@Override
public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<SnmpComponentHolder> rdc) throws Exception {
Set<DiscoveredResourceDetails> drd = new HashSet<DiscoveredResourceDetails>();
String rtName = rdc.getResourceType().getName();
log.debug("discover " + rtName);
Set<MeasurementDefinition> mds = rdc.getResourceType().getMetricDefinitions();
List<OID> oids = new ArrayList<OID>();
Configuration conf = rdc.getDefaultPluginConfiguration();
MibIndex digest = MibComponent.index(conf);
for (MeasurementDefinition md : mds) {
OID oid = digest.getNameRecord(md.getName()).getOid0();
oids.add(oid);
}
SnmpComponent snmp = rdc.getParentResourceComponent().getSnmpComponent();
if (oids.size() > 3) {
// don't discover entire OID list
oids = oids.subList(0, 3);
}
Map<OID, Variable> map = snmp.get(oids);
if (map.isEmpty()) {
log.debug("could not discover " + rtName + "; map empty");
return drd;
}
for (Variable v : map.values()) {
if (v.isException()) {
log.debug("could not discover " + rtName + "; variable was " + v);
return drd;
}
}
String version = null;
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
rdc.getResourceType(), // ResourceType
rtName, // won't run multiple instances (probably)
rtName, // resource name
version, // Version
rtName, // unique name
conf,
null // process information
);
drd.add(detail);
return drd;
}
示例5: checkForExceptions
import org.snmp4j.smi.Variable; //导入方法依赖的package包/类
/**
* Check a variable for a syntax exception (noSuchInstance, noSuchObject,
* endOfMibView).
*
* @param variable
* variable to be checked
* @throws SnmpSyntaxException
* if the syntax of this variable equals one of the following:
* <ul>
* <li>noSuchInstance</li>
* <li>noSuchObject</li>
* <li>endOfMibView</li> </li>
*/
public static void checkForExceptions(Variable variable)
throws SnmpSyntaxException {
if (variable.isException())
throw new SnmpSyntaxException(variable);
}