MCPcopy Index your code
hub / github.com/CodisLabs/codis / fillSlot

Method fillSlot

pkg/proxy/router.go:168–233  ·  view source on GitHub ↗
(m *models.Slot, switched bool, method forwardMethod)

Source from the content-addressed store, hash-verified

166}
167
168func (s *Router) fillSlot(m *models.Slot, switched bool, method forwardMethod) {
169 slot := &s.slots[m.Id]
170 slot.blockAndWait()
171
172 slot.backend.bc.Release()
173 slot.backend.bc = nil
174 slot.backend.id = 0
175 slot.migrate.bc.Release()
176 slot.migrate.bc = nil
177 slot.migrate.id = 0
178 for i := range slot.replicaGroups {
179 for _, bc := range slot.replicaGroups[i] {
180 bc.Release()
181 }
182 }
183 slot.replicaGroups = nil
184
185 slot.switched = switched
186
187 if addr := m.BackendAddr; len(addr) != 0 {
188 slot.backend.bc = s.pool.primary.Retain(addr)
189 slot.backend.id = m.BackendAddrGroupId
190 }
191 if from := m.MigrateFrom; len(from) != 0 {
192 slot.migrate.bc = s.pool.primary.Retain(from)
193 slot.migrate.id = m.MigrateFromGroupId
194 }
195 if !s.config.BackendPrimaryOnly {
196 for i := range m.ReplicaGroups {
197 var group []*sharedBackendConn
198 for _, addr := range m.ReplicaGroups[i] {
199 group = append(group, s.pool.replica.Retain(addr))
200 }
201 if len(group) == 0 {
202 continue
203 }
204 slot.replicaGroups = append(slot.replicaGroups, group)
205 }
206 }
207 if method != nil {
208 slot.method = method
209 }
210
211 if !m.Locked {
212 slot.unblock()
213 }
214 if !s.closed {
215 if slot.migrate.bc != nil {
216 if switched {
217 log.Warnf("fill slot %04d, backend.addr = %s, migrate.from = %s, locked = %t, +switched",
218 slot.id, slot.backend.bc.Addr(), slot.migrate.bc.Addr(), slot.lock.hold)
219 } else {
220 log.Warnf("fill slot %04d, backend.addr = %s, migrate.from = %s, locked = %t",
221 slot.id, slot.backend.bc.Addr(), slot.migrate.bc.Addr(), slot.lock.hold)
222 }
223 } else {
224 if switched {
225 log.Warnf("fill slot %04d, backend.addr = %s, locked = %t, +switched",

Callers 3

CloseMethod · 0.95
FillSlotMethod · 0.95
trySwitchMasterMethod · 0.95

Calls 6

blockAndWaitMethod · 0.80
unblockMethod · 0.80
WarnfMethod · 0.80
ReleaseMethod · 0.45
RetainMethod · 0.45
AddrMethod · 0.45

Tested by

no test coverage detected