Search in sources :

Example 6 with BBoxDBConfiguration

use of org.bboxdb.misc.BBoxDBConfiguration 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 7 with BBoxDBConfiguration

use of org.bboxdb.misc.BBoxDBConfiguration in project bboxdb by jnidzwetzki.

the class TestStorageRegistry method testDeleteTable.

/**
 * Test delete table
 * @throws StorageManagerException
 * @throws InterruptedException
 * @throws RejectedException
 */
@Test(timeout = 60000)
public void testDeleteTable() throws StorageManagerException, InterruptedException, RejectedException {
    storageRegistry.deleteTable(RELATION_NAME, true);
    Assert.assertFalse(storageRegistry.isStorageManagerActive(RELATION_NAME));
    storageRegistry.createTable(RELATION_NAME, new TupleStoreConfiguration());
    final TupleStoreManager storageManager = storageRegistry.getTupleStoreManager(RELATION_NAME);
    for (int i = 0; i < 50000; i++) {
        final Tuple createdTuple = new Tuple(Integer.toString(i), BoundingBox.FULL_SPACE, Integer.toString(i).getBytes());
        storageManager.put(createdTuple);
    }
    // Wait for requests to settle
    storageManager.flush();
    storageRegistry.deleteTable(RELATION_NAME, true);
    Assert.assertTrue(storageManager.isShutdownComplete());
    // Check the removal of the directory
    final BBoxDBConfiguration configuration = BBoxDBConfigurationManager.getConfiguration();
    final String storageDirectory = configuration.getStorageDirectories().get(0);
    final String pathname = SSTableHelper.getSSTableDir(storageDirectory, RELATION_NAME);
    final File directory = new File(pathname);
    System.out.println("Check for " + directory);
    Assert.assertFalse(directory.exists());
}
Also used : TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) BBoxDBConfiguration(org.bboxdb.misc.BBoxDBConfiguration) File(java.io.File) Tuple(org.bboxdb.storage.entity.Tuple) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager) Test(org.junit.Test)

Example 8 with BBoxDBConfiguration

use of org.bboxdb.misc.BBoxDBConfiguration in project bboxdb by jnidzwetzki.

the class SpatialIndexBuilderFactory method getInstance.

/**
 * Get an instance of the configured factory
 * @return
 */
public static SpatialIndexBuilder getInstance() {
    final BBoxDBConfiguration configuration = BBoxDBConfigurationManager.getConfiguration();
    final String factoryClass = configuration.getStorageSpatialIndexBuilder();
    // Instance the classname
    try {
        final Class<?> classObject = Class.forName(factoryClass);
        if (classObject == null) {
            throw new ClassNotFoundException("Unable to locate class: " + factoryClass);
        }
        final Object factoryObject = classObject.newInstance();
        if (!(factoryObject instanceof SpatialIndexBuilder)) {
            throw new ClassNotFoundException(factoryClass + " is not a instance of SpatialIndexer");
        }
        return (SpatialIndexBuilder) factoryObject;
    } catch (Exception e) {
        logger.warn("Unable to instance class" + factoryClass, e);
        throw new RuntimeException(e);
    }
}
Also used : BBoxDBConfiguration(org.bboxdb.misc.BBoxDBConfiguration)

Example 9 with BBoxDBConfiguration

use of org.bboxdb.misc.BBoxDBConfiguration in project bboxdb by jnidzwetzki.

the class SpatialIndexReaderFactory method getInstance.

/**
 * Get an instance of the configured factory
 * @return
 */
