[ 
https://issues.apache.org/jira/browse/IGNITE-2448?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15136848#comment-15136848
 ] 

Denis Magda commented on IGNITE-2448:
-------------------------------------

Hi Roman,

> 1. There is no destroy() hook to stop grid. From mailing list it seems that 
> myBatis cannot have it, but I will recheck.

As I see neither Hazelcast nor Redis cares of this. In my understanding an 
underlying cache system is considered to be stopped when myBatis process is 
terminated. In such a case an Ignite instance will be stopped automatically.

> 2. To create Ignite cache and grid, users will have to prepare 
> `IGNITE_HOME/config/default-config.xml` (or default configs will be used). 
> Since there is no way to set configuration parameters with the id coming as 
> an argument before IgniteCacheAdapter instantiation, what I do in the 
> constructor is somehow hacky. 

In general I'm ok with such approach because seems that there is no more 
elegant way to achieve the same. 

Review notes, related to the cache instantiation, are the following

a) Let's introduce in CacheConfiguration a specific cache that will always be 
used as a template for the rest of the caches that are going to be started in 
runtime. 

So as the first solution instead of this
{noformat}
        CacheConfiguration cacheConfig = cacheConfigs[cacheConfigs.length - 1];
        cacheConfig.setName(id);
{noformat}

you can start a new cache this way

{noformat}

        CacheConfiguration cacheCfg = null;

        for (CacheConfiguration cfg : cacheConfigs) {
            if (cfg.getName().equals("templateCache")) {
                cacheCfg = new CacheConfiguration(cfg);
                break;
            }
        }

        if (cacheCfg == null)
            throw new RuntimeException("Template cache is not found. Please add 
cache named 'templateCache' to " +
                "IgniteConfiguration.");
{noformat}

Moreover, we have even better solution that avoids creation of the template 
cache at all.
If you define CacheConfiguration bean in default-config.xml you can get it a 
way like this after that

{noformat}
        DefaultListableBeanFactory factory = new DefaultListableBeanFactory();

        new XmlBeanDefinitionReader(factory).loadBeanDefinitions(new 
FileSystemResource(
            new File("config/example-ignite.xml")));

        CacheConfiguration cfg = factory.getBean("templateCacheCfg");
{noformat}

The final possible solution is usage of properties mentioned by Eduardo.
_Properties are read from the cache elament and passed to any setter method in 
the adapter class. The code is here:_
_https://github.com/mybatis/mybatis-3/blob/master/src/main/java/org/apache/ibatis/mapping/CacheBuilder.java_

b) Always use new CacheConfiguration instance when you start a new cache.

I mean that instead of 
{noformat}
CacheConfiguration cacheConfig = cacheConfigs[cacheConfigs.length - 1];
{noformat}

You should use
{noformat}
cacheCfg = new CacheConfiguration(cfg);
{noformat}

> I provide 3 sample Ignite configuration files in `config/` with the default 
> server node in LOCAL mode. They are very simple, and I will mention in the 
> docs that eviction, expiration, etc. can be said according to how it is 
> specified in Ignite docs.

Sounds good to me.

> Ignite based second level cache for MyBatis
> -------------------------------------------
>
>                 Key: IGNITE-2448
>                 URL: https://issues.apache.org/jira/browse/IGNITE-2448
>             Project: Ignite
>          Issue Type: New Feature
>            Reporter: Denis Magda
>            Assignee: Roman Shtykh
>
> MyBatis [1] has a concept of a second level cache.
> It makes sense to implement a module that will allow to use Ignite as a 
> second level cache for this framework.
> In particular the following has to be done:
> - introduce ignite-cache module that will be located in MyBatis GIT 
> repository [2]
> - implement MyBatis {{Cache}} interface [3]
> - there should be configs inside of the module for different exemplary cases 
> (server node with a single local cache; server node that is a part of some 
> cluster and caches mybatis data in replicatred or partitioned cache; client 
> nodes that connects to the cluster and works with the cache); 
> - add documentation about the integration on Ignite readme.io
> - as a reference you may refer to Hazelcast [4] or other implementation
> More on caches in MyBatis
> http://www.mybatis.org/mybatis-3/sqlmap-xml.html#cache
> [1] http://www.mybatis.org/
> [2] https://github.com/mybatis/
> [3] 
> https://github.com/mybatis/mybatis-3/blob/master/src/main/java/org/apache/ibatis/cache/Cache.java
> [4] https://github.com/mybatis/hazelcast-cache



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to