fetching data from networknodes
This commit is contained in:
1 parent
ea519e2525
commit
480ab1b78e
3 files changed
+90
-12
No files matched your search
+37
-2
@@ -6,6 +6,7 @@ exports.newDataSet = function newDataSet(BOT, logger) {
|
||||
|
||||
let thisObject = {
|
||||
node: undefined,
|
||||
networkNode: undefined,
|
||||
initialize: initialize,
|
||||
getTextFile: getTextFile,
|
||||
createTextFile: createTextFile
|
||||
@@ -14,7 +15,7 @@ exports.newDataSet = function newDataSet(BOT, logger) {
|
||||
/* Storage account to be used here. */
|
||||
|
||||
const FILE_STORAGE = require('./FileStorage.js');
|
||||
let fileStorage = FILE_STORAGE.newFileStorage(logger);
|
||||
let fileStorage
|
||||
|
||||
return thisObject;
|
||||
|
||||
@@ -76,7 +77,41 @@ exports.newDataSet = function newDataSet(BOT, logger) {
|
||||
return
|
||||
}
|
||||
|
||||
callBackFunction(global.DEFAULT_OK_RESPONSE);
|
||||
/* Now we will see where do we need to fetch this data from. */
|
||||
let network = global.TASK_NETWORK.parentNode.parentNode.parentNode.parentNode.parentNode
|
||||
let datasetProductDefinition = thisObject.node.parentNode
|
||||
let datasetNetworkNode
|
||||
|
||||
for (let i = 0; i < network.networkNodes.length; i++) {
|
||||
let networkNode = network.networkNodes[i]
|
||||
if (networkNode.dataStorage !== undefined) {
|
||||
if (networkNode.dataStorage.sessionIndependentData !== undefined) {
|
||||
for (let j = 0; i < networkNode.dataStorage.sessionIndependentData.exchangeDataProducts.length; i++) {
|
||||
let exchangeDataProduct = exchangeDataProducts[j]
|
||||
for (let k = 0; k < exchangeDataProduct.singleMarketData.length; k++) {
|
||||
let singleMarketData = exchangeDataProduct.singleMarketData[k]
|
||||
for (let m = 0; m < singleMarketData.dataProducts.length; m++) {
|
||||
let dataProduct = singleMarketData.dataProducts[m]
|
||||
if (dataProduct.referenceParent !== undefined) {
|
||||
let productDefinition = dataProduct.referenceParent
|
||||
if (datasetProductDefinition.id === productDefinition.id) {
|
||||
|
||||
/* We found where the data is located on the network. */
|
||||
thisObject.networkNode = networkNode
|
||||
fileStorage = FILE_STORAGE.newFileStorage(logger, networkNode.code.host, networkNode.code.webPort);
|
||||
callBackFunction(global.DEFAULT_OK_RESPONSE);
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
logger.write(MODULE_NAME, "[ERROR] initialize -> Initialization Failed because we could not find where the data of this dataset is located within the network. Check the logs for more info.");
|
||||
|
||||
} catch (err) {
|
||||
logger.write(MODULE_NAME, "[ERROR] initialize -> err = "+ err.stack);
|
||||
|
||||
Reference in new issue
Block a user