Example #1
0
        public virtual StatementLocksFactory Select()
        {
            StatementLocksFactory statementLocksFactory;

            string serviceName = typeof(StatementLocksFactory).Name;
            IList <StatementLocksFactory> factories = ServiceLoadFactories();

            if (factories.Count == 0)
            {
                statementLocksFactory = new SimpleStatementLocksFactory();

                _log.info("No services implementing " + serviceName + " found. " + "Using " + typeof(SimpleStatementLocksFactory).Name);
            }
            else if (factories.Count == 1)
            {
                statementLocksFactory = factories[0];

                _log.info("Found single implementation of " + serviceName + ". Namely " + statementLocksFactory.GetType().Name);
            }
            else
            {
                throw new System.InvalidOperationException("Found more than one implementation of " + serviceName + ": " + factories);
            }

            statementLocksFactory.Initialize(_locks, _config);

            return(statementLocksFactory);
        }
Example #2
0
        private static KernelTransactions NewKernelTransactions(Locks locks, StorageEngine storageEngine, TransactionCommitProcess commitProcess, bool testKernelTransactions)
        {
            LifeSupport life = new LifeSupport();

            life.Start();

            TransactionIdStore transactionIdStore = mock(typeof(TransactionIdStore));

            when(transactionIdStore.LastCommittedTransaction).thenReturn(new TransactionId(0, 0, 0));

            Tracers tracers = new Tracers("null", NullLog.Instance, new Monitors(), mock(typeof(JobScheduler)), _clock);
            StatementLocksFactory statementLocksFactory = new SimpleStatementLocksFactory(locks);

            StatementOperationParts statementOperations = mock(typeof(StatementOperationParts));
            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);
        }