Ejemplo n.º 1
0
        public void ProcessComponent(ForEachComponentData data)
        {
            var accountTariffRepository = data.AccountDbContext.GetAccountTariffRepository();
            var tariffLimit             = accountTariffRepository.GetHardTariffLimit();
            var date = DateTimeHelper.TrimMs(DateTime.Now.AddDays(-tariffLimit.MetricsMaxDays));

            var metricHistoryRepository = data.AccountDbContext.GetMetricHistoryRepository();

            long deletedCount = 0;

            while (true)
            {
                DbProcessor.CancellationToken.ThrowIfCancellationRequested();

                var count = metricHistoryRepository.DeleteMetricsHistory(data.Component.Id, MaxDeleteCount, date);
                data.Logger.Trace("Удалено значений метрик: {0}", count);
                Interlocked.Add(ref DeletedMetricValueCount, count);

                if (count == 0)
                {
                    break;
                }

                deletedCount += count;
            }

            if (deletedCount > 0)
            {
                data.Logger.Debug("Удалено значений метрик: " + deletedCount + " по компоненту " + data.Component.Id);
            }
        }
Ejemplo n.º 2
0
        public void FilteredIJobChunkProcessesSameChunksAsFilteredJobForEach()
        {
            var archetypeA = m_Manager.CreateArchetype(typeof(EcsTestData), typeof(EcsTestSharedComp));
            var archetypeB = m_Manager.CreateArchetype(typeof(EcsTestData), typeof(EcsTestData2), typeof(EcsTestSharedComp));

            var entitiesA = new NativeArray <Entity>(5000, Allocator.Temp);

            m_Manager.CreateEntity(archetypeA, entitiesA);

            var entitiesB = new NativeArray <Entity>(5000, Allocator.Temp);

            // TODO this looks like a test bug. Shouldn't it be (archetypeB, entitiesB)?
            m_Manager.CreateEntity(archetypeA, entitiesB);

            for (int i = 0; i < 5000; ++i)
            {
                m_Manager.SetSharedComponentData(entitiesA[i], new EcsTestSharedComp {
                    value = i % 8
                });
                m_Manager.SetSharedComponentData(entitiesB[i], new EcsTestSharedComp {
                    value = i % 8
                });
            }

            var group = m_Manager.CreateEntityQuery(typeof(EcsTestData), typeof(EcsTestSharedComp));

            group.SetSharedComponentFilter(new EcsTestSharedComp {
                value = 1
            });

            var jobChunk = new ProcessChunkWriteIndex
            {
                ecsTestType = m_Manager.GetArchetypeChunkComponentType <EcsTestData>(false)
            };

            jobChunk.Schedule(group).Complete();

            var componentArrayA = group.ToComponentDataArray <EcsTestData>(Allocator.TempJob);

            var jobProcess = new ForEachComponentData
            {
            };

            jobProcess.Schedule(group).Complete();

            var componentArrayB = group.ToComponentDataArray <EcsTestData>(Allocator.TempJob);

            CollectionAssert.AreEqual(componentArrayA.ToArray(), componentArrayB.ToArray());

            componentArrayA.Dispose();
            componentArrayB.Dispose();
            group.Dispose();
        }
Ejemplo n.º 3
0
        public void ProcessComponent(DateTime?date, ForEachComponentData data)
        {
            var accountTariffRepository = data.AccountDbContext.GetAccountTariffRepository();
            var tarifLimit = accountTariffRepository.GetHardTariffLimit();
            var date2      = date ?? DateTimeHelper.TrimMs(DateTime.Now.AddDays(-tarifLimit.LogMaxDays));

            var logRepository = data.AccountDbContext.GetLogRepository();

            long count = 0;

            while (true)
            {
                DbProcessor.CancellationToken.ThrowIfCancellationRequested();

                DeleteProperties(
                    data.Logger,
                    logRepository,
                    data.Component.Id,
                    date2,
                    MaxDeleteCount);

                var result = DeleteLogs(
                    data.Logger,
                    logRepository,
                    data.Component.Id,
                    date2,
                    MaxDeleteCount);

                count += result;

                if (result == 0)
                {
                    break;
                }
            }

            if (count > 0)
            {
                data.Logger.Debug("Удалено логов: " + count + " по компоненту " + data.Component.Id);
            }
        }