Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xanadu
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
SYNERG
xanadu
Commits
38c00ae9
Commit
38c00ae9
authored
Apr 09, 2020
by
Nilanjan Daw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Chain probability data now stored on DB
parent
79fe003b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
32 deletions
+48
-32
dispatch_system/constants.json
dispatch_system/constants.json
+3
-2
dispatch_system/dispatch_manager/explicit_chain_handler.js
dispatch_system/dispatch_manager/explicit_chain_handler.js
+37
-24
dispatch_system/dispatch_manager/lib.js
dispatch_system/dispatch_manager/lib.js
+3
-3
dispatch_system/dispatch_manager/shared_meta.js
dispatch_system/dispatch_manager/shared_meta.js
+5
-3
No files found.
dispatch_system/constants.json
View file @
38c00ae9
...
@@ -7,7 +7,8 @@
...
@@ -7,7 +7,8 @@
"db"
:
{
"db"
:
{
"function_meta"
:
"serverless"
,
"function_meta"
:
"serverless"
,
"metrics"
:
"metrics"
,
"metrics"
:
"metrics"
,
"implicit_chain_meta"
:
"implicit_chain"
"implicit_chain_meta"
:
"implicit_chain"
,
"explicit_chain_meta"
:
"explicit_chain"
},
},
"network"
:
{
"network"
:
{
"network_bridge"
:
"hybrid_kafka-serverless"
,
"network_bridge"
:
"hybrid_kafka-serverless"
,
...
@@ -34,6 +35,6 @@
...
@@ -34,6 +35,6 @@
"alpha"
:
0.7
"alpha"
:
0.7
},
},
"speculative_deployment"
:
true
,
"speculative_deployment"
:
true
,
"JIT_deployment"
:
fals
e
,
"JIT_deployment"
:
tru
e
,
"id_size"
:
20
"id_size"
:
20
}
}
dispatch_system/dispatch_manager/explicit_chain_handler.js
View file @
38c00ae9
...
@@ -14,10 +14,11 @@ const logger = libSupport.logger
...
@@ -14,10 +14,11 @@ const logger = libSupport.logger
const
registry_url
=
constants
.
registry_url
const
registry_url
=
constants
.
registry_url
let
functionToResource
=
sharedMeta
.
functionToResource
,
let
functionToResource
=
sharedMeta
.
functionToResource
,
db
=
sharedMeta
.
db
,
db
=
sharedMeta
.
db
,
conditionProbabilityExp
ilict
=
sharedMeta
.
conditionProbabilityExpilic
t
,
conditionProbabilityExp
licit
=
sharedMeta
.
conditionProbabilityExplici
t
,
metricsDB
=
sharedMeta
.
metricsDB
,
metricsDB
=
sharedMeta
.
metricsDB
,
metadataDB
=
sharedMeta
.
metadataDB
metadataDB
=
sharedMeta
.
metadataDB
,
explicitChainDB
=
sharedMeta
.
explicitChainDB
router
.
post
(
'
/deploy
'
,
(
req
,
res
)
=>
{
router
.
post
(
'
/deploy
'
,
(
req
,
res
)
=>
{
...
@@ -193,22 +194,27 @@ async function deployContainer(path, imageName) {
...
@@ -193,22 +194,27 @@ async function deployContainer(path, imageName) {
router
.
post
(
'
/execute/:id
'
,
(
req
,
res
)
=>
{
router
.
post
(
'
/execute/:id
'
,
(
req
,
res
)
=>
{
let
map
,
aliases
let
map
,
aliases
let
chain_id
=
req
.
params
.
id
let
chain_id
=
req
.
params
.
id
if
(
req
.
files
&&
req
.
files
.
map
)
{
libSupport
.
fetchData
(
explicitChainDB
+
chain_id
)
map
=
JSON
.
parse
(
req
.
files
.
map
.
data
.
toString
());
.
then
(
chainData
=>
{
let
mapPlanner
=
JSON
.
parse
(
req
.
files
.
map
.
data
.
toString
());
console
.
log
(
chainData
);
readMap
(
`./repository/aliases
${
chain_id
}
.json`
,
true
)
if
(
chainData
.
error
!==
"
not_found
"
)
conditionProbabilityExplicit
[
chain_id
]
=
chainData
if
(
req
.
files
&&
req
.
files
.
map
)
{
map
=
JSON
.
parse
(
req
.
files
.
map
.
data
.
toString
());
let
mapPlanner
=
JSON
.
parse
(
req
.
files
.
map
.
data
.
toString
());
readMap
(
`./repository/aliases
${
chain_id
}
.json`
,
true
)
.
then
(
data
=>
{
.
then
(
data
=>
{
aliases
=
data
aliases
=
data
let
payload
=
JSON
.
parse
(
req
.
body
.
data
)
let
payload
=
JSON
.
parse
(
req
.
body
.
data
)
speculative_deployment
(
chain_id
,
aliases
,
mapPlanner
,
0
);
speculative_deployment
(
chain_id
,
aliases
,
mapPlanner
,
0
);
orchestrator
(
chain_id
,
res
,
payload
,
map
,
aliases
,
{})
orchestrator
(
chain_id
,
res
,
payload
,
map
,
aliases
,
{})
})
})
}
else
{
}
else
{
readMap
(
`./repository/map
${
chain_id
}
.json`
)
readMap
(
`./repository/map
${
chain_id
}
.json`
)
.
then
(
data
=>
{
.
then
(
data
=>
{
map
=
data
map
=
data
let
mapPlanner
=
JSON
.
parse
(
JSON
.
stringify
(
map
))
let
mapPlanner
=
JSON
.
parse
(
JSON
.
stringify
(
map
))
readMap
(
`./repository/aliases
${
chain_id
}
.json`
,
true
)
readMap
(
`./repository/aliases
${
chain_id
}
.json`
,
true
)
.
then
(
data
=>
{
.
then
(
data
=>
{
aliases
=
data
aliases
=
data
...
@@ -217,7 +223,8 @@ router.post('/execute/:id', (req, res) => {
...
@@ -217,7 +223,8 @@ router.post('/execute/:id', (req, res) => {
orchestrator
(
chain_id
,
res
,
payload
,
map
,
aliases
,
{})
orchestrator
(
chain_id
,
res
,
payload
,
map
,
aliases
,
{})
})
})
})
})
}
}
})
})
})
...
@@ -226,6 +233,12 @@ async function orchestrator(chain_id, res, payload, map, aliases, result) {
...
@@ -226,6 +233,12 @@ async function orchestrator(chain_id, res, payload, map, aliases, result) {
if
(
Object
.
keys
(
map
).
length
==
0
)
{
if
(
Object
.
keys
(
map
).
length
==
0
)
{
console
.
log
(
"
time to resolve
"
,
result
);
console
.
log
(
"
time to resolve
"
,
result
);
res
.
json
(
result
)
res
.
json
(
result
)
let
payload
=
{
method
:
'
put
'
,
body
:
JSON
.
stringify
(
conditionProbabilityExplicit
[
chain_id
]),
headers
:
{
'
Content-Type
'
:
'
application/json
'
}
}
libSupport
.
fetchData
(
explicitChainDB
+
chain_id
,
payload
)
// return resolve(result)
// return resolve(result)
}
}
...
@@ -246,7 +259,7 @@ async function orchestrator(chain_id, res, payload, map, aliases, result) {
...
@@ -246,7 +259,7 @@ async function orchestrator(chain_id, res, payload, map, aliases, result) {
delete
map
[
functionName
]
delete
map
[
functionName
]
aliases
[
functionName
].
status
=
"
running
"
aliases
[
functionName
].
status
=
"
running
"
fetch
(
url
,
data
).
then
(
res
=>
res
.
json
()
)
libSupport
.
fetchData
(
url
,
data
)
.
then
(
json
=>
{
.
then
(
json
=>
{
// console.log(json);
// console.log(json);
result
[
functionName
]
=
json
result
[
functionName
]
=
json
...
@@ -264,21 +277,21 @@ async function orchestrator(chain_id, res, payload, map, aliases, result) {
...
@@ -264,21 +277,21 @@ async function orchestrator(chain_id, res, payload, map, aliases, result) {
if
(
metadata
.
type
===
"
conditional
"
&&
metadata
.
wait_for
.
length
==
0
)
{
if
(
metadata
.
type
===
"
conditional
"
&&
metadata
.
wait_for
.
length
==
0
)
{
let
conditionResult
=
checkCondition
(
metadata
.
condition
.
op1
,
metadata
.
condition
.
op2
,
metadata
.
condition
.
op
,
result
)
let
conditionResult
=
checkCondition
(
metadata
.
condition
.
op1
,
metadata
.
condition
.
op2
,
metadata
.
condition
.
op
,
result
)
if
(
conditionProbabilityExp
ilic
t
[
chain_id
]
===
undefined
)
if
(
conditionProbabilityExp
lici
t
[
chain_id
]
===
undefined
)
conditionProbabilityExp
ilic
t
[
chain_id
]
=
{}
conditionProbabilityExp
lici
t
[
chain_id
]
=
{}
if
(
conditionProbabilityExp
ilic
t
[
chain_id
][
_key
]
===
undefined
)
if
(
conditionProbabilityExp
lici
t
[
chain_id
][
_key
]
===
undefined
)
conditionProbabilityExp
ilic
t
[
chain_id
][
_key
]
=
{
conditionProbabilityExp
lici
t
[
chain_id
][
_key
]
=
{
request_count
:
0
,
request_count
:
0
,
probability
:
0
probability
:
0
}
}
let
oldProbability
=
conditionProbabilityExp
ilic
t
[
chain_id
][
_key
].
probability
let
oldProbability
=
conditionProbabilityExp
lici
t
[
chain_id
][
_key
].
probability
let
updateProbability
=
(
conditionResult
===
'
success
'
)
?
1.0
:
0.0
let
updateProbability
=
(
conditionResult
===
'
success
'
)
?
1.0
:
0.0
conditionProbabilityExp
ilic
t
[
chain_id
][
_key
].
probability
=
conditionProbabilityExp
lici
t
[
chain_id
][
_key
].
probability
=
oldProbability
*
conditionProbabilityExp
ilic
t
[
chain_id
][
_key
].
request_count
+
updateProbability
oldProbability
*
conditionProbabilityExp
lici
t
[
chain_id
][
_key
].
request_count
+
updateProbability
conditionProbabilityExp
ilic
t
[
chain_id
][
_key
].
request_count
++
conditionProbabilityExp
lici
t
[
chain_id
][
_key
].
request_count
++
conditionProbabilityExp
ilic
t
[
chain_id
][
_key
].
probability
/=
conditionProbabilityExp
lici
t
[
chain_id
][
_key
].
probability
/=
conditionProbabilityExp
ilic
t
[
chain_id
][
_key
].
request_count
conditionProbabilityExp
lici
t
[
chain_id
][
_key
].
request_count
console
.
log
(
conditionResult
,
"
probability table
"
,
conditionProbabilityExp
ilic
t
);
console
.
log
(
conditionResult
,
"
probability table
"
,
conditionProbabilityExp
lici
t
);
let
branchToTake
=
metadata
[
conditionResult
]
let
branchToTake
=
metadata
[
conditionResult
]
branchMap
=
map
[
branchToTake
]
branchMap
=
map
[
branchToTake
]
delete
map
[
_key
]
delete
map
[
_key
]
...
@@ -323,7 +336,7 @@ async function speculative_deployment(chain_id, aliases, map, offset, done, toBe
...
@@ -323,7 +336,7 @@ async function speculative_deployment(chain_id, aliases, map, offset, done, toBe
if
(
metadata
.
type
===
'
conditional
'
&&
!
constants
.
JIT_deployment
)
{
if
(
metadata
.
type
===
'
conditional
'
&&
!
constants
.
JIT_deployment
)
{
let
probability
let
probability
try
{
try
{
probability
=
conditionProbabilityExp
ilic
t
[
chain_id
][
mod
].
probability
probability
=
conditionProbabilityExp
lici
t
[
chain_id
][
mod
].
probability
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
"
branch probability not present, random branch taken
"
);
console
.
log
(
"
branch probability not present, random branch taken
"
);
...
@@ -390,7 +403,7 @@ async function speculative_deployment(chain_id, aliases, map, offset, done, toBe
...
@@ -390,7 +403,7 @@ async function speculative_deployment(chain_id, aliases, map, offset, done, toBe
console
.
log
(
"
setting notification for conditional
"
,
mod
);
console
.
log
(
"
setting notification for conditional
"
,
mod
);
let
probability
let
probability
try
{
try
{
probability
=
conditionProbabilityExp
ilic
t
[
chain_id
][
mod
].
probability
probability
=
conditionProbabilityExp
lici
t
[
chain_id
][
mod
].
probability
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
"
branch probability not present, random branch taken
"
);
console
.
log
(
"
branch probability not present, random branch taken
"
);
probability
=
Math
.
random
()
probability
=
Math
.
random
()
...
...
dispatch_system/dispatch_manager/lib.js
View file @
38c00ae9
...
@@ -6,11 +6,10 @@ const winston = require('winston')
...
@@ -6,11 +6,10 @@ 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
({
...
@@ -19,7 +18,8 @@ let kafka = require('kafka-node'),
...
@@ -19,7 +18,8 @@ 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
...
...
dispatch_system/dispatch_manager/shared_meta.js
View file @
38c00ae9
...
@@ -7,7 +7,7 @@ let db = new Map(), // queue holding request to be dispatched
...
@@ -7,7 +7,7 @@ let db = new Map(), // queue holding request to be dispatched
// resources associated with the function
// resources associated with the function
workerNodes
=
new
Map
(),
// list of worker nodes currently known to the DM
workerNodes
=
new
Map
(),
// list of worker nodes currently known to the DM
functionBranchTree
=
new
Map
(),
// a tree to store function branch predictions
functionBranchTree
=
new
Map
(),
// a tree to store function branch predictions
conditionProbabilityExp
ilic
t
=
new
Map
()
// tree holding conditional probabilities for explicit chains
conditionProbabilityExp
lici
t
=
new
Map
()
// tree holding conditional probabilities for explicit chains
/**
/**
* URL to the couchdb database server used to store data
* URL to the couchdb database server used to store data
...
@@ -22,9 +22,11 @@ metricsDB = metricsDB + "/" + constants.db.metrics + "/"
...
@@ -22,9 +22,11 @@ metricsDB = metricsDB + "/" + constants.db.metrics + "/"
let
implicitChainDB
=
`http://
${
secrets
.
couchdb_username
}
:
${
secrets
.
couchdb_password
}
@
${
constants
.
couchdb_host
}
`
let
implicitChainDB
=
`http://
${
secrets
.
couchdb_username
}
:
${
secrets
.
couchdb_password
}
@
${
constants
.
couchdb_host
}
`
implicitChainDB
=
implicitChainDB
+
"
/
"
+
constants
.
db
.
implicit_chain_meta
+
"
/
"
implicitChainDB
=
implicitChainDB
+
"
/
"
+
constants
.
db
.
implicit_chain_meta
+
"
/
"
let
explicitChainDB
=
`http://
${
secrets
.
couchdb_username
}
:
${
secrets
.
couchdb_password
}
@
${
constants
.
couchdb_host
}
`
explicitChainDB
=
explicitChainDB
+
"
/
"
+
constants
.
db
.
explicit_chain_meta
+
"
/
"
module
.
exports
=
{
module
.
exports
=
{
db
,
functionBranchTree
,
functionToResource
,
workerNodes
,
resourceMap
,
db
,
functionBranchTree
,
functionToResource
,
workerNodes
,
resourceMap
,
conditionProbabilityExp
ilic
t
,
conditionProbabilityExp
lici
t
,
metadataDB
,
metricsDB
,
implicitChainDB
metadataDB
,
metricsDB
,
implicitChainDB
,
explicitChainDB
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment