Skip to content

Conversation

@zymap
Copy link
Member

@zymap zymap commented Sep 13, 2019

compact

➜  pulsarctl git:(topic-operation) ./pulsarctl topic compact -h
USED FOR:
    This command is used for compacting a persistent topic.

REQUIRED PERMISSION:
    This command is requires tenant admin permissions.

EXAMPLES:
    #Compact a persistent topic <topic-name>
    pulsarctl topic compact <topic-name>

OUTPUT:
    #normal output
    Sending compact topic <topic-name> request successfully

    #the topic name is not specified
    [✖]  only one argument is allowed to be used as a name

    #the specified topic does not found
    [✖]  code: 404 reason: Topic not found

    #the topic name is not in the format of <tenant>/<namespace>/<topic> or <topic>
    [✖]  Invalid short topic name '<topic-name>', it should be in the format of <tenant>/<namespace>/<topic> or <topic>

    #the topic name is not in the format of <domain>://<tenant>/<namespace>/<topic>
    [✖]  Invalid complete topic name '<topic-name>', it should be in the format of <domain>://<tenant>/<namespace>/<topic>

    #the topic name is not in the format of <tenant>/<namespace>/<topic>
    [✖]  Invalid topic name '<topic-name>', it should be in the format of<tenant>/<namespace>/<topic>

    #the namespace name is not in the format of <tenant>/<namespace>
    [✖]  The complete name of namespace is invalid. complete name : <namespace-complete-name>

    #the tenant name and(or) namespace name is empty
    [✖]  Invalid tenant or namespace. [<tenant>/<namespace>]

    #the tenant name contains unsupported special chars. the alphanumeric (a-zA-Z0-9) and the special chars (-=:.%)  is allowed
    [✖]  Tenant name include unsupported special chars. tenant : [<namespace>]

    #the namespace name contains unsupported special chars. the  alphanumeric (a-zA-Z0-9) and the special chars (-=:.%) is allowed
    [✖]  Namespace name include unsupported special chars. namespace : [<namespace>]

Usage: pulsarctl topics compact [flags]

compact-status

➜  pulsarctl git:(topic-operation) ./pulsarctl topic compact-status -h
USED FOR:
    This command is used for getting status of compaction on a topic.

REQUIRED PERMISSION:
    This command requires tenant admin permissions.

EXAMPLES:
    #Get status of compaction of a persistent topic <topic-name>
    pulsarctl topic compact-status <topic-name>

OUTPUT:
    #normal output
    Compaction was a success

    #Compaction is not running
    Compaction has not been run for <topic-name> since broker startup

    #Compaction is running
    Compaction is currently running

    #Compaction is error
    Error in compaction

    #the topic name is not specified
    [✖]  only one argument is allowed to be used as a name

    #the specified topic does not found
    [✖]  code: 404 reason: Topic not found

    #the topic name is not in the format of <tenant>/<namespace>/<topic> or <topic>
    [✖]  Invalid short topic name '<topic-name>', it should be in the format of <tenant>/<namespace>/<topic> or <topic>

    #the topic name is not in the format of <domain>://<tenant>/<namespace>/<topic>
    [✖]  Invalid complete topic name '<topic-name>', it should be in the format of <domain>://<tenant>/<namespace>/<topic>

    #the topic name is not in the format of <tenant>/<namespace>/<topic>
    [✖]  Invalid topic name '<topic-name>', it should be in the format of<tenant>/<namespace>/<topic>

    #the namespace name is not in the format of <tenant>/<namespace>
    [✖]  The complete name of namespace is invalid. complete name : <namespace-complete-name>

    #the tenant name and(or) namespace name is empty
    [✖]  Invalid tenant or namespace. [<tenant>/<namespace>]

    #the tenant name contains unsupported special chars. the alphanumeric (a-zA-Z0-9) and the special chars (-=:.%)  is allowed
    [✖]  Tenant name include unsupported special chars. tenant : [<namespace>]

    #the namespace name contains unsupported special chars. the  alphanumeric (a-zA-Z0-9) and the special chars (-=:.%) is allowed
    [✖]  Namespace name include unsupported special chars. namespace : [<namespace>]

