Skip to content
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

Merged
merged 3 commits into from
Jul 27, 2017
Merged

Adding MemoryMonitor to enforce memory limits #805

merged 3 commits into from
Jul 27, 2017

Conversation

paterczm
Copy link
Contributor

@paterczm paterczm commented Jul 27, 2017

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).

Copy link
Contributor

@alechenninger alechenninger left a 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;
}

}
Copy link
Contributor

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

Copy link
Contributor Author

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);
Copy link
Contributor

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.

Copy link
Contributor Author

@paterczm paterczm Jul 27, 2017

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.

@paterczm paterczm merged commit 5b37841 into master Jul 27, 2017
@paterczm paterczm deleted the cap2 branch July 27, 2017 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants