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
583d2163
Commit
583d2163
authored
Feb 16, 2020
by
Nilanjan Daw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed redundant event listeners
parent
79adfd7d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
41 deletions
+11
-41
.gitignore
.gitignore
+2
-1
dispatch_module/dispatch_daemon/execute.js
dispatch_module/dispatch_daemon/execute.js
+3
-16
dispatch_module/dispatch_daemon/index.js
dispatch_module/dispatch_daemon/index.js
+5
-24
dispatch_module/dispatch_daemon/lib.js
dispatch_module/dispatch_daemon/lib.js
+1
-0
No files found.
.gitignore
View file @
583d2163
...
@@ -5,3 +5,4 @@ package-lock.json
...
@@ -5,3 +5,4 @@ package-lock.json
firecracker*
firecracker*
secrets.json
secrets.json
resource_manager/bin/**
resource_manager/bin/**
grunt
dispatch_module/dispatch_daemon/execute.js
View file @
583d2163
...
@@ -4,9 +4,6 @@ const fs = require('fs')
...
@@ -4,9 +4,6 @@ const fs = require('fs')
const
{
spawn
}
=
require
(
'
child_process
'
);
const
{
spawn
}
=
require
(
'
child_process
'
);
const
{
Worker
,
isMainThread
,
workerData
}
=
require
(
'
worker_threads
'
);
const
{
Worker
,
isMainThread
,
workerData
}
=
require
(
'
worker_threads
'
);
const
registry_url
=
"
10.129.6.5:5000/
"
const
registry_url
=
"
10.129.6.5:5000/
"
const
events
=
require
(
'
events
'
);
const
workerEvent
=
new
events
.
EventEmitter
();
const
parentProcess
=
require
(
'
process
'
);
function
runIsolate
(
local_repository
,
functionHash
,
port
,
resource_id
)
{
function
runIsolate
(
local_repository
,
functionHash
,
port
,
resource_id
)
{
let
filename
=
local_repository
+
functionHash
+
"
.js
"
let
filename
=
local_repository
+
functionHash
+
"
.js
"
...
@@ -19,7 +16,6 @@ function runIsolate(local_repository, functionHash, port, resource_id) {
...
@@ -19,7 +16,6 @@ function runIsolate(local_repository, functionHash, port, resource_id) {
if
(
code
!==
0
)
if
(
code
!==
0
)
reject
(
new
Error
(
`Worker stopped with exit code
${
code
}
`
));
reject
(
new
Error
(
`Worker stopped with exit code
${
code
}
`
));
console
.
log
(
"
worker exited
"
);
console
.
log
(
"
worker exited
"
);
workerEvent
.
emit
(
'
end
'
,
port
,
"
isolate
"
);
})
})
worker
.
on
(
'
online
'
,
()
=>
{
worker
.
on
(
'
online
'
,
()
=>
{
workerEvent
.
emit
(
'
start
'
,
functionHash
,
port
,
"
isolate
"
)
workerEvent
.
emit
(
'
start
'
,
functionHash
,
port
,
"
isolate
"
)
...
@@ -41,7 +37,6 @@ function runProcess(local_repository, functionHash, port, resource_id) {
...
@@ -41,7 +37,6 @@ function runProcess(local_repository, functionHash, port, resource_id) {
result
+=
data
;
result
+=
data
;
let
timeDifference
=
Math
.
ceil
((
Date
.
now
()
-
timeStart
))
let
timeDifference
=
Math
.
ceil
((
Date
.
now
()
-
timeStart
))
console
.
log
(
"
process time taken:
"
,
timeDifference
);
console
.
log
(
"
process time taken:
"
,
timeDifference
);
// workerEvent.emit('start', functionHash, port, "process")
resolve
(
result
);
resolve
(
result
);
});
});
...
@@ -52,7 +47,6 @@ function runProcess(local_repository, functionHash, port, resource_id) {
...
@@ -52,7 +47,6 @@ function runProcess(local_repository, functionHash, port, resource_id) {
process
.
on
(
'
close
'
,
(
code
)
=>
{
process
.
on
(
'
close
'
,
(
code
)
=>
{
console
.
log
(
`child process exited with code
${
code
}
`
);
console
.
log
(
`child process exited with code
${
code
}
`
);
// workerEvent.emit('end', port, "process");
});
});
})
})
...
@@ -89,7 +83,6 @@ function runContainer(imageName, port, resource_id) {
...
@@ -89,7 +83,6 @@ function runContainer(imageName, port, resource_id) {
let
timeDifference
=
Math
.
ceil
((
Date
.
now
()
-
timeStart
))
let
timeDifference
=
Math
.
ceil
((
Date
.
now
()
-
timeStart
))
console
.
log
(
"
container run time taken:
"
,
timeDifference
);
console
.
log
(
"
container run time taken:
"
,
timeDifference
);
result
+=
data
;
result
+=
data
;
workerEvent
.
emit
(
'
start
'
,
imageName
,
port
,
"
container
"
)
resolve
(
result
);
resolve
(
result
);
});
});
...
@@ -99,7 +92,8 @@ function runContainer(imageName, port, resource_id) {
...
@@ -99,7 +92,8 @@ function runContainer(imageName, port, resource_id) {
});
});
process
.
on
(
'
close
'
,
(
code
)
=>
{
process
.
on
(
'
close
'
,
(
code
)
=>
{
workerEvent
.
emit
(
'
end
'
,
port
,
"
container
"
);
console
.
log
(
"
Exiting container
"
);
})
})
}
}
...
@@ -115,8 +109,6 @@ function runContainer(imageName, port, resource_id) {
...
@@ -115,8 +109,6 @@ function runContainer(imageName, port, resource_id) {
console
.
log
(
`stdout:
${
data
}
`
);
console
.
log
(
`stdout:
${
data
}
`
);
let
timeDifference
=
Math
.
ceil
((
Date
.
now
()
-
timeStart
))
let
timeDifference
=
Math
.
ceil
((
Date
.
now
()
-
timeStart
))
console
.
log
(
"
container run time taken:
"
,
timeDifference
);
console
.
log
(
"
container run time taken:
"
,
timeDifference
);
// result += data;
workerEvent
.
emit
(
'
start
'
,
imageName
,
port
,
"
container
"
)
resolve
(
result
);
resolve
(
result
);
});
});
...
@@ -126,7 +118,7 @@ function runContainer(imageName, port, resource_id) {
...
@@ -126,7 +118,7 @@ function runContainer(imageName, port, resource_id) {
});
});
process
.
on
(
'
close
'
,
(
code
)
=>
{
process
.
on
(
'
close
'
,
(
code
)
=>
{
workerEvent
.
emit
(
'
end
'
,
port
,
"
container
"
);
console
.
log
(
"
Exiting
container
"
);
})
})
}
}
...
@@ -138,11 +130,6 @@ function runContainer(imageName, port, resource_id) {
...
@@ -138,11 +130,6 @@ function runContainer(imageName, port, resource_id) {
}
}
parentProcess
.
stdout
.
on
(
'
data
'
,
data
=>
{
console
.
log
(
"
handler
"
,
data
);
})
module
.
exports
.
runContainer
=
runContainer
;
module
.
exports
.
runContainer
=
runContainer
;
module
.
exports
.
runProcess
=
runProcess
;
module
.
exports
.
runProcess
=
runProcess
;
module
.
exports
.
runIsolate
=
runIsolate
;
module
.
exports
.
runIsolate
=
runIsolate
;
...
...
dispatch_module/dispatch_daemon/index.js
View file @
583d2163
...
@@ -13,10 +13,7 @@ const kafka = require('kafka-node')
...
@@ -13,10 +13,7 @@ const kafka = require('kafka-node')
const
local_repository
=
__dirname
+
"
/local_repository/
"
const
local_repository
=
__dirname
+
"
/local_repository/
"
const
host_url
=
"
http://
"
+
constants
.
master_address
+
"
:
"
+
constants
.
master_port
const
host_url
=
"
http://
"
+
constants
.
master_address
+
"
:
"
+
constants
.
master_port
let
usedPort
=
new
Map
()
let
Producer
=
kafka
.
Producer
,
let
Producer
=
kafka
.
Producer
,
KeyedMessage
=
kafka
.
KeyedMessage
,
client
=
new
kafka
.
KafkaClient
({
client
=
new
kafka
.
KafkaClient
({
kafkaHost
:
constants
.
kafka_host
,
kafkaHost
:
constants
.
kafka_host
,
autoConnect
:
true
autoConnect
:
true
...
@@ -97,27 +94,6 @@ function heartbeat() {
...
@@ -97,27 +94,6 @@ function heartbeat() {
producer
.
send
(
payload
,
function
()
{})
producer
.
send
(
payload
,
function
()
{})
}
}
execute
.
workerEvent
.
on
(
"
start
"
,
(
functionHash
,
port
,
runtime
)
=>
{
console
.
log
(
"
started function Port:
"
,
port
,
functionHash
);
// producer.send(
// [{
// topic: "deployed",
// messages: JSON.stringify({ functionHash, port, runtime, node_id })
// }], () => { })
})
execute
.
workerEvent
.
on
(
'
end
'
,
(
port
,
runtime
)
=>
{
let
functionHash
=
usedPort
.
get
(
port
)
usedPort
.
delete
(
port
)
// producer.send(
// [{
// topic: "removeWorker",
// messages: JSON.stringify({ functionHash, port, runtime, node_id })
// }], () => {
// console.log("Ending worker for function", functionHash, usedPort);
// })
})
grunt
.
stdout
.
on
(
'
data
'
,
data
=>
{
grunt
.
stdout
.
on
(
'
data
'
,
data
=>
{
console
.
log
(
data
.
toString
());
console
.
log
(
data
.
toString
());
...
@@ -130,6 +106,11 @@ grunt.stderr.on('data', data => {
...
@@ -130,6 +106,11 @@ grunt.stderr.on('data', data => {
})
})
grunt
.
on
(
'
close
'
,
(
code
)
=>
{
console
.
log
(
"
Grunt exited with exit code
"
,
code
);
})
setInterval
(
heartbeat
,
1000
);
setInterval
(
heartbeat
,
1000
);
/**
/**
...
...
dispatch_module/dispatch_daemon/lib.js
View file @
583d2163
...
@@ -43,6 +43,7 @@ function makeTopic(id) {
...
@@ -43,6 +43,7 @@ function makeTopic(id) {
})
})
})
})
}
}
var
download
=
function
(
url
,
dest
,
cb
)
{
var
download
=
function
(
url
,
dest
,
cb
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
console
.
log
(
url
);
console
.
log
(
url
);
...
...
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