本文整理汇总了Java中net.floodlightcontroller.statistics.SwitchPortBandwidth类的典型用法代码示例。如果您正苦于以下问题:Java SwitchPortBandwidth类的具体用法?Java SwitchPortBandwidth怎么用?Java SwitchPortBandwidth使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SwitchPortBandwidth类属于net.floodlightcontroller.statistics包,在下文中一共展示了SwitchPortBandwidth类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serialize
import net.floodlightcontroller.statistics.SwitchPortBandwidth; //导入依赖的package包/类
@Override
public void serialize(SwitchPortBandwidth spb, JsonGenerator jGen, SerializerProvider serializer) throws IOException, JsonProcessingException {
jGen.configure(Feature.WRITE_NUMBERS_AS_STRINGS, true);
jGen.writeStartObject();
jGen.writeStringField("dpid", spb.getSwitchId().toString());
jGen.writeStringField("port", spb.getSwitchPort().toString());
jGen.writeStringField("updated", new Date(spb.getUpdateTime()).toString());
jGen.writeStringField("bits-per-second-rx", spb.getBitsPerSecondRx().getBigInteger().toString());
jGen.writeStringField("bits-per-second-tx", spb.getBitsPerSecondTx().getBigInteger().toString());
jGen.writeEndObject();
}
示例2: updateCurrentBandwidthUtilization
import net.floodlightcontroller.statistics.SwitchPortBandwidth; //导入依赖的package包/类
private void updateCurrentBandwidthUtilization() {
long capacity, util;
SwitchPortBandwidth switchPortBandwidth = null;
NodePortTuple keyNPT = null;
Set<Link> linkPair = null;
switchPortBwMap = mcObject.statisticsService.getBandwidthConsumption();
nodePortLinkMap = linkDiscService.getPortLinks();
mcObject.statisticsService.collectStatistics(true);
// logger.info("--------------");
// logger.info("switchPortBwMap : " + switchPortBwMap.toString());
// logger.info("--------------");
//
// logger.info("--------------");
// logger.info("NodePortLinkMap : " + nodePortLinkMap.toString());
// logger.info("--------------");
//
// logger.info("--------------");
// logger.info("switchPortBwMap size : " + switchPortBwMap.size());
// logger.info("NodePortLinkMap size : " + nodePortLinkMap.size());
// logger.info("--------------");
// for (NodePortTuple x : nodePortLinkMap.keySet()) {
// logger.info(x.toString());
// }
// logger.info("------updateCurrentBandwidthUtilization-------");
for (Entry<NodePortTuple, SwitchPortBandwidth> spb: switchPortBwMap.entrySet()) {
keyNPT = spb.getKey();
// logger.info("--------------");
// logger.info("keyNPT : " + keyNPT.toString());
// logger.info("--------------");
switchPortBandwidth = spb.getValue();
linkPair = nodePortLinkMap.get(keyNPT);
if (linkPair == null) continue;
// logger.info("--------------");
// logger.info("linkPair size : " + linkPair.size());
// logger.info("--------------");
for (Link l : linkPair) {
if (l.getSrc().getLong() == switchPortBandwidth.getSwitchId().getLong()) {
capacity = topologyHelper.getLinkCapacity(l.getSrc().getLong(), l.getDst().getLong());
/*converting bits/s into kb/s*/
util = switchPortBandwidth.getBitsPerSecondTx().getValue()/1024;
if (util < 0) {
logger.error("Negative bandwidth for link: " + l.toKeyString() + " " + Long.toString(util));
}
linkBandwidth.put(l, new LinkParameter(capacity, util));
// logger.info("Link=" + l.toKeyString() + ",LinkParameter=" +linkBandwidth.toString());
}
// if (l.getDst().getLong() == switchPortBandwidth.getSwitchId().getLong()) {
// capacity = topologyHelper.getLinkCapacity(l.getSrc().getLong(), l.getDst().getLong());
// /*converting bits/s into kb/s*/
// util = switchPortBandwidth.getBitsPerSecondRx().getValue()/1000;
//// linkBandwidth.put(l, new LinkParameter(capacity, util));
// logger.info("Link=" + l.toKeyString() + ",LinkParameter=" +linkBandwidth.toString());
// }
}
}
// logger.info("----------------------------------------------");
}