StateProviderReplica Interface
public interface StateProviderReplica
Defines methods a reliable state provider replica must implement for Service Fabric to interact with it.
Method Summary
Modifier and Type | Method and Description |
---|---|
void |
abort()
Forcefully abort the state provider replica.
Remarks:This generally occurs when a permanent fault is detected on the node, or when Service Fabric cannot reliably manage the replica's lifecycle due to internal failures. |
CompletableFuture<?> |
backupAsync(BackupOption option, Duration timeout, CancellationToken cancellationToken, BiFunction<BackupInfo, CancellationToken, CompletableFuture<Boolean>> backupCallback)
Performs a full backup of all reliable state managed by this ReliableStateManager.
Remarks: A FULL backup will be performed with a one-hour timeout. Boolean returned by the backupCallback indicate whether the service was able to successfully move the backup folder to an external location. If false is returned, BackupAsync throws UnsupportedOperationException with the relevant message indicating backupCallback returned false. Also, backup will be marked as unsuccessful. |
CompletableFuture<?> |
backupAsync(BiFunction<BackupInfo, CancellationToken, CompletableFuture<Boolean>> backupCallback)
Performs a full backup of all reliable state managed by this ReliableStateManager.
Remarks: A FULL backup will be performed with a one-hour timeout. Boolean returned by the backupCallback indicate whether the service was able to successfully move the backup folder to an external location. If false is returned, BackupAsync throws UnsupportedOperationException with the relevant message indicating backupCallback returned false. Also, backup will be marked as unsuccessful. |
CompletableFuture<?> |
changeRoleAsync(ReplicaRole newRole, CancellationToken cancellationToken)
Notify the state provider replica that its role is changing, for example to Primary or Secondary. |
CompletableFuture<?> |
closeAsync(CancellationToken cancellationToken)
Gracefully close the state provider replica.
Remarks:This generally occurs when the replica's code is being upgrade, the replica is being moved due to load balancing, or a transient fault is detected. |
void |
initialize(StatefulServiceInitializationParameters initializationParameters)
Initialize the state provider replica using the service initialization information.
Remarks:No complex processing should be done during Initialize. Expensive or long-running initialization should be done in OpenAsync. |
CompletableFuture<Replicator> |
openAsync(ReplicaOpenMode openMode, StatefulServicePartition partition, CancellationToken cancellationToken)
Open the state provider replica for use.
Remarks:Extended state provider initialization tasks can be started at this time. |
CompletableFuture<?> |
restoreAsync(String backupFolderPath)
Restore a backup taken.
Remarks:A safe restore will be performed, meaning the restore will only be completed if the data to restore is ahead of state of the current replica. |
CompletableFuture<?> |
restoreAsync(String backupFolderPath, RestorePolicy restorePolicy, Duration timeout, CancellationToken cancellationToken)
Restore a backup taken |
void |
setOnDataLossCallback(Function<CancellationToken, CompletableFuture<Boolean>> onDataLossAsync)
Function called during suspected data-loss |
Method Details
abort
public void abort()
Forcefully abort the state provider replica.
Remarks:This generally occurs when a permanent fault is detected on the node, or when Service Fabric cannot reliably manage the replica's lifecycle due to internal failures.
backupAsync
public CompletableFuture backupAsync(BackupOption option, Duration timeout, CancellationToken cancellationToken, BiFunction
Performs a full backup of all reliable state managed by this ReliableStateManager.
Remarks: A FULL backup will be performed with a one-hour timeout. Boolean returned by the backupCallback indicate whether the service was able to successfully move the backup folder to an external location. If false is returned, BackupAsync throws UnsupportedOperationException with the relevant message indicating backupCallback returned false. Also, backup will be marked as unsuccessful.
Parameters:
Returns:
backupAsync
public CompletableFuture backupAsync(BiFunction
Performs a full backup of all reliable state managed by this ReliableStateManager.
Remarks: A FULL backup will be performed with a one-hour timeout. Boolean returned by the backupCallback indicate whether the service was able to successfully move the backup folder to an external location. If false is returned, BackupAsync throws UnsupportedOperationException with the relevant message indicating backupCallback returned false. Also, backup will be marked as unsuccessful.
Parameters:
Returns:
changeRoleAsync
public CompletableFuture changeRoleAsync(ReplicaRole newRole, CancellationToken cancellationToken)
Notify the state provider replica that its role is changing, for example to Primary or Secondary.
Parameters:
CancellationToken object to indicate the cancellation status of the operation.
Returns:
closeAsync
public CompletableFuture closeAsync(CancellationToken cancellationToken)
Gracefully close the state provider replica.
Remarks:This generally occurs when the replica's code is being upgrade, the replica is being moved due to load balancing, or a transient fault is detected.
Parameters:
CancellationToken object to indicate the cancellation status of the operation.
Returns:
initialize
public void initialize(StatefulServiceInitializationParameters initializationParameters)
Initialize the state provider replica using the service initialization information.
Remarks:No complex processing should be done during Initialize. Expensive or long-running initialization should be done in OpenAsync.
Parameters:
openAsync
public CompletableFuture
Open the state provider replica for use.
Remarks:Extended state provider initialization tasks can be started at this time.
Parameters:
CancellationToken object to indicate the cancellation status of the operation.
Returns:
restoreAsync
public CompletableFuture restoreAsync(String backupFolderPath)
Restore a backup taken.
Remarks:A safe restore will be performed, meaning the restore will only be completed if the data to restore is ahead of state of the current replica.
Parameters:
Returns:
restoreAsync
public CompletableFuture restoreAsync(String backupFolderPath, RestorePolicy restorePolicy, Duration timeout, CancellationToken cancellationToken)
Restore a backup taken
Parameters:
Returns:
setOnDataLossCallback
public void setOnDataLossCallback(Function
Function called during suspected data-loss
Parameters:
Applies to
Azure SDK for Java