szetszwo commented on code in PR #6886:
URL: https://github.com/apache/ozone/pull/6886#discussion_r1685668456
##########
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()) {
Review Comment:
Use switch-case instead.
##########
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) {
Review Comment:
Let's rename it to `buildEndPointTask`.
```java
private Callable<EndPointStates> buildEndPointTask(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();
default:
return null;
}
}
```
##########
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())) {
Review Comment:
This for loop and the if-statement are not needed since
`endpointStateMachine` is not used to build the task.
--
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]