func (s *RaftServer) applyLogs() {
	for i := s.volatileInfo.LastApplied + 1; i <= s.volatileInfo.CommitIndex; i++ {
		countlog.Info(fmt.Sprintf("apply log %d", i))
		if logToApply, err := s.stableInfo.Logs.GetLogEntry(i); err == nil {
			if dbErr := s.dbStore.Set(logToApply.Command.Key, logToApply.Command.Value); dbErr == nil {
				countlog.Info(fmt.Sprintf("apply log %d [%s] success", i, logToApply.Command.String()))
				s.volatileInfo.LastApplied++
			} else {
				countlog.Error(fmt.Sprintf("applyLogs fails to DBSet %s: %s", logToApply.Command, err.Error()))
				break
			}
		} else {
			countlog.Error(fmt.Sprintf("applyLogs fails to GetLogEntry %d: %s", i, err.Error()))
			break
		}
	}
}
// applyLogs execute logs from last applied index to last log index
applyLogs execute logs from last applied index to last log index
// applyLogs execute logs from last applied index to last log index
func (s *RaftServer) applyLogs() {
	for i := s.volatileInfo.LastApplied + 1; i <= s.volatileInfo.CommitIndex; i++ {
		countlog.Info(fmt.Sprintf("apply log %d", i))
		if logToApply, err := s.stableInfo.Logs.GetLogEntry(i); err == nil {
			if dbErr := s.dbStore.Set(logToApply.Command.Key, logToApply.Command.Value); dbErr == nil {
				countlog.Info(fmt.Sprintf("apply log %d [%s] success", i, logToApply.Command.String()))
				s.volatileInfo.LastApplied++
			} else {
				countlog.Error(fmt.Sprintf("applyLogs fails to DBSet %s: %s", logToApply.Command, err.Error()))
				break
			}
		} else {
			countlog.Error(fmt.Sprintf("applyLogs fails to GetLogEntry %d: %s", i, err.Error()))
			break
		}
	}
}
func ( s * RaftServer ) applyLogs ( ) { for i := s . volatileInfo . LastApplied + 1 ; i <= s . volatileInfo . CommitIndex ; i ++ { countlog . Info ( fmt . Sprintf ( " " , i ) ) if logToApply , err := s . stableInfo . Logs . GetLogEntry ( i ) ; err == nil { if dbErr := s . dbStore . Set ( logToApply . Command . Key , logToApply . Command . Value ) ; dbErr == nil { countlog . Info ( fmt . Sprintf ( " " , i , logToApply . Command . String ( ) ) ) s . volatileInfo . LastApplied ++ } else { countlog . Error ( fmt . Sprintf ( " " , logToApply . Command , err . Error ( ) ) ) break } } else { countlog . Error ( fmt . Sprintf ( " " , i , err . Error ( ) ) ) break } } }
applyLogs execute logs from last applied index to last log index
applyLogs execute logs from last applied index to last log index