Showing posts with label logic module. Show all posts
Showing posts with label logic module. Show all posts

Thursday, August 5, 2010

"Soft" pencil down of coding. Begin to write documentaion



Logic caching system is at state of soft pencil down. This means I expect only commits with a javadoc.
My next step is writing documentation and adding it to the openmrs`s wiki.

The documentation will include structure of the caching system, description in details of classes and interfaces user needs to use caching system, code samples, links to different resources.

If some else documentation is needed please add a comment.

I have only one opened issue to add patch of openmrs-core, because of some small changes like adding Serializable to some org.openmrs.logoc.* classes and change ehcache library to the latest version. I plan to create ticket for this.

Tuesday, July 13, 2010

Web page for configuring logic cache

Hi!
    Last week I developed web page for configuring logic cache. Let`s look a chain of requirements to understand what and why is done.
    LogicCacheManager may have a lot of caches, each cache has it`s configuration and some features like flush cache data. If I can change cache`s configuration I want after application restart to have the same configuration, I say about storing/restoring settings.
    LogicCache is only layer between caching framework and some of them doesn`t allow to change some of their setting at runtime, so that`s why we need ability to "restart" cache to activate option. Restarting of a cache is simply recreating it, this mean I programmatically dispose and the create cache with the same name.

 So, the requirements are:
1) provide access to cache`s settings through the web page;
2) make "restart" feature for current caching framework;
3) store/restore settings.

I think we two web pages: the 1st with list of all caches and the 2nd with current cache settings.

below you can see such pages.
page with all caches we use in the project:











page with certain logic cache:





















That`s all.

Ah, no, I have something else. Temporary to test cache I added to the logic module tester page ability to run tests for cohort of patients:





















and result page:





















If we needn`t this I change these pages back.

OK, now that`s all.

Monday, June 21, 2010

Writing wrapper of caching frameworks, part2

Hi this post is about the structure of the Caching System for the Logic Module. I`ve already presented my structure, listened to question/comments and something changed it.

The main goal of this caching system is to wrap a caching framework and provide the interface for required features for us. Rest upon previous post where I made a review of simplified structure of two caching frameworks I designed a structure of the Caching System for the Logic Service.

Here is it:


















LogicCacheManager - utilitny class, provides a cache by its name, keeps Map of caches as well as a link to LogicCacheProvider.

LogicCacheProvider - class hides a control of the CacheManager of the certain caching framework. It is an abstract class. Contains a list of all created logicCaches.

LogicCache - the interface that is necessary to implement, which hides a cache of the certain caching framework, provides all the necessary methods: get, put, getSize etc. Some methods may throw IllegalOperationException, this means cachig framework behind it doesn`t support such features. Also it has getFeature method which take argument LogicCache.Feature type which is internal enumeration. Using "boolean getFeature(Feature)" we can ask our logicCache about what features are supported.

LogicCacheConfig - interface, provides access to manage some parameters of the cache at the runtime. For example: max size of the cache in the memory, default ttl for objects in cache etc. Like LogicCache it has internal enumeration LogicCacheConfig.Features and getFeature method to ask about what methods are supported.

Next post I`ll write about LogicCacheKey, serialization, how to test it.

Monday, June 14, 2010

Writing wrapper of caching frameworks, part1

My presentation was last week and I told about the design of the caching system for the logic service. As you know I`ll use a widely used caching framework which helps me to cover a bigger part of the requirements such:

  • provide an inmemory cache
  • provide a disk cache
  • expiration time for cache objects and so on.

Also one of the tasks was to design an abstraction layer for a caching framework to have opportunity to change it. We needn`t all of features of any caching framework (ehcache, jboss cache, jcs ...) and we will use only framework`s cache to get/put objects, cache manager to create caches and configuration objects to change some run time properties of the cache.

I tried to use ehcache, then I looked through the tutorial of the jboss-cache and jcs. I understood they similar in their using. All of them have configuration files to configure some central object in the meaning of the cache manager, using it we can create caches and change their configurations.

Below I provided simplified structures of ehcache and jboss-cache.

EhCache:

Using an ehcache.xml file we can create a CacheManager then we can get/create caches using the CacheManager. That`s all! we can put/get objects into/from a cache. Each cache has it`s configuration and some properties may be changed at run time.

JBoss-cache:

Using a CacheFactory and some config.xml file we can create a Cache. This cache is like a CacheManager. It has at least one ROOT node and may have a lot of them each node we can use like a cache where we can put/get objects.

There is a similar situation with jcs.

Next post I`ll write about my design to wrap caching framework.