jianghuazhu commented on code in PR #6886:
URL: https://github.com/apache/ozone/pull/6886#discussion_r1685454748
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/states/datanode/RunningDatanodeState.java:
##########
@@ -173,11 +118,32 @@ public void
setExecutorCompletionService(ExecutorCompletionService e) {
private Callable<EndPointStates> getEndPointTask(
EndpointStateMachine endpoint) {
- if (endpointTasks.containsKey(endpoint)) {
- return endpointTasks.get(endpoint).get(endpoint.getState());
- } else {
- throw new IllegalArgumentException("Illegal endpoint: " + endpoint);
+ Callable<EndPointStates> endpointTask = null;
+ for (EndpointStateMachine endpointStateMachine :
connectionManager.getValues()) {
+ if
(endpointStateMachine.getAddressString().equals(endpoint.getAddressString())) {
+ if (endpoint.getState().getValue() ==
EndPointStates.GETVERSION.getValue()) {
+ endpointTask = new VersionEndpointTask(endpoint, conf,
+ context.getParent().getContainer());
+ } else if (endpoint.getState().getValue() ==
EndPointStates.REGISTER.getValue()) {
+ endpointTask = RegisterEndpointTask.newBuilder()
+ .setConfig(conf)
+ .setEndpointStateMachine(endpoint)
+ .setContext(context)
+ .setDatanodeDetails(context.getParent().getDatanodeDetails())
+ .setOzoneContainer(context.getParent().getContainer())
+ .build();
+ } else if (endpoint.getState().getValue() ==
EndPointStates.HEARTBEAT.getValue()) {
+ endpointTask = HeartbeatEndpointTask.newBuilder()
+ .setConfig(conf)
+ .setEndpointStateMachine(endpoint)
+ .setDatanodeDetails(context.getParent().getDatanodeDetails())
+ .setContext(context)
+ .build();
+ }
Review Comment:
Thanks @szetszwo .
There are two reasons for this:
1. If endpointTasks is kept and initialized once, unfortunately, some CI
fail.
2. If endpointTasks is created each time execute is executed, a
VersionEndpointTask, RegisterEndpointTask, and HeartbeatEndpointTask are
created. However, HeartbeatEndpointTask is more often used, so it can be
created based on the endpoint state, which is less expensive.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]