src/backend/benchmark/logger/logger_workload.cpp
/**
 * @brief writing a simple log file
 */
@brief writing a simple log file
@brief writing a simple log file
bool PrepareLogFile(std::string file_name) {
	auto file_path = GetFilePath(state.log_file_dir, file_name);
	std::ifstream log_file(file_path);
	if (log_file.good()) {
		std::remove(file_path.c_str());
	}
	log_file.close();
	auto& log_manager = logging::LogManager::GetInstance();
	if (log_manager.ContainsFrontendLogger() == true) {
		LOG_ERROR("another logging thread is running now");
		return false;
	}
  Timer<> timer;
  std::thread thread;
  timer.Start();
	if (peloton_logging_mode != LOGGING_TYPE_INVALID) {
	  LOG_INFO("Log path :: %s", file_path.c_str());
	  log_manager.SetLogFileName(file_path);
	  thread = std::thread(&logging::LogManager::StartStandbyMode, &log_manager);
	  log_manager.WaitForModeTransition(LOGGING_STATUS_TYPE_STANDBY, true);
	  log_manager.StartRecoveryMode();
	  log_manager.WaitForModeTransition(LOGGING_STATUS_TYPE_LOGGING, true);
	}
	BuildLog();
  if (peloton_logging_mode != LOGGING_TYPE_INVALID) {
    if (log_manager.EndLogging()) {
      thread.join();
    }
  }
  timer.Stop();
  auto duration = timer.GetDuration();
  auto throughput = (ycsb::state.transaction_count * ycsb::state.backend_count)/duration;
  if (state.experiment_type == EXPERIMENT_TYPE_INVALID ||
      state.experiment_type == EXPERIMENT_TYPE_ACTIVE ||
      state.experiment_type == EXPERIMENT_TYPE_WAIT) {
    WriteOutput(throughput);
  } else if (state.experiment_type == EXPERIMENT_TYPE_STORAGE) {
    auto log_file_size = GetLogFileSize();
    WriteOutput(log_file_size);
  }
  return true;
}
bool PrepareLogFile ( std :: string file_name ) { auto file_path = GetFilePath ( state . log_file_dir , file_name ) ; std :: ifstream log_file ( file_path ) ; if ( log_file . good ( ) ) { std :: remove ( file_path . c_str ( ) ) ; } log_file . close ( ) ; auto & log_manager = logging :: LogManager :: GetInstance ( ) ; if ( log_manager . ContainsFrontendLogger ( ) == true ) { LOG_ERROR ( " " ) ; return false ; } Timer < > timer ; std :: thread thread ; timer . Start ( ) ; if ( peloton_logging_mode != LOGGING_TYPE_INVALID ) { LOG_INFO ( " " , file_path . c_str ( ) ) ; log_manager . SetLogFileName ( file_path ) ; thread = std :: thread ( & logging :: LogManager :: StartStandbyMode , & log_manager ) ; log_manager . WaitForModeTransition ( LOGGING_STATUS_TYPE_STANDBY , true ) ; log_manager . StartRecoveryMode ( ) ; log_manager . WaitForModeTransition ( LOGGING_STATUS_TYPE_LOGGING , true ) ; } BuildLog ( ) ; if ( peloton_logging_mode != LOGGING_TYPE_INVALID ) { if ( log_manager . EndLogging ( ) ) { thread . join ( ) ; } } timer . Stop ( ) ; auto duration = timer . GetDuration ( ) ; auto throughput = ( ycsb :: state . transaction_count * ycsb :: state . backend_count ) / duration ; if ( state . experiment_type == EXPERIMENT_TYPE_INVALID || state . experiment_type == EXPERIMENT_TYPE_ACTIVE || state . experiment_type == EXPERIMENT_TYPE_WAIT ) { WriteOutput ( throughput ) ; } else if ( state . experiment_type == EXPERIMENT_TYPE_STORAGE ) { auto log_file_size = GetLogFileSize ( ) ; WriteOutput ( log_file_size ) ; } return true ; }
@brief writing a simple log file
@brief writing a simple log file
// Reset the log file if exists // start a thread for logging // Start frontend logger if in a valid logging mode // set log file and logging type // start off the frontend logger of appropriate type in STANDBY mode // wait for the frontend logger to enter STANDBY mode // STANDBY -> RECOVERY mode // Wait for the frontend logger to enter LOGGING mode // Build the log // Stop frontend logger if in a valid logging mode //  Wait for the mode transition :: LOGGING -> TERMINATE -> SLEEP // Log the build log time