[ 
https://issues.apache.org/jira/browse/HDDS-14886?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Tsz-wo Sze updated HDDS-14886:
------------------------------
    Description: 
SCMHAInvocationHandler and the related classes use reflection to implement 
method calls. Reflection is inefficient and makes the code hard to understand. 
We should avoid it.

More details:
All the handlers has a well defined, fixed interface. However, the current 
approach is
 # Forget the interface and use Object for the handlers.
{code:java}
//SCMStateMachine
  private Map<RequestType, Object> handlers;
{code}
 # Use reflection to invoke method calls in SCMStateMachine.process(..).
 # Use Java Proxy and InvocationHandler to decide whether to invokeLocal, 
invokeRatisServer or invokeRatisClient.

Since all the interfaces/methods/annotations are fixed at compile time, it 
actually does not need any reflections/Proxy/InvocationHandler. For examples,
 - Example: when calling PipelineStateManager.addPipeline(..), we know that it 
needs DIRECT Replicate, we could just use invokeRatisServer instead of using 
reflection to go through Proxy -> SCMHAInvocationHandler ->  invokeRatisServer.

  was:
SCMHAInvocationHandler and the related classes use reflection to implement 
method calls. Reflection is inefficient and makes the code hard to understand. 
We should avoid it.

More details:
All the handlers has a well defined, fixed interface. However, the current 
approach is
 # Forget the interface and use Object for the handlers.
{code:java}
//SCMStateMachine
  private Map<RequestType, Object> handlers;
{code}

 # Use reflection to invoke method calls in SCMStateMachine.process(..).
 # Use Java Proxy and InvocationHandler to decide whether to invokeLocal, 
invokeRatisServer or invokeRatisClient.

Since all the interfaces/methods/annotations are fixed at compile time, it 
actually does not need any reflections/Proxy/InvocationHandler. For examples,
 - Example: when calling PipelineStateManager.addPipeline(..), we know that it 
needs DIRECT Replicate, we could just use invokeRatisServer instead of using 
reflection to go through Proxy -> SCMHAInvocationHandler ->  invokeRatisServer.


> Umbrella: Improve SCMHAInvocationHandler
> ----------------------------------------
>
>                 Key: HDDS-14886
>                 URL: https://issues.apache.org/jira/browse/HDDS-14886
>             Project: Apache Ozone
>          Issue Type: Improvement
>          Components: SCM HA
>            Reporter: Tsz-wo Sze
>            Assignee: Chen-Jheng Sing
>            Priority: Major
>
> SCMHAInvocationHandler and the related classes use reflection to implement 
> method calls. Reflection is inefficient and makes the code hard to 
> understand. We should avoid it.
> More details:
> All the handlers has a well defined, fixed interface. However, the current 
> approach is
>  # Forget the interface and use Object for the handlers.
> {code:java}
> //SCMStateMachine
>   private Map<RequestType, Object> handlers;
> {code}
>  # Use reflection to invoke method calls in SCMStateMachine.process(..).
>  # Use Java Proxy and InvocationHandler to decide whether to invokeLocal, 
> invokeRatisServer or invokeRatisClient.
> Since all the interfaces/methods/annotations are fixed at compile time, it 
> actually does not need any reflections/Proxy/InvocationHandler. For examples,
>  - Example: when calling PipelineStateManager.addPipeline(..), we know that 
> it needs DIRECT Replicate, we could just use invokeRatisServer instead of 
> using reflection to go through Proxy -> SCMHAInvocationHandler ->  
> invokeRatisServer.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to