StatefulServiceBase Class
- java.
lang. Object - microsoft.
servicefabric. services. runtime. StatefulServiceBase
- microsoft.
public class StatefulServiceBase
Represents base class for Microsoft Service Fabric based stateful reliable service.
Constructor Summary
Constructor | Description |
---|---|
StatefulServiceBase(StatefulServiceContext serviceContext, StateProviderReplica stateProviderReplica) |
Creates a new StatefulService. |
Method Summary
Modifier and Type | Method and Description |
---|---|
CompletableFuture<?> |
backupAsync(BackupDescription backupDescription)
Performs a backup of all reliable state managed by this StatefulServiceBase. |
CompletableFuture<?> |
backupAsync(BackupDescription backupDescription, Duration timeout, CancellationToken cancellationToken)
Performs a backup of all reliable state managed by this StatefulServiceBase. |
List<Service |
createServiceReplicaListeners()
Override this method to supply the communication listeners for the service replica. The endpoints returned by the communication listener's are stored as a JSON string of ListenerName, Endpoint string pairs like {"Endpoints":{"Listener1":"Endpoint1","Listener2":"Endpoint2" ...}} |
Map<String, String> |
getAddresses()
Gets list of all the addresses for this service replica as (ListenerName, Endpoint) key-value pair. |
Stateful |
getPartition()
Service partition to which current service replica belongs. |
Stateful |
getServiceContext()
Gets the service context that this stateful service is operating under. It provides information like ReplicaId, PartitionId, ServiceName etc. |
State |
getStateProviderReplica() |
void |
onAbort()
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. |
CompletableFuture<?> |
onChangeRoleAsync(ReplicaRole newRole, CancellationToken cancellationToken)
This method is called as the final step before completing changeRoleAsync(ReplicaRole newRole, CancellationToken cancellationToken) . Override this method to be notified that ChangeRole has completed for this replica's internal components. |
CompletableFuture<?> |
onCloseAsync(CancellationToken cancellationToken)
This method is called as the final step of closing the service. Override this method to be notified that Close has completed for this replica's internal components. |
CompletableFuture<Boolean> |
onDataLossAsync(RestoreContext context, CancellationToken cancellationToken)
This method is called during suspected data loss. You can override this method to restore the service in case of data loss. |
CompletableFuture<?> |
onOpenAsync(ReplicaOpenMode openMode, CancellationToken cancellationToken)
This method is called as the final step of opening the service. Override this method to be notified that Open has completed for this replica's internal components. |
CompletableFuture<?> |
runAsync(CancellationToken cancellationToken)
Services that want to implement a processing loop which runs when it is primary and has write status, just override this method with their logic. |
void |
setAddresses(Map<String, String> addresses)
Sets list of all the addresses for this service replica as (ListenerName, Endpoint) key-value pair. |
void |
setPartition(StatefulServicePartition partition)
Service partition to which current service replica belongs. |
Constructor Details
StatefulServiceBase
protected StatefulServiceBase(StatefulServiceContext serviceContext, StateProviderReplica stateProviderReplica)
Creates a new StatefulService.
Parameters:
Method Details
backupAsync
public CompletableFuture backupAsync(BackupDescription backupDescription)
Performs a backup of all reliable state managed by this StatefulServiceBase.
Parameters:
Returns:
backupAsync
public CompletableFuture backupAsync(BackupDescription backupDescription, Duration timeout, CancellationToken cancellationToken)
Performs a backup of all reliable state managed by this StatefulServiceBase.
Parameters:
Returns:
createServiceReplicaListeners
protected List
Override this method to supply the communication listeners for the service replica. The endpoints returned by the communication listener's are stored as a JSON string of ListenerName, Endpoint string pairs like {"Endpoints":{"Listener1":"Endpoint1","Listener2":"Endpoint2" ...}}
Returns:
getAddresses
protected Map
Gets list of all the addresses for this service replica as (ListenerName, Endpoint) key-value pair.
Returns:
getPartition
protected StatefulServicePartition getPartition()
Service partition to which current service replica belongs.
Returns:
getServiceContext
public StatefulServiceContext getServiceContext()
Gets the service context that this stateful service is operating under. It provides information like ReplicaId, PartitionId, ServiceName etc.
Returns:
getStateProviderReplica
protected StateProviderReplica getStateProviderReplica()
onAbort
protected void onAbort()
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.
onChangeRoleAsync
protected CompletableFuture onChangeRoleAsync(ReplicaRole newRole, CancellationToken cancellationToken)
This method is called as the final step before completing changeRoleAsync(ReplicaRole newRole, CancellationToken cancellationToken) . Override this method to be notified that ChangeRole has completed for this replica's internal components.
Parameters:
CancellationToken object to indicate the cancellation status of the operation.
Returns:
onCloseAsync
protected CompletableFuture onCloseAsync(CancellationToken cancellationToken)
This method is called as the final step of closing the service. Override this method to be notified that Close has completed for this replica's internal components.
Parameters:
CancellationToken object to indicate the cancellation status of the operation.
Returns:
onDataLossAsync
protected CompletableFuture
This method is called during suspected data loss. You can override this method to restore the service in case of data loss.
Parameters:
CancellationToken object to indicate the cancellation status of the operation.
Returns:
onOpenAsync
protected CompletableFuture onOpenAsync(ReplicaOpenMode openMode, CancellationToken cancellationToken)
This method is called as the final step of opening the service. Override this method to be notified that Open has completed for this replica's internal components.
Parameters:
CancellationToken object to indicate the cancellation status of the operation.
Returns:
runAsync
protected CompletableFuture runAsync(CancellationToken cancellationToken)
Services that want to implement a processing loop which runs when it is primary and has write status, just override this method with their logic.
Parameters:
CancellationToken object to indicate the cancellation status of the operation.
Returns:
setAddresses
protected void setAddresses(Map
Sets list of all the addresses for this service replica as (ListenerName, Endpoint) key-value pair.
Parameters:
setPartition
protected void setPartition(StatefulServicePartition partition)
Service partition to which current service replica belongs.
Parameters:
Applies to
Azure SDK for Java