7
7
8
8
package org .elasticsearch .xpack .ml .action ;
9
9
10
+ import org .apache .logging .log4j .LogManager ;
11
+ import org .apache .logging .log4j .Logger ;
10
12
import org .elasticsearch .ElasticsearchStatusException ;
11
13
import org .elasticsearch .action .ActionListener ;
12
14
import org .elasticsearch .action .FailedNodeException ;
32
34
33
35
import java .util .List ;
34
36
37
+ import static org .elasticsearch .core .Strings .format ;
38
+
35
39
public class TransportInferTrainedModelDeploymentAction extends TransportTasksAction <
36
40
TrainedModelDeploymentTask ,
37
41
InferTrainedModelDeploymentAction .Request ,
38
42
InferTrainedModelDeploymentAction .Response ,
39
43
InferTrainedModelDeploymentAction .Response > {
40
44
45
+ private static final Logger logger = LogManager .getLogger (TransportInferTrainedModelDeploymentAction .class );
46
+
41
47
private final TrainedModelProvider provider ;
42
48
43
49
@ Inject
@@ -94,6 +100,7 @@ protected void doExecute(
94
100
listener .onFailure (ExceptionsHelper .conflictStatusException (message ));
95
101
return ;
96
102
}
103
+ logger .trace (() -> format ("[%s] selecting node from routing table: %s" , assignment .getModelId (), assignment .getNodeRoutingTable ()));
97
104
String [] randomRunningNode = assignment .getStartedNodes ();
98
105
if (randomRunningNode .length == 0 ) {
99
106
String message = "Trained model [" + deploymentId + "] is not allocated to any nodes" ;
@@ -102,6 +109,7 @@ protected void doExecute(
102
109
}
103
110
// TODO Do better routing for inference calls
104
111
int nodeIndex = Randomness .get ().nextInt (randomRunningNode .length );
112
+ logger .trace (() -> format ("[%s] selected node [%s]" , assignment .getModelId (), randomRunningNode [nodeIndex ]));
105
113
request .setNodes (randomRunningNode [nodeIndex ]);
106
114
super .doExecute (task , request , listener );
107
115
}
@@ -118,6 +126,7 @@ protected InferTrainedModelDeploymentAction.Response newResponse(
118
126
} else if (failedNodeExceptions .isEmpty () == false ) {
119
127
throw org .elasticsearch .ExceptionsHelper .convertToElastic (failedNodeExceptions .get (0 ));
120
128
} else if (tasks .isEmpty ()) {
129
+ logger .trace (() -> format ("[%s] unable to find deployment task for inference" , request .getDeploymentId ()));
121
130
throw new ElasticsearchStatusException (
122
131
"[{}] unable to find deployment task for inference please stop and start the deployment or try again momentarily" ,
123
132
RestStatus .NOT_FOUND ,
0 commit comments