Return-Path: X-Original-To: apmail-aurora-dev-archive@minotaur.apache.org Delivered-To: apmail-aurora-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B514D18689 for ; Fri, 8 Jan 2016 01:18:06 +0000 (UTC) Received: (qmail 92697 invoked by uid 500); 8 Jan 2016 01:18:06 -0000 Delivered-To: apmail-aurora-dev-archive@aurora.apache.org Received: (qmail 92627 invoked by uid 500); 8 Jan 2016 01:18:06 -0000 Mailing-List: contact dev-help@aurora.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@aurora.apache.org Delivered-To: mailing list dev@aurora.apache.org Received: (qmail 92616 invoked by uid 99); 8 Jan 2016 01:18:06 -0000 Received: from mail-relay.apache.org (HELO mail-relay.apache.org) (140.211.11.15) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Jan 2016 01:18:06 +0000 Received: from mail-ob0-f174.google.com (mail-ob0-f174.google.com [209.85.214.174]) by mail-relay.apache.org (ASF Mail Server at mail-relay.apache.org) with ESMTPSA id 490EC1A023C for ; Fri, 8 Jan 2016 01:18:06 +0000 (UTC) Received: by mail-ob0-f174.google.com with SMTP id wp13so207041501obc.1 for ; Thu, 07 Jan 2016 17:18:06 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.60.65.74 with SMTP id v10mr3966708oes.58.1452215885367; Thu, 07 Jan 2016 17:18:05 -0800 (PST) Received: by 10.202.218.194 with HTTP; Thu, 7 Jan 2016 17:18:05 -0800 (PST) Date: Thu, 7 Jan 2016 17:18:05 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: [PROPOSAL] Replace commons-args From: Bill Farner To: dev@aurora.apache.org Content-Type: multipart/alternative; boundary=001a11c1d4f2fc14790528c85bee --001a11c1d4f2fc14790528c85bee Content-Type: text/plain; charset=UTF-8 All, I propose that we replace our current command line args system. For those unaware, the args system [1] we currently use was forked out of Twitter Commons several months ago. The goal when forking was to adapt/maintain or eventually replace these libraries. Given the code volume and complexity of commons-args, i propose we replace it and address some issues along the way. I suggest several goals: a. sidestep current development hurdles we have encountered with the args system (intellij/gradle not working nicely with apt) b. encourage better testability of Module classes by always injecting all args c. leverage a well-maintained third-party argument parsing library d. stretch: enable user-friendly features like logical option groups for better help/usage output e. stretch: enable alternative configuration inputs like a configuration file or environment variables (b) is currently an issue because command line arguments are driven from pseudo-constants within the code, for example: @NotNull @CmdLine(name = "cluster_name", help = "Name to identify the cluster being served.") private static final Arg CLUSTER_NAME = Arg.create(); @NotNull @NotEmpty @CmdLine(name = "serverset_path", help = "ZooKeeper ServerSet path to register at.") private static final Arg SERVERSET_PATH = Arg.create(); This makes it simple to add command line arguments. However, it means that a level of indirection is needed to parameterize and test the code consuming arg values. We have various examples of this throughout the project. I propose that we change the way command line arguments are declared such that a Module with the above arguments would instead declare an interface that produces its parameters: public interface Params { @Help("Name to identify the cluster being served.") String clusterName(); @NotEmpty @Help("ZooKeeper ServerSet path to register at.") String serversetPath(); } public SchedulerModule(Params params) { // Params are supplied to the module constructor. } Please see this review for a complete example of this part of the change: https://reviews.apache.org/r/41804 This is roughly the same amount of overhead for declaring arguments as the current scenario, with the addition of a very obvious mechanism for swapping the source of parameters. This allows us to isolate the body of code responsible for supplying configuration values, which we lack today. The remaining work is to bridge the gap between a command line argument system and Parameter interfaces. This is relatively easy to do with dynamic proxies. I have posted a proof of concept here: https://reviews.apache.org/r/42042 Regarding (c), i have done some analysis of libraries available and i suggest argparse4j [3]. It has thorough documentation, no transitive dependencies, and is being actively developed (last release Dec 2015). However, i would like to emphasize that i think we should minimize coupling to the argument parsing library so that we may switch in the future. Argparse4j has a feature that makes the non-critical feature (d) possible. With that, what do you think? Are there other goals we should add? Does the plan make sense? [1] https://github.com/apache/aurora/tree/master/commons-args/src/main/java/org/apache/aurora/common/args [2] https://github.com/twitter/commons [3] https://argparse4j.github.io/ --001a11c1d4f2fc14790528c85bee--