Package de.hybris.platform.util
Class StrandedItemsRegistry
java.lang.Object
de.hybris.platform.util.StrandedItemsRegistry
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic interfacestatic class -
Constructor Summary
ConstructorsConstructorDescriptionStrandedItemsRegistry(StrandedItemsRegistry.StrandedItemsResolutionHandler<?> resolutionHandler) -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckStrandedItems(int maxItemsToCheck) executes the check on stranded items<T extends Item>
voidmarkOnFailure(T item, Consumer<T> logic) Executes the logic and in case of exception, the item is registered as stranded.<T extends Item>
voidmarkOnFailure(T item, Consumer<T> logic, 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 Details
-
StrandedItemsRegistry
public StrandedItemsRegistry(StrandedItemsRegistry.StrandedItemsResolutionHandler<?> resolutionHandler)
-
-
Method Details
-
markOnFailure
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, Consumer<T> logic, 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
utility method that allows to add the given PK to the stranded items registry- Parameters:
pk-
-
getStrandedItems
- Returns:
- the PKs of stranded items
-
getStrandedItemContext
-
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)
-