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