Beta 6 without Execution

This commit is contained in:
Luis Fernando Molina committed 2020-07-06 15:43:34 +02:00
1 parent 4033d4d07f
commit d40b985f5e
123 files changed
+8114 -12392

No files matched your search

+43 -50
View File
@@ -23,7 +23,7 @@
status: undefined
};
let statusDependencyNode;
let statusDependencyNode;
/* Utilities needed. */
@@ -32,7 +32,7 @@
/* Storage account to be used here. */
const FILE_STORAGE = require('./FileStorage.js');
let fileStorage
let fileStorage
let sessionPath = ''
@@ -48,67 +48,60 @@
/* Some very basic validations that we have all the information needed. */
if (statusDependencyNode.referenceParent === undefined) {
logger.write(MODULE_NAME, "[ERROR] initialize -> Status Dependency without Reference Parent. Status Dependency = " + JSON.stringify(statusDependencyNode));
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
validationFailed(statusDependencyNode, "Status Dependency without Reference Parent.")
return
}
if (statusDependencyNode.referenceParent.parentNode === undefined) {
logger.write(MODULE_NAME, "[ERROR] initialize -> Status Report not attached to a Process Definition. Status Report = " + JSON.stringify(statusDependencyNode.referenceParent));
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
validationFailed(statusDependencyNode.referenceParent, "Status Report not attached to a Process Definition.")
return
}
if (statusDependencyNode.referenceParent.parentNode.code.codeName === undefined) {
logger.write(MODULE_NAME, "[ERROR] initialize -> Process Definition witn no codeName defined. Process Definition = " + JSON.stringify(statusDependencyNode.referenceParent.parentNode));
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
if (statusDependencyNode.referenceParent.parentNode.config.codeName === undefined) {
validationFailed(statusDependencyNode.referenceParent.parentNode, "Process Definition witn no codeName defined.")
return
}
if (statusDependencyNode.referenceParent.parentNode.parentNode === undefined) {
logger.write(MODULE_NAME, "[ERROR] initialize -> Process Definition not attached to a Bot. Process Definition = " + JSON.stringify(statusDependencyNode.referenceParent.parentNode));
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
validationFailed(statusDependencyNode.referenceParent.parentNode, "Process Definition not attached to a Bot.")
return
}
if (statusDependencyNode.referenceParent.parentNode.parentNode.code.codeName === undefined) {
logger.write(MODULE_NAME, "[ERROR] initialize -> Bot witn no codeName defined. Bot = " + JSON.stringify(statusDependencyNode.referenceParent.parentNode.parentNode));
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
if (statusDependencyNode.referenceParent.parentNode.parentNode.config.codeName === undefined) {
validationFailed(statusDependencyNode.referenceParent.parentNode.parentNode, "Bot with no codeName defined.")
return
}
if (statusDependencyNode.referenceParent.parentNode.parentNode.parentNode === undefined) {
logger.write(MODULE_NAME, "[ERROR] initialize -> Bot not attached to a Data Mine. Bot = " + JSON.stringify(statusDependencyNode.referenceParent.parentNode.parentNode));
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
validationFailed(statusDependencyNode.referenceParent.parentNode.parentNode, "Bot not attached to a Data Mine.")
return
}
if (statusDependencyNode.referenceParent.parentNode.parentNode.parentNode.code.codeName === undefined) {
logger.write(MODULE_NAME, "[ERROR] initialize -> Data Mine witn no codeName defined. Data Mine = " + JSON.stringify(statusDependencyNode.referenceParent.parentNode.parentNode.parentNode));
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
if (statusDependencyNode.referenceParent.parentNode.parentNode.parentNode.config.codeName === undefined) {
validationFailed(statusDependencyNode.referenceParent.parentNode.parentNode.parentNode, "Data Mine witn no codeName defined.")
return
}
function validationFailed(errorInNode, errorMessage) {
let nodeString = JSON.stringify(errorInNode)
logger.write(MODULE_NAME, "[ERROR] initialize -> " + errorMessage + ' -> nodeString = ' + nodeString)
bot.processError(errorInNode, errorMessage)
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
}
/* Simplifying the access to basic info */
statusDependencyNode.bot = statusDependencyNode.referenceParent.parentNode.parentNode.code.codeName
statusDependencyNode.process = statusDependencyNode.referenceParent.parentNode.code.codeName
statusDependencyNode.bot = statusDependencyNode.referenceParent.parentNode.parentNode.config.codeName
statusDependencyNode.process = statusDependencyNode.referenceParent.parentNode.config.codeName
statusDependencyNode.bottype = statusDependencyNode.referenceParent.parentNode.parentNode.type
statusDependencyNode.dataMine = statusDependencyNode.referenceParent.parentNode.parentNode.parentNode.code.codeName
statusDependencyNode.dataMine = statusDependencyNode.referenceParent.parentNode.parentNode.parentNode.config.codeName
/* We retrieve the report main utility */
if (statusDependencyNode.code !== undefined) {
if (statusDependencyNode.code.mainUtility !== undefined) {
thisObject.mainUtility = statusDependencyNode.code.mainUtility
if (statusDependencyNode.config !== undefined) {
if (statusDependencyNode.config.mainUtility !== undefined) {
thisObject.mainUtility = statusDependencyNode.config.mainUtility
}
}
/* This stuff is still hardcoded and unresolved. */
statusDependencyNode.botVersion = {
"major": 1,
"minor": 0
}
statusDependencyNode.dataSetVersion = "dataSet.V1"
if (bot.SESSION !== undefined && statusDependencyNode.bottype === "Trading Bot") {
sessionPath = bot.SESSION.folderName + "/"
}
@@ -119,13 +112,13 @@
for (let i = 0; i < network.networkNodes.length; i++) {
let networkNode = network.networkNodes[i]
if (checkThisBranch(networkNode.dataMining) === true) { return }
if (checkThisBranch(networkNode.testingEnvironment) === true) {return}
if (checkThisBranch(networkNode.testingEnvironment) === true) { return }
if (checkThisBranch(networkNode.productionEnvironment) === true) { return }
function checkThisBranch(branch) {
if (branch === undefined) {return}
if (branch === undefined) { return }
for (let j = 0; j < branch.exchangeTasks.length; j++) {
let exchangeTasks = branch.exchangeTasks[j]
for (let k = 0; k < exchangeTasks.taskManagers.length; k++) {
@@ -156,9 +149,9 @@
/* We found where the task that runs the process definition this status report depends on and where it is located on the network. */
thisObject.networkNode = networkNode
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] initialize -> Retrieving status report from " + networkNode.name + " -> host = " + networkNode.code.host + ' -> port = ' + networkNode.code.webPort + '.'); }
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] initialize -> Retrieving status report from " + networkNode.name + " -> host = " + networkNode.config.host + ' -> port = ' + networkNode.config.webPort + '.'); }
fileStorage = FILE_STORAGE.newFileStorage(logger, networkNode.code.host, networkNode.code.webPort);
fileStorage = FILE_STORAGE.newFileStorage(logger, networkNode.config.host, networkNode.config.webPort);
callBackFunction(global.DEFAULT_OK_RESPONSE);
return true
}
@@ -183,7 +176,7 @@
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
} catch (err) {
logger.write(MODULE_NAME, "[ERROR] initialize -> err = "+ err.stack);
logger.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.stack);
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
}
}
@@ -204,16 +197,16 @@
let fileName = "Status.Report.json";
let filePath;
let ownerId = statusDependencyNode.dataMine + "-" + statusDependencyNode.bot + "-" + statusDependencyNode.botVersion.major + "-" + statusDependencyNode.botVersion.minor + "-" + statusDependencyNode.process + "-" + statusDependencyNode.dataSetVersion;
let botId = bot.dataMine + "-" + bot.codeName + "-" + bot.version.major + "-" + bot.version.minor + "-" + bot.process + "-" + bot.dataSetVersion;
let ownerId = statusDependencyNode.dataMine + "-" + statusDependencyNode.bot + "-" + statusDependencyNode.process
let botId = bot.dataMine + "-" + bot.codeName + "-" + bot.process
if (ownerId !== botId) {
let rootPath = bot.exchange + "/" + bot.market.baseAsset + "-" + bot.market.quotedAsset + "/" + statusDependencyNode.dataMine + "/" + statusDependencyNode.bot
filePath = rootPath + "/Reports/" + sessionPath + statusDependencyNode.process ;
filePath = rootPath + "/Reports/" + sessionPath + statusDependencyNode.process;
} else {
filePath = bot.filePathRoot + "/Reports/" + sessionPath + statusDependencyNode.process ;
filePath = bot.filePathRoot + "/Reports/" + sessionPath + statusDependencyNode.process;
}
filePath += '/' + fileName
@@ -236,10 +229,10 @@
function onFileReceived(err, text) {
if ( err.result === global.CUSTOM_FAIL_RESPONSE.result && (err.message === 'Folder does not exist.' || err.message === 'File does not exist.')
if (err.result === global.CUSTOM_FAIL_RESPONSE.result && (err.message === 'Folder does not exist.' || err.message === 'File does not exist.')
|| err.code === "The specified key does not exist.") {
logger.write(MODULE_NAME, "[INFO] load -> onFileReceived -> err = "+ err.stack);
logger.write(MODULE_NAME, "[INFO] load -> onFileReceived -> err = " + err.message);
/* In this case we can assume that this is the first execution ever of this bot.*/
@@ -255,7 +248,7 @@
}
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
logger.write(MODULE_NAME, "[ERROR] load -> onFileReceived -> err = "+ err.stack);
logger.write(MODULE_NAME, "[ERROR] load -> onFileReceived -> err = " + err.message);
callBackFunction(err);
return;
}
@@ -290,7 +283,7 @@
}
} catch (err) {
logger.write(MODULE_NAME, "[ERROR] load -> err = "+ err.stack);
logger.write(MODULE_NAME, "[ERROR] load -> err = " + err.stack);
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
}
}
@@ -301,8 +294,8 @@
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] save -> Entering function."); }
let ownerId = statusDependencyNode.dataMine + "-" + statusDependencyNode.bot + "-" + statusDependencyNode.botVersion.major + "-" + statusDependencyNode.botVersion.minor + "-" + statusDependencyNode.process + "-" + statusDependencyNode.dataSetVersion;
let botId = bot.dataMine + "-" + bot.codeName + "-" + bot.version.major + "-" + bot.version.minor + "-" + bot.process + "-" + bot.dataSetVersion;
let ownerId = statusDependencyNode.dataMine + "-" + statusDependencyNode.bot + "-" + statusDependencyNode.process
let botId = bot.dataMine + "-" + bot.codeName + "-" + bot.process
if (ownerId !== botId && statusDependencyNode.process !== "Context") { // Context is a special case where the report is created by the Context.js module itself.
@@ -328,7 +321,7 @@
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] save -> onFileCreated -> Entering function."); }
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
logger.write(MODULE_NAME, "[ERROR] save -> onFileCreated -> err = "+ err.stack);
logger.write(MODULE_NAME, "[ERROR] save -> onFileCreated -> err = " + err.stack);
callBackFunction(err);
return;
}
@@ -348,7 +341,7 @@
}
catch (err) {
logger.write(MODULE_NAME, "[ERROR] save -> err = "+ err.stack);
logger.write(MODULE_NAME, "[ERROR] save -> err = " + err.stack);
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
}
}