ActorStateManager Interface

public interface ActorStateManager

Represents the interface that state manager for Actor implements.

Method Summary

Modifier and Type Method and Description
<T> CompletableFuture<T> addOrUpdateStateAsync(String stateName, T addValue, BiFunction<String, T, T> updateValueFactory)

Adds an actor state with given state name, if it does not already exist or updates specified state name and value, if it does not exist.

<T> CompletableFuture<T> addOrUpdateStateAsync(String stateName, T addValue, BiFunction<String, T, T> updateValueFactory, CancellationToken cancellationToken)

Adds an actor state with given state name, if it does not already exist or updates specified state name and value, if it does not exist.

<T> CompletableFuture<?> addStateAsync(String stateName, T value)

Adds an actor state with given state name.

<T> CompletableFuture<?> addStateAsync(String stateName, T value, CancellationToken cancellationToken)

Adds an actor state with given state name.

CompletableFuture<?> clearCacheAsync()

Clears all the cached actor states and any operation(s) performed on ActorStateManager since last state save operation.

Remarks: All the operation(s) performed on ActorStateManager since last save operation are cleared on clearing the cache and will not be included in next save operation.

CompletableFuture<?> clearCacheAsync(CancellationToken cancellationToken)

Clears all the cached actor states and any operation(s) performed on ActorStateManager since last state save operation.

Remarks: All the operation(s) performed on ActorStateManager since last save operation are cleared on clearing the cache and will not be included in next save operation.

CompletableFuture<Boolean> containsStateAsync(String stateName)

Checks if an actor state with specified name exists.

CompletableFuture<Boolean> containsStateAsync(String stateName, CancellationToken cancellationToken)

Checks if an actor state with specified name exists.

<T> CompletableFuture<T> getOrAddStateAsync(String stateName, T value)

Gets an actor state with given state name, if it exists or adds the state with the state with specified state name, if it exists.

<T> CompletableFuture<T> getOrAddStateAsync(String stateName, T value, CancellationToken cancellationToken)

Gets an actor state with given state name, if it exists or adds the state with the state with specified state name, if it exists.

<T> CompletableFuture<T> getStateAsync(String stateName)

Gets an actor state with specified state name.

<T> CompletableFuture<T> getStateAsync(String stateName, CancellationToken cancellationToken)

Gets an actor state with specified state name.

CompletableFuture<List<String>> getStateNamesAsync()

Creates an List of all actor state names for current actor.

CompletableFuture<List<String>> getStateNamesAsync(CancellationToken cancellationToken)

Creates an List of all actor state names for current actor.

CompletableFuture<?> removeStateAsync(String stateName)

Removes an actor state with given state name to specified value.

CompletableFuture<?> removeStateAsync(String stateName, CancellationToken cancellationToken)

Removes an actor state with given state name to specified value.

CompletableFuture<?> saveStateAsync()

Saves all the cached state changes (add/update/remove) that were made since last call to saveStateAsync(CancellationToken cancellationToken) by actor runtime or by user explicitly.

CompletableFuture<?> saveStateAsync(CancellationToken cancellationToken)

Saves all the cached state changes (add/update/remove) that were made since last call to saveStateAsync(CancellationToken cancellationToken) by actor runtime or by user explicitly.

<T> CompletableFuture<?> setStateAsync(String stateName, T value)

Removes an actor state with specified state name. If an actor state with specified name does not exist, it is added.

<T> CompletableFuture<?> setStateAsync(String stateName, T value, CancellationToken cancellationToken)

Removes an actor state with specified state name. If an actor state with specified name does not exist, it is added.

<T> CompletableFuture<Boolean> tryAddStateAsync(String stateName, T value)

Attempts to add an actor state with given state name.

<T> CompletableFuture<Boolean> tryAddStateAsync(String stateName, T value, CancellationToken cancellationToken)

Attempts to add an actor state with given state name.

<T> CompletableFuture<ConditionalValue<T>> tryGetStateAsync(String stateName)

Attempts to get an actor state with specified state name.

<T> CompletableFuture<ConditionalValue<T>> tryGetStateAsync(String stateName, CancellationToken cancellationToken)

Attempts to get an actor state with specified state name.

CompletableFuture<Boolean> tryRemoveStateAsync(String stateName)

Attempts to remove an actor state with specified state name.

CompletableFuture<Boolean> tryRemoveStateAsync(String stateName, CancellationToken cancellationToken)

Attempts to remove an actor state with specified state name.

Method Details

addOrUpdateStateAsync

public CompletableFuture addOrUpdateStateAsync(String stateName, T addValue, BiFunction updateValueFactory)

