szetszwo commented on code in PR #9995:
URL: https://github.com/apache/ozone/pull/9995#discussion_r3005073132


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMHAInvocationHandler.java:
##########
@@ -36,23 +36,32 @@
  * InvocationHandler which checks for {@link Replicate} annotation and
  * dispatches the request to Ratis Server.
  */
-public class SCMHAInvocationHandler implements InvocationHandler {
+public class SCMHAInvocationHandler<T> implements InvocationHandler {
 
   private static final Logger LOG = LoggerFactory
       .getLogger(SCMHAInvocationHandler.class);
 
   private final RequestType requestType;
-  private final Object localHandler;
+  private final T localHandler;
   private final SCMRatisServer ratisHandler;
+  private final SCMHAInvoker<T> localInvoker;

Review Comment:
   Let's call it invoker.  We will use it also for invokeRatisClient and 
invokeRatisServer later.



##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMRatisServer.java:
##########
@@ -72,10 +72,22 @@ SCMRatisResponse submitRequest(SCMRatisRequest request)
   RaftPeerId getLeaderId();
 
   default <T> T getProxyHandler(final RequestType type, final Class<T> intf, 
final T impl) {
-    final SCMHAInvocationHandler invocationHandler =
-        new SCMHAInvocationHandler(type, impl, this);
+    final SCMHAInvocationHandler<T> invocationHandler =
+        new SCMHAInvocationHandler<>(type, impl, this);
     return intf.cast(Proxy.newProxyInstance(getClass().getClassLoader(),
         new Class<?>[] {intf}, invocationHandler));
   }
 
+  default <T> T getProxyHandler(final RequestType type,

Review Comment:
   Add:
   ```java
     default <T> T getProxyHandler(ScmInvoker<T> invoker) {
       return getProxyHandler(invoker.getType(), invoker.getApi(), 
invoker.getImpl(), invoker);
     }
   ```



##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMHAInvocationHandler.java:
##########
@@ -36,23 +36,32 @@
  * InvocationHandler which checks for {@link Replicate} annotation and
  * dispatches the request to Ratis Server.
  */
-public class SCMHAInvocationHandler implements InvocationHandler {
+public class SCMHAInvocationHandler<T> implements InvocationHandler {

Review Comment:
   Remove `<T>`.



##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMHAInvoker.java:
##########
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hdds.scm.ha;
+
+import java.lang.reflect.Method;
+
+/**
+ * Invokes methods on a handler without using reflection.
+ */
+public interface SCMHAInvoker<T> {
+  Object invoke(T handler, Method method, Object[] args) throws Exception;

Review Comment:
   - Rename to `invoke` to `invokeLocal`.
   - Remove `handler`.
   - Rename `method` to `methodName`.
   ```java
     Object invokeLocal(String methodName, Object[] args) throws Exception;
   ```



##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMHAInvoker.java:
##########
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hdds.scm.ha;
+
+import java.lang.reflect.Method;
+
+/**
+ * Invokes methods on a handler without using reflection.
+ */
+public interface SCMHAInvoker<T> {

Review Comment:
   Let's simply call it `ScmInvoker` and add the following methods:
   ```java
     RequestType getType();
   
     Class<T> getApi();
   
     T getImpl();
   ```



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