Class RumorSpreadingManager
Represents a helper that allows to control spreading of the rumor (send/receive) using Lamport timestamps.
Inherited Members
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 SourceRumorSpreadingManager(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 SourceCheckOrder(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. |
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.
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.
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.