PrimaryBasedLogViewAdaptor<TLogView, TLogEntry, TSubmissionEntry>
class
Namespace: Orleans.EventSourcing.Common
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> : ILogConsistencyDiagnostics, ILogViewAdaptor<TLogView, TLogEntry>, ILogViewRead<TLogView, TLogEntry>, ILogViewUpdate<TLogEntry> where TLogView : class, new() where TLogEntry : class where TSubmissionEntry : Orleans.EventSourcing.Common.SubmissionEntry<TLogEntry>Properties
ConfirmedVersionThe length of the confirmed prefix of the logConfirmedViewConfirmed view of the log (reflecting only confirmed entries)TentativeViewLocal, tentative view of the log (reflecting both confirmed and unconfirmed entries)UnconfirmedSuffixA list of the submitted entries that do not yet appear in the confirmed prefix.
Methods
ClearLogAsync(CancellationToken)Clear the log stream completely. ThrowsSystem.NotSupportedExceptionif the log stream does not support clearing.ConfirmSubmittedEntriesConfirm all submitted entries.Waits until all previously submitted entries appear in the confirmed prefix of the log.
DisableStatsCollectionDisable stats collectionEnableStatsCollectionmethod is virtual so subclasses can add their own eventsGetStatsGet statesOnProtocolMessageReceived(ILogConsistencyProtocolMessage)Called from networkPostOnActivateCalled during activation, right after the user-definedGrain..PostOnDeactivateCalled during deactivation, right after the user-definedGrain.PreOnActivateCalled during activation, right before the user-definedGrain.RetrieveLogSegment(int, int)Attempt to retrieve a segment of the log, possibly from storage. ThrowsSystem.NotSupportedExceptionif the log cannot be read, which depends on the providers used and how they are configured.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.SynchronizeGet 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.
