zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "maoling (Jira)" <j...@apache.org>
Subject [jira] [Created] (ZOOKEEPER-3581) use factory design pattern to refactor ZooKeeperMain
Date Tue, 15 Oct 2019 02:22:00 GMT
maoling created ZOOKEEPER-3581:
----------------------------------

             Summary: use factory design pattern to refactor ZooKeeperMain
                 Key: ZOOKEEPER-3581
                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-3581
             Project: ZooKeeper
          Issue Type: Improvement
            Reporter: maoling


use factory design pattern to refactor ZooKeeperMain, make the code more elegant
{code:java}
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());
    }
}
{code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Mime
View raw message