Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-18859

PendingComparableValuesTracker extension in order to support multiple idependent waiters assosiated with values

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 3.0
    • None

    Description

      Motivation

      In order to implement placement driver API that will add an ability to await and get primary replicas in seems reasonable to reuse PendingComparableValuesTracker just because given class provides most of required functionality.

      /**
       * Tracker that stores comparable value internally, this value can grow when {@link #update(Comparable)} method is called. The tracker gives
       * ability to wait for certain value, see {@link #waitFor(Comparable)}.
       */
      public class PendingComparableValuesTracker<T extends Comparable<T>> implements ManuallyCloseable { 

      However some upgrades are needed - see the definition of done section.

      Definition of done

      • It's required to have an ability to complete pending waiter with specific value propagated to an PendingComparableValuesTracker#update() method.
      • It's required to support multiple independent waiters associated with same waiter key.

      Implementation notes

      It make sense to extend PendingComparableValuesTracker with a new class that will store multiple independent waiters instead of single one, in other words

      private final ConcurrentSkipListMap<T, Set<CompletableFuture<R>>> valueFutures = new ConcurrentSkipListMap<>(); 

      instead of

      private final ConcurrentSkipListMap<T, CompletableFuture<R>> valueFutures = new ConcurrentSkipListMap<>();

      In addition to that it makes sense to overload

      public void update(T newValue) 

      with

      public void update(T newValue, @Nullable R futureResult)  

      in order to retrieve CompletableFuture<R> from  PendingComparableValuesTracker#waitFor() instead of CompletableFuture<Void>. Of course it's valid to have Void as R.

       

      Attachments

        Issue Links

          Activity

            People

              alapin Alexander Lapin
              v.pyatkov Vladislav Pyatkov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1.5h
                  1.5h