Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions modules/application/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1445,7 +1445,6 @@ module.exports = {
const interval = req.query.interval || '-30d'

const credentials = await self.apos.modules.exn.getApplicationInfluxDBCredentials(doc.uuid)
console.log("Got credentials ",credentials)
if (!credentials) {
throw self.apos.error('error', "Could not retrieve credentials");
}
Expand Down Expand Up @@ -1473,7 +1472,13 @@ module.exports = {
const range = req.query.range || 10
const slice = req.query.slice || 5

const res = await self.apos.modules.influxdb.getTimeSeriesForMeasurements(doc.uuid, measurements, interval)
const credentials = await self.apos.modules.exn.getApplicationInfluxDBCredentials(doc.uuid)
if (!credentials) {
throw self.apos.error('error', "Could not retrieve credentials");
}
console.log(new Date(), "Fetching data ")
const res = await self.apos.modules.influxdb.getTimeSeriesForMeasurements(credentials,doc.uuid, measurements, interval)
console.log(new Date(), "Fetched data ... ")
return {
application: doc.title,
uuid: doc.uuid,
Expand Down
20 changes: 14 additions & 6 deletions modules/exn/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ module.exports = {
return
}
if (context.message.to === "topic://eu.nebulouscloud.app_cluster.influxdb.get.reply") {
correlations[context.message.correlation_id]['resolve'](context.message.body)
if (context.message.correlation_id in correlations) {
correlations[context.message.correlation_id]['resolve'](context.message.body)
}else{
console.warn("Ignoring reply, not initiated by us, correlation id ", context.message.correlation_id, "is not in", correlations);
}
return
}

Expand Down Expand Up @@ -400,9 +404,7 @@ module.exports = {
return new Promise((resolve, reject) => {

const correlation_id = uuidv4()
correlations[correlation_id] = {
'resolve': resolve, 'reject': reject,
};

const req = aposSelf.apos.task.getReq()
const message = {
to: sender_app_influxdb.options.target.address,
Expand All @@ -414,9 +416,15 @@ module.exports = {
const timer = setTimeout(() => {
console.warn("InfluxDB Crendetials not retrieved for application = ",uuid)
resolve(false)
}, 7000);

}, 10000);
console.log("[getApplicationInfluxDBCrendetials] Send ", JSON.stringify( message))
correlations[correlation_id] = {
'resolve': (data)=>{
clearTimeout(timer)
resolve(data)
}, 'reject': reject,
};

sender_app_influxdb.send(message)
})
},
Expand Down