-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
switcher.go
151 lines (113 loc) · 4.62 KB
/
switcher.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*
Copyright 2023 The Vitess Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package workflow
import (
"context"
"time"
topodatapb "vitess.io/vitess/go/vt/proto/topodata"
)
var _ iswitcher = (*switcher)(nil)
type switcher struct {
s *Server
ts *trafficSwitcher
}
func (r *switcher) addParticipatingTablesToKeyspace(ctx context.Context, keyspace, tableSpecs string) error {
return r.ts.addParticipatingTablesToKeyspace(ctx, keyspace, tableSpecs)
}
func (r *switcher) deleteRoutingRules(ctx context.Context) error {
return r.ts.deleteRoutingRules(ctx)
}
func (r *switcher) deleteShardRoutingRules(ctx context.Context) error {
return r.ts.deleteShardRoutingRules(ctx)
}
func (r *switcher) dropSourceDeniedTables(ctx context.Context) error {
return r.ts.dropSourceDeniedTables(ctx)
}
func (r *switcher) dropTargetDeniedTables(ctx context.Context) error {
return r.ts.dropTargetDeniedTables(ctx)
}
func (r *switcher) validateWorkflowHasCompleted(ctx context.Context) error {
return r.ts.validateWorkflowHasCompleted(ctx)
}
func (r *switcher) removeSourceTables(ctx context.Context, removalType TableRemovalType) error {
return r.ts.removeSourceTables(ctx, removalType)
}
func (r *switcher) dropSourceShards(ctx context.Context) error {
return r.ts.dropSourceShards(ctx)
}
func (r *switcher) switchShardReads(ctx context.Context, cells []string, servedTypes []topodatapb.TabletType, direction TrafficSwitchDirection) error {
return r.ts.switchShardReads(ctx, cells, servedTypes, direction)
}
func (r *switcher) switchTableReads(ctx context.Context, cells []string, servedTypes []topodatapb.TabletType, direction TrafficSwitchDirection) error {
return r.ts.switchTableReads(ctx, cells, servedTypes, direction)
}
func (r *switcher) startReverseVReplication(ctx context.Context) error {
return r.ts.startReverseVReplication(ctx)
}
func (r *switcher) createJournals(ctx context.Context, sourceWorkflows []string) error {
return r.ts.createJournals(ctx, sourceWorkflows)
}
func (r *switcher) allowTargetWrites(ctx context.Context) error {
return r.ts.allowTargetWrites(ctx)
}
func (r *switcher) changeRouting(ctx context.Context) error {
return r.ts.changeRouting(ctx)
}
func (r *switcher) streamMigraterfinalize(ctx context.Context, ts *trafficSwitcher, workflows []string) error {
return StreamMigratorFinalize(ctx, ts, workflows)
}
func (r *switcher) createReverseVReplication(ctx context.Context) error {
return r.ts.createReverseVReplication(ctx)
}
func (r *switcher) migrateStreams(ctx context.Context, sm *StreamMigrator) error {
return sm.MigrateStreams(ctx)
}
func (r *switcher) waitForCatchup(ctx context.Context, filteredReplicationWaitTime time.Duration) error {
return r.ts.waitForCatchup(ctx, filteredReplicationWaitTime)
}
func (r *switcher) stopSourceWrites(ctx context.Context) error {
return r.ts.stopSourceWrites(ctx)
}
func (r *switcher) stopStreams(ctx context.Context, sm *StreamMigrator) ([]string, error) {
return sm.StopStreams(ctx)
}
func (r *switcher) cancelMigration(ctx context.Context, sm *StreamMigrator) {
r.ts.cancelMigration(ctx, sm)
}
func (r *switcher) lockKeyspace(ctx context.Context, keyspace, action string) (context.Context, func(*error), error) {
return r.s.ts.LockKeyspace(ctx, keyspace, action)
}
func (r *switcher) freezeTargetVReplication(ctx context.Context) error {
return r.ts.freezeTargetVReplication(ctx)
}
func (r *switcher) dropTargetVReplicationStreams(ctx context.Context) error {
return r.ts.dropTargetVReplicationStreams(ctx)
}
func (r *switcher) dropSourceReverseVReplicationStreams(ctx context.Context) error {
return r.ts.dropSourceReverseVReplicationStreams(ctx)
}
func (r *switcher) removeTargetTables(ctx context.Context) error {
return r.ts.removeTargetTables(ctx)
}
func (r *switcher) dropTargetShards(ctx context.Context) error {
return r.ts.dropTargetShards(ctx)
}
func (r *switcher) logs() *[]string {
return nil
}
func (r *switcher) resetSequences(ctx context.Context) error {
return r.ts.resetSequences(ctx)
}
func (r *switcher) initializeTargetSequences(ctx context.Context, sequencesByBackingTable map[string]*sequenceMetadata) error {
return r.ts.initializeTargetSequences(ctx, sequencesByBackingTable)
}