Using an EntryEventImpl in the get code is the right idea. It seems odd to add befoteGet to CacheWriter since CacheWriter is only intended for modify operations.
I think it would make more sense to add both beforeGet and afterGet to CacheListener. Currently the only get operations that create an EntryEventImpl are client get requests. That is what the "clientEvent" parameter is about. On this particular method it is now always null so it could be removed. If you go down one more level (to the get that this method passes clientEvent to) you will say that that flavor of get has other callers from the client/server code that pass in a non-null arg. It looks to me like you could get rid of the clientEvent param on this method since it is now always null. One possible performance down-side to adding get events is that every get call would now also create an EntryEventImpl. When doing gets at a high rate it is going to cause the young gen of the garbage collector to fill up faster. It would be nice if the region does not have a CacheListener to not create an event for every get. But client gets always do so this might not be a big deal. Are your gets coming from a client? If so look at GetOperationContext. It is passed to com.gemstone.gemfire.security.AccessControl.authorizeOperation(String, OperationContext). You can implement AccessControl and plug it in and could use it just to be notified of what client gets a server is being sent and/or what the result of the get was. On Thu, Jan 28, 2016 at 6:43 AM, Nilkanth Patel <[email protected]> wrote: > Hello, > > Is it possible to get beforeGet(), afterGet() events for Region.get() API > with current state of codebase..? > > Seeing the internal code, it seems *i need to add code *(that invoke > listener, writer callbacks) for these events, something similar to the way > events for Region.put() are invoked. is this a correct understanding..? > > If so, I need to create a EntryEventImpl (shown in Red colour ) and pass > it. What is the purpose of clientEvent here ? can i use clientEvent > directly > to create Get events or is it used for some different purpose? > > *LocalRegion.java* > > @Override > public Object get(Object key, Object aCallbackArgument, > boolean generateCallbacks, EntryEventImpl clientEvent) throws > TimeoutException, CacheLoaderException > { > *clientEvent = newGetEntryEvent(key, aCallbackArgument);* > Object result = get(key, aCallbackArgument, generateCallbacks, > false, false, null, *clientEvent*, false, true/*allowReadFromHDFS*/); > if (Token.isInvalid(result)) { > result = null; > } > return result; > } > > > > If so, hook (listener, writer calls ) for GET callbacks are ok as shown in > red colour...? > > *LocalRegion.java* > > public final Object getDeserializedValue(RegionEntry re, final KeyInfo > keyInfo, final boolean updateStats, boolean disableCopyOnRead, > boolean preferCD, EntryEventImpl clientEvent, boolean > returnTombstones, boolean allowReadFromHDFS, boolean retainResult) { > * //hook for before GET - call CacheWriter * > try{ > if (this.diskRegion != null) { > this.diskRegion.setClearCountReference(); > > > //code in try ends here *//hook for after GET - call CacheListener.* > }finally { > if (this.diskRegion != null) { > this.diskRegion.removeClearCountReference(); > } > } > > } > > > Looking forward to a quick help. > > Nilkanth. >
