Fixed Bug when Reports are missing

This commit is contained in:
Luis Fernando Molina committed 2019-10-05 14:30:03 +02:00
1 parent a0843d2281
commit 606b183257
5 files changed
+38 -24

No files matched your search

+5 -8
View File
@@ -119,7 +119,7 @@
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> Entering function."); }
/* Loop Heartbeat sent to the UI */
hearBeat()
processHearBeat()
/* We define here all the modules that the rest of the infraestructure, including the bots themselves can consume. */
@@ -801,7 +801,7 @@
/* We show we reached the end of the loop. */
hearBeat()
processHearBeat()
/* Here we check if we must stop the loop gracefully. */
@@ -929,18 +929,15 @@
}
}
function hearBeat() {
let key = global.TASK_NODE.bot.processes[bot.processIndex].name + '-' + global.TASK_NODE.bot.processes[bot.processIndex].type + '-' + global.TASK_NODE.bot.processes[bot.processIndex].id
function processHearBeat() {
let event = {
seconds: (new Date()).getSeconds()
}
global.SYSTEM_EVENT_HANDLER.raiseEvent(key, 'Heartbeat', event)
global.SYSTEM_EVENT_HANDLER.raiseEvent(bot.processKey, 'Heartbeat', event)
}
function processStopped() {
let key = global.TASK_NODE.bot.processes[bot.processIndex].name + '-' + global.TASK_NODE.bot.processes[bot.processIndex].type + '-' + global.TASK_NODE.bot.processes[bot.processIndex].id
global.SYSTEM_EVENT_HANDLER.raiseEvent(key, 'Stopped')
global.SYSTEM_EVENT_HANDLER.raiseEvent(bot.processKey, 'Stopped')
}
} catch (err) {
+22 -3
View File
@@ -24,6 +24,8 @@
const FILE_STORAGE = require('./FileStorage.js');
let fileStorage = FILE_STORAGE.newFileStorage(logger);
let bootstrappingTheProcess = false
let processConfig;
return thisObject;
@@ -268,6 +270,13 @@
*/
interExecutionMemoryArray = [];
/*
Also, we will remember that we are bootstrapping the process, this will allow us, to advanceTime if necesary.
It can happen that a process depends on data from another process that does not produce a file during the first day, or even more days,
in that situation we want the process not to just wait for that data that will never arrive, but to advance time until it finds valid data.
*/
bootstrappingTheProcess = true
for (let i = 0; i < global.dailyFilePeriods.length; i++) {
let emptyObject = {};
@@ -449,7 +458,7 @@
if ((err.result === "Fail Because" && err.message === "File does not exist.") || err.code === 'The specified key does not exist.') {
logger.write(MODULE_NAME, "[ERROR] start -> processTimePeriods -> periodsLoopBody -> dependencyLoopBody -> getCurrentFile -> onFileReceived -> err = "+ err.stack);
logger.write(MODULE_NAME, "[ERROR] start -> processTimePeriods -> periodsLoopBody -> dependencyLoopBody -> getPreviousFile -> onFileReceived -> err = "+ err.stack);
callBackFunction(global.DEFAULT_RETRY_RESPONSE);
return;
}
@@ -504,6 +513,16 @@
if ((err.result === "Fail Because" && err.message === "File does not exist.") || err.code === 'The specified key does not exist.') {
if (bootstrappingTheProcess === true) {
/*
In the special situation where we are running this process for the first time (no status report found),
we will consider the possibility that a depanant process does not produce a file during the first day of the market,
or even more than one day. That is why we are going to advance time here.
*/
advanceTime()
return
}
logger.write(MODULE_NAME, "[ERROR] start -> processTimePeriods -> periodsLoopBody -> dependencyLoopBody -> getCurrentFile -> onFileReceived -> err = " + err.code);
logger.write(MODULE_NAME, "[ERROR] start -> processTimePeriods -> periodsLoopBody -> dependencyLoopBody -> getCurrentFile -> onFileReceived -> filePath = " + filePath);
logger.write(MODULE_NAME, "[ERROR] start -> processTimePeriods -> periodsLoopBody -> dependencyLoopBody -> getCurrentFile -> onFileReceived -> fileName = " + fileName);
@@ -513,7 +532,7 @@
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
logger.write(MODULE_NAME, "[ERROR] start -> processTimePeriods -> periodsLoopBody -> dependencyLoopBody -> getCurrentFile -> onFileReceived -> err = " + err.code);
logger.write(MODULE_NAME, "[ERROR] start -> processTimePeriods -> periodsLoopBody -> dependencyLoopBody -> getCurrentFile -> Not OK -> onFileReceived -> err = " + err.code);
callBackFunction(err);
return;
}
@@ -527,7 +546,7 @@
}
catch (err) {
logger.write(MODULE_NAME, "[ERROR] start -> processTimePeriods -> periodsLoopBody -> dependencyLoopBody -> getCurrentFile -> onFileReceived -> err = "+ err.stack);
logger.write(MODULE_NAME, "[ERROR] start -> processTimePeriods -> periodsLoopBody -> dependencyLoopBody -> getCurrentFile -> Catch Error -> onFileReceived -> err = "+ err.stack);
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
}
}
+4
View File
@@ -184,6 +184,10 @@
botConfig.filePathRoot = botConfig.devTeam + "/" + botConfig.codeName + "." + botConfig.version.major + "." + botConfig.version.minor + "/" + global.CLONE_EXECUTOR.codeName + "." + global.CLONE_EXECUTOR.version + "/" + global.EXCHANGE_NAME + "/" + botConfig.dataSetVersion;
/* Process Key */
botConfig.processKey = global.TASK_NODE.bot.processes[processIndex].name + '-' + global.TASK_NODE.bot.processes[processIndex].type + '-' + global.TASK_NODE.bot.processes[processIndex].id
if (FULL_LOG === true) { console.log(logDisplace + "Root : [INFO] start -> findProcess -> filePathRoot = " + botConfig.filePathRoot); }
/* Now we loop throug all the configured processes at each bots configuration until we find the one we are supposed to run at this Node.js process. */
+5 -8
View File
@@ -121,7 +121,7 @@
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> Entering function."); }
/* Loop Heartbeat sent to the UI */
hearBeat()
processHearBeat()
/* We define here all the modules that the rest of the infraestructure, including the bots themselves can consume. */
@@ -547,7 +547,7 @@
/* We show we reached the end of the loop. */
hearBeat()
processHearBeat()
/* Here we check if we must stop the loop gracefully. */
@@ -701,18 +701,15 @@
}
}
function hearBeat() {
let key = global.TASK_NODE.bot.processes[bot.processIndex].name + '-' + global.TASK_NODE.bot.processes[bot.processIndex].type + '-' + global.TASK_NODE.bot.processes[bot.processIndex].id
function processHearBeat() {
let event = {
seconds: (new Date()).getSeconds()
}
global.SYSTEM_EVENT_HANDLER.raiseEvent(key, 'Heartbeat', event)
global.SYSTEM_EVENT_HANDLER.raiseEvent(bot.processKey, 'Heartbeat', event)
}
function processStopped() {
let key = global.TASK_NODE.bot.processes[bot.processIndex].name + '-' + global.TASK_NODE.bot.processes[bot.processIndex].type + '-' + global.TASK_NODE.bot.processes[bot.processIndex].id
global.SYSTEM_EVENT_HANDLER.raiseEvent(key, 'Stopped')
global.SYSTEM_EVENT_HANDLER.raiseEvent(bot.processKey, 'Stopped')
}
}
+2 -5
View File
@@ -1054,12 +1054,10 @@
}
function processHeartBeat() {
let key = global.TASK_NODE.bot.processes[bot.processIndex].name + '-' + global.TASK_NODE.bot.processes[bot.processIndex].type + '-' + global.TASK_NODE.bot.processes[bot.processIndex].id
let event = {
seconds: (new Date()).getSeconds()
}
global.SYSTEM_EVENT_HANDLER.raiseEvent(key, 'Heartbeat', event)
global.SYSTEM_EVENT_HANDLER.raiseEvent(bot.processKey, 'Heartbeat', event)
}
function sessionHeartBeat(processingDate) {
@@ -1075,8 +1073,7 @@
}
function processStopped() {
let key = global.TASK_NODE.bot.processes[bot.processIndex].name + '-' + global.TASK_NODE.bot.processes[bot.processIndex].type + '-' + global.TASK_NODE.bot.processes[bot.processIndex].id
global.SYSTEM_EVENT_HANDLER.raiseEvent(key, 'Stopped')
global.SYSTEM_EVENT_HANDLER.raiseEvent(bot.processKey, 'Stopped')
}
function sessionStopped() {