@@ -212,7 +212,7 @@ public MLModelManager(
212
212
public void registerModelMeta (MLRegisterModelMetaInput mlRegisterModelMetaInput , ActionListener <String > listener ) {
213
213
try {
214
214
FunctionName functionName = mlRegisterModelMetaInput .getFunctionName ();
215
- mlStats .getStat (MLNodeLevelStat .ML_NODE_TOTAL_REQUEST_COUNT ).increment ();
215
+ mlStats .getStat (MLNodeLevelStat .ML_REQUEST_COUNT ).increment ();
216
216
mlStats .createCounterStatIfAbsent (functionName , REGISTER , ML_ACTION_REQUEST_COUNT ).increment ();
217
217
String modelGroupId = mlRegisterModelMetaInput .getModelGroupId ();
218
218
if (Strings .isBlank (modelGroupId )) {
@@ -322,9 +322,9 @@ public void registerMLModel(MLRegisterModelInput registerModelInput, MLTask mlTa
322
322
323
323
checkAndAddRunningTask (mlTask , maxRegisterTasksPerNode );
324
324
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 ();
327
326
mlStats .createCounterStatIfAbsent (mlTask .getFunctionName (), REGISTER , ML_ACTION_REQUEST_COUNT ).increment ();
327
+ mlStats .getStat (MLNodeLevelStat .ML_EXECUTING_TASK_COUNT ).increment ();
328
328
329
329
String modelGroupId = registerModelInput .getModelGroupId ();
330
330
GetRequest getModelGroupRequest = new GetRequest (ML_MODEL_GROUP_INDEX ).id (modelGroupId );
@@ -384,17 +384,14 @@ public void registerMLModel(MLRegisterModelInput registerModelInput, MLTask mlTa
384
384
} catch (Exception e ) {
385
385
handleException (registerModelInput .getFunctionName (), mlTask .getTaskId (), e );
386
386
} finally {
387
- mlStats .getStat (MLNodeLevelStat .ML_NODE_EXECUTING_TASK_COUNT ). increment ();
387
+ mlStats .getStat (MLNodeLevelStat .ML_EXECUTING_TASK_COUNT ). decrement ();
388
388
}
389
389
}
390
390
391
391
private void indexRemoteModel (MLRegisterModelInput registerModelInput , MLTask mlTask , String modelVersion ) {
392
392
String taskId = mlTask .getTaskId ();
393
393
FunctionName functionName = mlTask .getFunctionName ();
394
394
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 ();
398
395
399
396
String modelName = registerModelInput .getModelName ();
400
397
String version = modelVersion == null ? registerModelInput .getVersion () : modelVersion ;
@@ -443,8 +440,6 @@ private void indexRemoteModel(MLRegisterModelInput registerModelInput, MLTask ml
443
440
} catch (Exception e ) {
444
441
logException ("Failed to upload model" , e , log );
445
442
handleException (functionName , taskId , e );
446
- } finally {
447
- mlStats .getStat (MLNodeLevelStat .ML_NODE_EXECUTING_TASK_COUNT ).increment ();
448
443
}
449
444
}
450
445
@@ -462,9 +457,6 @@ private void registerModelFromUrl(MLRegisterModelInput registerModelInput, MLTas
462
457
String taskId = mlTask .getTaskId ();
463
458
FunctionName functionName = mlTask .getFunctionName ();
464
459
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 ();
468
460
String modelName = registerModelInput .getModelName ();
469
461
String version = modelVersion == null ? registerModelInput .getVersion () : modelVersion ;
470
462
String modelGroupId = registerModelInput .getModelGroupId ();
@@ -509,8 +501,6 @@ private void registerModelFromUrl(MLRegisterModelInput registerModelInput, MLTas
509
501
} catch (Exception e ) {
510
502
logException ("Failed to register model" , e , log );
511
503
handleException (functionName , taskId , e );
512
- } finally {
513
- mlStats .getStat (MLNodeLevelStat .ML_NODE_EXECUTING_TASK_COUNT ).increment ();
514
504
}
515
505
}
516
506
@@ -693,7 +683,7 @@ private void handleException(FunctionName functionName, String taskId, Exception
693
683
&& !(e instanceof MLResourceNotFoundException )
694
684
&& !(e instanceof IllegalArgumentException )) {
695
685
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 ();
697
687
}
698
688
Map <String , Object > updated = ImmutableMap .of (ERROR_FIELD , MLExceptionUtils .getRootCauseMessage (e ), STATE_FIELD , FAILED );
699
689
mlTaskManager .updateMLTask (taskId , updated , TIMEOUT_IN_MILLIS , true );
@@ -718,7 +708,8 @@ public void deployModel(
718
708
ActionListener <String > listener
719
709
) {
720
710
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 ();
722
713
List <String > workerNodes = mlTask .getWorkerNodes ();
723
714
if (modelCacheHelper .isModelDeployed (modelId )) {
724
715
if (workerNodes != null && workerNodes .size () > 0 ) {
@@ -800,7 +791,7 @@ public void deployModel(
800
791
MLExecutable mlExecutable = mlEngine .deployExecute (mlModel , params );
801
792
try {
802
793
modelCacheHelper .setMLExecutor (modelId , mlExecutable );
803
- mlStats .getStat (MLNodeLevelStat .ML_NODE_TOTAL_MODEL_COUNT ).increment ();
794
+ mlStats .getStat (MLNodeLevelStat .ML_DEPLOYED_MODEL_COUNT ).increment ();
804
795
modelCacheHelper .setModelState (modelId , MLModelState .DEPLOYED );
805
796
listener .onResponse ("successful" );
806
797
} catch (Exception e ) {
@@ -813,7 +804,7 @@ public void deployModel(
813
804
Predictable predictable = mlEngine .deploy (mlModel , params );
814
805
try {
815
806
modelCacheHelper .setPredictor (modelId , predictable );
816
- mlStats .getStat (MLNodeLevelStat .ML_NODE_TOTAL_MODEL_COUNT ).increment ();
807
+ mlStats .getStat (MLNodeLevelStat .ML_DEPLOYED_MODEL_COUNT ).increment ();
817
808
modelCacheHelper .setModelState (modelId , MLModelState .DEPLOYED );
818
809
Long modelContentSizeInBytes = mlModel .getModelContentSizeInBytes ();
819
810
long contentSize = modelContentSizeInBytes == null
@@ -837,6 +828,8 @@ public void deployModel(
837
828
})));
838
829
} catch (Exception e ) {
839
830
handleDeployModelException (modelId , functionName , listener , e );
831
+ } finally {
832
+ mlStats .getStat (MLNodeLevelStat .ML_EXECUTING_TASK_COUNT ).decrement ();
840
833
}
841
834
}
842
835
@@ -846,7 +839,7 @@ private void handleDeployModelException(String modelId, FunctionName functionNam
846
839
&& !(e instanceof MLResourceNotFoundException )
847
840
&& !(e instanceof IllegalArgumentException )) {
848
841
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 ();
850
843
}
851
844
removeModel (modelId );
852
845
listener .onFailure (e );
@@ -855,7 +848,7 @@ private void handleDeployModelException(String modelId, FunctionName functionNam
855
848
private void setupPredictable (String modelId , MLModel mlModel , Map <String , Object > params ) {
856
849
Predictable predictable = mlEngine .deploy (mlModel , params );
857
850
modelCacheHelper .setPredictor (modelId , predictable );
858
- mlStats .getStat (MLNodeLevelStat .ML_NODE_TOTAL_MODEL_COUNT ).increment ();
851
+ mlStats .getStat (MLNodeLevelStat .ML_DEPLOYED_MODEL_COUNT ).increment ();
859
852
modelCacheHelper .setModelState (modelId , MLModelState .DEPLOYED );
860
853
}
861
854
@@ -1056,8 +1049,8 @@ public synchronized Map<String, String> undeployModel(String[] modelIds) {
1056
1049
for (String modelId : modelIds ) {
1057
1050
if (modelCacheHelper .isModelDeployed (modelId )) {
1058
1051
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 ();
1061
1054
mlStats
1062
1055
.createCounterStatIfAbsent (getModelFunctionName (modelId ), ActionName .UNDEPLOY , ML_ACTION_REQUEST_COUNT )
1063
1056
.increment ();
@@ -1070,7 +1063,7 @@ public synchronized Map<String, String> undeployModel(String[] modelIds) {
1070
1063
log .debug ("undeploy all models {}" , Arrays .toString (getLocalDeployedModels ()));
1071
1064
for (String modelId : getLocalDeployedModels ()) {
1072
1065
modelUndeployStatus .put (modelId , UNDEPLOYED );
1073
- mlStats .getStat (MLNodeLevelStat .ML_NODE_TOTAL_MODEL_COUNT ).decrement ();
1066
+ mlStats .getStat (MLNodeLevelStat .ML_DEPLOYED_MODEL_COUNT ).decrement ();
1074
1067
mlStats .createCounterStatIfAbsent (getModelFunctionName (modelId ), ActionName .UNDEPLOY , ML_ACTION_REQUEST_COUNT ).increment ();
1075
1068
removeModel (modelId );
1076
1069
}
0 commit comments