private LogFiles createLogFiles( TransactionIdStore transactionIdStore, FileSystemAbstraction fileSystemAbstraction ) throws IOException { SimpleLogVersionRepository logVersionRepository = new SimpleLogVersionRepository(); return LogFilesBuilder.builder( databaseLayout, fileSystemAbstraction ) .withTransactionIdStore(transactionIdStore) .withLogVersionRepository( logVersionRepository ) .build(); }
@Test( expected = NullPointerException.class ) public void failToBuildFullContextWithoutTransactionIdStore() throws IOException { builder( testDirectory.databaseLayout(), fileSystem ).withLogVersionRepository( new SimpleLogVersionRepository( 2 ) ).buildContext(); }
private LogFiles buildDefaultLogFiles() throws IOException { return LogFilesBuilder.builder( directory.databaseLayout(), fileSystemRule ) .withLogVersionRepository( new SimpleLogVersionRepository() ) .withTransactionIdStore( new SimpleTransactionIdStore() ).build(); }
@Before public void setUp() throws IOException { logVersionRepository = new SimpleLogVersionRepository(); logFiles = LogFilesBuilder .activeFilesBuilder( testDirectory.databaseLayout(), fsRule, pageCacheRule.getPageCache( fsRule ) ) .withLogVersionRepository( logVersionRepository ) .build(); tailScanner = new LogTailScanner( logFiles, reader, monitors ); }
private LogFiles createLogFiles() throws IOException { return LogFilesBuilder .builder( testDirectory.databaseLayout(), fileSystemRule ) .withLogFileName( filename ) .withTransactionIdStore( new SimpleTransactionIdStore() ) .withLogVersionRepository( new SimpleLogVersionRepository() ) .build(); }
LogVersionRepository logVersionRepository = new SimpleLogVersionRepository(); LogFiles logFiles = LogFilesBuilder.builder( directory.databaseLayout(), fileSystemRule.get() ) .withLogVersionRepository( logVersionRepository )
@Test public void buildContextWithCustomAbsoluteLogFilesLocations() throws Throwable { File customLogDirectory = testDirectory.directory( "absoluteCustomLogDirectory" ); Config customLogLocationConfig = Config.defaults( logical_logs_location, customLogDirectory.getAbsolutePath() ); LogFiles logFiles = builder( testDirectory.databaseLayout(), fileSystem ).withConfig( customLogLocationConfig ) .withLogVersionRepository( new SimpleLogVersionRepository() ) .withTransactionIdStore( new SimpleTransactionIdStore() ).build(); logFiles.init(); logFiles.start(); assertEquals( customLogDirectory, logFiles.getHighestLogFile().getParentFile() ); logFiles.shutdown(); }
@Before public void setUp() throws IOException { LogVersionRepository logVersionRepository = new SimpleLogVersionRepository(); SimpleTransactionIdStore transactionIdStore = new SimpleTransactionIdStore(); LogFiles logFiles = LogFilesBuilder.builder( directory.databaseLayout(), fs ) .withLogVersionRepository( logVersionRepository ) .withTransactionIdStore( transactionIdStore ) .build(); life.add( logFiles ); logFile = logFiles.getLogFile(); }
@Before public void setUp() throws Exception { databaseDirectory = testDirectory.databaseDir(); SimpleLogVersionRepository logVersionRepository = new SimpleLogVersionRepository(); SimpleTransactionIdStore transactionIdStore = new SimpleTransactionIdStore(); logFiles = LogFilesBuilder.logFilesBasedOnlyBuilder( databaseDirectory, fileSystemRule ) .withRotationThreshold( LogHeader.LOG_HEADER_SIZE + 9L ) .withLogVersionRepository( logVersionRepository ) .withTransactionIdStore( transactionIdStore ).build(); life.add( logFiles ); logPruner = new CorruptedLogsTruncator( databaseDirectory, logFiles, fileSystemRule ); }
@Test public void buildContextWithCustomLogFilesLocations() throws Throwable { String customLogLocation = "customLogLocation"; Config customLogLocationConfig = Config.defaults( logical_logs_location, customLogLocation ); DatabaseLayout databaseLayout = testDirectory.databaseLayout(); LogFiles logFiles = builder( databaseLayout, fileSystem ).withConfig( customLogLocationConfig ) .withLogVersionRepository( new SimpleLogVersionRepository() ) .withTransactionIdStore( new SimpleTransactionIdStore() ).build(); logFiles.init(); logFiles.start(); assertEquals( databaseLayout.file( customLogLocation ), logFiles.getHighestLogFile().getParentFile() ); logFiles.shutdown(); }
@Test public void pruningStrategyShouldBeDynamic() throws IOException { CheckPointer checkPointer = getInstanceFromDb( CheckPointer.class ); Config config = getInstanceFromDb( Config.class ); FileSystemAbstraction fs = getInstanceFromDb( FileSystemAbstraction.class ); LogFiles logFiles = LogFilesBuilder.builder( db.databaseLayout(), fs ) .withLogVersionRepository( new SimpleLogVersionRepository() ) .withLastCommittedTransactionIdSupplier( () -> 1 ) .withTransactionIdStore( new SimpleTransactionIdStore() ).build(); // Force transaction log rotation writeTransactionsAndRotateTwice(); // Checkpoint to make sure strategy is evaluated checkPointer.forceCheckPoint( triggerInfo ); // Make sure file is still there since we have disable pruning assertThat( countTransactionLogs( logFiles ), is( 3 ) ); // Change pruning to true config.updateDynamicSetting( keep_logical_logs.name(), "false", "test" ); // Checkpoint to make sure strategy is evaluated checkPointer.forceCheckPoint( triggerInfo ); // Make sure file is removed assertThat( countTransactionLogs( logFiles ), is( 2 ) ); }
@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() ); }