本文整理汇总了Java中org.snmp4j.PDU.size方法的典型用法代码示例。如果您正苦于以下问题:Java PDU.size方法的具体用法?Java PDU.size怎么用?Java PDU.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.snmp4j.PDU
的用法示例。
在下文中一共展示了PDU.size方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processResponse
import org.snmp4j.PDU; //导入方法依赖的package包/类
private void processResponse(PDU response) {
try {
if (log().isDebugEnabled()) {
log().debug("Received a tracker PDU of type "+PDU.getTypeString(response.getType())+" from "+getAddress()+" of size "+response.size()+", errorStatus = "+response.getErrorStatus()+", errorStatusText = "+response.getErrorStatusText()+", errorIndex = "+response.getErrorIndex());
}
if (response.getType() == PDU.REPORT) {
handleAuthError("A REPORT PDU was returned from the agent. This is most likely an authentication problem. Please check the config");
} else {
if (!processErrors(response.getErrorStatus(), response.getErrorIndex())) {
if (response.size() == 0) { // NMS-6484
handleError("A PDU with no errors and 0 varbinds was returned from the agent at " + getAddress() + ". This seems to be related with a broken SNMP agent.");
} else {
for (int i = 0; i < response.size(); i++) {
VariableBinding vb = response.get(i);
SnmpObjId receivedOid = SnmpObjId.get(vb.getOid().getValue());
SnmpValue val = new Snmp4JValue(vb.getVariable());
Snmp4JWalker.this.processResponse(receivedOid, val);
}
}
}
buildAndSendNextPdu();
}
} catch (Throwable e) {
handleFatalError(e);
}
}
示例2: validateResponse
import org.snmp4j.PDU; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void validateResponse(ResponseEvent event) {
super.validateResponse(event);
PDU response = event.getResponse();
final int responseSize = response.size();
if (responseSize <= nonRepeaters) {
throw new TruncatedResponseException(
"response contains no repeaters; too many non-repeaters?");
}
if (nonRepeaters + repeaters >= responseSize) {
if (context.getConfig().isWalkAllowsTruncatedRepetition()) {
this.repeaters = responseSize - nonRepeaters;
}
else {
throw new TruncatedResponseException(
"response contains partial first repetition; "
+ "set walkAllowsTruncatedRepetition if you wish to allow it");
}
}
}
示例3: newVarbindCollection
import org.snmp4j.PDU; //导入方法依赖的package包/类
@Override
public VarbindCollection newVarbindCollection(PDU pdu) {
MutableVarbindCollection results = new MutableVarbindCollection();
Varbind[] indexes = new Varbind[0];
for (int i = 0; i < pdu.size(); i++) {
Varbind varbind = newVarbind(pdu.get(i));
results.add(i, objectNameToKey(varbind), varbind);
if (indexes.length == 0) {
indexes = varbind.getIndexes();
}
}
for (Varbind index : indexes) {
results.addIndex(objectNameToKey(index), index);
}
return results.immutableCopy();
}
示例4: extractSingleString
import org.snmp4j.PDU; //导入方法依赖的package包/类
public static String extractSingleString(ResponseEvent event) {
final PDU response = event.getResponse();
if (response != null && response.size() > 0) {
return response.get(0).getVariable().toString();
}
return "";
}
示例5: extractSingleInt
import org.snmp4j.PDU; //导入方法依赖的package包/类
public static int extractSingleInt(ResponseEvent event) {
final PDU response = event.getResponse();
if (response != null && response.size() > 0) {
return response.get(0).getVariable().toInt();
}
return -1;
}
示例6: createResult
import org.snmp4j.PDU; //导入方法依赖的package包/类
@Override
protected List<VarbindCollection> createResult(PDU response) {
final int repeaters = varbinds.length - nonRepeaters;
List<VarbindCollection> rows = new ArrayList<VarbindCollection>(maxRepetitions);
int offset = nonRepeaters;
while (offset < response.size()) {
rows.add(createRow(response, offset, repeaters));
offset += repeaters;
}
return rows;
}