use of org.bboxdb.distribution.zookeeper.DistributionGroupAdapter in project bboxdb by jnidzwetzki.
the class TestStorageRegistry method beforeClass.
@BeforeClass
public static void beforeClass() throws InterruptedException, BBoxDBException, ZookeeperException {
storageRegistry = new TupleStoreManagerRegistry();
storageRegistry.init();
final ZookeeperClient zookeeperClient = ZookeeperClientFactory.getZookeeperClient();
final DistributionGroupAdapter adapter = new DistributionGroupAdapter(zookeeperClient);
final DistributionGroupConfiguration configuration = DistributionGroupConfigurationBuilder.create(2).withPlacementStrategy("org.bboxdb.distribution.placement.DummyResourcePlacementStrategy", "").build();
adapter.createDistributionGroup(RELATION_NAME.getDistributionGroup(), configuration);
}
use of org.bboxdb.distribution.zookeeper.DistributionGroupAdapter in project bboxdb by jnidzwetzki.
the class TupleStoreManager method writeDistributionGroupMetaData.
/**
* Write the meta data for the distribution group
* @throws ZookeeperException
* @throws ZookeeperNotFoundException
* @throws IOException
*/
protected void writeDistributionGroupMetaData() throws ZookeeperException, ZookeeperNotFoundException, IOException {
if (!tupleStoreName.isDistributedTable()) {
return;
}
final String groupName = tupleStoreName.getDistributionGroup();
logger.debug("Write meta data for distribution group: ", groupName);
final ZookeeperClient zookeeperClient = ZookeeperClientFactory.getZookeeperClient();
final DistributionGroupAdapter dAdapter = new DistributionGroupAdapter(zookeeperClient);
final String path = dAdapter.getDistributionGroupPath(groupName);
final long version = NodeMutationHelper.getNodeMutationVersion(zookeeperClient, path, null);
DistributionGroupMetadata distributionGroupMetadata = new DistributionGroupMetadata();
distributionGroupMetadata.setVersion(version);
DistributionGroupMetadataHelper.writeMedatadataForGroup(storage.getBasedir().getAbsolutePath(), tupleStoreName.getDistributionGroup(), distributionGroupMetadata);
}
use of org.bboxdb.distribution.zookeeper.DistributionGroupAdapter in project bboxdb by jnidzwetzki.
the class DistributedRecoveryService method runRecovery.
/**
* Run the recovery
* @throws ZookeeperException
* @throws ZookeeperNotFoundException
*/
protected void runRecovery() throws ZookeeperException, ZookeeperNotFoundException {
final DistributionGroupAdapter distributionGroupZookeeperAdapter = ZookeeperClientFactory.getZookeeperClient().getDistributionGroupAdapter();
final List<String> distributionGroups = distributionGroupZookeeperAdapter.getDistributionGroups();
for (final String distributionGroupName : distributionGroups) {
logger.info("Recovery: running recovery for distribution group: {}", distributionGroupName);
runRecoveryForDistributionGroup(distributionGroupName);
logger.info("Recovery: recovery for distribution group done: {}", distributionGroupName);
}
}
use of org.bboxdb.distribution.zookeeper.DistributionGroupAdapter in project bboxdb by jnidzwetzki.
the class DistributionGroupConfigurationCache method getDistributionGroupConfiguration.
/**
* Get the distribution group configuration
* @param distributionGroupName
* @return
* @throws ZookeeperNotFoundException
*/
public synchronized DistributionGroupConfiguration getDistributionGroupConfiguration(final String distributionGroupName) throws ZookeeperNotFoundException {
if (!cache.containsKey(distributionGroupName)) {
try {
final ZookeeperClient zookeeperClient = ZookeeperClientFactory.getZookeeperClient();
final DistributionGroupAdapter distributionGroupZookeeperAdapter = new DistributionGroupAdapter(zookeeperClient);
final DistributionGroupConfiguration configuration = distributionGroupZookeeperAdapter.getDistributionGroupConfiguration(distributionGroupName);
addNewConfiguration(distributionGroupName, configuration);
} catch (InputParseException | ZookeeperException e) {
logger.error("Exception while reading zokeeper data", e);
return new DistributionGroupConfiguration();
}
}
return cache.get(distributionGroupName);
}
use of org.bboxdb.distribution.zookeeper.DistributionGroupAdapter in project bboxdb by jnidzwetzki.
the class AbstractUtilizationPlacementStrategy method calculateSystemUsage.
/**
* Calculate the usage of each system
*
* @return
* @throws ZookeeperException
* @throws ZookeeperNotFoundException
* @throws BBoxDBException
*/
protected Multiset<BBoxDBInstance> calculateSystemUsage() throws ZookeeperException, ZookeeperNotFoundException, BBoxDBException {
final DistributionGroupAdapter zookeeperAdapter = ZookeeperClientFactory.getZookeeperClient().getDistributionGroupAdapter();
final List<String> distributionGroups = zookeeperAdapter.getDistributionGroups();
// The overall usage
final ImmutableMultiset.Builder<BBoxDBInstance> builder = ImmutableMultiset.builder();
// Calculate usage for each distribution group
for (final String groupName : distributionGroups) {
final SpacePartitioner spacepartitioner = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(groupName);
final DistributionRegion region = spacepartitioner.getRootNode();
final Multiset<BBoxDBInstance> regionSystemUsage = DistributionRegionHelper.getSystemUtilization(region);
// Merge results
builder.addAll(regionSystemUsage);
}
return builder.build();
}
Aggregations