org.apache.storm.utils.Utils.zeroIfNaNOrInf()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(3.8k)|赞(0)|评价(0)|浏览(135)

本文整理了Java中org.apache.storm.utils.Utils.zeroIfNaNOrInf()方法的一些代码示例,展示了Utils.zeroIfNaNOrInf()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.zeroIfNaNOrInf()方法的具体详情如下:
包路径:org.apache.storm.utils.Utils
类名称:Utils
方法名:zeroIfNaNOrInf

Utils.zeroIfNaNOrInf介绍

暂无

代码示例

代码示例来源:origin: apache/storm

double readApproximateLatAvg(long lat, long count, long timeSpent, long[] bucketTime,
               long[] latBuckets, long[] countBuckets, long desiredTime) {
  long timeNeeded = desiredTime - timeSpent;
  long totalLat = lat;
  long totalCount = count;
  for (int i = 0; i < bucketTime.length && timeNeeded > 0; i++) {
    //Don't pro-rate anything, it is all approximate so an extra bucket is not that bad.
    totalLat += latBuckets[i];
    totalCount += countBuckets[i];
    timeNeeded -= bucketTime[i];
  }
  return Utils.zeroIfNaNOrInf(((double) totalLat) / totalCount);
}

代码示例来源:origin: apache/storm

synchronized Object getValueAndReset(long now) {
  long lat;
  long count;
  synchronized (_currentLock) {
    lat = _currentLatBucket;
    count = _currentCountBucket;
    _currentLatBucket = 0;
    _currentCountBucket = 0;
  }
  long timeSpent = now - _bucketStart;
  long exactExtraCountSum = count + _exactExtraCount;
  double ret = Utils.zeroIfNaNOrInf(
    ((double) (lat + _exactExtraLat)) / exactExtraCountSum);
  _bucketStart = now;
  _exactExtraLat = 0;
  _exactExtraCount = 0;
  rotateBuckets(lat, count, timeSpent);
  return ret;
}

代码示例来源:origin: apache/storm

synchronized Map<String, Double> getTimeLatAvg(long now) {
  Map<String, Double> ret = new HashMap<>();
  long lat;
  long count;
  synchronized (_currentLock) {
    lat = _currentLatBucket;
    count = _currentCountBucket;
  }
  long timeSpent = now - _bucketStart;
  ret.put("600", readApproximateLatAvg(lat, count, timeSpent, _tmTime, _tmLatBuckets, _tmCountBuckets, 600 * 1000));
  ret.put("10800", readApproximateLatAvg(lat, count, timeSpent, _thTime, _thLatBuckets, _thCountBuckets, 10800 * 1000));
  ret.put("86400", readApproximateLatAvg(lat, count, timeSpent, _odTime, _odLatBuckets, _odCountBuckets, 86400 * 1000));
  long allTimeCountSum = count + _allTimeCount;
  ret.put(":all-time", Utils.zeroIfNaNOrInf(
    (double) lat + _allTimeLat) / allTimeCountSum);
  return ret;
}

代码示例来源:origin: org.apache.storm/storm-core

double readApproximateLatAvg(long lat, long count, long timeSpent, long[] bucketTime,
     long[] latBuckets, long[] countBuckets, long desiredTime) {
  long timeNeeded = desiredTime - timeSpent;
  long totalLat = lat;
  long totalCount = count;
  for (int i = 0; i < bucketTime.length && timeNeeded > 0; i++) {
    //Don't pro-rate anything, it is all approximate so an extra bucket is not that bad.
    totalLat += latBuckets[i];
    totalCount += countBuckets[i];
    timeNeeded -= bucketTime[i];
  }
  return Utils.zeroIfNaNOrInf(((double) totalLat) / totalCount);
}

代码示例来源:origin: org.apache.storm/storm-core

synchronized Object getValueAndReset(long now) {
  long lat;
  long count;
  synchronized(_currentLock) {
    lat = _currentLatBucket;
    count = _currentCountBucket;
    _currentLatBucket = 0;
    _currentCountBucket = 0;
  }
  long timeSpent = now - _bucketStart;
  long exactExtraCountSum = count + _exactExtraCount;
  double ret = Utils.zeroIfNaNOrInf(
      ((double) (lat + _exactExtraLat)) / exactExtraCountSum);
  _bucketStart = now;
  _exactExtraLat = 0;
  _exactExtraCount = 0;
  rotateBuckets(lat, count, timeSpent);
  return ret;
}

代码示例来源:origin: org.apache.storm/storm-core

synchronized Map<String, Double> getTimeLatAvg(long now) {
  Map<String, Double> ret = new HashMap<>();
  long lat;
  long count;
  synchronized(_currentLock) {
    lat = _currentLatBucket;
    count = _currentCountBucket;
  }
  long timeSpent = now - _bucketStart;
  ret.put("600", readApproximateLatAvg(lat, count, timeSpent, _tmTime, _tmLatBuckets, _tmCountBuckets, 600 * 1000));
  ret.put("10800", readApproximateLatAvg(lat, count, timeSpent, _thTime, _thLatBuckets, _thCountBuckets, 10800 * 1000));
  ret.put("86400", readApproximateLatAvg(lat, count, timeSpent, _odTime, _odLatBuckets, _odCountBuckets, 86400 * 1000));
  long allTimeCountSum = count + _allTimeCount;
  ret.put(":all-time", Utils.zeroIfNaNOrInf(
      (double) lat + _allTimeLat)/allTimeCountSum);
  return ret;
}

相关文章

Utils类方法