当前位置: 首页>>代码示例>>Java>>正文


Java PDU.size方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:27,代码来源:Snmp4JWalker.java

示例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");
    }
  }
}
 
开发者ID:soulwing,项目名称:tnm4j,代码行数:26,代码来源:AbstractAsyncWalker.java

示例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();
}
 
开发者ID:soulwing,项目名称:tnm4j,代码行数:17,代码来源:SimpleVarbindFactory.java

示例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 "";
}
 
开发者ID:globocom,项目名称:groot,代码行数:8,代码来源:SimpleSnmpClient.java

示例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;
}
 
开发者ID:globocom,项目名称:groot,代码行数:8,代码来源:SimpleSnmpClient.java

示例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;
}
 
开发者ID:soulwing,项目名称:tnm4j,代码行数:12,代码来源:GetBulkOperation.java


注:本文中的org.snmp4j.PDU.size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。