cassandra-pr mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [cassandra] dcapwell commented on a change in pull request #470: CASSANDRA-15630 fix testSerializeError
Date Tue, 17 Mar 2020 19:39:35 GMT
dcapwell commented on a change in pull request #470: CASSANDRA-15630 fix testSerializeError
URL: https://github.com/apache/cassandra/pull/470#discussion_r393923231
 
 

 ##########
 File path: test/unit/org/apache/cassandra/net/ConnectionUtils.java
 ##########
 @@ -240,6 +247,27 @@ private void doCheck(FailCheck testAndFailCheck)
         }
     }
 
+    private static void longCheck(Runnable assertion, long timeout, TimeUnit timeUnit)
+    {
+        long start = System.currentTimeMillis();
+        for (;;)
+        {
+            try
+            {
+                assertion.run();
+                return;
+            }
+            catch (AssertionError e)
+            {
+                long elapsedMs = System.currentTimeMillis() - start;
+                if (elapsedMs > timeUnit.toMillis(timeout))
+                    throw e;
+                else
+                    Uninterruptibles.sleepUninterruptibly(5, TimeUnit.MILLISECONDS);
 
 Review comment:
   may want to take a look at the `org.apache.cassandra.utils.Retry` class.  I created it
recently since I didn't find common utils for retries.
   
   ```
   long maxDurationNanos = timeUnit.toMillis(timeout);
   long startNanos = System.nanoTime();
   Retry.retryWithBackoffBlocking(Integer.MAX_VALUE, () -> assertion.run(), (cause) ->
{
     if (!(cause instanceOf AssertionError)
       return false;
     return (System.nanoTime() - startNanos) <= maxDurationNanos;
   });
   ```
   
   the main differences are:
   1) retry doesn't block thread, only result (if you ask for blocking)
   2) default to exponential backoff

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Mime
View raw message