Adds an actor state with given state name, if it does not already exist or updates specified state name and value, if it does not exist.

Parameters:

stateName - Name of the actor state to add or get.
addValue - Value of the actor state to add if it doesn't exist.
updateValueFactory - Factory function to generate value of actor state to update if it exists.

Returns:

A task that represents the asynchronous add/update operation. The value of T parameter contains value of actor state that was added/updated.

addOrUpdateStateAsync

public CompletableFuture addOrUpdateStateAsync(String stateName, T addValue, BiFunction updateValueFactory, CancellationToken cancellationToken)

Adds an actor state with given state name, if it does not already exist or updates specified state name and value, if it does not exist.

Parameters:

stateName - Name of the actor state to add or get.
addValue - Value of the actor state to add if it doesn't exist.
updateValueFactory - Factory function to generate value of actor state to update if it exists.
cancellationToken -

CancellationToken object to indicate the cancellation status of the operation.

Returns:

A task that represents the asynchronous add/update operation. The value of T parameter contains value of actor state that was added/updated.

addStateAsync

public CompletableFuture addStateAsync(String stateName, T value)

Adds an actor state with given state name.

Parameters:

stateName - Name of the actor state to add.
value - Value of the actor state to add.

Returns:

A task that represents the asynchronous add operation.

addStateAsync

public CompletableFuture addStateAsync(String stateName, T value, CancellationToken cancellationToken)

Adds an actor state with given state name.

Parameters:

stateName - Name of the actor state to add.
value - Value of the actor state to add.
cancellationToken -

CancellationToken object to indicate the cancellation status of the operation.

Returns:

A task that represents the asynchronous add operation.

clearCacheAsync

public CompletableFuture clearCacheAsync()

Clears all the cached actor states and any operation(s) performed on ActorStateManager since last state save operation.

Remarks: All the operation(s) performed on ActorStateManager since last save operation are cleared on clearing the cache and will not be included in next save operation.

Returns:

A task that represents the asynchronous clear cache operation.

clearCacheAsync

public CompletableFuture clearCacheAsync(CancellationToken cancellationToken)

Clears all the cached actor states and any operation(s) performed on ActorStateManager since last state save operation.

Remarks: All the operation(s) performed on ActorStateManager since last save operation are cleared on clearing the cache and will not be included in next save operation.

Parameters:

cancellationToken -

CancellationToken object to indicate the cancellation status of the operation.

Returns:

A task that represents the asynchronous clear cache operation.

containsStateAsync

public CompletableFuture containsStateAsync(String stateName)

Checks if an actor state with specified name exists.

Parameters:

stateName - Name of the actor state.

Returns:

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

containsStateAsync

public CompletableFuture containsStateAsync(String stateName, CancellationToken cancellationToken)

Checks if an actor state with specified name exists.

Parameters:

stateName - Name of the actor state.
cancellationToken -

CancellationToken object to indicate the cancellation status of the operation.

Returns:

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

getOrAddStateAsync

public CompletableFuture getOrAddStateAsync(String stateName, T value)

Gets an actor state with given state name, if it exists or adds the state with the state with specified state name, if it exists.

Parameters:

stateName - Name of the actor state to add/update.
value - Value of the actor state to add /update.

Returns:

A task that represents the asynchronous add or get operation. The value of T parameter contains the value of the actor state with the given state.

getOrAddStateAsync

public CompletableFuture getOrAddStateAsync(String stateName, T value, CancellationToken cancellationToken)

Gets an actor state with given state name, if it exists or adds the state with the state with specified state name, if it exists.

Parameters:

stateName - Name of the actor state to add/update.
value - Value of the actor state to add /update.
cancellationToken -

CancellationToken object to indicate the cancellation status of the operation.

Returns:

A task that represents the asynchronous add or get operation. The value of T parameter contains the value of the actor state with the given state.

getStateAsync

public CompletableFuture getStateAsync(String stateName)

Gets an actor state with specified state name.

Parameters:

stateName - Name of the actor state to add.

Returns:

A task that represents the asynchronous get operation. The value of T parameter contains value of actor state with given state name.

getStateAsync

public CompletableFuture getStateAsync(String stateName, CancellationToken cancellationToken)

Gets an actor state with specified state name.

Parameters:

stateName - Name of the actor state to add.
cancellationToken -

CancellationToken object to indicate the cancellation status of the operation.

Returns:

A task that represents the asynchronous get operation. The value of T parameter contains value of actor state with given state name.

getStateNamesAsync

