use of org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles in project neo4j by neo4j.
the class NeoStoreDataSourceTest method noLogs.
private PhysicalLogFiles noLogs() {
PhysicalLogFiles files = mock(PhysicalLogFiles.class);
when(files.getLowestLogVersion()).thenReturn(-1L);
return files;
}
use of org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles in project neo4j by neo4j.
the class CoreBootstrapper method appendNullTransactionLogEntryToSetRaftIndexToMinusOne.
private void appendNullTransactionLogEntryToSetRaftIndexToMinusOne() throws IOException {
PhysicalLogFiles logFiles = new PhysicalLogFiles(storeDir, fs);
ReadOnlyLogVersionRepository logVersionRepository = new ReadOnlyLogVersionRepository(pageCache, storeDir);
ReadOnlyTransactionIdStore readOnlyTransactionIdStore = new ReadOnlyTransactionIdStore(pageCache, storeDir);
PhysicalLogFile logFile = new PhysicalLogFile(fs, logFiles, Long.MAX_VALUE, /*don't rotate*/
() -> readOnlyTransactionIdStore.getLastClosedTransactionId() - 1, logVersionRepository, new Monitors().newMonitor(PhysicalLogFile.Monitor.class), new LogHeaderCache(10));
long dummyTransactionId;
try (Lifespan lifespan = new Lifespan(logFile)) {
FlushableChannel channel = logFile.getWriter();
TransactionLogWriter writer = new TransactionLogWriter(new LogEntryWriter(channel));
long lastCommittedTransactionId = readOnlyTransactionIdStore.getLastCommittedTransactionId();
PhysicalTransactionRepresentation tx = new PhysicalTransactionRepresentation(Collections.emptyList());
byte[] txHeaderBytes = LogIndexTxHeaderEncoding.encodeLogIndexAsTxHeader(-1);
tx.setHeader(txHeaderBytes, -1, -1, -1, lastCommittedTransactionId, -1, -1);
dummyTransactionId = lastCommittedTransactionId + 1;
writer.append(tx, dummyTransactionId);
channel.prepareForFlush().flush();
}
File neoStoreFile = new File(storeDir, MetaDataStore.DEFAULT_NAME);
MetaDataStore.setRecord(pageCache, neoStoreFile, LAST_TRANSACTION_ID, dummyTransactionId);
}
use of org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles in project neo4j by neo4j.
the class Runner method createPhysicalLogFile.
private PhysicalLogFile createPhysicalLogFile(TransactionIdStore transactionIdStore, LogHeaderCache logHeaderCache, FileSystemAbstraction fileSystemAbstraction) {
PhysicalLogFiles logFiles = new PhysicalLogFiles(workingDirectory, fileSystemAbstraction);
long rotateAtSize = Settings.BYTES.apply(GraphDatabaseSettings.logical_log_rotation_threshold.getDefaultValue());
DeadSimpleLogVersionRepository logVersionRepository = new DeadSimpleLogVersionRepository(0);
return new PhysicalLogFile(fileSystemAbstraction, logFiles, rotateAtSize, transactionIdStore::getLastCommittedTransactionId, logVersionRepository, PhysicalLogFile.NO_MONITOR, logHeaderCache);
}
use of org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles in project neo4j by neo4j.
the class LogTestUtils method filterNeostoreLogicalLog.
public static File[] filterNeostoreLogicalLog(FileSystemAbstraction fileSystem, String storeDir, LogHook<LogEntry> filter) throws IOException {
PhysicalLogFiles logFiles = new PhysicalLogFiles(new File(storeDir), fileSystem);
final List<File> files = new ArrayList<>();
logFiles.accept((file, logVersion) -> files.add(file));
for (File file : files) {
File filteredLog = filterNeostoreLogicalLog(fileSystem, file, filter);
replace(filteredLog, file);
}
return files.toArray(new File[files.size()]);
}
use of org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles in project neo4j by neo4j.
the class MigrationTestUtils method removeCheckPointFromTxLog.
public static void removeCheckPointFromTxLog(FileSystemAbstraction fileSystem, File workingDirectory) throws IOException {
PhysicalLogFiles logFiles = new PhysicalLogFiles(workingDirectory, fileSystem);
LogEntryReader<ReadableClosablePositionAwareChannel> logEntryReader = new VersionAwareLogEntryReader<>();
LatestCheckPointFinder finder = new LatestCheckPointFinder(logFiles, fileSystem, logEntryReader);
LatestCheckPointFinder.LatestCheckPoint latestCheckPoint = finder.find(logFiles.getHighestLogVersion());
if (latestCheckPoint.commitsAfterCheckPoint) {
// done already
return;
}
// let's assume there is at least a checkpoint
assertNotNull(latestCheckPoint.checkPoint);
LogPosition logPosition = latestCheckPoint.checkPoint.getLogPosition();
File logFile = logFiles.getLogFileForVersion(logPosition.getLogVersion());
fileSystem.truncate(logFile, logPosition.getByteOffset());
}
Aggregations