Getting the end date of the task in the sheduler

pull/4/head
Ogoun 2 years ago
parent b0a1f5ba54
commit 479ef9152f

@ -298,6 +298,14 @@ namespace PartitionFileStorageTest
ulong totalData = 0; ulong totalData = 0;
ulong totalKeys = 0; ulong totalKeys = 0;
var s = new HashSet<ulong>();
store.Bypass(meta, (k, v) =>
{
s.Add(k);
});
Log.Info($"Keys count: {s.Count}");
using (var readPart = store.CreateAccessor(meta)) using (var readPart = store.CreateAccessor(meta))
{ {
/* /*

@ -0,0 +1,75 @@
using System.Collections.Generic;
namespace ZeroLevel.Services.Collections
{
public sealed class BitMapCardTable
{
private readonly long[] _bitmap;
public BitMapCardTable(int N)
{
var count = N / 64 + (N % 64 == 0 ? 0 : 1);
_bitmap = new long[count];
}
public bool this[int index]
{
get
{
var i = index / 64;
var n = _bitmap[i];
var bit_index = index % 64;
return (n & (1L << bit_index)) != 0;
}
set
{
var i = index / 64;
var bit_index = index % 64;
if (value)
{
_bitmap[i] = _bitmap[i] | (1L << bit_index);
}
else
{
_bitmap[i] = _bitmap[i] & ~(1L << bit_index);
}
}
}
public void ResetTo(bool value)
{
if (value)
{
for (int i = 0; i < _bitmap.Length; i++)
{
_bitmap[i] = long.MaxValue;
_bitmap[i] |= 1L << 63;
}
}
else
{
for (int i = 0; i < _bitmap.Length; i++)
{
_bitmap[i] = 0;
}
}
}
public IEnumerable<int> GetSetIndexes()
{
for (int i = 0; i < _bitmap.Length; i++)
{
if (_bitmap[i] != 0)
{
var start = i * 64;
for (int offset = 0; offset < 64; offset++)
{
if ((_bitmap[i] & (1L << offset)) != 0)
{
yield return start + offset;
}
}
}
}
}
}
}

@ -31,6 +31,14 @@ namespace ZeroLevel.Services.PartitionStorage
/// </summary> /// </summary>
Task<StoreSearchResult<TKey, TValue, TMeta>> Search(StoreSearchRequest<TKey, TMeta> searchRequest); Task<StoreSearchResult<TKey, TValue, TMeta>> Search(StoreSearchRequest<TKey, TMeta> searchRequest);
/// <summary> /// <summary>
/// bypass all key value by meta
/// </summary>
void Bypass(TMeta meta, Action<TKey, TValue> handler);
/// <summary>
/// true - if key exists
/// </summary>
bool Exists(TMeta meta, TKey key);
/// <summary>
/// Deleting a partition /// Deleting a partition
/// </summary> /// </summary>
void RemovePartition(TMeta info); void RemovePartition(TMeta info);

@ -95,5 +95,20 @@ namespace ZeroLevel.Services.PartitionStorage
{ {
_fileAccessorCachee.Dispose(); _fileAccessorCachee.Dispose();
} }
public void Bypass(TMeta meta, Action<TKey, TValue> handler)
{
var accessor = CreateAccessor(meta);
foreach (var kv in accessor.Iterate())
{
handler.Invoke(kv.Key, kv.Value);
}
}
public bool Exists(TMeta meta, TKey key)
{
var accessor = CreateAccessor(meta);
return accessor.Find(key).Status == SearchResult.Success;
}
} }
} }

@ -0,0 +1,7 @@
namespace ZeroLevel.Services.PartitionStorage
{
public sealed class UniformKeyValueStorage<TKey, TValue>
{
}
}

@ -1,6 +1,5 @@
using System; using System;
using System.Threading; using System.Threading;
using System.Threading.Tasks;
namespace ZeroLevel.Services.Shedulling namespace ZeroLevel.Services.Shedulling
{ {
@ -50,16 +49,6 @@ namespace ZeroLevel.Services.Shedulling
{ {
Log.SystemError(ex, $"Fault task '{result.Key}' on expiration date '{result.ExpirationDate.ToString("yyyy-MM-dd HH:mm:ss fff}")}'"); Log.SystemError(ex, $"Fault task '{result.Key}' on expiration date '{result.ExpirationDate.ToString("yyyy-MM-dd HH:mm:ss fff}")}'");
} }
/*Task.Run(() => result.Callback(result.Key)).ContinueWith(t =>
{
if (t.IsFaulted)
{
Exception ex = t.Exception;
while (ex is AggregateException && ex.InnerException != null)
ex = ex.InnerException;
Log.SystemError(ex, $"Fault task '{result.Key}' on expiration date '{result.ExpirationDate.ToString("yyyy-MM-dd HH:mm:ss fff}")}'");
}
});*/
} }
} }

