Aracılığıyla paylaş


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
StatefulService

Constructors

StatefulService(StatefulServiceContext, IReliableStateManagerReplica)

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

StatefulService(StatefulServiceContext)

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

Properties

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

Gets the service partition to which current service replica belongs.

(Inherited from StatefulServiceBase)
ServiceContext

Gets the Stateful service context.

(Inherited from StatefulServiceBase)
StateManager

Gets this replica's IReliableStateManager.

Methods

BackupAsync(BackupDescription, TimeSpan, CancellationToken)

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

(Inherited from StatefulServiceBase)
BackupAsync(BackupDescription)

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

(Inherited from 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

(Inherited from StatefulServiceBase)
GetAddresses()

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

(Inherited from StatefulServiceBase)
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)

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)

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)

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)

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)

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)

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