public LifeSupport createLife() { return new LifeSupport(); }
@Override public void init() { life = new LifeSupport(); dataSources.forEach( life::add ); }
private LifeSupport newLifeSupport() { return new LifeSupport(); }
life = new LifeSupport( );
private void instantiateKernelExtensions() { life = new LifeSupport(); life.start(); labelScanStore = new NativeLabelScanStore( pageCache, databaseLayout, fileSystem, FullStoreChangeStream.EMPTY, false, new Monitors(), RecoveryCleanupWorkCollector.immediate() ); life.add( labelScanStore ); }
private LifeSupport initializeExtensions( Dependencies dependencies ) { LifeSupport extensionsLife = new LifeSupport(); extensionsLife.add( new DatabaseKernelExtensions( new SimpleKernelContext( databaseLayout.databaseDirectory(), databaseInfo, dependencies ), kernelExtensionFactories, dependencies, fail() ) ); indexProviderMap = extensionsLife.add( new DefaultIndexProviderMap( dependencies, config ) ); dependencies.satisfyDependency( indexProviderMap ); extensionsLife.init(); return extensionsLife; }
@Test public void shouldConsultUnsatisfiedDependencyHandlerOnFailingDependencyClasses() { // GIVEN KernelContext context = mock( KernelContext.class ); KernelExtensionFailureStrategy handler = mock( KernelExtensionFailureStrategy.class ); Dependencies dependencies = new Dependencies(); // that hasn't got anything. UninitializableKernelExtensionFactory extensionFactory = new UninitializableKernelExtensionFactory(); GlobalKernelExtensions extensions = new GlobalKernelExtensions( context, iterable( extensionFactory ), dependencies, handler ); // WHEN LifeSupport life = new LifeSupport(); life.add( extensions ); try { life.start(); // THEN verify( handler ).handle( eq( extensionFactory ), any( IllegalArgumentException.class ) ); } finally { life.shutdown(); } }
@Test public void shouldConsultUnsatisfiedDependencyHandlerOnMissingDependencies() { // GIVEN KernelContext context = mock( KernelContext.class ); KernelExtensionFailureStrategy handler = mock( KernelExtensionFailureStrategy.class ); Dependencies dependencies = new Dependencies(); // that hasn't got anything. TestingExtensionFactory extensionFactory = new TestingExtensionFactory(); GlobalKernelExtensions extensions = new GlobalKernelExtensions( context, iterable( extensionFactory ), dependencies, handler ); // WHEN LifeSupport life = new LifeSupport(); life.add( extensions ); try { life.start(); // THEN verify( handler ).handle( eq( extensionFactory ), any( UnsatisfiedDependencyException.class ) ); } finally { life.shutdown(); } }
@Override public void evaluate() throws Throwable { try { if ( autoStart ) { start(); } base.evaluate(); life.shutdown(); } catch ( Throwable failure ) { try { life.shutdown(); } catch ( Throwable suppressed ) { failure.addSuppressed( suppressed ); } throw failure; } finally { life = new LifeSupport( ); } } };
cache.cacheTransactionMetadata( 10, new LogPosition( 2, 130 ), 1, 1, 100, System.currentTimeMillis() ); LifeSupport life = new LifeSupport();
private static KernelTransactions newKernelTransactions( Locks locks, StorageEngine storageEngine, TransactionCommitProcess commitProcess, boolean testKernelTransactions ) { LifeSupport life = new LifeSupport(); life.start(); TransactionIdStore transactionIdStore = mock( TransactionIdStore.class ); when( transactionIdStore.getLastCommittedTransaction() ).thenReturn( new TransactionId( 0, 0, 0 ) ); Tracers tracers = new Tracers( "null", NullLog.getInstance(), new Monitors(), mock( JobScheduler.class ), clock ); StatementLocksFactory statementLocksFactory = new SimpleStatementLocksFactory( locks ); StatementOperationParts statementOperations = mock( StatementOperationParts.class ); KernelTransactions transactions; if ( testKernelTransactions ) { transactions = createTestTransactions( storageEngine, commitProcess, transactionIdStore, tracers, statementLocksFactory, statementOperations, clock, databaseAvailabilityGuard ); } else { transactions = createTransactions( storageEngine, commitProcess, transactionIdStore, tracers, statementLocksFactory, statementOperations, clock, databaseAvailabilityGuard ); } transactions.start(); return transactions; }
private boolean recover( File storeDir, LogFiles logFiles ) { LifeSupport life = new LifeSupport(); RecoveryMonitor monitor = mock( RecoveryMonitor.class ); final AtomicBoolean recoveryRequired = new AtomicBoolean(); try { StorageEngine storageEngine = mock( StorageEngine.class ); final LogEntryReader<ReadableClosablePositionAwareChannel> reader = new VersionAwareLogEntryReader<>(); LogTailScanner tailScanner = getTailScanner( logFiles, reader ); TransactionMetadataCache metadataCache = new TransactionMetadataCache(); LogicalTransactionStore txStore = new PhysicalLogicalTransactionStore( logFiles, metadataCache, reader, monitors, false ); CorruptedLogsTruncator logPruner = new CorruptedLogsTruncator( storeDir, logFiles, fileSystemRule.get() ); life.add( new Recovery( new DefaultRecoveryService( storageEngine, tailScanner, transactionIdStore, txStore, versionRepository, NO_MONITOR ) { @Override public void startRecovery() { recoveryRequired.set( true ); } }, logPruner, monitor, SilentProgressReporter.INSTANCE, false ) ); life.start(); } finally { life.shutdown(); } return recoveryRequired.get(); }
private void start( List<NodeLabelUpdate> existingData, boolean usePersistentStore, boolean readOnly ) { life = new LifeSupport(); monitor = new TrackingMonitor(); store = createLabelScanStore( fileSystemRule.get(), testDirectory.databaseLayout(), asStream( existingData ), usePersistentStore, readOnly, monitor ); life.add( store ); life.start(); assertTrue( monitor.initCalled ); }
@Test public void shouldThrowNoSuchTransactionExceptionIfMetadataNotFound() throws Exception { // GIVEN LogFiles logFiles = mock( LogFiles.class ); TransactionMetadataCache cache = new TransactionMetadataCache(); LifeSupport life = new LifeSupport(); final LogicalTransactionStore txStore = new PhysicalLogicalTransactionStore( logFiles, cache, new VersionAwareLogEntryReader<>(), monitors, true ); try { life.start(); // WHEN try { txStore.getMetadataFor( 10 ); fail( "Should have thrown" ); } catch ( NoSuchTransactionException e ) { // THEN Good } } finally { life.shutdown(); } }
@Test public void shouldOpenCleanStore() throws Exception { // GIVEN TransactionIdStore transactionIdStore = new SimpleTransactionIdStore(); TransactionMetadataCache positionCache = new TransactionMetadataCache(); LifeSupport life = new LifeSupport(); final LogFiles logFiles = LogFilesBuilder.builder( dir.databaseLayout(), fileSystemRule.get() ) .withTransactionIdStore( transactionIdStore ) .withLogVersionRepository( mock( LogVersionRepository.class ) ).build(); life.add( logFiles ); life.add( new BatchingTransactionAppender( logFiles, NO_ROTATION, positionCache, transactionIdStore, BYPASS, DATABASE_HEALTH ) ); try { // WHEN life.start(); } finally { life.shutdown(); } }
long latestCommittedTxWhenStarted = 4545; long timeCommitted = timeStarted + 10; LifeSupport life = new LifeSupport(); final LogFiles logFiles = LogFilesBuilder.builder( dir.databaseLayout(), fileSystemRule.get() ) .withTransactionIdStore( transactionIdStore ) life = new LifeSupport(); life.add( logFiles ); final LogicalTransactionStore store = new PhysicalLogicalTransactionStore( logFiles, positionCache,
@Test public void shouldStartPopulationAgainIfNotCompletedFirstTime() { // given // label scan store init but no start LifeSupport life = new LifeSupport(); TrackingMonitor monitor = new TrackingMonitor(); life.add( createLabelScanStore( fileSystemRule.get(), testDirectory.databaseLayout(), EMPTY, true, false, monitor ) ); life.init(); assertTrue( monitor.noIndexCalled ); monitor.reset(); life.shutdown(); // when // starting label scan store again life = new LifeSupport(); life.add( createLabelScanStore( fileSystemRule.get(), testDirectory.databaseLayout(), EMPTY, true, false, monitor ) ); life.init(); // then // label scan store should recognize it still needs to be rebuilt assertTrue( monitor.corruptedIndex ); life.start(); assertTrue( monitor.rebuildingCalled ); assertTrue( monitor.rebuiltCalled ); life.shutdown(); }
@Test public void shouldRestartPopulationIfIndexFileWasNeverFullyInitialized() throws IOException { // given File labelScanStoreFile = NativeLabelScanStore.getLabelScanStoreFile( testDirectory.databaseLayout() ); fileSystemRule.create( labelScanStoreFile ).close(); TrackingMonitor monitor = new TrackingMonitor(); LifeSupport life = new LifeSupport(); // when life.add( createLabelScanStore( fileSystemRule.get(), testDirectory.databaseLayout(), EMPTY, true, false, monitor ) ); life.start(); // then assertTrue( monitor.corruptedIndex ); assertTrue( monitor.rebuildingCalled ); life.shutdown(); } }
long latestCommittedTxWhenStarted = 4545; long timeCommitted = timeStarted + 10; LifeSupport life = new LifeSupport(); final LogFiles logFiles = LogFilesBuilder.builder( dir.databaseLayout(), fileSystemRule.get() ) .withTransactionIdStore( transactionIdStore )
@Before public void setUp() throws Exception life = new LifeSupport(); PageCache pageCache = storage.pageCache(); DatabaseLayout databaseLayout = storage.directory().databaseLayout();