From 8758a575ab067628d172ebc4952bae8803dd0698 Mon Sep 17 00:00:00 2001 From: Jiashuo Date: Mon, 20 Jun 2022 16:52:13 +0800 Subject: [PATCH] feat(dup_enhancement#27): update dulication command in admin-cli (#1008) --- admin-cli/client/meta.go | 10 +++++----- admin-cli/cmd/duplication.go | 10 +++++----- admin-cli/executor/duplication.go | 4 ++-- admin-cli/go.mod | 2 +- admin-cli/go.sum | 2 ++ 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/admin-cli/client/meta.go b/admin-cli/client/meta.go index 91b71dc3ce..e07a115549 100644 --- a/admin-cli/client/meta.go +++ b/admin-cli/client/meta.go @@ -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) @@ -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) diff --git a/admin-cli/cmd/duplication.go b/admin-cli/cmd/duplication.go index 253ff86322..90584aa19a 100644 --- a/admin-cli/cmd/duplication.go +++ b/admin-cli/cmd/duplication.go @@ -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{ @@ -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") @@ -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") diff --git a/admin-cli/executor/duplication.go b/admin-cli/executor/duplication.go index e6ccc4e252..0a1736b8b5 100644 --- a/admin-cli/executor/duplication.go +++ b/admin-cli/executor/duplication.go @@ -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 } diff --git a/admin-cli/go.mod b/admin-cli/go.mod index 99f0bbdb5d..ca023b24a3 100644 --- a/admin-cli/go.mod +++ b/admin-cli/go.mod @@ -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 diff --git a/admin-cli/go.sum b/admin-cli/go.sum index 4d96344b47..3feeea67a9 100644 --- a/admin-cli/go.sum +++ b/admin-cli/go.sum @@ -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=