Search in sources :

Example 36 with ZookeeperException

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;
}
Also used : ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) TupleStoreAdapter(org.bboxdb.distribution.zookeeper.TupleStoreAdapter) DoNothingDuplicateResolver(org.bboxdb.storage.sstable.duplicateresolver.DoNothingDuplicateResolver) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) Tuple(org.bboxdb.storage.entity.Tuple)

Example 37 with ZookeeperException

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();
    }
}
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

ZookeeperException (org.bboxdb.distribution.zookeeper.ZookeeperException)37 BBoxDBException (org.bboxdb.misc.BBoxDBException)24 BoundingBox (org.bboxdb.commons.math.BoundingBox)17 DistributionRegion (org.bboxdb.distribution.region.DistributionRegion)17 BBoxDBInstance (org.bboxdb.distribution.membership.BBoxDBInstance)16 ZookeeperNotFoundException (org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException)13 DistributionGroupConfiguration (org.bboxdb.storage.entity.DistributionGroupConfiguration)13 DistributionGroupAdapter (org.bboxdb.distribution.zookeeper.DistributionGroupAdapter)11 DistributionRegionIdMapper (org.bboxdb.distribution.region.DistributionRegionIdMapper)10 ZookeeperClientFactory (org.bboxdb.distribution.zookeeper.ZookeeperClientFactory)10 CopyOnWriteArraySet (java.util.concurrent.CopyOnWriteArraySet)9 DistributionRegionState (org.bboxdb.distribution.partitioner.DistributionRegionState)9 DistributionRegionCallback (org.bboxdb.distribution.region.DistributionRegionCallback)9 DistributionRegionAdapter (org.bboxdb.distribution.zookeeper.DistributionRegionAdapter)9 DistributionGroupConfigurationBuilder (org.bboxdb.storage.entity.DistributionGroupConfigurationBuilder)9 Assert (org.junit.Assert)9 Test (org.junit.Test)9 Set (java.util.Set)8 CountDownLatch (java.util.concurrent.CountDownLatch)8 SpacePartitionerContext (org.bboxdb.distribution.partitioner.SpacePartitionerContext)8