Class Commands


  • public class Commands
    extends Object
    Class containing static methods for registering and running Commands, as well as default Command definitions.
    See Also:
    Command, JettyAdminServer
    • Method Detail

      • registerCommand

        public static void registerCommand​(Command command)
        Registers the given command. Registered commands can be run by passing any of their names to runCommand.
      • runCommand

        public static CommandResponse runCommand​(String cmdName,
                                                 ZooKeeperServer zkServer,
                                                 Map<String,​String> kwargs)
        Run the registered command with name cmdName. Commands should not produce any exceptions; any (anticipated) errors should be reported in the "error" entry of the returned map. Likewise, if no command with the given name is registered, this will be noted in the "error" entry.
        Parameters:
        cmdName -
        zkServer -
        kwargs - String-valued keyword arguments to the command (may be null if command requires no additional arguments)
        Returns:
        Map representing response to command containing at minimum: - "command" key containing the command's primary name - "error" key containing a String error message or null if no error
      • getPrimaryNames

        public static Set<String> getPrimaryNames()
        Returns the primary names of all registered commands.
      • getCommand

        public static Command getCommand​(String cmdName)
        Returns the commands registered under cmdName with registerCommand, or null if no command is registered with that name.