Skip to content

ConsulBasedMembershipTable Methods

A Membership Table implementation using Consul 0.6.0 https://consul.io/

CleanupDefunctSiloEntries(DateTimeOffset)

View source
public Task CleanupDefunctSiloEntries(DateTimeOffset beforeDate)
Delete all dead silo entries older than beforeDate

Parameters

beforeDateDateTimeOffset
The exclusive upper bound for the last known update time of entries to delete.

Returns

A task representing the cleanup operation.

DeleteMembershipTableEntries(string)

View source
public Task DeleteMembershipTableEntries(string clusterId)
Deletes all table entries of the given clusterId

Parameters

clusterIdstring
The identifier of the cluster whose entries are deleted.

Returns

A task representing the deletion operation.

InitializeMembershipTable(bool)

View source
public Task InitializeMembershipTable(bool tryInitTableVersion)
Initializes the Consul based membership table.

Parameters

tryInitTableVersionbool
Will be ignored: Consul does not support the extended Membership Protocol TableVersion

InsertRow(MembershipEntry, TableVersion)

View source
public Task<bool> InsertRow(MembershipEntry entry, TableVersion tableVersion)
Atomically tries to insert (add) a new MembershipEntry for one silo and also update the TableVersion. If operation succeeds, the following changes would be made to the table: 1) New MembershipEntry will be added to the table. 2) The newly added MembershipEntry will also be added with the new unique automatically generated eTag. 3) TableVersion.Version in the table will be updated to the new TableVersion.Version. 4) TableVersion etag in the table will be updated to the new unique automatically generated eTag. All those changes to the table, insert of a new row and update of the table version and the associated etags, should happen atomically, or fail atomically with no side effects. The operation should fail in each of the following conditions: 1) A MembershipEntry for a given silo already exist in the table 2) Update of the TableVersion failed since the given TableVersion etag (as specified by the TableVersion.VersionEtag property) did not match the TableVersion etag in the table.

Parameters

entryMembershipEntry
MembershipEntry to be inserted.
tableVersionTableVersion
The new TableVersion for this table, along with its etag.

Returns

True if the insert operation succeeded and false otherwise.

ReadAll

View source
public Task<MembershipTableData> ReadAll()
Atomically reads the full content of the Membership Table. The returned MembershipTableData includes all MembershipEntry entry for all silos in the table and the TableVersion for this table. The MembershipEntries and the TableVersion have to be read atomically.

Returns

The membership information for a given table: MembershipTableData consisting multiple MembershipEntry entries and TableVersion, all read atomically.

ReadAll(IConsulClient, string, string?, ILogger, string?)

static
View source
public static Task<MembershipTableData> ReadAll(IConsulClient consulClient, string clusterId, string? kvRootFolder, ILogger logger, string? versionKey)
Reads all membership entries for a cluster from Consul.

Parameters

consulClientIConsulClient
The Consul client.
clusterIdstring
The cluster identifier.
kvRootFolderstring?
The optional root folder containing Orleans keys.
loggerILogger
The logger.
versionKeystring?
The key containing the membership table version, or null when no version key is available.

Returns

The cluster membership entries and table version.

ReadRow(SiloAddress)

View source
public Task<MembershipTableData> ReadRow(SiloAddress siloAddress)
Atomically reads the Membership Table information about a given silo. The returned MembershipTableData includes one MembershipEntry entry for a given silo and the TableVersion for this table. The MembershipEntry and the TableVersion have to be read atomically.

Parameters

siloAddressSiloAddress
The address of the silo whose membership information needs to be read.

Returns

The membership information for a given silo: MembershipTableData consisting one MembershipEntry entry and TableVersion, read atomically.

UpdateIAmAlive(MembershipEntry)

View source
public Task UpdateIAmAlive(MembershipEntry entry)
Updates the IAmAlive part (column) of the MembershipEntry for this silo. This operation should only update the IAmAlive column and not change other columns. This operation is a "dirty write" or "in place update" and is performed without etag validation. With regards to eTags update: This operation may automatically update the eTag associated with the given silo row, but it does not have to. It can also leave the etag not changed ("dirty write"). With regards to TableVersion: this operation should not change the TableVersion of the table. It should leave it untouched. There is no scenario where this operation could fail due to table semantical reasons. It can only fail due to network problems or table unavailability.

Parameters

entryMembershipEntry
The membership entry containing the updated MembershipEntry value.

Returns

A task representing the update operation.

UpdateRow(MembershipEntry, string, TableVersion)

View source
public Task<bool> UpdateRow(MembershipEntry entry, string etag, TableVersion tableVersion)
Atomically tries to update the MembershipEntry for one silo and also update the TableVersion. If operation succeeds, the following changes would be made to the table: 1) The MembershipEntry for this silo will be updated to the new MembershipEntry (the old entry will be fully substituted by the new entry) 2) The eTag for the updated MembershipEntry will also be eTag with the new unique automatically generated eTag. 3) TableVersion.Version in the table will be updated to the new TableVersion.Version. 4) TableVersion etag in the table will be updated to the new unique automatically generated eTag. All those changes to the table, update of a new row and update of the table version and the associated etags, should happen atomically, or fail atomically with no side effects. The operation should fail in each of the following conditions: 1) A MembershipEntry for a given silo does not exist in the table 2) A MembershipEntry for a given silo exist in the table but its etag in the table does not match the provided etag. 3) Update of the TableVersion failed since the given TableVersion etag (as specified by the TableVersion.VersionEtag property) did not match the TableVersion etag in the table.

Parameters

entryMembershipEntry
MembershipEntry to be updated.
etagstring
The etag for the given MembershipEntry.
tableVersionTableVersion
The new TableVersion for this table, along with its etag.

Returns

True if the update operation succeeded and false otherwise.