Display results from Piscal processing
Error handling for Piscal processing
This commit is contained in:
@@ -31,13 +31,18 @@ namespace LeafWeb.Web.Services
|
||||
{
|
||||
logger.Trace("ProcessQueue entered");
|
||||
|
||||
ProcessRunning(logger);
|
||||
try
|
||||
{
|
||||
ProcessRunning(logger);
|
||||
|
||||
ProcessQueue(logger);
|
||||
ProcessQueue(logger);
|
||||
}
|
||||
finally
|
||||
{
|
||||
logger.Trace("ProcessQueue exit");
|
||||
|
||||
logger.Trace("ProcessQueue completed");
|
||||
|
||||
Monitor.Exit(ProcessQueueLock);
|
||||
Monitor.Exit(ProcessQueueLock);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -54,14 +59,25 @@ namespace LeafWeb.Web.Services
|
||||
var queuedFile =
|
||||
_dataService
|
||||
.GetLeafInputFiles(LeafInputStatusType.Queued)
|
||||
.OrderBy(l => l.Id)
|
||||
.OrderBy(l => l.StatusHistory.Min(sh => sh.DateTime))
|
||||
.FirstOrDefault();
|
||||
|
||||
if (queuedFile == null)
|
||||
return;
|
||||
|
||||
logger.Info("LeafInputFile: {0}, Start", queuedFile.Id);
|
||||
_piscalService.Run(queuedFile);
|
||||
try
|
||||
{
|
||||
_piscalService.Run(queuedFile);
|
||||
}
|
||||
catch (PiscalClientException ex)
|
||||
{
|
||||
logger.Error("LeafInputFile: {0}, ProcessQueue Exception: {1}", queuedFile.Id, ex.Message);
|
||||
_dataService.SetLeafInputFileStatus(queuedFile, LeafInputStatusType.Error, "Error occurred submitting LeafInput");
|
||||
|
||||
// TODO: re-queue
|
||||
//_dataService.SetLeafInputFileStatus(queuedFile, LeafInputStatusType.Queued, "Re-queuing LeafInput");
|
||||
}
|
||||
_dataService.SetLeafInputFileStatus(queuedFile, LeafInputStatusType.Running);
|
||||
}
|
||||
|
||||
@@ -71,33 +87,55 @@ namespace LeafWeb.Web.Services
|
||||
foreach (var file in runningLeafInputFiles)
|
||||
{
|
||||
var status = _piscalService.GetStatus(file);
|
||||
switch (status)
|
||||
try
|
||||
{
|
||||
case PiscalStatus.Running:
|
||||
logger.Trace("LeafInputFile: {0}, {1}", file.Id, status);
|
||||
// continue running
|
||||
break;
|
||||
case PiscalStatus.Success:
|
||||
logger.Info("LeafInputFile: {0}, {1}", file.Id, status);
|
||||
// collect the leaf output
|
||||
var leafOutputFiles = _piscalService.RetrieveOutputFiles(file).ToList();
|
||||
foreach (var outputFile in leafOutputFiles)
|
||||
_dataService.AddLeafOutputFile(outputFile);
|
||||
switch (status)
|
||||
{
|
||||
case PiscalStatus.Running:
|
||||
logger.Trace("LeafInputFile: {0}, Running", file.Id);
|
||||
// continue running
|
||||
break;
|
||||
|
||||
logger.Info("LeafInputFile: {0}, output files: {1}", file.Id,
|
||||
string.Join(", ", leafOutputFiles.Select(o => o.Filename)));
|
||||
case PiscalStatus.Success:
|
||||
logger.Info("LeafInputFile: {0}, Success", file.Id);
|
||||
// collect the leaf output
|
||||
var leafOutputFiles = _piscalService.RetrieveOutputFiles(file).ToList();
|
||||
foreach (var outputFile in leafOutputFiles)
|
||||
_dataService.AddLeafOutputFile(outputFile);
|
||||
|
||||
// update db
|
||||
_dataService.SetLeafInputFileStatus(file, LeafInputStatusType.Complete);
|
||||
logger.Info("LeafInputFile: {0}, output files: {1}", file.Id,
|
||||
string.Join(", ", leafOutputFiles.Select(o => o.Filename)));
|
||||
|
||||
// remove working data from the server
|
||||
logger.Info("LeafInputFile: {0}, cleanup", file.Id);
|
||||
_piscalService.Cleanup(file);
|
||||
break;
|
||||
case PiscalStatus.Error:
|
||||
logger.Info("LeafInputFile: {0}, error", file.Id);
|
||||
_dataService.SetLeafInputFileStatus(file, LeafInputStatusType.Error);
|
||||
break;
|
||||
// update db
|
||||
_dataService.SetLeafInputFileStatus(file, LeafInputStatusType.Complete);
|
||||
|
||||
// remove working data from the server
|
||||
logger.Info("LeafInputFile: {0}, Cleanup", file.Id);
|
||||
_piscalService.Cleanup(file);
|
||||
break;
|
||||
|
||||
case PiscalStatus.NotStarted:
|
||||
logger.Warn("LeafInputFile: {0}, Not Started, re-queueing", file.Id);
|
||||
// if it's not started, try to requeue the process - unusual state
|
||||
_dataService.SetLeafInputFileStatus(file, LeafInputStatusType.Queued);
|
||||
break;
|
||||
|
||||
case PiscalStatus.Error:
|
||||
logger.Info("LeafInputFile: {0}, Error", file.Id);
|
||||
|
||||
var errorMessage = _piscalService.GetErrorMessage(file);
|
||||
logger.Info("LeafInputFile: {0}, Error Message: {1}", file.Id, errorMessage);
|
||||
|
||||
_dataService.SetLeafInputFileStatus(file, LeafInputStatusType.Error, errorMessage);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (PiscalClientException ex)
|
||||
{
|
||||
logger.Error("LeafInputFile: {0}, ProcessRunning Exception: {1}", file.Id, ex.Message);
|
||||
_dataService.SetLeafInputFileStatus(file, LeafInputStatusType.Error, "Error occurred processing LeafInput");
|
||||
|
||||
// TODO: re-queue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,12 @@ namespace LeafWeb.Web.Services
|
||||
}
|
||||
}
|
||||
|
||||
public string GetErrorMessage(LeafInputFile leafInputFile)
|
||||
{
|
||||
var inputFile = new PiscalLeafInputFile(leafInputFile);
|
||||
return _piscalClient.GetErrorMessage(inputFile);
|
||||
}
|
||||
|
||||
public void Cleanup(LeafInputFile leafInputFile)
|
||||
{
|
||||
var inputFile = new PiscalLeafInputFile(leafInputFile);
|
||||
|
||||
Reference in New Issue
Block a user