forked from vitessio/vitess
-
Notifications
You must be signed in to change notification settings - Fork 0
/
split_diff_task.go
42 lines (35 loc) · 1.51 KB
/
split_diff_task.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
// Copyright 2015, Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package automation
import (
automationpb "github.com/youtube/vitess/go/vt/proto/automation"
"github.com/youtube/vitess/go/vt/topo/topoproto"
"golang.org/x/net/context"
)
// SplitDiffTask runs SplitDiff on a remote vtworker to compare the old shard against its new split shards.
type SplitDiffTask struct {
}
// Run is part of the Task interface.
func (t *SplitDiffTask) Run(parameters map[string]string) ([]*automationpb.TaskContainer, string, error) {
args := []string{"SplitDiff"}
if excludeTables := parameters["exclude_tables"]; excludeTables != "" {
args = append(args, "--exclude_tables="+excludeTables)
}
args = append(args, topoproto.KeyspaceShardString(parameters["keyspace"], parameters["dest_shard"]))
output, err := ExecuteVtworker(context.TODO(), parameters["vtworker_endpoint"], args)
// TODO(mberlin): Remove explicit reset when vtworker supports it implicility.
if err == nil {
// Ignore output and error of the Reset.
ExecuteVtworker(context.TODO(), parameters["vtworker_endpoint"], []string{"Reset"})
}
return nil, output, err
}
// RequiredParameters is part of the Task interface.
func (t *SplitDiffTask) RequiredParameters() []string {
return []string{"keyspace", "dest_shard", "vtworker_endpoint"}
}
// OptionalParameters is part of the Task interface.
func (t *SplitDiffTask) OptionalParameters() []string {
return []string{"exclude_tables"}
}