Class DefaultPileBase
Provides base for default implementation of IPile which stores objects on a local machine in memory or in the MMF
Inheritance
System.Object
DefaultPileBase
Implements
System.IDisposable
System.Collections.Generic.IEnumerable<
PileEntry>
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.dll
Syntax
public abstract class DefaultPileBase : DaemonWithInstrumentation<IApplicationComponent>, IDisposable, ILocalizedTimeProvider, IPileImplementation, IPile, IPileStatus, IEnumerable<PileEntry>, IEnumerable, IDaemon, IDaemonView, IApplicationComponent, INamed, IConfigurable, IInstrumentable, IExternallyParameterized
Constructors
DefaultPileBase(IApplicationComponent, String)
Declaration
protected DefaultPileBase(IApplicationComponent director, string name)
Parameters
DefaultPileBase(IApplication, String)
Declaration
protected DefaultPileBase(IApplication app, string name)
Parameters
Fields
CONFIG_FREE_CHUNK_SIZES_ATTR
Declaration
public const string CONFIG_FREE_CHUNK_SIZES_ATTR = "free-chunk-sizes"
Field Value
Type |
Description |
System.String |
|
CONFIG_PILE_SECTION
Declaration
public const string CONFIG_PILE_SECTION = "pile"
Field Value
Type |
Description |
System.String |
|
FREE_CHUNK_SIZE_MIN
Declaration
public const int FREE_CHUNK_SIZE_MIN = 64
Field Value
Type |
Description |
System.Int32 |
|
FREE_LST_COUNT
Declaration
public const int FREE_LST_COUNT = 16
Field Value
Type |
Description |
System.Int32 |
|
FREE_LST_SIZE_MAX
Declaration
public const int FREE_LST_SIZE_MAX = 131072
Field Value
Type |
Description |
System.Int32 |
|
FREE_LST_SIZE_MIN
Declaration
public const int FREE_LST_SIZE_MIN = 25600
Field Value
Type |
Description |
System.Int32 |
|
m_CurrentTypeRegistry
Declaration
protected volatile TypeRegistry m_CurrentTypeRegistry
Field Value
m_CurrentTypeRegistryLock
Declaration
protected object m_CurrentTypeRegistryLock
Field Value
Type |
Description |
System.Object |
|
SEG_SIZE_DFLT
Declaration
public const int SEG_SIZE_DFLT = 268435456
Field Value
Type |
Description |
System.Int32 |
|
SEG_SIZE_MAX
Declaration
public const int SEG_SIZE_MAX = 2147483376
Field Value
Type |
Description |
System.Int32 |
|
SEG_SIZE_MIN
Declaration
public const int SEG_SIZE_MIN = 67108864
Field Value
Type |
Description |
System.Int32 |
|
SVER_BUFF
Declaration
public const byte SVER_BUFF = 1
Field Value
Type |
Description |
System.Byte |
|
SVER_LINK
Declaration
public const byte SVER_LINK = 3
Field Value
Type |
Description |
System.Byte |
|
SVER_SLIM
Declaration
public const byte SVER_SLIM = 0
Field Value
Type |
Description |
System.Byte |
|
SVER_UTF8
Declaration
public const byte SVER_UTF8 = 2
Field Value
Type |
Description |
System.Byte |
|
Properties
AllocatedMemoryBytes
Returns the number of bytes allocated by this pile from the system memory heap.
As pile pre-allocates memory in segments, it is absolutely normal to have this property
return 100s of megabytes even when pile is almost empty.
This property may return close to all physical memory available
Declaration
public long AllocatedMemoryBytes { get; }
Property Value
Type |
Description |
System.Int64 |
|
AllocMode
Defines modes of allocation: space/time tradeoff
Declaration
[Config]
[ExternalParameter(new string[]{"pile", "instrumentation"})]
public AllocationMode AllocMode { get; set; }
Property Value
ComponentLogTopic
Declaration
public override string ComponentLogTopic { get; }
Property Value
Type |
Description |
System.String |
|
Overrides
FreeChunkSizes
Sets the sizes of free chunks that free lists group by.
Must be an array of FREE_LST_COUNT(16) of consequitively increasing integers
Declaration
public int[] FreeChunkSizes { get; set; }
Property Value
Type |
Description |
System.Int32[] |
|
FreeListSize
Determines the size of free chunk list. Every segment has FREE_LST_COUNT=16 lists each of this size.
This property may only be set on an inactive service instance
Declaration
[Config]
public int FreeListSize { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
Identity
When set to value greater than zero, provides a process-unique identity of the pile instance.
The property must be set to unique value in order to start the pile, or set to less or equal to zero to keep the instance private.
Used by Piled via PileInstances retrieved by Identity (if greater than zero)
Declaration
[Config]
public int Identity { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
InstrumentationEnabled
Implements IInstrumentable
Declaration
[Config(Default = false)]
[ExternalParameter(new string[]{"pile", "instrumentation"})]
public override bool InstrumentationEnabled { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
Overrides
Azos.Apps.DaemonWithInstrumentation<Azos.Apps.IApplicationComponent>.InstrumentationEnabled
Locality
Returns PileLocality.Local
Declaration
public virtual LocalityKind Locality { get; }
Property Value
MaxMemoryLimit
Imposes a limit on maximum number of bytes that a pile can allocate of the system heap.
The default value of 0 means no limit, meaning - the pile will keep allocating objects
until the system allows. The value may not be less than minimum 1 seg size (64 mb).
May set on an active instance, however no existing objects will be removed if the limit is exceeded
Declaration
[Config]
[ExternalParameter(new string[]{"pile", "instrumentation"})]
public long MaxMemoryLimit { get; set; }
Property Value
Type |
Description |
System.Int64 |
|
MaxSegmentLimit
Gets the maximum count of segments tha this pile can have.
The property is not thread-safe for set and can only be set if pile is inactive.
The value of zero means no limit
Declaration
[Config]
public int MaxSegmentLimit { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
MemoryCapacityBytes
Returns an approximate capacity of free memory that the system has left
Declaration
public long MemoryCapacityBytes { get; }
Property Value
Type |
Description |
System.Int64 |
|
NodeCount
Returns 1 as this pile is not distributed
Declaration
public int NodeCount { get; }
Property Value
Type |
Description |
System.Int32 |
|
ObjectCount
Returns the total number of objects allocated at this point in time
Declaration
public long ObjectCount { get; }
Property Value
Type |
Description |
System.Int64 |
|
ObjectLinkCount
Returns the total number of object links allocated at this point in time
Declaration
public long ObjectLinkCount { get; }
Property Value
Type |
Description |
System.Int64 |
|
OverheadBytes
Returns the number of extra bytes used by pile metadata currently occupied by object stored in this pile
Declaration
public long OverheadBytes { get; }
Property Value
Type |
Description |
System.Int64 |
|
Persistence
Returns PilePersistence - where data is kept
Declaration
public abstract ObjectPersistence Persistence { get; }
Property Value
SegmentCount
Returns the total number of segments allocated at this point in time
Declaration
public long SegmentCount { get; }
Property Value
Type |
Description |
System.Int64 |
|
SegmentSize
Gets the maximum segment size in bytes, up to (2^31)-1
The property is not thread-safe for set and can only be set if pile is inactive
Declaration
[Config]
public int SegmentSize { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
SegmentTotalCount
Returns the total number of total segments - allocated and empty at this point in time.
This number is greater or equal to SegmentCount
Declaration
public int SegmentTotalCount { get; }
Property Value
Type |
Description |
System.Int32 |
|
SupportsObjectExpiration
Declaration
public bool SupportsObjectExpiration { get; }
Property Value
Type |
Description |
System.Boolean |
|
SweepExpiredObjects
Returns false and does nothing on set in this implementation
if they are set
Declaration
public bool SweepExpiredObjects { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
UtilizedBytes
Returns the number of bytes currently occupied by object stored in this pile.
This number is always less than AllocatedMemoryBytes
Declaration
public long UtilizedBytes { get; }
Property Value
Type |
Description |
System.Int64 |
|
Methods
Compact()
Declaration
Returns
Type |
Description |
System.Int64 |
|
Crawl(Boolean)
Analyzes all segments scanning for free spaces. Returns number of uncovered free bytes.
This is a full-blocking long operation that may take around 8 seconds on a 64Gb heaps in non-parallel mode
Declaration
public DefaultPileBase.SegmentCrawlStatus Crawl(bool parallel)
Parameters
Type |
Name |
Description |
System.Boolean |
parallel |
|
Returns
Delete(PilePointer, Boolean)
Deletes object from pile by its pointer returning true if there is no access violation
and pointer is pointing to the valid object, throws otherwise unless
throwInvalid is set to false
Declaration
public bool Delete(PilePointer ptr, bool throwInvalid = true)
Parameters
Type |
Name |
Description |
PilePointer |
ptr |
|
System.Boolean |
throwInvalid |
|
Returns
Type |
Description |
System.Boolean |
|
delete(PilePointer, Boolean, Boolean)
Declaration
public bool delete(PilePointer ptr, bool throwInvalid, bool isLink)
Parameters
Type |
Name |
Description |
PilePointer |
ptr |
|
System.Boolean |
throwInvalid |
|
System.Boolean |
isLink |
|
Returns
Type |
Description |
System.Boolean |
|
Destructor()
Declaration
protected override void Destructor()
Overrides
DoAcceptManagerVisit(Object, DateTime)
Declaration
protected override void DoAcceptManagerVisit(object manager, DateTime managerNow)
Parameters
Type |
Name |
Description |
System.Object |
manager |
|
System.DateTime |
managerNow |
|
Overrides
Declaration
protected override void DoConfigure(IConfigSectionNode node)
Parameters
Overrides
DoStart()
Declaration
protected override void DoStart()
Overrides
DoWaitForCompleteStop()
Declaration
protected override void DoWaitForCompleteStop()
Overrides
Get(PilePointer)
Returns a CLR object by its pointer or throws access violation if pointer is invalid
Declaration
public object Get(PilePointer ptr)
Parameters
Returns
Type |
Description |
System.Object |
|
GetEnumerator()
Declaration
public IEnumerator<PileEntry> GetEnumerator()
Returns
Type |
Description |
System.Collections.Generic.IEnumerator<PileEntry> |
|
GetRawBuffer(PilePointer, out Byte)
Returns a raw byte[] occupied by the object payload, only payload is returned along with serializer flag
which tells what kind of serializer was used.
This method is rarely used, it is needed for debugging and special-case "direct" memory access on read
to bypass the de-serialization process altogether
Declaration
public byte[] GetRawBuffer(PilePointer ptr, out byte serializerFlag)
Parameters
Type |
Name |
Description |
PilePointer |
ptr |
|
System.Byte |
serializerFlag |
|
Returns
Type |
Description |
System.Byte[] |
|
Purge()
Declaration
Put(PilePointer, Object, UInt32, Boolean)
Tries to put the new object over an existing one at the pre-define position.
The pointer has to reference a valid allocated block.
If object fits in the allocated block returns true, otherwise tries to create an internal link
to the new pointer which is completely transparent to the caller. The linking may be explicitly disabled
in which case the method returns false when the new object does not fit into the existing block
Declaration
public bool Put(PilePointer ptr, object obj, uint lifeSpanSec = 0U, bool link = true)
Parameters
Type |
Name |
Description |
PilePointer |
ptr |
|
System.Object |
obj |
|
System.UInt32 |
lifeSpanSec |
|
System.Boolean |
link |
|
Returns
Type |
Description |
System.Boolean |
|
Put(Object, UInt32, Int32)
Puts a CLR object into the pile and returns a newly-allocated pointer.
Throws out-of-space if there is not enough space in the pile and limits are set.
Optional lifeSpanSec is ignored by this implementation
Declaration
public PilePointer Put(object obj, uint lifeSpanSec = 0U, int preallocateBlockSize = 0)
Parameters
Type |
Name |
Description |
System.Object |
obj |
|
System.UInt32 |
lifeSpanSec |
|
System.Int32 |
preallocateBlockSize |
|
Returns
Rejuvenate(PilePointer)
Declaration
public bool Rejuvenate(PilePointer ptr)
Parameters
Returns
Type |
Description |
System.Boolean |
|
SizeOf(PilePointer)
Declaration
public int SizeOf(PilePointer ptr)
Parameters
Returns
Type |
Description |
System.Int32 |
|
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