You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Denis Magda <dm...@gridgain.com> on 2015/11/09 10:41:52 UTC

Re: LOCAL CACHE MODE Configuration settings

Hi,

There is no specific parameters that you should enable additionally in order
to make a local cache workable.

Please share the stack trace of your NullPointerException (NPE). I want to
see an exact location that generates it.

Currently I have a feeling that this code 'endDatesCache.get(asOfDate)'
returns 'null' for 'asOfDate' key.
And since the full line looks like endDatesCache.get(asOfDate).size() you
get NPE.

Are you sure that your cache is populated and there is a value for
'asOfDate' key in it?

--
Denis



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/LOCAL-CACHE-MODE-Configuration-settings-tp1875p1888.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Fwd: LOCAL CACHE MODE Configuration settings

Posted by Valentin Kulichenko <va...@gmail.com>.
Igniters,

While investigating this issue reported by user, I noticed that LOCAL cache
is fully destroyed when close() is called, which is inconsistent with other
cache modes. Is there any reason for this?

-Val

---------- Forwarded message ----------
From: vkulichenko <va...@gmail.com>
Date: Tue, Nov 10, 2015 at 3:03 PM
Subject: Re: LOCAL CACHE MODE Configuration settings
To: user@ignite.apache.org


This happens because you use try-with-resources statement and therefore
close
the cache after populating it:

try (IgniteCache<String, Object> myCache =
Ignition.ignite().getOrCreateCache("MY_CACHE")) {
    ...
}

Local cache is completely destroyed in this case, while partitioned just
closes the current cache reference. I'm not sure why it's implemented this
way and I will start a discussion on dev@.

But anyway, just avoid closing the cache unless you want to destroy it and
it will work for you.

-Val



--
View this message in context:
http://apache-ignite-users.70518.x6.nabble.com/LOCAL-CACHE-MODE-Configuration-settings-tp1875p1922.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: LOCAL CACHE MODE Configuration settings

Posted by vkulichenko <va...@gmail.com>.
Deha,

I agree, it was a surprise for me as well :)

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/LOCAL-CACHE-MODE-Configuration-settings-tp1875p1926.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: LOCAL CACHE MODE Configuration settings

Posted by diopek <de...@gmail.com>.
Hi Val,
>From the API document, it is not very clear that LOCAL cache mode destroys
the current cache reference but this is different in PARTITION & REPLICATED
modes. Might be better to make it consistent unless there is some specific
reason. Thanks much for the info. Regards,
Deha



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/LOCAL-CACHE-MODE-Configuration-settings-tp1875p1925.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: LOCAL CACHE MODE Configuration settings

Posted by vkulichenko <va...@gmail.com>.
This happens because you use try-with-resources statement and therefore close
the cache after populating it:

try (IgniteCache<String, Object> myCache =
Ignition.ignite().getOrCreateCache("MY_CACHE")) {
    ...
}

Local cache is completely destroyed in this case, while partitioned just
closes the current cache reference. I'm not sure why it's implemented this
way and I will start a discussion on dev@.

But anyway, just avoid closing the cache unless you want to destroy it and
it will work for you.

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/LOCAL-CACHE-MODE-Configuration-settings-tp1875p1922.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: LOCAL CACHE MODE Configuration settings

Posted by diopek <de...@gmail.com>.
I meant Java8 Ignite project. I am using Ignite 1.4.0



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/LOCAL-CACHE-MODE-Configuration-settings-tp1875p1920.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: LOCAL CACHE MODE Configuration settings

Posted by diopek <de...@gmail.com>.
Hi Val,

I am able to replicate the error by using the below 3 source files.
If you can just create a Java package *com.mytest* and drop these 3 files
under that directory in any Java 8 project; after running
*ExampleNodeStartup.java*, you would be able to see that exception occurring
as currently 'MY_CACHE' *cacheMode* settings in *ignite-cache.xml* is set as
*LOCAL *. if you switch it back  to *PARTITION* cacheMode, it will run fine
without exception. 
ExampleNodeStartup.java
<http://apache-ignite-users.70518.x6.nabble.com/file/n1918/ExampleNodeStartup.java>   
ignite-cache.xml
<http://apache-ignite-users.70518.x6.nabble.com/file/n1918/ignite-cache.xml>  
launch-context.xml
<http://apache-ignite-users.70518.x6.nabble.com/file/n1918/launch-context.xml>  

Regards,



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/LOCAL-CACHE-MODE-Configuration-settings-tp1875p1918.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: LOCAL CACHE MODE Configuration settings

Posted by vkulichenko <va...@gmail.com>.
Hi Deha,

Is it possible for you to provide the example that reproduces the issue? You
can create a small project on GitHub if that's convenient for you.

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/LOCAL-CACHE-MODE-Configuration-settings-tp1875p1914.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: LOCAL CACHE MODE Configuration settings

Posted by diopek <de...@gmail.com>.
Hi Denis,
First I my code accessing ignite from single process.
I already sent out my Spring Configuration file that initializes
SpringCacheManager.
Then there are two types of access code, first one that populates Cache, use
the following API,
*
try (IgniteCache<KeyClass, ValueClass> myCache = Ignition.ignite()
				.getOrCreateCache(MY_CACHE_NAME)) {
     myCache .put(someKey, someValue);
}*

after that wherever I need to access the entries in populated caches I use
the following API;

* Ignition.ignite().cache(MY_CACHE_NAME);* 

below, you've mentioned that;
>>Now it seems that the local cache is started on one node but you're trying
to work with it on another one, that doesn't have it. <<

may be I am missing some fundamental concept here, since I am in single JVM,
I'd assume both API should be accessing on single node. Please advise.
Regards,
Deha




--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/LOCAL-CACHE-MODE-Configuration-settings-tp1875p1911.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: LOCAL CACHE MODE Configuration settings

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

I couldn't reproduce your issue on my side. Did exactly the following.

public class ExampleNodeStartup {
  
  public static void main(String[] args) throws IgniteException {
        BeanFactory factory = new
ClassPathXmlApplicationContext("org/apache/ignite/examples/example-spring-cache.xml");

        SpringCacheManager cacheManager =
(SpringCacheManager)factory.getBean("cacheManager");

        Ignite ignite = Ignition.ignite();

        System.out.println("Cache size:" +
ignite.cache("local_cache").size(CachePeekMode.ALL));
    }
} 

Code executes successfully. XML config, passed to the application context,
just has definitions of SpringCacheManager, local cache and basic
IgniteConfiguration. I'll be able to send the configs to you as attachments
when you subscribe to this user's list (see instructions in comments above).

Double-check that your SpringCacheManager starts the local cache on the same
node which instance you use here:
Ignition.ignite().cache(this.getCacheName()).

Now it seems that the local cache is started on one node but you're trying
to work with it on another one, that doesn't have it.

BTW, this line is useless 
<property name="gridName" value="dstreamGrid" /> 
because the local cache will be started on the grid which name is specified
in ignite-cache.xml. If ignite-cache.xml doesn't set the name then the
default name will be used - null.


Regards,
Denis



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/LOCAL-CACHE-MODE-Configuration-settings-tp1875p1908.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: LOCAL CACHE MODE Configuration settings

Posted by vkulichenko <va...@gmail.com>.
Hi,

Can you please subscribe to the mailing list so that we receive email
notifications? Follow the instructions here:
http://apache-ignite-users.70518.x6.nabble.com/mailing_list/MailingListOptions.jtp?forum=1

It looks like your cache is never started. Can you show how you do this?
Where do you provide cache configuration?

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/LOCAL-CACHE-MODE-Configuration-settings-tp1875p1901.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.