Search in sources :

Example 11 with ZookeeperClient

use of org.bboxdb.distribution.zookeeper.ZookeeperClient 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 12 with ZookeeperClient

use of org.bboxdb.distribution.zookeeper.ZookeeperClient in project bboxdb by jnidzwetzki.

the class BBoxDBMain method start.

/**
 * Start all services
 */
public void start() {
    logger.info("Starting up BBoxDB - version: {}", Const.VERSION);
    if (!runBaseChecks()) {
        logger.error("Some of the base checks have failed, exiting");
        System.exit(-1);
    }
    // Init all services
    for (final BBoxDBService service : services) {
        try {
            logger.info("Starting service: {}", service.getServicename());
            service.init();
        } catch (Throwable e) {
            logger.error("Got exception while init service:" + service.getServicename(), e);
            stop();
            System.exit(-1);
        }
    }
    // Read membership
    final ZookeeperClient zookeeperClient = ZookeeperClientFactory.getZookeeperClient();
    BBoxDBInstanceManager.getInstance().startMembershipObserver(zookeeperClient);
}
Also used : ZookeeperClient(org.bboxdb.distribution.zookeeper.ZookeeperClient) BBoxDBService(org.bboxdb.misc.BBoxDBService)

Example 13 with ZookeeperClient

use of org.bboxdb.distribution.zookeeper.ZookeeperClient 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 14 with ZookeeperClient

use of org.bboxdb.distribution.zookeeper.ZookeeperClient 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 15 with ZookeeperClient

use of org.bboxdb.distribution.zookeeper.ZookeeperClient in project bboxdb by jnidzwetzki.

the class CreateInitialPartitioning method main.

public static void main(final String[] args) throws Exception {
    if (args.length != 5) {
        System.err.println("Usage: <File> <Format> <Distribution group> <Partitiones> " + "<ZookeeperEndpoint> <Clustername>");
        System.exit(-1);
    }
    final String filename = args[0];
    final String format = args[1];
    final String distributionGroup = args[2];
    final int partitions = MathUtil.tryParseInt(args[3], () -> "Unable to parse: " + args[3]);
    final String zookeeperEndpoint = args[4];
    final String clustername = args[5];
    final ZookeeperClient zookeeperClient = new ZookeeperClient(Arrays.asList(zookeeperEndpoint), clustername);
    zookeeperClient.init();
    if (!zookeeperClient.isConnected()) {
        System.err.println("Unable to connect to zookeeper at: " + zookeeperEndpoint);
        System.exit(-1);
    }
    ZookeeperClientFactory.setDefaultZookeeperClient(zookeeperClient);
    doesGroupExist(distributionGroup);
    checkForExistingPartitioning(distributionGroup);
    final CreateInitialPartitioning dataRedistributionLoader = new CreateInitialPartitioning(filename, format, distributionGroup, partitions);
    dataRedistributionLoader.run();
}
Also used : ZookeeperClient(org.bboxdb.distribution.zookeeper.ZookeeperClient)

Aggregations

ZookeeperClient (org.bboxdb.distribution.zookeeper.ZookeeperClient)24 BBoxDBInstance (org.bboxdb.distribution.membership.BBoxDBInstance)13 Test (org.junit.Test)12 BBoxDBInstanceManager (org.bboxdb.distribution.membership.BBoxDBInstanceManager)9 ZookeeperBBoxDBInstanceAdapter (org.bboxdb.distribution.membership.ZookeeperBBoxDBInstanceAdapter)6 CountDownLatch (java.util.concurrent.CountDownLatch)3 DistributedInstanceEvent (org.bboxdb.distribution.membership.DistributedInstanceEvent)3 DistributionGroupAdapter (org.bboxdb.distribution.zookeeper.DistributionGroupAdapter)3 ZookeeperException (org.bboxdb.distribution.zookeeper.ZookeeperException)3 BBoxDBConfiguration (org.bboxdb.misc.BBoxDBConfiguration)2 DistributionGroupConfiguration (org.bboxdb.storage.entity.DistributionGroupConfiguration)2 ActionEvent (java.awt.event.ActionEvent)1 File (java.io.File)1 AbstractAction (javax.swing.AbstractAction)1 InputParseException (org.bboxdb.commons.InputParseException)1 SpacePartitioner (org.bboxdb.distribution.partitioner.SpacePartitioner)1 DistributionRegion (org.bboxdb.distribution.region.DistributionRegion)1 TupleStoreAdapter (org.bboxdb.distribution.zookeeper.TupleStoreAdapter)1 ZookeeperInstanceRegisterer (org.bboxdb.distribution.zookeeper.ZookeeperInstanceRegisterer)1 ZookeeperNotFoundException (org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException)1