JacksonYao287 commented on pull request #2079:
URL: https://github.com/apache/ozone/pull/2079#issuecomment-806785868
> MockRatisServer
> > > Check `ReconStorageContainerManagerFacade`, in the test, the non ratis
id gen can use below `MockSCMHAManager`
> > > ```
> > > this.scmhaManager = MockSCMHAManager.getInstance(
> > > true, new SCMDBTransactionBufferImpl());
> > > ```
> >
> >
> > @GlenGeng
> > the constructor of MockSCMHAManager is below
> > ```
> > private MockSCMHAManager(boolean isLeader, DBTransactionBuffer buffer) {
> > this.ratisServer = new MockRatisServer();
> > this.isLeader = isLeader;
> > this.transactionBuffer = buffer;
> > }
> > ```
> >
> >
> > 'this.ratisServer' will always be not null and it is not depend on
whether 'isLeader' is true.
> > so , after the above method is called , the 'ratisServer' in
MockSCMHAManager will not be null.
> > the stateManager constructor in SequenceIdGenerator is below
> > ```
> > this.stateManager = new StateManagerHAImpl.Builder()
> > .setRatisServer(scmhaManager.getRatisServer())
> > .setDBTransactionBuffer(scmhaManager.getDBTransactionBuffer())
> > .setSequenceIdTable(sequenceIdTable)
> > .build();
> > ```
> >
> >
> > so here,the ‘ratisServer’ in stateManager will not be null and
> > ```
> > final SCMHAInvocationHandler invocationHandler
> > = new SCMHAInvocationHandler(SEQUENCE_ID, impl, ratisServer);
> > ```
> >
> >
> > so,the ratisHandler below will not be null
> > ```
> > public Object invoke(final Object proxy, final Method method,
> > final Object[] args) throws Throwable {
> > try {
> > long startTime = Time.monotonicNow();
> > final Object result =
> > ratisHandler != null &&
method.isAnnotationPresent(Replicate.class) ?
> > invokeRatis(method, args) :
> > invokeLocal(method, args);
> > LOG.debug("Call: {} took {} ms", method, Time.monotonicNow() -
startTime);
> > return result;
> > } catch(InvocationTargetException iEx) {
> > throw iEx.getCause();
> > }
> > }
> > ```
> >
> >
> > so , if the 'ratisHandler' is not null and the method is comment with
'@replicate' , 'invokeRatis' will be called。
> > I modifed MockSCMHAManager so that it can build a instance who's
ratisServer is null
> > does this make sense?
>
> Hey Jackson, our design decision is, in HA mode, we just
`SCMRatisServerImpl`, whose `submitRequest` will call RaftServer; in non-HA
mode, or the bypass ratis mode, we use `MockRatisServer`, whose `submitRequest`
bypass ratis.
>
> In both situation, the `@Replicate` annotation, `invokeRatis()` and
`submitRequest()` take effect like always, yet `MockRatisServer` just
transition the call to be a pure in-mem call.
>
> Thus it is fine that the
>
> > the 'ratisHandler' is not null and the method is comment with
'@replicate' , 'invokeRatis' will be called
ok,I see , thanks
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]