| 89 | } |
| 90 | |
| 91 | func (this *Manager) Load() error { |
| 92 | var offset int64 = 0 |
| 93 | var size int64 = 10000 |
| 94 | for { |
| 95 | agentIPs, err := this.db.ListAgentIPs(offset, size) |
| 96 | if err != nil { |
| 97 | return err |
| 98 | } |
| 99 | if len(agentIPs) == 0 { |
| 100 | break |
| 101 | } |
| 102 | for _, agentIP := range agentIPs { |
| 103 | this.locker.Lock() |
| 104 | this.ipMap[agentIP.IP] = agentIP.AgentCode |
| 105 | this.locker.Unlock() |
| 106 | |
| 107 | if agentIP.Id > this.lastId { |
| 108 | this.lastId = agentIP.Id |
| 109 | } |
| 110 | } |
| 111 | offset += size |
| 112 | } |
| 113 | |
| 114 | return nil |
| 115 | } |
| 116 | |
| 117 | func (this *Manager) LoopAll() error { |
| 118 | for { |