Commit fb27d6a9 authored by Nilanjan Daw's avatar Nilanjan Daw

Adding support for permanent implicit chain metadata

parent 8a33c26a
{ {
"registry_url" :"10.129.6.5:5000/", "registry_url" :"10.129.6.5:5000/",
"master_port": 8080, "master_port": 8080,
"master_address": "10.129.6.5", "master_address": "localhost",
"grunt_host": "https://www.namandixit.net/lovecraftian_nightmares/grunt", "grunt_host": "https://www.namandixit.net/lovecraftian_nightmares/grunt",
"couchdb_host": "10.129.6.5:5984", "couchdb_host": "10.129.6.5:5984",
"db": { "db": {
...@@ -12,8 +12,9 @@ ...@@ -12,8 +12,9 @@
}, },
"network": { "network": {
"network_bridge": "hybrid_kafka-serverless", "network_bridge": "hybrid_kafka-serverless",
"use_bridge": false,
"internal": { "internal": {
"kafka_host": "kafka:9092" "kafka_host": "10.129.6.5:9092"
}, },
"external": { "external": {
"kafka_host": "10.129.6.5:9092" "kafka_host": "10.129.6.5:9092"
...@@ -34,7 +35,7 @@ ...@@ -34,7 +35,7 @@
"metrics": { "metrics": {
"alpha": 0.7 "alpha": 0.7
}, },
"speculative_deployment": false, "speculative_deployment": true,
"JIT_deployment": true, "JIT_deployment": true,
"id_size": 20 "id_size": 20
} }
{
"registry_url" :"10.129.6.5:5000/",
"master_port": 8080,
"master_address": "10.129.6.5",
"grunt_host": "https://www.namandixit.net/lovecraftian_nightmares/grunt",
"couchdb_host": "10.129.6.5:5984",
"db": {
"function_meta": "serverless",
"metrics": "metrics",
"implicit_chain_meta": "implicit_chain",
"explicit_chain_meta": "explicit_chain"
},
"network": {
"network_bridge": "hybrid_kafka-serverless",
"internal": {
"kafka_host": "kafka:9092"
},
"external": {
"kafka_host": "10.129.6.5:9092"
}
},
"topics": {
"request_dm_2_rm": "request",
"heartbeat": "heartbeat",
"deployed": "deployed",
"remove_worker": "removeWorker",
"response_rm_2_dm": "RESPONSE_RM_2_DM_DUMMY",
"hscale": "hscale",
"log_channel": "LOG_COMMON"
},
"autoscalar_metrics": {
"open_request_threshold": 100
},
"metrics": {
"alpha": 0.7
},
"speculative_deployment": false,
"JIT_deployment": true,
"id_size": 20
}
...@@ -92,9 +92,15 @@ function runContainer(metadata) { ...@@ -92,9 +92,15 @@ function runContainer(metadata) {
if (code != 0) if (code != 0)
reject("error") reject("error")
else { else {
const process = spawn('docker', ["run", "--rm", `--network=${constants.network.network_bridge}`, "-p", `${port}:${port}`, let process = null;
"--name", resource_id, registry_url + imageName, if (constants.network.use_bridge)
resource_id, imageName, port, "container", constants.network.internal.kafka_host]); process = spawn('docker', ["run", "--rm", `--network=${constants.network.network_bridge}`, "-p", `${port}:${port}`,
"--name", resource_id, registry_url + imageName,
resource_id, imageName, port, "container", constants.network.internal.kafka_host]);
else
process = spawn('docker', ["run", "--rm", "-p", `${port}:${port}`,
"--name", resource_id, registry_url + imageName,
resource_id, imageName, port, "container", constants.network.internal.kafka_host]);
let result = ""; let result = "";
// timeStart = Date.now() // timeStart = Date.now()
process.stdout.on('data', (data) => { process.stdout.on('data', (data) => {
...@@ -119,10 +125,15 @@ function runContainer(metadata) { ...@@ -119,10 +125,15 @@ function runContainer(metadata) {
}) })
} else { } else {
logger.info("container starting at port", port); logger.info("container starting at port", port);
let process = null;
const process = spawn('docker', ["run", "--rm", `--network=${constants.network.network_bridge}`, if (constants.network.use_bridge)
"-p", `${port}:${port}`, "--name", resource_id, process = spawn('docker', ["run", "--rm", `--network=${constants.network.network_bridge}`,
registry_url + imageName, resource_id, imageName, port, "container", constants.network.internal.kafka_host]); "-p", `${port}:${port}`, "--name", resource_id,
registry_url + imageName, resource_id, imageName, port, "container", constants.network.internal.kafka_host]);
else
process = spawn('docker', ["run", "--rm",
"-p", `${port}:${port}`, "--name", resource_id,
registry_url + imageName, resource_id, imageName, port, "container", constants.network.internal.kafka_host]);
let result = ""; let result = "";
// timeStart = Date.now() // timeStart = Date.now()
process.stdout.on('data', (data) => { process.stdout.on('data', (data) => {
......
...@@ -158,7 +158,7 @@ function heartbeat() { ...@@ -158,7 +158,7 @@ function heartbeat() {
topic: "heartbeat", topic: "heartbeat",
messages: JSON.stringify({"address": node_id, "timestamp": Date.now()}) messages: JSON.stringify({"address": node_id, "timestamp": Date.now()})
}] }]
producer.send(payload, function() {}) producer.send(payload, function(cb) {})
} }
......
...@@ -27,7 +27,7 @@ function updateConfig() { ...@@ -27,7 +27,7 @@ function updateConfig() {
} }
function makeTopic(id) { function makeTopic(id) {
console.log("Using Primary IP", id, "as topic"); console.log("Using Primary IP", id, "as topic", "publishing to:", constants.network.external.kafka_host);
let client = new kafka.KafkaClient({ let client = new kafka.KafkaClient({
kafkaHost: constants.network.external.kafka_host, kafkaHost: constants.network.external.kafka_host,
......
...@@ -254,7 +254,7 @@ async function orchestrator(chain_id, res, payload, map, aliases, result) { ...@@ -254,7 +254,7 @@ async function orchestrator(chain_id, res, payload, map, aliases, result) {
runtime: metadata.runtime, runtime: metadata.runtime,
payload payload
}), }),
headers: { 'Content-Type': 'application/json' } headers: { 'Content-Type': 'application/json', 'x-chain-type': 'explicit' }
} }
delete map[functionName] delete map[functionName]
aliases[functionName].status = "running" aliases[functionName].status = "running"
......
...@@ -219,7 +219,7 @@ app.post('/serverless/execute/:id', (req, res) => { ...@@ -219,7 +219,7 @@ app.post('/serverless/execute/:id', (req, res) => {
res.timestamp = Date.now() res.timestamp = Date.now()
if (functionToResource.has(id)) { if (functionToResource.has(id)) {
res.start = 'warmstart' res.start = 'warmstart'
libSupport.reverseProxy(req, res, functionToResource, resourceMap, functionBranchTree) libSupport.reverseProxy(req, res)
} else { } else {
res.start = 'coldstart' res.start = 'coldstart'
/** /**
...@@ -328,17 +328,14 @@ function postDeploy(message) { ...@@ -328,17 +328,14 @@ function postDeploy(message) {
"reason": "deployment", "reason": "deployment",
"status": true, "status": true,
starttime: (Date.now() - resource.deploy_request_time) starttime: (Date.now() - resource.deploy_request_time)
}, message.resource_id, resourceMap) }, message.resource_id)
if (db.has(id)) { if (db.has(id)) {
let sendQueue = db.get(id) let sendQueue = db.get(id)
logger.info("forwarding request via reverse proxy to: " + JSON.stringify(resource)); logger.info("forwarding request via reverse proxy to: " + JSON.stringify(resource));
while (sendQueue && sendQueue.length != 0) { while (sendQueue && sendQueue.length != 0) {
let { req, res } = sendQueue.shift() let { req, res } = sendQueue.shift()
libSupport.reverseProxy(req, res, functionToResource, resourceMap, functionBranchTree) libSupport.reverseProxy(req, res)
.then(() => {
})
} }
db.delete(id) db.delete(id)
} }
...@@ -404,7 +401,7 @@ consumer.on('message', function (message) { ...@@ -404,7 +401,7 @@ consumer.on('message', function (message) {
"reason": "terminate", "reason": "terminate",
"total_request": message.total_request, "total_request": message.total_request,
"status": true "status": true
}, message.resource_id, resourceMap) }, message.resource_id)
.then(() => { .then(() => {
resourceMap.delete(message.resource_id) resourceMap.delete(message.resource_id)
if (resourceArray.length == 0) if (resourceArray.length == 0)
...@@ -557,7 +554,7 @@ async function speculative_deployment(req, runtime) { ...@@ -557,7 +554,7 @@ async function speculative_deployment(req, runtime) {
} }
} }
setInterval(libSupport.metrics.broadcastMetrics, 5000) setInterval(libSupport.metrics.broadcastMetrics, 5000)
setInterval(libSupport.viterbi, 1000, functionBranchTree) // setInterval(libSupport.viterbi, 1000)
setInterval(autoscalar, 1000); setInterval(autoscalar, 1000);
setInterval(dispatch, 1000); setInterval(dispatch, 1000);
app.listen(port, () => logger.info(`Server listening on port ${port}!`)) app.listen(port, () => logger.info(`Server listening on port ${port}!`))
\ No newline at end of file
This diff is collapsed.
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