Skip to content

Commit

Permalink
solved bug on log journaling
Browse files Browse the repository at this point in the history
  • Loading branch information
zmn committed Apr 3, 2017
1 parent 9ab25a9 commit a4ca721
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
9 changes: 7 additions & 2 deletions Wlog.Library/BLL/Reporitories/DeletedLogRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,17 @@ public bool ExecuteEmptyBinJob(int daysToKeep, int rowsToKeep)
}


while (uow.Query<DeletedLogEntity>().Count() > rowsToKeep)
int remaining = 0;

while ((remaining = uow.Query<DeletedLogEntity>().Count() - rowsToKeep) > 0)
{
var tmpBatchSize = Math.Min(remaining, batchSize);


//After I May need to remove addictional data to keep no more than x rows
var logsForBin = uow.Query<DeletedLogEntity>()
.OrderBy(x => x.SourceDate)
.Take(batchSize).ToList();
.Take(tmpBatchSize).ToList();


if (logsForBin.Any())
Expand Down
10 changes: 8 additions & 2 deletions Wlog.Library/BLL/Reporitories/IndexRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace Wlog.Library.BLL.Reporitories
/// </summary>
public class IndexRepository: IRepository
{
string indexLock = "";
public Type GetEntityType()
{
return typeof(LuceneIndexManager);
Expand Down Expand Up @@ -78,8 +79,13 @@ private void CreateIndex(string name)
var path = Path.Combine(BasePath, name);
var idx = new LuceneIndexManager(name, path);
idx.CommitSize = int.MaxValue; //commit is owned by the caller.

indexList.Add(name,idx );
lock(indexLock)
{
if (!indexList.ContainsKey(name))
{
indexList.Add(name, idx);
}
}
}

/// <summary>
Expand Down
7 changes: 5 additions & 2 deletions Wlog.Library/BLL/Reporitories/LogRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -407,13 +407,16 @@ public bool ExecuteMoveToBinJob(int daysToKeep, int rowsToKeep)
//Repeat until all logs before date are deleted
}

int remaining = 0;

while (uow.Query<LogEntity>().Count()> rowsToKeep)
while ( (remaining=uow.Query<LogEntity>().Count()- rowsToKeep) >0)
{
var tmpBatchSize = Math.Min(remaining, batchSize);

//After I May need to remove addictional data to keep no more than x rows
var logsForBin = uow.Query<LogEntity>()
.OrderBy(x => x.SourceDate)
.Take(batchSize).ToList();
.Take(tmpBatchSize).ToList();


if (logsForBin.Any())
Expand Down
2 changes: 2 additions & 0 deletions Wlog.Library/Scheduler/Jobs/EmptyBinJob.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using NLog;
using System;
using Wlog.Library.BLL.Reporitories;
using Hangfire;

namespace Wlog.Library.Scheduler.Jobs
{
Expand All @@ -27,6 +28,7 @@ public EmptyBinJob()
_daysToKeep = Settings.Default.EmptyBinJob_DaysToKeep;
}

[DisableConcurrentExecution(3600)]
public override bool Execute()
{
try
Expand Down
2 changes: 2 additions & 0 deletions Wlog.Library/Scheduler/Jobs/MoveToBinJob.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using NLog;
using System;
using Wlog.Library.BLL.Reporitories;
using Hangfire;

namespace Wlog.Library.Scheduler.Jobs
{
Expand All @@ -27,6 +28,7 @@ public MoveToBinJob(int rowsToKeep, int daysToKeep)
_daysToKeep = daysToKeep;
}

[DisableConcurrentExecution(7200)]
public override bool Execute()
{
try
Expand Down

0 comments on commit a4ca721

Please sign in to comment.