Search in sources :

Example 1 with InputParseException

use of org.bboxdb.commons.InputParseException in project bboxdb by jnidzwetzki.

the class DistributionGroupConfigurationCache method getDistributionGroupConfiguration.

/**
 * Get the distribution group configuration
 * @param distributionGroupName
 * @return
 * @throws ZookeeperNotFoundException
 */
public synchronized DistributionGroupConfiguration getDistributionGroupConfiguration(final String distributionGroupName) throws ZookeeperNotFoundException {
    if (!cache.containsKey(distributionGroupName)) {
        try {
            final ZookeeperClient zookeeperClient = ZookeeperClientFactory.getZookeeperClient();
            final DistributionGroupAdapter distributionGroupZookeeperAdapter = new DistributionGroupAdapter(zookeeperClient);
            final DistributionGroupConfiguration configuration = distributionGroupZookeeperAdapter.getDistributionGroupConfiguration(distributionGroupName);
            addNewConfiguration(distributionGroupName, configuration);
        } catch (InputParseException | ZookeeperException e) {
            logger.error("Exception while reading zokeeper data", e);
            return new DistributionGroupConfiguration();
        }
    }
    return cache.get(distributionGroupName);
}
Also used : ZookeeperClient(org.bboxdb.distribution.zookeeper.ZookeeperClient) DistributionGroupAdapter(org.bboxdb.distribution.zookeeper.DistributionGroupAdapter) InputParseException(org.bboxdb.commons.InputParseException) ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) DistributionGroupConfiguration(org.bboxdb.storage.entity.DistributionGroupConfiguration)

Example 2 with InputParseException

use of org.bboxdb.commons.InputParseException in project bboxdb by jnidzwetzki.

the class DistributionRegionAdapter method processStatistics.

/**
 * @param result
 * @param statisticsPath
 * @param childs
 * @throws ZookeeperException
 */
private void processStatistics(final Map<BBoxDBInstance, Map<String, Long>> result, final String statisticsPath, final List<String> childs) throws ZookeeperException {
    for (final String system : childs) {
        final String path = statisticsPath + "/" + system;
        final Map<String, Long> systemMap = new HashMap<>();
        try {
            final String sizePath = path + "/" + ZookeeperNodeNames.NAME_STATISTICS_TOTAL_SIZE;
            if (zookeeperClient.exists(sizePath)) {
                final String sizeString = zookeeperClient.readPathAndReturnString(sizePath);
                final long size = MathUtil.tryParseLong(sizeString, () -> "Unable to parse " + sizeString);
                systemMap.put(ZookeeperNodeNames.NAME_STATISTICS_TOTAL_SIZE, size);
            }
            final String tuplePath = path + "/" + ZookeeperNodeNames.NAME_STATISTICS_TOTAL_TUPLES;
            if (zookeeperClient.exists(tuplePath)) {
                final String tuplesString = zookeeperClient.readPathAndReturnString(tuplePath);
                final long tuples = MathUtil.tryParseLong(tuplesString, () -> "Unable to parse " + tuplesString);
                systemMap.put(ZookeeperNodeNames.NAME_STATISTICS_TOTAL_TUPLES, tuples);
            }
            result.put(new BBoxDBInstance(system), systemMap);
        } catch (InputParseException | ZookeeperNotFoundException e) {
            logger.error("Unable to read statistics", e);
        }
    }
}
Also used : InputParseException(org.bboxdb.commons.InputParseException) HashMap(java.util.HashMap) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance)

Aggregations

InputParseException (org.bboxdb.commons.InputParseException)2 HashMap (java.util.HashMap)1 BBoxDBInstance (org.bboxdb.distribution.membership.BBoxDBInstance)1 DistributionGroupAdapter (org.bboxdb.distribution.zookeeper.DistributionGroupAdapter)1 ZookeeperClient (org.bboxdb.distribution.zookeeper.ZookeeperClient)1 ZookeeperException (org.bboxdb.distribution.zookeeper.ZookeeperException)1 DistributionGroupConfiguration (org.bboxdb.storage.entity.DistributionGroupConfiguration)1