Search in sources :

Example 21 with ZookeeperClient

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

the class TestDistributedInstanceManager method getNewZookeeperClient.

/**
 * Get a new instance of the zookeeper client
 * @param instance
 * @return
 */
private static ZookeeperClient getNewZookeeperClient(final BBoxDBInstance instance) {
    final BBoxDBConfiguration scalephantConfiguration = BBoxDBConfigurationManager.getConfiguration();
    final Collection<String> zookeepernodes = scalephantConfiguration.getZookeepernodes();
    final ZookeeperClient zookeeperClient = new ZookeeperClient(zookeepernodes, CLUSTER_NAME);
    zookeeperClient.init();
    if (instance != null) {
        final ZookeeperInstanceRegisterer registerer = new ZookeeperInstanceRegisterer(instance, zookeeperClient);
        registerer.init();
    }
    return zookeeperClient;
}
Also used : ZookeeperClient(org.bboxdb.distribution.zookeeper.ZookeeperClient) ZookeeperInstanceRegisterer(org.bboxdb.distribution.zookeeper.ZookeeperInstanceRegisterer) BBoxDBConfiguration(org.bboxdb.misc.BBoxDBConfiguration)

Example 22 with ZookeeperClient

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

the class DistributedRecoveryService method runRecoveryForDistributionGroup.

/**
 * Run recovery for distribution group
 * @param distributionGroupName
 * @throws ZookeeperException
 */
protected void runRecoveryForDistributionGroup(final String distributionGroupName) {
    try {
        final ZookeeperClient zookeeperClient = ZookeeperClientFactory.getZookeeperClient();
        final BBoxDBInstance localInstance = ZookeeperClientFactory.getLocalInstanceName();
        for (final DiskStorage storage : storageRegistry.getAllStorages()) {
            checkGroupVersion(storage, distributionGroupName, zookeeperClient);
        }
        final SpacePartitioner spacePartitioner = SpacePartitionerCache.getInstance().getSpacePartitionerForGroupName(distributionGroupName);
        final DistributionRegion distributionGroup = spacePartitioner.getRootNode();
        final List<OutdatedDistributionRegion> outdatedRegions = DistributionRegionHelper.getOutdatedRegions(distributionGroup, localInstance);
        handleOutdatedRegions(distributionGroupName, outdatedRegions);
    } catch (Throwable e) {
        logger.error("Got exception while running recovery for distribution group: " + distributionGroupName, e);
    }
}
Also used : ZookeeperClient(org.bboxdb.distribution.zookeeper.ZookeeperClient) DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) DiskStorage(org.bboxdb.storage.tuplestore.DiskStorage) SpacePartitioner(org.bboxdb.distribution.partitioner.SpacePartitioner)

Example 23 with ZookeeperClient

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

the class StatisticsUpdateRunnable method updateNodeStats.

/**
 * Update the local node stats (diskspace, memory)
 * @throws ZookeeperException
 */
private void updateNodeStats() {
    try {
        final BBoxDBInstance instance = ZookeeperClientFactory.getLocalInstanceName();
        logger.debug("Update zookeeper node stats");
        final ZookeeperClient zookeeperClient = ZookeeperClientFactory.getZookeeperClient();
        final ZookeeperBBoxDBInstanceAdapter zookeeperBBoxDBInstanceAdapter = new ZookeeperBBoxDBInstanceAdapter(zookeeperClient);
        zookeeperBBoxDBInstanceAdapter.updateNodeInfo(instance);
    } catch (ZookeeperException e) {
        logger.error("Got exception while updating local node stats", e);
    }
}
Also used : ZookeeperClient(org.bboxdb.distribution.zookeeper.ZookeeperClient) ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) ZookeeperBBoxDBInstanceAdapter(org.bboxdb.distribution.membership.ZookeeperBBoxDBInstanceAdapter)

Example 24 with ZookeeperClient

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

the class BBoxDBInstanceManager method stopMembershipObserver.

/**
 * Stop the membership observer. This will send a delete event for all known
 * instances if the membership observer was active.
 */
public synchronized void stopMembershipObserver() {
    if (zookeeperBBoxDBInstanceAdapter != null) {
        final ZookeeperClient zookeeper = zookeeperBBoxDBInstanceAdapter.getZookeeperClient();
        zookeeper.getServiceState().removeCallback(zookeeperStartedCallback);
        zookeeper.getServiceState().removeCallback(zookeeperShutdownCallback);
        zookeeperBBoxDBInstanceAdapter = null;
    }
    zookeeperDisconnect();
}
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