Class ForceSerializationHelper
java.lang.Object
org.sentrysoftware.metricshub.engine.strategy.utils.ForceSerializationHelper
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TforceSerialization(@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
-
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 exampleCriterionTestResultor aSourceTable- Parameters:
executable- the supplier executable function, e.g. visiting a criterion or a sourcetelemetryManager- wraps the host's properties where the connector namespace holds the lockconnectorId- the identifier of the connector (criterion, source or compute) belongs toobjToProcess- the object to process used for debug purposedescription- the object to process description used in the debug messagesdefaultValue- the default value to return in case of any glitch- Returns:
- T instance
-