Skip to content

Commit

Permalink
DicomReprocessor: Log progress every 100 batches
Browse files Browse the repository at this point in the history
  • Loading branch information
rkm committed Feb 18, 2020
1 parent 227d19f commit 6ffd244
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,9 @@ public override void Start()

if (_processor.TotalProcessed == 0)
Logger.Warn("Nothing reprocessed");

Logger.Info("Total messages sent: " + _processor.TotalProcessed);
Logger.Info("Total failed to reprocess : " + _processor.TotalFailed);

else
_processor.LogProgress();

if (queryTime != default)
Logger.Info("Average documents processed per second: " + Convert.ToInt32(_processor.TotalProcessed / queryTime.TotalSeconds));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public async Task<TimeSpan> RunQuery(string query, IDocumentProcessor processor,

_logger.Info("Starting reprocess operation");
start = DateTime.Now;
var totalBatches = 0;

//Note: Can only check for the cancellation request every time we start to process a new batch
while (await cursor.MoveNextAsync() && !_tokenSource.IsCancellationRequested)
Expand All @@ -114,6 +115,9 @@ public async Task<TimeSpan> RunQuery(string query, IDocumentProcessor processor,

processor.SendMessages();

if (++totalBatches % 100 == 0)
processor.LogProgress();

_logger.Debug($"Batch processed, sleeping for {options.SleepTime.TotalMilliseconds}ms");
Thread.Sleep(options.SleepTime);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@


using Dicom;
using DicomTypeTranslation;
using MongoDB.Bson;
Expand Down Expand Up @@ -129,6 +129,8 @@ public void SendMessages()
}
}

public void LogProgress() => _logger.Info($"Total messages sent: {TotalProcessed}. Total failed to reprocess: {TotalFailed}");

private void LogUnprocessedDocument(string documentId, Exception e)
{
_logger.Error(e, "Error when processing document with _id " + documentId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,7 @@ public interface IDocumentProcessor
///
/// </summary>
void SendMessages();

void LogProgress();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Smi.Common.Messaging;
using Smi.Common.Messaging;
using Smi.Common.Options;
using MongoDB.Bson;
using NLog;
Expand Down Expand Up @@ -49,5 +49,10 @@ public void SendMessages()
{
throw new NotImplementedException();
}

public void LogProgress()
{
throw new NotImplementedException();
}
}
}

0 comments on commit 6ffd244

Please sign in to comment.