Show / Hide Table of Contents

Class RumorSpreadingManager

Represents a helper that allows to control spreading of the rumor (send/receive) using Lamport timestamps.

Inheritance
object
RumorSpreadingManager
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: DotNext.Net.Cluster.Messaging.Gossip
Assembly: DotNext.Net.Cluster.dll
Syntax
public sealed class RumorSpreadingManager
Remarks

Any instance members of this class are thread-safe. This class helps to organize rumour spreading across peers in the network. When the peer acts as a source of the rumour (sender), it should call Tick() method to obtain a Lamport timestamp for the message. Then it attaches the address of the local peer to the rumour. Receiver calls CheckOrder(EndPoint, in RumorTimestamp) method to check the message order correctness. If the method returns true the receiver processes the message and retransmits it to other peers using the algorithm described for the sender (original address and id remain intact). If the method returns false then the receiver must skip the message and prevent its retransmission.

Constructors

| Edit this page View Source

RumorSpreadingManager(IEqualityComparer<EndPoint>?)

Initializes a new manager.

Declaration
public RumorSpreadingManager(IEqualityComparer<EndPoint>? addressComparer = null)
Parameters
Type Name Description
IEqualityComparer<EndPoint> addressComparer

The peer comparison algorithm.

Methods

| Edit this page View Source

CheckOrder(EndPoint, in RumorTimestamp)

Checks whether the received rumour should be processed by the local peer and retransmitted to other peers.

Declaration
public bool CheckOrder(EndPoint origin, in RumorTimestamp timestamp)
Parameters
Type Name Description
EndPoint origin

The address of the sender.

RumorTimestamp timestamp

The rumor timestamp.

Returns
Type Description
bool

true if the message is allowed for processing; false if the message must be skipped.

| Edit this page View Source

Tick()

Advances the logical timer.

Declaration
public RumorTimestamp Tick()
Returns
Type Description
RumorTimestamp

The monotonically increased local timer value.

Remarks

This method is typically called by the source of the rumour.

| Edit this page View Source

TryDisableControl(EndPoint)

Attempts to disable message order control for the specified peer.

Declaration
public bool TryDisableControl(EndPoint peerAddress)
Parameters
Type Name Description
EndPoint peerAddress

The address of the peer.

Returns
Type Description
bool

true if the tracking for the specified endpoint disabled successfully; otherwise, false.

Remarks

This method can be used as a reaction on PeerGone event.

| Edit this page View Source

TryEnableControl(EndPoint)

Attempts to enable message order control for the specified peer.

Declaration
public bool TryEnableControl(EndPoint peerAddress)
Parameters
Type Name Description
EndPoint peerAddress

The address of the peer.

Returns
Type Description
bool

true if the peer is added to this manager successfully; false if the peer is already tracking by this manager.

Remarks

Without calling of this method, CheckOrder(EndPoint, in RumorTimestamp) rejects any message from the particular sender. This method can be used as a reaction on PeerDiscovered event.

Extension Methods

BasicExtensions.As<T>(T)
BasicExtensions.GetUserData<T>(T)
BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, ReadOnlySpan<T>)
ExpressionBuilder.Const<T>(T)
AsyncLockAcquisition.AcquireLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireLockAsync<T>(T, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, bool, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, bool, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, TimeSpan, CancellationToken)
LockAcquisition.AcquireReadLock<T>(T)
LockAcquisition.AcquireReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireUpgradeableReadLock<T>(T)
LockAcquisition.AcquireUpgradeableReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireWriteLock<T>(T)
LockAcquisition.AcquireWriteLock<T>(T, TimeSpan)
  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