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;
}
}
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();
}
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;
}
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);
}
}
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);
}
Aggregations