Class GdidGenerator
Generates Global Distributed IDs (GDID).
This class is thread safe (for calling Generate)
Inheritance
System.Object
GdidGenerator
Implements
System.IDisposable
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Assembly: Azos.Sky.dll
Syntax
public sealed class GdidGenerator : ApplicationComponent, IDisposable, IApplicationComponent, IConfigurable, IGdidProvider, IUniqueSequenceProvider, INamed
Constructors
GdidGenerator(IApplicationComponent, String)
Declaration
public GdidGenerator(IApplicationComponent director, string name)
Parameters
GdidGenerator(IApplicationComponent, String, String, String)
Declaration
public GdidGenerator(IApplicationComponent director, string name, string scopePrefix, string sequencePrefix)
Parameters
Type |
Name |
Description |
IApplicationComponent |
director |
|
System.String |
name |
|
System.String |
scopePrefix |
|
System.String |
sequencePrefix |
|
GdidGenerator(IApplication)
Declaration
public GdidGenerator(IApplication app)
Parameters
GdidGenerator(IApplication, String)
Declaration
public GdidGenerator(IApplication app, string name)
Parameters
Fields
BLOCK_LOW_WATER_MARK
Specifies the level of "free" ID range in block below which reservation of the next block gets triggered
Declaration
public const double BLOCK_LOW_WATER_MARK = 0.25
Field Value
Type |
Description |
System.Double |
|
CONFIG_AUTHORITY_SECTION
Declaration
public const string CONFIG_AUTHORITY_SECTION = "authority"
Field Value
Type |
Description |
System.String |
|
CONFIG_GDID_SECTION
Declaration
public const string CONFIG_GDID_SECTION = "gdid"
Field Value
Type |
Description |
System.String |
|
Properties
AuthorityHosts
Returns host names that host GDID generation authority service
Declaration
public Registry<GdidGenerator.AuthorityHost> AuthorityHosts { get; }
Property Value
BlockWasAllocated
Returns true after block was allocated at least once
Declaration
public bool BlockWasAllocated { get; }
Property Value
Type |
Description |
System.Boolean |
|
ComponentCommonName
Declaration
public override string ComponentCommonName { get; }
Property Value
Type |
Description |
System.String |
|
Overrides
ComponentLogTopic
Declaration
public override string ComponentLogTopic { get; }
Property Value
Type |
Description |
System.String |
|
Overrides
Name
Declaration
public string Name { get; }
Property Value
Type |
Description |
System.String |
|
ScopePrefix
Returns immutable scope prefix set in .ctor or null. This name is prepended to all requests
Declaration
public string ScopePrefix { get; }
Property Value
Type |
Description |
System.String |
|
SequencePrefix
Returns immutable sequence prefix set in .ctor or null. This name is prepended to all requests
Declaration
public string SequencePrefix { get; }
Property Value
Type |
Description |
System.String |
|
SequenceScopeNames
Returns the list of all scope names in the instance
Declaration
public IEnumerable<string> SequenceScopeNames { get; }
Property Value
Type |
Description |
System.Collections.Generic.IEnumerable<System.String> |
|
TestingAuthorityNode
Gets/sets Authority Glue Node for testing. It can only be set once in the testing app container init before the first call to
Generate is made. When this setting is set then any authority nodes which would have been normally used will be
completely bypassed during block allocation
Declaration
public string TestingAuthorityNode { get; set; }
Property Value
Type |
Description |
System.String |
|
Methods
Declaration
public void Configure(IConfigSectionNode node)
Parameters
GenerateOneGdid(String, String, Int32, Nullable<UInt64>, Boolean)
Generates a single Globally-Unique distributed ID (GDID) for the supplied sequence name. This method is thread-safe.
The algorithm also respects LWM value, once the number of free counters gets below LWM the asynchronous non-blocking acquisition from authority is triggered
Declaration
public GDID GenerateOneGdid(string scopeName, string sequenceName, int blockSize = 0, ulong? vicinity, bool noLWM = false)
Parameters
Type |
Name |
Description |
System.String |
scopeName |
The name of scope where sequences are kept
|
System.String |
sequenceName |
The name of sequence within the scope for which ID to be obtained
|
System.Int32 |
blockSize |
If >0 requests to pre-allocate specified number of sequences, otherwise the generator will pre-allocate the most suitable/configured size
|
System.Nullable<System.UInt64> |
vicinity |
The location on ID counter scale, the authority may disregard this parameter
|
System.Boolean |
noLWM |
When true, does not start async fetch of the next ID block while the current block reaches low-water-mark.
This may not be desired in some short-lived processes.
The provider may disregard this flag
|
Returns
Type |
Description |
GDID |
The GDID instance
|
GetSequenceInfos(String)
Returns sequence information enumerable for all sequences in the named scope
Declaration
public IEnumerable<GdidGenerator.SequenceInfo> GetSequenceInfos(string scopeName)
Parameters
Type |
Name |
Description |
System.String |
scopeName |
|
Returns
TryGenerateManyConsecutiveGdids(String, String, Int32, Nullable<UInt64>, Boolean)
Tries to generate the specified number of Globally-Unique distributed IDs (GDID) for the supplied sequence name. This method is thread-safe.
The method may generate less GUIDs than requested. All IDs come from the same authority
Declaration
public GDID[] TryGenerateManyConsecutiveGdids(string scopeName, string sequenceName, int gdidCount, ulong? vicinity, bool noLWM = false)
Parameters
Type |
Name |
Description |
System.String |
scopeName |
The name of scope where sequences are kept
|
System.String |
sequenceName |
The name of sequence within the scope for which ID to be obtained
|
System.Int32 |
gdidCount |
The desired number of consecutive GDIDs
|
System.Nullable<System.UInt64> |
vicinity |
The location on ID counter scale, the authority may disregard this parameter
|
System.Boolean |
noLWM |
When true, does not start async fetch of the next ID block while the current block reaches low-water-mark.
This may not be desired in some short-lived processes.
The provider may disregard this flag
|
Returns
Type |
Description |
GDID[] |
The GDID instance array which may be shorter than requested
|
Explicit Interface Implementations
IUniqueSequenceProvider.GenerateOneSequenceId(String, String, Int32, Nullable<UInt64>, Boolean)
Declaration
ulong IUniqueSequenceProvider.GenerateOneSequenceId(string scopeName, string sequenceName, int blockSize, ulong? vicinity, bool noLWM)
Parameters
Type |
Name |
Description |
System.String |
scopeName |
|
System.String |
sequenceName |
|
System.Int32 |
blockSize |
|
System.Nullable<System.UInt64> |
vicinity |
|
System.Boolean |
noLWM |
|
Returns
Type |
Description |
System.UInt64 |
|
IUniqueSequenceProvider.GetSequenceInfos(String)
Declaration
IEnumerable<ISequenceInfo> IUniqueSequenceProvider.GetSequenceInfos(string scopeName)
Parameters
Type |
Name |
Description |
System.String |
scopeName |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<ISequenceInfo> |
|
IUniqueSequenceProvider.TryGenerateManyConsecutiveSequenceIds(String, String, Int32, Nullable<UInt64>, Boolean)
Declaration
ConsecutiveUniqueSequenceIds IUniqueSequenceProvider.TryGenerateManyConsecutiveSequenceIds(string scopeName, string sequenceName, int idCount, ulong? vicinity, bool noLWM)
Parameters
Type |
Name |
Description |
System.String |
scopeName |
|
System.String |
sequenceName |
|
System.Int32 |
idCount |
|
System.Nullable<System.UInt64> |
vicinity |
|
System.Boolean |
noLWM |
|
Returns
Implements
System.IDisposable
Extension Methods