Skip to content

Commit faf4dfc

Browse files
committed
HDDS-15053. Update ScmInvokerCodeGenerator for generating the latest invokeLocal
1 parent 99b53f4 commit faf4dfc

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/invoker/ScmInvokerCodeGenerator.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import java.util.stream.Collectors;
4646
import java.util.stream.IntStream;
4747
import org.apache.hadoop.hdds.scm.metadata.Replicate;
48+
import org.apache.ratis.protocol.Message;
4849
import org.apache.ratis.util.Preconditions;
4950
import 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

Comments
 (0)