ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Me" ...@linlyu.com>
Subject Re: How to filter the CacheInterceptor for a certain cacheefficiently?
Date Mon, 09 Nov 2015 12:35:11 GMT
Hi,I found that I can access the real CacheConfiguration object with a conversatation from
IgniteCache to IgniteCacheProxy.But is there any more graceful and less intrusive way to do
the same thing?public void testForInterpectorModifyDynamically() throws Exception {
    IgniteCache<Integer, Person> cache = ignite1.getOrCreateCache(cache_name);// convert
the cache object to IgniteCaceProxy and modify the config in its context...
    ((IgniteCacheProxy) cache).context().config().setInterceptor(new PersonalInterceptor(1));
    cache.put(1,new Person("Lin","Lyu"));
    assertEquals("LYU", cache.get(1).getLastName());
Lin Lyu

------------------ Original ------------------
From:  "Me";<me@linlyu.com>;
Date:  Mon, Nov 9, 2015 07:21 PM
To:  "user-ignite"<user@ignite.apache.org>; 

Subject:  Re:  How to filter the CacheInterceptor for a certain cacheefficiently?

Hi Val,

Thank you for your nice reply. It works when I am creating one cache with a certain CacheConfiguration
with interceptor, But I don't know how to changed the interceptor when the cache object is

PS: here is the code on creating a cache with interceptor.
public void testInterceptorWithConfigOnCreate() throws Exception {
    CacheConfiguration cfg = new CacheConfiguration(); 
    cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); // required, but ATOMIC
    cfg.setInterceptor(new PersonalInterceptor(1)); // combined with given interceptor
    ignite1.createCache(cfg); // create this cache with given name and interceptor.// NOTICE,
the cfg will be cloned in the createCache/getOrCreateCache
    final IgniteCache<Integer, Person> cache = ignite1.cache(cache_name);
    Person p = new Person("Jason", "Green");
    Person out = cache.get(1);
    assertEquals(p.getLastName().toUpperCase(), out.getLastName());}As I known, the CacheConfiguration
object in the cache object is different from what I created, and I haven't found the right
way to update the interceptor dynamically.I have read some codes like org/apache/ignite/internal/processors/cache/GridCacheOnCopyFlagAbstractSelfTest.java,
I think the method used only in test cases  org.apache.ignite.testframework.junits.GridAbstractTest#getConfiguration(java.lang.String)
was hacked in org.apache.ignite.internal.processors.cache.GridCacheOnCopyFlagAbstractSelfTest#cacheConfiguration,
so the instance of CacheConfigurations are the same object.
But I have no idea how to do this in a real production environment.
Hopes for you reply.Thanks again.
Lin Lyu.

------------------ Original ------------------
From:  "vkulichenko";<valentin.kulichenko@gmail.com>;
Date:  Sat, Nov 7, 2015 09:55 AM
To:  "user"<user@ignite.apache.org>; 

Subject:  Re: How to filter the CacheInterceptor for a certain cacheefficiently?

Hi Lin Lyu,

Cahe interceptor is configured per cache (see
CacheConfiguration.setInterceptor() configuration property). So you don't
need to do any additional filtering, just set this configuration only for
one cache.


View this message in context: http://apache-ignite-users.70518.x6.nabble.com/How-to-filter-the-CacheInterceptor-for-a-certain-cache-efficiently-tp1864p1878.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.
View raw message