Ejemplo n.º 1
0
        public TransactionManager(TransactionLog transactionLog, IOptions <TransactionsConfiguration> configOption, Factory <string, Logger> logFactory)
        {
            this.transactionLog = transactionLog;
            this.config         = configOption.Value;
            this.Logger         = logFactory(nameof(TransactionManager));

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

            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.checkpointedLSN = 0;
            this.IsRunning       = false;
        }
Ejemplo n.º 2
0
        public TransactionManager(TransactionLog transactionLog, IOptions <TransactionsConfiguration> configOption, ILoggerFactory loggerFactory, TimeSpan?logMaintenanceInterval = null)
        {
            this.transactionLog         = transactionLog;
            this.config                 = 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.checkpointedLSN = 0;
            this.IsRunning       = false;
        }
Ejemplo n.º 3
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)
            {
                IsBackground = true,
                Name         = nameof(ActiveTransactionsTracker)
            };
        }
Ejemplo n.º 4
0
        public ActiveTransactionsTracker(IOptions <TransactionsConfiguration> configOption, TransactionLog transactionLog, Factory <string, Logger> logFactory)
        {
            this.config         = configOption.Value;
            this.transactionLog = transactionLog;
            this.logger         = logFactory(nameof(ActiveTransactionsTracker));
            lockObj             = new object();

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