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

Glen Geng updated HDDS-4059:
----------------------------
    Description: 
 applyTransaction should not call trx.getClientRequest(), since client request 
will not be replicated from leader to follower. 
{code:java}
SCMStateMachine
  applyTransaction()
    final SCMRatisRequest request = SCMRatisRequest.decode(
        trx.getClientRequest().getMessage());{code}
 

instead, we should call trx.getStateMachineLogEntry()
{code:java}
SCMStateMachine
  applyTransaction()
    final SCMRatisRequest request = SCMRatisRequest.decode(
        Message.valueOf(trx.getStateMachineLogEntry().getLogData()));{code}
 

since content of client request will be injected to StateMachineEntryProto at 
leader,
{code:java}
static StateMachineLogEntryProto toStateMachineLogEntryProto(
    RaftClientRequest request, ByteString logData, ByteString stateMachineData) 
{
  if (logData == null) {
    logData = request.getMessage().getContent();
  }
  return toStateMachineLogEntryProto(request.getClientId(), 
request.getCallId(), logData, stateMachineData);
}
{code}
 

and extracted from log entry at follower.
{code:java}
/**
 * Construct a {@link TransactionContext} from a {@link LogEntryProto}.
 * Used by followers for applying committed entries to the state machine.
 * @param logEntry the log entry to be applied
 */
public TransactionContextImpl(RaftPeerRole serverRole, StateMachine 
stateMachine, LogEntryProto logEntry) {
  this(serverRole, stateMachine);
  this.logEntry = logEntry;
  this.smLogEntryProto = logEntry.getStateMachineLogEntry();
}
{code}
 

  was:
 applyTransaction should not call trx.getClientRequest(), since client request 
will not be replicated from leader to follower. 
{code:java}
SCMStateMachine
  applyTransaction()
    final SCMRatisRequest request = SCMRatisRequest.decode(
        trx.getClientRequest().getMessage());{code}
 

instead, we should call trx.getStateMachineLogEntry()
{code:java}
SCMStateMachine
  applyTransaction()
    final SCMRatisRequest request = SCMRatisRequest.decode(
        Message.valueOf(trx.getStateMachineLogEntry().getLogData()));{code}
 

since content of client request will be injected to StateMachineEntryProto at 
leader.
{code:java}
static StateMachineLogEntryProto toStateMachineLogEntryProto(
    RaftClientRequest request, ByteString logData, ByteString stateMachineData) 
{
  if (logData == null) {
    logData = request.getMessage().getContent();
  }
  return toStateMachineLogEntryProto(request.getClientId(), 
request.getCallId(), logData, stateMachineData);
}
{code}
 

and extracted from log entry at follower.
{code:java}
/**
 * Construct a {@link TransactionContext} from a {@link LogEntryProto}.
 * Used by followers for applying committed entries to the state machine.
 * @param logEntry the log entry to be applied
 */
public TransactionContextImpl(RaftPeerRole serverRole, StateMachine 
stateMachine, LogEntryProto logEntry) {
  this(serverRole, stateMachine);
  this.logEntry = logEntry;
  this.smLogEntryProto = logEntry.getStateMachineLogEntry();
}
{code}
 


> SCMStateMachine::applyTransaction() should not invoke 
> TransactionContext.getClientRequest()
> -------------------------------------------------------------------------------------------
>
>                 Key: HDDS-4059
>                 URL: https://issues.apache.org/jira/browse/HDDS-4059
>             Project: Hadoop Distributed Data Store
>          Issue Type: Sub-task
>          Components: SCM
>            Reporter: Glen Geng
>            Assignee: Glen Geng
>            Priority: Major
>
>  applyTransaction should not call trx.getClientRequest(), since client 
> request will not be replicated from leader to follower. 
> {code:java}
> SCMStateMachine
>   applyTransaction()
>     final SCMRatisRequest request = SCMRatisRequest.decode(
>         trx.getClientRequest().getMessage());{code}
>  
> instead, we should call trx.getStateMachineLogEntry()
> {code:java}
> SCMStateMachine
>   applyTransaction()
>     final SCMRatisRequest request = SCMRatisRequest.decode(
>         Message.valueOf(trx.getStateMachineLogEntry().getLogData()));{code}
>  
> since content of client request will be injected to StateMachineEntryProto at 
> leader,
> {code:java}
> static StateMachineLogEntryProto toStateMachineLogEntryProto(
>     RaftClientRequest request, ByteString logData, ByteString 
> stateMachineData) {
>   if (logData == null) {
>     logData = request.getMessage().getContent();
>   }
>   return toStateMachineLogEntryProto(request.getClientId(), 
> request.getCallId(), logData, stateMachineData);
> }
> {code}
>  
> and extracted from log entry at follower.
> {code:java}
> /**
>  * Construct a {@link TransactionContext} from a {@link LogEntryProto}.
>  * Used by followers for applying committed entries to the state machine.
>  * @param logEntry the log entry to be applied
>  */
> public TransactionContextImpl(RaftPeerRole serverRole, StateMachine 
> stateMachine, LogEntryProto logEntry) {
>   this(serverRole, stateMachine);
>   this.logEntry = logEntry;
>   this.smLogEntryProto = logEntry.getStateMachineLogEntry();
> }
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: ozone-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: ozone-issues-h...@hadoop.apache.org

Reply via email to