Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-10385

Implement a waitUntilCondition utils

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Invalid
    • 1.7.0
    • None
    • None

    Description

      Recently when I refine some tests, I notice that it is a common requirement to wait until a (stable) condition occur.

      To achieve this, we have ExecutionGraphTestUtils#waitUntilJobStatus and many. Most of them can simply abstract as

      public static void waitUntilCondition(SupplierWithException<Boolean, Throwable> conditionSupplier, Deadline deadline) {
        while (deadline.hasTimeLeft()) {
          if (conditionSupplier.get()) { return; }
          Thread.sleep(Math.min(deadline.toMillis(), 500);
        }
        throws new IlleagalStateException("...");
      }
      

       

      I propose to implement such a method to avoid too many utils method scattered to achieve the same purpose.
      Looking forward to your advice. If there is previous code/project already implemented this, I am glad to introduce it.

      cc Zentol

       

      PS: the file attached is some code I found could satisfy this proposal.

      Attachments

        1. example.java
          4 kB
          Zili Chen

        Activity

          People

            Unassigned Unassigned
            tison Zili Chen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: