Class AdvancedFailoverHandler<T>

java.lang.Object
com.societegenerale.failover.core.AdvancedFailoverHandler<T>
Type Parameters:
T - the type of the payload managed by this handler
All Implemented Interfaces:
FailoverHandler<T>

public class AdvancedFailoverHandler<T> extends Object implements FailoverHandler<T>
FailoverHandler decorator that publishes metrics on every store/recover operation and delegates payload post-processing to a RecoveredPayloadHandler.

This is the outermost handler — its store/recover fire once per intercepted method call (the composite), so the metrics it publishes are at method-call granularity (e.g. a single findAll() is one recover event, not one per slice). Each metric carries the intercepted method and the failover domain; the method is forwarded downstream.

Author:
Anand Manissery
  • Constructor Details

    • AdvancedFailoverHandler

      public AdvancedFailoverHandler()
  • Method Details

    • store

      public T store(@NonNull Failover failover, @NonNull Method method, List<Object> args, T payload)
      Description copied from interface: FailoverHandler
      Stores the payload for later recovery.
      Specified by:
      store in interface FailoverHandler<T>
      Parameters:
      failover - annotation metadata for the failover point
      method - the reflected intercepted method (never null)
      args - method arguments used to derive the store key
      payload - the result to store
      Returns:
      the stored payload
    • recover

      public T recover(@NonNull Failover failover, @NonNull Method method, List<Object> args, Class<T> clazz, Throwable cause)
      Description copied from interface: FailoverHandler
      Recovers a previously stored payload after a failure.
      Specified by:
      recover in interface FailoverHandler<T>
      Parameters:
      failover - annotation metadata for the failover point
      method - the reflected intercepted method (never null)
      args - method arguments used to derive the lookup key
      clazz - expected return type
      cause - the exception that triggered recovery
      Returns:
      the recovered payload, or null if not found or expired
    • clean

      public void clean()
      Description copied from interface: FailoverHandler
      Removes all expired entries from the failover store.
      Specified by:
      clean in interface FailoverHandler<T>