Calculate percentage of instances online

@param collectorItemId Collector Item Id of deploy
@return percentage of instances online
761026
private Double fetchInstancesOnlineRatio(ObjectId collectorItemId) {
    int totalInstances = 0, totalInstancesOnline = 0;
    Double instancesOnlineScore = null;

    List<EnvironmentStatus> statuses = environmentStatusRepository
      .findByCollectorItemId(collectorItemId);

    if (null == statuses || statuses.isEmpty()) {
      return null;
    }

    for (EnvironmentStatus environmentStatus : statuses) {
      totalInstances++;
      if (environmentStatus.isOnline()) {
        totalInstancesOnline++;
      }
    }
    instancesOnlineScore = ((totalInstancesOnline * 100) / (double) totalInstances);
    LOGGER.info("totalInstances " + totalInstances + " totalInstancesOnline " + totalInstancesOnline + " instancesOnlineScore " + instancesOnlineScore);

    return instancesOnlineScore;
  }
118348
@Override
    public FeatureCollector getCollector() {
        JiraMode mode = featureSettings.isJiraBoardAsTeam() ? JiraMode.Board : JiraMode.Team;
        FeatureCollector collector = FeatureCollector.prototype(mode);
        FeatureCollector existing = featureCollectorRepository.findByName(collector.getName());
        if (existing != null) {
            collector.setLastRefreshTime(existing.getLastRefreshTime());
        }
        return collector;
    }
883968
public Double getMemoryMetric(ID metricToCollect) {

        GlobalMemory mem = getMemory();

        if (PlatformMetricType.MEMORY_AVAILABLE.getMetricTypeId().equals(metricToCollect)) {
            return Double.valueOf(mem.getAvailable());
        } else if (PlatformMetricType.MEMORY_TOTAL.getMetricTypeId().equals(metricToCollect)) {
            return Double.valueOf(mem.getTotal());
        } else {
            throw new UnsupportedOperationException("Invalid memory metric to collect: " + metricToCollect);
        }
    }
15325
@Override
    public int countMissing() {
        int count = 0;
        for (int i = 0; i < size(); i++) {
            if (getPackedDateTime(i) == DateTimeColumnType.missingValueIndicator()) {
                count++;
            }
        }
        return count;
    }
242212
private function buildManualResult(CollectionItem $collectionItem, Iterator $queryIterator): ?Result
    {
        if (!$this->visibilityResolver->isVisible($collectionItem) || !$collectionItem->isValid()) {
            $queryValue = $this->getQueryValue($queryIterator);
            if (!$queryValue instanceof CmsItemInterface) {
                return null;
            }

            return new Result($collectionItem->getPosition(), $queryValue, new ManualItem($collectionItem));
        }

        return new Result($collectionItem->getPosition(), new ManualItem($collectionItem));
    }
859121
private function calculateCountriesPercentage(Collection $countries)
    {
        $total = $countries->sum('count');

        return $countries->transform(function ($item) use ($total) {
            return $item + [
                'percentage' => round(($item['count'] / $total) * 100, 2)
            ];
        });
    }
9620
private function _percentageSumCalculation($groupID,$seriesCount) {
		//	Adjust our values to a percentage value across all series in the group
		for($i = 0; $i < $seriesCount; ++$i) {
			if ($i == 0) {
				$sumValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
			} else {
				$nextValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
				foreach($nextValues as $k => $value) {
					if (isset($sumValues[$k])) {
						$sumValues[$k] += $value;
					} else {
						$sumValues[$k] = $value;
					}
				}
			}
		}

		return $sumValues;
	}
121374
@Override public int getItemCount() {
    int size = items.size();
    if (hasHeader()) {
      size++;
    }
    if (hasFooter()) {
      size++;
    }
    return size;
  }
871445
public Map<String, Integer> getOnTierPercentages() {
    return mOrderedTierAliases.stream().collect(Collectors.toMap(tier -> tier, tier -> {
      Long sizeOnTier = mSizeOnTier.getOrDefault(tier, 0L);
      return mSize > 0 ? (int) (100 * sizeOnTier / mSize) : 0;
    }));
  }
462700
public final long getTotalSize()
    {
        long result = 0;
        result = result + _storedItemManager.getStatistics().getTotalSize();
        result = result + _unstoredItemManager.getStatistics().getTotalSize();
        return result;
    }
