Class ReadOnlyConditionsHelper

java.lang.Object
de.hybris.platform.jalo.flexiblesearch.internal.ReadOnlyConditionsHelper

public class ReadOnlyConditionsHelper extends Object
  • Field Details

  • Constructor Details

    • ReadOnlyConditionsHelper

      public ReadOnlyConditionsHelper()
  • Method Details

    • isTxActive

      protected boolean isTxActive()
    • isMasterDataSourceActive

      protected boolean isMasterDataSourceActive(Tenant tenant)
    • readOnlyDataSourceEnabledInSessionContext

      protected Optional<Boolean> readOnlyDataSourceEnabledInSessionContext(Tenant tenant)
      Method checks whether a current session context has an attribute CTX_ENABLE_FS_ON_READ_REPLICA declared and if so, whether its value is true
      Parameters:
      tenant - the tenant for which the session should be checked
      Returns:
      Optional.of(true) if there is a session and it has the attribute set to true (or string equivalent); Optional.of(false) if there is a session and it has the attribute set to false (or string equivalent); Optional.empty() if there is no session active or there is no attribute defined in the session
    • readOnlyDataSourceEnabledInSessionContext

      public Optional<Boolean> readOnlyDataSourceEnabledInSessionContext(SessionContext ctx)
      Method checks whether a session context has an attribute CTX_ENABLE_FS_ON_READ_REPLICA declared and if so, whether its value is true
      Parameters:
      ctx - the session context
      Returns:
      Optional.of(true) if the session has the attribute set to true (or string equivalent); Optional.of(false) if the session has the attribute set to false (or string equivalent); Optional.empty() if there is no attribute defined in the session or it cannot be parsed to boolean
    • getReadOnlyDataSource

      public Optional<HybrisDataSource> getReadOnlyDataSource(Tenant tenant)
      returns the read-only datasource only if:
      • read-only datasource is properly configured with property defined in PARAM_FS_READ_ONLY_DATASOURCE;
      • the configured read-only datasource is using the same DB provider as main datasource
      Returns:
      Optional containing read-only datasource if all points mentioned in the description are fulfilled, otherwise Optional.empty()
    • isDataSourceReadOnlyReplica

      public boolean isDataSourceReadOnlyReplica(HybrisDataSource hybrisDataSource)
    • couldUseReadOnlyDataSource

      public boolean couldUseReadOnlyDataSource(Tenant tenant, List<Hint> hints)
      this method checks whether all below conditions are fulfilled:
      Returns:
      true if all conditions mentioned in the description are fulfilled, otherwise false
    • checkHints

      protected Optional<Boolean> checkHints(Tenant tenant, List<Hint> hints)
      Returns:
      Optional.empty() if hints do not give any indication about using read-only datasource; otherwise Optional<Boolean> that will contain whether read-only datasource can be used. If false, the read-only datasource should not be used, even when allowed by other conditions