@ -4,6 +4,8 @@ namespace ZeroLevel.Services.Shedulling
{ {
public interface ISheduller : IDisposable public interface ISheduller : IDisposable
{ {
DateTime this[long index] { get; }
#region One time events #region One time events
long RemindAfter(TimeSpan timespan, Action<long> callback); long RemindAfter(TimeSpan timespan, Action<long> callback);

@ -1,5 +1,4 @@
using System; using System;
using System.Threading.Tasks;
using ZeroLevel.Services.Shedulling; using ZeroLevel.Services.Shedulling;
namespace ZeroLevel namespace ZeroLevel
@ -46,6 +45,11 @@ namespace ZeroLevel
} }
} }
public static DateTime GetExpirationDate(long index)
{
return DefaultInstance[index];
}
#endregion Singletones #endregion Singletones
#region Sync default instance api #region Sync default instance api

@ -34,6 +34,18 @@ namespace ZeroLevel.Services.Shedulling
private readonly ConcurrentDictionary<long, ExpiredObject> _repitableActions = new ConcurrentDictionary<long, ExpiredObject>(); private readonly ConcurrentDictionary<long, ExpiredObject> _repitableActions = new ConcurrentDictionary<long, ExpiredObject>();
public DateTime this[long index]
{
get
{
if (_repitableActions.TryGetValue(index, out var result))
{
return result.ExpirationDate;
}
return DateTime.MinValue;
}
}
/// <summary> /// <summary>
/// Performs an action once a period, while the period is recalculated according to the transferred function at each re-creation of the task. /// Performs an action once a period, while the period is recalculated according to the transferred function at each re-creation of the task.
/// </summary> /// </summary>

@ -2,20 +2,20 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<Description>Infrastructure Layer Toolkit. <Description>Multi-tool
</Description> </Description>
<Authors>ogoun</Authors> <Authors>ogoun</Authors>
<Company>ogoun</Company> <Company>ogoun</Company>
<AssemblyVersion>3.3.9.5</AssemblyVersion> <AssemblyVersion>3.3.9.8</AssemblyVersion>
<PackageReleaseNotes>Partition storage. Fix.</PackageReleaseNotes> <PackageReleaseNotes>Getting the end date of the task in the sheduler</PackageReleaseNotes>
<PackageProjectUrl>https://github.com/ogoun/Zero/wiki</PackageProjectUrl> <PackageProjectUrl>https://github.com/ogoun/Zero/wiki</PackageProjectUrl>
<Copyright>Copyright Ogoun 2023</Copyright> <Copyright>Copyright Ogoun 2023</Copyright>
<PackageLicenseUrl></PackageLicenseUrl> <PackageLicenseUrl></PackageLicenseUrl>
<PackageIconUrl></PackageIconUrl> <PackageIconUrl></PackageIconUrl>
<RepositoryUrl>https://github.com/ogoun/Zero</RepositoryUrl> <RepositoryUrl>https://github.com/ogoun/Zero</RepositoryUrl>
<RepositoryType>git</RepositoryType> <RepositoryType>git</RepositoryType>
<Version>3.3.9.5</Version> <Version>3.3.9.8</Version>
<FileVersion>3.3.9.5</FileVersion> <FileVersion>3.3.9.8</FileVersion>
<Platforms>AnyCPU;x64;x86</Platforms> <Platforms>AnyCPU;x64;x86</Platforms>
<PackageIcon>zero.png</PackageIcon> <PackageIcon>zero.png</PackageIcon>
<DebugType>full</DebugType> <DebugType>full</DebugType>

Loading…
Cancel
Save

Powered by TurnKey Linux.