public ReadOnlyTransactionIdStore( PageCache pageCache, DatabaseLayout databaseLayout ) throws IOException { long id = 0; long checksum = 0; long logVersion = 0; long byteOffset = 0; if ( NeoStores.isStorePresent( pageCache, databaseLayout ) ) { File neoStore = databaseLayout.metadataStore(); id = getRecord( pageCache, neoStore, Position.LAST_TRANSACTION_ID ); checksum = getRecord( pageCache, neoStore, Position.LAST_TRANSACTION_CHECKSUM ); logVersion = getRecord( pageCache, neoStore, Position.LAST_CLOSED_TRANSACTION_LOG_VERSION ); byteOffset = getRecord( pageCache, neoStore, Position.LAST_CLOSED_TRANSACTION_LOG_BYTE_OFFSET ); } this.transactionId = id; this.transactionChecksum = checksum; this.logVersion = logVersion; this.byteOffset = byteOffset; }
public boolean isRecoveryRequiredAt( DatabaseLayout databaseLayout ) throws IOException { // We need config to determine where the logical log files are if ( !NeoStores.isStorePresent( pageCache, databaseLayout ) ) { return false; } LogEntryReader<ReadableClosablePositionAwareChannel> reader = new VersionAwareLogEntryReader<>(); LogFiles logFiles = LogFilesBuilder.activeFilesBuilder( databaseLayout, fs, pageCache ) .withConfig( config ) .withLogEntryReader( reader ).build(); LogTailScanner tailScanner = new LogTailScanner( logFiles, reader, monitors ); return new RecoveryStartInformationProvider( tailScanner, NO_MONITOR ).get().isRecoveryRequired(); }
@Test public void isPresentFalseAfterCreatingAllButLastStoreType() throws Exception { // given FileSystemAbstraction fileSystem = fs.get(); fileSystem.deleteRecursively( databaseLayout.databaseDirectory() ); DefaultIdGeneratorFactory idFactory = new DefaultIdGeneratorFactory( fileSystem ); StoreFactory factory = new StoreFactory( databaseLayout, Config.defaults(), idFactory, pageCache, fileSystem, LOG_PROVIDER, EmptyVersionContextSupplier.EMPTY ); StoreType[] allStoreTypes = StoreType.values(); StoreType[] allButLastStoreTypes = Arrays.copyOf( allStoreTypes, allStoreTypes.length - 1 ); // when try ( NeoStores ignore = factory.openNeoStores( true, allButLastStoreTypes ) ) { // then assertFalse( NeoStores.isStorePresent( pageCache, databaseLayout ) ); } }
@Test public void isPresentAfterCreatingAllStores() throws Exception { // given FileSystemAbstraction fileSystem = fs.get(); fileSystem.deleteRecursively( databaseLayout.databaseDirectory() ); DefaultIdGeneratorFactory idFactory = new DefaultIdGeneratorFactory( fileSystem ); StoreFactory factory = new StoreFactory( databaseLayout, Config.defaults(), idFactory, pageCache, fileSystem, LOG_PROVIDER, EmptyVersionContextSupplier.EMPTY ); // when try ( NeoStores ignore = factory.openAllNeoStores( true ) ) { // then assertTrue( NeoStores.isStorePresent( pageCache, databaseLayout ) ); } }
public ReadOnlyTransactionIdStore( PageCache pageCache, DatabaseLayout databaseLayout ) throws IOException { long id = 0; long checksum = 0; long logVersion = 0; long byteOffset = 0; if ( NeoStores.isStorePresent( pageCache, databaseLayout ) ) { File neoStore = databaseLayout.metadataStore(); id = getRecord( pageCache, neoStore, Position.LAST_TRANSACTION_ID ); checksum = getRecord( pageCache, neoStore, Position.LAST_TRANSACTION_CHECKSUM ); logVersion = getRecord( pageCache, neoStore, Position.LAST_CLOSED_TRANSACTION_LOG_VERSION ); byteOffset = getRecord( pageCache, neoStore, Position.LAST_CLOSED_TRANSACTION_LOG_BYTE_OFFSET ); } this.transactionId = id; this.transactionChecksum = checksum; this.logVersion = logVersion; this.byteOffset = byteOffset; }
public boolean isRecoveryRequiredAt( DatabaseLayout databaseLayout ) throws IOException { // We need config to determine where the logical log files are if ( !NeoStores.isStorePresent( pageCache, databaseLayout ) ) { return false; } LogEntryReader<ReadableClosablePositionAwareChannel> reader = new VersionAwareLogEntryReader<>(); LogFiles logFiles = LogFilesBuilder.activeFilesBuilder( databaseLayout, fs, pageCache ) .withConfig( config ) .withLogEntryReader( reader ).build(); LogTailScanner tailScanner = new LogTailScanner( logFiles, reader, monitors ); return new RecoveryStartInformationProvider( tailScanner, NO_MONITOR ).get().isRecoveryRequired(); }