use of org.bboxdb.storage.StorageManagerException in project bboxdb by jnidzwetzki.
the class SSTableServiceRunnable method processTupleStores.
/**
* Process the tuple stores
*
* @param storageRegistry
* @param tupleStores
* @throws InterruptedException
*/
private void processTupleStores(final TupleStoreManagerRegistry storageRegistry, final List<TupleStoreName> tupleStores) throws InterruptedException {
for (final TupleStoreName tupleStoreName : tupleStores) {
try {
logger.debug("Running compact for: {}", tupleStoreName);
final TupleStoreManager tupleStoreManager = storageRegistry.getTupleStoreManager(tupleStoreName);
if (tupleStoreManager.getSstableManagerState() == TupleStoreManagerState.READ_ONLY) {
logger.debug("Skipping compact for read only sstable manager: {}", tupleStoreName);
continue;
}
if (!CompactorHelper.isRegionActive(tupleStoreName)) {
logger.info("Skipping compact run, because region is not active {}", tupleStoreName);
continue;
}
final List<SSTableFacade> facades = getAllTupleStores(tupleStoreManager);
final MergeTask mergeTask = mergeStrategy.getMergeTask(facades);
executeCompactTask(mergeTask, tupleStoreManager);
testForRegionOverflow(tupleStoreManager);
} catch (StorageManagerException | BBoxDBException e) {
logger.error("Error while merging tables", e);
}
}
}
use of org.bboxdb.storage.StorageManagerException in project bboxdb by jnidzwetzki.
the class SSTableServiceRunnable method registerNewFacadeAndDeleteOldInstances.
/**
* Register a new sstable facade and delete the old ones
* @param oldFacades
* @param directory
* @param name
* @param tablenumber
* @throws StorageManagerException
*/
private void registerNewFacadeAndDeleteOldInstances(final TupleStoreManager sstableManager, final List<SSTableFacade> oldFacades, final List<SSTableWriter> newTableWriter) throws StorageManagerException {
final List<SSTableFacade> newFacades = new ArrayList<>();
// Open new facades
openFacades(newTableWriter, newFacades);
// Manager has switched to read only
if (sstableManager.getSstableManagerState() == TupleStoreManagerState.READ_ONLY) {
logger.info("Manager is in read only mode, cancel compact run");
handleCompactException(newFacades);
return;
}
try {
for (final SSTableFacade facade : newFacades) {
facade.init();
}
// Switch facades in registry
sstableManager.replaceCompactedSStables(newFacades, oldFacades);
// Schedule facades for deletion
oldFacades.forEach(f -> f.deleteOnClose());
} catch (BBoxDBException | RejectedException e) {
handleCompactException(newFacades);
throw new StorageManagerException(e);
} catch (InterruptedException e) {
handleCompactException(newFacades);
Thread.currentThread().interrupt();
throw new StorageManagerException(e);
}
}
use of org.bboxdb.storage.StorageManagerException in project bboxdb by jnidzwetzki.
the class RTreeMemoryReader method readFromFile.
@Override
public void readFromFile(final RandomAccessFile randomAccessFile) throws StorageManagerException, InterruptedException {
assert (rootNode == null);
try {
// Validate the magic bytes
validateStream(randomAccessFile);
maxNodeSize = DataEncoderHelper.readIntFromDataInput(randomAccessFile);
readDirectoryNode(randomAccessFile, null);
while (!childToReadQueue.isEmpty()) {
final Entry<RTreeDirectoryNode, Integer> element = childToReadQueue.remove();
readDirectoryNode(randomAccessFile, element.getKey());
}
} catch (IOException e) {
throw new StorageManagerException(e);
}
}
use of org.bboxdb.storage.StorageManagerException in project bboxdb by jnidzwetzki.
the class RTreeSerializer method writeToStream.
/**
* Serialize the tree to the file
* @param randomAccessFile
* @throws StorageManagerException
*/
public void writeToStream(final RandomAccessFile randomAccessFile) throws StorageManagerException {
nodesQueue.clear();
try {
// Write the magic bytes
randomAccessFile.write(SSTableConst.MAGIC_BYTES_SPATIAL_RTREE_INDEX);
// Write the tree configuration
final ByteBuffer nodeSizeBytes = DataEncoderHelper.intToByteBuffer(maxNodeSize);
randomAccessFile.write(nodeSizeBytes.array());
nodesQueue.push(rootNode);
while (!nodesQueue.isEmpty()) {
final RTreeDirectoryNode node = nodesQueue.pop();
handleNewNode(randomAccessFile, node);
}
updateIndexNodePointer(randomAccessFile);
} catch (IOException e) {
throw new StorageManagerException(e);
}
}
use of org.bboxdb.storage.StorageManagerException in project bboxdb by jnidzwetzki.
the class RTreeMMFReader method readFromFile.
@Override
public void readFromFile(final RandomAccessFile randomAccessFile) throws StorageManagerException, InterruptedException {
try {
validateStream(randomAccessFile);
maxNodeSize = DataEncoderHelper.readIntFromDataInput(randomAccessFile);
firstNodePos = (int) randomAccessFile.getFilePointer();
fileChannel = randomAccessFile.getChannel();
final long size = fileChannel.size();
memory = fileChannel.map(FileChannel.MapMode.READ_ONLY, 0, size);
memory.order(Const.APPLICATION_BYTE_ORDER);
} catch (IOException e) {
throw new StorageManagerException(e);
}
}
Aggregations