Search in sources :

Example 1 with RemoveBlockType

use of jetbrains.exodus.io.RemoveBlockType in project xodus by JetBrains.

the class GarbageCollector method deletePendingFiles.

void deletePendingFiles() {
    cleaner.checkThread();
    final LongArrayList filesToDelete = new LongArrayList();
    Long fileAddress;
    while ((fileAddress = deletionQueue.poll()) != null) {
        if (pendingFilesToDelete.remove(fileAddress)) {
            filesToDelete.add(fileAddress);
        }
    }
    if (!filesToDelete.isEmpty()) {
        // force flush and fsync in order to fix XD-249
        // in order to avoid data loss, it's necessary to make sure that any GC transaction is flushed
        // to underlying storage device before any file is deleted
        env.flushAndSync();
        RemoveBlockType rbt = ec.getGcRenameFiles() ? RemoveBlockType.Rename : RemoveBlockType.Delete;
        env.removeFiles(filesToDelete.toArray(), rbt);
    }
}
Also used : LongArrayList(jetbrains.exodus.core.dataStructures.LongArrayList) RemoveBlockType(jetbrains.exodus.io.RemoveBlockType)

Aggregations

LongArrayList (jetbrains.exodus.core.dataStructures.LongArrayList)1 RemoveBlockType (jetbrains.exodus.io.RemoveBlockType)1