Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@ ifndef NOBANNER
echo $$(date): Compiling proto definitions
endif

$(PROTO_GO_OUTS): install_protoc-gen-go proto/*.proto
$(PROTO_GO_OUTS): minimaltools install_protoc-gen-go proto/*.proto
for name in $(PROTO_SRC_NAMES); do \
$(VTROOT)/bin/protoc --go_out=plugins=grpc:. -Iproto proto/$${name}.proto && \
goimports -local vitess.io/vitess -w vitess.io/vitess/go/vt/proto/$${name}/$${name}.pb.go; \
$(VTROOT)/bin/protoc --go_out=plugins=grpc:. -I${PWD}/dist/vt-protoc-3.6.1/include:proto proto/$${name}.proto && \
goimports -w vitess.io/vitess/go/vt/proto/$${name}/$${name}.pb.go; \
done
cp -Rf vitess.io/vitess/go/vt/proto/* go/vt/proto
rm -rf vitess.io/vitess/go/vt/proto/
Expand Down
2 changes: 1 addition & 1 deletion examples/local/101_initial_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ for i in 100 101 102; do
done

# set one of the replicas to master
vtctlclient InitShardMaster -force commerce/0 zone1-100
vtctldclient InitShardPrimary --force commerce/0 zone1-100

# create the schema
vtctlclient ApplySchema -sql-file create_commerce_schema.sql commerce
Expand Down
2 changes: 1 addition & 1 deletion examples/local/201_customer_tablets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ for i in 200 201 202; do
CELL=zone1 KEYSPACE=customer TABLET_UID=$i ./scripts/vttablet-up.sh
done

vtctlclient InitShardMaster -force customer/0 zone1-200
vtctldclient InitShardPrimary --force customer/0 zone1-200
4 changes: 2 additions & 2 deletions examples/local/302_new_shards.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ for i in 400 401 402; do
SHARD=80- CELL=zone1 KEYSPACE=customer TABLET_UID=$i ./scripts/vttablet-up.sh
done

vtctlclient InitShardMaster -force customer/-80 zone1-300
vtctlclient InitShardMaster -force customer/80- zone1-400
vtctldclient InitShardPrimary --force customer/-80 zone1-300
vtctldclient InitShardPrimary --force customer/80- zone1-400
1 change: 1 addition & 0 deletions examples/local/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ mkdir -p "${VTDATAROOT}/tmp"

alias mysql="command mysql -h 127.0.0.1 -P 15306"
alias vtctlclient="command vtctlclient -server localhost:15999 -log_dir ${VTDATAROOT}/tmp -alsologtostderr"
alias vtctldclient="command vtctldclient --server localhost:15999"

# Make sure aliases are expanded in non-interactive shell
shopt -s expand_aliases
Expand Down
44 changes: 44 additions & 0 deletions go/cmd/vtctldclient/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ package main
import (
"encoding/json"
"fmt"
"time"

"github.com/golang/protobuf/ptypes"
"github.com/spf13/cobra"

"vitess.io/vitess/go/vt/log"
vtctldatapb "vitess.io/vitess/go/vt/proto/vtctldata"
"vitess.io/vitess/go/vt/topo/topoproto"
)

var (
Expand All @@ -44,6 +48,11 @@ var (
Args: cobra.NoArgs,
RunE: commandGetKeyspaces,
}
initShardPrimaryCmd = &cobra.Command{
Use: "InitShardPrimary",
Args: cobra.ExactArgs(2),
RunE: commandInitShardPrimary,
}
)

func commandFindAllShardsInKeyspace(cmd *cobra.Command, args []string) error {
Expand Down Expand Up @@ -91,8 +100,43 @@ func commandGetKeyspaces(cmd *cobra.Command, args []string) error {
return nil
}

var initShardPrimaryArgs = struct {
WaitReplicasTimeout time.Duration
Force bool
}{}

func commandInitShardPrimary(cmd *cobra.Command, args []string) error {
keyspace, shard, err := topoproto.ParseKeyspaceShard(cmd.Flags().Arg(0))
if err != nil {
return err
}

tabletAlias, err := topoproto.ParseTabletAlias(cmd.Flags().Arg(1))
if err != nil {
return err
}

resp, err := client.InitShardPrimary(commandCtx, &vtctldatapb.InitShardPrimaryRequest{
Keyspace: keyspace,
Shard: shard,
PrimaryElectTabletAlias: tabletAlias,
WaitReplicasTimeout: ptypes.DurationProto(initShardPrimaryArgs.WaitReplicasTimeout),
Force: initShardPrimaryArgs.Force,
})

for _, event := range resp.Events {
log.Infof("%v", event)
}

return err
}

func init() {
rootCmd.AddCommand(findAllShardsInKeyspaceCmd)
rootCmd.AddCommand(getKeyspaceCmd)
rootCmd.AddCommand(getKeyspacesCmd)

initShardPrimaryCmd.Flags().DurationVar(&initShardPrimaryArgs.WaitReplicasTimeout, "wait-replicas-timeout", 30*time.Second, "time to wait for replicas to catch up in reparenting")
initShardPrimaryCmd.Flags().BoolVar(&initShardPrimaryArgs.Force, "force", false, "will force the reparent even if the provided tablet is not a master or the shard master")
rootCmd.AddCommand(initShardPrimaryCmd)
}
1 change: 0 additions & 1 deletion go/vt/proto/automationservice/automationservice.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion go/vt/proto/binlogdata/binlogdata.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion go/vt/proto/binlogservice/binlogservice.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion go/vt/proto/logutil/logutil.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion go/vt/proto/query/query.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion go/vt/proto/queryservice/queryservice.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion go/vt/proto/tabletmanagerdata/tabletmanagerdata.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion go/vt/proto/throttlerservice/throttlerservice.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion go/vt/proto/topodata/topodata.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion go/vt/proto/vschema/vschema.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion go/vt/proto/vtadmin/vtadmin.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading