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

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.atlassian.bamboo.plan.cache.ImmutablePlanCacheService
ImmutablePlanCacheService.CacheInvalidator
 
Constructor Summary
ImmutablePlanCacheServiceImpl(ImmutablePlanManager immutablePlanManager, PlanDao planDao, org.springframework.transaction.support.TransactionTemplate transactionTemplate, org.springframework.orm.hibernate.HibernateTemplate hibernateTemplate)
           
 
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.
protected  org.springframework.transaction.support.TransactionTemplate createTransactionTemplate(org.springframework.transaction.support.TransactionTemplate transactionTemplate)
           
 void disableCache()
          Disable cache.
 void enableCache()
          Enable cache.
 java.util.List<ImmutableChainBranch> getBranchesForChain(PlanKey planKey)
          Returns a list of branches for given chain
 int[] getBuildNumberOverrides(PlanKey planKey)
          internal use only.
 BambooCacheStats getCacheStats()
          Retrieve cache statistics
 java.lang.Iterable<PlanKey> getChainsToInvalidate(ImmutablePlanCacheService.CacheInvalidator invalidator)
          Internal.
 ImmutableChain getImmutablePlanByKey(PlanKey planKey)
          Returns a plan if one exists with the key.
 java.util.concurrent.locks.ReentrantReadWriteLock getLock(PlanKey planKey)
          Makes plan inaccessible
 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
 void setBuildNumberOverrides(PlanKey planKey, int firstBuildNumber, int lastBuildNumber, int nextBuildNumber)
          internal use only.
 
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,
                                     @NotNull
                                     org.springframework.transaction.support.TransactionTemplate transactionTemplate,
                                     @NotNull
                                     org.springframework.orm.hibernate.HibernateTemplate hibernateTemplate)
Method Detail

createTransactionTemplate

protected org.springframework.transaction.support.TransactionTemplate createTransactionTemplate(org.springframework.transaction.support.TransactionTemplate transactionTemplate)

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:

getBranchesForChain

@NotNull
public java.util.List<ImmutableChainBranch> getBranchesForChain(@NotNull
                                                                        PlanKey planKey)
Description copied from interface: ImmutablePlanCacheService
Returns a list of branches for given chain

Specified by:
getBranchesForChain 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

getChainsToInvalidate

@NotNull
public java.lang.Iterable<PlanKey> getChainsToInvalidate(@NotNull
                                                                 ImmutablePlanCacheService.CacheInvalidator invalidator)
Description copied from interface: ImmutablePlanCacheService
Internal. Calls apply on the supplied $ImmutablePlanCacheService.CacheInvalidator

Specified by:
getChainsToInvalidate in interface ImmutablePlanCacheService

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()
Description copied from interface: ImmutablePlanCacheService
Retrieve cache statistics

Specified by:
getCacheStats in interface ImmutablePlanCacheService
Returns:
Cache statistics

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

getLock

public java.util.concurrent.locks.ReentrantReadWriteLock getLock(@NotNull
                                                                 PlanKey planKey)
Description copied from interface: ImmutablePlanCacheService
Makes plan inaccessible

Specified by:
getLock in interface ImmutablePlanCacheService
Parameters:
planKey - key of the Plan to be made inaccessible

setBuildNumberOverrides

public void setBuildNumberOverrides(PlanKey planKey,
                                    int firstBuildNumber,
                                    int lastBuildNumber,
                                    int nextBuildNumber)
Description copied from interface: ImmutablePlanCacheService
internal use only.

Specified by:
setBuildNumberOverrides in interface ImmutablePlanCacheService

getBuildNumberOverrides

@Nullable
public int[] getBuildNumberOverrides(PlanKey planKey)
Description copied from interface: ImmutablePlanCacheService
internal use only.

Specified by:
getBuildNumberOverrides in interface ImmutablePlanCacheService


Copyright © 2013 Atlassian Software Systems Pty Ltd. All Rights Reserved.