Usage: pulsarctl topics compact-status [flags]

offload

➜  pulsarctl git:(topic-operation) ./pulsarctl topic offload -h
USED FOR:
    This command is used for triggering offload the data from a topic to long-term storage (e.g. Amazon S3)

REQUIRED PERMISSION:
    This command requires tenant admin permissions.

EXAMPLES:
    #Trigger offload the data from a topic <topic-name> to long-term storage and keep <threshold> size data in BookKeeper (e.g. 10M, 5G, default is byte)
    pulsarctl topic offload <topic-name> <threshold>

OUTPUT:
    #normal output
    Offload trigger for <topic-name> for messages before <message-id>

    #noting to offload
    Nothing to offload

    #the topic name is not specified or the offload threshold is not specified
    [✖]  only two argument is allowed to be used as names

    #the specified topic does not found
    [✖]  code: 404 reason: Topic not found

    #the topic name is not in the format of <tenant>/<namespace>/<topic> or <topic>
    [✖]  Invalid short topic name '<topic-name>', it should be in the format of <tenant>/<namespace>/<topic> or <topic>

    #the topic name is not in the format of <domain>://<tenant>/<namespace>/<topic>
    [✖]  Invalid complete topic name '<topic-name>', it should be in the format of <domain>://<tenant>/<namespace>/<topic>

    #the topic name is not in the format of <tenant>/<namespace>/<topic>
    [✖]  Invalid topic name '<topic-name>', it should be in the format of<tenant>/<namespace>/<topic>

    #the namespace name is not in the format of <tenant>/<namespace>
    [✖]  The complete name of namespace is invalid. complete name : <namespace-complete-name>

    #the tenant name and(or) namespace name is empty
    [✖]  Invalid tenant or namespace. [<tenant>/<namespace>]

    #the tenant name contains unsupported special chars. the alphanumeric (a-zA-Z0-9) and the special chars (-=:.%)  is allowed
    [✖]  Tenant name include unsupported special chars. tenant : [<namespace>]

    #the namespace name contains unsupported special chars. the  alphanumeric (a-zA-Z0-9) and the special chars (-=:.%) is allowed
    [✖]  Namespace name include unsupported special chars. namespace : [<namespace>]

Usage: pulsarctl topics offload [flags]

offload-status

➜  pulsarctl git:(topic-operation) ./pulsarctl topic offload-status -h
USED FOR:
    This command is used for checking the status of data offloading from a persistent topic to long-term storage.

REQUIRED PERMISSION:
    This command requires tenant admin permissions.

EXAMPLES:
    #Check the status of data offloading from a topic <persistent-topic-name> to long-term storage
    pulsarctl topic offload-status <persistent-topic-name>

    #Wait for offloading to complete
    pulsarctl topic offload-status --wait <persistent-topic-name>

OUTPUT:
    #normal output
    Offload was a success

    #Offloading is not running
    Offload has not been run for <topic-name> since broker startup

    #Offloading is running
    Offload is currently running

    #Offload is error
    Error in offload

    #the topic name is not specified
    [✖]  only one argument is allowed to be used as a name

    #the specified topic does not found
    [✖]  code: 404 reason: Topic not found

    #the topic name is not in the format of <tenant>/<namespace>/<topic> or <topic>
    [✖]  Invalid short topic name '<topic-name>', it should be in the format of <tenant>/<namespace>/<topic> or <topic>

    #the topic name is not in the format of <domain>://<tenant>/<namespace>/<topic>
    [✖]  Invalid complete topic name '<topic-name>', it should be in the format of <domain>://<tenant>/<namespace>/<topic>

    #the topic name is not in the format of <tenant>/<namespace>/<topic>
    [✖]  Invalid topic name '<topic-name>', it should be in the format of<tenant>/<namespace>/<topic>

    #the namespace name is not in the format of <tenant>/<namespace>
    [✖]  The complete name of namespace is invalid. complete name : <namespace-complete-name>

    #the tenant name and(or) namespace name is empty
    [✖]  Invalid tenant or namespace. [<tenant>/<namespace>]

    #the tenant name contains unsupported special chars. the alphanumeric (a-zA-Z0-9) and the special chars (-=:.%)  is allowed
    [✖]  Tenant name include unsupported special chars. tenant : [<namespace>]

    #the namespace name contains unsupported special chars. the  alphanumeric (a-zA-Z0-9) and the special chars (-=:.%) is allowed
    [✖]  Namespace name include unsupported special chars. namespace : [<namespace>]

