Class ForceSerializationHelper

java.lang.Object
org.sentrysoftware.metricshub.engine.strategy.utils.ForceSerializationHelper

public class ForceSerializationHelper extends Object
The ForceSerializationHelper class provides utility methods for enforcing serialization of operations on connector namespaces. It aims to acquire a lock before running an executable function, ensuring that the serialization is maintained. The class is designed to have a private no-argument constructor to prevent instantiation.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> T
    forceSerialization(@NonNull Supplier<T> executable, @NonNull TelemetryManager telemetryManager, @NonNull String connectorId, Object objToProcess, @NonNull String description, T defaultValue)
    Force the serialization when processing the given object, this method tries to acquire the connector namespace lock before running the executable, if the lock cannot be acquired or there is an exception or an interruption then the defaultValue is returned

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ForceSerializationHelper

      public ForceSerializationHelper()
  • Method Details

    • forceSerialization

      public static <T> T forceSerialization(@NonNull @NonNull Supplier<T> executable, @NonNull @NonNull TelemetryManager telemetryManager, @NonNull @NonNull String connectorId, Object objToProcess, @NonNull @NonNull String description, @NonNull T defaultValue)
      Force the serialization when processing the given object, this method tries to acquire the connector namespace lock before running the executable, if the lock cannot be acquired or there is an exception or an interruption then the defaultValue is returned
      Type Parameters:
      T - for example CriterionTestResult or a SourceTable
      Parameters:
      executable - the supplier executable function, e.g. visiting a criterion or a source
      telemetryManager - wraps the host's properties where the connector namespace holds the lock
      connectorId - the identifier of the connector (criterion, source or compute) belongs to
      objToProcess - the object to process used for debug purpose
      description - the object to process description used in the debug messages
      defaultValue - the default value to return in case of any glitch
      Returns:
      T instance