Redigera

Dela via


PrimaryBasedLogViewAdaptor<TLogView,TLogEntry,TSubmissionEntry> Class

Definition

A general template for constructing log view adaptors that are based on a sequentially read and written primary. We use this to construct a variety of different log-consistency providers, all following the same basic pattern (read and write latest view from/to primary, and send notifications after writing).

Note that the log itself is transient, i.e. not actually saved to storage - only the latest view and some metadata (the log position, and write flags) is stored in the primary. It is safe to interleave calls to this adaptor (using grain scheduler only, of course).

Subclasses override ReadAsync and WriteAsync to read from / write to primary. Calls to the primary are serialized, i.e. never interleave.

public abstract class PrimaryBasedLogViewAdaptor<TLogView,TLogEntry,TSubmissionEntry> : Orleans.LogConsistency.ILogViewAdaptor<TLogView,TLogEntry>, Orleans.LogConsistency.ILogViewRead<TLogView,TLogEntry>, Orleans.LogConsistency.ILogViewUpdate<TLogEntry> where TLogView : class, new() where TLogEntry : class where TSubmissionEntry : SubmissionEntry<TLogEntry>
public abstract class PrimaryBasedLogViewAdaptor<TLogView,TLogEntry,TSubmissionEntry> : Orleans.EventSourcing.ILogViewAdaptor<TLogView,TLogEntry>, Orleans.EventSourcing.ILogViewRead<TLogView,TLogEntry>, Orleans.EventSourcing.ILogViewUpdate<TLogEntry> where TLogView : class, new() where TLogEntry : class where TSubmissionEntry : SubmissionEntry<TLogEntry>
type PrimaryBasedLogViewAdaptor<'LogView, 'LogEntry, 'SubmissionEntry (requires 'LogView : null and 'LogView : (new : unit -> 'LogView) and 'LogEntry : null and 'SubmissionEntry :> SubmissionEntry<'LogEntry>)> = class
    interface ILogViewAdaptor<'LogView, 'LogEntry (requires 'LogView : null and 'LogView : (new : unit -> 'LogView) and 'LogEntry : null)>
    interface ILogViewRead<'LogView, 'LogEntry (requires 'LogView : null and 'LogView : (new : unit -> 'LogView) and 'LogEntry : null)>
    interface ILogViewUpdate<'LogEntry (requires 'LogEntry : null)>
    interface ILogConsistencyDiagnostics
Public MustInherit Class PrimaryBasedLogViewAdaptor(Of TLogView, TLogEntry, TSubmissionEntry)
Implements ILogViewAdaptor(Of TLogView, TLogEntry), ILogViewRead(Of TLogView, TLogEntry), ILogViewUpdate(Of TLogEntry)

Type Parameters

TLogView

The user-defined view of the log

TLogEntry

The type of the log entries

TSubmissionEntry

The type of submission entries stored in pending queue

Inheritance
PrimaryBasedLogViewAdaptor<TLogView,TLogEntry,TSubmissionEntry>
Implements

Constructors

PrimaryBasedLogViewAdaptor<TLogView,TLogEntry,TSubmissionEntry>(ILogViewAdaptorHost<TLogView,TLogEntry>, TLogView, ILogConsistencyProtocolServices)

Construct an instance, for the given parameters.

PrimaryBasedLogViewAdaptor<TLogView,TLogEntry,TSubmissionEntry>(ILogViewAdaptorHost<TLogView,TLogEntry>, TLogView, ILogConsistencyProtocolServices)

Construct an instance, for the given parameters.

Fields

LastPrimaryIssue

Store the last issue that occurred while reading or updating primary. Is null if successful.

stats

Properties

Configuration

The current multi-cluster configuration for this grain instance.

ConfirmedVersion

The length of the confirmed prefix of the log

ConfirmedView

Confirmed view of the log (reflecting only confirmed entries)

Host

The grain that is using this adaptor.

Services

The runtime services required for implementing notifications between grain instances in different cluster.

SupportSubmissions

Whether this cluster supports submitting updates

TentativeView

Local, tentative view of the log (reflecting both confirmed and unconfirmed entries)

UnconfirmedSuffix

A list of the submitted entries that do not yet appear in the confirmed prefix.

UnresolvedConnectionIssues

returns a list of all connection health issues that have not been restored yet. Such issues are observed while communicating with the primary, or while trying to notify other clusters, for example.

Methods

BroadcastNotification(INotificationMessage, String)

Send a notification message to all remote instances

ConfirmSubmittedEntries()

Confirm all submitted entries.

Waits until all previously submitted entries appear in the confirmed prefix of the log.

CopyTentativeState()
DisableStatsCollection()

Disable stats collection

EnableStatsCollection()

method is virtual so subclasses can add their own events

EnsureClusterJoinedAsync()

Block until this cluster is joined to the multicluster.

GetCaughtUpWithConfigurationAsync(DateTime)

Wait until this cluster has received a configuration that is at least as new as timestamp

GetConfirmedVersion()

Read version of cached global state.

GetCurrentBatchOfUpdates()
GetNumberPendingUpdates()
GetStats()

Get states

InitializeConfirmedView(TLogView)

Set confirmed view the initial value (a view of the empty log)

IsMyClusterJoined()
LastConfirmedView()

Read cached global state.

MakeSubmissionEntry(TLogEntry)

Create a submission entry for the submitted log entry. Using a type parameter so we can add protocol-specific info to this class.

Merge(INotificationMessage, INotificationMessage)

Merge two notification messages, for batching. Override to handle notification subtypes.

NotifyPromises(Int32, Boolean)

send failure notifications

OnConfigurationChange(MultiClusterConfiguration)

Called when configuration of the multicluster is changing.

OnMessageReceived(ILogConsistencyProtocolMessage)

Handle protocol messages.

OnMessageReceived(ILogConsistencyProtocolMessage)

Handle protocol messages.

OnMultiClusterConfigurationChange(MultiClusterConfiguration)

Called by MultiClusterOracle when there is a configuration change.

OnNotificationReceived(INotificationMessage)

Handle notification messages. Override this to handle notification subtypes.

OnProtocolMessageReceived(ILogConsistencyProtocolMessage)

Called from network

OnProtocolMessageReceived(ILogConsistencyProtocolMessage)

Called from network

PostOnActivate()
PostOnDeactivate()

Called during deactivation, right after the user-defined OnDeactivateAsync().

PreOnActivate()

Called during activation, right before the user-defined OnActivateAsync().

ProcessNotifications()

Process stored notifications during worker cycle. Override to handle notification subtypes.

ReadAsync()

Read the latest primary state. Must block/retry until successful. Should not throw exceptions, but record them in LastPrimaryIssue

RemoveStaleConditionalUpdates()

go through updates and remove all the conditional updates that have already failed

RetrieveLogSegment(Int32, Int32)
Submit(TLogEntry)

Submit a single log entry to be appended to the global log, either at the current or at any later position.

SubmitRange(IEnumerable<TLogEntry>)

Submit a range of log entries to be appended atomically to the global log, either at the current or at any later position.

Synchronize()

Get the latest log view and confirm all submitted entries.

Waits until all previously submitted entries appear in the confirmed prefix of the log, and forces a refresh of the confirmed prefix.

TryAppend(TLogEntry)

Try to append a single log entry at the current position of the log.

TryAppendRange(IEnumerable<TLogEntry>)

Try to append a range of log entries atomically at the current position of the log.

WriteAsync()

Apply pending entries to the primary. Must block/retry until successful. Should not throw exceptions, but record them in LastPrimaryIssue

Applies to