use of org.bboxdb.distribution.region.DistributionRegionCallback in project bboxdb by jnidzwetzki.
the class SpacePartitionerCache method getSpacePartitionerForGroupName.
/**
* Get the distribution region for the given group name
* @param groupName
* @return
* @throws BBoxDBException
* @throws ZookeeperException
* @throws ZookeeperNotFoundException
*/
public synchronized SpacePartitioner getSpacePartitionerForGroupName(final String groupName) throws BBoxDBException {
try {
if (!spacePartitioner.containsKey(groupName)) {
final String path = zookeeperClient.getDistributionGroupAdapter().getDistributionGroupPath(groupName);
final long version = NodeMutationHelper.getNodeMutationVersion(zookeeperClient, path, this);
// Create callback list
if (!callbacks.containsKey(groupName)) {
final Set<DistributionRegionCallback> callback = new CopyOnWriteArraySet<>();
callbacks.put(groupName, callback);
}
// Create region id mapper
if (!distributionRegionIdMapper.containsKey(groupName)) {
final DistributionRegionIdMapper mapper = new DistributionRegionIdMapper(groupName);
distributionRegionIdMapper.put(groupName, mapper);
}
final SpacePartitioner adapter = zookeeperClient.getDistributionGroupAdapter().getSpaceparitioner(groupName, callbacks.get(groupName), distributionRegionIdMapper.get(groupName));
partitionerVersions.put(groupName, version);
spacePartitioner.put(groupName, adapter);
}
return spacePartitioner.get(groupName);
} catch (ZookeeperException | ZookeeperNotFoundException e) {
throw new BBoxDBException(e);
}
}
Aggregations