Class ReadOnlyConditionsHelper
java.lang.Object
de.hybris.platform.jalo.flexiblesearch.internal.ReadOnlyConditionsHelper
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncheckHints(Tenant tenant, List<Hint> hints) booleancouldUseReadOnlyDataSource(Tenant tenant, List<Hint> hints) this method checks whether all below conditions are fulfilled:
there is noTransactioncurrently active - implemented inisTxActive(); currently activeHybrisDataSourceis not an alternative (activated withDataSourceProvider.activateAlternativeMasterDataSource(String)or slave dataSource (activated withDataSourceProvider.activateSlaveDataSource(String)- implemented inisMasterDataSourceActive(Tenant)SessionContextfor currentJaloSessiondoes not contain a attributeCTX_ENABLE_FS_ON_READ_REPLICAwith valuefalsenone of the categories set for the query (through aFlexibleSearchHints.CategorizedQueryHint) is configured to not use read-only dataSource - implemented incheckHints(Tenant, List)any of the below is true:SessionContextfor currentJaloSessioncontains a attributeCTX_ENABLE_FS_ON_READ_REPLICAwith valuetrue- implemented inreadOnlyDataSourceEnabledInSessionContext(Tenant)at least one category set for the query (through aFlexibleSearchHints.CategorizedQueryHint) is configured to use read-only dataSource - implemented incheckHints(Tenant, List)getReadOnlyDataSource(Tenant tenant) returns the read-only datasource only if:
read-only datasource is properly configured with property defined inPARAM_FS_READ_ONLY_DATASOURCE; the configured read-only datasource is using the same DB provider as main datasourcebooleanisDataSourceReadOnlyReplica(HybrisDataSource hybrisDataSource) protected booleanisMasterDataSourceActive(Tenant tenant) protected booleanMethod checks whether a current session context has an attributeCTX_ENABLE_FS_ON_READ_REPLICAdeclared and if so, whether its value istrueMethod checks whether a session context has an attributeCTX_ENABLE_FS_ON_READ_REPLICAdeclared and if so, whether its value istrue
-
Field Details
-
PARAM_FS_READ_ONLY_DATASOURCE
- See Also:
-
CTX_ENABLE_FS_ON_READ_REPLICA
- See Also:
-
-
Constructor Details
-
ReadOnlyConditionsHelper
public ReadOnlyConditionsHelper()
-
-
Method Details
-
isTxActive
protected boolean isTxActive() -
isMasterDataSourceActive
-
readOnlyDataSourceEnabledInSessionContext
Method checks whether a current session context has an attributeCTX_ENABLE_FS_ON_READ_REPLICAdeclared and if so, whether its value istrue- 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 totrue(or string equivalent);Optional.of(false)if there is a session and it has the attribute set tofalse(or string equivalent);Optional.empty()if there is no session active or there is no attribute defined in the session
-
readOnlyDataSourceEnabledInSessionContext
Method checks whether a session context has an attributeCTX_ENABLE_FS_ON_READ_REPLICAdeclared and if so, whether its value istrue- Parameters:
ctx- the session context- Returns:
Optional.of(true)if the session has the attribute set totrue(or string equivalent);Optional.of(false)if the session has the attribute set tofalse(or string equivalent);Optional.empty()if there is no attribute defined in the session or it cannot be parsed to boolean
-
getReadOnlyDataSource
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:
Optionalcontaining read-only datasource if all points mentioned in the description are fulfilled, otherwiseOptional.empty()
- read-only datasource is properly configured with property defined in
-
isDataSourceReadOnlyReplica
-
couldUseReadOnlyDataSource
this method checks whether all below conditions are fulfilled:
- there is no
Transactioncurrently active - implemented inisTxActive(); - currently active
HybrisDataSourceis not an alternative (activated withDataSourceProvider.activateAlternativeMasterDataSource(String)or slave dataSource (activated withDataSourceProvider.activateSlaveDataSource(String)- implemented inisMasterDataSourceActive(Tenant) SessionContextfor currentJaloSessiondoes not contain a attributeCTX_ENABLE_FS_ON_READ_REPLICAwith valuefalse- none of the categories set for the query (through a
FlexibleSearchHints.CategorizedQueryHint) is configured to not use read-only dataSource - implemented incheckHints(Tenant, List) - any of the below is true:
SessionContextfor currentJaloSessioncontains a attributeCTX_ENABLE_FS_ON_READ_REPLICAwith valuetrue- implemented inreadOnlyDataSourceEnabledInSessionContext(Tenant)- at least one category set for the query (through a
FlexibleSearchHints.CategorizedQueryHint) is configured to use read-only dataSource - implemented incheckHints(Tenant, List)
- Returns:
trueif all conditions mentioned in the description are fulfilled, otherwisefalse
- there is no
-
checkHints
- Returns:
Optional.empty()if hints do not give any indication about using read-only datasource; otherwiseOptional<Boolean>that will contain whether read-only datasource can be used. Iffalse, the read-only datasource should not be used, even when allowed by other conditions
-