Remove GetChanNameByVirtualChan (#5999)

* remove redundant ctx

Signed-off-by: yudong.cai <yudong.cai@zilliz.com>

* remove GetChanNameByVirtualChan

Signed-off-by: yudong.cai <yudong.cai@zilliz.com>
This commit is contained in:
Cai Yudong 2021-06-23 11:18:05 +08:00 committed by GitHub
parent 99be4c09a5
commit ba5aacd3f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 41 deletions

View File

@ -146,8 +146,6 @@ func (s *Server) init() error {
rootcoord.Params.Port = Params.Port
log.Debug("grpc init done ...")
ctx := context.Background()
closer := trace.InitTracing("root_coord")
s.closer = closer
@ -166,8 +164,8 @@ func (s *Server) init() error {
s.rootCoord.UpdateStateCode(internalpb.StateCode_Initializing)
log.Debug("RootCoord", zap.Any("State", internalpb.StateCode_Initializing))
s.rootCoord.SetNewProxyClient(
func(s *sessionutil.Session) (types.Proxy, error) {
cli, err := pnc.NewClient(ctx, s.Address, retry.Attempts(300))
func(se *sessionutil.Session) (types.Proxy, error) {
cli, err := pnc.NewClient(s.ctx, se.Address, retry.Attempts(300))
if err != nil {
return nil, err
}
@ -184,7 +182,7 @@ func (s *Server) init() error {
if s.newDataCoordClient != nil {
log.Debug("RootCoord start to create DataCoord client")
dataCoord := s.newDataCoordClient(rootcoord.Params.MetaRootPath, rootcoord.Params.EtcdEndpoints, retry.Attempts(300))
if err := s.rootCoord.SetDataCoord(ctx, dataCoord); err != nil {
if err := s.rootCoord.SetDataCoord(s.ctx, dataCoord); err != nil {
panic(err)
}
s.dataCoord = dataCoord
@ -218,7 +216,6 @@ func (s *Server) startGrpc() error {
}
func (s *Server) startGrpcLoop(grpcPort int) {
defer s.wg.Done()
log.Debug("start grpc ", zap.Int("port", grpcPort))
@ -244,7 +241,6 @@ func (s *Server) startGrpcLoop(grpcPort int) {
if err := s.grpcServer.Serve(lis); err != nil {
s.grpcErrChan <- err
}
}
func (s *Server) start() error {

View File

@ -68,7 +68,6 @@ type metaTable struct {
segID2PartitionID map[typeutil.UniqueID]typeutil.UniqueID // segment id -> partition id
flushedSegID map[typeutil.UniqueID]bool // flushed segment id
partitionID2CollID map[typeutil.UniqueID]typeutil.UniqueID // partition id -> collection id
vChan2Chan map[string]string // virtual channel name to physical channel name
tenantLock sync.RWMutex
proxyLock sync.RWMutex
@ -102,7 +101,6 @@ func (mt *metaTable) reloadFromKV() error {
mt.segID2CollID = make(map[typeutil.UniqueID]typeutil.UniqueID)
mt.segID2PartitionID = make(map[typeutil.UniqueID]typeutil.UniqueID)
mt.flushedSegID = make(map[typeutil.UniqueID]bool)
mt.vChan2Chan = make(map[string]string)
_, values, err := mt.client.LoadWithPrefix(TenantMetaPrefix, 0)
if err != nil {
@ -148,10 +146,6 @@ func (mt *metaTable) reloadFromKV() error {
for _, partID := range collInfo.PartitionIDs {
mt.partitionID2CollID[partID] = collInfo.ID
}
shardsNum := len(collInfo.VirtualChannelNames)
for i := 0; i < shardsNum; i++ {
mt.vChan2Chan[collInfo.VirtualChannelNames[i]] = collInfo.PhysicalChannelNames[i]
}
}
_, values, err = mt.client.LoadWithPrefix(PartitionMetaPrefix, 0)
@ -298,11 +292,6 @@ func (mt *metaTable) AddCollection(coll *pb.CollectionInfo, part *pb.PartitionIn
meta[k] = v
}
shardsNum := len(coll.VirtualChannelNames)
for i := 0; i < shardsNum; i++ {
mt.vChan2Chan[coll.VirtualChannelNames[i]] = coll.PhysicalChannelNames[i]
}
// save ddOpStr into etcd
addition := mt.getAdditionKV(ddOpStr, meta)
ts, err := mt.client.MultiSave(meta, addition)
@ -353,11 +342,6 @@ func (mt *metaTable) DeleteCollection(collID typeutil.UniqueID, ddOpStr func(ts
delete(mt.indexID2Meta, idxInfo.IndexID)
}
shardsNum := len(collMeta.VirtualChannelNames)
for i := 0; i < shardsNum; i++ {
delete(mt.vChan2Chan, collMeta.VirtualChannelNames[i])
}
delMetakeys := []string{
fmt.Sprintf("%s/%d", CollectionMetaPrefix, collID),
fmt.Sprintf("%s/%d", PartitionMetaPrefix, collID),
@ -1182,15 +1166,3 @@ func (mt *metaTable) AddFlushedSegment(segID typeutil.UniqueID) error {
mt.flushedSegID[segID] = true
return nil
}
// GetChanNameByVirtualChan return physical channel name corresponding the virtual channel
func (mt *metaTable) GetChanNameByVirtualChan(vname string) (string, error) {
mt.ddLock.RLock()
defer mt.ddLock.RUnlock()
chanName, ok := mt.vChan2Chan[vname]
if !ok {
return "", fmt.Errorf("cannot find virtual channel %s", vname)
}
return chanName, nil
}

View File

@ -443,7 +443,6 @@ func TestMasterService(t *testing.T) {
assert.Nil(t, err)
assert.Equal(t, commonpb.ErrorCode_Success, status.ErrorCode)
assert.Equal(t, 2, len(core.MetaTable.vChan2Chan))
assert.Equal(t, 2, len(core.dmlChannels.dml))
pChan := core.MetaTable.ListCollectionPhysicalChannels()
@ -463,9 +462,7 @@ func TestMasterService(t *testing.T) {
assert.Equal(t, 2, len(createMeta.PhysicalChannelNames))
vChanName := createMeta.VirtualChannelNames[0]
chanName, err := core.MetaTable.GetChanNameByVirtualChan(vChanName)
assert.Nil(t, err)
assert.Equal(t, createMeta.PhysicalChannelNames[0], chanName)
assert.Equal(t, createMeta.PhysicalChannelNames[0], ToPhysicalChannel(vChanName))
// get CreatePartitionMsg
msgPack, ok = <-dmlStream.Chan()
@ -1058,8 +1055,7 @@ func TestMasterService(t *testing.T) {
assert.Equal(t, commonpb.ErrorCode_Success, status.ErrorCode)
vChanName := collMeta.VirtualChannelNames[0]
_, err = core.MetaTable.GetChanNameByVirtualChan(vChanName)
assert.NotNil(t, err)
assert.Equal(t, collMeta.PhysicalChannelNames[0], ToPhysicalChannel(vChanName))
msgs := getNotTtMsg(ctx, 1, dmlStream.Chan())
assert.Equal(t, 1, len(msgs))