com.atlassian.greenhopper.service.timetracking
Class WorklogHistoryCacheImpl

java.lang.Object
  extended by com.atlassian.greenhopper.service.timetracking.WorklogHistoryCacheImpl
All Implemented Interfaces:
WorklogHistoryCache

@Service(value="gh-worklogHistoryCache")
public class WorklogHistoryCacheImpl
extends java.lang.Object
implements WorklogHistoryCache


Field Summary
 
Fields inherited from interface com.atlassian.greenhopper.service.timetracking.WorklogHistoryCache
DEFAULT_MEMORY_SIZE, SERVICE
 
Constructor Summary
WorklogHistoryCacheImpl()
           
 
Method Summary
 long calculateInMemorySize()
          Warning: huge performance / blocking impact.
 void clear()
          Removes all entries from the cache
 void destroyCache()
          Destroy the backing ehcache
 net.sf.ehcache.Element getElement(java.lang.String issueKey)
          Get the cache element for the issue key.
 long getMemoryStoreSize()
           
 double getUsageRatio()
           
 void initCache()
          We'll get the configuration from the greenHopper data store, which will give us a user-defined entry or the default if there is none.
 void remove(java.lang.String issueKey)
           
 void resize(int newSize)
          Ehcache 1.6 doesn't allow resizing of the memory store.
 void setEntry(java.lang.String issueKey, java.util.SortedMap<org.joda.time.DateMidnight,DayWorkHistory> entry)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorklogHistoryCacheImpl

public WorklogHistoryCacheImpl()
Method Detail

getElement

public net.sf.ehcache.Element getElement(java.lang.String issueKey)
Description copied from interface: WorklogHistoryCache
Get the cache element for the issue key. The actual cache value is not returned here directly, since null values are cached. So the result could be:

Specified by:
getElement in interface WorklogHistoryCache
Parameters:
issueKey - : The issue to fetch the timeline for

remove

public void remove(java.lang.String issueKey)
Specified by:
remove in interface WorklogHistoryCache

setEntry

public void setEntry(java.lang.String issueKey,
                     java.util.SortedMap<org.joda.time.DateMidnight,DayWorkHistory> entry)
Specified by:
setEntry in interface WorklogHistoryCache

clear

public void clear()
Description copied from interface: WorklogHistoryCache
Removes all entries from the cache

Specified by:
clear in interface WorklogHistoryCache

getMemoryStoreSize

public long getMemoryStoreSize()
Specified by:
getMemoryStoreSize in interface WorklogHistoryCache
Returns:
The number of entries currently in the memory cache

calculateInMemorySize

public long calculateInMemorySize()
Description copied from interface: WorklogHistoryCache
Warning: huge performance / blocking impact. Use with care.

Specified by:
calculateInMemorySize in interface WorklogHistoryCache

getUsageRatio

public double getUsageRatio()
Specified by:
getUsageRatio in interface WorklogHistoryCache
Returns:
the memory cache usage ratio - percentage of how much of the memory cache is currently used

resize

public void resize(int newSize)
Ehcache 1.6 doesn't allow resizing of the memory store. To avoid stale data (an entry could be invalidated while we're carrying it over), we create an empty cache instance and replace the live one once it's registered (initialised)

Specified by:
resize in interface WorklogHistoryCache
Parameters:
newSize - : The maximum number of entries that the cache can hold.

initCache

public void initCache()
               throws java.lang.IllegalStateException
We'll get the configuration from the greenHopper data store, which will give us a user-defined entry or the default if there is none.

Throws:
java.lang.IllegalStateException - if the backing ehcache implementation is not in a correct state

destroyCache

public void destroyCache()
                  throws java.lang.IllegalStateException
Destroy the backing ehcache

Throws:
java.lang.IllegalStateException - if the backing ehcache implementation is not in a correct state


Copyright © 2007-2013 Atlassian. All Rights Reserved.