Compartir vía


ActorStateProvider Interface

public interface ActorStateProvider extends StateProviderReplica

Represents the interface that an actor state provider needs to implement for actor runtime to communicate with it.

Method Summary

Modifier and Type Method and Description
CompletableFuture<?> actorActivatedAsync(ActorId actorId, CancellationToken cancellationToken)

This method is invoked as part of the activation process of the actor with the specified Id.

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<PagedResult<ActorId>> 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.

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<?> 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<?> 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.

Inherited Members

Method Details

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.

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.

containsStateAsync

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

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

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.

deleteReminderAsync

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

Deletes the specified actor reminder if it exists.

Parameters:

actorId - ID of the actor for which 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

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.

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 numItemsToReturn, ContinuationToken continuationToken, CancellationToken cancellationToken)

Gets ActorIds from the State Provider.

Remarks: The

Parameters:

numItemsToReturn - 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.

initialize

public void initialize(ActorTypeInformation actorTypeInformation)

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

Parameters:

actorTypeInformation - Type information of the actor class

loadRemindersAsync

public CompletableFuture loadRemindersAsync(CancellationToken cancellationToken)

Loads all the reminders contained in the actor state provider.

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.

Parameters:

actorId - ID of the actor for which to load the state.
stateName - Name of the actor state to load.
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.

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

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.

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.

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.

Parameters:

actorId - ID of the actor for which to save the 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.

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.

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.

Applies to