Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-14374

BeeLine argument, and configuration handling cleanup

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.2.0
    • None
    • Beeline
    • None

    Description

      BeeLine uses reflection, to set the BeeLineOpts attributes when parsing command line arguments, and when loading the configuration file.

      This means, that creating a setXXX, getXXX method in BeeLineOpts is a potential risk of exposing an attribute for the user unintentionally. There is a possibility to exclude an attribute from saving the value in the configuration file with the Ignore annotation. This does not restrict the loading or command line setting of these parameters which means there are many undocumented "features" as-is, like setting the lastConnectedUrl, allowMultilineCommand, maxHeight, trimScripts, etc. from command line.

      This part of the code needs a little cleanup.

      I think we should make this exposure more explicit, and be able to differentiate the configurable options depending on the source (command line, and configuration file), so I propose to create a mechanism to tell explicitly which BeeLineOpts attributes are settable by command line, and configuration file, and every other attribute should be inaccessible by the user of the beeline cli.

      One possible solution could be two annotations like these:

      • CommandLineOption - there could be a mandatory text parameter here, so the developer had to provide the help text for it which could be displayed to the user
      • ConfigurationFileOption - no text is required here

      Something like this:

      • This attribute could be provided by command line, and from a configuration file too:
        @CommandLineOption("automatically save preferences")
        @ConfigurationFileOption
        public void setAutosave(boolean autosave) {
          this.autosave = autosave;
        }
        
        public void getAutosave() {
          return this.autosave;
        }
        
      • This attribute could be set through the configuration only
        @ConfigurationFileOption
        public void setLastConnectedUrl(String lastConnectedUrl) {
          this.lastConnectedUrl = lastConnectedUrl;

        }
        

        public String getLastConnectedUrl()
        {

          return lastConnectedUrl;
        
}
        

      • Attribute could be set through command line only - I think this is not too relevant, but possible
        @CommandLineOption("specific command line option")
        public void setSpecificCommandLineOption(String specificCommandLineOption) {
        
  this.specificCommandLineOption = specificCommandLineOption;
        
}
        

        public String getSpecificCommandLineOption() {
        
  return specificCommandLineOption;
        
}
        

      • Attribute could not be set
        public static Env getEnv() {
        
  return env;
        
}
        
        

public static void setEnv(Env envToUse) {
        
  env = envToUse;
        
}
        

      Accouring to our previous conversations, I think you might be interested in:
      spena, vihangk1, aihuaxu, ngangam, ychena, xuefuz
      but anyone is welcome to discuss this.

      What do you think about the proposed solution?
      Any better ideas, or extensions?

      Thanks,
      Peter

      Attachments

        Activity

          People

            Unassigned Unassigned
            pvary Peter Vary
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated: