Re: Custom CacheStoreAdapter implementation - fields are null

2017-10-17 Thread vkulichenko
Matt, Rick,

Can you show stack traces for these two invocations of the create() method?
It sounds like a bug to me.

-Val



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: Custom CacheStoreAdapter implementation - fields are null

2017-10-17 Thread rick_tem
I put my shared per-thread stuff in thread local and reference it from
CacheStoreAdapter.  That will hopefully work for you.  For example, I have
connections I want to re-use within the same transaction and don't want them
returned to the pool until the transaction ends.  That means multiple
put-->write calls until I finally get a sessionEnd() call with write-through
cache.

Best,
Rick



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: Custom CacheStoreAdapter implementation - fields are null

2017-10-17 Thread matt
Yeah, that's definitely happening. 2 instances are being created. Is there a
workaround for this that you know of?

Thanks,
Matt



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: Custom CacheStoreAdapter implementation - fields are null

2017-10-16 Thread rick_tem
Could be because there are two instances of your cacheStore created?  At
least that's what I see in the debugger with my particular CacheStoreAdapter
in version 2.0.  Could you break in the constructor and see if that is the
case?  I had an issue with static and noticed two instances being created.

Best,
Rick



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: Custom CacheStoreAdapter implementation - fields are null

2017-10-16 Thread matt
Hi, thanks for the reply. I should've mentioned that I do use a factory, and
the http-client is passed into the factory, which is then set on a field.
When the create() method is called, I return a new CacheStoreAdapter along
with the client that's in the factory. At the time the create() method is
called, the http client is present and is properly passed to the
CacheStoreAdapter instance. But when my loadAll() method is called, it is
null.

- Matt



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: Custom CacheStoreAdapter implementation - fields are null

2017-10-16 Thread vkulichenko
Hi Matt,

CacheStore is implementation usually should not be serialized in the first
place (actually I doubt it would be possible to properly serialize a HTTP
client instance). In CacheConfiguration you provide a Factory instead, so
you can provide your own implementation that will correctly create the store
instance. Don't forget to deploy the factory class on all the nodes before
starting.

-Val



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Custom CacheStoreAdapter implementation - fields are null

2017-10-16 Thread matt
Hi,

I've implemented a CacheStoreAdapter and am seeing that when Ignite starts
to use this class (loadAll, etc.) the fields that I set in my constructor
with values, are null when the methods are called. I realized there's
something I'm doing wrong in terms of how my CacheStoreAdapter is
serialized, but not sure what to do. The values passed into my
CacheStoreAdapter constructor, are arbitrary, but one includes an http
client and another is a basic Java class used for cache key/field mapping.
How can I make sure that my adapter has access to the objects it requires
when Ignite is calling on it?

Thanks,
Matt



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/