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
6ddbd13c
Commit
6ddbd13c
authored
Jan 26, 2020
by
nilanjandaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoupling daemons almost done
Issue with file server remains, unable to download file from master node
parent
df51f208
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
8 deletions
+14
-8
dispatcher/index.js
dispatcher/index.js
+14
-8
No files found.
dispatcher/index.js
View file @
6ddbd13c
...
@@ -12,19 +12,21 @@ const client = mqtt.connect('mqtt://localhost')
...
@@ -12,19 +12,21 @@ const client = mqtt.connect('mqtt://localhost')
const
app
=
express
()
const
app
=
express
()
const
libSupport
=
require
(
'
./lib
'
)
const
libSupport
=
require
(
'
./lib
'
)
// const secret = require('../secrets.json')
// const db = require('nano')(`http://${secret.dispatched_db_username}:${secret.dispatched_db_password}@localhost:5984/dispatched`)
let
db
=
new
Map
()
let
db
=
new
Map
()
app
.
use
(
morgan
(
'
combined
'
))
app
.
use
(
morgan
(
'
combined
'
))
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
false
}))
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
false
}))
app
.
use
(
bodyParser
.
json
())
app
.
use
(
bodyParser
.
json
())
const
file_path
=
__dirname
+
"
/repository
"
app
.
use
(
'
/repository
'
,
express
.
static
(
file_path
));
app
.
use
(
fileUpload
())
app
.
use
(
fileUpload
())
const
node_id
=
"
20sez54hq8
"
const
WINDOW_SIZE
=
1
const
port
=
8080
let
requestQueue
=
[]
let
requestQueue
=
[]
const
node_id
=
"
20sez54hq8
"
const
WINDOW_SIZE
=
10
const
port
=
8080
app
.
post
(
'
/serverless/deploy
'
,
(
req
,
res
)
=>
{
app
.
post
(
'
/serverless/deploy
'
,
(
req
,
res
)
=>
{
...
@@ -33,7 +35,7 @@ app.post('/serverless/deploy', (req, res) => {
...
@@ -33,7 +35,7 @@ app.post('/serverless/deploy', (req, res) => {
let
functionHash
=
file
.
md5
let
functionHash
=
file
.
md5
file
.
mv
(
__dirname
+
"
/test/
"
+
functionHash
,
function
(
err
)
{
file
.
mv
(
file_path
+
functionHash
,
function
(
err
)
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
err
);
console
.
log
(
err
);
res
.
send
(
"
error
"
).
status
(
400
)
res
.
send
(
"
error
"
).
status
(
400
)
...
@@ -117,7 +119,8 @@ app.post('/serverless/execute/:id', (req, res) => {
...
@@ -117,7 +119,8 @@ app.post('/serverless/execute/:id', (req, res) => {
function
dispatch
()
{
function
dispatch
()
{
for
(
let
i
=
0
;
i
<
WINDOW_SIZE
;
i
++
)
{
let
lookbackWindow
=
Math
.
min
(
WINDOW_SIZE
,
requestQueue
.
length
)
for
(
let
i
=
0
;
i
<
lookbackWindow
;
i
++
)
{
let
{
req
,
res
}
=
requestQueue
.
shift
()
let
{
req
,
res
}
=
requestQueue
.
shift
()
let
runtime
=
req
.
body
.
runtime
let
runtime
=
req
.
body
.
runtime
let
functionHash
=
req
.
params
.
id
let
functionHash
=
req
.
params
.
id
...
@@ -145,6 +148,7 @@ client.on('message', function (topic, message) {
...
@@ -145,6 +148,7 @@ client.on('message', function (topic, message) {
"
status
"
:
"
success
"
,
"
status
"
:
"
success
"
,
"
reply
"
:
message
.
result
"
reply
"
:
message
.
result
})
})
db
.
delete
(
message
.
function_id
)
}
}
})
})
...
@@ -152,4 +156,6 @@ app.listen(port, () => console.log(`Server listening on port ${port}!`))
...
@@ -152,4 +156,6 @@ app.listen(port, () => console.log(`Server listening on port ${port}!`))
client
.
on
(
'
connect
'
,
function
()
{
client
.
on
(
'
connect
'
,
function
()
{
client
.
subscribe
(
"
response
"
)
client
.
subscribe
(
"
response
"
)
})
})
\ No newline at end of file
setInterval
(
dispatch
,
1000
);
\ 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