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_r370227896
##########
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:
Can you please explain why a string-based map is better than using the
endpoint itself as a key?
----------------------------------------------------------------
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]