public void handle(MessageHandler handler) throws GondolaException, InterruptedException {
switch (type) {
case TYPE_APPEND_ENTRY_REQ:
    boolean cont=handler.appendEntryRequest(this,fromMemberId,term,prevRid.term,prevRid.index,commitIndex,isHeartbeat,entryTerm,buffer,bufferOffset,commandSize,size == overhead[TYPE_APPEND_ENTRY_REQ] + commandSize);
  if (!cont) {
    break;
  }
int pli=prevRid.index;
int bo=bufferOffset;
int cs=commandSize;
int s=overhead[TYPE_APPEND_ENTRY_REQ] + commandSize;
int nc=commandSize > 0 ? 1 : 0;
while (s < size) {
bo+=cs;
cs=(0x0ff & buffer[bo]) << 8 | (0x0ff & buffer[bo + 1]);
bo+=2;
pli+=1;
if (messageTracing) {
tracingInfo=String.format("AE(cterm=%d pterm=%d eterm=%d index=%d ci=%d size=%d) batch(%d)",term,prevRid.term,entryTerm,pli + 1,commitIndex,cs,nc);
}
boolean lastCommand=size == s + cs + 2;
cont=handler.appendEntryRequest(this,fromMemberId,term,prevRid.term,pli,commitIndex,isHeartbeat,entryTerm,buffer,bo,cs,lastCommand);
if (!cont) {
break;
}
nc++;
s+=cs + 2;
}
break;
case TYPE_APPEND_ENTRY_REP:
handler.appendEntryReply(this,fromMemberId,term,mnIndex,success);
break;
case TYPE_REQUEST_VOTE_REQ:
handler.requestVoteRequest(this,fromMemberId,term,isPrevote,prevRid);
break;
case TYPE_REQUEST_VOTE_REP:
handler.requestVoteReply(this,fromMemberId,term,isPrevote,voteGranted);
break;
}
}

public void handle ( MessageHandler handler ) throws GondolaException , InterruptedException { switch ( type ) { case TYPE_APPEND_ENTRY_REQ : boolean cont = handler . appendEntryRequest ( this , fromMemberId , term , prevRid . term , prevRid . index , commitIndex , isHeartbeat , entryTerm , buffer , bufferOffset , commandSize , size == overhead [ TYPE_APPEND_ENTRY_REQ ] + commandSize ) ; if ( ! cont ) { break ; } int pli = prevRid . index ; int bo = bufferOffset ; int cs = commandSize ; int s = overhead [ TYPE_APPEND_ENTRY_REQ ] + commandSize ; int nc = commandSize > 0 ? 1 : 0 ; while ( s < size ) { bo += cs ; cs = ( 0x0ff & buffer [ bo ] ) << 8 | ( 0x0ff & buffer [ bo + 1 ] ) ; bo += 2 ; pli += 1 ; if ( messageTracing ) { tracingInfo = String . format ( "AE(cterm=%d pterm=%d eterm=%d index=%d ci=%d size=%d) batch(%d)" , term , prevRid . term , entryTerm , pli + 1 , commitIndex , cs , nc ) ; } boolean lastCommand = size == s + cs + 2 ; cont = handler . appendEntryRequest ( this , fromMemberId , term , prevRid . term , pli , commitIndex , isHeartbeat , entryTerm , buffer , bo , cs , lastCommand ) ; if ( ! cont ) { break ; } nc ++ ; s += cs + 2 ; } break ; case TYPE_APPEND_ENTRY_REP : handler . appendEntryReply ( this , fromMemberId , term , mnIndex , success ) ; break ; case TYPE_REQUEST_VOTE_REQ : handler . requestVoteRequest ( this , fromMemberId , term , isPrevote , prevRid ) ; break ; case TYPE_REQUEST_VOTE_REP : handler . requestVoteReply ( this , fromMemberId , term , isPrevote , voteGranted ) ; break ; } }
delivers this message to the handler . the caller is responsible for releasing this message after calling this method .
