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

    https://github.com/apache/drill/pull/565#discussion_r82267967
  
    --- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/client/DrillClient.java ---
    @@ -688,4 +802,142 @@ public DrillBuf getBuffer() {
           return null;
         }
       }
    +
    +  /**
    +   * Return a new {@link DrillClient.Builder Drill client builder}.
    +   * @return a new builder
    +   */
    +  public static Builder newBuilder() {
    +    return new Builder();
    +  }
    +
    +  /**
    +   * Helper class to construct a {@link DrillClient Drill client}.
    +   */
    +  public static class Builder {
    +
    +    private DrillConfig config;
    +    private BufferAllocator allocator;
    +    private ClusterCoordinator clusterCoordinator;
    +    private EventLoopGroup eventLoopGroup;
    +    private ExecutorService executor;
    +
    +    // defaults
    +    private boolean supportComplexTypes = true;
    +    private boolean isDirectConnection = false;
    +
    +    /**
    +     * Sets the {@link DrillConfig configuration} for this client.
    +     *
    +     * @param drillConfig drill configuration
    +     * @return this builder
    +     */
    +    public Builder setConfig(DrillConfig drillConfig) {
    +      this.config = drillConfig;
    +      return this;
    +    }
    +
    +    /**
    +     * Sets the {@link DrillConfig configuration} for this client based on 
the given file.
    +     *
    +     * @param fileName configuration file name
    +     * @return this builder
    +     */
    +    public Builder setConfigFromFile(final String fileName) {
    +      this.config = DrillConfig.create(fileName);
    +      return this;
    +    }
    +
    +    /**
    +     * Sets the {@link BufferAllocator buffer allocator} to be used by 
this client.
    +     * If this is not set, an allocator will be created based on the 
configuration.
    +     *
    +     * If this is set, the caller is responsible for closing the given 
allocator.
    +     *
    +     * @param allocator buffer allocator
    +     * @return this builder
    +     */
    +    public Builder setAllocator(final BufferAllocator allocator) {
    +      this.allocator = allocator;
    +      return this;
    +    }
    +
    +    /**
    +     * Sets the {@link ClusterCoordinator cluster coordinator} that this 
client
    +     * registers with. If this is not set and the this client does not use 
a
    +     * {@link #setDirectConnection direct connection}, a cluster 
coordinator will
    +     * be created based on the configuration.
    +     *
    +     * If this is set, the caller is responsible for closing the given 
coordinator.
    +     *
    +     * @param clusterCoordinator cluster coordinator
    +     * @return this builder
    +     */
    +    public Builder setClusterCoordinator(final ClusterCoordinator 
clusterCoordinator) {
    +      this.clusterCoordinator = clusterCoordinator;
    +      return this;
    +    }
    +
    +    /**
    +     * Sets the event loop group that to be used by the client. If this is 
not set,
    +     * an event loop group will be created based on the configuration.
    +     *
    +     * If this is set, the caller is responsible for closing the given 
event loop group.
    +     *
    +     * @param eventLoopGroup event loop group
    +     * @return this builder
    +     */
    +    public Builder setEventLoopGroup(final EventLoopGroup eventLoopGroup) {
    +      this.eventLoopGroup = eventLoopGroup;
    +      return this;
    +    }
    +
    +    /**
    +     * Sets the executor service to be used by the client. If this is not 
set,
    +     * an executor will be created based on the configuration.
    +     *
    +     * If this is set, the caller is responsible for closing the given 
executor.
    +     *
    +     * @param executor executor service
    +     * @return this builder
    +     */
    +    public Builder setExecutorService(final ExecutorService executor) {
    +      this.executor = executor;
    +      return this;
    +    }
    +
    +    /**
    +     * Sets whether the application is willing to accept complex types 
(Map, Arrays)
    +     * in the returned result set. Default is {@code true}. If set to 
{@code false},
    +     * the complex types are returned as JSON encoded VARCHAR type.
    +     *
    +     * @param supportComplexTypes if client accepts complex types
    +     * @return this builder
    +     */
    +    public Builder setSupportsComplexTypes(final boolean 
supportComplexTypes) {
    +      this.supportComplexTypes = supportComplexTypes;
    +      return this;
    +    }
    +
    +    /**
    +     * Sets whether the client will connect directly to the drillbit 
instead of going
    --- End diff --
    
    Here (or in the class comment), explain how to use this with an embedded 
Drillbit. There is no ZK in that case. Would I use a direct connection for 
embedded?
    
    If I choose to use embedded, where do I pass in the actual host:port 
information? Should this method take that info and, in so doing, implicitly set 
the "is direct" flag?
    
    What is the default?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to