Search in sources :

Example 6 with ZookeeperNotFoundException

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

the class GuiModel method updateDistributionRegion.

/**
 * Update the distribution region
 *
 * @throws ZookeeperException
 * @throws ZookeeperNotFoundException
 */
public void updateDistributionRegion() throws ZookeeperException, ZookeeperNotFoundException {
    logger.info("Reread distribution group: {}", distributionGroup);
    if (distributionGroup == null) {
        return;
    }
    // Show wait cursor
    SwingUtilities.invokeLater(() -> {
        if (bboxdbGui.getGlassPane() != null) {
            bboxdbGui.getGlassPane().setVisible(true);
            bboxdbGui.getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        }
    });
    // Read distribution group async
    (new Thread(() -> {
        unregisterTreeChangeListener();
        if (distributionGroup == null) {
            spacePartitioner = null;
            return;
        }
        try {
            spacePartitioner = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(distributionGroup);
            final DistributionGroupConfiguration config = DistributionGroupConfigurationCache.getInstance().getDistributionGroupConfiguration(distributionGroup);
            spacePartitioner.registerCallback(GuiModel.this);
            final StringBuilder sb = new StringBuilder();
            sb.append("Cluster name: " + getClustername());
            sb.append(", Replication factor: " + config.getReplicationFactor());
            sb.append(", Dimensions: " + config.getDimensions());
            sb.append(", Space partitioner: " + config.getSpacePartitioner());
            bboxdbGui.getStatusLabel().setText(sb.toString());
            logger.info("Read distribution group {} done", distributionGroup);
            // Reset cursor
            SwingUtilities.invokeLater(() -> {
                updateModel();
                if (bboxdbGui.getGlassPane() != null) {
                    final Cursor defaultCursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
                    bboxdbGui.getGlassPane().setCursor(defaultCursor);
                    bboxdbGui.getGlassPane().setVisible(false);
                }
            });
        } catch (Exception e) {
            logger.warn("Got exception", e);
        }
    })).start();
}
Also used : DistributionGroupConfiguration(org.bboxdb.storage.entity.DistributionGroupConfiguration) Cursor(java.awt.Cursor) ZookeeperNotFoundException(org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException) ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException)

Example 7 with ZookeeperNotFoundException

use of org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException 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 8 with ZookeeperNotFoundException

use of org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException 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 9 with ZookeeperNotFoundException

use of org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException 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 10 with ZookeeperNotFoundException

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

the class AbstractTreeSpacePartitoner method createRootNode.

@Override
public void createRootNode(final DistributionGroupConfiguration configuration) throws BBoxDBException {
    try {
        final String distributionGroup = spacePartitionerContext.getDistributionGroupName();
        final String rootPath = distributionGroupZookeeperAdapter.getDistributionGroupRootElementPath(distributionGroup);
        zookeeperClient.createDirectoryStructureRecursive(rootPath);
        final int nameprefix = distributionGroupZookeeperAdapter.getNextTableIdForDistributionGroup(distributionGroup);
        zookeeperClient.createPersistentNode(rootPath + "/" + ZookeeperNodeNames.NAME_NAMEPREFIX, Integer.toString(nameprefix).getBytes());
        zookeeperClient.createPersistentNode(rootPath + "/" + ZookeeperNodeNames.NAME_SYSTEMS, "".getBytes());
        final BoundingBox rootBox = getRootBox(configuration);
        distributionRegionZookeeperAdapter.setBoundingBoxForPath(rootPath, rootBox);
        zookeeperClient.createPersistentNode(rootPath + "/" + ZookeeperNodeNames.NAME_REGION_STATE, DistributionRegionState.ACTIVE.getStringValue().getBytes());
        SpacePartitionerHelper.allocateSystemsToRegion(rootPath, distributionGroup, new HashSet<>(), zookeeperClient);
        NodeMutationHelper.markNodeMutationAsComplete(zookeeperClient, rootPath);
    } catch (ZookeeperException | ResourceAllocationException | ZookeeperNotFoundException e) {
        throw new BBoxDBException(e);
    }
}
Also used : ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) ZookeeperNotFoundException(org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException) BoundingBox(org.bboxdb.commons.math.BoundingBox) ResourceAllocationException(org.bboxdb.distribution.placement.ResourceAllocationException) BBoxDBException(org.bboxdb.misc.BBoxDBException)

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