linyiqun commented on a change in pull request #480: HDDS-2927. Cache EndPoint 
tasks instead of creating them all the time in RunningDatanodeState
URL: https://github.com/apache/hadoop-ozone/pull/480#discussion_r370452693
 
 

 ##########
 File path: 
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/states/datanode/RunningDatanodeState.java
 ##########
 @@ -98,35 +148,14 @@ public void execute(ExecutorService executor) {
       }
     }
   }
-  //TODO : Cache some of these tasks instead of creating them
-  //all the time.
-  private Callable<EndpointStateMachine.EndPointStates>
-      getEndPointTask(EndpointStateMachine endpoint) {
-    switch (endpoint.getState()) {
-    case GETVERSION:
-      return new VersionEndpointTask(endpoint, conf, context.getParent()
-          .getContainer());
-    case REGISTER:
-      return  RegisterEndpointTask.newBuilder()
-          .setConfig(conf)
-          .setEndpointStateMachine(endpoint)
-          .setContext(context)
-          .setDatanodeDetails(context.getParent().getDatanodeDetails())
-          .setOzoneContainer(context.getParent().getContainer())
-          .build();
-    case HEARTBEAT:
-      return HeartbeatEndpointTask.newBuilder()
-          .setConfig(conf)
-          .setEndpointStateMachine(endpoint)
-          .setDatanodeDetails(context.getParent().getDatanodeDetails())
-          .setContext(context)
-          .build();
-    case SHUTDOWN:
-      break;
-    default:
-      throw new IllegalArgumentException("Illegal Argument.");
+
+  private Callable<EndPointStates> getEndPointTask(
+      EndpointStateMachine endpoint) {
+    if (endpointTasks.containsKey(endpoint.toString())) {
+      return endpointTasks.get(endpoint.toString()).get(endpoint.getState());
 
 Review comment:
   I just wan to use a more simple identity to indicate the different  Endpoint 
instance. So I use the endpoint address. But I have updated this to use 
Endpoint itself now.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to