Reputation: 3328
Using Geode 1.2 and 9.1 Pivotal native client the following code:
IRegion<string, IPdxInstance> r = cache.GetRegion<string, IPdxInstance>("myRegion");
return r[key];
then triggers an AfterCreate
event for myRegion
. Why does that happen when no data is created, only read?
Upvotes: 0
Views: 143
Reputation: 1720
Same here, never used Native Client. I agreed with what @Urizen suspected - you are calling r[key]
from an instance of Geode that doesn't have the entry, so it pulls the data from other instance, which "create" the entry locally.
You have a few options here:
Performing an interest registration for the instance you are initiating the call using registerAllKeys()
(doc here). There is a catch here: (might not be applicable for native client), in Java API, you have an option to register interest with an InterestResultPolicy
. If you use KEYS_VALUES
, you will load all data to local from remote on startup WITHOUT triggering afterCreate callback. If you choose KEYS only or NONE, you will likely have similar problem.
You can check for boolean flag remoteOrigin
in EntryEvent
. If it is false, it is purely local. In a non-WAN setup, this should be enough to distinguish your local operation from remotely initiated operation (be it a cache syncing or a genuine creation initiated by other cache). Vaguely remembering WAN works a bit different here.
Upvotes: 1
Reputation: 1421
I've never used the Native Client but, at a first glance, it should be expected for the afterCreate
event to be invoked on the client side as the entry is actually being created on the local cache. What I mean is that the entry might exists on the server but, internally, the client needs to retrieve it from the server, and then create it locally (thus invoking the afterCreate
for the locally installed CacheListener
). Makes sense?.
Upvotes: 1