Class WorkSet<TItem>
Facilitates distributed processing coordination of the set of work which consists of TItems,
by using lock manager to exchange the status with other workers working on the same set.
Sets are identified by Name within the cluster Path.
This class is abstract and must be inherited-from to specify the actual work partitioning -
as required by the particular task (i.e. Process all users that...) by overriding AssignWorkSegment().
The system retains the lock session for the duration of this instance existence, please dispose
both the instance and the enumerable returned by GetEnumerator().
This class IS NOT thread safe.
Inheritance
System.Object
WorkSet<TItem>
Implements
System.IDisposable
System.Collections.Generic.IEnumerable<TItem>
System.Collections.IEnumerable
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 abstract class WorkSet<TItem> : ApplicationComponent, IDisposable, IApplicationComponent, INamed, IEnumerable<TItem>, IEnumerable
Type Parameters
Constructors
WorkSet(IApplication, String, String)
Declaration
protected WorkSet(IApplication app, string path, string name)
Parameters
Type |
Name |
Description |
IApplication |
app |
|
System.String |
path |
|
System.String |
name |
|
Fields
m_MyFirstWorkIndex
Declaration
protected int m_MyFirstWorkIndex
Field Value
Type |
Description |
System.Int32 |
|
m_MyWorkCount
Declaration
protected int m_MyWorkCount
Field Value
Type |
Description |
System.Int32 |
|
m_TotalWorkCount
Declaration
protected int m_TotalWorkCount
Field Value
Type |
Description |
System.Int32 |
|
WORKSET_NS
Declaration
public const string WORKSET_NS = "~WORKSET~"
Field Value
Type |
Description |
System.String |
|
Properties
MyFirstWorkIndex
Returns the index of the first work item that this worker is assigned to
Declaration
public int MyFirstWorkIndex { get; }
Property Value
Type |
Description |
System.Int32 |
|
MyIndex
Returns the index of this worker in the set
Declaration
public int MyIndex { get; }
Property Value
Type |
Description |
System.Int32 |
|
MyWorkCount
Returns the number of work items to be processed by this worker starting at MyFirstWorkIndex
Declaration
public int MyWorkCount { get; }
Property Value
Type |
Description |
System.Int32 |
|
Name
Returns the workset name which uniquely identifies the set at the cluster level
Declaration
public string Name { get; }
Property Value
Type |
Description |
System.String |
|
OneItemProcessingTimeSec
Override to specify the average anticipated time of one item processing
Declaration
public virtual int OneItemProcessingTimeSec { get; }
Property Value
Type |
Description |
System.Int32 |
|
Path
The cluster path/level where the workset is going to execute.
The workset.Name is unique within this path
Declaration
public string Path { get; }
Property Value
Type |
Description |
System.String |
|
RoundDurationSec
Specifies the duration of the work round - this is when a worker gets assigned a position in the set.
The periodic repositioning is needed to ensure the 100% eventual coverage of the whole set as some workers may fail.
It also controls how often the whole work set is Assigned into portions between workers
Declaration
public virtual int RoundDurationSec { get; }
Property Value
Type |
Description |
System.Int32 |
|
TotalWorkCount
Returns the total number of work units int the set
Declaration
public int TotalWorkCount { get; }
Property Value
Type |
Description |
System.Int32 |
|
WorkerCount
Returns the total number of workers in the set including this one
Declaration
public int WorkerCount { get; }
Property Value
Type |
Description |
System.Int32 |
|
Methods
AssignWorkSegment()
Override to estimate the whole work by setting TotalWorkUnits,
and depending on TotalWorkUnits, set ThisFirstUnitIndex, and ThisLastUnitIndex
Declaration
protected abstract void AssignWorkSegment()
Destructor()
Declaration
protected override void Destructor()
Overrides
GetEnumerator()
Enumerates the work items which are assigned just to this worker.
The WorkSet class tries to coordinate the work of multiple workers so that they
do not intersect
Declaration
public IEnumerator<TItem> GetEnumerator()
Returns
Type |
Description |
System.Collections.Generic.IEnumerator<TItem> |
|
GetSegmentEnumerator()
Override to provide source enumeration of work items which depends on ThisFirstUnitIndex, ThisLastUnitIndex and TotalWorkUnits
Declaration
protected abstract IEnumerator<TItem> GetSegmentEnumerator()
Returns
Type |
Description |
System.Collections.Generic.IEnumerator<TItem> |
|
Touch()
Call this method when the instance is not enumerated for a long time.
Enumeration refreshes the worker registration automatically.
Declaration
Explicit Interface Implementations
IEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type |
Description |
System.Collections.IEnumerator |
|
Implements
System.IDisposable
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable
Extension Methods