StatefulServiceBase Class

Definition

Represents the base class for Microsoft Service Fabric based stateful reliable service.

public abstract class StatefulServiceBase
type StatefulServiceBase = class
Public MustInherit Class StatefulServiceBase
Inheritance
StatefulServiceBase
Derived

Constructors

StatefulServiceBase(StatefulServiceContext, IStateProviderReplica)

Initializes a new instance of the StatefulServiceBase class.

Properties

Context

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

Partition

Gets the service partition to which current service replica belongs.

ServiceContext

Gets the Stateful service context.

Methods

BackupAsync(BackupDescription)

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

BackupAsync(BackupDescription, TimeSpan, CancellationToken)

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

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

GetAddresses()

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

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

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

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

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.

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

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.

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

Applies to