@@ -44,86 +44,18 @@ import (
4444 "github.com/pingcap/ticdc/server/watcher"
4545 "github.com/stretchr/testify/require"
4646 pd "github.com/tikv/pd/client"
47- pdgc "github.com/tikv/pd/client/clients/gc"
4847 "go.uber.org/zap"
4948 "google.golang.org/grpc"
5049)
5150
5251type mockPdClient struct {
5352 pd.Client
54- mu sync.Mutex
55- gcClient map [uint32 ]* mockGCStatesClient
5653}
5754
5855func (m * mockPdClient ) UpdateServiceGCSafePoint (ctx context.Context , serviceID string , ttl int64 , safePoint uint64 ) (uint64 , error ) {
5956 return safePoint , nil
6057}
6158
62- func (m * mockPdClient ) GetGCStatesClient (keyspaceID uint32 ) pdgc.GCStatesClient {
63- m .mu .Lock ()
64- defer m .mu .Unlock ()
65-
66- if m .gcClient == nil {
67- m .gcClient = make (map [uint32 ]* mockGCStatesClient )
68- }
69- if cli , ok := m .gcClient [keyspaceID ]; ok {
70- return cli
71- }
72- cli := newMockGCStatesClient (keyspaceID )
73- m .gcClient [keyspaceID ] = cli
74- return cli
75- }
76-
77- type mockGCStatesClient struct {
78- keyspaceID uint32
79-
80- mu sync.Mutex
81- barriers map [string ]* pdgc.GCBarrierInfo
82- }
83-
84- func newMockGCStatesClient (keyspaceID uint32 ) * mockGCStatesClient {
85- return & mockGCStatesClient {
86- keyspaceID : keyspaceID ,
87- barriers : make (map [string ]* pdgc.GCBarrierInfo ),
88- }
89- }
90-
91- func (c * mockGCStatesClient ) SetGCBarrier (ctx context.Context , barrierID string , barrierTS uint64 , ttl time.Duration ) (* pdgc.GCBarrierInfo , error ) {
92- c .mu .Lock ()
93- defer c .mu .Unlock ()
94-
95- info := pdgc .NewGCBarrierInfo (barrierID , barrierTS , ttl , time .Now ())
96- c .barriers [barrierID ] = info
97- return info , nil
98- }
99-
100- func (c * mockGCStatesClient ) DeleteGCBarrier (ctx context.Context , barrierID string ) (* pdgc.GCBarrierInfo , error ) {
101- c .mu .Lock ()
102- defer c .mu .Unlock ()
103-
104- info , ok := c .barriers [barrierID ]
105- if ok {
106- delete (c .barriers , barrierID )
107- }
108- return info , nil
109- }
110-
111- func (c * mockGCStatesClient ) GetGCState (ctx context.Context ) (pdgc.GCState , error ) {
112- c .mu .Lock ()
113- defer c .mu .Unlock ()
114-
115- barriers := make ([]* pdgc.GCBarrierInfo , 0 , len (c .barriers ))
116- for _ , info := range c .barriers {
117- barriers = append (barriers , info )
118- }
119- return pdgc.GCState {
120- KeyspaceID : c .keyspaceID ,
121- TxnSafePoint : 0 ,
122- GCSafePoint : 0 ,
123- GCBarriers : barriers ,
124- }, nil
125- }
126-
12759type mockMaintainerManager struct {
12860 mc messaging.MessageCenter
12961 msgCh chan * messaging.TargetMessage
0 commit comments