You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozone.apache.org by jh...@apache.org on 2026/05/01 02:23:11 UTC

(ozone) 01/02: HDDS-15053. Update ScmInvokerCodeGenerator for generating the latest invokeLocal

This is an automated email from the ASF dual-hosted git repository.

Russole pushed a commit to branch HDDS-15053
in repository https://gitbox.apache.org/repos/asf/ozone.git

commit faf4dfcf07f2b068efb94f89b9b7259cb6be98e9
Author: Russole <85...@gmail.com>
AuthorDate: Fri May 1 08:07:10 2026 +0800

    HDDS-15053. Update ScmInvokerCodeGenerator for generating the latest invokeLocal
---
 .../hadoop/hdds/scm/ha/invoker/ScmInvokerCodeGenerator.java | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/invoker/ScmInvokerCodeGenerator.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/invoker/ScmInvokerCodeGenerator.java
index e9898b9532d..a99364bc99b 100644
--- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/invoker/ScmInvokerCodeGenerator.java
+++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/invoker/ScmInvokerCodeGenerator.java
@@ -45,6 +45,7 @@
 import java.util.stream.Collectors;
 import java.util.stream.IntStream;
 import org.apache.hadoop.hdds.scm.metadata.Replicate;
+import org.apache.ratis.protocol.Message;
 import org.apache.ratis.util.Preconditions;
 import org.apache.ratis.util.UncheckedAutoCloseable;
 
@@ -69,7 +70,7 @@ public final class ScmInvokerCodeGenerator {
   static final DeclaredMethod INVOKE_LOCAL = new DeclaredMethod("invokeLocal",
       new Class[]{String.class, Object[].class},
       new String[]{"methodName", "p"},
-      Object.class,
+      Message.class,
       new Class<?>[]{Exception.class});
 
   private final Class<?> api;
@@ -359,9 +360,11 @@ void printCase(Method apiMethod, String actualParameter, AtomicInteger argCount)
       }
       if (apiMethod.getReturnType() == void.class) {
         println("getImpl().%s(%s);", apiMethod.getName(), b);
-        println("return null;");
+        println("return Message.EMPTY;");
       } else {
-        println("return getImpl().%s(%s);", apiMethod.getName(), b);
+        println("returnType = %s.class;", getClassname(apiMethod.getReturnType()));
+        println("returnValue = getImpl().%s(%s);", apiMethod.getName(), b);
+        println("break;");
       }
     }
     println();
@@ -390,7 +393,11 @@ void printInvokeMethod(DeclaredMethod method) {
     println("@Override");
     printf(method.getSignature());
     try (UncheckedAutoCloseable ignored = printScope()) {
+      println("final Class<?> returnType;");
+      println("final Object returnValue;");
       printSwitch(method);
+      println();
+      println("return SCMRatisResponse.encode(returnValue, returnType);");
     }
   }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@ozone.apache.org
For additional commands, e-mail: commits-help@ozone.apache.org