Пример #1
0
        /// <summary>
        /// Called when the service instance changes role.
        /// </summary>
        /// <param name="newRole">New role.</param>
        /// <param name="cancellationToken">CancellationToken instance.</param>
        /// <returns></returns>
        protected override Task OnChangeRoleAsync(ReplicaRole newRole, CancellationToken cancellationToken)
        {
            _eventSource?.ChangeRoleAsyncInvoked(Context.ServiceTypeName, Context.PartitionId, Context.ReplicaOrInstanceId, newRole.ToString());

            // Let the base change the role.
            Task t = base.OnChangeRoleAsync(newRole, cancellationToken);

            // Change the role, then fire an event if necessary.
            var oldRole = CurrentRole;

            CurrentRole = newRole;
            OnRoleChangeEvent?.Invoke(this, new RoleChangedEventArgs(oldRole, CurrentRole));

            return(t);
        }
        protected override Task OnChangeRoleAsync(ReplicaRole newRole, CancellationToken cancellationToken)
        {
            ServiceEventSource.Current.ServiceMessage(this, "*** OnChangeRole for {0}, Parition {1}. new role is: {2}", this.Context.ServiceName, this.Context.PartitionId, newRole.ToString());
            // TODO: record role change

            return(base.OnChangeRoleAsync(newRole, cancellationToken));
        }
Пример #3
0
 public ServiceRoleChangeEvent(StatefulServiceContext context, ReplicaRole role, int inFlightMessageCount) : base(context)
 {
     ReplicaRole          = role.ToString();
     InFlightMessageCount = inFlightMessageCount;
 }