MCPcopy
hub / github.com/CodisLabs/codis / SyncCreateAction

Method SyncCreateAction

pkg/topom/topom_group.go:451–475  ·  view source on GitHub ↗
(addr string)

Source from the content-addressed store, hash-verified

449}
450
451func (s *Topom) SyncCreateAction(addr string) error {
452 s.mu.Lock()
453 defer s.mu.Unlock()
454 ctx, err := s.newContext()
455 if err != nil {
456 return err
457 }
458
459 g, index, err := ctx.getGroupByServer(addr)
460 if err != nil {
461 return err
462 }
463 if g.Promoting.State != models.ActionNothing {
464 return errors.Errorf("group-[%d] is promoting", g.Id)
465 }
466
467 if g.Servers[index].Action.State == models.ActionPending {
468 return errors.Errorf("server-[%s] action already exist", addr)
469 }
470 defer s.dirtyGroupCache(g.Id)
471
472 g.Servers[index].Action.Index = ctx.maxSyncActionIndex() + 1
473 g.Servers[index].Action.State = models.ActionPending
474 return s.storeUpdateGroup(g)
475}
476
477func (s *Topom) SyncRemoveAction(addr string) error {
478 s.mu.Lock()

Callers 3

TestSyncActionFunction · 0.45
TestApiGroupFunction · 0.45

Calls 6

newContextMethod · 0.95
dirtyGroupCacheMethod · 0.95
storeUpdateGroupMethod · 0.95
getGroupByServerMethod · 0.80
ErrorfMethod · 0.80
maxSyncActionIndexMethod · 0.80

Tested by 2

TestSyncActionFunction · 0.36
TestApiGroupFunction · 0.36