Commit 4d37177c authored by nilanjandaw's avatar nilanjandaw

added request sampler for prob model

parent ca61f8b9
{"id":"192.168.31.51","master_node":"10.129.6.5"} {"id":"10.196.6.51","master_node":"10.129.6.5"}
\ No newline at end of file \ No newline at end of file
...@@ -47,10 +47,7 @@ function generateExecutor(functionPath, functionHash) { ...@@ -47,10 +47,7 @@ function generateExecutor(functionPath, functionHash) {
} }
function reverseProxy(req, res, functionToResource, resourceMap) { function reverseProxy(req, res, functionToResource, resourceMap) {
if (req.headers["x-resource-id"]) { branchChainPredictor(req, resourceMap)
branchChainPredictor(req, resourceMap)
}
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let runtime = req.body.runtime let runtime = req.body.runtime
let id = req.params.id + runtime let id = req.params.id + runtime
...@@ -144,33 +141,56 @@ function compare(a, b) { ...@@ -144,33 +141,56 @@ function compare(a, b) {
} }
function branchChainPredictor(req, resourceMap) { function branchChainPredictor(req, resourceMap) {
let resource_id = req.headers['x-resource-id'] console.log(req.headers['x-resource-id']);
let resource = resourceMap.get(resource_id)
let forwardBranch = req.params.id if (req.headers['x-resource-id'] === undefined) {
if (!functionBranchTree.has(resource.functionHash)) { let functionHash = req.params.id
let data = { if (functionBranchTree.has(functionHash)) {
req_count: 1, let branchInfo = functionBranchTree.get(functionHash)
branches: new Map() branchInfo.req_count++
} else {
let data = {
req_count: 1,
parent: true,
branches: new Map()
}
functionBranchTree.set(functionHash, data)
} }
data.branches.set(forwardBranch, 1)
functionBranchTree.set(resource.functionHash, data)
} else { } else {
let branchInfo = functionBranchTree.get(resource.functionHash) let resource_id = req.headers['x-resource-id']
branchInfo.req_count++ let resource = resourceMap.get(resource_id)
if (branchInfo.branches.has(forwardBranch)) { let forwardBranch = req.params.id
let branchProb = branchInfo.branches.get(forwardBranch) if (!functionBranchTree.has(resource.functionHash)) {
branchProb = (branchProb * (branchInfo.req_count - 1) + 1.0) let data = {
branchInfo.branches.set(forwardBranch, branchProb) req_count: 1,
parent: false,
branches: new Map()
}
data.branches.set(forwardBranch, 1)
functionBranchTree.set(resource.functionHash, data)
} else { } else {
branchInfo.branches.set(forwardBranch, 1.0) let branchInfo = functionBranchTree.get(resource.functionHash)
} if (!branchInfo.parent)
for (let [branch, prob] of branchInfo.branches.entries()) { branchInfo.req_count++
if (branch !== forwardBranch) if (branchInfo.branches.has(forwardBranch)) {
prob *= (branchInfo.req_count - 1) let branchProb = branchInfo.branches.get(forwardBranch)
prob /= branchInfo.req_count branchProb = (branchProb * (branchInfo.req_count - 1) + 1.0)
branchInfo.branches.set(branch, prob) branchInfo.branches.set(forwardBranch, branchProb)
} else {
branchInfo.branches.set(forwardBranch, 1.0)
}
for (let [branch, prob] of branchInfo.branches.entries()) {
if (branch !== forwardBranch)
prob *= (branchInfo.req_count - 1)
prob /= branchInfo.req_count
branchInfo.branches.set(branch, prob)
}
} }
} }
console.log(functionBranchTree); console.log(functionBranchTree);
} }
......
#!/usr/bin/env node
var mime = require('./mime.js');
var file = process.argv[2];
var type = mime.lookup(file);
process.stdout.write(type + '\n');
cJSON @ f790e17b
Subproject commit f790e17b6cecef030c4eda811149d238c2085fcf
nlib @ 75bc1a11
Subproject commit 75bc1a11e2a10cf249f566b40c85d6526c16f123
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