Skip to content

Commit

Permalink
move response out from delete chunk
Browse files Browse the repository at this point in the history
Signed-off-by: zane-neo <[email protected]>
  • Loading branch information
zane-neo committed Jan 16, 2024
1 parent 22efba5 commit 587116a
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ protected void doExecute(Task task, ActionRequest request, ActionListener<Delete
void deleteModelChunks(String modelId, DeleteResponse deleteResponse, ActionListener<DeleteResponse> actionListener) {
DeleteByQueryRequest deleteModelsRequest = new DeleteByQueryRequest(ML_MODEL_INDEX);
deleteModelsRequest.setQuery(new TermsQueryBuilder(MODEL_ID_FIELD, modelId));

long startTime = System.currentTimeMillis();
client.execute(DeleteByQueryAction.INSTANCE, deleteModelsRequest, ActionListener.wrap(r -> {
if ((r.getBulkFailures() == null || r.getBulkFailures().size() == 0)
&& (r.getSearchFailures() == null || r.getSearchFailures().size() == 0)) {
Expand All @@ -197,7 +197,7 @@ void deleteModelChunks(String modelId, DeleteResponse deleteResponse, ActionList
// ResourceNotFound is returned to notify that this model was deleted.
// This is a walk around to avoid cleaning up model leftovers. Will revisit if
// necessary.
actionListener.onResponse(deleteResponse);
log.info("####################################### Delete model chunks success!" + modelId + ", time taken: " + (System.currentTimeMillis() - startTime));
}
} else {
returnFailure(r, modelId, actionListener);
Expand All @@ -218,7 +218,8 @@ private void returnFailure(BulkByScrollResponse response, String modelId, Action
errorMessage = OS_STATUS_EXCEPTION_MESSAGE + ", " + SEARCH_FAILURE_MSG + modelId;
}
log.debug(response.toString());
actionListener.onFailure(new OpenSearchStatusException(errorMessage, RestStatus.INTERNAL_SERVER_ERROR));
log.info("####################################### Delete model failed!" + modelId + ", response is: " + response);
// actionListener.onFailure(new OpenSearchStatusException(errorMessage, RestStatus.INTERNAL_SERVER_ERROR));
}

private void deleteModel(String modelId, ActionListener<DeleteResponse> actionListener) {
Expand All @@ -229,6 +230,7 @@ public void onResponse(DeleteResponse deleteResponse) {
deleteModelChunks(modelId, deleteResponse, actionListener);
deleteModelController(modelId);
log.info("####################################### Delete model after delete chunks!" + modelId);
actionListener.onResponse(deleteResponse);
}

@Override
Expand Down

0 comments on commit 587116a

Please sign in to comment.