本文整理汇总了Java中org.openflow.protocol.statistics.OFPortStatisticsRequest.getLength方法的典型用法代码示例。如果您正苦于以下问题:Java OFPortStatisticsRequest.getLength方法的具体用法?Java OFPortStatisticsRequest.getLength怎么用?Java OFPortStatisticsRequest.getLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openflow.protocol.statistics.OFPortStatisticsRequest
的用法示例。
在下文中一共展示了OFPortStatisticsRequest.getLength方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPortStatsForSwitch
import org.openflow.protocol.statistics.OFPortStatisticsRequest; //导入方法依赖的package包/类
private HashMap<Short, OFStatistics> getPortStatsForSwitch(IOFSwitch sw){
List <OFStatistics> values = null;
Future<List<OFStatistics>> future;
// Statistics request object for getting flows
OFStatisticsRequest req = new OFStatisticsRequest();
req.setStatisticType(OFStatisticsType.PORT);
int requestLength = req.getLengthU();
OFPortStatisticsRequest specificReq = new OFPortStatisticsRequest();
specificReq.setPortNumber(OFPort.OFPP_NONE.getValue());
req.setStatistics(Collections.singletonList((OFStatistics)specificReq));
requestLength += specificReq.getLength();
req.setLengthU(requestLength);
HashMap<Short, OFStatistics> statsReply = new HashMap<Short, OFStatistics>();
try {
future = sw.queryStatistics(req);
log.debug(future.toString());
values = future.get(10, TimeUnit.SECONDS);
log.debug(values.toString());
if(values != null){
for(OFStatistics stat : values){
OFPortStatisticsReply portStat = (OFPortStatisticsReply) stat;
log.debug("Adding Stat");
statsReply.put(portStat.getPortNumber(), stat);
}
}
} catch (Exception e) {
log.error("Failure retrieving statistics from switch " + sw, e);
}
log.debug("Stats cached for switch: " + sw.getId() + ". Total ports stats cached: " + statsReply.size());
return statsReply;
}
示例2: query
import org.openflow.protocol.statistics.OFPortStatisticsRequest; //导入方法依赖的package包/类
public ConcurrentMap<Long, List<OFStatistics>> query() {
Map<Long, Set<Link>> linkMap = linkDiscoveryService.getSwitchLinks();
for (Long switchId : linkMap.keySet()) {
// IOFSwitch sw = floodlightProvider.getSwitches().get(switchId);
IOFSwitch sw = floodlightProvider.getSwitch(switchId);
// System.out.println("sw = &&&&&&&&&&&&&&&&&&&" + switchId);
Future<List<OFStatistics>> future;
List<OFStatistics> values = null;
if (sw != null) {
OFStatisticsRequest req = new OFStatisticsRequest();
req.setStatisticType(OFStatisticsType.PORT);
OFPortStatisticsRequest specificReq = new OFPortStatisticsRequest();
specificReq.setPortNumber((short) OFPort.OFPP_NONE.getValue());
req.setStatistics(Collections
.singletonList((OFStatistics) specificReq));
int requestLength = req.getLengthU();
requestLength += specificReq.getLength();
req.setLengthU(requestLength);
try {
future = sw.queryStatistics(req);
values = future.get(10, TimeUnit.SECONDS);
// System.out
// .println("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<get port statics info="
// + values);
if (ofstaticsMap.get(switchId) != null) {
preofstaticsMap.put(switchId,
ofstaticsMap.get(switchId));
}
ofstaticsMap.put(switchId, values);
// System.out
// .println("------------->>>>>>switchid<<<<<<--------------"
// + switchId + ofstaticsMap.get(switchId));
// System.out
// .println("------------->>>>>>switchid<<<<<<--------------"
// + switchId + values);
} catch (Exception e) {
log.error(
"Failure retrieving statistics from switch " + sw,
e);
}
}
}
return ofstaticsMap;
}