adoroszlai 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_r370225721
 
 

 ##########
 File path: 
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/states/datanode/RunningDatanodeState.java
 ##########
 @@ -49,14 +52,62 @@
   private final SCMConnectionManager connectionManager;
   private final Configuration conf;
   private final StateContext context;
-  private CompletionService<EndpointStateMachine.EndPointStates> ecs;
+  private CompletionService<EndPointStates> ecs;
+  /** Cache the end point task per end point per end point state. */
+  private Map<String, Map<EndPointStates,
+      Callable<EndPointStates>>> endpointTasks;
 
   public RunningDatanodeState(Configuration conf,
       SCMConnectionManager connectionManager,
       StateContext context) {
     this.connectionManager = connectionManager;
     this.conf = conf;
     this.context = context;
+    initEndPointTask();
+  }
+
+  /**
+   * Initialize end point tasks corresponding to each end point,
+   * each end point state.
+   */
+  private void initEndPointTask() {
+    endpointTasks = new HashMap<String, Map<EndPointStates,
+        Callable<EndPointStates>>>();
+    for (EndpointStateMachine endpoint : connectionManager.getValues()) {
+      Map<EndPointStates, Callable<EndPointStates>> endpointTaskForState
+          = new HashMap<EndPointStates, Callable<EndPointStates>>();
+
+      for (EndPointStates state : EndPointStates.values()) {
+        Callable<EndPointStates> endPointTask = null;
+        switch (endpoint.getState()) {
 
 Review comment:
   Shouldn't this be `state` instead of `endpoint.getState()`?  Assuming the 
endpoint state is constant during initialization, wouldn't this create several 
instances of the same type (eg. `RegisterEndpointTask`) for each endpoint?

----------------------------------------------------------------
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