Skip to content

Commit

Permalink
format code
Browse files Browse the repository at this point in the history
Signed-off-by: zane-neo <[email protected]>
  • Loading branch information
zane-neo committed Feb 7, 2024
1 parent b7b74cb commit 3951275
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ protected void doExecute(Task task, ActionRequest request, ActionListener<Delete
wrappedListener.onFailure(e);
}
} else {
// when model metadata is not found, model chunk and controller might still there, delete them here and return success response
// when model metadata is not found, model chunk and controller might still there, delete them here and return success
// response
deleteModelChunksAndController(null, wrappedListener, modelId, null);
}
}, e -> { wrappedListener.onFailure((new OpenSearchStatusException("Failed to find model", RestStatus.NOT_FOUND))); }));
Expand Down Expand Up @@ -233,7 +234,12 @@ public void onFailure(Exception e) {
});
}

private void deleteModelChunksAndController(FunctionName functionName, ActionListener<DeleteResponse> actionListener, String modelId, DeleteResponse deleteResponse) {
private void deleteModelChunksAndController(
FunctionName functionName,
ActionListener<DeleteResponse> actionListener,
String modelId,
DeleteResponse deleteResponse
) {
if (FunctionName.REMOTE != functionName) {
CountDownLatch countDownLatch = new CountDownLatch(2);
AtomicBoolean bothDeleted = new AtomicBoolean(true);
Expand All @@ -242,11 +248,7 @@ private void deleteModelChunksAndController(FunctionName functionName, ActionLis
bothDeleted.compareAndSet(true, b);
if (countDownLatch.getCount() == 0) {
if (bothDeleted.get()) {
log
.debug(
"model chunks and model controller for model {} deleted successfully",
modelId
);
log.debug("model chunks and model controller for model {} deleted successfully", modelId);
if (deleteResponse != null) {
actionListener.onResponse(deleteResponse);
} else {
Expand Down Expand Up @@ -281,10 +283,7 @@ private void deleteModelChunksAndController(FunctionName functionName, ActionLis
}
}, e -> {
log.error("Failed to delete model controller, please try again: " + modelId, e);
actionListener
.onFailure(
new IllegalStateException("Failed to delete model controller, please try again: " + modelId, e)
);
actionListener.onFailure(new IllegalStateException("Failed to delete model controller, please try again: " + modelId, e));
});
deleteController(modelId, deleteControllerListener);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,7 @@ public void testDeleteRemoteModel_deleteModelController_failed() throws IOExcept
deleteModelTransportAction.doExecute(null, mlModelDeleteRequest, actionListener);
ArgumentCaptor<Exception> argumentCaptor = ArgumentCaptor.forClass(Exception.class);
verify(actionListener).onFailure(argumentCaptor.capture());
assertEquals(
"Failed to delete model controller, please try again: test_id",
argumentCaptor.getValue().getMessage()
);
assertEquals("Failed to delete model controller, please try again: test_id", argumentCaptor.getValue().getMessage());
}

public void testDeleteLocalModel_deleteModelController_failed() throws IOException {
Expand Down

0 comments on commit 3951275

Please sign in to comment.