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

    https://github.com/apache/flink/pull/2484#discussion_r79462622
  
    --- Diff: 
flink-streaming-connectors/flink-connector-cassandra/src/test/java/org/apache/flink/streaming/connectors/cassandra/CassandraConnectorITCase.java
 ---
    @@ -178,89 +166,122 @@ public static void startCassandra() throws 
IOException {
                }
                scanner.close();
     
    -
    -           // Tell cassandra where the configuration files are.
    -           // Use the test configuration file.
    -           System.setProperty("cassandra.config", 
tmp.getAbsoluteFile().toURI().toString());
    -
                if (EMBEDDED) {
    -                   cassandra = new EmbeddedCassandraService();
    -                   cassandra.start();
    +                   String javaCommand = getJavaCommandPath();
    +
    +                   // create a logging file for the process
    +                   File tempLogFile = File.createTempFile("testlogconfig", 
"properties");
    +                   CommonTestUtils.printLog4jDebugConfig(tempLogFile);
    +
    +                   // start the task manager process
    +                   String[] command = new String[]{
    +                           javaCommand,
    +                           "-Dlog.level=DEBUG",
    +                           "-Dlog4j.configuration=file:" + 
tempLogFile.getAbsolutePath(),
    +                           "-Dcassandra.config=" + tmp.toURI(),
    +                           // these options were taken directly from the 
jvm.options file in the cassandra repo
    +                           "-XX:+UseThreadPriorities",
    +                           "-Xss256k",
    +                           "-XX:+AlwaysPreTouch",
    +                           "-XX:+UseTLAB",
    +                           "-XX:+ResizeTLAB",
    +                           "-XX:+UseNUMA",
    +                           "-XX:+PerfDisableSharedMem",
    +                           "-XX:+UseParNewGC",
    +                           "-XX:+UseConcMarkSweepGC",
    +                           "-XX:+CMSParallelRemarkEnabled",
    +                           "-XX:SurvivorRatio=8",
    +                           "-XX:MaxTenuringThreshold=1",
    +                           "-XX:CMSInitiatingOccupancyFraction=75",
    +                           "-XX:+UseCMSInitiatingOccupancyOnly",
    +                           "-XX:CMSWaitDuration=10000",
    +                           "-XX:+CMSParallelInitialMarkEnabled",
    +                           "-XX:+CMSEdenChunksRecordAlways",
    +                           "-XX:+CMSClassUnloadingEnabled",
    +
    +                           "-classpath", getCurrentClasspath(),
    +                           EmbeddedCassandraService.class.getName()
    +                   };
    +
    +                   ProcessBuilder bld = new ProcessBuilder(command);
    +                   cassandra = bld.start();
    +                   sw = new StringWriter();
    +                   new PipeForwarder(cassandra.getErrorStream(), sw);
                }
     
    -           try {
    -                   Thread.sleep(1000 * 10);
    -           } catch (InterruptedException e) { //give cassandra a few 
seconds to start up
    +           int attempt = 0;
    +           while (true) {
    +                   try {
    +                           attempt++;
    +                           cluster = builder.getCluster();
    +                           session = cluster.connect();
    +                           break;
    +                   } catch (Exception e) {
    +                           if (attempt > 30) {
    +                                   throw e;
    +                           }
    +                           try {
    +                                   Thread.sleep(1000);
    --- End diff --
    
    It is not guaranteed that this actually waits as long as it is set, so a 
good strategy is actually to have a `while` loop with a deadline, rather than a 
fix number of attempts and a sleep.


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