@Test public void loadSingleAvailableFactory() { Locks locks = mock( Locks.class ); StatementLocksFactory factory = mock( StatementLocksFactory.class ); StatementLocksFactorySelector loader = newLoader( locks, factory ); StatementLocksFactory loadedFactory = loader.select(); assertSame( factory, loadedFactory ); verify( factory ).initialize( same( locks ), any( Config.class ) ); }
public StatementLocksFactory select() { StatementLocksFactory statementLocksFactory; String serviceName = StatementLocksFactory.class.getSimpleName(); List<StatementLocksFactory> factories = serviceLoadFactories(); if ( factories.isEmpty() ) { statementLocksFactory = new SimpleStatementLocksFactory(); log.info( "No services implementing " + serviceName + " found. " + "Using " + SimpleStatementLocksFactory.class.getSimpleName() ); } else if ( factories.size() == 1 ) { statementLocksFactory = factories.get( 0 ); log.info( "Found single implementation of " + serviceName + ". Namely " + statementLocksFactory.getClass().getSimpleName() ); } else { throw new IllegalStateException( "Found more than one implementation of " + serviceName + ": " + factories ); } statementLocksFactory.initialize( locks, config ); return statementLocksFactory; }
@Override protected StatementLocksFactory createStatementLocksFactory( Locks locks, Config config, LogService logService ) { return new StatementLocksFactorySelector( locks, config, logService ).select(); }
private void editionInvariants( PlatformModule platformModule, Dependencies dependencies, Config config, LogService logging, LifeSupport life ) { statementLocksFactory = new StatementLocksFactorySelector( lockManager, config, logging ).select(); dependencies.satisfyDependency( createKernelData( platformModule.fileSystem, platformModule.pageCache, platformModule.storeDir, config, platformModule.graphDatabaseFacade, life ) ); ioLimiter = new ConfigurableIOLimiter( platformModule.config ); headerInformationFactory = createHeaderInformationFactory(); schemaWriteGuard = createSchemaWriteGuard(); transactionStartTimeout = config.get( GraphDatabaseSettings.transaction_start_timeout ).toMillis(); constraintSemantics = new EnterpriseConstraintSemantics(); coreAPIAvailabilityGuard = new CoreAPIAvailabilityGuard( platformModule.availabilityGuard, transactionStartTimeout ); registerRecovery( platformModule.databaseInfo, life, dependencies ); publishEditionInfo( dependencies.resolveDependency( UsageData.class ), platformModule.databaseInfo, config ); dependencies.satisfyDependency( createSessionTracker() ); }
private void editionInvariants( PlatformModule platformModule, Dependencies dependencies, Config config, LogService logging, LifeSupport life ) { statementLocksFactory = new StatementLocksFactorySelector( lockManager, config, logging ).select(); dependencies.satisfyDependency( createKernelData( platformModule.fileSystem, platformModule.pageCache, platformModule.storeDir, config, platformModule.graphDatabaseFacade, life ) ); ioLimiter = new ConfigurableIOLimiter( platformModule.config ); headerInformationFactory = createHeaderInformationFactory(); schemaWriteGuard = createSchemaWriteGuard(); transactionStartTimeout = config.get( GraphDatabaseSettings.transaction_start_timeout ); constraintSemantics = new EnterpriseConstraintSemantics(); coreAPIAvailabilityGuard = new CoreAPIAvailabilityGuard( platformModule.availabilityGuard, transactionStartTimeout ); registerRecovery( platformModule.databaseInfo, life, dependencies ); publishEditionInfo( dependencies.resolveDependency( UsageData.class ), platformModule.databaseInfo, config ); dependencies.satisfyDependency( createSessionTracker() ); }
@Test public void loadSimpleStatementLocksFactoryWhenNoServices() { Locks locks = mock( Locks.class ); Locks.Client locksClient = mock( Client.class ); when( locks.newClient() ).thenReturn( locksClient ); StatementLocksFactorySelector loader = newLoader( locks ); StatementLocksFactory factory = loader.select(); StatementLocks statementLocks = factory.newInstance(); assertThat( factory, instanceOf( SimpleStatementLocksFactory.class ) ); assertThat( statementLocks, instanceOf( SimpleStatementLocks.class ) ); assertSame( locksClient, statementLocks.optimistic() ); assertSame( locksClient, statementLocks.pessimistic() ); }
public StatementLocksFactory select() { StatementLocksFactory statementLocksFactory; String serviceName = StatementLocksFactory.class.getSimpleName(); List<StatementLocksFactory> factories = serviceLoadFactories(); if ( factories.isEmpty() ) { statementLocksFactory = new SimpleStatementLocksFactory(); log.info( "No services implementing " + serviceName + " found. " + "Using " + SimpleStatementLocksFactory.class.getSimpleName() ); } else if ( factories.size() == 1 ) { statementLocksFactory = factories.get( 0 ); log.info( "Found single implementation of " + serviceName + ". Namely " + statementLocksFactory.getClass().getSimpleName() ); } else { throw new IllegalStateException( "Found more than one implementation of " + serviceName + ": " + factories ); } statementLocksFactory.initialize( locks, config ); return statementLocksFactory; }
statementLocksFactory = new StatementLocksFactorySelector( lockManager, config, logging ).select();
statementLocksFactory = new StatementLocksFactorySelector( lockManager, config, logging ).select();