Class DenormalisedPermissionStateManagerImpl
- java.lang.Object
-
- com.atlassian.confluence.security.denormalisedpermissions.impl.DenormalisedPermissionStateManagerImpl
-
- All Implemented Interfaces:
DenormalisedPermissionStateManager,org.springframework.beans.factory.DisposableBean
public class DenormalisedPermissionStateManagerImpl extends Object implements DenormalisedPermissionStateManager, org.springframework.beans.factory.DisposableBean
- Since:
- 7.11.0
-
-
Field Summary
Fields Modifier and Type Field Description static longMAX_ALLOWED_RELOAD_STATE_DELAYstatic intSERVICE_STATE_RELOADING_INTERVALstatic intSERVICE_STATE_RELOADING_INTERVAL_WHEN_SERVICE_IS_DISABLED
-
Constructor Summary
Constructors Constructor Description DenormalisedPermissionStateManagerImpl(com.atlassian.event.api.EventPublisher eventPublisher, DenormalisedServiceStateDao denormalisedServiceStateDao, org.springframework.transaction.PlatformTransactionManager transactionManager, DenormalisedPermissionStateLogService denormalisedPermissionStateLogService, DenormalisedLockService denormalisedLockService, DenormalisedChangeLogDao denormalisedChangeLogDao)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcreateStateRecordsIfTheyDoNotExist()When the service is starting up for the first time, we need to create "state records".voiddestroy()voiddisableService(boolean cleanDenormalisedData)Disables the service and deletes all triggers/functions, so denormalised data will not be updated.voidenableContentService()voidenableService()Enables the service.voidenableSpaceService()LonggetContentPermissionUpdateLag()Returns the time difference between updating regular content permissions and denormalised content permissionsDenormalisedPermissionServiceStategetContentServiceState(boolean realTimeData)Get the state of denormalised content service.LonggetSpacePermissionUpdateLag()Returns the time difference between updating regular space permissions and denormalised space permissionsDenormalisedPermissionServiceStategetSpaceServiceState(boolean realTimeData)Get the state of denormalised space service.List<StateChangeInformation>getStateChangeLog(int limit)Returns a list of service state change eventsvoidinit()booleanisApiReady()Returns true if the state of the service is "READY", if both CONTENT and SPACE services are in ready state Possible reasons for returning false: 1.booleanisContentApiReady()Returns true if the state of denormalised CONTENT service is "READY", which means that denormalised content permissions reflect real permissions.booleanisSpaceApiReady()Returns true if the state of denormalised SPACE service is "READY", which means that denormalised space permissions reflect real permissions.voidonApplicationStartedEvent(com.atlassian.config.lifecycle.events.ApplicationStartedEvent event)voidonApplicationStoppingEvent(com.atlassian.config.lifecycle.events.ApplicationStoppingEvent event)voidonImportFinishEvent(AsyncImportFinishedEvent event)voidonImportStartEvent(AsyncImportStartedEvent event)voidreloadServiceState()We need to support it's state in memory because we'd like to avoid reading this value from DB for every request denormalised permissions receive.voidscheduled()
-
-
-
Field Detail
-
MAX_ALLOWED_RELOAD_STATE_DELAY
public static final long MAX_ALLOWED_RELOAD_STATE_DELAY
-
SERVICE_STATE_RELOADING_INTERVAL_WHEN_SERVICE_IS_DISABLED
public static final int SERVICE_STATE_RELOADING_INTERVAL_WHEN_SERVICE_IS_DISABLED
- See Also:
- Constant Field Values
-
SERVICE_STATE_RELOADING_INTERVAL
public static final int SERVICE_STATE_RELOADING_INTERVAL
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DenormalisedPermissionStateManagerImpl
public DenormalisedPermissionStateManagerImpl(com.atlassian.event.api.EventPublisher eventPublisher, DenormalisedServiceStateDao denormalisedServiceStateDao, org.springframework.transaction.PlatformTransactionManager transactionManager, DenormalisedPermissionStateLogService denormalisedPermissionStateLogService, DenormalisedLockService denormalisedLockService, DenormalisedChangeLogDao denormalisedChangeLogDao)
-
-
Method Detail
-
init
@PostConstruct public void init()
-
scheduled
@Scheduled(fixedDelay=3000L) public void scheduled()
- Specified by:
scheduledin interfaceDenormalisedPermissionStateManager
-
onApplicationStartedEvent
@EventListener public void onApplicationStartedEvent(com.atlassian.config.lifecycle.events.ApplicationStartedEvent event)
-
reloadServiceState
@Internal public void reloadServiceState()
We need to support it's state in memory because we'd like to avoid reading this value from DB for every request denormalised permissions receive. This state is used in router to switch between real denormalised permissions and the fallback service.
-
isApiReady
public boolean isApiReady()
Returns true if the state of the service is "READY", if both CONTENT and SPACE services are in ready state Possible reasons for returning false: 1. Service is disabled 2. Denormalized tables are not ready- Specified by:
isApiReadyin interfaceDenormalisedPermissionStateManager- Returns:
- the state of the service
-
isSpaceApiReady
public boolean isSpaceApiReady()
Returns true if the state of denormalised SPACE service is "READY", which means that denormalised space permissions reflect real permissions. Possible reasons for returning false: 1. Service is disabled 2. Denormalized tables are not ready- Specified by:
isSpaceApiReadyin interfaceDenormalisedPermissionStateManager- Returns:
- the state of the SPACe service
-
isContentApiReady
public boolean isContentApiReady()
Returns true if the state of denormalised CONTENT service is "READY", which means that denormalised content permissions reflect real permissions. Possible reasons for returning false: 1. Service is disabled 2. Denormalized tables are not ready- Specified by:
isContentApiReadyin interfaceDenormalisedPermissionStateManager- Returns:
- the state of the SPACe service
-
getSpaceServiceState
public DenormalisedPermissionServiceState getSpaceServiceState(boolean realTimeData)
Description copied from interface:DenormalisedPermissionStateManagerGet the state of denormalised space service.- Specified by:
getSpaceServiceStatein interfaceDenormalisedPermissionStateManager- Parameters:
realTimeData- if true, data will be read from the DB. If false, cached data will be returned.- Returns:
- the state of denormalised SPACE service
-
getContentServiceState
public DenormalisedPermissionServiceState getContentServiceState(boolean realTimeData)
Description copied from interface:DenormalisedPermissionStateManagerGet the state of denormalised content service.- Specified by:
getContentServiceStatein interfaceDenormalisedPermissionStateManager- Parameters:
realTimeData- if true, data will be read from the DB. If false, cached data will be returned.- Returns:
- the state of denormalised CONTENT service
-
enableService
public void enableService()
Enables the service. It would take some time to update denormalised data- Specified by:
enableServicein interfaceDenormalisedPermissionStateManager
-
enableSpaceService
public void enableSpaceService()
-
enableContentService
public void enableContentService()
-
createStateRecordsIfTheyDoNotExist
@Internal public void createStateRecordsIfTheyDoNotExist() throws ExecutionException, InterruptedExceptionWhen the service is starting up for the first time, we need to create "state records". It's important to do this in separate transaction because these records will be used for cluster-wide locking.
-
getSpacePermissionUpdateLag
public Long getSpacePermissionUpdateLag()
Returns the time difference between updating regular space permissions and denormalised space permissions- Specified by:
getSpacePermissionUpdateLagin interfaceDenormalisedPermissionStateManager- Returns:
- lag in ms, or null if the data record is not found (for example, the service has never been enabled)
-
getContentPermissionUpdateLag
public Long getContentPermissionUpdateLag()
Returns the time difference between updating regular content permissions and denormalised content permissions- Specified by:
getContentPermissionUpdateLagin interfaceDenormalisedPermissionStateManager- Returns:
- lag in ms, or null if the data record is not found (for example, the service has never been enabled)
-
disableService
public void disableService(boolean cleanDenormalisedData)
Disables the service and deletes all triggers/functions, so denormalised data will not be updated.- Specified by:
disableServicein interfaceDenormalisedPermissionStateManager- Parameters:
cleanDenormalisedData- - if true, all denormalised data will be truncated
-
getStateChangeLog
public List<StateChangeInformation> getStateChangeLog(int limit)
Returns a list of service state change events- Specified by:
getStateChangeLogin interfaceDenormalisedPermissionStateManager- Parameters:
limit- limit- Returns:
- list or events, sorted by event date (desc)
-
onImportStartEvent
@EventListener public void onImportStartEvent(AsyncImportStartedEvent event)
-
onImportFinishEvent
@EventListener public void onImportFinishEvent(AsyncImportFinishedEvent event)
-
onApplicationStoppingEvent
@EventListener public void onApplicationStoppingEvent(com.atlassian.config.lifecycle.events.ApplicationStoppingEvent event)
-
-