StatefulServiceReplica Interface
public interface StatefulServiceReplica
Defines behavior that governs the lifecycle of a replica, such as startup, initialization, role changes, and shutdown.
Remarks:Stateful service types must implement this interface. The logic of a stateful service type includes behavior that is invoked on Primary replicas and behavior that is invoked on Secondary replicas. If the service author wants to make use of the provided FabricReplicator, then the service must also implement StateProvider to use the implementation of StateReplicator that is provided by FabricReplicator
Method Summary
Modifier and Type | Method and Description |
---|---|
void |
abort()
Ungracefully terminates an instance.
Remarks:Lease loss and, in response to the service, the use of reportFault(FaultType faultType) to report a Permanent fault are examples of ungraceful termination. When this method is invoked, the service instance should immediately release and clean up all references and return. |
CompletableFuture<String> |
changeRoleAsync(ReplicaRole newRole, CancellationToken cancellationToken)
Changes the role of a Primary or Secondary replica.
Remarks:The new role is indicated as a parameter. When the service transitions to the new role, the service has a chance to update its current listening address. The listening address is the address where clients connect to it. This enables the service when it is a Primary replica to only claim some resources such as ports when communication from clients is expected. |
CompletableFuture<Void> |
closeAsync(CancellationToken cancellationToken)
Closes the service replica when it is being shut down. Note that cancellation is advisory and that the operation might still be completed even if it is canceled. |
void |
initialize(StatefulServiceInitializationParameters initializationParameters)
Initializes a newly created service replica. |
CompletableFuture<Replicator> |
openAsync(ReplicaOpenMode openMode, StatefulServicePartition partition, CancellationToken cancellationToken)
Opens an initialized service replica so that additional actions can be taken. |
Method Details
abort
public void abort()
Ungracefully terminates an instance.
Remarks:Lease loss and, in response to the service, the use of reportFault(FaultType faultType) to report a Permanent fault are examples of ungraceful termination. When this method is invoked, the service instance should immediately release and clean up all references and return.
changeRoleAsync
public CompletableFuture
Changes the role of a Primary or Secondary replica.
Remarks:The new role is indicated as a parameter. When the service transitions to the new role, the service has a chance to update its current listening address. The listening address is the address where clients connect to it. This enables the service when it is a Primary replica to only claim some resources such as ports when communication from clients is expected.
Parameters:
CancellationToken object to indicate the cancellation status of the operation.
Returns:
closeAsync
public CompletableFuture
Closes the service replica when it is being shut down. Note that cancellation is advisory and that the operation might still be completed even if it is canceled.
Parameters:
CancellationToken object to indicate the cancellation status of the operation.
Returns:
initialize
public void initialize(StatefulServiceInitializationParameters initializationParameters)
Initializes a newly created service replica.
Parameters:
openAsync
public CompletableFuture
Opens an initialized service replica so that additional actions can be taken.
Parameters:
CancellationToken object to indicate the cancellation status of the operation.
Returns:
Applies to
Azure SDK for Java