Uploaded image for project: 'ZooKeeper'
  1. ZooKeeper
  2. ZOOKEEPER-3581

use factory design pattern to refactor ZooKeeperMain

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 3.7.0
    • None

    Description

      use factory design pattern to refactor ZooKeeperMain, make the code more elegant

      static {
          commandMap.put("connect", "host:port");
          commandMap.put("history", "");
          commandMap.put("redo", "cmdno");
          commandMap.put("printwatches", "on|off");
          commandMap.put("quit", "");
      
          new CloseCommand().addToMap(commandMapCli);
          new CreateCommand().addToMap(commandMapCli);
          new DeleteCommand().addToMap(commandMapCli);
          new DeleteAllCommand().addToMap(commandMapCli);
          // Depricated: rmr
          new DeleteAllCommand("rmr").addToMap(commandMapCli);
          new SetCommand().addToMap(commandMapCli);
          new GetCommand().addToMap(commandMapCli);
          new LsCommand().addToMap(commandMapCli);
          new Ls2Command().addToMap(commandMapCli);
          new GetAclCommand().addToMap(commandMapCli);
          new SetAclCommand().addToMap(commandMapCli);
          new StatCommand().addToMap(commandMapCli);
          new SyncCommand().addToMap(commandMapCli);
          new SetQuotaCommand().addToMap(commandMapCli);
          new ListQuotaCommand().addToMap(commandMapCli);
          new DelQuotaCommand().addToMap(commandMapCli);
          new AddAuthCommand().addToMap(commandMapCli);
          new ReconfigCommand().addToMap(commandMapCli);
          new GetConfigCommand().addToMap(commandMapCli);
          new RemoveWatchesCommand().addToMap(commandMapCli);
          new GetEphemeralsCommand().addToMap(commandMapCli);
          new GetAllChildrenNumberCommand().addToMap(commandMapCli);
          new VersionCommand().addToMap(commandMapCli);
      
          // add all to commandMap
          for (Entry<String, CliCommand> entry : commandMapCli.entrySet()) {
              commandMap.put(entry.getKey(), entry.getValue().getOptionStr());
          }
      }
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              maoling Ling Mao
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: