sreejasahithi commented on code in PR #10079:
URL: https://github.com/apache/ozone/pull/10079#discussion_r3084225443


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMStateMachine.java:
##########
@@ -200,6 +212,24 @@ public static Message process(final SCMRatisRequest 
request, Object handler) thr
     }
   }
 
+  public static Message process(final SCMRatisRequest request,
+      final ScmInvoker<?> invoker) throws Exception {
+
+    if (invoker == null) {
+      throw new IOException("No invoker found for request type "
+          + request.getType());
+    }
+
+    final Object result = invoker.invoke(
+        request.getOperation(),
+        request.getArguments());
+
+    final Class<?> returnType =
+        invoker.getReturnType(request.getOperation(), 
request.getParameterTypes());
+

Review Comment:
   request.getOperation() is called twice here can we call it once store in a 
variable and use that.



##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/invoker/ScmInvokerCodeGenerator.java:
##########
@@ -442,6 +448,73 @@ void printProxyMethod() {
     }
   }
 
+  void printReturnTypeMethod() {
+    println();
+    println("@Override");
+    printf("public Class<?> getReturnType(String methodName, Class<?>[] 
parameterTypes)");
+    try (UncheckedAutoCloseable ignored = printScope()) {
+      printReturnTypeSwitch();
+    }
+  }
+
+  void printReturnTypeSwitch() {
+    printf("switch (methodName)");
+    try (UncheckedAutoCloseable ignored = printScope(true, 0)) {
+      final List<Method> apiMethods = getReturnTypeMethods();
+
+      final List<String> methodNames = apiMethods.stream()
+          .map(Method::getName)
+          .distinct()
+          .sorted()
+          .collect(Collectors.toList());

Review Comment:
   it is already sorted by getReturnTypeMethods()



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

Reply via email to