()
| 28 | ) |
| 29 | |
| 30 | func init() { |
| 31 | rootCmd := &grumble.Command{ |
| 32 | Name: "partition-split", |
| 33 | Help: "partition split related commands", |
| 34 | } |
| 35 | rootCmd.AddCommand(&grumble.Command{ |
| 36 | Name: "start", |
| 37 | Help: "start partition split for a specific table", |
| 38 | Usage: `start <-a|--tableName TABLE_NAME> <-p|--newPartitionCount NEW_PARTITION_COUNT>`, |
| 39 | Run: func(c *grumble.Context) error { |
| 40 | if c.Flags.String("tableName") == "" { |
| 41 | return fmt.Errorf("tableName cannot be empty") |
| 42 | } |
| 43 | if c.Flags.Int("newPartitionCount") == 0 { |
| 44 | return fmt.Errorf("newPartitionCount cannot be empty") |
| 45 | } |
| 46 | |
| 47 | tableName := c.Flags.String("tableName") |
| 48 | newPartitionCount := c.Flags.Int("newPartitionCount") |
| 49 | return executor.StartPartitionSplit(pegasusClient, tableName, newPartitionCount) |
| 50 | }, |
| 51 | Flags: func(f *grumble.Flags) { |
| 52 | /*define the flags*/ |
| 53 | f.String("a", "tableName", "", "table name") |
| 54 | f.Int("p", "newPartitionCount", 0, "new_partition_count, should be double of current partition_count") |
| 55 | }, |
| 56 | }) |
| 57 | rootCmd.AddCommand(&grumble.Command{ |
| 58 | Name: "query", |
| 59 | Help: "query partition split status for a specific table", |
| 60 | Usage: "query <-a|--tableName TABLE_NAME>", |
| 61 | Run: func(c *grumble.Context) error { |
| 62 | if c.Flags.String("tableName") == "" { |
| 63 | return fmt.Errorf("tableName cannot be empty") |
| 64 | } |
| 65 | tableName := c.Flags.String("tableName") |
| 66 | return executor.QuerySplitStatus(pegasusClient, tableName) |
| 67 | }, |
| 68 | Flags: func(f *grumble.Flags) { |
| 69 | /*define the flags*/ |
| 70 | f.String("a", "tableName", "", "table name") |
| 71 | }, |
| 72 | }) |
| 73 | rootCmd.AddCommand(&grumble.Command{ |
| 74 | Name: "pause", |
| 75 | Help: "pause partition split for specific partition or all partitions of a table", |
| 76 | Usage: "pause <-a|--tableName TABLE_NAME> [-i|--parentPidx PARENT_PIDX]", |
| 77 | Run: func(c *grumble.Context) error { |
| 78 | if c.Flags.String("tableName") == "" { |
| 79 | return fmt.Errorf("tableName cannot be empty") |
| 80 | } |
| 81 | tableName := c.Flags.String("tableName") |
| 82 | parentPidx := c.Flags.Int("parentPidx") |
| 83 | return executor.PausePartitionSplit(pegasusClient, tableName, parentPidx) |
| 84 | }, |
| 85 | Flags: func(f *grumble.Flags) { |
| 86 | /*define the flags*/ |
| 87 | f.String("a", "tableName", "", "table name") |
nothing calls this directly
no test coverage detected