Пример #1
0
        public TransactionManager(TransactionLog transactionLog, IOptions <TransactionsConfiguration> configOption, ILoggerFactory loggerFactory, ITelemetryProducer telemetryProducer,
                                  Factory <NodeConfiguration> getNodeConfig, 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.metrics        =
                new TransactionManagerMetrics(telemetryProducer, getNodeConfig().StatisticsMetricsTableWriteInterval);
            this.checkpointedLSN = 0;
            this.IsRunning       = false;
        }
Пример #2
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);
        }
Пример #3
0
 public void Copy(TransactionsConfiguration other)
 {
     if (other == null)
     {
         UseDefaults();
     }
     else
     {
         this.TransactionIdAllocationBatchSize      = other.TransactionIdAllocationBatchSize;
         this.AvailableTransactionIdThreshold       = other.AvailableTransactionIdThreshold;
         this.TransactionRecordPreservationDuration = other.TransactionRecordPreservationDuration;
     }
 }
Пример #4
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;
        }
Пример #5
0
        /// TODO: Remove when we move to using silo builder for tests
        #region pre-siloBuilder

        public static void UseInClusterTransactionManager(this IServiceCollection services, TransactionsConfiguration config)
        {
            // TODO: Move configuration to container configuration phase, once we move to silo builder in tests.
            services.AddSingleton(config);
            services.AddTransient <TransactionLog>();
            services.AddTransient <ITransactionManager, TransactionManager>();
            services.AddSingleton <TransactionServiceGrainFactory>();
            services.AddSingleton(sp => sp.GetRequiredService <TransactionServiceGrainFactory>().CreateTransactionManagerService());
        }
Пример #6
0
 /// <summary>
 /// Configure cluster to use an in-cluster transaction manager.
 /// </summary>
 /// <param name="builder"></param>
 /// <returns></returns>
 public static ISiloBuilder UseInClusterTransactionManager(this ISiloBuilder builder, TransactionsConfiguration config)
 {
     return(builder.ConfigureServices(services => services.UseInClusterTransactionManager(config)));
 }
Пример #7
0
 /// <summary>
 /// Configure cluster to use an in-cluster transaction manager.
 /// </summary>
 public static ISiloHostBuilder UseInClusterTransactionManager(this ISiloHostBuilder builder, TransactionsConfiguration config)
 {
     return(builder.ConfigureServices(UseInClusterTransactionManager)
            .Configure <TransactionsConfiguration>((cfg) => cfg.Copy(config)));
 }