Commit 7fbb2e90 authored by Nilanjan Daw's avatar Nilanjan Daw

streamlined various shared data

parent 8aec2c81
...@@ -4,9 +4,11 @@ ...@@ -4,9 +4,11 @@
"master_address": "localhost", "master_address": "localhost",
"grunt_host": "https://www.namandixit.net/lovecraftian_nightmares/grunt", "grunt_host": "https://www.namandixit.net/lovecraftian_nightmares/grunt",
"couchdb_host": "localhost:5984", "couchdb_host": "localhost:5984",
"function_db_name": "serverless", "db": {
"metrics_db_name": "metrics", "function_meta": "serverless",
"implicit_chain_db_name": "implicit_chain", "metrics": "metrics",
"implicit_chain_meta": "implicit_chain"
},
"network": { "network": {
"network_bridge": "hybrid_kafka-serverless", "network_bridge": "hybrid_kafka-serverless",
"internal": { "internal": {
......
...@@ -6,22 +6,18 @@ const fs = require('fs') ...@@ -6,22 +6,18 @@ const fs = require('fs')
const { spawn } = require('child_process') const { spawn } = require('child_process')
const fetch = require('node-fetch') const fetch = require('node-fetch')
const constants = require('../constants.json') const constants = require('../constants.json')
const secrets = require('./secrets.json')
const operator = require('./operator') const operator = require('./operator')
const sharedStructures = require('./shared_structures') const sharedMeta = require('./shared_meta')
let metadataDB = `http://${secrets.couchdb_username}:${secrets.couchdb_password}@${constants.couchdb_host}`
metadataDB = metadataDB + "/" + constants.function_db_name + "/"
let metricsDB = `http://${secrets.couchdb_username}:${secrets.couchdb_password}@${constants.couchdb_host}`
metricsDB = metricsDB + "/" + constants.metrics_db_name + "/"
const logger = libSupport.logger const logger = libSupport.logger
const registry_url = constants.registry_url const registry_url = constants.registry_url
let functionToResource = sharedStructures.functionToResource, let functionToResource = sharedMeta.functionToResource,
db = sharedStructures.db, db = sharedMeta.db,
conditionProbabilityExpilict = sharedStructures.conditionProbabilityExpilict conditionProbabilityExpilict = sharedMeta.conditionProbabilityExpilict,
metricsDB = sharedMeta.metricsDB,
metadataDB = sharedMeta.metadataDB
router.post('/deploy', (req, res) => { router.post('/deploy', (req, res) => {
...@@ -478,10 +474,7 @@ function createDirectory(path) { ...@@ -478,10 +474,7 @@ function createDirectory(path) {
}) })
} }
function initialise(functionToResource) {
this.functionToResource = functionToResource
}
module.exports = { module.exports = {
router, initialise router
} }
...@@ -10,19 +10,11 @@ const { spawn } = require('child_process'); ...@@ -10,19 +10,11 @@ const { spawn } = require('child_process');
const morgan = require('morgan'); const morgan = require('morgan');
const heap = require('heap'); const heap = require('heap');
const fetch = require('node-fetch'); const fetch = require('node-fetch');
const swStats = require('swagger-stats'); // const swStats = require('swagger-stats');
const apiSpec = require('./swagger.json'); // const apiSpec = require('./swagger.json');
const util = require('util') const util = require('util')
const sharedStructures = require('./shared_structures') const sharedMeta = require('./shared_meta')
/**
* URL to the couchdb database server used to store function metadata
*/
let metadataDB = `http://${secrets.couchdb_username}:${secrets.couchdb_password}@${constants.couchdb_host}`
metadataDB = metadataDB + "/" + constants.function_db_name + "/"
let metricsDB = `http://${secrets.couchdb_username}:${secrets.couchdb_password}@${constants.couchdb_host}`
metricsDB = metricsDB + "/" + constants.metrics_db_name + "/"
const app = express() const app = express()
const libSupport = require('./lib') const libSupport = require('./lib')
...@@ -31,14 +23,16 @@ let date = new Date(); ...@@ -31,14 +23,16 @@ let date = new Date();
let log_channel = constants.topics.log_channel let log_channel = constants.topics.log_channel
let usedPort = new Map(), // TODO: remove after integration with RM let usedPort = new Map(), // TODO: remove after integration with RM
db = sharedStructures.db, // queue holding request to be dispatched db = sharedMeta.db, // queue holding request to be dispatched
resourceMap = sharedStructures.resourceMap, // map between resource_id and resource details like node_id, port, associated function etc resourceMap = sharedMeta.resourceMap, // map between resource_id and resource details like node_id, port, associated function etc
functionToResource = sharedStructures.functionToResource, // a function to resource map. Each map contains a minheap of functionToResource = sharedMeta.functionToResource, // a function to resource map. Each map contains a minheap of
// resources associated with the function // resources associated with the function
workerNodes = sharedStructures.workerNodes, // list of worker nodes currently known to the DM workerNodes = sharedMeta.workerNodes, // list of worker nodes currently known to the DM
functionBranchTree = sharedStructures.functionBranchTree // a tree to store function branch predictions functionBranchTree = sharedMeta.functionBranchTree, // a tree to store function branch predictions
chainHandler.initialise(functionToResource) metricsDB = sharedMeta.metricsDB,
metadataDB = sharedMeta.metadataDB
let kafka = require('kafka-node'), let kafka = require('kafka-node'),
Producer = kafka.Producer, Producer = kafka.Producer,
client = new kafka.KafkaClient({ client = new kafka.KafkaClient({
...@@ -67,7 +61,7 @@ app.use(express.urlencoded({ extended: true })); ...@@ -67,7 +61,7 @@ app.use(express.urlencoded({ extended: true }));
const file_path = __dirname + "/repository/" const file_path = __dirname + "/repository/"
app.use('/repository', express.static(file_path)); // file server hosting deployed functions app.use('/repository', express.static(file_path)); // file server hosting deployed functions
app.use(fileUpload()) app.use(fileUpload())
app.use(swStats.getMiddleware({ swaggerSpec: apiSpec })); // statistics middleware // app.use(swStats.getMiddleware({ swaggerSpec: apiSpec })); // statistics middleware
app.use('/serverless/chain', chainHandler.router); // chain router (explicit_chain_handler.js) for handling explicit chains app.use('/serverless/chain', chainHandler.router); // chain router (explicit_chain_handler.js) for handling explicit chains
let requestQueue = [] let requestQueue = []
......
...@@ -6,10 +6,11 @@ const winston = require('winston') ...@@ -6,10 +6,11 @@ const winston = require('winston')
const constants = require('.././constants.json') const constants = require('.././constants.json')
const secrets = require('./secrets.json') const secrets = require('./secrets.json')
const metrics = require('./metrics') const metrics = require('./metrics')
const sharedMeta = require('./shared_meta')
const { createLogger, format, transports } = winston; const { createLogger, format, transports } = winston;
const heap = require('heap') const heap = require('heap')
let implicitChainDB = sharedMeta.implicitChainDB
let kafka = require('kafka-node'), let kafka = require('kafka-node'),
Producer = kafka.Producer, Producer = kafka.Producer,
client = new kafka.KafkaClient({ client = new kafka.KafkaClient({
...@@ -18,8 +19,7 @@ let kafka = require('kafka-node'), ...@@ -18,8 +19,7 @@ let kafka = require('kafka-node'),
}), }),
producer = new Producer(client) producer = new Producer(client)
let implicitChainDB = `http://${secrets.couchdb_username}:${secrets.couchdb_password}@${constants.couchdb_host}`
implicitChainDB = implicitChainDB + "/" + constants.implicit_chain_db_names + "/"
/** /**
* Generates unique IDs of arbitrary length * Generates unique IDs of arbitrary length
......
const secrets = require('./secrets.json')
const constants = require('.././constants.json')
let db = new Map(), // queue holding request to be dispatched let db = new Map(), // queue holding request to be dispatched
resourceMap = new Map(), // map between resource_id and resource details like node_id, port, associated function etc resourceMap = new Map(), // map between resource_id and resource details like node_id, port, associated function etc
functionToResource = new Map(), // a function to resource map. Each map contains a minheap of functionToResource = new Map(), // a function to resource map. Each map contains a minheap of
...@@ -6,8 +9,22 @@ let db = new Map(), // queue holding request to be dispatched ...@@ -6,8 +9,22 @@ let db = new Map(), // queue holding request to be dispatched
functionBranchTree = new Map(), // a tree to store function branch predictions functionBranchTree = new Map(), // a tree to store function branch predictions
conditionProbabilityExpilict = new Map() // tree holding conditional probabilities for explicit chains conditionProbabilityExpilict = new Map() // tree holding conditional probabilities for explicit chains
/**
* URL to the couchdb database server used to store data
*/
let metadataDB = `http://${secrets.couchdb_username}:${secrets.couchdb_password}@${constants.couchdb_host}`
metadataDB = metadataDB + "/" + constants.db.function_meta + "/"
let metricsDB = `http://${secrets.couchdb_username}:${secrets.couchdb_password}@${constants.couchdb_host}`
metricsDB = metricsDB + "/" + constants.db.metrics + "/"
let implicitChainDB = `http://${secrets.couchdb_username}:${secrets.couchdb_password}@${constants.couchdb_host}`
implicitChainDB = implicitChainDB + "/" + constants.db.implicit_chain_meta + "/"
module.exports = { module.exports = {
db, functionBranchTree, functionToResource, workerNodes, resourceMap, db, functionBranchTree, functionToResource, workerNodes, resourceMap,
conditionProbabilityExpilict conditionProbabilityExpilict,
metadataDB, metricsDB, implicitChainDB
} }
\ 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