public void calculateNextfileID(final List<JournalFile> files) { for (JournalFile file : files) { final long fileIdFromFile = file.getFileID(); final long fileIdFromName = getFileNameID(file.getFile().getFileName()); // The compactor could create a fileName but use a previously assigned ID. // Because of that we need to take both parts into account setNextFileID(Math.max(fileIdFromName, fileIdFromFile)); } }
public void calculateNextfileID(final List<JournalFile> files) { for (JournalFile file : files) { final long fileIdFromFile = file.getFileID(); final long fileIdFromName = getFileNameID(file.getFile().getFileName()); // The compactor could create a fileName but use a previously assigned ID. // Because of that we need to take both parts into account setNextFileID(Math.max(fileIdFromName, fileIdFromFile)); } }
private void criticalIO(Throwable e) throws Exception { if (criticalErrorListener != null) { criticalErrorListener.onIOException(e, e.getMessage(), currentFile == null ? null : currentFile.getFile()); } if (e instanceof Exception) { throw (Exception) e; } else if (e instanceof IllegalStateException) { throw (IllegalStateException) e; } else { IOException ioex = new IOException(); ioex.initCause(e); throw ioex; } }
private void criticalIO(Throwable e) throws Exception { if (criticalErrorListener != null) { criticalErrorListener.onIOException(e, e.getMessage(), currentFile == null ? null : currentFile.getFile()); } if (e instanceof Exception) { throw (Exception) e; } else if (e instanceof IllegalStateException) { throw (IllegalStateException) e; } else { IOException ioex = new IOException(); ioex.initCause(e); throw ioex; } }
@Override public String toString() { StringBuilder buffer = new StringBuilder(); buffer.append("JournalRecord(add=" + addFile.getFile().getFileName()); if (updateFiles != null) { for (Pair<JournalFile, Integer> update : updateFiles) { buffer.append(", update=" + update.getA().getFile().getFileName()); } } buffer.append(")"); return buffer.toString(); } }
@Override public String toString() { StringBuilder buffer = new StringBuilder(); buffer.append("JournalRecord(add=" + addFile.getFile().getFileName()); if (updateFiles != null) { for (Pair<JournalFile, Integer> update : updateFiles) { buffer.append(", update=" + update.getA().getFile().getFileName()); } } buffer.append(")"); return buffer.toString(); } }
public JournalSyncFile(JournalFile jFile) throws Exception { SequentialFile seqFile = jFile.getFile(); file = seqFile.getJavaFile(); seqFile.close(); }
public void clear() throws Exception { dataFiles.clear(); freeFiles.clear(); freeFilesCount.set(0); for (JournalFile file : openedFiles) { try { file.getFile().close(); } catch (Exception e) { ActiveMQJournalLogger.LOGGER.errorClosingFile(e); } } openedFiles.clear(); }
public void clear() throws Exception { dataFiles.clear(); freeFiles.clear(); freeFilesCount.set(0); for (JournalFile file : openedFiles) { try { file.getFile().close(); } catch (Exception e) { ActiveMQJournalLogger.LOGGER.errorClosingFile(e); } } openedFiles.clear(); }
/** * 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; }
public void closeFile(final JournalFile file) throws Exception { fileFactory.deactivateBuffer(); file.getFile().close(); if (!dataFiles.contains(file)) { // This is not a retry from openFile // If you don't check this then retries keep adding the same file into // dataFiles list and the compactor then re-adds multiple copies of the // same file into freeFiles. // The consequence of that is that you can end up with the same file // twice in a row in the list of openedFiles // The consequence of that is that JournalImpl::switchFileIfNecessary // will throw throw new IllegalStateException("Invalid logic on buffer allocation") // because the file will be checked effectively twice and the buffer will // not fit in it dataFiles.add(file); } }
private JournalFile reinitializeFile(final JournalFile file) throws Exception { long newFileID = generateFileID(); SequentialFile sf = file.getFile(); sf.open(1, false); int position = JournalImpl.initFileHeader(fileFactory, sf, userVersion, newFileID); JournalFile jf = new JournalFileImpl(sf, newFileID, JournalImpl.FORMAT_VERSION); sf.position(position); sf.close(); return jf; }
private JournalFile reinitializeFile(final JournalFile file) throws Exception { long newFileID = generateFileID(); SequentialFile sf = file.getFile(); sf.open(1, false); int position = JournalImpl.initFileHeader(fileFactory, sf, userVersion, newFileID); JournalFile jf = new JournalFileImpl(sf, newFileID, JournalImpl.FORMAT_VERSION); sf.position(position); sf.close(); return jf; }