-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode_master.lua
More file actions
54 lines (44 loc) · 1.33 KB
/
node_master.lua
File metadata and controls
54 lines (44 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
local log = require('log')
local vertex_methods = require('pregel.vertex').vertex_methods
local constants = require('constants')
local node_status = constants.node_status
local vertex_type = constants.vertex_type
local node_common_methods = require('node_common').methods
local node_master_methods = {
__init = function(self)
self:set_status(node_status.WORKING)
log.info('<MASTER> Initializing')
end,
work = function(self)
local value = self:get_value()
local wc = self:get_worker_context()
if self:get_superstep() == 1 then
for name, _ in pairs(wc.taskPhases) do
log.info('<MASTER> Adding task vertex %s', name)
self:add_vertex({
name = name,
vtype = vertex_type.TASK,
features = value.features,
status = node_status.NEW
})
end
end
self:set_status(node_status.INACTIVE)
self:vote_halt()
end,
}
local node_master_mt = {
__index = {}
}
for k, v in pairs(vertex_methods) do
node_master_mt.__index[k] = v
end
for k, v in pairs(node_common_methods) do
node_master_mt.__index[k] = v
end
for k, v in pairs(node_master_methods) do
node_master_mt.__index[k] = v
end
return {
mt = node_master_mt
}