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

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

Github user sohami commented on a diff in the pull request:

    https://github.com/apache/drill/pull/648#discussion_r87351696
  
    --- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/client/DrillClient.java ---
    @@ -223,19 +223,65 @@ public void connect(Properties props) throws 
RpcException {
         connect(null, props);
       }
     
    +  /**
    +   * Function to populate the endpointList with information of all the 
drillbits
    +   * provided in the connection string by client
    +   * @param endpointList - ArrayList of DrillbitEndpoints
    +   * @param drillbits - One or more drillbit ip[:port] provided in 
connection string
    +   */
    +  public void populateEndpointsList(ArrayList<DrillbitEndpoint> 
endpointList, String drillbits){
    +
    +    // If no information about drillbits is provided then just return 
empty list.
    +    if(drillbits == null || drillbits.length() == 0){
    +      return;
    +    }
    +    final String[] connectInfo = drillbits.split(",");
    +
    +    /* For direct connection we can get URL string having drillbit 
property as below:
    +         drillbit=<ip>:<port> --- Use the IP and port specified as the 
Foreman IP and port
    +         drillbit=<ip>        --- Use the IP specified as the Foreman IP 
with default port in config file
    +         drillbit=<ip1>:<port1>,<ip2>:<port2>... --- Randomly select the 
IP and port pair from the specified
    +                                                     list as the Foreman 
IP and port.
    +
    +       Fetch ip address and port information for each drillbit and 
populate the list
    +    */
    +    for(String info : connectInfo){
    +      info = info.trim();
    +
    +      if(info != null){
    +        // Split each info to get ip address and port value
    +        final String[] drillbitInfo = info.split(":");
    +
    +        // Check for malformed ip:port string
    +        if(drillbitInfo == null || drillbitInfo.length == 0){
    +          continue;
    +        }
    +
    +        /* If port is present use that one else use the configured one
    +           Assumptions: 1) IP Address provided in connection string is 
valid
    +                        2) Port without IP address is never specified.
    +        */
    +        final String port = (drillbitInfo.length == 2) ? drillbitInfo[1] : 
config.getString(ExecConstants.INITIAL_USER_PORT);
    +        final DrillbitEndpoint endpoint = DrillbitEndpoint.newBuilder()
    +                                          .setAddress(drillbitInfo[0])
    +                                          
.setUserPort(Integer.parseInt(port))
    +                                          .build();
    +        endpointList.add(endpoint);
    +      }
    +    }
    +  }
    +
       public synchronized void connect(String connect, Properties props) 
throws RpcException {
         if (connected) {
           return;
         }
     
         final DrillbitEndpoint endpoint;
    +    final ArrayList<DrillbitEndpoint> endpoints = new ArrayList<>();
    --- End diff --
    
    fixed


> As per documentation, when issuing a list of drillbits in the connection 
> string, we always attempt to connect only to the first one
> -----------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DRILL-5015
>                 URL: https://issues.apache.org/jira/browse/DRILL-5015
>             Project: Apache Drill
>          Issue Type: Bug
>          Components: Client - JDBC
>    Affects Versions: 1.8.0, 1.9.0
>            Reporter: Sorabh Hamirwasia
>            Assignee: Sudheesh Katkam
>
> When trying to connect to a Drill cluster by specifying more than 1 drillbits 
> to connect to, we always attempt to connect to only the first drillbit.
> As an example, we tested against a pair of drillbits, but we always connect 
> to the first entry in the CSV list by querying for the 'current' drillbit. 
> The remaining entries are never attempted.
> [root@pssc-60 agileSqlPerfTests]# /opt/mapr/drill/drill-1.8.0/bin/sqlline  -u 
>  "jdbc:drill:schema=dfs.tmp;drillbit=pssc-61:31010,pssc-62:31010" -f 
> whereAmI.q  | grep -v logback
> 1/1          select * from sys.drillbits where `current`;
> +-----------------+------------+---------------+------------+----------+
> |    hostname     | user_port  | control_port  | data_port  | current  |
> +-----------------+------------+---------------+------------+----------+
> | pssc-61.qa.lab  | 31010      | 31011         | 31012      | true     |
> +-----------------+------------+---------------+------------+----------+
> 1 row selected (0.265 seconds)
> Closing: org.apache.drill.jdbc.impl.DrillConnectionImpl
> apache drill 1.8.0 
> "a little sql for your nosql"
> This property is meant for use by clients when not wanting to overload the ZK 
> for fetching a list of existing Drillbits, but the behaviour doesn't match 
> the documentation. 
> [Making a Direct Drillbit Connection | 
> https://drill.apache.org/docs/using-the-jdbc-driver/#using-the-jdbc-url-format-for-a-direct-drillbit-connection
>  ]
> We need to randomly shuffle between this list and If an entry in the shuffled 
> list is unreachable, we need to try for the next entry in the list.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to