다음을 통해 공유


VolatileActorStateProvider Class

public class VolatileActorStateProvider implements ActorStateProvider,StateProvider

ActorStateProvider implementation for Volatile persistence i.e Actor state is kept in-memory only.

Constructor Summary

Constructor Description
VolatileActorStateProvider()

Creates an instance of VolatileActorStateProvider.

VolatileActorStateProvider(ReplicatorSettings replicatorSettings)

Creates an instance of VolatileActorStateProvider with specified replicator settings.

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 life-cycle 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 state managed by this actor state provider

Remarks:Backup/restore is not supported by VolatileActorStateProvider.

CompletableFuture<?> backupAsync(BiFunction<BackupInfo, CancellationToken, CompletableFuture<Boolean>> backupCallback)

Performs a full backup of state managed by this actor state provider

Remarks:Backup/restore is not supported by VolatileActorStateProvider.

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.

ReplicaRole currentReplicaRole()
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<PagedResult<ActorId>> getActorsAsync(int itemsCount, ContinuationToken continuationToken, CancellationToken cancellationToken)

Gets ActorIds from the State Provider.

Remarks: The

OperationDataStream getCopyContext()

Obtains context on a Secondary replica after it is created and opened to send context to the Primary replica.

Remarks:The Primary replica analyzes the context and sends back state via getCopyState(SequenceNumber upToSequenceNumber, OperationDataStream copyContext). getCopyContext() is called on newly created, idle Secondary replicas and provides a mechanism to asynchronously establish a bidirectional conversation with the Primary replica. The Secondary replica sends OperationData objects with which the Primary replica can determine the progress of collecting context on the Secondary replica. The Primary replica responds by sending the required state back. See getCopyState(SequenceNumber upToSequenceNumber, OperationDataStream copyContext) at the Primary replica for the other half of the exchange. For in-memory services, the getCopyContext() method is not called, as the state of the Secondary replicas is known (they are empty and will require all of the state).

OperationDataStream getCopyState(SequenceNumber upToSequenceNumber, OperationDataStream copyContext)

Obtains state on a Primary replica that is required to build a Secondary replica.

Remarks:Just as getCopyContext() enables the Secondary replica to send context to the Primary replica via an OperationDataStream, getCopyState(SequenceNumber upToSequenceNumber, OperationDataStream copyContext) enables the Primary replica to respond with an OperationDataStream. The stream contains objects that are delivered to the Secondary replica via the getCopyStream() method of the FabricReplicator class. The objects implement Operation and contain the specified data. When the Primary replica receives this call, it should create and return another OperationDataStream that contains OperationData. OperationData represents the data/state that the Secondary replica

long getLastCommittedSequenceNumber()

Obtains the last sequence number that the service has committed.

Remarks:This method is called on a service when it first starts up, in case it has any persistent state, and when data loss is suspected. When a stateful service replica starts up, it has the option to restore any data that might have persisted from previous updates. If it restores some state in this manner, its current progress is the last written sequence number for that data. A volatile service can simply return 0. Note that this method is not called to determine a new primary election during fail-over, because the current committed progress is already known by the FabricReplicator class at that time.

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<ActorReminderCollection> 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<Boolean> onDataLossAsync(CancellationToken cancellationToken)

Indicates that a write quorum of replicas in this replica set has been lost, and that therefore data loss might have occurred. The replica set consists of a majority of replicas, which includes the Primary replica.

Remarks:When the Service Fabric runtime observes the failure of a quorum of replicas, which includes the Primary replica, it elects a new Primary replica and immediately calls this method on the new Primary replica. A Primary replica that is informed of possible data loss can choose to restore its state from some external data source or can continue to run with the state that it currently has. If the service continues to run with its current state, it should return false from this method, which indicates that no state change has been made. If it has restored or altered its state, such as rolling back incomplete work, it should return true. If true is returned, then the state in other replicas must be assumed to be incorrect. Therefore, the Service Fabric runtime removes the other replicas from the replica set and recreates them.

