use of net.sf.ehcache.config.CacheConfiguration in project ORCID-Source by ORCID.
the class OrcidProfileCacheManagerImpl method init.
@PostConstruct
private void init() {
CacheConfiguration config1 = publicProfileCache.getCacheConfiguration();
publicProfileCacheTTI = config1.getTimeToIdleSeconds() > 0 ? TimeUtil.convertTimeToInt(config1.getTimeToIdleSeconds()) : DEFAULT_TTI;
publicProfileCacheTTL = config1.getTimeToLiveSeconds() > 0 ? TimeUtil.convertTimeToInt(config1.getTimeToLiveSeconds()) : DEFAULT_TTL;
CacheConfiguration config2 = publicBioCache.getCacheConfiguration();
publicBioCacheTTI = config2.getTimeToIdleSeconds() > 0 ? TimeUtil.convertTimeToInt(config2.getTimeToIdleSeconds()) : DEFAULT_TTI;
publicBioCacheTTL = config2.getTimeToLiveSeconds() > 0 ? TimeUtil.convertTimeToInt(config2.getTimeToLiveSeconds()) : DEFAULT_TTL;
CacheConfiguration config3 = profileCache.getCacheConfiguration();
profileCacheTTI = config3.getTimeToIdleSeconds() > 0 ? TimeUtil.convertTimeToInt(config3.getTimeToIdleSeconds()) : DEFAULT_TTI;
profileCacheTTL = config3.getTimeToLiveSeconds() > 0 ? TimeUtil.convertTimeToInt(config3.getTimeToLiveSeconds()) : DEFAULT_TTL;
CacheConfiguration config4 = profileBioAndInternalCache.getCacheConfiguration();
profileBioAndInternalCacheTTI = config4.getTimeToIdleSeconds() > 0 ? TimeUtil.convertTimeToInt(config4.getTimeToIdleSeconds()) : DEFAULT_TTI;
profileBioAndInternalCacheTTL = config4.getTimeToLiveSeconds() > 0 ? TimeUtil.convertTimeToInt(config4.getTimeToLiveSeconds()) : DEFAULT_TTL;
}
use of net.sf.ehcache.config.CacheConfiguration in project ORCID-Source by ORCID.
the class WorkEntityCacheManagerImpl method init.
@PostConstruct
private void init() {
CacheConfiguration config1 = fullWorkEntityCache.getCacheConfiguration();
fullWorkEntityCacheTTI = config1.getTimeToIdleSeconds() > 0 ? TimeUtil.convertTimeToInt(config1.getTimeToIdleSeconds()) : DEFAULT_TTI;
fullWorkEntityCacheTTL = config1.getTimeToLiveSeconds() > 0 ? TimeUtil.convertTimeToInt(config1.getTimeToLiveSeconds()) : DEFAULT_TTL;
CacheConfiguration config2 = workLastModifiedCache.getCacheConfiguration();
workLastModifiedCacheTTI = config2.getTimeToIdleSeconds() > 0 ? TimeUtil.convertTimeToInt(config2.getTimeToIdleSeconds()) : DEFAULT_TTI;
workLastModifiedCacheTTL = config2.getTimeToLiveSeconds() > 0 ? TimeUtil.convertTimeToInt(config2.getTimeToLiveSeconds()) : DEFAULT_TTL;
CacheConfiguration config3 = publicWorkLastModifiedCache.getCacheConfiguration();
publicWorkLastModifiedCacheTTI = config3.getTimeToIdleSeconds() > 0 ? TimeUtil.convertTimeToInt(config3.getTimeToIdleSeconds()) : DEFAULT_TTI;
publicWorkLastModifiedCacheTTL = config3.getTimeToLiveSeconds() > 0 ? TimeUtil.convertTimeToInt(config3.getTimeToLiveSeconds()) : DEFAULT_TTL;
CacheConfiguration config4 = minimizedWorkEntityCache.getCacheConfiguration();
minimizedWorkEntityCacheTTI = config4.getTimeToIdleSeconds() > 0 ? TimeUtil.convertTimeToInt(config4.getTimeToIdleSeconds()) : DEFAULT_TTI;
minimizedWorkEntityCacheTTL = config4.getTimeToLiveSeconds() > 0 ? TimeUtil.convertTimeToInt(config4.getTimeToLiveSeconds()) : DEFAULT_TTL;
}
use of net.sf.ehcache.config.CacheConfiguration in project Mycat_plus by coderczp.
the class EnchachePooFactory method createCachePool.
@Override
public CachePool createCachePool(String poolName, int cacheSize, int expiredSeconds) {
CacheManager cacheManager = CacheManager.create();
Cache enCache = cacheManager.getCache(poolName);
if (enCache == null) {
CacheConfiguration cacheConf = cacheManager.getConfiguration().getDefaultCacheConfiguration().clone();
cacheConf.setName(poolName);
if (cacheConf.getMaxEntriesLocalHeap() != 0) {
cacheConf.setMaxEntriesLocalHeap(cacheSize);
} else {
cacheConf.setMaxBytesLocalHeap(String.valueOf(cacheSize));
}
cacheConf.setTimeToIdleSeconds(expiredSeconds);
Cache cache = new Cache(cacheConf);
cacheManager.addCache(cache);
return new EnchachePool(poolName, cache, cacheSize);
} else {
return new EnchachePool(poolName, enCache, cacheSize);
}
}
use of net.sf.ehcache.config.CacheConfiguration in project Mycat_plus by coderczp.
the class TestCachePoolPerformance method createEnCachePool.
public static CachePool createEnCachePool() {
CacheConfiguration cacheConf = new CacheConfiguration();
cacheConf.setName("testcache");
cacheConf.maxBytesLocalHeap(400, MemoryUnit.MEGABYTES).timeToIdleSeconds(3600);
Cache cache = new Cache(cacheConf);
CacheManager.create().addCache(cache);
EnchachePool enCachePool = new EnchachePool(cacheConf.getName(), cache, 400 * 10000);
return enCachePool;
}
use of net.sf.ehcache.config.CacheConfiguration in project oozie by apache.
the class EhcacheHCatDependencyCache method addMissingDependency.
@Override
public void addMissingDependency(HCatURI hcatURI, String actionID) {
String serverName = canonicalizeHostname(hcatURI.getServer());
// Create cache for the server if we don't have one
Cache missingCache = missingDepsByServer.get(serverName);
if (missingCache == null) {
CacheConfiguration clonedConfig = cacheConfig.clone();
clonedConfig.setName(serverName);
missingCache = new Cache(clonedConfig);
Cache exists = missingDepsByServer.putIfAbsent(serverName, missingCache);
if (exists == null) {
cacheManager.addCache(missingCache);
missingCache.getCacheEventNotificationService().registerListener(this);
} else {
// discard
missingCache.dispose();
}
}
// Add hcat uri into the missingCache
SortedPKV sortedPKV = new SortedPKV(hcatURI.getPartitionMap());
String partKeys = sortedPKV.getPartKeys();
String missingKey = hcatURI.getDb() + TABLE_DELIMITER + hcatURI.getTable() + TABLE_DELIMITER + partKeys + TABLE_DELIMITER + sortedPKV.getPartVals();
boolean newlyAdded = true;
synchronized (missingCache) {
Element element = missingCache.get(missingKey);
if (element == null) {
WaitingActions waitingActions = new WaitingActions();
element = new Element(missingKey, waitingActions);
Element exists = missingCache.putIfAbsent(element);
if (exists != null) {
newlyAdded = false;
waitingActions = (WaitingActions) exists.getObjectValue();
}
waitingActions.add(new WaitingAction(actionID, hcatURI.toURIString()));
} else {
newlyAdded = false;
WaitingActions waitingActions = (WaitingActions) element.getObjectValue();
waitingActions.add(new WaitingAction(actionID, hcatURI.toURIString()));
}
}
// Increment count for the partition key pattern
if (newlyAdded) {
String tableKey = canonicalizeHostname(hcatURI.getServer()) + TABLE_DELIMITER + hcatURI.getDb() + TABLE_DELIMITER + hcatURI.getTable();
synchronized (partKeyPatterns) {
ConcurrentMap<String, SettableInteger> patternCounts = partKeyPatterns.get(tableKey);
if (patternCounts == null) {
patternCounts = new ConcurrentHashMap<String, SettableInteger>();
partKeyPatterns.put(tableKey, patternCounts);
}
SettableInteger count = patternCounts.get(partKeys);
if (count == null) {
patternCounts.put(partKeys, new SettableInteger(1));
} else {
count.increment();
}
}
}
}
Aggregations