Ejemplo n.º 1
0
        public TransactionManager(
            TransactionLog transactionLog,
            IOptions <TransactionsOptions> configOption,
            ILoggerFactory loggerFactory,
            ITelemetryProducer telemetryProducer,
            IOptions <StatisticsOptions> statisticsOptions,
            TimeSpan?logMaintenanceInterval = null)
        {
            this.transactionLog         = transactionLog;
            this.options                = configOption.Value;
            this.logger                 = loggerFactory.CreateLogger <TransactionManager>();
            this.logMaintenanceInterval = logMaintenanceInterval ?? DefaultLogMaintenanceInterval;

            activeTransactionsTracker = new ActiveTransactionsTracker(configOption, this.transactionLog, loggerFactory);

            transactionsTable = new ConcurrentDictionary <long, Transaction>(2, 1000000);

            dependencyQueue  = new ConcurrentQueue <Transaction>();
            groupCommitQueue = new ConcurrentQueue <Tuple <CommitRecord, Transaction> >();
            checkpointQueue  = new ConcurrentQueue <Transaction>();

            this.dependencyLock = new InterlockedExchangeLock();
            this.commitLock     = new InterlockedExchangeLock();
            this.checkpointLock = new InterlockedExchangeLock();
            this.resources      = new Dictionary <ITransactionalResource, long>();
            this.transactions   = new List <Transaction>();
            this.metrics        =
                new TransactionManagerMetrics(telemetryProducer, configOption.Value.MetricsWritePeriod);
            this.checkpointedLSN = 0;
            this.IsRunning       = false;
        }
Ejemplo n.º 2
0
        public ActiveTransactionsTracker(IOptions <TransactionsOptions> configOption, TransactionLog transactionLog, ILoggerFactory loggerFactory)
        {
            this.options        = configOption.Value;
            this.transactionLog = transactionLog;
            this.logger         = loggerFactory.CreateLogger(nameof(ActiveTransactionsTracker));
            lockObj             = new object();

            allocationEvent  = new AutoResetEvent(true);
            allocationThread = new Thread(AllocateTransactionId);
        }