CompletableFuture<?> onSnapshotAsync(Duration currentLogicalTime)
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 by microsoft.servicefabric.data.StateProviderReplica#backupAsync(BiFunction) or microsoft.servicefabric.data.StateProviderReplica#backupAsync(BackupOption, Duration, CancellationToken, BiFunction)Remarks:Backup/restore is not supported by VolatileActorStateProvider.

CompletableFuture<?> restoreAsync(String backupFolderPath, RestorePolicy restorePolicy, Duration timeout, CancellationToken cancellationToken)

Restore a backup taken by microsoft.servicefabric.data.StateProviderReplica#backupAsync(BiFunction) or microsoft.servicefabric.data.StateProviderReplica#backupAsync(BackupOption, Duration, CancellationToken, BiFunction)Remarks:Backup/restore is not supported by VolatileActorStateProvider.

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.

void setOnDataLossCallback(Function<CancellationToken, CompletableFuture<Boolean>> onDataLossAsync)

Function called during suspected data-loss

String traceId()
String traceType()
Duration transientErrorRetryDelay()
CompletableFuture<?> updateEpochAsync(Epoch epoch, SequenceNumber previousEpochLastSequenceNumber, CancellationToken cancellationToken)

Indicates to a replica that the configuration of a replica set has changed due to a change or attempted change to the Primary replica. The change occurs due to failure or load balancing of the previous Primary replica. Epoch changes act as a barrier by segmenting operations into the exact configuration periods in which they were sent by a specific Primary replica.

Remarks:This method is called because the Primary replica of the replica set has changed, or a change was attempted. Secondary replicas receive this method either when they are about to become the new Primary replica, or, if they are not the new Primary replica, they receive it when they attempt to get the first operation from the new Primary replica from the replication stream. Primary replicas might occasionally receive this method if there is an attempt to swap the Primary replica, which fails. The information in the updateEpochAsync(Epoch epoch, SequenceNumber previousEpochLastSequenceNumber, CancellationToken cancellationToken) method enables the service to maintain a progress vector, which is a list of each epoch that the replica has received, and the maximum LSN that they contained. The progress vector data along with the current applied maximum LSN is useful for a Secondary replica to send during the copy operation to describe how far the operation has progressed. Comparing progress vectors that are received from Secondary replicas during the copy operation enables Primary replicas to determine whether the Secondary replica is up-to-date, what state must be sent to the Secondary replica, and whether the Secondary replica has made false progress. False progress means that an LSN in a previous epoch was greater than the LSN that the Primary replica receives.

Constructor Details

VolatileActorStateProvider

public VolatileActorStateProvider()

Creates an instance of VolatileActorStateProvider.

VolatileActorStateProvider

public VolatileActorStateProvider(ReplicatorSettings replicatorSettings)

Creates an instance of VolatileActorStateProvider with specified replicator settings.

Parameters:

replicatorSettings - A ReplicatorSettings object that describes replicator settings.

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 life-cycle due to internal failures.

Overrides:

VolatileActorStateProvider.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:

VolatileActorStateProvider.actorActivatedAsync(ActorId actorId, CancellationToken cancellationToken)

Parameters:

actorId - Id of the actor that is activated.
cancellationToken -

CancellationToken object to indicate the cancellation status of the operation.

Returns:

A task that represents the asynchronous Actor activation notification processing.

backupAsync

public CompletableFuture backupAsync(BackupOption option, Duration timeout, CancellationToken cancellationToken, BiFunction> backupCallback)

Performs a full backup of state managed by this actor state provider

Remarks:Backup/restore is not supported by VolatileActorStateProvider.

Overrides:

VolatileActorStateProvider.backupAsync(BackupOption option, Duration timeout, CancellationToken cancellationToken, BiFunction<BackupInfo, CancellationToken, CompletableFuture<Boolean>> backupCallback)

Parameters:

option -

BackupOption for the callback

timeout -

java.time.Duration that describes timeout for the backup

cancellationToken - The token to monitor for cancellation requests.
backupCallback - BackupCallbackCallback to be called when the backup folder has been created locally and is ready to be moved out of the node.

Returns:

Task that represents the asynchronous backup operation.

Throws:

UnsupportedOperationException

backupAsync

