Compartir vía


FabricActorService Class

  • java.lang.Object

public class FabricActorService extends StatefulServiceBase implements ActorService

Represents the base class for Microsoft Service Fabric based reliable actors service.

Remarks:Derive from this class to implement your own custom actor service if you want to override any service level behavior for your actors.

Constructor Summary

Constructor Description
FabricActorService(StatefulServiceContext context, ActorTypeInformation actorTypeInfo)

Initializes a new instance of the ActorService class.

FabricActorService(StatefulServiceContext context, ActorTypeInformation actorTypeInfo, BiFunction<FabricActorService, ActorId, ActorBase> actorFactory)

Initializes a new instance of the ActorService class.

FabricActorService(StatefulServiceContext context, ActorTypeInformation actorTypeInfo, BiFunction<FabricActorService, ActorId, ActorBase> actorFactory, BiFunction<ActorBase, ActorStateProvider, ActorStateManager> stateManagerFactory, ActorStateProvider stateProvider, ActorServiceSettings settings)

Initializes a new instance of the ActorService class.

Method Summary

Modifier and Type Method and Description
List<ServiceReplicaListener> createServiceReplicaListeners()

Creates Service Replica Listeners.

CompletableFuture<?> deleteActorAsync(ActorId actorId, CancellationToken cancellationToken)

Deletes an Actor from the Actor service.

An active actor, will be deactivated and its state will also be deleted from state provider. An in-active actor's state will be deleted from state provider. If this method is called for a non-existent actor id in the system, it will be a no-op.

CompletableFuture<PagedResult<ActorInformation>> getActorsAsync(ContinuationToken continuationToken, CancellationToken cancellationToken)

Gets the list of Actors by querying the actor service.

ActorTypeInformation getActorTypeInformation()

Gets ActorTypeInformation for actor service.

ActorServiceSettings getSettings()

Gets settings for the actor service.

ActorStateProvider getStateProvider()

Gets a ActorStateProvider that represents the state provider for the actor service.

void onAbort()

Overrides onAbort()

CompletableFuture<?> onChangeRoleAsync(ReplicaRole newRole, CancellationToken cancellationToken)

Overrides onChangeRoleAsync(ReplicaRole newRole, CancellationToken cancellationToken)

CompletableFuture<?> onCloseAsync(CancellationToken cancellationToken)

Overrides onCloseAsync(CancellationToken cancellationToken)

CompletableFuture<?> onOpenAsync(ReplicaOpenMode openMode, CancellationToken cancellationToken)

This method is called as the final step of opening the service. Override this method to be notified that Open has completed for this replica's internal components.

CompletableFuture<?> runAsync(CancellationToken cancellationToken)

Overrides runAsync(CancellationToken cancellationToken)

Inherited Members

Constructor Details

FabricActorService

public FabricActorService(StatefulServiceContext context, ActorTypeInformation actorTypeInfo)

Initializes a new instance of the ActorService class.

Parameters:

context - Service context the actor service is operating under.
actorTypeInfo - Type information of the actor.

FabricActorService

public FabricActorService(StatefulServiceContext context, ActorTypeInformation actorTypeInfo, BiFunction actorFactory)

Initializes a new instance of the ActorService class.

Parameters:

context - Service context the actor service is operating under.
actorTypeInfo - Type information of the actor.
actorFactory - A factory method to create actor objects.

FabricActorService

public FabricActorService(StatefulServiceContext context, ActorTypeInformation actorTypeInfo, BiFunction actorFactory, BiFunction stateManagerFactory, ActorStateProvider stateProvider, ActorServiceSettings settings)

Initializes a new instance of the ActorService class.

Parameters:

context - Service context the actor service is operating under.
actorTypeInfo - Type information of the actor.
actorFactory - A factory method to create actor objects.
stateManagerFactory - A factory method to create ActorStateManager.
stateProvider - State provider to store the state for actor objects.
settings - Settings to configures behavior of Actor Service.

Method Details

createServiceReplicaListeners

protected List createServiceReplicaListeners()

Creates Service Replica Listeners.

Returns:

Endpoint string pairs like {"Endpoints":{"Listener1":"Endpoint1","Listener2":"Endpoint2" ...}}

deleteActorAsync

public CompletableFuture deleteActorAsync(ActorId actorId, CancellationToken cancellationToken)

Deletes an Actor from the Actor service.

An active actor, will be deactivated and its state will also be deleted from state provider. An in-active actor's state will be deleted from state provider. If this method is called for a non-existent actor id in the system, it will be a no-op.

Overrides:

FabricActorService.deleteActorAsync(ActorId actorId, CancellationToken cancellationToken)

Parameters:

actorId -

ActorId of the actor to be deleted.

cancellationToken -

CancellationToken object to indicate the cancellation status of the operation.

Returns:

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

getActorsAsync

public CompletableFuture> getActorsAsync(ContinuationToken continuationToken, CancellationToken cancellationToken)

Gets the list of Actors by querying the actor service.

Overrides:

FabricActorService.getActorsAsync(ContinuationToken continuationToken, CancellationToken cancellationToken)

Parameters:

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 CompletableFuture that represents the asynchronous operation of call to server.

getActorTypeInformation

public ActorTypeInformation getActorTypeInformation()

Gets ActorTypeInformation for actor service.

Returns:

ActorTypeInformation for the actor hosted by the service replica.

getSettings

public ActorServiceSettings getSettings()

Gets settings for the actor service.

Returns:

Settings for the actor service.

getStateProvider

public ActorStateProvider getStateProvider()

Gets a ActorStateProvider that represents the state provider for the actor service.

Returns:

ActorStateProvider representing the state provider for the actor service.

onAbort

protected void onAbort()

Overrides onAbort()

onChangeRoleAsync

protected CompletableFuture onChangeRoleAsync(ReplicaRole newRole, CancellationToken cancellationToken)

Overrides onChangeRoleAsync(ReplicaRole newRole, CancellationToken cancellationToken)

Parameters:

newRole - New role for the replica.
cancellationToken -

CancellationToken object to indicate the cancellation status of the operation.

Returns:

A task that represents the asynchronous operation performed when the replica becomes primary.

onCloseAsync

protected CompletableFuture onCloseAsync(CancellationToken cancellationToken)

Overrides onCloseAsync(CancellationToken cancellationToken)

Parameters:

cancellationToken - The token to monitor for cancellation requests.

Returns:

A task that represents the asynchronous operation performed when the replica is closed.

onOpenAsync

protected CompletableFuture onOpenAsync(ReplicaOpenMode openMode, CancellationToken cancellationToken)

This method is called as the final step of opening the service. Override this method to be notified that Open has completed for this replica's internal components.

Parameters:

openMode - for this service replica.
cancellationToken -

CancellationToken object to indicate the cancellation status of the operation.

Returns:

A CompletableFuture that represents outstanding operation.

runAsync

protected CompletableFuture runAsync(CancellationToken cancellationToken)

Overrides runAsync(CancellationToken cancellationToken)

Parameters:

cancellationToken -

CancellationToken object to indicate the cancellation status of the operation.

Returns:

A task that represents the asynchronous operation of loading reminders when the replica becomes primary.

Applies to