4545import java .util .stream .Collectors ;
4646import java .util .stream .IntStream ;
4747import org .apache .hadoop .hdds .scm .metadata .Replicate ;
48+ import org .apache .ratis .protocol .Message ;
4849import org .apache .ratis .util .Preconditions ;
4950import org .apache .ratis .util .UncheckedAutoCloseable ;
5051
@@ -69,7 +70,7 @@ public final class ScmInvokerCodeGenerator {
6970 static final DeclaredMethod INVOKE_LOCAL = new DeclaredMethod ("invokeLocal" ,
7071 new Class []{String .class , Object [].class },
7172 new String []{"methodName" , "p" },
72- Object .class ,
73+ Message .class ,
7374 new Class <?>[]{Exception .class });
7475
7576 private final Class <?> api ;
@@ -359,9 +360,11 @@ void printCase(Method apiMethod, String actualParameter, AtomicInteger argCount)
359360 }
360361 if (apiMethod .getReturnType () == void .class ) {
361362 println ("getImpl().%s(%s);" , apiMethod .getName (), b );
362- println ("return null ;" );
363+ println ("return Message.EMPTY ;" );
363364 } else {
364- println ("return getImpl().%s(%s);" , apiMethod .getName (), b );
365+ println ("returnType = %s.class;" , getClassname (apiMethod .getReturnType ()));
366+ println ("returnValue = getImpl().%s(%s);" , apiMethod .getName (), b );
367+ println ("break;" );
365368 }
366369 }
367370 println ();
@@ -390,7 +393,11 @@ void printInvokeMethod(DeclaredMethod method) {
390393 println ("@Override" );
391394 printf (method .getSignature ());
392395 try (UncheckedAutoCloseable ignored = printScope ()) {
396+ println ("final Class<?> returnType;" );
397+ println ("final Object returnValue;" );
393398 printSwitch (method );
399+ println ();
400+ println ("return SCMRatisResponse.encode(returnValue, returnType);" );
394401 }
395402 }
396403
0 commit comments