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


Java ICounter.getCounterDate方法代码示例

本文整理汇总了Java中net.floodlightcontroller.counter.ICounter.getCounterDate方法的典型用法代码示例。如果您正苦于以下问题:Java ICounter.getCounterDate方法的具体用法?Java ICounter.getCounterDate怎么用?Java ICounter.getCounterDate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.floodlightcontroller.counter.ICounter的用法示例。


在下文中一共展示了ICounter.getCounterDate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPktInRate

import net.floodlightcontroller.counter.ICounter; //导入方法依赖的package包/类
protected int getPktInRate(ICounter newCnt, Date currentTime) {
    if (newCnt == null ||
        newCnt.getCounterDate() == null ||
        newCnt.getCounterValue() == null) {
        return 0;
    }

    // Somehow the system time is messed up. return max packetIn rate
    // to reduce the system load.
    if (newCnt.getCounterDate().before(
            lastPacketInCounter.getCounterDate())) {
        logger.debug("Time is going backward. new {}, old {}",
                newCnt.getCounterDate(),
                lastPacketInCounter.getCounterDate());
        return MAX_SYSTEM_LOAD_PER_SECOND;
    }

    long elapsedTimeInSecond = (currentTime.getTime() -
                lastPacketInCounter.getCounterDate().getTime()) / 1000;
    if (elapsedTimeInSecond == 0) {
        // This should never happen. Check to avoid division by zero.
        return 0;
    }

    long diff = 0;
    switch (newCnt.getCounterValue().getType()) {
        case LONG:
            long newLong = newCnt.getCounterValue().getLong();
            long oldLong = lastPacketInCounter.getCounterValue().getLong();
            if (newLong < oldLong) {
                // Roll over event
                diff = Long.MAX_VALUE - oldLong + newLong;
            } else {
                diff = newLong - oldLong;
            }
            break;

        case DOUBLE:
            double newDouble = newCnt.getCounterValue().getDouble();
            double oldDouble = lastPacketInCounter.getCounterValue().getDouble();
            if (newDouble < oldDouble) {
                // Roll over event
                diff = (long)(Double.MAX_VALUE - oldDouble + newDouble);
            } else {
                diff = (long)(newDouble - oldDouble);
            }
            break;
    }

    return (int)(diff/elapsedTimeInSecond);
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:52,代码来源:FlowReconcileManager.java


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