You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ignite.apache.org by Alexey Kuznetsov <ak...@gridgain.com> on 2015/11/30 10:41:04 UTC

Local cache on client node.

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

Re: Local cache on client node.

Posted by Alexey Kuznetsov <ak...@gridgain.com>.
As for me I also think it is better to preserve current behaviour and add
note to documentation.
I like to treat LOCAL cache as HashMap with cool features.

I created newbie "IGNITE-2037 Update javadocs and documentation about LOCAL
cache could be created on client node"
https://issues.apache.org/jira/browse/IGNITE-2037

On Tue, Dec 1, 2015 at 2:32 PM, Yakov Zhdanov <yz...@apache.org> wrote:

> I think there is nothing bad in this. I would leave it as is and just
> properly fix javadoc that local cache can be created.
>
> --Yakov
>
> 2015-12-01 10:21 GMT+03:00 Denis Magda <dm...@gridgain.com>:
>
> > Alex,
> >
> > This is seems to be one more poor documented feature :)
> >
> > To be serious my preference is to throw an exception in response to an
> > attempt to create a LOCAL cache on a client node because client nodes
> can't
> > store cache data by notion.
> >
> > Any other thoughts?
> >
> > --
> > Denis
> >
> >
> > On 11/30/2015 12:41 PM, Alexey Kuznetsov wrote:
> >
> >> 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));
> >>      }
> >> }
> >>
> >>
> >>
> > --
> > Regards,
> > Denis Magda
> > Lead Professional Services Engineer, GridGain Systems
> > http://www.gridgain.com/
> >
> >
>



-- 
Alexey Kuznetsov
GridGain Systems
www.gridgain.com

Re: Local cache on client node.

Posted by Yakov Zhdanov <yz...@apache.org>.
I think there is nothing bad in this. I would leave it as is and just
properly fix javadoc that local cache can be created.

--Yakov

2015-12-01 10:21 GMT+03:00 Denis Magda <dm...@gridgain.com>:

> Alex,
>
> This is seems to be one more poor documented feature :)
>
> To be serious my preference is to throw an exception in response to an
> attempt to create a LOCAL cache on a client node because client nodes can't
> store cache data by notion.
>
> Any other thoughts?
>
> --
> Denis
>
>
> On 11/30/2015 12:41 PM, Alexey Kuznetsov wrote:
>
>> 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));
>>      }
>> }
>>
>>
>>
> --
> Regards,
> Denis Magda
> Lead Professional Services Engineer, GridGain Systems
> http://www.gridgain.com/
>
>

Re: Local cache on client node.

Posted by Denis Magda <dm...@gridgain.com>.
Alex,

This is seems to be one more poor documented feature :)

To be serious my preference is to throw an exception in response to an 
attempt to create a LOCAL cache on a client node because client nodes 
can't store cache data by notion.

Any other thoughts?

--
Denis

On 11/30/2015 12:41 PM, Alexey Kuznetsov wrote:
> 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));
>      }
> }
>
>

-- 
Regards,
Denis Magda
Lead Professional Services Engineer, GridGain Systems
http://www.gridgain.com/