use of org.bboxdb.distribution.zookeeper.ZookeeperException in project bboxdb by jnidzwetzki.
the class InsertTupleHandler method createMissingTables.
/**
* Create all missing tables
*/
protected void createMissingTables(final TupleStoreName requestTable, final TupleStoreManagerRegistry storageRegistry, final Collection<TupleStoreName> localTables) throws StorageManagerException {
try {
final TupleStoreAdapter tupleStoreAdapter = ZookeeperClientFactory.getZookeeperClient().getTupleStoreAdapter();
if (!tupleStoreAdapter.isTableKnown(requestTable)) {
throw new StorageManagerException("Table: " + requestTable.getFullname() + " is unkown");
}
final TupleStoreConfiguration config = tupleStoreAdapter.readTuplestoreConfiguration(requestTable);
for (final TupleStoreName tupleStoreName : localTables) {
final boolean alreadyKnown = storageRegistry.isStorageManagerKnown(tupleStoreName);
if (!alreadyKnown) {
storageRegistry.createTableIfNotExist(tupleStoreName, config);
}
}
} catch (ZookeeperException e) {
throw new StorageManagerException(e);
}
}
use of org.bboxdb.distribution.zookeeper.ZookeeperException 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.ZookeeperException 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.ZookeeperException 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.ZookeeperException in project bboxdb by jnidzwetzki.
the class StatisticsUpdateRunnable method updateNodeStats.
/**
* Update the local node stats (diskspace, memory)
* @throws ZookeeperException
*/
private void updateNodeStats() {
try {
final BBoxDBInstance instance = ZookeeperClientFactory.getLocalInstanceName();
logger.debug("Update zookeeper node stats");
final ZookeeperClient zookeeperClient = ZookeeperClientFactory.getZookeeperClient();
final ZookeeperBBoxDBInstanceAdapter zookeeperBBoxDBInstanceAdapter = new ZookeeperBBoxDBInstanceAdapter(zookeeperClient);
zookeeperBBoxDBInstanceAdapter.updateNodeInfo(instance);
} catch (ZookeeperException e) {
logger.error("Got exception while updating local node stats", e);
}
}
Aggregations