Search in sources :

Example 41 with BBoxDBInstance

use of org.bboxdb.distribution.membership.BBoxDBInstance in project bboxdb by jnidzwetzki.

the class TupleStoreFlushZookeeperAdapter method accept.

@Override
public void accept(final TupleStoreName ssTableName, final Long flushTimestamp) {
    // Fetch the local instance
    final BBoxDBInstance localInstance = ZookeeperClientFactory.getLocalInstanceName();
    try {
        final String distributionGroup = ssTableName.getDistributionGroup();
        final SpacePartitioner spacepartitioner = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(distributionGroup);
        final DistributionRegion distributionGroupRoot = spacepartitioner.getRootNode();
        if (distributionGroupRoot == null) {
            logger.error("Root for {} is null, not executing callback", ssTableName);
            return;
        }
        final long regionId = ssTableName.getRegionId().getAsLong();
        final DistributionRegion distributionRegion = DistributionRegionHelper.getDistributionRegionForNamePrefix(distributionGroupRoot, regionId);
        logger.debug("Updating checkpoint for: {} to {}", ssTableName.getFullname(), flushTimestamp);
        final DistributionRegionAdapter distributionRegionAdapter = ZookeeperClientFactory.getZookeeperClient().getDistributionRegionAdapter();
        if (distributionRegionAdapter != null && distributionRegion != null) {
            distributionRegionAdapter.setCheckpointForDistributionRegion(distributionRegion, localInstance, flushTimestamp);
        }
    } catch (ZookeeperException | BBoxDBException e) {
        if (Thread.currentThread().isInterrupted()) {
            return;
        }
        logger.warn("Unable to find distribution region: ", e);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        return;
    }
}
Also used : ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) DistributionRegionAdapter(org.bboxdb.distribution.zookeeper.DistributionRegionAdapter) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) BBoxDBException(org.bboxdb.misc.BBoxDBException) SpacePartitioner(org.bboxdb.distribution.partitioner.SpacePartitioner)

Example 42 with BBoxDBInstance

use of org.bboxdb.distribution.membership.BBoxDBInstance in project bboxdb by jnidzwetzki.

the class DistributionRegionComponent method getToolTipText.

/**
 * Get the tooltip text
 * @return
 */
public String getToolTipText() {
    final StringBuilder sb = new StringBuilder("<html>");
    try {
        final Map<BBoxDBInstance, Map<String, Long>> statistics = addStatisticsToTooltip(sb);
        final BoundingBox boundingBox = distributionRegion.getConveringBox();
        for (int i = 0; i < boundingBox.getDimension(); i++) {
            final DoubleInterval floatInterval = boundingBox.getIntervalForDimension(i);
            sb.append("Dimension: " + i + " ");
            sb.append(floatInterval.toString());
            sb.append("<br>");
        }
        final Collection<BBoxDBInstance> systems = distributionRegion.getSystems();
        for (final BBoxDBInstance instance : systems) {
            if (!statistics.keySet().contains(instance)) {
                sb.append("System: ");
                sb.append(instance.toGUIString(guiModel.isScreenshotMode()));
                sb.append(" <br>");
            }
        }
        final boolean mergeableByZookeeper = RegionMergeHelper.isMergingByZookeeperAllowed(distributionRegion);
        final boolean mergeableBySpacePartitioner = RegionMergeHelper.isMergingBySpacePartitionerAllowed(distributionRegion);
        sb.append("Merge supported by configuration <i>" + mergeableByZookeeper + "</i>, by space partitioner <i>" + mergeableBySpacePartitioner + "</i><br>");
        final boolean isSplitSupported = RegionSplitHelper.isSplittingSupported(distributionRegion);
        sb.append("Split supported by space partitioner <i>" + isSplitSupported + "</i><br>");
    } catch (Exception e) {
        logger.error("Got an exception while reading statistics for distribution group", e);
    }
    sb.append("</html>");
    return sb.toString();
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) DoubleInterval(org.bboxdb.commons.math.DoubleInterval) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) Map(java.util.Map) ZookeeperNotFoundException(org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException) ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException)

Example 43 with BBoxDBInstance

use of org.bboxdb.distribution.membership.BBoxDBInstance in project bboxdb by jnidzwetzki.

the class DistributionRegionComponent method addStatisticsToTooltip.

/**
 * Add the statistics to the tooltip
 * @param sb
 * @return
 * @throws ZookeeperException
 * @throws ZookeeperNotFoundException
 */
