Interface QueueingSegmentListener<K,​V,​E extends Event<K,​V>>

  • All Superinterfaces:
    IntConsumer

    public interface QueueingSegmentListener<K,​V,​E extends Event<K,​V>>
    extends IntConsumer
    This interface describes methods needed for a segment listener that is used when iterating over the current events and be able to queue them properly
    Since:
    7.0
    Author:
    wburns
    • Field Detail

      • NOTIFIED

        static final Object NOTIFIED
      • REMOVED

        static final Object REMOVED
    • Method Detail

      • markKeyAsProcessing

        Object markKeyAsProcessing​(K key)
        This should be invoked on a key before actually processing the data. This way the handler knows to keep any newer events have come after the iteration.
        Parameters:
        key - The key being processed
        Returns:
        The previous value that was found to be updated, NOTIFIED if the key was previously marked as processing or REMOVED if the key was removed and this value shouldn't be processed
      • findCreatedEntries

        Set<CacheEntry<K,​V>> findCreatedEntries()
        This method is to be called just before marking the transfer as complete and after all keys have been manually processed. This will return all the entries that were raised in an event but not manually marked. This is indicative of a CREATE event occurring but not seeing the value.
        Returns:
      • delayProcessing

        CompletionStage<Void> delayProcessing()
        Invoked to determine if processing should be delayed or not. Will return CompletableFutures.completedNull() if processing can continue immediately, otherwise should wait until this is complete.
        Returns:
        null if no notifications are required or a non null CompletionStage that when completed all notifications are done
      • handleEvent

        boolean handleEvent​(EventWrapper<K,​V,​E> wrapper,
                            ListenerInvocation<Event<K,​V>> invocation)
        This should be called by any listener when an event is generated to possibly queue it. If it is not queued, then the caller should take appropriate action such as manually firing the invocation.
        Parameters:
        wrapper - The event that was just raised
        invocation - The invocation the event would be fired on
        Returns:
        Whether or not it was queued. If it wasn't queued the invocation should be fired manually
      • transferComplete

        CompletionStage<Void> transferComplete()
        This is needed to tell the handler when the complete iteration is done. Depending on the implementation this could also fire all queued events that are remaining.