private boolean needsCompact() throws Exception { JournalFile[] dataFiles = getDataFiles(); long totalLiveSize = 0; for (JournalFile file : dataFiles) { totalLiveSize += file.getLiveSize(); } long totalBytes = dataFiles.length * (long) fileSize; long compactMargin = (long) (totalBytes * compactPercentage); boolean needCompact = totalLiveSize < compactMargin && dataFiles.length > compactMinFiles; return needCompact; }
private boolean needsCompact() throws Exception { JournalFile[] dataFiles = getDataFiles(); long totalLiveSize = 0; for (JournalFile file : dataFiles) { totalLiveSize += file.getLiveSize(); } long totalBytes = dataFiles.length * (long) fileSize; long compactMargin = (long) (totalBytes * compactPercentage); boolean needCompact = totalLiveSize < compactMargin && dataFiles.length > compactMinFiles; return needCompact; }
@Override public String debug() throws Exception { reclaimer.scan(getDataFiles()); StringBuilder builder = new StringBuilder(); for (JournalFile file : filesRepository.getDataFiles()) { builder.append("DataFile:" + file + " posCounter = " + file.getPosCount() + " reclaimStatus = " + file.isCanReclaim() + " live size = " + file.getLiveSize() + "\n"); if (file instanceof JournalFileImpl) { builder.append(((JournalFileImpl) file).debug()); } } for (JournalFile file : filesRepository.getFreeFiles()) { builder.append("FreeFile:" + file + "\n"); } if (currentFile != null) { builder.append("CurrentFile:" + currentFile + " posCounter = " + currentFile.getPosCount() + "\n"); if (currentFile instanceof JournalFileImpl) { builder.append(((JournalFileImpl) currentFile).debug()); } } else { builder.append("CurrentFile: No current file at this point!"); } return builder.toString(); }
@Override public String debug() throws Exception { reclaimer.scan(getDataFiles()); StringBuilder builder = new StringBuilder(); for (JournalFile file : filesRepository.getDataFiles()) { builder.append("DataFile:" + file + " posCounter = " + file.getPosCount() + " reclaimStatus = " + file.isCanReclaim() + " live size = " + file.getLiveSize() + "\n"); if (file instanceof JournalFileImpl) { builder.append(((JournalFileImpl) file).debug()); } } for (JournalFile file : filesRepository.getFreeFiles()) { builder.append("FreeFile:" + file + "\n"); } if (currentFile != null) { builder.append("CurrentFile:" + currentFile + " posCounter = " + currentFile.getPosCount() + "\n"); if (currentFile instanceof JournalFileImpl) { builder.append(((JournalFileImpl) currentFile).debug()); } } else { builder.append("CurrentFile: No current file at this point!"); } return builder.toString(); }
Assert.assertEquals(expectedSizes.get(i).intValue(), files[i].getLiveSize()); Assert.assertEquals(expectedSizes.get(i).intValue(), files2[i].getLiveSize()); Assert.assertEquals(0, file.getLiveSize()); Assert.assertEquals(0, file.getLiveSize());
Assert.assertEquals(expectedSizes.get(i).intValue(), files[i].getLiveSize()); Assert.assertEquals(expectedSizes.get(i).intValue(), files2[i].getLiveSize()); Assert.assertEquals(0, file.getLiveSize()); Assert.assertEquals(0, file.getLiveSize());