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