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

    https://github.com/apache/twill/pull/9#discussion_r77082082
  
    --- 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 --
    
    Currently it's set in the ApplicationMasterService. Probably better to have 
it left empty (or set to 0) in order to trigger this logic.


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