Skip to content

Commit

Permalink
feat(dup_enhancement#27): update dulication command in admin-cli (#1008)
Browse files Browse the repository at this point in the history
  • Loading branch information
foreverneverer authored Jun 20, 2022
1 parent 1b726c8 commit 8758a57
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
10 changes: 5 additions & 5 deletions admin-cli/client/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ type Meta interface {

ModifyDuplication(tableName string, dupid int, status admin.DuplicationStatus) error

AddDuplication(tableName string, remoteCluster string, freezed bool) (*admin.DuplicationAddResponse, error)
AddDuplication(tableName string, remoteCluster string, duplicateCheckpoint bool) (*admin.DuplicationAddResponse, error)

QueryDuplication(tableName string) (*admin.DuplicationQueryResponse, error)

Expand Down Expand Up @@ -314,12 +314,12 @@ func (m *rpcBasedMeta) ModifyDuplication(tableName string, dupid int, status adm
return err
}

func (m *rpcBasedMeta) AddDuplication(tableName string, remoteCluster string, freezed bool) (*admin.DuplicationAddResponse, error) {
func (m *rpcBasedMeta) AddDuplication(tableName string, remoteCluster string, duplicateCheckpoint bool) (*admin.DuplicationAddResponse, error) {
var result *admin.DuplicationAddResponse
req := &admin.DuplicationAddRequest{
AppName: tableName,
RemoteClusterName: remoteCluster,
Freezed: freezed,
AppName: tableName,
RemoteClusterName: remoteCluster,
IsDuplicatingCheckpoint: duplicateCheckpoint,
}
err := m.callMeta("AddDuplication", req, func(resp interface{}) {
result = resp.(*admin.DuplicationAddResponse)
Expand Down
10 changes: 5 additions & 5 deletions admin-cli/cmd/duplication.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ func init() {
if c.Flags.String("cluster") == "" {
return fmt.Errorf("cluster cannot be empty")
}
return executor.AddDuplication(pegasusClient, c.UseTable, c.Flags.String("cluster"), c.Flags.Bool("freezed"))
return executor.AddDuplication(pegasusClient, c.UseTable, c.Flags.String("cluster"), c.Flags.Bool("checkpoint"))
}),
Flags: func(f *grumble.Flags) {
f.String("c", "cluster", "", "the destination where the source data is duplicated")
f.Bool("f", "freezed", false, "whether to freeze replica GC when duplication created")
f.Bool("p", "checkpoint", true, "whether to duplicate checkpoint when duplication created")
},
})
rootCmd.AddCommand(&grumble.Command{
Expand All @@ -72,7 +72,7 @@ func init() {
})
rootCmd.AddCommand(&grumble.Command{
Name: "pause",
Help: "pause a duplication",
Help: "pause a duplication, it only support pause from `DS_LOG`",
Run: shell.RequireUseTable(func(c *shell.Context) error {
if c.Flags.Int("dupid") == -1 {
return fmt.Errorf("dupid cannot be empty")
Expand All @@ -85,12 +85,12 @@ func init() {
})
rootCmd.AddCommand(&grumble.Command{
Name: "start",
Help: "start a duplication",
Help: "start a duplication, it only support start from `DS_PAUSE`",
Run: shell.RequireUseTable(func(c *shell.Context) error {
if c.Flags.Int("dupid") == -1 {
return fmt.Errorf("dupid cannot be empty")
}
return executor.ModifyDuplication(pegasusClient, c.UseTable, c.Flags.Int("dupid"), admin.DuplicationStatus_DS_START)
return executor.ModifyDuplication(pegasusClient, c.UseTable, c.Flags.Int("dupid"), admin.DuplicationStatus_DS_LOG)
}),
Flags: func(f *grumble.Flags) {
f.Int("d", "dupid", -1, "the dupid")
Expand Down
4 changes: 2 additions & 2 deletions admin-cli/executor/duplication.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ func QueryDuplication(c *Client, tableName string) error {
}

// AddDuplication command
func AddDuplication(c *Client, tableName string, remoteCluster string, freezed bool) error {
resp, err := c.Meta.AddDuplication(tableName, remoteCluster, freezed)
func AddDuplication(c *Client, tableName string, remoteCluster string, duplicateCheckpoint bool) error {
resp, err := c.Meta.AddDuplication(tableName, remoteCluster, duplicateCheckpoint)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion admin-cli/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module github.com/apache/incubator-pegasus/admin-cli
go 1.14

require (
github.com/apache/incubator-pegasus/go-client v0.0.0-20220526071020-be5634371701
github.com/apache/incubator-pegasus/go-client v0.0.0-20220617101220-e49a69d25a52
github.com/cheggaaa/pb/v3 v3.0.6
github.com/desertbit/grumble v1.1.1
github.com/dustin/go-humanize v1.0.0
Expand Down
2 changes: 2 additions & 0 deletions admin-cli/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk5
github.com/andybalholm/brotli v1.0.0/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
github.com/apache/incubator-pegasus/go-client v0.0.0-20220526071020-be5634371701 h1:J9d8jaC0rKlnf8iQuImyBiDrZnl794JlGMXX8DhMNrs=
github.com/apache/incubator-pegasus/go-client v0.0.0-20220526071020-be5634371701/go.mod h1:vOnSzVwVYmatouq8qEBX+yWV4AvoCTLRpQn6JA+qojs=
github.com/apache/incubator-pegasus/go-client v0.0.0-20220617101220-e49a69d25a52 h1:RvSh9D6x+zfq56hk4vXZyUwjdnpAhBO6pSqcT2nRFgY=
github.com/apache/incubator-pegasus/go-client v0.0.0-20220617101220-e49a69d25a52/go.mod h1:vOnSzVwVYmatouq8qEBX+yWV4AvoCTLRpQn6JA+qojs=
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
github.com/apache/thrift v0.13.0 h1:5hryIiq9gtn+MiLVn0wP37kb/uTeRZgN08WoCsAhIhI=
github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
Expand Down

0 comments on commit 8758a57

Please sign in to comment.