Search in sources :

Example 31 with BBoxDBException

use of org.bboxdb.misc.BBoxDBException in project bboxdb by jnidzwetzki.

the class TreeJPanel method paintComponent.

@Override
protected void paintComponent(final Graphics g) {
    super.paintComponent(g);
    setBackground(Color.WHITE);
    // Group is not set
    if (guiModel.getTreeAdapter() == null) {
        return;
    }
    final Graphics2D graphics2D = (Graphics2D) g;
    graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    graphics2D.scale(zoomFactor, zoomFactor);
    try {
        final DistributionRegion distributionRegion = guiModel.getTreeAdapter().getRootNode();
        regions.clear();
        if (distributionRegion == null) {
            logger.error("Got null root node");
            return;
        }
        final int maxChildren = distributionRegion.getThisAndChildRegions().stream().mapToInt(r -> r.getDirectChildren().size()).max().orElse(0);
        // Fake position to calculate the real width
        rootPosX = 100000;
        createDistribtionRegionComponents(distributionRegion, maxChildren);
        calculateRootNodeXPos();
        final BoundingBox drawBox = drawDistributionRegion(graphics2D);
        updateComponentSize(drawBox);
    } catch (BBoxDBException e) {
        logger.error("Got an exception", e);
    }
}
Also used : DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) BoundingBox(org.bboxdb.commons.math.BoundingBox) BBoxDBException(org.bboxdb.misc.BBoxDBException) Graphics2D(java.awt.Graphics2D)

Example 32 with BBoxDBException

use of org.bboxdb.misc.BBoxDBException in project bboxdb by jnidzwetzki.

the class SSTableServiceRunnable method processTupleStores.

/**
 * Process the tuple stores
 *
 * @param storageRegistry
 * @param tupleStores
 * @throws InterruptedException
 */
private void processTupleStores(final TupleStoreManagerRegistry storageRegistry, final List<TupleStoreName> tupleStores) throws InterruptedException {
    for (final TupleStoreName tupleStoreName : tupleStores) {
        try {
            logger.debug("Running compact for: {}", tupleStoreName);
            final TupleStoreManager tupleStoreManager = storageRegistry.getTupleStoreManager(tupleStoreName);
            if (tupleStoreManager.getSstableManagerState() == TupleStoreManagerState.READ_ONLY) {
                logger.debug("Skipping compact for read only sstable manager: {}", tupleStoreName);
                continue;
            }
            if (!CompactorHelper.isRegionActive(tupleStoreName)) {
                logger.info("Skipping compact run, because region is not active {}", tupleStoreName);
                continue;
            }
            final List<SSTableFacade> facades = getAllTupleStores(tupleStoreManager);
            final MergeTask mergeTask = mergeStrategy.getMergeTask(facades);
            executeCompactTask(mergeTask, tupleStoreManager);
            testForRegionOverflow(tupleStoreManager);
        } catch (StorageManagerException | BBoxDBException e) {
            logger.error("Error while merging tables", e);
        }
    }
}
Also used : SSTableFacade(org.bboxdb.storage.sstable.reader.SSTableFacade) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) StorageManagerException(org.bboxdb.storage.StorageManagerException) BBoxDBException(org.bboxdb.misc.BBoxDBException) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager)

Example 33 with BBoxDBException

use of org.bboxdb.misc.BBoxDBException in project bboxdb by jnidzwetzki.

the class SSTableServiceRunnable method testForRegionOverflow.

/**
 * Does the region needs to be split?
 * @param sstableManager
 * @throws BBoxDBException
 * @throws InterruptedException
 */
