Package de.hybris.platform.util
Class StrandedItemsRegistry
- java.lang.Object
-
- de.hybris.platform.util.StrandedItemsRegistry
-
public class StrandedItemsRegistry extends java.lang.ObjectA 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.StrandedItemsResolutionHandlerobject passed as a constructor argument of this class instance.- Since:
- 2011.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classStrandedItemsRegistry.StrandedItemContextstatic interfaceStrandedItemsRegistry.StrandedItemContextProviderstatic classStrandedItemsRegistry.StrandedItemsResolutionHandler<T>
-
Constructor Summary
Constructors Constructor Description StrandedItemsRegistry(StrandedItemsRegistry.StrandedItemsResolutionHandler<?> resolutionHandler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckStrandedItems(int maxItemsToCheck)executes the check on stranded itemsjava.util.Optional<StrandedItemsRegistry.StrandedItemContext>getStrandedItemContext(PK pk)java.util.Set<PK>getStrandedItems()<T extends Item>
voidmarkOnFailure(T item, java.util.function.Consumer<T> logic)Executes the logic and in case of exception, the item is registered as stranded.<T extends Item>
voidmarkOnFailure(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.voidmarkStrandedItem(PK pk)utility method that allows to add the given PK to the stranded items registry
-
-
-
Constructor Detail
-
StrandedItemsRegistry
public StrandedItemsRegistry(StrandedItemsRegistry.StrandedItemsResolutionHandler<?> resolutionHandler)
-
-
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 exceptionlogic- 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 exceptionlogic- the consumer of the item that should be executeditemContextFunction- 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
-
getStrandedItemContext
public java.util.Optional<StrandedItemsRegistry.StrandedItemContext> getStrandedItemContext(PK pk)
-
checkStrandedItems
public void checkStrandedItems(int maxItemsToCheck)
executes the check on stranded items- Parameters:
maxItemsToCheck- max count of items to check during the execution of this method. If lower than or equal 0 all registered items will be check with this call- See Also:
StrandedItemsRegistry.StrandedItemsResolutionHandler.checkStrandedItems(StrandedItemsRegistry, Set)
-
-