Class StrandedItemsRegistry


  • public class StrandedItemsRegistry
    extends java.lang.Object
    A class that allows to register an item as stranded - ex. a CronJob that has not updated the status or runningOnClusterNode fields but it's execution was finished (this could be a result of db outage or network problems).

    Class allows to register such items and later check their state. The logic of selecting the items from registry to be check and the check itself is provided by StrandedItemsRegistry.StrandedItemsResolutionHandler object passed as a constructor argument of this class instance.

    Since:
    2011.0
    • Method Detail

      • markOnFailure

        public <T extends Item> void markOnFailure​(T item,
                                                   java.util.function.Consumer<T> logic)
        Executes the logic and in case of exception, the item is registered as stranded.
        Parameters:
        item - the item to be passed to consumer and registered in case of exception
        logic - the consumer of the item that should be executed
      • markOnFailure

        public <T extends Item> void markOnFailure​(T item,
                                                   java.util.function.Consumer<T> logic,
                                                   java.util.function.Function<T,​StrandedItemsRegistry.StrandedItemContext> itemContextFunction)
        Executes the logic and in case of exception, the item is registered as stranded.
        Parameters:
        item - the item to be passed to consumer and registered in case of exception
        logic - the consumer of the item that should be executed
        itemContextFunction - the function to provide the additional data for the resolution of this item
      • markStrandedItem

        public void markStrandedItem​(PK pk)
        utility method that allows to add the given PK to the stranded items registry
        Parameters:
        pk -
      • getStrandedItems

        public java.util.Set<PK> getStrandedItems()
        Returns:
        the PKs of stranded items