Skip to content

PrimaryBasedLogViewAdaptor<TLogView, TLogEntry, TSubmissionEntry> Methods

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.

ClearLogAsync(CancellationToken)

virtual
View source
public virtual Task PrimaryBasedLogViewAdaptor<TLogView, TLogEntry, ClearLogAsync(CancellationToken cancellationToken)
Clear the log stream completely. Throws System.NotSupportedException if the log stream does not support clearing.

Parameters

cancellationTokenCancellationToken
A cancellation token to cancel the operation.

Returns

A task that represents the asynchronous clear operation.

ConfirmSubmittedEntries

View source
public Task PrimaryBasedLogViewAdaptor<TLogView, TLogEntry, ConfirmSubmittedEntries()
Confirm all submitted entries.

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

Returns

A task that completes after all entries are confirmed.

EnableStatsCollection

virtual
View source
public virtual void PrimaryBasedLogViewAdaptor<TLogView, TLogEntry, EnableStatsCollection()
method is virtual so subclasses can add their own events

GetStats

View source
public LogConsistencyStatistics PrimaryBasedLogViewAdaptor<TLogView, TLogEntry, GetStats()
Get states

PostOnActivate

virtual
View source
public virtual Task PrimaryBasedLogViewAdaptor<TLogView, TLogEntry, PostOnActivate()
Called during activation, right after the user-defined Grain..

PostOnDeactivate

virtual
View source
public virtual Task PrimaryBasedLogViewAdaptor<TLogView, TLogEntry, PostOnDeactivate()
Called during deactivation, right after the user-defined Grain.

PreOnActivate

virtual
View source
public virtual Task PrimaryBasedLogViewAdaptor<TLogView, TLogEntry, PreOnActivate()
Called during activation, right before the user-defined Grain.

RetrieveLogSegment(int, int)

virtual
View source
public virtual Task<IReadOnlyList<TLogEntry>> PrimaryBasedLogViewAdaptor<TLogView, TLogEntry, RetrieveLogSegment(int fromVersion, int length)
Attempt to retrieve a segment of the log, possibly from storage. Throws System.NotSupportedException if the log cannot be read, which depends on the providers used and how they are configured.

Parameters

fromVersionint
the start position
lengthint
the end position

Returns

a

Submit(TLogEntry)

View source
public void PrimaryBasedLogViewAdaptor<TLogView, TLogEntry, Submit(TLogEntry logEntry)
Submit a single log entry to be appended to the global log, either at the current or at any later position.

Parameters

logEntryTLogEntry

SubmitRange(IEnumerable<TLogEntry>)

View source
public void PrimaryBasedLogViewAdaptor<TLogView, TLogEntry, SubmitRange(IEnumerable<TLogEntry> logEntries)
Submit a range of log entries to be appended atomically to the global log, either at the current or at any later position.

Parameters

logEntriesIEnumerable<TLogEntry>

Synchronize

View source
public Task PrimaryBasedLogViewAdaptor<TLogView, TLogEntry, 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.

Returns

A task that completes after getting the latest version and confirming all entries.

TryAppend(TLogEntry)

View source
public Task<bool> PrimaryBasedLogViewAdaptor<TLogView, TLogEntry, TryAppend(TLogEntry logEntry)
Try to append a single log entry at the current position of the log.

Parameters

logEntryTLogEntry

Returns

true if the entry was appended successfully, or false if there was a concurrency conflict (i.e. some other entries were previously appended).

TryAppendRange(IEnumerable<TLogEntry>)

View source
public Task<bool> PrimaryBasedLogViewAdaptor<TLogView, TLogEntry, TryAppendRange(IEnumerable<TLogEntry> logEntries)
Try to append a range of log entries atomically at the current position of the log.

Parameters

logEntriesIEnumerable<TLogEntry>

Returns

true if the entries were appended successfully, or false if there was a concurrency conflict (i.e. some other entries were previously appended).