public TocTransactionQueue( TService service, IOptions <TransactionalStateOptions> options, ParticipantId resource, Action deactivate, ITransactionalStateStorage <TransactionCommitter <TService> .OperationState> storage, JsonSerializerSettings serializerSettings, IClock clock, ILogger logger) : base(options, resource, deactivate, storage, serializerSettings, clock, logger) { this.service = service; }
public TocTransactionQueue( TService service, IOptions <TransactionalStateOptions> options, ParticipantId resource, Action deactivate, ITransactionalStateStorage <TransactionCommitter <TService> .OperationState> storage, IClock clock, ILogger logger, ITimerManager timerManager, IActivationLifetime activationLifetime) : base(options, resource, deactivate, storage, clock, logger, timerManager, activationLifetime) { this.service = service; }
public async Task <string> Store(ITransactionalStateStorage <TState> storage) { var jsonMetaData = JsonConvert.SerializeObject(MetaData, this.serializerSettings); var list = new List <PendingTransactionState <TState> >(); if (prepares != null) { foreach (var kvp in prepares) { list.Add(kvp.Value); } } return(await storage.Store(ETag, jsonMetaData, list, (confirm > 0)?confirmUpTo : (long?)null, (cancelAbove < cancelAboveStart)?cancelAbove : (long?)null)); }
private async Task OnSetupState(CancellationToken ct) { if (ct.IsCancellationRequested) { return; } Tuple <TransactionalExtension, ITransactionalExtension> boundExtension = await this.runtime.BindExtension <TransactionalExtension, ITransactionalExtension>(() => new TransactionalExtension()); boundExtension.Item1.Register(this.config.StateName, this); this.transactionalResource = boundExtension.Item2.AsTransactionalResource(this.config.StateName); INamedTransactionalStateStorageFactory storageFactory = this.context.ActivationServices.GetRequiredService <INamedTransactionalStateStorageFactory>(); this.storage = storageFactory.Create <TState>(this.config.StorageName); // recover state await DoLoad(); this.validState = true; }
public TransactionQueue( IOptions <TransactionalStateOptions> options, ITransactionParticipant resource, Action deactivate, ITransactionalStateStorage <TState> storage, JsonSerializerSettings serializerSettings, IClock clock, ILogger logger) { this.options = options.Value; this.resource = resource; this.deactivate = deactivate; this.storage = storage; this.serializerSettings = serializerSettings; this.Clock = new CausalClock(clock); this.logger = logger; this.confirmationTasks = new Dictionary <Guid, TransactionRecord <TState> >(); this.storageWorker = new BatchWorkerFromDelegate(StorageWork); this.confirmationWorker = new BatchWorkerFromDelegate(ConfirmationWork); this.RWLock = new ReadWriteLock <TState>(options, this, this.storageWorker, logger); }
public TransactionQueue( IOptions <TransactionalStateOptions> options, ParticipantId resource, Action deactivate, ITransactionalStateStorage <TState> storage, JsonSerializerSettings serializerSettings, IClock clock, ILogger logger) { this.options = options.Value; this.resource = resource; this.deactivate = deactivate; this.storage = storage; this.Clock = new CausalClock(clock); this.logger = logger; this.storageWorker = new BatchWorkerFromDelegate(StorageWork); this.RWLock = new ReadWriteLock <TState>(options, this, this.storageWorker, logger); this.confirmationWorker = new ConfirmationWorker <TState>(options, this.resource, this.storageWorker, () => this.storageBatch, this.logger); this.unprocessedPreparedMessages = new Dictionary <DateTime, PreparedMessages>(); this.commitQueue = new CommitQueue <TState>(); this.readyTask = Task.CompletedTask; }
private async Task OnSetupState(CancellationToken ct) { if (ct.IsCancellationRequested) { return; } var boundExtension = await this.runtime.BindExtension <TransactionParticipantExtension, ITransactionParticipantExtension>(() => new TransactionParticipantExtension()); boundExtension.Item1.Register(this.config.StateName, this); this.thisParticipant = boundExtension.Item2.AsTransactionParticipant(this.config.StateName); this.logger = loggerFactory.CreateLogger($"{context.GrainType.Name}.{this.config.StateName}.{this.thisParticipant.ToShortString()}"); var storageFactory = this.context.ActivationServices.GetRequiredService <INamedTransactionalStateStorageFactory>(); this.storage = storageFactory.Create <TState>(this.config.StorageName, this.config.StateName); // recover state await Restore(); storageWorker.Notify(); }