Skip to content

Conversation

@codyrioux
Copy link
Contributor

Information and status

Added caching similar to MantisAPI to reduce the overall connections any one client maintains to Mantis Master.

Note: I'm not seeing the "Purging jobId from job scheduling info cache" messages for whatever reason but it does appear to be correctly reusing the connection. This is evident as additional incoming connections do not showing additional "Caching scheduling change observable for jobId." log line. Furthermore if all connections are closed and then another re-opened we do see the "Caching scheduling change observable for jobId."

I have the release candidate built off this pulled into a local mantis-api build which has its own connection re-use turned off. Everything is operating as expected.

Context

This pull request causes the client to re-use existing scheduling information and status update streams from the master thus reducing the overall load on Mantis Master.

Checklist

  • ./gradlew build compiles code correctly
  • Added new tests where applicable
  • ./gradlew test passes all tests
  • Extended README or added javadocs where applicable
  • Added copyright headers for new files from CONTRIBUTING.md

.onErrorResumeNext(Observable.empty())
.doOnCompleted(() -> {
logger.info("Purging {} from job status cache", id);
jobSchedulingInfoCache.remove(id);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codyrioux This change will affect mantisclient and hence all jobs as well. Should we move the caching up a layer to reduce potential impact?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Up a layer as in directly inside Mantis API?

If so, already implemented. I thought we might want to do it here because multiple connections to jobs via the Mantis API (if they use different query params) will still cause multiple subscriptions to scheduling info.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, yah in that case we could make this optional and default it to false, and then only enable it on mantis api first and then slowly roll out to jobs perhaps?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, given the blast radius, +1 for putting this behind a property so it can be disabled at runtime if we see any issues

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 on rollout. should we also add a unit test to test this behavior?

logger.info("Purging {} from job status cache", id);
jobSchedulingInfoCache.remove(id);
})
.replay(25)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing a doOnError to clear the cache? Wonder if that is causing the log line to not get printed in your testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly the cache is evicted immediately with the new doOnError, but still no error message logged.

.retryWhen(retryLogic)
;
.doOnCompleted(() -> {
logger.info("Purging {} from job scheudling info cache", id);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: scheudling -> scheduling

@codyrioux codyrioux force-pushed the connection-caching branch from 98d8eaf to 84eefa3 Compare April 2, 2020 03:05
logger.info("Purging {} from job status cache", id);
jobSchedulingInfoCache.remove(id);
})
.doOnError((t) -> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noticed the onErrorResumeNext() up this observable chain, so this doOnError will not get executed, it should probably be before the onErrorResumeNext

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.

5 participants