New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Entry listener with predicate should be notified on value entry/exit from predicate value space #8340
Conversation
Test PASSed. |
04430c5
to
700a17c
Compare
Test |
700a17c
to
188c68d
Compare
Test |
|
188c68d
to
605076a
Compare
Test PASSed. |
Object mergingValue) { | ||
|
||
Map<Integer, EntryEventData> eventDataIncludingValues = new Int2ObjectHashMap<EntryEventData>(EVENT_DATA_MAP_CAPACITY); | ||
Map<Integer, EntryEventData> eventDataExcludingValues = new Int2ObjectHashMap<EntryEventData>(EVENT_DATA_MAP_CAPACITY); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can defer Int2ObjectHashMap
creation at a later point, and can do it when needed, now for ex., if i have value-included
event registrations and don't have any value-excluded
ones, there will be always two Int2ObjectHashMap
instance creation although one is sufficient. This event publishing part is on hot-path and it is better to create possible minimum number of objects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, deferred map creation until actually needed.
605076a
to
5cae199
Compare
Test |
5cae199
to
ddd6f6a
Compare
Test PASSed. |
Object mergingValue) { | ||
|
||
Map<Integer, EntryEventData> eventDataIncludingValues = null; | ||
Map<Integer, EntryEventData> eventDataExcludingValues = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't an ArrayList
cheaper than Map
to hold event data in terms of number of created objects and calculations needed for hash? Seems an ArrayList
is a better fit here and no need a Map
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The need here is to maintain a mapping from event type of event-to-be-published to the EntryEventData
object (which can be reused across events published to listeners). At the moment, given the filtering strategies implemented in this PR, in the worst case for an UPDATED
event we might create 2 more entries for event types REMOVED
and ADDED
(when the QueryCacheNaturalFilteringStrategy
is used and appropriately configured listeners with predicates are registered).
On the other hand, with the default filtering strategy, there is no need to use a map at all, we just need to maintain two possible forms of the EntryEventData
(with & without values), so in this case the Map
s are indeed overkill.
Caching EntryEventData
is not a direct concern of the chosen filtering strategy, however the caching implementation can be optimized depending on the chosen filtering strategy, so I will try something like introducing a new interface EntryEventDataCache
, with an instance obtainable from the FilteringStrategy
itself:
interface EntryEventDataCache {
EntryEventData getOrCreateEventData(mapName, caller, dataKey, value, oldValue, mergingValue, eventTypeForPublishing);
}
interface FilteringStrategy {
....
EntryEventDataCache getEntryEventDataCache();
}
Test |
e7e2188
to
d58b51b
Compare
Test |
d58c92b
to
49c8653
Compare
Test PASSed. |
1 similar comment
Test PASSed. |
Maybe you want to remove some unused methods in other than that LGTM 👍 |
49c8653
to
ae93547
Compare
Good catch, thanks for pointing that out. |
Test |
The |
ae93547
to
42809d9
Compare
Test PASSed. |
run-lab-run |
Test PASSed. |
@Override | ||
public int doFilter(EventFilter filter, Data dataKey, Object dataOldValue, Object dataValue, EntryEventType eventType, | ||
String mapNameOrNull) { | ||
if (filter instanceof MapPartitionLostEventFilter) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can the mapName be null?
👍 good job (some minor comments) |
Thanks @ahmetmircik & @tombujok, I pushed updated javadoc & fixed the argument name that was leftover as |
Test PASSed. |
private Extractors getExtractorsForMapName(String mapName) { | ||
if (mapName == null) { | ||
return Extractors.empty(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha, one more thing. If the mapName can't be null (since you changed it in the last commit) is this null check here necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This null
check was introduced in faa6428 but I don't think there are any chances mapName
could be null
as all code paths arrive at this point via one of publishEvent
variants and the callers are various map operations, which should have a non-null map name.
Test |
…ring strategy maintains Hazelcast entry events behavior. New filtering strategy introduced which processes UPDATED entry events and, depending on listener's predicate, may alter the type event, to match exit/entry of value from predicate value space.
Unrelated test failure
|
run-lab-run |
Test PASSed. |
a9b7d9a
to
08f0f91
Compare
Test PASSed. |
08f0f91
to
2fa7d9a
Compare
Test PASSed. |
This PR introduces filtering strategies in map event publisher, to facilitate building a 'query cache' style listener with predicate on
IMap
. Default filtering strategy maintains Hazelcast entry events behavior. A new filtering strategy has been introduced which processes UPDATED entry events and, depending on listener's predicate, may alter the type of event, to match exit/entry of value from predicate value space.An EE counterpart is required.