public static SpatialIndexReader getInstance() {
    final BBoxDBConfiguration configuration = BBoxDBConfigurationManager.getConfiguration();
    final String factoryClass = configuration.getStorageSpatialIndexReader();
    // Instance the classname
    try {
        final Class<?> classObject = Class.forName(factoryClass);
        if (classObject == null) {
            throw new ClassNotFoundException("Unable to locate class: " + factoryClass);
        }
        final Object factoryObject = classObject.newInstance();
        if (!(factoryObject instanceof SpatialIndexReader)) {
            throw new ClassNotFoundException(factoryClass + " is not a instance of SpatialIndexer");
        }
        return (SpatialIndexReader) factoryObject;
    } catch (Exception e) {
        logger.warn("Unable to instance class" + factoryClass, e);
        throw new RuntimeException(e);
    }
}
Also used : BBoxDBConfiguration(org.bboxdb.misc.BBoxDBConfiguration)

Example 10 with BBoxDBConfiguration

use of org.bboxdb.misc.BBoxDBConfiguration in project bboxdb by jnidzwetzki.

the class ZookeeperBBoxDBInstanceAdapter method updateNodeInfo.

/**
 * Update the hardware info
 * @param zookeeperClient
 * @throws ZookeeperException
 */
public void updateNodeInfo(final BBoxDBInstance instance) throws ZookeeperException {
    // Version
    final String versionPath = pathHelper.getInstancesVersionPath(instance);
    zookeeperClient.replacePersistentNode(versionPath, Const.VERSION.getBytes());
    // CPUs
    final int cpuCores = SystemInfo.getCPUCores();
    final String cpuCoresPath = pathHelper.getInstancesCpuCorePath(instance);
    zookeeperClient.replacePersistentNode(cpuCoresPath, Integer.toString(cpuCores).getBytes());
    // Memory
    final long memory = SystemInfo.getAvailableMemory();
    final String memoryPath = pathHelper.getInstancesMemoryPath(instance);
    zookeeperClient.replacePersistentNode(memoryPath, Long.toString(memory).getBytes());
    // Diskspace
    final BBoxDBConfiguration bboxDBConfiguration = BBoxDBConfigurationManager.getConfiguration();
    final List<String> directories = bboxDBConfiguration.getStorageDirectories();
    for (final String directory : directories) {
        final File path = new File(directory);
        // Free
        final long freeDiskspace = SystemInfo.getFreeDiskspace(path);
        final String freeDiskspacePath = pathHelper.getInstancesDiskspaceFreePath(instance, directory);
        zookeeperClient.replacePersistentNode(freeDiskspacePath, Long.toString(freeDiskspace).getBytes());
        // Total
        final long totalDiskspace = SystemInfo.getTotalDiskspace(path);
        final String totalDiskspacePath = pathHelper.getInstancesDiskspaceTotalPath(instance, directory);
        zookeeperClient.replacePersistentNode(totalDiskspacePath, Long.toString(totalDiskspace).getBytes());
    }
}
Also used : BBoxDBConfiguration(org.bboxdb.misc.BBoxDBConfiguration) File(java.io.File)

Aggregations

BBoxDBConfiguration (org.bboxdb.misc.BBoxDBConfiguration)11 File (java.io.File)3 BBoxDBInstance (org.bboxdb.distribution.membership.BBoxDBInstance)2 ZookeeperClient (org.bboxdb.distribution.zookeeper.ZookeeperClient)2 Test (org.junit.Test)2 HTTPServer (io.prometheus.client.exporter.HTTPServer)1 IOException (java.io.IOException)1 ZookeeperInstanceRegisterer (org.bboxdb.distribution.zookeeper.ZookeeperInstanceRegisterer)1 Tuple (org.bboxdb.storage.entity.Tuple)1 TupleStoreConfiguration (org.bboxdb.storage.entity.TupleStoreConfiguration)1 SSTableCheckpointRunnable (org.bboxdb.storage.sstable.SSTableCheckpointRunnable)1 SSTableWriter (org.bboxdb.storage.sstable.SSTableWriter)1 SSTableFacade (org.bboxdb.storage.sstable.reader.SSTableFacade)1 TupleStoreManager (org.bboxdb.storage.tuplestore.manager.TupleStoreManager)1 TupleStoreManagerRegistry (org.bboxdb.storage.tuplestore.manager.TupleStoreManagerRegistry)1