Liran Zelkha has posted comments on this change.

Change subject: Adding caching capabilities to database access
......................................................................


Patch Set 1: (9 inline comments)

I agree with all remarks, some, however, were forced :-(

....................................................
File 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VdsDynamic.java
Line 13: import org.ovirt.engine.core.compat.StringHelper;
Line 14: import org.ovirt.engine.core.compat.Version;
Line 15: import org.ovirt.engine.core.compat.cache.TimeToLiveInCache;
Line 16: 
Line 17: @TimeToLiveInCache(30)
Idea is to have 3000 seconds for static, 30 seconds for dynamic, and 0 for 
statistics. I think it's a trial and error model. What do you think?
Line 18: public class VdsDynamic implements BusinessEntity<Guid> {
Line 19:     private static final long serialVersionUID = -6010035855157006935L;
Line 20: 
Line 21:     private Guid id;


....................................................
File 
backend/manager/modules/compat/src/main/java/org/ovirt/engine/core/compat/cache/TimeToLiveInCache.java
Line 6: import java.lang.annotation.Target;
Line 7: 
Line 8: @Target(ElementType.TYPE)
Line 9: @Retention(RetentionPolicy.RUNTIME)
Line 10: 
Must go into compat, as we need to cache GUID
Line 11: public @interface TimeToLiveInCache {
Line 12:     int value();
Line 13: 


....................................................
File 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/cache/CacheItemWrapper.java
Line 1: package org.ovirt.engine.core.dal.cache;
Line 2: 
Line 3: public class CacheItemWrapper {
We can, but all the CacheManager job is with Reflection anyway, as it gets an 
Object of unknown type at Runtime - so I'm not sure we need to do this.
Line 4:     private long cacheTime;
Line 5:     private Object data;
Line 6: 
Line 7:     public CacheItemWrapper(long cacheTime, Object data) {


....................................................
File 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/cache/CacheManager.java
Line 15:     private static final Log log = LogFactory
Line 16:             .getLog(CacheableJdbcTemplate.class);
Line 17:     private static CacheManager instance = new CacheManager();
Line 18: 
Line 19:     private Map<CacheKey, CacheItemWrapper> cache = new 
WeakHashMap<CacheKey, CacheItemWrapper>();
Until I integrate Infinispan, I was worried of memory leaks
Line 20:     private Map<Class, List<CacheKey>> typeToKeymapping = new 
WeakHashMap<Class, List<CacheKey>>();
Line 21: 
Line 22:     private CacheManager() {
Line 23: 


Line 29: 
Line 30:     public Object getFromCache(String sql, Object[] args) {
Line 31: 
Line 32:         if (log.isDebugEnabled())
Line 33:             log.debug("Getting from cache for query " + sql);
Will fix
Line 34: 
Line 35:         CacheKey key = new CacheKey(sql, args);
Line 36: 
Line 37:         CacheItemWrapper wrapper = cache.get(key);


Line 49:             return null;
Line 50:         }
Line 51: 
Line 52:         Class<? extends Object> type = wrapper.getData().getClass();
Line 53: 
You are right, I'll add a comment. Concerning other Collections - didn't have 
time to support it yet.
Line 54:         if (List.class.isAssignableFrom(type)) {
Line 55: 
Line 56:             List dataList = (List) wrapper.getData();
Line 57:             if (dataList.size() > 0)


Line 101: 
Line 102:     }
Line 103: 
Line 104:     // TODO: Should be synchronized for updatedType
Line 105:     public void cleanCacheForType(Class updatedType) {
You are right. Will do.
Line 106:         List<CacheKey> cacheKeys = typeToKeymapping.get(updatedType);
Line 107: 
Line 108:         if (cacheKeys != null) {
Line 109:             for (CacheKey key : cacheKeys) {


....................................................
File 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/PostgresDbEngineDialect.java
Line 26: /**
Line 27:  *  Postgres db engine dialect.
Line 28:  */
Line 29: public class PostgresDbEngineDialect implements DbEngineDialect {
Line 30:     @SuppressWarnings("unused")
No. That's all the change. I had to change the JdbcTemplate, and this looked 
like the best place.
Line 31:     private static final Log log = LogFactory
Line 32:             .getLog(PostgresDbEngineDialect.class);
Line 33:     /**
Line 34:      * Prefix used in our PostgreSQL function parameters.


....................................................
File 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/SimpleJdbcCallsHandler.java
Line 99:     private CallCreator createCallForModification(final String 
procedureName) {
Line 100:         return new CallCreator() {
Line 101:             @Override
Line 102:             public SimpleJdbcCall createCall() {
Line 103: //                return new 
SimpleJdbcCall(template).withProcedureName(procedureName);
Will do
Line 104:                 return new 
CacheableJdbcCall(template).withProcedureName(procedureName);
Line 105:             }
Line 106:         };
Line 107:     }


--
To view, visit http://gerrit.ovirt.org/14188
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I04d7edea6a52626c68f88362416abdb025e4b026
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Liran Zelkha <[email protected]>
Gerrit-Reviewer: Liran Zelkha <[email protected]>
Gerrit-Reviewer: Michael Kublin <[email protected]>
Gerrit-Reviewer: Roy Golan <[email protected]>
Gerrit-Reviewer: Yair Zaslavsky <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to