private void testForRegionOverflow(final TupleStoreManager sstableManager) throws BBoxDBException, InterruptedException {
    // Don't try to split non-distributed tables
    if (!sstableManager.getTupleStoreName().isDistributedTable()) {
        return;
    }
    try {
        final TupleStoreName ssTableName = sstableManager.getTupleStoreName();
        final long regionId = ssTableName.getRegionId().getAsLong();
        final SpacePartitioner spacePartitioner = getSpacePartitioner(ssTableName);
        final DistributionRegion distributionRegion = spacePartitioner.getRootNode();
        final DistributionRegion regionToSplit = DistributionRegionHelper.getDistributionRegionForNamePrefix(distributionRegion, regionId);
        // Region does not exist
        if (regionToSplit == null) {
            return;
        }
        if (!RegionSplitHelper.isSplittingSupported(regionToSplit)) {
            return;
        }
        if (!RegionSplitHelper.isRegionOverflow(regionToSplit)) {
            return;
        }
        executeSplit(sstableManager, spacePartitioner, regionToSplit);
    } catch (Exception e) {
        throw new BBoxDBException(e);
    }
}
Also used : DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) BBoxDBException(org.bboxdb.misc.BBoxDBException) RejectedException(org.bboxdb.commons.RejectedException) ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) StorageManagerException(org.bboxdb.storage.StorageManagerException) BBoxDBException(org.bboxdb.misc.BBoxDBException) SpacePartitioner(org.bboxdb.distribution.partitioner.SpacePartitioner)

Example 34 with BBoxDBException

use of org.bboxdb.misc.BBoxDBException in project bboxdb by jnidzwetzki.

the class SSTableServiceRunnable method registerNewFacadeAndDeleteOldInstances.

/**
 * Register a new sstable facade and delete the old ones
 * @param oldFacades
 * @param directory
 * @param name
 * @param tablenumber
 * @throws StorageManagerException
 */
private void registerNewFacadeAndDeleteOldInstances(final TupleStoreManager sstableManager, final List<SSTableFacade> oldFacades, final List<SSTableWriter> newTableWriter) throws StorageManagerException {
    final List<SSTableFacade> newFacades = new ArrayList<>();
    // Open new facades
    openFacades(newTableWriter, newFacades);
    // Manager has switched to read only
    if (sstableManager.getSstableManagerState() == TupleStoreManagerState.READ_ONLY) {
        logger.info("Manager is in read only mode, cancel compact run");
        handleCompactException(newFacades);
        return;
    }
    try {
        for (final SSTableFacade facade : newFacades) {
            facade.init();
        }
        // Switch facades in registry
        sstableManager.replaceCompactedSStables(newFacades, oldFacades);
        // Schedule facades for deletion
        oldFacades.forEach(f -> f.deleteOnClose());
    } catch (BBoxDBException | RejectedException e) {
        handleCompactException(newFacades);
        throw new StorageManagerException(e);
    } catch (InterruptedException e) {
        handleCompactException(newFacades);
        Thread.currentThread().interrupt();
        throw new StorageManagerException(e);
    }
}
Also used : RejectedException(org.bboxdb.commons.RejectedException) ArrayList(java.util.ArrayList) SSTableFacade(org.bboxdb.storage.sstable.reader.SSTableFacade) StorageManagerException(org.bboxdb.storage.StorageManagerException) BBoxDBException(org.bboxdb.misc.BBoxDBException)

Example 35 with BBoxDBException

use of org.bboxdb.misc.BBoxDBException in project bboxdb by jnidzwetzki.

the class SSTableServiceRunnable method testForMergeInGroup.

/**
 * Test for merge in distribution region
 *
 * @param localinstance
 * @param groupName
 * @throws BBoxDBException
 */
