本文整理汇总了Java中net.floodlightcontroller.debugcounter.DebugCounterResource.getCounterValue方法的典型用法代码示例。如果您正苦于以下问题:Java DebugCounterResource.getCounterValue方法的具体用法?Java DebugCounterResource.getCounterValue怎么用?Java DebugCounterResource.getCounterValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.floodlightcontroller.debugcounter.DebugCounterResource
的用法示例。
在下文中一共展示了DebugCounterResource.getCounterValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPktInRate
import net.floodlightcontroller.debugcounter.DebugCounterResource; //导入方法依赖的package包/类
protected int getPktInRate(DebugCounterResource newCnt, Date currentTime) {
if (newCnt == null ||
newCnt.getCounterLastModified() == null ||
newCnt.getCounterValue() == null) {
return 0;
}
// Somehow the system time is messed up. return max packetIn rate
// to reduce the system load.
if (newCnt.getCounterLastModified() < lastPacketInCounter.getLastModified()) {
logger.debug("Time is going backward. new {}, old {}",
newCnt.getCounterLastModified(),
lastPacketInCounter.getLastModified());
return MAX_SYSTEM_LOAD_PER_SECOND;
}
long elapsedTimeInSecond = (currentTime.getTime() - lastPacketInCounter.getLastModified()) / 1000;
if (elapsedTimeInSecond == 0) {
// This should never happen. Check to avoid division by zero.
return 0;
}
long diff = 0;
long newValue = newCnt.getCounterValue().longValue();
long oldValue = lastPacketInCounter.getCounterValue();
if (newValue < oldValue) {
// Roll over event
diff = Long.MAX_VALUE - oldValue + newValue;
} else {
diff = newValue - oldValue;
}
return (int)(diff/elapsedTimeInSecond);
}