Skip to content

Commit

Permalink
SAK-33381: Use cache properties for calendar (sakaiproject#4812)
Browse files Browse the repository at this point in the history
  • Loading branch information
juanarcadio authored and juanjmerono committed Sep 20, 2017
1 parent c0bb6b2 commit 05a0f80
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,19 @@ public interface ExternalCalendarSubscriptionService
/** sakai.properties: event type forced list of ical external subscriptions */
public final static String SAK_PROP_EXTSUBSCRIPTIONS_EVENTTYPE = "calendar.external.subscriptions.eventtype";

/**
* sakai.properties: number of cached entries for institutional ical external subscriptions
*/
public final static String SAK_PROP_EXTSUBSCRIPTIONS_INST_CACHEENTRIES = "calendar.external.subscriptions.user.cacheentries";

/**
* sakai.properties: cache time for institutional ical external
* subscriptions (iCal updated after expiration)
*/
public final static String SAK_PROP_EXTSUBSCRIPTIONS_INST_CACHETIME = "calendar.external.subscriptions.institutional.cachetime";

/**
* sakai.properties: number of cached entries for user procided ical
* external subscriptions
* sakai.properties: number of cached entries for user-provided ical external subscriptions
*/
public final static String SAK_PROP_EXTSUBSCRIPTIONS_USER_CACHEENTRIES = "calendar.external.subscriptions.user.cacheentries";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,19 +232,24 @@ public void init()
if (enabled)
{
// INIT the caches
long cacheRefreshRate = 43200; // 12 hours
SimpleConfiguration<String, BaseExternalSubscriptionDetails> cacheConfig = new SimpleConfiguration<>(1000, cacheRefreshRate, 0); // 12 hours
cacheConfig.setStatisticsEnabled(true);
long userCacheRefreshRate = 60 * m_configurationService.getInt(SAK_PROP_EXTSUBSCRIPTIONS_USER_CACHETIME, 120);
long instCacheRefreshRate = 60 * m_configurationService.getInt(SAK_PROP_EXTSUBSCRIPTIONS_INST_CACHETIME, 120);
long userCacheMaxEntries = m_configurationService.getInt(SAK_PROP_EXTSUBSCRIPTIONS_USER_CACHEENTRIES, 32);
long instCacheMaxEntries = m_configurationService.getInt(SAK_PROP_EXTSUBSCRIPTIONS_INST_CACHEENTRIES, 32);
SimpleConfiguration<String, BaseExternalSubscriptionDetails> userCacheConfig = new SimpleConfiguration<>(userCacheMaxEntries, userCacheRefreshRate, 0);
SimpleConfiguration<String, BaseExternalSubscriptionDetails> instCacheConfig = new SimpleConfiguration<>(instCacheMaxEntries, instCacheRefreshRate, 0);
userCacheConfig.setStatisticsEnabled(true);
instCacheConfig.setStatisticsEnabled(true);
institutionalSubscriptionCache = new SubscriptionCache(
m_memoryService.createCache("org.sakaiproject.calendar.impl.BaseExternalCacheSubscriptionService.institutionalCache", cacheConfig), clock);
m_memoryService.createCache("org.sakaiproject.calendar.impl.BaseExternalCacheSubscriptionService.institutionalCache", instCacheConfig), clock);
usersSubscriptionCache = new SubscriptionCache(
m_memoryService.createCache("org.sakaiproject.calendar.impl.BaseExternalCacheSubscriptionService.userCache", cacheConfig), clock);
m_memoryService.createCache("org.sakaiproject.calendar.impl.BaseExternalCacheSubscriptionService.userCache", userCacheConfig), clock);
// TODO replace this with a real solution for when the caches are distributed by disabling the timer and using jobscheduler
if (institutionalSubscriptionCache.getCache().isDistributed()) {
m_log.error(institutionalSubscriptionCache.getCache().getName()+" is distributed but calendar subscription caches have a local timer refresh which means they will cause cache replication storms once every "+cacheRefreshRate+" seconds, do NOT distribute this cache");
m_log.error(institutionalSubscriptionCache.getCache().getName()+" is distributed but calendar subscription caches have a local timer refresh which means they will cause cache replication storms once every "+instCacheRefreshRate+" seconds, do NOT distribute this cache");
}
if (usersSubscriptionCache.getCache().isDistributed()) {
m_log.error(usersSubscriptionCache.getCache().getName()+" is distributed but calendar subscription caches have a local timer refresh which means they will cause cache replication storms once every "+cacheRefreshRate+" seconds, do NOT distribute this cache");
m_log.error(usersSubscriptionCache.getCache().getName()+" is distributed but calendar subscription caches have a local timer refresh which means they will cause cache replication storms once every "+userCacheRefreshRate+" seconds, do NOT distribute this cache");
}

// iCal column map
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2182,6 +2182,7 @@
# 4. Subscription cache settings (optional)
# Institutional subscription defaults: reload every 120min
# User subscriptions defaults: max 32 subscriptions in memory, reload every 120min
# calendar.external.subscriptions.institutional.cacheentries=32
# calendar.external.subscriptions.institutional.cachetime=120
# calendar.external.subscriptions.user.cacheentries=32
# calendar.external.subscriptions.user.cachetime=120
Expand Down

0 comments on commit 05a0f80

Please sign in to comment.