public CompletableFuture backupAsync(BiFunction> backupCallback)

Performs a full backup of state managed by this actor state provider

Remarks:Backup/restore is not supported by VolatileActorStateProvider.

Overrides:

VolatileActorStateProvider.backupAsync(BiFunction<BackupInfo, CancellationToken, CompletableFuture<Boolean>> backupCallback)

Parameters:

backupCallback - BackupCallbackCallback to be called when the backup folder has been created locally and is ready to be moved out of the node.

Returns:

Task that represents the asynchronous backup operation.

Throws:

UnsupportedOperationException

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:

VolatileActorStateProvider.changeRoleAsync(ReplicaRole newRole, CancellationToken cancellationToken)

Parameters:

newRole - The new ReplicaRole, such as primary or secondary.
cancellationToken -

CancellationToken object to indicate the cancellation status of the operation.

Returns:

Task that represents the asynchronous change role operation.

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:

VolatileActorStateProvider.closeAsync(CancellationToken cancellationToken)

Parameters:

cancellationToken -

CancellationToken object to indicate the cancellation status of the operation.

Returns:

Task that represents the asynchronous close operation.

containsStateAsync

public CompletableFuture containsStateAsync(ActorId actorId, String stateName, CancellationToken cancellationToken)

Checks whether actor state provider contains an actor state with specified state name.

Overrides:

VolatileActorStateProvider.containsStateAsync(ActorId actorId, String stateName, CancellationToken cancellationToken)

Parameters:

actorId - ID of the actor for which to check state existence.
stateName - Name of the actor state to check for existence.
cancellationToken -

CancellationToken object to indicate the cancellation status of the operation.

Returns:

A task that represents the asynchronous check operation. The value of TResult parameter is true if state with specified name exists otherwise false.

currentReplicaRole

public ReplicaRole currentReplicaRole()

deleteReminderAsync

public CompletableFuture deleteReminderAsync(ActorId actorId, String reminderName, CancellationToken cancellationToken)

Deletes the specified actor reminder if it exists.

Overrides:

VolatileActorStateProvider.deleteReminderAsync(ActorId actorId, String reminderName, CancellationToken cancellationToken)

Parameters:

actorId - ID of the actor to delete the reminder.
reminderName - Name of the reminder to delete.
cancellationToken -

CancellationToken object to indicate the cancellation status of the operation.

Returns:

A task that represents the asynchronous delete operation.

deleteRemindersAsync

public CompletableFuture deleteRemindersAsync(Map> reminderNames, CancellationToken cancellationToken)

Deletes the specified set of reminders

Overrides:

VolatileActorStateProvider.deleteRemindersAsync(Map<ActorId, Collection<String>> reminderNames, CancellationToken cancellationToken)

Parameters:

reminderNames - The set of reminders to delete
cancellationToken -

CancellationToken object to indicate the cancellation status of the operation.

Returns:

A task that represents the asynchronous delete operation.

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:

VolatileActorStateProvider.enumerateStateNamesAsync(ActorId actorId, CancellationToken cancellationToken)

Parameters:

actorId - ID of the actor for which to create enumerable.
cancellationToken -

CancellationToken object to indicate the cancellation status of the operation.

Returns:

A task that represents the asynchronous enumeration operation. The value of TResult parameter is an enumerable of all state names associated with specified actor.

getActorsAsync

public CompletableFuture> getActorsAsync(int itemsCount, ContinuationToken continuationToken, CancellationToken cancellationToken)

Gets ActorIds from the State Provider.

Remarks: The

Overrides:

VolatileActorStateProvider.getActorsAsync(int itemsCount, ContinuationToken continuationToken, CancellationToken cancellationToken)

Parameters:

itemsCount - Number of items requested to be returned.
continuationToken - A continuation token to start querying the results from. A null value of continuation token means start returning values form the beginning.
cancellationToken -

CancellationToken object to indicate the cancellation status of the operation.

Returns:

A task that represents the asynchronous operation of call to server.

getCopyContext

public OperationDataStream getCopyContext()

Obtains context on a Secondary replica after it is created and opened to send context to the Primary replica.