Usage: pulsarctl topics offload-status [flags]

unload

➜  pulsarctl git:(topic-operation) ./pulsarctl topic unload -h
USED FOR:
    This command is used for unloading a topic.

REQUIRED PERMISSION:
    This command requires super-user permissions.

EXAMPLES:
    #Unload a topic <topic-name>
    pulsarctl topic unload <topic-name>

OUTPUT:
    #normal output
    Unload topic <topic-name> successfully

    #the topic name is not specified
    [✖]  only one argument is allowed to be used as a name

    #the specified topic does not found
    [✖]  code: 404 reason: Topic not found

    #the topic name is not in the format of <tenant>/<namespace>/<topic> or <topic>
    [✖]  Invalid short topic name '<topic-name>', it should be in the format of <tenant>/<namespace>/<topic> or <topic>

    #the topic name is not in the format of <domain>://<tenant>/<namespace>/<topic>
    [✖]  Invalid complete topic name '<topic-name>', it should be in the format of <domain>://<tenant>/<namespace>/<topic>

    #the topic name is not in the format of <tenant>/<namespace>/<topic>
    [✖]  Invalid topic name '<topic-name>', it should be in the format of<tenant>/<namespace>/<topic>

    #the namespace name is not in the format of <tenant>/<namespace>
    [✖]  The complete name of namespace is invalid. complete name : <namespace-complete-name>

    #the tenant name and(or) namespace name is empty
    [✖]  Invalid tenant or namespace. [<tenant>/<namespace>]

    #the tenant name contains unsupported special chars. the alphanumeric (a-zA-Z0-9) and the special chars (-=:.%)  is allowed
    [✖]  Tenant name include unsupported special chars. tenant : [<namespace>]

    #the namespace name contains unsupported special chars. the  alphanumeric (a-zA-Z0-9) and the special chars (-=:.%) is allowed
    [✖]  Namespace name include unsupported special chars. namespace : [<namespace>]

Usage: pulsarctl topics unload [flags]

terminate

➜  pulsarctl git:(topic-operation) ./pulsarctl topic terminate -h
USED FOR:
    This command is used for terminating a topic and don't allow any more messages to  be published.

REQUIRED PERMISSION:
    This command requires tenant admin permissions.

EXAMPLES:
    #Terminate a topic <topic-name> and don't allow any messages to be published
    pulsarctl topic terminate <topic-name>

OUTPUT:
    #normal output
    Topic <topic-name> successfully terminated at <message-id>

    #the topic name is not specified
    [✖]  only one argument is allowed to be used as a name

    #the topic name is not in the format of <tenant>/<namespace>/<topic> or <topic>
    [✖]  Invalid short topic name '<topic-name>', it should be in the format of <tenant>/<namespace>/<topic> or <topic>

    #the topic name is not in the format of <domain>://<tenant>/<namespace>/<topic>
    [✖]  Invalid complete topic name '<topic-name>', it should be in the format of <domain>://<tenant>/<namespace>/<topic>

    #the topic name is not in the format of <tenant>/<namespace>/<topic>
    [✖]  Invalid topic name '<topic-name>', it should be in the format of<tenant>/<namespace>/<topic>

    #the namespace name is not in the format of <tenant>/<namespace>
    [✖]  The complete name of namespace is invalid. complete name : <namespace-complete-name>

    #the tenant name and(or) namespace name is empty
    [✖]  Invalid tenant or namespace. [<tenant>/<namespace>]

    #the tenant name contains unsupported special chars. the alphanumeric (a-zA-Z0-9) and the special chars (-=:.%)  is allowed
    [✖]  Tenant name include unsupported special chars. tenant : [<namespace>]

    #the namespace name contains unsupported special chars. the  alphanumeric (a-zA-Z0-9) and the special chars (-=:.%) is allowed
    [✖]  Namespace name include unsupported special chars. namespace : [<namespace>]

