(preds []string)
| 482 | } |
| 483 | |
| 484 | func (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 |
| 534 | func (g *groupi) Tablet(key string) (*pb.Tablet, error) { |
no test coverage detected