/** * You need to guarantee lock.acquire() before calling this method! */ protected void moveNextFile(final boolean scheduleReclaim) throws Exception { filesRepository.closeFile(currentFile); currentFile = filesRepository.openFile(); if (scheduleReclaim) { scheduleReclaim(); } if (logger.isTraceEnabled()) { logger.trace("Moving next file " + currentFile); } fileFactory.activateBuffer(currentFile.getFile()); }
/** * You need to guarantee lock.acquire() before calling this method! */ protected void moveNextFile(final boolean scheduleReclaim) throws Exception { filesRepository.closeFile(currentFile); currentFile = filesRepository.openFile(); if (scheduleReclaim) { scheduleReclaim(); } if (logger.isTraceEnabled()) { logger.trace("Moving next file " + currentFile); } fileFactory.activateBuffer(currentFile.getFile()); }
public JournalFile openFileCMP() throws Exception { JournalFile file = openFile(); SequentialFile sequentialFile = file.getFile(); sequentialFile.close(); sequentialFile.renameTo(sequentialFile.getFileName() + ".cmp"); return file; }
public JournalFile openFileCMP() throws Exception { JournalFile file = openFile(); SequentialFile sequentialFile = file.getFile(); sequentialFile.close(); sequentialFile.renameTo(sequentialFile.getFileName() + ".cmp"); return file; }
/** * This will get a File from freeFile without initializing it * * @return uninitialized JournalFile * @throws Exception * @see JournalImpl#initFileHeader(SequentialFileFactory, SequentialFile, int, long) */ private JournalFile takeFile(final boolean keepOpened, final boolean multiAIO, final boolean initFile, final boolean tmpCompactExtension) throws Exception { JournalFile nextFile = null; nextFile = freeFiles.poll(); if (nextFile != null) { freeFilesCount.getAndDecrement(); } if (nextFile == null) { nextFile = createFile(keepOpened, multiAIO, initFile, tmpCompactExtension, -1); } else { if (tmpCompactExtension) { SequentialFile sequentialFile = nextFile.getFile(); sequentialFile.renameTo(sequentialFile.getFileName() + ".cmp"); } if (keepOpened) { openFile(nextFile, multiAIO); } } return nextFile; }
/** * This will get a File from freeFile without initializing it * * @return uninitialized JournalFile * @throws Exception * @see JournalImpl#initFileHeader(SequentialFileFactory, SequentialFile, int, long) */ private JournalFile takeFile(final boolean keepOpened, final boolean multiAIO, final boolean initFile, final boolean tmpCompactExtension) throws Exception { JournalFile nextFile = null; nextFile = freeFiles.poll(); if (nextFile != null) { freeFilesCount.getAndDecrement(); } if (nextFile == null) { nextFile = createFile(keepOpened, multiAIO, initFile, tmpCompactExtension, -1); } else { if (tmpCompactExtension) { SequentialFile sequentialFile = nextFile.getFile(); sequentialFile.renameTo(sequentialFile.getFileName() + ".cmp"); } if (keepOpened) { openFile(nextFile, multiAIO); } } return nextFile; }
LinkedList<Integer> values = new LinkedList<>(); for (int i = 0; i < 5000; i++) { file = repository.openFile(); Assert.assertNotNull(file); values.add(file.getRecordID());
/** * @param lastDataPos * @return * @throws Exception */ protected JournalFile setUpCurrentFile(int lastDataPos) throws Exception { // Create any more files we need filesRepository.ensureMinFiles(); // The current file is the last one that has data currentFile = filesRepository.pollLastDataFile(); if (currentFile != null) { if (!currentFile.getFile().isOpen()) currentFile.getFile().open(); currentFile.getFile().position(currentFile.getFile().calculateBlockStart(lastDataPos)); } else { currentFile = filesRepository.getFreeFile(); filesRepository.openFile(currentFile, true); } fileFactory.activateBuffer(currentFile.getFile()); filesRepository.pushOpenedFile(); return currentFile; }
/** * @param lastDataPos * @return * @throws Exception */ protected JournalFile setUpCurrentFile(int lastDataPos) throws Exception { // Create any more files we need filesRepository.ensureMinFiles(); // The current file is the last one that has data currentFile = filesRepository.pollLastDataFile(); if (currentFile != null) { if (!currentFile.getFile().isOpen()) currentFile.getFile().open(); currentFile.getFile().position(currentFile.getFile().calculateBlockStart(lastDataPos)); } else { currentFile = filesRepository.getFreeFile(); filesRepository.openFile(currentFile, true); } fileFactory.activateBuffer(currentFile.getFile()); filesRepository.pushOpenedFile(); return currentFile; }