Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 2B5D0200BF1 for ; Mon, 28 Nov 2016 23:47:01 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 2A518160B22; Mon, 28 Nov 2016 22:47:01 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 1C16E160B27 for ; Mon, 28 Nov 2016 23:46:59 +0100 (CET) Received: (qmail 14282 invoked by uid 500); 28 Nov 2016 22:46:59 -0000 Mailing-List: contact issues-help@drill.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@drill.apache.org Delivered-To: mailing list issues@drill.apache.org Received: (qmail 14245 invoked by uid 99); 28 Nov 2016 22:46:59 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Nov 2016 22:46:59 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 38F1A2C03E8 for ; Mon, 28 Nov 2016 22:46:59 +0000 (UTC) Date: Mon, 28 Nov 2016 22:46:59 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@drill.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (DRILL-5015) As per documentation, when issuing a list of drillbits in the connection string, we always attempt to connect only to the first one MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Mon, 28 Nov 2016 22:47:01 -0000 [ https://issues.apache.org/jira/browse/DRILL-5015?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15703384#comment-15703384 ] ASF GitHub Bot commented on DRILL-5015: --------------------------------------- Github user sudheeshkatkam commented on a diff in the pull request: https://github.com/apache/drill/pull/648#discussion_r89902789 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/client/DrillClient.java --- @@ -223,19 +224,100 @@ public void connect(Properties props) throws RpcException { connect(null, props); } + /** + * Populates the endpointlist with drillbits information provided in the connection string by client. + * For direct connection we can have connection string with drillbit property as below: + *
+ *
drillbit=ip
+ *
use the ip specified as the Foreman ip with default port in config file
+ *
drillbit=ip:port
+ *
use the ip and port specified as the Foreman ip and port
+ *
drillbit=ip1:port1,ip2:port2,...
+ *
randomly select the ip and port pair from the specified list as the Foreman ip and port.
+ *
+ * + * @param drillbits string with drillbit value provided in connection string + * @param defaultUserPort string with default userport of drillbit specified in config file + * @return list of drillbit endpoints parsed from connection string + * @throws InvalidConnectionInfoException if the connection string has invalid or no drillbit information + */ + static List parseAndVerifyEndpoints(String drillbits, String defaultUserPort) + throws InvalidConnectionInfoException { + // If no drillbits is provided then throw exception + drillbits = drillbits.trim(); + if (drillbits.isEmpty()) { + throw new InvalidConnectionInfoException("No drillbit information specified in the connection string"); + } + + ArrayList endpointList = new ArrayList<>(); + final String[] connectInfo = drillbits.split(","); + + // Fetch ip address and port information for each drillbit and populate the list + for (String drillbit : connectInfo) { + + // Trim all the empty spaces and check if the entry is empty string. + // Ignore the empty ones. + drillbit = drillbit.trim(); + + if (!drillbit.isEmpty()) { + // Verify if we have only ":" or only ":port" pattern + if (drillbit.charAt(0) == ':') { + // Invalid drillbit information + throw new InvalidConnectionInfoException("Malformed connection string with drillbit hostname or " + + "hostaddress missing for an entry: " + drillbit); + } + + // We are now sure that each ip:port entry will have both the values atleast once. + // Split each drillbit connection string to get ip address and port value + final String[] drillbitInfo = drillbit.split(":"); + + // Check if we have more than one port + if (drillbitInfo.length > 2) { + throw new InvalidConnectionInfoException("Malformed connection string with more than one port in a " + + "drillbit entry: " + drillbit); + } + + // At this point we are sure that drillbitInfo has atleast hostname or host address + // trim all the empty spaces which might be present in front of hostname or + // host address information + final String ipAddress = drillbitInfo[0].trim(); + String port = defaultUserPort; + + if (drillbitInfo.length == 2) { + // We have a port value also given by user. trim all the empty spaces between : and port value before + // validating the correctness of value. + port = drillbitInfo[1].trim(); + } + + try { + final DrillbitEndpoint endpoint = DrillbitEndpoint.newBuilder() + .setAddress(ipAddress) + .setUserPort(Integer.parseInt(port)) + .build(); + + endpointList.add(endpoint); + } catch (NumberFormatException e) { + throw new InvalidConnectionInfoException("Malformed port value in entry: " + ipAddress + ":" + port + " " + + "passed in connection string"); + } + } + } + if(endpointList.size() == 0){ --- End diff -- spacing fix > 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 > Labels: ready-to-commit > > 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)