@Override public int calculateBlockStart(int position) throws Exception { return this.sequentialFile.calculateBlockStart(position); }
@Override public int calculateBlockStart(int position) throws Exception { return this.sequentialFile.calculateBlockStart(position); }
/** * @param size * @return * @throws Exception */ protected JournalFile switchFileIfNecessary(int size) throws Exception { // We take into account the fileID used on the Header if (size > fileSize - currentFile.getFile().calculateBlockStart(JournalImpl.SIZE_HEADER)) { throw new IllegalArgumentException("Record is too large to store " + size); } try { if (!currentFile.getFile().fits(size)) { moveNextFile(true); // The same check needs to be done at the new file also if (!currentFile.getFile().fits(size)) { // Sanity check, this should never happen throw new IllegalStateException("Invalid logic on buffer allocation"); } } return currentFile; } catch (Throwable e) { criticalIO(e); return null; // this will never happen, the method will call throw } }
/** * @param size * @return * @throws Exception */ protected JournalFile switchFileIfNecessary(int size) throws Exception { // We take into account the fileID used on the Header if (size > fileSize - currentFile.getFile().calculateBlockStart(JournalImpl.SIZE_HEADER)) { throw new IllegalArgumentException("Record is too large to store " + size); } try { if (!currentFile.getFile().fits(size)) { moveNextFile(true); // The same check needs to be done at the new file also if (!currentFile.getFile().fits(size)) { // Sanity check, this should never happen throw new IllegalStateException("Invalid logic on buffer allocation"); } } return currentFile; } catch (Throwable e) { criticalIO(e); return null; // this will never happen, the method will call throw } }
public void openFile(final JournalFile file, final boolean multiAIO) throws Exception { if (multiAIO) { file.getFile().open(); } else { file.getFile().open(1, false); } file.getFile().position(file.getFile().calculateBlockStart(JournalImpl.SIZE_HEADER)); }
public void openFile(final JournalFile file, final boolean multiAIO) throws Exception { if (multiAIO) { file.getFile().open(); } else { file.getFile().open(1, false); } file.getFile().position(file.getFile().calculateBlockStart(JournalImpl.SIZE_HEADER)); }
/** * @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; }