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;
}
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());
}
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);
}
}
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);
}
}
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());
}
}
Aggregations