StatefulService StatefulService StatefulService Class

Definition

Represents the base class for Microsoft Service Fabric based stateful reliable service which provides an IReliableStateManager to manage service's state. Derive from this class to implement a Microsoft Service Fabric based stateful reliable service.

public abstract class StatefulService : Microsoft.ServiceFabric.Services.Runtime.StatefulServiceBase
type StatefulService = class
    inherit StatefulServiceBase
Public MustInherit Class StatefulService
Inherits StatefulServiceBase
Inheritance

Constructors

StatefulService(StatefulServiceContext) StatefulService(StatefulServiceContext) StatefulService(StatefulServiceContext)

Initializes a new instance of the StatefulService class with default reliable state manager (ReliableStateManager).

StatefulService(StatefulServiceContext, IReliableStateManagerReplica) StatefulService(StatefulServiceContext, IReliableStateManagerReplica) StatefulService(StatefulServiceContext, IReliableStateManagerReplica)

Initializes a new instance of the StatefulService class with non-default reliable state manager replica.

Properties

Context Context Context

Gets the service context that this stateful service is operating under. It provides information like replica ID, partition ID, service name etc.

(Inherited from StatefulServiceBase)
Partition Partition Partition

Gets the service partition to which current service replica belongs.

(Inherited from StatefulServiceBase)
StateManager StateManager StateManager

Gets this replica's IReliableStateManager.

Methods

BackupAsync(BackupDescription) BackupAsync(BackupDescription) BackupAsync(BackupDescription)

Performs a backup of all reliable state managed by this StatefulServiceBase.

(Inherited from StatefulServiceBase)
BackupAsync(BackupDescription, TimeSpan, CancellationToken) BackupAsync(BackupDescription, TimeSpan, CancellationToken) BackupAsync(BackupDescription, TimeSpan, CancellationToken)

Performs a backup of all reliable state managed by this StatefulServiceBase.

(Inherited from StatefulServiceBase)
CreateServiceReplicaListeners() CreateServiceReplicaListeners() CreateServiceReplicaListeners()

Override this method to supply the communication listeners for the service replica. The endpoints returned by the communication listener are stored as a JSON string of ListenerName, Endpoint string pairs like

{"Endpoints":{"Listener1":"Endpoint1","Listener2":"Endpoint2" ...}}

For information about Reliable Services life cycle please see https://docs.microsoft.com/azure/service-fabric/service-fabric-reliable-services-lifecycle

(Inherited from StatefulServiceBase)
GetAddresses() GetAddresses() GetAddresses()

Gets the list of all the addresses for this service replica as (ListenerName, Endpoint) key-value pair.

(Inherited from StatefulServiceBase)
OnAbort() OnAbort() OnAbort()

The notification that the service is being aborted. RunAsync MAY be running concurrently with the execution of this method, as cancellation is not awaited on the abort path.

For information about Reliable Services life cycle please see https://docs.microsoft.com/azure/service-fabric/service-fabric-reliable-services-lifecycle

(Inherited from StatefulServiceBase)
OnChangeRoleAsync(ReplicaRole, CancellationToken) OnChangeRoleAsync(ReplicaRole, CancellationToken) OnChangeRoleAsync(ReplicaRole, CancellationToken)

This method is called when role of the replica is changing and it is the final step before completing ChangeRoleAsync(ReplicaRole, CancellationToken). Override this method to be notified that ChangeRole has completed for this replica's internal components.

For information about Reliable Services life cycle please see https://docs.microsoft.com/azure/service-fabric/service-fabric-reliable-services-lifecycle

(Inherited from StatefulServiceBase)
OnCloseAsync(CancellationToken) OnCloseAsync(CancellationToken) OnCloseAsync(CancellationToken)

This method is called as the final step of closing the service gracefully. Override this method to be notified that Close has completed for this replica's internal components.

For information about Reliable Services life cycle please see https://docs.microsoft.com/azure/service-fabric/service-fabric-reliable-services-lifecycle

(Inherited from StatefulServiceBase)
OnDataLossAsync(RestoreContext, CancellationToken) OnDataLossAsync(RestoreContext, CancellationToken) OnDataLossAsync(RestoreContext, CancellationToken)

This method is called during suspected data loss. You can override this method to restore the service in case of data loss.

(Inherited from StatefulServiceBase)
OnOpenAsync(ReplicaOpenMode, CancellationToken) OnOpenAsync(ReplicaOpenMode, CancellationToken) OnOpenAsync(ReplicaOpenMode, CancellationToken)

This method is called when the replica is being opened and it is the final step of opening the service. Override this method to be notified that Open has completed for this replica's internal components.

For information about Reliable Services life cycle please see https://docs.microsoft.com/azure/service-fabric/service-fabric-reliable-services-lifecycle

(Inherited from StatefulServiceBase)
OnRestoreCompletedAsync(CancellationToken) OnRestoreCompletedAsync(CancellationToken) OnRestoreCompletedAsync(CancellationToken)

This method is called when replica's state has been restored successfully via the Backup Restore service. This is only supported when the reliable state provider replica object passed in the constructor is derived from IStateProviderReplica2.

(Inherited from StatefulServiceBase)
RunAsync(CancellationToken) RunAsync(CancellationToken) RunAsync(CancellationToken)

This method is implemented as a processing loop and will only be called when the replica is primary with write status. Override this method with the application logic.

For information about Reliable Services life cycle please see https://docs.microsoft.com/azure/service-fabric/service-fabric-reliable-services-lifecycle

(Inherited from StatefulServiceBase)

Applies to