com.atlassian.bamboo.plan.cache
Interface ImmutablePlanCacheService

All Known Implementing Classes:
ImmutablePlanCacheServiceImpl

public interface ImmutablePlanCacheService

An experimental API for getting immutable, weakly held, cached ImmutableChain. This Service does not check for permissions currently. Only works for Chain. Cache is disabled by default and should be explicitly enabled by application (preferably by calling initialiseCache())
Concepts:

cache invalidation
Temporary removal of plan from cache (ie as an effect of changed plan configuration). Cache invalidation will remove Plan from cache but will not remove metadata information (ie planKey->id mapping)
cache reset
Permament removal of plan from cache (ie as an effect of plan deletion or move to another project). Cache reset will remove Plan and all related data from the cache.
This class is for internal use only, you should probably be using CachedPlanManager instead. In 3.4, only used for Dashboard Cache

Since:
v3.4

Nested Class Summary
static interface ImmutablePlanCacheService.CacheInvalidator
           
 
Method Summary
 void cascadeInvalidate(long planId)
          Removes the cached reference for the passed plan and its children.
 void cascadeInvalidate(PlanKey planKey)
          Removes the cached reference for the passed plan and its children.
 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)
          Deprecated. 
 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)
          Deprecated. 
 

Method Detail

getImmutablePlanByKey

@Nullable
ImmutableChain getImmutablePlanByKey(@NotNull
                                              PlanKey planKey)
Returns a plan if one exists with the key.

Parameters:
planKey -
Returns:

getBranchesForChain

@NotNull
java.util.List<ImmutableChainBranch> getBranchesForChain(@NotNull
                                                                 PlanKey planKey)
Returns a list of branches for given chain

Parameters:
chain -
Returns:

getMasterOfJob

@Nullable
ImmutableJob getMasterOfJob(@NotNull
                                     PlanKey jobKey,
                                     @NotNull
                                     PlanKey masterChainKey)

getPlans

@NotNull
<T extends ImmutablePlan> java.util.List<T> getPlans(java.lang.Class<T> planType)
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.

Parameters:
planType - - the type of the plan to retrieve
Returns:
plans sorted by DescriptionProvider.getName()

getPlans

@NotNull
<T extends ImmutablePlan> java.util.List<T> getPlans(java.lang.Class<T> planType,
                                                             @NotNull
                                                             com.google.common.base.Predicate<? super T> filter)
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.

Parameters:
planType - - the type of the plan to retrieve
Returns:
plans sorted by DescriptionProvider.getName()

getPlanIdentifierForPermissionCheckingByKey

@Nullable
PlanIdentifier getPlanIdentifierForPermissionCheckingByKey(@NotNull
                                                                    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

Parameters:
planKey - of the plan to find
Returns:
plan by the id if found, otherwise null

getLock

java.util.concurrent.locks.ReentrantReadWriteLock getLock(@NotNull
                                                          PlanKey planKey)
Makes plan inaccessible

Parameters:
planKey - key of the Plan to be made inaccessible

invalidate

void invalidate(@NotNull
                PlanKey planKey)
Removes the cached Plan. Retains Plan metadata.

Parameters:
planKey - key of the Plan to be removed from cache

cascadeInvalidate

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

Parameters:
planKey - key of the Plan to be removed from cache

cascadeInvalidate

void cascadeInvalidate(long planId)
Removes the cached reference for the passed plan and its children. Currently only propagates invalidation from Chain to ChainBranch

Parameters:
planId -

reset

void reset(@NotNull
           PlanKey planKey)
Removes the cached Plan and its metadata.

Parameters:
planKey - key of the Plan to be removed from cache

resetAll

void resetAll()
Nukes the cache


initialiseCache

void initialiseCache()
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.


disableCache

void disableCache()
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.


enableCache

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


getCacheStats

BambooCacheStats getCacheStats()
Retrieve cache statistics

Returns:
Cache statistics

setBuildNumberOverrides

@Deprecated
void setBuildNumberOverrides(PlanKey planKey,
                                        int firstBuildNumber,
                                        int lastBuildNumber,
                                        int nextBuildNumber)
Deprecated. 

internal use only.


getBuildNumberOverrides

@Deprecated
@Nullable
int[] getBuildNumberOverrides(PlanKey planKey)
Deprecated. 

internal use only.


getChainsToInvalidate

@NotNull
java.lang.Iterable<PlanKey> getChainsToInvalidate(@NotNull
                                                          ImmutablePlanCacheService.CacheInvalidator invalidator)
Internal. Calls apply on the supplied $ImmutablePlanCacheService.CacheInvalidator

Parameters:
invalidator -


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