public CompletableFuture<>> getStateNamesAsync()

Creates an List of all actor state names for current actor.

Returns:

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

getStateNamesAsync

public CompletableFuture<>> getStateNamesAsync(CancellationToken cancellationToken)

Creates an List of all actor state names for current actor.

Parameters:

cancellationToken -

CancellationToken object to indicate the cancellation status of the operation.

Returns:

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

removeStateAsync

public CompletableFuture removeStateAsync(String stateName)

Removes an actor state with given state name to specified value.

Parameters:

stateName - Name of the actor state to remove.

Returns:

A task that represents the asynchronous remove operation.

removeStateAsync

public CompletableFuture removeStateAsync(String stateName, CancellationToken cancellationToken)

Removes an actor state with given state name to specified value.

Parameters:

stateName - Name of the actor state to remove.
cancellationToken -

CancellationToken object to indicate the cancellation status of the operation.

Returns:

A task that represents the asynchronous remove operation.

saveStateAsync

public CompletableFuture saveStateAsync()

Saves all the cached state changes (add/update/remove) that were made since last call to saveStateAsync(CancellationToken cancellationToken) by actor runtime or by user explicitly.

Returns:

A task that represents the asynchronous save operation.

saveStateAsync

public CompletableFuture saveStateAsync(CancellationToken cancellationToken)

Saves all the cached state changes (add/update/remove) that were made since last call to saveStateAsync(CancellationToken cancellationToken) by actor runtime or by user explicitly.

Parameters:

cancellationToken -

CancellationToken object to indicate the cancellation status of the operation.

Returns:

A task that represents the asynchronous save operation.

setStateAsync

public CompletableFuture setStateAsync(String stateName, T value)

Removes an actor state with specified state name. If an actor state with specified name does not exist, it is added.

Parameters:

stateName - Name of the actor state to set.
value - Value of the actor state to set.

Returns:

A task that represents the asynchronous set operation.

setStateAsync

public CompletableFuture setStateAsync(String stateName, T value, CancellationToken cancellationToken)

Removes an actor state with specified state name. If an actor state with specified name does not exist, it is added.

Parameters:

stateName - Name of the actor state to set.
value - Value of the actor state to set.
cancellationToken -

CancellationToken object to indicate the cancellation status of the operation.

Returns:

A task that represents the asynchronous set operation.

tryAddStateAsync

public CompletableFuture tryAddStateAsync(String stateName, T value)

Attempts to add an actor state with given state name.

Parameters:

stateName - Name of the actor state to add.
value - Value of the actor state to add.

Returns:

A task that represents the asynchronous add operation. The value of T parameter indicates if the state was successfully added.

tryAddStateAsync

public CompletableFuture tryAddStateAsync(String stateName, T value, CancellationToken cancellationToken)

Attempts to add an actor state with given state name.

Parameters:

stateName - Name of the actor state to add.
value - Value of the actor state to add.
cancellationToken -

CancellationToken object to indicate the cancellation status of the operation.

Returns:

A task that represents the asynchronous add operation. The value of T parameter indicates if the state was successfully added.

tryGetStateAsync

public CompletableFuture<>> tryGetStateAsync(String stateName)

Attempts to get an actor state with specified state name.

Parameters:

stateName - Name of the actor state to get.

Returns:

A task that represents the asynchronous get operation. The value of T parameter contains ConditionalValue indicating whether the actor state is present and the value of actor state if it is present.

tryGetStateAsync

public CompletableFuture<>> tryGetStateAsync(String stateName, CancellationToken cancellationToken)

Attempts to get an actor state with specified state name.

Parameters:

stateName - Name of the actor state to get.
cancellationToken -

CancellationToken object to indicate the cancellation status of the operation.

Returns:

A task that represents the asynchronous get operation. The value of T parameter contains ConditionalValue indicating whether the actor state is present and the value of actor state if it is present.

tryRemoveStateAsync

public CompletableFuture tryRemoveStateAsync(String stateName)

Attempts to remove an actor state with specified state name.

Parameters:

stateName - Name of the actor state to remove.

Returns:

A task that represents the asynchronous remove operation. The value of T parameter indicates if the state was successfully removed.

tryRemoveStateAsync

public CompletableFuture tryRemoveStateAsync(String stateName, CancellationToken cancellationToken)

Attempts to remove an actor state with specified state name.

Parameters:

stateName - Name of the actor state to remove.
cancellationToken -

CancellationToken object to indicate the cancellation status of the operation.

Returns:

A task that represents the asynchronous remove operation. The value of T parameter indicates if the state was successfully removed.

Applies to