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
ce3d339d
Commit
ce3d339d
authored
Aug 06, 2020
by
NILANJAN DAW
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
restructuring resource manager
parent
f738058f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
0 deletions
+56
-0
dispatch_system/dispatch_manager/rm.js
dispatch_system/dispatch_manager/rm.js
+56
-0
No files found.
dispatch_system/dispatch_manager/rm.js
0 → 100644
View file @
ce3d339d
let
workerNodes
=
{},
timeline
=
{}
const
constants
=
require
(
'
../constants.json
'
)
let
kafka
=
require
(
'
kafka-node
'
),
Producer
=
kafka
.
Producer
,
client
=
new
kafka
.
KafkaClient
({
kafkaHost
:
constants
.
network
.
external
.
kafka_host
,
autoConnect
:
true
}),
producer
=
new
Producer
(
client
),
Consumer
=
kafka
.
Consumer
,
consumer
=
new
Consumer
(
client
,
[
{
topic
:
'
heartbeat
'
},
// receives heartbeat messages from workers, also acts as worker join message
{
topic
:
"
request
"
}
// receives deployment details from RM
],
[
{
autoCommit
:
true
}
])
function
getAddress
()
{
}
consumer
.
on
(
'
message
'
,
function
(
message
)
{
let
topic
=
message
.
topic
message
=
message
.
value
if
(
topic
!==
"
heartbeat
"
)
console
.
log
(
message
);
if
(
topic
===
"
heartbeat
"
)
{
message
=
JSON
.
parse
(
message
)
if
(
Date
.
now
()
-
message
.
timestamp
<
1000
)
if
(
!
workerNodes
[
message
.
address
])
{
workerNodes
[
message
.
address
]
=
message
console
.
log
(
"
New worker discovered. Worker List:
"
)
console
.
log
(
workerNodes
);
}
}
else
if
(
topic
===
"
request
"
)
{
message
=
JSON
.
parse
(
message
)
console
.
log
(
message
);
let
payload
=
[{
topic
:
"
RESPONSE_RM_2_DM_DUMMY
"
,
messages
:
JSON
.
stringify
({
"
resource_id
"
:
message
.
resource_id
,
"
timestamp
"
:
Date
.
now
(),
"
nodes
"
:
[
{
node_id
:
getAddress
(),
port
:
null
}]
}),
partition
:
0
}]
producer
.
send
(
payload
,
()
=>
{
console
.
log
(
`Replied`
)
})
}
})
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