use of org.bboxdb.distribution.zookeeper.ZookeeperException in project bboxdb by jnidzwetzki.
the class TupleStoreConfigurationCache method getDuplicateResolverForTupleStore.
public synchronized DuplicateResolver<Tuple> getDuplicateResolverForTupleStore(final String tupleStorename) {
if (!cache.containsKey(tupleStorename)) {
try {
final TupleStoreAdapter tupleStoreAdapter = ZookeeperClientFactory.getZookeeperClient().getTupleStoreAdapter();
final TupleStoreName tupleStoreNameObject = new TupleStoreName(tupleStorename);
if (!tupleStoreAdapter.isTableKnown(tupleStoreNameObject)) {
logger.error("Table {} is not known, using do nothing duplicate resolver", tupleStorename);
return new DoNothingDuplicateResolver();
}
final TupleStoreConfiguration tupleStoreConfiguration = tupleStoreAdapter.readTuplestoreConfiguration(tupleStoreNameObject);
final DuplicateResolver<Tuple> resolver = TupleDuplicateResolverFactory.build(tupleStoreConfiguration);
cache.put(tupleStorename, resolver);
} catch (ZookeeperException e) {
logger.error("Exception while reading zookeeper data", e);
return new DoNothingDuplicateResolver();
}
}
final DuplicateResolver<Tuple> duplicateResolver = cache.get(tupleStorename);
return duplicateResolver;
}
use of org.bboxdb.distribution.zookeeper.ZookeeperException 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