drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sudheeshkatkam <...@git.apache.org>
Subject [GitHub] drill pull request #679: DRILL-5098: Improving fault tolerance for connectio...
Date Tue, 13 Dec 2016 23:29:20 GMT
Github user sudheeshkatkam commented on a diff in the pull request:

    https://github.com/apache/drill/pull/679#discussion_r92291348
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/client/DrillClient.java ---
    @@ -357,10 +357,53 @@ protected void afterExecute(final Runnable r, final Throwable t)
{
             super.afterExecute(r, t);
           }
         };
    -    client = new UserClient(clientName, config, supportComplexTypes, allocator, eventLoopGroup,
executor);
    -    logger.debug("Connecting to server {}:{}", endpoint.getAddress(), endpoint.getUserPort());
    -    connect(endpoint);
    -    connected = true;
    +
    +    // "tries" is max number of unique drillbit to try connecting until successfully
connected to one of them
    +    final String connectTriesConf = (props != null) ? props.getProperty("tries", "5")
: "5";
    +
    +    int connectTriesVal;
    +    try {
    +      connectTriesVal = Math.min(endpoints.size(), Integer.parseInt(connectTriesConf));
    +    } catch (NumberFormatException e) {
    +      throw new InvalidConnectionInfoException("Invalid tries value: " + connectTriesConf
+ " specified in " +
    +                                               "connection string");
    +    }
    +
    +    // If the value provided in the connection string is <=0 then override with 1
since we want to try connecting
    +    // at least once
    +    connectTriesVal = Math.max(1, connectTriesVal);
    +
    +    int triedEndpointIndex = 0;
    +    DrillbitEndpoint endpoint;
    +
    +    while (triedEndpointIndex < connectTriesVal) {
    +      client = new UserClient(clientName, config, supportComplexTypes, allocator, eventLoopGroup,
executor);
    +      endpoint = endpoints.get(triedEndpointIndex);
    +      logger.debug("Connecting to server {}:{}", endpoint.getAddress(), endpoint.getUserPort());
    +
    +      try {
    +        connect(endpoint);
    +        connected = true;
    +        logger.info("Successfully connected to server {}:{}", endpoint.getAddress(),
endpoint.getUserPort());
    +        break;
    +      } catch (InvalidConnectionInfoException ex) {
    +        logger.error("Connection to {}:{} failed with error {}. Not retrying anymore",
endpoint.getAddress(),
    +                     endpoint.getUserPort(), ex.getMessage());
    +        throw ex;
    +      } catch (RpcException ex) {
    +        ++triedEndpointIndex;
    +        logger.error("Attempt {}: Failed to connect to server {}:{}", triedEndpointIndex,
endpoint.getAddress(),
    +                     endpoint.getUserPort());
    +
    +        // Close the connection
    +        client.close();
    --- End diff --
    
    Is `UserClient#close` idempotent?
    
    Looks like `if (triedEndpointIndex == connectTriesVal)`, then `UserClient#close` is called
twice, here and in `DrillClient#close`. The is unlike the previous catch clause i.e. `catch
(InvalidConnectionInfoException ex)`.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message