Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

add async stopModel #93

Merged
merged 1 commit into from
May 6, 2020
Merged

add async stopModel #93

merged 1 commit into from
May 6, 2020

Conversation

wnbts
Copy link
Contributor

@wnbts wnbts commented Apr 28, 2020

Current stopModel is a synchronous operation for stopping hosting models. As part of migration to asynchronous implementation, this change adds an asynchronous equivalent using the same business logic with one minor change/fix - setting lastCheckpointTime on a stopped and saved model object going into garbage collection is unnecessary and is therefore removed for cleanness.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@wnbts wnbts marked this pull request as ready for review April 28, 2020 17:58
@wnbts wnbts changed the base branch from development to master April 29, 2020 21:01
@@ -537,10 +537,50 @@ public void stopModel(String detectorId, String modelId) {
Optional
.ofNullable(models.remove(modelId))
.filter(model -> model.getLastCheckpointTime().plus(checkpointInterval).isBefore(now))
.ifPresent(model -> {
checkpointDao.putModelCheckpoint(modelId, toCheckpoint.apply(model.getModel()));
model.setLastCheckpointTime(now);
Copy link
Member

Choose a reason for hiding this comment

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

Why is setting last checkpoint time not necessary any more?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because the model has been removed from the managed models at line 538 and has become garbage at the end of the method.

@wnbts wnbts merged commit a852539 into opendistro-for-elasticsearch:master May 6, 2020
@wnbts wnbts deleted the mm-stop branch September 11, 2020 01:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants