Skip to content

Commit

Permalink
store/tikv: extract GetTiFlashAddrs from MPPClient (#22802)
Browse files Browse the repository at this point in the history
Signed-off-by: disksing <[email protected]>
  • Loading branch information
disksing authored Feb 19, 2021
1 parent 8842bbc commit 381ac81
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
10 changes: 3 additions & 7 deletions store/tikv/mpp.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,10 @@ func (c *batchCopTask) GetAddress() string {

func (c *MPPClient) selectAllTiFlashStore() []kv.MPPTaskMeta {
resultTasks := make([]kv.MPPTaskMeta, 0)
c.store.regionCache.storeMu.RLock()
for _, st := range c.store.regionCache.storeMu.stores {
if st.storeType == kv.TiFlash {
task := &batchCopTask{storeAddr: st.addr, cmdType: tikvrpc.CmdMPPTask}
resultTasks = append(resultTasks, task)
}
for _, addr := range c.store.regionCache.GetTiFlashStoreAddrs() {
task := &batchCopTask{storeAddr: addr, cmdType: tikvrpc.CmdMPPTask}
resultTasks = append(resultTasks, task)
}
c.store.regionCache.storeMu.RUnlock()
return resultTasks
}

Expand Down
13 changes: 13 additions & 0 deletions store/tikv/region_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -1244,6 +1244,19 @@ func (c *RegionCache) PDClient() pd.Client {
return c.pdClient
}

// GetTiFlashStoreAddrs returns addresses of all tiflash nodes.
func (c *RegionCache) GetTiFlashStoreAddrs() []string {
c.storeMu.RLock()
defer c.storeMu.RUnlock()
var addrs []string
for _, s := range c.storeMu.stores {
if s.storeType == kv.TiFlash {
addrs = append(addrs, s.addr)
}
}
return addrs
}

// btreeItem is BTree's Item that uses []byte to compare.
type btreeItem struct {
key []byte
Expand Down

0 comments on commit 381ac81

Please sign in to comment.