Search in sources :

Example 26 with ZookeeperException

use of org.bboxdb.distribution.zookeeper.ZookeeperException in project bboxdb by jnidzwetzki.

the class InsertTupleHandler method createMissingTables.

/**
 * Create all missing tables
 */
protected void createMissingTables(final TupleStoreName requestTable, final TupleStoreManagerRegistry storageRegistry, final Collection<TupleStoreName> localTables) throws StorageManagerException {
    try {
        final TupleStoreAdapter tupleStoreAdapter = ZookeeperClientFactory.getZookeeperClient().getTupleStoreAdapter();
        if (!tupleStoreAdapter.isTableKnown(requestTable)) {
            throw new StorageManagerException("Table: " + requestTable.getFullname() + " is unkown");
        }
        final TupleStoreConfiguration config = tupleStoreAdapter.readTuplestoreConfiguration(requestTable);
        for (final TupleStoreName tupleStoreName : localTables) {
            final boolean alreadyKnown = storageRegistry.isStorageManagerKnown(tupleStoreName);
            if (!alreadyKnown) {
                storageRegistry.createTableIfNotExist(tupleStoreName, config);
            }
        }
    } catch (ZookeeperException e) {
        throw new StorageManagerException(e);
    }
}
Also used : ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) TupleStoreAdapter(org.bboxdb.distribution.zookeeper.TupleStoreAdapter) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) StorageManagerException(org.bboxdb.storage.StorageManagerException)

Example 27 with ZookeeperException

use of org.bboxdb.distribution.zookeeper.ZookeeperException in project bboxdb by jnidzwetzki.

the class DistributedRecoveryService method checkGroupVersion.

/**
 * Check the group version
 * @param storage
 * @param distributionGroupName
 * @param zookeeperClient
 */
protected void checkGroupVersion(final DiskStorage storage, final String distributionGroupName, final ZookeeperClient zookeeperClient) {
    try {
        final DistributionGroupMetadata metaData = DistributionGroupMetadataHelper.getMedatadaForGroup(storage.getBasedir().getAbsolutePath(), distributionGroupName);
        if (metaData == null) {
            logger.debug("Metadata for storage {} and group {} is null, skipping check", storage.getBasedir(), distributionGroupName);
            return;
        }
        final DistributionGroupAdapter distributionGroupZookeeperAdapter = new DistributionGroupAdapter(zookeeperClient);
        final String path = distributionGroupZookeeperAdapter.getDistributionGroupPath(distributionGroupName);
        final long remoteVersion = NodeMutationHelper.getNodeMutationVersion(zookeeperClient, path, null);
        final long localVersion = metaData.getVersion();
        if (remoteVersion != localVersion) {
            logger.error("Local version {} of dgroup {} does not match remtote version {}", localVersion, distributionGroupName, remoteVersion);
            System.exit(-1);
        }
    } catch (ZookeeperException | ZookeeperNotFoundException e) {
        logger.error("Got an exception while checking group version");
    }
}
Also used : DistributionGroupAdapter(org.bboxdb.distribution.zookeeper.DistributionGroupAdapter) ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) ZookeeperNotFoundException(org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException) DistributionGroupMetadata(org.bboxdb.storage.entity.DistributionGroupMetadata)

Example 28 with ZookeeperException

use of org.bboxdb.distribution.zookeeper.ZookeeperException in project bboxdb by jnidzwetzki.

the class RegionMergeHelper method isRegionUnderflow.

/**
 * Needs the region a merge?
 * @param region
 * @return
 * @throws BBoxDBException
 */