1363455
@Override
  protected final MtasDataItemLongAdvanced getItem(int i) {
    if (i >= 0 && i < size) {
      return new MtasDataItemLongAdvanced(advancedValueSumList[i],
          advancedValueSumOfLogsList[i], advancedValueSumOfSquaresList[i],
          advancedValueMinList[i], advancedValueMaxList[i],
          advancedValueNList[i], hasSub() ? subCollectorListNextLevel[i] : null,
          getStatsItems(), sortType, sortDirection, errorNumber[i],
          errorList[i], sourceNumberList[i]);
    } else {
      return null;
    }
  }
943016
public static Map<Object, Map<Object, Double>>
			countCategoryCoincidence(final ICodingAnnotationItem item) {
		Map<Object, Map<Object, Double>> result =
				new HashMap<Object, Map<Object, Double>>();
		for (IAnnotationUnit unit1 : item.getUnits()) {
            for (IAnnotationUnit unit2 : item.getUnits()) {
				if (unit1 == unit2) {
                    continue;
                }

				Object category1 = unit1.getCategory();
				Object category2 = unit2.getCategory();
				if (category1 == null || category2 == null) {
                    continue;
                }

				Map<Object, Double> cat1 = result.get(category1);
				if (cat1 == null) {
					cat1 = new HashMap<Object, Double>();
					result.put(category1, cat1);
				}

				Double value = cat1.get(category2);
				if (value == null) {
                    cat1.put(category2, 1.0);
                }
                else {
                    cat1.put(category2, value + 1.0);
                }
			}
        }

		int raterCount = item.getRaterCount();
		for (Map<Object, Double> cat2 : result.values()) {
            for (Entry<Object, Double> entry : cat2.entrySet()) {
                cat2.put(entry.getKey(), entry.getValue() / (raterCount - 1));
            }
        }

		return result;
	}
218141
@Override
  protected MtasDataItemDoubleFull getItem(int i) {
    if (i >= 0 && i < size) {
      return new MtasDataItemDoubleFull(
          ArrayUtils.toPrimitive(fullValueList[i]),
          hasSub() ? subCollectorListNextLevel[i] : null, getStatsItems(),
          sortType, sortDirection, errorNumber[i], errorList[i],
          sourceNumberList[i]);
    } else {
      return null;
    }
  }
772162
public static <T, U> Collector<T, ?, Optional<T>> medianBy(Function<? super T, ? extends U> function, Comparator<? super U> comparator) {
        return percentileBy(0.5, function, comparator);
    }
909091
function percentBy(valueMapper) {
    var valueSetter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;

    return function (input) {
        if (input.isEmpty()) {
            return input;
        }
        var percents = input.map(valueMapper).update(percent());

        if (!valueSetter) {
            return percents;
        }
        return input.map(function (item, kk, iter) {
            var value = percents.get(kk);
            return valueSetter(item, value, kk, iter);
        });
    };
}
1295593
@Override
  public GoogleCloudStorageItemInfo getItemInfo(StorageResourceId resourceId)
      throws IOException {
    logger.atFine().log("getItemInfo(%s)", resourceId);

    // Handle ROOT case first.
    if (resourceId.isRoot()) {
      return GoogleCloudStorageItemInfo.ROOT_INFO;
    }

    GoogleCloudStorageItemInfo itemInfo = null;

    // Determine object size.
    //
    // For buckets, size is 0.
    // For objects not found, size is -1.
    // For objects that exist, size is in number of bytes.
    if (resourceId.isBucket()) {
      Bucket bucket = getBucket(resourceId.getBucketName());
      if (bucket != null) {
        itemInfo = createItemInfoForBucket(resourceId, bucket);
      }
    } else {
      StorageObject object = getObject(resourceId);
      if (object != null) {
        itemInfo = createItemInfoForStorageObject(resourceId, object);
      }
    }

    if (itemInfo == null) {
      itemInfo = GoogleCloudStorageItemInfo.createNotFound(resourceId);
    }
    logger.atFine().log("getItemInfo: %s", itemInfo);
    return itemInfo;
  }
853666
private static int getCollectionSize(int[] repetitionLevels, int maxRepetitionLevel, int nextIndex)
    {
        int size = 1;
        while (hasMoreElements(repetitionLevels, nextIndex) && !isCollectionBeginningMarker(repetitionLevels, maxRepetitionLevel, nextIndex)) {
            // Collection elements can not only be primitive, but also can have nested structure
            // Counting only elements which belong to current collection, skipping inner elements of nested collections/structs
            if (repetitionLevels[nextIndex] <= maxRepetitionLevel) {
                size++;
            }
            nextIndex++;
        }
        return size;
    }