MCPcopy
hub / github.com/dgraph-io/dgraph / Inform

Method Inform

worker/groups.go:484–531  ·  view source on GitHub ↗
(preds []string)

Source from the content-addressed store, hash-verified

482}
483
484func (g *groupi) Inform(preds []string) ([]*pb.Tablet, error) {
485 unknownPreds := make([]*pb.Tablet, 0)
486 tablets := make([]*pb.Tablet, 0)
487 g.RLock()
488 for _, p := range preds {
489 if len(p) == 0 {
490 continue
491 }
492
493 if tab, ok := g.tablets[p]; !ok {
494 unknownPreds = append(unknownPreds, &pb.Tablet{GroupId: g.groupId(), Predicate: p})
495 } else {
496 tablets = append(tablets, tab)
497 }
498 }
499 g.RUnlock()
500
501 if len(unknownPreds) == 0 {
502 return nil, nil
503 }
504
505 pl := g.connToZeroLeader()
506 zc := pb.NewZeroClient(pl.Get())
507 out, err := zc.Inform(g.Ctx(), &pb.TabletRequest{
508 Tablets: unknownPreds,
509 GroupId: g.groupId(),
510 })
511 if err != nil {
512 glog.Errorf("Error while Inform grpc call %v", err)
513 return nil, err
514 }
515
516 // Do not store tablets with group ID 0, as they are just dummy tablets for
517 // predicates that do no exist.
518 g.Lock()
519 for _, t := range out.Tablets {
520 if t.GroupId > 0 {
521 g.tablets[t.GetPredicate()] = t
522 tablets = append(tablets, t)
523 }
524
525 if t.GroupId == groups().groupId() {
526 glog.Infof("Serving tablet for: %v\n", t.GetPredicate())
527 }
528 }
529 g.Unlock()
530 return tablets, nil
531}
532
533// Do not modify the returned Tablet
534func (g *groupi) Tablet(key string) (*pb.Tablet, error) {

Callers 1

Calls 14

groupIdMethod · 0.95
connToZeroLeaderMethod · 0.95
InformMethod · 0.95
CtxMethod · 0.95
NewZeroClientFunction · 0.92
groupsFunction · 0.85
RLockMethod · 0.80
RUnlockMethod · 0.80
InfofMethod · 0.80
GetMethod · 0.65
ErrorfMethod · 0.45
LockMethod · 0.45

Tested by

no test coverage detected