Class TimestampedCollection<K,​V>

  • Direct Known Subclasses:
    SuspendedFiberStorage

    public class TimestampedCollection<K,​V>
    extends Object
    TODO javadoc WARNING: This class is a private utility class used by WS-RX implementation. Any usage outside the intedned scope is strongly discouraged. The API exposed by this class may be changed, replaced or removed without any advance notice.
    Author:
    Marek Potociar
    • Method Detail

      • register

        public V register​(@NotNull
                          K correlationId,
                          @NotNull
                          V subject)
        Registers a subject and maps it to a given correlationId. The newly created registration is timestamped which allows for later removal based on the age of registration using removeOldest() method.
        Parameters:
        correlationId - correlation identifier to be associated with a given subject
        subject - a primary registration object
        Returns:
        old subject associated with a given correlationId or null if there's no such subject
        See Also:
        remove(java.lang.Object), removeOldest()
      • register

        public boolean register​(@NotNull
                                V subject)
        Creates a new subject registration. The newly created registration is timestamped which allows for later removal based on the age of registration using removeOldest() method.
        Parameters:
        subject - a primary registration subject
        Returns:
        true if the registration was successfull, false otherwise
        See Also:
        removeOldest()
      • register

        public boolean register​(long timestamp,
                                @NotNull
                                V subject)
        Creates a new subject registration. The newly created registration is timestamped using a value of the timestamp parameter which allows for later removal based on the age of registration using removeOldest() method.
        Parameters:
        timestamp - a timestamp to be used for the registration
        subject - a primary registration subject
        Returns:
        true if the registration was successfull, false otherwise
        See Also:
        removeOldest()
      • remove

        public V remove​(@NotNull
                        K correlationId)
        Removes a registration from the collection based on a correlationId and returns the value of the registered subject. This method may return null
        Parameters:
        correlationId - identifier to be associated with an already registered subject
        Returns:
        a registered subject associated with a given correlationId or null if there's no such subject
        See Also:
        register(java.lang.Object, java.lang.Object)
      • removeAll

        public List<V> removeAll()
        Removes all values from the time-stamped collection and returns them as an ordered FIFO list.
        Returns:
        ordered FIFO list of the removed values. Returns empty list in case there are no values stored in the collection.
      • isEmpty

        public boolean isEmpty()
        Call this function to determine whether the collection is empty or not.
        Returns:
        true if the collection is empty, false otherwise
      • size

        public int size()
        Returns the number of elements in this collection. If the collection contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.
        Returns:
        the number of elements in this collection.
      • getOldestRegistrationTimestamp

        public long getOldestRegistrationTimestamp()
        Returns a timestamp of the oldest registered subject.
        Returns:
        timestamp of the oldest registered subject.
        Throws:
        NoSuchElementException - if the underlying collection is empty.
        See Also:
        removeOldest()