[ 
https://issues.apache.org/jira/browse/DRILL-5547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16105708#comment-16105708
 ] 

ASF GitHub Bot commented on DRILL-5547:
---------------------------------------

Github user paul-rogers commented on a diff in the pull request:

    https://github.com/apache/drill/pull/868#discussion_r130187202
  
    --- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/server/options/TypeValidators.java
 ---
    @@ -217,19 +236,52 @@ public void validate(final OptionValue v, final 
OptionSet manager) {
         }
       }
     
    +  /** Max width is a special validator which computes and validates
    +   *  the maxwidth. If the maxwidth is already set in system/session
    +   * the value is returned or else it is computed dynamically based on
    +   * the available number of processors and cpu load average
    +   */
    +  public static class MaxWidthValidator extends TypeValidator{
    +
    +    public MaxWidthValidator(String name) {
    +      this(name, false);
    +    }
    +
    +    public MaxWidthValidator(String name, boolean isAdminOption) {
    +      super(name, Kind.LONG, isAdminOption);
    +    }
    +
    +    public void loadDefault(DrillConfig bootConfig) {
    +      OptionValue value = OptionValue.createLong(OptionType.SYSTEM, 
getOptionName(), bootConfig.getLong(getConfigProperty()), OptionScope.BOOT);
    +      setDefaultValue(value);
    +    }
    +
    +    public int computeMaxWidth(double cpuLoadAverage, long maxWidth) {
    +      // if maxwidth is already set return it
    +      if (maxWidth != 0) {
    +        return (int) maxWidth;
    +      }
    +      // else compute the value and return
    +      else {
    +        int maxWidthPerNode;
    +        int availProc = Runtime.getRuntime().availableProcessors();
    +        maxWidthPerNode = (int) Math.max(1, Math.min(availProc, 
Math.round(availProc * cpuLoadAverage)));
    --- End diff --
    
    `int maxWidthPerNode = ...`
    or even just
    `return (int) ...`


> Drill config options and session options do not work as intended
> ----------------------------------------------------------------
>
>                 Key: DRILL-5547
>                 URL: https://issues.apache.org/jira/browse/DRILL-5547
>             Project: Apache Drill
>          Issue Type: Bug
>          Components:  Server
>    Affects Versions: 1.10.0
>            Reporter: Karthikeyan Manivannan
>            Assignee: Venkata Jyothsna Donapati
>             Fix For: Future
>
>
> In Drill, session options should take precedence over config options. But 
> several of these session options are assigned hard-coded default values when 
> the option validators are initialized. Because of this config options will 
> never be read and honored even if the user did not specify the session 
> option. 
> ClassCompilerSelector.JAVA_COMPILER_VALIDATOR uses CompilerPolicy.DEFAULT as 
> the default value. This default value gets into the session options map via 
> the initialization of validators in SystemOptionManager. 
> Now any piece of code that tries to check if a session option is set will 
> never see a null, so it will always use that value and never try to look into 
> the config options. For example, in the following piece of code from 
> ClassCompilerSelector (), the policy will never be read from the config file.
> policy = CompilerPolicy.valueOf((value != null) ? 
> value.string_val.toUpperCase() : 
> config.getString(JAVA_COMPILER_CONFIG).toUpperCase());



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to