-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueue.go
More file actions
143 lines (107 loc) · 2.71 KB
/
queue.go
File metadata and controls
143 lines (107 loc) · 2.71 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
package queue
import (
//"fmt"
//"time"
config "DistSysTestPlatform/src/utils/config"
)
type TimeoutQueue struct {
NetQueue TQueue
NetQueueCh chan TQueueItem
DiskQueue TQueue
DiskQueueCh chan TQueueItem
SysCpuQueue TQueue
SysCpuQueueCh chan TQueueItem
SysMemQueue TQueue
SysMemQueueCh chan TQueueItem
ProcQueue TQueue
ProcQueueCh chan TQueueItem
}
func (this *TimeoutQueue) Initialize() bool {
this.NetQueue = NewBasicTimeoutQueue()
this.NetQueueCh = this.NetQueue.GetDequeueChan()
this.DiskQueue = NewBasicTimeoutQueue()
this.DiskQueueCh = this.DiskQueue.GetDequeueChan()
this.SysCpuQueue = NewBasicTimeoutQueue()
this.SysCpuQueueCh = this.SysCpuQueue.GetDequeueChan()
this.SysMemQueue = NewBasicTimeoutQueue()
this.SysMemQueueCh = this.SysMemQueue.GetDequeueChan()
this.ProcQueue = NewBasicTimeoutQueue()
this.ProcQueueCh = this.ProcQueue.GetDequeueChan()
return true
}
func (this *TimeoutQueue) NetEnqueue(
element_json_config config.EthernetConfig,
duration int64 /*second*/) error {
//fmt.Println(element_json_config)
item, err := NewBasicTimeoutQueueItem(element_json_config, int(duration))
if err != nil {
return err
}
err = this.NetQueue.Enqueue(item)
if err != nil {
return err
}
return nil
}
func (this *TimeoutQueue) DiskEnqueue(
element_json_config config.DiskConfig,
duration int64 /*second*/) error {
//fmt.Println(element_json_config)
item, err := NewBasicTimeoutQueueItem(element_json_config, int(duration))
if err != nil {
return err
}
err = this.DiskQueue.Enqueue(item)
if err != nil {
return err
}
return nil
}
func (this *TimeoutQueue) SysCpuEnqueue(
element_json_config config.SysCpuConfig,
duration int64 /*second*/) error {
item, err := NewBasicTimeoutQueueItem(element_json_config, int(duration))
if err != nil {
return err
}
err = this.SysCpuQueue.Enqueue(item)
if err != nil {
return err
}
return nil
}
func (this *TimeoutQueue) SysMemEnqueue(
element_json_config config.SysMemConfig,
duration int64 /*second*/) error {
item, err := NewBasicTimeoutQueueItem(element_json_config, int(duration))
if err != nil {
return err
}
err = this.SysMemQueue.Enqueue(item)
if err != nil {
return err
}
return nil
}
func (this *TimeoutQueue) ProcEnqueue(
element_json_config config.ProcConfig,
duration int64 /*second*/) error {
//fmt.Println(element_json_config)
item, err := NewBasicTimeoutQueueItem(element_json_config, int(duration))
if err != nil {
return err
}
err = this.ProcQueue.Enqueue(item)
if err != nil {
return err
}
return nil
}
func NewQueueSingleton() *TimeoutQueue {
return &TimeoutQueue{}
}
var QueueFactory *TimeoutQueue
func init() {
QueueFactory = NewQueueSingleton()
QueueFactory.Initialize()
}