상속: IStateProvider, IDisposable, IReplicationNotifier
 public void Abort()
 {
     this.logger.Log(nameof(this.Abort));
     this.stateProvider?.Dispose();
     this.stateProvider = null;
     this.logger.Log("Completed " + nameof(this.Abort));
 }
        public async Task <IReplicator> OpenAsync(
            ReplicaOpenMode openMode,
            IStatefulServicePartition servicePartition,
            CancellationToken cancellationToken)
        {
            var self = this.serviceParameters;

            this.logger = new Logger(self)
            {
                Prefix = () => $"[{this.unsafeRole}] "
            };
            this.logger.Log("OpenAsync");
            IReplicator   result;
            StateProvider provider;

            lock (this.replicaLock)
            {
                this.partition = servicePartition;
                provider       = this.stateProvider = new StateProvider(this.logFilePath, this.logger, this.serializer);
                var replicatorSettings = ReplicatorSettings.LoadFrom(
                    self.CodePackageActivationContext,
                    ConfigPackageName,
                    ReplicatorConfigSectionName);
                replicatorSettings.BatchAcknowledgementInterval = TimeSpan.FromMilliseconds(1);
                result = this.fabricReplicator = servicePartition.CreateReplicator(this.stateProvider, replicatorSettings);
            }

            await provider.Initialize();

            this.logger.Log("Completed OpenAsync");
            return(result);
        }
예제 #3
0
        public Task CloseAsync(CancellationToken cancellationToken)
        {
            this.logger.Log(nameof(this.CloseAsync));
            this.stateProvider?.Dispose();
            this.stateProvider = null;

            this.logger.Log("Completed " + nameof(this.CloseAsync));
            return(Task.FromResult(0));
        }
        public OperationReplicator(IStateReplicator replicator, StateProvider stateProvider, Logger logger, Serializer serializer)
        {
            this.replicator    = replicator;
            this.stateProvider = stateProvider;
            this.logger        = logger;
            this.serializer    = serializer;
            var options = new ExecutionDataflowBlockOptions {
                MaxDegreeOfParallelism = 1, BoundedCapacity = 128
            };

            this.replicationWorker = new ActionBlock <ReplicationRequest>(this.InitiateOrderedReplication, options);
            this.completionWorker  = new ActionBlock <ReplicationRequest>(this.CompleteOrderedReplication, options);
        }