use of org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException in project bboxdb by jnidzwetzki.
the class StatisticsHelper method getAndUpdateStatistics.
/**
* Get the max total size from the statistics map
* @param statistics
* @return
* @throws ZookeeperNotFoundException
* @throws ZookeeperException
*/
public static OptionalDouble getAndUpdateStatistics(final DistributionRegion region) {
try {
final Map<BBoxDBInstance, Map<String, Long>> statistics = distributionGroupZookeeperAdapter.getRegionStatistics(region);
final OptionalDouble regionSize = statistics.values().stream().mapToDouble(p -> p.get(ZookeeperNodeNames.NAME_STATISTICS_TOTAL_SIZE)).filter(Objects::nonNull).max();
if (regionSize.isPresent()) {
final String regionIdentifier = region.getIdentifier();
updateStatisticsHistory(regionIdentifier, regionSize.getAsDouble());
}
return regionSize;
} catch (Exception e) {
logger.error("Got an exception while reading statistics", e);
return OptionalDouble.empty();
}
}
Aggregations