Remarks:The Primary replica analyzes the context and sends back state via getCopyState(SequenceNumber upToSequenceNumber, OperationDataStream copyContext). getCopyContext() is called on newly created, idle Secondary replicas and provides a mechanism to asynchronously establish a bidirectional conversation with the Primary replica. The Secondary replica sends OperationData objects with which the Primary replica can determine the progress of collecting context on the Secondary replica. The Primary replica responds by sending the required state back. See getCopyState(SequenceNumber upToSequenceNumber, OperationDataStream copyContext) at the Primary replica for the other half of the exchange. For in-memory services, the getCopyContext() method is not called, as the state of the Secondary replicas is known (they are empty and will require all of the state).

Overrides:

VolatileActorStateProvider.getCopyContext()

Returns:

Returns OperationDataStream.

getCopyState

public OperationDataStream getCopyState(SequenceNumber upToSequenceNumber, OperationDataStream copyContext)

Obtains state on a Primary replica that is required to build a Secondary replica.

Remarks:Just as getCopyContext() enables the Secondary replica to send context to the Primary replica via an OperationDataStream, getCopyState(SequenceNumber upToSequenceNumber, OperationDataStream copyContext) enables the Primary replica to respond with an OperationDataStream. The stream contains objects that are delivered to the Secondary replica via the getCopyStream() method of the FabricReplicator class. The objects implement Operation and contain the specified data. When the Primary replica receives this call, it should create and return another OperationDataStream that contains OperationData. OperationData represents the data/state that the Secondary replica

Overrides:

VolatileActorStateProvider.getCopyState(SequenceNumber upToSequenceNumber, OperationDataStream copyContext)

Parameters:

upToSequenceNumber - The maximum last sequence number (LSN) that should be placed in the copy stream via the getCopyStream() method. LSNs greater than this number are delivered to the Secondary replica as a part of the replication stream via the getReplicationStream() method.
copyContext - An OperationDataStream that contains the OperationData objects that are created by the Secondary replica. requires to catch up to the provided

Returns:

Returns OperationDataStream.

Throws:

IllegalStateException

getLastCommittedSequenceNumber

public long getLastCommittedSequenceNumber()

Obtains the last sequence number that the service has committed.

Remarks:This method is called on a service when it first starts up, in case it has any persistent state, and when data loss is suspected. When a stateful service replica starts up, it has the option to restore any data that might have persisted from previous updates. If it restores some state in this manner, its current progress is the last written sequence number for that data. A volatile service can simply return 0. Note that this method is not called to determine a new primary election during fail-over, because the current committed progress is already known by the FabricReplicator class at that time.

Overrides:

VolatileActorStateProvider.getLastCommittedSequenceNumber()

Returns:

Returns long.

initialize

public void initialize(ActorTypeInformation actorTypeInformation)

Initializes the actor state provider with type information of the actor type associated with it.

Overrides:

VolatileActorStateProvider.initialize(ActorTypeInformation actorTypeInformation)

Parameters:

actorTypeInformation -

ActorTypeInformation Type information of the actor class.

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:

VolatileActorStateProvider.initialize(StatefulServiceInitializationParameters initializationParameters)

Parameters:

initializationParameters -

StatefulServiceInitializationParameters such as service name, partition id, replica id, and code package information.

loadRemindersAsync

public CompletableFuture loadRemindersAsync(CancellationToken cancellationToken)

Loads all the reminders contained in the actor state provider.

Overrides:

VolatileActorStateProvider.loadRemindersAsync(CancellationToken cancellationToken)

Parameters:

cancellationToken -

CancellationToken object to indicate the cancellation status of the operation.

Returns:

A task that represents the asynchronous load operation. The value of TResult parameter is a collection of all actor reminders contained in the actor state provider.

loadStateAsync

public CompletableFuture loadStateAsync(ActorId actorId, String stateName, CancellationToken cancellationToken)

Loads the actor state associated with the specified state name.

Overrides:

VolatileActorStateProvider.loadStateAsync(ActorId actorId, String stateName, CancellationToken cancellationToken)

Parameters:

actorId - Id of the actor that is activated.
stateName - StateName.
cancellationToken -

