Search in sources :

Example 16 with ZookeeperNotFoundException

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();
    }
}
Also used : BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) HashMap(java.util.HashMap) Map(java.util.Map) OptionalDouble(java.util.OptionalDouble) ZookeeperNotFoundException(org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException) ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException)

Aggregations

ZookeeperNotFoundException (org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException)16 ZookeeperException (org.bboxdb.distribution.zookeeper.ZookeeperException)13 BBoxDBException (org.bboxdb.misc.BBoxDBException)8 BoundingBox (org.bboxdb.commons.math.BoundingBox)6 BBoxDBInstance (org.bboxdb.distribution.membership.BBoxDBInstance)5 DistributionGroupConfiguration (org.bboxdb.storage.entity.DistributionGroupConfiguration)5 ResourceAllocationException (org.bboxdb.distribution.placement.ResourceAllocationException)4 OptionalDouble (java.util.OptionalDouble)2 SamplingBasedSplitStrategy (org.bboxdb.distribution.partitioner.regionsplit.SamplingBasedSplitStrategy)2 SplitpointStrategy (org.bboxdb.distribution.partitioner.regionsplit.SplitpointStrategy)2 Cursor (java.awt.Cursor)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 CopyOnWriteArraySet (java.util.concurrent.CopyOnWriteArraySet)1 Predicate (java.util.function.Predicate)1 Watcher (org.apache.zookeeper.Watcher)1