Commit 0029b21b authored by Nilanjan Daw's avatar Nilanjan Daw

Integrated RM with new arch

Integrated RM functionalities with new architecture. Tested using dummy_rm
parent d872ace4
...@@ -3,4 +3,6 @@ node_modules ...@@ -3,4 +3,6 @@ node_modules
package-lock.json package-lock.json
firecracker* firecracker*
secrets.json secrets.json
grunt grunt
\ No newline at end of file .clinic
rm_dummy.js
\ No newline at end of file
...@@ -6,5 +6,8 @@ ...@@ -6,5 +6,8 @@
"grunt_host": "https://www.namandixit.net/lovecraftian_nightmares/grunt", "grunt_host": "https://www.namandixit.net/lovecraftian_nightmares/grunt",
"log_channel": "LOG_COMMON", "log_channel": "LOG_COMMON",
"couchdb_host": "10.129.6.5:5984", "couchdb_host": "10.129.6.5:5984",
"couchdb_db_name": "serverless" "couchdb_db_name": "serverless",
"topics": {
}
} }
\ No newline at end of file
This diff is collapsed.
...@@ -3,6 +3,8 @@ const fs = require('fs') ...@@ -3,6 +3,8 @@ const fs = require('fs')
const rp = require('request-promise'); const rp = require('request-promise');
const fetch = require('node-fetch'); const fetch = require('node-fetch');
const winston = require('winston') const winston = require('winston')
const constants = require('.././constants.json')
const { createLogger, format, transports } = winston; const { createLogger, format, transports } = winston;
const heap = require('heap') const heap = require('heap')
...@@ -54,14 +56,14 @@ function reverseProxy(req, res, functionToResource, resourceMap) { ...@@ -54,14 +56,14 @@ function reverseProxy(req, res, functionToResource, resourceMap) {
let functionHeap = functionToResource.get(id) let functionHeap = functionToResource.get(id)
let forwardTo = functionHeap[0] let forwardTo = functionHeap[0]
let resource = resourceMap.get(forwardTo.resource_id) let resource = resourceMap.get(forwardTo.resource_id)
logger.info(`Choosing resource ${JSON.stringify(forwardTo.resource_id)}` + // logger.info(`Choosing resource ${JSON.stringify(forwardTo.resource_id)}` +
"\n forwarding via reverse proxy to: " + JSON.stringify(resource)); // "\n forwarding via reverse proxy to: " + JSON.stringify(resource));
let url = `http://${resource.node_id}:${resource.port}/serverless/function/execute` let url = `http://${resource.node_id}:${resource.port}/serverless/function/execute`
logger.info("Request received at reverseproxy. Forwarding to: " + url); // logger.info("Request received at reverseproxy. Forwarding to: " + url);
forwardTo.metric += 1 forwardTo.open_request_count += 1
heap.heapify(functionHeap, compare) heap.heapify(functionHeap, compare)
logger.info(functionHeap); // logger.info(functionHeap);
var options = { var options = {
method: 'POST', method: 'POST',
...@@ -77,15 +79,13 @@ function reverseProxy(req, res, functionToResource, resourceMap) { ...@@ -77,15 +79,13 @@ function reverseProxy(req, res, functionToResource, resourceMap) {
.then(function (parsedBody) { .then(function (parsedBody) {
res.json(parsedBody) res.json(parsedBody)
forwardTo.metric -= 1 forwardTo.open_request_count -= 1
heap.heapify(functionHeap, compare) heap.heapify(functionHeap, compare)
console.log(functionHeap);
resolve() resolve()
}) })
.catch(function (err) { .catch(function (err) {
forwardTo.metric -= 1 forwardTo.open_request_count -= 1
heap.heapify(functionHeap, compare) heap.heapify(functionHeap, compare)
console.log(functionHeap);
logger.error("error" + err.error.errno); logger.error("error" + err.error.errno);
res.json(err.message).status(err.statusCode) res.json(err.message).status(err.statusCode)
resolve() resolve()
...@@ -136,7 +136,7 @@ const logger = winston.createLogger({ ...@@ -136,7 +136,7 @@ const logger = winston.createLogger({
}); });
function compare(a, b) { function compare(a, b) {
return a.metric - b.metric return a.open_request_count - b.open_request_count
} }
module.exports = { module.exports = {
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
"express-fileupload": "^1.1.6", "express-fileupload": "^1.1.6",
"heap": "^0.2.6", "heap": "^0.2.6",
"isolated-vm": "^3.0.0", "isolated-vm": "^3.0.0",
"kafka-logger": "^7.1.0",
"kafka-node": "^5.0.0", "kafka-node": "^5.0.0",
"morgan": "^1.9.1", "morgan": "^1.9.1",
"mqtt": "^3.0.0", "mqtt": "^3.0.0",
...@@ -23,6 +24,7 @@ ...@@ -23,6 +24,7 @@
"request": "^2.88.0", "request": "^2.88.0",
"request-promise": "^4.2.5", "request-promise": "^4.2.5",
"save": "^2.4.0", "save": "^2.4.0",
"swagger-stats": "^0.95.16",
"winston": "^3.2.1" "winston": "^3.2.1"
} }
} }
{
"name": "xanadu",
"uriPath": "/xanadu"
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment