ReliableCollectionsActorStateProvider Class
- java.
lang. Object - StateProviderReplica
- ActorStateProvider
- microsoft.
servicefabric. actors. runtime. ReliableCollectionsActorStateProvider
- microsoft.
public class ReliableCollectionsActorStateProvider implements ActorStateProvider
Constructor Summary
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<?> |
actorActivatedAsync(ActorId actorId, CancellationToken cancellationToken)
This method is invoked as part of the activation process of the actor with the specified Id. |
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. |
CompletableFuture<Boolean> |
containsStateAsync(ActorId actorId, String stateName, CancellationToken cancellationToken)
Checks whether actor state provider contains an actor state with specified state name. |
CompletableFuture<?> |
deleteReminderAsync(ActorId actorId, String reminderName, CancellationToken cancellationToken)
Deletes the specified actor reminder if it exists. |
CompletableFuture<?> |
deleteRemindersAsync(Map<ActorId, Collection<String>> reminderNames, CancellationToken cancellationToken)
Deletes the specified set of reminders |
CompletableFuture<List<String>> |
enumerateStateNamesAsync(ActorId actorId, CancellationToken cancellationToken)
Creates an enumerable of all the state names associated with specified actor.
Remarks:The enumerator returned from actor state provider is safe to use concurrently with reads and writes to the state provider. It represents a snapshot consistent view of the state provider. |
CompletableFuture<Paged |
getActorsAsync(int numItemsToReturn, ContinuationToken continuationToken, CancellationToken cancellationToken)
Gets ActorIds from the State Provider.
Remarks: The |
void |
initialize(ActorTypeInformation actorTypeInformation)
Initializes the actor state provider with type information of the actor type associated with it. |
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<Actor |
loadRemindersAsync(CancellationToken cancellationToken)
Loads all the reminders contained in the actor state provider. |
<T> CompletableFuture<T> |
loadStateAsync(ActorId actorId, String stateName, CancellationToken cancellationToken)
Loads the actor state associated with the specified state name. |
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<?> |
reminderCallbackCompletedAsync(ActorId actorId, ActorReminder reminder, CancellationToken cancellationToken)
Invoked when a reminder fires and finishes executing its callback receiveReminderAsync(String reminderName, byte[] context, Duration timeSpan, Duration period) successfully |
CompletableFuture<?> |
removeActorAsync(ActorId actorId, CancellationToken cancellationToken)
Removes all the existing states and reminders associated with specified actor atomically. |
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 |
CompletableFuture<?> |
saveReminderAsync(ActorId actorId, ActorReminder reminder, CancellationToken cancellationToken)
Saves the specified actor reminder. If an actor reminder with given name does not exist, it adds the actor reminder otherwise existing actor reminder with same name is updated. |
CompletableFuture<?> |
saveStateAsync(ActorId actorId, List<ActorStateChange> stateChanges, CancellationToken cancellationToken)
Saves the specified set of actor state changes atomically.
Remarks: The collection of state changes should contain only one item for a given state name. The save operation will fail on trying to add an actor state which already exists or update/remove an actor state which does not exist. |
void |
setOnDataLossCallback(Function<CancellationToken, CompletableFuture<Boolean>> onDataLossAsync)
Function called during suspected data-loss |
Inherited Members
Constructor Details
ReliableCollectionsActorStateProvider
public ReliableCollectionsActorStateProvider()
ReliableCollectionsActorStateProvider
public ReliableCollectionsActorStateProvider(ReliableStateManagerConfiguration stateManagerConfig)
Parameters:
ReliableCollectionsActorStateProvider
public ReliableCollectionsActorStateProvider(ReliableStateManagerConfiguration stateManagerConfig, int actorStateMapCount, int reminderMapCount)
Parameters:
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.
Overrides:
ReliableCollectionsActorStateProvider.abort()actorActivatedAsync
public CompletableFuture actorActivatedAsync(ActorId actorId, CancellationToken cancellationToken)
This method is invoked as part of the activation process of the actor with the specified Id.
Overrides:
ReliableCollectionsActorStateProvider.actorActivatedAsync(ActorId actorId, CancellationToken cancellationToken)Parameters:
CancellationToken object to indicate the cancellation status of the operation.
Returns:
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.
Overrides:
ReliableCollectionsActorStateProvider.backupAsync(BackupOption option, Duration timeout, CancellationToken cancellationToken, BiFunction<BackupInfo, CancellationToken, CompletableFuture<Boolean>> backupCallback)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.
Overrides:
ReliableCollectionsActorStateProvider.backupAsync(BiFunction<BackupInfo, CancellationToken, CompletableFuture<Boolean>> backupCallback)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.
Overrides:
ReliableCollectionsActorStateProvider.changeRoleAsync(ReplicaRole newRole, CancellationToken cancellationToken)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.
Overrides:
ReliableCollectionsActorStateProvider.closeAsync(CancellationToken cancellationToken)Parameters:
CancellationToken object to indicate the cancellation status of the operation.
Returns:
containsStateAsync
public CompletableFuture
Checks whether actor state provider contains an actor state with specified state name.
Overrides:
ReliableCollectionsActorStateProvider.containsStateAsync(ActorId actorId, String stateName, CancellationToken cancellationToken)Parameters:
CancellationToken object to indicate the cancellation status of the operation.
Returns:
deleteReminderAsync
public CompletableFuture deleteReminderAsync(ActorId actorId, String reminderName, CancellationToken cancellationToken)
Deletes the specified actor reminder if it exists.
Overrides:
ReliableCollectionsActorStateProvider.deleteReminderAsync(ActorId actorId, String reminderName, CancellationToken cancellationToken)Parameters:
CancellationToken object to indicate the cancellation status of the operation.
Returns:
deleteRemindersAsync
public CompletableFuture deleteRemindersAsync(Map
Deletes the specified set of reminders
Overrides:
ReliableCollectionsActorStateProvider.deleteRemindersAsync(Map<ActorId, Collection<String>> reminderNames, CancellationToken cancellationToken)Parameters:
CancellationToken object to indicate the cancellation status of the operation.
Returns:
enumerateStateNamesAsync
public CompletableFuture> enumerateStateNamesAsync(ActorId actorId, CancellationToken cancellationToken)
Creates an enumerable of all the state names associated with specified actor.
Remarks:The enumerator returned from actor state provider is safe to use concurrently with reads and writes to the state provider. It represents a snapshot consistent view of the state provider.
Overrides:
ReliableCollectionsActorStateProvider.enumerateStateNamesAsync(ActorId actorId, CancellationToken cancellationToken)Parameters:
CancellationToken object to indicate the cancellation status of the operation.
Returns:
getActorsAsync
public CompletableFuture
Gets ActorIds from the State Provider.
Remarks: The
Overrides:
ReliableCollectionsActorStateProvider.getActorsAsync(int numItemsToReturn, ContinuationToken continuationToken, CancellationToken cancellationToken)Parameters:
CancellationToken object to indicate the cancellation status of the operation.
Returns:
initialize
public void initialize(ActorTypeInformation actorTypeInformation)
Initializes the actor state provider with type information of the actor type associated with it.
Overrides:
ReliableCollectionsActorStateProvider.initialize(ActorTypeInformation actorTypeInformation)Parameters:
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.
Overrides:
ReliableCollectionsActorStateProvider.initialize(StatefulServiceInitializationParameters initializationParameters)Parameters:
loadRemindersAsync
public CompletableFuture
Loads all the reminders contained in the actor state provider.
Overrides:
ReliableCollectionsActorStateProvider.loadRemindersAsync(CancellationToken cancellationToken)Parameters:
CancellationToken object to indicate the cancellation status of the operation.
Returns:
loadStateAsync
public
Loads the actor state associated with the specified state name.
Overrides:
ReliableCollectionsActorStateProvider.loadStateAsync(ActorId actorId, String stateName, CancellationToken cancellationToken)Parameters:
CancellationToken object to indicate the cancellation status of the operation.
Returns:
openAsync
public CompletableFuture
Open the state provider replica for use.
Remarks:Extended state provider initialization tasks can be started at this time.
Overrides:
ReliableCollectionsActorStateProvider.openAsync(ReplicaOpenMode openMode, StatefulServicePartition partition, CancellationToken cancellationToken)Parameters:
CancellationToken object to indicate the cancellation status of the operation.
Returns:
reminderCallbackCompletedAsync
public CompletableFuture reminderCallbackCompletedAsync(ActorId actorId, ActorReminder reminder, CancellationToken cancellationToken)
Invoked when a reminder fires and finishes executing its callback receiveReminderAsync(String reminderName, byte[] context, Duration timeSpan, Duration period) successfully
Overrides:
ReliableCollectionsActorStateProvider.reminderCallbackCompletedAsync(ActorId actorId, ActorReminder reminder, CancellationToken cancellationToken)Parameters:
Returns:
removeActorAsync
public CompletableFuture removeActorAsync(ActorId actorId, CancellationToken cancellationToken)
Removes all the existing states and reminders associated with specified actor atomically.
Overrides:
ReliableCollectionsActorStateProvider.removeActorAsync(ActorId actorId, CancellationToken cancellationToken)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.
Overrides:
ReliableCollectionsActorStateProvider.restoreAsync(String backupFolderPath)Parameters:
Returns:
restoreAsync
public CompletableFuture restoreAsync(String backupFolderPath, RestorePolicy restorePolicy, Duration timeout, CancellationToken cancellationToken)
Restore a backup taken
Overrides:
ReliableCollectionsActorStateProvider.restoreAsync(String backupFolderPath, RestorePolicy restorePolicy, Duration timeout, CancellationToken cancellationToken)Parameters:
Returns:
saveReminderAsync
public CompletableFuture saveReminderAsync(ActorId actorId, ActorReminder reminder, CancellationToken cancellationToken)
Saves the specified actor reminder. If an actor reminder with given name does not exist, it adds the actor reminder otherwise existing actor reminder with same name is updated.
Overrides:
ReliableCollectionsActorStateProvider.saveReminderAsync(ActorId actorId, ActorReminder reminder, CancellationToken cancellationToken)Parameters:
CancellationToken object to indicate the cancellation status of the operation.
Returns:
saveStateAsync
public CompletableFuture saveStateAsync(ActorId actorId, List
Saves the specified set of actor state changes atomically.
Remarks: The collection of state changes should contain only one item for a given state name. The save operation will fail on trying to add an actor state which already exists or update/remove an actor state which does not exist.
Overrides:
ReliableCollectionsActorStateProvider.saveStateAsync(ActorId actorId, List<ActorStateChange> stateChanges, CancellationToken cancellationToken)Parameters:
CancellationToken object to indicate the cancellation status of the operation.
Returns:
setOnDataLossCallback
public void setOnDataLossCallback(Function
Function called during suspected data-loss
Overrides:
ReliableCollectionsActorStateProvider.setOnDataLossCallback(Function<CancellationToken, CompletableFuture<Boolean>> onDataLossAsync)Parameters:
Applies to
Azure SDK for Java