private void testForMergeInGroup(final String groupName) throws BBoxDBException {
    final BBoxDBInstance localinstance = ZookeeperClientFactory.getLocalInstanceName();
    final SpacePartitioner spacePartitioner = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(groupName);
    final DistributionRegion rootNode = spacePartitioner.getRootNode();
    if (rootNode == null) {
        return;
    }
    final List<DistributionRegion> mergeCandidates = rootNode.getThisAndChildRegions().stream().filter(r -> r.getSystems().contains(localinstance)).collect(Collectors.toList());
    for (final DistributionRegion region : mergeCandidates) {
        testForUnderflow(spacePartitioner, region);
    }
}
Also used : RegionSplitHelper(org.bboxdb.distribution.partitioner.regionsplit.RegionSplitHelper) SSTableWriter(org.bboxdb.storage.sstable.SSTableWriter) LinkedTransferQueue(java.util.concurrent.LinkedTransferQueue) SpacePartitioner(org.bboxdb.distribution.partitioner.SpacePartitioner) RejectedException(org.bboxdb.commons.RejectedException) DistributionRegionHelper(org.bboxdb.distribution.region.DistributionRegionHelper) ExceptionSafeRunnable(org.bboxdb.commons.concurrent.ExceptionSafeRunnable) RegionMergeHelper(org.bboxdb.distribution.partitioner.regionsplit.RegionMergeHelper) BBoxDBConfiguration(org.bboxdb.misc.BBoxDBConfiguration) LoggerFactory(org.slf4j.LoggerFactory) SSTableFacade(org.bboxdb.storage.sstable.reader.SSTableFacade) ArrayList(java.util.ArrayList) ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager) DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) SSTableKeyIndexReader(org.bboxdb.storage.sstable.reader.SSTableKeyIndexReader) StorageManagerException(org.bboxdb.storage.StorageManagerException) DiskStorage(org.bboxdb.storage.tuplestore.DiskStorage) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) ZookeeperClientFactory(org.bboxdb.distribution.zookeeper.ZookeeperClientFactory) Logger(org.slf4j.Logger) RegionSplitter(org.bboxdb.distribution.partitioner.regionsplit.RegionSplitter) Set(java.util.Set) Collectors(java.util.stream.Collectors) TupleStoreManagerState(org.bboxdb.storage.tuplestore.manager.TupleStoreManagerState) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) TupleStoreManagerRegistry(org.bboxdb.storage.tuplestore.manager.TupleStoreManagerRegistry) List(java.util.List) RegionMerger(org.bboxdb.distribution.partitioner.regionsplit.RegionMerger) BBoxDBException(org.bboxdb.misc.BBoxDBException) SpacePartitionerCache(org.bboxdb.distribution.partitioner.SpacePartitionerCache) VisibleForTesting(com.google.common.annotations.VisibleForTesting) DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) SpacePartitioner(org.bboxdb.distribution.partitioner.SpacePartitioner)

Aggregations

BBoxDBException (org.bboxdb.misc.BBoxDBException)64 DistributionRegion (org.bboxdb.distribution.region.DistributionRegion)24 ZookeeperException (org.bboxdb.distribution.zookeeper.ZookeeperException)22 BoundingBox (org.bboxdb.commons.math.BoundingBox)17 BBoxDBInstance (org.bboxdb.distribution.membership.BBoxDBInstance)14 SpacePartitioner (org.bboxdb.distribution.partitioner.SpacePartitioner)13 ArrayList (java.util.ArrayList)12 ZookeeperNotFoundException (org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException)12 StorageManagerException (org.bboxdb.storage.StorageManagerException)12 List (java.util.List)11 TupleStoreName (org.bboxdb.storage.entity.TupleStoreName)11 EmptyResultFuture (org.bboxdb.network.client.future.EmptyResultFuture)10 Tuple (org.bboxdb.storage.entity.Tuple)9 ResourceAllocationException (org.bboxdb.distribution.placement.ResourceAllocationException)7 RoutingHop (org.bboxdb.network.routing.RoutingHop)7 JoinedTupleListFuture (org.bboxdb.network.client.future.JoinedTupleListFuture)6 RoutingHeader (org.bboxdb.network.routing.RoutingHeader)6 RejectedException (org.bboxdb.commons.RejectedException)5 DistributionRegionIdMapper (org.bboxdb.distribution.region.DistributionRegionIdMapper)5 JoinedTuple (org.bboxdb.storage.entity.JoinedTuple)5