CancellationToken object to indicate the cancellation status of the operation.

Returns:

A task that represents the asynchronous load operation. The value of TResult parameter contains value of actor state associated with given state name.

Throws:

FabricKeyNotFoundException - If Actor state associated with specified state name does not exist.

onDataLossAsync

public CompletableFuture onDataLossAsync(CancellationToken cancellationToken)

Indicates that a write quorum of replicas in this replica set has been lost, and that therefore data loss might have occurred. The replica set consists of a majority of replicas, which includes the Primary replica.

Remarks:When the Service Fabric runtime observes the failure of a quorum of replicas, which includes the Primary replica, it elects a new Primary replica and immediately calls this method on the new Primary replica. A Primary replica that is informed of possible data loss can choose to restore its state from some external data source or can continue to run with the state that it currently has. If the service continues to run with its current state, it should return false from this method, which indicates that no state change has been made. If it has restored or altered its state, such as rolling back incomplete work, it should return true. If true is returned, then the state in other replicas must be assumed to be incorrect. Therefore, the Service Fabric runtime removes the other replicas from the replica set and recreates them.

Overrides:

VolatileActorStateProvider.onDataLossAsync(CancellationToken cancellationToken)

Parameters:

cancellationToken -

CancellationToken object to indicate the cancellation status of the operation.

Returns:

Returns java.util.concurrent.CompletableFuture of type java.lang.Boolean, that indicates whether state changed. When it changed, the method returns true or when it did not change, the method returns false.

onSnapshotAsync

public CompletableFuture onSnapshotAsync(Duration currentLogicalTime)

Parameters:

currentLogicalTime

openAsync

public CompletableFuture 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.

Overrides:

VolatileActorStateProvider.openAsync(ReplicaOpenMode openMode, StatefulServicePartition partition, CancellationToken cancellationToken)

Parameters:

openMode - The ReplicaOpenMode that indicates whether this is a new or existing replica.
partition - The StatefulServicePartition partition the replica belongs to.
cancellationToken -

CancellationToken object to indicate the cancellation status of the operation.

Returns:

Task that represents the asynchronous open operation. The result contains the replicator responsible for replicating state between other state provider replicas in the partition.

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:

VolatileActorStateProvider.reminderCallbackCompletedAsync(ActorId actorId, ActorReminder reminder, CancellationToken cancellationToken)

Parameters:

actorId - ID of the actor which own reminder
reminder - Actor reminder that completed successfully.
cancellationToken - The token to monitor for cancellation requests.

Returns:

A task that represents the asynchronous reminder callback completed notification processing.

removeActorAsync

public CompletableFuture removeActorAsync(ActorId actorId, CancellationToken cancellationToken)

Removes all the existing states and reminders associated with specified actor atomically.

Overrides:

VolatileActorStateProvider.removeActorAsync(ActorId actorId, CancellationToken cancellationToken)

Parameters:

actorId - ID of the actor for which to remove state.
cancellationToken -

CancellationToken object to indicate the cancellation status of the operation.

Returns:

A task that represents the asynchronous remove operation.

restoreAsync

public CompletableFuture restoreAsync(String backupFolderPath)

Restore a backup taken by microsoft.servicefabric.data.StateProviderReplica#backupAsync(BiFunction) or microsoft.servicefabric.data.StateProviderReplica#backupAsync(BackupOption, Duration, CancellationToken, BiFunction)Remarks:Backup/restore is not supported by VolatileActorStateProvider.

Overrides:

VolatileActorStateProvider.restoreAsync(String backupFolderPath)

Parameters:

backupFolderPath - Directory from where replica will be restored from.

Returns:

Task that represents the asynchronous restore operation.

Throws:

UnsupportedOperationException

restoreAsync

public CompletableFuture restoreAsync(String backupFolderPath, RestorePolicy restorePolicy, Duration timeout, CancellationToken cancellationToken)

Restore a backup taken by microsoft.servicefabric.data.StateProviderReplica#backupAsync(BiFunction) or microsoft.servicefabric.data.StateProviderReplica#backupAsync(BackupOption, Duration, CancellationToken, BiFunction)Remarks:Backup/restore is not supported by VolatileActorStateProvider.