Usage: pulsarctl topics terminate [flags]

@zymap zymap requested a review from sijie September 13, 2019 16:11
@zymap zymap self-assigned this Sep 13, 2019
@zymap zymap removed the request for review from sijie September 13, 2019 16:14
Copy link
Member

@sijie sijie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request contains too many unrelated groups of commands. I would suggest breaking it down into multiple pull requests.

  • offload
  • terminate
  • compaction
  • status

"so please make sure the service urls provided in this command are reachable\n" +
"between clusters.\n" +
"\n" +
"This command is used for adding the configuration data for a cluster.\n"+
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you are change formats in different pull requests. sometimes you add spaces and sometimes delete the spaces. I would suggest avoiding including style or code-convention changes in a huge pull request. if we need enforce a certain code convention, please enforce in the CI. /cc @wolfstudy

func CheckTopicNameTwoArgs(args []string) error {
if len(args) != 2 {
return errors.New("need to specified the topic name and the partitions")
return errors.New("only two argument is allowed to be used as names")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you change the message here? If this method is used for other purpose, please create a new method and make sure the error message is self-explained and specific.

admin := cmdutils.NewPulsarClient()
err = admin.Topics().Compact(*topic)
if err == nil {
vc.Command.Printf("Sending compact topic %s request successfully/n", topic.String())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
vc.Command.Printf("Sending compact topic %s request successfully/n", topic.String())
vc.Command.Printf("Started compacting topic %s successfully/n", topic.String())


func CompactStatusCmd(vc *cmdutils.VerbCmd) {
var desc LongDescription
desc.CommandUsedFor = "This command is used for getting status of compaction on a topic."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
desc.CommandUsedFor = "This command is used for getting status of compaction on a topic."
desc.CommandUsedFor = "This command is used for getting the compaction status of a topic."

Please fix the example output as well.


var examples []Example
offload := Example{
Desc: "Trigger offload the data from a topic <topic-name> to long-term storage and " +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Desc: "Trigger offload the data from a topic <topic-name> to long-term storage and " +
Desc: "Trigger offloading the data from a topic <topic-name> to a long-term storage and " +

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also fix all the output examples.

var examples []Example
offload := Example{
Desc: "Trigger offload the data from a topic <topic-name> to long-term storage and " +
"keep <threshold> size data in BookKeeper (e.g. 10M, 5G, default is byte)",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep the configured amount of data in BookKeeper only

return nil
}

func validateSize(s string) (int64, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please find any existing libraries already did that?

}

errorOut := Output{
Desc: "Offload is error",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix this sentence


notRun := Output{
Desc: "Offloading is not running",
Out: "Offload has not been run for <topic-name> since broker startup",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the syntax

}
}

switch status.Status {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make sure all the output sentences include namespace name.

@sijie
Copy link
Member

sijie commented Sep 17, 2019

Also it seems that #56 contains changes from #46. so which one I should review?

@sijie sijie mentioned this pull request Sep 18, 2019
29 tasks
@zymap
Copy link
Member Author

zymap commented Sep 24, 2019

This pull request contains too many unrelated groups of commands. I would suggest breaking it down into multiple pull requests.

  • offload
  • terminate
  • compaction
  • status

@sijie This pull request breaks down as #73 #74 #75 #76. PTAL

@zymap zymap closed this Oct 10, 2019
@wolfstudy wolfstudy deleted the topic-operation branch October 11, 2019 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants