Search in sources :

Example 1 with DistributionGroupAdapter

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);
}
Also used : ZookeeperClient(org.bboxdb.distribution.zookeeper.ZookeeperClient) DistributionGroupAdapter(org.bboxdb.distribution.zookeeper.DistributionGroupAdapter) TupleStoreManagerRegistry(org.bboxdb.storage.tuplestore.manager.TupleStoreManagerRegistry) DistributionGroupConfiguration(org.bboxdb.storage.entity.DistributionGroupConfiguration) BeforeClass(org.junit.BeforeClass)

Example 2 with DistributionGroupAdapter

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

Example 3 with DistributionGroupAdapter

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);
    }
}
Also used : DistributionGroupAdapter(org.bboxdb.distribution.zookeeper.DistributionGroupAdapter)

Example 4 with DistributionGroupAdapter

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);
}
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 5 with DistributionGroupAdapter

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();
}
Also used : DistributionGroupAdapter(org.bboxdb.distribution.zookeeper.DistributionGroupAdapter) ImmutableMultiset(com.google.common.collect.ImmutableMultiset) DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) SpacePartitioner(org.bboxdb.distribution.partitioner.SpacePartitioner)

Aggregations

DistributionGroupAdapter (org.bboxdb.distribution.zookeeper.DistributionGroupAdapter)9 ZookeeperClient (org.bboxdb.distribution.zookeeper.ZookeeperClient)3 IOException (java.io.IOException)2 SpacePartitioner (org.bboxdb.distribution.partitioner.SpacePartitioner)2 DistributionRegion (org.bboxdb.distribution.region.DistributionRegion)2 ZookeeperException (org.bboxdb.distribution.zookeeper.ZookeeperException)2 PackageEncodeException (org.bboxdb.network.packages.PackageEncodeException)2 ErrorResponse (org.bboxdb.network.packages.response.ErrorResponse)2 SuccessResponse (org.bboxdb.network.packages.response.SuccessResponse)2 DistributionGroupConfiguration (org.bboxdb.storage.entity.DistributionGroupConfiguration)2 DistributionGroupMetadata (org.bboxdb.storage.entity.DistributionGroupMetadata)2 ImmutableMultiset (com.google.common.collect.ImmutableMultiset)1 InputParseException (org.bboxdb.commons.InputParseException)1 BBoxDBInstance (org.bboxdb.distribution.membership.BBoxDBInstance)1 DistributionRegionAdapter (org.bboxdb.distribution.zookeeper.DistributionRegionAdapter)1 ZookeeperNotFoundException (org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException)1 CreateDistributionGroupRequest (org.bboxdb.network.packages.request.CreateDistributionGroupRequest)1 DeleteDistributionGroupRequest (org.bboxdb.network.packages.request.DeleteDistributionGroupRequest)1 TupleStoreManagerRegistry (org.bboxdb.storage.tuplestore.manager.TupleStoreManagerRegistry)1 BeforeClass (org.junit.BeforeClass)1