Search in sources :

Example 6 with ZookeeperException

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);
}
Also used : TupleRedistributor(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.TupleRedistributor) Arrays(java.util.Arrays) BeforeClass(org.junit.BeforeClass) TupleStoreAdapter(org.bboxdb.distribution.zookeeper.TupleStoreAdapter) LocalTupleSink(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.LocalTupleSink) Tuple(org.bboxdb.storage.entity.Tuple) BoundingBox(org.bboxdb.commons.math.BoundingBox) ArrayList(java.util.ArrayList) ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) Map(java.util.Map) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) StorageManagerException(org.bboxdb.storage.StorageManagerException) DistributionGroupConfiguration(org.bboxdb.storage.entity.DistributionGroupConfiguration) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) ZookeeperClientFactory(org.bboxdb.distribution.zookeeper.ZookeeperClientFactory) NetworkTupleSink(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.NetworkTupleSink) DistributionGroupConfigurationBuilder(org.bboxdb.storage.entity.DistributionGroupConfigurationBuilder) Test(org.junit.Test) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) TupleStoreManagerRegistry(org.bboxdb.storage.tuplestore.manager.TupleStoreManagerRegistry) Mockito(org.mockito.Mockito) List(java.util.List) AbstractTupleSink(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.AbstractTupleSink) BBoxDBException(org.bboxdb.misc.BBoxDBException) TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) DistributionGroupAdapter(org.bboxdb.distribution.zookeeper.DistributionGroupAdapter) SpacePartitionerCache(org.bboxdb.distribution.partitioner.SpacePartitionerCache) TupleRedistributor(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.TupleRedistributor) Assert(org.junit.Assert) DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) LocalTupleSink(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.LocalTupleSink) NetworkTupleSink(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.NetworkTupleSink) ArrayList(java.util.ArrayList) List(java.util.List) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) Test(org.junit.Test)

Example 7 with ZookeeperException

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);
    }
}
Also used : ZookeeperClient(org.bboxdb.distribution.zookeeper.ZookeeperClient) ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) ZookeeperNotFoundException(org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException) ZookeeperBBoxDBInstanceAdapter(org.bboxdb.distribution.membership.ZookeeperBBoxDBInstanceAdapter) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance)

Example 8 with ZookeeperException

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);
}
Also used : ZookeeperClient(org.bboxdb.distribution.zookeeper.ZookeeperClient) DistributionGroupAdapter(org.bboxdb.distribution.zookeeper.DistributionGroupAdapter) InputParseException(org.bboxdb.commons.InputParseException) ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) DistributionGroupConfiguration(org.bboxdb.storage.entity.DistributionGroupConfiguration)

Example 9 with ZookeeperException

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;
}
Also used : Arrays(java.util.Arrays) OutdatedDistributionRegion(org.bboxdb.distribution.OutdatedDistributionRegion) Multiset(com.google.common.collect.Multiset) RoutingHop(org.bboxdb.network.routing.RoutingHop) HashMap(java.util.HashMap) Callable(java.util.concurrent.Callable) DistributionRegionState(org.bboxdb.distribution.partitioner.DistributionRegionState) BoundingBox(org.bboxdb.commons.math.BoundingBox) ZookeeperClient(org.bboxdb.distribution.zookeeper.ZookeeperClient) ArrayList(java.util.ArrayList) Const(org.bboxdb.misc.Const) ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) HashMultiset(com.google.common.collect.HashMultiset) Map(java.util.Map) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) ZookeeperClientFactory(org.bboxdb.distribution.zookeeper.ZookeeperClientFactory) Predicate(java.util.function.Predicate) Collection(java.util.Collection) Retryer(org.bboxdb.commons.Retryer) InetSocketAddress(java.net.InetSocketAddress) Collectors(java.util.stream.Collectors) List(java.util.List) Entry(java.util.Map.Entry) Optional(java.util.Optional) BBoxDBException(org.bboxdb.misc.BBoxDBException) ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) OutdatedDistributionRegion(org.bboxdb.distribution.OutdatedDistributionRegion) OutdatedDistributionRegion(org.bboxdb.distribution.OutdatedDistributionRegion) ArrayList(java.util.ArrayList) BBoxDBException(org.bboxdb.misc.BBoxDBException)

Example 10 with ZookeeperException

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);
    }
}
Also used : ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) BBoxDBException(org.bboxdb.misc.BBoxDBException)

Aggregations

ZookeeperException (org.bboxdb.distribution.zookeeper.ZookeeperException)37 BBoxDBException (org.bboxdb.misc.BBoxDBException)24 BoundingBox (org.bboxdb.commons.math.BoundingBox)17 DistributionRegion (org.bboxdb.distribution.region.DistributionRegion)17 BBoxDBInstance (org.bboxdb.distribution.membership.BBoxDBInstance)16 ZookeeperNotFoundException (org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException)13 DistributionGroupConfiguration (org.bboxdb.storage.entity.DistributionGroupConfiguration)13 DistributionGroupAdapter (org.bboxdb.distribution.zookeeper.DistributionGroupAdapter)11 DistributionRegionIdMapper (org.bboxdb.distribution.region.DistributionRegionIdMapper)10 ZookeeperClientFactory (org.bboxdb.distribution.zookeeper.ZookeeperClientFactory)10 CopyOnWriteArraySet (java.util.concurrent.CopyOnWriteArraySet)9 DistributionRegionState (org.bboxdb.distribution.partitioner.DistributionRegionState)9 DistributionRegionCallback (org.bboxdb.distribution.region.DistributionRegionCallback)9 DistributionRegionAdapter (org.bboxdb.distribution.zookeeper.DistributionRegionAdapter)9 DistributionGroupConfigurationBuilder (org.bboxdb.storage.entity.DistributionGroupConfigurationBuilder)9 Assert (org.junit.Assert)9 Test (org.junit.Test)9 Set (java.util.Set)8 CountDownLatch (java.util.concurrent.CountDownLatch)8 SpacePartitionerContext (org.bboxdb.distribution.partitioner.SpacePartitionerContext)8