use of org.apache.hyracks.storage.common.file.BufferedFileHandle in project asterixdb by apache.
the class BufferCache method deleteFile.
@Override
public synchronized void deleteFile(int fileId, boolean flushDirtyPages) throws HyracksDataException {
if (LOGGER.isLoggable(fileOpsLevel)) {
LOGGER.log(fileOpsLevel, "Deleting file: " + fileId + " in cache: " + this);
}
synchronized (fileInfoMap) {
sweepAndFlush(fileId, flushDirtyPages);
BufferedFileHandle fInfo = null;
try {
fInfo = fileInfoMap.get(fileId);
if (fInfo != null && fInfo.getReferenceCount() > 0) {
throw new HyracksDataException("Deleting open file");
}
} finally {
fileMapManager.unregisterFile(fileId);
if (fInfo != null) {
// the pages are not flushed to disk but only invalidated.
synchronized (fInfo) {
if (!fInfo.fileHasBeenDeleted()) {
ioManager.close(fInfo.getFileHandle());
fInfo.markAsDeleted();
}
}
}
}
}
}
use of org.apache.hyracks.storage.common.file.BufferedFileHandle in project asterixdb by apache.
the class BufferCache method purgeHandle.
@Override
public /**
* _ONLY_ call this if you absolutely, positively know this file has no dirty pages in the cache!
* Bypasses the normal lifecycle of a file handle and evicts all references to it immediately.
*/
void purgeHandle(int fileId) throws HyracksDataException {
synchronized (fileInfoMap) {
BufferedFileHandle fh = fileInfoMap.get(fileId);
if (fh != null) {
ioManager.close(fh.getFileHandle());
fileInfoMap.remove(fileId);
fileMapManager.unregisterFile(fileId);
}
}
}
Aggregations