你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

StateReplicator Interface

public interface StateReplicator

Exposes replication related functions of the FabricReplicator class that are used by StateProvider to replicate state to ensure high availability.

Method Summary

Modifier and Type Method and Description
OperationStream getCopyStream()

Gets copy stream

OperationStream getReplicationStream()

Gets replication stream.

CompletableFuture<SequenceNumber> replicateAsync(OperationData operationData, SequenceNumber sequenceNumber, CancellationToken cancellationToken)

Replicates state changes from Primary replica to the Secondary replicas and receives a quorum acknowledgement that those state changes have been applied.

void updateReplicatorSettings(ReplicatorSettings settings)

Enables modification of replicator settings during runtime. The only setting which can be modified is the security credentials.

Method Details

getCopyStream

public OperationStream getCopyStream()

Gets copy stream

Returns:

The returned CopyStream contains OperationData objects that implement Operation. The OperationData objects are obtained from the CopyState OperationDataStream that the Primary replica returns from getCopyState(SequenceNumber upToSequenceNumber, OperationDataStream copyContext). When a replica is created and has to catch up, it should obtain the CopyStream and begin to send, apply, and acknowledge the Copy objects that implement Operation. In parallel, the replica responds to the corresponding getCopyContext() and getNextAsync(CancellationToken cancellationToken)calls. The stream is empty when the returned Operation method is null.

getReplicationStream

public OperationStream getReplicationStream()

Gets replication stream.

Returns:

The ReplicationStream implements OperationStream. The ReplicationStream contains OperationData objects that implement Operation. The objects are provided by the Primary replica via replicateAsync(OperationData operationData, SequenceNumber sequenceNumber, CancellationToken cancellationToken). Generally a Secondary replica should send getOperationAsync(CancellationToken cancellationToken). Although Service Fabric does not require services to do so, generally services should transfer all OperationData objects out of the copy stream first, and then transfer operations out of the replication stream. The transfer from both copies in parallel is supported but increases the complexity of applying state updates correctly and is recommended only for advanced services. The stream is empty when the returned Operation method is null.

replicateAsync

public CompletableFuture replicateAsync(OperationData operationData, SequenceNumber sequenceNumber, CancellationToken cancellationToken)

Replicates state changes from Primary replica to the Secondary replicas and receives a quorum acknowledgement that those state changes have been applied.

Parameters:

operationData - Represents the state change that the Primary replica wants to replicate.
sequenceNumber - Long, the LSN of the operation. Note that this is the same value which is returned by the task. Providing it as an out parameter is useful for services which want to prepare the local write to commit when the task finishes.
cancellationToken - A write quorum of replicas that have been lost. It can be used to send a notification that the operation should be canceled. Note that cancellation is advisory and that the operation might still be completed even if it is canceled.

Returns:

Returns completable future of type long, the LSN of the operation.

updateReplicatorSettings

public void updateReplicatorSettings(ReplicatorSettings settings)

Enables modification of replicator settings during runtime. The only setting which can be modified is the security credentials.

Parameters:

settings - The new ReplicatorSettings with updated credentials.

Applies to