-
Notifications
You must be signed in to change notification settings - Fork 23
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
Adding MemoryMonitor to enforce memory limits #805
Conversation
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.
Overall looks good for a quick fix, some suggestions that may be worthwhile in the mid term
this.event = event; | ||
} | ||
|
||
} |
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.
How about "fire" method that handles calling the callback and changing state? You could also have a method to encapsulate checking its threshold
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.
Not sure I understand. You're proposing to add 2 more methods with the logic currently implemented in checkThresholdMonitors?
for (ThresholdMonitor<T> m: monitors) { | ||
if (dataSizeB > m.thresholdB && !m.fired) { | ||
m.fired = true; | ||
m.event.fire(dataSizeB, m.thresholdB, obj); |
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.
May be worth capturing a TODO or something here that the first monitor to throw an exception will stop all other callbacks from firing. As a general purpose class, this is probably surprising, though we know with its current usages it may not be problematic. So, I suggest at least a TODO and/or open an issue to remind ourselves that this should probably catch any thrown exceptions and aggregate them.
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.
Without a use case this does not justify a TODO/issue imo. I will clarify in javadoc.
The limits need to be enforced in multiple locations: Response, BulkExecutionContext, HookManager and IterateAndUpdate (last one from lightblue-mongo). To avoid logic redundancy, creating MemoryMonitor utility.
Note that Mediator level hooks are not used (#804).