@@ -212,7 +212,7 @@ public MLModelManager(
212212 public void registerModelMeta (MLRegisterModelMetaInput mlRegisterModelMetaInput , ActionListener <String > listener ) {
213213 try {
214214 FunctionName functionName = mlRegisterModelMetaInput .getFunctionName ();
215- mlStats .getStat (MLNodeLevelStat .ML_NODE_TOTAL_REQUEST_COUNT ).increment ();
215+ mlStats .getStat (MLNodeLevelStat .ML_REQUEST_COUNT ).increment ();
216216 mlStats .createCounterStatIfAbsent (functionName , REGISTER , ML_ACTION_REQUEST_COUNT ).increment ();
217217 String modelGroupId = mlRegisterModelMetaInput .getModelGroupId ();
218218 if (Strings .isBlank (modelGroupId )) {
@@ -322,9 +322,9 @@ public void registerMLModel(MLRegisterModelInput registerModelInput, MLTask mlTa
322322
323323 checkAndAddRunningTask (mlTask , maxRegisterTasksPerNode );
324324 try {
325- mlStats .getStat (MLNodeLevelStat .ML_NODE_TOTAL_REQUEST_COUNT ).increment ();
326- mlStats .getStat (MLNodeLevelStat .ML_NODE_EXECUTING_TASK_COUNT ).increment ();
325+ mlStats .getStat (MLNodeLevelStat .ML_REQUEST_COUNT ).increment ();
327326 mlStats .createCounterStatIfAbsent (mlTask .getFunctionName (), REGISTER , ML_ACTION_REQUEST_COUNT ).increment ();
327+ mlStats .getStat (MLNodeLevelStat .ML_EXECUTING_TASK_COUNT ).increment ();
328328
329329 String modelGroupId = registerModelInput .getModelGroupId ();
330330 GetRequest getModelGroupRequest = new GetRequest (ML_MODEL_GROUP_INDEX ).id (modelGroupId );
@@ -384,17 +384,14 @@ public void registerMLModel(MLRegisterModelInput registerModelInput, MLTask mlTa
384384 } catch (Exception e ) {
385385 handleException (registerModelInput .getFunctionName (), mlTask .getTaskId (), e );
386386 } finally {
387- mlStats .getStat (MLNodeLevelStat .ML_NODE_EXECUTING_TASK_COUNT ). increment ();
387+ mlStats .getStat (MLNodeLevelStat .ML_EXECUTING_TASK_COUNT ). decrement ();
388388 }
389389 }
390390
391391 private void indexRemoteModel (MLRegisterModelInput registerModelInput , MLTask mlTask , String modelVersion ) {
392392 String taskId = mlTask .getTaskId ();
393393 FunctionName functionName = mlTask .getFunctionName ();
394394 try (ThreadContext .StoredContext context = client .threadPool ().getThreadContext ().stashContext ()) {
395- mlStats .getStat (MLNodeLevelStat .ML_NODE_TOTAL_REQUEST_COUNT ).increment ();
396- mlStats .createCounterStatIfAbsent (functionName , REGISTER , ML_ACTION_REQUEST_COUNT ).increment ();
397- mlStats .getStat (MLNodeLevelStat .ML_NODE_EXECUTING_TASK_COUNT ).increment ();
398395
399396 String modelName = registerModelInput .getModelName ();
400397 String version = modelVersion == null ? registerModelInput .getVersion () : modelVersion ;
@@ -443,8 +440,6 @@ private void indexRemoteModel(MLRegisterModelInput registerModelInput, MLTask ml
443440 } catch (Exception e ) {
444441 logException ("Failed to upload model" , e , log );
445442 handleException (functionName , taskId , e );
446- } finally {
447- mlStats .getStat (MLNodeLevelStat .ML_NODE_EXECUTING_TASK_COUNT ).increment ();
448443 }
449444 }
450445
@@ -462,9 +457,6 @@ private void registerModelFromUrl(MLRegisterModelInput registerModelInput, MLTas
462457 String taskId = mlTask .getTaskId ();
463458 FunctionName functionName = mlTask .getFunctionName ();
464459 try (ThreadContext .StoredContext context = client .threadPool ().getThreadContext ().stashContext ()) {
465- mlStats .getStat (MLNodeLevelStat .ML_NODE_TOTAL_REQUEST_COUNT ).increment ();
466- mlStats .createCounterStatIfAbsent (functionName , REGISTER , ML_ACTION_REQUEST_COUNT ).increment ();
467- mlStats .getStat (MLNodeLevelStat .ML_NODE_EXECUTING_TASK_COUNT ).increment ();
468460 String modelName = registerModelInput .getModelName ();
469461 String version = modelVersion == null ? registerModelInput .getVersion () : modelVersion ;
470462 String modelGroupId = registerModelInput .getModelGroupId ();
@@ -509,8 +501,6 @@ private void registerModelFromUrl(MLRegisterModelInput registerModelInput, MLTas
509501 } catch (Exception e ) {
510502 logException ("Failed to register model" , e , log );
511503 handleException (functionName , taskId , e );
512- } finally {
513- mlStats .getStat (MLNodeLevelStat .ML_NODE_EXECUTING_TASK_COUNT ).increment ();
514504 }
515505 }
516506
@@ -693,7 +683,7 @@ private void handleException(FunctionName functionName, String taskId, Exception
693683 && !(e instanceof MLResourceNotFoundException )
694684 && !(e instanceof IllegalArgumentException )) {
695685 mlStats .createCounterStatIfAbsent (functionName , REGISTER , MLActionLevelStat .ML_ACTION_FAILURE_COUNT ).increment ();
696- mlStats .getStat (MLNodeLevelStat .ML_NODE_TOTAL_FAILURE_COUNT ).increment ();
686+ mlStats .getStat (MLNodeLevelStat .ML_FAILURE_COUNT ).increment ();
697687 }
698688 Map <String , Object > updated = ImmutableMap .of (ERROR_FIELD , MLExceptionUtils .getRootCauseMessage (e ), STATE_FIELD , FAILED );
699689 mlTaskManager .updateMLTask (taskId , updated , TIMEOUT_IN_MILLIS , true );
@@ -718,7 +708,8 @@ public void deployModel(
718708 ActionListener <String > listener
719709 ) {
720710 mlStats .createCounterStatIfAbsent (functionName , ActionName .DEPLOY , ML_ACTION_REQUEST_COUNT ).increment ();
721- mlStats .getStat (MLNodeLevelStat .ML_NODE_TOTAL_REQUEST_COUNT ).increment ();
711+ mlStats .getStat (MLNodeLevelStat .ML_EXECUTING_TASK_COUNT ).increment ();
712+ mlStats .getStat (MLNodeLevelStat .ML_REQUEST_COUNT ).increment ();
722713 List <String > workerNodes = mlTask .getWorkerNodes ();
723714 if (modelCacheHelper .isModelDeployed (modelId )) {
724715 if (workerNodes != null && workerNodes .size () > 0 ) {
@@ -800,7 +791,7 @@ public void deployModel(
800791 MLExecutable mlExecutable = mlEngine .deployExecute (mlModel , params );
801792 try {
802793 modelCacheHelper .setMLExecutor (modelId , mlExecutable );
803- mlStats .getStat (MLNodeLevelStat .ML_NODE_TOTAL_MODEL_COUNT ).increment ();
794+ mlStats .getStat (MLNodeLevelStat .ML_DEPLOYED_MODEL_COUNT ).increment ();
804795 modelCacheHelper .setModelState (modelId , MLModelState .DEPLOYED );
805796 listener .onResponse ("successful" );
806797 } catch (Exception e ) {
@@ -813,7 +804,7 @@ public void deployModel(
813804 Predictable predictable = mlEngine .deploy (mlModel , params );
814805 try {
815806 modelCacheHelper .setPredictor (modelId , predictable );
816- mlStats .getStat (MLNodeLevelStat .ML_NODE_TOTAL_MODEL_COUNT ).increment ();
807+ mlStats .getStat (MLNodeLevelStat .ML_DEPLOYED_MODEL_COUNT ).increment ();
817808 modelCacheHelper .setModelState (modelId , MLModelState .DEPLOYED );
818809 Long modelContentSizeInBytes = mlModel .getModelContentSizeInBytes ();
819810 long contentSize = modelContentSizeInBytes == null
@@ -837,6 +828,8 @@ public void deployModel(
837828 })));
838829 } catch (Exception e ) {
839830 handleDeployModelException (modelId , functionName , listener , e );
831+ } finally {
832+ mlStats .getStat (MLNodeLevelStat .ML_EXECUTING_TASK_COUNT ).decrement ();
840833 }
841834 }
842835
@@ -846,7 +839,7 @@ private void handleDeployModelException(String modelId, FunctionName functionNam
846839 && !(e instanceof MLResourceNotFoundException )
847840 && !(e instanceof IllegalArgumentException )) {
848841 mlStats .createCounterStatIfAbsent (functionName , ActionName .DEPLOY , MLActionLevelStat .ML_ACTION_FAILURE_COUNT ).increment ();
849- mlStats .getStat (MLNodeLevelStat .ML_NODE_TOTAL_FAILURE_COUNT ).increment ();
842+ mlStats .getStat (MLNodeLevelStat .ML_FAILURE_COUNT ).increment ();
850843 }
851844 removeModel (modelId );
852845 listener .onFailure (e );
@@ -855,7 +848,7 @@ private void handleDeployModelException(String modelId, FunctionName functionNam
855848 private void setupPredictable (String modelId , MLModel mlModel , Map <String , Object > params ) {
856849 Predictable predictable = mlEngine .deploy (mlModel , params );
857850 modelCacheHelper .setPredictor (modelId , predictable );
858- mlStats .getStat (MLNodeLevelStat .ML_NODE_TOTAL_MODEL_COUNT ).increment ();
851+ mlStats .getStat (MLNodeLevelStat .ML_DEPLOYED_MODEL_COUNT ).increment ();
859852 modelCacheHelper .setModelState (modelId , MLModelState .DEPLOYED );
860853 }
861854
@@ -1056,8 +1049,8 @@ public synchronized Map<String, String> undeployModel(String[] modelIds) {
10561049 for (String modelId : modelIds ) {
10571050 if (modelCacheHelper .isModelDeployed (modelId )) {
10581051 modelUndeployStatus .put (modelId , UNDEPLOYED );
1059- mlStats .getStat (MLNodeLevelStat .ML_NODE_TOTAL_MODEL_COUNT ).decrement ();
1060- mlStats .getStat (MLNodeLevelStat .ML_NODE_TOTAL_REQUEST_COUNT ).increment ();
1052+ mlStats .getStat (MLNodeLevelStat .ML_DEPLOYED_MODEL_COUNT ).decrement ();
1053+ mlStats .getStat (MLNodeLevelStat .ML_REQUEST_COUNT ).increment ();
10611054 mlStats
10621055 .createCounterStatIfAbsent (getModelFunctionName (modelId ), ActionName .UNDEPLOY , ML_ACTION_REQUEST_COUNT )
10631056 .increment ();
@@ -1070,7 +1063,7 @@ public synchronized Map<String, String> undeployModel(String[] modelIds) {
10701063 log .debug ("undeploy all models {}" , Arrays .toString (getLocalDeployedModels ()));
10711064 for (String modelId : getLocalDeployedModels ()) {
10721065 modelUndeployStatus .put (modelId , UNDEPLOYED );
1073- mlStats .getStat (MLNodeLevelStat .ML_NODE_TOTAL_MODEL_COUNT ).decrement ();
1066+ mlStats .getStat (MLNodeLevelStat .ML_DEPLOYED_MODEL_COUNT ).decrement ();
10741067 mlStats .createCounterStatIfAbsent (getModelFunctionName (modelId ), ActionName .UNDEPLOY , ML_ACTION_REQUEST_COUNT ).increment ();
10751068 removeModel (modelId );
10761069 }
0 commit comments