ignite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexey Kuznetsov <akuznet...@gridgain.com>
Subject Local cache on client node.
Date Mon, 30 Nov 2015 09:41:04 GMT
Ignites,

If I start client node and create local cache on it seems that local cache
created on client node.
Is this correct behaviour or not not?

>From API consistency - seems not, because PARTITIONED and REPLICATED caches
throw exception.

But from user point it may be very useful in some cases, because LOCAL
cache is a kind of HashMap on "steroids" (it has transactions, evictions,
and more).

So we should throw exception or describe in documentation.

Thoughs?

Code that show local cache on client node:

public class LocalCacheOnClient {
    public static void main(String[] args) throws IgniteException {
        IgniteConfiguration cfgSrv = new IgniteConfiguration();
        cfgSrv.setGridName("srv");
        Ignite n1 = Ignition.start(cfgSrv);

        IgniteConfiguration cfgClm = new IgniteConfiguration();
        cfgClm.setGridName("cln");
        cfgClm.setClientMode(true);
        Ignite n2 = Ignition.start(cfgClm);

        CacheConfiguration<Integer, Integer> ccfg = new
CacheConfiguration<>("local");
        ccfg.setCacheMode(CacheMode.LOCAL);

        IgniteCache<Integer, Integer> c = n2.getOrCreateCache(ccfg);

        c.put(1, 100);

        n1.close(); // stop server node

        c.put(2, 200); // local cache works fine.

        System.out.println(c.get(1));
        System.out.println(c.get(2));
    }
}


-- 
Alexey Kuznetsov
GridGain Systems
www.gridgain.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message