@Override public void init() throws IOException { logVersionRepository = context.getLogVersionRepository(); // Make sure at least a bare bones log file is available before recovery long lastLogVersionUsed = this.logVersionRepository.getCurrentLogVersion(); channel = logFiles.createLogChannelForVersion( lastLogVersionUsed, OpenMode.READ_WRITE, context::getLastCommittedTransactionId ); channel.close(); }
@Override public void start() throws IOException { // Recovery has taken place before this, so the log file has been truncated to last known good tx // Just read header and move to the end long lastLogVersionUsed = logVersionRepository.getCurrentLogVersion(); channel = logFiles.createLogChannelForVersion( lastLogVersionUsed, OpenMode.READ_WRITE, context::getLastCommittedTransactionId ); // Move to the end channel.position( channel.size() ); writer = new PositionAwarePhysicalFlushableChannel( channel ); }
@Override public void registered( NeoStoreDataSource ds ) { StoreId id = ds.getStoreId(); storeLogVersion = ds.getDependencyResolver().resolveDependency( LogVersionRepository.class ).getCurrentLogVersion(); storeCreationDate = id.getCreationTime(); isReadOnly = ds.isReadOnly(); storeId = id.getRandomId(); databaseName = ds.getDatabaseName(); }
private void verifyThatIndexCreationTransactionIsTheFirstOne() throws Exception long version = db.getDependencyResolver().resolveDependency( LogVersionRepository.class ).getCurrentLogVersion(); db.getDependencyResolver().resolveDependency( LogRotation.class ).rotateLogFile(); db.getDependencyResolver().resolveDependency( CheckPointer.class ).forceCheckPoint(
@Test public void buildActiveFilesOnlyContext() throws IOException { PageCache pageCache = pageCacheRule.getPageCache( fileSystem ); TransactionLogFilesContext context = activeFilesBuilder( testDirectory.databaseLayout(), fileSystem, pageCache ).buildContext(); assertEquals( fileSystem, context.getFileSystem() ); assertNotNull( context.getLogEntryReader() ); assertSame( LogFileCreationMonitor.NO_MONITOR, context.getLogFileCreationMonitor() ); assertEquals( Long.MAX_VALUE, context.getRotationThreshold().get() ); assertEquals( 0, context.getLastCommittedTransactionId() ); assertEquals( 0, context.getLogVersionRepository().getCurrentLogVersion() ); }
@Test public void buildDefaultContext() throws IOException { TransactionLogFilesContext context = builder( testDirectory.databaseLayout(), fileSystem ) .withLogVersionRepository( new SimpleLogVersionRepository( 2 ) ) .withTransactionIdStore( new SimpleTransactionIdStore() ).buildContext(); assertEquals( fileSystem, context.getFileSystem() ); assertNotNull( context.getLogEntryReader() ); assertSame( LogFileCreationMonitor.NO_MONITOR, context.getLogFileCreationMonitor() ); assertEquals( ByteUnit.mebiBytes( 250 ), context.getRotationThreshold().get() ); assertEquals( 1, context.getLastCommittedTransactionId() ); assertEquals( 2, context.getLogVersionRepository().getCurrentLogVersion() ); }
@Test public void buildDefaultContextWithDependencies() throws IOException { SimpleLogVersionRepository logVersionRepository = new SimpleLogVersionRepository( 2 ); SimpleTransactionIdStore transactionIdStore = new SimpleTransactionIdStore(); Dependencies dependencies = new Dependencies(); dependencies.satisfyDependency( logVersionRepository ); dependencies.satisfyDependency( transactionIdStore ); TransactionLogFilesContext context = builder( testDirectory.databaseLayout(), fileSystem ).withDependencies( dependencies ).buildContext(); assertEquals( fileSystem, context.getFileSystem() ); assertNotNull( context.getLogEntryReader() ); assertSame( LogFileCreationMonitor.NO_MONITOR, context.getLogFileCreationMonitor() ); assertEquals( ByteUnit.mebiBytes( 250 ), context.getRotationThreshold().get() ); assertEquals( 1, context.getLastCommittedTransactionId() ); assertEquals( 2, context.getLogVersionRepository().getCurrentLogVersion() ); }
@Test public void skipLogFileWithoutHeader() throws IOException { FileSystemAbstraction fs = fileSystemRule.get(); LogFiles logFiles = LogFilesBuilder.builder( directory.databaseLayout(), fs ) .withTransactionIdStore( transactionIdStore ) .withLogVersionRepository( logVersionRepository ).build(); life.add( logFiles ); life.start(); // simulate new file without header presence logVersionRepository.incrementAndGetVersion(); fs.create( logFiles.getLogFileForVersion( logVersionRepository.getCurrentLogVersion() ) ).close(); transactionIdStore.transactionCommitted( 5L, 5L, 5L ); PhysicalLogicalTransactionStore.LogVersionLocator versionLocator = new PhysicalLogicalTransactionStore.LogVersionLocator( 4L ); logFiles.accept( versionLocator ); LogPosition logPosition = versionLocator.getLogPosition(); assertEquals( 1, logPosition.getLogVersion() ); }
@Override public void init() throws IOException { logVersionRepository = context.getLogVersionRepository(); // Make sure at least a bare bones log file is available before recovery long lastLogVersionUsed = this.logVersionRepository.getCurrentLogVersion(); channel = logFiles.createLogChannelForVersion( lastLogVersionUsed, OpenMode.READ_WRITE, context::getLastCommittedTransactionId ); channel.close(); }
@Override public void start() throws IOException { // Recovery has taken place before this, so the log file has been truncated to last known good tx // Just read header and move to the end long lastLogVersionUsed = logVersionRepository.getCurrentLogVersion(); channel = logFiles.createLogChannelForVersion( lastLogVersionUsed, OpenMode.READ_WRITE, context::getLastCommittedTransactionId ); // Move to the end channel.position( channel.size() ); writer = new PositionAwarePhysicalFlushableChannel( channel ); }
@Override public void registered( NeoStoreDataSource ds ) { StoreId id = ds.getStoreId(); storeLogVersion = ds.getDependencyResolver().resolveDependency( LogVersionRepository.class ).getCurrentLogVersion(); storeCreationDate = id.getCreationTime(); isReadOnly = ds.isReadOnly(); storeId = id.getRandomId(); databaseName = ds.getDatabaseName(); }