use of org.bboxdb.storage.StorageManagerException in project bboxdb by jnidzwetzki.
the class TupleStoreManager method getAllTupleVersionsForKey.
/**
* Get all tuples for a given key
* @param tuple
* @param activeStorage
* @return
* @throws StorageManagerException
*/
public List<Tuple> getAllTupleVersionsForKey(final String key) throws StorageManagerException {
List<ReadOnlyTupleStore> aquiredStorages = null;
try {
aquiredStorages = aquireStorage();
final List<Tuple> resultTuples = new ArrayList<>();
for (final ReadOnlyTupleStore readOnlyTupleStorage : aquiredStorages) {
final List<Tuple> possibleTuples = readOnlyTupleStorage.get(key);
resultTuples.addAll(possibleTuples);
}
return resultTuples;
} catch (Exception e) {
throw e;
} finally {
releaseStorage(aquiredStorages);
}
}
use of org.bboxdb.storage.StorageManagerException in project bboxdb by jnidzwetzki.
the class TupleStoreManagerRegistry method deleteAllTablesInDistributionGroup.
/**
* Delete all tables that are part of the distribution group
* @param distributionGroupName
* @throws StorageManagerException
*/
public synchronized void deleteAllTablesInDistributionGroup(final String distributionGroupName) throws StorageManagerException {
// Memtables
logger.info("Shuting down active memtables for distribution group: {}", distributionGroupName);
final Predicate<TupleStoreName> deleteTablePredicate = (t) -> (t.getDistributionGroup().equals(distributionGroupName));
shutdownAndDeleteTablesForPredicate(deleteTablePredicate, true);
// Delete the group dir
for (final String directory : storages.keySet()) {
logger.info("Deleting all local stored data for distribution group {} in path {} ", distributionGroupName, directory);
executePendingDeletes(directory);
deleteMedatadaOfDistributionGroup(distributionGroupName, directory);
final String groupDirName = SSTableHelper.getDistributionGroupDir(directory, distributionGroupName);
final File groupDir = new File(groupDirName);
final String[] children = groupDir.list();
if (children != null && children.length > 0) {
final List<String> childList = Arrays.asList(children);
throw new StorageManagerException("Unable to delete non empty dir: " + groupDirName + " / " + childList);
}
if (groupDir.exists()) {
logger.debug("Deleting {}", groupDir);
groupDir.delete();
}
}
}
use of org.bboxdb.storage.StorageManagerException in project bboxdb by jnidzwetzki.
the class TupleStoreManagerRegistry method init.
/**
* Init the service
* @throws BBoxDBException
*/
@Override
public synchronized void init() throws InterruptedException, BBoxDBException {
if (!serviceState.isInNewState()) {
throw new BBoxDBException("Unable to init service is in state: " + serviceState.getState());
}
serviceState.dipatchToStarting();
final List<String> storageDirs = configuration.getStorageDirectories();
if (storageDirs.isEmpty()) {
throw new IllegalArgumentException("Unable to init storage registry without any data directory");
}
// Populate the sstable location map
for (final String directory : storageDirs) {
try {
tupleStoreLocations.putAll(TupleStoreLocator.scanDirectoryForExistingTables(directory));
final int flushThreadsPerStorage = configuration.getMemtableFlushThreadsPerStorage();
final DiskStorage storage = new DiskStorage(this, new File(directory), flushThreadsPerStorage);
storage.init();
storages.put(directory, storage);
} catch (StorageManagerException e) {
final String dataDirString = SSTableHelper.getDataDir(directory);
logger.error("Directory {} does not exists, exiting...", dataDirString);
System.exit(-1);
}
}
serviceState.dispatchToRunning();
}
use of org.bboxdb.storage.StorageManagerException in project bboxdb by jnidzwetzki.
the class TupleStoreManagerRegistry method deleteTable.
/**
* Delete the given table
* @param table
* @throws StorageManagerException
*/
public void deleteTable(final TupleStoreName table, final boolean synchronous) throws StorageManagerException {
if (!table.isValid()) {
throw new StorageManagerException("Invalid tablename: " + table);
}
String storageDirectory = null;
synchronized (this) {
if (managerInstances.containsKey(table)) {
shutdownSStable(table);
}
if (!tupleStoreLocations.containsKey(table)) {
logger.error("Table {} not known during deletion", table.getFullname());
return;
}
storageDirectory = tupleStoreLocations.get(table);
tupleStoreLocations.remove(table);
}
final DiskStorage storage = storages.get(storageDirectory);
logger.info("Deleting table {} synchronous {}", table.getFullname(), synchronous);
if (synchronous) {
TupleStoreManager.deletePersistentTableData(storageDirectory, table);
} else {
storage.getPendingTableDeletions().add(table);
}
}
use of org.bboxdb.storage.StorageManagerException in project bboxdb by jnidzwetzki.
the class TupleStoreManagerRegistry method createTable.
/**
* Create a new table
* @param tupleStoreName
* @param configuration
* @return
* @throws StorageManagerException
*/
public synchronized TupleStoreManager createTable(final TupleStoreName tupleStoreName, final TupleStoreConfiguration tupleStoreConfiguration) throws StorageManagerException {
// Find a new storage directory for the sstable manager
if (tupleStoreLocations.containsKey(tupleStoreName)) {
throw new StorageManagerException("Table already exist");
}
final String location = getLocationLowestUtilizedDataLocation();
tupleStoreLocations.put(tupleStoreName, location);
final DiskStorage storage = storages.get(location);
final TupleStoreManager tupleStoreManager = new TupleStoreManager(storage, tupleStoreName, configuration);
tupleStoreManager.create(tupleStoreConfiguration);
tupleStoreManager.init();
managerInstances.put(tupleStoreName, tupleStoreManager);
return tupleStoreManager;
}
Aggregations