com.atlassian.bamboo.plan.cache
Class ImmutablePlanCacheServiceImpl

java.lang.Object
  extended by com.atlassian.bamboo.plan.cache.ImmutablePlanCacheServiceImpl
All Implemented Interfaces:
ImmutablePlanCacheService

public class ImmutablePlanCacheServiceImpl
extends java.lang.Object
implements ImmutablePlanCacheService

Since:
v3.4

Constructor Summary
ImmutablePlanCacheServiceImpl(ImmutablePlanManager immutablePlanManager, PlanDao planDao)
           
 
Method Summary
 void cascadeInvalidate(long chainId)
          Resetting cache by id is evil and should not be done.
 void cascadeInvalidate(PlanKey planKey)
          Removes the cached reference for the passed plan and its children.
 void disableCache()
          Disable cache.
 void enableCache()
          Enable cache.
 BambooCacheStats getCacheStats()
           
 ImmutableChain getImmutablePlanByKey(PlanKey planKey)
          Returns a plan if one exists with the key.
 ImmutableJob getMasterOfJob(PlanKey jobKey, PlanKey masterChainKey)
           
 PlanIdentifier getPlanIdentifierForPermissionCheckingByKey(PlanKey planKey)
          Returns a Plan skeleton skeleton providing ONLY id and key, that matches the given key This method should be used only for permission checking using Acegi

If Job key is provided as a parameter, parent Chain will be returned anyway, as Acegi assertions are defined only for TopLevelPlans

<T extends ImmutablePlan>
java.util.List<T>
getPlans(java.lang.Class<T> planType)
          Returns all Plan's filtered by Class.
<T extends ImmutablePlan>
java.util.List<T>
getPlans(java.lang.Class<T> planType, com.google.common.base.Predicate<? super T> filter)
          Returns all Plan's filtered by Class.
 void initialiseCache()
          Clear the cache and attempt to read all Chains from DB in order to cache them.
 void invalidate(PlanKey planKey)
          Removes the cached Plan.
 void reset(PlanKey planKey)
          Removes the cached Plan and its metadata.
 void resetAll()
          Nukes the cache
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImmutablePlanCacheServiceImpl

public ImmutablePlanCacheServiceImpl(@NotNull
                                     ImmutablePlanManager immutablePlanManager,
                                     @NotNull
                                     PlanDao planDao)
Method Detail

getImmutablePlanByKey

@Nullable
public ImmutableChain getImmutablePlanByKey(@NotNull
                                                     PlanKey planKey)
Description copied from interface: ImmutablePlanCacheService
Returns a plan if one exists with the key.

Specified by:
getImmutablePlanByKey in interface ImmutablePlanCacheService
Returns:

getMasterOfJob

public ImmutableJob getMasterOfJob(@NotNull
                                   PlanKey jobKey,
                                   @NotNull
                                   PlanKey masterChainKey)
Specified by:
getMasterOfJob in interface ImmutablePlanCacheService

invalidate

public void invalidate(@NotNull
                       PlanKey planKey)
Description copied from interface: ImmutablePlanCacheService
Removes the cached Plan. Retains Plan metadata.

Specified by:
invalidate in interface ImmutablePlanCacheService
Parameters:
planKey - key of the Plan to be removed from cache

cascadeInvalidate

public void cascadeInvalidate(@NotNull
                              PlanKey planKey)
Description copied from interface: ImmutablePlanCacheService
Removes the cached reference for the passed plan and its children. Currently only propagates invalidation from Chain to ChainBranch

Specified by:
cascadeInvalidate in interface ImmutablePlanCacheService
Parameters:
planKey - key of the Plan to be removed from cache

cascadeInvalidate

public void cascadeInvalidate(long chainId)
Resetting cache by id is evil and should not be done. However we have one case when we need to do it PlanConfigurationAspect.resetImmutablePlanCacheService(BranchCommitInformation)

Specified by:
cascadeInvalidate in interface ImmutablePlanCacheService
Parameters:
chainId - id of chain to be removed from cache

reset

public void reset(@NotNull
                  PlanKey planKey)
Description copied from interface: ImmutablePlanCacheService
Removes the cached Plan and its metadata.

Specified by:
reset in interface ImmutablePlanCacheService
Parameters:
planKey - key of the Plan to be removed from cache

resetAll

public void resetAll()
Description copied from interface: ImmutablePlanCacheService
Nukes the cache

Specified by:
resetAll in interface ImmutablePlanCacheService

initialiseCache

public void initialiseCache()
Description copied from interface: ImmutablePlanCacheService
Clear the cache and attempt to read all Chains from DB in order to cache them. If cache was disabled it will be enabled by this method.

Specified by:
initialiseCache in interface ImmutablePlanCacheService

disableCache

public void disableCache()
Description copied from interface: ImmutablePlanCacheService
Disable cache. When cache is disabled all cache requests will be logged with severity WARN until cache will be enabled again. This method will clear cache.

Specified by:
disableCache in interface ImmutablePlanCacheService

enableCache

public void enableCache()
Description copied from interface: ImmutablePlanCacheService
Enable cache. This method will not load anything when it is enabled, you should consider calling ImmutablePlanCacheService.initialiseCache() instead if you expect plans to be loaded.

Specified by:
enableCache in interface ImmutablePlanCacheService

getCacheStats

public BambooCacheStats getCacheStats()
Specified by:
getCacheStats in interface ImmutablePlanCacheService

getPlans

@NotNull
public <T extends ImmutablePlan> java.util.List<T> getPlans(java.lang.Class<T> planType)
Description copied from interface: ImmutablePlanCacheService
Returns all Plan's filtered by Class. Does not include plans marked for deletion. This method will not load anything from DB - it will operate only on cached data.

Specified by:
getPlans in interface ImmutablePlanCacheService
Parameters:
planType - - the type of the plan to retrieve
Returns:
plans sorted by DescriptionProvider.getName()

getPlans

@NotNull
public <T extends ImmutablePlan> java.util.List<T> getPlans(java.lang.Class<T> planType,
                                                                    @NotNull
                                                                    com.google.common.base.Predicate<? super T> filter)
Description copied from interface: ImmutablePlanCacheService
Returns all Plan's filtered by Class. Does not include plans marked for deletion. This method will not load anything from DB - it will operate only on cached data.

Specified by:
getPlans in interface ImmutablePlanCacheService
Parameters:
planType - - the type of the plan to retrieve
Returns:
plans sorted by DescriptionProvider.getName()

getPlanIdentifierForPermissionCheckingByKey

public PlanIdentifier getPlanIdentifierForPermissionCheckingByKey(@NotNull
                                                                  PlanKey planKey)
Description copied from interface: ImmutablePlanCacheService
Returns a Plan skeleton skeleton providing ONLY id and key, that matches the given key This method should be used only for permission checking using Acegi

If Job key is provided as a parameter, parent Chain will be returned anyway, as Acegi assertions are defined only for TopLevelPlans

Specified by:
getPlanIdentifierForPermissionCheckingByKey in interface ImmutablePlanCacheService
Parameters:
planKey - of the plan to find
Returns:
plan by the id if found, otherwise null


Copyright © 2012 Atlassian. All Rights Reserved.