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

    https://github.com/apache/flink/pull/2484#discussion_r79463411
  
    --- 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);
    +                           } catch (InterruptedException e1) {
    +                           }
    +                   }
                }
    -
    -           cluster = builder.getCluster();
    -           session = cluster.connect();
    +           LOG.debug("Connection established after " + attempt + " 
attempts.");
     
                session.execute(CREATE_KEYSPACE_QUERY);
    -           session.execute(CREATE_TABLE_QUERY);
    -   }
    -
    -   @BeforeClass
    -   public static void startFlink() throws Exception {
    -           Configuration config = new Configuration();
    -           config.setInteger(ConfigConstants.TASK_MANAGER_NUM_TASK_SLOTS, 
4);
    +           session.execute(CREATE_TABLE_QUERY.replace("$TABLE", 
"flink_initial"));
     
    -           flinkCluster = new ForkableFlinkMiniCluster(config);
    -           flinkCluster.start();
    +           try {
    +                   Thread.sleep(5000);
    --- End diff --
    
    Fix time sleeps usually result in a mix of long build times (value is 
large) and instability (value is sometimes not large enough). Can one do a 
polling scheme here, that checks if the statement is completed?


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to