public static boolean isRegionUnderflow(final List<DistributionRegion> sources) throws BBoxDBException {
    assert (!sources.isEmpty()) : "Sources can not be empty";
    final List<String> sourceIds = getRegionIdsFromRegionList(sources);
    logger.info("Testing for underflow: {}", sourceIds);
    final boolean inactiveChilds = sources.stream().anyMatch(c -> c.getState() != DistributionRegionState.ACTIVE);
    if (inactiveChilds) {
        logger.info("Not all children ready, skip merge test for {}", sourceIds);
        return false;
    }
    // We are not responsible to this region
    final BBoxDBInstance localInstanceName = ZookeeperClientFactory.getLocalInstanceName();
    final boolean localSystemContained = sources.stream().anyMatch(r -> r.getSystems().contains(localInstanceName));
    if (!localSystemContained) {
        logger.info("Not testing for underflow for {} on {}", sourceIds, localInstanceName);
        return false;
    }
    final OptionalDouble childRegionSize = getTotalRegionSize(sources);
    if (!childRegionSize.isPresent()) {
        logger.info("Got invalid statistics for {}", sourceIds);
        return false;
    }
    try {
        final String fullname = sources.get(0).getDistributionGroupName();
        final long minSize = getConfiguredRegionMinSizeInMB(fullname);
        final double childDoubleSize = childRegionSize.getAsDouble();
        logger.info("Testing for region {} underflow curent size is {} / min is {}", sourceIds, childDoubleSize, minSize);
        return (childDoubleSize < minSize);
    } catch (ZookeeperException | ZookeeperNotFoundException e) {
        throw new BBoxDBException(e);
    }
}
Also used : ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) ZookeeperNotFoundException(org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) BBoxDBException(org.bboxdb.misc.BBoxDBException) OptionalDouble(java.util.OptionalDouble)

Example 29 with ZookeeperException

use of org.bboxdb.distribution.zookeeper.ZookeeperException in project bboxdb by jnidzwetzki.

the class DistributionRegionSyncer method getRootNode.

/**
 * Get the root node
 * @return
 */
public DistributionRegion getRootNode() {
    // Reload root node
    if (rootNode == null) {
        final String groupNameString = distributionGroupName.toString();
        final String path = distributionGroupAdapter.getDistributionGroupRootElementPath(groupNameString);
        try {
            if (NodeMutationHelper.isNodeCompletelyCreated(zookeeperClient, path)) {
                logger.info("Create new root element for {}", distributionGroupName);
                final BoundingBox rootBoundingBox = distributionRegionAdapter.getBoundingBoxForPath(path);
                rootNode = new DistributionRegion(distributionGroupName, rootBoundingBox);
                updateNodeIfNeeded(path, rootNode);
            } else {
                logger.info("Root node does not exist");
            }
        } catch (ZookeeperException | ZookeeperNotFoundException e) {
            logger.debug("Got exception while reading root node", e);
        }
    }
    return rootNode;
}
Also used : ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) ZookeeperNotFoundException(org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException) BoundingBox(org.bboxdb.commons.math.BoundingBox)

Example 30 with ZookeeperException

use of org.bboxdb.distribution.zookeeper.ZookeeperException in project bboxdb by jnidzwetzki.

the class StatisticsUpdateRunnable method updateNodeStats.

/**
 * Update the local node stats (diskspace, memory)
 * @throws ZookeeperException
 */
private void updateNodeStats() {
    try {
        final BBoxDBInstance instance = ZookeeperClientFactory.getLocalInstanceName();
        logger.debug("Update zookeeper node stats");
        final ZookeeperClient zookeeperClient = ZookeeperClientFactory.getZookeeperClient();
        final ZookeeperBBoxDBInstanceAdapter zookeeperBBoxDBInstanceAdapter = new ZookeeperBBoxDBInstanceAdapter(zookeeperClient);
        zookeeperBBoxDBInstanceAdapter.updateNodeInfo(instance);
    } catch (ZookeeperException e) {
        logger.error("Got exception while updating local node stats", e);
    }
}
Also used : ZookeeperClient(org.bboxdb.distribution.zookeeper.ZookeeperClient) ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) ZookeeperBBoxDBInstanceAdapter(org.bboxdb.distribution.membership.ZookeeperBBoxDBInstanceAdapter)

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