-
Notifications
You must be signed in to change notification settings - Fork 51
/
collector_reader.go
59 lines (46 loc) · 1.21 KB
/
collector_reader.go
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
package statscollector
import (
"go.aporeto.io/trireme-lib/collector"
)
// Count returns the current number of flows.
func (c *collectorImpl) Count() int {
c.Lock()
defer c.Unlock()
return len(c.Flows)
}
// GetAllRecords should return all flow records stashed so far.
func (c *collectorImpl) GetAllRecords() map[string]*collector.FlowRecord {
c.Lock()
defer c.Unlock()
if len(c.Flows) == 0 {
return nil
}
retval := c.Flows
c.Flows = make(map[string]*collector.FlowRecord)
return retval
}
// GetUserRecords retrieves all the user records.
func (c *collectorImpl) GetUserRecords() map[string]*collector.UserRecord {
c.Lock()
defer c.Unlock()
if len(c.Users) == 0 {
return nil
}
retval := c.Users
c.Users = map[string]*collector.UserRecord{}
return retval
}
// FlushUserCache flushes the user cache.
func (c *collectorImpl) FlushUserCache() {
c.Lock()
defer c.Unlock()
c.ProcessedUsers = map[string]bool{}
}
// GetAllDataPathPacketRecords returns all datapath packet tracing records
func (c *collectorImpl) GetAllDataPathPacketRecords() []*collector.PacketReport {
c.Lock()
defer c.Unlock()
record := c.DatapathPacketReports
c.DatapathPacketReports = []*collector.PacketReport{}
return record
}