Overrides:

VolatileActorStateProvider.restoreAsync(String backupFolderPath, RestorePolicy restorePolicy, Duration timeout, CancellationToken cancellationToken)

Parameters:

backupFolderPath - Directory from where replica will be restored from.
restorePolicy - The RestorePolicy.
timeout - The timeout for this operation.
cancellationToken - The token to monitor for cancellation requests.

Returns:

Task that represents the asynchronous restore operation.

Throws:

UnsupportedOperationException

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:

VolatileActorStateProvider.saveReminderAsync(ActorId actorId, ActorReminder reminder, CancellationToken cancellationToken)

Parameters:

actorId - ID of actor for which to save reminder.
reminder - Actor reminder to save.
cancellationToken -

CancellationToken object to indicate the cancellation status of the operation.

Returns:

A task that represents the asynchronous save operation.

saveStateAsync

public CompletableFuture saveStateAsync(ActorId actorId, List stateChanges, CancellationToken cancellationToken)

Saves the specified set of actor state changes atomically.

Overrides:

VolatileActorStateProvider.saveStateAsync(ActorId actorId, List<ActorStateChange> stateChanges, CancellationToken cancellationToken)

Parameters:

actorId - ID of the actor for which to save the state changes.
stateChanges - Collection of state changes to save.
cancellationToken -

CancellationToken object to indicate the cancellation status of the operation.

Returns:

A task that represents the asynchronous save operation. 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.

setOnDataLossCallback

public void setOnDataLossCallback(Function> onDataLossAsync)

Function called during suspected data-loss

Overrides:

VolatileActorStateProvider.setOnDataLossCallback(Function<CancellationToken, CompletableFuture<Boolean>> onDataLossAsync)

Parameters:

onDataLossAsync - TODO. Function called as part of suspected data loss processing. Function takes in CancellationToken and returns a CompletableFuture that represents the asynchronous processing of the event. Returning true, indicates that the replica's state has been restored. False indicates that the replica's state has not been changed.

traceId

public String traceId()

traceType

public String traceType()

transientErrorRetryDelay

public Duration transientErrorRetryDelay()

updateEpochAsync

public CompletableFuture updateEpochAsync(Epoch epoch, SequenceNumber previousEpochLastSequenceNumber, CancellationToken cancellationToken)

Indicates to a replica that the configuration of a replica set has changed due to a change or attempted change to the Primary replica. The change occurs due to failure or load balancing of the previous Primary replica. Epoch changes act as a barrier by segmenting operations into the exact configuration periods in which they were sent by a specific Primary replica.

Remarks:This method is called because the Primary replica of the replica set has changed, or a change was attempted. Secondary replicas receive this method either when they are about to become the new Primary replica, or, if they are not the new Primary replica, they receive it when they attempt to get the first operation from the new Primary replica from the replication stream. Primary replicas might occasionally receive this method if there is an attempt to swap the Primary replica, which fails. The information in the updateEpochAsync(Epoch epoch, SequenceNumber previousEpochLastSequenceNumber, CancellationToken cancellationToken) method enables the service to maintain a progress vector, which is a list of each epoch that the replica has received, and the maximum LSN that they contained. The progress vector data along with the current applied maximum LSN is useful for a Secondary replica to send during the copy operation to describe how far the operation has progressed. Comparing progress vectors that are received from Secondary replicas during the copy operation enables Primary replicas to determine whether the Secondary replica is up-to-date, what state must be sent to the Secondary replica, and whether the Secondary replica has made false progress. False progress means that an LSN in a previous epoch was greater than the LSN that the Primary replica receives.

Overrides:

VolatileActorStateProvider.updateEpochAsync(Epoch epoch, SequenceNumber previousEpochLastSequenceNumber, CancellationToken cancellationToken)

Parameters:

epoch - The new Epoch.
previousEpochLastSequenceNumber - The maximum sequence number (LSN) that should have been observed in the previous epoch.
cancellationToken -

CancellationToken object to indicate the cancellation status of the operation.

Returns:

Returns Task.

Applies to