use of org.bboxdb.distribution.zookeeper.ZookeeperException in project bboxdb by jnidzwetzki.
the class TestTupleSink method testTupleSink.
/**
* Test the tuple sinks
* @throws StorageManagerException
* @throws BBoxDBException
* @throws ZookeeperException
* @throws InterruptedException
*/
@Test(timeout = 60000)
public void testTupleSink() throws StorageManagerException, BBoxDBException, ZookeeperException, InterruptedException {
final DistributionRegion distributionRegion = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(TEST_GROUP).getRootNode();
tupleStoreAdapter.deleteTable(TABLENAME);
tupleStoreAdapter.writeTuplestoreConfiguration(TABLENAME, new TupleStoreConfiguration());
final List<BBoxDBInstance> systems = Arrays.asList(new BBoxDBInstance("10.0.0.1:10000"), new BBoxDBInstance("10.0.0.2:10000"), ZookeeperClientFactory.getLocalInstanceName());
distributionRegion.setSystems(systems);
final TupleRedistributor tupleRedistributor = createTupleRedistributor();
tupleRedistributor.registerRegion(distributionRegion);
final Map<DistributionRegion, List<AbstractTupleSink>> map = tupleRedistributor.getRegionMap();
Assert.assertEquals(1, map.size());
final long networkSinks = map.values().stream().flatMap(e -> e.stream()).filter(s -> s instanceof NetworkTupleSink).count();
Assert.assertEquals(2, networkSinks);
final long localSinks = map.values().stream().flatMap(e -> e.stream()).filter(s -> s instanceof LocalTupleSink).count();
Assert.assertEquals(1, localSinks);
}
use of org.bboxdb.distribution.zookeeper.ZookeeperException in project bboxdb by jnidzwetzki.
the class DistributedRecoveryService method init.
@Override
public void init() {
try {
final ZookeeperClient zookeeperClient = ZookeeperClientFactory.getZookeeperClient();
final ZookeeperBBoxDBInstanceAdapter zookeeperBBoxDBInstanceAdapter = new ZookeeperBBoxDBInstanceAdapter(zookeeperClient);
final BBoxDBInstance distributedInstance = ZookeeperClientFactory.getLocalInstanceName();
zookeeperBBoxDBInstanceAdapter.updateStateData(distributedInstance, BBoxDBInstanceState.OUTDATED);
logger.info("Running recovery for local stored data");
runRecovery();
logger.info("Running recovery for local stored data DONE");
zookeeperBBoxDBInstanceAdapter.updateStateData(distributedInstance, BBoxDBInstanceState.READY);
} catch (ZookeeperException | ZookeeperNotFoundException e) {
logger.error("Got an exception during recovery: ", e);
}
}
use of org.bboxdb.distribution.zookeeper.ZookeeperException 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.ZookeeperException in project bboxdb by jnidzwetzki.
the class DistributionRegionHelper method getOutdatedRegions.
/**
* Find the outdated regions for the distributed instance
* @param region
* @param distributedInstance
* @return
* @throws BBoxDBException
*/
public static List<OutdatedDistributionRegion> getOutdatedRegions(final DistributionRegion region, final BBoxDBInstance distributedInstance) throws BBoxDBException {
final List<OutdatedDistributionRegion> result = new ArrayList<>();
if (region == null) {
return result;
}
final List<DistributionRegion> regions = region.getThisAndChildRegions().stream().filter(r -> r.getSystems().contains(distributedInstance)).collect(Collectors.toList());
for (final DistributionRegion regionToInspect : regions) {
try {
final OutdatedDistributionRegion regionResult = processRegion(distributedInstance, ZookeeperClientFactory.getZookeeperClient(), regionToInspect);
if (regionResult != null) {
result.add(regionResult);
}
} catch (ZookeeperException e) {
throw new BBoxDBException(e);
}
}
return result;
}
use of org.bboxdb.distribution.zookeeper.ZookeeperException in project bboxdb by jnidzwetzki.
the class AbstractSpacePartitioner method splitFailed.
@Override
public void splitFailed(final DistributionRegion sourceRegion, final List<DistributionRegion> destination) throws BBoxDBException {
try {
distributionRegionZookeeperAdapter.setStateForDistributionRegion(sourceRegion, DistributionRegionState.ACTIVE);
for (final DistributionRegion childRegion : destination) {
logger.info("Deleting child after failed split: {}", childRegion.getIdentifier());
distributionRegionZookeeperAdapter.deleteChild(childRegion);
}
} catch (ZookeeperException e) {
throw new BBoxDBException(e);
}
}
Aggregations