private Map<BBoxDBInstance, Map<String, Long>> addStatisticsToTooltip(final StringBuilder sb) throws ZookeeperException, ZookeeperNotFoundException {
    final DistributionRegionAdapter adapter = ZookeeperClientFactory.getZookeeperClient().getDistributionRegionAdapter();
    final Map<BBoxDBInstance, Map<String, Long>> statistics = adapter.getRegionStatistics(distributionRegion);
    for (final BBoxDBInstance instance : statistics.keySet()) {
        final Map<String, Long> statisticData = statistics.get(instance);
        sb.append("Node: ");
        sb.append(instance.toGUIString(guiModel.isScreenshotMode()));
        sb.append(" Tuples: ");
        sb.append(statisticData.get(ZookeeperNodeNames.NAME_STATISTICS_TOTAL_TUPLES));
        sb.append(", Size: ");
        sb.append(statisticData.get(ZookeeperNodeNames.NAME_STATISTICS_TOTAL_SIZE));
        sb.append(" MB <br>");
    }
    return statistics;
}
Also used : DistributionRegionAdapter(org.bboxdb.distribution.zookeeper.DistributionRegionAdapter) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) Map(java.util.Map)

Example 44 with BBoxDBInstance

use of org.bboxdb.distribution.membership.BBoxDBInstance 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)

Example 45 with BBoxDBInstance

use of org.bboxdb.distribution.membership.BBoxDBInstance in project bboxdb by jnidzwetzki.

the class BBoxDBCluster method deleteTuple.

@Override
public EmptyResultFuture deleteTuple(final String table, final String key, final long timestamp) throws BBoxDBException {
    final DeletedTuple tuple = new DeletedTuple(key);
    final DistributionRegion distributionRegion = getRootNode(table);
    final Supplier<List<NetworkOperationFuture>> supplier = () -> {
        final List<RoutingHop> hops = RoutingHopHelper.getRoutingHopsForWrite(distributionRegion, tuple.getBoundingBox());
        final List<NetworkOperationFuture> futures = new ArrayList<>();
        for (final RoutingHop hop : hops) {
            final BBoxDBInstance instance = hop.getDistributedInstance();
            final BBoxDBConnection connection = membershipConnectionService.getConnectionForInstance(instance);
            final RoutingHeader routingHeader = new RoutingHeader((short) 0, Arrays.asList(hop));
            final NetworkOperationFuture future = connection.getBboxDBClient().getInsertTupleFuture(table, tuple, routingHeader);
            futures.add(future);
        }
        return futures;
    };
    return new EmptyResultFuture(supplier);
}
Also used : DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) NetworkOperationFuture(org.bboxdb.network.client.future.NetworkOperationFuture) RoutingHeader(org.bboxdb.network.routing.RoutingHeader) ArrayList(java.util.ArrayList) List(java.util.List) RoutingHop(org.bboxdb.network.routing.RoutingHop) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture)

Aggregations

BBoxDBInstance (org.bboxdb.distribution.membership.BBoxDBInstance)78 Test (org.junit.Test)36 ArrayList (java.util.ArrayList)28 DistributionRegion (org.bboxdb.distribution.region.DistributionRegion)25 BBoxDBException (org.bboxdb.misc.BBoxDBException)16 ZookeeperClient (org.bboxdb.distribution.zookeeper.ZookeeperClient)14 List (java.util.List)13 RoutingHop (org.bboxdb.network.routing.RoutingHop)13 BBoxDBInstanceManager (org.bboxdb.distribution.membership.BBoxDBInstanceManager)11 ZookeeperException (org.bboxdb.distribution.zookeeper.ZookeeperException)11 RoutingHeader (org.bboxdb.network.routing.RoutingHeader)11 BoundingBox (org.bboxdb.commons.math.BoundingBox)9 NetworkOperationFuture (org.bboxdb.network.client.future.NetworkOperationFuture)8 Map (java.util.Map)7 HashMap (java.util.HashMap)6 ZookeeperBBoxDBInstanceAdapter (org.bboxdb.distribution.membership.ZookeeperBBoxDBInstanceAdapter)6 ZookeeperNotFoundException (org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException)6 JoinedTupleListFuture (org.bboxdb.network.client.future.JoinedTupleListFuture)6 TupleListFuture (org.bboxdb.network.client.future.TupleListFuture)6 OptionalDouble (java.util.OptionalDouble)4