-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.go
More file actions
39 lines (32 loc) · 792 Bytes
/
Copy pathnode.go
File metadata and controls
39 lines (32 loc) · 792 Bytes
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
/*
FileName : node.go
Description : Signifies a node/computer on which processes are migrated to
DateCreated : October 13 in 20255
Author : Leonard Jombo
*/
package main
import "fmt"
type Node struct {
ID string
Processes map[int]*Process
}
func NewNode(id string) *Node {
return &Node{
ID: id,
Processes: make(map[int]*Process),
}
}
func (n *Node) AddProcess(p *Process) {
n.Processes[p.PID] = p
fmt.Printf("Node %s: Added process %d\n", n.ID, p.PID)
}
func (n *Node) RemoveProcess(pid int) {
delete(n.Processes, pid)
fmt.Printf("Node %s: Removed process %d\n", n.ID, pid)
}
func (n *Node) PrintProcesses() {
fmt.Printf("\nNode %s Process Table:\n", n.ID)
for _, p := range n.Processes {
p.PrintInfo()
}
}