mirror of https://github.com/tikv/client-go.git
parent
0d003d077b
commit
39cd84957f
|
|
@ -84,23 +84,29 @@ const (
|
|||
defaultRegionsPerBatch = 128
|
||||
)
|
||||
|
||||
// Return false means label doesn't match, and will ignore this store.
|
||||
// LabelFilter returns false means label doesn't match, and will ignore this store.
|
||||
type LabelFilter = func(labels []*metapb.StoreLabel) bool
|
||||
|
||||
// LabelFilterOnlyTiFlashWriteNode will only select stores whose label contains: <engine, tiflash> and <engine_role, write>.
|
||||
// Only used for tiflash_compute node.
|
||||
var LabelFilterOnlyTiFlashWriteNode = func(labels []*metapb.StoreLabel) bool {
|
||||
return isStoreContainLabel(labels, tikvrpc.EngineLabelKey, tikvrpc.EngineLabelTiFlash) &&
|
||||
isStoreContainLabel(labels, tikvrpc.EngineRoleLabelKey, tikvrpc.EngineRoleWrite)
|
||||
isStoreContainLabel(labels, tikvrpc.EngineRoleLabelKey, tikvrpc.EngineRoleWrite)
|
||||
}
|
||||
|
||||
// LabelFilterNoTiFlashWriteNode will only select stores whose label contains: <engine, tiflash>, but not contains <engine_role, write>.
|
||||
// Normally tidb use this filter.
|
||||
var LabelFilterNoTiFlashWriteNode = func(labels []*metapb.StoreLabel) bool {
|
||||
return isStoreContainLabel(labels, tikvrpc.EngineLabelKey, tikvrpc.EngineLabelTiFlash) &&
|
||||
!isStoreContainLabel(labels, tikvrpc.EngineRoleLabelKey, tikvrpc.EngineRoleWrite)
|
||||
!isStoreContainLabel(labels, tikvrpc.EngineRoleLabelKey, tikvrpc.EngineRoleWrite)
|
||||
}
|
||||
|
||||
// LabelFilterAllTiFlashNode will select all tiflash stores.
|
||||
var LabelFilterAllTiFlashNode = func(labels []*metapb.StoreLabel) bool {
|
||||
return isStoreContainLabel(labels, tikvrpc.EngineLabelKey, tikvrpc.EngineLabelTiFlash)
|
||||
}
|
||||
|
||||
// LabelFilterAllNode will select all stores.
|
||||
var LabelFilterAllNode = func(_ []*metapb.StoreLabel) bool {
|
||||
return true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -997,7 +997,7 @@ func (s *testRegionCacheSuite) TestRegionEpochOnTiFlash() {
|
|||
s.Equal(lctx.Peer.Id, peer3)
|
||||
|
||||
// epoch-not-match on tiflash
|
||||
ctxTiFlash, err := s.cache.GetTiFlashRPCContext(s.bo, loc1.Region, true)
|
||||
ctxTiFlash, err := s.cache.GetTiFlashRPCContext(s.bo, loc1.Region, true, LabelFilterNoTiFlashWriteNode)
|
||||
s.Nil(err)
|
||||
s.Equal(ctxTiFlash.Peer.Id, s.peer1)
|
||||
ctxTiFlash.Peer.Role = metapb.PeerRole_Learner
|
||||
|
|
|
|||
|
|
@ -204,8 +204,19 @@ func NewRegionCache(pdClient pd.Client) *locate.RegionCache {
|
|||
return locate.NewRegionCache(pdClient)
|
||||
}
|
||||
|
||||
// LabelFilter returns false means label doesn't match, and will ignore this store.
|
||||
type LabelFilter = locate.LabelFilter
|
||||
|
||||
// LabelFilterOnlyTiFlashWriteNode will only select stores whose label contains: <engine, tiflash> and <engine_role, write>.
|
||||
// Only used for tiflash_compute node.
|
||||
var LabelFilterOnlyTiFlashWriteNode = locate.LabelFilterOnlyTiFlashWriteNode
|
||||
|
||||
// LabelFilterNoTiFlashWriteNode will only select stores whose label contains: <engine, tiflash>, but not contains <engine_role, write>.
|
||||
// Normally tidb use this filter.
|
||||
var LabelFilterNoTiFlashWriteNode = locate.LabelFilterNoTiFlashWriteNode
|
||||
|
||||
// LabelFilterAllTiFlashNode will select all tiflash stores.
|
||||
var LabelFilterAllTiFlashNode = locate.LabelFilterAllTiFlashNode
|
||||
|
||||
// LabelFilterAllNode will select all stores.
|
||||
var LabelFilterAllNode = locate.LabelFilterAllNode
|
||||
|
|
|
|||
Loading…
Reference in New Issue