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

    https://github.com/apache/twill/pull/9#discussion_r77083133
  
    --- Diff: 
twill-core/src/main/java/org/apache/twill/internal/kafka/EmbeddedKafkaServer.java
 ---
    @@ -65,9 +72,19 @@ protected void startUp() throws Exception {
             if (rootCause instanceof ZkTimeoutException) {
               // Potentially caused by race condition bug described in 
TWILL-139.
               LOG.warn("Timeout when connecting to ZooKeeper from KafkaServer. 
Attempt number {}.", tries, rootCause);
    +        } else if (rootCause instanceof BindException) {
    +          LOG.warn("Kafka failed to bind to port {}. Attempt number {}.", 
kafkaConfig.port(), tries, rootCause);
             } else {
               throw e;
             }
    +
    +        // Do a random sleep of < 200ms
    +        TimeUnit.MILLISECONDS.sleep(new Random().nextInt(200) + 1L);
    +
    +        // Generate a new port for the Kafka
    +        int port = Networks.getRandomPort();
    +        Preconditions.checkState(port > 0, "Failed to get random port.");
    +        properties.setProperty("port", Integer.toString(port));
    --- End diff --
    
    Should we only do this if its originally set to 0 or left empty? Without 
reading the code I would expect it to connect to the port I set, or not connect 
at all.
    
    Or is this not a concern because the port is not used to connect?


---
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